@rivmux/runtime-worker 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/rivmux-runtime-worker.d.ts +0 -1
- package/dist/rivmux-runtime-worker.d.ts.map +1 -1
- package/dist/rivmux-runtime-worker.js +100 -151
- package/dist/rivmux-runtime-worker.js.map +1 -1
- package/dist/rivmux-transmux-core.wasm +0 -0
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NormalizedRivmuxPlayerOptions, PlayerError, WorkerCommand, WorkerMessage } from "@rivmux/protocol";
|
|
2
|
-
|
|
3
2
|
//#region src/index.d.ts
|
|
4
3
|
type WorkerLike = Pick<Worker, 'addEventListener' | 'postMessage' | 'removeEventListener' | 'terminate'>;
|
|
5
4
|
type RuntimeWorkerFactory = (options: NormalizedRivmuxPlayerOptions) => WorkerLike;
|
|
@@ -7,6 +6,13 @@ type WorkerClientHooks = {
|
|
|
7
6
|
onMessage(message: WorkerMessage): void;
|
|
8
7
|
onError(error: PlayerError): void;
|
|
9
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Returns the packaged WASM asset URL for the application bundler to track.
|
|
11
|
+
*
|
|
12
|
+
* Vite rewrites this static URL during the client build and emits the matching
|
|
13
|
+
* binary next to the application assets.
|
|
14
|
+
*/
|
|
15
|
+
declare function getBundledWasmUrl(): string;
|
|
10
16
|
declare class WorkerClient {
|
|
11
17
|
private readonly worker;
|
|
12
18
|
private readonly hooks;
|
|
@@ -40,5 +46,5 @@ declare class WorkerClient {
|
|
|
40
46
|
}
|
|
41
47
|
declare function createRuntimeWorker(options: NormalizedRivmuxPlayerOptions): WorkerLike;
|
|
42
48
|
//#endregion
|
|
43
|
-
export { RuntimeWorkerFactory, WorkerClient, WorkerClientHooks, WorkerLike, createRuntimeWorker };
|
|
49
|
+
export { RuntimeWorkerFactory, WorkerClient, WorkerClientHooks, WorkerLike, createRuntimeWorker, getBundledWasmUrl };
|
|
44
50
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;KAIY,aAAa,KAAK;KAElB,wBAAwB,SAAS,kCAAkC;KAOnE;EACV,UAAU,SAAS;EACnB,QAAQ,OAAO;;;;;;;;iBASD;cAMH;mBACM;mBACA;mBACA;mBAGA;UAKT;UACA;UACA;UACA;UACA;UACA;UACA;UACA;cAEI,QAAQ,YAAY,OAAO;EAOvC,KAAK,SAAS;EASd,yBAAyB,SAAS,gBAAgB;EAYlD,eAAe,SAAS,gBAAgB;EAYxC,iBAAiB,SAAS,gBAAgB;EAY1C;UAOQ;UA4BA;UAQA;UAMA;UAMA;UAMA;UAaA;UAaA;UAQA;UAOA;UAOA;;iBAQM,oBAAoB,SAAS,gCAAgC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
|
+
const bundledWasmUrl = new URL("./rivmux-transmux-core.wasm", import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* Returns the packaged WASM asset URL for the application bundler to track.
|
|
5
|
+
*
|
|
6
|
+
* Vite rewrites this static URL during the client build and emits the matching
|
|
7
|
+
* binary next to the application assets.
|
|
8
|
+
*/
|
|
9
|
+
function getBundledWasmUrl() {
|
|
10
|
+
return bundledWasmUrl.href;
|
|
11
|
+
}
|
|
2
12
|
const REQUEST_TIMEOUT_MS = 5e3;
|
|
3
13
|
var WorkerClient = class {
|
|
4
14
|
worker;
|
|
@@ -177,6 +187,6 @@ function createRuntimeWorkerError(code, message, terminal, cause) {
|
|
|
177
187
|
};
|
|
178
188
|
}
|
|
179
189
|
//#endregion
|
|
180
|
-
export { WorkerClient, createRuntimeWorker };
|
|
190
|
+
export { WorkerClient, createRuntimeWorker, getBundledWasmUrl };
|
|
181
191
|
|
|
182
192
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { NormalizedRivmuxPlayerOptions, PlayerError, WorkerCommand, WorkerMessage } from '@rivmux/protocol'\n\nexport type WorkerLike = Pick<Worker, 'addEventListener' | 'postMessage' | 'removeEventListener' | 'terminate'>\n\nexport type RuntimeWorkerFactory = (options: NormalizedRivmuxPlayerOptions) => WorkerLike\n\ntype PendingRequest = {\n resolve: () => void\n reject: (error: PlayerError) => void\n}\n\nexport type WorkerClientHooks = {\n onMessage(message: WorkerMessage): void\n onError(error: PlayerError): void\n}\n\nconst REQUEST_TIMEOUT_MS = 5000\n\nexport class WorkerClient {\n private readonly worker: WorkerLike\n private readonly hooks: WorkerClientHooks\n private readonly handleMessage = (event: MessageEvent<WorkerMessage>): void => {\n this.handleWorkerMessage(event.data)\n }\n private readonly handleError = (event: ErrorEvent): void => {\n const error = createRuntimeWorkerError('RIVMUX_WORKER_ERROR', event.message || 'Worker runtime failed.', true, event.error)\n this.rejectAll(error)\n this.hooks.onError(error)\n }\n private pendingAttach?: PendingRequest\n private pendingStop?: PendingRequest\n private pendingDestroy?: PendingRequest\n private workerReady = false\n private queuedCommands: WorkerCommand[] = []\n private attachTimer?: ReturnType<typeof setTimeout>\n private stoppedTimer?: ReturnType<typeof setTimeout>\n private destroyedTimer?: ReturnType<typeof setTimeout>\n\n constructor(worker: WorkerLike, hooks: WorkerClientHooks) {\n this.worker = worker\n this.hooks = hooks\n this.worker.addEventListener('message', this.handleMessage as EventListener)\n this.worker.addEventListener('error', this.handleError as EventListener)\n }\n\n post(command: WorkerCommand): void {\n if (!this.workerReady) {\n this.queuedCommands.push(command)\n return\n }\n\n this.worker.postMessage(command)\n }\n\n waitForMediaSourceHandle(command: WorkerCommand): Promise<void> {\n if (this.pendingAttach !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_ATTACH_IN_PROGRESS', 'A media source attach request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingAttach = { resolve, reject }\n this.attachTimer = this.startTimeout('RIVMUX_ATTACH_TIMEOUT', 'Timed out waiting for worker MediaSourceHandle.', reject)\n this.post(command)\n })\n }\n\n waitForStopped(command: WorkerCommand): Promise<void> {\n if (this.pendingStop !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_STOP_IN_PROGRESS', 'A stop request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingStop = { resolve, reject }\n this.stoppedTimer = this.startTimeout('RIVMUX_STOP_TIMEOUT', 'Timed out waiting for worker stop.', reject)\n this.post(command)\n })\n }\n\n waitForDestroyed(command: WorkerCommand): Promise<void> {\n if (this.pendingDestroy !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_DESTROY_IN_PROGRESS', 'A destroy request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingDestroy = { resolve, reject }\n this.destroyedTimer = this.startTimeout('RIVMUX_DESTROY_TIMEOUT', 'Timed out waiting for worker destroy.', reject)\n this.post(command)\n })\n }\n\n dispose(): void {\n this.rejectAll(createRuntimeWorkerError('RIVMUX_WORKER_DISPOSED', 'Worker client was disposed.', true))\n this.worker.removeEventListener('message', this.handleMessage as EventListener)\n this.worker.removeEventListener('error', this.handleError as EventListener)\n this.worker.terminate()\n }\n\n private handleWorkerMessage(message: WorkerMessage): void {\n if (message.type === 'worker-ready') {\n this.flushQueuedCommands()\n return\n }\n\n this.hooks.onMessage(message)\n\n if (message.type === 'media-source-handle') {\n this.resolveAttach()\n return\n }\n\n if (message.type === 'stopped') {\n this.resolveStop()\n return\n }\n\n if (message.type === 'destroyed') {\n this.resolveDestroy()\n return\n }\n\n if (message.type === 'error') {\n this.rejectPendingForWorkerError(message.error)\n }\n }\n\n private rejectPendingForWorkerError(error: PlayerError): void {\n if (!error.terminal) {\n return\n }\n\n this.rejectAll(error)\n }\n\n private resolveAttach(): void {\n this.clearAttachTimer()\n this.pendingAttach?.resolve()\n this.pendingAttach = undefined\n }\n\n private resolveStop(): void {\n this.clearStoppedTimer()\n this.pendingStop?.resolve()\n this.pendingStop = undefined\n }\n\n private resolveDestroy(): void {\n this.clearDestroyedTimer()\n this.pendingDestroy?.resolve()\n this.pendingDestroy = undefined\n }\n\n private rejectAll(error: PlayerError): void {\n this.queuedCommands = []\n this.clearAttachTimer()\n this.clearStoppedTimer()\n this.clearDestroyedTimer()\n this.pendingAttach?.reject(error)\n this.pendingStop?.reject(error)\n this.pendingDestroy?.reject(error)\n this.pendingAttach = undefined\n this.pendingStop = undefined\n this.pendingDestroy = undefined\n }\n\n private flushQueuedCommands(): void {\n if (this.workerReady) {\n return\n }\n\n this.workerReady = true\n const commands = this.queuedCommands\n this.queuedCommands = []\n for (const command of commands) {\n this.worker.postMessage(command)\n }\n }\n\n private startTimeout(code: string, message: string, reject: (error: PlayerError) => void): ReturnType<typeof setTimeout> {\n return setTimeout(() => {\n const error = createRuntimeWorkerError(code, message, true)\n reject(error)\n this.rejectAll(error)\n }, REQUEST_TIMEOUT_MS)\n }\n\n private clearAttachTimer(): void {\n if (this.attachTimer !== undefined) {\n clearTimeout(this.attachTimer)\n this.attachTimer = undefined\n }\n }\n\n private clearStoppedTimer(): void {\n if (this.stoppedTimer !== undefined) {\n clearTimeout(this.stoppedTimer)\n this.stoppedTimer = undefined\n }\n }\n\n private clearDestroyedTimer(): void {\n if (this.destroyedTimer !== undefined) {\n clearTimeout(this.destroyedTimer)\n this.destroyedTimer = undefined\n }\n }\n}\n\nexport function createRuntimeWorker(options: NormalizedRivmuxPlayerOptions): WorkerLike {\n const url = options.runtime.workerUrl === undefined ? new URL('./rivmux-runtime-worker.js', import.meta.url) : options.runtime.workerUrl\n\n return new Worker(url, {\n name: 'rivmux-runtime-worker',\n type: 'module',\n })\n}\n\nfunction createRuntimeWorkerError(code: string, message: string, terminal: boolean, cause?: unknown): PlayerError {\n return cause === undefined ? { kind: 'runtime', code, message, terminal } : { kind: 'runtime', code, message, terminal, cause }\n}\n"],"mappings":";AAgBA,MAAM,qBAAqB;AAE3B,IAAa,eAAb,MAA0B;CACxB;CACA;CACA,iBAAkC,UAA6C;EAC7E,KAAK,oBAAoB,MAAM,IAAI;CACrC;CACA,eAAgC,UAA4B;EAC1D,MAAM,QAAQ,yBAAyB,uBAAuB,MAAM,WAAW,0BAA0B,MAAM,MAAM,KAAK;EAC1H,KAAK,UAAU,KAAK;EACpB,KAAK,MAAM,QAAQ,KAAK;CAC1B;CACA;CACA;CACA;CACA,cAAsB;CACtB,iBAA0C,CAAC;CAC3C;CACA;CACA;CAEA,YAAY,QAAoB,OAA0B;EACxD,KAAK,SAAS;EACd,KAAK,QAAQ;EACb,KAAK,OAAO,iBAAiB,WAAW,KAAK,aAA8B;EAC3E,KAAK,OAAO,iBAAiB,SAAS,KAAK,WAA4B;CACzE;CAEA,KAAK,SAA8B;EACjC,IAAI,CAAC,KAAK,aAAa;GACrB,KAAK,eAAe,KAAK,OAAO;GAChC;EACF;EAEA,KAAK,OAAO,YAAY,OAAO;CACjC;CAEA,yBAAyB,SAAuC;EAC9D,IAAI,KAAK,kBAAkB,KAAA,GACzB,OAAO,QAAQ,OAAO,yBAAyB,6BAA6B,qDAAqD,KAAK,CAAC;EAGzI,OAAO,IAAI,SAAS,SAAS,WAAW;GACtC,KAAK,gBAAgB;IAAE;IAAS;GAAO;GACvC,KAAK,cAAc,KAAK,aAAa,yBAAyB,mDAAmD,MAAM;GACvH,KAAK,KAAK,OAAO;EACnB,CAAC;CACH;CAEA,eAAe,SAAuC;EACpD,IAAI,KAAK,gBAAgB,KAAA,GACvB,OAAO,QAAQ,OAAO,yBAAyB,2BAA2B,sCAAs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B,OAAO,KAAK,GAAG,IAAI,QAAQ,QAAQ;CAE/H,OAAO,IAAI,OAAO,KAAK;EACrB,MAAM;EACN,MAAM;CACR,CAAC;AACH;AAEA,SAAS,yBAAyB,MAAc,SAAiB,UAAmB,OAA8B;CAChH,OAAO,UAAU,KAAA,IAAY;EAAE,MAAM;EAAW;EAAM;EAAS;CAAS,IAAI;EAAE,MAAM;EAAW;EAAM;EAAS;EAAU;CAAM;AAChI"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { NormalizedRivmuxPlayerOptions, PlayerError, WorkerCommand, WorkerMessage } from '@rivmux/protocol'\n\nconst bundledWasmUrl = new URL('./rivmux-transmux-core.wasm', import.meta.url)\n\nexport type WorkerLike = Pick<Worker, 'addEventListener' | 'postMessage' | 'removeEventListener' | 'terminate'>\n\nexport type RuntimeWorkerFactory = (options: NormalizedRivmuxPlayerOptions) => WorkerLike\n\ntype PendingRequest = {\n resolve: () => void\n reject: (error: PlayerError) => void\n}\n\nexport type WorkerClientHooks = {\n onMessage(message: WorkerMessage): void\n onError(error: PlayerError): void\n}\n\n/**\n * Returns the packaged WASM asset URL for the application bundler to track.\n *\n * Vite rewrites this static URL during the client build and emits the matching\n * binary next to the application assets.\n */\nexport function getBundledWasmUrl(): string {\n return bundledWasmUrl.href\n}\n\nconst REQUEST_TIMEOUT_MS = 5000\n\nexport class WorkerClient {\n private readonly worker: WorkerLike\n private readonly hooks: WorkerClientHooks\n private readonly handleMessage = (event: MessageEvent<WorkerMessage>): void => {\n this.handleWorkerMessage(event.data)\n }\n private readonly handleError = (event: ErrorEvent): void => {\n const error = createRuntimeWorkerError('RIVMUX_WORKER_ERROR', event.message || 'Worker runtime failed.', true, event.error)\n this.rejectAll(error)\n this.hooks.onError(error)\n }\n private pendingAttach?: PendingRequest\n private pendingStop?: PendingRequest\n private pendingDestroy?: PendingRequest\n private workerReady = false\n private queuedCommands: WorkerCommand[] = []\n private attachTimer?: ReturnType<typeof setTimeout>\n private stoppedTimer?: ReturnType<typeof setTimeout>\n private destroyedTimer?: ReturnType<typeof setTimeout>\n\n constructor(worker: WorkerLike, hooks: WorkerClientHooks) {\n this.worker = worker\n this.hooks = hooks\n this.worker.addEventListener('message', this.handleMessage as EventListener)\n this.worker.addEventListener('error', this.handleError as EventListener)\n }\n\n post(command: WorkerCommand): void {\n if (!this.workerReady) {\n this.queuedCommands.push(command)\n return\n }\n\n this.worker.postMessage(command)\n }\n\n waitForMediaSourceHandle(command: WorkerCommand): Promise<void> {\n if (this.pendingAttach !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_ATTACH_IN_PROGRESS', 'A media source attach request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingAttach = { resolve, reject }\n this.attachTimer = this.startTimeout('RIVMUX_ATTACH_TIMEOUT', 'Timed out waiting for worker MediaSourceHandle.', reject)\n this.post(command)\n })\n }\n\n waitForStopped(command: WorkerCommand): Promise<void> {\n if (this.pendingStop !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_STOP_IN_PROGRESS', 'A stop request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingStop = { resolve, reject }\n this.stoppedTimer = this.startTimeout('RIVMUX_STOP_TIMEOUT', 'Timed out waiting for worker stop.', reject)\n this.post(command)\n })\n }\n\n waitForDestroyed(command: WorkerCommand): Promise<void> {\n if (this.pendingDestroy !== undefined) {\n return Promise.reject(createRuntimeWorkerError('RIVMUX_DESTROY_IN_PROGRESS', 'A destroy request is already pending.', false))\n }\n\n return new Promise((resolve, reject) => {\n this.pendingDestroy = { resolve, reject }\n this.destroyedTimer = this.startTimeout('RIVMUX_DESTROY_TIMEOUT', 'Timed out waiting for worker destroy.', reject)\n this.post(command)\n })\n }\n\n dispose(): void {\n this.rejectAll(createRuntimeWorkerError('RIVMUX_WORKER_DISPOSED', 'Worker client was disposed.', true))\n this.worker.removeEventListener('message', this.handleMessage as EventListener)\n this.worker.removeEventListener('error', this.handleError as EventListener)\n this.worker.terminate()\n }\n\n private handleWorkerMessage(message: WorkerMessage): void {\n if (message.type === 'worker-ready') {\n this.flushQueuedCommands()\n return\n }\n\n this.hooks.onMessage(message)\n\n if (message.type === 'media-source-handle') {\n this.resolveAttach()\n return\n }\n\n if (message.type === 'stopped') {\n this.resolveStop()\n return\n }\n\n if (message.type === 'destroyed') {\n this.resolveDestroy()\n return\n }\n\n if (message.type === 'error') {\n this.rejectPendingForWorkerError(message.error)\n }\n }\n\n private rejectPendingForWorkerError(error: PlayerError): void {\n if (!error.terminal) {\n return\n }\n\n this.rejectAll(error)\n }\n\n private resolveAttach(): void {\n this.clearAttachTimer()\n this.pendingAttach?.resolve()\n this.pendingAttach = undefined\n }\n\n private resolveStop(): void {\n this.clearStoppedTimer()\n this.pendingStop?.resolve()\n this.pendingStop = undefined\n }\n\n private resolveDestroy(): void {\n this.clearDestroyedTimer()\n this.pendingDestroy?.resolve()\n this.pendingDestroy = undefined\n }\n\n private rejectAll(error: PlayerError): void {\n this.queuedCommands = []\n this.clearAttachTimer()\n this.clearStoppedTimer()\n this.clearDestroyedTimer()\n this.pendingAttach?.reject(error)\n this.pendingStop?.reject(error)\n this.pendingDestroy?.reject(error)\n this.pendingAttach = undefined\n this.pendingStop = undefined\n this.pendingDestroy = undefined\n }\n\n private flushQueuedCommands(): void {\n if (this.workerReady) {\n return\n }\n\n this.workerReady = true\n const commands = this.queuedCommands\n this.queuedCommands = []\n for (const command of commands) {\n this.worker.postMessage(command)\n }\n }\n\n private startTimeout(code: string, message: string, reject: (error: PlayerError) => void): ReturnType<typeof setTimeout> {\n return setTimeout(() => {\n const error = createRuntimeWorkerError(code, message, true)\n reject(error)\n this.rejectAll(error)\n }, REQUEST_TIMEOUT_MS)\n }\n\n private clearAttachTimer(): void {\n if (this.attachTimer !== undefined) {\n clearTimeout(this.attachTimer)\n this.attachTimer = undefined\n }\n }\n\n private clearStoppedTimer(): void {\n if (this.stoppedTimer !== undefined) {\n clearTimeout(this.stoppedTimer)\n this.stoppedTimer = undefined\n }\n }\n\n private clearDestroyedTimer(): void {\n if (this.destroyedTimer !== undefined) {\n clearTimeout(this.destroyedTimer)\n this.destroyedTimer = undefined\n }\n }\n}\n\nexport function createRuntimeWorker(options: NormalizedRivmuxPlayerOptions): WorkerLike {\n const url = options.runtime.workerUrl === undefined ? new URL('./rivmux-runtime-worker.js', import.meta.url) : options.runtime.workerUrl\n\n return new Worker(url, {\n name: 'rivmux-runtime-worker',\n type: 'module',\n })\n}\n\nfunction createRuntimeWorkerError(code: string, message: string, terminal: boolean, cause?: unknown): PlayerError {\n return cause === undefined ? { kind: 'runtime', code, message, terminal } : { kind: 'runtime', code, message, terminal, cause }\n}\n"],"mappings":";AAEA,MAAM,iBAAiB,IAAI,IAAI,+BAA+B,OAAO,KAAK,GAAG;;;;;;;AAsB7E,SAAgB,oBAA4B;CAC1C,OAAO,eAAe;AACxB;AAEA,MAAM,qBAAqB;AAE3B,IAAa,eAAb,MAA0B;CACxB;CACA;CACA,iBAAkC,UAA6C;EAC7E,KAAK,oBAAoB,MAAM,IAAI;CACrC;CACA,eAAgC,UAA4B;EAC1D,MAAM,QAAQ,yBAAyB,uBAAuB,MAAM,WAAW,0BAA0B,MAAM,MAAM,KAAK;EAC1H,KAAK,UAAU,KAAK;EACpB,KAAK,MAAM,QAAQ,KAAK;CAC1B;CACA;CACA;CACA;CACA,cAAsB;CACtB,iBAA0C,CAAC;CAC3C;CACA;CACA;CAEA,YAAY,QAAoB,OAA0B;EACxD,KAAK,SAAS;EACd,KAAK,QAAQ;EACb,KAAK,OAAO,iBAAiB,WAAW,KAAK,aAA8B;EAC3E,KAAK,OAAO,iBAAiB,SAAS,KAAK,WAA4B;CACzE;CAEA,KAAK,SAA8B;EACjC,IAAI,CAAC,KAAK,aAAa;GACrB,KAAK,eAAe,KAAK,OAAO;GAChC;EACF;EAEA,KAAK,OAAO,YAAY,OAAO;CACjC;CAEA,yBAAyB,SAAuC;EAC9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B,KAAK,cAAc,KAAA;EACrB;CACF;CAEA,oBAAkC;EAChC,IAAI,KAAK,iBAAiB,KAAA,GAAW;GACnC,aAAa,KAAK,YAAY;GAC9B,KAAK,eAAe,KAAA;EACtB;CACF;CAEA,sBAAoC;EAClC,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,aAAa,KAAK,cAAc;GAChC,KAAK,iBAAiB,KAAA;EACxB;CACF;AACF;AAEA,SAAgB,oBAAoB,SAAoD;CACtF,MAAM,MAAM,QAAQ,QAAQ,cAAc,KAAA,IAAY,IAAI,IAAI,8BAA8B,OAAO,KAAK,GAAG,IAAI,QAAQ,QAAQ;CAE/H,OAAO,IAAI,OAAO,KAAK;EACrB,MAAM;EACN,MAAM;CACR,CAAC;AACH;AAEA,SAAS,yBAAyB,MAAc,SAAiB,UAAmB,OAA8B;CAChH,OAAO,UAAU,KAAA,IAAY;EAAE,MAAM;EAAW;EAAM;EAAS;CAAS,IAAI;EAAE,MAAM;EAAW;EAAM;EAAS;EAAU;CAAM;AAChI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rivmux-runtime-worker.d.ts","names":[],"sources":["../src/latency/buffer-ranges.ts","../src/loader/loader.ts","../src/wasm/rivmux-transmux-wasm.ts","../src/runtime.ts","../src/loader/http-flv-loader.ts","../src/mse/mse-controller.ts","../src/mse/source-buffer-queue.ts","../src/mse/mime.ts","../src/wasm/wasm-loader.ts","../src/worker-entry.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rivmux-runtime-worker.d.ts","names":[],"sources":["../src/latency/buffer-ranges.ts","../src/loader/loader.ts","../src/wasm/rivmux-transmux-wasm.ts","../src/runtime.ts","../src/loader/http-flv-loader.ts","../src/mse/mse-controller.ts","../src/mse/source-buffer-queue.ts","../src/mse/mime.ts","../src/wasm/wasm-loader.ts","../src/worker-entry.ts"],"mappings":";;KAAY;EACV;EACA;;;;KCAU;EACV,OAAO;EACP;;KAGU;EACV;EACA;EACA;EACA;EAC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Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) __defProp(target, name, {
|
|
6
|
-
get: all[name],
|
|
7
|
-
enumerable: true
|
|
8
|
-
});
|
|
9
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
-
return target;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
1
|
//#region src/latency/buffer-ranges.ts
|
|
14
2
|
function normalizeBufferedRanges(input) {
|
|
15
3
|
if (isBufferedRangeArray(input)) return input.filter(isValidRange).map((range) => ({
|
|
@@ -545,7 +533,7 @@ var MseController = class {
|
|
|
545
533
|
await this.ensureQueue(segment.track, mimeType).append(toAppendBuffer(segment.bytes));
|
|
546
534
|
}
|
|
547
535
|
async appendMediaSegment(segment) {
|
|
548
|
-
const queue = this.queues.get(segment.track)
|
|
536
|
+
const queue = this.queues.get(segment.track);
|
|
549
537
|
if (queue === void 0) throw new Error(`Cannot append ${segment.track} media segment before init segment.`);
|
|
550
538
|
await queue.append(toAppendBuffer(segment.bytes));
|
|
551
539
|
const mediaSource = this.requireMediaSource();
|
|
@@ -670,7 +658,7 @@ function coreWarningToPlayerWarning(warning) {
|
|
|
670
658
|
};
|
|
671
659
|
}
|
|
672
660
|
function normalizeCoreEvent(value) {
|
|
673
|
-
if (!isRecord
|
|
661
|
+
if (!isRecord(value) || typeof value.type !== "string") throw new TypeError("Transmux core event is missing a string type.");
|
|
674
662
|
const data = value.data;
|
|
675
663
|
switch (value.type) {
|
|
676
664
|
case "probeResult": return {
|
|
@@ -710,7 +698,7 @@ function normalizeCoreEvent(value) {
|
|
|
710
698
|
}
|
|
711
699
|
}
|
|
712
700
|
function normalizeInitSegment(value) {
|
|
713
|
-
if (!isRecord
|
|
701
|
+
if (!isRecord(value)) throw new TypeError("Transmux core initSegment event payload must be an object.");
|
|
714
702
|
return {
|
|
715
703
|
track: normalizeTrackKind(value.track),
|
|
716
704
|
codec: normalizeRequiredPrimitive(value.codec, "string", "initSegment codec"),
|
|
@@ -719,7 +707,7 @@ function normalizeInitSegment(value) {
|
|
|
719
707
|
};
|
|
720
708
|
}
|
|
721
709
|
function normalizeMediaSegment(value) {
|
|
722
|
-
if (!isRecord
|
|
710
|
+
if (!isRecord(value)) throw new TypeError("Transmux core mediaSegment event payload must be an object.");
|
|
723
711
|
return {
|
|
724
712
|
track: normalizeTrackKind(value.track),
|
|
725
713
|
dtsStartMs: normalizeRequiredPrimitive(value.dtsStartMs, "number", "mediaSegment dtsStartMs"),
|
|
@@ -729,7 +717,7 @@ function normalizeMediaSegment(value) {
|
|
|
729
717
|
};
|
|
730
718
|
}
|
|
731
719
|
function normalizeProbeResult(value) {
|
|
732
|
-
if (!isRecord
|
|
720
|
+
if (!isRecord(value) || value.container !== "flv" && value.container !== "mpegts") throw new TypeError("Transmux core probe result has an unsupported container.");
|
|
733
721
|
const result = { container: value.container };
|
|
734
722
|
const video = normalizeOptionalString(value.video, [
|
|
735
723
|
"avc",
|
|
@@ -748,7 +736,7 @@ function normalizeProbeResult(value) {
|
|
|
748
736
|
return result;
|
|
749
737
|
}
|
|
750
738
|
function normalizeMediaInfo(value) {
|
|
751
|
-
if (!isRecord
|
|
739
|
+
if (!isRecord(value)) throw new TypeError("Transmux core mediaInfo event payload must be an object.");
|
|
752
740
|
const result = { ...normalizeProbeResult(value) };
|
|
753
741
|
const videoCodec = normalizeOptionalPrimitive(value.videoCodec, "string");
|
|
754
742
|
const audioCodec = normalizeOptionalPrimitive(value.audioCodec, "string");
|
|
@@ -765,14 +753,14 @@ function normalizeMediaInfo(value) {
|
|
|
765
753
|
return result;
|
|
766
754
|
}
|
|
767
755
|
function normalizeWarning(value) {
|
|
768
|
-
if (!isRecord
|
|
756
|
+
if (!isRecord(value) || typeof value.code !== "string" || typeof value.message !== "string") throw new TypeError("Transmux core warning payload must include code and message.");
|
|
769
757
|
return {
|
|
770
758
|
code: value.code,
|
|
771
759
|
message: value.message
|
|
772
760
|
};
|
|
773
761
|
}
|
|
774
762
|
function normalizeError(value) {
|
|
775
|
-
if (!isRecord
|
|
763
|
+
if (!isRecord(value) || typeof value.code !== "string" || typeof value.message !== "string") throw new TypeError("Transmux core error payload must include code and message.");
|
|
776
764
|
return {
|
|
777
765
|
code: normalizeCoreErrorCode(value.code),
|
|
778
766
|
message: value.message
|
|
@@ -829,29 +817,11 @@ function normalizeBytes(value, field) {
|
|
|
829
817
|
if (Array.isArray(value) && value.every((entry) => Number.isInteger(entry) && entry >= 0 && entry <= 255)) return new Uint8Array(value);
|
|
830
818
|
throw new TypeError(`Expected ${field} to be Uint8Array-compatible bytes.`);
|
|
831
819
|
}
|
|
832
|
-
function isRecord
|
|
820
|
+
function isRecord(value) {
|
|
833
821
|
return typeof value === "object" && value !== null;
|
|
834
822
|
}
|
|
835
823
|
//#endregion
|
|
836
|
-
//#region
|
|
837
|
-
function instantiate(source, imports, stream) {
|
|
838
|
-
const instantiate = WebAssembly[stream ? "instantiateStreaming" : "instantiate"];
|
|
839
|
-
return instantiate(source, imports).then(({ instance }) => instance);
|
|
840
|
-
}
|
|
841
|
-
function loadWasmModule(sync, fileUrl, src, imports) {
|
|
842
|
-
let buf = null;
|
|
843
|
-
if (fileUrl) return instantiate(fetch(fileUrl), imports, true);
|
|
844
|
-
const raw = globalThis.atob(src);
|
|
845
|
-
const len = raw.length;
|
|
846
|
-
buf = new Uint8Array(new ArrayBuffer(len));
|
|
847
|
-
for (let i = 0; i < len; i++) buf[i] = raw.charCodeAt(i);
|
|
848
|
-
if (sync) {
|
|
849
|
-
const mod = new WebAssembly.Module(buf);
|
|
850
|
-
return new WebAssembly.Instance(mod, imports);
|
|
851
|
-
} else return instantiate(buf, imports);
|
|
852
|
-
}
|
|
853
|
-
//#endregion
|
|
854
|
-
//#region ../../crates/transmux-core/dist/rivmux_transmux_core_bg.js
|
|
824
|
+
//#region ../../crates/transmux-core/dist/rivmux_transmux_core.js
|
|
855
825
|
var TransmuxCore = class {
|
|
856
826
|
__destroy_into_raw() {
|
|
857
827
|
const ptr = this.__wbg_ptr;
|
|
@@ -910,44 +880,52 @@ var TransmuxCore = class {
|
|
|
910
880
|
}
|
|
911
881
|
};
|
|
912
882
|
if (Symbol.dispose) TransmuxCore.prototype[Symbol.dispose] = TransmuxCore.prototype.free;
|
|
913
|
-
function
|
|
914
|
-
return
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
883
|
+
function __wbg_get_imports() {
|
|
884
|
+
return {
|
|
885
|
+
__proto__: null,
|
|
886
|
+
"./rivmux_transmux_core_bg.js": {
|
|
887
|
+
__proto__: null,
|
|
888
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
889
|
+
return addHeapObject(Error(getStringFromWasm0(arg0, arg1)));
|
|
890
|
+
},
|
|
891
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
892
|
+
const ptr1 = passStringToWasm0(String(getObject(arg1)), wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
893
|
+
const len1 = WASM_VECTOR_LEN;
|
|
894
|
+
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
895
|
+
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
896
|
+
},
|
|
897
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
898
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
899
|
+
},
|
|
900
|
+
__wbg_new_2e117a478906f062: function() {
|
|
901
|
+
return addHeapObject(/* @__PURE__ */ new Object());
|
|
902
|
+
},
|
|
903
|
+
__wbg_new_36e147a8ced3c6e0: function() {
|
|
904
|
+
return addHeapObject(new Array());
|
|
905
|
+
},
|
|
906
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
907
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
908
|
+
},
|
|
909
|
+
__wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
|
|
910
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
911
|
+
},
|
|
912
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
913
|
+
return addHeapObject(arg0);
|
|
914
|
+
},
|
|
915
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
916
|
+
return addHeapObject(arg0);
|
|
917
|
+
},
|
|
918
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
919
|
+
return addHeapObject(getStringFromWasm0(arg0, arg1));
|
|
920
|
+
},
|
|
921
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
922
|
+
return addHeapObject(getObject(arg0));
|
|
923
|
+
},
|
|
924
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
925
|
+
takeObject(arg0);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
};
|
|
951
929
|
}
|
|
952
930
|
const TransmuxCoreFinalization = typeof FinalizationRegistry === "undefined" ? {
|
|
953
931
|
register: () => {},
|
|
@@ -1053,87 +1031,58 @@ if (!("encodeInto" in cachedTextEncoder)) cachedTextEncoder.encodeInto = functio
|
|
|
1053
1031
|
};
|
|
1054
1032
|
let WASM_VECTOR_LEN = 0;
|
|
1055
1033
|
let wasm;
|
|
1056
|
-
function
|
|
1057
|
-
wasm =
|
|
1034
|
+
function __wbg_finalize_init(instance, module) {
|
|
1035
|
+
wasm = instance.exports;
|
|
1036
|
+
cachedDataViewMemory0 = null;
|
|
1037
|
+
cachedUint8ArrayMemory0 = null;
|
|
1038
|
+
return wasm;
|
|
1039
|
+
}
|
|
1040
|
+
async function __wbg_load(module, imports) {
|
|
1041
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
1042
|
+
if (typeof WebAssembly.instantiateStreaming === "function") try {
|
|
1043
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1044
|
+
} catch (e) {
|
|
1045
|
+
if (module.ok && expectedResponseType(module.type) && module.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1046
|
+
else throw e;
|
|
1047
|
+
}
|
|
1048
|
+
const bytes = await module.arrayBuffer();
|
|
1049
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1050
|
+
} else {
|
|
1051
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1052
|
+
if (instance instanceof WebAssembly.Instance) return {
|
|
1053
|
+
instance,
|
|
1054
|
+
module
|
|
1055
|
+
};
|
|
1056
|
+
else return instance;
|
|
1057
|
+
}
|
|
1058
|
+
function expectedResponseType(type) {
|
|
1059
|
+
switch (type) {
|
|
1060
|
+
case "basic":
|
|
1061
|
+
case "cors":
|
|
1062
|
+
case "default": return true;
|
|
1063
|
+
}
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
async function __wbg_init(module_or_path) {
|
|
1068
|
+
if (wasm !== void 0) return wasm;
|
|
1069
|
+
if (module_or_path !== void 0) if (Object.getPrototypeOf(module_or_path) === Object.prototype) ({module_or_path} = module_or_path);
|
|
1070
|
+
else console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
1071
|
+
if (module_or_path === void 0) module_or_path = new URL("rivmux_transmux_core_bg.wasm", import.meta.url);
|
|
1072
|
+
const imports = __wbg_get_imports();
|
|
1073
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) module_or_path = fetch(module_or_path);
|
|
1074
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1075
|
+
return __wbg_finalize_init(instance, module);
|
|
1058
1076
|
}
|
|
1059
|
-
//#endregion
|
|
1060
|
-
//#region ../../crates/transmux-core/dist/rivmux_transmux_core_bg.wasm
|
|
1061
|
-
var rivmux_transmux_core_bg_exports = /* @__PURE__ */ __exportAll({
|
|
1062
|
-
__abort_handler: () => __abort_handler,
|
|
1063
|
-
__instance_terminated: () => __instance_terminated,
|
|
1064
|
-
__wbg_transmuxcore_free: () => __wbg_transmuxcore_free,
|
|
1065
|
-
__wbindgen_add_to_stack_pointer: () => __wbindgen_add_to_stack_pointer,
|
|
1066
|
-
__wbindgen_export: () => __wbindgen_export,
|
|
1067
|
-
__wbindgen_export2: () => __wbindgen_export2,
|
|
1068
|
-
memory: () => memory,
|
|
1069
|
-
transmuxcore_destroy: () => transmuxcore_destroy,
|
|
1070
|
-
transmuxcore_flush: () => transmuxcore_flush,
|
|
1071
|
-
transmuxcore_new: () => transmuxcore_new,
|
|
1072
|
-
transmuxcore_pushChunk: () => transmuxcore_pushChunk,
|
|
1073
|
-
transmuxcore_reset: () => transmuxcore_reset
|
|
1074
|
-
});
|
|
1075
|
-
function __wasm_init(imports) {
|
|
1076
|
-
return loadWasmModule(false, new URL("rivmux-transmux-core.wasm", import.meta.url), null, imports);
|
|
1077
|
-
}
|
|
1078
|
-
const instance = await __wasm_init({ "./rivmux_transmux_core_bg.js": {
|
|
1079
|
-
"__wbindgen_object_drop_ref": __wbindgen_object_drop_ref,
|
|
1080
|
-
"__wbg_set_dc601f4a69da0bc2": __wbg_set_dc601f4a69da0bc2,
|
|
1081
|
-
"__wbg_set_6be42768c690e380": __wbg_set_6be42768c690e380,
|
|
1082
|
-
"__wbindgen_object_clone_ref": __wbindgen_object_clone_ref,
|
|
1083
|
-
"__wbg_String_8564e559799eccda": __wbg_String_8564e559799eccda,
|
|
1084
|
-
"__wbg_new_36e147a8ced3c6e0": __wbg_new_36e147a8ced3c6e0,
|
|
1085
|
-
"__wbg_new_2e117a478906f062": __wbg_new_2e117a478906f062,
|
|
1086
|
-
"__wbg___wbindgen_throw_ea4887a5f8f9a9db": __wbg___wbindgen_throw_ea4887a5f8f9a9db,
|
|
1087
|
-
"__wbg_Error_fdd633d4bb5dd76a": __wbg_Error_fdd633d4bb5dd76a,
|
|
1088
|
-
"__wbindgen_cast_0000000000000001": __wbindgen_cast_0000000000000001,
|
|
1089
|
-
"__wbindgen_cast_0000000000000002": __wbindgen_cast_0000000000000002,
|
|
1090
|
-
"__wbindgen_cast_0000000000000003": __wbindgen_cast_0000000000000003
|
|
1091
|
-
} });
|
|
1092
|
-
const memory = instance.exports.memory;
|
|
1093
|
-
const __wbg_transmuxcore_free = instance.exports.__wbg_transmuxcore_free;
|
|
1094
|
-
const transmuxcore_destroy = instance.exports.transmuxcore_destroy;
|
|
1095
|
-
const transmuxcore_flush = instance.exports.transmuxcore_flush;
|
|
1096
|
-
const transmuxcore_new = instance.exports.transmuxcore_new;
|
|
1097
|
-
const transmuxcore_pushChunk = instance.exports.transmuxcore_pushChunk;
|
|
1098
|
-
const transmuxcore_reset = instance.exports.transmuxcore_reset;
|
|
1099
|
-
const __abort_handler = instance.exports.__abort_handler;
|
|
1100
|
-
const __instance_terminated = instance.exports.__instance_terminated;
|
|
1101
|
-
const __wbindgen_export = instance.exports.__wbindgen_export;
|
|
1102
|
-
const __wbindgen_export2 = instance.exports.__wbindgen_export2;
|
|
1103
|
-
const __wbindgen_add_to_stack_pointer = instance.exports.__wbindgen_add_to_stack_pointer;
|
|
1104
|
-
//#endregion
|
|
1105
|
-
//#region ../../crates/transmux-core/dist/rivmux_transmux_core.js
|
|
1106
|
-
__wbg_set_wasm(rivmux_transmux_core_bg_exports);
|
|
1107
1077
|
//#endregion
|
|
1108
1078
|
//#region src/wasm/wasm-loader.ts
|
|
1109
1079
|
function createWasmTransmuxCoreHost(Core) {
|
|
1110
1080
|
if (Core === void 0) throw new TypeError("WASM transmux core constructor is not available.");
|
|
1111
1081
|
return new WasmTransmuxCoreHost(Core);
|
|
1112
1082
|
}
|
|
1113
|
-
function createBundledWasmTransmuxCoreHost() {
|
|
1114
|
-
return createWasmTransmuxCoreHost(TransmuxCore);
|
|
1115
|
-
}
|
|
1116
1083
|
async function loadWasmTransmuxCoreHost(wasmUrl) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
await wasmModule.default(wasmUrl);
|
|
1120
|
-
return createWasmTransmuxCoreHost(wasmModule.TransmuxCore);
|
|
1121
|
-
}
|
|
1122
|
-
function toWasmBindgenGlueUrl(wasmUrl) {
|
|
1123
|
-
const url = new URL(wasmUrl, globalThis.location?.href ?? "http://localhost/");
|
|
1124
|
-
const path = url.pathname;
|
|
1125
|
-
url.pathname = path.endsWith("_bg.wasm") ? `${path.slice(0, -8)}.js` : path.replace(/\.wasm$/u, ".js");
|
|
1126
|
-
return url.href;
|
|
1127
|
-
}
|
|
1128
|
-
function normalizeWasmBindgenModule(value) {
|
|
1129
|
-
if (!isRecord(value) || typeof value.default !== "function" || typeof value.TransmuxCore !== "function") throw new TypeError("WASM transmux module must export default init and TransmuxCore.");
|
|
1130
|
-
return value;
|
|
1131
|
-
}
|
|
1132
|
-
function nativeDynamicImport(url) {
|
|
1133
|
-
return new Function("url", "return import(url)")(url);
|
|
1134
|
-
}
|
|
1135
|
-
function isRecord(value) {
|
|
1136
|
-
return typeof value === "object" && value !== null;
|
|
1084
|
+
await __wbg_init(wasmUrl ?? new URL("./rivmux-transmux-core.wasm", import.meta.url));
|
|
1085
|
+
return createWasmTransmuxCoreHost(TransmuxCore);
|
|
1137
1086
|
}
|
|
1138
1087
|
//#endregion
|
|
1139
1088
|
//#region src/runtime.ts
|