@utoo/web 1.4.1 → 1.4.3
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/loaderWorker.js +1 -1
- package/esm/project/InternalProject.d.ts +1 -4
- package/esm/project/InternalProject.js +4 -4
- package/esm/project/Project.d.ts +1 -1
- package/esm/project/Project.js +9 -10
- package/esm/utoo/index.js +24 -24
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/cjs.js +20 -59
- package/package.json +1 -1
|
@@ -14,10 +14,7 @@ declare class InternalEndpoint implements ProjectEndpoint {
|
|
|
14
14
|
config?: ConfigComplete;
|
|
15
15
|
cleanup?: boolean;
|
|
16
16
|
}): Promise<any>;
|
|
17
|
-
dev(
|
|
18
|
-
config?: ConfigComplete;
|
|
19
|
-
onUpdate?: (result: any) => void;
|
|
20
|
-
}): Promise<void>;
|
|
17
|
+
dev(config?: ConfigComplete, onUpdate?: (result: any) => void): Promise<void>;
|
|
21
18
|
readFile(path: string, encoding?: "utf8"): Promise<any>;
|
|
22
19
|
writeFile(path: string, content: string | Uint8Array, _encoding?: "utf8"): Promise<void>;
|
|
23
20
|
copyFile(src: string, dst: string): Promise<void>;
|
|
@@ -51,15 +51,15 @@ class InternalEndpoint {
|
|
|
51
51
|
}
|
|
52
52
|
return await ProjectInternal.build(buildOptions);
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
// @ts-expect-error - Comlink delivers (config, onUpdate) as separate args, not as options object
|
|
55
|
+
async dev(config, onUpdate) {
|
|
55
56
|
var _a, _b;
|
|
56
57
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.loaderWorkerUrl) && !this.loaderWorkerPoolInitialized) {
|
|
57
58
|
runLoaderWorkerPool(this.options.cwd, this.options.loaderWorkerUrl, (_b = this.options) === null || _b === void 0 ? void 0 : _b.loadersImportMap);
|
|
58
59
|
this.loaderWorkerPoolInitialized = true;
|
|
59
60
|
}
|
|
60
|
-
this.rootTask = await ProjectInternal.entrypointsSubscribe(
|
|
61
|
-
|
|
62
|
-
(_a = options === null || options === void 0 ? void 0 : options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, result);
|
|
61
|
+
this.rootTask = await ProjectInternal.entrypointsSubscribe(config, (result) => {
|
|
62
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(result);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
async readFile(path, encoding) {
|
package/esm/project/Project.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class Project implements ProjectEndpoint {
|
|
|
22
22
|
dev(options?: {
|
|
23
23
|
config?: ConfigComplete;
|
|
24
24
|
onUpdate?: (result: BuildOutput) => void;
|
|
25
|
-
}): void
|
|
25
|
+
}): Promise<void>;
|
|
26
26
|
hmrSubscribe(identifier: string, callback: (update: unknown) => void): Promise<void>;
|
|
27
27
|
updateInfoSubscribe(aggregationMs: number, callback: (message: UpdateMessage) => void): void;
|
|
28
28
|
readFile(path: string, encoding?: "utf8"): Promise<any>;
|
package/esm/project/Project.js
CHANGED
|
@@ -81,7 +81,8 @@ export class Project {
|
|
|
81
81
|
handleIssues(res.issues, false, false);
|
|
82
82
|
return res;
|
|
83
83
|
}
|
|
84
|
-
dev(options) {
|
|
84
|
+
async dev(options) {
|
|
85
|
+
await __classPrivateFieldGet(this, _Project_mount, "f");
|
|
85
86
|
// Create HmrServer lazily on first dev() call
|
|
86
87
|
if (!this.hmrServer) {
|
|
87
88
|
this.hmrServer = new HmrServer({
|
|
@@ -92,15 +93,13 @@ export class Project {
|
|
|
92
93
|
},
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
config: options === null || options === void 0 ? void 0 : options.config,
|
|
103
|
-
});
|
|
96
|
+
// Pass config and onUpdate as separate top-level args for Comlink serialization
|
|
97
|
+
this.remote.dev(options === null || options === void 0 ? void 0 : options.config, (options === null || options === void 0 ? void 0 : options.onUpdate)
|
|
98
|
+
? comlink.proxy((result) => {
|
|
99
|
+
handleIssues(result.issues, false, false);
|
|
100
|
+
options.onUpdate(result);
|
|
101
|
+
})
|
|
102
|
+
: undefined);
|
|
104
103
|
}
|
|
105
104
|
async hmrSubscribe(identifier, callback) {
|
|
106
105
|
await this.remote.hmrSubscribe(identifier, comlink.proxy(callback));
|
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
|
|
1483
|
+
return __wasm_bindgen_func_elem_3869(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:
|
|
1811
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1810
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1460, function: Function { arguments: [Externref], shim_idx: 5649, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1811
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21929, __wasm_bindgen_func_elem_80603);
|
|
1812
1812
|
return addHeapObject(ret);
|
|
1813
1813
|
},
|
|
1814
1814
|
__wbindgen_cast_0000000000000002: function (arg0, arg1) {
|
|
1815
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1816
|
-
const ret =
|
|
1815
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1460, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 5649, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1816
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21929, __wasm_bindgen_func_elem_80603);
|
|
1817
1817
|
return addHeapObject(ret);
|
|
1818
1818
|
},
|
|
1819
1819
|
__wbindgen_cast_0000000000000003: function (arg0, arg1) {
|
|
1820
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1821
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1820
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1460, function: Function { arguments: [Ref(NamedExternref("MessageEvent"))], shim_idx: 5652, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1821
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21929, __wasm_bindgen_func_elem_80639);
|
|
1822
1822
|
return addHeapObject(ret);
|
|
1823
1823
|
},
|
|
1824
1824
|
__wbindgen_cast_0000000000000004: function (arg0, arg1) {
|
|
1825
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1826
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1825
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 1460, function: Function { arguments: [], shim_idx: 1461, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1826
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_21929, __wasm_bindgen_func_elem_21930);
|
|
1827
1827
|
return addHeapObject(ret);
|
|
1828
1828
|
},
|
|
1829
1829
|
__wbindgen_cast_0000000000000005: function (arg0, arg1) {
|
|
1830
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1831
|
-
const ret =
|
|
1830
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 5629, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 5630, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
|
1831
|
+
const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_79864, __wasm_bindgen_func_elem_79865);
|
|
1832
1832
|
return addHeapObject(ret);
|
|
1833
1833
|
},
|
|
1834
1834
|
__wbindgen_cast_0000000000000006: function (arg0, arg1) {
|
|
1835
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1836
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1835
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 5655, function: Function { arguments: [], shim_idx: 1461, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1836
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_80659, __wasm_bindgen_func_elem_21930);
|
|
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
|
|
1885
|
-
wasm.
|
|
1884
|
+
function __wasm_bindgen_func_elem_21930(arg0, arg1) {
|
|
1885
|
+
wasm.__wasm_bindgen_func_elem_21930(arg0, arg1);
|
|
1886
1886
|
}
|
|
1887
|
-
function
|
|
1888
|
-
wasm.
|
|
1887
|
+
function __wasm_bindgen_func_elem_80603(arg0, arg1, arg2) {
|
|
1888
|
+
wasm.__wasm_bindgen_func_elem_80603(arg0, arg1, addHeapObject(arg2));
|
|
1889
1889
|
}
|
|
1890
|
-
function
|
|
1891
|
-
wasm.__wasm_bindgen_func_elem_80437(arg0, arg1, addHeapObject(arg2));
|
|
1892
|
-
}
|
|
1893
|
-
function __wasm_bindgen_func_elem_80643(arg0, arg1, arg2) {
|
|
1890
|
+
function __wasm_bindgen_func_elem_80639(arg0, arg1, arg2) {
|
|
1894
1891
|
try {
|
|
1895
|
-
wasm.
|
|
1892
|
+
wasm.__wasm_bindgen_func_elem_80639(arg0, arg1, addBorrowedObject(arg2));
|
|
1896
1893
|
}
|
|
1897
1894
|
finally {
|
|
1898
1895
|
heap[stack_pointer++] = undefined;
|
|
1899
1896
|
}
|
|
1900
1897
|
}
|
|
1901
|
-
function
|
|
1902
|
-
wasm.
|
|
1898
|
+
function __wasm_bindgen_func_elem_79865(arg0, arg1, arg2) {
|
|
1899
|
+
wasm.__wasm_bindgen_func_elem_79865(arg0, arg1, addHeapObject(arg2));
|
|
1900
|
+
}
|
|
1901
|
+
function __wasm_bindgen_func_elem_3869(arg0, arg1, arg2, arg3) {
|
|
1902
|
+
wasm.__wasm_bindgen_func_elem_3869(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"];
|
package/esm/utoo/index_bg.wasm
CHANGED
|
Binary file
|
|
@@ -3,7 +3,6 @@ import nodePolyFills from "./polyfills/nodePolyFills";
|
|
|
3
3
|
const fs = nodePolyFills.fs;
|
|
4
4
|
const path = nodePolyFills.path;
|
|
5
5
|
const installedModules = {};
|
|
6
|
-
const statCache = {};
|
|
7
6
|
const pkgJsonCache = {};
|
|
8
7
|
const resolutionCache = {};
|
|
9
8
|
const searchPathsCache = {};
|
|
@@ -35,7 +34,7 @@ const resolveWithExtensions = (p, skipIndexJsIfJs = false) => {
|
|
|
35
34
|
}
|
|
36
35
|
return null;
|
|
37
36
|
};
|
|
38
|
-
const executeModule = (
|
|
37
|
+
const executeModule = (moduleId, moduleCode, importMaps, entrypoint) => {
|
|
39
38
|
if (installedModules[moduleId]) {
|
|
40
39
|
return installedModules[moduleId].exports;
|
|
41
40
|
}
|
|
@@ -44,9 +43,7 @@ const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
|
|
|
44
43
|
const moduleRequire = (childId) => loadModule(childId, context, importMaps, entrypoint);
|
|
45
44
|
moduleRequire.resolve = (request) => request;
|
|
46
45
|
const module = { exports: finalExports, require: moduleRequire };
|
|
47
|
-
if (moduleId.includes("node_modules") ||
|
|
48
|
-
id in importMaps ||
|
|
49
|
-
moduleId in importMaps) {
|
|
46
|
+
if (moduleId.includes("node_modules") || moduleId in importMaps) {
|
|
50
47
|
installedModules[moduleId] = module;
|
|
51
48
|
}
|
|
52
49
|
if (moduleId === entrypoint) {
|
|
@@ -69,23 +66,12 @@ const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
|
|
|
69
66
|
console.error(`Worker: Error executing module ${moduleId}:`, e);
|
|
70
67
|
throw new Error(`Failed to load dependency ${moduleId}: ${e.message}`);
|
|
71
68
|
}
|
|
72
|
-
const originalWarn = console.warn;
|
|
73
|
-
console.warn = (...args) => {
|
|
74
|
-
var _a;
|
|
75
|
-
const msg = ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString()) || "";
|
|
76
|
-
if (!msg.includes("(SystemJS Error#W3")) {
|
|
77
|
-
originalWarn.apply(console, args);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
69
|
try {
|
|
81
70
|
System.set(moduleId, { default: finalExports });
|
|
82
71
|
}
|
|
83
72
|
catch (_a) {
|
|
84
73
|
// ignore
|
|
85
74
|
}
|
|
86
|
-
finally {
|
|
87
|
-
console.warn = originalWarn;
|
|
88
|
-
}
|
|
89
75
|
return finalExports;
|
|
90
76
|
};
|
|
91
77
|
const loadModule = (id, context, importMaps, entrypoint) => {
|
|
@@ -95,19 +81,6 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
95
81
|
const cachedId = resolutionCache[cacheKey];
|
|
96
82
|
if (installedModules[cachedId])
|
|
97
83
|
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
|
-
}
|
|
107
|
-
const code = tryReadFile(cachedId);
|
|
108
|
-
if (code !== null) {
|
|
109
|
-
return executeModule(code, cachedId, id, importMaps, entrypoint);
|
|
110
|
-
}
|
|
111
84
|
}
|
|
112
85
|
// 1. Resolve
|
|
113
86
|
let resolvedId = id.startsWith(".") ? path.join(context, id) : id;
|
|
@@ -120,30 +93,9 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
120
93
|
return nodePolyFills[id];
|
|
121
94
|
if (resolvedId in nodePolyFills)
|
|
122
95
|
return nodePolyFills[resolvedId];
|
|
123
|
-
// 4. Check importMaps
|
|
124
|
-
let moduleCode = importMaps[
|
|
125
|
-
let moduleId =
|
|
126
|
-
if (!moduleCode) {
|
|
127
|
-
let longestMatch = null;
|
|
128
|
-
for (const key in importMaps) {
|
|
129
|
-
const sanitized = key.replace(/^\.?\//, "");
|
|
130
|
-
if (!sanitized)
|
|
131
|
-
continue;
|
|
132
|
-
const isMatch = [id, resolvedId].some((p) => p.startsWith("/") &&
|
|
133
|
-
p.endsWith(sanitized) &&
|
|
134
|
-
p[p.length - sanitized.length - 1] === "/");
|
|
135
|
-
if (isMatch && (!longestMatch || key.length > longestMatch.key.length)) {
|
|
136
|
-
longestMatch = { key, sanitized };
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (longestMatch) {
|
|
140
|
-
moduleCode = importMaps[longestMatch.key];
|
|
141
|
-
moduleId =
|
|
142
|
-
id.startsWith("/") && id.endsWith(longestMatch.sanitized)
|
|
143
|
-
? id
|
|
144
|
-
: resolvedId;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
96
|
+
// 4. Check importMaps
|
|
97
|
+
let moduleCode = importMaps[id];
|
|
98
|
+
let moduleId = moduleCode ? id : resolvedId;
|
|
147
99
|
// Fallback: Try resolving from node_modules
|
|
148
100
|
if (!moduleCode && !id.startsWith(".") && !id.startsWith("/")) {
|
|
149
101
|
let searchPaths = searchPathsCache[context];
|
|
@@ -185,7 +137,7 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
185
137
|
const res = resolveWithExtensions(pkgMain);
|
|
186
138
|
if (res) {
|
|
187
139
|
moduleCode = res.code;
|
|
188
|
-
moduleId =
|
|
140
|
+
moduleId = res.id;
|
|
189
141
|
break;
|
|
190
142
|
}
|
|
191
143
|
}
|
|
@@ -193,7 +145,7 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
193
145
|
const res = resolveWithExtensions(nodeModulesPath);
|
|
194
146
|
if (res) {
|
|
195
147
|
moduleCode = res.code;
|
|
196
|
-
moduleId =
|
|
148
|
+
moduleId = res.id;
|
|
197
149
|
break;
|
|
198
150
|
}
|
|
199
151
|
}
|
|
@@ -203,14 +155,14 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
203
155
|
const res = resolveWithExtensions(resolvedId, id.endsWith(".js"));
|
|
204
156
|
if (res) {
|
|
205
157
|
moduleCode = res.code;
|
|
206
|
-
moduleId =
|
|
158
|
+
moduleId = res.id;
|
|
207
159
|
}
|
|
208
160
|
}
|
|
209
161
|
if (moduleCode) {
|
|
210
162
|
resolutionCache[`${context}:${id}`] = moduleId;
|
|
211
|
-
return executeModule(
|
|
163
|
+
return executeModule(moduleId, moduleCode, importMaps, entrypoint);
|
|
212
164
|
}
|
|
213
|
-
const error = new Error(`Worker: Dependency ${id} (resolved: ${
|
|
165
|
+
const error = new Error(`Worker: Dependency ${id} (resolved: ${moduleId}) not found. Context: ${context}. ` +
|
|
214
166
|
`ImportMaps count: ${Object.keys(importMaps).length}. ` +
|
|
215
167
|
`CWD: ${nodePolyFills.process.cwd()}. ` +
|
|
216
168
|
`Sample ImportMaps keys: ${Object.keys(importMaps).slice(0, 5).join(", ")}`);
|
|
@@ -218,7 +170,7 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
218
170
|
throw error;
|
|
219
171
|
};
|
|
220
172
|
export async function cjs(entrypoint, importMaps) {
|
|
221
|
-
[
|
|
173
|
+
[pkgJsonCache, resolutionCache, searchPathsCache].forEach((c) => {
|
|
222
174
|
for (const key in c)
|
|
223
175
|
delete c[key];
|
|
224
176
|
});
|
|
@@ -240,6 +192,15 @@ export async function cjs(entrypoint, importMaps) {
|
|
|
240
192
|
}
|
|
241
193
|
}
|
|
242
194
|
}));
|
|
195
|
+
// Suppress SystemJS W3 warnings during module loading
|
|
196
|
+
const originalWarn = console.warn;
|
|
197
|
+
console.warn = (...args) => {
|
|
198
|
+
var _a;
|
|
199
|
+
const msg = ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString()) || "";
|
|
200
|
+
if (!msg.includes("(SystemJS Error#W3")) {
|
|
201
|
+
originalWarn.apply(console, args);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
243
204
|
// @ts-ignore
|
|
244
205
|
self.__systemjs_require__ = (id) => loadModule(id, path.dirname(entrypoint), importMaps, entrypoint);
|
|
245
206
|
// @ts-ignore
|