soma-core 2.2.9 → 2.2.11

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 (51) hide show
  1. package/README.md +8 -19
  2. package/bin/service-codegen.cjs +2 -3
  3. package/bin/soma.cjs +2 -2
  4. package/core/build/compiler/soma-precompile.js +19 -6
  5. package/core/client/data/region-scope-port.ts +8 -3
  6. package/core/client/engine/event-engine.ts +1 -1
  7. package/core/client/engine/soma-bootstrap.ts +9 -0
  8. package/core/client/engines/diff/code.ts +205 -0
  9. package/core/client/engines/diff/index.ts +27 -1
  10. package/core/client/engines/diff/port.ts +75 -0
  11. package/core/client/parser/confirm-spec.ts +10 -4
  12. package/core/client/parser/ui-config-parser.ts +14 -2
  13. package/core/index.ts +1 -1
  14. package/core/server/api/load-host-service.ts +0 -1
  15. package/core/server/host/source-packages.cjs +3 -0
  16. package/core/shared/registry-generated/diagnostic-registry-index.ts +16 -0
  17. package/core/shared/registry-generated/diagnostic-registry.ts +130 -0
  18. package/core/shared/registry-generated/limits.ts +6 -2
  19. package/core/shared/registry-generated/std-grammar-views.ts +1 -1
  20. package/core/shared/registry-generated/std-grammar.ts +1 -1
  21. package/core/shared/types/region-scope.types.ts +6 -0
  22. package/dist/browser/runtime-bundle.manifest.json +12 -12
  23. package/dist/browser/soma-runtime.js +752 -489
  24. package/dist/core/index.cjs +752 -489
  25. package/dist/host-native/aot-builder.cjs +366 -226
  26. package/dist/host-native/native-server.cjs +131 -56
  27. package/dist/lsp/component-tree.cjs +23 -10
  28. package/dist/types/client/data/region-scope-port.d.ts +1 -1
  29. package/dist/types/client/engine/soma-bootstrap.d.ts +5 -0
  30. package/dist/types/client/engines/diff/code.d.ts +27 -0
  31. package/dist/types/client/engines/diff/index.d.ts +2 -1
  32. package/dist/types/client/engines/diff/port.d.ts +77 -0
  33. package/dist/types/client/parser/confirm-spec.d.ts +1 -1
  34. package/dist/types/server/host/source-packages.d.cts +5 -0
  35. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +113 -1
  36. package/dist/types/shared/registry-generated/limits.d.ts +4 -0
  37. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +1 -1
  38. package/dist/types/shared/registry-generated/std-grammar.d.ts +1 -1
  39. package/dist/types/shared/types/region-scope.types.d.ts +6 -0
  40. package/host-native/bin/host-native.cjs +1 -1
  41. package/host-native/client/browser-entry.ts +12 -1
  42. package/host-native/client/first-frame.ts +8 -0
  43. package/host-native/client/router-bridge.ts +8 -2
  44. package/host-native/src/aot-builder.ts +173 -93
  45. package/host-native/src/native-server.ts +131 -25
  46. package/host-native/src/public-packages.cjs +156 -50
  47. package/host-native/styles/globals.css +28 -2
  48. package/package.json +2 -2
  49. package/dist/core/adaptive-pure.cjs +0 -41
  50. package/dist/core/theme-pure.cjs +0 -38
  51. package/dist/preview-export.cjs +0 -3401
@@ -0,0 +1,27 @@
1
+ import type { CodeDiff, CodeDiffHunk, CodeDiffLine, MarkdownBlockKind, MarkdownDiff } from './port';
2
+ import { type ProseRun } from './prose';
3
+ export interface CodeConfig {
4
+ readonly maxChars: number;
5
+ readonly maxAlignTokens: number;
6
+ readonly maxPairMatrix: number;
7
+ readonly pairAt: number;
8
+ /** 每块上下文行数 */
9
+ readonly context: number;
10
+ /** 行内字符差异只对不超过此长度的行做 */
11
+ readonly intraMaxLine: number;
12
+ }
13
+ /** 行级操作 → 按上下文切块(纯函数) */
14
+ export declare function hunksOf(lines: readonly CodeDiffLine[], context: number): CodeDiffHunk[];
15
+ export declare function runCode(run: ProseRun, cfg: CodeConfig, a: string, b: string): Promise<CodeDiff>;
16
+ /** 源码 → 块(空行分隔;围栏代码整块,围栏里的空行不切);纯函数 */
17
+ export declare function splitMarkdownBlocks(source: string): string[];
18
+ export declare function markdownBlockKind(block: string): {
19
+ kind: MarkdownBlockKind;
20
+ detail: string;
21
+ };
22
+ /** 块的可比文字:去掉块首标记(# / > / 列表符号 / 围栏行),空白归一 */
23
+ export declare function markdownBlockText(block: string, kind: MarkdownBlockKind): string;
24
+ export interface MarkdownConfig extends CodeConfig {
25
+ readonly maxBlocks: number;
26
+ }
27
+ export declare function runMarkdown(run: ProseRun, cfg: MarkdownConfig, a: string, b: string): Promise<MarkdownDiff>;
@@ -1,5 +1,6 @@
1
- export type { DiffFragment, DiffMode, DiffOptions, DiffPart, ItemDiff, ItemDiffEntry, ItemDiffOptions, ItemFieldDiff, ItemFieldSpec, ItemFieldType, ItemState, ProseBlock, ProseDegraded, ProseDiff, ProseDiffOptions, ProseNormalizeOptions, SomaDiffAdapter, SomaDiffPort, } from './port';
1
+ export type { CodeDiff, CodeDiffHunk, CodeDiffLine, CodeDiffOptions, MarkdownBlockKind, MarkdownDiff, MarkdownDiffBlock, DiffFragment, DiffMode, DiffOptions, DiffPart, ItemDiff, ItemDiffEntry, ItemDiffOptions, ItemFieldDiff, ItemFieldSpec, ItemFieldType, ItemState, ProseBlock, ProseDegraded, ProseDiff, ProseDiffOptions, ProseNormalizeOptions, SomaDiffAdapter, SomaDiffPort, } from './port';
2
2
  export { assertDiffAdapter } from './port';
3
+ export { hunksOf, markdownBlockKind, markdownBlockText, splitMarkdownBlocks } from './code';
3
4
  import type { EngineLoadTelemetry } from '../load';
4
5
  import { type SomaDiffAdapter, type SomaDiffPort } from './port';
5
6
  export interface DiffPortOptions {
@@ -127,6 +127,79 @@ export interface ItemDiff {
127
127
  readonly movesSkipped: boolean;
128
128
  readonly degraded?: ProseDegraded | 'too-many-items';
129
129
  }
130
+ export interface CodeDiffLine {
131
+ readonly op: 'eq' | 'ins' | 'del';
132
+ /** 旧版行号(1 起;增行无) */
133
+ readonly a?: number;
134
+ /** 新版行号(1 起;删行无) */
135
+ readonly b?: number;
136
+ readonly text: string;
137
+ /** 改行:配对另一侧的行号(删行给新版行号,增行给旧版行号) */
138
+ readonly pair?: number;
139
+ /** 改行的行内字符差异(删行只含 eq / del,增行只含 eq / ins);行过长或超时缺省 */
140
+ readonly fragments?: readonly DiffFragment[];
141
+ }
142
+ export interface CodeDiffHunk {
143
+ readonly aStart: number;
144
+ readonly aLines: number;
145
+ readonly bStart: number;
146
+ readonly bLines: number;
147
+ /** 在 `lines` 中的起止下标(含) */
148
+ readonly from: number;
149
+ readonly to: number;
150
+ readonly lines: readonly CodeDiffLine[];
151
+ }
152
+ export interface CodeDiff {
153
+ readonly kind: 'same' | 'changed';
154
+ /** 全部行(合并视图顺序:改行组内删行在增行上方) */
155
+ readonly lines: readonly CodeDiffLine[];
156
+ /** 按 design `contentEngines.diff.codeContext` 行上下文切出的块 */
157
+ readonly hunks: readonly CodeDiffHunk[];
158
+ readonly stats: {
159
+ readonly added: number;
160
+ readonly removed: number;
161
+ readonly modified: number;
162
+ };
163
+ /** 去掉全部空白后两侧相同 */
164
+ readonly whitespaceOnly: boolean;
165
+ /** too-large / timeout:不逐行对齐,整体按「全删 + 全增」给出 */
166
+ readonly degraded?: 'too-large' | 'timeout';
167
+ }
168
+ export type MarkdownBlockKind = 'heading' | 'paragraph' | 'list' | 'quote' | 'code' | 'table' | 'hr';
169
+ export interface MarkdownDiffBlock {
170
+ readonly op: 'eq' | 'ins' | 'del' | 'mod';
171
+ readonly kind: MarkdownBlockKind;
172
+ /** 块的 Markdown 源码(组件经 Markdown 端口渲染) */
173
+ readonly before?: string;
174
+ readonly after?: string;
175
+ /** mod:块文字(去块首标记)的词级差异;代码块不给(组件改用 diffCode) */
176
+ readonly fragments?: readonly DiffFragment[];
177
+ /** 结构变化:标题层级、列表有序 / 无序、代码语言 */
178
+ readonly notes?: readonly {
179
+ readonly what: 'heading-level' | 'list-type' | 'code-language';
180
+ readonly before: string;
181
+ readonly after: string;
182
+ }[];
183
+ readonly similarity?: number;
184
+ }
185
+ export interface MarkdownDiff {
186
+ readonly kind: 'same' | 'changed';
187
+ readonly blocks: readonly MarkdownDiffBlock[];
188
+ readonly stats: {
189
+ readonly added: number;
190
+ readonly removed: number;
191
+ readonly modified: number;
192
+ readonly same: number;
193
+ };
194
+ /** too-large / timeout:blocks 为空,组件退回源码对比(diffCode) */
195
+ readonly degraded?: 'too-large' | 'timeout';
196
+ }
197
+ export interface CodeDiffOptions {
198
+ /** 时限(调用方只能更小) */
199
+ readonly timeoutMs?: number;
200
+ /** 上下文行数(调用方只能更小) */
201
+ readonly context?: number;
202
+ }
130
203
  export interface SomaDiffPort {
131
204
  /** 两段字符串按粒度求片段(超时退回整段替换,不抛错) */
132
205
  diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[]>;
@@ -134,5 +207,9 @@ export interface SomaDiffPort {
134
207
  diffProse(a: string, b: string, options?: ProseDiffOptions): Promise<ProseDiff>;
135
208
  /** 条目列表差异:key 或内容配对、字段差异、LIS 最少移动 */
136
209
  diffItems(before: readonly unknown[], after: readonly unknown[], options?: ItemDiffOptions): Promise<ItemDiff>;
210
+ /** 代码差异:按行对齐、改行行内字符差异、按上下文切块;超长 / 超时退化为全删 + 全增(不抛) */
211
+ diffCode(a: string, b: string, options?: CodeDiffOptions): Promise<CodeDiff>;
212
+ /** Markdown 差异:源码块级对齐 + 块内词级 + 结构变化说明;超长 / 超时 blocks 为空并标 degraded(不抛) */
213
+ diffMarkdown(a: string, b: string, options?: CodeDiffOptions): Promise<MarkdownDiff>;
137
214
  }
138
215
  export declare function assertDiffAdapter(adapter: unknown): void;
@@ -37,7 +37,7 @@ export interface SomaConfirmContext {
37
37
  export declare function listConfirmPlaceholders(text: string): string[];
38
38
  /** 代入一段确认文案里的占位;`onMissing` 收到每个缺失的占位名(引擎用它记开发期告警) */
39
39
  export declare function substituteConfirmText(text: string, context: SomaConfirmContext, onMissing?: (name: string) => void): string;
40
- /** 把确认规格的 text / impact 代入占位;无花括号时返回原规格(同一引用) */
40
+ /** 把确认规格的 text / impact / phrase 代入占位;无花括号时返回原规格(同一引用)。phrase 缺任一占位值 → 空串(确认钮恒不可用) */
41
41
  export declare function resolveConfirmSpec(spec: SomaConfirmSpec, context: SomaConfirmContext, onMissing?: (name: string) => void): SomaConfirmSpec;
42
42
  /** 开发期告警(按占位名去重;生产构建不输出) */
43
43
  export declare function warnConfirmMissing(name: string, where: string): void;
@@ -10,6 +10,11 @@ export type SomaAssetSourceItem = {
10
10
  };
11
11
  /** 环境变量:显式声明的源包名(逗号分隔),不论其 package.json 怎么写都当源包 */
12
12
  export const SOMA_SOURCE_PACKAGES_ENV: "SOMA_SOURCE_PACKAGES";
13
+ /** 源包判定:显式声明(环境变量)或 `package.json` 的 `soma.source === true` */
14
+ export function isSomaSourcePackage(packageRoot: any, explicit: any): boolean;
15
+ /** @param {SomaEnv} [env] */
16
+ export function readExplicitSourcePackages(env?: SomaEnv): string[];
17
+ export function resolvePackageRoot(hostDir: any, packageName: any, version: any): string | null;
13
18
  export function getSomaHostSourceRoot(hostDir: any, env?: NodeJS.ProcessEnv): string;
14
19
  export function getSomaHostApiRoot(hostDir: any, env?: NodeJS.ProcessEnv): string;
15
20
  /** 子路径必须落在 parent 内且存在,否则回落 parent(越界不报错、不跟随) */
@@ -13,7 +13,7 @@ export declare const SOMA_PIPELINE_DIAGNOSTIC_REGISTRY: {
13
13
  readonly warn: "none";
14
14
  readonly advice: "none";
15
15
  };
16
- readonly closedFamilies: readonly ["BDL-ALIAS", "CORE", "CT", "ERR-ADAPT", "ERR-AI", "ERR-APP", "ERR-BIZ", "ERR-CAP", "ERR-CAT", "ERR-COMPOSE", "ERR-CONTRACT", "ERR-DSN", "ERR-EXPAND", "ERR-GEN", "ERR-LAYOUT", "ERR-LOCALE", "ERR-PACK", "ERR-PAGE", "ERR-PUB", "ERR-RUN", "ERR-TYPE", "ERR-UNIT", "FND-DEFECT", "FND-GUARD", "FND-INTR", "FND-LAYOUT", "FND-PROOF", "FND-STYLE", "FND-THEME", "OOUI-ART", "OOUI-ASM", "OOUI-SEM", "OOUI-SPA", "THM-CMP", "THM-COORD", "THM-DSL", "THM-MAN", "THM-OUT", "THM-PRESET", "THM-REC", "THM-ROLE", "THM-RULE", "THM-STYLE", "THM-VF"];
16
+ readonly closedFamilies: readonly ["BDL-ALIAS", "CORE", "CT", "ERR-ADAPT", "ERR-AI", "ERR-APP", "ERR-BIZ", "ERR-CAP", "ERR-CAT", "ERR-COMPOSE", "ERR-CONTRACT", "ERR-DSN", "ERR-EXPAND", "ERR-GEN", "ERR-LAYOUT", "ERR-LOCALE", "ERR-PACK", "ERR-PAGE", "ERR-PUB", "ERR-RUN", "ERR-TYPE", "ERR-UNIT", "FND-DEFECT", "FND-GUARD", "FND-INTR", "FND-LAYOUT", "FND-PROOF", "FND-STYLE", "FND-THEME", "KIT-PAGE-GATE", "KIT-THEME-GATE", "OOUI-ART", "OOUI-ASM", "OOUI-SEM", "OOUI-SPA", "THM-CMP", "THM-COORD", "THM-DSL", "THM-MAN", "THM-OUT", "THM-PRESET", "THM-REC", "THM-ROLE", "THM-RULE", "THM-STYLE", "THM-VF"];
17
17
  readonly codes: readonly [{
18
18
  readonly code: "BDL-ALIAS-COMPAT";
19
19
  readonly family: "BDL-ALIAS";
@@ -3729,6 +3729,118 @@ export declare const SOMA_PIPELINE_DIAGNOSTIC_REGISTRY: {
3729
3729
  readonly stage: "foundation";
3730
3730
  readonly severity: "error";
3731
3731
  readonly owner: "soma-foundation/src/primitives/diag.ts";
3732
+ }, {
3733
+ readonly code: "KIT-PAGE-GATE-001";
3734
+ readonly family: "KIT-PAGE-GATE";
3735
+ readonly stage: "page";
3736
+ readonly severity: "error";
3737
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3738
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3739
+ }, {
3740
+ readonly code: "KIT-PAGE-GATE-002";
3741
+ readonly family: "KIT-PAGE-GATE";
3742
+ readonly stage: "page";
3743
+ readonly severity: "error";
3744
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3745
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3746
+ }, {
3747
+ readonly code: "KIT-PAGE-GATE-003";
3748
+ readonly family: "KIT-PAGE-GATE";
3749
+ readonly stage: "page";
3750
+ readonly severity: "error";
3751
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3752
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3753
+ }, {
3754
+ readonly code: "KIT-PAGE-GATE-004";
3755
+ readonly family: "KIT-PAGE-GATE";
3756
+ readonly stage: "page";
3757
+ readonly severity: "error";
3758
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3759
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3760
+ }, {
3761
+ readonly code: "KIT-PAGE-GATE-005";
3762
+ readonly family: "KIT-PAGE-GATE";
3763
+ readonly stage: "page";
3764
+ readonly severity: "error";
3765
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3766
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3767
+ }, {
3768
+ readonly code: "KIT-PAGE-GATE-006";
3769
+ readonly family: "KIT-PAGE-GATE";
3770
+ readonly stage: "page";
3771
+ readonly severity: "warn";
3772
+ readonly owner: "soma-kit/src/spatial/emit.ts";
3773
+ readonly negative: "soma-kit/tests/spatial/emit-gates.test.ts";
3774
+ }, {
3775
+ readonly code: "KIT-PAGE-GATE-900";
3776
+ readonly family: "KIT-PAGE-GATE";
3777
+ readonly stage: "page";
3778
+ readonly severity: "warn";
3779
+ readonly owner: "soma-kit/src/compile/page-pipeline.ts";
3780
+ readonly negative: "soma-kit/tests/compile/page-pipeline-wiring.test.ts";
3781
+ }, {
3782
+ readonly code: "KIT-PAGE-GATE-901";
3783
+ readonly family: "KIT-PAGE-GATE";
3784
+ readonly stage: "page";
3785
+ readonly severity: "error";
3786
+ readonly owner: "soma-kit/src/compile/compile-page.ts";
3787
+ readonly negative: "soma-kit/tests/compile/page-pipeline-wiring.test.ts";
3788
+ }, {
3789
+ readonly code: "KIT-THEME-GATE-001";
3790
+ readonly family: "KIT-THEME-GATE";
3791
+ readonly stage: "theme";
3792
+ readonly severity: "error";
3793
+ readonly owner: "soma-kit/src/theme/value-table.ts";
3794
+ readonly negative: "soma-kit/tests/theme/value-table.test.ts";
3795
+ }, {
3796
+ readonly code: "KIT-THEME-GATE-002";
3797
+ readonly family: "KIT-THEME-GATE";
3798
+ readonly stage: "theme";
3799
+ readonly severity: "error";
3800
+ readonly owner: "soma-kit/src/theme/value-table.ts";
3801
+ readonly negative: "soma-kit/tests/theme/value-table.test.ts";
3802
+ }, {
3803
+ readonly code: "KIT-THEME-GATE-003";
3804
+ readonly family: "KIT-THEME-GATE";
3805
+ readonly stage: "theme";
3806
+ readonly severity: "warn";
3807
+ readonly owner: "soma-kit/src/theme/value-table.ts";
3808
+ readonly negative: "soma-kit/tests/theme/value-table.test.ts";
3809
+ }, {
3810
+ readonly code: "KIT-THEME-GATE-010";
3811
+ readonly family: "KIT-THEME-GATE";
3812
+ readonly stage: "theme";
3813
+ readonly severity: "error";
3814
+ readonly owner: "soma-kit/src/app/tier-compat.ts";
3815
+ readonly negative: "soma-kit/tests/app/tier-compat.test.ts";
3816
+ }, {
3817
+ readonly code: "KIT-THEME-GATE-011";
3818
+ readonly family: "KIT-THEME-GATE";
3819
+ readonly stage: "theme";
3820
+ readonly severity: "warn";
3821
+ readonly owner: "soma-kit/src/app/tier-compat.ts";
3822
+ readonly negative: "soma-kit/tests/app/tier-compat.test.ts";
3823
+ }, {
3824
+ readonly code: "KIT-THEME-GATE-012";
3825
+ readonly family: "KIT-THEME-GATE";
3826
+ readonly stage: "theme";
3827
+ readonly severity: "warn";
3828
+ readonly owner: "soma-kit/src/app/server.ts";
3829
+ readonly negative: "soma-kit/tests/app/tier-compat.test.ts";
3830
+ }, {
3831
+ readonly code: "KIT-THEME-GATE-013";
3832
+ readonly family: "KIT-THEME-GATE";
3833
+ readonly stage: "theme";
3834
+ readonly severity: "warn";
3835
+ readonly owner: "soma-kit/src/app/tier-compat.ts";
3836
+ readonly negative: "soma-kit/tests/app/tier-compat.test.ts";
3837
+ }, {
3838
+ readonly code: "KIT-THEME-GATE-014";
3839
+ readonly family: "KIT-THEME-GATE";
3840
+ readonly stage: "theme";
3841
+ readonly severity: "warn";
3842
+ readonly owner: "soma-kit/src/theme/value-table.ts";
3843
+ readonly negative: "soma-kit/tests/theme/value-table.test.ts";
3732
3844
  }, {
3733
3845
  readonly code: "OOUI-ART-ANCHOR-DUPLICATE";
3734
3846
  readonly family: "OOUI-ART";
@@ -531,6 +531,8 @@ export declare const SOMA_PIPELINE_LIMITS: {
531
531
  readonly maxAlignTokens: "序列对齐的不同键数上限(每个键映射为一个 BMP 私用区字符,U+E000–U+F8FF 共 6400 个)";
532
532
  readonly maxPairMatrix: "一段删增区间内句 / 段配对的候选矩阵上限(删数 × 增数),超出不配对、按删 + 增呈现;经验值,证据弱";
533
533
  readonly maxPairCandidates: "无 key 条目按相似度配对的候选矩阵上限(剩余旧条目 × 剩余新条目);经验值,证据弱";
534
+ readonly codeContext: "代码差异每块的上下文行数(笔记 C.5「上下文 3 行」,同 git diff -U3 / VS Code)";
535
+ readonly codeIntraMaxLine: "代码改行做行内字符差异的单行长度上限(字符);更长的行只标整行增删(经验值:压缩后的长行逐字比较无意义且耗时)";
534
536
  };
535
537
  readonly maxChars: 200000;
536
538
  readonly maxCharsPerCompare: 20000;
@@ -546,6 +548,8 @@ export declare const SOMA_PIPELINE_LIMITS: {
546
548
  readonly maxAlignTokens: 6400;
547
549
  readonly maxPairMatrix: 2500;
548
550
  readonly maxPairCandidates: 250000;
551
+ readonly codeContext: 3;
552
+ readonly codeIntraMaxLine: 500;
549
553
  };
550
554
  readonly highlight: {
551
555
  readonly basis: {
@@ -270,7 +270,7 @@ export declare const SOMA_STD_PAGE_FORBIDDEN_LOGIC_KEYS: {
270
270
  };
271
271
  };
272
272
  readonly exemptContexts: readonly ["diagnostics", "diagnosticExamples", "rejected", "title", "basis", "was", "summary", "docSummary"];
273
- readonly exampleRoots: readonly ["soma-kit-demo/pages", "soma-kit/examples", "soma-ui/tests/fixtures/hosts", "soma-core-demo/ui", "soma-core-demo/pages"];
273
+ readonly exampleRoots: readonly ["soma-kit-demo/pages", "soma-kit/examples", "soma-ui/tests/fixtures/hosts"];
274
274
  readonly exampleFilePatterns: readonly ["_ui.yaml", ".kit.yaml", "_style.yaml"];
275
275
  readonly exampleSkipDirs: readonly ["node_modules", "negative", "__negative__"];
276
276
  readonly note: "forbiddenShape: 'object' = 只禁对象 / 列表形,值为字符串(纯路径绑定)放行;scope: 'standard' = 只在 core 标准格式(四件套 / 注入口)判定,不进 G83 的跨方言语法源与示例页扫描(方言同名键含义不同,如 steps 页面模式)";
@@ -3302,7 +3302,7 @@ export declare const SOMA_PIPELINE_STD_GRAMMAR: {
3302
3302
  };
3303
3303
  };
3304
3304
  readonly exemptContexts: readonly ["diagnostics", "diagnosticExamples", "rejected", "title", "basis", "was", "summary", "docSummary"];
3305
- readonly exampleRoots: readonly ["soma-kit-demo/pages", "soma-kit/examples", "soma-ui/tests/fixtures/hosts", "soma-core-demo/ui", "soma-core-demo/pages"];
3305
+ readonly exampleRoots: readonly ["soma-kit-demo/pages", "soma-kit/examples", "soma-ui/tests/fixtures/hosts"];
3306
3306
  readonly exampleFilePatterns: readonly ["_ui.yaml", ".kit.yaml", "_style.yaml"];
3307
3307
  readonly exampleSkipDirs: readonly ["node_modules", "negative", "__negative__"];
3308
3308
  readonly note: "forbiddenShape: 'object' = 只禁对象 / 列表形,值为字符串(纯路径绑定)放行;scope: 'standard' = 只在 core 标准格式(四件套 / 注入口)判定,不进 G83 的跨方言语法源与示例页扫描(方言同名键含义不同,如 steps 页面模式)";
@@ -66,6 +66,12 @@ export interface SomaScopeSliceDecl {
66
66
  readonly readers?: readonly string[];
67
67
  /** 带 ready 位:初值未就绪,owner 调 `markReady()` 置位 */
68
68
  readonly ready?: boolean;
69
+ /**
70
+ * 切片初值(纯 JSON 值):装入与重置(`reset`)时切片取它的副本而不是空;不写 = 空(读作 undefined)。
71
+ * 用途:读接口参数经镜像绑切片子路径时,首个请求就带上初值(例:列表视图切片 `{ page: 1, size: <每页缺省> }`),
72
+ * 不必等 owner 第一次写入后再重取。初值不经写权核对(它是声明的一部分,不是某个部件的写入)。
73
+ */
74
+ readonly initial?: unknown;
69
75
  }
70
76
  /**
71
77
  * 切片镜像:把切片值(或其子路径的值)镜像进页面状态,供宿主片段里的 `ui.show` prop 绑定读取。
@@ -199,7 +199,7 @@ async function run() {
199
199
  const { url, port: actualPort } = await instance.start();
200
200
  // 只警告不退出:纯四件套原生工程没有 soma.app.ts 是合法的。装配代码只认文件名 soma.app.ts(应用根或源码根下,见 host-assembly.ts)。
201
201
  if (![hostDir, webRoot].some((dir) => fs.existsSync(path.join(dir, 'soma.app.ts')))) {
202
- console.warn(`[soma-native] 未找到 soma.app.ts,当前目录:${hostDir};若这是 soma-kit / 应用工程,请确认在工程根目录运行`);
202
+ console.warn(`[soma-native] 未找到 soma.app.ts,当前目录:${hostDir};若这是应用工程,请确认在工程根目录运行`);
203
203
  }
204
204
  const modeText = isDev ? '开发态 (增量热更新)' : '生产态 (极速 AOT)';
205
205
 
@@ -1,5 +1,6 @@
1
1
  // 纯原生 DOM 极速客户端入口:零 React,零 Next,体积小、性能快
2
2
  import { PageAccessError, readPageAccessError, loginRedirectTarget } from './page-access';
3
+ import { declaresLoadingState } from './first-frame';
3
4
  import {
4
5
  createBrowserNavigate,
5
6
  pendingNavigateInfo,
@@ -149,6 +150,8 @@ class NativePageClient {
149
150
  private containerEl: HTMLElement;
150
151
  private statusEl: HTMLElement;
151
152
  private navigate: SomaShellNavigate;
153
+ /** 最近一次渲染(或开始渲染)的页面地址:pathname + search + hash;popstate 落到同一地址时不重渲染 */
154
+ private renderedUrl = '';
152
155
 
153
156
  constructor(appRoot: HTMLElement) {
154
157
  this.appRoot = appRoot;
@@ -190,9 +193,10 @@ class NativePageClient {
190
193
  void this.renderPage(url);
191
194
  });
192
195
 
196
+ // 同一地址的历史项(页面内组件压的浏览状态)不重渲染页面:只有地址变了才是换页
193
197
  setupPopstateListener((url) => {
194
198
  void this.renderPage(url);
195
- });
199
+ }, () => this.renderedUrl);
196
200
 
197
201
  this.setupDevHmr();
198
202
  }
@@ -281,6 +285,7 @@ class NativePageClient {
281
285
  const runId = ++this.currentRunId;
282
286
 
283
287
  const parsed = new URL(targetUrl, window.location.href);
288
+ this.renderedUrl = parsed.pathname + parsed.search + parsed.hash;
284
289
  const pagePath = parsed.pathname;
285
290
  const routerPath = parsed.search ? `${pagePath}${parsed.search}` : pagePath;
286
291
 
@@ -461,6 +466,12 @@ class NativePageClient {
461
466
  ...assets,
462
467
  });
463
468
 
469
+ // 首帧:首轮渲染画出了页面自己声明的加载态(aria-busy,如骨架)就先显示容器,不等数据落定;
470
+ // 没声明加载态的页面仍在落定后才显示(判据见 first-frame.ts)。
471
+ await bs.whenRendered();
472
+ if (runId !== this.currentRunId) return;
473
+ if (declaresLoadingState(this.containerEl)) this.showContainer();
474
+
464
475
  await bs.whenSettled();
465
476
  if (runId !== this.currentRunId) return;
466
477
 
@@ -0,0 +1,8 @@
1
+ // 首帧显示判据(与方言无关):首轮渲染后,页面在容器里自己声明了加载态——标准 ARIA `aria-busy="true"`
2
+ // (骨架、加载面板等)——宿主就不等数据落定、先显示容器,让页头与骨架先被看见;数据到位仍走原来的落定流程。
3
+ // 没有声明加载态的页面(如未写加载态的原生四件套页)保持原行为:数据落定后再显示,不闪未就绪内容。
4
+
5
+ /** 容器内是否有元素声明「正在加载」(aria-busy="true")。 */
6
+ export function declaresLoadingState(container: ParentNode): boolean {
7
+ return container.querySelector('[aria-busy="true"]') !== null;
8
+ }
@@ -104,12 +104,18 @@ export function setupLinkInterceptor(navigate: SomaShellNavigate): () => void {
104
104
  };
105
105
  }
106
106
 
107
- /** 监听浏览器前进后退事件并触发路由回调 */
108
- export function setupPopstateListener(onPop: (url: string) => void): () => void {
107
+ /**
108
+ * 监听浏览器前进后退事件并触发路由回调。
109
+ * renderedUrl 给出当前已渲染页面的地址(pathname + search + hash):后退 / 前进落到同一地址时不是换页,
110
+ * 而是页面里的组件自己压的浏览历史项(例如整页表单视图「浏览器后退 = 取消」),交给压它的组件处理,壳不重渲染页面
111
+ * (重渲染会卸掉整页、丢掉未保存的编辑)。
112
+ */
113
+ export function setupPopstateListener(onPop: (url: string) => void, renderedUrl?: () => string): () => void {
109
114
  if (typeof window === 'undefined') return () => undefined;
110
115
 
111
116
  const handlePopstate = () => {
112
117
  const current = window.location.pathname + window.location.search + window.location.hash;
118
+ if (renderedUrl !== undefined && renderedUrl() === current) return;
113
119
  onPop(current);
114
120
  };
115
121