@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/daemon/wasm.d.ts CHANGED
@@ -1,11 +1,2 @@
1
- /// <reference types="node" />
2
1
  import '../go/go';
3
- import nodeFs from 'fs';
4
- declare global {
5
- interface Window {
6
- /** Make it global accessible for wasm_exec.js */
7
- fs: typeof nodeFs;
8
- module: any;
9
- }
10
- }
11
2
  export declare function startWasmDaemon(): Promise<void>;
package/daemon.js CHANGED
@@ -17233,14 +17233,14 @@
17233
17233
  return;
17234
17234
  }
17235
17235
  return origClose.call(this, ...args, function(err) {
17236
- return callback.call(this, err ?? null);
17236
+ return callback.call(this, err != null ? err : null);
17237
17237
  });
17238
17238
  };
17239
17239
  const origMkdir = fs.mkdir;
17240
17240
  fs.mkdir = function(...args) {
17241
17241
  const callback = args.pop();
17242
17242
  return origMkdir.call(this, ...args, function(err, path) {
17243
- return callback.call(this, err ?? null, path);
17243
+ return callback.call(this, err != null ? err : null, path);
17244
17244
  });
17245
17245
  };
17246
17246
  const origWrite = fs.write;
@@ -17275,12 +17275,25 @@
17275
17275
  }
17276
17276
 
17277
17277
  // go/go.ts
17278
+ var WASM_EXEC_URL = "wasm_exec.js";
17278
17279
  function getGoEnv() {
17279
17280
  return {
17280
17281
  HOME: "/",
17281
17282
  USER: "unknown"
17282
17283
  };
17283
17284
  }
17285
+ async function initGoEnvironment() {
17286
+ if (!window.fs) {
17287
+ const fs = await initBrowserFS();
17288
+ window.fs = fs;
17289
+ }
17290
+ if (!window.module) {
17291
+ window.module = {};
17292
+ }
17293
+ if (!window.Go) {
17294
+ await injectScript(WASM_EXEC_URL);
17295
+ }
17296
+ }
17284
17297
 
17285
17298
  // daemon/plain.ts
17286
17299
  var DAEMON_JS_URL = "supra-client-daemon.js";
@@ -17294,16 +17307,12 @@
17294
17307
 
17295
17308
  // daemon/wasm.ts
17296
17309
  var DAEMON_WASM_URL = "supra-client-daemon.wasm";
17297
- var WASM_EXEC_URL = "wasm_exec.js";
17298
17310
  async function startWasmDaemon() {
17299
- const fs = await initBrowserFS();
17300
- window.fs = fs;
17301
- window.module = {};
17302
- await injectScript(WASM_EXEC_URL);
17311
+ await initGoEnvironment();
17303
17312
  await startGoDaemon();
17304
17313
  }
17305
17314
  async function startGoDaemon() {
17306
- const go = new Go();
17315
+ const go = new window.Go();
17307
17316
  const result = await WebAssembly.instantiateStreaming(fetch(DAEMON_WASM_URL), go.importObject);
17308
17317
  go.env = getGoEnv();
17309
17318
  go.argv = getGoArgv();