@utoo/web 0.0.1-alpha.36 → 0.0.1-alpha.38

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.
@@ -2,7 +2,7 @@ import { ProjectEndpoint } from "./type";
2
2
  export declare class ForkedProject implements ProjectEndpoint {
3
3
  private endpoint;
4
4
  constructor(port: MessagePort);
5
- install(packageLock: string): Promise<void>;
5
+ install(packageLock: string, maxConcurrentDownloads?: number): Promise<void>;
6
6
  build(): Promise<import("./type").BuildOutput>;
7
7
  readFile(path: string, encoding?: "utf8"): Promise<any>;
8
8
  writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
@@ -4,8 +4,8 @@ export class ForkedProject {
4
4
  var _a;
5
5
  (_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
6
6
  }
7
- async install(packageLock) {
8
- return await this.endpoint.install(packageLock);
7
+ async install(packageLock, maxConcurrentDownloads) {
8
+ return await this.endpoint.install(packageLock, maxConcurrentDownloads);
9
9
  }
10
10
  async build() {
11
11
  return await this.endpoint.build();
package/esm/project.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare class Project implements ProjectEndpoint {
7
7
  private connectWorker;
8
8
  installServiceWorker(): Promise<void>;
9
9
  mount(): Promise<void>;
10
- install(packageLock: string): Promise<void>;
10
+ install(packageLock: string, maxConcurrentDownloads?: number): Promise<void>;
11
11
  build(): Promise<BuildOutput>;
12
12
  readFile(path: string, encoding?: "utf8"): Promise<any>;
13
13
  writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
package/esm/project.js CHANGED
@@ -63,9 +63,9 @@ export class Project {
63
63
  async mount() {
64
64
  return await __classPrivateFieldGet(this, _Project_mount, "f");
65
65
  }
66
- async install(packageLock) {
66
+ async install(packageLock, maxConcurrentDownloads) {
67
67
  await __classPrivateFieldGet(this, _Project_mount, "f");
68
- return await this.remote.install(packageLock);
68
+ return await this.remote.install(packageLock, maxConcurrentDownloads);
69
69
  }
70
70
  async build() {
71
71
  await __classPrivateFieldGet(this, _Project_mount, "f");
@@ -22,7 +22,10 @@ self.addEventListener("fetch", async (event) => {
22
22
  event.respondWith(readFileFromProject(projectPath));
23
23
  }
24
24
  else {
25
- event.respondWith(fetch(event.request));
25
+ event.respondWith(fetch(new Request(event.request, {
26
+ mode: "cors",
27
+ credentials: "same-origin",
28
+ })));
26
29
  }
27
30
  });
28
31
  async function readFileFromProject(projectPath) {
package/esm/type.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface BuildOutput {
15
15
  issues: Issue[];
16
16
  }
17
17
  export interface ProjectEndpoint {
18
- install: (packageLock: string) => Promise<void>;
18
+ install: (packageLock: string, maxConcurrentDownloads?: number) => Promise<void>;
19
19
  build: () => Promise<BuildOutput>;
20
20
  readFile(path: string): Promise<Uint8Array>;
21
21
  readFile(path: string, encoding?: "utf8"): Promise<string>;
@@ -107,9 +107,10 @@ export class Project {
107
107
  write(path: string, content: Uint8Array): Promise<void>;
108
108
  /**
109
109
  * @param {string} package_lock
110
+ * @param {number | null} [max_concurrent_downloads]
110
111
  * @returns {Promise<void>}
111
112
  */
112
- install(package_lock: string): Promise<void>;
113
+ install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
113
114
  /**
114
115
  * @param {string} path
115
116
  * @returns {Promise<Metadata>}
package/esm/utoo/index.js CHANGED
@@ -208,6 +208,15 @@ function makeMutClosure(arg0, arg1, dtor, f) {
208
208
  CLOSURE_DTORS.register(real, state, state);
209
209
  return real;
210
210
  }
211
+ function getArrayJsValueFromWasm0(ptr, len) {
212
+ ptr = ptr >>> 0;
213
+ const mem = getDataViewMemory0();
214
+ const result = [];
215
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
216
+ result.push(takeObject(mem.getUint32(i, true)));
217
+ }
218
+ return result;
219
+ }
211
220
  function makeClosure(arg0, arg1, dtor, f) {
212
221
  const state = { a: arg0, b: arg1, cnt: 1, dtor };
213
222
  const real = (...args) => {
@@ -230,15 +239,6 @@ function makeClosure(arg0, arg1, dtor, f) {
230
239
  CLOSURE_DTORS.register(real, state, state);
231
240
  return real;
232
241
  }
233
- function getArrayJsValueFromWasm0(ptr, len) {
234
- ptr = ptr >>> 0;
235
- const mem = getDataViewMemory0();
236
- const result = [];
237
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
238
- result.push(takeObject(mem.getUint32(i, true)));
239
- }
240
- return result;
241
- }
242
242
  export function init_pack() {
243
243
  wasm.init_pack();
244
244
  }
@@ -255,12 +255,9 @@ function passArray8ToWasm0(arg, malloc) {
255
255
  export function wasm_thread_entry_point(ptr) {
256
256
  wasm.wasm_thread_entry_point(ptr);
257
257
  }
258
- function __wbg_adapter_4(arg0, arg1, arg2) {
258
+ function __wbg_adapter_6(arg0, arg1, arg2) {
259
259
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
260
260
  }
261
- function __wbg_adapter_7(arg0, arg1, arg2) {
262
- wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
263
- }
264
261
  let stack_pointer = 128;
265
262
  function addBorrowedObject(obj) {
266
263
  if (stack_pointer == 1)
@@ -268,15 +265,18 @@ function addBorrowedObject(obj) {
268
265
  heap[--stack_pointer] = obj;
269
266
  return stack_pointer;
270
267
  }
271
- function __wbg_adapter_10(arg0, arg1, arg2) {
268
+ function __wbg_adapter_9(arg0, arg1, arg2) {
272
269
  try {
273
- wasm.__wbindgen_export_8(arg0, arg1, addBorrowedObject(arg2));
270
+ wasm.__wbindgen_export_7(arg0, arg1, addBorrowedObject(arg2));
274
271
  }
275
272
  finally {
276
273
  heap[stack_pointer++] = undefined;
277
274
  }
278
275
  }
279
- function __wbg_adapter_13(arg0, arg1) {
276
+ function __wbg_adapter_18(arg0, arg1, arg2) {
277
+ wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2));
278
+ }
279
+ function __wbg_adapter_23(arg0, arg1) {
280
280
  wasm.__wbindgen_export_9(arg0, arg1);
281
281
  }
282
282
  function __wbg_adapter_92(arg0, arg1, arg2, arg3) {
@@ -561,12 +561,13 @@ export class Project {
561
561
  }
562
562
  /**
563
563
  * @param {string} package_lock
564
+ * @param {number | null} [max_concurrent_downloads]
564
565
  * @returns {Promise<void>}
565
566
  */
566
- install(package_lock) {
567
+ install(package_lock, max_concurrent_downloads) {
567
568
  const ptr0 = passStringToWasm0(package_lock, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
568
569
  const len0 = WASM_VECTOR_LEN;
569
- const ret = wasm.project_install(this.__wbg_ptr, ptr0, len0);
570
+ const ret = wasm.project_install(this.__wbg_ptr, ptr0, len0, isLikeNone(max_concurrent_downloads) ? 0x100000001 : (max_concurrent_downloads) >>> 0);
570
571
  return takeObject(ret);
571
572
  }
572
573
  /**
@@ -686,7 +687,7 @@ function __wbg_get_imports() {
686
687
  return addHeapObject(ret);
687
688
  }, arguments);
688
689
  };
689
- imports.wbg.__wbg_changedHandle_9c4d7f94c0b78c7d = function (arg0) {
690
+ imports.wbg.__wbg_changedHandle_51cdba7dd85fac27 = function (arg0) {
690
691
  const ret = getObject(arg0).changedHandle;
691
692
  return addHeapObject(ret);
692
693
  };
@@ -764,6 +765,11 @@ function __wbg_get_imports() {
764
765
  const ret = fetch(getObject(arg0));
765
766
  return addHeapObject(ret);
766
767
  };
768
+ imports.wbg.__wbg_flush_d2487a24f3bc3cf4 = function () {
769
+ return handleError(function (arg0) {
770
+ getObject(arg0).flush();
771
+ }, arguments);
772
+ };
767
773
  imports.wbg.__wbg_from_88bc52ce20ba6318 = function (arg0) {
768
774
  const ret = Array.from(getObject(arg0));
769
775
  return addHeapObject(ret);
@@ -935,10 +941,6 @@ function __wbg_get_imports() {
935
941
  const ret = new Map();
936
942
  return addHeapObject(ret);
937
943
  };
938
- imports.wbg.__wbg_new_3958f7343c57c948 = function (arg0) {
939
- const ret = new FileSystemObserver(getObject(arg0));
940
- return addHeapObject(ret);
941
- };
942
944
  imports.wbg.__wbg_new_638ebfaedbf32a5e = function (arg0) {
943
945
  const ret = new Uint8Array(getObject(arg0));
944
946
  return addHeapObject(ret);
@@ -953,6 +955,10 @@ function __wbg_get_imports() {
953
955
  const ret = new Error();
954
956
  return addHeapObject(ret);
955
957
  };
958
+ imports.wbg.__wbg_new_9b2344bc56f77a2b = function (arg0) {
959
+ const ret = new FileSystemObserver(getObject(arg0));
960
+ return addHeapObject(ret);
961
+ };
956
962
  imports.wbg.__wbg_new_9d476835fd376de6 = function () {
957
963
  return handleError(function (arg0, arg1) {
958
964
  const ret = new Worker(getStringFromWasm0(arg0, arg1));
@@ -1021,7 +1027,7 @@ function __wbg_get_imports() {
1021
1027
  const ret = getObject(arg0).now();
1022
1028
  return ret;
1023
1029
  };
1024
- imports.wbg.__wbg_observe_23bf99c5799b428b = function (arg0, arg1, arg2) {
1030
+ imports.wbg.__wbg_observe_a98641e2bc5e6a17 = function (arg0, arg1, arg2) {
1025
1031
  const ret = getObject(arg0).observe(getObject(arg1), getObject(arg2));
1026
1032
  return addHeapObject(ret);
1027
1033
  };
@@ -1073,7 +1079,7 @@ function __wbg_get_imports() {
1073
1079
  return ret;
1074
1080
  }, arguments);
1075
1081
  };
1076
- imports.wbg.__wbg_relativePathComponents_35d81f85c00300f2 = function (arg0) {
1082
+ imports.wbg.__wbg_relativePathComponents_71b7af6cc056eaa1 = function (arg0) {
1077
1083
  const ret = getObject(arg0).relativePathComponents;
1078
1084
  return addHeapObject(ret);
1079
1085
  };
@@ -1149,7 +1155,7 @@ function __wbg_get_imports() {
1149
1155
  imports.wbg.__wbg_setrecursive_072599988d5f7e8d = function (arg0, arg1) {
1150
1156
  getObject(arg0).recursive = arg1 !== 0;
1151
1157
  };
1152
- imports.wbg.__wbg_setrecursive_2f6a071c98b6be16 = function (arg0, arg1) {
1158
+ imports.wbg.__wbg_setrecursive_0b3e76f293311ab5 = function (arg0, arg1) {
1153
1159
  getObject(arg0).recursive = arg1 !== 0;
1154
1160
  };
1155
1161
  imports.wbg.__wbg_setsignal_8c45ad1247a74809 = function (arg0, arg1) {
@@ -1233,7 +1239,7 @@ function __wbg_get_imports() {
1233
1239
  getObject(arg0).truncate(arg1 >>> 0);
1234
1240
  }, arguments);
1235
1241
  };
1236
- imports.wbg.__wbg_type_5f9dd3f303ae4dde = function (arg0) {
1242
+ imports.wbg.__wbg_type_7ef9242007bd4c65 = function (arg0) {
1237
1243
  const ret = getObject(arg0).type;
1238
1244
  return (__wbindgen_enum_FileSystemChangeRecordType.indexOf(ret) + 1 || 7) - 1;
1239
1245
  };
@@ -1343,9 +1349,9 @@ function __wbg_get_imports() {
1343
1349
  return ret;
1344
1350
  }, arguments);
1345
1351
  };
1346
- imports.wbg.__wbindgen_cast_00971014be4c41e9 = function (arg0, arg1) {
1347
- // Cast intrinsic for `Closure(Closure { dtor_idx: 9063, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 9073, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1348
- const ret = makeMutClosure(arg0, arg1, 9063, __wbg_adapter_10);
1352
+ imports.wbg.__wbindgen_cast_0fa6bc778e36759b = function (arg0, arg1) {
1353
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 610, function: Function { arguments: [], shim_idx: 611, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1354
+ const ret = makeMutClosure(arg0, arg1, 610, __wbg_adapter_23);
1349
1355
  return addHeapObject(ret);
1350
1356
  };
1351
1357
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
@@ -1358,9 +1364,9 @@ function __wbg_get_imports() {
1358
1364
  const ret = BigInt.asUintN(64, arg0);
1359
1365
  return addHeapObject(ret);
1360
1366
  };
1361
- imports.wbg.__wbindgen_cast_631793fd2186b3cf = function (arg0, arg1) {
1362
- // Cast intrinsic for `Closure(Closure { dtor_idx: 9063, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 9064, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1363
- const ret = makeClosure(arg0, arg1, 9063, __wbg_adapter_7);
1367
+ imports.wbg.__wbindgen_cast_53cee94be1b4fb3e = function (arg0, arg1) {
1368
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 8798, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 8799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1369
+ const ret = makeMutClosure(arg0, arg1, 8798, __wbg_adapter_6);
1364
1370
  return addHeapObject(ret);
1365
1371
  };
1366
1372
  imports.wbg.__wbindgen_cast_76322aab70622876 = function (arg0, arg1) {
@@ -1377,34 +1383,29 @@ function __wbg_get_imports() {
1377
1383
  const ret = v0;
1378
1384
  return addHeapObject(ret);
1379
1385
  };
1380
- imports.wbg.__wbindgen_cast_9ae0607507abb057 = function (arg0) {
1381
- // Cast intrinsic for `I64 -> Externref`.
1382
- const ret = arg0;
1386
+ imports.wbg.__wbindgen_cast_77d64c9ca30913b0 = function (arg0, arg1) {
1387
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 9076, function: Function { arguments: [], shim_idx: 611, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1388
+ const ret = makeMutClosure(arg0, arg1, 9076, __wbg_adapter_23);
1383
1389
  return addHeapObject(ret);
1384
1390
  };
1385
- imports.wbg.__wbindgen_cast_a1eef3adaaf2ed9c = function (arg0, arg1) {
1386
- // Cast intrinsic for `Closure(Closure { dtor_idx: 8793, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 8794, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1387
- const ret = makeMutClosure(arg0, arg1, 8793, __wbg_adapter_4);
1391
+ imports.wbg.__wbindgen_cast_825af389dca3f1f2 = function (arg0, arg1) {
1392
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 9065, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 9074, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1393
+ const ret = makeMutClosure(arg0, arg1, 9065, __wbg_adapter_9);
1388
1394
  return addHeapObject(ret);
1389
1395
  };
1390
- imports.wbg.__wbindgen_cast_aa86286f6e9d676e = function (arg0, arg1) {
1391
- // Cast intrinsic for `Closure(Closure { dtor_idx: 620, function: Function { arguments: [], shim_idx: 621, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1392
- const ret = makeMutClosure(arg0, arg1, 620, __wbg_adapter_13);
1396
+ imports.wbg.__wbindgen_cast_94f0e9bba4cd221c = function (arg0, arg1) {
1397
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 8798, function: Function { arguments: [Externref], shim_idx: 8799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1398
+ const ret = makeMutClosure(arg0, arg1, 8798, __wbg_adapter_6);
1393
1399
  return addHeapObject(ret);
1394
1400
  };
1395
- imports.wbg.__wbindgen_cast_b3f2dc423ce0326d = function (arg0, arg1) {
1396
- // Cast intrinsic for `Closure(Closure { dtor_idx: 9075, function: Function { arguments: [], shim_idx: 621, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1397
- const ret = makeMutClosure(arg0, arg1, 9075, __wbg_adapter_13);
1398
- return addHeapObject(ret);
1399
- };
1400
- imports.wbg.__wbindgen_cast_b95228bca84fbfaa = function (arg0, arg1) {
1401
- // Cast intrinsic for `Closure(Closure { dtor_idx: 8793, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 8794, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1402
- const ret = makeMutClosure(arg0, arg1, 8793, __wbg_adapter_4);
1401
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function (arg0) {
1402
+ // Cast intrinsic for `I64 -> Externref`.
1403
+ const ret = arg0;
1403
1404
  return addHeapObject(ret);
1404
1405
  };
1405
- imports.wbg.__wbindgen_cast_cadf9b3f6ab5c9a3 = function (arg0, arg1) {
1406
- // Cast intrinsic for `Closure(Closure { dtor_idx: 8793, function: Function { arguments: [Externref], shim_idx: 8794, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1407
- const ret = makeMutClosure(arg0, arg1, 8793, __wbg_adapter_4);
1406
+ imports.wbg.__wbindgen_cast_c33e49d357e1ea8e = function (arg0, arg1) {
1407
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 9065, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 9066, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
1408
+ const ret = makeClosure(arg0, arg1, 9065, __wbg_adapter_18);
1408
1409
  return addHeapObject(ret);
1409
1410
  };
1410
1411
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function (arg0) {
@@ -1412,6 +1413,11 @@ function __wbg_get_imports() {
1412
1413
  const ret = arg0;
1413
1414
  return addHeapObject(ret);
1414
1415
  };
1416
+ imports.wbg.__wbindgen_cast_e68759fde1fb8044 = function (arg0, arg1) {
1417
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 8798, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 8799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1418
+ const ret = makeMutClosure(arg0, arg1, 8798, __wbg_adapter_6);
1419
+ return addHeapObject(ret);
1420
+ };
1415
1421
  imports.wbg.__wbindgen_link_dd5153a359f2e504 = function (arg0) {
1416
1422
  const val = `onmessage = function (ev) {
1417
1423
  let [ia, index, value] = ev.data;
Binary file
package/esm/worker.js CHANGED
@@ -24,9 +24,9 @@ const projectEndpoint = {
24
24
  this.projectInternal = new ProjectInternal(cwd, finalThreadWorkerUrl);
25
25
  return;
26
26
  },
27
- async install(packageLock) {
27
+ async install(packageLock, maxConcurrentDownloads) {
28
28
  await this.wasmInit;
29
- await this.projectInternal.install(packageLock);
29
+ await this.projectInternal.install(packageLock, maxConcurrentDownloads);
30
30
  return;
31
31
  },
32
32
  async build() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/web",
3
- "version": "0.0.1-alpha.36",
3
+ "version": "0.0.1-alpha.38",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [