@supraio/client-daemon-js 0.0.1-mz-warmup.1 → 0.0.1-mz-webcodecs.1

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/sdk.js CHANGED
@@ -17243,14 +17243,14 @@ function shim(fs) {
17243
17243
  return;
17244
17244
  }
17245
17245
  return origClose.call(this, ...args, function(err) {
17246
- return callback.call(this, err ?? null);
17246
+ return callback.call(this, err != null ? err : null);
17247
17247
  });
17248
17248
  };
17249
17249
  const origMkdir = fs.mkdir;
17250
17250
  fs.mkdir = function(...args) {
17251
17251
  const callback = args.pop();
17252
17252
  return origMkdir.call(this, ...args, function(err, path) {
17253
- return callback.call(this, err ?? null, path);
17253
+ return callback.call(this, err != null ? err : null, path);
17254
17254
  });
17255
17255
  };
17256
17256
  const origWrite = fs.write;
@@ -17285,12 +17285,25 @@ function shim(fs) {
17285
17285
  }
17286
17286
 
17287
17287
  // go/go.ts
17288
+ var WASM_EXEC_URL = "wasm_exec.js";
17288
17289
  function getGoEnv() {
17289
17290
  return {
17290
17291
  HOME: "/",
17291
17292
  USER: "unknown"
17292
17293
  };
17293
17294
  }
17295
+ async function initGoEnvironment() {
17296
+ if (!window.fs) {
17297
+ const fs = await initBrowserFS();
17298
+ window.fs = fs;
17299
+ }
17300
+ if (!window.module) {
17301
+ window.module = {};
17302
+ }
17303
+ if (!window.Go) {
17304
+ await injectScript(WASM_EXEC_URL);
17305
+ }
17306
+ }
17294
17307
 
17295
17308
  // daemon/plain.ts
17296
17309
  var DAEMON_JS_URL = "supra-client-daemon.js";
@@ -17304,16 +17317,12 @@ async function startPlainDaemon() {
17304
17317
 
17305
17318
  // daemon/wasm.ts
17306
17319
  var DAEMON_WASM_URL = "supra-client-daemon.wasm";
17307
- var WASM_EXEC_URL = "wasm_exec.js";
17308
17320
  async function startWasmDaemon() {
17309
- const fs = await initBrowserFS();
17310
- window.fs = fs;
17311
- window.module = {};
17312
- await injectScript(WASM_EXEC_URL);
17321
+ await initGoEnvironment();
17313
17322
  await startGoDaemon();
17314
17323
  }
17315
17324
  async function startGoDaemon() {
17316
- const go = new Go();
17325
+ const go = new window.Go();
17317
17326
  const result = await WebAssembly.instantiateStreaming(fetch(DAEMON_WASM_URL), go.importObject);
17318
17327
  go.env = getGoEnv();
17319
17328
  go.argv = getGoArgv();
@@ -17474,15 +17483,11 @@ if (typeof window !== void 0) {
17474
17483
 
17475
17484
  // screen/wasm.ts
17476
17485
  var SCREEN_WASM_URL = "supra-client-screen.wasm";
17477
- var WASM_EXEC_URL2 = "wasm_exec.js";
17478
17486
  async function startWasmScreen(options) {
17479
- const screenOptions = options ?? parseQueryOptions();
17480
- const fs = await initBrowserFS();
17487
+ const screenOptions = options != null ? options : parseQueryOptions();
17481
17488
  const h264Decoder = await createH264Decoder();
17482
17489
  window.h264Decoder = h264Decoder;
17483
- window.fs = fs;
17484
- window.module = {};
17485
- await injectScript(WASM_EXEC_URL2);
17490
+ await initGoEnvironment();
17486
17491
  await startGoScreen(h264Decoder, screenOptions);
17487
17492
  }
17488
17493
  function parseQueryOptions() {
@@ -17519,7 +17524,7 @@ async function createH264Decoder() {
17519
17524
  return h264Decoder;
17520
17525
  }
17521
17526
  async function startGoScreen(h264Decoder, options) {
17522
- const go = new Go();
17527
+ const go = new window.Go();
17523
17528
  go.h264 = h264Decoder.memory;
17524
17529
  const result = await WebAssembly.instantiateStreaming(fetch(SCREEN_WASM_URL), go.importObject);
17525
17530
  go.env = getGoEnv();