mirror of
https://github.com/MercuryWorkshop/bare-mux.git
synced 2025-05-14 23:00:01 -04:00
allow transferables while setting client
This commit is contained in:
parent
646a521e49
commit
d750186782
3 changed files with 15 additions and 9 deletions
|
@ -105,18 +105,21 @@ export class BareMuxConnection {
|
|||
return (await this.worker.sendMessage({ type: "get" })).name;
|
||||
}
|
||||
|
||||
async setTransport(path: string, options: any[]) {
|
||||
async setTransport(path: string, options: any[], transferables?: Transferable[]) {
|
||||
await this.setManualTransport(`
|
||||
const { default: BareTransport } = await import("${path}");
|
||||
return [new BareTransport(${options.map(x => JSON.stringify(x)).join(", ")}), "${path}"];
|
||||
`);
|
||||
return [BareTransport, "${path}"];
|
||||
`, options, transferables);
|
||||
}
|
||||
|
||||
async setManualTransport(functionBody: string) {
|
||||
async setManualTransport(functionBody: string, options: any[], transferables?: Transferable[]) {
|
||||
await this.worker.sendMessage({
|
||||
type: "set",
|
||||
client: functionBody,
|
||||
});
|
||||
client: {
|
||||
function: functionBody,
|
||||
args: options,
|
||||
},
|
||||
}, transferables);
|
||||
}
|
||||
|
||||
getInnerPort(): MessagePort | Promise<MessagePort> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue