@crazx/dsh-client-modules 0.1.5-alpha.1.zw.2 → 0.1.5-rc.1.zw.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/README.i18n.yaml +2 -2
- package/README.md +3 -3
- package/README.zh.md +11 -11
- package/package.json +4 -4
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/client/modules/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 311a14c79cc8a6eb4a28213ba7ea9e2fbc6e3cb2
|
|
6
|
+
README.zh.md: b8958c10fdf68ba6a35e55f94cfae02fec866a28
|
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ This section explains how the module system is built; observable behavior is cov
|
|
|
57
57
|
|
|
58
58
|
### Design concept
|
|
59
59
|
|
|
60
|
-
The package
|
|
60
|
+
The package has two sides: the Node half is the composition and serving side (`ctx.clientModules`, `ClientModuleRegistry`), the browser half is the loading side (`ctx.modules`, `ClientModuleSystem`). The wire between them is the boot graph — `WebBootEntry` rows injected as `window.__DSH_BOOT__`, with `<` escaped so plugin-controlled strings cannot break out of the script element. The vendored Loader's only consumption point is `EntryTree.import`, so the module system is the single replacement for "how plugin code arrives".
|
|
61
61
|
|
|
62
62
|
### Lazy-CJS model
|
|
63
63
|
|
|
@@ -65,9 +65,9 @@ Executing a plugin bundle only registers its factory; every module-body side eff
|
|
|
65
65
|
|
|
66
66
|
### Incremental composition
|
|
67
67
|
|
|
68
|
-
The
|
|
68
|
+
The Node half scans incrementally per package — no full-rescan path. Every `internal/plugin` emission marks the fiber's entry name dirty; a microtask flush reconciles each dirty name against the live loader entries, and the activation pass seeds the same dirty set and flushes synchronously, so first scan and steady state share one implementation. Package metadata is cached per Loader specifier and owning-tree base URL until restart, while the resolved manifest package name identifies the browser module. A scoped republish whose unscoped package name matches still owns that row. Distinct active Loader sources resolving to one package name are rejected; removing the conflict promotes the remaining source without requiring its fiber to restart. Bundle content changes reach the graph only through `rebuilt()` (the HMR hook).
|
|
69
69
|
|
|
70
|
-
The
|
|
70
|
+
The Node half snapshots each client bundle and available source map before publication. It groups resources into `/plugins/??...&rev=...` combo URLs, with one bootstrap combo for the modules row and one or more application combos for the other rows; each phase is partitioned before a URL exceeds 3 KiB. Every combo map is Indexed Source Map v3 and uses an authored section when available or an identity section for the packaged bundle. Initial per-plugin revisions use process nonces, so startup does not hash every plugin; HMR hashes only an artifact reported as changed. Advertised responses are immutable, and an unknown combination or revision returns 404.
|
|
71
71
|
|
|
72
72
|
### Boot manifest injection
|
|
73
73
|
|
package/README.zh.md
CHANGED
|
@@ -25,7 +25,7 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
声明类型使用 [`DshClientManifest`](../../util/package-manifest/README.zh.md)。Client-modules
|
|
28
|
+
声明类型使用 [`DshClientManifest`](../../util/package-manifest/README.zh.md)。Client-modules 校验 JSON,并持有归一化后的启动图。
|
|
29
29
|
|
|
30
30
|
组合或构建浏览器客户端插件时使用它:本包把包的 `dsh.client` 声明变成可加载的浏览器 bundle,无需任何逐插件接线。它随 web 组合激活;外壳在任何插件运行前启动它。
|
|
31
31
|
|
|
@@ -35,15 +35,15 @@ kind: "package-reference"
|
|
|
35
35
|
|
|
36
36
|
### 浏览器加载什么
|
|
37
37
|
|
|
38
|
-
application combo
|
|
38
|
+
application combo 脚本在启动时仅注册一次插件 factory;模块主体仍保持惰性,只在首次 import 或物化时运行。共享 combo URL 的 row 共用一个进行中的脚本任务。HMR(热模块替换)会让一条发生变化的 row 改用带 revision 的单资源 combo URL。`<id>/client` 与裸 id 解析到同一组导出,因为插件 bundle 就是其包的客户端半侧。
|
|
39
39
|
|
|
40
40
|
### 共享模块
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
外壳初始化一张冻结的模块表(`PLATFORM_MODULES`:React、Cordis 与静态 UI 库);每个动态 bundle 都精确针对该基座解析其 external。`dsh.client.external` 只添加基座之外的精确请求;系统会将每个请求解析到其指定的动态包 row 或完全匹配的静态表键。纯类型 import 会被擦除,不产生请求。组合阶段会拒绝畸形请求、缺失提供方、自请求与同步请求环。
|
|
43
43
|
|
|
44
44
|
### 构建要求
|
|
45
45
|
|
|
46
|
-
宿主提供的是已构建的客户端 bundle,因此启动前 `pnpm run build` 必须已产出每个 `lib/client.js`;缺失 bundle
|
|
46
|
+
宿主提供的是已构建的客户端 bundle,因此启动前 `pnpm run build` 必须已产出每个 `lib/client.js`;缺失 bundle 会明确导致激活失败,并给出一条构建说明及包/路径列表。源码启动会把宿主侧导入映射到 TypeScript 源码,但仍消费这一构建后的客户端导出。本包自身不接受任何插件配置。
|
|
47
47
|
|
|
48
48
|
-----
|
|
49
49
|
|
|
@@ -57,7 +57,7 @@ application combo 脚本在启动时注册插件 factory;模块主体仍保持
|
|
|
57
57
|
|
|
58
58
|
### 设计理念
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
本包分为两侧:Node 半侧负责组合与提供(`ctx.clientModules`,`ClientModuleRegistry`),浏览器半侧负责加载(`ctx.modules`,`ClientModuleSystem`)。两者之间的协议是启动图——以 `window.__DSH_BOOT__` 注入的 `WebBootEntry` 行,`<` 已转义,插件控制的字符串无法逃出 script 元素。vendored Loader 唯一的消费点是 `EntryTree.import`,因此模块系统就是「插件代码如何到达」的唯一可替换实现。
|
|
61
61
|
|
|
62
62
|
### 惰性 CJS 模型
|
|
63
63
|
|
|
@@ -65,22 +65,22 @@ application combo 脚本在启动时注册插件 factory;模块主体仍保持
|
|
|
65
65
|
|
|
66
66
|
### 增量组合
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Node 半侧逐包增量扫描——没有全量重扫路径。每次发出 `internal/plugin` 事件时,系统都会把该 fiber 的 entry 名标脏;微任务 flush 会把每个脏名与当前 loader 条目对账,激活 pass 会初始化同一个脏集合并同步 flush,因此首次扫描与稳态共用同一实现。包元数据按 Loader specifier 与所属 tree base URL 缓存至重启,解析出的 manifest(元数据清单)包名作为浏览器模块身份。换 scope 再发布且去掉 scope 后的包名仍相同时,该 manifest 仍拥有对应 row。若不同的 active Loader source 解析到同一包名,组合会失败;移除冲突来源后,剩余来源无需重启 fiber 即可接替。bundle 内容变更只能通过 `rebuilt()`(HMR 钩子)进入图。
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Node 半侧会在发布前快照每个客户端 bundle 及其现有 source map。它把资源分组到 `/plugins/??...&rev=...` combo URL:modules row 使用一个 bootstrap combo,其余 row 使用一个或多个 application combo;每个阶段都会在 URL 超过 3 KiB 之前分区。每个 combo map 都是 Indexed Source Map v3,并在可用时使用作者提供的 section,否则为已打包 bundle 生成 identity section。初始逐插件 revision 使用进程 nonce,所以启动时不哈希每个插件;HMR 只哈希被报告为已变化的产物。已公告响应不可变;未知组合或 revision 返回 404。
|
|
71
71
|
|
|
72
|
-
###
|
|
72
|
+
### 启动 manifest 注入
|
|
73
73
|
|
|
74
74
|
宿主贡献结构化 index 行,并向 `<head>` 注入:`window.__ModuleLoader__` queue facade、每个 application combo 的提示性 preload、阻塞 parser 的 bootstrap combo 脚本,然后才是外壳读取前的启动图。Web 载体把这些行渲染进 index 响应;由 shell 持有的载体则可以在没有 Web server 时渲染同一批行。facade 的 `create()` 物化 modules bundle、把构造委托给其 `createClientModuleSystem` 导出,并让同一 facade 进入 live registration 模式。
|
|
75
75
|
|
|
76
|
-
###
|
|
76
|
+
### 源码索引
|
|
77
77
|
|
|
78
78
|
| 文件 | 职责 |
|
|
79
79
|
|---|---|
|
|
80
|
-
| [`src/index.ts`](src/index.ts) |
|
|
80
|
+
| [`src/index.ts`](src/index.ts) | Node 半侧:`ClientModuleRegistry`、扫描、产物快照、可选 combo 路由、结构化 index 行 |
|
|
81
81
|
| [`src/client/index.ts`](src/client/index.ts) | 浏览器半侧:bootstrap 导出、`ctx.modules` 登记 |
|
|
82
82
|
| [`src/client/system.ts`](src/client/system.ts) | `ClientModuleSystem`:加载/物化/失效机制 |
|
|
83
|
-
| [`src/client/manifest.ts`](src/client/manifest.ts) |
|
|
83
|
+
| [`src/client/manifest.ts`](src/client/manifest.ts) | 协议类型与启动 manifest 解析 |
|
|
84
84
|
|
|
85
85
|
</details>
|
|
86
86
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crazx/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.5-
|
|
4
|
+
"version": "0.1.5-rc.1.zw.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.3",
|
|
42
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.5-
|
|
43
|
-
"@deepseek-ai/dsh-invariants": "^0.1.5-
|
|
42
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1",
|
|
43
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-rc.1",
|
|
44
44
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
45
|
-
"@deepseek-ai/dsh-package-manifest": "^0.1.5-
|
|
45
|
+
"@deepseek-ai/dsh-package-manifest": "^0.1.5-rc.1"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"lib/index.js",
|