soma-core 2.0.1 → 2.1.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.
Files changed (161) hide show
  1. package/README.md +2 -2
  2. package/bin/eject.cjs +5 -5
  3. package/bin/soma-runtime.cjs +5 -123
  4. package/bin/soma.cjs +2 -2
  5. package/bin/soma.ts +8 -20
  6. package/core/build/compiler/page-declaration-compiler.ts +5 -6
  7. package/core/build/lsp/soma-declaration.cjs +0 -6
  8. package/core/client/container/SomaContainerAdapter.ts +1 -1
  9. package/core/client/data/region-scope-views.ts +1 -1
  10. package/core/client/engine/event-engine.ts +1 -6
  11. package/core/client/engine/soma-bootstrap.ts +5 -13
  12. package/core/client/host-bridge/soma-bootstrap-from-app.ts +2 -2
  13. package/core/client/infra/i18n/II18n.ts +5 -6
  14. package/core/client/infra/i18n/locale-catalog.ts +8 -5
  15. package/core/client/infra/identity/identity-port.ts +1 -1
  16. package/core/client/keyboard/index.ts +0 -1
  17. package/core/client/keyboard/wiring.ts +0 -3
  18. package/core/client/parser/ui-config-parser.ts +6 -9
  19. package/core/client/registry/declaration-renderer.ts +1 -1
  20. package/core/client/runtime/SomaRuntimeServices.ts +1 -1
  21. package/core/inspect/check-runtime.ts +2 -3
  22. package/core/server/host/content-security-policy.ts +2 -11
  23. package/core/server/host/host-assembly-entry.ts +10 -2
  24. package/core/server/host/host-assembly.ts +28 -10
  25. package/core/server/host/host-caller.ts +52 -0
  26. package/core/server/host/host-response-headers.ts +49 -0
  27. package/core/server/host/locale-yaml.ts +7 -5
  28. package/core/server/host/published-page-assets.ts +1 -1
  29. package/core/server/host/resolve-host-request-hook.ts +2 -11
  30. package/core/server/host/resolve-host-tree-context.ts +7 -41
  31. package/core/server/host/server-page-assets.ts +0 -22
  32. package/core/server/host/source-packages.cjs +3 -4
  33. package/core/server/host/virtual-pages.ts +12 -70
  34. package/core/server/index.ts +1 -3
  35. package/core/server/node.ts +0 -1
  36. package/core/server/page-assets.ts +2 -20
  37. package/core/server/page-declaration.ts +1 -1
  38. package/core/server/registry/api-registry-store.ts +5 -25
  39. package/core/server/registry/asset-store.ts +5 -23
  40. package/core/server/registry/page-registry-repository.ts +9 -13
  41. package/core/server/registry/page-registry-store.ts +44 -82
  42. package/core/server/registry/publish-asset-pin.ts +3 -4
  43. package/core/server/registry/registry-subjects.ts +6 -6
  44. package/core/server/registry/rollback-plan.ts +5 -8
  45. package/core/server/registry/source/version-store.ts +8 -30
  46. package/core/server/registry/standard-product.ts +1 -1
  47. package/core/server/runtime-space/bindings.ts +1 -4
  48. package/core/server/runtime-space/gc.ts +2 -3
  49. package/core/server/runtime-space/inject.ts +4 -5
  50. package/core/server/runtime-space/resolve.ts +13 -27
  51. package/core/server/runtime-space/root.cjs +9 -100
  52. package/core/server/runtime-space/root.ts +3 -23
  53. package/core/server/runtime-space/types.ts +0 -11
  54. package/core/shared/artifact-compatibility.ts +6 -16
  55. package/core/shared/component-tree-artifact.ts +4 -8
  56. package/core/shared/core-diagnostic-codes.ts +1 -3
  57. package/core/shared/pipeline-error-codes-view.ts +1 -2
  58. package/core/shared/published-page-route.ts +1 -6
  59. package/core/shared/registry-generated/diagnostic-registry-index.ts +0 -2
  60. package/core/shared/registry-generated/diagnostic-registry.ts +0 -14
  61. package/core/shared/source-file-suffix.ts +8 -0
  62. package/core/shared/types/component-tree-artifact.types.ts +2 -15
  63. package/core/shared/types/host-assembly.types.ts +31 -2
  64. package/core/shared/types/locale.types.ts +3 -3
  65. package/core/shared/types/region-scope.types.ts +1 -1
  66. package/core/shared/types/ui-config.types.ts +2 -7
  67. package/core/shared/types/write.types.ts +1 -1
  68. package/dist/browser/soma-runtime.js +20 -36
  69. package/dist/cli/soma.js +8 -21
  70. package/dist/core/index.cjs +20 -38
  71. package/dist/lsp/component-tree.cjs +7 -14
  72. package/dist/types/client/container/SomaContainerAdapter.d.ts +1 -1
  73. package/dist/types/client/engine/event-engine.d.ts +0 -2
  74. package/dist/types/client/engine/soma-bootstrap.d.ts +2 -3
  75. package/dist/types/client/host-bridge/soma-bootstrap-from-app.d.ts +2 -2
  76. package/dist/types/client/infra/i18n/II18n.d.ts +5 -6
  77. package/dist/types/client/infra/i18n/locale-catalog.d.ts +3 -3
  78. package/dist/types/client/infra/identity/identity-port.d.ts +1 -1
  79. package/dist/types/client/keyboard/index.d.ts +1 -1
  80. package/dist/types/client/keyboard/wiring.d.ts +0 -2
  81. package/dist/types/client/registry/declaration-renderer.d.ts +1 -1
  82. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +1 -1
  83. package/dist/types/server/host/content-security-policy.d.ts +0 -5
  84. package/dist/types/server/host/host-assembly-entry.d.ts +5 -2
  85. package/dist/types/server/host/host-assembly.d.ts +9 -4
  86. package/dist/types/server/host/host-caller.d.ts +10 -0
  87. package/dist/types/server/host/host-response-headers.d.ts +16 -0
  88. package/dist/types/server/host/published-page-assets.d.ts +1 -1
  89. package/dist/types/server/host/resolve-host-request-hook.d.ts +0 -4
  90. package/dist/types/server/host/resolve-host-tree-context.d.ts +1 -1
  91. package/dist/types/server/host/server-page-assets.d.ts +0 -2
  92. package/dist/types/server/host/virtual-pages.d.ts +4 -14
  93. package/dist/types/server/index.d.ts +1 -2
  94. package/dist/types/server/node.d.ts +1 -1
  95. package/dist/types/server/page-assets.d.ts +1 -4
  96. package/dist/types/server/page-declaration.d.ts +1 -1
  97. package/dist/types/server/registry/api-registry-store.d.ts +1 -6
  98. package/dist/types/server/registry/asset-store.d.ts +2 -11
  99. package/dist/types/server/registry/page-registry-repository.d.ts +4 -4
  100. package/dist/types/server/registry/page-registry-store.d.ts +22 -30
  101. package/dist/types/server/registry/registry-subjects.d.ts +2 -2
  102. package/dist/types/server/registry/rollback-plan.d.ts +0 -3
  103. package/dist/types/server/registry/source/version-store.d.ts +1 -9
  104. package/dist/types/server/registry/standard-product.d.ts +1 -1
  105. package/dist/types/server/runtime-space/resolve.d.ts +0 -3
  106. package/dist/types/server/runtime-space/root.d.cts +6 -29
  107. package/dist/types/server/runtime-space/root.d.ts +2 -7
  108. package/dist/types/server/runtime-space/types.d.ts +0 -9
  109. package/dist/types/shared/artifact-compatibility.d.ts +1 -3
  110. package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
  111. package/dist/types/shared/published-page-route.d.ts +1 -3
  112. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +0 -12
  113. package/dist/types/shared/types/component-tree-artifact.types.d.ts +2 -15
  114. package/dist/types/shared/types/host-assembly.types.d.ts +27 -1
  115. package/dist/types/shared/types/locale.types.d.ts +1 -1
  116. package/dist/types/shared/types/region-scope.types.d.ts +1 -1
  117. package/dist/types/shared/types/ui-config.types.d.ts +2 -7
  118. package/dist/types/shared/types/write.types.d.ts +1 -1
  119. package/global.d.ts +0 -9
  120. package/host-next/app/SomaPageClient.tsx +359 -0
  121. package/host-next/app/[...path]/page.tsx +22 -0
  122. package/host-next/app/api/[...path]/route.ts +98 -0
  123. package/host-next/app/api/soma-registry/[...path]/route.ts +79 -0
  124. package/host-next/app/components/SomaHostPage.tsx +128 -0
  125. package/host-next/app/components/SomaHydrationShell.tsx +20 -0
  126. package/host-next/app/components/SomaPageClientBoundary.tsx +13 -0
  127. package/host-next/app/components/SomaPageForbidden.tsx +19 -0
  128. package/host-next/app/favicon.ico/route.ts +13 -0
  129. package/host-next/app/globals.css +177 -0
  130. package/host-next/app/layout.tsx +27 -0
  131. package/host-next/app/page-access.ts +47 -0
  132. package/host-next/app/page.tsx +9 -0
  133. package/host-next/app/router-bridge.ts +42 -0
  134. package/host-next/app/soma/[...path]/route.ts +9 -0
  135. package/host-next/app/soma/_shared/host-prepare.ts +33 -0
  136. package/host-next/app/soma/_shared/page-http.ts +86 -0
  137. package/host-next/app/soma/manifest/route.ts +98 -0
  138. package/host-next/app/soma/page/route.ts +36 -0
  139. package/host-next/app/soma/route.ts +9 -0
  140. package/host-next/app/soma-runtime/[...file]/route.ts +21 -0
  141. package/host-next/app/soma-runtime/_shared/static-file.ts +89 -0
  142. package/host-next/bin/host-next.cjs +59 -0
  143. package/host-next/instrumentation.ts +13 -0
  144. package/host-next/next-env.d.ts +7 -0
  145. package/host-next/next.config.js +382 -0
  146. package/host-next/proxy.ts +43 -0
  147. package/host-next/src/shell-routes.cjs +51 -0
  148. package/host-next/src/workspace.ts +543 -0
  149. package/package.json +66 -41
  150. package/tsconfig.json +2 -1
  151. package/core/server/host/page-response-mode.cjs +0 -96
  152. package/core/server/host/page-response-request.ts +0 -33
  153. package/core/server/host/request-origin.ts +0 -18
  154. package/core/server/host/soma-request-hook-host.stub.ts +0 -4
  155. package/core/server/runtime-space/migrate-sources.ts +0 -124
  156. package/core/shared/source-compat.ts +0 -9
  157. package/dist/types/server/host/page-response-request.d.ts +0 -8
  158. package/dist/types/server/host/request-origin.d.ts +0 -1
  159. package/dist/types/server/host/soma-request-hook-host.stub.d.ts +0 -2
  160. package/dist/types/server/runtime-space/migrate-sources.d.ts +0 -19
  161. /package/dist/types/shared/{source-compat.d.ts → source-file-suffix.d.ts} +0 -0
package/README.md CHANGED
@@ -28,8 +28,8 @@ Host 文件页优先,Registry 页面在 Host 404 时兜底;存量 `/pages/<n
28
28
  Temporal 值语义(`temporal`)、图表(`chart`)、拖放(`dnd`)、文本差异(`diff`)、二维码(`qrcode`)各一个子路径;
29
29
  引擎库只在 `adapter-*.ts` 里动态 import,可经 `SomaBootstrapOptions.engines` 逐槽替换。
30
30
  - **渲染端口**:`render-ports` 的 notify / regionFallback 由 UI 体系注入,缺省无头(只记录 / 只打标记)。
31
- - **宿主与 CLI**:core 不含 Next / React;Next App Router 宿主壳在 `soma-host-next/`,`soma dev/build/start` 以子进程转调它;`soma` CLI
32
- (`dev/build/start` 转调 soma-host-next、`db generate|migrate|pull|prisma|codegen`、`sync`、`lsp`、`component eject|diff|upgrade` 与 `pack init` 转调 soma-ui,见 `bin/` 与 `soma help`)。
31
+ - **宿主与 CLI**:core 运行时不含 Next / React;Next App Router 宿主壳在包内 `host-next/`(next / react / react-dom 为可选 peer),`soma dev/build/start` 以子进程转调它;`soma` CLI
32
+ (`dev/build/start` 转调包内 host-next、`db generate|migrate|pull|prisma|codegen`、`sync`、`lsp`、`component eject|diff|upgrade` 与 `pack init` 转调 soma-ui,见 `bin/` 与 `soma help`)。
33
33
  mock 服务器与 `soma-mock` 已迁 soma-testkit;`verify` 在 soma-testkit。
34
34
 
35
35
  ## 文档索引
package/bin/eject.cjs CHANGED
@@ -10,8 +10,8 @@
10
10
  // 3. **校验不过就回滚**:`--verify "<命令>"` 给了就跑,不过则把这次写的全部撤掉,
11
11
  // 宿主目录回到固化之前的样子(半新半旧的目录比失败本身更难收拾)。
12
12
  //
13
- // 取材直接读运行时态文件(<runtime 根>/registry/pages/<名>.json,缺省 <host>/.soma/runtime;
14
- // 旧位置 data/soma-runtime/pages 只读回退),不要求服务器在跑。
13
+ // 取材直接读运行时态文件(<runtime 根>/registry/pages/<名>.json,缺省 <host>/.soma/runtime),
14
+ // 不要求服务器在跑。
15
15
 
16
16
  const fs = require('node:fs');
17
17
  const path = require('node:path');
@@ -26,7 +26,7 @@ function usage() {
26
26
  '',
27
27
  '选项:',
28
28
  ' --version <N> 固化指定版本(缺省:最新 published 版本)',
29
- ' --registry <目录> 运行时态页面目录(缺省 <runtime 根>/registry/pages;SOMA_RUNTIME_DIR 可改根,旧目录只读回退)',
29
+ ' --registry <目录> 运行时态页面目录(缺省 <runtime 根>/registry/pages;SOMA_RUNTIME_DIR 可改根)',
30
30
  ' --host <目录> 宿主根目录(缺省当前目录)',
31
31
  ' --force 覆盖同名既有文件(默认撞名即中止)',
32
32
  ' --verify "<命令>" 落盘后跑一条校验命令,不过则整体回滚',
@@ -89,7 +89,7 @@ function runEject(argv) {
89
89
  }
90
90
  // SOMA_INVOKE_CWD:经 soma CLI 委派进来时,调用方的原始 cwd(委派本身以包根为 cwd)
91
91
  const hostDir = path.resolve(options.hostDir || process.env.SOMA_INVOKE_CWD || process.cwd());
92
- // 页面目录唯一解析:--registry > 旧变量别名 > <runtime 根>/registry/pages;只在缺省位置时才带旧目录回退
92
+ // 页面目录唯一解析:--registry > <runtime 根>/registry/pages
93
93
  const layoutHost = options.hostDir ? hostDir : resolveSomaHostDir(process.env, process.env.SOMA_INVOKE_CWD || process.cwd());
94
94
  let registryDirs;
95
95
  if (options.registryDir) {
@@ -102,7 +102,7 @@ function runEject(argv) {
102
102
  console.error(`[soma eject] ${error.message}`);
103
103
  process.exit(1);
104
104
  }
105
- registryDirs = [layout.dirs.pages, ...layout.legacy.pages];
105
+ registryDirs = [layout.dirs.pages];
106
106
  }
107
107
 
108
108
  // 规划器与落盘器是 TS 源码,用 jiti 现编译加载(与宿主服务加载器同一条路)
@@ -1,26 +1,15 @@
1
- // `soma runtime migrate | gc`:runtime 空间的维护命令(规格 §3.2、§3.4)。
1
+ // `soma runtime gc`:runtime 空间的维护命令(规格 §3.4)。
2
2
  //
3
- // soma runtime migrate [--host <目录>] [--dry-run]
4
- // 把旧目录(data/soma-runtime/<kind>,含 .soma/next 下的落点)搬进 <runtime 根>/registry/<kind>。
5
- // 幂等:搬完旧目录即空,再跑无事可做;目标已存在时内容相同视为已迁移(删旧副本),内容不同不覆盖、保留旧文件并报冲突(退出码 1)。
6
- // 显式设了旧环境变量别名的类别不迁(目录是用户指定的,不属于旧缺省位置)。
7
- // 源附件(AD-46 ①,C6-e)另有一步:旧目录键 biz(registry/biz、data/soma-runtime/biz)搬到 sources,
8
- // 旧后缀 .biz.json 改名 .source.json(含显式别名目录里的就地改名)。同样幂等,冲突不覆盖、中途失败源文件不丢。
9
3
  // soma runtime gc [--host <目录>] [--dry-run] [--min-age <秒>]
10
4
  // 删除 <root>/artifacts 中不被绑定、预热索引、Registry 版本引用的产物。
11
5
 
12
- const fs = require('node:fs');
13
6
  const path = require('node:path');
14
7
  const { resolveSomaHostDir, resolveSomaRuntimeLayout } = require('../core/server/runtime-space/root.cjs');
15
8
 
16
- // 源附件(sources)走专门步骤 migrateSourceFiles(要改后缀),不在通用搬运里
17
- const KINDS = ['pages', 'assets', 'apis'];
18
-
19
9
  function usage() {
20
10
  console.error([
21
- 'Usage: soma runtime <migrate|gc> [选项]',
11
+ 'Usage: soma runtime gc [选项]',
22
12
  '',
23
- ' migrate [--dry-run] 旧目录(data/soma-runtime/*)搬进 runtime 根的 registry/*(幂等,冲突不覆盖)',
24
13
  ' gc [--dry-run] [--min-age <秒>] 清理 runtime 根里不再被引用的产物(缺省保护 300 秒内的新文件)',
25
14
  '',
26
15
  '通用:--host <目录> 宿主根(缺省 SOMA_HOST_DIR,再缺省当前目录);SOMA_RUNTIME_DIR 可改 runtime 根。',
@@ -43,92 +32,9 @@ function parse(argv) {
43
32
  return { options };
44
33
  }
45
34
 
46
- function walkFiles(dir, base = dir) {
47
- let entries;
48
- try {
49
- entries = fs.readdirSync(dir, { withFileTypes: true });
50
- } catch {
51
- return [];
52
- }
53
- const out = [];
54
- for (const entry of entries) {
55
- const full = path.join(dir, entry.name);
56
- if (entry.isDirectory()) out.push(...walkFiles(full, base));
57
- else if (entry.isFile() && !entry.name.endsWith('.lock') && !entry.name.endsWith('.tmp')) {
58
- out.push(path.relative(base, full));
59
- }
60
- }
61
- return out;
62
- }
63
-
64
- function moveFile(from, to) {
65
- fs.mkdirSync(path.dirname(to), { recursive: true });
66
- try {
67
- fs.renameSync(from, to);
68
- } catch (error) {
69
- if (error.code !== 'EXDEV') throw error;
70
- fs.copyFileSync(from, to);
71
- fs.unlinkSync(from);
72
- }
73
- }
74
-
75
- function removeEmptyDirs(dir) {
76
- let entries;
77
- try {
78
- entries = fs.readdirSync(dir, { withFileTypes: true });
79
- } catch {
80
- return;
81
- }
82
- for (const entry of entries) {
83
- if (entry.isDirectory()) removeEmptyDirs(path.join(dir, entry.name));
84
- }
85
- try {
86
- if (fs.readdirSync(dir).length === 0) fs.rmdirSync(dir);
87
- } catch {
88
- /* 非空或并发:保留 */
89
- }
90
- }
91
-
92
- /** 迁移;返回 SomaRuntimeMigrateReport 形状 */
93
- function migrateRuntime(layout, dryRun) {
94
- const moved = [];
95
- const conflicts = [];
96
- let identical = 0;
97
- for (const kind of KINDS) {
98
- const target = layout.dirs[kind];
99
- for (const source of layout.legacy[kind]) {
100
- for (const relative of walkFiles(source)) {
101
- const from = path.join(source, relative);
102
- const to = path.join(target, relative);
103
- if (fs.existsSync(to)) {
104
- if (fs.readFileSync(from).equals(fs.readFileSync(to))) {
105
- identical += 1;
106
- if (!dryRun) fs.unlinkSync(from);
107
- } else {
108
- conflicts.push({ kind, from, to });
109
- }
110
- continue;
111
- }
112
- moved.push({ kind, from, to });
113
- if (!dryRun) moveFile(from, to);
114
- }
115
- if (!dryRun) removeEmptyDirs(source);
116
- }
117
- }
118
- // 源附件:旧目录键 biz -> sources、旧后缀 .biz.json -> .source.json(TS 实现经 jiti 载入,与 gc 同一条路)
119
- const createJiti = require('jiti');
120
- const jiti = createJiti(__filename, { interopDefault: true });
121
- const { migrateSourceFiles } = jiti(path.resolve(__dirname, '..', 'core/server/runtime-space/migrate-sources.ts'));
122
- const sourceReport = migrateSourceFiles(layout.dirs.sources, layout.legacy.sources, dryRun);
123
- for (const item of sourceReport.moved) moved.push({ kind: 'sources', ...item });
124
- for (const item of sourceReport.conflicts) conflicts.push({ kind: 'sources', ...item });
125
- identical += sourceReport.identical;
126
- return { root: layout.root, dryRun, moved, conflicts, identical };
127
- }
128
-
129
35
  function runRuntimeCommand(argv) {
130
36
  const parsed = parse(argv);
131
- if (parsed.error || !['migrate', 'gc'].includes(argv[3] || '')) {
37
+ if (parsed.error || argv[3] !== 'gc') {
132
38
  if (parsed.error) console.error(`[soma runtime] ${parsed.error}`);
133
39
  usage();
134
40
  return 2;
@@ -138,34 +44,12 @@ function runRuntimeCommand(argv) {
138
44
  const hostDir = options.host ? path.resolve(cwd, options.host) : resolveSomaHostDir(process.env, cwd);
139
45
  let layout;
140
46
  try {
141
- layout = resolveSomaRuntimeLayout(hostDir, process.env, cwd);
47
+ layout = resolveSomaRuntimeLayout(hostDir, process.env);
142
48
  } catch (error) {
143
49
  console.error(`[soma runtime] ${error.message}`);
144
50
  return 1;
145
51
  }
146
52
 
147
- if (options.action === 'migrate') {
148
- let report;
149
- try {
150
- report = migrateRuntime(layout, options.dryRun);
151
- } catch (error) {
152
- // 单文件 rename / 拷贝失败:已搬的保持新位置、没搬的源文件原地不动,重跑即可继续(幂等)
153
- console.error(`[soma runtime] 迁移中断:${error.message}。已搬的文件在新位置,未搬的仍在原处;排除原因后重跑 soma runtime migrate 即可继续。`);
154
- return 1;
155
- }
156
- const verb = options.dryRun ? '将迁移' : '已迁移';
157
- console.log(`[soma runtime] 根 ${report.root}`);
158
- for (const item of report.moved) console.log(` ${verb} ${item.kind}: ${item.from} -> ${item.to}`);
159
- if (report.identical > 0) console.log(` ${report.identical} 个文件在新位置已有相同副本(旧副本${options.dryRun ? '将删除' : '已删除'})`);
160
- for (const item of report.conflicts) {
161
- console.error(` 冲突(未覆盖,旧文件保留) ${item.kind}: ${item.from} 与 ${item.to} 内容不同,请人工处理`);
162
- }
163
- if (report.moved.length === 0 && report.identical === 0 && report.conflicts.length === 0) {
164
- console.log(' 没有需要迁移的旧目录数据');
165
- }
166
- return report.conflicts.length > 0 ? 1 : 0;
167
- }
168
-
169
53
  // gc:TS 实现经 jiti 加载(与 eject 同一条路)
170
54
  const createJiti = require('jiti');
171
55
  const jiti = createJiti(__filename, { interopDefault: true });
@@ -174,8 +58,6 @@ function runRuntimeCommand(argv) {
174
58
  try {
175
59
  report = collectRuntimeGarbage(layout.dirs, {
176
60
  dryRun: options.dryRun,
177
- // 还没迁移的旧目录里的版本记录同样引用产物:漏扫会误删
178
- extraRegistryDirs: ['pages', 'sources', 'assets', 'apis'].flatMap((kind) => layout.legacy[kind]),
179
61
  minAgeMs: options.minAgeSeconds === undefined ? undefined : options.minAgeSeconds * 1000,
180
62
  });
181
63
  } catch (error) {
@@ -190,4 +72,4 @@ function runRuntimeCommand(argv) {
190
72
  return 0;
191
73
  }
192
74
 
193
- module.exports = { runRuntimeCommand, migrateRuntime };
75
+ module.exports = { runRuntimeCommand };
package/bin/soma.cjs CHANGED
@@ -155,12 +155,12 @@ function printHelp() {
155
155
  console.log([
156
156
  'Usage: soma <命令> [...参数]',
157
157
  '',
158
- ' dev | build | start 在 Host 根启动 Next 开发 / 生产构建 / 启动产物(转调 soma-host-next)',
158
+ ' dev | build | start 在 Host 根启动 Next 开发 / 生产构建 / 启动产物(转调包内 host-next)',
159
159
  ' codegen [service] ... Domain Class 装饰器 → 页面声明;service 分支生成 IService 骨架',
160
160
  ' sync [--from <目录>] [--to <目录>] 把包内预构建的浏览器运行包拷到 <runtime 根>/static/(--to 可改)',
161
161
  ' lsp [--check <文件或目录>] stdio JSON-RPC 语言服务(同 soma-lsp);--check 单次诊断,有错退出码 1',
162
162
  ' eject <页面名> 运行态页面固化成源码',
163
- ' runtime migrate | gc 旧 Registry 目录搬入 runtime 根 / 清理未被引用的产物(--dry-run 预览)',
163
+ ' runtime gc 清理未被引用的产物(--dry-run 预览)',
164
164
  ' <扩展命令> ... 由已装扩展包在 package.json 的 soma.commands 登记(如生成解释、声明检查、主题可解释性)',
165
165
  ' check --core <产物目录> [--json] [--dump [文件]] core 标准产物独立校验(不登记编译端口;有错退出码 1,用法错 2)',
166
166
  ' doctor 打印 Node 与 soma 版本;扩展命令表里有 app 时再跑 soma app check(退出码同它)',
package/bin/soma.ts CHANGED
@@ -134,21 +134,10 @@ if (command === 'check') {
134
134
  process.exit(1);
135
135
  });
136
136
  }
137
- /** soma-host-next 命令行相对 Host 工程根的位置(与 bin/soma.cjs 的 soma-ui 定位同一约定:不经 import / require 说明符) */
138
- const HOST_NEXT_CLI_RELATIVE = path.join('node_modules', 'soma-host-next', 'bin', 'soma-host-next.cjs');
139
-
140
- /** 环境变量 `SOMA_HOST_NEXT_CLI`(显式路径,优先)→ 当前目录及其各级父目录下的 soma-host-next 命令行;找不到返回 null */
141
- function locateHostNextCli(hostDir: string): string | null {
142
- const explicit = process.env.SOMA_HOST_NEXT_CLI;
143
- if (explicit && explicit.trim() !== '') {
144
- const resolved = path.resolve(explicit);
145
- return fs.existsSync(resolved) ? resolved : null;
146
- }
147
- for (let dir = hostDir; ; dir = path.dirname(dir)) {
148
- const candidate = path.join(dir, HOST_NEXT_CLI_RELATIVE);
149
- if (fs.existsSync(candidate)) return candidate;
150
- if (path.dirname(dir) === dir) return null;
151
- }
137
+ /** Next 宿主壳命令行:随 soma-core 包发布的 host-next/bin/host-next.cjs(包内相对定位,不去 node_modules 找外部包) */
138
+ function locateHostNextCli(): string | null {
139
+ const candidate = path.join(packageRoot, 'host-next', 'bin', 'host-next.cjs');
140
+ return fs.existsSync(candidate) ? candidate : null;
152
141
  }
153
142
 
154
143
  // check 的 runtime 阶段是异步收尾(上面 then 里 process.exit),不得落进下面的 dev/build/start 转调
@@ -160,15 +149,14 @@ if (command !== 'check') {
160
149
  process.exit(1);
161
150
  }
162
151
 
163
- // `soma dev|build|start`:Next 宿主壳(app/、next.config、proxy、Next 工作区装配)归 soma-host-next,
164
- // core 不含 Next / React;这里以子进程转调它的命令行,参数、环境变量与退出码透传(同 component eject → soma-ui 的约定)。
152
+ // `soma dev|build|start`:Next 宿主壳(app/、next.config、proxy、Next 工作区装配)在包内 host-next/ 目录,
153
+ // core 运行时(core/**)不 import 它、不含 Next / React;这里以子进程转调它的命令行,参数、环境变量与退出码透传。
165
154
  // Host 目录取当前目录,覆盖外部陈旧的 SOMA_HOST_DIR。
166
155
  const hostDir = path.resolve(process.cwd());
167
- const hostNextCli = locateHostNextCli(hostDir);
156
+ const hostNextCli = locateHostNextCli();
168
157
  if (!hostNextCli) {
169
158
  console.error(
170
- `[soma ${command}] 找不到 soma-host-next 的命令行入口:Next 宿主壳由 soma-host-next 提供。\n`
171
- + ` 在 Host 工程里安装 soma-host-next(期望 <Host>/${HOST_NEXT_CLI_RELATIVE}),或用环境变量 SOMA_HOST_NEXT_CLI 指向它。`,
159
+ `[soma ${command}] 找不到 Next 宿主壳入口 host-next/bin/host-next.cjs:soma-core 包不完整,请重新安装。`,
172
160
  );
173
161
  process.exit(1);
174
162
  }
@@ -139,8 +139,8 @@ export const SOMA_UNKNOWN_COMPILE_IDENTITY = '';
139
139
  const dump = (value: unknown): string =>
140
140
  yaml.dump(value, { lineWidth: 120, noRefs: true, quotingType: '"' });
141
141
 
142
- /** 兼容一参旧调用方的缺省用途 */
143
- const LEGACY_DEFAULT_OPTIONS: SomaPageCompileOptions = { purpose: 'static' };
142
+ /** 未显式传入编译选项时的缺省用途 */
143
+ const DEFAULT_OPTIONS: SomaPageCompileOptions = { purpose: 'static' };
144
144
 
145
145
  /**
146
146
  * 编译一整页四件套(html + 平铺 uiYaml + eventYaml? + styleYaml?,只认 core 标准格式)。块声明、非白名单顶层键、形状不合法的侧车在唯一入口直接拒绝。
@@ -150,7 +150,7 @@ const LEGACY_DEFAULT_OPTIONS: SomaPageCompileOptions = { purpose: 'static' };
150
150
  */
151
151
  export function compilePageDeclaration(
152
152
  source: SomaPageSource,
153
- options: SomaPageCompileOptions = LEGACY_DEFAULT_OPTIONS,
153
+ options: SomaPageCompileOptions = DEFAULT_OPTIONS,
154
154
  ): SomaPageCompileResult {
155
155
  try { return compilePageDeclarationInternal(source, options) as SomaPageCompileResult; } catch (error) {
156
156
  throw rewrapTreeError(source, error);
@@ -171,7 +171,7 @@ function rewrapTreeError(input: SomaPageSource, error: unknown): unknown {
171
171
  */
172
172
  export function declarePageDeclaration(
173
173
  source: SomaPageSource,
174
- options: SomaPageCompileOptions = LEGACY_DEFAULT_OPTIONS,
174
+ options: SomaPageCompileOptions = DEFAULT_OPTIONS,
175
175
  ): readonly unknown[] {
176
176
  const sink: unknown[] = [];
177
177
  try { compilePageDeclarationInternal(source, options, sink); } catch (error) { sink.push(error); }
@@ -219,8 +219,7 @@ function coreEnvelopeHead(markup: SomaPageMarkup, artifact: ComponentTreeRuntime
219
219
  if (markup === 'component-tree' && artifact !== undefined) {
220
220
  return {
221
221
  sourceMarkup: 'component-tree',
222
- schemaVersion: 1,
223
- grammarVersion: 1,
222
+ format: artifact.format,
224
223
  capabilities: [...artifact.capabilities],
225
224
  componentRefs: artifact.componentRefs,
226
225
  };
@@ -23,11 +23,6 @@ function parseFlatDeclaration(source, label = '_ui.yaml') {
23
23
  return doc;
24
24
  }
25
25
 
26
- /** 兼容旧名:读平铺 `_ui.yaml` */
27
- function parseSomaDeclaration(source) {
28
- return parseFlatDeclaration(source, '_ui.yaml');
29
- }
30
-
31
26
  function anchorOf(key) {
32
27
  const at = key.indexOf('@');
33
28
  const dot = key.lastIndexOf('.');
@@ -81,7 +76,6 @@ function declarationFacts(source, eventSource) {
81
76
  module.exports = {
82
77
  isBlockDeclarationText,
83
78
  parseFlatDeclaration,
84
- parseSomaDeclaration,
85
79
  anchorOf,
86
80
  collectUiAnchors,
87
81
  collectEventAnchors,
@@ -118,7 +118,7 @@ export class SomaContainerAdapter implements IContainerAdapter {
118
118
  element.innerHTML = sanitizeSomaHtml(value).html;
119
119
  }
120
120
 
121
- /** 显隐只有 `hidden` 属性这一个机制:不写内联样式、不切类名;元素自带的 display 规则压不过 `[hidden]`,见 soma-host-next/app/globals.css(宿主壳样式) */
121
+ /** 显隐只有 `hidden` 属性这一个机制:不写内联样式、不切类名;元素自带的 display 规则压不过 `[hidden]`,见 host-next/app/globals.css(宿主壳样式) */
122
122
  setVisibility(element: HTMLElement, visible: boolean): void {
123
123
  element.hidden = !visible;
124
124
  }
@@ -3,7 +3,7 @@
3
3
  // · 镜像(`SomaScopeDecl.mirrors`):切片值(或子路径值)写进页面状态 `page.region_mirror.<作用域>.<镜像键>`,
4
4
  // 宿主片段里没有契约 `scope:` 段的组件的 `ui.show` prop 绑定读它——组件拿到的是普通 prop,不碰区域端口;
5
5
  // · 显隐门(`SomaScopeGateDecl`):按切片值的业务真值(`scopeTruthy`)切换元素的 `hidden` 属性,不写内联样式
6
- // (隐藏规则是页面级样式片里的 `[data-soma-gate][hidden]`;兼容期旧产物为 `[data-soma-when][hidden]`)。
6
+ // (隐藏规则是页面级样式片里的 `[data-soma-gate][hidden]`)。
7
7
  //
8
8
  // 读切片只经 `store.port(scopeId, null)` 的句柄:不带写者身份,天然只读;store 换代(页面卸载 / 热替换)后旧句柄读空、
9
9
  // 订阅得空退订,本模块再用自己的 `disposed` 位兜住已排队的通知,所以旧页面的绑定不会写进新页面的状态。
@@ -54,8 +54,6 @@ export interface SomaEventEngineOptions<TContext extends Record<string, unknown>
54
54
  scopeTracker: WeakMap<HTMLElement, any>;
55
55
  callbacks: {
56
56
  onRefresh: () => void | Promise<void>;
57
- /** @deprecated 使用 onCommit */
58
- onFlush?: () => void | Promise<void>;
59
57
  onCommit?: () => void | Promise<void>;
60
58
  onBeginTransaction?: () => void;
61
59
  onEndTransaction?: () => void;
@@ -108,10 +106,7 @@ export class SomaEventEngine<TContext extends Record<string, unknown> = Record<s
108
106
  this.scopeTracker = options.scopeTracker;
109
107
  this.callbacks = {
110
108
  onRefresh: options.callbacks.onRefresh,
111
- onCommit:
112
- options.callbacks.onCommit ??
113
- options.callbacks.onFlush ??
114
- (() => Promise.resolve()),
109
+ onCommit: options.callbacks.onCommit ?? (() => Promise.resolve()),
115
110
  onBeginTransaction: options.callbacks.onBeginTransaction,
116
111
  onEndTransaction: options.callbacks.onEndTransaction,
117
112
  onDiscardPending: options.callbacks.onDiscardPending,
@@ -150,7 +150,7 @@ export interface SomaPageAssets extends ComponentTreeRuntimeEnvelope {
150
150
  timerConfig?: ParsedTimer[];
151
151
  styleConfig?: StyleConfig;
152
152
  /**
153
- * 多语言词表(KC2,`format: 'soma.locale-bundle'`);迁移期仍认单字典(无 `format` 视为应用缺省语言词表)。
153
+ * 多语言词表(KC2,`format: 'soma.locale-bundle'`);只认词表信封(空对象 = 无词表)。
154
154
  * 运行期按当前显示语言渲染文案,切换不重编、不换产物(`setLocale`)。
155
155
  * 与注入载荷同名同形:可给词表文本(YAML 字符串,运行期解析)或已解析对象。
156
156
  */
@@ -266,9 +266,7 @@ export function assertPageRuntimeAssets(assets: SomaPageAssets, hostComponents:
266
266
  const supply = supplyFromDefinitions({ ...hostComponents, ...(assets.components ?? {}) });
267
267
  const verdict = checkArtifactRuntimeCompatibility({
268
268
  sourceMarkup: 'component-tree',
269
- ...(assets.artifact!.format !== undefined ? { format: assets.artifact!.format } : {}),
270
- ...(assets.artifact!.schemaVersion !== undefined ? { schemaVersion: assets.artifact!.schemaVersion } : {}),
271
- ...(assets.artifact!.grammarVersion !== undefined ? { grammarVersion: assets.artifact!.grammarVersion } : {}),
269
+ format: assets.artifact!.format,
272
270
  capabilities: assets.artifact!.capabilities,
273
271
  componentRefs: assets.artifact!.componentRefs,
274
272
  }, supply);
@@ -497,8 +495,6 @@ export function fragmentHtmlFingerprint(html: string): string {
497
495
  return (hash >>> 0).toString(16).padStart(8, '0');
498
496
  }
499
497
 
500
- /** @deprecated 改用 fragmentHtmlFingerprint(同一算法;本别名保留一个发布周期) */
501
-
502
498
  /**
503
499
  * 错误采集接线声明(可观测性,默认关闭)。
504
500
  *
@@ -840,7 +836,7 @@ export class SomaBootstrap {
840
836
  // 1. 解析资产(委托给 AssetResolver)
841
837
  const parsed = this.assetResolver.resolve(this.assets);
842
838
 
843
- // 1.5 文案目录:词表信封 / 单字典装入,定当前显示语言(挂载选项 locale.initial,缺省取词表的缺省语言)
839
+ // 1.5 文案目录:词表信封装入,定当前显示语言(挂载选项 locale.initial,缺省取词表的缺省语言)
844
840
  this.loadLocale(parsed.locale);
845
841
 
846
842
  // 2. 挂载 HTML
@@ -2322,12 +2318,9 @@ export class SomaBootstrap {
2322
2318
  if (this.preferredLocale !== undefined) this.localeCatalog.setCurrentLocale(this.preferredLocale);
2323
2319
  }
2324
2320
 
2325
- /** 页面 `_locale` 绑定表(`page._locale.<键>`):词表信封取当前显示语言的词条,单字典原样 */
2321
+ /** 页面 `_locale` 绑定表(`page._locale.<键>`):词表信封取当前显示语言的词条;无词表为空表 */
2326
2322
  private localeTable(locale: SomaLocaleBundle | Record<string, unknown>): Record<string, string> {
2327
- // @soma-compat core-locale-single-dict
2328
- return isLocaleBundle(locale)
2329
- ? this.localeCatalog.dictionary()
2330
- : locale as Record<string, string>;
2323
+ return isLocaleBundle(locale) ? this.localeCatalog.dictionary() : {};
2331
2324
  }
2332
2325
 
2333
2326
  /** 缺词条回退上报(ERR-LOCALE-001,soma-ui 码表;不抛、不中断渲染) */
@@ -2357,7 +2350,6 @@ export class SomaBootstrap {
2357
2350
  private refreshLocaleSurface(): void {
2358
2351
  this.preferredLocale = this.localeCatalog.currentLocale();
2359
2352
  this.localeBinder.rerender(this.localeCatalog);
2360
- // @soma-compat core-locale-single-dict(单字典没有可切换的语言)
2361
2353
  if (this.domainInstance && isLocaleBundle(this.lastLocale)) {
2362
2354
  this.domainInstance._locale = this.localeTable(this.lastLocale);
2363
2355
  applyLocaleMetadata(this.domainInstance);
@@ -1,6 +1,6 @@
1
1
  /**
2
- * 浏览器侧的 Host 装配桥(06e §2.11;08e AD-APP-01):Host 没有存量约定钩子 `bootstrap/soma-bootstrap.ts`、
3
- * 但有 `soma.app.ts`(`defineSomaApp` 默认导出)时,`next.config.js` 把 `@soma-host/bootstrap/soma-bootstrap`
2
+ * 浏览器侧的 Host 装配桥(06e §2.11;08e AD-APP-01):Host 有 `soma.app.ts`(`defineSomaApp` 默认导出)时,
3
+ * `next.config.js` 把 `@soma-host/bootstrap/soma-bootstrap`
4
4
  * 指到本文件,由装配的 `host.bootstrap()` 交出浏览器引导选项(组件表、控制器、管道、中间件……)。
5
5
  *
6
6
  * `soma.app.ts` 本身必须能进浏览器包(只含纯数据);它惰性引用的服务端面 `./soma.server` 由 next.config 在客户端构建里忽略。
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * 文案服务接口(多语言,06e K8 / 06b 2.2a)。
3
3
  *
4
- * 向下兼容:`t` / `loadContent` / `hasKey` 与单字典时代同名同义;新增的是「当前显示语言」相关成员。
5
- * `loadContent` 在多语言词表之下只作为开发期热替换与兼容入口:消息写入应用缺省语言词表。
4
+ * `loadContent` 在多语言词表之下只作为开发期热替换入口:消息写入应用缺省语言词表。
6
5
  */
7
- import type { SomaLocaleBundle, SomaLocaleDictionary } from '../../../shared/types/locale.types';
6
+ import type { SomaLocaleBundle } from '../../../shared/types/locale.types';
8
7
 
9
8
  export interface II18n {
10
9
  /** 按当前显示语言取文案;回退链 当前语言 → 应用缺省语言 → 内置受控词表 → 键名(缺键返回键名本身) */
11
10
  t(key: string, params?: Record<string, string | number>): string;
12
- /** 把消息并入应用缺省语言词表(单字典兼容入口 / 开发期热替换) */
11
+ /** 把消息并入应用缺省语言词表(开发期热替换) */
13
12
  loadContent(messages: Record<string, string>): void;
14
13
  /** 当前显示语言(或应用缺省语言、内置受控词表)是否有这个词条键 */
15
14
  hasKey(key: string): boolean;
@@ -19,6 +18,6 @@ export interface II18n {
19
18
  locales(): readonly string[];
20
19
  /** 设当前显示语言;不在 `locales()` 内返回 false 且不改变当前语言 */
21
20
  setCurrentLocale(locale: string): boolean;
22
- /** 装载多语言词表(单字典视为应用缺省语言词表) */
23
- loadBundle(bundle: SomaLocaleBundle | SomaLocaleDictionary): void;
21
+ /** 装载多语言词表信封;空对象 = 无词表,其余非信封抛错 */
22
+ loadBundle(bundle: SomaLocaleBundle | Readonly<Record<string, unknown>>): void;
24
23
  }
@@ -9,7 +9,7 @@
9
9
  * 不变式:
10
10
  * - 当前显示语言是运行期状态,不进编译身份、不进产物缓存键(这里不碰任何编译产物);
11
11
  * - 业务数据值不是文案,不经本服务;
12
- * - 单字典(扁平 键→文案)按「应用缺省语言词表」处理,与存量 DefaultI18n 行为兼容。
12
+ * - 词表只认信封(`format: soma.locale-bundle`);扁平单字典不是词表,装载抛错。
13
13
  */
14
14
  import type { II18n } from './II18n';
15
15
  import { SOMA_BUILTIN_LOCALE } from './builtin-locale';
@@ -41,7 +41,7 @@ export interface SomaLocaleCatalogOptions {
41
41
  }
42
42
 
43
43
  export class SomaLocaleCatalog implements II18n {
44
- /** 应用词表(产物 / 单字典装载进来的):语言 → 键 → 文案 */
44
+ /** 应用词表(产物词表信封装载进来的):语言 → 键 → 文案 */
45
45
  private readonly dictionaries = new Map<string, Record<string, string>>();
46
46
  private builtin: SomaLocaleBundle;
47
47
  private defaultLocale: string | undefined;
@@ -91,10 +91,13 @@ export class SomaLocaleCatalog implements II18n {
91
91
  this.builtin = builtin;
92
92
  }
93
93
 
94
- loadBundle(bundle: SomaLocaleBundle | SomaLocaleDictionary): void {
95
- // @soma-compat core-locale-single-dict(单字典按缺省语言装入;兼容别名台账登记,removeIn 到期只认词表信封)
94
+ loadBundle(bundle: SomaLocaleBundle | Readonly<Record<string, unknown>>): void {
96
95
  if (!isLocaleBundle(bundle)) {
97
- this.loadContent(bundle as SomaLocaleDictionary as Record<string, string>);
96
+ // 空对象 = 页面没有自带词表;其余一律不是词表信封(扁平单字典不再接受)
97
+ if (typeof bundle !== 'object' || bundle === null || Array.isArray(bundle) || Object.keys(bundle).length > 0) {
98
+ throw new Error('[soma-core][词表] 词表必须是 { format: soma.locale-bundle, defaultLocale, <语言>: { 键: 文案 } } 信封;不接受扁平单字典');
99
+ }
100
+ this.loadContent({});
98
101
  return;
99
102
  }
100
103
  for (const locale of localesOf(bundle)) {
@@ -28,7 +28,7 @@ export interface SomaIdentityPort {
28
28
  /** 当前提供了哪些闭集字段(explain 用) */
29
29
  provided(): readonly SomaUserRefField[];
30
30
  /**
31
- * 身份变更通知(可选,向后兼容:旧实现 / 手写端口可以没有)。返回取消订阅函数。
31
+ * 身份变更通知(可选:手写端口可以没有)。返回取消订阅函数。
32
32
  * 来源两路:Host 的 provider 函数上挂了 `subscribe`;或调用 `notifyChanged()`(Host 切换身份后主动告知)。
33
33
  */
34
34
  subscribe?(listener: () => void): () => void;
@@ -58,7 +58,6 @@ export {
58
58
  } from './compose-keys';
59
59
  export {
60
60
  createKeyboardWiring,
61
- type KeyboardContract,
62
61
  type KeyboardDateStep,
63
62
  type KeyboardWiring,
64
63
  type KeyboardWiringOptions,
@@ -26,9 +26,6 @@ import {
26
26
  import { createTypeahead } from './typeahead';
27
27
  import { isImeProcessing } from './ime';
28
28
 
29
- /** 兼容别名:契约段本身就是接线的输入 */
30
- export type KeyboardContract = SomaContractKeyboard;
31
-
32
29
  /**
33
30
  * 日期网格的一步(契约 `date_grid: true`,F-19):`days` / `months` / `years` 是带符号的步长,
34
31
  * `edge` 是本周首末。四个字段互斥,每次只给一个——"往哪走多远"由矩阵定,"那一天是哪天"由组件算。
@@ -458,7 +458,7 @@ export function parseUiConfig(raw: any, options?: SomaUiConfigParseOptions): UiC
458
458
  // 片段载体的键闭集与样式注入键文法
459
459
  /** 产物键闭集(以产物类型为准做编译期对账) */
460
460
  const FRAGMENTS_ARTIFACT_KEYS = {
461
- format: true, version: true, regions: true, scopes: true, css: true, css_key: true, degradedRegions: true,
461
+ format: true, regions: true, scopes: true, css: true, css_key: true, degradedRegions: true,
462
462
  } as const satisfies Record<keyof SomaPageFragments, true>;
463
463
 
464
464
  /** 样式注入键文法:`<前缀>:<内容哈希前 8 位十六进制>`(通用哈希键,前缀由产出方自取) */
@@ -482,8 +482,7 @@ export function parseFragmentsSection(raw: unknown, label: string = SOMA_FRAGMEN
482
482
  }
483
483
  // 按产物契约的原始视图读(键取自 SomaPageFragments、值未核),逐项核完再搬进重建的产物
484
484
  const entry = raw as SomaRawJson<SomaPageFragments>;
485
- // 格式标识:目标字段 `format`,存量 `version: 1` 迁移期双认;两者都不认识的产物整份不可信,不猜字段
486
- // @soma-compat core-region-artifact-version(兼容别名台账登记,removeIn 到期删本分支与下方 version 搬运)
485
+ // 格式标识:只认 `format`;不认识的产物整份不可信,不猜字段
487
486
  // 键闭集:产物格式收紧后不再有 `components`(生成组件定义已退役)——带它的是旧格式产物,
488
487
  // 走摘要不等的自动重编,不在运行时兼容;其余未知键同样整份拒收,不静默丢弃
489
488
  if (Object.hasOwn(entry, 'components')) {
@@ -494,10 +493,10 @@ export function parseFragmentsSection(raw: unknown, label: string = SOMA_FRAGMEN
494
493
  );
495
494
  }
496
495
  shapeClosedKeys(entry as Record<string, unknown>, FRAGMENTS_ARTIFACT_KEYS, label, label);
497
- if (entry.format !== SOMA_FRAGMENTS_FORMAT && entry.version !== 1) {
496
+ if (entry.format !== SOMA_FRAGMENTS_FORMAT) {
498
497
  throw new SomaUiConfigError(
499
- `${label} 的格式标识不认识(format 须为 ${SOMA_FRAGMENTS_FORMAT},或存量 version 为 1),`
500
- + `收到 format=${JSON.stringify(entry.format)} version=${JSON.stringify(entry.version)}`
498
+ `${label} 的格式标识不认识(format 须为 ${SOMA_FRAGMENTS_FORMAT}),`
499
+ + `收到 format=${JSON.stringify(entry.format)}`
501
500
  + '——格式对不上的产物整份不可信,按旧字段名读出来的界面是谁都没设计过的样子',
502
501
  `${label}.format`,
503
502
  );
@@ -512,11 +511,9 @@ export function parseFragmentsSection(raw: unknown, label: string = SOMA_FRAGMEN
512
511
  }
513
512
  }
514
513
  const artifact: SomaPageFragments = {
514
+ format: SOMA_FRAGMENTS_FORMAT,
515
515
  regions: entry.regions as SomaPageFragments['regions'],
516
516
  };
517
- // 显式搬进格式标识:这个函数重建产物对象,不搬的键就是"能写、不报错、值被静默丢弃"
518
- if (entry.format === SOMA_FRAGMENTS_FORMAT) artifact.format = SOMA_FRAGMENTS_FORMAT;
519
- if (entry.version === 1) artifact.version = 1;
520
517
  if (entry.degradedRegions !== undefined) {
521
518
  if (!Array.isArray(entry.degradedRegions)) {
522
519
  throw new SomaUiConfigError(`${label}.degradedRegions 必须是数组`, `${label}.degradedRegions`);
@@ -30,7 +30,7 @@ export interface PrecompiledDeclarationAssets extends ComponentTreeRuntimeEnvelo
30
30
  compiledStyles?: unknown;
31
31
  /** 页面色彩方案声明(KC2 colorScheme);core 只透传 */
32
32
  colorScheme?: unknown;
33
- /** 多语言词表(KC2 locale,单字典或 bundle 双认);core 只透传 */
33
+ /** 多语言词表(KC2 locale,只认词表信封);core 只透传 */
34
34
  locale?: unknown;
35
35
  }
36
36
 
@@ -157,7 +157,7 @@ function createNoopUiService(): SomaUiService {
157
157
 
158
158
  export function createDefaultRuntimeServices(options?: {
159
159
  appConfig?: unknown;
160
- /** 页面词表:多语言词表信封,或单字典(视为应用缺省语言词表) */
160
+ /** 页面词表:多语言词表信封 */
161
161
  locale?: Record<string, unknown>;
162
162
  initialPath?: string;
163
163
  /** Host 提供的角色集来源(KC13 `auth`):给出时角色判定走默认拒绝的角色门 */