soma-core 2.2.5 → 2.2.7
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/README.md +5 -6
- package/bin/soma.cjs +2 -2
- package/core/build/compiler/flat-page.ts +16 -0
- package/core/build/compiler/full-manifest-builder.ts +0 -3
- package/core/build/compiler/page-assets.ts +0 -1
- package/core/build/compiler/page-closure.ts +245 -0
- package/core/build/compiler/page-declaration-compiler.ts +2 -5
- package/core/build/compiler/soma-precompile.js +1972 -3312
- package/core/build/compiler/soma-precompile.ts +4 -7
- package/core/build/component-tree/artifact-codec.ts +4 -8
- package/core/build/lsp/soma-declaration.cjs +1 -1
- package/core/build/lsp/std-completion.generated.json +3 -3
- package/core/client/a11y/a11y-config.ts +2 -1
- package/core/client/a11y/dom-id.ts +1 -1
- package/core/client/base/SomaHttpClient.ts +11 -3
- package/core/client/base/SomaPageRootBase.ts +6 -0
- package/core/client/base/defineSomaView.ts +178 -0
- package/core/client/base/index.ts +13 -0
- package/core/client/base/view-context.ts +328 -0
- package/core/client/behavior/adapter-collection.ts +2 -2
- package/core/client/compiler/manifest-compiler.ts +5 -36
- package/core/client/component/component-definition.types.ts +2 -1
- package/core/client/component/component-manager.ts +110 -20
- package/core/client/component/structure-adapter.ts +3 -7
- package/core/client/container/IContainerAdapter.ts +4 -0
- package/core/client/container/SomaContainerAdapter.ts +52 -3
- package/core/client/data/data-object-resolver.ts +523 -184
- package/core/client/data/data-write-actions.ts +79 -15
- package/core/client/data/format-config.ts +3 -1
- package/core/client/data/region-scope-port.ts +11 -0
- package/core/client/engine/asset-resolver.ts +2 -5
- package/core/client/engine/dom-renderer.ts +7 -40
- package/core/client/engine/event-engine.ts +29 -108
- package/core/client/engine/property-watcher.ts +1 -1
- package/core/client/engine/reactive-proxy.ts +78 -17
- package/core/client/engine/runtime-builder.ts +0 -14
- package/core/client/engine/scope-resolver.ts +18 -0
- package/core/client/engine/soma-bootstrap.ts +387 -99
- package/core/client/engine/style-binder.ts +49 -106
- package/core/client/engine/timer-engine.ts +11 -1
- package/core/client/host-bridge/load-host-domain-class.ts +2 -1
- package/core/client/infra/http/SomaHttpService.ts +15 -4
- package/core/client/infra/i18n/pack-locales.ts +2 -2
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
- package/core/client/mount/domain-rule.ts +7 -3
- package/core/client/mount/mount-page.ts +38 -5
- package/core/client/mount/types.ts +2 -0
- package/core/client/parser/confirm-spec.ts +100 -7
- package/core/client/parser/data-config-parser.ts +28 -211
- package/core/client/parser/pipeline-parser.ts +16 -60
- package/core/client/parser/style-config-parser.ts +101 -95
- package/core/client/parser/timer-parser.ts +21 -0
- package/core/client/parser/ui-config-parser.ts +64 -12
- package/core/client/registry/declaration-renderer.ts +1 -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/client/runtime/SomaRuntimeServices.ts +2 -1
- package/core/client/runtime/SomaSnapshotStore.ts +5 -0
- package/core/client/security/url-guard.ts +71 -11
- package/core/client/validation/async-check-registry.ts +2 -1
- package/core/client/validation/contract-validator.ts +2 -6
- package/core/client/validation/field-rules.ts +3 -13
- package/core/client/validation/object-rules.ts +2 -10
- package/core/index.ts +17 -39
- package/core/inspect/check-product.ts +5 -5
- package/core/inspect/runtime.ts +2 -1
- package/core/server/api/dispatch-service-api.ts +35 -36
- package/core/server/api/load-host-service.ts +8 -4
- package/core/server/api/paged-list.ts +259 -0
- package/core/server/compile-port.ts +1 -1
- package/core/server/host/app-config-composer.ts +2 -1
- package/core/server/host/empty-host-bootstrap.mjs +3 -0
- package/core/server/host/host-assembly-entry.ts +1 -0
- package/core/server/host/host-assembly.ts +50 -3
- package/core/server/host/host-caller.ts +2 -1
- package/core/server/host/host-dir.ts +9 -0
- package/core/server/host/host-response-headers.ts +2 -1
- package/core/server/host/invoke-host-request-hook.ts +28 -4
- package/core/server/host/published-page-assets.ts +2 -1
- package/core/server/host/resolve-host-request-hook.ts +25 -7
- package/core/server/host/server-page-assets.ts +4 -4
- 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/host/virtual-pages.ts +3 -2
- package/core/server/infra/cache/ServerFileCache.ts +83 -10
- package/core/server/node.ts +10 -0
- package/core/server/registry/api-registry-store.ts +3 -1
- package/core/server/registry/declaration-precompiler.ts +0 -2
- package/core/server/registry/page-registry-repository.ts +2 -1
- package/core/server/registry/page-registry-store.ts +2 -1
- package/core/server/registry/registry-error.ts +6 -1
- package/core/server/registry/registry-file-lock.ts +296 -23
- package/core/server/registry/request-body-limit.ts +3 -2
- package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
- package/core/server/runtime-space/access-gate.ts +21 -7
- package/core/server/runtime-space/bindings.ts +3 -6
- package/core/server/runtime-space/dynamic-pages.ts +181 -49
- package/core/server/runtime-space/errors.ts +3 -0
- package/core/server/runtime-space/inject.ts +78 -16
- package/core/server/runtime-space/page-grants.ts +7 -1
- package/core/server/runtime-space/resolve.ts +66 -19
- package/core/server/runtime-space/store.ts +32 -3
- package/core/server/runtime-space/submit-steps.ts +2 -1
- package/core/server/runtime-space/types.ts +3 -1
- package/core/shared/component-tree-errors.ts +2 -1
- package/core/shared/contract-a11y.ts +1 -1
- package/core/shared/contract-sections.ts +2 -2
- package/core/shared/core-diagnostic-codes.ts +14 -0
- package/core/shared/data-declaration-checks.ts +29 -3
- package/core/shared/declaration-keys.ts +1 -1
- package/core/shared/engines/engine-error.ts +2 -1
- package/core/shared/generation-error.ts +2 -1
- package/core/shared/page-envelope.ts +1 -1
- package/core/shared/pure-binding.ts +88 -0
- package/core/shared/registry-generated/diagnostic-registry-index.ts +21 -19
- package/core/shared/registry-generated/diagnostic-registry.ts +170 -177
- package/core/shared/registry-generated/limits.ts +65 -13
- package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
- package/core/shared/registry-generated/std-grammar-views.ts +40 -10
- package/core/shared/registry-generated/std-grammar.ts +43 -21
- package/core/shared/soma-error.ts +36 -0
- package/core/shared/types/compile-port.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +20 -18
- package/core/shared/types/engine.types.ts +0 -3
- package/core/shared/types/event.types.ts +10 -11
- package/core/shared/types/generation-error.types.ts +5 -1
- package/core/shared/types/host-assembly.types.ts +7 -1
- package/core/shared/types/manifest.types.ts +0 -3
- package/core/shared/types/region-scope.types.ts +5 -1
- package/core/shared/types/scope-manifest.types.ts +0 -2
- package/core/shared/types/style-config.types.ts +21 -21
- package/core/shared/types/ui-config.types.ts +4 -5
- package/core/shared/types/watcher.types.ts +1 -1
- package/dist/browser/runtime-bundle.manifest.json +11 -13
- package/dist/browser/soma-runtime.js +2733 -2712
- package/dist/core/index.cjs +5665 -5534
- package/dist/host-native/aot-builder.cjs +330 -1
- package/dist/host-native/native-server.cjs +5434 -4726
- package/dist/lsp/component-tree.cjs +5868 -7040
- package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
- package/dist/types/build/compiler/page-closure.d.ts +21 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
- package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
- package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
- package/dist/types/client/a11y/a11y-config.d.ts +2 -1
- package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
- package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
- package/dist/types/client/base/defineSomaView.d.ts +46 -0
- package/dist/types/client/base/index.d.ts +2 -0
- package/dist/types/client/base/view-context.d.ts +136 -0
- package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
- package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
- package/dist/types/client/component/component-definition.types.d.ts +2 -1
- package/dist/types/client/component/component-manager.d.ts +29 -0
- 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 +93 -31
- package/dist/types/client/data/format-config.d.ts +2 -1
- package/dist/types/client/engine/dom-renderer.d.ts +1 -2
- package/dist/types/client/engine/event-engine.d.ts +0 -7
- package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
- package/dist/types/client/engine/runtime-builder.d.ts +0 -4
- package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
- package/dist/types/client/engine/style-binder.d.ts +8 -4
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
- package/dist/types/client/mount/domain-rule.d.ts +2 -0
- package/dist/types/client/mount/mount-page.d.ts +2 -1
- package/dist/types/client/mount/types.d.ts +2 -0
- package/dist/types/client/parser/confirm-spec.d.ts +27 -3
- package/dist/types/client/parser/data-config-parser.d.ts +6 -5
- package/dist/types/client/parser/style-config-parser.d.ts +7 -3
- package/dist/types/client/parser/timer-parser.d.ts +5 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
- 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/client/runtime/SomaSnapshotStore.d.ts +2 -0
- package/dist/types/client/security/url-guard.d.ts +14 -0
- package/dist/types/client/validation/async-check-registry.d.ts +2 -1
- package/dist/types/client/validation/object-rules.d.ts +0 -5
- package/dist/types/index.d.ts +6 -11
- package/dist/types/inspect/runtime.d.ts +2 -1
- package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
- package/dist/types/server/api/load-host-service.d.ts +1 -1
- package/dist/types/server/api/paged-list.d.ts +101 -0
- package/dist/types/server/compile-port.d.ts +1 -1
- package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
- package/dist/types/server/host/host-assembly.d.ts +2 -0
- package/dist/types/server/host/host-dir.d.ts +2 -0
- package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
- package/dist/types/server/host/published-page-assets.d.ts +2 -1
- package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
- package/dist/types/server/host/server-page-assets.d.ts +2 -1
- 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/infra/cache/ServerFileCache.d.ts +8 -0
- package/dist/types/server/node.d.ts +1 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
- package/dist/types/server/registry/registry-error.d.ts +5 -1
- package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
- package/dist/types/server/registry/request-body-limit.d.ts +3 -2
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
- package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
- package/dist/types/server/runtime-space/bindings.d.ts +3 -2
- package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
- package/dist/types/server/runtime-space/errors.d.ts +1 -1
- package/dist/types/server/runtime-space/resolve.d.ts +2 -0
- package/dist/types/server/runtime-space/store.d.ts +8 -1
- package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
- package/dist/types/server/runtime-space/types.d.ts +3 -1
- package/dist/types/shared/component-tree-errors.d.ts +2 -1
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/declaration-keys.d.ts +1 -1
- package/dist/types/shared/engines/engine-error.d.ts +2 -1
- package/dist/types/shared/generation-error.d.ts +2 -1
- package/dist/types/shared/pure-binding.d.ts +48 -0
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +149 -158
- package/dist/types/shared/registry-generated/limits.d.ts +54 -10
- package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
- package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
- package/dist/types/shared/registry-generated/std-grammar.d.ts +110 -242
- package/dist/types/shared/soma-error.d.ts +15 -0
- package/dist/types/shared/types/data-config.types.d.ts +17 -17
- package/dist/types/shared/types/engine.types.d.ts +0 -3
- package/dist/types/shared/types/event.types.d.ts +9 -7
- package/dist/types/shared/types/generation-error.types.d.ts +1 -1
- package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
- package/dist/types/shared/types/manifest.types.d.ts +0 -3
- package/dist/types/shared/types/region-scope.types.d.ts +4 -1
- package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
- package/dist/types/shared/types/style-config.types.d.ts +17 -19
- package/dist/types/shared/types/ui-config.types.d.ts +4 -5
- package/host-native/bin/host-native.cjs +22 -1
- package/host-native/client/browser-entry.ts +21 -172
- package/host-native/src/aot-builder.ts +75 -0
- package/host-native/src/host-prepare.ts +39 -5
- package/host-native/src/manifest-http.ts +2 -3
- package/host-native/src/native-server.ts +812 -174
- package/host-native/src/page-http.ts +3 -3
- package/host-native/src/public-packages.cjs +0 -1
- package/host-native/src/registry-handler.ts +12 -5
- package/host-native/src/static-file.ts +203 -53
- package/host-native/styles/globals.css +30 -28
- package/package.json +14 -2
- package/core/client/engine/step-runner.ts +0 -212
- package/core/client/engine/trigger-engine.ts +0 -55
- package/core/client/format/zoned.ts +0 -10
- package/core/client/parser/step-parser.ts +0 -359
- package/core/client/parser/trigger-parser.ts +0 -90
- package/core/client/parser/value-lang.ts +0 -340
- package/core/client/time/instant.ts +0 -2
- package/core/shared/calc/coerce.ts +0 -2
- package/core/shared/calc/errors.ts +0 -40
- package/core/shared/calc/evaluator.ts +0 -113
- package/core/shared/calc/index.ts +0 -11
- package/core/shared/calc/lexer.ts +0 -189
- package/core/shared/calc/parser.ts +0 -193
- package/core/shared/calc/typer.ts +0 -171
- package/core/shared/date-parts.ts +0 -2
- package/core/shared/show-when.ts +0 -77
- package/core/shared/types/step.types.ts +0 -91
- package/core/shared/types/trigger.types.ts +0 -14
- package/dist/types/client/engine/step-runner.d.ts +0 -42
- package/dist/types/client/engine/trigger-engine.d.ts +0 -16
- package/dist/types/client/format/zoned.d.ts +0 -1
- package/dist/types/client/parser/step-parser.d.ts +0 -23
- package/dist/types/client/parser/trigger-parser.d.ts +0 -13
- package/dist/types/client/parser/value-lang.d.ts +0 -63
- package/dist/types/client/time/instant.d.ts +0 -1
- package/dist/types/shared/calc/coerce.d.ts +0 -1
- package/dist/types/shared/calc/errors.d.ts +0 -14
- package/dist/types/shared/calc/evaluator.d.ts +0 -2
- package/dist/types/shared/calc/index.d.ts +0 -6
- package/dist/types/shared/calc/lexer.d.ts +0 -19
- package/dist/types/shared/calc/parser.d.ts +0 -43
- package/dist/types/shared/calc/typer.d.ts +0 -11
- package/dist/types/shared/date-parts.d.ts +0 -1
- package/dist/types/shared/show-when.d.ts +0 -21
- package/dist/types/shared/types/step.types.d.ts +0 -76
- package/dist/types/shared/types/trigger.types.d.ts +0 -12
|
@@ -123,7 +123,6 @@ var require_public_packages = __commonJS({
|
|
|
123
123
|
path2.join(repoRoot2, "soma-core"),
|
|
124
124
|
path2.join(repoRoot2, "soma-foundation"),
|
|
125
125
|
path2.join(repoRoot2, "soma-ui"),
|
|
126
|
-
path2.join(repoRoot2, "soma-lite"),
|
|
127
126
|
path2.join(repoRoot2, "soma-kit"),
|
|
128
127
|
path2.join(repoRoot2, "soma-ai")
|
|
129
128
|
];
|
|
@@ -448,6 +447,7 @@ var require_source_packages = __commonJS({
|
|
|
448
447
|
SOMA_SOURCE_PACKAGES_ENV,
|
|
449
448
|
getSomaHostSourceRoot: getSomaHostSourceRoot2,
|
|
450
449
|
getSomaHostApiRoot: getSomaHostApiRoot2,
|
|
450
|
+
resolveSafeChildRoot,
|
|
451
451
|
clearSomaAssetSourcesCache,
|
|
452
452
|
getSomaAssetSources,
|
|
453
453
|
listSomaSourcePackageNames,
|
|
@@ -459,6 +459,274 @@ var require_source_packages = __commonJS({
|
|
|
459
459
|
}
|
|
460
460
|
});
|
|
461
461
|
|
|
462
|
+
// core/server/host/source-aliases.cjs
|
|
463
|
+
var require_source_aliases = __commonJS({
|
|
464
|
+
"core/server/host/source-aliases.cjs"(exports2, module2) {
|
|
465
|
+
"use strict";
|
|
466
|
+
var fs2 = require("node:fs");
|
|
467
|
+
var path2 = require("node:path");
|
|
468
|
+
var nodeModule = require("node:module");
|
|
469
|
+
var { getSomaHostApiRoot: getSomaHostApiRoot2, getSomaHostSourceRoot: getSomaHostSourceRoot2, resolveSafeChildRoot } = require_source_packages();
|
|
470
|
+
var CODE_INVALID = "CORE-HOST-ALIAS-INVALID";
|
|
471
|
+
var CODE_RESERVED = "CORE-HOST-ALIAS-RESERVED";
|
|
472
|
+
var CODE_SHADOW = "CORE-HOST-ALIAS-SHADOW";
|
|
473
|
+
var CODE_DUPLICATE = "CORE-HOST-ALIAS-DUPLICATE";
|
|
474
|
+
var CODE_TSCONFIG_DRIFT = "CORE-HOST-ALIAS-TSCONFIG-DRIFT";
|
|
475
|
+
var ALIAS_NAME_RE = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
|
|
476
|
+
var RESERVED_NAMES = /* @__PURE__ */ new Set(["server-only", "node_modules", "soma"]);
|
|
477
|
+
var BUILTIN_WITH_SUBPATH = new Set(
|
|
478
|
+
nodeModule.builtinModules.filter((m) => m.includes("/")).map((m) => m.slice(0, m.indexOf("/")))
|
|
479
|
+
);
|
|
480
|
+
var MAX_CACHE = 64;
|
|
481
|
+
var resolveCache = /* @__PURE__ */ new Map();
|
|
482
|
+
var warned = /* @__PURE__ */ new Set();
|
|
483
|
+
function clearSomaSourceRootCache() {
|
|
484
|
+
resolveCache.clear();
|
|
485
|
+
warned.clear();
|
|
486
|
+
}
|
|
487
|
+
function readJson(filePath) {
|
|
488
|
+
try {
|
|
489
|
+
if (!fs2.existsSync(filePath)) return null;
|
|
490
|
+
return JSON.parse(fs2.readFileSync(filePath, "utf8"));
|
|
491
|
+
} catch {
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function readTsconfig(filePath) {
|
|
496
|
+
let raw;
|
|
497
|
+
try {
|
|
498
|
+
raw = fs2.readFileSync(filePath, "utf8");
|
|
499
|
+
} catch {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
const stripped = raw.replace(/("(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (_m, str) => str ?? "").replace(/,(\s*[}\]])/g, "$1");
|
|
503
|
+
try {
|
|
504
|
+
return JSON.parse(stripped);
|
|
505
|
+
} catch {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function reservedReason(name) {
|
|
510
|
+
if (name === "soma" || name.startsWith("soma-")) return "\u4E0E soma \u516C\u5F00\u5305\u540D\u7A7A\u95F4\u51B2\u7A81";
|
|
511
|
+
if (RESERVED_NAMES.has(name)) return "\u662F\u4FDD\u7559\u540D";
|
|
512
|
+
if (BUILTIN_WITH_SUBPATH.has(name)) return `\u4F1A\u52AB\u6301 Node \u5185\u7F6E\u5B50\u8DEF\u5F84\uFF08\u5982 ${name}/...\uFF09`;
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
function realInside(parent, child) {
|
|
516
|
+
try {
|
|
517
|
+
const p = fs2.realpathSync(parent);
|
|
518
|
+
const c = fs2.realpathSync(child);
|
|
519
|
+
return c === p || c.startsWith(`${p}${path2.sep}`);
|
|
520
|
+
} catch {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function resolveSomaSourceRoots(hostDir, env = process.env) {
|
|
525
|
+
let normalizedHostDir = path2.resolve(hostDir);
|
|
526
|
+
if (!fs2.existsSync(path2.join(normalizedHostDir, "package.json"))) {
|
|
527
|
+
for (let dir = path2.dirname(normalizedHostDir); ; dir = path2.dirname(dir)) {
|
|
528
|
+
if (fs2.existsSync(path2.join(dir, "package.json"))) {
|
|
529
|
+
normalizedHostDir = dir;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
if (path2.dirname(dir) === dir) break;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const packageJsonPath = path2.join(normalizedHostDir, "package.json");
|
|
536
|
+
const stat = fs2.statSync(packageJsonPath, { throwIfNoEntry: false });
|
|
537
|
+
const cacheKey = `${normalizedHostDir}\0${env?.SOMA_API_DIR ?? ""}\0${env?.SOMA_WEB_DIR ?? ""}\0${stat ? `${stat.mtimeMs}:${stat.size}` : "none"}`;
|
|
538
|
+
const cached = resolveCache.get(cacheKey);
|
|
539
|
+
if (cached) return cached;
|
|
540
|
+
const result = compute(normalizedHostDir, env, readJson(packageJsonPath));
|
|
541
|
+
if (resolveCache.size >= MAX_CACHE) resolveCache.delete(resolveCache.keys().next().value);
|
|
542
|
+
resolveCache.set(cacheKey, result);
|
|
543
|
+
return result;
|
|
544
|
+
}
|
|
545
|
+
function compute(hostDir, env, packageJson) {
|
|
546
|
+
const diagnostics = [];
|
|
547
|
+
const raw = packageJson?.soma?.sourceRoots;
|
|
548
|
+
const empty = { declared: false, entries: [], aliases: {}, diagnostics };
|
|
549
|
+
if (raw === void 0 || raw === null) return empty;
|
|
550
|
+
const invalid = (message) => diagnostics.push({ code: CODE_INVALID, severity: "error", message: `soma.sourceRoots ${message}` });
|
|
551
|
+
const candidates = [];
|
|
552
|
+
let firstRoot = null;
|
|
553
|
+
const addRoot = (rootDir) => {
|
|
554
|
+
if (firstRoot === null) firstRoot = rootDir;
|
|
555
|
+
let children;
|
|
556
|
+
try {
|
|
557
|
+
children = fs2.readdirSync(rootDir, { withFileTypes: true });
|
|
558
|
+
} catch {
|
|
559
|
+
invalid(`\u7684\u6E90\u7801\u6839\u4E0D\u53EF\u8BFB\uFF1A${rootDir}`);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
for (const entry of children.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
563
|
+
const full = path2.join(rootDir, entry.name);
|
|
564
|
+
const isDir = entry.isDirectory() || entry.isSymbolicLink() && fs2.statSync(full, { throwIfNoEntry: false })?.isDirectory();
|
|
565
|
+
if (!isDir || entry.name.startsWith(".") || entry.name === "node_modules" || !ALIAS_NAME_RE.test(entry.name)) continue;
|
|
566
|
+
candidates.push({ name: entry.name, dir: full });
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
const safeRoot = (rel) => {
|
|
570
|
+
if (typeof rel !== "string" || !rel.trim() || rel.includes("\0")) {
|
|
571
|
+
invalid("\u7684\u8DEF\u5F84\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
const resolved = path2.resolve(hostDir, rel.trim());
|
|
575
|
+
const safe = resolveSafeChildRoot(hostDir, rel);
|
|
576
|
+
if (safe !== resolved || !fs2.existsSync(safe) || !fs2.statSync(safe).isDirectory() || !realInside(hostDir, safe)) {
|
|
577
|
+
invalid(`\u7684\u8DEF\u5F84 "${rel}" \u5FC5\u987B\u662F\u5BBF\u4E3B\u76EE\u5F55\u5185\u5DF2\u5B58\u5728\u7684\u76EE\u5F55`);
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
return safe;
|
|
581
|
+
};
|
|
582
|
+
if (raw === "auto") {
|
|
583
|
+
const apiRoot = getSomaHostApiRoot2(hostDir, env);
|
|
584
|
+
addRoot(apiRoot);
|
|
585
|
+
} else if (typeof raw === "string" || Array.isArray(raw)) {
|
|
586
|
+
for (const rel of Array.isArray(raw) ? raw : [raw]) {
|
|
587
|
+
const root = safeRoot(rel);
|
|
588
|
+
if (root) addRoot(root);
|
|
589
|
+
}
|
|
590
|
+
} else if (typeof raw === "object") {
|
|
591
|
+
for (const [name, rel] of Object.entries(raw)) {
|
|
592
|
+
if (!ALIAS_NAME_RE.test(name)) {
|
|
593
|
+
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` });
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
const dir = safeRoot(rel);
|
|
597
|
+
if (dir) candidates.push({ name, dir });
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
invalid('\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');
|
|
601
|
+
return { ...empty, declared: true };
|
|
602
|
+
}
|
|
603
|
+
const entries = [];
|
|
604
|
+
const taken = /* @__PURE__ */ new Map();
|
|
605
|
+
for (const candidate of candidates) {
|
|
606
|
+
const reason = reservedReason(candidate.name);
|
|
607
|
+
if (reason) {
|
|
608
|
+
diagnostics.push({
|
|
609
|
+
code: CODE_RESERVED,
|
|
610
|
+
severity: "error",
|
|
611
|
+
name: candidate.name,
|
|
612
|
+
message: `\u6E90\u7801\u6839\u522B\u540D "${candidate.name}" ${reason}\uFF0C\u8BF7\u628A\u8BE5\u76EE\u5F55\u6539\u540D\u6216\u79FB\u51FA\u6E90\u7801\u6839`
|
|
613
|
+
});
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
if (taken.has(candidate.name)) {
|
|
617
|
+
diagnostics.push({
|
|
618
|
+
code: CODE_DUPLICATE,
|
|
619
|
+
severity: "warning",
|
|
620
|
+
name: candidate.name,
|
|
621
|
+
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`
|
|
622
|
+
});
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
taken.set(candidate.name, candidate.dir);
|
|
626
|
+
entries.push(candidate);
|
|
627
|
+
}
|
|
628
|
+
for (const { name, dir } of entries) {
|
|
629
|
+
const installed = path2.join(hostDir, "node_modules", name);
|
|
630
|
+
const installedStat = fs2.lstatSync(installed, { throwIfNoEntry: false });
|
|
631
|
+
if (!installedStat) continue;
|
|
632
|
+
let same = false;
|
|
633
|
+
try {
|
|
634
|
+
same = fs2.realpathSync(installed) === fs2.realpathSync(dir);
|
|
635
|
+
} catch {
|
|
636
|
+
same = false;
|
|
637
|
+
}
|
|
638
|
+
if (!same) {
|
|
639
|
+
diagnostics.push({
|
|
640
|
+
code: CODE_SHADOW,
|
|
641
|
+
severity: "warning",
|
|
642
|
+
name,
|
|
643
|
+
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`
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (firstRoot !== null) {
|
|
648
|
+
const tsconfig = readTsconfig(path2.join(hostDir, "tsconfig.json"));
|
|
649
|
+
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
|
650
|
+
if (typeof baseUrl === "string" && path2.resolve(hostDir, baseUrl) !== path2.resolve(firstRoot)) {
|
|
651
|
+
diagnostics.push({
|
|
652
|
+
code: CODE_TSCONFIG_DRIFT,
|
|
653
|
+
severity: "warning",
|
|
654
|
+
message: `tsconfig.json \u7684 baseUrl\uFF08${baseUrl}\uFF09\u4E0E soma.sourceRoots \u7684\u6E90\u7801\u6839\uFF08${path2.relative(hostDir, firstRoot) || "."}\uFF09\u4E0D\u4E00\u81F4\uFF1A\u7F16\u8F91\u5668\u4E0E\u8FD0\u884C\u671F\u4F1A\u89E3\u6790\u5230\u4E0D\u540C\u76EE\u5F55`
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const aliases = {};
|
|
659
|
+
for (const { name, dir } of entries) aliases[name] = dir;
|
|
660
|
+
return { declared: true, entries, aliases, diagnostics };
|
|
661
|
+
}
|
|
662
|
+
function formatDiagnostic(d) {
|
|
663
|
+
return `[soma-core][${d.code}] ${d.message}`;
|
|
664
|
+
}
|
|
665
|
+
function getSomaSourceRootAliases2(hostDir, env = process.env) {
|
|
666
|
+
const resolved = resolveSomaSourceRoots(hostDir, env);
|
|
667
|
+
const errors = resolved.diagnostics.filter((d) => d.severity === "error");
|
|
668
|
+
if (errors.length > 0) {
|
|
669
|
+
const error = new Error(errors.map(formatDiagnostic).join("\n"));
|
|
670
|
+
error.code = errors[0].code;
|
|
671
|
+
error.diagnostics = errors;
|
|
672
|
+
throw error;
|
|
673
|
+
}
|
|
674
|
+
for (const d of resolved.diagnostics) {
|
|
675
|
+
const key = `${path2.resolve(hostDir)}\0${d.code}\0${d.name ?? ""}\0${d.message}`;
|
|
676
|
+
if (warned.has(key)) continue;
|
|
677
|
+
warned.add(key);
|
|
678
|
+
console.warn(`[soma-core][\u5F15\u64CE] ${d.code} ${d.message}`);
|
|
679
|
+
}
|
|
680
|
+
return { ...resolved.aliases };
|
|
681
|
+
}
|
|
682
|
+
function matchSomaSourceRoot2(aliases, specifier) {
|
|
683
|
+
if (typeof specifier !== "string") return null;
|
|
684
|
+
const slash = specifier.indexOf("/");
|
|
685
|
+
if (slash <= 0) return null;
|
|
686
|
+
const name = specifier.slice(0, slash);
|
|
687
|
+
const dir = Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : void 0;
|
|
688
|
+
if (dir === void 0) return null;
|
|
689
|
+
return { name, dir, subpath: specifier.slice(slash + 1) };
|
|
690
|
+
}
|
|
691
|
+
function somaSourceRootFilter2(aliases) {
|
|
692
|
+
const names = Object.keys(aliases);
|
|
693
|
+
if (names.length === 0) return null;
|
|
694
|
+
return new RegExp(`^(?:${names.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})/`);
|
|
695
|
+
}
|
|
696
|
+
function somaViteAliases(hostDir, env = process.env) {
|
|
697
|
+
return Object.entries(getSomaSourceRootAliases2(hostDir, env)).map(([name, dir]) => ({
|
|
698
|
+
find: new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`),
|
|
699
|
+
replacement: `${dir.split(path2.sep).join("/")}/`
|
|
700
|
+
}));
|
|
701
|
+
}
|
|
702
|
+
var HOST_BOOTSTRAP_SPECIFIER = "@soma-host/bootstrap/soma-bootstrap";
|
|
703
|
+
var HOST_BOOTSTRAP_CANDIDATES = ["soma-bootstrap.ts", "soma-bootstrap.js", "soma-bootstrap.mjs"];
|
|
704
|
+
function somaViteHostAliases(hostDir, env = process.env) {
|
|
705
|
+
const sourceRoot = getSomaHostSourceRoot2(path2.resolve(hostDir), env);
|
|
706
|
+
const found = HOST_BOOTSTRAP_CANDIDATES.map((name) => path2.join(sourceRoot, "bootstrap", name)).find((file) => fs2.existsSync(file));
|
|
707
|
+
const target = found ?? path2.join(__dirname, "empty-host-bootstrap.mjs");
|
|
708
|
+
return [
|
|
709
|
+
...somaViteAliases(hostDir, env),
|
|
710
|
+
{ find: new RegExp(`^${HOST_BOOTSTRAP_SPECIFIER}$`), replacement: target.split(path2.sep).join("/") }
|
|
711
|
+
];
|
|
712
|
+
}
|
|
713
|
+
module2.exports = {
|
|
714
|
+
somaViteHostAliases,
|
|
715
|
+
CODE_INVALID,
|
|
716
|
+
CODE_RESERVED,
|
|
717
|
+
CODE_SHADOW,
|
|
718
|
+
CODE_DUPLICATE,
|
|
719
|
+
CODE_TSCONFIG_DRIFT,
|
|
720
|
+
clearSomaSourceRootCache,
|
|
721
|
+
resolveSomaSourceRoots,
|
|
722
|
+
getSomaSourceRootAliases: getSomaSourceRootAliases2,
|
|
723
|
+
matchSomaSourceRoot: matchSomaSourceRoot2,
|
|
724
|
+
somaSourceRootFilter: somaSourceRootFilter2,
|
|
725
|
+
somaViteAliases
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
|
|
462
730
|
// host-native/src/aot-builder.ts
|
|
463
731
|
var aot_builder_exports = {};
|
|
464
732
|
__export(aot_builder_exports, {
|
|
@@ -479,6 +747,19 @@ function toPascalCase(str) {
|
|
|
479
747
|
|
|
480
748
|
// host-native/src/aot-builder.ts
|
|
481
749
|
var import_source_packages = __toESM(require_source_packages());
|
|
750
|
+
var import_source_aliases = __toESM(require_source_aliases());
|
|
751
|
+
function registerSourceRootResolve(build, hostDir, env) {
|
|
752
|
+
const aliases = (0, import_source_aliases.getSomaSourceRootAliases)(hostDir, env);
|
|
753
|
+
const filter = (0, import_source_aliases.somaSourceRootFilter)(aliases);
|
|
754
|
+
if (!filter) return;
|
|
755
|
+
const nodeModulesSegment = `${import_node_path.default.sep}node_modules${import_node_path.default.sep}`;
|
|
756
|
+
build.onResolve({ filter }, (args) => {
|
|
757
|
+
if (args.importer.includes(nodeModulesSegment)) return void 0;
|
|
758
|
+
const hit = (0, import_source_aliases.matchSomaSourceRoot)(aliases, args.path);
|
|
759
|
+
if (!hit) return void 0;
|
|
760
|
+
return { path: resolveModuleFile(hit.dir, hit.subpath) };
|
|
761
|
+
});
|
|
762
|
+
}
|
|
482
763
|
function resolveModuleFile(baseDir, subpath) {
|
|
483
764
|
const target = subpath ? import_node_path.default.resolve(baseDir, subpath) : import_node_path.default.resolve(baseDir);
|
|
484
765
|
for (const ext of ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]) {
|
|
@@ -570,6 +851,7 @@ function createBrowserClientPlugin(options) {
|
|
|
570
851
|
}
|
|
571
852
|
return { path: target };
|
|
572
853
|
});
|
|
854
|
+
registerSourceRootResolve(build, hostDir);
|
|
573
855
|
build.onResolve({ filter: /core\/client\/engine\// }, (args) => {
|
|
574
856
|
if (!args.importer.includes("soma-core")) {
|
|
575
857
|
throw new Error(
|
|
@@ -585,6 +867,52 @@ function createBrowserClientPlugin(options) {
|
|
|
585
867
|
}
|
|
586
868
|
return void 0;
|
|
587
869
|
});
|
|
870
|
+
build.onResolve({ filter: /^echarts(?:\/.*)?$/ }, async (args) => {
|
|
871
|
+
if (args.pluginData?.skipEchartsStub) return void 0;
|
|
872
|
+
const resolveOpts = {
|
|
873
|
+
resolveDir: args.resolveDir,
|
|
874
|
+
kind: args.kind,
|
|
875
|
+
importer: args.importer,
|
|
876
|
+
pluginData: { skipEchartsStub: true }
|
|
877
|
+
};
|
|
878
|
+
const resolved = await build.resolve(args.path, resolveOpts);
|
|
879
|
+
if (resolved.errors.length === 0 && resolved.path) {
|
|
880
|
+
return { path: resolved.path };
|
|
881
|
+
}
|
|
882
|
+
const bare = args.path === "echarts" ? resolved : await build.resolve("echarts", resolveOpts);
|
|
883
|
+
if (bare.errors.length === 0 && bare.path) {
|
|
884
|
+
return { errors: resolved.errors };
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
path: args.path,
|
|
888
|
+
namespace: "soma-optional-echarts-stub"
|
|
889
|
+
};
|
|
890
|
+
});
|
|
891
|
+
build.onLoad({ filter: /.*/, namespace: "soma-optional-echarts-stub" }, () => ({
|
|
892
|
+
contents: `
|
|
893
|
+
// \u672A\u5B89\u88C5\u53EF\u9009\u4F9D\u8D56 echarts \u65F6\u7684\u65E0\u5934\u6869\uFF1A\u9996\u6B21 init() \u63D0\u793A\u4E00\u6B21\uFF0C\u56FE\u8868\u4E0D\u6E32\u67D3
|
|
894
|
+
let warned = false;
|
|
895
|
+
export const SVGRenderer = {};
|
|
896
|
+
export function use() {}
|
|
897
|
+
export function init() {
|
|
898
|
+
if (!warned) {
|
|
899
|
+
warned = true;
|
|
900
|
+
console.warn('\u672A\u5B89\u88C5\u53EF\u9009\u4F9D\u8D56 echarts\uFF0C\u56FE\u8868\u4E0D\u4F1A\u6E32\u67D3\uFF1Anpm i echarts');
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
setOption() {},
|
|
904
|
+
dispatchAction() {},
|
|
905
|
+
on() {},
|
|
906
|
+
off() {},
|
|
907
|
+
resize() {},
|
|
908
|
+
dispose() {},
|
|
909
|
+
getModel() { return { getSeriesByIndex() { return undefined; } }; },
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
export default { SVGRenderer, use, init };
|
|
913
|
+
`,
|
|
914
|
+
loader: "js"
|
|
915
|
+
}));
|
|
588
916
|
}
|
|
589
917
|
};
|
|
590
918
|
}
|
|
@@ -772,6 +1100,7 @@ async function buildServerAot(options) {
|
|
|
772
1100
|
const subpath = args.path.replace(/^@soma-host\/?/, "");
|
|
773
1101
|
return { path: resolveModuleFile(webRoot, subpath) };
|
|
774
1102
|
});
|
|
1103
|
+
registerSourceRootResolve(build, hostDir, options.env);
|
|
775
1104
|
build.onResolve({ filter: /^@soma-api(?:\/.*)?$/ }, (args) => {
|
|
776
1105
|
const subpath = args.path.replace(/^@soma-api\/?/, "");
|
|
777
1106
|
return { path: resolveModuleFile(apiRoot, subpath) };
|