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
@@ -1,4 +1,4 @@
1
- import type { UiConfig } from '../../shared/types/ui-config.types';
1
+ import type { UiConfig, BindDeclaration } from '../../shared/types/ui-config.types';
2
2
  import { type HtmlAnchorIndex } from './html-index';
3
3
  import { type UseBlockAst } from '../../client/parser/blocks/use-parser';
4
4
  export interface CompiledSomaBlocks {
@@ -34,6 +34,15 @@ export interface CompileSomaBlocksInput {
34
34
  externalBlocks?: ReadonlyMap<string, string>;
35
35
  /** 词典键集合(locale 批量段校验;缺省不校验) */
36
36
  localeKeys?: ReadonlySet<string>;
37
+ /** Build-only AST ownership proof; never derived from regex or exposed as author YAML. */
38
+ treeBindings?: {
39
+ htmlIndex: HtmlAnchorIndex;
40
+ collections: readonly {
41
+ symbol: string;
42
+ parentSymbol?: string;
43
+ bind: BindDeclaration;
44
+ }[];
45
+ };
37
46
  }
38
47
  /**
39
48
  * 编译一份块声明。
@@ -5,8 +5,14 @@ import type { ParsedTimer } from '../../shared/types/timer.types';
5
5
  import type { StyleConfig } from '../../shared/types/style-config.types';
6
6
  import type { SomaDataConfig } from '../../shared/types/data-config.types';
7
7
  import { type SomaRouteEntry } from './route-builder';
8
+ import type { SomaPageMarkup, TreeCompileContext } from '../../shared/types/component-tree.types';
9
+ import type { TreeArtifact } from '../../shared/types/component-tree-artifact.types';
8
10
  export interface SomaPrecompiledPage {
9
11
  path: string;
12
+ /** Optional only for compatibility with manifests created before REQ-016. */
13
+ sourceMarkup?: SomaPageMarkup;
14
+ html?: string;
15
+ artifact?: TreeArtifact;
10
16
  uiConfig: UiConfig;
11
17
  eventConfig: ParsedEvent[];
12
18
  triggers: PropertyTrigger[];
@@ -34,6 +40,9 @@ export declare function precompileAll(inputs: {
34
40
  path: string;
35
41
  html: string;
36
42
  uiYaml: string;
43
+ markup?: SomaPageMarkup;
44
+ grammarVersion?: number;
45
+ treeContext?: TreeCompileContext;
37
46
  appConfigYaml?: string;
38
47
  externalBlocks?: ReadonlyMap<string, string>;
39
48
  includes?: Readonly<Record<string, string>>;
@@ -1,3 +1,8 @@
1
1
  import type { SomaPageAssets } from '../../client/engine/soma-bootstrap';
2
+ import type { SomaPageMarkup, TreeCompileContext } from '../../shared/types/component-tree.types';
2
3
  /** 把 SOMA DSL 源声明编译成客户端挂载所需的运行时资产。 */
3
- export declare function compilePageAssets(assets: SomaPageAssets): SomaPageAssets;
4
+ export declare function compilePageAssets(assets: SomaPageAssets, options?: {
5
+ markup?: SomaPageMarkup;
6
+ grammarVersion?: number;
7
+ treeContext?: TreeCompileContext;
8
+ }): SomaPageAssets;
@@ -5,9 +5,15 @@ import type { StyleConfig } from '../../shared/types/style-config.types';
5
5
  import type { ParsedTimer } from '../../shared/types/timer.types';
6
6
  import type { UiConfig } from '../../shared/types/ui-config.types';
7
7
  import { type SomaEnvironment, type SomaOouiEngine, type SomaTrace } from '../ooui';
8
+ import type { SomaPageMarkup, TreeCompileContext, ComponentTreeTrace } from '../../shared/types/component-tree.types';
9
+ import type { ComponentTreeRuntimeEnvelope } from '../../shared/types/component-tree-artifact.types';
8
10
  export interface SomaPageDeclarationInput {
9
11
  html: string;
10
12
  uiYaml: string;
13
+ /** Explicit source format. Component trees require a trusted Registry/policy context. */
14
+ markup?: SomaPageMarkup;
15
+ grammarVersion?: number;
16
+ treeContext?: TreeCompileContext;
11
17
  eventYaml?: string;
12
18
  styleYaml?: string;
13
19
  dataYaml?: string;
@@ -33,13 +39,17 @@ export interface SomaPageDeclarationInput {
33
39
  /** 演绎环境(可用宽度档、已装配组件清单)。缺省 = 不限宽、不筛候选 */
34
40
  oouiEnv?: SomaEnvironment;
35
41
  }
36
- export interface SomaRuntimeDeclarationAssets {
42
+ export interface SomaRuntimeDeclarationAssets extends ComponentTreeRuntimeEnvelope {
43
+ sourceMarkup: SomaPageMarkup;
44
+ html: string;
37
45
  uiYaml: string;
38
46
  eventYaml: string;
39
47
  styleYaml: string;
40
48
  dataYaml?: string;
41
49
  }
42
50
  export interface CompiledPageDeclaration {
51
+ /** Source/contract/symbol lineage; never sent to browser assets. */
52
+ treeTrace?: ComponentTreeTrace;
43
53
  uiConfig: UiConfig;
44
54
  eventConfig: ParsedEvent[];
45
55
  triggers: PropertyTrigger[];
@@ -1,4 +1,5 @@
1
1
  import type { SomaComponentDefinition } from '../../client/component/component-definition.types';
2
+ import type { ComponentTreeRegistryEntry } from '../component-tree/registry-snapshot';
2
3
  export declare class SomaComponentPackageError extends Error {
3
4
  readonly packageDir: string;
4
5
  /**
@@ -17,6 +18,8 @@ export interface PackScanWarning {
17
18
  message: string;
18
19
  }
19
20
  export interface LoadPackagesOptions {
21
+ /** Actual composed external dependencies for trusted collection preparation. */
22
+ componentTreeDependencies?: readonly ComponentTreeRegistryEntry[];
20
23
  /**
21
24
  * 警告汇总回调(缺省时汇总为单块 console.warn)。
22
25
  * 刻意做成"扫描结束一次性给全部"而不是逐条打印:dev 服务器的滚动输出里,
@@ -33,7 +36,7 @@ interface PackageEntry {
33
36
  packageDir: string;
34
37
  }
35
38
  /** 装载单个组件包目录 → 运行时定义(结构校验 fail fast) */
36
- export declare function loadComponentPackage(packageDir: string): SomaComponentDefinition;
39
+ export declare function loadComponentPackage(packageDir: string, options?: LoadPackagesOptions): SomaComponentDefinition;
37
40
  /** 装载单个组件包目录 → 定义 + 样式 + 警告(供整包装载复用) */
38
41
  export declare function loadComponentPackageEntry(packageDir: string): PackageEntry;
39
42
  /**
@@ -0,0 +1,50 @@
1
+ import type { ComponentTreeRuntimeEnvelope, TreeArtifact } from '../../shared/types/component-tree-artifact.types';
2
+ import type { SomaPageMarkup, TreeCompileContext } from '../../shared/types/component-tree.types';
3
+ /** Increment whenever the tree lowering or logical artifact protocol changes. */
4
+ export declare const TREE_COMPILER_VERSION = "component-tree:1.0.0";
5
+ export interface RuntimeConfigInput {
6
+ uiConfig?: unknown;
7
+ uiYaml?: string;
8
+ eventConfig?: unknown;
9
+ eventYaml?: string;
10
+ triggers?: unknown;
11
+ triggerConfig?: unknown;
12
+ timers?: unknown;
13
+ timerConfig?: unknown;
14
+ dataConfig?: unknown;
15
+ dataYaml?: string;
16
+ styleConfig?: unknown;
17
+ styleYaml?: string;
18
+ layoutCss?: string;
19
+ oouiArtifact?: unknown;
20
+ }
21
+ export interface TreeCompileKeyInput {
22
+ html: string;
23
+ uiYaml: string;
24
+ markup?: SomaPageMarkup;
25
+ grammarVersion?: number;
26
+ treeContext: TreeCompileContext;
27
+ externalBlocks?: ReadonlyMap<string, string>;
28
+ }
29
+ type Data = null | boolean | number | string | Data[] | {
30
+ [key: string]: Data;
31
+ };
32
+ /** Canonical JSON: ordered keys, unchanged strings/array order, no getters or cycles. */
33
+ export declare function canonicalTreeData(value: unknown): Data;
34
+ export declare function digestTreeData(value: unknown): string;
35
+ /** Pure artifact decoding. Never instantiates a Domain or falls back to Host configuration. */
36
+ export declare function normalizeRuntimeConfig(input: RuntimeConfigInput): Data;
37
+ export declare function treeContextIdentity(context: TreeCompileContext): {
38
+ registrySnapshotDigest: string;
39
+ policyDigest: string;
40
+ assetSupplyKey: string;
41
+ };
42
+ export declare function computeTreeSourceDigest(input: Pick<TreeCompileKeyInput, 'html' | 'uiYaml' | 'externalBlocks'>): string;
43
+ export declare function computeTreeCompileKey(input: TreeCompileKeyInput): string;
44
+ export declare function sealTreeRuntimeAssets(input: RuntimeConfigInput & {
45
+ sourceMarkup: 'component-tree';
46
+ html: string;
47
+ artifact: Omit<TreeArtifact, 'artifactDigest'>;
48
+ }): TreeArtifact;
49
+ export declare function verifyTreeRuntimeAssets(input: ComponentTreeRuntimeEnvelope & RuntimeConfigInput, source?: TreeCompileKeyInput): boolean;
50
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { CompileSomaBlocksInput } from '../blocks/block-compile';
2
+ import type { TreeCompileContext, TreeValidationResult, ComponentTreeTrace } from '../../shared/types/component-tree.types';
3
+ import type { ComponentRef, RepeatPlan, StructurePlan } from '../../shared/types/component-tree-artifact.types';
4
+ export interface TreeBindingResult {
5
+ html: string;
6
+ uiYaml: string;
7
+ treeBindings: NonNullable<CompileSomaBlocksInput['treeBindings']>;
8
+ structurePlan: StructurePlan[];
9
+ repeatPlans: RepeatPlan[];
10
+ componentRefs: ComponentRef[];
11
+ effectiveParents: ReadonlyMap<string, string | undefined>;
12
+ trace: ComponentTreeTrace;
13
+ }
14
+ /** AST-owned scopes, canonical rows, lowering and escaped HTML share one symbol table. */
15
+ export declare function bindComponentTree(validated: TreeValidationResult, input: {
16
+ uiYaml: string;
17
+ externalBlocks?: ReadonlyMap<string, string>;
18
+ treeContext: TreeCompileContext;
19
+ }): TreeBindingResult;
@@ -0,0 +1,18 @@
1
+ import type { CollectionConsumerOwner, CollectionDeclarationScope, RepeatPlan } from '../../shared/types/component-tree-artifact.types';
2
+ import { type TreeCollectionSource, type TreeLimits } from '../../shared/types/component-tree.types';
3
+ export interface LowerCollectionBindingInput {
4
+ planId: string;
5
+ scopeId: string;
6
+ parentPlanId?: string;
7
+ sourcePath: string;
8
+ itemAlias: string;
9
+ keyPath: string;
10
+ declarationScope: CollectionDeclarationScope;
11
+ consumerOwner: CollectionConsumerOwner;
12
+ rowTemplateId: string;
13
+ localSymbols: Record<string, string>;
14
+ collectionSources: readonly TreeCollectionSource[];
15
+ limits?: Partial<TreeLimits>;
16
+ }
17
+ /** Shared page/definition source lowering; no controller, reader or DOM execution. */
18
+ export declare function lowerCollectionBinding(input: LowerCollectionBindingInput): RepeatPlan;
@@ -0,0 +1,11 @@
1
+ import type { SomaComponentDefinition } from '../../client/component/component-definition.types';
2
+ import type { TreeRegistrySnapshot } from '../../shared/types/component-tree.types';
3
+ import { type ComponentTreeRegistryEntry } from './registry-snapshot';
4
+ export interface PreparedComponentTreeDefinitions {
5
+ definitions: SomaComponentDefinition[];
6
+ registrySnapshot: TreeRegistrySnapshot;
7
+ }
8
+ /** Prepare real composed definitions on the build/server side, never in a browser factory. */
9
+ export declare function prepareComponentTreeDefinitions(entries: readonly ComponentTreeRegistryEntry[]): PreparedComponentTreeDefinitions;
10
+ /** Trusted templateHtml + nested props/bind/show becomes the same RepeatPlan as a page tree. */
11
+ export declare function lowerDefinitionCollections(definition: SomaComponentDefinition, registry: TreeRegistrySnapshot): SomaComponentDefinition;
@@ -0,0 +1,35 @@
1
+ import { type ComponentTreeMigrationPlan } from './migration';
2
+ import type { TreeCompileContext } from '../../shared/types/component-tree.types';
3
+ interface TrackedFile {
4
+ file: string;
5
+ text: string;
6
+ exists: boolean;
7
+ digest: string;
8
+ external?: string;
9
+ }
10
+ export interface ComponentTreeMigrationPage {
11
+ hostDir: string;
12
+ base: string;
13
+ plan: ComponentTreeMigrationPlan;
14
+ htmlFile: string;
15
+ uiFile: string;
16
+ markupFile: string;
17
+ files: TrackedFile[];
18
+ /** Source packages are inventory-only; modifying installed dependencies is never automatic. */
19
+ writable: boolean;
20
+ }
21
+ /** Standard Host inventory, without loading Domain classes, credentials or application services. */
22
+ export declare function inspectComponentTreeMigrationPage(hostDir: string, pageBase: string, explicitContext?: TreeCompileContext): ComponentTreeMigrationPage;
23
+ export declare function listComponentTreeMigrationPages(hostDir: string): string[];
24
+ /** Explicit proposal output only; existing files are never overwritten. */
25
+ export declare function writeComponentTreeMigrationProposal(page: ComponentTreeMigrationPage, outputDir: string): void;
26
+ /** Reviewed exact plan only. Stage everything first; retain backups and compensate a failed rename. */
27
+ export declare function applyComponentTreeMigrationPlan(page: ComponentTreeMigrationPage, approval: {
28
+ sourceDigest: string;
29
+ planDigest: string;
30
+ reviewed: boolean;
31
+ }): {
32
+ changed: string[];
33
+ backupDirectory: string;
34
+ };
35
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type SomaPageDeclarationInput } from '../compiler/page-declaration-compiler';
2
+ export type ComponentTreeMigrationStatus = 'converted' | 'needs-business-component' | 'unsupported' | 'unchanged';
3
+ export interface ComponentTreeMigrationItem {
4
+ status: 'needs-business-component' | 'unsupported';
5
+ sourcePath: string;
6
+ reason: string;
7
+ }
8
+ export interface ComponentTreeMigrationPlan {
9
+ schemaVersion: 1;
10
+ status: ComponentTreeMigrationStatus;
11
+ sourceDigest: string;
12
+ planDigest: string;
13
+ mappings: Array<{
14
+ sourcePath: string;
15
+ targetPath: string;
16
+ identity?: string;
17
+ }>;
18
+ manualItems: ComponentTreeMigrationItem[];
19
+ requiredComparisons: string[];
20
+ candidate?: {
21
+ markup: 'component-tree';
22
+ grammarVersion: 1;
23
+ html: string;
24
+ uiYaml: string;
25
+ };
26
+ }
27
+ /** Pure migration analysis. It never guesses a component for a native business/layout node. */
28
+ export declare function planComponentTreeMigration(input: SomaPageDeclarationInput): ComponentTreeMigrationPlan;
@@ -0,0 +1,13 @@
1
+ import { type SomaComponentTree, type TreeLimits } from '../../shared/types/component-tree.types';
2
+ export interface ParseComponentTreeOptions {
3
+ sourceId?: string;
4
+ limits?: Partial<TreeLimits>;
5
+ }
6
+ type Tag = 'soma-host' | 'soma-component' | 'soma-slot' | 'soma-fragment' | 'soma-repeat';
7
+ export declare const COMPONENT_TREE_ATTRIBUTES: Readonly<Record<Tag, readonly string[]>>;
8
+ /**
9
+ * Strict build-time syntax parser. It deliberately does not use the browser's
10
+ * error-recovering HTML parser, resolve Registry entries, or inspect live data.
11
+ */
12
+ export declare function parseComponentTree(source: string, options?: ParseComponentTreeOptions): SomaComponentTree;
13
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { SomaComponentDefinition } from '../../client/component/component-definition.types';
2
+ import type { TreeRegistrySnapshot } from '../../shared/types/component-tree.types';
3
+ export interface ComponentTreeRegistryEntry {
4
+ definition: SomaComponentDefinition;
5
+ packName?: string;
6
+ packVersion?: string;
7
+ }
8
+ export interface ComponentTreeRegistrySnapshotOptions {
9
+ sourceId?: string;
10
+ }
11
+ /**
12
+ * Captures contract/schema preconditions without executing controllers or UI package code.
13
+ * Captures trusted implementation topology without retaining templates or executing controllers.
14
+ */
15
+ export declare function buildComponentTreeRegistrySnapshot(entries: readonly ComponentTreeRegistryEntry[], options?: ComponentTreeRegistrySnapshotOptions): TreeRegistrySnapshot;
@@ -0,0 +1,22 @@
1
+ import type { SomaPageMarkup, TreeCompileContext, TreeValidationResult } from '../../shared/types/component-tree.types';
2
+ export interface ComponentTreePreflightInput {
3
+ html: string;
4
+ uiYaml: string;
5
+ markup?: SomaPageMarkup;
6
+ grammarVersion?: number;
7
+ treeContext?: TreeCompileContext;
8
+ externalBlocks?: ReadonlyMap<string, string>;
9
+ }
10
+ /** Explicit format selection. Invalid metadata must never fall back to legacy HTML. */
11
+ export declare function resolvePageMarkup(input: Pick<ComponentTreePreflightInput, 'markup' | 'grammarVersion'>): SomaPageMarkup;
12
+ /**
13
+ * Build/server preflight only: grammar, identity, Registry and composition rules.
14
+ * It does not compile canonical props/events, emit HTML or produce a publishable artifact.
15
+ */
16
+ export declare function preflightComponentTree(input: ComponentTreePreflightInput): TreeValidationResult;
17
+ /**
18
+ * A syntax leak guard, not an HTML sanitizer. Use the HTML tree-builder's actual
19
+ * namespace/raw-text rules and visit inert template content as well as ordinary children.
20
+ * Existing Registry injection checks retain responsibility for unsafe native HTML.
21
+ */
22
+ export declare function assertNoComponentTreeSyntax(html: string): void;
@@ -0,0 +1,7 @@
1
+ import type { SomaComponentContract } from '../../shared/types/component-contract.types';
2
+ import type { SomaStructureAdapterDefinition } from '../../shared/types/component-tree-artifact.types';
3
+ /** Proves the trusted implementation topology once, without a browser or controllers. */
4
+ export declare function inspectStructureTopology(contract: SomaComponentContract, templateHtml: string, adapter?: SomaStructureAdapterDefinition, uiConfig?: unknown): {
5
+ internalRootId?: string;
6
+ templateRootTag?: string;
7
+ };
@@ -0,0 +1,9 @@
1
+ import { type SomaComponentTree, type TreeCompileContext, type TreeValidationResult } from '../../shared/types/component-tree.types';
2
+ /**
3
+ * Validate only source/context facts. The return value is not an executable asset;
4
+ * binding lowering, effective-parent proof and full artifact delivery are separate.
5
+ */
6
+ export declare function validateComponentTree(tree: SomaComponentTree, input: {
7
+ domain: string;
8
+ context: TreeCompileContext;
9
+ }): TreeValidationResult;
@@ -0,0 +1,34 @@
1
+ import type { TreeCompileContext, TreeRegistrySnapshot } from '../../shared/types/component-tree.types';
2
+ export { loadPageMarkupConfig } from '../../server/host/page-markup-config';
3
+ export interface TreeEditorPosition {
4
+ line: number;
5
+ character: number;
6
+ }
7
+ export interface TreeEditorDiagnostic {
8
+ uri: string;
9
+ code: string;
10
+ severity: number;
11
+ source: string;
12
+ message: string;
13
+ range: {
14
+ start: TreeEditorPosition;
15
+ end: TreeEditorPosition;
16
+ };
17
+ }
18
+ /** Same parser/compiler as publishing. LSP supplies only trusted Host context, never source metadata. */
19
+ export declare function diagnoseComponentTree(input: {
20
+ html: string;
21
+ uiYaml: string;
22
+ htmlUri: string;
23
+ uiUri: string;
24
+ markup?: 'legacy-html' | 'component-tree';
25
+ grammarVersion?: number;
26
+ treeContext?: TreeCompileContext;
27
+ }): TreeEditorDiagnostic[];
28
+ /** Tolerant cursor context is only for suggestions; it never claims a partial document is valid. */
29
+ export declare function completeComponentTree(text: string, position: TreeEditorPosition, registry?: TreeRegistrySnapshot): {
30
+ label: string;
31
+ insertText: string;
32
+ detail: string;
33
+ kind: number;
34
+ }[];
@@ -4,8 +4,15 @@ export interface SomaAdaptiveSize {
4
4
  }
5
5
  export type SomaAdaptiveSizeCallback = (size: SomaAdaptiveSize) => void;
6
6
  export interface SomaAdaptiveObserverPool {
7
- /** 订阅元素尺寸;返回退订函数(幂等,重复调用不抛错) */
8
- observe(target: Element, onSize: SomaAdaptiveSizeCallback): () => void;
7
+ /**
8
+ * 订阅元素尺寸;返回退订函数(幂等,重复调用不抛错)。
9
+ * `options.box` 选盒模型:省略 = 内容盒(默认);`'border-box'` = 含内边距与边框的行盒。
10
+ * 选项类型就地写在签名里而不另立导出名:池子对外只该有一个 `observe`,
11
+ * 多一个导出符号就多一份要跟着走的对外契约。
12
+ */
13
+ observe(target: Element, onSize: SomaAdaptiveSizeCallback, options?: {
14
+ box?: 'content-box' | 'border-box';
15
+ }): () => void;
9
16
  }
10
17
  /**
11
18
  * 取得观察者池。
@@ -25,8 +25,17 @@ export declare class SomaManifestCompiler {
25
25
  * 无管道时原样返回(零开销路径)。
26
26
  */
27
27
  private parsePipes;
28
- /** 列表/对象子作用域配置的管道预校验(行内解释执行前的编译期 fail fast) */
29
- private validateScopedPipes;
28
+ /**
29
+ * 列表 / 对象子作用域配置的编译期闸门:管道白名单预校验 + model 拒收。
30
+ *
31
+ * 行内绑定是解释执行的(不经这里编译成 BindingEntry),编译期不看就只剩运行时才发现。
32
+ * 两件事都在这一趟走完:管道名不在白名单 → fail fast;行 / 对象作用域里写了 model → 拒收。
33
+ * model 那条从渲染器的挂载期告警移上来(原 SomaDomRenderer.reportScopedModels):
34
+ * 告警发生在绑定表建好之后,页面照常上屏,控件却既不按数据选中、改了也不回写——
35
+ * 一个看着正常、实则失效的表单控件,比页面起不来危险得多。页面与组件实例都经这一趟编译,
36
+ * 两边同一道闸(组件实例不过契约校验器,只有这里拦得住)。
37
+ */
38
+ private validateScopedDeclarations;
30
39
  private parseSomaKey;
31
40
  private parseConditionalPath;
32
41
  private resolveBindingType;
@@ -1,4 +1,5 @@
1
- import { type SomaComponentContract, type SomaContractKeyboard, type SomaContractOverlay, type SomaGeometryFamily } from '../../shared/types/component-contract.types';
1
+ import { type CatalogExampleCapabilities } from './catalog-examples';
2
+ import { type SomaComponentContract, type SomaContractKeyboard, type SomaContractOverlay, type SomaGeometryFamily, type SomaContractExample, type SomaContractStructure } from '../../shared/types/component-contract.types';
2
3
  import type { SomaComponentDefinition } from './component-definition.types';
3
4
  export interface SomaAiCatalogEntry {
4
5
  name: string;
@@ -44,6 +45,19 @@ export interface SomaAiCatalogEntry {
44
45
  };
45
46
  /** 浮层行为契约(声明了才有) */
46
47
  overlay?: SomaContractOverlay;
48
+ /** Public structural summary; implementation anchor names/selectors never enter the catalog. */
49
+ structure?: {
50
+ kind: SomaContractStructure['kind'];
51
+ rootless: boolean;
52
+ treeMount: SomaContractStructure['tree_mount'];
53
+ semantics?: SomaContractStructure['semantics'];
54
+ slots: Array<{
55
+ name: string;
56
+ kind: 'projection' | 'collection';
57
+ directChildren: boolean;
58
+ rowContainer?: 'none' | 'list-item';
59
+ }>;
60
+ };
47
61
  /** 契约级依赖(F-46):装这个还要装什么 */
48
62
  uses?: string[];
49
63
  /** 组件级令牌(M-1):这个组件开放的可调旋钮及其 CSS 变量名 */
@@ -57,6 +71,7 @@ export interface SomaAiCatalogEntry {
57
71
  whenToUse: string;
58
72
  whenNotToUse?: string;
59
73
  example: string;
74
+ examples?: readonly SomaContractExample[];
60
75
  antiPatterns?: string[];
61
76
  };
62
77
  /**
@@ -97,6 +112,8 @@ export interface GenerateAiCatalogOptions {
97
112
  * 不传则目录产物与历史完全一致。
98
113
  */
99
114
  conventions?: string;
115
+ /** Human/tool consumers may opt in; AI/native-page consumers remain legacy-only by default. */
116
+ exampleCapabilities?: CatalogExampleCapabilities;
100
117
  }
101
118
  /**
102
119
  * 生成完整 AI 目录。
@@ -0,0 +1,18 @@
1
+ import type { SomaContractExample } from '../../shared/types/component-contract.types';
2
+ export interface CatalogExampleSource {
3
+ ai?: {
4
+ example?: string;
5
+ examples?: readonly SomaContractExample[];
6
+ };
7
+ }
8
+ export interface CatalogExampleCapabilities {
9
+ /** In preference order. Missing options intentionally means legacy-only. */
10
+ formats?: readonly SomaContractExample['format'][];
11
+ capabilities?: readonly string[];
12
+ }
13
+ /** No tree source is selected unless both its grammar format and capabilities are accepted. */
14
+ export declare function selectSomaCatalogExample(entry: CatalogExampleSource, options?: CatalogExampleCapabilities): SomaContractExample | null;
15
+ /** Human-readable usage retains format metadata, rather than pretending tree tags are HTML. */
16
+ export declare function formatSomaCatalogExample(example: SomaContractExample): string;
17
+ /** Validate the portable example envelope without importing build-time parsers in the client. */
18
+ export declare function copyCatalogExamples(examples: readonly SomaContractExample[]): SomaContractExample[];
@@ -1,6 +1,8 @@
1
1
  import type { UiConfig } from '../../shared/types/ui-config.types';
2
2
  import type { ParsedEvent } from '../../shared/types/event.types';
3
3
  import type { SomaComponentContract } from '../../shared/types/component-contract.types';
4
+ import type { DefinitionPreparation, DefinitionRepeatPlan, SomaStructureAdapterDefinition } from '../../shared/types/component-tree-artifact.types';
5
+ import type { TreeCollectionSource } from '../../shared/types/component-tree.types';
4
6
  /** 控制器工厂上下文:props 即实例作用域根(可读取最新值),emit 向页面上抛 */
5
7
  export interface SomaComponentControllerContext {
6
8
  props: Record<string, unknown>;
@@ -61,6 +63,13 @@ export interface SomaComponentStyleFeature {
61
63
  }
62
64
  export interface SomaComponentDefinition {
63
65
  contract: SomaComponentContract;
66
+ structureAdapter?: SomaStructureAdapterDefinition;
67
+ collectionSources?: readonly TreeCollectionSource[];
68
+ definitionRepeatPlans?: DefinitionRepeatPlan[];
69
+ definitionPreparation?: DefinitionPreparation;
70
+ /** Precomputed by the trusted package build; never browser-computed with Node. */
71
+ structureDigest?: string;
72
+ contractDigest?: string;
64
73
  /**
65
74
  * 组件内部结构模板。内部锚点写 data-soma-id(与页面 DSL 一致),
66
75
  * 展开器统一改写为 data-soma-scoped-id 实现作用域隔离。
@@ -1,4 +1,5 @@
1
1
  import type { SomaComponentDefinition } from './component-definition.types';
2
+ import type { StructurePlan } from '../../shared/types/component-tree-artifact.types';
2
3
  export declare const SOMA_COMPONENT_ATTR = "data-soma-component";
3
4
  /**
4
5
  * 展开完成标记;**值为该次展开分配的 scopeId**(此前是空串)。
@@ -20,7 +21,7 @@ export declare class SomaComponentExpander {
20
21
  /** 已展开宿主的 scopeId(未展开返回 null) */
21
22
  scopeIdOf(host: HTMLElement): string | null;
22
23
  /** @returns 本次展开分配的 scopeId(宿主已展开时返回既有的那个) */
23
- expand(host: HTMLElement, def: SomaComponentDefinition): string;
24
+ expand(host: HTMLElement, def: SomaComponentDefinition, plan?: StructurePlan, staticProps?: Record<string, unknown>): string;
24
25
  private scopeAnchors;
25
26
  private collectSlotOutlets;
26
27
  }