dsh-edge 0.18.0 → 0.19.0-alpha.2
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/README.i18n.yaml +2 -2
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/THIRD_PARTY_NOTICES.md +2011 -449
- package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
- package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
- package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
- package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
- package/dist/assets/index-Cq6ljTv2.css +1 -0
- package/dist/assets/index-Dy0OhsZ5.js +127 -0
- package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
- package/dist/assets/langs/bat-BkioyH1T.js +2 -0
- package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
- package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
- package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
- package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
- package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
- package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
- package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
- package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
- package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
- package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
- package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
- package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
- package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
- package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
- package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
- package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
- package/dist/assets/langs/html-fwsONPVS.js +2 -0
- package/dist/assets/langs/http-DcV90OkR.js +2 -0
- package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
- package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
- package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
- package/dist/assets/langs/log-2UxHyX5q.js +2 -0
- package/dist/assets/langs/make-CHLpvVh8.js +2 -0
- package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
- package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
- package/dist/assets/langs/php-LEPfNACG.js +2 -0
- package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
- package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
- package/dist/assets/langs/r-Dspwwk_N.js +2 -0
- package/dist/assets/langs/rst-BbocfKWr.js +2 -0
- package/dist/assets/langs/ruby-R292Iif0.js +2 -0
- package/dist/assets/langs/scala-C151Ov-r.js +2 -0
- package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
- package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
- package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
- package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
- package/dist/assets/langs/vue-Dq2x6432.js +2 -0
- package/dist/favicon-dark.svg +3 -0
- package/dist/favicon.svg +0 -5
- package/dist/index.html +5 -4
- package/dist/manifest.webmanifest +3 -4
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
- package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
- package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
- package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
- package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
- package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
- package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
- package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
- package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
- package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
- package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
- package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
- package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
- package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
- package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
- package/package.json +96 -86
- package/scripts/cli.mjs +16 -4
- package/scripts/install.d.mts +12 -2
- package/scripts/install.mjs +36 -9
- package/scripts/legal-files.mjs +15 -0
- package/worker/direct/index.js +2564 -1822
- package/worker/isolated/index.js +2144 -1402
- package/dist/assets/index-BKQ_L1z6.js +0 -117
- package/dist/assets/index-DPX2bQLO.css +0 -1
- package/dist/assets/langs/html-CfGypltT.js +0 -2
- package/dist/assets/langs/php-DJl5gRdb.js +0 -2
- package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
- package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
|
@@ -50,6 +50,43 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
return value;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
+
* Narrow an unknown parsed JSON value to the `dsh.client` declaration. Shared
|
|
54
|
+
* by the node half's Loader scan and the roster generator, so both read a
|
|
55
|
+
* package's browser declaration through one validator.
|
|
56
|
+
* @param pkgName - package name used as the diagnostic prefix.
|
|
57
|
+
* @param value - the raw `dsh.client` field of the package manifest.
|
|
58
|
+
* @returns the validated declaration, or undefined when the field is absent.
|
|
59
|
+
* @throws {Error} when the field is present but any member is malformed.
|
|
60
|
+
*/
|
|
61
|
+
function parseDshClient(pkgName, value) {
|
|
62
|
+
if (value === void 0) return void 0;
|
|
63
|
+
if (typeof value !== "object" || value === null) throw new Error(`client-modules: ${pkgName} has a non-object dsh.client declaration`);
|
|
64
|
+
const decl = value;
|
|
65
|
+
if (typeof decl.platform !== "string") throw new Error(`client-modules: ${pkgName} dsh.client.platform must be a string`);
|
|
66
|
+
const inject = optionalStringArray(pkgName, "dsh.client.inject", decl.inject);
|
|
67
|
+
const external = optionalStringArray(pkgName, "dsh.client.external", decl.external);
|
|
68
|
+
if (decl.immediately !== void 0 && typeof decl.immediately !== "boolean") throw new Error(`client-modules: ${pkgName} dsh.client.immediately must be a boolean`);
|
|
69
|
+
return {
|
|
70
|
+
platform: decl.platform,
|
|
71
|
+
...inject !== void 0 ? { inject } : {},
|
|
72
|
+
...external !== void 0 ? { external } : {},
|
|
73
|
+
...decl.immediately !== void 0 ? { immediately: decl.immediately } : {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The bare package-root specifier `specifier` names, or undefined for a subpath, a path, or any scheme-qualified
|
|
78
|
+
* specifier (`cordis:` builtins, `node:` modules, URLs).
|
|
79
|
+
* @param specifier - Loader row name.
|
|
80
|
+
* @returns the package name, or undefined.
|
|
81
|
+
*/
|
|
82
|
+
function exactPackageSpecifier(specifier) {
|
|
83
|
+
if (specifier.startsWith("@")) {
|
|
84
|
+
const parts = specifier.split("/");
|
|
85
|
+
return parts.length === 2 && parts.every(Boolean) ? specifier : void 0;
|
|
86
|
+
}
|
|
87
|
+
return specifier.length > 0 && !specifier.includes("/") && !specifier.includes(":") ? specifier : void 0;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
53
90
|
* Normalize a module specifier onto the graph row that owns it: a plugin bundle
|
|
54
91
|
* IS its package's client half, so `<id>/client` (the exports subpath external
|
|
55
92
|
* bundles emit) and the bare package name resolve to the same exports. Both the
|
|
@@ -135,6 +172,274 @@ window.__ModuleLoader__.load({
|
|
|
135
172
|
};
|
|
136
173
|
}
|
|
137
174
|
//#endregion
|
|
175
|
+
//#region lib/types/client/entry-lifecycle.js
|
|
176
|
+
/**
|
|
177
|
+
* Release a runtime before clearing its entry fiber so Loader refresh can import new code.
|
|
178
|
+
* Registry deletion prevents Loader from treating replacement as a user disable.
|
|
179
|
+
* @param entry - Entry retained for code replacement.
|
|
180
|
+
*/
|
|
181
|
+
async function tearDownEntryFiber(entry) {
|
|
182
|
+
const fiber = entry.fiber;
|
|
183
|
+
if (fiber === void 0) return;
|
|
184
|
+
const runtime = fiber.runtime;
|
|
185
|
+
/* v8 ignore next -- Loader entries own plugin fibers; only the root context has a null runtime. */
|
|
186
|
+
if (runtime !== null) entry.ctx.registry.delete(runtime.callback);
|
|
187
|
+
while (fiber.inertia !== void 0) await fiber.inertia;
|
|
188
|
+
delete entry.fiber;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Remove styles after their plugin's effect cleanup has settled.
|
|
192
|
+
* @param id - Package whose factory owns the style tags.
|
|
193
|
+
*/
|
|
194
|
+
function removeOwnedStyles(id) {
|
|
195
|
+
if (typeof document === "undefined") return;
|
|
196
|
+
for (const el of document.querySelectorAll("style[data-plugin]")) if (el.getAttribute("data-plugin") === id) el.remove();
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region lib/types/client/entries.js
|
|
200
|
+
/** Numeric values mirror Cordis's const enum, which bundle loaders cannot import as a runtime object. */
|
|
201
|
+
const ACTIVE = 2;
|
|
202
|
+
const FAILED = 3;
|
|
203
|
+
/** Revisions and requests identify desired code; URLs only select its immutable delivery resource. */
|
|
204
|
+
function entryTargets(manifest) {
|
|
205
|
+
return JSON.stringify(manifest.modules.map((row) => [
|
|
206
|
+
row.id,
|
|
207
|
+
row.rev,
|
|
208
|
+
row.inject,
|
|
209
|
+
row.external
|
|
210
|
+
]));
|
|
211
|
+
}
|
|
212
|
+
/** Manages only entries created from the Host manifest; other Loader contributors retain ownership. */
|
|
213
|
+
var ClientEntries = class {
|
|
214
|
+
modules;
|
|
215
|
+
index;
|
|
216
|
+
/** Stable observable consumed by page diagnostics through the renderer's injected hook. */
|
|
217
|
+
state = {
|
|
218
|
+
getSnapshot: () => this.snapshot,
|
|
219
|
+
subscribe: (listener) => {
|
|
220
|
+
this.listeners.add(listener);
|
|
221
|
+
return () => {
|
|
222
|
+
this.listeners.delete(listener);
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
snapshot = {
|
|
227
|
+
syncing: false,
|
|
228
|
+
failures: []
|
|
229
|
+
};
|
|
230
|
+
listeners = /* @__PURE__ */ new Set();
|
|
231
|
+
managed = /* @__PURE__ */ new Map();
|
|
232
|
+
revisions = /* @__PURE__ */ new Map();
|
|
233
|
+
loader;
|
|
234
|
+
queue = Promise.resolve();
|
|
235
|
+
desired;
|
|
236
|
+
generation = 0;
|
|
237
|
+
stopped = false;
|
|
238
|
+
/**
|
|
239
|
+
* Construct the page controller before Cordis boot.
|
|
240
|
+
* @param modules - Module arrival and materialization owner.
|
|
241
|
+
* @param index - Private descriptor replacement and unused-module cleanup.
|
|
242
|
+
*/
|
|
243
|
+
constructor(modules, index) {
|
|
244
|
+
this.modules = modules;
|
|
245
|
+
this.index = index;
|
|
246
|
+
this.desired = modules.manifest;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create the initial roster and retain its entry identities for subsequent reconciliation.
|
|
250
|
+
* @param loader - Page Loader, already configured with the module system.
|
|
251
|
+
* @param manifest - Initial roster audited by the boot caller.
|
|
252
|
+
* @returns after initial entries and their activation settle; boot owns its activation audit.
|
|
253
|
+
*/
|
|
254
|
+
start(loader, manifest) {
|
|
255
|
+
if (this.loader !== void 0) throw new Error("client-modules: entries already started");
|
|
256
|
+
this.loader = loader;
|
|
257
|
+
this.desired = manifest;
|
|
258
|
+
loader.ctx.effect(() => () => {
|
|
259
|
+
this.stopped = true;
|
|
260
|
+
this.generation++;
|
|
261
|
+
return this.queue;
|
|
262
|
+
}, "client-modules: entry reconciliation");
|
|
263
|
+
return this.enqueue(async () => {
|
|
264
|
+
await Promise.all(this.desired.plugins.map(async ({ id }) => {
|
|
265
|
+
await this.create(loader, id);
|
|
266
|
+
}));
|
|
267
|
+
await loader.await();
|
|
268
|
+
for (const row of this.modules.manifest.modules) this.revisions.set(row.id, row.rev);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Validate and apply the latest full Host graph. Changed targets cancel obsolete mounts; identical targets share pending loads.
|
|
273
|
+
* @param graph - JSON-decoded graph received from the Host.
|
|
274
|
+
* @returns after the queued reconciliation; per-package failures remain available in {@link state}.
|
|
275
|
+
*/
|
|
276
|
+
sync(graph) {
|
|
277
|
+
const manifest = parseBootManifest(graph);
|
|
278
|
+
if (entryTargets(manifest) !== entryTargets(this.desired)) this.generation++;
|
|
279
|
+
this.desired = manifest;
|
|
280
|
+
const generation = this.generation;
|
|
281
|
+
return this.enqueue(() => this.reconcile(generation));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Retry failed entries against the latest graph, including an unchanged revision.
|
|
285
|
+
* @returns after retry settlement, with remaining errors in {@link state}.
|
|
286
|
+
*/
|
|
287
|
+
retry() {
|
|
288
|
+
const generation = ++this.generation;
|
|
289
|
+
return this.enqueue(() => this.reconcile(generation));
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Replace one entry's code in the same queue as graph updates; duplicate revisions are ignored.
|
|
293
|
+
* Entries missing after a failed import are reconciled; bootstrap replacement fails before teardown.
|
|
294
|
+
* @param id - Package id from a rebuilt frame.
|
|
295
|
+
* @param rev - Opaque revision selecting the rebuilt artifact.
|
|
296
|
+
* @returns after queued work; replacement errors reject, while per-package reconciliation errors remain in {@link state}.
|
|
297
|
+
*/
|
|
298
|
+
reload(id, rev) {
|
|
299
|
+
this.desired = {
|
|
300
|
+
...this.desired,
|
|
301
|
+
modules: this.desired.modules.map((row) => row.id === id ? {
|
|
302
|
+
...row,
|
|
303
|
+
rev
|
|
304
|
+
} : row)
|
|
305
|
+
};
|
|
306
|
+
return this.enqueue(async () => {
|
|
307
|
+
const desired = this.desired.modules.find((row) => row.id === id);
|
|
308
|
+
if (this.stopped || desired === void 0) return;
|
|
309
|
+
const entry = this.managed.get(id);
|
|
310
|
+
if (entry === void 0) {
|
|
311
|
+
this.modules.invalidate(id, desired.rev);
|
|
312
|
+
removeOwnedStyles(id);
|
|
313
|
+
await this.reconcile(this.generation);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (this.revisions.get(id) === rev) return;
|
|
317
|
+
this.publish({
|
|
318
|
+
syncing: true,
|
|
319
|
+
failures: this.snapshot.failures.filter((failure) => failure.id !== id)
|
|
320
|
+
});
|
|
321
|
+
await this.replace(entry, id, rev, this.generation);
|
|
322
|
+
this.publish({
|
|
323
|
+
syncing: false,
|
|
324
|
+
failures: this.snapshot.failures
|
|
325
|
+
});
|
|
326
|
+
}, id);
|
|
327
|
+
}
|
|
328
|
+
publish(snapshot) {
|
|
329
|
+
this.snapshot = snapshot;
|
|
330
|
+
for (const listener of [...this.listeners]) try {
|
|
331
|
+
listener();
|
|
332
|
+
} catch (error) {
|
|
333
|
+
console.error("client-modules: synchronization subscriber failed", error);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
enqueue(task, subject = "graph") {
|
|
337
|
+
const run = this.queue.then(task);
|
|
338
|
+
this.queue = run.then(() => void 0, (error) => {
|
|
339
|
+
this.publish({
|
|
340
|
+
syncing: false,
|
|
341
|
+
failures: [...this.snapshot.failures.filter((failure) => failure.id !== subject), {
|
|
342
|
+
id: subject,
|
|
343
|
+
message: String(error)
|
|
344
|
+
}]
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
return run;
|
|
348
|
+
}
|
|
349
|
+
current(generation) {
|
|
350
|
+
return !this.stopped && generation === this.generation;
|
|
351
|
+
}
|
|
352
|
+
/** Keep ownership even when Loader rejects a module's plugin exports after inserting its entry. */
|
|
353
|
+
async create(loader, id) {
|
|
354
|
+
const options = { name: id };
|
|
355
|
+
const entryId = loader.ensureId(options);
|
|
356
|
+
try {
|
|
357
|
+
await loader.create(options);
|
|
358
|
+
} finally {
|
|
359
|
+
this.managed.set(id, loader.resolve(entryId));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async replace(entry, id, rev, generation) {
|
|
363
|
+
this.index.invalidateForReplacement(id, rev);
|
|
364
|
+
await this.modules.prefetch(id);
|
|
365
|
+
if (!this.current(generation)) return;
|
|
366
|
+
await tearDownEntryFiber(entry);
|
|
367
|
+
removeOwnedStyles(id);
|
|
368
|
+
if (!this.current(generation)) return;
|
|
369
|
+
await this.modules.import(id, "", {});
|
|
370
|
+
if (!this.current(generation)) return;
|
|
371
|
+
await entry.refresh();
|
|
372
|
+
await entry.fiber?.await();
|
|
373
|
+
if (entry.fiber === void 0) throw new Error(`client-modules: ${id} import failed (see console)`);
|
|
374
|
+
this.revisions.set(id, rev);
|
|
375
|
+
}
|
|
376
|
+
async reconcile(generation) {
|
|
377
|
+
if (!this.current(generation)) return;
|
|
378
|
+
const loader = this.loader;
|
|
379
|
+
if (loader === void 0) throw new Error("client-modules: entries have not started");
|
|
380
|
+
const manifest = this.desired;
|
|
381
|
+
this.publish({
|
|
382
|
+
syncing: true,
|
|
383
|
+
failures: []
|
|
384
|
+
});
|
|
385
|
+
const failures = [];
|
|
386
|
+
this.index.update(manifest, this.managed.keys());
|
|
387
|
+
const wanted = new Set(manifest.plugins.map((row) => row.id));
|
|
388
|
+
for (const [id, entry] of this.managed) {
|
|
389
|
+
if (wanted.has(id)) continue;
|
|
390
|
+
const fiber = entry.fiber;
|
|
391
|
+
loader.remove(entry.id);
|
|
392
|
+
this.managed.delete(id);
|
|
393
|
+
this.revisions.delete(id);
|
|
394
|
+
while (fiber?.inertia !== void 0) await fiber.inertia;
|
|
395
|
+
}
|
|
396
|
+
for (const row of manifest.modules) {
|
|
397
|
+
if (!this.current(generation)) break;
|
|
398
|
+
try {
|
|
399
|
+
const entry = this.managed.get(row.id);
|
|
400
|
+
if (entry === void 0) {
|
|
401
|
+
await this.modules.prefetch(row.id);
|
|
402
|
+
if (!this.current(generation)) break;
|
|
403
|
+
await this.modules.import(row.id, "", {});
|
|
404
|
+
if (!this.current(generation)) break;
|
|
405
|
+
await this.create(loader, row.id);
|
|
406
|
+
this.revisions.set(row.id, row.rev);
|
|
407
|
+
} else if (this.revisions.get(row.id) !== row.rev) await this.replace(entry, row.id, row.rev, generation);
|
|
408
|
+
else if (entry.fiber === void 0) await this.replace(entry, row.id, row.rev, generation);
|
|
409
|
+
else if (entry.fiber.state === FAILED) entry.fiber.update(entry.options.config);
|
|
410
|
+
} catch (error) {
|
|
411
|
+
failures.push({
|
|
412
|
+
id: row.id,
|
|
413
|
+
message: String(error)
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
await loader.await();
|
|
418
|
+
for (const [id, entry] of this.managed) {
|
|
419
|
+
if (failures.some((failure) => failure.id === id)) continue;
|
|
420
|
+
if (entry.fiber?.state === ACTIVE) continue;
|
|
421
|
+
try {
|
|
422
|
+
if (entry.fiber === void 0) throw new Error(`client-modules: ${id} import failed (see console)`);
|
|
423
|
+
await entry.fiber.await();
|
|
424
|
+
failures.push({
|
|
425
|
+
id,
|
|
426
|
+
message: `client-modules: ${id} is waiting for activation`
|
|
427
|
+
});
|
|
428
|
+
} catch (error) {
|
|
429
|
+
failures.push({
|
|
430
|
+
id,
|
|
431
|
+
message: String(error)
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
this.index.prune([...loader.entries()].map((entry) => entry.options.name));
|
|
436
|
+
if (this.current(generation)) this.publish({
|
|
437
|
+
syncing: false,
|
|
438
|
+
failures
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
//#endregion
|
|
138
443
|
//#region lib/types/client/system.js
|
|
139
444
|
/**
|
|
140
445
|
* ClientModuleSystem — the implementation behind the {@link ClientModuleLoader}
|
|
@@ -162,6 +467,23 @@ window.__ModuleLoader__.load({
|
|
|
162
467
|
if (!/[?&]rev=[^&#]*/.test(url)) throw new Error(`client-modules: bundle URL ${url} has no revision`);
|
|
163
468
|
return url.replace(/([?&]rev=)[^&#]*/, `$1${encodeURIComponent(rev)}`);
|
|
164
469
|
}
|
|
470
|
+
const CLIENT_CHUNK = /^client\.[A-Za-z0-9][A-Za-z0-9._-]*\.js$/;
|
|
471
|
+
/** The message of a thrown value: an Error's message, anything else stringified. */
|
|
472
|
+
function describeError(error) {
|
|
473
|
+
return error instanceof Error ? error.message : String(error);
|
|
474
|
+
}
|
|
475
|
+
/** Internal module-table key for one package-local chunk. */
|
|
476
|
+
function chunkId(ownerId, fileName) {
|
|
477
|
+
return `${ownerId}/${fileName}`;
|
|
478
|
+
}
|
|
479
|
+
/** Resolve a sibling chunk against the package's one-resource URL and current revision. */
|
|
480
|
+
function chunkUrl(row, fileName, rev) {
|
|
481
|
+
const url = atRevision(row.url, rev);
|
|
482
|
+
const resourceStart = url.indexOf("/??");
|
|
483
|
+
const revisionStart = url.indexOf("&rev=", resourceStart + 3);
|
|
484
|
+
if ((resourceStart < 0 || revisionStart < 0 ? void 0 : url.slice(resourceStart + 3, revisionStart)) !== `${row.id}/client.js`) throw new Error(`client-modules: cannot resolve chunk ${JSON.stringify(fileName)} from bundle URL ${url}`);
|
|
485
|
+
return `${url.slice(0, resourceStart)}/${row.id}/${fileName}?${url.slice(revisionStart + 1)}`;
|
|
486
|
+
}
|
|
165
487
|
/**
|
|
166
488
|
* Claim and inventory the <style> tags a factory injected during
|
|
167
489
|
* materialization: preset-emitted tags arrive pre-tagged with data-plugin;
|
|
@@ -184,30 +506,48 @@ window.__ModuleLoader__.load({
|
|
|
184
506
|
var ClientModuleSystem = class {
|
|
185
507
|
version = "client";
|
|
186
508
|
manifest;
|
|
509
|
+
entries;
|
|
187
510
|
loadCache = /* @__PURE__ */ new Map();
|
|
188
511
|
seed;
|
|
189
512
|
factories = /* @__PURE__ */ new Map();
|
|
190
513
|
bootstrapIds = /* @__PURE__ */ new Set();
|
|
191
514
|
/** In-flight script transport per URL; every row in one batch shares it. */
|
|
192
515
|
pendingArrival = /* @__PURE__ */ new Map();
|
|
516
|
+
/** Owner generation captured by in-flight chunk requests and advanced on invalidation. */
|
|
517
|
+
generations = /* @__PURE__ */ new Map();
|
|
193
518
|
/** Single-resource combo URL selected by HMR after invalidating one row. */
|
|
194
|
-
|
|
519
|
+
reloadTargets = /* @__PURE__ */ new Map();
|
|
195
520
|
/** Materialization re-entrancy guard: factory-form CJS cannot deliver partial exports, so a cycle is fatal. */
|
|
196
521
|
materializing = /* @__PURE__ */ new Set();
|
|
197
522
|
graphRows = /* @__PURE__ */ new Map();
|
|
198
523
|
loadBundle;
|
|
524
|
+
/** Last import or prefetch failure per graph row, cleared by a later success or invalidation. */
|
|
525
|
+
importErrors = /* @__PURE__ */ new Map();
|
|
526
|
+
/** Batch URLs whose transport or execution already failed; rows still missing from them go straight to their one-resource URL. */
|
|
527
|
+
failedBundleUrls = /* @__PURE__ */ new Set();
|
|
528
|
+
/** Every URL whose script has executed once; a batch among them is never requested again. */
|
|
529
|
+
executedBundleUrls = /* @__PURE__ */ new Set();
|
|
199
530
|
/**
|
|
200
531
|
* Build the module system over the parsed boot rows.
|
|
201
532
|
* @param options - Parsed graph, platform seed, bootstrap module, registration facade, and transport.
|
|
202
533
|
*/
|
|
203
534
|
constructor(options) {
|
|
204
535
|
this.manifest = options.manifest;
|
|
536
|
+
this.entries = new ClientEntries(this, {
|
|
537
|
+
update: (manifest, managed) => {
|
|
538
|
+
this.updateManifest(manifest, managed);
|
|
539
|
+
},
|
|
540
|
+
invalidateForReplacement: (id, rev) => {
|
|
541
|
+
if (this.bootstrapIds.has(id)) throw new Error(`client-modules: replacing bootstrap module ${id} requires a page reload`);
|
|
542
|
+
this.invalidate(id, rev);
|
|
543
|
+
},
|
|
544
|
+
prune: (roots) => {
|
|
545
|
+
this.prune(roots);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
205
548
|
this.seed = new Map(Object.entries(options.staticModules));
|
|
206
549
|
this.loadBundle = options.loadBundle ?? defaultLoadBundle;
|
|
207
|
-
for (const row of options.manifest.modules)
|
|
208
|
-
if (this.graphRows.has(row.id)) throw new Error(`client-modules: duplicate graph entry "${row.id}"`);
|
|
209
|
-
this.graphRows.set(row.id, row);
|
|
210
|
-
}
|
|
550
|
+
for (const row of options.manifest.modules) this.graphRows.set(row.id, row);
|
|
211
551
|
const bootstrapId = stripClientSuffix(options.bootstrapModule.id);
|
|
212
552
|
this.bootstrapIds.add(bootstrapId);
|
|
213
553
|
this.loadCache.set(bootstrapId, {
|
|
@@ -227,27 +567,78 @@ window.__ModuleLoader__.load({
|
|
|
227
567
|
}
|
|
228
568
|
/** Register one bundle factory, rejecting a script that executes twice without invalidation. */
|
|
229
569
|
register(registration) {
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
|
|
570
|
+
const ownerId = stripClientSuffix(registration.id);
|
|
571
|
+
if (registration.chunk !== void 0 && !CLIENT_CHUNK.test(registration.chunk)) throw new Error(`client-modules: invalid package-local chunk ${JSON.stringify(registration.chunk)}`);
|
|
572
|
+
const id = registration.chunk === void 0 ? ownerId : chunkId(ownerId, registration.chunk);
|
|
573
|
+
if (this.bootstrapIds.has(id) || this.factories.has(id)) {
|
|
574
|
+
const registrationName = registration.chunk === void 0 ? registration.id : id;
|
|
575
|
+
throw new Error(`client-modules: duplicate factory registration for "${registrationName}" (bundle executed twice without invalidate?)`);
|
|
576
|
+
}
|
|
577
|
+
this.factories.set(id, {
|
|
578
|
+
factory: registration.factory,
|
|
579
|
+
rev: this.reloadTargets.get(ownerId)?.rev ?? this.graphRows.get(ownerId)?.rev
|
|
580
|
+
});
|
|
233
581
|
}
|
|
234
|
-
/**
|
|
235
|
-
|
|
236
|
-
const { id } = row;
|
|
237
|
-
if (this.loadCache.has(id) || this.factories.has(id)) return Promise.resolve();
|
|
238
|
-
const reloadUrl = this.reloadUrls.get(id);
|
|
239
|
-
const url = reloadUrl ?? row.initialUrl;
|
|
582
|
+
/** Run one bundle transport per URL; every row waiting on the same URL shares the in-flight request. */
|
|
583
|
+
loadShared(url) {
|
|
240
584
|
let transport = this.pendingArrival.get(url);
|
|
241
585
|
if (transport === void 0) {
|
|
242
|
-
transport = this.loadBundle(url).
|
|
586
|
+
transport = this.loadBundle(url).then(() => {
|
|
587
|
+
this.executedBundleUrls.add(url);
|
|
588
|
+
}).finally(() => {
|
|
243
589
|
this.pendingArrival.delete(url);
|
|
244
590
|
});
|
|
245
591
|
this.pendingArrival.set(url, transport);
|
|
246
592
|
}
|
|
247
|
-
return transport
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
593
|
+
return transport;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Load one graph row so its factory is registered (idempotent per in-flight
|
|
597
|
+
* arrival). A batch script is one classic script that registers every
|
|
598
|
+
* package in sequence, and {@link register} rejects a second registration,
|
|
599
|
+
* so the two failure kinds differ: a transport failure (`error` event, nothing
|
|
600
|
+
* executed) is retried once on the same URL; a script that loaded without
|
|
601
|
+
* registering this row (a parse error registered nothing, or a runtime throw
|
|
602
|
+
* stopped it after registering others) is never re-executed, because a replay
|
|
603
|
+
* would stop again at the first duplicate registration; that holds even when
|
|
604
|
+
* the row that first imports from the batch is one it did register, because
|
|
605
|
+
* every executed batch URL is remembered. Either way the row then falls back
|
|
606
|
+
* to its own one-resource URL, which the Host serves for every package, so one
|
|
607
|
+
* failed batch costs at most three requests per missing row and never fails
|
|
608
|
+
* the rows that were registered.
|
|
609
|
+
*/
|
|
610
|
+
async arrive(row) {
|
|
611
|
+
const { id } = row;
|
|
612
|
+
if (this.loadCache.has(id) || this.factories.has(id)) return;
|
|
613
|
+
const reload = this.reloadTargets.get(id);
|
|
614
|
+
const preferred = reload?.url ?? row.initialUrl;
|
|
615
|
+
const fallback = reload === void 0 && row.url !== preferred ? row.url : void 0;
|
|
616
|
+
const failures = [];
|
|
617
|
+
const attempt = async (url) => {
|
|
618
|
+
try {
|
|
619
|
+
await this.loadShared(url);
|
|
620
|
+
} catch (error) {
|
|
621
|
+
failures.push(`${url}: ${describeError(error)}`);
|
|
622
|
+
return "transport-failed";
|
|
623
|
+
}
|
|
624
|
+
if (this.factories.has(id)) return "registered";
|
|
625
|
+
failures.push(`${url}: loaded without registering "${id}" via __ModuleLoader__.load`);
|
|
626
|
+
return "not-registered";
|
|
627
|
+
};
|
|
628
|
+
let outcome = "transport-failed";
|
|
629
|
+
if (this.failedBundleUrls.has(preferred)) failures.push(`${preferred}: skipped after an earlier failure of this bundle`);
|
|
630
|
+
else if (fallback !== void 0 && this.executedBundleUrls.has(preferred)) {
|
|
631
|
+
failures.push(`${preferred}: already executed without registering "${id}"`);
|
|
632
|
+
outcome = "not-registered";
|
|
633
|
+
this.failedBundleUrls.add(preferred);
|
|
634
|
+
} else {
|
|
635
|
+
outcome = await attempt(preferred);
|
|
636
|
+
if (outcome === "transport-failed") outcome = await attempt(preferred);
|
|
637
|
+
if (outcome !== "registered" && fallback !== void 0) this.failedBundleUrls.add(preferred);
|
|
638
|
+
}
|
|
639
|
+
if (outcome !== "registered" && fallback !== void 0) outcome = await attempt(fallback);
|
|
640
|
+
if (outcome !== "registered") throw new Error(`client-modules: could not load "${id}": ${failures.join("; ")}`);
|
|
641
|
+
if (reload !== void 0 && this.reloadTargets.get(id) === reload) this.reloadTargets.delete(id);
|
|
251
642
|
}
|
|
252
643
|
/** Register each injected package and unresolved dynamic request before its consumer. */
|
|
253
644
|
async arriveGraphRow(row, open = [], visited = /* @__PURE__ */ new Set()) {
|
|
@@ -260,16 +651,24 @@ window.__ModuleLoader__.load({
|
|
|
260
651
|
const id = stripClientSuffix(request);
|
|
261
652
|
if (this.seed.has(request) || this.loadCache.has(id)) continue;
|
|
262
653
|
const dependency = this.graphRows.get(id);
|
|
263
|
-
if (dependency !== void 0) await this.
|
|
654
|
+
if (dependency !== void 0) await this.arriveDependency(row.id, dependency, next, visited);
|
|
264
655
|
}
|
|
265
656
|
for (const packageName of row.inject) {
|
|
266
657
|
const dependency = this.graphRows.get(packageName);
|
|
267
|
-
if (dependency !== void 0) await this.
|
|
658
|
+
if (dependency !== void 0) await this.arriveDependency(row.id, dependency, [], visited);
|
|
268
659
|
}
|
|
269
660
|
await this.arrive(row);
|
|
270
661
|
}
|
|
662
|
+
/** Arrive one dependency, naming the consumer it failed for so a cascade reads as a chain, not as 44 unrelated failures. */
|
|
663
|
+
async arriveDependency(consumerId, dependency, open, visited) {
|
|
664
|
+
try {
|
|
665
|
+
await this.arriveGraphRow(dependency, open, visited);
|
|
666
|
+
} catch (error) {
|
|
667
|
+
throw new Error(`client-modules: "${consumerId}" not loaded because dependency "${dependency.id}" failed: ${describeError(error)}`, { cause: error });
|
|
668
|
+
}
|
|
669
|
+
}
|
|
271
670
|
/** Materialize a registered factory (synchronous; memoized in loadCache). */
|
|
272
|
-
materialize(id) {
|
|
671
|
+
materialize(id, ownerId = id) {
|
|
273
672
|
const existing = this.loadCache.get(id);
|
|
274
673
|
if (existing !== void 0) return existing;
|
|
275
674
|
const registered = this.factories.get(id);
|
|
@@ -281,24 +680,22 @@ window.__ModuleLoader__.load({
|
|
|
281
680
|
const edges = /* @__PURE__ */ new Set();
|
|
282
681
|
const record = {
|
|
283
682
|
id,
|
|
284
|
-
exports: registered(this.makeRequire(edges)),
|
|
285
|
-
styles: claimStyles(
|
|
683
|
+
exports: registered.factory(this.makeRequire(ownerId, edges)),
|
|
684
|
+
styles: claimStyles(ownerId),
|
|
286
685
|
edges
|
|
287
686
|
};
|
|
288
687
|
this.loadCache.set(id, record);
|
|
289
688
|
return record;
|
|
689
|
+
} catch (error) {
|
|
690
|
+
removeOwnedStyles(ownerId);
|
|
691
|
+
throw error;
|
|
290
692
|
} finally {
|
|
291
693
|
this.materializing.delete(id);
|
|
292
694
|
}
|
|
293
695
|
}
|
|
294
|
-
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
* from here; an external dynamic package must have arrived before its
|
|
298
|
-
* consumer materializes.
|
|
299
|
-
*/
|
|
300
|
-
makeRequire(edges) {
|
|
301
|
-
return (spec) => {
|
|
696
|
+
/** Build the synchronous module-table require and its asynchronous chunk operation. */
|
|
697
|
+
makeRequire(ownerId, edges) {
|
|
698
|
+
const require = (spec) => {
|
|
302
699
|
edges.add(spec);
|
|
303
700
|
if (this.seed.has(spec)) return this.seed.get(spec);
|
|
304
701
|
const id = stripClientSuffix(spec);
|
|
@@ -307,6 +704,41 @@ window.__ModuleLoader__.load({
|
|
|
307
704
|
if (this.factories.has(id)) return this.materialize(id).exports;
|
|
308
705
|
throw new Error(`client-modules: require("${spec}") missed the module table — not a platform seed word, not a materialized module, and no registered package factory (a build-time externals drift, or a dynamic dependency that did not arrive)`);
|
|
309
706
|
};
|
|
707
|
+
require.async = async (spec) => {
|
|
708
|
+
edges.add(spec);
|
|
709
|
+
if (!spec.startsWith("./")) return await this.import(spec);
|
|
710
|
+
const fileName = spec.slice(2);
|
|
711
|
+
if (!CLIENT_CHUNK.test(fileName)) throw new Error(`client-modules: invalid relative chunk request ${JSON.stringify(spec)}`);
|
|
712
|
+
return await this.importChunk(ownerId, fileName);
|
|
713
|
+
};
|
|
714
|
+
return require;
|
|
715
|
+
}
|
|
716
|
+
/** Load, register, and materialize one package-local dynamic chunk. */
|
|
717
|
+
async importChunk(ownerId, fileName) {
|
|
718
|
+
const id = chunkId(ownerId, fileName);
|
|
719
|
+
const existing = this.loadCache.get(id);
|
|
720
|
+
if (existing !== void 0) return existing.exports;
|
|
721
|
+
if (!this.factories.has(id)) {
|
|
722
|
+
const generation = this.generations.get(ownerId) ?? 0;
|
|
723
|
+
const row = this.graphRows.get(ownerId);
|
|
724
|
+
if (row === void 0) throw new Error(`client-modules: chunk owner "${ownerId}" is not a boot graph entry`);
|
|
725
|
+
const url = chunkUrl(row, fileName, this.factories.get(ownerId)?.rev ?? this.reloadTargets.get(ownerId)?.rev ?? row.rev);
|
|
726
|
+
let transport = this.pendingArrival.get(url);
|
|
727
|
+
if (transport === void 0) {
|
|
728
|
+
transport = this.loadBundle(url).finally(() => {
|
|
729
|
+
this.pendingArrival.delete(url);
|
|
730
|
+
});
|
|
731
|
+
this.pendingArrival.set(url, transport);
|
|
732
|
+
}
|
|
733
|
+
await transport;
|
|
734
|
+
if ((this.generations.get(ownerId) ?? 0) !== generation) {
|
|
735
|
+
this.factories.delete(id);
|
|
736
|
+
this.loadCache.delete(id);
|
|
737
|
+
return await this.importChunk(ownerId, fileName);
|
|
738
|
+
}
|
|
739
|
+
if (!this.factories.has(id)) throw new Error(`client-modules: bundle ${url} loaded without registering "${id}" via __ModuleLoader__.load`);
|
|
740
|
+
}
|
|
741
|
+
return this.materialize(id, ownerId).exports;
|
|
310
742
|
}
|
|
311
743
|
async import(specifier) {
|
|
312
744
|
if (this.seed.has(specifier)) return this.seed.get(specifier);
|
|
@@ -314,61 +746,137 @@ window.__ModuleLoader__.load({
|
|
|
314
746
|
const existing = this.loadCache.get(id);
|
|
315
747
|
if (existing !== void 0) return existing.exports;
|
|
316
748
|
const row = this.graphRows.get(id);
|
|
317
|
-
if (row
|
|
318
|
-
|
|
319
|
-
|
|
749
|
+
if (row === void 0) {
|
|
750
|
+
if (this.factories.has(id)) return this.materialize(id).exports;
|
|
751
|
+
throw new Error(`client-modules: cannot resolve "${specifier}" — not a seed word, not a materialized module, and not a row in the boot graph (the runtime mirror of the bundle purity gate)`);
|
|
752
|
+
}
|
|
753
|
+
return this.recordingImportError(id, async () => {
|
|
754
|
+
await this.arriveGraphRow(row);
|
|
755
|
+
return this.materialize(id).exports;
|
|
756
|
+
});
|
|
320
757
|
}
|
|
321
758
|
async prefetch(id) {
|
|
322
759
|
const normalized = stripClientSuffix(id);
|
|
323
760
|
if (this.loadCache.has(normalized)) return;
|
|
324
761
|
const row = this.graphRows.get(normalized);
|
|
325
762
|
if (row === void 0) throw new Error(`client-modules: prefetch("${id}") — not a graph entry`);
|
|
326
|
-
await this.arriveGraphRow(row);
|
|
763
|
+
await this.recordingImportError(normalized, () => this.arriveGraphRow(row));
|
|
764
|
+
}
|
|
765
|
+
importError(id) {
|
|
766
|
+
return this.importErrors.get(stripClientSuffix(id));
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Run one graph-row operation, recording its failure for the boot audit and
|
|
770
|
+
* clearing the record on success. Arrival and materialization both run in
|
|
771
|
+
* here, so a factory that throws is recorded as well as a bundle that never
|
|
772
|
+
* arrived; the Loader only sees a missing fiber either way.
|
|
773
|
+
*/
|
|
774
|
+
async recordingImportError(id, operation) {
|
|
775
|
+
try {
|
|
776
|
+
const result = await operation();
|
|
777
|
+
this.importErrors.delete(id);
|
|
778
|
+
return result;
|
|
779
|
+
} catch (error) {
|
|
780
|
+
this.importErrors.set(id, error instanceof Error ? error : new Error(describeError(error)));
|
|
781
|
+
throw error;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
/** Refresh descriptors and unowned factory revisions before any entry imports its dependencies. */
|
|
785
|
+
updateManifest(manifest, managed) {
|
|
786
|
+
for (const id of this.bootstrapIds) if (this.manifest.modules.some((row) => row.id === id) && !manifest.modules.some((row) => row.id === id)) throw new Error(`client-modules: removing bootstrap module ${id} requires a page reload`);
|
|
787
|
+
const owned = new Set(managed);
|
|
788
|
+
for (const row of manifest.modules) {
|
|
789
|
+
this.graphRows.set(row.id, {
|
|
790
|
+
...row,
|
|
791
|
+
initialUrl: row.url
|
|
792
|
+
});
|
|
793
|
+
const cachedRevision = this.factories.get(row.id)?.rev ?? this.reloadTargets.get(row.id)?.rev;
|
|
794
|
+
if (!owned.has(row.id) && cachedRevision !== void 0 && cachedRevision !== row.rev) {
|
|
795
|
+
this.invalidate(row.id, row.rev);
|
|
796
|
+
removeOwnedStyles(row.id);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
this.manifest = manifest;
|
|
800
|
+
}
|
|
801
|
+
/** Retain live Loader modules and their transitive requests before evicting unreferenced graph records. */
|
|
802
|
+
prune(roots) {
|
|
803
|
+
const retained = new Set(this.bootstrapIds);
|
|
804
|
+
const visit = (specifier) => {
|
|
805
|
+
const id = stripClientSuffix(specifier);
|
|
806
|
+
if (retained.has(id)) return;
|
|
807
|
+
retained.add(id);
|
|
808
|
+
const row = this.graphRows.get(id);
|
|
809
|
+
for (const request of [
|
|
810
|
+
...row?.external ?? [],
|
|
811
|
+
...row?.inject ?? [],
|
|
812
|
+
...this.loadCache.get(id)?.edges ?? []
|
|
813
|
+
]) visit(request);
|
|
814
|
+
};
|
|
815
|
+
for (const row of this.manifest.modules) visit(row.id);
|
|
816
|
+
for (const id of roots) visit(id);
|
|
817
|
+
for (const id of this.graphRows.keys()) {
|
|
818
|
+
if (retained.has(id)) continue;
|
|
819
|
+
this.graphRows.delete(id);
|
|
820
|
+
this.invalidate(id);
|
|
821
|
+
removeOwnedStyles(id);
|
|
822
|
+
}
|
|
327
823
|
}
|
|
328
824
|
invalidate(id, rev) {
|
|
329
825
|
const normalized = stripClientSuffix(id);
|
|
330
826
|
if (this.bootstrapIds.has(normalized)) return;
|
|
827
|
+
this.importErrors.delete(normalized);
|
|
828
|
+
this.generations.set(normalized, (this.generations.get(normalized) ?? 0) + 1);
|
|
331
829
|
const row = this.graphRows.get(normalized);
|
|
332
|
-
if (row !== void 0)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
830
|
+
if (row !== void 0) {
|
|
831
|
+
const revision = rev ?? row.rev;
|
|
832
|
+
this.reloadTargets.set(normalized, {
|
|
833
|
+
url: atRevision(row.url, revision),
|
|
834
|
+
rev: revision
|
|
835
|
+
});
|
|
836
|
+
} else this.reloadTargets.delete(normalized);
|
|
837
|
+
for (const key of this.factories.keys()) if (key === normalized || key.startsWith(`${normalized}/client.`)) this.factories.delete(key);
|
|
838
|
+
for (const key of this.loadCache.keys()) if (key === normalized || key.startsWith(`${normalized}/client.`)) this.loadCache.delete(key);
|
|
336
839
|
}
|
|
337
840
|
};
|
|
338
841
|
//#endregion
|
|
339
842
|
//#region lib/types/client/index.js
|
|
340
|
-
let moduleSystem;
|
|
341
843
|
/**
|
|
342
844
|
* Build the live module system from the HTML facade's materialized modules bundle.
|
|
343
845
|
* @param target - Stable registration facade whose pending queue becomes the live sink.
|
|
344
846
|
* @param bootstrapModule - This bundle's id and already-materialized exports.
|
|
345
847
|
* @param options - Raw boot graph, platform seed, and optional bundle transport.
|
|
346
|
-
* @returns The created module system
|
|
848
|
+
* @returns The created module system.
|
|
347
849
|
*/
|
|
348
850
|
function createClientModuleSystem(target, bootstrapModule, options) {
|
|
349
|
-
|
|
851
|
+
return new ClientModuleSystem({
|
|
350
852
|
manifest: parseBootManifest(options.boot),
|
|
351
853
|
staticModules: options.staticModules,
|
|
352
854
|
registrationTarget: target,
|
|
353
855
|
bootstrapModule,
|
|
354
856
|
...options.loadBundle === void 0 ? {} : { loadBundle: options.loadBundle }
|
|
355
857
|
});
|
|
356
|
-
return moduleSystem;
|
|
357
858
|
}
|
|
859
|
+
/** Required service: the Loader whose internal module system this plugin publishes. */
|
|
860
|
+
const inject = ["loader"];
|
|
358
861
|
/**
|
|
359
862
|
* Enroll the kernel-built module system as `ctx.modules`.
|
|
360
863
|
* @param ctx - client root context.
|
|
361
864
|
*/
|
|
362
865
|
function apply(ctx) {
|
|
363
|
-
|
|
364
|
-
|
|
866
|
+
const modules = ctx.loader.internal;
|
|
867
|
+
if (modules?.version !== "client") throw new Error("client-modules: the Loader has no client module system");
|
|
868
|
+
ctx.reflect.provide("modules", modules);
|
|
365
869
|
}
|
|
366
870
|
//#endregion
|
|
367
871
|
exports.ClientModuleSystem = ClientModuleSystem;
|
|
368
872
|
exports.apply = apply;
|
|
369
873
|
exports.createClientModuleSystem = createClientModuleSystem;
|
|
874
|
+
exports.exactPackageSpecifier = exactPackageSpecifier;
|
|
875
|
+
exports.inject = inject;
|
|
370
876
|
exports.parseBootManifest = parseBootManifest;
|
|
877
|
+
exports.parseDshClient = parseDshClient;
|
|
371
878
|
exports.stripClientSuffix = stripClientSuffix;
|
|
879
|
+
exports.tearDownEntryFiber = tearDownEntryFiber;
|
|
372
880
|
return module.exports;
|
|
373
881
|
}
|
|
374
882
|
});
|