soma-core 2.2.8 → 2.2.10
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.
- package/core/build/compiler/full-manifest-builder.ts +1 -1
- package/core/build/compiler/host-config-sync.cjs +1 -1
- package/core/build/compiler/soma-manifest-webpack-plugin.js +2 -6
- package/core/build/compiler/soma-precompile.js +84 -4
- package/core/client/a11y/announcer.ts +2 -16
- package/core/client/base/SomaPageRootBase.ts +2 -2
- package/core/client/base/defineSomaView.ts +11 -2
- package/core/client/base/runtime-services.types.ts +57 -0
- package/core/client/data/role-gate.ts +2 -8
- package/core/client/engine/event-engine.ts +1 -0
- package/core/client/engines/diff/adapter-jsdiff.ts +27 -8
- package/core/client/engines/diff/code.ts +205 -0
- package/core/client/engines/diff/index.ts +107 -6
- package/core/client/engines/diff/items.ts +212 -0
- package/core/client/engines/diff/port.ts +215 -3
- package/core/client/engines/diff/prose.ts +443 -0
- package/core/client/engines/engine-adapters.ts +6 -0
- package/core/client/engines/highlight/adapter-lezer.ts +109 -0
- package/core/client/engines/highlight/index.ts +135 -0
- package/core/client/engines/highlight/port.ts +92 -0
- package/core/client/engines/markdown/adapter-markdown-it.ts +65 -0
- package/core/client/engines/markdown/blocks.ts +335 -0
- package/core/client/engines/markdown/index.ts +51 -0
- package/core/client/engines/markdown/port.ts +94 -0
- package/core/client/engines/markdown/vendor-modules.d.ts +6 -0
- package/core/client/engines/structured/adapter-js-yaml.ts +33 -0
- package/core/client/engines/structured/index.ts +139 -0
- package/core/client/engines/structured/port.ts +59 -0
- package/core/client/infra/http/SomaHttpService.ts +2 -4
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -3
- package/core/client/infra/permission/SomaPermission.ts +1 -1
- package/core/client/render-ports/notify-renderer.ts +2 -46
- package/core/client/runtime/SomaRuntimeServices.ts +16 -45
- package/core/server/host/app-config-composer.ts +6 -52
- package/core/server/host/host-config-paths.cjs +2 -100
- package/core/server/host/precompiled-manifest.ts +69 -0
- package/core/server/host/source-packages.cjs +3 -0
- package/core/server/infra/host-config-paths.cjs +100 -0
- package/core/server/page-assets.ts +2 -70
- package/core/server/runtime-space/bindings.ts +33 -4
- package/core/server/runtime-space/store.ts +16 -1
- package/core/shared/app-config-merge.ts +59 -0
- package/core/shared/registry-generated/limits.ts +84 -4
- package/core/shared/types/announcer.types.ts +18 -0
- package/core/shared/types/notify.types.ts +26 -0
- package/core/shared/types/role-gate.types.ts +11 -0
- package/dist/browser/runtime-bundle.manifest.json +51 -7
- package/dist/browser/soma-runtime.js +120952 -104762
- package/dist/core/index.cjs +113613 -97412
- package/dist/host-native/aot-builder.cjs +582 -371
- package/dist/host-native/native-server.cjs +203 -72
- package/dist/lsp/component-tree.cjs +84 -4
- package/dist/types/build/compiler/full-manifest-builder.d.ts +1 -1
- package/dist/types/client/a11y/announcer.d.ts +2 -14
- package/dist/types/client/base/SomaPageRootBase.d.ts +2 -2
- package/dist/types/client/base/runtime-services.types.d.ts +50 -0
- package/dist/types/client/data/role-gate.d.ts +2 -8
- package/dist/types/client/engines/diff/code.d.ts +27 -0
- package/dist/types/client/engines/diff/index.d.ts +2 -1
- package/dist/types/client/engines/diff/items.d.ts +24 -0
- package/dist/types/client/engines/diff/port.d.ts +201 -2
- package/dist/types/client/engines/diff/prose.d.ts +80 -0
- package/dist/types/client/engines/engine-adapters.d.ts +6 -0
- package/dist/types/client/engines/highlight/adapter-lezer.d.ts +6 -0
- package/dist/types/client/engines/highlight/index.d.ts +15 -0
- package/dist/types/client/engines/highlight/port.d.ts +64 -0
- package/dist/types/client/engines/markdown/adapter-markdown-it.d.ts +6 -0
- package/dist/types/client/engines/markdown/blocks.d.ts +29 -0
- package/dist/types/client/engines/markdown/index.d.ts +9 -0
- package/dist/types/client/engines/markdown/port.d.ts +166 -0
- package/dist/types/client/engines/structured/adapter-js-yaml.d.ts +6 -0
- package/dist/types/client/engines/structured/index.d.ts +29 -0
- package/dist/types/client/engines/structured/port.d.ts +45 -0
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +2 -3
- package/dist/types/client/infra/permission/SomaPermission.d.ts +1 -1
- package/dist/types/client/render-ports/notify-renderer.d.ts +1 -56
- package/dist/types/client/runtime/SomaRuntimeServices.d.ts +9 -44
- package/dist/types/server/host/app-config-composer.d.ts +2 -3
- package/dist/types/server/host/host-config-paths.d.cts +2 -7
- package/dist/types/server/host/precompiled-manifest.d.ts +5 -0
- package/dist/types/server/host/source-packages.d.cts +5 -0
- package/dist/types/server/infra/host-config-paths.d.cts +7 -0
- package/dist/types/server/page-assets.d.ts +2 -5
- package/dist/types/server/runtime-space/store.d.ts +4 -0
- package/dist/types/shared/app-config-merge.d.ts +3 -0
- package/dist/types/shared/registry-generated/limits.d.ts +82 -4
- package/dist/types/shared/types/announcer.types.d.ts +14 -0
- package/dist/types/shared/types/notify.types.d.ts +36 -0
- package/dist/types/shared/types/role-gate.types.d.ts +8 -0
- package/host-native/src/aot-builder.ts +159 -96
- package/host-native/src/dev-chunk-gc.ts +104 -0
- package/host-native/src/host-prepare.ts +1 -1
- package/host-native/src/manifest-http.ts +1 -1
- package/host-native/src/page-http.ts +2 -67
- package/host-native/src/page-payload-cache.ts +68 -0
- package/host-native/src/public-packages.cjs +147 -50
- package/package.json +16 -2
|
@@ -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/
|
|
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/
|
|
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/
|
|
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/
|
|
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,74 @@ 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
|
+
readonly codeContext: "代码差异每块的上下文行数(笔记 C.5「上下文 3 行」,同 git diff -U3 / VS Code)";
|
|
535
|
+
readonly codeIntraMaxLine: "代码改行做行内字符差异的单行长度上限(字符);更长的行只标整行增删(经验值:压缩后的长行逐字比较无意义且耗时)";
|
|
536
|
+
};
|
|
537
|
+
readonly maxChars: 200000;
|
|
538
|
+
readonly maxCharsPerCompare: 20000;
|
|
539
|
+
readonly timeoutMs: 1000;
|
|
540
|
+
readonly maxItems: 2000;
|
|
541
|
+
readonly moveDetectMaxChanged: 500;
|
|
542
|
+
readonly pairAt: 0.5;
|
|
543
|
+
readonly rewriteBelow: 0.4;
|
|
544
|
+
readonly absorbOrphan: 1;
|
|
545
|
+
readonly absorbOrphanMax: 4;
|
|
546
|
+
readonly titleAt: 0.6;
|
|
547
|
+
readonly bodyAt: 0.5;
|
|
548
|
+
readonly maxAlignTokens: 6400;
|
|
549
|
+
readonly maxPairMatrix: 2500;
|
|
550
|
+
readonly maxPairCandidates: 250000;
|
|
551
|
+
readonly codeContext: 3;
|
|
552
|
+
readonly codeIntraMaxLine: 500;
|
|
553
|
+
};
|
|
554
|
+
readonly highlight: {
|
|
555
|
+
readonly basis: {
|
|
556
|
+
readonly maxLines: "高亮的最多行数;超出部分按纯文本(参考文本差异组件笔记 C.2 端口 2 maxLines 5 000)";
|
|
557
|
+
readonly maxLineLength: "单行超过此字符数整行按纯文本(笔记 C.2 maxLineLength 2 000,压缩后的单行 JS / JSON 常见)";
|
|
558
|
+
readonly timeoutMs: "一次解析的时限(毫秒);Lezer 按 advance() 分步解析,超时整段按纯文本(经验值,与差异端口同取 1 000)";
|
|
559
|
+
readonly maxChars: "整段超过此字符数不解析、按纯文本(经验值,证据弱:约 1 MB 文本)";
|
|
560
|
+
readonly jsonSniffMaxChars: "语言推断「整体能 JSON.parse」只对不超过此字符数的样本做(避免对大文本反复解析;经验值)";
|
|
561
|
+
};
|
|
562
|
+
readonly maxLines: 5000;
|
|
563
|
+
readonly maxLineLength: 2000;
|
|
564
|
+
readonly timeoutMs: 1000;
|
|
565
|
+
readonly maxChars: 1000000;
|
|
566
|
+
readonly jsonSniffMaxChars: 200000;
|
|
567
|
+
};
|
|
568
|
+
readonly structured: {
|
|
569
|
+
readonly basis: {
|
|
570
|
+
readonly maxChars: "JSON / YAML 原文超过此字符数不解析、按原文显示(与代码高亮端口 maxChars 同取约 1 MB;经验值,证据弱)";
|
|
571
|
+
readonly maxNodes: "解析后值的节点总数上限(对象 / 数组 / 叶子各计 1);YAML 别名展开超限即按 too-many-nodes 降级,防「十亿笑声」式别名炸弹(经验值:20 万节点约为 1 MB 紧凑 JSON 的量级)";
|
|
572
|
+
};
|
|
573
|
+
readonly maxChars: 1000000;
|
|
574
|
+
readonly maxNodes: 200000;
|
|
575
|
+
};
|
|
576
|
+
readonly markdown: {
|
|
577
|
+
readonly basis: {
|
|
578
|
+
readonly maxChars: "Markdown 原文超过此字符数不解析、按纯文本显示(参考文本差异组件笔记 C.2 端口 1 limits.maxChars 200 000)";
|
|
579
|
+
readonly maxBlocks: "块数上限,超出截断并标 truncated(笔记 C.2 maxBlocks 5 000)";
|
|
580
|
+
readonly summaryChars: "meta.summary 取去标记全文的前 N 字(笔记 C.2「前 80 字」)";
|
|
581
|
+
};
|
|
582
|
+
readonly maxChars: 200000;
|
|
583
|
+
readonly maxBlocks: 5000;
|
|
584
|
+
readonly summaryChars: 80;
|
|
585
|
+
};
|
|
586
|
+
};
|
|
509
587
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type AnnouncePoliteness = 'polite' | 'assertive';
|
|
2
|
+
export interface AnnounceOptions {
|
|
3
|
+
readonly politeness?: AnnouncePoliteness;
|
|
4
|
+
}
|
|
5
|
+
export interface Announcer {
|
|
6
|
+
/** 追加一条播报;空消息忽略;politeness 缺省 polite,未知值抛 TypeError */
|
|
7
|
+
announce(message: string, options?: AnnounceOptions): void;
|
|
8
|
+
/** 两个常驻宿主 */
|
|
9
|
+
hosts(): Readonly<Record<AnnouncePoliteness, HTMLElement>>;
|
|
10
|
+
/** 立即移除全部待清理节点 */
|
|
11
|
+
clear(): void;
|
|
12
|
+
/** 清空、取消计时并移除宿主;之后 announce 忽略 */
|
|
13
|
+
dispose(): void;
|
|
14
|
+
}
|
|
@@ -35,3 +35,39 @@ export interface INotifyService {
|
|
|
35
35
|
/** 读屏播报(S7 · `NOTIFY | announce`);可选,缺省实现见 DefaultNotifyService */
|
|
36
36
|
announce?(message: string, politeness?: 'polite' | 'assertive'): void;
|
|
37
37
|
}
|
|
38
|
+
/** 交给渲染器的一条通知;`duration` 只透传调用方给的值,未给则不带字段,由渲染器决定停留 */
|
|
39
|
+
export interface NotifyEntry {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly level: NotifyLevel;
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly title?: string;
|
|
44
|
+
readonly duration?: number;
|
|
45
|
+
/** 呈现载体偏好;未给则渲染器按级别与动作自定 */
|
|
46
|
+
readonly carrier?: NotifyCarrier;
|
|
47
|
+
/** 附带动作;未给则无 */
|
|
48
|
+
readonly action?: NotifyAction;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 通知渲染端口(UI 体系注入,经 `SomaBootstrap` 选项 `renderPorts.notify`)。
|
|
52
|
+
* core 不带可见实现:停留、动效、位置、模态呈现全在渲染器里。
|
|
53
|
+
*/
|
|
54
|
+
export interface NotifyRenderer {
|
|
55
|
+
show(entry: NotifyEntry): {
|
|
56
|
+
dismiss(): void;
|
|
57
|
+
};
|
|
58
|
+
confirm(req: {
|
|
59
|
+
message: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
spec?: SomaConfirmSpec;
|
|
62
|
+
}): Promise<boolean>;
|
|
63
|
+
alert(req: {
|
|
64
|
+
message: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
confirmChoice?(spec: SomaChoiceConfirmSpec): Promise<SomaChoiceConfirmOutcome>;
|
|
68
|
+
announce?(req: {
|
|
69
|
+
message: string;
|
|
70
|
+
politeness: 'polite' | 'assertive';
|
|
71
|
+
}): void;
|
|
72
|
+
dispose(): void;
|
|
73
|
+
}
|
|
@@ -2,7 +2,8 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import esbuild, { type BuildContext, type Plugin } from 'esbuild';
|
|
5
|
-
import { readAllSomaPublicAliases } from './public-packages.cjs';
|
|
5
|
+
import { readAllSomaPublicAliases, createPublicAliasesFilter } from './public-packages.cjs';
|
|
6
|
+
import { collectDevChunks, outputsRelativeTo, releaseDevChunks } from './dev-chunk-gc';
|
|
6
7
|
import { toPascalCase } from '../../core/server/api/service-path';
|
|
7
8
|
import { getSomaHostSourceRoot, getSomaHostApiRoot } from '../../core/server/host/source-packages.cjs';
|
|
8
9
|
import { getSomaSourceRootAliases, matchSomaSourceRoot, somaSourceRootFilter } from '../../core/server/host/source-aliases.cjs';
|
|
@@ -86,14 +87,16 @@ const repoRoot = path.resolve(coreRoot, '..');
|
|
|
86
87
|
* 客户端专属 esbuild 插件:
|
|
87
88
|
* 1. 严禁 import 'server-only';
|
|
88
89
|
* 2. 映射 @soma-host/* 虚拟/可选模块;
|
|
89
|
-
* 3. 映射 soma-*
|
|
90
|
+
* 3. 映射 soma-* 及 soma.source 源包公开子路径。
|
|
90
91
|
*/
|
|
91
92
|
function createBrowserClientPlugin(options: {
|
|
92
93
|
hostDir: string;
|
|
93
94
|
webRoot: string;
|
|
95
|
+
env?: NodeJS.ProcessEnv;
|
|
94
96
|
}): Plugin {
|
|
95
|
-
const { hostDir, webRoot } = options;
|
|
96
|
-
const publicAliases = readAllSomaPublicAliases(hostDir, repoRoot, [webRoot, coreRoot]) as Record<string, string>;
|
|
97
|
+
const { hostDir, webRoot, env } = options;
|
|
98
|
+
const publicAliases = readAllSomaPublicAliases(hostDir, repoRoot, [webRoot, coreRoot], env) as Record<string, string>;
|
|
99
|
+
const publicFilter = createPublicAliasesFilter(publicAliases);
|
|
97
100
|
|
|
98
101
|
return {
|
|
99
102
|
name: 'soma-browser-client-plugin',
|
|
@@ -174,7 +177,7 @@ function createBrowserClientPlugin(options: {
|
|
|
174
177
|
});
|
|
175
178
|
|
|
176
179
|
// 5b. 源码根别名(soma.sourceRoots)
|
|
177
|
-
registerSourceRootResolve(build, hostDir);
|
|
180
|
+
registerSourceRootResolve(build, hostDir, env);
|
|
178
181
|
|
|
179
182
|
// 6. 拦截内部 engine 模块私有深导入(RT4 守卫)
|
|
180
183
|
build.onResolve({ filter: /core\/client\/engine\// }, (args) => {
|
|
@@ -186,14 +189,16 @@ function createBrowserClientPlugin(options: {
|
|
|
186
189
|
return undefined;
|
|
187
190
|
});
|
|
188
191
|
|
|
189
|
-
// 7. soma-*
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
// 7. soma-* 与 soma.source 源包公开子路径解析
|
|
193
|
+
if (publicFilter) {
|
|
194
|
+
build.onResolve({ filter: publicFilter }, (args) => {
|
|
195
|
+
const direct = publicAliases[args.path];
|
|
196
|
+
if (direct && fs.existsSync(direct)) {
|
|
197
|
+
return { path: direct };
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
197
202
|
|
|
198
203
|
// 8. 可选 peer 依赖 echarts:仅当包 `echarts` 本身无法解析(未安装)时才回落轻量无头桩模块,
|
|
199
204
|
// 防未装 echarts 的应用在 soma dev / build 时崩溃;已安装 echarts 但某个子路径解析失败(版本不符、路径写错)
|
|
@@ -263,7 +268,7 @@ export async function buildBrowserClient(
|
|
|
263
268
|
fs.mkdirSync(clientOutDir, { recursive: true });
|
|
264
269
|
|
|
265
270
|
const clientEntry = path.join(hostNativeRoot, 'client/browser-entry.ts');
|
|
266
|
-
const plugin = createBrowserClientPlugin({ hostDir, webRoot });
|
|
271
|
+
const plugin = createBrowserClientPlugin({ hostDir, webRoot, env: options.env });
|
|
267
272
|
|
|
268
273
|
// 编译并输出 CSS
|
|
269
274
|
const cssSourcePath = path.join(hostNativeRoot, 'styles/globals.css');
|
|
@@ -315,9 +320,16 @@ export async function buildBrowserClient(
|
|
|
315
320
|
let ctx: BuildContext | null = null;
|
|
316
321
|
let entryUrl = '/_soma/client/browser-entry.js';
|
|
317
322
|
|
|
323
|
+
// 开发态每次构建后按进程登记回收旧分片(dev-chunk-gc.ts):旧实现从不清理,chunks/ 会无限增长
|
|
324
|
+
const devRebuild = async (): Promise<void> => {
|
|
325
|
+
if (!ctx) return;
|
|
326
|
+
const result = await ctx.rebuild();
|
|
327
|
+
if (result.metafile) collectDevChunks(clientOutDir, outputsRelativeTo(clientOutDir, Object.keys(result.metafile.outputs)));
|
|
328
|
+
};
|
|
329
|
+
|
|
318
330
|
if (options.dev) {
|
|
319
|
-
ctx = await esbuild.context(buildOptions);
|
|
320
|
-
await
|
|
331
|
+
ctx = await esbuild.context({ ...buildOptions, metafile: true });
|
|
332
|
+
await devRebuild();
|
|
321
333
|
entryUrl = '/_soma/client/browser-entry.js';
|
|
322
334
|
} else {
|
|
323
335
|
const result = await esbuild.build({
|
|
@@ -352,20 +364,31 @@ export async function buildBrowserClient(
|
|
|
352
364
|
cssUrl,
|
|
353
365
|
cssText: finalCss,
|
|
354
366
|
rebuild: async () => {
|
|
355
|
-
|
|
356
|
-
await ctx.rebuild();
|
|
357
|
-
}
|
|
367
|
+
await devRebuild();
|
|
358
368
|
},
|
|
359
369
|
dispose: async () => {
|
|
360
370
|
if (ctx) {
|
|
361
371
|
await ctx.dispose();
|
|
372
|
+
releaseDevChunks(clientOutDir);
|
|
362
373
|
}
|
|
363
374
|
},
|
|
364
375
|
};
|
|
365
376
|
}
|
|
366
377
|
|
|
378
|
+
/** 将公开包说明符映射为无冲突的共享 AOT 预编译文件名(不含 .cjs 后缀) */
|
|
379
|
+
function sharedPackageSlug(specifier: string): string {
|
|
380
|
+
const safe = specifier
|
|
381
|
+
.replace(/^@/, '')
|
|
382
|
+
.replace(/[^a-zA-Z0-9_-]+/g, '__')
|
|
383
|
+
.replace(/^_+|_+$/g, '');
|
|
384
|
+
const hash = createHash('sha256').update(specifier).digest('hex').slice(0, 8);
|
|
385
|
+
return `${safe || 'pkg'}-${hash}`;
|
|
386
|
+
}
|
|
387
|
+
|
|
367
388
|
/**
|
|
368
|
-
* 后端 AOT 预编译:扫描后端服务源文件及 soma.app.ts,内联编译成 Node CJS 极速产物并生成 aot-manifest.json
|
|
389
|
+
* 后端 AOT 预编译:扫描后端服务源文件及 soma.app.ts,内联编译成 Node CJS 极速产物并生成 aot-manifest.json。
|
|
390
|
+
* 被引用的 soma-* / soma.source 源包出口统一预编译一次到 `aot-server/_packages/*.cjs`,各服务通过相对 require 共享同一份实例,
|
|
391
|
+
* 既彻底避免 Node 24 拒绝在 node_modules 下剥离 .ts 类型(ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING),又避免多服务重复内联导致的体积膨胀与单例分裂。
|
|
369
392
|
*/
|
|
370
393
|
export async function buildServerAot(
|
|
371
394
|
options: BuildServerAotOptions,
|
|
@@ -375,15 +398,17 @@ export async function buildServerAot(
|
|
|
375
398
|
const apiRoot = path.resolve(options.apiRoot || getSomaHostApiRoot(hostDir, options.env));
|
|
376
399
|
const outDir = path.resolve(options.outDir);
|
|
377
400
|
const aotServerDir = path.join(outDir, 'aot-server');
|
|
401
|
+
const sharedPackagesDir = path.join(aotServerDir, '_packages');
|
|
378
402
|
fs.mkdirSync(aotServerDir, { recursive: true });
|
|
403
|
+
fs.rmSync(sharedPackagesDir, { recursive: true, force: true });
|
|
379
404
|
|
|
380
405
|
const serviceFiles = scanServiceFiles(apiRoot, webRoot);
|
|
381
|
-
const
|
|
406
|
+
const serviceEntryPoints: Record<string, string> = {};
|
|
382
407
|
const routes: Record<string, string> = {};
|
|
383
408
|
|
|
384
409
|
for (const item of serviceFiles) {
|
|
385
410
|
const entryName = `services/${item.routeKey.replace(/\//g, '_')}`;
|
|
386
|
-
|
|
411
|
+
serviceEntryPoints[entryName] = item.filePath;
|
|
387
412
|
routes[item.routeKey] = `${entryName}.cjs`;
|
|
388
413
|
|
|
389
414
|
// 支持不同大小写路由键
|
|
@@ -402,85 +427,123 @@ export async function buildServerAot(
|
|
|
402
427
|
let hostAppCompiledPath: string | undefined;
|
|
403
428
|
const hostAppPath = path.resolve(webRoot, 'soma.app.ts');
|
|
404
429
|
if (fs.existsSync(hostAppPath)) {
|
|
405
|
-
entryPoints['host-app'] = hostAppPath;
|
|
406
430
|
hostAppCompiledPath = 'host-app.cjs';
|
|
407
431
|
}
|
|
408
432
|
|
|
409
|
-
|
|
433
|
+
const publicAliases = readAllSomaPublicAliases(hostDir, repoRoot, [webRoot, apiRoot, coreRoot], options.env) as Record<string, string>;
|
|
434
|
+
const publicFilter = createPublicAliasesFilter(publicAliases);
|
|
435
|
+
const sharedEntries = new Map<string, string>();
|
|
436
|
+
const nodePaths = [
|
|
437
|
+
path.join(apiRoot, 'node_modules'),
|
|
438
|
+
path.join(webRoot, 'node_modules'),
|
|
439
|
+
path.join(hostDir, 'node_modules'),
|
|
440
|
+
path.join(coreRoot, 'node_modules'),
|
|
441
|
+
].filter((d) => fs.existsSync(d));
|
|
442
|
+
|
|
443
|
+
const createServerAotPlugin = (mode: { sharedOutPrefix: string } | { inlinePublic: true }): Plugin => ({
|
|
444
|
+
name: 'soma-server-aot-plugin',
|
|
445
|
+
setup(build) {
|
|
446
|
+
build.onResolve({ filter: /^server-only$/ }, () => {
|
|
447
|
+
return { path: path.resolve(coreRoot, 'core/server/host/server-only-noop.cjs') };
|
|
448
|
+
});
|
|
449
|
+
build.onResolve({ filter: /^@core(?:\/.*)?$/ }, (args) => {
|
|
450
|
+
const subpath = args.path.replace(/^@core\/?/, '');
|
|
451
|
+
return { path: resolveModuleFile(path.resolve(coreRoot, 'core'), subpath) };
|
|
452
|
+
});
|
|
453
|
+
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-bootstrap$/ }, () => {
|
|
454
|
+
const candidateHostFile = path.resolve(webRoot, 'bootstrap/soma-bootstrap');
|
|
455
|
+
for (const ext of ['.ts', '.js', '.mjs']) {
|
|
456
|
+
if (fs.existsSync(candidateHostFile + ext)) {
|
|
457
|
+
return { path: candidateHostFile + ext };
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (fs.existsSync(path.resolve(webRoot, 'soma.app.ts'))) {
|
|
461
|
+
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-bootstrap-from-app.ts') };
|
|
462
|
+
}
|
|
463
|
+
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-bootstrap-host.stub.ts') };
|
|
464
|
+
});
|
|
465
|
+
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-domain-loaders$/ }, () => {
|
|
466
|
+
const candidateLoader = path.resolve(webRoot, 'bootstrap/soma-domain-loaders');
|
|
467
|
+
for (const ext of ['.ts', '.js', '.mjs']) {
|
|
468
|
+
if (fs.existsSync(candidateLoader + ext)) {
|
|
469
|
+
return { path: candidateLoader + ext };
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-domain-loaders.stub.ts') };
|
|
473
|
+
});
|
|
474
|
+
build.onResolve({ filter: /^@soma-host\/domain\/ui\/.*Class\.ts$/ }, (args) => {
|
|
475
|
+
const baseName = path.basename(args.path);
|
|
476
|
+
const diskFile = path.resolve(webRoot, 'domain/ui', baseName);
|
|
477
|
+
if (fs.existsSync(diskFile)) {
|
|
478
|
+
return { path: diskFile };
|
|
479
|
+
}
|
|
480
|
+
return { path: args.path, namespace: 'soma-absent-domain' };
|
|
481
|
+
});
|
|
482
|
+
build.onLoad({ filter: /.*/, namespace: 'soma-absent-domain' }, (args) => ({
|
|
483
|
+
contents: `const err = new Error("Cannot find module '${args.path}'"); err.code = "MODULE_NOT_FOUND"; throw err;`,
|
|
484
|
+
loader: 'js',
|
|
485
|
+
}));
|
|
486
|
+
build.onResolve({ filter: /^@soma-host(?:\/.*)?$/ }, (args) => {
|
|
487
|
+
const subpath = args.path.replace(/^@soma-host\/?/, '');
|
|
488
|
+
return { path: resolveModuleFile(webRoot, subpath) };
|
|
489
|
+
});
|
|
490
|
+
registerSourceRootResolve(build, hostDir, options.env);
|
|
491
|
+
build.onResolve({ filter: /^@soma-api(?:\/.*)?$/ }, (args) => {
|
|
492
|
+
const subpath = args.path.replace(/^@soma-api\/?/, '');
|
|
493
|
+
return { path: resolveModuleFile(apiRoot, subpath) };
|
|
494
|
+
});
|
|
495
|
+
if (publicFilter) {
|
|
496
|
+
build.onResolve({ filter: publicFilter }, (args) => {
|
|
497
|
+
const direct = publicAliases[args.path];
|
|
498
|
+
if (!direct || !fs.existsSync(direct)) {
|
|
499
|
+
return undefined;
|
|
500
|
+
}
|
|
501
|
+
if ('inlinePublic' in mode) {
|
|
502
|
+
return { path: direct };
|
|
503
|
+
}
|
|
504
|
+
const slug = sharedPackageSlug(args.path);
|
|
505
|
+
sharedEntries.set(slug, direct);
|
|
506
|
+
return { path: `${mode.sharedOutPrefix}_packages/${slug}.cjs`, external: true };
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
const baseServerBuildOptions: Omit<esbuild.BuildOptions, 'entryPoints' | 'outdir' | 'plugins'> = {
|
|
513
|
+
bundle: true,
|
|
514
|
+
platform: 'node',
|
|
515
|
+
format: 'cjs',
|
|
516
|
+
target: 'node20',
|
|
517
|
+
packages: 'external',
|
|
518
|
+
nodePaths,
|
|
519
|
+
outExtension: { '.js': '.cjs' },
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
if (Object.keys(serviceEntryPoints).length > 0) {
|
|
523
|
+
await esbuild.build({
|
|
524
|
+
...baseServerBuildOptions,
|
|
525
|
+
entryPoints: serviceEntryPoints,
|
|
526
|
+
outdir: aotServerDir,
|
|
527
|
+
plugins: [createServerAotPlugin({ sharedOutPrefix: '../' })],
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (hostAppCompiledPath) {
|
|
410
532
|
await esbuild.build({
|
|
411
|
-
|
|
533
|
+
...baseServerBuildOptions,
|
|
534
|
+
entryPoints: { 'host-app': hostAppPath },
|
|
412
535
|
outdir: aotServerDir,
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const publicAliases = readAllSomaPublicAliases(hostDir, repoRoot, [webRoot, apiRoot, coreRoot]) as Record<string, string>;
|
|
425
|
-
build.onResolve({ filter: /^server-only$/ }, () => {
|
|
426
|
-
return { path: path.resolve(coreRoot, 'core/server/host/server-only-noop.cjs') };
|
|
427
|
-
});
|
|
428
|
-
build.onResolve({ filter: /^@core(?:\/.*)?$/ }, (args) => {
|
|
429
|
-
const subpath = args.path.replace(/^@core\/?/, '');
|
|
430
|
-
return { path: resolveModuleFile(path.resolve(coreRoot, 'core'), subpath) };
|
|
431
|
-
});
|
|
432
|
-
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-bootstrap$/ }, () => {
|
|
433
|
-
const candidateHostFile = path.resolve(webRoot, 'bootstrap/soma-bootstrap');
|
|
434
|
-
for (const ext of ['.ts', '.js', '.mjs']) {
|
|
435
|
-
if (fs.existsSync(candidateHostFile + ext)) {
|
|
436
|
-
return { path: candidateHostFile + ext };
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
if (fs.existsSync(path.resolve(webRoot, 'soma.app.ts'))) {
|
|
440
|
-
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-bootstrap-from-app.ts') };
|
|
441
|
-
}
|
|
442
|
-
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-bootstrap-host.stub.ts') };
|
|
443
|
-
});
|
|
444
|
-
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-domain-loaders$/ }, () => {
|
|
445
|
-
const candidateLoader = path.resolve(webRoot, 'bootstrap/soma-domain-loaders');
|
|
446
|
-
for (const ext of ['.ts', '.js', '.mjs']) {
|
|
447
|
-
if (fs.existsSync(candidateLoader + ext)) {
|
|
448
|
-
return { path: candidateLoader + ext };
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
return { path: path.resolve(coreRoot, 'core/client/host-bridge/soma-domain-loaders.stub.ts') };
|
|
452
|
-
});
|
|
453
|
-
build.onResolve({ filter: /^@soma-host\/domain\/ui\/.*Class\.ts$/ }, (args) => {
|
|
454
|
-
const baseName = path.basename(args.path);
|
|
455
|
-
const diskFile = path.resolve(webRoot, 'domain/ui', baseName);
|
|
456
|
-
if (fs.existsSync(diskFile)) {
|
|
457
|
-
return { path: diskFile };
|
|
458
|
-
}
|
|
459
|
-
return { path: args.path, namespace: 'soma-absent-domain' };
|
|
460
|
-
});
|
|
461
|
-
build.onLoad({ filter: /.*/, namespace: 'soma-absent-domain' }, (args) => ({
|
|
462
|
-
contents: `const err = new Error("Cannot find module '${args.path}'"); err.code = "MODULE_NOT_FOUND"; throw err;`,
|
|
463
|
-
loader: 'js',
|
|
464
|
-
}));
|
|
465
|
-
build.onResolve({ filter: /^@soma-host(?:\/.*)?$/ }, (args) => {
|
|
466
|
-
const subpath = args.path.replace(/^@soma-host\/?/, '');
|
|
467
|
-
return { path: resolveModuleFile(webRoot, subpath) };
|
|
468
|
-
});
|
|
469
|
-
registerSourceRootResolve(build, hostDir, options.env);
|
|
470
|
-
build.onResolve({ filter: /^@soma-api(?:\/.*)?$/ }, (args) => {
|
|
471
|
-
const subpath = args.path.replace(/^@soma-api\/?/, '');
|
|
472
|
-
return { path: resolveModuleFile(apiRoot, subpath) };
|
|
473
|
-
});
|
|
474
|
-
build.onResolve({ filter: /^soma-[a-z0-9-]+(?:\/.*)?$/ }, (args) => {
|
|
475
|
-
const direct = publicAliases[args.path];
|
|
476
|
-
if (direct && fs.existsSync(direct)) {
|
|
477
|
-
return { path: direct };
|
|
478
|
-
}
|
|
479
|
-
return undefined;
|
|
480
|
-
});
|
|
481
|
-
},
|
|
482
|
-
},
|
|
483
|
-
],
|
|
536
|
+
plugins: [createServerAotPlugin({ sharedOutPrefix: './' })],
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (sharedEntries.size > 0) {
|
|
541
|
+
fs.mkdirSync(sharedPackagesDir, { recursive: true });
|
|
542
|
+
await esbuild.build({
|
|
543
|
+
...baseServerBuildOptions,
|
|
544
|
+
entryPoints: Object.fromEntries(sharedEntries),
|
|
545
|
+
outdir: sharedPackagesDir,
|
|
546
|
+
plugins: [createServerAotPlugin({ inlinePublic: true })],
|
|
484
547
|
});
|
|
485
548
|
}
|
|
486
549
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 开发态客户端分片回收(`soma dev`)。
|
|
6
|
+
*
|
|
7
|
+
* 背景:开发态 esbuild 以 `chunks/[name]-[hash]` 命名分片、带内联 sourcemap;每次启动 / 重建内容一变就写一份新的,
|
|
8
|
+
* 旧的从不清理,几个应用累计到数 GB。
|
|
9
|
+
*
|
|
10
|
+
* 做法(按进程登记,不按时间猜):
|
|
11
|
+
* 1. 每个 dev 进程在 `<clientOutDir>/.live/<pid>.json` 登记自己当前这次构建产出的全部文件(相对 clientOutDir 的路径)。
|
|
12
|
+
* 2. 每次构建 / 重建后回收:保留集 = 自己的登记 ∪ 仍存活的其他 dev 进程的登记(`process.kill(pid, 0)` 判活;
|
|
13
|
+
* 已退出进程的登记文件随即删除);`chunks/` 下不在保留集里的文件删除。
|
|
14
|
+
* 3. 进程正常退出(dispose)时删除自己的登记。异常退出留下的登记,在下一个进程回收时因判活失败被清掉。
|
|
15
|
+
* 同一应用目录并发启动:内容相同的分片同名(内容哈希),两边登记里都有,不会误删;内容不同时各自的登记互相保留。
|
|
16
|
+
* 只回收 `chunks/` 目录下的文件;入口 `browser-entry.js` 与 `globals.css` 在开发态是固定名,覆盖写,不涉及回收。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const LIVE_DIR = '.live';
|
|
20
|
+
const CHUNKS_DIR = 'chunks';
|
|
21
|
+
|
|
22
|
+
function isAlive(pid: number): boolean {
|
|
23
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
24
|
+
if (pid === process.pid) return true;
|
|
25
|
+
try {
|
|
26
|
+
process.kill(pid, 0);
|
|
27
|
+
return true;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// EPERM:进程存在但无权发信号 → 视为存活(保守,不删它的产物)
|
|
30
|
+
return (error as NodeJS.ErrnoException).code === 'EPERM';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function readLiveSet(file: string): readonly string[] {
|
|
35
|
+
try {
|
|
36
|
+
const parsed: unknown = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
37
|
+
return Array.isArray(parsed) ? parsed.filter((v): v is string => typeof v === 'string') : [];
|
|
38
|
+
} catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** esbuild metafile 的输出路径(相对 cwd 或绝对)→ 相对 clientOutDir 的 posix 路径 */
|
|
44
|
+
export function outputsRelativeTo(clientOutDir: string, outputs: readonly string[]): string[] {
|
|
45
|
+
const rel: string[] = [];
|
|
46
|
+
for (const out of outputs) {
|
|
47
|
+
const abs = path.resolve(out);
|
|
48
|
+
const r = path.relative(clientOutDir, abs);
|
|
49
|
+
if (r === '' || r.startsWith('..') || path.isAbsolute(r)) continue;
|
|
50
|
+
rel.push(r.split(path.sep).join('/'));
|
|
51
|
+
}
|
|
52
|
+
return rel;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 登记本进程的产物并回收不再被任何存活 dev 进程使用的分片。失败只吞掉(回收是尽力而为,不影响开发服务)。 */
|
|
56
|
+
export function collectDevChunks(clientOutDir: string, ownOutputs: readonly string[]): { readonly removed: number } {
|
|
57
|
+
let removed = 0;
|
|
58
|
+
try {
|
|
59
|
+
const liveDir = path.join(clientOutDir, LIVE_DIR);
|
|
60
|
+
fs.mkdirSync(liveDir, { recursive: true });
|
|
61
|
+
fs.writeFileSync(path.join(liveDir, `${process.pid}.json`), JSON.stringify(ownOutputs), 'utf8');
|
|
62
|
+
|
|
63
|
+
const keep = new Set<string>(ownOutputs);
|
|
64
|
+
for (const name of fs.readdirSync(liveDir)) {
|
|
65
|
+
if (!name.endsWith('.json')) continue;
|
|
66
|
+
const pid = Number(name.slice(0, -'.json'.length));
|
|
67
|
+
const file = path.join(liveDir, name);
|
|
68
|
+
if (pid === process.pid) continue;
|
|
69
|
+
if (!isAlive(pid)) {
|
|
70
|
+
fs.rmSync(file, { force: true });
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
for (const rel of readLiveSet(file)) keep.add(rel);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const chunksDir = path.join(clientOutDir, CHUNKS_DIR);
|
|
77
|
+
if (!fs.existsSync(chunksDir)) return { removed };
|
|
78
|
+
for (const name of fs.readdirSync(chunksDir)) {
|
|
79
|
+
const rel = `${CHUNKS_DIR}/${name}`;
|
|
80
|
+
if (keep.has(rel)) continue;
|
|
81
|
+
const abs = path.join(chunksDir, name);
|
|
82
|
+
try {
|
|
83
|
+
if (fs.statSync(abs).isFile()) {
|
|
84
|
+
fs.rmSync(abs, { force: true });
|
|
85
|
+
removed += 1;
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
// 另一进程刚好删掉了:忽略
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
// 尽力而为
|
|
93
|
+
}
|
|
94
|
+
return { removed };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** dispose 时删除本进程的登记(产物留给下一次启动按登记回收)。 */
|
|
98
|
+
export function releaseDevChunks(clientOutDir: string): void {
|
|
99
|
+
try {
|
|
100
|
+
fs.rmSync(path.join(clientOutDir, LIVE_DIR, `${process.pid}.json`), { force: true });
|
|
101
|
+
} catch {
|
|
102
|
+
// 尽力而为
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { assertReservedRoutesShape, loadHostAssembly, invalidateHostAssembly, registerShellRoutes as registerCoreShellRoutes } from 'soma-core/server/host-assembly';
|
|
4
|
-
import { clearPagePayloadBufferCache } from './page-
|
|
4
|
+
import { clearPagePayloadBufferCache } from './page-payload-cache';
|
|
5
5
|
import { precompileAll, precompilePage } from '../../core/build/compiler/full-manifest-builder';
|
|
6
6
|
import { addressOfPageBase } from '../../core/build/compiler/page-base-resolver';
|
|
7
7
|
import { loadPageMarkupConfig } from '../../core/server/host/page-markup-config';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadPrecompiledManifest, findPrecompiledPage } from '../../core/server/
|
|
1
|
+
import { loadPrecompiledManifest, findPrecompiledPage } from '../../core/server/host/precompiled-manifest';
|
|
2
2
|
import { listBindings } from '../../core/server/runtime-space';
|
|
3
3
|
import { resolveSomaRuntimeLayout } from '../../core/server/runtime-space/root';
|
|
4
4
|
import { SomaRuntimeStore } from '../../core/server/runtime-space/store';
|