@utoo/web 1.4.0 → 1.4.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/esm/utoo/index.js CHANGED
@@ -1480,7 +1480,7 @@ function __wbg_get_imports(memory) {
1480
1480
  const a = state0.a;
1481
1481
  state0.a = 0;
1482
1482
  try {
1483
- return __wasm_bindgen_func_elem_3890(a, state0.b, arg0, arg1);
1483
+ return __wasm_bindgen_func_elem_3879(a, state0.b, arg0, arg1);
1484
1484
  }
1485
1485
  finally {
1486
1486
  state0.a = a;
@@ -1807,33 +1807,33 @@ function __wbg_get_imports(memory) {
1807
1807
  }, arguments);
1808
1808
  },
1809
1809
  __wbindgen_cast_0000000000000001: function (arg0, arg1) {
1810
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1451, function: Function { arguments: [Externref], shim_idx: 5637, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1811
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21830, __wasm_bindgen_func_elem_80453);
1810
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1458, function: Function { arguments: [Externref], shim_idx: 5646, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1811
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21941, __wasm_bindgen_func_elem_80607);
1812
1812
  return addHeapObject(ret);
1813
1813
  },
1814
1814
  __wbindgen_cast_0000000000000002: function (arg0, arg1) {
1815
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1451, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 5619, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1816
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21830, __wasm_bindgen_func_elem_80283);
1815
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1458, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 5628, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1816
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21941, __wasm_bindgen_func_elem_80437);
1817
1817
  return addHeapObject(ret);
1818
1818
  },
1819
1819
  __wbindgen_cast_0000000000000003: function (arg0, arg1) {
1820
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1451, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 5637, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1821
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21830, __wasm_bindgen_func_elem_80453);
1820
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1458, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 5646, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1821
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21941, __wasm_bindgen_func_elem_80607);
1822
1822
  return addHeapObject(ret);
1823
1823
  },
1824
1824
  __wbindgen_cast_0000000000000004: function (arg0, arg1) {
1825
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1451, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 5640, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1826
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21830, __wasm_bindgen_func_elem_80489);
1825
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1458, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 5649, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1826
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21941, __wasm_bindgen_func_elem_80643);
1827
1827
  return addHeapObject(ret);
1828
1828
  },
1829
1829
  __wbindgen_cast_0000000000000005: function (arg0, arg1) {
1830
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1451, function: Function { arguments: [], shim_idx: 1452, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1831
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21830, __wasm_bindgen_func_elem_21831);
1830
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1458, function: Function { arguments: [], shim_idx: 1459, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1831
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21941, __wasm_bindgen_func_elem_21942);
1832
1832
  return addHeapObject(ret);
1833
1833
  },
1834
1834
  __wbindgen_cast_0000000000000006: function (arg0, arg1) {
1835
- // Cast intrinsic for `Closure(Closure { dtor_idx: 5643, function: Function { arguments: [], shim_idx: 1452, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1836
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_80509, __wasm_bindgen_func_elem_21831);
1835
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 5652, function: Function { arguments: [], shim_idx: 1459, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1836
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_80663, __wasm_bindgen_func_elem_21942);
1837
1837
  return addHeapObject(ret);
1838
1838
  },
1839
1839
  __wbindgen_cast_0000000000000007: function (arg0) {
@@ -1881,25 +1881,25 @@ function __wbg_get_imports(memory) {
1881
1881
  "./index_bg.js": import0,
1882
1882
  };
1883
1883
  }
1884
- function __wasm_bindgen_func_elem_21831(arg0, arg1) {
1885
- wasm.__wasm_bindgen_func_elem_21831(arg0, arg1);
1884
+ function __wasm_bindgen_func_elem_21942(arg0, arg1) {
1885
+ wasm.__wasm_bindgen_func_elem_21942(arg0, arg1);
1886
1886
  }
1887
- function __wasm_bindgen_func_elem_80453(arg0, arg1, arg2) {
1888
- wasm.__wasm_bindgen_func_elem_80453(arg0, arg1, addHeapObject(arg2));
1887
+ function __wasm_bindgen_func_elem_80607(arg0, arg1, arg2) {
1888
+ wasm.__wasm_bindgen_func_elem_80607(arg0, arg1, addHeapObject(arg2));
1889
1889
  }
1890
- function __wasm_bindgen_func_elem_80283(arg0, arg1, arg2) {
1891
- wasm.__wasm_bindgen_func_elem_80283(arg0, arg1, addHeapObject(arg2));
1890
+ function __wasm_bindgen_func_elem_80437(arg0, arg1, arg2) {
1891
+ wasm.__wasm_bindgen_func_elem_80437(arg0, arg1, addHeapObject(arg2));
1892
1892
  }
1893
- function __wasm_bindgen_func_elem_80489(arg0, arg1, arg2) {
1893
+ function __wasm_bindgen_func_elem_80643(arg0, arg1, arg2) {
1894
1894
  try {
1895
- wasm.__wasm_bindgen_func_elem_80489(arg0, arg1, addBorrowedObject(arg2));
1895
+ wasm.__wasm_bindgen_func_elem_80643(arg0, arg1, addBorrowedObject(arg2));
1896
1896
  }
1897
1897
  finally {
1898
1898
  heap[stack_pointer++] = undefined;
1899
1899
  }
1900
1900
  }
1901
- function __wasm_bindgen_func_elem_3890(arg0, arg1, arg2, arg3) {
1902
- wasm.__wasm_bindgen_func_elem_3890(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1901
+ function __wasm_bindgen_func_elem_3879(arg0, arg1, arg2, arg3) {
1902
+ wasm.__wasm_bindgen_func_elem_3879(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1903
1903
  }
1904
1904
  const __wbindgen_enum_DirEntryType = ["file", "directory"];
1905
1905
  const __wbindgen_enum_FileSystemChangeRecordType = ["appeared", "disappeared", "errored", "modified", "moved", "unknown"];
Binary file
@@ -44,7 +44,9 @@ const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
44
44
  const moduleRequire = (childId) => loadModule(childId, context, importMaps, entrypoint);
45
45
  moduleRequire.resolve = (request) => request;
46
46
  const module = { exports: finalExports, require: moduleRequire };
47
- if (moduleId.includes("node_modules")) {
47
+ if (moduleId.includes("node_modules") ||
48
+ id in importMaps ||
49
+ moduleId in importMaps) {
48
50
  installedModules[moduleId] = module;
49
51
  }
50
52
  if (moduleId === entrypoint) {
@@ -93,6 +95,15 @@ const loadModule = (id, context, importMaps, entrypoint) => {
93
95
  const cachedId = resolutionCache[cacheKey];
94
96
  if (installedModules[cachedId])
95
97
  return installedModules[cachedId].exports;
98
+ const sysCached = System.get(cachedId) || (id !== cachedId && System.get(id));
99
+ if (sysCached)
100
+ return sysCached.default;
101
+ // importMaps takes priority over cached FS path
102
+ const importMapCode = importMaps[cachedId] || importMaps[id];
103
+ if (importMapCode) {
104
+ const mid = importMaps[cachedId] ? cachedId : id;
105
+ return executeModule(importMapCode, mid, id, importMaps, entrypoint);
106
+ }
96
107
  const code = tryReadFile(cachedId);
97
108
  if (code !== null) {
98
109
  return executeModule(code, cachedId, id, importMaps, entrypoint);
@@ -211,11 +211,7 @@ export function readFile(path, options, cb) {
211
211
  const promise = encoding
212
212
  ? fs.readToString(resolvedPath)
213
213
  : fs.read(resolvedPath);
214
- promise
215
- .then((data) => {
216
- cb(null, encoding ? data : Buffer.from(data));
217
- })
218
- .catch((e) => cb(translateError(e, path, "open")));
214
+ promise.then((data) => cb(null, encoding ? data : Buffer.from(data)), (e) => cb(translateError(e, path, "open")));
219
215
  }
220
216
  export function readdir(path, options, cb) {
221
217
  if (typeof options === "function") {
@@ -238,8 +234,7 @@ export function readdir(path, options, cb) {
238
234
  return json.name;
239
235
  });
240
236
  cb(null, result);
241
- })
242
- .catch((e) => cb(translateError(e, path, "scandir")));
237
+ }, (e) => cb(translateError(e, path, "scandir")));
243
238
  }
244
239
  export function writeFile(path, data, options, cb) {
245
240
  if (typeof options === "function") {
@@ -251,9 +246,7 @@ export function writeFile(path, data, options, cb) {
251
246
  const promise = typeof data === "string"
252
247
  ? fs.writeString(resolvedPath, data)
253
248
  : fs.write(resolvedPath, data);
254
- promise
255
- .then(() => cb(null))
256
- .catch((e) => cb(translateError(e, path, "open")));
249
+ promise.then(() => cb(null), (e) => cb(translateError(e, path, "open")));
257
250
  }
258
251
  export function mkdir(path, options, cb) {
259
252
  if (typeof options === "function") {
@@ -265,9 +258,7 @@ export function mkdir(path, options, cb) {
265
258
  const promise = (options === null || options === void 0 ? void 0 : options.recursive)
266
259
  ? fs.createDirAll(resolvedPath)
267
260
  : fs.createDir(resolvedPath);
268
- promise
269
- .then(() => cb(null))
270
- .catch((e) => cb(translateError(e, path, "mkdir")));
261
+ promise.then(() => cb(null), (e) => cb(translateError(e, path, "mkdir")));
271
262
  }
272
263
  export function rm(path, options, cb) {
273
264
  if (typeof options === "function") {
@@ -286,8 +277,7 @@ export function rm(path, options, cb) {
286
277
  return fs.removeDir(resolvedPath, !!(options === null || options === void 0 ? void 0 : options.recursive));
287
278
  }
288
279
  })
289
- .then(() => cb(null))
290
- .catch((e) => cb(translateError(e, path, "rm")));
280
+ .then(() => cb(null), (e) => cb(translateError(e, path, "rm")));
291
281
  }
292
282
  export function rmdir(path, options, cb) {
293
283
  if (typeof options === "function") {
@@ -296,14 +286,12 @@ export function rmdir(path, options, cb) {
296
286
  }
297
287
  getFs()
298
288
  .removeDir(resolvePath(path), !!(options === null || options === void 0 ? void 0 : options.recursive))
299
- .then(() => cb(null))
300
- .catch((e) => cb(translateError(e, path, "rmdir")));
289
+ .then(() => cb(null), (e) => cb(translateError(e, path, "rmdir")));
301
290
  }
302
291
  export function copyFile(src, dst, cb) {
303
292
  getFs()
304
293
  .copyFile(resolvePath(src), resolvePath(dst))
305
- .then(() => cb(null))
306
- .catch((e) => cb(translateError(e, src, "copyfile")));
294
+ .then(() => cb(null), (e) => cb(translateError(e, src, "copyfile")));
307
295
  }
308
296
  export function stat(p, cb) {
309
297
  getFs()
@@ -314,8 +302,7 @@ export function stat(p, cb) {
314
302
  type: json.type,
315
303
  size: Number(json.file_size || 0),
316
304
  }));
317
- })
318
- .catch((e) => cb(translateError(e, p, "stat")));
305
+ }, (e) => cb(translateError(e, p, "stat")));
319
306
  }
320
307
  export function lstat(p, cb) {
321
308
  getFs()
@@ -326,8 +313,7 @@ export function lstat(p, cb) {
326
313
  type: json.type,
327
314
  size: Number(json.file_size || 0),
328
315
  }));
329
- })
330
- .catch((e) => cb(translateError(e, p, "lstat")));
316
+ }, (e) => cb(translateError(e, p, "lstat")));
331
317
  }
332
318
  export function realpath(p, cb) {
333
319
  cb(null, p);
@@ -342,8 +328,7 @@ export function access(p, mode, cb) {
342
328
  .then(() => {
343
329
  if (cb)
344
330
  cb(null);
345
- })
346
- .catch((e) => {
331
+ }, (e) => {
347
332
  if (cb)
348
333
  cb(translateError(e, p, "access"));
349
334
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/web",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [