soma-core 2.2.8 → 2.2.9

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 (93) hide show
  1. package/core/build/compiler/full-manifest-builder.ts +1 -1
  2. package/core/build/compiler/host-config-sync.cjs +1 -1
  3. package/core/build/compiler/soma-manifest-webpack-plugin.js +2 -6
  4. package/core/build/compiler/soma-precompile.js +80 -4
  5. package/core/client/a11y/announcer.ts +2 -16
  6. package/core/client/base/SomaPageRootBase.ts +2 -2
  7. package/core/client/base/defineSomaView.ts +11 -2
  8. package/core/client/base/runtime-services.types.ts +57 -0
  9. package/core/client/data/role-gate.ts +2 -8
  10. package/core/client/engine/event-engine.ts +1 -0
  11. package/core/client/engines/diff/adapter-jsdiff.ts +27 -8
  12. package/core/client/engines/diff/index.ts +81 -6
  13. package/core/client/engines/diff/items.ts +212 -0
  14. package/core/client/engines/diff/port.ts +140 -3
  15. package/core/client/engines/diff/prose.ts +443 -0
  16. package/core/client/engines/engine-adapters.ts +6 -0
  17. package/core/client/engines/highlight/adapter-lezer.ts +109 -0
  18. package/core/client/engines/highlight/index.ts +135 -0
  19. package/core/client/engines/highlight/port.ts +92 -0
  20. package/core/client/engines/markdown/adapter-markdown-it.ts +65 -0
  21. package/core/client/engines/markdown/blocks.ts +335 -0
  22. package/core/client/engines/markdown/index.ts +51 -0
  23. package/core/client/engines/markdown/port.ts +94 -0
  24. package/core/client/engines/markdown/vendor-modules.d.ts +6 -0
  25. package/core/client/engines/structured/adapter-js-yaml.ts +33 -0
  26. package/core/client/engines/structured/index.ts +139 -0
  27. package/core/client/engines/structured/port.ts +59 -0
  28. package/core/client/infra/http/SomaHttpService.ts +2 -4
  29. package/core/client/infra/notify/DefaultNotifyService.ts +2 -3
  30. package/core/client/infra/permission/SomaPermission.ts +1 -1
  31. package/core/client/render-ports/notify-renderer.ts +2 -46
  32. package/core/client/runtime/SomaRuntimeServices.ts +16 -45
  33. package/core/server/host/app-config-composer.ts +6 -52
  34. package/core/server/host/host-config-paths.cjs +2 -100
  35. package/core/server/host/precompiled-manifest.ts +69 -0
  36. package/core/server/infra/host-config-paths.cjs +100 -0
  37. package/core/server/page-assets.ts +2 -70
  38. package/core/server/runtime-space/bindings.ts +33 -4
  39. package/core/server/runtime-space/store.ts +16 -1
  40. package/core/shared/app-config-merge.ts +59 -0
  41. package/core/shared/registry-generated/limits.ts +80 -4
  42. package/core/shared/types/announcer.types.ts +18 -0
  43. package/core/shared/types/notify.types.ts +26 -0
  44. package/core/shared/types/role-gate.types.ts +11 -0
  45. package/dist/browser/runtime-bundle.manifest.json +50 -7
  46. package/dist/browser/soma-runtime.js +120741 -104799
  47. package/dist/core/index.cjs +113807 -97854
  48. package/dist/host-native/aot-builder.cjs +277 -189
  49. package/dist/host-native/native-server.cjs +196 -72
  50. package/dist/lsp/component-tree.cjs +80 -4
  51. package/dist/types/build/compiler/full-manifest-builder.d.ts +1 -1
  52. package/dist/types/client/a11y/announcer.d.ts +2 -14
  53. package/dist/types/client/base/SomaPageRootBase.d.ts +2 -2
  54. package/dist/types/client/base/runtime-services.types.d.ts +50 -0
  55. package/dist/types/client/data/role-gate.d.ts +2 -8
  56. package/dist/types/client/engines/diff/index.d.ts +1 -1
  57. package/dist/types/client/engines/diff/items.d.ts +24 -0
  58. package/dist/types/client/engines/diff/port.d.ts +124 -2
  59. package/dist/types/client/engines/diff/prose.d.ts +80 -0
  60. package/dist/types/client/engines/engine-adapters.d.ts +6 -0
  61. package/dist/types/client/engines/highlight/adapter-lezer.d.ts +6 -0
  62. package/dist/types/client/engines/highlight/index.d.ts +15 -0
  63. package/dist/types/client/engines/highlight/port.d.ts +64 -0
  64. package/dist/types/client/engines/markdown/adapter-markdown-it.d.ts +6 -0
  65. package/dist/types/client/engines/markdown/blocks.d.ts +29 -0
  66. package/dist/types/client/engines/markdown/index.d.ts +9 -0
  67. package/dist/types/client/engines/markdown/port.d.ts +166 -0
  68. package/dist/types/client/engines/structured/adapter-js-yaml.d.ts +6 -0
  69. package/dist/types/client/engines/structured/index.d.ts +29 -0
  70. package/dist/types/client/engines/structured/port.d.ts +45 -0
  71. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  72. package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +2 -3
  73. package/dist/types/client/infra/permission/SomaPermission.d.ts +1 -1
  74. package/dist/types/client/render-ports/notify-renderer.d.ts +1 -56
  75. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +9 -44
  76. package/dist/types/server/host/app-config-composer.d.ts +2 -3
  77. package/dist/types/server/host/host-config-paths.d.cts +2 -7
  78. package/dist/types/server/host/precompiled-manifest.d.ts +5 -0
  79. package/dist/types/server/infra/host-config-paths.d.cts +7 -0
  80. package/dist/types/server/page-assets.d.ts +2 -5
  81. package/dist/types/server/runtime-space/store.d.ts +4 -0
  82. package/dist/types/shared/app-config-merge.d.ts +3 -0
  83. package/dist/types/shared/registry-generated/limits.d.ts +78 -4
  84. package/dist/types/shared/types/announcer.types.d.ts +14 -0
  85. package/dist/types/shared/types/notify.types.d.ts +36 -0
  86. package/dist/types/shared/types/role-gate.types.d.ts +8 -0
  87. package/host-native/src/aot-builder.ts +12 -5
  88. package/host-native/src/dev-chunk-gc.ts +104 -0
  89. package/host-native/src/host-prepare.ts +1 -1
  90. package/host-native/src/manifest-http.ts +1 -1
  91. package/host-native/src/page-http.ts +2 -67
  92. package/host-native/src/page-payload-cache.ts +68 -0
  93. package/package.json +16 -2
@@ -0,0 +1,9 @@
1
+ export type { MdAlign, MdBlock, MdFailure, MdInline, MdListItem, MdMeta, MdParseOptions, MdResult, MdSrc, MdToken, SomaMarkdownAdapter, SomaMarkdownPort, } from './port';
2
+ export { assertMarkdownAdapter } from './port';
3
+ export { buildMarkdown, inlineText, mdSlug, plainOf, safeMdHref, safeMdImage, softBreakJoiner } from './blocks';
4
+ import type { EngineLoadTelemetry } from '../load';
5
+ import { type SomaMarkdownAdapter, type SomaMarkdownPort } from './port';
6
+ export interface MarkdownPortOptions {
7
+ readonly telemetry?: EngineLoadTelemetry;
8
+ }
9
+ export declare function createMarkdownPort(adapter?: SomaMarkdownAdapter, options?: MarkdownPortOptions): SomaMarkdownPort;
@@ -0,0 +1,166 @@
1
+ export type MdAlign = 'left' | 'center' | 'right' | null;
2
+ /** 源码行区间 [起, 止),0 起;取不到为 [-1, -1] */
3
+ export type MdSrc = readonly [number, number];
4
+ export type MdInline = {
5
+ readonly t: 'text';
6
+ readonly v: string;
7
+ } | {
8
+ readonly t: 'strong';
9
+ readonly c: readonly MdInline[];
10
+ } | {
11
+ readonly t: 'em';
12
+ readonly c: readonly MdInline[];
13
+ } | {
14
+ readonly t: 'del';
15
+ readonly c: readonly MdInline[];
16
+ } | {
17
+ readonly t: 'code';
18
+ readonly v: string;
19
+ } | {
20
+ readonly t: 'br';
21
+ }
22
+ /** href 已过白名单;不合格的链接降为它的文字 */
23
+ | {
24
+ readonly t: 'link';
25
+ readonly href: string;
26
+ readonly external: boolean;
27
+ readonly title?: string;
28
+ readonly c: readonly MdInline[];
29
+ }
30
+ /** src 已过白名单;不合格的图片降为 alt 文字 */
31
+ | {
32
+ readonly t: 'image';
33
+ readonly src: string;
34
+ readonly alt: string;
35
+ readonly title?: string;
36
+ } | {
37
+ readonly t: 'fnref';
38
+ readonly id: string;
39
+ readonly n: number;
40
+ };
41
+ export interface MdListItem {
42
+ readonly task: boolean | null;
43
+ readonly blocks: readonly MdBlock[];
44
+ }
45
+ export type MdBlock = {
46
+ readonly t: 'heading';
47
+ readonly depth: 1 | 2 | 3 | 4 | 5 | 6;
48
+ readonly id: string;
49
+ readonly inline: readonly MdInline[];
50
+ readonly src: MdSrc;
51
+ }
52
+ /** tight = 紧凑列表里的段落(列表项内不留段距) */
53
+ | {
54
+ readonly t: 'paragraph';
55
+ readonly inline: readonly MdInline[];
56
+ readonly tight: boolean;
57
+ readonly src: MdSrc;
58
+ } | {
59
+ readonly t: 'list';
60
+ readonly ordered: boolean;
61
+ readonly start?: number;
62
+ readonly items: readonly MdListItem[];
63
+ readonly src: MdSrc;
64
+ } | {
65
+ readonly t: 'quote';
66
+ readonly blocks: readonly MdBlock[];
67
+ readonly src: MdSrc;
68
+ }
69
+ /** lang = 围栏信息串的第一个词(原样;语言归一交给代码高亮端口的 resolveLanguage);closed = 围栏已闭合(流式时末尾围栏可能未闭合) */
70
+ | {
71
+ readonly t: 'code';
72
+ readonly lang: string;
73
+ readonly text: string;
74
+ readonly closed: boolean;
75
+ readonly src: MdSrc;
76
+ } | {
77
+ readonly t: 'table';
78
+ readonly align: readonly MdAlign[];
79
+ readonly head: readonly (readonly MdInline[])[];
80
+ readonly rows: readonly (readonly (readonly MdInline[])[])[];
81
+ readonly src: MdSrc;
82
+ } | {
83
+ readonly t: 'hr';
84
+ readonly src: MdSrc;
85
+ }
86
+ /** 原始 HTML 块:不渲染,按原文文字显示 */
87
+ | {
88
+ readonly t: 'html';
89
+ readonly text: string;
90
+ readonly src: MdSrc;
91
+ } | {
92
+ readonly t: 'footnotes';
93
+ readonly items: readonly {
94
+ readonly id: string;
95
+ readonly n: number;
96
+ readonly blocks: readonly MdBlock[];
97
+ }[];
98
+ readonly src: MdSrc;
99
+ };
100
+ export interface MdMeta {
101
+ /** 标题大纲(id 一律 `md-` 前缀) */
102
+ readonly outline: readonly {
103
+ readonly depth: 1 | 2 | 3 | 4 | 5 | 6;
104
+ readonly text: string;
105
+ readonly id: string;
106
+ }[];
107
+ /** 去标记全文(供摘要、搜索、差异) */
108
+ readonly plainText: string;
109
+ /** 前 N 字(N 取 design limits.json#contentEngines.markdown.summaryChars) */
110
+ readonly summary: string;
111
+ readonly counts: {
112
+ readonly chars: number;
113
+ readonly blocks: number;
114
+ readonly images: number;
115
+ readonly links: number;
116
+ readonly codeBlocks: number;
117
+ readonly tables: number;
118
+ };
119
+ /** 被按文字保留的原始 HTML 与被拒的不安全地址数(> 0 时组件给一条提示) */
120
+ readonly dropped: {
121
+ readonly html: number;
122
+ readonly unsafeUrls: number;
123
+ };
124
+ /** 块数超过上限被截断 */
125
+ readonly truncated: boolean;
126
+ }
127
+ export type MdFailure = 'too-long' | 'parse-error' | 'engine-load-failed';
128
+ export type MdResult = {
129
+ readonly ok: true;
130
+ readonly blocks: readonly MdBlock[];
131
+ readonly meta: MdMeta;
132
+ } | {
133
+ readonly ok: false;
134
+ readonly reason: MdFailure;
135
+ readonly plainText: string;
136
+ };
137
+ export interface MdParseOptions {
138
+ /** 脚注语法(缺省开) */
139
+ readonly footnotes?: boolean;
140
+ /** 缺省取 design `limits.json#contentEngines.markdown`;调用方只能更小 */
141
+ readonly maxChars?: number;
142
+ readonly maxBlocks?: number;
143
+ }
144
+ /** 适配器输出的令牌(markdown-it Token 的可序列化子集) */
145
+ export interface MdToken {
146
+ readonly type: string;
147
+ readonly tag: string;
148
+ readonly nesting: number;
149
+ readonly content: string;
150
+ readonly info: string;
151
+ readonly markup: string;
152
+ readonly map: readonly [number, number] | null;
153
+ readonly attrs: readonly (readonly [string, string])[] | null;
154
+ readonly hidden: boolean;
155
+ readonly meta: unknown;
156
+ readonly children: readonly MdToken[] | null;
157
+ }
158
+ export interface SomaMarkdownAdapter {
159
+ tokenize(source: string, options: {
160
+ readonly footnotes: boolean;
161
+ }): Promise<readonly MdToken[]>;
162
+ }
163
+ export interface SomaMarkdownPort {
164
+ parse(source: string, options?: MdParseOptions): Promise<MdResult>;
165
+ }
166
+ export declare function assertMarkdownAdapter(adapter: unknown): void;
@@ -0,0 +1,6 @@
1
+ import { type EngineLoadTelemetry } from '../load';
2
+ import type { SomaStructuredAdapter } from './port';
3
+ export interface JsYamlAdapterOptions {
4
+ readonly telemetry?: EngineLoadTelemetry;
5
+ }
6
+ export declare function createJsYamlAdapter(options?: JsYamlAdapterOptions): SomaStructuredAdapter;
@@ -0,0 +1,29 @@
1
+ export type { SomaStructuredAdapter, SomaStructuredPort, StructuredFailure, StructuredFormat, StructuredParseFail, StructuredParseOk, StructuredParseOptions, StructuredParseResult, } from './port';
2
+ export { assertStructuredAdapter } from './port';
3
+ import type { EngineLoadTelemetry } from '../load';
4
+ import { type SomaStructuredAdapter, type SomaStructuredPort, type StructuredFormat } from './port';
5
+ export interface StructuredPortOptions {
6
+ readonly telemetry?: EngineLoadTelemetry;
7
+ }
8
+ /** 循环引用的占位文字(数据里出现同样的字符串不受影响:它只在 cycles > 0 时有意义) */
9
+ export declare const STRUCTURED_CYCLE_MARK = "[\u5FAA\u73AF\u5F15\u7528]";
10
+ /** 确定性格式推断(纯函数) */
11
+ export declare function detectStructuredFormat(text: string, hint?: {
12
+ readonly format?: string;
13
+ readonly filename?: string;
14
+ }): StructuredFormat;
15
+ /** JSON.parse 的错误位置:新版 V8 给 (line L column C),旧版给 position N;都取不到返回空 */
16
+ export declare function jsonErrorPosition(text: string, message: string): {
17
+ line?: number;
18
+ column?: number;
19
+ };
20
+ /**
21
+ * 原始值 → 纯 JSON 值(纯函数):节点超过 maxNodes 返回 null(调用方按 too-many-nodes 降级)。
22
+ * 只在祖先链上判循环(共享别名照常展开、计入节点数,防「十亿笑声」靠节点上限)。
23
+ */
24
+ export declare function normalizeStructured(raw: unknown, maxNodes: number): {
25
+ value: unknown;
26
+ nodes: number;
27
+ cycles: number;
28
+ } | null;
29
+ export declare function createStructuredPort(adapter?: SomaStructuredAdapter, options?: StructuredPortOptions): SomaStructuredPort;
@@ -0,0 +1,45 @@
1
+ export type StructuredFormat = 'json' | 'yaml';
2
+ /** 解析失败的原因闭集 */
3
+ export type StructuredFailure = 'syntax' | 'too-large' | 'too-many-nodes' | 'not-structured' | 'engine-load-failed';
4
+ export interface StructuredParseOptions {
5
+ /** 缺省取 design `limits.json#contentEngines.structured`;调用方只能更小 */
6
+ readonly maxChars?: number;
7
+ readonly maxNodes?: number;
8
+ }
9
+ export interface StructuredParseOk {
10
+ readonly ok: true;
11
+ readonly format: StructuredFormat;
12
+ /** 纯 JSON 值(可序列化;YAML 的共享别名已展开、循环引用替换成字符串 `[循环引用]` 并计入 `cycles`) */
13
+ readonly value: unknown;
14
+ /** 值里的节点总数(对象 / 数组 / 叶子各计 1) */
15
+ readonly nodes: number;
16
+ /** YAML 文档里被替换掉的循环引用数(JSON 恒为 0) */
17
+ readonly cycles: number;
18
+ }
19
+ export interface StructuredParseFail {
20
+ readonly ok: false;
21
+ readonly format: StructuredFormat;
22
+ readonly reason: StructuredFailure;
23
+ /** 语法错误的位置(1 起);取不到时缺省 */
24
+ readonly line?: number;
25
+ readonly column?: number;
26
+ /** 引擎给的原话(仅 syntax;不可信字符串,组件只能 textContent 写入) */
27
+ readonly message?: string;
28
+ }
29
+ export type StructuredParseResult = StructuredParseOk | StructuredParseFail;
30
+ /** 适配器只做 YAML 文本 → 原始值;语法错误抛带 `mark { line, column }`(0 起)的错误 */
31
+ export interface SomaStructuredAdapter {
32
+ parseYaml(text: string): Promise<unknown>;
33
+ }
34
+ export interface SomaStructuredPort {
35
+ /**
36
+ * 确定性的格式推断(同步、纯函数):显式 format 优先;文件名扩展名 .json / .yaml / .yml;
37
+ * 去掉开头空白后以 `{` / `[` 开头 → json(解析失败报 JSON 行列);否则 yaml(由 parse 判定它是不是结构)。
38
+ */
39
+ detect(text: string, hint?: {
40
+ readonly format?: string;
41
+ readonly filename?: string;
42
+ }): StructuredFormat;
43
+ parse(text: string, format?: StructuredFormat | 'auto', options?: StructuredParseOptions): Promise<StructuredParseResult>;
44
+ }
45
+ export declare function assertStructuredAdapter(adapter: unknown): void;
@@ -1,4 +1,4 @@
1
- import { SomaHttpClientConfig } from 'soma-core/base';
1
+ import { type SomaHttpClientConfig } from '../../base/SomaHttpClient';
2
2
  import { IHttpClient, HttpRequestConfig, UploadOptions } from './IHttpClient';
3
3
  /**
4
4
  * SomaHttpService — wraps the core SomaHttpClient and implements IHttpClient.
@@ -1,7 +1,6 @@
1
- import type { Announcer } from '../../a11y/announcer';
2
- import type { NotifyRenderer } from '../../render-ports/notify-renderer';
1
+ import type { Announcer } from '../../../shared/types/announcer.types';
3
2
  import type { SomaConfirmSpec } from '../../../shared/types/event.types';
4
- import type { INotifyService, NotifyOptions } from '../../../shared/types/notify.types';
3
+ import type { INotifyService, NotifyOptions, NotifyRenderer } from '../../../shared/types/notify.types';
5
4
  import type { SomaChoiceConfirmOutcome, SomaChoiceConfirmSpec } from '../../../shared/types/choice-confirm.types';
6
5
  /**
7
6
  * DefaultNotifyService — 无头通知服务(notify 端口的缺省适配器)。
@@ -1,5 +1,5 @@
1
1
  import { IPermission } from './IPermission';
2
- import type { SomaRoleGate } from '../../data/role-gate';
2
+ import type { SomaRoleGate } from '../../../shared/types/role-gate.types';
3
3
  /**
4
4
  * SomaPermission — stores roles and permissions as Sets.
5
5
  *
@@ -1,56 +1 @@
1
- import type { SomaConfirmSpec } from '../../shared/types/event.types';
2
- import type { NotifyLevel } from '../../shared/types/notify.types';
3
- import type { NotifyAction, NotifyCarrier } from '../../shared/types/notify.types';
4
- import type { SomaChoiceConfirmOutcome, SomaChoiceConfirmSpec } from '../../shared/types/choice-confirm.types';
5
- /** 交给渲染器的一条通知;`duration` 只透传调用方给的值,未给则不带字段,由渲染器决定停留 */
6
- export interface NotifyEntry {
7
- readonly id: string;
8
- readonly level: NotifyLevel;
9
- readonly message: string;
10
- readonly title?: string;
11
- readonly duration?: number;
12
- /** 呈现载体偏好;未给则渲染器按级别与动作自定 */
13
- readonly carrier?: NotifyCarrier;
14
- /** 附带动作;未给则无 */
15
- readonly action?: NotifyAction;
16
- }
17
- /**
18
- * 通知渲染端口(UI 体系注入,经 `SomaBootstrap` 选项 `renderPorts.notify`)。
19
- * core 不带可见实现:停留、动效、位置、模态呈现全在渲染器里。
20
- */
21
- export interface NotifyRenderer {
22
- show(entry: NotifyEntry): {
23
- dismiss(): void;
24
- };
25
- /**
26
- * 确认。`spec` 只在 typed / consent 级或 `tone: 'danger'` 时出现(plain 且无语气不带),`message` 恒等于 `spec.text`,不认识分级的渲染器照旧显示一句话。
27
- * `spec.tone === 'danger'`(破坏性确认):渲染器应给确认钮警示呈现,并把初始焦点放在「取消」;typed / consent 的放行规则不变。
28
- * 认识分级的渲染器必须用 `confirmSatisfied(spec, { typed, consented })` 决定确认钮此刻能不能点:
29
- * typed 要键入 `phrase`、consent 要先勾选同意(`impact` 是勾选旁的影响说明);
30
- * 键入框里输入法组字(`isImeProcessing`)期间的 Enter 是选词,不算确认;取消 / Esc / 点遮罩一律 resolve(false)。
31
- */
32
- confirm(req: {
33
- message: string;
34
- title?: string;
35
- spec?: SomaConfirmSpec;
36
- }): Promise<boolean>;
37
- alert(req: {
38
- message: string;
39
- title?: string;
40
- }): Promise<void>;
41
- /**
42
- * 选择型确认(C37 / C43,删除前转移):可选。实现了它,`services.notify.confirmChoice` 才存在(`DefaultNotifyService` 原样转发);
43
- * 没实现,通知服务不暴露该成员,行删除确认管道按「宿主不支持选择型确认」处理。取消 / Esc / 点遮罩一律 `{ accepted: false }`;
44
- * `required` 为真时没选不能确认;`value` 必须是 `candidates[].id` 之一。
45
- */
46
- confirmChoice?(spec: SomaChoiceConfirmSpec): Promise<SomaChoiceConfirmOutcome>;
47
- /**
48
- * 读屏播报(`NOTIFY | announce`,S7):可选。渲染器自己持有 live region 宿主,
49
- * 仅在通知服务没有接统一播报通道(`soma-core/a11y` 的页面级 Announcer)时才被调用;通道在场则由通道投递,不再走渲染器。
50
- */
51
- announce?(req: {
52
- message: string;
53
- politeness: 'polite' | 'assertive';
54
- }): void;
55
- dispose(): void;
56
- }
1
+ export type { NotifyEntry, NotifyRenderer } from '../../shared/types/notify.types';
@@ -21,6 +21,9 @@ import type { SomaChartEnginePort } from '../engines/chart';
21
21
  import type { SomaDragPort } from '../engines/dnd';
22
22
  import type { SomaDiffPort } from '../engines/diff';
23
23
  import type { SomaQrPort } from '../engines/qrcode';
24
+ import type { SomaHighlightPort } from '../engines/highlight';
25
+ import type { SomaStructuredPort } from '../engines/structured';
26
+ import type { SomaMarkdownPort } from '../engines/markdown';
24
27
  import { SomaPermission } from '../infra/permission/SomaPermission';
25
28
  import { SomaRouter } from '../infra/router/SomaRouter';
26
29
  import type { IStorageService } from '../infra/storage/IStorageService';
@@ -28,12 +31,13 @@ import { SomaTimer } from '../infra/timer/SomaTimer';
28
31
  import type { IRealtimeService } from '../infra/realtime/IRealtimeService';
29
32
  import type { SomaNavPort } from '../../shared/types/nav.types';
30
33
  import { type SomaNavHistory } from './nav-history';
31
- import type { SomaRuntimeServicesBase } from '../../shared/types/domain.types';
34
+ import type { SomaRuntimeServicesShape, SomaUiService } from '../base/runtime-services.types';
32
35
  import { type SomaIdentityPort, type SomaIdentityProvider } from '../infra/identity/identity-port';
33
36
  import { type SomaAppConfigPort } from '../infra/config/feature-flags';
34
37
  import type { SomaShortcutRegistry } from '../../shared/types/write-runtime.types';
38
+ export type { SomaRuntimeServicesShape, SomaUiService };
35
39
  /** Runtime infrastructure injected into domain instances by bootstrap */
36
- export interface SomaRuntimeServices extends SomaRuntimeServicesBase {
40
+ export interface SomaRuntimeServices extends SomaRuntimeServicesShape<SomaEnginePorts, SomaNavHistory> {
37
41
  router: SomaRouter;
38
42
  notify: DefaultNotifyService;
39
43
  logger: ConsoleLogger;
@@ -47,51 +51,13 @@ export interface SomaRuntimeServices extends SomaRuntimeServicesBase {
47
51
  permission: SomaPermission;
48
52
  i18n: SomaLocaleCatalog;
49
53
  realtime: IRealtimeService;
50
- /**
51
- * 界面中途提交:把此刻改过的页面状态立刻上屏,**不结束**当前事件事务。
52
- *
53
- * 存在的理由:一次事件 = 一次原子提交是刻意的设计(避免中间态闪烁、出错整体回滚),
54
- * 代价是**长任务里的中途进展播不出去**——实测 AI 生成 P50 约 40 秒,期间 Domain
55
- * 改多少次状态,界面一次都不动,连"生成中"都看不到。
56
- *
57
- * 它是**自愿**的:不调用,行为与过去逐字节一致;调用了,就等于声明
58
- * "已上屏的这部分不再享有失败回滚"。这个取舍只能由业务自己做。
59
- * 引擎未接线时(纯 Node 单测、无渲染宿主)为空操作,调用方不必判空。
60
- */
61
54
  ui: SomaUiService;
62
- /**
63
- * 通用观测通道(06e AD-CORE-06):数据组件 / 层栈上报 `adaptive` / `overlays` 流。
64
- * 未开观测时是空操作实现(`NOOP_OBSERVATION_CHANNEL`);开启时 bootstrap 换成真实采集器。
65
- */
66
55
  observation: SomaObservationChannel;
67
- /**
68
- * 引擎端口表(core 引擎端口设计 §1.2):`SomaBootstrapOptions.engines` 给出的适配器在这里变成端口,
69
- * 未给的槽位用各端口的缺省适配器。端口按需惰性构造(首次读取才建,缺省适配器首次使用才动态加载)。
70
- * 组件须在契约 `services` 白名单里声明 `engines` 才可见。
71
- */
72
56
  readonly engines: SomaEnginePorts;
73
- /**
74
- * 导航目录(E4,只读):服务端随页面下发的、按请求身份裁剪过的目录。外壳(顶栏、框架菜单)读它渲染。
75
- * 由 bootstrap 在创建页面根时接上;单测替身可以不给,所以是可选成员。
76
- */
77
57
  nav?: SomaNavPort;
78
- /**
79
- * 当前用户身份(K8,只读):值来自 Host 注入的 `identity` 函数,每次现读;查询里的 `$user.id` / `$user.team` 经它解析。
80
- * 没注入时什么字段都不提供(引用 `$user.*` 的查询按无结果处理)。
81
- */
82
58
  readonly identity: SomaIdentityPort;
83
- /**
84
- * 返回栈(C48,K53):`back(fallback, opts) / resolveBack / visit / settle / go / originOfCurrent / entries`。
85
- * 栈由 bootstrap 持有唯一一份(跨页面根同一份),路由端口来自宿主注入的 `navHistory`,没注入退化为浏览器历史。
86
- * 单测替身可不给。
87
- */
88
59
  readonly navHistory?: SomaNavHistory;
89
- /** 部署层只读端口(K30):页面 / 组件只读;`createDefaultRuntimeServices` 造的服务表一定带,单测替身可不给 */
90
60
  readonly appConfig?: SomaAppConfigPort;
91
- /**
92
- * 应用级快捷键注册中心(C56 K81,`app.shortcuts`):`register / on / pushScope / handle / helpTable`;每个服务表一份。
93
- * 序列键位的间隔取 design `shortcuts.sequenceTimeoutMs`;修饰键本平台映射由 `SomaBootstrapOptions.shortcutsModKey` 给。单测替身可不给。
94
- */
95
61
  readonly shortcuts?: SomaShortcutRegistry;
96
62
  }
97
63
  /** 组件 / Domain 可取的引擎端口;`temporal` 的时区与语言由调用方给出(core 不猜) */
@@ -103,6 +69,9 @@ export interface SomaEnginePorts {
103
69
  readonly dnd: SomaDragPort;
104
70
  readonly diff: SomaDiffPort;
105
71
  readonly qrcode: SomaQrPort;
72
+ readonly highlight: SomaHighlightPort;
73
+ readonly structured: SomaStructuredPort;
74
+ readonly markdown: SomaMarkdownPort;
106
75
  temporal(options: {
107
76
  readonly timeZone: string;
108
77
  readonly locale: string;
@@ -110,10 +79,6 @@ export interface SomaEnginePorts {
110
79
  }
111
80
  /** 按 `engines` 给出的适配器惰性构造各端口 */
112
81
  export declare function createEnginePorts(adapters?: Readonly<Partial<SomaEngineAdapters>>, telemetry?: EngineLoadTelemetry): SomaEnginePorts;
113
- /** 界面中途提交服务(见 SomaRuntimeServices.ui) */
114
- export interface SomaUiService {
115
- publish(): Promise<void>;
116
- }
117
82
  export declare function createDefaultRuntimeServices(options?: {
118
83
  appConfig?: unknown;
119
84
  /** 页面词表:多语言词表信封 */
@@ -1,6 +1,5 @@
1
- export declare function parseAppConfigYaml(source: string): unknown;
2
- /** Source packages provide defaults; the Host remains the final App-config owner. */
3
- export declare function mergeSourcePackageAppConfig(sourcePackageConfig: unknown, hostConfig: unknown): unknown;
1
+ import { mergeSourcePackageAppConfig, parseAppConfigYaml } from '../../shared/app-config-merge';
2
+ export { mergeSourcePackageAppConfig, parseAppConfigYaml };
4
3
  export declare function composeAppConfigYaml(sourcePackageConfigYaml: string, hostConfigYaml: string): string;
5
4
  /** Browser metadata uses the Host App's displayName, never a source-package brand. */
6
5
  export declare function readHostAppDisplayName(hostDir?: string | undefined): string;
@@ -1,7 +1,2 @@
1
- export function normalizeSomaEnv(raw: any): "test" | "prod";
2
- /** Priority: SOMA_ENV → APP_ENV → NODE_ENV (framework-neutral only). */
3
- export function readSomaEnv(env?: NodeJS.ProcessEnv): "test" | "prod";
4
- export function resolveHostConfigRoot(hostDir: any): any;
5
- export function getSomaHostConfigRoot(hostDir: any): any;
6
- export function resolveAppConfigPath(configRoot: any, envName: any): string | null;
7
- export function resolveHostAppConfigPath(hostDir: any, envName: any): string | null;
1
+ declare const _exports: typeof import("../infra/host-config-paths.cjs");
2
+ export = _exports;
@@ -0,0 +1,5 @@
1
+ import type { SomaPrecompiledManifest, SomaPrecompiledPage } from '../../build/compiler/full-manifest-builder';
2
+ /** 读构建期预编译清单:只读 runtime 空间的预热;没有预热或页面校验不过都返回 null。 */
3
+ export declare function loadPrecompiledManifest(hostDir: string, env?: Readonly<Record<string, string | undefined>>): SomaPrecompiledManifest | null;
4
+ /** Find precompiled page by route (supports /items → items/index short path) */
5
+ export declare function findPrecompiledPage(manifest: SomaPrecompiledManifest, urlPath: string): SomaPrecompiledPage | null;
@@ -0,0 +1,7 @@
1
+ export function normalizeSomaEnv(raw: any): "test" | "prod";
2
+ /** Priority: SOMA_ENV → APP_ENV → NODE_ENV (framework-neutral only). */
3
+ export function readSomaEnv(env?: NodeJS.ProcessEnv): "test" | "prod";
4
+ export function resolveHostConfigRoot(hostDir: any): any;
5
+ export function getSomaHostConfigRoot(hostDir: any): any;
6
+ export function resolveAppConfigPath(configRoot: any, envName: any): string | null;
7
+ export function resolveHostAppConfigPath(hostDir: any, envName: any): string | null;
@@ -3,12 +3,9 @@
3
3
  *
4
4
  * 刻意不 `import 'server-only'`:soma-ai 的冒烟探测器在经 jiti 加载的宿主服务里
5
5
  * 动态 import 本入口,server-only 在纯 Node 语境下会抛错(理由同 `server/page-declaration.ts`)。
6
+ * CORE-L04:本文件为纯薄契约重导出。
6
7
  */
7
8
  export { compilePageAssets } from '../build/compiler/page-assets';
8
9
  export { compileSomaPageAssets } from './host/soma-page-compile';
9
10
  export { compilePublishedPageArtifact } from './host/published-page-artifact-cache';
10
- import type { SomaPrecompiledManifest, SomaPrecompiledPage } from '../build/compiler/full-manifest-builder';
11
- /** 读构建期预编译清单:只读 runtime 空间的预热;没有预热或页面校验不过都返回 null。 */
12
- export declare function loadPrecompiledManifest(hostDir: string, env?: Readonly<Record<string, string | undefined>>): SomaPrecompiledManifest | null;
13
- /** Find precompiled page by route (supports /items → items/index short path) */
14
- export declare function findPrecompiledPage(manifest: SomaPrecompiledManifest, urlPath: string): SomaPrecompiledPage | null;
11
+ export { loadPrecompiledManifest, findPrecompiledPage } from './host/precompiled-manifest';
@@ -44,6 +44,8 @@ export declare class SomaRuntimeStore {
44
44
  };
45
45
  /** 先 L1 再 L2,读到回填 L1;文件缺失或摘要与内容不符返回 null(不信任损坏文件) */
46
46
  getArtifact(digest: string): SomaStandardPage | null;
47
+ /** 删除产物文件(升级丢弃旧产物后清理用;调用方保证没有别的绑定引用它);返回是否真删了文件 */
48
+ removeArtifact(digest: string): boolean;
47
49
  hasArtifact(digest: string): boolean;
48
50
  /** 记下某摘要产出的编译结果键,供按 URL 替换 / 撤下时一并作废 */
49
51
  trackCompiled(digest: string, key: string): void;
@@ -61,6 +63,8 @@ export declare class SomaRuntimeStore {
61
63
  /** 其他进程改过该绑定文件吗(mtime 比对);文件不在也算变了(被解绑) */
62
64
  bindingChanged(address: string, lastMtimeMs: number | null): boolean;
63
65
  removeBinding(address: string): boolean;
66
+ /** 本进程读绑定时因落盘格式版本不符而丢弃的旧绑定个数(启动汇总日志用) */
67
+ legacyDiscarded: number;
64
68
  /** 严格删除:文件本来就不在返回 false(视为成功);其他失败(权限 / IO)原样抛出,不吞 */
65
69
  removeBindingStrict(address: string): boolean;
66
70
  /** 读 `bindings/` 下全部绑定(启动装入用);损坏文件跳过 */
@@ -0,0 +1,3 @@
1
+ export declare function parseAppConfigYaml(source: string): unknown;
2
+ /** Source packages provide defaults; the Host remains the final App-config owner. */
3
+ export declare function mergeSourcePackageAppConfig(sourcePackageConfig: unknown, hostConfig: unknown): unknown;
@@ -81,6 +81,14 @@ export declare const SOMA_PIPELINE_LIMITS: {
81
81
  readonly module: "soma-core";
82
82
  readonly file: "core/server/registry/api-registry-store.ts";
83
83
  readonly symbol: "SOMA_PIPELINE_LIMITS";
84
+ }, {
85
+ readonly module: "soma-core";
86
+ readonly file: "core/client/engines/diff/index.ts";
87
+ readonly symbol: "SOMA_PIPELINE_LIMITS";
88
+ }, {
89
+ readonly module: "soma-core";
90
+ readonly file: "core/client/engines/highlight/index.ts";
91
+ readonly symbol: "SOMA_PIPELINE_LIMITS";
84
92
  }, {
85
93
  readonly module: "soma-core";
86
94
  readonly file: "core/server/registry/page-registry-store.ts";
@@ -323,15 +331,15 @@ export declare const SOMA_PIPELINE_LIMITS: {
323
331
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI";
324
332
  }, {
325
333
  readonly module: "soma-ai";
326
- readonly file: "src/api/common/RateLimitBackend.ts";
334
+ readonly file: "src/server/common/RateLimitBackend.ts";
327
335
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI";
328
336
  }, {
329
337
  readonly module: "soma-ai";
330
- readonly file: "src/api/common/RequestBodyLimit.ts";
338
+ readonly file: "src/server/common/RequestBodyLimit.ts";
331
339
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI";
332
340
  }, {
333
341
  readonly module: "soma-ai";
334
- readonly file: "src/api/service/ai-assistant/Chat.ts";
342
+ readonly file: "src/server/services/ai-assistant/Chat.ts";
335
343
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI";
336
344
  }, {
337
345
  readonly module: "soma-ai";
@@ -343,7 +351,7 @@ export declare const SOMA_PIPELINE_LIMITS: {
343
351
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI";
344
352
  }, {
345
353
  readonly module: "soma-ai";
346
- readonly file: "src/api/common/TrustedRequestContext.ts";
354
+ readonly file: "src/domain/ai-shared/TrustedRequestContext.ts";
347
355
  readonly symbol: "SOMA_PIPELINE_LIMITS_AI_RUNTIME";
348
356
  }, {
349
357
  readonly module: "soma-ai";
@@ -506,4 +514,70 @@ export declare const SOMA_PIPELINE_LIMITS: {
506
514
  readonly componentBytesPerPage: 163840;
507
515
  readonly overrideBlockBytes: 8192;
508
516
  };
517
+ readonly contentEngines: {
518
+ readonly diff: {
519
+ readonly basis: {
520
+ readonly maxChars: "单个差异计算两侧合计字数上限;超限不计算、整段替换(参考文本差异组件笔记 C.5「单个差异组件总量 200 000 字」,实测 4:万字级逐字比较需超时与退化)";
521
+ readonly maxCharsPerCompare: "单次词级比较(一对句子 / 一次 diff 调用)两侧合计字数上限(笔记 C.2 BaseOpts maxChars 20 000)";
522
+ readonly timeoutMs: "一次 diffProse / diffItems 的总时限(毫秒),同 VisualEditor timeout 1000(笔记 C.2)";
523
+ readonly maxItems: "条目列表单侧条目数上限;超限不逐条比较(笔记 C.5「条目 2 000 个」)";
524
+ readonly moveDetectMaxChanged: "变化条目(增 + 删)超过此数不做移动检测(笔记 C.2,wikidiff2 增删合计 > 100 不检测的放宽版,经验值)";
525
+ readonly pairAt: "句 / 段配对阈值:字符多重集 Dice ≥ 此值视为改写(VisualEditor diffThreshold 0.5;实测 3 的改写句为 0.84–0.89)";
526
+ readonly rewriteBelow: "整体相似度低于此值整段替换(等效 VE keep < 0.5 × diff;实测 2 的 C3 整句重写约 0.16)";
527
+ readonly absorbOrphan: "孤字吸收:夹在两处改动间、长度 ≤ 此值(字)的非标点相同片段并入改动(实测 2 的 C5「期」)";
528
+ readonly absorbOrphanMax: "调用方可调的孤字吸收上限(字),防止把整句吸成改动";
529
+ readonly titleAt: "无 key 条目按标题配对的相似度阈值(笔记 C.2 ItemOpts.match.titleAt 0.6)";
530
+ readonly bodyAt: "无 key 条目按正文配对的相似度阈值(笔记 C.2 ItemOpts.match.bodyAt 0.5)";
531
+ readonly maxAlignTokens: "序列对齐的不同键数上限(每个键映射为一个 BMP 私用区字符,U+E000–U+F8FF 共 6400 个)";
532
+ readonly maxPairMatrix: "一段删增区间内句 / 段配对的候选矩阵上限(删数 × 增数),超出不配对、按删 + 增呈现;经验值,证据弱";
533
+ readonly maxPairCandidates: "无 key 条目按相似度配对的候选矩阵上限(剩余旧条目 × 剩余新条目);经验值,证据弱";
534
+ };
535
+ readonly maxChars: 200000;
536
+ readonly maxCharsPerCompare: 20000;
537
+ readonly timeoutMs: 1000;
538
+ readonly maxItems: 2000;
539
+ readonly moveDetectMaxChanged: 500;
540
+ readonly pairAt: 0.5;
541
+ readonly rewriteBelow: 0.4;
542
+ readonly absorbOrphan: 1;
543
+ readonly absorbOrphanMax: 4;
544
+ readonly titleAt: 0.6;
545
+ readonly bodyAt: 0.5;
546
+ readonly maxAlignTokens: 6400;
547
+ readonly maxPairMatrix: 2500;
548
+ readonly maxPairCandidates: 250000;
549
+ };
550
+ readonly highlight: {
551
+ readonly basis: {
552
+ readonly maxLines: "高亮的最多行数;超出部分按纯文本(参考文本差异组件笔记 C.2 端口 2 maxLines 5 000)";
553
+ readonly maxLineLength: "单行超过此字符数整行按纯文本(笔记 C.2 maxLineLength 2 000,压缩后的单行 JS / JSON 常见)";
554
+ readonly timeoutMs: "一次解析的时限(毫秒);Lezer 按 advance() 分步解析,超时整段按纯文本(经验值,与差异端口同取 1 000)";
555
+ readonly maxChars: "整段超过此字符数不解析、按纯文本(经验值,证据弱:约 1 MB 文本)";
556
+ readonly jsonSniffMaxChars: "语言推断「整体能 JSON.parse」只对不超过此字符数的样本做(避免对大文本反复解析;经验值)";
557
+ };
558
+ readonly maxLines: 5000;
559
+ readonly maxLineLength: 2000;
560
+ readonly timeoutMs: 1000;
561
+ readonly maxChars: 1000000;
562
+ readonly jsonSniffMaxChars: 200000;
563
+ };
564
+ readonly structured: {
565
+ readonly basis: {
566
+ readonly maxChars: "JSON / YAML 原文超过此字符数不解析、按原文显示(与代码高亮端口 maxChars 同取约 1 MB;经验值,证据弱)";
567
+ readonly maxNodes: "解析后值的节点总数上限(对象 / 数组 / 叶子各计 1);YAML 别名展开超限即按 too-many-nodes 降级,防「十亿笑声」式别名炸弹(经验值:20 万节点约为 1 MB 紧凑 JSON 的量级)";
568
+ };
569
+ readonly maxChars: 1000000;
570
+ readonly maxNodes: 200000;
571
+ };
572
+ readonly markdown: {
573
+ readonly basis: {
574
+ readonly maxChars: "Markdown 原文超过此字符数不解析、按纯文本显示(参考文本差异组件笔记 C.2 端口 1 limits.maxChars 200 000)";
575
+ readonly maxBlocks: "块数上限,超出截断并标 truncated(笔记 C.2 maxBlocks 5 000)";
576
+ readonly summaryChars: "meta.summary 取去标记全文的前 N 字(笔记 C.2「前 80 字」)";
577
+ };
578
+ readonly maxChars: 200000;
579
+ readonly maxBlocks: 5000;
580
+ readonly summaryChars: 80;
581
+ };
582
+ };
509
583
  };