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.
Files changed (77) hide show
  1. package/core/build/compiler/soma-precompile.js +66 -10
  2. package/core/client/container/IContainerAdapter.ts +4 -0
  3. package/core/client/container/SomaContainerAdapter.ts +43 -2
  4. package/core/client/data/data-object-resolver.ts +43 -8
  5. package/core/client/engine/event-engine.ts +28 -3
  6. package/core/client/engine/soma-bootstrap.ts +2 -1
  7. package/core/client/engines/chart/adapter-echarts.ts +75 -2
  8. package/core/client/engines/chart/index.ts +18 -0
  9. package/core/client/engines/chart/port.ts +13 -0
  10. package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
  11. package/core/client/parser/confirm-spec.ts +99 -6
  12. package/core/client/parser/data-config-parser.ts +1 -1
  13. package/core/client/parser/pipeline-parser.ts +2 -1
  14. package/core/client/render-ports/hide-transition.ts +9 -0
  15. package/core/client/render-ports/index.ts +4 -0
  16. package/core/client/render-ports/notify-renderer.ts +2 -1
  17. package/core/index.ts +16 -4
  18. package/core/server/api/load-host-service.ts +3 -0
  19. package/core/server/api/paged-list.ts +259 -0
  20. package/core/server/host/empty-host-bootstrap.mjs +3 -0
  21. package/core/server/host/host-assembly.ts +3 -0
  22. package/core/server/host/source-aliases.cjs +345 -0
  23. package/core/server/host/source-aliases.ts +32 -0
  24. package/core/server/host/source-packages.cjs +1 -0
  25. package/core/server/infra/cache/ServerFileCache.ts +4 -1
  26. package/core/server/node.ts +10 -0
  27. package/core/server/runtime-space/bindings.ts +47 -1
  28. package/core/server/runtime-space/digest.ts +6 -0
  29. package/core/server/runtime-space/index.ts +1 -1
  30. package/core/server/runtime-space/inject.ts +4 -1
  31. package/core/server/runtime-space/prewarm.ts +8 -8
  32. package/core/server/runtime-space/store.ts +8 -7
  33. package/core/server/runtime-space/types.ts +3 -2
  34. package/core/shared/core-diagnostic-codes.ts +6 -0
  35. package/core/shared/data-declaration-checks.ts +29 -3
  36. package/core/shared/registry-generated/diagnostic-registry-index.ts +5 -0
  37. package/core/shared/registry-generated/diagnostic-registry.ts +35 -0
  38. package/core/shared/registry-generated/limits.ts +18 -2
  39. package/core/shared/registry-generated/std-grammar.ts +1 -1
  40. package/core/shared/types/data-config.types.ts +3 -1
  41. package/core/shared/types/event.types.ts +9 -0
  42. package/dist/browser/soma-runtime.js +262 -23
  43. package/dist/core/index.cjs +283 -23
  44. package/dist/host-native/aot-builder.cjs +284 -0
  45. package/dist/host-native/native-server.cjs +395 -24
  46. package/dist/lsp/component-tree.cjs +66 -10
  47. package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
  48. package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
  49. package/dist/types/client/data/data-object-resolver.d.ts +2 -0
  50. package/dist/types/client/engines/chart/index.d.ts +1 -1
  51. package/dist/types/client/engines/chart/port.d.ts +15 -0
  52. package/dist/types/client/parser/confirm-spec.d.ts +27 -3
  53. package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
  54. package/dist/types/client/render-ports/index.d.ts +4 -0
  55. package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
  56. package/dist/types/index.d.ts +4 -4
  57. package/dist/types/server/api/paged-list.d.ts +101 -0
  58. package/dist/types/server/host/source-aliases.d.cts +53 -0
  59. package/dist/types/server/host/source-aliases.d.ts +30 -0
  60. package/dist/types/server/host/source-packages.d.cts +2 -0
  61. package/dist/types/server/node.d.ts +1 -0
  62. package/dist/types/server/runtime-space/bindings.d.ts +9 -0
  63. package/dist/types/server/runtime-space/digest.d.ts +5 -0
  64. package/dist/types/server/runtime-space/index.d.ts +1 -1
  65. package/dist/types/server/runtime-space/prewarm.d.ts +2 -2
  66. package/dist/types/server/runtime-space/types.d.ts +3 -2
  67. package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
  68. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +30 -0
  69. package/dist/types/shared/registry-generated/limits.d.ts +14 -0
  70. package/dist/types/shared/registry-generated/std-grammar.d.ts +1 -1
  71. package/dist/types/shared/types/data-config.types.d.ts +3 -1
  72. package/dist/types/shared/types/event.types.d.ts +8 -0
  73. package/host-native/src/aot-builder.ts +23 -0
  74. package/host-native/src/host-prepare.ts +18 -1
  75. package/host-native/src/native-server.ts +16 -0
  76. package/host-native/styles/globals.css +30 -28
  77. package/package.json +13 -2
@@ -311,6 +311,7 @@ var require_source_packages = __commonJS({
311
311
  SOMA_SOURCE_PACKAGES_ENV,
312
312
  getSomaHostSourceRoot: getSomaHostSourceRoot4,
313
313
  getSomaHostApiRoot: getSomaHostApiRoot4,
314
+ resolveSafeChildRoot: resolveSafeChildRoot2,
314
315
  clearSomaAssetSourcesCache: clearSomaAssetSourcesCache2,
315
316
  getSomaAssetSources: getSomaAssetSources3,
316
317
  listSomaSourcePackageNames: listSomaSourcePackageNames2,
@@ -441,6 +442,274 @@ var require_root = __commonJS({
441
442
  }
442
443
  });
443
444
 
445
+ // core/server/host/source-aliases.cjs
446
+ var require_source_aliases = __commonJS({
447
+ "core/server/host/source-aliases.cjs"(exports2, module2) {
448
+ "use strict";
449
+ var fs16 = require("node:fs");
450
+ var path18 = require("node:path");
451
+ var nodeModule2 = require("node:module");
452
+ var { getSomaHostApiRoot: getSomaHostApiRoot4, getSomaHostSourceRoot: getSomaHostSourceRoot4, resolveSafeChildRoot: resolveSafeChildRoot2 } = require_source_packages();
453
+ var CODE_INVALID = "CORE-HOST-ALIAS-INVALID";
454
+ var CODE_RESERVED = "CORE-HOST-ALIAS-RESERVED";
455
+ var CODE_SHADOW = "CORE-HOST-ALIAS-SHADOW";
456
+ var CODE_DUPLICATE = "CORE-HOST-ALIAS-DUPLICATE";
457
+ var CODE_TSCONFIG_DRIFT = "CORE-HOST-ALIAS-TSCONFIG-DRIFT";
458
+ var ALIAS_NAME_RE = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
459
+ var RESERVED_NAMES = /* @__PURE__ */ new Set(["server-only", "node_modules", "soma"]);
460
+ var BUILTIN_WITH_SUBPATH = new Set(
461
+ nodeModule2.builtinModules.filter((m) => m.includes("/")).map((m) => m.slice(0, m.indexOf("/")))
462
+ );
463
+ var MAX_CACHE = 64;
464
+ var resolveCache = /* @__PURE__ */ new Map();
465
+ var warned = /* @__PURE__ */ new Set();
466
+ function clearSomaSourceRootCache() {
467
+ resolveCache.clear();
468
+ warned.clear();
469
+ }
470
+ function readJson2(filePath) {
471
+ try {
472
+ if (!fs16.existsSync(filePath)) return null;
473
+ return JSON.parse(fs16.readFileSync(filePath, "utf8"));
474
+ } catch {
475
+ return null;
476
+ }
477
+ }
478
+ function readTsconfig(filePath) {
479
+ let raw;
480
+ try {
481
+ raw = fs16.readFileSync(filePath, "utf8");
482
+ } catch {
483
+ return null;
484
+ }
485
+ const stripped = raw.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_m, str) => str ?? "").replace(/,(\s*[}\]])/g, "$1");
486
+ try {
487
+ return JSON.parse(stripped);
488
+ } catch {
489
+ return null;
490
+ }
491
+ }
492
+ function reservedReason(name) {
493
+ if (name === "soma" || name.startsWith("soma-")) return "\u4E0E soma \u516C\u5F00\u5305\u540D\u7A7A\u95F4\u51B2\u7A81";
494
+ if (RESERVED_NAMES.has(name)) return "\u662F\u4FDD\u7559\u540D";
495
+ if (BUILTIN_WITH_SUBPATH.has(name)) return `\u4F1A\u52AB\u6301 Node \u5185\u7F6E\u5B50\u8DEF\u5F84\uFF08\u5982 ${name}/...\uFF09`;
496
+ return null;
497
+ }
498
+ function realInside(parent, child) {
499
+ try {
500
+ const p = fs16.realpathSync(parent);
501
+ const c = fs16.realpathSync(child);
502
+ return c === p || c.startsWith(`${p}${path18.sep}`);
503
+ } catch {
504
+ return false;
505
+ }
506
+ }
507
+ function resolveSomaSourceRoots2(hostDir, env = process.env) {
508
+ let normalizedHostDir = path18.resolve(hostDir);
509
+ if (!fs16.existsSync(path18.join(normalizedHostDir, "package.json"))) {
510
+ for (let dir = path18.dirname(normalizedHostDir); ; dir = path18.dirname(dir)) {
511
+ if (fs16.existsSync(path18.join(dir, "package.json"))) {
512
+ normalizedHostDir = dir;
513
+ break;
514
+ }
515
+ if (path18.dirname(dir) === dir) break;
516
+ }
517
+ }
518
+ const packageJsonPath = path18.join(normalizedHostDir, "package.json");
519
+ const stat = fs16.statSync(packageJsonPath, { throwIfNoEntry: false });
520
+ const cacheKey = `${normalizedHostDir}\0${env?.SOMA_API_DIR ?? ""}\0${env?.SOMA_WEB_DIR ?? ""}\0${stat ? `${stat.mtimeMs}:${stat.size}` : "none"}`;
521
+ const cached = resolveCache.get(cacheKey);
522
+ if (cached) return cached;
523
+ const result = compute(normalizedHostDir, env, readJson2(packageJsonPath));
524
+ if (resolveCache.size >= MAX_CACHE) resolveCache.delete(resolveCache.keys().next().value);
525
+ resolveCache.set(cacheKey, result);
526
+ return result;
527
+ }
528
+ function compute(hostDir, env, packageJson) {
529
+ const diagnostics = [];
530
+ const raw = packageJson?.soma?.sourceRoots;
531
+ const empty = { declared: false, entries: [], aliases: {}, diagnostics };
532
+ if (raw === void 0 || raw === null) return empty;
533
+ const invalid2 = (message4) => diagnostics.push({ code: CODE_INVALID, severity: "error", message: `soma.sourceRoots ${message4}` });
534
+ const candidates = [];
535
+ let firstRoot = null;
536
+ const addRoot = (rootDir) => {
537
+ if (firstRoot === null) firstRoot = rootDir;
538
+ let children;
539
+ try {
540
+ children = fs16.readdirSync(rootDir, { withFileTypes: true });
541
+ } catch {
542
+ invalid2(`\u7684\u6E90\u7801\u6839\u4E0D\u53EF\u8BFB\uFF1A${rootDir}`);
543
+ return;
544
+ }
545
+ for (const entry of children.sort((a, b) => a.name.localeCompare(b.name))) {
546
+ const full = path18.join(rootDir, entry.name);
547
+ const isDir = entry.isDirectory() || entry.isSymbolicLink() && fs16.statSync(full, { throwIfNoEntry: false })?.isDirectory();
548
+ if (!isDir || entry.name.startsWith(".") || entry.name === "node_modules" || !ALIAS_NAME_RE.test(entry.name)) continue;
549
+ candidates.push({ name: entry.name, dir: full });
550
+ }
551
+ };
552
+ const safeRoot = (rel) => {
553
+ if (typeof rel !== "string" || !rel.trim() || rel.includes("\0")) {
554
+ invalid2("\u7684\u8DEF\u5F84\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");
555
+ return null;
556
+ }
557
+ const resolved = path18.resolve(hostDir, rel.trim());
558
+ const safe = resolveSafeChildRoot2(hostDir, rel);
559
+ if (safe !== resolved || !fs16.existsSync(safe) || !fs16.statSync(safe).isDirectory() || !realInside(hostDir, safe)) {
560
+ invalid2(`\u7684\u8DEF\u5F84 "${rel}" \u5FC5\u987B\u662F\u5BBF\u4E3B\u76EE\u5F55\u5185\u5DF2\u5B58\u5728\u7684\u76EE\u5F55`);
561
+ return null;
562
+ }
563
+ return safe;
564
+ };
565
+ if (raw === "auto") {
566
+ const apiRoot = getSomaHostApiRoot4(hostDir, env);
567
+ addRoot(apiRoot);
568
+ } else if (typeof raw === "string" || Array.isArray(raw)) {
569
+ for (const rel of Array.isArray(raw) ? raw : [raw]) {
570
+ const root = safeRoot(rel);
571
+ if (root) addRoot(root);
572
+ }
573
+ } else if (typeof raw === "object") {
574
+ for (const [name, rel] of Object.entries(raw)) {
575
+ if (!ALIAS_NAME_RE.test(name)) {
576
+ diagnostics.push({ code: CODE_INVALID, severity: "error", name, message: `\u522B\u540D "${name}" \u4E0D\u5408\u6CD5\uFF08\u53EA\u5141\u8BB8\u5B57\u6BCD\u6570\u5B57 _ . -\uFF0C\u4E14\u4E0D\u542B\u659C\u6760\uFF09` });
577
+ continue;
578
+ }
579
+ const dir = safeRoot(rel);
580
+ if (dir) candidates.push({ name, dir });
581
+ }
582
+ } else {
583
+ invalid2('\u5FC5\u987B\u662F "auto"\u3001\u76EE\u5F55\u5B57\u7B26\u4E32\u3001\u5B57\u7B26\u4E32\u6570\u7EC4\u6216\u300C\u522B\u540D \u2192 \u76EE\u5F55\u300D\u5BF9\u8C61');
584
+ return { ...empty, declared: true };
585
+ }
586
+ const entries = [];
587
+ const taken = /* @__PURE__ */ new Map();
588
+ for (const candidate of candidates) {
589
+ const reason = reservedReason(candidate.name);
590
+ if (reason) {
591
+ diagnostics.push({
592
+ code: CODE_RESERVED,
593
+ severity: "error",
594
+ name: candidate.name,
595
+ message: `\u6E90\u7801\u6839\u522B\u540D "${candidate.name}" ${reason}\uFF0C\u8BF7\u628A\u8BE5\u76EE\u5F55\u6539\u540D\u6216\u79FB\u51FA\u6E90\u7801\u6839`
596
+ });
597
+ continue;
598
+ }
599
+ if (taken.has(candidate.name)) {
600
+ diagnostics.push({
601
+ code: CODE_DUPLICATE,
602
+ severity: "warning",
603
+ name: candidate.name,
604
+ message: `\u6E90\u7801\u6839\u522B\u540D "${candidate.name}" \u540C\u65F6\u51FA\u73B0\u5728 ${taken.get(candidate.name)} \u4E0E ${candidate.dir}\uFF0C\u5148\u58F0\u660E\u8005\u751F\u6548`
605
+ });
606
+ continue;
607
+ }
608
+ taken.set(candidate.name, candidate.dir);
609
+ entries.push(candidate);
610
+ }
611
+ for (const { name, dir } of entries) {
612
+ const installed = path18.join(hostDir, "node_modules", name);
613
+ const installedStat = fs16.lstatSync(installed, { throwIfNoEntry: false });
614
+ if (!installedStat) continue;
615
+ let same2 = false;
616
+ try {
617
+ same2 = fs16.realpathSync(installed) === fs16.realpathSync(dir);
618
+ } catch {
619
+ same2 = false;
620
+ }
621
+ if (!same2) {
622
+ diagnostics.push({
623
+ code: CODE_SHADOW,
624
+ severity: "warning",
625
+ name,
626
+ message: `\u6E90\u7801\u6839\u522B\u540D "${name}" \u906E\u853D\u4E86\u5DF2\u5B89\u88C5\u7684\u5305 node_modules/${name}\uFF1A\u5BBF\u4E3B\u4EE3\u7801\u91CC\u7684 "${name}/..." \u4E00\u5F8B\u89E3\u6790\u5230 ${dir}\uFF08\u58F0\u660E\u7684\u522B\u540D\u4F18\u5148\u4E8E\u5DF2\u88C5\u5305\uFF09`
627
+ });
628
+ }
629
+ }
630
+ if (firstRoot !== null) {
631
+ const tsconfig = readTsconfig(path18.join(hostDir, "tsconfig.json"));
632
+ const baseUrl = tsconfig?.compilerOptions?.baseUrl;
633
+ if (typeof baseUrl === "string" && path18.resolve(hostDir, baseUrl) !== path18.resolve(firstRoot)) {
634
+ diagnostics.push({
635
+ code: CODE_TSCONFIG_DRIFT,
636
+ severity: "warning",
637
+ message: `tsconfig.json \u7684 baseUrl\uFF08${baseUrl}\uFF09\u4E0E soma.sourceRoots \u7684\u6E90\u7801\u6839\uFF08${path18.relative(hostDir, firstRoot) || "."}\uFF09\u4E0D\u4E00\u81F4\uFF1A\u7F16\u8F91\u5668\u4E0E\u8FD0\u884C\u671F\u4F1A\u89E3\u6790\u5230\u4E0D\u540C\u76EE\u5F55`
638
+ });
639
+ }
640
+ }
641
+ const aliases = {};
642
+ for (const { name, dir } of entries) aliases[name] = dir;
643
+ return { declared: true, entries, aliases, diagnostics };
644
+ }
645
+ function formatDiagnostic(d) {
646
+ return `[soma-core][${d.code}] ${d.message}`;
647
+ }
648
+ function getSomaSourceRootAliases3(hostDir, env = process.env) {
649
+ const resolved = resolveSomaSourceRoots2(hostDir, env);
650
+ const errors = resolved.diagnostics.filter((d) => d.severity === "error");
651
+ if (errors.length > 0) {
652
+ const error = new Error(errors.map(formatDiagnostic).join("\n"));
653
+ error.code = errors[0].code;
654
+ error.diagnostics = errors;
655
+ throw error;
656
+ }
657
+ for (const d of resolved.diagnostics) {
658
+ const key = `${path18.resolve(hostDir)}\0${d.code}\0${d.name ?? ""}\0${d.message}`;
659
+ if (warned.has(key)) continue;
660
+ warned.add(key);
661
+ console.warn(`[soma-core][\u5F15\u64CE] ${d.code} ${d.message}`);
662
+ }
663
+ return { ...resolved.aliases };
664
+ }
665
+ function matchSomaSourceRoot(aliases, specifier) {
666
+ if (typeof specifier !== "string") return null;
667
+ const slash = specifier.indexOf("/");
668
+ if (slash <= 0) return null;
669
+ const name = specifier.slice(0, slash);
670
+ const dir = Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : void 0;
671
+ if (dir === void 0) return null;
672
+ return { name, dir, subpath: specifier.slice(slash + 1) };
673
+ }
674
+ function somaSourceRootFilter(aliases) {
675
+ const names = Object.keys(aliases);
676
+ if (names.length === 0) return null;
677
+ return new RegExp(`^(?:${names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})/`);
678
+ }
679
+ function somaViteAliases2(hostDir, env = process.env) {
680
+ return Object.entries(getSomaSourceRootAliases3(hostDir, env)).map(([name, dir]) => ({
681
+ find: new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`),
682
+ replacement: `${dir.split(path18.sep).join("/")}/`
683
+ }));
684
+ }
685
+ var HOST_BOOTSTRAP_SPECIFIER = "@soma-host/bootstrap/soma-bootstrap";
686
+ var HOST_BOOTSTRAP_CANDIDATES = ["soma-bootstrap.ts", "soma-bootstrap.js", "soma-bootstrap.mjs"];
687
+ function somaViteHostAliases2(hostDir, env = process.env) {
688
+ const sourceRoot = getSomaHostSourceRoot4(path18.resolve(hostDir), env);
689
+ const found = HOST_BOOTSTRAP_CANDIDATES.map((name) => path18.join(sourceRoot, "bootstrap", name)).find((file) => fs16.existsSync(file));
690
+ const target = found ?? path18.join(__dirname, "empty-host-bootstrap.mjs");
691
+ return [
692
+ ...somaViteAliases2(hostDir, env),
693
+ { find: new RegExp(`^${HOST_BOOTSTRAP_SPECIFIER}$`), replacement: target.split(path18.sep).join("/") }
694
+ ];
695
+ }
696
+ module2.exports = {
697
+ somaViteHostAliases: somaViteHostAliases2,
698
+ CODE_INVALID,
699
+ CODE_RESERVED,
700
+ CODE_SHADOW,
701
+ CODE_DUPLICATE,
702
+ CODE_TSCONFIG_DRIFT,
703
+ clearSomaSourceRootCache,
704
+ resolveSomaSourceRoots: resolveSomaSourceRoots2,
705
+ getSomaSourceRootAliases: getSomaSourceRootAliases3,
706
+ matchSomaSourceRoot,
707
+ somaSourceRootFilter,
708
+ somaViteAliases: somaViteAliases2
709
+ };
710
+ }
711
+ });
712
+
444
713
  // host-native/src/native-server.ts
445
714
  var native_server_exports = {};
446
715
  __export(native_server_exports, {
@@ -1933,6 +2202,17 @@ var SOMA_CORE_DIAGNOSTIC_CODES = [
1933
2202
  // 时间:ready() 前调同步方法
1934
2203
  "CORE-TEMPORAL-ZONE",
1935
2204
  // 时间:时区标识非法
2205
+ // 宿主源码别名(产生点 core/server/host/source-aliases.cjs,CJS 不能 import 本表,码字面量两处各一份,由本表对账测试与注册表一致)
2206
+ "CORE-HOST-ALIAS-INVALID",
2207
+ // 别名声明形状不对 / 路径越界或不存在 / 别名名字非法(error)
2208
+ "CORE-HOST-ALIAS-RESERVED",
2209
+ // 别名占了保留名(soma / soma-*、server-only、node_modules、带子路径的 Node 内置)(error)
2210
+ "CORE-HOST-ALIAS-SHADOW",
2211
+ // 宿主 node_modules/<别名> 已存在且不是指向别名目录的软链(warning,别名仍生效)
2212
+ "CORE-HOST-ALIAS-DUPLICATE",
2213
+ // 多个源码根里同名别名,先声明者胜(warning)
2214
+ "CORE-HOST-ALIAS-TSCONFIG-DRIFT",
2215
+ // tsconfig.json 的 baseUrl 与第一个源码根不一致(warning)
1936
2216
  "CORE-DND-SPEC",
1937
2217
  // 拖放:getData 返回非对象 / 同元素重复登记
1938
2218
  "CORE-ALGO-DIFF-INPUT",
@@ -2213,6 +2493,11 @@ var SOMA_PIPELINE_LIMITS = {
2213
2493
  "file": "core/server/registry/registry-file-lock.ts",
2214
2494
  "symbol": "SOMA_PIPELINE_LIMITS"
2215
2495
  },
2496
+ {
2497
+ "module": "soma-core",
2498
+ "file": "core/server/api/paged-list.ts",
2499
+ "symbol": "SOMA_PIPELINE_LIMITS"
2500
+ },
2216
2501
  {
2217
2502
  "module": "soma-core",
2218
2503
  "file": "core/server/registry/registry-write-pipeline.ts",
@@ -2228,6 +2513,11 @@ var SOMA_PIPELINE_LIMITS = {
2228
2513
  "file": "core/server/registry/source/version-store.ts",
2229
2514
  "symbol": "SOMA_PIPELINE_LIMITS"
2230
2515
  },
2516
+ {
2517
+ "module": "soma-core",
2518
+ "file": "core/server/runtime-space/inject.ts",
2519
+ "symbol": "SOMA_PIPELINE_LIMITS"
2520
+ },
2231
2521
  {
2232
2522
  "module": "soma-ui",
2233
2523
  "file": "src/compiler/bdl/registry/archive.ts",
@@ -2576,7 +2866,8 @@ var SOMA_PIPELINE_LIMITS = {
2576
2866
  "watchFailLimit": 2,
2577
2867
  "serverFileMaxEntries": 512,
2578
2868
  "serverFileMaxBytes": 33554432,
2579
- "serverDirMaxEntries": 256
2869
+ "serverDirMaxEntries": 256,
2870
+ "sourceRootAliasCapacity": 64
2580
2871
  },
2581
2872
  "runtimeCache": {
2582
2873
  "basis": "runtime \u7A7A\u95F4 L1 \u5185\u5B58 LRU \u7684\u6761\u76EE\u5BB9\u91CF\uFF08\u7F16\u8BD1\u7ED3\u679C\u4E0E\u6807\u51C6\u683C\u5F0F\u4EA7\u7269\u5404\u4E00\u6761\u76EE\uFF09\u4E0E\u9759\u6001\u9875\u5730\u5740\u6E05\u5355\u7684\u5F00\u53D1\u6001\u590D\u6838\u95F4\u9694\uFF1B\u5BB9\u91CF\u4E0D\u5C0F\u4E8E\u53D1\u5E03\u9875\u4EA7\u7269\u7F13\u5B58\u5BB9\u91CF\uFF08cache.publishedArtifactCapacity\uFF09\uFF0C\u56E0\u4E3A L1 \u8981\u5BB9\u5F97\u4E0B\u5DF2\u53D1\u5E03\u9875\u52A0\u4E0A\u8FD0\u884C\u671F\u6309 URL \u6CE8\u5165\u7684\u9875\uFF1B\u590D\u6838\u95F4\u9694\u8BA9\u65B0\u589E\u9759\u6001\u9875\u6700\u8FDF\u8FD9\u4E2A\u6BEB\u79D2\u6570\u540E\u8FDB\u5165\u5199\u5165\u671F\u51B2\u7A81\u5224\u5B9A\uFF08\u751F\u4EA7\u6001\u4E0D\u8FC7\u671F\uFF09\u3002\u8FC1\u5165\u524D\u662F soma-core store.ts \u7684 SOMA_RUNTIME_CACHE_ENTRIES_DEFAULT \u4E0E static-source.ts \u7684 DEV_TTL_MS",
@@ -2594,6 +2885,10 @@ var SOMA_PIPELINE_LIMITS = {
2594
2885
  "maxWaitMs": 5e3,
2595
2886
  "waitSliceMs": 15
2596
2887
  },
2888
+ "pagedList": {
2889
+ "pageSizeDefault": 10,
2890
+ "pageSizeMax": 500
2891
+ },
2597
2892
  "writeRate": {
2598
2893
  "limit": 120,
2599
2894
  "windowMs": 6e4
@@ -2604,7 +2899,8 @@ var SOMA_PIPELINE_LIMITS = {
2604
2899
  "defaultDebounceMs": 300
2605
2900
  },
2606
2901
  "inject": {
2607
- "pageMaxBytes": 4194304
2902
+ "pageMaxBytes": 4194304,
2903
+ "batchFailureMessageMaxChars": 2e3
2608
2904
  },
2609
2905
  "execution": {
2610
2906
  "maxNodes": 128,
@@ -3812,14 +4108,16 @@ function inspectSourceRequire(raw, paramNames) {
3812
4108
  }
3813
4109
  const issues = [];
3814
4110
  const seen = /* @__PURE__ */ new Set();
3815
- raw.forEach((name, index) => {
3816
- const at = `require[${index}]`;
4111
+ const checkName = (name, at, inGroup) => {
3817
4112
  if (typeof name !== "string" || name.trim() === "") {
3818
4113
  issues.push({ path: at, message: `require \u91CC\u7684\u53C2\u6570\u540D\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${show(name)}` });
3819
4114
  return;
3820
4115
  }
3821
4116
  if (seen.has(name)) {
3822
- issues.push({ path: at, message: `require \u91CC\u6709\u91CD\u590D\u7684\u53C2\u6570\u540D "${name}"` });
4117
+ issues.push({
4118
+ path: at,
4119
+ message: inGroup ? `require \u91CC\u6709\u91CD\u590D\u7684\u53C2\u6570\u540D "${name}"\uFF08\u540C\u540D\u4E0D\u80FD\u5728\u5355\u9879\u4E0E\u5206\u7EC4\u91CC\u3001\u6216\u4E24\u4E2A\u5206\u7EC4\u91CC\u91CD\u590D\u51FA\u73B0\uFF09` : `require \u91CC\u6709\u91CD\u590D\u7684\u53C2\u6570\u540D "${name}"`
4120
+ });
3823
4121
  return;
3824
4122
  }
3825
4123
  seen.add(name);
@@ -3829,6 +4127,28 @@ function inspectSourceRequire(raw, paramNames) {
3829
4127
  message: `require \u91CC\u7684 "${name}" \u6CA1\u6709\u51FA\u73B0\u5728\u540C\u4E00\u6765\u6E90\u7684 params \u91CC\uFF08params \u6709: ${paramNames.join(" / ") || "\u65E0"}\uFF09`
3830
4128
  });
3831
4129
  }
4130
+ };
4131
+ raw.forEach((entry, index) => {
4132
+ const at = `require[${index}]`;
4133
+ if (!Array.isArray(entry)) {
4134
+ checkName(entry, at, false);
4135
+ return;
4136
+ }
4137
+ if (entry.length < 2) {
4138
+ issues.push({
4139
+ path: at,
4140
+ message: `require \u91CC\u7684\u300C\u81F3\u5C11\u4E00\u4E2A\u300D\u5206\u7EC4\u81F3\u5C11\u8981 2 \u4E2A\u53C2\u6570\u540D\uFF08\u5355\u4E2A\u53C2\u6570\u76F4\u63A5\u5199\u540D\u5B57\uFF09\uFF0C\u5F53\u524D\u503C: ${show(entry)}`
4141
+ });
4142
+ return;
4143
+ }
4144
+ entry.forEach((member, memberIndex) => {
4145
+ const memberAt = `${at}[${memberIndex}]`;
4146
+ if (Array.isArray(member)) {
4147
+ issues.push({ path: memberAt, message: `require \u7684\u5206\u7EC4\u53EA\u8BB8\u4E00\u5C42\uFF0C\u4E0D\u80FD\u518D\u5D4C\u5957\u6570\u7EC4\uFF0C\u5F53\u524D\u503C: ${show(member)}` });
4148
+ return;
4149
+ }
4150
+ checkName(member, memberAt, true);
4151
+ });
3832
4152
  });
3833
4153
  return issues;
3834
4154
  }
@@ -4136,7 +4456,7 @@ function parseSource(raw, path18, objectNames, selfName, deps) {
4136
4456
  SOMA_FROM_REQUIRE_CODE
4137
4457
  );
4138
4458
  }
4139
- source2.require = [...requireRaw];
4459
+ source2.require = requireRaw.map((entry) => Array.isArray(entry) ? [...entry] : entry);
4140
4460
  }
4141
4461
  return source2;
4142
4462
  }
@@ -4560,11 +4880,12 @@ function parseDataConfig(raw) {
4560
4880
  var NOTIFY_LEVELS = ["success", "info", "warning", "error", "alert", "announce"];
4561
4881
  var NOTIFY_POLITENESS = ["polite", "assertive"];
4562
4882
  var SOMA_CONFIRM_LEVELS = ["plain", "typed", "consent"];
4883
+ var SOMA_CONFIRM_TONES = ["default", "danger"];
4563
4884
 
4564
4885
  // core/client/parser/confirm-spec.ts
4565
4886
  var SOMA_CONFIRM_REJECTED_PREFIX = "soma-confirm:";
4566
4887
  var SOMA_CONFIRM_TEXT_MAX = 1e3;
4567
- var SPEC_KEYS = ["level", "text", "phrase", "impact"];
4888
+ var SPEC_KEYS = ["level", "text", "phrase", "impact", "tone"];
4568
4889
  function boundedText(value2, key) {
4569
4890
  if (typeof value2 !== "string" || value2.trim() === "") return `confirm.${key} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(value2)}`;
4570
4891
  if (value2.length > SOMA_CONFIRM_TEXT_MAX) return `confirm.${key} \u8FC7\u957F\uFF08\u4E0A\u9650 ${SOMA_CONFIRM_TEXT_MAX} \u5B57\u7B26\uFF09`;
@@ -4572,7 +4893,7 @@ function boundedText(value2, key) {
4572
4893
  }
4573
4894
  function checkConfirmSpec(raw) {
4574
4895
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
4575
- return { ok: false, error: `confirm \u7ED3\u6784\u5FC5\u987B\u662F { level, text, phrase?, impact? } \u5BF9\u8C61\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}` };
4896
+ return { ok: false, error: `confirm \u7ED3\u6784\u5FC5\u987B\u662F { level, text, phrase?, impact?, tone? } \u5BF9\u8C61\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}` };
4576
4897
  }
4577
4898
  const record3 = raw;
4578
4899
  const extra = Object.keys(record3).find((key) => !SPEC_KEYS.includes(key));
@@ -4583,6 +4904,9 @@ function checkConfirmSpec(raw) {
4583
4904
  if (typeof level !== "string" || !SOMA_CONFIRM_LEVELS.includes(level)) {
4584
4905
  return { ok: false, error: `confirm.level \u5FC5\u987B\u662F ${SOMA_CONFIRM_LEVELS.join(" / ")} \u4E4B\u4E00\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(level)}` };
4585
4906
  }
4907
+ if (record3.tone !== void 0 && (typeof record3.tone !== "string" || !SOMA_CONFIRM_TONES.includes(record3.tone))) {
4908
+ return { ok: false, error: `confirm.tone \u5FC5\u987B\u662F ${SOMA_CONFIRM_TONES.join(" / ")} \u4E4B\u4E00\uFF08\u4E0D\u5199 = default\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(record3.tone)}` };
4909
+ }
4586
4910
  const textProblem = boundedText(record3.text, "text");
4587
4911
  if (textProblem !== null) return { ok: false, error: textProblem };
4588
4912
  for (const key of ["phrase", "impact"]) {
@@ -4610,7 +4934,8 @@ function checkConfirmSpec(raw) {
4610
4934
  level: lv,
4611
4935
  text,
4612
4936
  ...lv === "typed" ? { phrase: record3.phrase.trim() } : {},
4613
- ...lv !== "plain" && record3.impact !== void 0 ? { impact: record3.impact.trim() } : {}
4937
+ ...lv !== "plain" && record3.impact !== void 0 ? { impact: record3.impact.trim() } : {},
4938
+ ...record3.tone === "danger" ? { tone: "danger" } : {}
4614
4939
  }
4615
4940
  };
4616
4941
  }
@@ -4831,7 +5156,7 @@ function splitOptionalSegments(parts) {
4831
5156
  const segment = parseConfirmSegment(message4);
4832
5157
  if ("error" in segment) throw new SomaEventParseError(segment.error, parts.join(" | "));
4833
5158
  confirm = segment.spec.text;
4834
- confirmSpec = segment.spec.level === "plain" ? void 0 : segment.spec;
5159
+ confirmSpec = segment.spec.level === "plain" && segment.spec.tone === void 0 ? void 0 : segment.spec;
4835
5160
  continue;
4836
5161
  }
4837
5162
  if (index > 0 && part.startsWith(PERMISSION_PREFIX)) {
@@ -5610,6 +5935,7 @@ function compileFlatPage(input) {
5610
5935
 
5611
5936
  // core/server/runtime-space/digest.ts
5612
5937
  var import_node_crypto = require("node:crypto");
5938
+ var SOMA_RUNTIME_STORE_FORMAT = 2;
5613
5939
  var SOMA_RUNTIME_DIGEST_PATTERN = /^[0-9a-f]{64}$/;
5614
5940
  function isRuntimeDigest(value2) {
5615
5941
  return typeof value2 === "string" && SOMA_RUNTIME_DIGEST_PATTERN.test(value2);
@@ -5753,6 +6079,10 @@ var getSomaAssetSources2 = impl2.getSomaAssetSources;
5753
6079
  var collectPageEntries2 = impl2.collectPageEntries;
5754
6080
  var collectIncludes2 = impl2.collectIncludes;
5755
6081
 
6082
+ // core/server/host/source-aliases.ts
6083
+ var impl3 = __toESM(require_source_aliases());
6084
+ var getSomaSourceRootAliases2 = impl3.getSomaSourceRootAliases;
6085
+
5756
6086
  // core/server/host/host-assembly.ts
5757
6087
  var import_meta = {};
5758
6088
  var CREATE_REQUIRE_KEY = "createRequire";
@@ -5934,6 +6264,8 @@ function loadAppSync(appRoot) {
5934
6264
  moduleCache: false,
5935
6265
  requireCache: false,
5936
6266
  alias: {
6267
+ // 源码根别名(soma.sourceRoots):与服务加载器同一实现;固定别名在后,不可被覆盖
6268
+ ...getSomaSourceRootAliases2(key),
5937
6269
  "@soma-host": hostRoot,
5938
6270
  "@core": coreDir,
5939
6271
  ...serverOnlyEmpty !== void 0 ? { "server-only": serverOnlyEmpty } : {}
@@ -6299,6 +6631,7 @@ var ServerFileCache = class _ServerFileCache {
6299
6631
  const resolvedRoot = (0, import_path.resolve)(rootDir);
6300
6632
  if (this.isWatching(resolvedRoot) || this.unwatchableRoots.has(resolvedRoot)) return;
6301
6633
  try {
6634
+ (0, import_fs.statSync)(resolvedRoot);
6302
6635
  const watcher = (0, import_fs.watch)(resolvedRoot, { recursive: true }, (_event, filename) => {
6303
6636
  this.watchFailures.delete(resolvedRoot);
6304
6637
  if (!filename) return;
@@ -8180,7 +8513,7 @@ var SomaRuntimeStore = class {
8180
8513
  }
8181
8514
  writeBinding(binding) {
8182
8515
  import_node_fs8.default.mkdirSync(this.dirs.bindings, { recursive: true });
8183
- const record3 = { schemaVersion: 1, binding };
8516
+ const record3 = { schemaVersion: SOMA_RUNTIME_STORE_FORMAT, binding };
8184
8517
  writeFileAtomic(this.bindingFile(binding.address), `${JSON.stringify(record3, null, 2)}
8185
8518
  `);
8186
8519
  }
@@ -8189,7 +8522,7 @@ var SomaRuntimeStore = class {
8189
8522
  try {
8190
8523
  const stat = import_node_fs8.default.statSync(file);
8191
8524
  const record3 = JSON.parse(import_node_fs8.default.readFileSync(file, "utf8"));
8192
- if (record3.schemaVersion !== 1 || !record3.binding) return null;
8525
+ if (record3.schemaVersion !== SOMA_RUNTIME_STORE_FORMAT || !record3.binding) return null;
8193
8526
  return { binding: record3.binding, mtimeMs: stat.mtimeMs };
8194
8527
  } catch {
8195
8528
  return null;
@@ -8236,7 +8569,8 @@ var SomaRuntimeStore = class {
8236
8569
  const file = import_node_path8.default.join(this.dirs.bindings, name);
8237
8570
  const stat = import_node_fs8.default.statSync(file);
8238
8571
  const record3 = JSON.parse(import_node_fs8.default.readFileSync(file, "utf8"));
8239
- if (record3.schemaVersion === 1 && record3.binding) out.push({ binding: record3.binding, mtimeMs: stat.mtimeMs });
8572
+ if (record3.schemaVersion === SOMA_RUNTIME_STORE_FORMAT && record3.binding) out.push({ binding: record3.binding, mtimeMs: stat.mtimeMs });
8573
+ else import_node_fs8.default.unlinkSync(file);
8240
8574
  } catch {
8241
8575
  }
8242
8576
  }
@@ -8246,14 +8580,14 @@ var SomaRuntimeStore = class {
8246
8580
  readPrewarmIndex() {
8247
8581
  try {
8248
8582
  const parsed = JSON.parse(import_node_fs8.default.readFileSync(import_node_path8.default.join(this.dirs.prewarm, "index.json"), "utf8"));
8249
- if (parsed.schemaVersion === 1 && parsed.entries && typeof parsed.entries === "object") return parsed;
8583
+ if (parsed.schemaVersion === SOMA_RUNTIME_STORE_FORMAT && parsed.entries && typeof parsed.entries === "object") return parsed;
8250
8584
  } catch {
8251
8585
  }
8252
- return { schemaVersion: 1, entries: {} };
8586
+ return { schemaVersion: SOMA_RUNTIME_STORE_FORMAT, entries: {} };
8253
8587
  }
8254
8588
  writePrewarmIndex(entries) {
8255
8589
  import_node_fs8.default.mkdirSync(this.dirs.prewarm, { recursive: true });
8256
- const index = { schemaVersion: 1, entries };
8590
+ const index = { schemaVersion: SOMA_RUNTIME_STORE_FORMAT, entries };
8257
8591
  writeFileAtomic(import_node_path8.default.join(this.dirs.prewarm, "index.json"), `${JSON.stringify(index, null, 2)}
8258
8592
  `);
8259
8593
  }
@@ -8273,7 +8607,8 @@ function space() {
8273
8607
  loadedRoots: /* @__PURE__ */ new Set(),
8274
8608
  stores: /* @__PURE__ */ new Map(),
8275
8609
  layoutMemo: null,
8276
- rootErrorReported: false
8610
+ rootErrorReported: false,
8611
+ ownerGuards: /* @__PURE__ */ new Map()
8277
8612
  };
8278
8613
  }
8279
8614
  var LAYOUT_ENV_KEYS = ["SOMA_HOST_DIR", "SOMA_RUNTIME_DIR"];
@@ -8336,11 +8671,22 @@ function ensureLoaded() {
8336
8671
  console.warn(`[soma-core][\u5F15\u64CE] \u6301\u4E45\u7ED1\u5B9A ${binding.address} \u7684\u4EA7\u7269\u7F3A\u5931\u6216\u635F\u574F\uFF08${binding.digest.slice(0, 12)}\u2026\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\uFF1B\u91CD\u65B0 inject \u5373\u53EF\u6062\u590D\u3002`);
8337
8672
  continue;
8338
8673
  }
8674
+ const envelope = page.envelope ?? readFlatEnvelope(page.uiYaml);
8675
+ if (page.format !== SOMA_PAGE_FORMAT_VERSION) {
8676
+ store.removeBinding(binding.address);
8677
+ console.warn(`[soma-core][\u5F15\u64CE] \u6301\u4E45\u7ED1\u5B9A ${binding.address} \u7684\u4EA7\u7269\u6807\u51C6\u683C\u5F0F\u7248\u672C\u4E0D\u7B26\uFF0C\u5DF2\u4E22\u5F03\uFF1B\u7531\u4EA7\u51FA\u65B9\u91CD\u65B0\u7F16\u8BD1\u6CE8\u5165\u3002`);
8678
+ continue;
8679
+ }
8680
+ const guard = binding.owner === void 0 ? void 0 : state2.ownerGuards.get(binding.owner);
8681
+ if (guard !== void 0 && !guard(binding.version)) {
8682
+ store.removeBinding(binding.address);
8683
+ continue;
8684
+ }
8339
8685
  state2.generations.set(key, Math.max(state2.generations.get(key) ?? 0, binding.generation));
8340
8686
  state2.entries.set(key, {
8341
8687
  binding: { ...binding, persisted: true },
8342
8688
  page,
8343
- envelope: page.envelope ?? null,
8689
+ envelope,
8344
8690
  prefix: null,
8345
8691
  registryName: null,
8346
8692
  mtimeMs: read.mtimeMs
@@ -13302,6 +13648,8 @@ function getJitiLoader(hostDir, apiRoot, webRoot, reload = false) {
13302
13648
  moduleCache: !reload,
13303
13649
  requireCache: !reload,
13304
13650
  alias: {
13651
+ // 源码根别名(soma.sourceRoots):jiti 只匹配带斜杠的整段前缀,不劫持裸名;固定别名在后,不可被覆盖
13652
+ ...getSomaSourceRootAliases2(normalizedHostDir),
13305
13653
  "@core": getCoreDir(),
13306
13654
  "@soma-host": normalizedWebRoot,
13307
13655
  "@soma-api": normalizedApiRoot,
@@ -13814,7 +14162,7 @@ function writeIfChanged(file, content) {
13814
14162
  function readCompiledRecord(file) {
13815
14163
  try {
13816
14164
  const record3 = JSON.parse(import_node_fs14.default.readFileSync(file, "utf8"));
13817
- return record3.schemaVersion === 1 && typeof record3.digest === "string" ? record3 : null;
14165
+ return record3.schemaVersion === SOMA_RUNTIME_STORE_FORMAT && typeof record3.digest === "string" ? record3 : null;
13818
14166
  } catch {
13819
14167
  return null;
13820
14168
  }
@@ -13847,7 +14195,7 @@ async function runPrewarm(options) {
13847
14195
  continue;
13848
14196
  }
13849
14197
  const record3 = {
13850
- schemaVersion: 1,
14198
+ schemaVersion: SOMA_RUNTIME_STORE_FORMAT,
13851
14199
  address: item.address,
13852
14200
  digest,
13853
14201
  inputsDigest: item.inputsDigest,
@@ -13868,7 +14216,7 @@ async function runPrewarm(options) {
13868
14216
  } catch {
13869
14217
  }
13870
14218
  if (options.meta !== void 0) {
13871
- const record3 = { schemaVersion: 1, meta: options.meta };
14219
+ const record3 = { schemaVersion: SOMA_RUNTIME_STORE_FORMAT, meta: options.meta };
13872
14220
  writeIfChanged(import_node_path16.default.join(layout.dirs.prewarm, SOMA_PREWARM_META_FILE), `${JSON.stringify(record3)}
13873
14221
  `);
13874
14222
  }
@@ -13885,7 +14233,7 @@ async function runPrewarm(options) {
13885
14233
  persistedBindings += 1;
13886
14234
  }
13887
14235
  const sorted = Object.fromEntries(Object.entries(entries).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
13888
- const indexText = `${JSON.stringify({ schemaVersion: 1, entries: sorted }, null, 2)}
14236
+ const indexText = `${JSON.stringify({ schemaVersion: SOMA_RUNTIME_STORE_FORMAT, entries: sorted }, null, 2)}
13889
14237
  `;
13890
14238
  writeIfChanged(import_node_path16.default.join(layout.dirs.prewarm, "index.json"), indexText);
13891
14239
  return {
@@ -13913,7 +14261,7 @@ function readPrewarmCompiled(layout) {
13913
14261
  let meta = null;
13914
14262
  try {
13915
14263
  const parsed = JSON.parse(import_node_fs14.default.readFileSync(import_node_path16.default.join(layout.dirs.prewarm, SOMA_PREWARM_META_FILE), "utf8"));
13916
- if (parsed.schemaVersion === 1) meta = parsed.meta;
14264
+ if (parsed.schemaVersion === SOMA_RUNTIME_STORE_FORMAT) meta = parsed.meta;
13917
14265
  } catch {
13918
14266
  }
13919
14267
  return { pages, meta };
@@ -14102,6 +14450,18 @@ function precompilePage(p, context) {
14102
14450
  // host-native/src/host-prepare.ts
14103
14451
  var import_host_config_paths5 = __toESM(require_host_config_paths());
14104
14452
  var SOMA_SHELL_ROUTES_ENV = "SOMA_SHELL_ROUTES";
14453
+ var coreIdentityMemo = null;
14454
+ function coreCompilerIdentity() {
14455
+ if (coreIdentityMemo !== null) return coreIdentityMemo;
14456
+ let version = "unknown";
14457
+ try {
14458
+ const raw = JSON.parse(import_node_fs15.default.readFileSync(import_node_path17.default.join(__dirname, "..", "..", "package.json"), "utf8"));
14459
+ if (typeof raw.version === "string") version = raw.version;
14460
+ } catch {
14461
+ }
14462
+ coreIdentityMemo = `soma-core@${version}/store-format-${SOMA_RUNTIME_STORE_FORMAT}`;
14463
+ return coreIdentityMemo;
14464
+ }
14105
14465
  var lastRaw;
14106
14466
  var lastParsed = [];
14107
14467
  function readShellRoutesFromEnv(env = process.env) {
@@ -14206,7 +14566,8 @@ async function prewarmHostPages(hostDir, env = process.env) {
14206
14566
  appConfigYaml: compileInput.appConfigYaml,
14207
14567
  hostAppConfigYaml: appConfigYaml,
14208
14568
  treeContext: compileInput.treeContext ?? null,
14209
- compilerIdentity: null
14569
+ // 预编译旁档只在「同一份 core 编的」时复用:core 升级后整批旁档自动失效,不需要手工清 .soma/runtime
14570
+ compilerIdentity: coreCompilerIdentity()
14210
14571
  }),
14211
14572
  compile: () => precompilePage(compileInput, { hostAppConfig: shell.appConfig })
14212
14573
  };
@@ -15154,6 +15515,13 @@ data: ${data || ""}
15154
15515
  });
15155
15516
  return refreshTask;
15156
15517
  };
15518
+ const waitForDevRefreshIdle = async () => {
15519
+ const deadline = Date.now() + 3e4;
15520
+ while (!watcherClosed && (refreshTask !== null || refreshPending || debounceTimer !== null) && Date.now() < deadline) {
15521
+ if (refreshTask !== null) await refreshTask.catch(() => void 0);
15522
+ else await new Promise((resolve4) => setTimeout(resolve4, 50));
15523
+ }
15524
+ };
15157
15525
  if (dev) {
15158
15526
  try {
15159
15527
  fsWatcher = import_node_fs17.default.watch(webRoot, { recursive: true }, (_event, filename) => {
@@ -15251,8 +15619,10 @@ data: ${data || ""}
15251
15619
  const subSegments = pathname.slice("/_soma/client/".length).split("/").filter(Boolean);
15252
15620
  const staticReq = createStaticLookupRequest(req, method);
15253
15621
  const clientStaticDir = import_node_path19.default.resolve(runtimeLayout2.dirs.static, "client");
15622
+ if (dev) await waitForDevRefreshIdle();
15254
15623
  const clientRes = serveStaticFromRoot(clientStaticDir, subSegments, staticReq, true);
15255
15624
  if (clientRes) {
15625
+ if (dev && !/immutable/.test(clientRes.headers.get("cache-control") ?? "")) clientRes.headers.set("cache-control", "no-cache");
15256
15626
  await sendWebResponse(clientRes, res, method);
15257
15627
  return;
15258
15628
  }
@@ -15316,6 +15686,7 @@ data: ${data || ""}
15316
15686
  await sendWebResponse(response, res, method);
15317
15687
  return;
15318
15688
  } catch (error) {
15689
+ if (!isStatusError(error)) console.error(`[soma-native] \u9875\u9762\u8F7D\u5165\u5931\u8D25 path=${pagePath}`, error);
15319
15690
  let response = pageErrorResponse(error, assembly);
15320
15691
  response = await applyHostAndCspHeaders(response, { method: "GET", pathname }, env);
15321
15692
  await sendWebResponse(response, res, method);