Release Vulpes OS 2.7-preview.24

This commit is contained in:
OverSu 2026-11-04 12:52:20 +01:00
commit 97ef99f827
135 changed files with 7717 additions and 2524 deletions

View file

@ -19,9 +19,10 @@ export function exchange(path, params, limit=65536, timeout=20000) {
const bytes=new TextEncoder().encode(JSON.stringify(params)+'\n');
if (bytes.length>1228800) return Promise.reject(Error('REQUEST_TOO_LARGE'));
return new Promise((resolve,reject)=>{
let transport,input,output,reader,timer,finished=false,received='',offset=0;
let transport,input,output,reader,pump,timer,finished=false,received='',offset=0;
const finish=(error,value)=>{
if(finished)return;finished=true;clearTimeout(timer);
try{pump?.cancel(Cr.NS_BINDING_ABORTED);}catch(_){}
try{input?.close();}catch(_){}try{output?.close();}catch(_){}
try{transport?.close(Cr.NS_BINDING_ABORTED);}catch(_){}
if(error)reject(error);else resolve(value);
@ -35,20 +36,31 @@ export function exchange(path, params, limit=65536, timeout=20000) {
output=transport.openOutputStream(0,0,0).QueryInterface(Ci.nsIAsyncOutputStream);
reader=Cc['@mozilla.org/scriptableinputstream;1'].createInstance(Ci.nsIScriptableInputStream);
reader.init(input);
const read={onInputStreamReady(){
if(finished)return;
try{
const count=input.available();
if(!count)throw Error('BROKER_CLOSED');
if(received.length+count>limit)throw Error('BROKER_REPLY_TOO_LARGE');
received+=reader.readBytes(count);
const read={
onStartRequest() {},
onDataAvailable(_request,stream,_offset,count){
if(finished)return;
try{
if(received.length+count>limit)throw Error('BROKER_REPLY_TOO_LARGE');
received+=reader.readBytes(count);
const end=received.indexOf('\n');
if(end>=0){
const data=Uint8Array.from(received.slice(0,end),c=>c.charCodeAt(0));
finish(null,JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(data)));
}
}catch(error){finish(error);}
},
onStopRequest(_request,status){
if(finished)return;
const end=received.indexOf('\n');
if(end>=0){
const data=Uint8Array.from(received.slice(0,end),c=>c.charCodeAt(0));
finish(null,JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(data)));
}else input.asyncWait(read,0,0,Services.tm.currentThread);
}catch(error){finish(error);}
}};
try{
const data=Uint8Array.from(received.slice(0,end),c=>c.charCodeAt(0));
finish(null,JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(data)));
}catch(error){finish(error);}
}else finish(Error(status===Cr.NS_OK?'BROKER_CLOSED':'BROKER_READ_FAILED'));
}
};
const write={onOutputStreamReady(){
if(finished)return;
try{
@ -57,7 +69,13 @@ export function exchange(path, params, limit=65536, timeout=20000) {
if(offset<bytes.length)output.asyncWait(write,0,0,Services.tm.currentThread);
}catch(error){finish(error);}
}};
input.asyncWait(read,0,0,Services.tm.currentThread);
pump=Cc['@mozilla.org/network/input-stream-pump;1'].createInstance(Ci.nsIInputStreamPump);
// Gecko removed the stream position/length parameters. Its current
// signature is (stream, segmentSize, segmentCount, closeWhenDone,
// mainThreadTarget), so passing the legacy six arguments puts an
// integer where the optional event target is expected.
pump.init(input,0,0,false);
pump.asyncRead(read);
output.asyncWait(write,0,0,Services.tm.currentThread);
}catch(error){finish(error);}
});