@utoo/web 0.0.1-alpha.17 → 0.0.1-alpha.19

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/project.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare class Project implements ProjectEndpoint {
6
6
  constructor(options: ProjectOptions);
7
7
  private connectWorker;
8
8
  installServiceWorker(): Promise<void>;
9
+ init(): Promise<void>;
9
10
  install(packageLock: string): Promise<void>;
10
11
  build(): Promise<void>;
11
12
  readFile(path: string, encoding?: "utf8"): Promise<any>;
@@ -23,5 +24,5 @@ export declare class Project implements ProjectEndpoint {
23
24
  rmdir(path: string, options?: {
24
25
  recursive?: boolean;
25
26
  }): Promise<void>;
26
- static fork(channel: MessageChannel, eventSource: Client | DedicatedWorkerGlobalScope): ProjectEndpoint;
27
+ static fork(channel: MessageChannel, eventSource?: Client | DedicatedWorkerGlobalScope): ProjectEndpoint;
27
28
  }
package/esm/project.js CHANGED
@@ -51,17 +51,47 @@ export class Project {
51
51
  }
52
52
  }
53
53
  async installServiceWorker() {
54
- var _a;
55
54
  if (this.serviceWorkerOptions) {
56
55
  const { url, scope } = this.serviceWorkerOptions;
57
56
  // Should add "Service-Worker-Allowed": "/" in page root response headers,
58
- await navigator.serviceWorker.register(url, { scope: "/" });
59
- (_a = navigator.serviceWorker.controller) === null || _a === void 0 ? void 0 : _a.postMessage({
60
- [ServiceWorkerHandShake]: true,
61
- scope,
57
+ const registration = await navigator.serviceWorker.register(url, {
58
+ scope: "/",
59
+ });
60
+ return new Promise((resolve) => {
61
+ function sendMessage(sw) {
62
+ sw.postMessage({
63
+ [ServiceWorkerHandShake]: true,
64
+ scope,
65
+ });
66
+ resolve();
67
+ }
68
+ function listenForActivation(sw) {
69
+ sw.addEventListener("statechange", () => {
70
+ if (sw.state === "activated") {
71
+ sendMessage(sw);
72
+ }
73
+ });
74
+ }
75
+ function checkSWState(registration) {
76
+ if (registration.active) {
77
+ sendMessage(registration.active);
78
+ }
79
+ else if (registration.installing) {
80
+ listenForActivation(registration.installing);
81
+ }
82
+ registration.addEventListener("updatefound", () => {
83
+ if (registration.installing) {
84
+ listenForActivation(registration.installing);
85
+ }
86
+ });
87
+ }
88
+ checkSWState(registration);
62
89
  });
63
90
  }
64
91
  }
92
+ async init() {
93
+ return await __classPrivateFieldGet(this, _Project_tunnel, "f");
94
+ }
65
95
  async install(packageLock) {
66
96
  await __classPrivateFieldGet(this, _Project_tunnel, "f");
67
97
  return await this.remote.install(packageLock);
@@ -100,7 +130,7 @@ export class Project {
100
130
  return await this.remote.rmdir(path, options);
101
131
  }
102
132
  static fork(channel, eventSource) {
103
- eventSource.postMessage(Fork, {
133
+ (eventSource || self).postMessage(Fork, {
104
134
  transfer: [channel.port2],
105
135
  });
106
136
  return new ForkedProject(channel.port1);
@@ -6,12 +6,6 @@ let _promise = new Promise((resolve) => {
6
6
  });
7
7
  let _projectEndpoint;
8
8
  let _serviceWorkerScope;
9
- self.addEventListener("install", (event) => {
10
- event.waitUntil(self.skipWaiting());
11
- });
12
- self.addEventListener("activate", (event) => {
13
- event.waitUntil(self.clients.claim());
14
- });
15
9
  self.addEventListener("message", (event) => {
16
10
  if (event.data && event.data[ServiceWorkerHandShake] === true) {
17
11
  _serviceWorkerScope = event.data.scope;
package/esm/utoo/index.js CHANGED
@@ -132,6 +132,28 @@ function makeMutClosure(arg0, arg1, dtor, f) {
132
132
  CLOSURE_DTORS.register(real, state, state);
133
133
  return real;
134
134
  }
135
+ function makeClosure(arg0, arg1, dtor, f) {
136
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
137
+ const real = (...args) => {
138
+ // First up with a closure we increment the internal reference
139
+ // count. This ensures that the Rust closure environment won't
140
+ // be deallocated while we're invoking it.
141
+ state.cnt++;
142
+ try {
143
+ return f(state.a, state.b, ...args);
144
+ }
145
+ finally {
146
+ if (--state.cnt === 0) {
147
+ wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b);
148
+ state.a = 0;
149
+ CLOSURE_DTORS.unregister(state);
150
+ }
151
+ }
152
+ };
153
+ real.original = state;
154
+ CLOSURE_DTORS.register(real, state, state);
155
+ return real;
156
+ }
135
157
  function debugString(val) {
136
158
  // primitive types
137
159
  const type = typeof val;
@@ -216,11 +238,14 @@ export function init_pack() {
216
238
  export function wasm_thread_entry_point(ptr) {
217
239
  wasm.wasm_thread_entry_point(ptr);
218
240
  }
219
- function __wbg_adapter_46(arg0, arg1) {
220
- wasm.__wbindgen_export_6(arg0, arg1);
241
+ function __wbg_adapter_46(arg0, arg1, arg2) {
242
+ wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
221
243
  }
222
- function __wbg_adapter_49(arg0, arg1, arg2) {
223
- wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
244
+ function __wbg_adapter_49(arg0, arg1) {
245
+ wasm.__wbindgen_export_7(arg0, arg1);
246
+ }
247
+ function __wbg_adapter_52(arg0, arg1, arg2) {
248
+ wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2));
224
249
  }
225
250
  let stack_pointer = 128;
226
251
  function addBorrowedObject(obj) {
@@ -229,18 +254,19 @@ function addBorrowedObject(obj) {
229
254
  heap[--stack_pointer] = obj;
230
255
  return stack_pointer;
231
256
  }
232
- function __wbg_adapter_56(arg0, arg1, arg2) {
257
+ function __wbg_adapter_59(arg0, arg1, arg2) {
233
258
  try {
234
- wasm.__wbindgen_export_8(arg0, arg1, addBorrowedObject(arg2));
259
+ wasm.__wbindgen_export_9(arg0, arg1, addBorrowedObject(arg2));
235
260
  }
236
261
  finally {
237
262
  heap[stack_pointer++] = undefined;
238
263
  }
239
264
  }
240
- function __wbg_adapter_107(arg0, arg1, arg2, arg3) {
241
- wasm.__wbindgen_export_9(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
265
+ function __wbg_adapter_135(arg0, arg1, arg2, arg3) {
266
+ wasm.__wbindgen_export_10(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
242
267
  }
243
268
  const __wbindgen_enum_DirEntryType = ["file", "directory"];
269
+ const __wbindgen_enum_FileSystemChangeRecordType = ["appeared", "disappeared", "errored", "modified", "moved", "unknown"];
244
270
  const __wbindgen_enum_FileSystemHandleKind = ["file", "directory"];
245
271
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
246
272
  const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
@@ -628,6 +654,10 @@ function __wbg_get_imports() {
628
654
  return addHeapObject(ret);
629
655
  }, arguments);
630
656
  };
657
+ imports.wbg.__wbg_changedHandle_9868832cc8229f2c = function (arg0) {
658
+ const ret = getObject(arg0).changedHandle;
659
+ return addHeapObject(ret);
660
+ };
631
661
  imports.wbg.__wbg_clearTimeout_0b53d391c1b94dda = function (arg0) {
632
662
  const ret = clearTimeout(takeObject(arg0));
633
663
  return addHeapObject(ret);
@@ -822,6 +852,10 @@ function __wbg_get_imports() {
822
852
  const ret = getObject(arg0).length;
823
853
  return ret;
824
854
  };
855
+ imports.wbg.__wbg_length_e2d2a49132c1b256 = function (arg0) {
856
+ const ret = getObject(arg0).length;
857
+ return ret;
858
+ };
825
859
  imports.wbg.__wbg_message_d1685a448ba00178 = function (arg0, arg1) {
826
860
  const ret = getObject(arg1).message;
827
861
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
@@ -857,7 +891,7 @@ function __wbg_get_imports() {
857
891
  const a = state0.a;
858
892
  state0.a = 0;
859
893
  try {
860
- return __wbg_adapter_107(a, state0.b, arg0, arg1);
894
+ return __wbg_adapter_135(a, state0.b, arg0, arg1);
861
895
  }
862
896
  finally {
863
897
  state0.a = a;
@@ -896,6 +930,10 @@ function __wbg_get_imports() {
896
930
  return addHeapObject(ret);
897
931
  }, arguments);
898
932
  };
933
+ imports.wbg.__wbg_new_de718f1ba9208ce9 = function (arg0) {
934
+ const ret = new FileSystemObserver(getObject(arg0));
935
+ return addHeapObject(ret);
936
+ };
899
937
  imports.wbg.__wbg_new_e25e5aab09ff45db = function () {
900
938
  return handleError(function () {
901
939
  const ret = new AbortController();
@@ -962,6 +1000,10 @@ function __wbg_get_imports() {
962
1000
  const ret = getObject(arg0).now();
963
1001
  return ret;
964
1002
  };
1003
+ imports.wbg.__wbg_observe_ebeca2bd94926dd3 = function (arg0, arg1, arg2) {
1004
+ const ret = getObject(arg0).observe(getObject(arg1), getObject(arg2));
1005
+ return addHeapObject(ret);
1006
+ };
965
1007
  imports.wbg.__wbg_of_4a05197bfc89556f = function (arg0, arg1, arg2) {
966
1008
  const ret = Array.of(getObject(arg0), getObject(arg1), getObject(arg2));
967
1009
  return addHeapObject(ret);
@@ -1007,6 +1049,10 @@ function __wbg_get_imports() {
1007
1049
  return ret;
1008
1050
  }, arguments);
1009
1051
  };
1052
+ imports.wbg.__wbg_relativePathComponents_be1e6346d5710da1 = function (arg0) {
1053
+ const ret = getObject(arg0).relativePathComponents;
1054
+ return addHeapObject(ret);
1055
+ };
1010
1056
  imports.wbg.__wbg_removeEntry_a424e90dff229b19 = function (arg0, arg1, arg2, arg3) {
1011
1057
  const ret = getObject(arg0).removeEntry(getStringFromWasm0(arg1, arg2), getObject(arg3));
1012
1058
  return addHeapObject(ret);
@@ -1079,6 +1125,9 @@ function __wbg_get_imports() {
1079
1125
  imports.wbg.__wbg_setrecursive_536113a081d6177a = function (arg0, arg1) {
1080
1126
  getObject(arg0).recursive = arg1 !== 0;
1081
1127
  };
1128
+ imports.wbg.__wbg_setrecursive_a252fcfd38b96fbf = function (arg0, arg1) {
1129
+ getObject(arg0).recursive = arg1 !== 0;
1130
+ };
1082
1131
  imports.wbg.__wbg_setsignal_75b21ef3a81de905 = function (arg0, arg1) {
1083
1132
  getObject(arg0).signal = getObject(arg1);
1084
1133
  };
@@ -1160,6 +1209,10 @@ function __wbg_get_imports() {
1160
1209
  getObject(arg0).truncate(arg1 >>> 0);
1161
1210
  }, arguments);
1162
1211
  };
1212
+ imports.wbg.__wbg_type_95004db40bfe9ad8 = function (arg0) {
1213
+ const ret = getObject(arg0).type;
1214
+ return (__wbindgen_enum_FileSystemChangeRecordType.indexOf(ret) + 1 || 7) - 1;
1215
+ };
1163
1216
  imports.wbg.__wbg_url_ae10c34ca209681d = function (arg0, arg1) {
1164
1217
  const ret = getObject(arg1).url;
1165
1218
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
@@ -1225,28 +1278,32 @@ function __wbg_get_imports() {
1225
1278
  const ret = false;
1226
1279
  return ret;
1227
1280
  };
1228
- imports.wbg.__wbindgen_closure_wrapper163189 = function (arg0, arg1, arg2) {
1229
- const ret = makeMutClosure(arg0, arg1, 9520, __wbg_adapter_49);
1281
+ imports.wbg.__wbindgen_closure_wrapper163525 = function (arg0, arg1, arg2) {
1282
+ const ret = makeMutClosure(arg0, arg1, 9546, __wbg_adapter_52);
1283
+ return addHeapObject(ret);
1284
+ };
1285
+ imports.wbg.__wbindgen_closure_wrapper163527 = function (arg0, arg1, arg2) {
1286
+ const ret = makeMutClosure(arg0, arg1, 2020, __wbg_adapter_52);
1230
1287
  return addHeapObject(ret);
1231
1288
  };
1232
- imports.wbg.__wbindgen_closure_wrapper163191 = function (arg0, arg1, arg2) {
1233
- const ret = makeMutClosure(arg0, arg1, 2008, __wbg_adapter_49);
1289
+ imports.wbg.__wbindgen_closure_wrapper169287 = function (arg0, arg1, arg2) {
1290
+ const ret = makeMutClosure(arg0, arg1, 9546, __wbg_adapter_52);
1234
1291
  return addHeapObject(ret);
1235
1292
  };
1236
- imports.wbg.__wbindgen_closure_wrapper168988 = function (arg0, arg1, arg2) {
1237
- const ret = makeMutClosure(arg0, arg1, 9520, __wbg_adapter_49);
1293
+ imports.wbg.__wbindgen_closure_wrapper169341 = function (arg0, arg1, arg2) {
1294
+ const ret = makeMutClosure(arg0, arg1, 9549, __wbg_adapter_59);
1238
1295
  return addHeapObject(ret);
1239
1296
  };
1240
- imports.wbg.__wbindgen_closure_wrapper169042 = function (arg0, arg1, arg2) {
1241
- const ret = makeMutClosure(arg0, arg1, 9523, __wbg_adapter_56);
1297
+ imports.wbg.__wbindgen_closure_wrapper169364 = function (arg0, arg1, arg2) {
1298
+ const ret = makeMutClosure(arg0, arg1, 9553, __wbg_adapter_49);
1242
1299
  return addHeapObject(ret);
1243
1300
  };
1244
- imports.wbg.__wbindgen_closure_wrapper169065 = function (arg0, arg1, arg2) {
1245
- const ret = makeMutClosure(arg0, arg1, 9527, __wbg_adapter_46);
1301
+ imports.wbg.__wbindgen_closure_wrapper30471 = function (arg0, arg1, arg2) {
1302
+ const ret = makeMutClosure(arg0, arg1, 2020, __wbg_adapter_49);
1246
1303
  return addHeapObject(ret);
1247
1304
  };
1248
- imports.wbg.__wbindgen_closure_wrapper30132 = function (arg0, arg1, arg2) {
1249
- const ret = makeMutClosure(arg0, arg1, 2008, __wbg_adapter_46);
1305
+ imports.wbg.__wbindgen_closure_wrapper326 = function (arg0, arg1, arg2) {
1306
+ const ret = makeClosure(arg0, arg1, 39, __wbg_adapter_46);
1250
1307
  return addHeapObject(ret);
1251
1308
  };
1252
1309
  imports.wbg.__wbindgen_debug_string = function (arg0, arg1) {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/web",
3
- "version": "0.0.1-alpha.17",
3
+ "version": "0.0.1-alpha.19",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [