@deepseek-ai/dsh-client-modules 0.1.0-rc.8 → 0.1.1-rc.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/lib/index.js CHANGED
@@ -68,10 +68,10 @@ function stripClientSuffix(spec) {
68
68
  * the host Loader's entries for packages declaring `dsh.client`, composes the
69
69
  * `window.__DSH_BOOT__` entry graph (wire single source: {@link WebBootEntry}
70
70
  * in `./client/manifest.ts`) in module-graph order, serves
71
- * `/plugins/<id>/client.js` and its source map, taps the index render to
72
- * inject the boot manifest plus the parser-blocking bootstrap preloads, and
73
- * provides the `clientModuleHost` service (the HMR node half's
74
- * registration/notification face).
71
+ * `/plugins/<id>/client.js` and its source map, contributes the boot manifest
72
+ * plus the parser-blocking bootstrap preloads to the webserver's index
73
+ * injection table, and provides the `clientModuleHost` service (the HMR node
74
+ * half's registration/notification face).
75
75
  *
76
76
  * Scanning is incremental per package — there is no full-rescan code path.
77
77
  * Every cordis `internal/plugin` emission (fiber construction/disposal) marks
@@ -196,25 +196,18 @@ function orderByModuleGraph(entries) {
196
196
  const CLIENT_MODULES_ID = "@deepseek-ai/dsh-client-modules";
197
197
  /** Ordinary dynamic bundles the HTML parser executes before the Vite shell. */
198
198
  const PARSER_PRELOAD_IDS = [CLIENT_MODULES_ID, "@deepseek-ai/dsh-client-runtime"];
199
- /** Escape a graph URL before placing it in a quoted HTML attribute. */
200
- function escapeHtmlAttribute(value) {
201
- return value.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
202
- }
203
199
  /**
204
- * Inject the boot protocol into index.html. The inline registration queue precedes
205
- * blocking classic scripts for modules' and runtime's ordinary
200
+ * The boot protocol as index injection rows. The inline registration queue
201
+ * precedes blocking classic scripts for modules' and runtime's ordinary
206
202
  * `lib/client.js` artifacts. Its `create()` method materializes the modules
207
203
  * bundle, delegates construction to that bundle, and leaves the same facade
208
- * in live-registration mode. The graph script follows before the shell reads
209
- * it. `<` is escaped in JSON so a plugin-controlled string cannot break out
210
- * of the script element.
211
- * @param html - the index.html source.
204
+ * in live-registration mode. The graph global follows before the shell reads
205
+ * it.
212
206
  * @param graph - the composed entry graph.
213
- * @returns the html with the graph script injected.
207
+ * @returns head rows in execution order: queue script, preload scripts, graph global.
214
208
  */
215
- function injectBootManifest(html, graph) {
216
- const json = JSON.stringify(graph).replaceAll("<", "\\u003c");
217
- const script = `${`<script>(()=>{
209
+ function bootInjections(graph) {
210
+ const queue = `(()=>{
218
211
  const pendingQueue=[]
219
212
  window.__ModuleLoader__={
220
213
  mode:"queue",
@@ -235,14 +228,29 @@ window.__ModuleLoader__={
235
228
  return exports.createClientModuleSystem(this,{id:registration.id,exports},options)
236
229
  }
237
230
  }
238
- })()<\/script>`}${PARSER_PRELOAD_IDS.map((id) => graph.entries.find((entry) => entry.id === id)).filter((entry) => entry !== void 0).map((entry) => `<script src="${escapeHtmlAttribute(entry.url)}"><\/script>`).join("")}<script>window.__DSH_BOOT__ = ${json}<\/script>`;
239
- const head = html.indexOf("<head>");
240
- if (head !== -1) return `${html.slice(0, head + 6)}${script}${html.slice(head + 6)}`;
241
- return `${script}${html}`;
231
+ })()`;
232
+ const preload = PARSER_PRELOAD_IDS.map((id) => graph.entries.find((entry) => entry.id === id)).filter((entry) => entry !== void 0).map((entry) => ({
233
+ kind: "script-src",
234
+ placement: "head",
235
+ src: entry.url
236
+ }));
237
+ return [
238
+ {
239
+ kind: "script",
240
+ placement: "head",
241
+ text: queue
242
+ },
243
+ ...preload,
244
+ {
245
+ kind: "global",
246
+ name: "__DSH_BOOT__",
247
+ value: graph
248
+ }
249
+ ];
242
250
  }
243
251
  /**
244
252
  * The web plugin table service: incremental `dsh.client` scan + wire composition
245
- * + bundle route + index tap. Construction runs the activation scan
253
+ * + bundle route + index injection rows. Construction runs the activation scan
246
254
  * synchronously — a malformed declaration or missing bundle among the
247
255
  * already-loaded entries aggregates into one loud throw (FAILED fiber; the
248
256
  * boot activation audit reports it).
@@ -289,7 +297,9 @@ var ClientModuleRegistry = class extends Service {
289
297
  path: "/plugins",
290
298
  handler: this.serveBundle
291
299
  }), "client-modules: bundle route");
292
- ctx.effect(() => ctx.webServer.tapIndex((html) => injectBootManifest(html, this.composed)), "client-modules: boot manifest injection");
300
+ ctx.on("webserver/index-inject", (table) => {
301
+ table.push(...bootInjections(this.composed));
302
+ });
293
303
  }
294
304
  /**
295
305
  * Current composed entry graph (stable object between changes).
@@ -480,4 +490,4 @@ var ClientModuleRegistry = class extends Service {
480
490
  };
481
491
  };
482
492
  //#endregion
483
- export { ClientModuleRegistry, ClientModuleRegistry as default, injectBootManifest, orderByModuleGraph, stripClientSuffix };
493
+ export { ClientModuleRegistry, ClientModuleRegistry as default, bootInjections, orderByModuleGraph, stripClientSuffix };
@@ -3,10 +3,10 @@
3
3
  * the host Loader's entries for packages declaring `dsh.client`, composes the
4
4
  * `window.__DSH_BOOT__` entry graph (wire single source: {@link WebBootEntry}
5
5
  * in `./client/manifest.ts`) in module-graph order, serves
6
- * `/plugins/<id>/client.js` and its source map, taps the index render to
7
- * inject the boot manifest plus the parser-blocking bootstrap preloads, and
8
- * provides the `clientModuleHost` service (the HMR node half's
9
- * registration/notification face).
6
+ * `/plugins/<id>/client.js` and its source map, contributes the boot manifest
7
+ * plus the parser-blocking bootstrap preloads to the webserver's index
8
+ * injection table, and provides the `clientModuleHost` service (the HMR node
9
+ * half's registration/notification face).
10
10
  *
11
11
  * Scanning is incremental per package — there is no full-rescan code path.
12
12
  * Every cordis `internal/plugin` emission (fiber construction/disposal) marks
@@ -22,6 +22,7 @@
22
22
  */
23
23
  import { Service } from '@deepseek-ai/cordis';
24
24
  import type { Context } from '@deepseek-ai/cordis';
25
+ import type { IndexInjection } from '@deepseek-ai/dsh-host-webserver';
25
26
  import type { WebBootEntry, WebBootGraph } from './client/manifest.ts';
26
27
  export { stripClientSuffix } from './client/manifest.ts';
27
28
  export type { BootManifest, BootModuleRow, BootPluginRow, WebBootEntry, WebBootGraph, } from './client/manifest.ts';
@@ -43,21 +44,19 @@ declare module '@deepseek-ai/cordis' {
43
44
  */
44
45
  export declare function orderByModuleGraph(entries: readonly WebBootEntry[]): WebBootEntry[];
45
46
  /**
46
- * Inject the boot protocol into index.html. The inline registration queue precedes
47
- * blocking classic scripts for modules' and runtime's ordinary
47
+ * The boot protocol as index injection rows. The inline registration queue
48
+ * precedes blocking classic scripts for modules' and runtime's ordinary
48
49
  * `lib/client.js` artifacts. Its `create()` method materializes the modules
49
50
  * bundle, delegates construction to that bundle, and leaves the same facade
50
- * in live-registration mode. The graph script follows before the shell reads
51
- * it. `<` is escaped in JSON so a plugin-controlled string cannot break out
52
- * of the script element.
53
- * @param html - the index.html source.
51
+ * in live-registration mode. The graph global follows before the shell reads
52
+ * it.
54
53
  * @param graph - the composed entry graph.
55
- * @returns the html with the graph script injected.
54
+ * @returns head rows in execution order: queue script, preload scripts, graph global.
56
55
  */
57
- export declare function injectBootManifest(html: string, graph: WebBootGraph): string;
56
+ export declare function bootInjections(graph: WebBootGraph): IndexInjection[];
58
57
  /**
59
58
  * The web plugin table service: incremental `dsh.client` scan + wire composition
60
- * + bundle route + index tap. Construction runs the activation scan
59
+ * + bundle route + index injection rows. Construction runs the activation scan
61
60
  * synchronously — a malformed declaration or missing bundle among the
62
61
  * already-loaded entries aggregates into one loud throw (FAILED fiber; the
63
62
  * boot activation audit reports it).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-client-modules",
3
3
  "description": "Client module system, dual-face: node half composes the __DSH_BOOT__ entry graph (incremental dsh.client scan, bundle route, index tap, webPlugins service); browser half is the lazy-CJS module table the vendored cordis Loader consumes as its internal seam",
4
- "version": "0.1.0-rc.8",
4
+ "version": "0.1.1-rc.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -39,8 +39,8 @@
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
41
  "@deepseek-ai/cordis-plugin-loader": "^1.0.2",
42
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8",
43
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
42
+ "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
43
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
44
44
  "@deepseek-ai/cordis": "^4.0.1"
45
45
  },
46
46
  "files": [
@@ -50,10 +50,10 @@
50
50
  "lib/types/**/*.d.ts"
51
51
  ],
52
52
  "peerDependencies": {
53
- "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
53
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
54
54
  "@deepseek-ai/cordis": "^4.0.1",
55
55
  "@deepseek-ai/cordis-plugin-loader": "^1.0.2",
56
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8"
56
+ "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1"
57
57
  },
58
58
  "scripts": {
59
59
  "bundle": "tsdown",