dsh-edge 0.1.0
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +183 -0
- package/README.zh.md +183 -0
- package/THIRD_PARTY_NOTICES.md +199 -0
- package/dist/_headers +3 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/index-C-1AiF3k.js +112 -0
- package/dist/assets/index-CSGf6Qzd.css +1 -0
- package/dist/assets/langs/c-BIGW1oBm.js +2 -0
- package/dist/assets/langs/cpp-DIPi6g--.js +2 -0
- package/dist/assets/langs/csharp-DSvCPggb.js +2 -0
- package/dist/assets/langs/css-CLj8gQPS.js +2 -0
- package/dist/assets/langs/go-C27-OAKa.js +2 -0
- package/dist/assets/langs/html-CfGypltT.js +2 -0
- package/dist/assets/langs/ini-BEwlwnbL.js +2 -0
- package/dist/assets/langs/java-CylS5w8V.js +2 -0
- package/dist/assets/langs/kotlin-BdnUsdx6.js +2 -0
- package/dist/assets/langs/less-B1dDrJ26.js +2 -0
- package/dist/assets/langs/lua-BaeVxFsk.js +2 -0
- package/dist/assets/langs/markdown-Cvjx9yec.js +2 -0
- package/dist/assets/langs/mdx-Cmh6b_Ma.js +2 -0
- package/dist/assets/langs/php-D-uCvoST.js +2 -0
- package/dist/assets/langs/python-B6aJPvgy.js +2 -0
- package/dist/assets/langs/ruby-DEItuUFs.js +2 -0
- package/dist/assets/langs/rust-B1yitclQ.js +2 -0
- package/dist/assets/langs/scss-D5BDwBP9.js +2 -0
- package/dist/assets/langs/sql-CRqJ_cUM.js +2 -0
- package/dist/assets/langs/swift-D82vCrfD.js +2 -0
- package/dist/assets/langs/toml-vGWfd6FD.js +2 -0
- package/dist/assets/langs/xml-sdJ4AIDG.js +2 -0
- package/dist/assets/langs/yaml-Buea-lGh.js +2 -0
- package/dist/assets/vendor-Cjbwl5VI.js +411 -0
- package/dist/assets/vendor-CjyC-hUb.css +1 -0
- package/dist/favicon.svg +8 -0
- package/dist/index.html +35 -0
- package/dist/manifest.webmanifest +16 -0
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +420 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +5937 -0
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +10207 -0
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +1231 -0
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +259 -0
- package/dist/plugins/@deepseek-ai/dsh-client-runtime/client.js +10539 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1725 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +1116 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +9832 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +373 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-edge/client.js +549 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +859 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +280 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +456 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +804 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +461 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +254 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +609 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +292 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +327 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +710 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +1312 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +1630 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +7370 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +700 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +474 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2426 -0
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +1372 -0
- package/package.json +97 -0
- package/scripts/assemble-web.mjs +230 -0
- package/scripts/bundle-size.d.mts +2 -0
- package/scripts/bundle-size.mjs +26 -0
- package/scripts/bundle.mjs +53 -0
- package/scripts/cli.d.mts +39 -0
- package/scripts/cli.mjs +496 -0
- package/scripts/install.d.mts +149 -0
- package/scripts/install.mjs +989 -0
- package/scripts/legal-files.mjs +24 -0
- package/scripts/verify-packed.mjs +32 -0
- package/scripts/wrangler-config.d.mts +18 -0
- package/scripts/wrangler-config.mjs +84 -0
- package/src/agent.ts +119 -0
- package/src/auth.ts +352 -0
- package/src/deepseek.ts +231 -0
- package/src/deployment.ts +147 -0
- package/src/direct-shell-core-empty.ts +10 -0
- package/src/direct-shell-protocol.ts +5 -0
- package/src/direct-shell.ts +341 -0
- package/src/do-session-persistence.ts +1064 -0
- package/src/edge-api.ts +796 -0
- package/src/edge-credentials.ts +56 -0
- package/src/edge-remotes.ts +41 -0
- package/src/edge-workspace-store.ts +339 -0
- package/src/http.ts +212 -0
- package/src/index.ts +196 -0
- package/src/instance.ts +1007 -0
- package/src/isolated-direct-shell-unavailable.ts +11 -0
- package/src/protocol.ts +39 -0
- package/src/release.ts +9 -0
- package/src/session-store.ts +1110 -0
- package/src/sse.ts +86 -0
- package/src/web-search.ts +38 -0
- package/src/workspace.ts +270 -0
- package/wrangler.jsonc +56 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@deepseek-ai/dsh-client-modules",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region lib/types/client/system.js
|
|
8
|
+
/** Default bundle-load hook: same-origin external classic script. */
|
|
9
|
+
const defaultLoadBundle = (url) => new Promise((resolve, reject) => {
|
|
10
|
+
const el = document.createElement("script");
|
|
11
|
+
el.async = true;
|
|
12
|
+
el.src = url;
|
|
13
|
+
el.addEventListener("load", () => {
|
|
14
|
+
el.remove();
|
|
15
|
+
resolve();
|
|
16
|
+
}, { once: true });
|
|
17
|
+
el.addEventListener("error", () => {
|
|
18
|
+
el.remove();
|
|
19
|
+
reject(/* @__PURE__ */ new Error(`client-modules: bundle script ${url} failed to load`));
|
|
20
|
+
}, { once: true });
|
|
21
|
+
document.head.append(el);
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* A plugin bundle IS its package's client half: `<id>/client` (the exports
|
|
25
|
+
* subpath external bundles emit) and the bare graph id name the same
|
|
26
|
+
* exports, so table lookups normalize the suffix away.
|
|
27
|
+
*/
|
|
28
|
+
const stripClientSuffix = (spec) => spec.endsWith("/client") ? spec.slice(0, -7) : spec;
|
|
29
|
+
/**
|
|
30
|
+
* Claim and inventory the <style> tags a factory injected during
|
|
31
|
+
* materialization: preset-emitted tags arrive pre-tagged with data-plugin;
|
|
32
|
+
* any untagged tag is claimed for the materializing plugin (HMR bookkeeping).
|
|
33
|
+
*/
|
|
34
|
+
const claimStyles = (id) => {
|
|
35
|
+
if (typeof document === "undefined") return [];
|
|
36
|
+
for (const el of document.querySelectorAll("style:not([data-plugin])")) el.setAttribute("data-plugin", id);
|
|
37
|
+
const owned = [];
|
|
38
|
+
for (const el of document.querySelectorAll(`style[data-plugin=${JSON.stringify(id)}]`)) owned.push(el.getAttribute("data-plugin-css") ?? id);
|
|
39
|
+
return owned;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The client module system: state tables plus the arrival/materialization
|
|
43
|
+
* machinery implementing {@link ClientModuleLoader} (whose members carry the
|
|
44
|
+
* contract documentation). Construction indexes the boot rows and installs the
|
|
45
|
+
* `window.__ModuleLoader__` registration sink — once per page.
|
|
46
|
+
*/
|
|
47
|
+
var ClientModuleSystem = class {
|
|
48
|
+
version = "client";
|
|
49
|
+
loadCache = /* @__PURE__ */ new Map();
|
|
50
|
+
seed;
|
|
51
|
+
statics = /* @__PURE__ */ new Map();
|
|
52
|
+
factories = /* @__PURE__ */ new Map();
|
|
53
|
+
/** In-flight prefetch (script load) per id; concurrent callers share it. */
|
|
54
|
+
pendingArrival = /* @__PURE__ */ new Map();
|
|
55
|
+
/** Materialization re-entrancy guard: factory-form CJS cannot deliver partial exports, so a cycle is fatal. */
|
|
56
|
+
materializing = /* @__PURE__ */ new Set();
|
|
57
|
+
graphRows = /* @__PURE__ */ new Map();
|
|
58
|
+
loadBundle;
|
|
59
|
+
/**
|
|
60
|
+
* Build the module system over the parsed boot rows.
|
|
61
|
+
* @param options - Module rows, module-table staticModules, and bundle-load hook.
|
|
62
|
+
*/
|
|
63
|
+
constructor(options) {
|
|
64
|
+
this.seed = new Map(Object.entries(options.staticModules));
|
|
65
|
+
this.loadBundle = options.loadBundle ?? defaultLoadBundle;
|
|
66
|
+
for (const row of options.modules) {
|
|
67
|
+
if (this.graphRows.has(row.id)) throw new Error(`client-modules: duplicate graph entry "${row.id}"`);
|
|
68
|
+
this.graphRows.set(row.id, row);
|
|
69
|
+
}
|
|
70
|
+
const win = globalThis;
|
|
71
|
+
if (win.__ModuleLoader__ !== void 0) throw new Error("client-modules: window.__ModuleLoader__ already installed (double boot?)");
|
|
72
|
+
win.__ModuleLoader__ = { load: (handoff) => {
|
|
73
|
+
if (this.factories.has(handoff.id)) throw new Error(`client-modules: duplicate factory registration for "${handoff.id}" (bundle executed twice without invalidate?)`);
|
|
74
|
+
this.factories.set(handoff.id, handoff.factory);
|
|
75
|
+
} };
|
|
76
|
+
}
|
|
77
|
+
/** Load one graph row so its factory is registered (idempotent per in-flight arrival). */
|
|
78
|
+
arrive(row) {
|
|
79
|
+
const { id, url } = row;
|
|
80
|
+
const pending = this.pendingArrival.get(id);
|
|
81
|
+
if (pending !== void 0) return pending;
|
|
82
|
+
if (this.factories.has(id)) return Promise.resolve();
|
|
83
|
+
const task = this.loadBundle(url).then(() => {
|
|
84
|
+
if (!this.factories.has(id)) throw new Error(`client-modules: bundle ${url} loaded without registering "${id}" via __ModuleLoader__.load`);
|
|
85
|
+
}).finally(() => {
|
|
86
|
+
this.pendingArrival.delete(id);
|
|
87
|
+
});
|
|
88
|
+
this.pendingArrival.set(id, task);
|
|
89
|
+
return task;
|
|
90
|
+
}
|
|
91
|
+
/** Materialize a registered factory (synchronous; memoized in loadCache). */
|
|
92
|
+
materialize(id) {
|
|
93
|
+
const existing = this.loadCache.get(id);
|
|
94
|
+
if (existing !== void 0) return existing;
|
|
95
|
+
const registered = this.factories.get(id);
|
|
96
|
+
/* v8 ignore next -- callers check the factory branch before dispatching here. */
|
|
97
|
+
if (registered === void 0) throw new Error(`client-modules: no registered factory for "${id}"`);
|
|
98
|
+
if (this.materializing.has(id)) throw new Error(`client-modules: require cycle through "${id}" (factory-form CJS cannot deliver partial exports)`);
|
|
99
|
+
this.materializing.add(id);
|
|
100
|
+
try {
|
|
101
|
+
const edges = /* @__PURE__ */ new Set();
|
|
102
|
+
const record = {
|
|
103
|
+
id,
|
|
104
|
+
exports: registered(this.makeRequire(edges)),
|
|
105
|
+
styles: claimStyles(id),
|
|
106
|
+
edges
|
|
107
|
+
};
|
|
108
|
+
this.loadCache.set(id, record);
|
|
109
|
+
return record;
|
|
110
|
+
} finally {
|
|
111
|
+
this.materializing.delete(id);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The synchronous require answered to factories: seed → static → memoized
|
|
116
|
+
* record → registered factory (recursive materialization — this is what
|
|
117
|
+
* makes load order self-resolving). Fetching is async and therefore
|
|
118
|
+
* unreachable from here; an unregistered plugin specifier is loud (and a
|
|
119
|
+
* cross-plugin value import is already a build error upstream).
|
|
120
|
+
*/
|
|
121
|
+
makeRequire(edges) {
|
|
122
|
+
return (spec) => {
|
|
123
|
+
edges.add(spec);
|
|
124
|
+
if (this.seed.has(spec)) return this.seed.get(spec);
|
|
125
|
+
if (this.statics.has(spec)) return this.statics.get(spec);
|
|
126
|
+
const id = stripClientSuffix(spec);
|
|
127
|
+
const record = this.loadCache.get(id);
|
|
128
|
+
if (record !== void 0) return record.exports;
|
|
129
|
+
if (this.factories.has(id)) return this.materialize(id).exports;
|
|
130
|
+
throw new Error(`client-modules: require("${spec}") missed the module table — not a platform seed word, not a shell-own module, and no registered factory (a build-time externals drift, or a forbidden cross-plugin value import)`);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async import(specifier) {
|
|
134
|
+
if (this.seed.has(specifier)) return this.seed.get(specifier);
|
|
135
|
+
const existing = this.loadCache.get(specifier);
|
|
136
|
+
if (existing !== void 0) return existing.exports;
|
|
137
|
+
if (this.statics.has(specifier)) {
|
|
138
|
+
const exports = this.statics.get(specifier);
|
|
139
|
+
this.loadCache.set(specifier, {
|
|
140
|
+
id: specifier,
|
|
141
|
+
exports,
|
|
142
|
+
styles: [],
|
|
143
|
+
edges: /* @__PURE__ */ new Set()
|
|
144
|
+
});
|
|
145
|
+
return exports;
|
|
146
|
+
}
|
|
147
|
+
if (!this.factories.has(specifier)) {
|
|
148
|
+
const row = this.graphRows.get(specifier);
|
|
149
|
+
if (row === void 0) throw new Error(`client-modules: cannot resolve "${specifier}" — not a seed word, not a shell-own module, and not a row in the boot graph (the runtime mirror of the bundle purity gate)`);
|
|
150
|
+
await this.arrive(row);
|
|
151
|
+
}
|
|
152
|
+
return this.materialize(specifier).exports;
|
|
153
|
+
}
|
|
154
|
+
registerStatic(id, module) {
|
|
155
|
+
if (this.statics.has(id)) throw new Error(`client-modules: shell-own module "${id}" registered twice`);
|
|
156
|
+
this.statics.set(id, module);
|
|
157
|
+
}
|
|
158
|
+
async prefetch(id) {
|
|
159
|
+
if (this.statics.has(id)) return;
|
|
160
|
+
const row = this.graphRows.get(id);
|
|
161
|
+
if (row === void 0) throw new Error(`client-modules: prefetch("${id}") — not a graph entry`);
|
|
162
|
+
await this.arrive(row);
|
|
163
|
+
}
|
|
164
|
+
invalidate(id) {
|
|
165
|
+
this.factories.delete(id);
|
|
166
|
+
this.loadCache.delete(id);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region lib/types/client/manifest.js
|
|
171
|
+
/**
|
|
172
|
+
* Client module system: the browser peer of Node's internal ESM loader, built
|
|
173
|
+
* as a lazy CJS table. The vendored cordis Loader consumes this object
|
|
174
|
+
* through its `internal` contract (the only call site is `EntryTree.import` →
|
|
175
|
+
* `internal.import`), which keeps entry governance (fiber lifecycle, inject
|
|
176
|
+
* waiting, update/refresh) entirely on the vendored side while this package
|
|
177
|
+
* owns code arrival.
|
|
178
|
+
*
|
|
179
|
+
* Lazy CJS model: executing a plugin bundle only REGISTERS its
|
|
180
|
+
* factory (`window.__ModuleLoader__.load({id, factory})`); every module body
|
|
181
|
+
* side effect — including CSS injection — lives inside the factory closure
|
|
182
|
+
* and runs at materialization, not at script execution. Materialization
|
|
183
|
+
* (factory(require) → exports) happens on first import/require and is
|
|
184
|
+
* memoized in {@link ClientModuleLoader.loadCache}; a factory that requires
|
|
185
|
+
* another registered-but-unmaterialized module materializes it recursively,
|
|
186
|
+
* so load order needs no external sequencing.
|
|
187
|
+
*
|
|
188
|
+
* Resolution branch order (import): seed word → shell instance; memoized
|
|
189
|
+
* record → exports; static registry (shell-own modules, e.g. app-shell) →
|
|
190
|
+
* module; registered factory → materialize; graph row → load + materialize;
|
|
191
|
+
* anything else → throw (loud — the runtime mirror of the
|
|
192
|
+
* build-time bundle purity gate). The synchronous `require` handed to
|
|
193
|
+
* factories walks the same order minus the load branch: loading is async,
|
|
194
|
+
* so only already-registered bundles can be required — and cross-plugin value
|
|
195
|
+
* imports are a build error anyway.
|
|
196
|
+
*
|
|
197
|
+
* This file is the browser-safe contract face (zero node imports): the
|
|
198
|
+
* `__DSH_BOOT__` wire types, the boot-manifest parser, and the boundaries around
|
|
199
|
+
* {@link ClientModuleSystem}. The package root is the host-side service that
|
|
200
|
+
* composes the wire.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Parse `window.__DSH_BOOT__` into the two consumer views. Wire boundary:
|
|
204
|
+
* a missing or malformed graph throws (the shell shows the loud failure —
|
|
205
|
+
* a page without a valid manifest cannot boot anything).
|
|
206
|
+
* @param wire - the raw `window.__DSH_BOOT__` value.
|
|
207
|
+
* @returns the manifest with optional plugin-view fields normalized.
|
|
208
|
+
*/
|
|
209
|
+
function parseBootManifest(wire) {
|
|
210
|
+
if (typeof wire !== "object" || wire === null) throw new Error("client-modules: window.__DSH_BOOT__ is missing or not an object");
|
|
211
|
+
const graph = wire;
|
|
212
|
+
if (typeof graph.rev !== "string") throw new Error("client-modules: boot manifest rev must be a string");
|
|
213
|
+
if (!Array.isArray(graph.entries)) throw new Error("client-modules: boot manifest entries must be an array");
|
|
214
|
+
const modules = [];
|
|
215
|
+
const plugins = [];
|
|
216
|
+
for (const value of graph.entries) {
|
|
217
|
+
if (typeof value !== "object" || value === null) throw new Error("client-modules: boot manifest entry is not an object");
|
|
218
|
+
const row = value;
|
|
219
|
+
const where = typeof row.id === "string" ? `"${row.id}"` : JSON.stringify(row);
|
|
220
|
+
if (typeof row.id !== "string" || typeof row.url !== "string" || typeof row.rev !== "string") throw new Error(`client-modules: boot manifest entry ${where} must carry string id/url/rev`);
|
|
221
|
+
if (row.inject !== void 0 && (!Array.isArray(row.inject) || row.inject.some((i) => typeof i !== "string"))) throw new Error(`client-modules: boot manifest entry ${where} inject must be a string array`);
|
|
222
|
+
if (row.immediately !== void 0 && typeof row.immediately !== "boolean") throw new Error(`client-modules: boot manifest entry ${where} immediately must be a boolean`);
|
|
223
|
+
modules.push({
|
|
224
|
+
id: row.id,
|
|
225
|
+
url: row.url,
|
|
226
|
+
rev: row.rev
|
|
227
|
+
});
|
|
228
|
+
plugins.push({
|
|
229
|
+
id: row.id,
|
|
230
|
+
inject: row.inject === void 0 ? [] : [...row.inject],
|
|
231
|
+
immediately: row.immediately === true
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
rev: graph.rev,
|
|
236
|
+
modules,
|
|
237
|
+
plugins
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region lib/types/client/index.js
|
|
242
|
+
/**
|
|
243
|
+
* Enroll the kernel-built module system as `ctx.modules`.
|
|
244
|
+
* @param ctx - client root context.
|
|
245
|
+
*/
|
|
246
|
+
function apply(ctx) {
|
|
247
|
+
const modules = globalThis.__DSH_MODULES__;
|
|
248
|
+
if (modules === void 0) throw new Error("client-modules: window.__DSH_MODULES__ missing — the shell kernel must construct the module system before plugin boot");
|
|
249
|
+
ctx.reflect.provide("modules", modules);
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
exports.ClientModuleSystem = ClientModuleSystem;
|
|
253
|
+
exports.apply = apply;
|
|
254
|
+
exports.parseBootManifest = parseBootManifest;
|
|
255
|
+
return module.exports;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
//# sourceMappingURL=client.js.map
|