soma-core 1.5.1 → 2.0.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.
Files changed (173) hide show
  1. package/app/SomaPageClient.tsx +28 -9
  2. package/app/soma/manifest/route.ts +3 -0
  3. package/bin/migrate.cjs +71 -1
  4. package/bin/soma-lsp.cjs +8 -1
  5. package/core/build/blocks/block-compile.ts +23 -5
  6. package/core/build/compiler/full-manifest-builder.ts +15 -0
  7. package/core/build/compiler/page-assets.ts +17 -1
  8. package/core/build/compiler/page-declaration-compiler.ts +67 -11
  9. package/core/build/compiler/precompiled-manifest-loader.ts +7 -0
  10. package/core/build/compiler/soma-manifest-webpack-plugin.js +7 -0
  11. package/core/build/compiler/soma-precompile.js +212 -21
  12. package/core/build/component/package-loader.ts +35 -4
  13. package/core/build/component-tree/artifact-codec.ts +192 -0
  14. package/core/build/component-tree/binding-bridge.ts +272 -0
  15. package/core/build/component-tree/collection-binding-lowerer.ts +65 -0
  16. package/core/build/component-tree/definition-preparation.ts +320 -0
  17. package/core/build/component-tree/migration-files.ts +214 -0
  18. package/core/build/component-tree/migration.ts +170 -0
  19. package/core/build/component-tree/parser.ts +362 -0
  20. package/core/build/component-tree/registry-snapshot.ts +317 -0
  21. package/core/build/component-tree/source-preflight.ts +132 -0
  22. package/core/build/component-tree/structure-topology.ts +63 -0
  23. package/core/build/component-tree/validator.ts +318 -0
  24. package/core/build/eject/component-eject.ts +1 -0
  25. package/core/build/lsp/component-tree-service.ts +79 -0
  26. package/core/build/lsp/component-tree.cjs +42 -0
  27. package/core/build/lsp/cross-file-diagnostics.cjs +15 -3
  28. package/core/build/lsp/extra-completion.cjs +7 -0
  29. package/core/client/adaptive/observer-pool.ts +122 -8
  30. package/core/client/compiler/manifest-compiler.ts +48 -5
  31. package/core/client/component/ai-catalog.ts +41 -3
  32. package/core/client/component/catalog-examples.ts +60 -0
  33. package/core/client/component/component-defaults.ts +1 -1
  34. package/core/client/component/component-definition.types.ts +9 -0
  35. package/core/client/component/component-expander.ts +22 -6
  36. package/core/client/component/component-manager.ts +881 -45
  37. package/core/client/component/component-pack.ts +1 -1
  38. package/core/client/component/component-registry.ts +11 -2
  39. package/core/client/component/scoped-adapter.ts +29 -2
  40. package/core/client/component/structure-adapter.ts +207 -0
  41. package/core/client/component/verify-pack.ts +21 -1
  42. package/core/client/container/SomaContainerAdapter.ts +103 -2
  43. package/core/client/data/data-object-resolver.ts +45 -1
  44. package/core/client/engine/asset-resolver.ts +1 -1
  45. package/core/client/engine/dom-renderer.ts +712 -26
  46. package/core/client/engine/event-engine.ts +328 -21
  47. package/core/client/engine/property-watcher.ts +164 -18
  48. package/core/client/engine/reactive-proxy.ts +194 -23
  49. package/core/client/engine/render-engine.ts +120 -11
  50. package/core/client/engine/row-range.ts +62 -0
  51. package/core/client/engine/row-scope.ts +77 -0
  52. package/core/client/engine/runtime-builder.ts +2 -0
  53. package/core/client/engine/scope-resolver.ts +3 -3
  54. package/core/client/engine/soma-bootstrap.ts +176 -17
  55. package/core/client/parser/adaptive-parser.ts +1 -1
  56. package/core/client/parser/annotation-extractor.ts +1 -1
  57. package/core/client/parser/blocks/page-parser.ts +53 -3
  58. package/core/client/parser/blocks/use-parser.ts +21 -6
  59. package/core/client/parser/data-config-parser.ts +1 -1
  60. package/core/client/parser/pipeline-parser.ts +252 -15
  61. package/core/client/parser/style-config-parser.ts +1 -1
  62. package/core/client/parser/timer-parser.ts +1 -1
  63. package/core/client/parser/trigger-parser.ts +1 -1
  64. package/core/client/parser/ui-config-parser.ts +39 -7
  65. package/core/client/pipes/pipe-registry.ts +45 -4
  66. package/core/client/registry/declaration-renderer.ts +32 -24
  67. package/core/client/registry/remote-page.ts +1 -1
  68. package/core/client/runtime/SomaSnapshotStore.ts +1 -1
  69. package/core/client/scheduler/SomaScheduler.ts +1 -1
  70. package/core/client/security/attribute-presence.ts +3 -0
  71. package/core/client/theme/harmony.ts +135 -13
  72. package/core/client/theme/scene-tokens.ts +17 -2
  73. package/core/client/theme/theme-axes.ts +43 -6
  74. package/core/client/theme/theme-engine.ts +921 -126
  75. package/core/client/validation/contract-validator.ts +2 -2
  76. package/core/index.ts +3 -0
  77. package/core/server/host/page-markup-config.ts +42 -0
  78. package/core/server/host/published-page-artifact-cache.ts +36 -4
  79. package/core/server/host/published-page-assets.ts +13 -7
  80. package/core/server/host/resolve-host-tree-context.ts +43 -0
  81. package/core/server/host/server-page-assets.ts +23 -4
  82. package/core/server/host/soma-page-compile.ts +10 -0
  83. package/core/server/mock/node/cli.mjs +3 -3
  84. package/core/server/page-declaration.ts +7 -0
  85. package/core/server/registry/declaration-precompiler.ts +35 -3
  86. package/core/server/registry/page-registry-repository.ts +31 -3
  87. package/core/server/registry/page-registry-store.ts +64 -7
  88. package/core/server/registry/publish-asset-pin.ts +6 -1
  89. package/core/server/registry/services/pages/Get.ts +11 -6
  90. package/core/server/registry/validation/compile-gate.ts +10 -1
  91. package/core/shared/component-tree-artifact.ts +237 -0
  92. package/core/shared/component-tree-errors.ts +52 -0
  93. package/core/shared/path-algebra.ts +1 -1
  94. package/core/shared/types/component-contract.types.ts +51 -0
  95. package/core/shared/types/component-tree-artifact.types.ts +121 -0
  96. package/core/shared/types/component-tree.types.ts +170 -0
  97. package/core/shared/types/engine.types.ts +5 -0
  98. package/core/shared/types/event.types.ts +8 -4
  99. package/core/shared/types/manifest.types.ts +4 -0
  100. package/core/shared/types/ui-config.types.ts +8 -0
  101. package/dist/cli/soma.js +1 -1
  102. package/dist/core/index.cjs +14508 -11358
  103. package/dist/lsp/component-tree.cjs +20997 -0
  104. package/dist/types/build/blocks/block-compile.d.ts +10 -1
  105. package/dist/types/build/compiler/full-manifest-builder.d.ts +9 -0
  106. package/dist/types/build/compiler/page-assets.d.ts +6 -1
  107. package/dist/types/build/compiler/page-declaration-compiler.d.ts +11 -1
  108. package/dist/types/build/component/package-loader.d.ts +4 -1
  109. package/dist/types/build/component-tree/artifact-codec.d.ts +50 -0
  110. package/dist/types/build/component-tree/binding-bridge.d.ts +19 -0
  111. package/dist/types/build/component-tree/collection-binding-lowerer.d.ts +18 -0
  112. package/dist/types/build/component-tree/definition-preparation.d.ts +11 -0
  113. package/dist/types/build/component-tree/migration-files.d.ts +35 -0
  114. package/dist/types/build/component-tree/migration.d.ts +28 -0
  115. package/dist/types/build/component-tree/parser.d.ts +13 -0
  116. package/dist/types/build/component-tree/registry-snapshot.d.ts +15 -0
  117. package/dist/types/build/component-tree/source-preflight.d.ts +22 -0
  118. package/dist/types/build/component-tree/structure-topology.d.ts +7 -0
  119. package/dist/types/build/component-tree/validator.d.ts +9 -0
  120. package/dist/types/build/lsp/component-tree-service.d.ts +34 -0
  121. package/dist/types/client/adaptive/observer-pool.d.ts +9 -2
  122. package/dist/types/client/compiler/manifest-compiler.d.ts +11 -2
  123. package/dist/types/client/component/ai-catalog.d.ts +18 -1
  124. package/dist/types/client/component/catalog-examples.d.ts +18 -0
  125. package/dist/types/client/component/component-definition.types.d.ts +9 -0
  126. package/dist/types/client/component/component-expander.d.ts +2 -1
  127. package/dist/types/client/component/component-manager.d.ts +97 -0
  128. package/dist/types/client/component/scoped-adapter.d.ts +1 -0
  129. package/dist/types/client/component/structure-adapter.d.ts +17 -0
  130. package/dist/types/client/container/SomaContainerAdapter.d.ts +8 -0
  131. package/dist/types/client/data/data-object-resolver.d.ts +19 -0
  132. package/dist/types/client/engine/dom-renderer.d.ts +125 -2
  133. package/dist/types/client/engine/event-engine.d.ts +62 -3
  134. package/dist/types/client/engine/property-watcher.d.ts +41 -1
  135. package/dist/types/client/engine/reactive-proxy.d.ts +42 -2
  136. package/dist/types/client/engine/render-engine.d.ts +55 -3
  137. package/dist/types/client/engine/row-range.d.ts +13 -0
  138. package/dist/types/client/engine/row-scope.d.ts +20 -0
  139. package/dist/types/client/engine/runtime-builder.d.ts +1 -0
  140. package/dist/types/client/engine/soma-bootstrap.d.ts +4 -1
  141. package/dist/types/client/parser/blocks/use-parser.d.ts +18 -0
  142. package/dist/types/client/parser/pipeline-parser.d.ts +12 -4
  143. package/dist/types/client/parser/ui-config-parser.d.ts +2 -0
  144. package/dist/types/client/pipes/pipe-registry.d.ts +39 -1
  145. package/dist/types/client/registry/declaration-renderer.d.ts +5 -1
  146. package/dist/types/client/registry/remote-page.d.ts +1 -1
  147. package/dist/types/client/theme/harmony.d.ts +44 -2
  148. package/dist/types/client/theme/scene-tokens.d.ts +11 -1
  149. package/dist/types/client/theme/theme-axes.d.ts +36 -6
  150. package/dist/types/index.d.ts +3 -1
  151. package/dist/types/server/host/page-markup-config.d.ts +6 -0
  152. package/dist/types/server/host/published-page-artifact-cache.d.ts +9 -1
  153. package/dist/types/server/host/published-page-assets.d.ts +5 -3
  154. package/dist/types/server/host/resolve-host-tree-context.d.ts +8 -0
  155. package/dist/types/server/host/server-page-assets.d.ts +6 -0
  156. package/dist/types/server/host/soma-page-compile.d.ts +10 -1
  157. package/dist/types/server/page-declaration.d.ts +6 -0
  158. package/dist/types/server/registry/declaration-precompiler.d.ts +8 -3
  159. package/dist/types/server/registry/page-registry-repository.d.ts +5 -0
  160. package/dist/types/server/registry/page-registry-store.d.ts +11 -1
  161. package/dist/types/server/registry/publish-asset-pin.d.ts +4 -0
  162. package/dist/types/server/registry/validation/compile-gate.d.ts +4 -1
  163. package/dist/types/shared/component-tree-artifact.d.ts +5 -0
  164. package/dist/types/shared/component-tree-errors.d.ts +22 -0
  165. package/dist/types/shared/types/component-contract.types.d.ts +42 -0
  166. package/dist/types/shared/types/component-tree-artifact.types.d.ts +104 -0
  167. package/dist/types/shared/types/component-tree.types.d.ts +149 -0
  168. package/dist/types/shared/types/engine.types.d.ts +5 -0
  169. package/dist/types/shared/types/event.types.d.ts +8 -4
  170. package/dist/types/shared/types/manifest.types.d.ts +4 -0
  171. package/dist/types/shared/types/ui-config.types.d.ts +8 -0
  172. package/package.json +5 -4
  173. package/dist/preview-export.cjs +0 -3401
@@ -19,6 +19,9 @@
19
19
 
20
20
  import fs from 'node:fs';
21
21
  import type { CompiledPageDeclaration } from '../../build/compiler/page-declaration-compiler';
22
+ import type { SomaPageMarkup, TreeCompileContext } from '../../shared/types/component-tree.types';
23
+ import { resolvePageMarkup } from '../../build/component-tree/source-preflight';
24
+ import { resolveHostTreeCompileContext } from '../host/resolve-host-tree-context';
22
25
  import {
23
26
  DECLARATION_COMPILER_VERSION,
24
27
  precompileDeclaration,
@@ -120,6 +123,8 @@ export class PageRegistryError extends RegistryError {
120
123
 
121
124
  /** 页面声明本体:与 /api/ai-page/generate 的产物同构(dataYaml 为数据对象绑定拓展位) */
122
125
  export interface PageRegistryDeclaration {
126
+ markup?: SomaPageMarkup;
127
+ grammarVersion?: number;
123
128
  html: string;
124
129
  uiYaml: string;
125
130
  eventYaml: string;
@@ -196,6 +201,7 @@ export interface PageRegistryWriteOptions {
196
201
 
197
202
  /** 追加新版本时的规范化字段;文件后端与条件写后端共用同一状态机输入。 */
198
203
  export interface PageVersionFields {
204
+ treeContext?: TreeCompileContext;
199
205
  declaration: PageRegistryDeclaration;
200
206
  status: PageRegistryStatus;
201
207
  app: string;
@@ -264,6 +270,8 @@ export interface PageRegistryListResult {
264
270
  }
265
271
 
266
272
  export interface PageRegistryStoreOptions {
273
+ /** Trusted server assembly only; never accepted through publish request options. */
274
+ treeContextResolver?: (name: string, app: string) => TreeCompileContext | undefined;
267
275
  /** 持久化目录(每页面一个 <name>.json),默认 data/soma-runtime/pages */
268
276
  baseDir?: string;
269
277
  /** 时钟注入点,默认 Date.now;测试传确定性时钟 */
@@ -271,6 +279,7 @@ export interface PageRegistryStoreOptions {
271
279
  }
272
280
 
273
281
  export class PageRegistryStore {
282
+ private readonly treeContextResolver: NonNullable<PageRegistryStoreOptions['treeContextResolver']>;
274
283
  private readonly baseDir: string;
275
284
  private readonly now: () => number;
276
285
  /**
@@ -285,6 +294,13 @@ export class PageRegistryStore {
285
294
  constructor(options: PageRegistryStoreOptions = {}) {
286
295
  this.baseDir = path.resolve(options.baseDir ?? path.join('data', 'soma-runtime', 'pages'));
287
296
  this.now = options.now ?? Date.now;
297
+ this.treeContextResolver = options.treeContextResolver ?? ((name, app) => (
298
+ resolveHostTreeCompileContext(process.env.SOMA_HOST_DIR, { pageBase: name, app })
299
+ ));
300
+ }
301
+
302
+ getTreeCompileContext(name: string, app: string): TreeCompileContext | undefined {
303
+ return this.treeContextResolver(name, app);
288
304
  }
289
305
 
290
306
  /** 供共享 FS 聚合协调器使用;对象存储模式不依赖本地路径。 */
@@ -313,7 +329,9 @@ export class PageRegistryStore {
313
329
  ): PageVersionRecord {
314
330
  const safeName = assertPageName(name);
315
331
  const normalizedOptions = normalizePublishOptions(options);
316
- const { declaration: normalized, compiledPage } = normalizeDeclaration(declaration);
332
+ const treeContext = isTreeDeclaration(declaration)
333
+ ? this.getTreeCompileContext(safeName, normalizedOptions.app ?? 'default') : undefined;
334
+ const { declaration: normalized, compiledPage } = normalizeDeclaration(declaration, treeContext);
317
335
  this.cache.delete(safeName);
318
336
  return this.appendLocked(safeName, {
319
337
  declaration: normalized,
@@ -323,6 +341,7 @@ export class PageRegistryStore {
323
341
  meta: normalizedOptions.meta,
324
342
  operator: normalizedOptions.operator,
325
343
  compiledPage,
344
+ treeContext,
326
345
  });
327
346
  }
328
347
 
@@ -440,8 +459,14 @@ export class PageRegistryStore {
440
459
  assertVersionNumber(version);
441
460
  this.cache.delete(safeName);
442
461
  const target = this.mustFindVersion(safeName, version, '无法回滚');
462
+ const treeContext = target.declaration.markup === 'component-tree'
463
+ ? this.getTreeCompileContext(safeName, target.app) : undefined;
464
+ const verified = target.declaration.markup === 'component-tree'
465
+ ? normalizeDeclaration(target.declaration, treeContext) : undefined;
443
466
  return this.appendLocked(safeName, {
444
- declaration: target.declaration,
467
+ declaration: verified?.declaration ?? target.declaration,
468
+ compiledPage: verified?.compiledPage,
469
+ treeContext,
445
470
  status: 'published',
446
471
  app: target.app,
447
472
  tags: target.tags,
@@ -696,7 +721,12 @@ export function createPageVersionRecord(
696
721
  };
697
722
  // 发布路径上闸门已经编过这同一份声明(`fields.compiledPage`),直接复用;
698
723
  // rollback / archive 复制的是旧声明,没有闸门那一次,照旧在这里编。
699
- const compiled = precompileDeclaration(fields.declaration, fields.compiledPage);
724
+ const compiled = fields.status === 'archived' && fields.declaration.markup === 'component-tree'
725
+ ? null : precompileDeclaration(fields.declaration, fields.compiledPage, fields.treeContext);
726
+ if (fields.status !== 'archived' && fields.declaration.markup === 'component-tree' && !compiled) {
727
+ throw new PageRegistryError(PageRegistryErrorCodes.PAGE_DECLARATION_INVALID,
728
+ '组件树未产生完整、可验证的编译产物;不会创建新版本');
729
+ }
700
730
  // 钉资产必须与产生版本记录**在同一步**完成:分成两步就有了"版本已落库、资产还没落库"
701
731
  // 的中间态,而那个中间态崩一次就留下一个指向不存在字节的钉子。
702
732
  //
@@ -707,6 +737,7 @@ export function createPageVersionRecord(
707
737
  const assets = pinPublishedAssets(fields.declaration, {
708
738
  compilerVersion: compiled?.compilerVersion ?? DECLARATION_COMPILER_VERSION,
709
739
  ...(artifact ? { artifact } : {}),
740
+ ...(compiled?.artifact ? { componentRefs: compiled.artifact.componentRefs } : {}),
710
741
  });
711
742
  // 组件库在两次发布之间换了,就在**发布这一刻**说;等回滚时再说已经是故障现场了。
712
743
  const drift = assetSupplyDriftNotice(
@@ -854,7 +885,7 @@ function normalizeMeta(meta: unknown): PageRegistryMeta {
854
885
  * **同一份归一化声明**、同一个纯函数,发布路径上相邻两步——第二遍只是重付一次编译代价
855
886
  * (演绎链接进来之后这笔代价随声明规模长),而落库结果逐字相同,多编一遍不会让任何东西红。
856
887
  */
857
- export function normalizeDeclaration(declaration: unknown): {
888
+ export function normalizeDeclaration(declaration: unknown, treeContext?: TreeCompileContext): {
858
889
  declaration: PageRegistryDeclaration;
859
890
  compiledPage: CompiledPageDeclaration;
860
891
  } {
@@ -865,6 +896,16 @@ export function normalizeDeclaration(declaration: unknown): {
865
896
  );
866
897
  }
867
898
  const source = declaration as Record<string, unknown>;
899
+ if (source.markup !== undefined && source.markup !== 'legacy-html' && source.markup !== 'component-tree') {
900
+ throw new PageRegistryError(PageRegistryErrorCodes.PAGE_DECLARATION_INVALID, 'declaration.markup 不受支持');
901
+ }
902
+ if (source.grammarVersion !== undefined && typeof source.grammarVersion !== 'number') {
903
+ throw new PageRegistryError(PageRegistryErrorCodes.PAGE_DECLARATION_INVALID, 'declaration.grammarVersion 必须为数字');
904
+ }
905
+ const format: { markup?: SomaPageMarkup; grammarVersion?: number } = {
906
+ markup: source.markup, grammarVersion: source.grammarVersion,
907
+ };
908
+ resolvePageMarkup(format);
868
909
  for (const field of ['html', 'uiYaml'] as const) {
869
910
  if (typeof source[field] !== 'string' || source[field] === '') {
870
911
  throw new PageRegistryError(
@@ -893,6 +934,8 @@ export function normalizeDeclaration(declaration: unknown): {
893
934
  html: source.html as string,
894
935
  uiYaml: source.uiYaml as string,
895
936
  eventYaml: '',
937
+ ...(format.markup !== undefined ? { markup: format.markup } : {}),
938
+ ...(format.grammarVersion !== undefined ? { grammarVersion: format.grammarVersion } : {}),
896
939
  notes: (source.notes as string | undefined) || undefined,
897
940
  };
898
941
 
@@ -917,7 +960,7 @@ export function normalizeDeclaration(declaration: unknown): {
917
960
  // 取 WithDiagnostics 形态有两个理由:
918
961
  // ① 拒绝时把结构化诊断(code / src / trace / remedy)挂到错误上,AI 修订链才修得动;
919
962
  // ② 通过时把编译产物留在手里,下面的取数白名单与落库的预编译产物都直接复用,不再编第二遍。
920
- const gate = dryRunCompileWithDiagnostics(normalized);
963
+ const gate = dryRunCompileWithDiagnostics(normalized, treeContext);
921
964
  if (gate.issues.length > 0) {
922
965
  throw new PageRegistryError(
923
966
  PageRegistryErrorCodes.PAGE_DECLARATION_INVALID,
@@ -927,7 +970,9 @@ export function normalizeDeclaration(declaration: unknown): {
927
970
  }
928
971
 
929
972
  // 组件存在性:引用了宿主没注册的组件就拦住(宿主没交清单时本闸门不判定)。
930
- const unknownComponents = scanUnknownComponents(normalized.html);
973
+ // Trees were checked against the explicit snapshot, not the legacy process-wide name list.
974
+ const unknownComponents = normalized.markup === 'component-tree'
975
+ ? [] : scanUnknownComponents(normalized.html);
931
976
  if (unknownComponents.length > 0) {
932
977
  throw new PageRegistryError(
933
978
  PageRegistryErrorCodes.PAGE_DECLARATION_INVALID,
@@ -952,6 +997,11 @@ export function normalizeDeclaration(declaration: unknown): {
952
997
  + '这不是声明的问题,请检查 soma-core 产物是否陈旧(npm run build:precompile / build:core-dist)后重试。',
953
998
  );
954
999
  }
1000
+ const unsafeOutput = scanDeclarationSafety({ ...normalized, html: gate.compiled.runtimeAssets.html });
1001
+ if (unsafeOutput.length > 0) {
1002
+ throw new PageRegistryError(PageRegistryErrorCodes.PAGE_DECLARATION_INVALID,
1003
+ `编译产物未通过安全扫描:${unsafeOutput.join(';')}`);
1004
+ }
955
1005
  const unregistered = crossCheckDeclaredApis(gate.compiled.dataConfig);
956
1006
  if (unregistered.length > 0) {
957
1007
  throw new PageRegistryError(
@@ -963,13 +1013,20 @@ export function normalizeDeclaration(declaration: unknown): {
963
1013
  return { declaration: normalized, compiledPage: gate.compiled };
964
1014
  }
965
1015
 
1016
+ /** Inspect only the format discriminator; the full declaration is validated by normalizeDeclaration. */
1017
+ export function isTreeDeclaration(value: unknown): boolean {
1018
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
1019
+ && (value as Record<string, unknown>).markup === 'component-tree';
1020
+ }
1021
+
966
1022
  /** 声明总字节数:UTF-8 计,涵盖 declaration 的全部字符串字段 */
967
1023
  export function declarationByteSize(declaration: PageRegistryDeclaration): number {
968
1024
  let bytes = 0;
969
- for (const field of ['html', 'uiYaml', 'eventYaml', 'styleYaml', 'dataYaml', 'notes'] as const) {
1025
+ for (const field of ['html', 'uiYaml', 'eventYaml', 'styleYaml', 'dataYaml', 'notes', 'markup'] as const) {
970
1026
  const value = declaration[field];
971
1027
  if (typeof value === 'string') bytes += Buffer.byteLength(value, 'utf8');
972
1028
  }
1029
+ if (declaration.grammarVersion !== undefined) bytes += Buffer.byteLength(String(declaration.grammarVersion), 'utf8');
973
1030
  return bytes;
974
1031
  }
975
1032
 
@@ -180,6 +180,8 @@ export interface PinnableDeclaration {
180
180
  }
181
181
 
182
182
  export interface PinPublishedAssetsOptions {
183
+ /** Tree compilation includes macros and the complete transitive uses closure. */
184
+ componentRefs?: readonly { name: string }[];
183
185
  /** 演绎产物。演绎选出的组件不在 `html` 里,不带上就会漏钉恰好是演绎选中的那些 */
184
186
  artifact?: SomaPageOouiArtifact | undefined;
185
187
  /** 资产库(缺省取进程共享库) */
@@ -295,7 +297,10 @@ export function pinPublishedAssets(
295
297
  const supply = currentAssetSupply();
296
298
  if (!supply) return null;
297
299
 
298
- const members = pinnedAssetMembers(declaration?.html ?? '', options.artifact);
300
+ const members = [...new Set([
301
+ ...pinnedAssetMembers(declaration?.html ?? '', options.artifact),
302
+ ...(options.componentRefs ?? []).map((ref) => ref.name),
303
+ ])].sort();
299
304
  if (members.length === 0) return null;
300
305
 
301
306
  const assembled = assembleComponentCss(supply, members);
@@ -3,7 +3,8 @@ import {
3
3
  pageRegistryErrorResponse,
4
4
  pageRegistrySuccessResponse,
5
5
  } from '../../registry-response';
6
- import { PageRegistryError, PageRegistryErrorCodes } from '../../page-registry-store';
6
+ import { PageRegistryError, PageRegistryErrorCodes, type PageVersionRecord } from '../../page-registry-store';
7
+ import type { TreeCompileContext } from '../../../../shared/types/component-tree.types';
7
8
  import { getPageRegistryRepository } from '../../page-registry-repository';
8
9
  import { isCompiledUsable, precompileDeclaration } from '../../declaration-precompiler';
9
10
  import { isRegistryReadPrivileged } from '../../registry-write-pipeline';
@@ -14,8 +15,8 @@ import { readQueryParams } from '../service-utils';
14
15
  * 与"当前运行的是哪个版本"的地方——客户端拿不到后者,在那边判是自欺。
15
16
  * 版本对不上就在服务端从统一源声明重新编译;浏览器没有源声明解析回退。
16
17
  */
17
- function withUsableCompiled<T extends { compiled?: unknown; declaration?: unknown }>(record: T): T {
18
- if (isCompiledUsable(record.compiled as never)) {
18
+ function withUsableCompiled(record: PageVersionRecord, treeContext?: TreeCompileContext): PageVersionRecord {
19
+ if (isCompiledUsable(record.compiled, undefined, undefined, { declaration: record.declaration, treeContext })) {
19
20
  return record;
20
21
  }
21
22
  const declaration = record.declaration;
@@ -25,7 +26,7 @@ function withUsableCompiled<T extends { compiled?: unknown; declaration?: unknow
25
26
  '存量页面记录缺少统一 SOMA DSL 声明,请先离线迁移后再读取',
26
27
  );
27
28
  }
28
- const compiled = precompileDeclaration(declaration as never);
29
+ const compiled = precompileDeclaration(declaration, undefined, treeContext);
29
30
  if (!compiled) {
30
31
  throw new PageRegistryError(
31
32
  PageRegistryErrorCodes.PAGE_DECLARATION_INVALID,
@@ -70,10 +71,14 @@ export default class GetService implements IService {
70
71
  if (explicitVersion !== undefined) {
71
72
  const record = await repository.get(name, explicitVersion);
72
73
  assertReadableStatus(record, req);
73
- return pageRegistrySuccessResponse(withUsableCompiled({ ...record }));
74
+ const treeContext = record.declaration.markup === 'component-tree'
75
+ ? repository.getTreeCompileContext?.(record.name, record.app) : undefined;
76
+ return pageRegistrySuccessResponse({ ...withUsableCompiled(record, treeContext) });
74
77
  }
75
78
  const record = await repository.get(name);
76
- return pageRegistrySuccessResponse(withUsableCompiled({ ...record }));
79
+ const treeContext = record.declaration.markup === 'component-tree'
80
+ ? repository.getTreeCompileContext?.(record.name, record.app) : undefined;
81
+ return pageRegistrySuccessResponse({ ...withUsableCompiled(record, treeContext) });
77
82
  } catch (error) {
78
83
  return pageRegistryErrorResponse(error);
79
84
  }
@@ -49,8 +49,11 @@
49
49
  // 不能"没编出来就跳过白名单"。
50
50
 
51
51
  import { compilePageDeclaration, type CompiledPageDeclaration } from '../../../build/compiler/page-declaration-compiler';
52
+ import type { SomaPageMarkup, TreeCompileContext } from '../../../shared/types/component-tree.types';
52
53
 
53
54
  export interface CompilableDeclaration {
55
+ markup?: SomaPageMarkup;
56
+ grammarVersion?: number;
54
57
  html: string;
55
58
  uiYaml: string;
56
59
  eventYaml?: string;
@@ -198,11 +201,17 @@ function toDiagnostic(error: unknown, issue: string): SomaCompileDiagnostic {
198
201
  *
199
202
  * `issues` 与 `dryRunCompile()` 逐字一致——两者是同一条判定,不是两套规则。
200
203
  */
201
- export function dryRunCompileWithDiagnostics(declaration: CompilableDeclaration): CompileGateResult {
204
+ export function dryRunCompileWithDiagnostics(
205
+ declaration: CompilableDeclaration,
206
+ treeContext?: TreeCompileContext,
207
+ ): CompileGateResult {
202
208
  try {
203
209
  const compiled = compilePageDeclaration({
204
210
  html: declaration.html ?? '',
205
211
  uiYaml: declaration.uiYaml ?? '',
212
+ markup: declaration.markup,
213
+ grammarVersion: declaration.grammarVersion,
214
+ treeContext,
206
215
  ...(declaration.eventYaml ? { eventYaml: declaration.eventYaml } : {}),
207
216
  ...(declaration.styleYaml ? { styleYaml: declaration.styleYaml } : {}),
208
217
  ...(declaration.dataYaml ? { dataYaml: declaration.dataYaml } : {}),
@@ -0,0 +1,237 @@
1
+ import { SomaComponentTreeError } from './component-tree-errors';
2
+ import {
3
+ COMPONENT_TREE_CAPABILITIES,
4
+ type ComponentTreeRuntimeEnvelope,
5
+ type DefinitionPreparation,
6
+ } from './types/component-tree-artifact.types';
7
+
8
+ const DIGEST = /^[a-f0-9]{64}$/;
9
+ const SYMBOL = /^[A-Za-z_][A-Za-z0-9_-]{0,255}$/;
10
+ const PATH = /^[A-Za-z_$][A-Za-z0-9_$]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*$/;
11
+ const UNSAFE = new Set(['__proto__', 'prototype', 'constructor']);
12
+ const TAGS = new Set(['div', 'main', 'section', 'article', 'aside', 'header', 'footer', 'nav', 'span', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li']);
13
+ type RecordValue = Record<string, unknown>;
14
+
15
+ function fail(path: string, kind: 'shape' | 'version' | 'capability' = 'shape'): never {
16
+ throw new SomaComponentTreeError({
17
+ code: kind === 'version' ? 'CT-ARTIFACT-VERSION'
18
+ : kind === 'capability' ? 'CT-ARTIFACT-CAPABILITY' : 'CT-ARTIFACT-INCOMPLETE',
19
+ phase: 'artifact', sourceId: '<runtime-assets>', nodePath: path,
20
+ fixHint: '组件树资产不完整、不兼容或引用不一致;请由当前服务端重新编译整份资产。',
21
+ });
22
+ }
23
+
24
+ function record(value: unknown, path: string): RecordValue {
25
+ if (!value || typeof value !== 'object' || Array.isArray(value)
26
+ || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail(path);
27
+ return value as RecordValue;
28
+ }
29
+
30
+ function string(value: unknown, path: string, pattern?: RegExp): string {
31
+ if (typeof value !== 'string' || value.length === 0 || (pattern && !pattern.test(value))) fail(path);
32
+ return value;
33
+ }
34
+
35
+ function dataPath(value: unknown, path: string): void {
36
+ const text = string(value, path, PATH);
37
+ if (text.split('.').some(part => UNSAFE.has(part))) fail(path);
38
+ }
39
+
40
+ function list(value: unknown, path: string): unknown[] {
41
+ if (!Array.isArray(value) || value.length > 4096) fail(path);
42
+ return value;
43
+ }
44
+
45
+ function capabilities(value: unknown, path: string): Set<string> {
46
+ const items = list(value, path);
47
+ const result = new Set<string>();
48
+ for (const item of items) {
49
+ if (typeof item !== 'string' || !COMPONENT_TREE_CAPABILITIES.some(known => known === item)) {
50
+ fail(path, 'capability');
51
+ }
52
+ if (result.has(item)) fail(path);
53
+ result.add(item);
54
+ }
55
+ return result;
56
+ }
57
+
58
+ function closed(value: RecordValue, keys: readonly string[], path: string): void {
59
+ if (Object.keys(value).some(key => !keys.includes(key))) fail(path);
60
+ }
61
+
62
+ /** Reject non-wire data before walking nested plans, without invoking accessors. */
63
+ function assertWireData(value: unknown): void {
64
+ const seen = new Set<object>();
65
+ const pending: Array<{ value: unknown; depth: number; leave?: boolean }> = [{ value, depth: 0 }];
66
+ let nodes = 0;
67
+ while (pending.length) {
68
+ const item = pending.pop()!;
69
+ if (item.leave) { seen.delete(item.value as object); continue; }
70
+ if (++nodes > 65536 || item.depth > 96) fail('artifact.limit');
71
+ if (item.value === null || typeof item.value === 'string' || typeof item.value === 'boolean') continue;
72
+ if (typeof item.value === 'number' && Number.isFinite(item.value)) continue;
73
+ if (!item.value || typeof item.value !== 'object' || seen.has(item.value)) fail('artifact.data');
74
+ seen.add(item.value);
75
+ pending.push({ ...item, leave: true });
76
+ if (!Array.isArray(item.value)) record(item.value, 'artifact.data');
77
+ for (const key of Object.keys(item.value)) {
78
+ if (UNSAFE.has(key)) fail('artifact.data');
79
+ const descriptor = Object.getOwnPropertyDescriptor(item.value, key)!;
80
+ if (!('value' in descriptor)) fail('artifact.data');
81
+ pending.push({ value: descriptor.value, depth: item.depth + 1 });
82
+ }
83
+ }
84
+ }
85
+
86
+ /** Pure browser/server schema gate. Hash/context verification remains build/server-owned. */
87
+ export function assertRuntimeArtifact(input: unknown): asserts input is ComponentTreeRuntimeEnvelope {
88
+ const envelope = record(input, 'assets');
89
+ for (const key of ['sourceMarkup', 'html', 'artifact']) {
90
+ const descriptor = Object.getOwnPropertyDescriptor(envelope, key);
91
+ if (descriptor && !('value' in descriptor)) fail('assets.property');
92
+ }
93
+ if (envelope.sourceMarkup === undefined || envelope.sourceMarkup === 'legacy-html') {
94
+ if (envelope.artifact !== undefined) fail('sourceMarkup');
95
+ return;
96
+ }
97
+ if (envelope.sourceMarkup !== 'component-tree') fail('sourceMarkup', 'version');
98
+ string(envelope.html, 'html');
99
+ const artifact = record(envelope.artifact, 'artifact');
100
+ assertWireData(artifact);
101
+ closed(artifact, ['schemaVersion', 'grammarVersion', 'compilerVersion', 'sourceDigest', 'registrySnapshotDigest', 'policyDigest',
102
+ 'assetSupplyKey', 'capabilities', 'componentRefs', 'structurePlan', 'repeatPlans', 'artifactDigest'], 'artifact');
103
+ if (artifact.schemaVersion !== 1 || artifact.grammarVersion !== 1) fail('artifact.schemaVersion', 'version');
104
+ string(artifact.compilerVersion, 'artifact.compilerVersion');
105
+ for (const key of ['sourceDigest', 'registrySnapshotDigest', 'policyDigest', 'artifactDigest']) {
106
+ string(artifact[key], `artifact.${key}`, DIGEST);
107
+ }
108
+ string(artifact.assetSupplyKey, 'artifact.assetSupplyKey');
109
+ const required = capabilities(artifact.capabilities, 'artifact.capabilities');
110
+ if (!required.has('component-tree:1')) fail('artifact.capabilities', 'capability');
111
+ const refs = new Set<string>();
112
+ const refDigests = new Map<string, string>();
113
+ const refDependencies = new Map<string, string[]>();
114
+ for (const value of list(artifact.componentRefs, 'artifact.componentRefs')) {
115
+ const ref = record(value, 'componentRef');
116
+ const name = string(ref.name, 'componentRef.name', /^[A-Z][A-Za-z0-9]*$/);
117
+ if (refs.has(name)) fail('componentRef.name');
118
+ refs.add(name);
119
+ string(ref.contractDigest, 'componentRef.contractDigest', DIGEST);
120
+ string(ref.structureDigest, 'componentRef.structureDigest', DIGEST);
121
+ refDigests.set(name, String(ref.structureDigest));
122
+ refDependencies.set(name, list(ref.uses, 'componentRef.uses').map(dependency => string(dependency, 'componentRef.uses', /^[A-Z][A-Za-z0-9]*$/)));
123
+ for (const key of ['packName', 'packVersion']) if (ref[key] !== undefined) string(ref[key], `componentRef.${key}`);
124
+ }
125
+ if (refs.size === 0) fail('artifact.componentRefs');
126
+ for (const dependencies of refDependencies.values()) {
127
+ if (new Set(dependencies).size !== dependencies.length || dependencies.some(name => !refs.has(name))) fail('componentRef.uses');
128
+ }
129
+ const complete = new Set<string>();
130
+ for (const name of refs) {
131
+ const visiting = new Set<string>();
132
+ const pending = [{ name, leave: false }];
133
+ while (pending.length) {
134
+ const item = pending.pop()!;
135
+ if (item.leave) { visiting.delete(item.name); complete.add(item.name); continue; }
136
+ if (complete.has(item.name)) continue;
137
+ if (visiting.has(item.name)) fail('componentRef.uses');
138
+ visiting.add(item.name);
139
+ pending.push({ name: item.name, leave: true });
140
+ for (const child of refDependencies.get(item.name) ?? []) pending.push({ name: child, leave: false });
141
+ }
142
+ }
143
+ const instances = new Map<string, RecordValue>();
144
+ for (const value of list(artifact.structurePlan, 'artifact.structurePlan')) {
145
+ const plan = record(value, 'structurePlan');
146
+ const symbol = string(plan.instanceSymbol, 'structurePlan.instanceSymbol', SYMBOL);
147
+ if (instances.has(symbol) || !refs.has(string(plan.componentName, 'structurePlan.componentName'))) fail('structurePlan.instanceSymbol');
148
+ instances.set(symbol, plan);
149
+ if (!['legacy-host', 'controlled-host', 'single-host'].includes(String(plan.mountMode))
150
+ || !TAGS.has(String(plan.hostTag))) fail('structurePlan.mountMode');
151
+ if (!required.has('structure-host:1')) fail('artifact.capabilities', 'capability');
152
+ string(plan.structureDigest, 'structurePlan.structureDigest', DIGEST);
153
+ if (plan.structureDigest !== refDigests.get(String(plan.componentName))) fail('structurePlan.structureDigest');
154
+ if (plan.staticProps !== undefined) {
155
+ for (const value of Object.values(record(plan.staticProps, 'structurePlan.staticProps'))) {
156
+ if (typeof value !== 'string' && typeof value !== 'boolean') fail('structurePlan.staticProps');
157
+ }
158
+ }
159
+ if (plan.internalRootId !== undefined) string(plan.internalRootId, 'structurePlan.internalRootId', SYMBOL);
160
+ const slots = new Set<string>();
161
+ for (const item of list(plan.slotPlans, 'structurePlan.slotPlans')) {
162
+ const slot = record(item, 'slotPlan');
163
+ const name = string(slot.name, 'slotPlan.name', SYMBOL);
164
+ if (slots.has(name) || slot.ownerSymbol !== symbol || typeof slot.directChildren !== 'boolean'
165
+ || !['projection', 'collection'].includes(String(slot.kind))) fail('slotPlan');
166
+ slots.add(name);
167
+ if (slot.layoutRootKey !== undefined) string(slot.layoutRootKey, 'slotPlan.layoutRootKey', SYMBOL);
168
+ if ((slot.directChildren || slot.kind === 'collection') && slot.layoutRootKey === undefined) fail('slotPlan.layoutRootKey');
169
+ if (slot.kind === 'collection' && !['none', 'list-item'].includes(String(slot.rowContainer))) fail('slotPlan.rowContainer');
170
+ }
171
+ }
172
+ if (instances.size === 0) fail('artifact.structurePlan');
173
+ const repeats = new Set<string>();
174
+ const repeatPlans = list(artifact.repeatPlans, 'artifact.repeatPlans');
175
+ for (const value of repeatPlans) {
176
+ const plan = record(value, 'repeatPlan');
177
+ const id = string(plan.planId, 'repeatPlan.planId', SYMBOL);
178
+ if (repeats.has(id)) fail('repeatPlan.planId');
179
+ repeats.add(id);
180
+ for (const key of ['scopeId', 'rowTemplateId']) string(plan[key], `repeatPlan.${key}`, SYMBOL);
181
+ const alias = string(plan.itemAlias, 'repeatPlan.itemAlias', /^[A-Za-z_$][A-Za-z0-9_$]*$/);
182
+ dataPath(plan.sourcePath, 'repeatPlan.sourcePath');
183
+ dataPath(plan.keyPath, 'repeatPlan.keyPath');
184
+ if (!String(plan.keyPath).startsWith(`${alias}.`)) fail('repeatPlan.keyPath');
185
+ const declaration = record(plan.declarationScope, 'repeatPlan.declarationScope');
186
+ if (!['page', 'component'].includes(String(declaration.kind))) fail('repeatPlan.declarationScope');
187
+ for (const key of ['ownerSymbol', 'emitOwnerSymbol', 'readerRoot']) string(declaration[key], `declarationScope.${key}`);
188
+ const consumer = record(plan.consumerOwner, 'repeatPlan.consumerOwner');
189
+ const owner = instances.get(string(consumer.instanceSymbol, 'consumerOwner.instanceSymbol', SYMBOL));
190
+ if (!owner || owner.componentName !== consumer.componentName || !['none', 'list-item'].includes(String(consumer.rowContainer))) fail('repeatPlan.consumerOwner');
191
+ string(consumer.slotName, 'consumerOwner.slotName', SYMBOL);
192
+ string(consumer.layoutRootKey, 'consumerOwner.layoutRootKey', SYMBOL);
193
+ const outlet = (owner.slotPlans as RecordValue[]).find(slot => slot.name === consumer.slotName);
194
+ if (!outlet || outlet.kind !== 'collection' || outlet.layoutRootKey !== consumer.layoutRootKey
195
+ || outlet.rowContainer !== consumer.rowContainer) fail('repeatPlan.consumerOwner');
196
+ const status = record(plan.statusPlan, 'repeatPlan.statusPlan');
197
+ if (status.kind !== 'sync' && status.kind !== 'async') fail('repeatPlan.statusPlan');
198
+ if (status.kind === 'async') dataPath(status.statePath, 'repeatPlan.statusPlan.statePath');
199
+ for (const symbol of Object.values(record(plan.localSymbols, 'repeatPlan.localSymbols'))) {
200
+ if (!instances.has(string(symbol, 'repeatPlan.localSymbols', SYMBOL))) fail('repeatPlan.localSymbols');
201
+ }
202
+ const limits = record(plan.limits, 'repeatPlan.limits');
203
+ for (const key of ['maxRows', 'maxPageRows', 'maxKeyLength', 'maxDepth']) {
204
+ if (!Number.isSafeInteger(limits[key]) || Number(limits[key]) < 1) fail('repeatPlan.limits');
205
+ }
206
+ }
207
+ const parents = new Map(repeatPlans.map(value => {
208
+ const plan = value as RecordValue;
209
+ return [String(plan.planId), plan.parentPlanId === undefined ? undefined : String(plan.parentPlanId)];
210
+ }));
211
+ for (const value of repeatPlans) {
212
+ const plan = value as RecordValue;
213
+ if (plan.parentPlanId !== undefined && (!repeats.has(String(plan.parentPlanId)) || plan.parentPlanId === plan.planId)) fail('repeatPlan.parentPlanId');
214
+ const ancestors = new Set<string>();
215
+ let current: string | undefined = String(plan.planId);
216
+ while (current !== undefined) {
217
+ if (ancestors.has(current)) fail('repeatPlan.parentPlanId');
218
+ ancestors.add(current);
219
+ current = parents.get(current);
220
+ }
221
+ }
222
+ if (repeatPlans.length && (!required.has('repeat-range:1') || !required.has('row-bindings:1'))) {
223
+ fail('artifact.capabilities', 'capability');
224
+ }
225
+ }
226
+
227
+ /** Definitions carry their own gate even when mounted from a legacy page. */
228
+ export function assertDefinitionPreparation(input: unknown): asserts input is DefinitionPreparation {
229
+ const preparation = record(input, 'definitionPreparation');
230
+ assertWireData(preparation);
231
+ if (preparation.schemaVersion !== 1) fail('definitionPreparation.schemaVersion', 'version');
232
+ capabilities(preparation.requiredCapabilities, 'definitionPreparation.requiredCapabilities');
233
+ string(preparation.definitionDigest, 'definitionPreparation.definitionDigest', DIGEST);
234
+ for (const value of Object.values(record(preparation.dependencyDigests, 'definitionPreparation.dependencyDigests'))) {
235
+ string(value, 'definitionPreparation.dependencyDigests', DIGEST);
236
+ }
237
+ }
@@ -0,0 +1,52 @@
1
+ import type { SourceSpan } from './types/component-tree.types';
2
+
3
+ export type ComponentTreeErrorCode =
4
+ | 'CT-SYNTAX-ROOT' | 'CT-SYNTAX-ELEMENT' | 'CT-SYNTAX-CLOSE' | 'CT-SYNTAX-ATTRIBUTE'
5
+ | 'CT-IDENTITY-ID' | 'CT-IDENTITY-HOST'
6
+ | 'CT-REGISTRY-CONTEXT' | 'CT-REGISTRY-COMPONENT' | 'CT-POLICY-COMPONENT'
7
+ | 'CT-SLOT-CONTRACT' | 'CT-STRUCTURE-MOUNT'
8
+ | 'CT-BINDING-SCOPE' | 'CT-BINDING-DUPLICATE'
9
+ | 'CT-REPEAT-SOURCE' | 'CT-REPEAT-KEY' | 'CT-LIMIT' | 'CT-LAYOUT-PARENT'
10
+ | 'CT-ARTIFACT-VERSION' | 'CT-ARTIFACT-CAPABILITY' | 'CT-ARTIFACT-INCOMPLETE'
11
+ | 'CT-SYNTAX-LEAK' | 'CT-MIGRATION-UNSAFE';
12
+
13
+ export interface ComponentTreeDiagnostic {
14
+ code: ComponentTreeErrorCode;
15
+ phase: 'input' | 'parse' | 'registry' | 'validate' | 'bind' | 'lower' | 'emit' | 'artifact' | 'runtime' | 'migration';
16
+ sourceId: string;
17
+ nodePath: string;
18
+ span?: SourceSpan;
19
+ relatedSpans?: readonly SourceSpan[];
20
+ attribute?: string;
21
+ expected?: string;
22
+ /** Describe the invalid shape/token category, never copy business data or credentials. */
23
+ actualSummary?: string;
24
+ fixHint?: string;
25
+ }
26
+
27
+ /** Stable, serializable diagnostics without retaining the page source or context. */
28
+ export class SomaComponentTreeError extends Error {
29
+ readonly code: ComponentTreeErrorCode;
30
+ readonly diagnostic: Readonly<ComponentTreeDiagnostic>;
31
+
32
+ constructor(diagnostic: ComponentTreeDiagnostic) {
33
+ const at = diagnostic.span
34
+ ? `${diagnostic.sourceId}:${diagnostic.span.startLine}:${diagnostic.span.startColumn}`
35
+ : diagnostic.sourceId;
36
+ super(`[soma-core][${diagnostic.code}] ${at} ${diagnostic.nodePath}`
37
+ + (diagnostic.fixHint ? `: ${diagnostic.fixHint}` : ''));
38
+ this.name = 'SomaComponentTreeError';
39
+ this.code = diagnostic.code;
40
+ this.diagnostic = Object.freeze({
41
+ ...diagnostic,
42
+ ...(diagnostic.span ? { span: Object.freeze({ ...diagnostic.span }) } : {}),
43
+ ...(diagnostic.relatedSpans ? {
44
+ relatedSpans: Object.freeze(diagnostic.relatedSpans.map(span => Object.freeze({ ...span }))),
45
+ } : {}),
46
+ });
47
+ }
48
+
49
+ toJSON(): Readonly<ComponentTreeDiagnostic> {
50
+ return this.diagnostic;
51
+ }
52
+ }
@@ -43,7 +43,7 @@ export function isListPath(reference: string): boolean {
43
43
 
44
44
  export class SomaPathError extends Error {
45
45
  constructor(message: string) {
46
- super(`[SOMA Path] ${message}`);
46
+ super(`[soma-core][引擎] ${message}`);
47
47
  this.name = 'SomaPathError';
48
48
  }
49
49
  }