@utoo/web 0.0.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/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { ProjectEndpoint } from "./type";
2
+ import type { DirEntry } from "./utoo";
3
+ export declare class Project implements ProjectEndpoint {
4
+ #private;
5
+ private cwd;
6
+ private remote;
7
+ constructor(cwd: string);
8
+ install(packageLock: string): Promise<void>;
9
+ build(): Promise<void>;
10
+ readFile(path: string): Promise<string>;
11
+ writeFile(path: string, content: string): Promise<void>;
12
+ copyFile(src: string, dst: string): Promise<void>;
13
+ readDir(path: string): Promise<DirEntry[]>;
14
+ createDir(path: string): Promise<void>;
15
+ createDirAll(path: string): Promise<void>;
16
+ static fork(port1: MessagePort, port2: MessagePort): ProjectEndpoint;
17
+ }
18
+ export * from "./type";
package/esm/index.js ADDED
@@ -0,0 +1,105 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _Project_tunnel;
13
+ import * as comlink from "comlink";
14
+ import { Fork, HandShake } from "./message";
15
+ let ProjectWorker;
16
+ const ConnectedPorts = new Set();
17
+ export class Project {
18
+ constructor(cwd) {
19
+ var _a, _b;
20
+ _Project_tunnel.set(this, void 0);
21
+ this.cwd = cwd;
22
+ const { port1, port2 } = new MessageChannel();
23
+ (_a = this.remote) !== null && _a !== void 0 ? _a : (this.remote = comlink.wrap(port1));
24
+ if (!ProjectWorker) {
25
+ ProjectWorker = new Worker(new URL("./worker", import.meta.url));
26
+ self.addEventListener("message", (e) => {
27
+ const port = e.ports[0];
28
+ if (e.data === Fork && !ConnectedPorts.has(port)) {
29
+ ProjectWorker.postMessage(HandShake, [port]);
30
+ }
31
+ });
32
+ }
33
+ ProjectWorker.postMessage(HandShake, [port2]);
34
+ __classPrivateFieldSet(this, _Project_tunnel, (_b = __classPrivateFieldGet(this, _Project_tunnel, "f")) !== null && _b !== void 0 ? _b : this.remote.mount(this.cwd), "f");
35
+ }
36
+ async install(packageLock) {
37
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
38
+ return await this.remote.install(packageLock);
39
+ }
40
+ async build() {
41
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
42
+ return await this.remote.build();
43
+ }
44
+ async readFile(path) {
45
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
46
+ return await this.remote.readFile(path);
47
+ }
48
+ async writeFile(path, content) {
49
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
50
+ return await this.remote.writeFile(path, content);
51
+ }
52
+ async copyFile(src, dst) {
53
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
54
+ return await this.remote.copyFile(src, dst);
55
+ }
56
+ async readDir(path) {
57
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
58
+ return await this.remote.readDir(path);
59
+ }
60
+ async createDir(path) {
61
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
62
+ return await this.remote.createDir(path);
63
+ }
64
+ async createDirAll(path) {
65
+ await __classPrivateFieldGet(this, _Project_tunnel, "f");
66
+ return await this.remote.createDirAll(path);
67
+ }
68
+ // This should be called from different worker
69
+ static fork(port1, port2) {
70
+ self.postMessage(Fork, [port2]);
71
+ return new ForkedProject(port1);
72
+ }
73
+ }
74
+ _Project_tunnel = new WeakMap();
75
+ class ForkedProject {
76
+ constructor(port) {
77
+ var _a;
78
+ (_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
79
+ }
80
+ async install(packageLock) {
81
+ return await this.endpoint.install(packageLock);
82
+ }
83
+ async build() {
84
+ return await this.endpoint.build();
85
+ }
86
+ async readFile(path) {
87
+ return await this.endpoint.readFile(path);
88
+ }
89
+ async writeFile(path, content) {
90
+ return await this.endpoint.writeFile(path, content);
91
+ }
92
+ async copyFile(src, dst) {
93
+ return await this.endpoint.copyFile(src, dst);
94
+ }
95
+ async readDir(path) {
96
+ return await this.endpoint.readDir(path);
97
+ }
98
+ async createDir(path) {
99
+ return await this.endpoint.createDir(path);
100
+ }
101
+ async createDirAll(path) {
102
+ return await this.endpoint.createDirAll(path);
103
+ }
104
+ }
105
+ export * from "./type";
@@ -0,0 +1,2 @@
1
+ export declare const HandShake = "__handshake__";
2
+ export declare const Fork = "__fork__";
package/esm/message.js ADDED
@@ -0,0 +1,2 @@
1
+ export const HandShake = "__handshake__";
2
+ export const Fork = "__fork__";
package/esm/type.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { DirEntry } from "./utoo";
2
+ export interface ProjectEndpoint {
3
+ install: (packageLock: string) => Promise<void>;
4
+ build: () => Promise<void>;
5
+ readFile(path: string): Promise<string>;
6
+ writeFile(path: string, content: string): Promise<void>;
7
+ readDir(path: string): Promise<DirEntry[]>;
8
+ createDir(path: string): Promise<void>;
9
+ createDirAll(path: string): Promise<void>;
10
+ copyFile(src: string, dst: string): Promise<void>;
11
+ }
package/esm/type.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,88 @@
1
+ export class CreateSyncAccessHandleOptions {
2
+ static __wrap(ptr: any): any;
3
+ __destroy_into_raw(): number | undefined;
4
+ __wbg_ptr: number | undefined;
5
+ free(): void;
6
+ }
7
+ /**
8
+ * Directory entry with name and type information
9
+ */
10
+ export class DirEntry {
11
+ static __wrap(ptr: any): any;
12
+ __destroy_into_raw(): number | undefined;
13
+ __wbg_ptr: number | undefined;
14
+ free(): void;
15
+ /**
16
+ * @param {string} arg0
17
+ */
18
+ set name(arg0: string);
19
+ /**
20
+ * @returns {string}
21
+ */
22
+ get name(): string;
23
+ /**
24
+ * @param {DirEntryType} arg0
25
+ */
26
+ set type(arg0: DirEntryType);
27
+ /**
28
+ * @returns {DirEntryType}
29
+ */
30
+ get type(): DirEntryType;
31
+ }
32
+ export class Project {
33
+ /**
34
+ * @param {string} cwd
35
+ */
36
+ constructor(cwd: string);
37
+ __destroy_into_raw(): number;
38
+ __wbg_ptr: number;
39
+ free(): void;
40
+ /**
41
+ * @returns {string}
42
+ */
43
+ get cwd(): string;
44
+ /**
45
+ * @param {string} package_lock
46
+ * @returns {Promise<void>}
47
+ */
48
+ install(package_lock: string): Promise<void>;
49
+ /**
50
+ * @returns {Promise<void>}
51
+ */
52
+ build(): Promise<void>;
53
+ /**
54
+ * @param {string} path
55
+ * @returns {Promise<string>}
56
+ */
57
+ readFile(path: string): Promise<string>;
58
+ /**
59
+ * @param {string} path
60
+ * @param {string} content
61
+ * @returns {Promise<void>}
62
+ */
63
+ writeFile(path: string, content: string): Promise<void>;
64
+ /**
65
+ * @param {string} path
66
+ * @returns {Promise<DirEntry[]>}
67
+ */
68
+ readDir(path: string): Promise<DirEntry[]>;
69
+ /**
70
+ * @param {string} path
71
+ * @returns {Promise<void>}
72
+ */
73
+ createDir(path: string): Promise<void>;
74
+ /**
75
+ * @param {string} path
76
+ * @returns {Promise<void>}
77
+ */
78
+ createDirAll(path: string): Promise<void>;
79
+ /**
80
+ * @param {string} src
81
+ * @param {string} dst
82
+ * @returns {Promise<void>}
83
+ */
84
+ copyFile(src: string, dst: string): Promise<void>;
85
+ }
86
+ export default __wbg_init;
87
+ export function initSync(module: any): any;
88
+ declare function __wbg_init(module_or_path: any): Promise<any>;
@@ -0,0 +1,931 @@
1
+ let wasm;
2
+ const heap = new Array(128).fill(undefined);
3
+ heap.push(undefined, null, true, false);
4
+ function getObject(idx) { return heap[idx]; }
5
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available'); } });
6
+ if (typeof TextDecoder !== 'undefined') {
7
+ cachedTextDecoder.decode();
8
+ }
9
+ ;
10
+ let cachedUint8ArrayMemory0 = null;
11
+ function getUint8ArrayMemory0() {
12
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
+ }
15
+ return cachedUint8ArrayMemory0;
16
+ }
17
+ function getStringFromWasm0(ptr, len) {
18
+ ptr = ptr >>> 0;
19
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
20
+ }
21
+ let heap_next = heap.length;
22
+ function addHeapObject(obj) {
23
+ if (heap_next === heap.length)
24
+ heap.push(heap.length + 1);
25
+ const idx = heap_next;
26
+ heap_next = heap[idx];
27
+ heap[idx] = obj;
28
+ return idx;
29
+ }
30
+ function handleError(f, args) {
31
+ try {
32
+ return f.apply(this, args);
33
+ }
34
+ catch (e) {
35
+ wasm.__wbindgen_export_0(addHeapObject(e));
36
+ }
37
+ }
38
+ function dropObject(idx) {
39
+ if (idx < 132)
40
+ return;
41
+ heap[idx] = heap_next;
42
+ heap_next = idx;
43
+ }
44
+ function takeObject(idx) {
45
+ const ret = getObject(idx);
46
+ dropObject(idx);
47
+ return ret;
48
+ }
49
+ let WASM_VECTOR_LEN = 0;
50
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available'); } });
51
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
52
+ ? function (arg, view) {
53
+ return cachedTextEncoder.encodeInto(arg, view);
54
+ }
55
+ : function (arg, view) {
56
+ const buf = cachedTextEncoder.encode(arg);
57
+ view.set(buf);
58
+ return {
59
+ read: arg.length,
60
+ written: buf.length
61
+ };
62
+ });
63
+ function passStringToWasm0(arg, malloc, realloc) {
64
+ if (realloc === undefined) {
65
+ const buf = cachedTextEncoder.encode(arg);
66
+ const ptr = malloc(buf.length, 1) >>> 0;
67
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
68
+ WASM_VECTOR_LEN = buf.length;
69
+ return ptr;
70
+ }
71
+ let len = arg.length;
72
+ let ptr = malloc(len, 1) >>> 0;
73
+ const mem = getUint8ArrayMemory0();
74
+ let offset = 0;
75
+ for (; offset < len; offset++) {
76
+ const code = arg.charCodeAt(offset);
77
+ if (code > 0x7F)
78
+ break;
79
+ mem[ptr + offset] = code;
80
+ }
81
+ if (offset !== len) {
82
+ if (offset !== 0) {
83
+ arg = arg.slice(offset);
84
+ }
85
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
86
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
87
+ const ret = encodeString(arg, view);
88
+ offset += ret.written;
89
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
90
+ }
91
+ WASM_VECTOR_LEN = offset;
92
+ return ptr;
93
+ }
94
+ let cachedDataViewMemory0 = null;
95
+ function getDataViewMemory0() {
96
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
97
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
98
+ }
99
+ return cachedDataViewMemory0;
100
+ }
101
+ function getArrayU8FromWasm0(ptr, len) {
102
+ ptr = ptr >>> 0;
103
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
104
+ }
105
+ function isLikeNone(x) {
106
+ return x === undefined || x === null;
107
+ }
108
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
109
+ ? { register: () => { }, unregister: () => { } }
110
+ : new FinalizationRegistry(state => {
111
+ wasm.__wbindgen_export_3.get(state.dtor)(state.a, state.b);
112
+ });
113
+ function makeMutClosure(arg0, arg1, dtor, f) {
114
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
115
+ const real = (...args) => {
116
+ // First up with a closure we increment the internal reference
117
+ // count. This ensures that the Rust closure environment won't
118
+ // be deallocated while we're invoking it.
119
+ state.cnt++;
120
+ const a = state.a;
121
+ state.a = 0;
122
+ try {
123
+ return f(a, state.b, ...args);
124
+ }
125
+ finally {
126
+ if (--state.cnt === 0) {
127
+ wasm.__wbindgen_export_3.get(state.dtor)(a, state.b);
128
+ CLOSURE_DTORS.unregister(state);
129
+ }
130
+ else {
131
+ state.a = a;
132
+ }
133
+ }
134
+ };
135
+ real.original = state;
136
+ CLOSURE_DTORS.register(real, state, state);
137
+ return real;
138
+ }
139
+ function debugString(val) {
140
+ // primitive types
141
+ const type = typeof val;
142
+ if (type == 'number' || type == 'boolean' || val == null) {
143
+ return `${val}`;
144
+ }
145
+ if (type == 'string') {
146
+ return `"${val}"`;
147
+ }
148
+ if (type == 'symbol') {
149
+ const description = val.description;
150
+ if (description == null) {
151
+ return 'Symbol';
152
+ }
153
+ else {
154
+ return `Symbol(${description})`;
155
+ }
156
+ }
157
+ if (type == 'function') {
158
+ const name = val.name;
159
+ if (typeof name == 'string' && name.length > 0) {
160
+ return `Function(${name})`;
161
+ }
162
+ else {
163
+ return 'Function';
164
+ }
165
+ }
166
+ // objects
167
+ if (Array.isArray(val)) {
168
+ const length = val.length;
169
+ let debug = '[';
170
+ if (length > 0) {
171
+ debug += debugString(val[0]);
172
+ }
173
+ for (let i = 1; i < length; i++) {
174
+ debug += ', ' + debugString(val[i]);
175
+ }
176
+ debug += ']';
177
+ return debug;
178
+ }
179
+ // Test for built-in
180
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
181
+ let className;
182
+ if (builtInMatches && builtInMatches.length > 1) {
183
+ className = builtInMatches[1];
184
+ }
185
+ else {
186
+ // Failed to match the standard '[object ClassName]'
187
+ return toString.call(val);
188
+ }
189
+ if (className == 'Object') {
190
+ // we're a user defined class or Object
191
+ // JSON.stringify avoids problems with cycles, and is generally much
192
+ // easier than looping through ownProperties of `val`.
193
+ try {
194
+ return 'Object(' + JSON.stringify(val) + ')';
195
+ }
196
+ catch (_) {
197
+ return 'Object';
198
+ }
199
+ }
200
+ // errors
201
+ if (val instanceof Error) {
202
+ return `${val.name}: ${val.message}\n${val.stack}`;
203
+ }
204
+ // TODO we could test for more things here, like `Set`s and `Map`s.
205
+ return className;
206
+ }
207
+ function __wbg_adapter_28(arg0, arg1) {
208
+ wasm.__wbindgen_export_5(arg0, arg1);
209
+ }
210
+ function __wbg_adapter_31(arg0, arg1, arg2) {
211
+ wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
212
+ }
213
+ function __wbg_adapter_66(arg0, arg1, arg2, arg3) {
214
+ wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
215
+ }
216
+ const __wbindgen_enum_DirEntryType = ["file", "directory"];
217
+ const __wbindgen_enum_FileSystemHandleKind = ["file", "directory"];
218
+ const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
219
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
220
+ const CreateSyncAccessHandleOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
221
+ ? { register: () => { }, unregister: () => { } }
222
+ : new FinalizationRegistry(ptr => wasm.__wbg_createsyncaccesshandleoptions_free(ptr >>> 0, 1));
223
+ export class CreateSyncAccessHandleOptions {
224
+ static __wrap(ptr) {
225
+ ptr = ptr >>> 0;
226
+ const obj = Object.create(CreateSyncAccessHandleOptions.prototype);
227
+ obj.__wbg_ptr = ptr;
228
+ CreateSyncAccessHandleOptionsFinalization.register(obj, obj.__wbg_ptr, obj);
229
+ return obj;
230
+ }
231
+ __destroy_into_raw() {
232
+ const ptr = this.__wbg_ptr;
233
+ this.__wbg_ptr = 0;
234
+ CreateSyncAccessHandleOptionsFinalization.unregister(this);
235
+ return ptr;
236
+ }
237
+ free() {
238
+ const ptr = this.__destroy_into_raw();
239
+ wasm.__wbg_createsyncaccesshandleoptions_free(ptr, 0);
240
+ }
241
+ }
242
+ const DirEntryFinalization = (typeof FinalizationRegistry === 'undefined')
243
+ ? { register: () => { }, unregister: () => { } }
244
+ : new FinalizationRegistry(ptr => wasm.__wbg_direntry_free(ptr >>> 0, 1));
245
+ /**
246
+ * Directory entry with name and type information
247
+ */
248
+ export class DirEntry {
249
+ static __wrap(ptr) {
250
+ ptr = ptr >>> 0;
251
+ const obj = Object.create(DirEntry.prototype);
252
+ obj.__wbg_ptr = ptr;
253
+ DirEntryFinalization.register(obj, obj.__wbg_ptr, obj);
254
+ return obj;
255
+ }
256
+ __destroy_into_raw() {
257
+ const ptr = this.__wbg_ptr;
258
+ this.__wbg_ptr = 0;
259
+ DirEntryFinalization.unregister(this);
260
+ return ptr;
261
+ }
262
+ free() {
263
+ const ptr = this.__destroy_into_raw();
264
+ wasm.__wbg_direntry_free(ptr, 0);
265
+ }
266
+ /**
267
+ * @returns {string}
268
+ */
269
+ get name() {
270
+ let deferred1_0;
271
+ let deferred1_1;
272
+ try {
273
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
274
+ wasm.__wbg_get_direntry_name(retptr, this.__wbg_ptr);
275
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
276
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
277
+ deferred1_0 = r0;
278
+ deferred1_1 = r1;
279
+ return getStringFromWasm0(r0, r1);
280
+ }
281
+ finally {
282
+ wasm.__wbindgen_add_to_stack_pointer(16);
283
+ wasm.__wbindgen_export_4(deferred1_0, deferred1_1, 1);
284
+ }
285
+ }
286
+ /**
287
+ * @param {string} arg0
288
+ */
289
+ set name(arg0) {
290
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
291
+ const len0 = WASM_VECTOR_LEN;
292
+ wasm.__wbg_set_direntry_name(this.__wbg_ptr, ptr0, len0);
293
+ }
294
+ /**
295
+ * @returns {DirEntryType}
296
+ */
297
+ get type() {
298
+ const ret = wasm.__wbg_get_direntry_type(this.__wbg_ptr);
299
+ return __wbindgen_enum_DirEntryType[ret];
300
+ }
301
+ /**
302
+ * @param {DirEntryType} arg0
303
+ */
304
+ set type(arg0) {
305
+ wasm.__wbg_set_direntry_type(this.__wbg_ptr, (__wbindgen_enum_DirEntryType.indexOf(arg0) + 1 || 3) - 1);
306
+ }
307
+ }
308
+ const ProjectFinalization = (typeof FinalizationRegistry === 'undefined')
309
+ ? { register: () => { }, unregister: () => { } }
310
+ : new FinalizationRegistry(ptr => wasm.__wbg_project_free(ptr >>> 0, 1));
311
+ export class Project {
312
+ __destroy_into_raw() {
313
+ const ptr = this.__wbg_ptr;
314
+ this.__wbg_ptr = 0;
315
+ ProjectFinalization.unregister(this);
316
+ return ptr;
317
+ }
318
+ free() {
319
+ const ptr = this.__destroy_into_raw();
320
+ wasm.__wbg_project_free(ptr, 0);
321
+ }
322
+ /**
323
+ * @param {string} cwd
324
+ */
325
+ constructor(cwd) {
326
+ const ptr0 = passStringToWasm0(cwd, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
327
+ const len0 = WASM_VECTOR_LEN;
328
+ const ret = wasm.project_new(ptr0, len0);
329
+ this.__wbg_ptr = ret >>> 0;
330
+ ProjectFinalization.register(this, this.__wbg_ptr, this);
331
+ return this;
332
+ }
333
+ /**
334
+ * @returns {string}
335
+ */
336
+ get cwd() {
337
+ let deferred1_0;
338
+ let deferred1_1;
339
+ try {
340
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
341
+ wasm.project_cwd(retptr, this.__wbg_ptr);
342
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
343
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
344
+ deferred1_0 = r0;
345
+ deferred1_1 = r1;
346
+ return getStringFromWasm0(r0, r1);
347
+ }
348
+ finally {
349
+ wasm.__wbindgen_add_to_stack_pointer(16);
350
+ wasm.__wbindgen_export_4(deferred1_0, deferred1_1, 1);
351
+ }
352
+ }
353
+ /**
354
+ * @param {string} package_lock
355
+ * @returns {Promise<void>}
356
+ */
357
+ install(package_lock) {
358
+ const ptr0 = passStringToWasm0(package_lock, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.project_install(this.__wbg_ptr, ptr0, len0);
361
+ return takeObject(ret);
362
+ }
363
+ /**
364
+ * @returns {Promise<void>}
365
+ */
366
+ build() {
367
+ const ret = wasm.project_build(this.__wbg_ptr);
368
+ return takeObject(ret);
369
+ }
370
+ /**
371
+ * @param {string} path
372
+ * @returns {Promise<string>}
373
+ */
374
+ readFile(path) {
375
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
376
+ const len0 = WASM_VECTOR_LEN;
377
+ const ret = wasm.project_readFile(this.__wbg_ptr, ptr0, len0);
378
+ return takeObject(ret);
379
+ }
380
+ /**
381
+ * @param {string} path
382
+ * @param {string} content
383
+ * @returns {Promise<void>}
384
+ */
385
+ writeFile(path, content) {
386
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
387
+ const len0 = WASM_VECTOR_LEN;
388
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
389
+ const len1 = WASM_VECTOR_LEN;
390
+ const ret = wasm.project_writeFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
391
+ return takeObject(ret);
392
+ }
393
+ /**
394
+ * @param {string} path
395
+ * @returns {Promise<DirEntry[]>}
396
+ */
397
+ readDir(path) {
398
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
399
+ const len0 = WASM_VECTOR_LEN;
400
+ const ret = wasm.project_readDir(this.__wbg_ptr, ptr0, len0);
401
+ return takeObject(ret);
402
+ }
403
+ /**
404
+ * @param {string} path
405
+ * @returns {Promise<void>}
406
+ */
407
+ createDir(path) {
408
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
409
+ const len0 = WASM_VECTOR_LEN;
410
+ const ret = wasm.project_createDir(this.__wbg_ptr, ptr0, len0);
411
+ return takeObject(ret);
412
+ }
413
+ /**
414
+ * @param {string} path
415
+ * @returns {Promise<void>}
416
+ */
417
+ createDirAll(path) {
418
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
419
+ const len0 = WASM_VECTOR_LEN;
420
+ const ret = wasm.project_createDirAll(this.__wbg_ptr, ptr0, len0);
421
+ return takeObject(ret);
422
+ }
423
+ /**
424
+ * @param {string} src
425
+ * @param {string} dst
426
+ * @returns {Promise<void>}
427
+ */
428
+ copyFile(src, dst) {
429
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
430
+ const len0 = WASM_VECTOR_LEN;
431
+ const ptr1 = passStringToWasm0(dst, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
432
+ const len1 = WASM_VECTOR_LEN;
433
+ const ret = wasm.project_copyFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
434
+ return takeObject(ret);
435
+ }
436
+ }
437
+ async function __wbg_load(module, imports) {
438
+ if (typeof Response === 'function' && module instanceof Response) {
439
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
440
+ try {
441
+ return await WebAssembly.instantiateStreaming(module, imports);
442
+ }
443
+ catch (e) {
444
+ if (module.headers.get('Content-Type') != 'application/wasm') {
445
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
446
+ }
447
+ else {
448
+ throw e;
449
+ }
450
+ }
451
+ }
452
+ const bytes = await module.arrayBuffer();
453
+ return await WebAssembly.instantiate(bytes, imports);
454
+ }
455
+ else {
456
+ const instance = await WebAssembly.instantiate(module, imports);
457
+ if (instance instanceof WebAssembly.Instance) {
458
+ return { instance, module };
459
+ }
460
+ else {
461
+ return instance;
462
+ }
463
+ }
464
+ }
465
+ function __wbg_get_imports() {
466
+ const imports = {};
467
+ imports.wbg = {};
468
+ imports.wbg.__wbg_abort_410ec47a64ac6117 = function (arg0, arg1) {
469
+ getObject(arg0).abort(getObject(arg1));
470
+ };
471
+ imports.wbg.__wbg_abort_775ef1d17fc65868 = function (arg0) {
472
+ getObject(arg0).abort();
473
+ };
474
+ imports.wbg.__wbg_append_8c7dd8d641a5f01b = function () {
475
+ return handleError(function (arg0, arg1, arg2, arg3, arg4) {
476
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
477
+ }, arguments);
478
+ };
479
+ imports.wbg.__wbg_arrayBuffer_d1b44c4390db422f = function () {
480
+ return handleError(function (arg0) {
481
+ const ret = getObject(arg0).arrayBuffer();
482
+ return addHeapObject(ret);
483
+ }, arguments);
484
+ };
485
+ imports.wbg.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
486
+ const ret = getObject(arg0).buffer;
487
+ return addHeapObject(ret);
488
+ };
489
+ imports.wbg.__wbg_call_672a4d21634d4a24 = function () {
490
+ return handleError(function (arg0, arg1) {
491
+ const ret = getObject(arg0).call(getObject(arg1));
492
+ return addHeapObject(ret);
493
+ }, arguments);
494
+ };
495
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function () {
496
+ return handleError(function (arg0, arg1, arg2) {
497
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
498
+ return addHeapObject(ret);
499
+ }, arguments);
500
+ };
501
+ imports.wbg.__wbg_clearTimeout_0b53d391c1b94dda = function (arg0) {
502
+ const ret = clearTimeout(takeObject(arg0));
503
+ return addHeapObject(ret);
504
+ };
505
+ imports.wbg.__wbg_close_a17af48266bd9942 = function (arg0) {
506
+ getObject(arg0).close();
507
+ };
508
+ imports.wbg.__wbg_createsyncaccesshandleoptions_new = function (arg0) {
509
+ const ret = CreateSyncAccessHandleOptions.__wrap(arg0);
510
+ return addHeapObject(ret);
511
+ };
512
+ imports.wbg.__wbg_direntry_new = function (arg0) {
513
+ const ret = DirEntry.__wrap(arg0);
514
+ return addHeapObject(ret);
515
+ };
516
+ imports.wbg.__wbg_done_769e5ede4b31c67b = function (arg0) {
517
+ const ret = getObject(arg0).done;
518
+ return ret;
519
+ };
520
+ imports.wbg.__wbg_entries_19efe296f7d36df9 = function (arg0) {
521
+ const ret = getObject(arg0).entries();
522
+ return addHeapObject(ret);
523
+ };
524
+ imports.wbg.__wbg_fetch_11bff8299d0ecd2b = function (arg0) {
525
+ const ret = fetch(getObject(arg0));
526
+ return addHeapObject(ret);
527
+ };
528
+ imports.wbg.__wbg_fetch_509096533071c657 = function (arg0, arg1) {
529
+ const ret = getObject(arg0).fetch(getObject(arg1));
530
+ return addHeapObject(ret);
531
+ };
532
+ imports.wbg.__wbg_from_2a5d3e218e67aa85 = function (arg0) {
533
+ const ret = Array.from(getObject(arg0));
534
+ return addHeapObject(ret);
535
+ };
536
+ imports.wbg.__wbg_getDirectoryHandle_c48a138373d79b3d = function (arg0, arg1, arg2, arg3) {
537
+ const ret = getObject(arg0).getDirectoryHandle(getStringFromWasm0(arg1, arg2), getObject(arg3));
538
+ return addHeapObject(ret);
539
+ };
540
+ imports.wbg.__wbg_getDirectory_c206b0540c9acc0f = function (arg0) {
541
+ const ret = getObject(arg0).getDirectory();
542
+ return addHeapObject(ret);
543
+ };
544
+ imports.wbg.__wbg_getFileHandle_5fb877d1ecc74d52 = function (arg0, arg1, arg2, arg3) {
545
+ const ret = getObject(arg0).getFileHandle(getStringFromWasm0(arg1, arg2), getObject(arg3));
546
+ return addHeapObject(ret);
547
+ };
548
+ imports.wbg.__wbg_getSize_e7dbd5ffa0b43df1 = function () {
549
+ return handleError(function (arg0) {
550
+ const ret = getObject(arg0).getSize();
551
+ return ret;
552
+ }, arguments);
553
+ };
554
+ imports.wbg.__wbg_get_67b2ba62fc30de12 = function () {
555
+ return handleError(function (arg0, arg1) {
556
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
557
+ return addHeapObject(ret);
558
+ }, arguments);
559
+ };
560
+ imports.wbg.__wbg_get_b9b93047fe3cf45b = function (arg0, arg1) {
561
+ const ret = getObject(arg0)[arg1 >>> 0];
562
+ return addHeapObject(ret);
563
+ };
564
+ imports.wbg.__wbg_has_a5ea9117f258a0ec = function () {
565
+ return handleError(function (arg0, arg1) {
566
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
567
+ return ret;
568
+ }, arguments);
569
+ };
570
+ imports.wbg.__wbg_headers_9cb51cfd2ac780a4 = function (arg0) {
571
+ const ret = getObject(arg0).headers;
572
+ return addHeapObject(ret);
573
+ };
574
+ imports.wbg.__wbg_instanceof_DomException_ed1ccb7aaf39034c = function (arg0) {
575
+ let result;
576
+ try {
577
+ result = getObject(arg0) instanceof DOMException;
578
+ }
579
+ catch (_) {
580
+ result = false;
581
+ }
582
+ const ret = result;
583
+ return ret;
584
+ };
585
+ imports.wbg.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function (arg0) {
586
+ let result;
587
+ try {
588
+ result = getObject(arg0) instanceof Response;
589
+ }
590
+ catch (_) {
591
+ result = false;
592
+ }
593
+ const ret = result;
594
+ return ret;
595
+ };
596
+ imports.wbg.__wbg_iterator_9a24c88df860dc65 = function () {
597
+ const ret = Symbol.iterator;
598
+ return addHeapObject(ret);
599
+ };
600
+ imports.wbg.__wbg_kind_e326a1c6387aad5e = function (arg0) {
601
+ const ret = getObject(arg0).kind;
602
+ return (__wbindgen_enum_FileSystemHandleKind.indexOf(ret) + 1 || 3) - 1;
603
+ };
604
+ imports.wbg.__wbg_length_a446193dc22c12f8 = function (arg0) {
605
+ const ret = getObject(arg0).length;
606
+ return ret;
607
+ };
608
+ imports.wbg.__wbg_name_f2d27098bfd843e7 = function (arg0, arg1) {
609
+ const ret = getObject(arg1).name;
610
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
611
+ const len1 = WASM_VECTOR_LEN;
612
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
613
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
614
+ };
615
+ imports.wbg.__wbg_navigator_0a9bf1120e24fec2 = function (arg0) {
616
+ const ret = getObject(arg0).navigator;
617
+ return addHeapObject(ret);
618
+ };
619
+ imports.wbg.__wbg_new_018dcc2d6c8c2f6a = function () {
620
+ return handleError(function () {
621
+ const ret = new Headers();
622
+ return addHeapObject(ret);
623
+ }, arguments);
624
+ };
625
+ imports.wbg.__wbg_new_23a2665fac83c611 = function (arg0, arg1) {
626
+ try {
627
+ var state0 = { a: arg0, b: arg1 };
628
+ var cb0 = (arg0, arg1) => {
629
+ const a = state0.a;
630
+ state0.a = 0;
631
+ try {
632
+ return __wbg_adapter_66(a, state0.b, arg0, arg1);
633
+ }
634
+ finally {
635
+ state0.a = a;
636
+ }
637
+ };
638
+ const ret = new Promise(cb0);
639
+ return addHeapObject(ret);
640
+ }
641
+ finally {
642
+ state0.a = state0.b = 0;
643
+ }
644
+ };
645
+ imports.wbg.__wbg_new_405e22f390576ce2 = function () {
646
+ const ret = new Object();
647
+ return addHeapObject(ret);
648
+ };
649
+ imports.wbg.__wbg_new_a12002a7f91c75be = function (arg0) {
650
+ const ret = new Uint8Array(getObject(arg0));
651
+ return addHeapObject(ret);
652
+ };
653
+ imports.wbg.__wbg_new_e25e5aab09ff45db = function () {
654
+ return handleError(function () {
655
+ const ret = new AbortController();
656
+ return addHeapObject(ret);
657
+ }, arguments);
658
+ };
659
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function (arg0, arg1) {
660
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
661
+ return addHeapObject(ret);
662
+ };
663
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function (arg0, arg1, arg2) {
664
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
665
+ return addHeapObject(ret);
666
+ };
667
+ imports.wbg.__wbg_newwithstrandinit_06c535e0a867c635 = function () {
668
+ return handleError(function (arg0, arg1, arg2) {
669
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
670
+ return addHeapObject(ret);
671
+ }, arguments);
672
+ };
673
+ imports.wbg.__wbg_next_25feadfc0913fea9 = function (arg0) {
674
+ const ret = getObject(arg0).next;
675
+ return addHeapObject(ret);
676
+ };
677
+ imports.wbg.__wbg_next_6574e1a8a62d1055 = function () {
678
+ return handleError(function (arg0) {
679
+ const ret = getObject(arg0).next();
680
+ return addHeapObject(ret);
681
+ }, arguments);
682
+ };
683
+ imports.wbg.__wbg_next_c3ab0d59847b3b5c = function () {
684
+ return handleError(function (arg0) {
685
+ const ret = getObject(arg0).next();
686
+ return addHeapObject(ret);
687
+ }, arguments);
688
+ };
689
+ imports.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function (arg0) {
690
+ queueMicrotask(getObject(arg0));
691
+ };
692
+ imports.wbg.__wbg_queueMicrotask_d3219def82552485 = function (arg0) {
693
+ const ret = getObject(arg0).queueMicrotask;
694
+ return addHeapObject(ret);
695
+ };
696
+ imports.wbg.__wbg_read_f8fdd4b410209222 = function () {
697
+ return handleError(function (arg0, arg1, arg2, arg3) {
698
+ const ret = getObject(arg0).read(getArrayU8FromWasm0(arg1, arg2), getObject(arg3));
699
+ return ret;
700
+ }, arguments);
701
+ };
702
+ imports.wbg.__wbg_resolve_4851785c9c5f573d = function (arg0) {
703
+ const ret = Promise.resolve(getObject(arg0));
704
+ return addHeapObject(ret);
705
+ };
706
+ imports.wbg.__wbg_setTimeout_73ce8df12de4f2f2 = function (arg0, arg1) {
707
+ const ret = setTimeout(getObject(arg0), arg1);
708
+ return addHeapObject(ret);
709
+ };
710
+ imports.wbg.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
711
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
712
+ };
713
+ imports.wbg.__wbg_setat_2a071a392643c10e = function (arg0, arg1) {
714
+ getObject(arg0).at = arg1;
715
+ };
716
+ imports.wbg.__wbg_setbody_5923b78a95eedf29 = function (arg0, arg1) {
717
+ getObject(arg0).body = getObject(arg1);
718
+ };
719
+ imports.wbg.__wbg_setcreate_139bad94b2874fb5 = function (arg0, arg1) {
720
+ getObject(arg0).create = arg1 !== 0;
721
+ };
722
+ imports.wbg.__wbg_setcreate_4ca762e23d9f78da = function (arg0, arg1) {
723
+ getObject(arg0).create = arg1 !== 0;
724
+ };
725
+ imports.wbg.__wbg_setcredentials_c3a22f1cd105a2c6 = function (arg0, arg1) {
726
+ getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];
727
+ };
728
+ imports.wbg.__wbg_setheaders_834c0bdb6a8949ad = function (arg0, arg1) {
729
+ getObject(arg0).headers = getObject(arg1);
730
+ };
731
+ imports.wbg.__wbg_setmethod_3c5280fe5d890842 = function (arg0, arg1, arg2) {
732
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
733
+ };
734
+ imports.wbg.__wbg_setmode_5dc300b865044b65 = function (arg0, arg1) {
735
+ getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
736
+ };
737
+ imports.wbg.__wbg_setsignal_75b21ef3a81de905 = function (arg0, arg1) {
738
+ getObject(arg0).signal = getObject(arg1);
739
+ };
740
+ imports.wbg.__wbg_signal_aaf9ad74119f20a4 = function (arg0) {
741
+ const ret = getObject(arg0).signal;
742
+ return addHeapObject(ret);
743
+ };
744
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function () {
745
+ const ret = typeof global === 'undefined' ? null : global;
746
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
747
+ };
748
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function () {
749
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
750
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
751
+ };
752
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function () {
753
+ const ret = typeof self === 'undefined' ? null : self;
754
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
755
+ };
756
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function () {
757
+ const ret = typeof window === 'undefined' ? null : window;
758
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
759
+ };
760
+ imports.wbg.__wbg_status_f6360336ca686bf0 = function (arg0) {
761
+ const ret = getObject(arg0).status;
762
+ return ret;
763
+ };
764
+ imports.wbg.__wbg_storage_07eb754b88898955 = function (arg0) {
765
+ const ret = getObject(arg0).storage;
766
+ return addHeapObject(ret);
767
+ };
768
+ imports.wbg.__wbg_stringify_f7ed6987935b4a24 = function () {
769
+ return handleError(function (arg0) {
770
+ const ret = JSON.stringify(getObject(arg0));
771
+ return addHeapObject(ret);
772
+ }, arguments);
773
+ };
774
+ imports.wbg.__wbg_then_44b73946d2fb3e7d = function (arg0, arg1) {
775
+ const ret = getObject(arg0).then(getObject(arg1));
776
+ return addHeapObject(ret);
777
+ };
778
+ imports.wbg.__wbg_then_48b406749878a531 = function (arg0, arg1, arg2) {
779
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
780
+ return addHeapObject(ret);
781
+ };
782
+ imports.wbg.__wbg_toString_5285597960676b7b = function (arg0) {
783
+ const ret = getObject(arg0).toString();
784
+ return addHeapObject(ret);
785
+ };
786
+ imports.wbg.__wbg_truncate_29261a6365c72b01 = function () {
787
+ return handleError(function (arg0, arg1) {
788
+ getObject(arg0).truncate(arg1 >>> 0);
789
+ }, arguments);
790
+ };
791
+ imports.wbg.__wbg_url_ae10c34ca209681d = function (arg0, arg1) {
792
+ const ret = getObject(arg1).url;
793
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
794
+ const len1 = WASM_VECTOR_LEN;
795
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
796
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
797
+ };
798
+ imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function (arg0) {
799
+ const ret = getObject(arg0).value;
800
+ return addHeapObject(ret);
801
+ };
802
+ imports.wbg.__wbg_write_530d3c84df874f53 = function () {
803
+ return handleError(function (arg0, arg1, arg2, arg3) {
804
+ const ret = getObject(arg0).write(getArrayU8FromWasm0(arg1, arg2), getObject(arg3));
805
+ return ret;
806
+ }, arguments);
807
+ };
808
+ imports.wbg.__wbindgen_array_new = function () {
809
+ const ret = [];
810
+ return addHeapObject(ret);
811
+ };
812
+ imports.wbg.__wbindgen_array_push = function (arg0, arg1) {
813
+ getObject(arg0).push(takeObject(arg1));
814
+ };
815
+ imports.wbg.__wbindgen_cb_drop = function (arg0) {
816
+ const obj = takeObject(arg0).original;
817
+ if (obj.cnt-- == 1) {
818
+ obj.a = 0;
819
+ return true;
820
+ }
821
+ const ret = false;
822
+ return ret;
823
+ };
824
+ imports.wbg.__wbindgen_closure_wrapper1051 = function (arg0, arg1, arg2) {
825
+ const ret = makeMutClosure(arg0, arg1, 172, __wbg_adapter_28);
826
+ return addHeapObject(ret);
827
+ };
828
+ imports.wbg.__wbindgen_closure_wrapper1669 = function (arg0, arg1, arg2) {
829
+ const ret = makeMutClosure(arg0, arg1, 443, __wbg_adapter_31);
830
+ return addHeapObject(ret);
831
+ };
832
+ imports.wbg.__wbindgen_debug_string = function (arg0, arg1) {
833
+ const ret = debugString(getObject(arg1));
834
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
835
+ const len1 = WASM_VECTOR_LEN;
836
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
837
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
838
+ };
839
+ imports.wbg.__wbindgen_is_function = function (arg0) {
840
+ const ret = typeof (getObject(arg0)) === 'function';
841
+ return ret;
842
+ };
843
+ imports.wbg.__wbindgen_is_object = function (arg0) {
844
+ const val = getObject(arg0);
845
+ const ret = typeof (val) === 'object' && val !== null;
846
+ return ret;
847
+ };
848
+ imports.wbg.__wbindgen_is_undefined = function (arg0) {
849
+ const ret = getObject(arg0) === undefined;
850
+ return ret;
851
+ };
852
+ imports.wbg.__wbindgen_memory = function () {
853
+ const ret = wasm.memory;
854
+ return addHeapObject(ret);
855
+ };
856
+ imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
857
+ const ret = getObject(arg0);
858
+ return addHeapObject(ret);
859
+ };
860
+ imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
861
+ takeObject(arg0);
862
+ };
863
+ imports.wbg.__wbindgen_string_get = function (arg0, arg1) {
864
+ const obj = getObject(arg1);
865
+ const ret = typeof (obj) === 'string' ? obj : undefined;
866
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
867
+ var len1 = WASM_VECTOR_LEN;
868
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
869
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
870
+ };
871
+ imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
872
+ const ret = getStringFromWasm0(arg0, arg1);
873
+ return addHeapObject(ret);
874
+ };
875
+ imports.wbg.__wbindgen_throw = function (arg0, arg1) {
876
+ throw new Error(getStringFromWasm0(arg0, arg1));
877
+ };
878
+ return imports;
879
+ }
880
+ function __wbg_init_memory(imports, memory) {
881
+ }
882
+ function __wbg_finalize_init(instance, module) {
883
+ wasm = instance.exports;
884
+ __wbg_init.__wbindgen_wasm_module = module;
885
+ cachedDataViewMemory0 = null;
886
+ cachedUint8ArrayMemory0 = null;
887
+ return wasm;
888
+ }
889
+ function initSync(module) {
890
+ if (wasm !== undefined)
891
+ return wasm;
892
+ if (typeof module !== 'undefined') {
893
+ if (Object.getPrototypeOf(module) === Object.prototype) {
894
+ ({ module } = module);
895
+ }
896
+ else {
897
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
898
+ }
899
+ }
900
+ const imports = __wbg_get_imports();
901
+ __wbg_init_memory(imports);
902
+ if (!(module instanceof WebAssembly.Module)) {
903
+ module = new WebAssembly.Module(module);
904
+ }
905
+ const instance = new WebAssembly.Instance(module, imports);
906
+ return __wbg_finalize_init(instance, module);
907
+ }
908
+ async function __wbg_init(module_or_path) {
909
+ if (wasm !== undefined)
910
+ return wasm;
911
+ if (typeof module_or_path !== 'undefined') {
912
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
913
+ ({ module_or_path } = module_or_path);
914
+ }
915
+ else {
916
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead');
917
+ }
918
+ }
919
+ if (typeof module_or_path === 'undefined') {
920
+ module_or_path = new URL('index_bg.wasm', import.meta.url);
921
+ }
922
+ const imports = __wbg_get_imports();
923
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
924
+ module_or_path = fetch(module_or_path);
925
+ }
926
+ __wbg_init_memory(imports);
927
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
928
+ return __wbg_finalize_init(instance, module);
929
+ }
930
+ export { initSync };
931
+ export default __wbg_init;
Binary file
@@ -0,0 +1 @@
1
+ export {};
package/esm/worker.js ADDED
@@ -0,0 +1,42 @@
1
+ import * as comlink from "comlink";
2
+ import { HandShake } from "./message";
3
+ import initWasm, { Project as ProjectInternal } from "./utoo";
4
+ const projectEndpoint = {
5
+ projectInternal: undefined,
6
+ async mount(cwd) {
7
+ await initWasm();
8
+ this.projectInternal = new ProjectInternal(cwd);
9
+ },
10
+ async install(packageLock) {
11
+ await this.projectInternal.install(packageLock);
12
+ },
13
+ async build() {
14
+ await this.projectInternal.build();
15
+ },
16
+ async readFile(path) {
17
+ return await this.projectInternal.readFile(path);
18
+ },
19
+ async writeFile(path, content) {
20
+ return await this.projectInternal.writeFile(path, content);
21
+ },
22
+ async copyFile(src, dst) {
23
+ return await this.projectInternal.copyFile(src, dst);
24
+ },
25
+ async readDir(path) {
26
+ return await this.projectInternal.readDir(path);
27
+ },
28
+ async createDir(path) {
29
+ return await this.projectInternal.createDir(path);
30
+ },
31
+ async createDirAll(path) {
32
+ return await this.projectInternal.createDirAll(path);
33
+ },
34
+ };
35
+ const ConnectedPorts = new Set();
36
+ self.addEventListener("message", (e) => {
37
+ const port = e.ports[0];
38
+ if (e.data === HandShake && !ConnectedPorts.has(port)) {
39
+ comlink.expose(projectEndpoint, port);
40
+ ConnectedPorts.add(port);
41
+ }
42
+ });
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@utoo/web",
3
+ "version": "0.0.1",
4
+ "module": "esm/index.js",
5
+ "types": "esm/index.d.ts",
6
+ "files": [
7
+ "esm/*"
8
+ ],
9
+ "scripts": {
10
+ "wasmpack": "wasm-pack build ../../crates/utoo-wasm --out-dir ../../packages/utoo-web/src/utoo --out-name index --no-pack --target web",
11
+ "tsx": "rm -rf esm && tsc -p ./tsconfig.json",
12
+ "dev": "npm run wasmpack -- --dev && npm run tsx && cp ./src/utoo/*.wasm ./esm/utoo",
13
+ "build": "npm run wasmpack -- --release && npm run tsx && cp ./src/utoo/*.wasm ./esm/utoo",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "dependencies": {
17
+ "comlink": "^4.4.2"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.8.3"
21
+ },
22
+ "engines": {
23
+ "node": ">= 20"
24
+ },
25
+ "author": "xusd320",
26
+ "license": "MIT"
27
+ }