soma-core 2.2.6 → 2.2.8
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/soma-precompile.js +66 -10
- package/core/client/container/IContainerAdapter.ts +4 -0
- package/core/client/container/SomaContainerAdapter.ts +43 -2
- package/core/client/data/data-object-resolver.ts +43 -8
- package/core/client/engine/event-engine.ts +28 -3
- package/core/client/engine/soma-bootstrap.ts +2 -1
- package/core/client/engines/chart/adapter-echarts.ts +75 -2
- package/core/client/engines/chart/index.ts +18 -0
- package/core/client/engines/chart/port.ts +13 -0
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
- package/core/client/parser/confirm-spec.ts +99 -6
- package/core/client/parser/data-config-parser.ts +1 -1
- package/core/client/parser/pipeline-parser.ts +2 -1
- package/core/client/render-ports/hide-transition.ts +9 -0
- package/core/client/render-ports/index.ts +4 -0
- package/core/client/render-ports/notify-renderer.ts +2 -1
- package/core/index.ts +16 -4
- package/core/server/api/load-host-service.ts +3 -0
- package/core/server/api/paged-list.ts +259 -0
- package/core/server/host/empty-host-bootstrap.mjs +3 -0
- package/core/server/host/host-assembly.ts +3 -0
- package/core/server/host/source-aliases.cjs +345 -0
- package/core/server/host/source-aliases.ts +32 -0
- package/core/server/host/source-packages.cjs +1 -0
- package/core/server/infra/cache/ServerFileCache.ts +4 -1
- package/core/server/node.ts +10 -0
- package/core/server/runtime-space/bindings.ts +47 -1
- package/core/server/runtime-space/digest.ts +6 -0
- package/core/server/runtime-space/index.ts +1 -1
- package/core/server/runtime-space/inject.ts +4 -1
- package/core/server/runtime-space/prewarm.ts +8 -8
- package/core/server/runtime-space/store.ts +8 -7
- package/core/server/runtime-space/types.ts +3 -2
- package/core/shared/core-diagnostic-codes.ts +6 -0
- package/core/shared/data-declaration-checks.ts +29 -3
- package/core/shared/registry-generated/diagnostic-registry-index.ts +5 -0
- package/core/shared/registry-generated/diagnostic-registry.ts +35 -0
- package/core/shared/registry-generated/limits.ts +18 -2
- package/core/shared/registry-generated/std-grammar.ts +1 -1
- package/core/shared/types/data-config.types.ts +3 -1
- package/core/shared/types/event.types.ts +9 -0
- package/dist/browser/soma-runtime.js +262 -23
- package/dist/core/index.cjs +283 -23
- package/dist/host-native/aot-builder.cjs +284 -0
- package/dist/host-native/native-server.cjs +395 -24
- package/dist/lsp/component-tree.cjs +66 -10
- package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
- package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
- package/dist/types/client/data/data-object-resolver.d.ts +2 -0
- package/dist/types/client/engines/chart/index.d.ts +1 -1
- package/dist/types/client/engines/chart/port.d.ts +15 -0
- package/dist/types/client/parser/confirm-spec.d.ts +27 -3
- package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
- package/dist/types/client/render-ports/index.d.ts +4 -0
- package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/server/api/paged-list.d.ts +101 -0
- package/dist/types/server/host/source-aliases.d.cts +53 -0
- package/dist/types/server/host/source-aliases.d.ts +30 -0
- package/dist/types/server/host/source-packages.d.cts +2 -0
- package/dist/types/server/node.d.ts +1 -0
- package/dist/types/server/runtime-space/bindings.d.ts +9 -0
- package/dist/types/server/runtime-space/digest.d.ts +5 -0
- package/dist/types/server/runtime-space/index.d.ts +1 -1
- package/dist/types/server/runtime-space/prewarm.d.ts +2 -2
- package/dist/types/server/runtime-space/types.d.ts +3 -2
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +30 -0
- package/dist/types/shared/registry-generated/limits.d.ts +14 -0
- package/dist/types/shared/registry-generated/std-grammar.d.ts +1 -1
- package/dist/types/shared/types/data-config.types.d.ts +3 -1
- package/dist/types/shared/types/event.types.d.ts +8 -0
- package/host-native/src/aot-builder.ts +23 -0
- package/host-native/src/host-prepare.ts +18 -1
- package/host-native/src/native-server.ts +16 -0
- package/host-native/styles/globals.css +30 -28
- package/package.json +13 -2
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
// 源码根别名的唯一实现(`package.json#soma.sourceRoots`;《core 标准格式与 runtime 空间》P12 同族)。
|
|
2
|
+
//
|
|
3
|
+
// 为什么是 .cjs:构建期(esbuild 插件、host-native 内核、vitest 配置)是 CommonJS / 纯 Node 环境,运行期(TS)经 `source-aliases.ts`
|
|
4
|
+
// 带类型再导出同一份,不再各写一份。「哪些顶层目录是别名」「哪些名字不许占」「与已装包冲突怎么办」只在这里判定。
|
|
5
|
+
//
|
|
6
|
+
// 契约:
|
|
7
|
+
// 声明(`package.json#soma.sourceRoots`,缺省 = 完全不生效、返回空)
|
|
8
|
+
// "auto" → 以 apiRoot(`soma.apiRoot`,缺省回落 webRoot / hostRoot)为源码根
|
|
9
|
+
// "<相对目录>" | string[] → 每项是一个源码根(相对宿主目录,必须落在宿主目录内且存在)
|
|
10
|
+
// { "<别名>": "<相对目录>" } → 显式「别名 → 目录」,目录同样必须落在宿主目录内且存在
|
|
11
|
+
// 源码根形态下,其「一级子目录」各成一个别名:`<dir>/...` 解析到 `<源码根>/<dir>/...`(同 tsconfig `baseUrl` / vite 别名语义)。
|
|
12
|
+
// 只认带斜杠的子路径说明符:裸 `domain`、`kit`、npm 包名、`node:` 内置一概不劫持;没有子路径的 `domain` 仍走原解析。
|
|
13
|
+
// 前缀必须整段匹配(别名 `kit` 不匹配 `kitchen/x`)。
|
|
14
|
+
//
|
|
15
|
+
// 优先级(确定性,与 talent_graph 旧补丁里的 jiti 别名一致):声明的别名先于 node_modules 里的同名包。
|
|
16
|
+
// 宿主 `node_modules/<别名>` 存在且不是指向别名目录的软链 → 诊断 CORE-HOST-ALIAS-SHADOW(warning,别名仍生效,此时该包的
|
|
17
|
+
// `<别名>/...` 子路径说明符在宿主代码里读不到);指向别名目录的软链(旧补丁遗留)视为同一目录、不报。
|
|
18
|
+
// 多个源码根里同名别名:先声明者胜,后者 CORE-HOST-ALIAS-DUPLICATE(warning)。
|
|
19
|
+
//
|
|
20
|
+
// 诊断(error 级由 `getSomaSourceRootAliases` 抛出,不静默降级):
|
|
21
|
+
// CORE-HOST-ALIAS-INVALID error 声明形状不对 / 路径越界或不存在 / 别名名字非法
|
|
22
|
+
// CORE-HOST-ALIAS-RESERVED error 别名占了保留名:`soma` / `soma-*`、`server-only`、`node_modules`、以及带子路径的 Node 内置(`fs`、`path` ...)
|
|
23
|
+
// CORE-HOST-ALIAS-SHADOW warning 见上
|
|
24
|
+
// CORE-HOST-ALIAS-DUPLICATE warning 见上
|
|
25
|
+
// CORE-HOST-ALIAS-TSCONFIG-DRIFT warning tsconfig.json 的 baseUrl 与(auto / 数组形态的)第一个源码根不一致
|
|
26
|
+
//
|
|
27
|
+
// 与 core 的纪律:这里不出现任何 Host / 方言 / 外壳的名字;路径只经 `path.join / path.resolve` 对 hostDir 拼接(G100)。
|
|
28
|
+
const fs = require("node:fs");
|
|
29
|
+
const path = require("node:path");
|
|
30
|
+
const nodeModule = require("node:module");
|
|
31
|
+
const { getSomaHostApiRoot, getSomaHostSourceRoot, resolveSafeChildRoot } = require("./source-packages.cjs");
|
|
32
|
+
|
|
33
|
+
const CODE_INVALID = "CORE-HOST-ALIAS-INVALID";
|
|
34
|
+
const CODE_RESERVED = "CORE-HOST-ALIAS-RESERVED";
|
|
35
|
+
const CODE_SHADOW = "CORE-HOST-ALIAS-SHADOW";
|
|
36
|
+
const CODE_DUPLICATE = "CORE-HOST-ALIAS-DUPLICATE";
|
|
37
|
+
const CODE_TSCONFIG_DRIFT = "CORE-HOST-ALIAS-TSCONFIG-DRIFT";
|
|
38
|
+
|
|
39
|
+
/** 合法别名:字母数字下划线开头,之后允许 `.` `-`;不含斜杠、`@`、`:`、空白 */
|
|
40
|
+
const ALIAS_NAME_RE = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
|
|
41
|
+
const RESERVED_NAMES = new Set(["server-only", "node_modules", "soma"]);
|
|
42
|
+
const BUILTIN_WITH_SUBPATH = new Set(
|
|
43
|
+
nodeModule.builtinModules.filter((m) => m.includes("/")).map((m) => m.slice(0, m.indexOf("/"))),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// number-source: limits#/cache/sourceRootAliasCapacity
|
|
47
|
+
const MAX_CACHE = 64;
|
|
48
|
+
/** @type {Map<string, object>} */
|
|
49
|
+
const resolveCache = new Map();
|
|
50
|
+
const warned = new Set();
|
|
51
|
+
|
|
52
|
+
function clearSomaSourceRootCache() {
|
|
53
|
+
resolveCache.clear();
|
|
54
|
+
warned.clear();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function readJson(filePath) {
|
|
58
|
+
try {
|
|
59
|
+
if (!fs.existsSync(filePath)) return null;
|
|
60
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** tsconfig 允许注释与尾逗号:字符串感知地去掉再解析;失败返回 null(漂移检查直接跳过) */
|
|
67
|
+
function readTsconfig(filePath) {
|
|
68
|
+
let raw;
|
|
69
|
+
try {
|
|
70
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const stripped = raw
|
|
75
|
+
.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_m, str) => str ?? "")
|
|
76
|
+
.replace(/,(\s*[}\]])/g, "$1");
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(stripped);
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function reservedReason(name) {
|
|
85
|
+
if (name === "soma" || name.startsWith("soma-")) return "与 soma 公开包名空间冲突";
|
|
86
|
+
if (RESERVED_NAMES.has(name)) return "是保留名";
|
|
87
|
+
if (BUILTIN_WITH_SUBPATH.has(name)) return `会劫持 Node 内置子路径(如 ${name}/...)`;
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 目录是否真实落在宿主目录内(跟随软链,防越界软链) */
|
|
92
|
+
function realInside(parent, child) {
|
|
93
|
+
try {
|
|
94
|
+
const p = fs.realpathSync(parent);
|
|
95
|
+
const c = fs.realpathSync(child);
|
|
96
|
+
return c === p || c.startsWith(`${p}${path.sep}`);
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 解析声明的源码根 → 别名表。纯函数式(只读文件系统),不抛、不打印;结果带诊断。
|
|
104
|
+
* @returns {{ declared: boolean, entries: Array<{ name: string, dir: string }>, aliases: Record<string, string>, diagnostics: Array<{ code: string, severity: "error" | "warning", message: string, name?: string }> }}
|
|
105
|
+
*/
|
|
106
|
+
function resolveSomaSourceRoots(hostDir, env = process.env) {
|
|
107
|
+
let normalizedHostDir = path.resolve(hostDir);
|
|
108
|
+
// 传进来的可能是应用根(package 里的子目录,如 <工程>/src/kit)而不是工程根:声明在最近的上级 package.json 里,
|
|
109
|
+
// 向上找到它再解析(别名表属于工程,不属于某个子目录);一路没有 package.json 就按原目录处理(= 未声明)。
|
|
110
|
+
if (!fs.existsSync(path.join(normalizedHostDir, "package.json"))) {
|
|
111
|
+
for (let dir = path.dirname(normalizedHostDir); ; dir = path.dirname(dir)) {
|
|
112
|
+
if (fs.existsSync(path.join(dir, "package.json"))) { normalizedHostDir = dir; break; }
|
|
113
|
+
if (path.dirname(dir) === dir) break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const packageJsonPath = path.join(normalizedHostDir, "package.json");
|
|
117
|
+
const stat = fs.statSync(packageJsonPath, { throwIfNoEntry: false });
|
|
118
|
+
const cacheKey = `${normalizedHostDir}\0${env?.SOMA_API_DIR ?? ""}\0${env?.SOMA_WEB_DIR ?? ""}\0${stat ? `${stat.mtimeMs}:${stat.size}` : "none"}`;
|
|
119
|
+
const cached = resolveCache.get(cacheKey);
|
|
120
|
+
if (cached) return cached;
|
|
121
|
+
|
|
122
|
+
const result = compute(normalizedHostDir, env, readJson(packageJsonPath));
|
|
123
|
+
if (resolveCache.size >= MAX_CACHE) resolveCache.delete(resolveCache.keys().next().value);
|
|
124
|
+
resolveCache.set(cacheKey, result);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function compute(hostDir, env, packageJson) {
|
|
129
|
+
const diagnostics = [];
|
|
130
|
+
const raw = packageJson?.soma?.sourceRoots;
|
|
131
|
+
const empty = { declared: false, entries: [], aliases: {}, diagnostics };
|
|
132
|
+
if (raw === undefined || raw === null) return empty;
|
|
133
|
+
|
|
134
|
+
const invalid = (message) => diagnostics.push({ code: CODE_INVALID, severity: "error", message: `soma.sourceRoots ${message}` });
|
|
135
|
+
|
|
136
|
+
/** 候选:{ name, dir, from } 按声明顺序 */
|
|
137
|
+
const candidates = [];
|
|
138
|
+
let firstRoot = null;
|
|
139
|
+
|
|
140
|
+
const addRoot = (rootDir) => {
|
|
141
|
+
if (firstRoot === null) firstRoot = rootDir;
|
|
142
|
+
let children;
|
|
143
|
+
try {
|
|
144
|
+
children = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
145
|
+
} catch {
|
|
146
|
+
invalid(`的源码根不可读:${rootDir}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (const entry of children.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
150
|
+
const full = path.join(rootDir, entry.name);
|
|
151
|
+
const isDir = entry.isDirectory() || (entry.isSymbolicLink() && fs.statSync(full, { throwIfNoEntry: false })?.isDirectory());
|
|
152
|
+
// 隐藏目录、node_modules 与不合法的名字在发现式声明里静默跳过(不是用户写进去的)
|
|
153
|
+
if (!isDir || entry.name.startsWith(".") || entry.name === "node_modules" || !ALIAS_NAME_RE.test(entry.name)) continue;
|
|
154
|
+
candidates.push({ name: entry.name, dir: full });
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const safeRoot = (rel) => {
|
|
159
|
+
if (typeof rel !== "string" || !rel.trim() || rel.includes("\0")) {
|
|
160
|
+
invalid("的路径必须是非空字符串");
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const resolved = path.resolve(hostDir, rel.trim());
|
|
164
|
+
const safe = resolveSafeChildRoot(hostDir, rel);
|
|
165
|
+
// resolveSafeChildRoot 对越界 / 不存在一律回落 parent;回落且并非本来就指向 parent → 拒绝
|
|
166
|
+
if (safe !== resolved || !fs.existsSync(safe) || !fs.statSync(safe).isDirectory() || !realInside(hostDir, safe)) {
|
|
167
|
+
invalid(`的路径 "${rel}" 必须是宿主目录内已存在的目录`);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return safe;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
if (raw === "auto") {
|
|
174
|
+
const apiRoot = getSomaHostApiRoot(hostDir, env);
|
|
175
|
+
addRoot(apiRoot);
|
|
176
|
+
} else if (typeof raw === "string" || Array.isArray(raw)) {
|
|
177
|
+
for (const rel of Array.isArray(raw) ? raw : [raw]) {
|
|
178
|
+
const root = safeRoot(rel);
|
|
179
|
+
if (root) addRoot(root);
|
|
180
|
+
}
|
|
181
|
+
} else if (typeof raw === "object") {
|
|
182
|
+
for (const [name, rel] of Object.entries(raw)) {
|
|
183
|
+
if (!ALIAS_NAME_RE.test(name)) {
|
|
184
|
+
diagnostics.push({ code: CODE_INVALID, severity: "error", name, message: `别名 "${name}" 不合法(只允许字母数字 _ . -,且不含斜杠)` });
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const dir = safeRoot(rel);
|
|
188
|
+
if (dir) candidates.push({ name, dir });
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
invalid('必须是 "auto"、目录字符串、字符串数组或「别名 → 目录」对象');
|
|
192
|
+
return { ...empty, declared: true };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const entries = [];
|
|
196
|
+
const taken = new Map();
|
|
197
|
+
for (const candidate of candidates) {
|
|
198
|
+
const reason = reservedReason(candidate.name);
|
|
199
|
+
if (reason) {
|
|
200
|
+
diagnostics.push({
|
|
201
|
+
code: CODE_RESERVED,
|
|
202
|
+
severity: "error",
|
|
203
|
+
name: candidate.name,
|
|
204
|
+
message: `源码根别名 "${candidate.name}" ${reason},请把该目录改名或移出源码根`,
|
|
205
|
+
});
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (taken.has(candidate.name)) {
|
|
209
|
+
diagnostics.push({
|
|
210
|
+
code: CODE_DUPLICATE,
|
|
211
|
+
severity: "warning",
|
|
212
|
+
name: candidate.name,
|
|
213
|
+
message: `源码根别名 "${candidate.name}" 同时出现在 ${taken.get(candidate.name)} 与 ${candidate.dir},先声明者生效`,
|
|
214
|
+
});
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
taken.set(candidate.name, candidate.dir);
|
|
218
|
+
entries.push(candidate);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (const { name, dir } of entries) {
|
|
222
|
+
const installed = path.join(hostDir, "node_modules", name);
|
|
223
|
+
const installedStat = fs.lstatSync(installed, { throwIfNoEntry: false });
|
|
224
|
+
if (!installedStat) continue;
|
|
225
|
+
let same = false;
|
|
226
|
+
try {
|
|
227
|
+
same = fs.realpathSync(installed) === fs.realpathSync(dir);
|
|
228
|
+
} catch {
|
|
229
|
+
same = false;
|
|
230
|
+
}
|
|
231
|
+
if (!same) {
|
|
232
|
+
diagnostics.push({
|
|
233
|
+
code: CODE_SHADOW,
|
|
234
|
+
severity: "warning",
|
|
235
|
+
name,
|
|
236
|
+
message: `源码根别名 "${name}" 遮蔽了已安装的包 node_modules/${name}:宿主代码里的 "${name}/..." 一律解析到 ${dir}(声明的别名优先于已装包)`,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (firstRoot !== null) {
|
|
242
|
+
const tsconfig = readTsconfig(path.join(hostDir, "tsconfig.json"));
|
|
243
|
+
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
|
244
|
+
if (typeof baseUrl === "string" && path.resolve(hostDir, baseUrl) !== path.resolve(firstRoot)) {
|
|
245
|
+
diagnostics.push({
|
|
246
|
+
code: CODE_TSCONFIG_DRIFT,
|
|
247
|
+
severity: "warning",
|
|
248
|
+
message: `tsconfig.json 的 baseUrl(${baseUrl})与 soma.sourceRoots 的源码根(${path.relative(hostDir, firstRoot) || "."})不一致:编辑器与运行期会解析到不同目录`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const aliases = {};
|
|
254
|
+
for (const { name, dir } of entries) aliases[name] = dir;
|
|
255
|
+
return { declared: true, entries, aliases, diagnostics };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function formatDiagnostic(d) {
|
|
259
|
+
return `[soma-core][${d.code}] ${d.message}`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 运行期 / 构建期取别名表的统一入口:error 级诊断抛出(带 `code`),warning 级每个宿主每条只打一次。
|
|
264
|
+
* 未声明 → `{}`。
|
|
265
|
+
* @returns {Record<string, string>} 别名 → 绝对目录(无尾斜杠)
|
|
266
|
+
*/
|
|
267
|
+
function getSomaSourceRootAliases(hostDir, env = process.env) {
|
|
268
|
+
const resolved = resolveSomaSourceRoots(hostDir, env);
|
|
269
|
+
const errors = resolved.diagnostics.filter((d) => d.severity === "error");
|
|
270
|
+
if (errors.length > 0) {
|
|
271
|
+
const error = new Error(errors.map(formatDiagnostic).join("\n"));
|
|
272
|
+
error.code = errors[0].code;
|
|
273
|
+
error.diagnostics = errors;
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
276
|
+
for (const d of resolved.diagnostics) {
|
|
277
|
+
const key = `${path.resolve(hostDir)}\0${d.code}\0${d.name ?? ""}\0${d.message}`;
|
|
278
|
+
if (warned.has(key)) continue;
|
|
279
|
+
warned.add(key);
|
|
280
|
+
// 日志前缀 `[包名][事件域]`(verify:logs):事件域取「引擎」,诊断码跟在后面
|
|
281
|
+
console.warn(`[soma-core][引擎] ${d.code} ${d.message}`);
|
|
282
|
+
}
|
|
283
|
+
return { ...resolved.aliases };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** 说明符 → `{ dir, subpath }`(只认带斜杠的整段前缀匹配);不匹配 → null。供 esbuild 等自己解析的构建器使用 */
|
|
287
|
+
function matchSomaSourceRoot(aliases, specifier) {
|
|
288
|
+
if (typeof specifier !== "string") return null;
|
|
289
|
+
const slash = specifier.indexOf("/");
|
|
290
|
+
if (slash <= 0) return null;
|
|
291
|
+
const name = specifier.slice(0, slash);
|
|
292
|
+
const dir = Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : undefined;
|
|
293
|
+
if (dir === undefined) return null;
|
|
294
|
+
return { name, dir, subpath: specifier.slice(slash + 1) };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** esbuild `onResolve` 的 filter:`^(?:a|b)/`;无别名 → null(调用方不注册钩子,零开销) */
|
|
298
|
+
function somaSourceRootFilter(aliases) {
|
|
299
|
+
const names = Object.keys(aliases);
|
|
300
|
+
if (names.length === 0) return null;
|
|
301
|
+
return new RegExp(`^(?:${names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})/`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** vitest / vite `resolve.alias` 数组:`[{ find: /^name\//, replacement: "<dir>/" }]`;未声明 → [] */
|
|
305
|
+
function somaViteAliases(hostDir, env = process.env) {
|
|
306
|
+
return Object.entries(getSomaSourceRootAliases(hostDir, env)).map(([name, dir]) => ({
|
|
307
|
+
find: new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`),
|
|
308
|
+
replacement: `${dir.split(path.sep).join("/")}/`,
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** core 可选宿主引导模块的说明符(与 core/client/host-bridge/resolve-host-bootstrap.ts 的 HOST_BOOTSTRAP_MODULE 同值) */
|
|
313
|
+
const HOST_BOOTSTRAP_SPECIFIER = "@soma-host/bootstrap/soma-bootstrap";
|
|
314
|
+
const HOST_BOOTSTRAP_CANDIDATES = ["soma-bootstrap.ts", "soma-bootstrap.js", "soma-bootstrap.mjs"];
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* vitest / vite 用的完整宿主别名:源码根别名(`somaViteAliases`)+ 可选宿主引导模块。
|
|
318
|
+
* core 对 `@soma-host/bootstrap/soma-bootstrap` 做可选动态 import:原生 Node 下缺失会被捕获(按「无宿主钩子」处理),
|
|
319
|
+
* 但 vite 在转换期就要解析该说明符,宿主没有这个文件时测试直接失败——以前每个应用自己写一个空垫片。
|
|
320
|
+
* 这里统一给出:宿主源码根下有该文件就指向它,没有就指向 core 自带的空模块(与运行期「无钩子」同形)。
|
|
321
|
+
*/
|
|
322
|
+
function somaViteHostAliases(hostDir, env = process.env) {
|
|
323
|
+
const sourceRoot = getSomaHostSourceRoot(path.resolve(hostDir), env);
|
|
324
|
+
const found = HOST_BOOTSTRAP_CANDIDATES.map((name) => path.join(sourceRoot, "bootstrap", name)).find((file) => fs.existsSync(file));
|
|
325
|
+
const target = found ?? path.join(__dirname, "empty-host-bootstrap.mjs");
|
|
326
|
+
return [
|
|
327
|
+
...somaViteAliases(hostDir, env),
|
|
328
|
+
{ find: new RegExp(`^${HOST_BOOTSTRAP_SPECIFIER}$`), replacement: target.split(path.sep).join("/") },
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
module.exports = {
|
|
333
|
+
somaViteHostAliases,
|
|
334
|
+
CODE_INVALID,
|
|
335
|
+
CODE_RESERVED,
|
|
336
|
+
CODE_SHADOW,
|
|
337
|
+
CODE_DUPLICATE,
|
|
338
|
+
CODE_TSCONFIG_DRIFT,
|
|
339
|
+
clearSomaSourceRootCache,
|
|
340
|
+
resolveSomaSourceRoots,
|
|
341
|
+
getSomaSourceRootAliases,
|
|
342
|
+
matchSomaSourceRoot,
|
|
343
|
+
somaSourceRootFilter,
|
|
344
|
+
somaViteAliases,
|
|
345
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as impl from "./source-aliases.cjs";
|
|
2
|
+
|
|
3
|
+
export interface SomaSourceRootDiagnostic {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly severity: "error" | "warning";
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SomaSourceRootResolution {
|
|
11
|
+
readonly declared: boolean;
|
|
12
|
+
readonly entries: ReadonlyArray<{ readonly name: string; readonly dir: string }>;
|
|
13
|
+
readonly aliases: Readonly<Record<string, string>>;
|
|
14
|
+
readonly diagnostics: readonly SomaSourceRootDiagnostic[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
18
|
+
|
|
19
|
+
/** 实现只有 `source-aliases.cjs` 一份(单实现);这里只补类型再导出,不另写第二份。 */
|
|
20
|
+
export const resolveSomaSourceRoots: (hostDir: string, env?: Env) => SomaSourceRootResolution =
|
|
21
|
+
impl.resolveSomaSourceRoots as never;
|
|
22
|
+
|
|
23
|
+
/** 别名 → 绝对目录;未声明 → `{}`;error 级诊断抛出(带 `code`) */
|
|
24
|
+
export const getSomaSourceRootAliases: (hostDir: string, env?: Env) => Record<string, string> =
|
|
25
|
+
impl.getSomaSourceRootAliases;
|
|
26
|
+
|
|
27
|
+
export const somaViteAliases: (hostDir: string, env?: Env) => Array<{ find: RegExp; replacement: string }> =
|
|
28
|
+
impl.somaViteAliases;
|
|
29
|
+
|
|
30
|
+
/** vitest / vite 的完整宿主别名:源码根别名 + 可选宿主引导模块(宿主没有该文件时指向 core 自带空模块) */
|
|
31
|
+
export const somaViteHostAliases: (hostDir: string, env?: Env) => Array<{ find: RegExp; replacement: string }> =
|
|
32
|
+
impl.somaViteHostAliases as never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, readdirSync, watch, type FSWatcher } from 'fs';
|
|
1
|
+
import { readFileSync, readdirSync, statSync, watch, type FSWatcher } from 'fs';
|
|
2
2
|
import { resolve, extname, normalize, sep } from 'path';
|
|
3
3
|
import { SOMA_PIPELINE_LIMITS } from '../../../shared/registry-generated/limits';
|
|
4
4
|
|
|
@@ -223,6 +223,9 @@ export class ServerFileCache {
|
|
|
223
223
|
if (this.isWatching(resolvedRoot) || this.unwatchableRoots.has(resolvedRoot)) return;
|
|
224
224
|
|
|
225
225
|
try {
|
|
226
|
+
// Node 24 / Linux 的递归监听对不存在的目录不再同步抛 ENOENT(静默成功却永不投递事件),
|
|
227
|
+
// 缓存会因此长期服务旧内容;先显式探测,使「根不存在」与旧行为一样走失败登记 + 绕过缓存。
|
|
228
|
+
statSync(resolvedRoot);
|
|
226
229
|
const watcher = watch(resolvedRoot, { recursive: true }, (_event, filename) => {
|
|
227
230
|
// 监听投递过变更回调,证明它在工作:此前的失败计数作废
|
|
228
231
|
this.watchFailures.delete(resolvedRoot);
|
package/core/server/node.ts
CHANGED
|
@@ -30,6 +30,16 @@ export {
|
|
|
30
30
|
type SomaSourcePageEntry,
|
|
31
31
|
} from "./host/source-packages";
|
|
32
32
|
|
|
33
|
+
// 源码根别名(`package.json#soma.sourceRoots`,单实现 source-aliases.cjs)
|
|
34
|
+
export {
|
|
35
|
+
getSomaSourceRootAliases,
|
|
36
|
+
resolveSomaSourceRoots,
|
|
37
|
+
somaViteAliases,
|
|
38
|
+
somaViteHostAliases,
|
|
39
|
+
type SomaSourceRootDiagnostic,
|
|
40
|
+
type SomaSourceRootResolution,
|
|
41
|
+
} from "./host/source-aliases";
|
|
42
|
+
|
|
33
43
|
// 页面资产与页面标记配置
|
|
34
44
|
export {
|
|
35
45
|
loadSomaServerPageAssets,
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
// 不管:载荷校验与摘要(inject.ts)、取页与编译(resolve.ts)。
|
|
9
9
|
|
|
10
10
|
import { currentHostDir } from '../host/host-dir';
|
|
11
|
+
import { readFlatEnvelope } from '../../build/compiler/flat-page';
|
|
12
|
+
import { SOMA_PAGE_FORMAT_VERSION } from '../../shared/page-envelope';
|
|
11
13
|
import {
|
|
12
14
|
addressKindOf,
|
|
13
15
|
addressShapeKey,
|
|
@@ -31,6 +33,9 @@ import type {
|
|
|
31
33
|
SomaStandardPageEnvelope,
|
|
32
34
|
} from './types';
|
|
33
35
|
|
|
36
|
+
/** 方言所有者给的版本守卫:`version` 是它随产物给出的不透明版本号;返回 false = 该产物不是本版产出方编的,不得恢复 */
|
|
37
|
+
export type OwnerVersionGuard = (version: string | undefined) => boolean;
|
|
38
|
+
|
|
34
39
|
/** 前缀解析器交回的东西:标准格式载荷,或兼容旧入口已经拼好的运行时资产(虚拟页的 `artifact` / 声明分支) */
|
|
35
40
|
export type PrefixPageResult =
|
|
36
41
|
| { readonly kind: 'page'; readonly page: SomaStandardPage; readonly title?: string }
|
|
@@ -74,6 +79,8 @@ interface SpaceState {
|
|
|
74
79
|
readonly stores: Map<string, SomaRuntimeStore>;
|
|
75
80
|
layoutMemo: { readonly signature: string; readonly layout: SomaRuntimeLayout } | null;
|
|
76
81
|
rootErrorReported: boolean;
|
|
82
|
+
/** owner → 版本守卫(方言所有者登记;core 不解释 version) */
|
|
83
|
+
readonly ownerGuards: Map<string, OwnerVersionGuard>;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
const SLOT = Symbol.for('soma-core.runtime-space');
|
|
@@ -91,6 +98,7 @@ export function space(): SpaceState {
|
|
|
91
98
|
stores: new Map(),
|
|
92
99
|
layoutMemo: null,
|
|
93
100
|
rootErrorReported: false,
|
|
101
|
+
ownerGuards: new Map(),
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -106,6 +114,29 @@ export function resetRuntimeSpace(): void {
|
|
|
106
114
|
state.stores.clear();
|
|
107
115
|
state.layoutMemo = null;
|
|
108
116
|
state.rootErrorReported = false;
|
|
117
|
+
state.ownerGuards.clear();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 方言所有者登记版本守卫(升级隐患闸):持久绑定恢复时,owner 相同的条目其 `version` 须被守卫接受,否则丢弃(连绑定文件),
|
|
122
|
+
* 页面由所有者按本版编译器重新注入。登记时已装入的同 owner 持久条目立刻对一遍。core 只存守卫、不解释 version(缓存键 = URL + version)。
|
|
123
|
+
*/
|
|
124
|
+
export function registerOwnerVersionGuard(owner: string, guard: OwnerVersionGuard): void {
|
|
125
|
+
const state = space();
|
|
126
|
+
state.ownerGuards.set(owner, guard);
|
|
127
|
+
let dropped = false;
|
|
128
|
+
for (const [key, entry] of state.entries) {
|
|
129
|
+
const binding = entry.binding;
|
|
130
|
+
if (binding.owner !== owner || !binding.persisted || binding.origin !== 'inject' || guard(binding.version)) continue;
|
|
131
|
+
state.entries.delete(key);
|
|
132
|
+
try {
|
|
133
|
+
runtimeStore().removeBinding(binding.address);
|
|
134
|
+
} catch {
|
|
135
|
+
/* 根不可用:没有落盘可清 */
|
|
136
|
+
}
|
|
137
|
+
dropped = true;
|
|
138
|
+
}
|
|
139
|
+
if (dropped) bumpNavGeneration();
|
|
109
140
|
}
|
|
110
141
|
|
|
111
142
|
// ── 布局与存储 ────────────────────────────────────────────────────────────────
|
|
@@ -186,11 +217,26 @@ export function ensureLoaded(): void {
|
|
|
186
217
|
console.warn(`[soma-core][引擎] 持久绑定 ${binding.address} 的产物缺失或损坏(${binding.digest.slice(0, 12)}…),已跳过;重新 inject 即可恢复。`);
|
|
187
218
|
continue;
|
|
188
219
|
}
|
|
220
|
+
// 恢复的信封与注入口同一读法:载荷 `envelope` 优先,其次 `_ui.yaml` 顶层 `envelope:`
|
|
221
|
+
const envelope = page.envelope ?? (readFlatEnvelope(page.uiYaml) as SomaStandardPageEnvelope | null);
|
|
222
|
+
// 标准格式版本不符的旧产物不恢复:丢弃并清掉绑定文件,由方言所有者重新编译注入(信封可缺:原生页信封是可选的,
|
|
223
|
+
// 缺信封的方言旧产物由落盘格式版本与产出方版本守卫拦下)
|
|
224
|
+
if (page.format !== SOMA_PAGE_FORMAT_VERSION) {
|
|
225
|
+
store.removeBinding(binding.address);
|
|
226
|
+
console.warn(`[soma-core][引擎] 持久绑定 ${binding.address} 的产物标准格式版本不符,已丢弃;由产出方重新编译注入。`);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
// 产出方版本指纹闸(见 registerOwnerVersionGuard):已登记守卫且不认这个 version → 丢弃
|
|
230
|
+
const guard = binding.owner === undefined ? undefined : state.ownerGuards.get(binding.owner);
|
|
231
|
+
if (guard !== undefined && !guard(binding.version)) {
|
|
232
|
+
store.removeBinding(binding.address);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
189
235
|
state.generations.set(key, Math.max(state.generations.get(key) ?? 0, binding.generation));
|
|
190
236
|
state.entries.set(key, {
|
|
191
237
|
binding: { ...binding, persisted: true },
|
|
192
238
|
page,
|
|
193
|
-
envelope
|
|
239
|
+
envelope,
|
|
194
240
|
prefix: null,
|
|
195
241
|
registryName: null,
|
|
196
242
|
mtimeMs: read.mtimeMs,
|
|
@@ -4,6 +4,12 @@ import { createHash } from 'node:crypto';
|
|
|
4
4
|
import { addressShapeKey } from '../../shared/runtime-address';
|
|
5
5
|
import type { SomaStandardPage } from './types';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* core 落盘产物的格式版本(绑定记录、预热索引与旁档、预热元数据共用)。落盘结构(信封、闸门等)有不兼容变化时递增;
|
|
9
|
+
* 读回时版本不符一律视为无效并丢弃,由方言所有者重新编译注入,不做迁移也不手工清目录。
|
|
10
|
+
*/
|
|
11
|
+
export const SOMA_RUNTIME_STORE_FORMAT = 2;
|
|
12
|
+
|
|
7
13
|
/** 摘要形状:64 位小写十六进制 */
|
|
8
14
|
export const SOMA_RUNTIME_DIGEST_PATTERN = /^[0-9a-f]{64}$/;
|
|
9
15
|
|
|
@@ -31,7 +31,7 @@ export {
|
|
|
31
31
|
} from './dynamic-pages';
|
|
32
32
|
export { resolveAddress, loadPageByAddress, listBindings, runtimeSpaceStats, type SomaLoadedPage, type SomaLoadPageOptions } from './resolve';
|
|
33
33
|
export { SomaRuntimeError, type SomaRuntimeBatchFailure, type SomaRuntimeErrorCode } from './errors';
|
|
34
|
-
export { setNavProvider, type NavProvider } from './bindings';
|
|
34
|
+
export { setNavProvider, registerOwnerVersionGuard, type NavProvider, type OwnerVersionGuard } from './bindings';
|
|
35
35
|
export {
|
|
36
36
|
registerPage,
|
|
37
37
|
registerPages,
|
|
@@ -15,6 +15,7 @@ import { looksLikeBlockDeclaration } from '../../shared/declaration-keys';
|
|
|
15
15
|
import { domainStaticOnlyHint } from '../../client/mount/domain-rule';
|
|
16
16
|
import { parseAddress, validateAddressText } from '../../shared/runtime-address';
|
|
17
17
|
import { SOMA_PAGE_FORMAT_VERSION } from '../../shared/page-envelope';
|
|
18
|
+
import { SOMA_PIPELINE_LIMITS } from '../../shared/registry-generated/limits';
|
|
18
19
|
import { bindingStorageKey, computeStandardPageDigest } from './digest';
|
|
19
20
|
import { evictArtifactsOfUrl } from './artifact-evict';
|
|
20
21
|
import { assertNavCapacity } from './nav-catalog';
|
|
@@ -390,8 +391,10 @@ export function injectMany(entries: readonly SomaInjectManyEntry[], options: Som
|
|
|
390
391
|
});
|
|
391
392
|
if (failures.length > 0 && atomic) {
|
|
392
393
|
restoreSpace(snapshot);
|
|
394
|
+
const maxChars = SOMA_PIPELINE_LIMITS.inject.batchFailureMessageMaxChars;
|
|
393
395
|
throw runtimeError('CORE-RUNTIME-BATCH', `批量注入 ${entries.length} 页`,
|
|
394
|
-
|
|
396
|
+
// 每条失败带上原因摘要(截断),否则只见错误码、无从定位是哪个键 / 哪条绑定越界
|
|
397
|
+
`${failures.length} 条失败,整批未生效:${failures.map((item) => `#${item.index} ${item.address} ${item.code}(${item.message.length > maxChars ? `${item.message.slice(0, maxChars)}…` : item.message})`).join(';')}`,
|
|
395
398
|
'逐条修复后整批重试', { failures });
|
|
396
399
|
}
|
|
397
400
|
const attempted: string[] = [];
|
|
@@ -15,7 +15,7 @@ import { createHash } from 'node:crypto';
|
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import { writeFileAtomic } from '../registry/registry-file-lock';
|
|
18
|
-
import { bindingFileName, canonicalJson } from './digest';
|
|
18
|
+
import { bindingFileName, canonicalJson, SOMA_RUNTIME_STORE_FORMAT } from './digest';
|
|
19
19
|
import { resolveSomaRuntimeLayout } from './root';
|
|
20
20
|
import { SomaRuntimeStore } from './store';
|
|
21
21
|
import type { SomaRuntimeLayout, SomaStandardPage } from './types';
|
|
@@ -25,7 +25,7 @@ export const SOMA_PREWARM_META_FILE = 'meta.json';
|
|
|
25
25
|
|
|
26
26
|
/** 旁档:一个静态页的构建期编译结果 */
|
|
27
27
|
export interface SomaPrewarmCompiledRecord<T = unknown> {
|
|
28
|
-
readonly schemaVersion:
|
|
28
|
+
readonly schemaVersion: number;
|
|
29
29
|
readonly address: string;
|
|
30
30
|
/** 对应标准格式产物的摘要;与索引不一致即视为失效 */
|
|
31
31
|
readonly digest: string;
|
|
@@ -36,7 +36,7 @@ export interface SomaPrewarmCompiledRecord<T = unknown> {
|
|
|
36
36
|
|
|
37
37
|
/** 全局元数据(路由表、词表、应用配置):不属于某一页 */
|
|
38
38
|
export interface SomaPrewarmMeta<M = unknown> {
|
|
39
|
-
readonly schemaVersion:
|
|
39
|
+
readonly schemaVersion: number;
|
|
40
40
|
readonly meta: M;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -105,7 +105,7 @@ function writeIfChanged(file: string, content: string): void {
|
|
|
105
105
|
function readCompiledRecord<T>(file: string): SomaPrewarmCompiledRecord<T> | null {
|
|
106
106
|
try {
|
|
107
107
|
const record = JSON.parse(fs.readFileSync(file, 'utf8')) as SomaPrewarmCompiledRecord<T>;
|
|
108
|
-
return record.schemaVersion ===
|
|
108
|
+
return record.schemaVersion === SOMA_RUNTIME_STORE_FORMAT && typeof record.digest === 'string' ? record : null;
|
|
109
109
|
} catch {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
@@ -150,7 +150,7 @@ export async function runPrewarm<T = unknown, M = unknown>(options: SomaPrewarmO
|
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
152
|
const record: SomaPrewarmCompiledRecord<T> = {
|
|
153
|
-
schemaVersion:
|
|
153
|
+
schemaVersion: SOMA_RUNTIME_STORE_FORMAT,
|
|
154
154
|
address: item.address,
|
|
155
155
|
digest,
|
|
156
156
|
inputsDigest: item.inputsDigest,
|
|
@@ -174,7 +174,7 @@ export async function runPrewarm<T = unknown, M = unknown>(options: SomaPrewarmO
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
if (options.meta !== undefined) {
|
|
177
|
-
const record: SomaPrewarmMeta<M> = { schemaVersion:
|
|
177
|
+
const record: SomaPrewarmMeta<M> = { schemaVersion: SOMA_RUNTIME_STORE_FORMAT, meta: options.meta };
|
|
178
178
|
writeIfChanged(path.join(layout.dirs.prewarm, SOMA_PREWARM_META_FILE), `${JSON.stringify(record)}\n`);
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -194,7 +194,7 @@ export async function runPrewarm<T = unknown, M = unknown>(options: SomaPrewarmO
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
const sorted = Object.fromEntries(Object.entries(entries).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
197
|
-
const indexText = `${JSON.stringify({ schemaVersion:
|
|
197
|
+
const indexText = `${JSON.stringify({ schemaVersion: SOMA_RUNTIME_STORE_FORMAT, entries: sorted }, null, 2)}\n`;
|
|
198
198
|
writeIfChanged(path.join(layout.dirs.prewarm, 'index.json'), indexText);
|
|
199
199
|
|
|
200
200
|
return {
|
|
@@ -226,7 +226,7 @@ export function readPrewarmCompiled<T = unknown, M = unknown>(
|
|
|
226
226
|
let meta: M | null = null;
|
|
227
227
|
try {
|
|
228
228
|
const parsed = JSON.parse(fs.readFileSync(path.join(layout.dirs.prewarm, SOMA_PREWARM_META_FILE), 'utf8')) as SomaPrewarmMeta<M>;
|
|
229
|
-
if (parsed.schemaVersion ===
|
|
229
|
+
if (parsed.schemaVersion === SOMA_RUNTIME_STORE_FORMAT) meta = parsed.meta;
|
|
230
230
|
} catch {
|
|
231
231
|
/* 缺失:meta 为空 */
|
|
232
232
|
}
|