soma-core 1.5.1 → 2.0.0
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/app/SomaPageClient.tsx +28 -9
- package/app/soma/manifest/route.ts +3 -0
- package/bin/migrate.cjs +71 -1
- package/bin/soma-lsp.cjs +8 -1
- package/core/build/blocks/block-compile.ts +23 -5
- package/core/build/compiler/full-manifest-builder.ts +15 -0
- package/core/build/compiler/page-assets.ts +17 -1
- package/core/build/compiler/page-declaration-compiler.ts +67 -11
- package/core/build/compiler/precompiled-manifest-loader.ts +7 -0
- package/core/build/compiler/soma-manifest-webpack-plugin.js +7 -0
- package/core/build/compiler/soma-precompile.js +212 -21
- package/core/build/component/package-loader.ts +35 -4
- package/core/build/component-tree/artifact-codec.ts +192 -0
- package/core/build/component-tree/binding-bridge.ts +272 -0
- package/core/build/component-tree/collection-binding-lowerer.ts +65 -0
- package/core/build/component-tree/definition-preparation.ts +320 -0
- package/core/build/component-tree/migration-files.ts +214 -0
- package/core/build/component-tree/migration.ts +170 -0
- package/core/build/component-tree/parser.ts +362 -0
- package/core/build/component-tree/registry-snapshot.ts +317 -0
- package/core/build/component-tree/source-preflight.ts +132 -0
- package/core/build/component-tree/structure-topology.ts +63 -0
- package/core/build/component-tree/validator.ts +318 -0
- package/core/build/eject/component-eject.ts +1 -0
- package/core/build/lsp/component-tree-service.ts +79 -0
- package/core/build/lsp/component-tree.cjs +42 -0
- package/core/build/lsp/cross-file-diagnostics.cjs +15 -3
- package/core/build/lsp/extra-completion.cjs +7 -0
- package/core/client/adaptive/observer-pool.ts +122 -8
- package/core/client/compiler/manifest-compiler.ts +48 -5
- package/core/client/component/ai-catalog.ts +41 -3
- package/core/client/component/catalog-examples.ts +60 -0
- package/core/client/component/component-defaults.ts +1 -1
- package/core/client/component/component-definition.types.ts +9 -0
- package/core/client/component/component-expander.ts +22 -6
- package/core/client/component/component-manager.ts +881 -45
- package/core/client/component/component-pack.ts +1 -1
- package/core/client/component/component-registry.ts +11 -2
- package/core/client/component/scoped-adapter.ts +29 -2
- package/core/client/component/structure-adapter.ts +207 -0
- package/core/client/component/verify-pack.ts +21 -1
- package/core/client/container/SomaContainerAdapter.ts +103 -2
- package/core/client/data/data-object-resolver.ts +45 -1
- package/core/client/engine/asset-resolver.ts +1 -1
- package/core/client/engine/dom-renderer.ts +712 -26
- package/core/client/engine/event-engine.ts +328 -21
- package/core/client/engine/property-watcher.ts +164 -18
- package/core/client/engine/reactive-proxy.ts +194 -23
- package/core/client/engine/render-engine.ts +120 -11
- package/core/client/engine/row-range.ts +62 -0
- package/core/client/engine/row-scope.ts +77 -0
- package/core/client/engine/runtime-builder.ts +2 -0
- package/core/client/engine/scope-resolver.ts +3 -3
- package/core/client/engine/soma-bootstrap.ts +176 -17
- package/core/client/parser/adaptive-parser.ts +1 -1
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/page-parser.ts +53 -3
- package/core/client/parser/blocks/use-parser.ts +21 -6
- package/core/client/parser/data-config-parser.ts +1 -1
- package/core/client/parser/pipeline-parser.ts +252 -15
- package/core/client/parser/style-config-parser.ts +1 -1
- package/core/client/parser/timer-parser.ts +1 -1
- package/core/client/parser/trigger-parser.ts +1 -1
- package/core/client/parser/ui-config-parser.ts +39 -7
- package/core/client/pipes/pipe-registry.ts +45 -4
- package/core/client/registry/declaration-renderer.ts +32 -24
- package/core/client/registry/remote-page.ts +1 -1
- package/core/client/runtime/SomaSnapshotStore.ts +1 -1
- package/core/client/scheduler/SomaScheduler.ts +1 -1
- package/core/client/security/attribute-presence.ts +3 -0
- package/core/client/theme/harmony.ts +135 -13
- package/core/client/theme/scene-tokens.ts +17 -2
- package/core/client/theme/theme-axes.ts +43 -6
- package/core/client/theme/theme-engine.ts +921 -126
- package/core/client/validation/contract-validator.ts +2 -2
- package/core/index.ts +3 -0
- package/core/server/host/page-markup-config.ts +42 -0
- package/core/server/host/published-page-artifact-cache.ts +36 -4
- package/core/server/host/published-page-assets.ts +13 -7
- package/core/server/host/resolve-host-tree-context.ts +43 -0
- package/core/server/host/server-page-assets.ts +23 -4
- package/core/server/host/soma-page-compile.ts +10 -0
- package/core/server/mock/node/cli.mjs +3 -3
- package/core/server/page-declaration.ts +7 -0
- package/core/server/registry/declaration-precompiler.ts +35 -3
- package/core/server/registry/page-registry-repository.ts +31 -3
- package/core/server/registry/page-registry-store.ts +64 -7
- package/core/server/registry/publish-asset-pin.ts +6 -1
- package/core/server/registry/services/pages/Get.ts +11 -6
- package/core/server/registry/validation/compile-gate.ts +10 -1
- package/core/shared/component-tree-artifact.ts +237 -0
- package/core/shared/component-tree-errors.ts +52 -0
- package/core/shared/path-algebra.ts +1 -1
- package/core/shared/types/component-contract.types.ts +51 -0
- package/core/shared/types/component-tree-artifact.types.ts +121 -0
- package/core/shared/types/component-tree.types.ts +170 -0
- package/core/shared/types/engine.types.ts +5 -0
- package/core/shared/types/event.types.ts +8 -4
- package/core/shared/types/manifest.types.ts +4 -0
- package/core/shared/types/ui-config.types.ts +8 -0
- package/dist/cli/soma.js +1 -1
- package/dist/core/index.cjs +14508 -11358
- package/dist/lsp/component-tree.cjs +20997 -0
- package/dist/types/build/blocks/block-compile.d.ts +10 -1
- package/dist/types/build/compiler/full-manifest-builder.d.ts +9 -0
- package/dist/types/build/compiler/page-assets.d.ts +6 -1
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +11 -1
- package/dist/types/build/component/package-loader.d.ts +4 -1
- package/dist/types/build/component-tree/artifact-codec.d.ts +50 -0
- package/dist/types/build/component-tree/binding-bridge.d.ts +19 -0
- package/dist/types/build/component-tree/collection-binding-lowerer.d.ts +18 -0
- package/dist/types/build/component-tree/definition-preparation.d.ts +11 -0
- package/dist/types/build/component-tree/migration-files.d.ts +35 -0
- package/dist/types/build/component-tree/migration.d.ts +28 -0
- package/dist/types/build/component-tree/parser.d.ts +13 -0
- package/dist/types/build/component-tree/registry-snapshot.d.ts +15 -0
- package/dist/types/build/component-tree/source-preflight.d.ts +22 -0
- package/dist/types/build/component-tree/structure-topology.d.ts +7 -0
- package/dist/types/build/component-tree/validator.d.ts +9 -0
- package/dist/types/build/lsp/component-tree-service.d.ts +34 -0
- package/dist/types/client/adaptive/observer-pool.d.ts +9 -2
- package/dist/types/client/compiler/manifest-compiler.d.ts +11 -2
- package/dist/types/client/component/ai-catalog.d.ts +18 -1
- package/dist/types/client/component/catalog-examples.d.ts +18 -0
- package/dist/types/client/component/component-definition.types.d.ts +9 -0
- package/dist/types/client/component/component-expander.d.ts +2 -1
- package/dist/types/client/component/component-manager.d.ts +97 -0
- package/dist/types/client/component/scoped-adapter.d.ts +1 -0
- package/dist/types/client/component/structure-adapter.d.ts +17 -0
- package/dist/types/client/container/SomaContainerAdapter.d.ts +8 -0
- package/dist/types/client/data/data-object-resolver.d.ts +19 -0
- package/dist/types/client/engine/dom-renderer.d.ts +125 -2
- package/dist/types/client/engine/event-engine.d.ts +62 -3
- package/dist/types/client/engine/property-watcher.d.ts +41 -1
- package/dist/types/client/engine/reactive-proxy.d.ts +42 -2
- package/dist/types/client/engine/render-engine.d.ts +55 -3
- package/dist/types/client/engine/row-range.d.ts +13 -0
- package/dist/types/client/engine/row-scope.d.ts +20 -0
- package/dist/types/client/engine/runtime-builder.d.ts +1 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +4 -1
- package/dist/types/client/parser/blocks/use-parser.d.ts +18 -0
- package/dist/types/client/parser/pipeline-parser.d.ts +12 -4
- package/dist/types/client/parser/ui-config-parser.d.ts +2 -0
- package/dist/types/client/pipes/pipe-registry.d.ts +39 -1
- package/dist/types/client/registry/declaration-renderer.d.ts +5 -1
- package/dist/types/client/registry/remote-page.d.ts +1 -1
- package/dist/types/client/theme/harmony.d.ts +44 -2
- package/dist/types/client/theme/scene-tokens.d.ts +11 -1
- package/dist/types/client/theme/theme-axes.d.ts +36 -6
- package/dist/types/index.d.ts +3 -1
- package/dist/types/server/host/page-markup-config.d.ts +6 -0
- package/dist/types/server/host/published-page-artifact-cache.d.ts +9 -1
- package/dist/types/server/host/published-page-assets.d.ts +5 -3
- package/dist/types/server/host/resolve-host-tree-context.d.ts +8 -0
- package/dist/types/server/host/server-page-assets.d.ts +6 -0
- package/dist/types/server/host/soma-page-compile.d.ts +10 -1
- package/dist/types/server/page-declaration.d.ts +6 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +8 -3
- package/dist/types/server/registry/page-registry-repository.d.ts +5 -0
- package/dist/types/server/registry/page-registry-store.d.ts +11 -1
- package/dist/types/server/registry/publish-asset-pin.d.ts +4 -0
- package/dist/types/server/registry/validation/compile-gate.d.ts +4 -1
- package/dist/types/shared/component-tree-artifact.d.ts +5 -0
- package/dist/types/shared/component-tree-errors.d.ts +22 -0
- package/dist/types/shared/types/component-contract.types.d.ts +42 -0
- package/dist/types/shared/types/component-tree-artifact.types.d.ts +104 -0
- package/dist/types/shared/types/component-tree.types.d.ts +149 -0
- package/dist/types/shared/types/engine.types.d.ts +5 -0
- package/dist/types/shared/types/event.types.d.ts +8 -4
- package/dist/types/shared/types/manifest.types.d.ts +4 -0
- package/dist/types/shared/types/ui-config.types.d.ts +8 -0
- package/package.json +5 -4
- package/dist/preview-export.cjs +0 -3401
|
@@ -3184,7 +3184,7 @@ var SOMA_ADAPTIVE_MAX_LADDER = 5;
|
|
|
3184
3184
|
var SomaAdaptiveConfigError = class extends Error {
|
|
3185
3185
|
constructor(message, path = "") {
|
|
3186
3186
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
3187
|
-
super(`[
|
|
3187
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
3188
3188
|
this.name = "SomaAdaptiveConfigError";
|
|
3189
3189
|
this.path = path;
|
|
3190
3190
|
}
|
|
@@ -3523,7 +3523,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
3523
3523
|
var SomaUiConfigError = class extends Error {
|
|
3524
3524
|
constructor(message, path = "") {
|
|
3525
3525
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
3526
|
-
super(`[
|
|
3526
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
3527
3527
|
this.name = "SomaUiConfigError";
|
|
3528
3528
|
this.path = path;
|
|
3529
3529
|
}
|
|
@@ -3547,6 +3547,15 @@ function validateBind(bind, path) {
|
|
|
3547
3547
|
if ("onChange" in bind && bind.onChange !== void 0) {
|
|
3548
3548
|
parseOnChangeRules(bind.onChange, `${path}.onChange`);
|
|
3549
3549
|
}
|
|
3550
|
+
if (bind.key !== void 0 && (typeof bind.key !== "string" || !bind.key.startsWith(`${bind.var}.`) || !/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)+$/.test(bind.key) || bind.key.split(".").some((part) => ["__proto__", "prototype", "constructor"].includes(part)))) {
|
|
3551
|
+
throw new SomaUiConfigError("bind.key \u5FC5\u987B\u662F\u5F53\u524D\u884C\u53D8\u91CF\u7684\u5B89\u5168\u5B57\u6BB5\u8DEF\u5F84", path);
|
|
3552
|
+
}
|
|
3553
|
+
if (bind.repeatPlanId !== void 0 && (typeof bind.repeatPlanId !== "string" || !bind.repeatPlanId.trim() || bind.key !== void 0 || bind.collectionSlot !== void 0)) {
|
|
3554
|
+
throw new SomaUiConfigError("repeatPlanId \u5FC5\u987B\u662F\u975E\u7A7A\u5F15\u7528\u4E14\u4E0D\u80FD\u4E0E key/collectionSlot \u53CC\u5199", path);
|
|
3555
|
+
}
|
|
3556
|
+
if (bind.collectionSlot !== void 0 && (typeof bind.collectionSlot !== "string" || !bind.collectionSlot.trim() || bind.key === void 0)) {
|
|
3557
|
+
throw new SomaUiConfigError("collectionSlot \u5FC5\u987B\u5177\u540D\u5E76\u63D0\u4F9B\u552F\u4E00\u663E\u5F0F key", path);
|
|
3558
|
+
}
|
|
3550
3559
|
}
|
|
3551
3560
|
function parseOnChangeRules(raw, path) {
|
|
3552
3561
|
if (!Array.isArray(raw)) {
|
|
@@ -3604,7 +3613,7 @@ function isExtendedShowValue(value) {
|
|
|
3604
3613
|
const extendedKeys = ["text", "model", "when", "class", "show", "props"];
|
|
3605
3614
|
return extendedKeys.some((key) => key in value);
|
|
3606
3615
|
}
|
|
3607
|
-
function parseShowMapping(rawShow, path) {
|
|
3616
|
+
function parseShowMapping(rawShow, path, options) {
|
|
3608
3617
|
if (!rawShow || typeof rawShow !== "object") {
|
|
3609
3618
|
throw new SomaUiConfigError(`show \u5FC5\u987B\u662F\u5BF9\u8C61`, path);
|
|
3610
3619
|
}
|
|
@@ -3617,20 +3626,32 @@ function parseShowMapping(rawShow, path) {
|
|
|
3617
3626
|
if (typeof value === "string") {
|
|
3618
3627
|
result[key] = value;
|
|
3619
3628
|
} else if (/^item:.+/.test(key) && typeof value === "object" && value !== null && !isNestedShowMapping(value) && !isExtendedShowValue(value)) {
|
|
3620
|
-
result[key] = { show: parseShowMapping(value, currentPath) };
|
|
3629
|
+
result[key] = { show: parseShowMapping(value, currentPath, options) };
|
|
3621
3630
|
} else if (isNestedShowMapping(value)) {
|
|
3622
3631
|
const nestedPath = `${currentPath}.bind`;
|
|
3623
3632
|
validateBind(value.bind, nestedPath);
|
|
3633
|
+
if (value.bind.collectionSlot !== void 0 && options?.collectionBindingStage !== "definition-source") {
|
|
3634
|
+
throw new SomaUiConfigError("collectionSlot \u4EC5\u5141\u8BB8\u53D7\u4FE1\u7EC4\u4EF6\u5B9A\u4E49\u6E90\uFF1B\u8FD0\u884C\u65F6\u5FC5\u987B\u4F7F\u7528\u51C6\u5907\u8BA1\u5212", nestedPath);
|
|
3635
|
+
}
|
|
3624
3636
|
const nested = {
|
|
3625
3637
|
bind: {
|
|
3626
3638
|
obj: value.bind.obj,
|
|
3627
3639
|
var: value.bind.var,
|
|
3628
|
-
...typeof value.bind.role_by === "string" ? { role_by: value.bind.role_by } : {}
|
|
3640
|
+
...typeof value.bind.role_by === "string" ? { role_by: value.bind.role_by } : {},
|
|
3641
|
+
...value.bind.key !== void 0 ? { key: value.bind.key } : {},
|
|
3642
|
+
...value.bind.repeatPlanId !== void 0 ? { repeatPlanId: value.bind.repeatPlanId } : {},
|
|
3643
|
+
...value.bind.collectionSlot !== void 0 ? { collectionSlot: value.bind.collectionSlot } : {}
|
|
3629
3644
|
},
|
|
3630
|
-
show: parseShowMapping(value.show, `${currentPath}.show
|
|
3645
|
+
show: parseShowMapping(value.show, `${currentPath}.show`, options),
|
|
3631
3646
|
// when 与 bind 同处一层:整块显隐(列表在错误/加载态整体隐藏靠它)
|
|
3632
3647
|
...typeof value.when === "string" ? { when: value.when } : {}
|
|
3633
3648
|
};
|
|
3649
|
+
if (value.props !== void 0) {
|
|
3650
|
+
if (!value.props || typeof value.props !== "object" || Array.isArray(value.props)) {
|
|
3651
|
+
throw new SomaUiConfigError("props \u5FC5\u987B\u662F\u5BF9\u8C61", currentPath);
|
|
3652
|
+
}
|
|
3653
|
+
nested.props = { ...value.props };
|
|
3654
|
+
}
|
|
3634
3655
|
result[key] = nested;
|
|
3635
3656
|
} else if (typeof value === "object" && value !== null && isExtendedShowValue(value)) {
|
|
3636
3657
|
const extended = {};
|
|
@@ -3681,7 +3702,7 @@ function parseShowMapping(rawShow, path) {
|
|
|
3681
3702
|
extended.class = classMap;
|
|
3682
3703
|
}
|
|
3683
3704
|
if ("show" in value && value.show !== void 0) {
|
|
3684
|
-
extended.show = parseShowMapping(value.show, `${currentPath}.show
|
|
3705
|
+
extended.show = parseShowMapping(value.show, `${currentPath}.show`, options);
|
|
3685
3706
|
}
|
|
3686
3707
|
if ("props" in value && value.props !== void 0) {
|
|
3687
3708
|
if (typeof value.props !== "object" || value.props === null || Array.isArray(value.props)) {
|
|
@@ -3737,7 +3758,10 @@ function parseUiConfig(raw, options) {
|
|
|
3737
3758
|
if (Array.isArray(raw.bind.onChange)) {
|
|
3738
3759
|
bind.onChange = parseOnChangeRules(raw.bind.onChange, "bind.onChange");
|
|
3739
3760
|
}
|
|
3740
|
-
|
|
3761
|
+
if (raw.bind.key !== void 0 || raw.bind.repeatPlanId !== void 0 || raw.bind.collectionSlot !== void 0) {
|
|
3762
|
+
throw new SomaUiConfigError("\u9876\u5C42 bind \u4E0D\u63A5\u53D7\u96C6\u5408\u884C\u5B57\u6BB5", "bind");
|
|
3763
|
+
}
|
|
3764
|
+
const show = parseShowMapping(raw.show, "show", options);
|
|
3741
3765
|
const config = { bind, show };
|
|
3742
3766
|
if ("initProps" in raw && raw.initProps !== void 0) {
|
|
3743
3767
|
config.initProps = parseInitProps(raw.initProps, "initProps");
|
|
@@ -4381,7 +4405,7 @@ var VALID_KEY_MODIFIER_NAMES = new Set(Object.keys(SOMA_KEY_MODIFIERS));
|
|
|
4381
4405
|
// core/client/parser/pipeline-parser.ts
|
|
4382
4406
|
var SomaEventParseError = class extends Error {
|
|
4383
4407
|
constructor(message, rawExpression) {
|
|
4384
|
-
super(`[
|
|
4408
|
+
super(`[soma-core][\u5F15\u64CE] ${message} \u2014 \u539F\u59CB\u8868\u8FBE\u5F0F: "${rawExpression}"`);
|
|
4385
4409
|
this.name = "SomaEventParseError";
|
|
4386
4410
|
this.rawExpression = rawExpression;
|
|
4387
4411
|
}
|
|
@@ -4400,6 +4424,8 @@ var VALID_DOM_EVENTS = /* @__PURE__ */ new Set([
|
|
|
4400
4424
|
"change",
|
|
4401
4425
|
"blur",
|
|
4402
4426
|
"focus",
|
|
4427
|
+
"focusin",
|
|
4428
|
+
"focusout",
|
|
4403
4429
|
"mouseenter",
|
|
4404
4430
|
"mouseleave",
|
|
4405
4431
|
"submit",
|
|
@@ -4416,6 +4442,54 @@ var VALID_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
4416
4442
|
"select"
|
|
4417
4443
|
]);
|
|
4418
4444
|
var EMIT_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
4445
|
+
var HOVER_ALTERNATIVE = "\u60AC\u505C\u6837\u5F0F\u7528 Style transitions \u7684 hover\uFF1B\u60AC\u505C\u624D\u51FA\u73B0\u7684\u63D0\u793A\u6216\u9762\u677F\u7528 click\u3001focusin / focusout\uFF0C\u6216 Tooltip \u7EC4\u4EF6";
|
|
4446
|
+
var CONTROLLER_ALTERNATIVE = "\u5C01\u88C5\u6210\u7EC4\u4EF6\uFF0C\u7531\u63A7\u5236\u5668\u628A\u76D1\u542C\u76F4\u63A5\u6302\u5230\u5143\u7D20\u4E0A\uFF0C\u518D\u7ECF\u5951\u7EA6 emit \u4E0A\u62A5";
|
|
4447
|
+
function hintGroup(names, hint) {
|
|
4448
|
+
return names.map((name) => [name, hint]);
|
|
4449
|
+
}
|
|
4450
|
+
var UNLISTED_DOM_EVENT_HINTS = new Map([
|
|
4451
|
+
...hintGroup(
|
|
4452
|
+
["mouseover", "mouseout", "pointerover", "pointerout"],
|
|
4453
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u4F46\u6307\u9488\u5728\u951A\u70B9\u5185\u7684\u5B50\u5143\u7D20\u4E4B\u95F4\u79FB\u52A8\u65F6\u4F1A\u53CD\u590D\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${HOVER_ALTERNATIVE}`
|
|
4454
|
+
),
|
|
4455
|
+
...hintGroup(
|
|
4456
|
+
["pointerenter", "pointerleave"],
|
|
4457
|
+
`\u4E0D\u5192\u6CE1\uFF0C\u5185\u5C42\u951A\u70B9\u4E0A\u7684\u58F0\u660E\u6C38\u8FDC\u4E0D\u4F1A\u6267\u884C\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${HOVER_ALTERNATIVE}`
|
|
4458
|
+
),
|
|
4459
|
+
...hintGroup(
|
|
4460
|
+
["mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"],
|
|
4461
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 click\uFF1B\u786E\u5B9E\u8981\u533A\u5206\u6309\u4E0B\u4E0E\u62AC\u8D77\u65F6${CONTROLLER_ALTERNATIVE}`
|
|
4462
|
+
),
|
|
4463
|
+
...hintGroup(
|
|
4464
|
+
["mousemove", "pointermove", "touchmove", "wheel"],
|
|
4465
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u6BCF\u6B21\u6D3E\u53D1\u90FD\u6267\u884C\u4E00\u904D Pipeline\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
4466
|
+
),
|
|
4467
|
+
...hintGroup(
|
|
4468
|
+
[
|
|
4469
|
+
"contextmenu",
|
|
4470
|
+
"auxclick",
|
|
4471
|
+
"pointercancel",
|
|
4472
|
+
"touchcancel",
|
|
4473
|
+
"dragstart",
|
|
4474
|
+
"dragend",
|
|
4475
|
+
"dragenter",
|
|
4476
|
+
"dragleave",
|
|
4477
|
+
"dragover",
|
|
4478
|
+
"animationend",
|
|
4479
|
+
"transitionend"
|
|
4480
|
+
],
|
|
4481
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
4482
|
+
),
|
|
4483
|
+
...hintGroup(
|
|
4484
|
+
["scrollend"],
|
|
4485
|
+
`\u5728\u5143\u7D20\u4E0A\u4E0D\u5192\u6CE1\uFF0C\u5185\u5C42\u951A\u70B9\u4E0A\u7684\u58F0\u660E\u6C38\u8FDC\u4E0D\u4F1A\u6267\u884C\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
4486
|
+
),
|
|
4487
|
+
...hintGroup(["keypress"], "\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\uFF0C\u4F46\u5DF2\u88AB\u6D4F\u89C8\u5668\u5F03\u7528\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 keydown"),
|
|
4488
|
+
...hintGroup(
|
|
4489
|
+
["beforeinput", "compositionstart", "compositionupdate", "compositionend"],
|
|
4490
|
+
"\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 input"
|
|
4491
|
+
)
|
|
4492
|
+
]);
|
|
4419
4493
|
function isStepsDeclaration(value) {
|
|
4420
4494
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.steps);
|
|
4421
4495
|
}
|
|
@@ -4437,7 +4511,26 @@ function collectWhenRoots(steps) {
|
|
|
4437
4511
|
}
|
|
4438
4512
|
var CONFIRM_PREFIX = "confirm:";
|
|
4439
4513
|
var PERMISSION_PREFIX = "permission:";
|
|
4514
|
+
var ACTION_PREFIX = "action:";
|
|
4440
4515
|
var FORCE_SEGMENT = "force";
|
|
4516
|
+
var NAMED_SEGMENT_PREFIXES = [CONFIRM_PREFIX, PERMISSION_PREFIX, ACTION_PREFIX];
|
|
4517
|
+
var NAMED_SEGMENT_SHAPE = /^[a-z][a-z0-9_]*:/;
|
|
4518
|
+
var POSITIONAL_ARITY = {
|
|
4519
|
+
NAV_STATIC: 1,
|
|
4520
|
+
NAV_ACTION: 2,
|
|
4521
|
+
UI_REFRESH: 1,
|
|
4522
|
+
ACTION: 1,
|
|
4523
|
+
UI_INTERACT: 3
|
|
4524
|
+
};
|
|
4525
|
+
var URL_SLOT = /* @__PURE__ */ new Map([
|
|
4526
|
+
["NAV_STATIC", 1],
|
|
4527
|
+
["NAV_ACTION", 2]
|
|
4528
|
+
]);
|
|
4529
|
+
var IMPLICIT_REFRESH_FUNC_PATH = /^[a-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)+$/;
|
|
4530
|
+
function unknownPrefixMessage(segment) {
|
|
4531
|
+
const name = segment.slice(0, segment.indexOf(":") + 1);
|
|
4532
|
+
return `\u672A\u77E5\u7684\u5177\u540D\u6BB5\u524D\u7F00 "${name}"\uFF0C\u53EF\u7528: ${NAMED_SEGMENT_PREFIXES.join(" / ")}\uFF08\u5199\u9519\u524D\u7F00\u7684\u6BB5\u4EE5\u524D\u88AB\u5F53\u6210\u4F4D\u7F6E\u503C\u5403\u6389\uFF1Aconfirm \u62FC\u9519\u4E00\u4E2A\u5B57\u6BCD\u5C31\u7B49\u4E8E\u6574\u6761\u786E\u8BA4\u6846\u6D88\u5931\uFF09`;
|
|
4533
|
+
}
|
|
4441
4534
|
var VALID_KEY_MODIFIERS = VALID_KEY_MODIFIER_NAMES;
|
|
4442
4535
|
function parseSelector(selector) {
|
|
4443
4536
|
const parts = selector.split(".");
|
|
@@ -4458,6 +4551,12 @@ function parseSelector(selector) {
|
|
|
4458
4551
|
selector
|
|
4459
4552
|
);
|
|
4460
4553
|
}
|
|
4554
|
+
const unlistedHint = UNLISTED_DOM_EVENT_HINTS.get(domEvent);
|
|
4555
|
+
if (unlistedHint) {
|
|
4556
|
+
console.warn(
|
|
4557
|
+
`[soma-core][\u5F15\u64CE] \u4E8B\u4EF6\u89E3\u6790 "${selector}"\uFF1A${domEvent} \u4E0D\u5728\u652F\u6301\u7684 DOM \u4E8B\u4EF6\u91CC\uFF0C\u6309\u7EC4\u4EF6\u5951\u7EA6 emit \u540D\u653E\u884C\uFF08\u89E3\u6790\u65F6\u770B\u4E0D\u5230\u7EC4\u4EF6\u6CE8\u518C\u8868\uFF0C\u5206\u4E0D\u6E05 ${somaId} \u662F\u4E0D\u662F\u7EC4\u4EF6\u5B9E\u4F8B\uFF09\u3002${somaId} \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u3001\u5951\u7EA6\u58F0\u660E\u4E86 emit "${domEvent}" \u65F6\u5FFD\u7565\u672C\u63D0\u793A\uFF1B\u5426\u5219\u4E0D\u8D70 emit \u8DEF\u7531\uFF0C\u5F15\u64CE\u6309\u539F\u751F\u4E8B\u4EF6\u540D\u539F\u6837\u59D4\u6258\u2014\u2014${domEvent} ${unlistedHint}\u3002\u652F\u6301\u7684 DOM \u4E8B\u4EF6: ${[...VALID_DOM_EVENTS].join(", ")}`
|
|
4558
|
+
);
|
|
4559
|
+
}
|
|
4461
4560
|
return { somaId, domEvent };
|
|
4462
4561
|
}
|
|
4463
4562
|
if (parts.length === 3) {
|
|
@@ -4488,6 +4587,7 @@ function splitOptionalSegments(parts) {
|
|
|
4488
4587
|
let confirm;
|
|
4489
4588
|
let refreshForce = false;
|
|
4490
4589
|
let permission;
|
|
4590
|
+
let action;
|
|
4491
4591
|
const segments = [];
|
|
4492
4592
|
for (let index = 0; index < parts.length; index++) {
|
|
4493
4593
|
const part = parts[index];
|
|
@@ -4511,17 +4611,67 @@ function splitOptionalSegments(parts) {
|
|
|
4511
4611
|
permission = code;
|
|
4512
4612
|
continue;
|
|
4513
4613
|
}
|
|
4614
|
+
if (index > 0 && part.startsWith(ACTION_PREFIX)) {
|
|
4615
|
+
const name = part.slice(ACTION_PREFIX.length).trim();
|
|
4616
|
+
if (!name) {
|
|
4617
|
+
throw new SomaEventParseError("action segment requires an action name", parts.join(" | "));
|
|
4618
|
+
}
|
|
4619
|
+
if (action !== void 0) {
|
|
4620
|
+
throw new SomaEventParseError(`\u5177\u540D\u6BB5 "action:" \u5199\u4E86\u4E24\u6B21`, parts.join(" | "));
|
|
4621
|
+
}
|
|
4622
|
+
action = name;
|
|
4623
|
+
continue;
|
|
4624
|
+
}
|
|
4514
4625
|
segments.push(part);
|
|
4515
4626
|
}
|
|
4516
|
-
return { segments, confirm, refreshForce, permission };
|
|
4627
|
+
return { segments, confirm, refreshForce, permission, action };
|
|
4628
|
+
}
|
|
4629
|
+
function assertSegmentShape(type2, parts, expression) {
|
|
4630
|
+
const arity = POSITIONAL_ARITY[type2];
|
|
4631
|
+
const urlSlot = URL_SLOT.get(type2);
|
|
4632
|
+
for (let slot = 1; slot < parts.length; slot++) {
|
|
4633
|
+
const value = parts[slot];
|
|
4634
|
+
if (slot !== urlSlot && NAMED_SEGMENT_SHAPE.test(value)) {
|
|
4635
|
+
throw new SomaEventParseError(unknownPrefixMessage(value), expression);
|
|
4636
|
+
}
|
|
4637
|
+
if (slot <= arity || !value) {
|
|
4638
|
+
continue;
|
|
4639
|
+
}
|
|
4640
|
+
throw new SomaEventParseError(
|
|
4641
|
+
`${type2} \u6700\u591A ${arity} \u4E2A\u53C2\u6570\u6BB5\uFF0C\u7B2C ${slot} \u6BB5 "${value}" \u6CA1\u6709\u5BF9\u5E94\u7684\u69FD\uFF08\u591A\u5199\u7684\u6BB5\u4EE5\u524D\u88AB\u9759\u9ED8\u4E22\u5F03\uFF0C\u73B0\u5728\u5F53\u573A\u62A5\u9519\uFF09`,
|
|
4642
|
+
expression
|
|
4643
|
+
);
|
|
4644
|
+
}
|
|
4517
4645
|
}
|
|
4518
4646
|
function parsePipelineBody(expression) {
|
|
4519
4647
|
const rawParts = expression.split("|").map((s) => s.trim());
|
|
4520
|
-
const {
|
|
4648
|
+
const {
|
|
4649
|
+
segments: parts,
|
|
4650
|
+
confirm,
|
|
4651
|
+
refreshForce,
|
|
4652
|
+
permission,
|
|
4653
|
+
action: namedAction
|
|
4654
|
+
} = splitOptionalSegments(rawParts);
|
|
4655
|
+
if (!VALID_TYPES.has(parts[0]) && IMPLICIT_REFRESH_FUNC_PATH.test(parts[0])) {
|
|
4656
|
+
parts.unshift("UI_REFRESH");
|
|
4657
|
+
}
|
|
4521
4658
|
const type2 = parts[0];
|
|
4522
4659
|
if (!VALID_TYPES.has(type2)) {
|
|
4523
4660
|
throw new SomaEventParseError(
|
|
4524
|
-
`\u672A\u77E5\u4E8B\u4EF6\u7C7B\u578B "${type2}"\uFF0C\u652F\u6301\u7684\u7C7B\u578B: ${[...VALID_TYPES].join(", ")}`,
|
|
4661
|
+
`\u672A\u77E5\u4E8B\u4EF6\u7C7B\u578B "${type2}"\uFF0C\u652F\u6301\u7684\u7C7B\u578B: ${[...VALID_TYPES].join(", ")}\uFF1B\u7701\u7565\u52A8\u8BCD\u6309 UI_REFRESH \u5904\u7406\uFF0C\u4F46\u9996\u6BB5\u987B\u662F\u5C0F\u5199\u8D77\u5934\u3001\u81F3\u5C11\u4E24\u6BB5\u7684 funcPath\uFF08\u5982 page.save\uFF09`,
|
|
4662
|
+
expression
|
|
4663
|
+
);
|
|
4664
|
+
}
|
|
4665
|
+
assertSegmentShape(type2, parts, expression);
|
|
4666
|
+
if (namedAction !== void 0 && type2 !== "UI_INTERACT") {
|
|
4667
|
+
throw new SomaEventParseError(
|
|
4668
|
+
`\u5177\u540D\u6BB5 "action:" \u53EA\u5C5E\u4E8E UI_INTERACT\uFF0C${type2} \u6CA1\u6709\u52A8\u4F5C\u69FD`,
|
|
4669
|
+
expression
|
|
4670
|
+
);
|
|
4671
|
+
}
|
|
4672
|
+
if (refreshForce && type2 !== "UI_REFRESH") {
|
|
4673
|
+
throw new SomaEventParseError(
|
|
4674
|
+
`\u53EF\u9009\u6BB5 "force" \u53EA\u5C5E\u4E8E UI_REFRESH\uFF08\u5168\u91CF\u6E32\u67D3\uFF09\uFF0C${type2} \u4E0A\u5199\u4E86\u4E0D\u4F1A\u751F\u6548`,
|
|
4525
4675
|
expression
|
|
4526
4676
|
);
|
|
4527
4677
|
}
|
|
@@ -4571,7 +4721,13 @@ function parsePipelineBody(expression) {
|
|
|
4571
4721
|
result.targetId = parts[1] || void 0;
|
|
4572
4722
|
result.funcPath = parts[2] || null;
|
|
4573
4723
|
{
|
|
4574
|
-
|
|
4724
|
+
if (namedAction !== void 0 && parts[3]) {
|
|
4725
|
+
throw new SomaEventParseError(
|
|
4726
|
+
`UI_INTERACT \u7684\u52A8\u4F5C\u540C\u65F6\u5199\u4E86\u5177\u540D\u6BB5 "action:${namedAction}" \u4E0E\u4F4D\u7F6E\u5F0F "${parts[3]}"\uFF0C\u53EA\u80FD\u7559\u4E00\u79CD`,
|
|
4727
|
+
expression
|
|
4728
|
+
);
|
|
4729
|
+
}
|
|
4730
|
+
const action = namedAction || parts[3] || "toggle";
|
|
4575
4731
|
if (!VALID_ACTIONS.has(action)) {
|
|
4576
4732
|
throw new SomaEventParseError(
|
|
4577
4733
|
`\u4E0D\u652F\u6301\u7684\u4EA4\u4E92\u52A8\u4F5C "${action}"\uFF0C\u652F\u6301\u7684\u52A8\u4F5C: ${[...VALID_ACTIONS].join(", ")}`,
|
|
@@ -4645,7 +4801,7 @@ function parseEventConfig(config, parentPath = []) {
|
|
|
4645
4801
|
// core/client/parser/timer-parser.ts
|
|
4646
4802
|
var SomaTimerParseError = class extends Error {
|
|
4647
4803
|
constructor(message) {
|
|
4648
|
-
super(`[
|
|
4804
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
4649
4805
|
this.name = "SomaTimerParseError";
|
|
4650
4806
|
}
|
|
4651
4807
|
};
|
|
@@ -4694,7 +4850,7 @@ function parseTimers(raw) {
|
|
|
4694
4850
|
// core/client/parser/trigger-parser.ts
|
|
4695
4851
|
var SomaTriggerParseError = class extends Error {
|
|
4696
4852
|
constructor(message) {
|
|
4697
|
-
super(`[
|
|
4853
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
4698
4854
|
this.name = "SomaTriggerParseError";
|
|
4699
4855
|
}
|
|
4700
4856
|
};
|
|
@@ -4760,7 +4916,7 @@ function splitEventConfigRaw(raw) {
|
|
|
4760
4916
|
var SomaStyleConfigError = class extends Error {
|
|
4761
4917
|
constructor(message, path = "", kind) {
|
|
4762
4918
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
4763
|
-
super(`[
|
|
4919
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
4764
4920
|
this.name = "SomaStyleConfigError";
|
|
4765
4921
|
this.path = path;
|
|
4766
4922
|
this.kind = kind;
|
|
@@ -5127,8 +5283,44 @@ var SomaPipeRegistry = class {
|
|
|
5127
5283
|
}
|
|
5128
5284
|
}
|
|
5129
5285
|
}
|
|
5130
|
-
/**
|
|
5286
|
+
/**
|
|
5287
|
+
* 链式应用(从左到右);单个管道异常时降级为原值字符串并告警,不中断渲染。
|
|
5288
|
+
*
|
|
5289
|
+
* **仓内零消费者,保留是因为它是对外公开 API**(`core/index.ts` 导出 `SomaPipeRegistry`,
|
|
5290
|
+
* 1.6.0 已发布)。四条内部路径——页面绑定(`dom-renderer.ts:441`)、行绑定
|
|
5291
|
+
* (`dom-renderer.ts:1351`)、组件 props(`component-manager.ts:1246`)、data transform
|
|
5292
|
+
* (`data-object-resolver.ts:728`)——2026-09 全部改走 `tryApply`,改的理由四处写得一样:
|
|
5293
|
+
* 本方法的告警**不带锚点、不带声明、不带 prop,而且每次重算都打一遍**,
|
|
5294
|
+
* 而失败时上屏的又是一个"看起来像格式化过"的原值字符串。
|
|
5295
|
+
* 谁在什么位置坏了,看控制台是看不出来的。
|
|
5296
|
+
*
|
|
5297
|
+
* 那删不删?**不删**:删它是对外 breaking change,而它的降级**是出声的**
|
|
5298
|
+
* (console.warn),不属于"猜错了还装作正确"那一类,外部 Host 想要"格式化失败也别炸"
|
|
5299
|
+
* 时它仍是一个诚实的选择。两者的差别取舍另见
|
|
5300
|
+
* 《soma 运行时引擎详设》§5.3「管道失败」,那里逐字写明了降级值相同、告警质量不同。
|
|
5301
|
+
*
|
|
5302
|
+
* **但仓内代码一律用 `tryApply`。** 这条规则目前**没有机器面**:
|
|
5303
|
+
* `verify-symbols` 的符号图不收类成员(`scripts/lib/symbol-graph.mjs` 文件头
|
|
5304
|
+
* "类成员不进图:类活着,全部成员体里的引用都算活"),所以它既不会把本方法报成
|
|
5305
|
+
* public-only、也不会拦住谁在仓内重新用起它——换句话说,重新引入这条差路是**不报错**的。
|
|
5306
|
+
* 想让它变成机器判定,最便宜的落点是 `scripts/` 下加一条 grep 式检查
|
|
5307
|
+
* (生产面禁止出现 `.apply(` 接 pipes 的调用),不是在这里加运行时开关。
|
|
5308
|
+
*/
|
|
5131
5309
|
apply(value, pipes, ctx) {
|
|
5310
|
+
const result = this.tryApply(value, pipes, ctx);
|
|
5311
|
+
if (!result.ok) {
|
|
5312
|
+
console.warn(`[soma-core][\u7BA1\u9053] \u7BA1\u9053 "${result.pipeName}" \u6267\u884C\u5931\u8D25:`, result.error);
|
|
5313
|
+
return String(value ?? "");
|
|
5314
|
+
}
|
|
5315
|
+
return result.value;
|
|
5316
|
+
}
|
|
5317
|
+
/**
|
|
5318
|
+
* 与 apply 同一条链式执行,区别只在管道函数抛错时:不告警、不降级,停在出错的那一段,
|
|
5319
|
+
* 把管道名与原始异常作为结果交回。失败的降级值与告警由调用方决定——
|
|
5320
|
+
* 组件 props 管道出错时按 undefined 下发,并点名实例锚点与 prop 告警(component-manager 的 resolvePipedProp)。
|
|
5321
|
+
* 其余与 apply 相同:未注册的管道照样在这里告警并跳过;绑定型实参读取(ctx.read)抛错不算管道失败,照样向外抛。
|
|
5322
|
+
*/
|
|
5323
|
+
tryApply(value, pipes, ctx) {
|
|
5132
5324
|
let current = value;
|
|
5133
5325
|
for (const pipe of pipes) {
|
|
5134
5326
|
const fn = this.fns.get(pipe.name);
|
|
@@ -5143,11 +5335,10 @@ var SomaPipeRegistry = class {
|
|
|
5143
5335
|
try {
|
|
5144
5336
|
current = fn(current, args, ctx);
|
|
5145
5337
|
} catch (error) {
|
|
5146
|
-
|
|
5147
|
-
return String(value ?? "");
|
|
5338
|
+
return { ok: false, pipeName: pipe.name, error };
|
|
5148
5339
|
}
|
|
5149
5340
|
}
|
|
5150
|
-
return String(current ?? "");
|
|
5341
|
+
return { ok: true, value: String(current ?? "") };
|
|
5151
5342
|
}
|
|
5152
5343
|
};
|
|
5153
5344
|
function localeText(ctx, key, fallback) {
|
|
@@ -6420,7 +6611,7 @@ function dictHash(fields) {
|
|
|
6420
6611
|
var SomaDataConfigError = class extends Error {
|
|
6421
6612
|
constructor(message, path = "") {
|
|
6422
6613
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
6423
|
-
super(`[
|
|
6614
|
+
super(`[soma-core][\u6570\u636E] ${message}${prefix}`);
|
|
6424
6615
|
this.name = "SomaDataConfigError";
|
|
6425
6616
|
this.path = path;
|
|
6426
6617
|
}
|
|
@@ -30,6 +30,9 @@ import {
|
|
|
30
30
|
type SomaComponentContract,
|
|
31
31
|
} from '../../shared/types/component-contract.types';
|
|
32
32
|
import type { SomaComponentDefinition } from '../../client/component/component-definition.types';
|
|
33
|
+
import { prepareComponentTreeDefinitions } from '../component-tree/definition-preparation';
|
|
34
|
+
import { canonicalTreeData } from '../component-tree/artifact-codec';
|
|
35
|
+
import type { ComponentTreeRegistryEntry } from '../component-tree/registry-snapshot';
|
|
33
36
|
|
|
34
37
|
export class SomaComponentPackageError extends Error {
|
|
35
38
|
/**
|
|
@@ -56,6 +59,8 @@ export interface PackScanWarning {
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
export interface LoadPackagesOptions {
|
|
62
|
+
/** Actual composed external dependencies for trusted collection preparation. */
|
|
63
|
+
componentTreeDependencies?: readonly ComponentTreeRegistryEntry[];
|
|
59
64
|
/**
|
|
60
65
|
* 警告汇总回调(缺省时汇总为单块 console.warn)。
|
|
61
66
|
* 刻意做成"扫描结束一次性给全部"而不是逐条打印:dev 服务器的滚动输出里,
|
|
@@ -74,8 +79,10 @@ interface PackageEntry {
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
/** 装载单个组件包目录 → 运行时定义(结构校验 fail fast) */
|
|
77
|
-
export function loadComponentPackage(packageDir: string): SomaComponentDefinition {
|
|
78
|
-
|
|
82
|
+
export function loadComponentPackage(packageDir: string, options: LoadPackagesOptions = {}): SomaComponentDefinition {
|
|
83
|
+
const entry = loadComponentPackageEntry(packageDir);
|
|
84
|
+
preparePackageEntries([entry], options);
|
|
85
|
+
return entry.definition;
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
/** 装载单个组件包目录 → 定义 + 样式 + 警告(供整包装载复用) */
|
|
@@ -94,16 +101,26 @@ export function loadComponentPackageEntry(packageDir: string): PackageEntry {
|
|
|
94
101
|
const contract = validateContract(rawContract, packageDir);
|
|
95
102
|
|
|
96
103
|
const templateHtml = fs.readFileSync(templatePath, 'utf-8').trim();
|
|
97
|
-
if (!templateHtml) {
|
|
104
|
+
if (!templateHtml && contract.structure?.kind !== 'fragment-macro') {
|
|
98
105
|
throw new SomaComponentPackageError('template.html 为空', packageDir);
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
const definition: SomaComponentDefinition = { contract, templateHtml };
|
|
109
|
+
const metadataPath = path.join(packageDir, 'definition.yaml');
|
|
110
|
+
if (fs.existsSync(metadataPath)) {
|
|
111
|
+
const raw = canonicalTreeData(yaml.load(fs.readFileSync(metadataPath, 'utf-8')));
|
|
112
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)
|
|
113
|
+
|| Object.keys(raw).some(key => !['structureAdapter', 'collectionSources'].includes(key))) {
|
|
114
|
+
throw new SomaComponentPackageError('definition.yaml 仅接受 structureAdapter/collectionSources 纯实现元信息', packageDir);
|
|
115
|
+
}
|
|
116
|
+
if (raw.structureAdapter !== undefined) definition.structureAdapter = raw.structureAdapter as unknown as SomaComponentDefinition['structureAdapter'];
|
|
117
|
+
if (raw.collectionSources !== undefined) definition.collectionSources = raw.collectionSources as unknown as SomaComponentDefinition['collectionSources'];
|
|
118
|
+
}
|
|
102
119
|
|
|
103
120
|
const uiPath = path.join(packageDir, 'ui.yaml');
|
|
104
121
|
if (fs.existsSync(uiPath)) {
|
|
105
122
|
try {
|
|
106
|
-
definition.uiConfig = parseUiConfig(yaml.load(fs.readFileSync(uiPath, 'utf-8')));
|
|
123
|
+
definition.uiConfig = parseUiConfig(yaml.load(fs.readFileSync(uiPath, 'utf-8')), { collectionBindingStage: 'definition-source' });
|
|
107
124
|
} catch (error) {
|
|
108
125
|
throw new SomaComponentPackageError(
|
|
109
126
|
`ui.yaml 非法: ${(error as Error).message}`,
|
|
@@ -193,9 +210,23 @@ export function scanComponentPackages(
|
|
|
193
210
|
}
|
|
194
211
|
|
|
195
212
|
reportWarnings(rootDir, entries.length, warnings, options.onWarning);
|
|
213
|
+
preparePackageEntries(entries, options);
|
|
196
214
|
return entries;
|
|
197
215
|
}
|
|
198
216
|
|
|
217
|
+
function preparePackageEntries(entries: PackageEntry[], options: LoadPackagesOptions): void {
|
|
218
|
+
const hasCollection = (value: unknown): boolean => {
|
|
219
|
+
if (!value || typeof value !== 'object') return false;
|
|
220
|
+
if ('collectionSlot' in value || 'repeatPlanId' in value) return true;
|
|
221
|
+
return Object.values(value).some(hasCollection);
|
|
222
|
+
};
|
|
223
|
+
if (!entries.some(entry => entry.definition.contract.structure || hasCollection(entry.definition.uiConfig))) return;
|
|
224
|
+
const all = [...(options.componentTreeDependencies ?? []), ...entries.map(entry => ({ definition: entry.definition }))];
|
|
225
|
+
const prepared = prepareComponentTreeDefinitions(all);
|
|
226
|
+
const byName = new Map(prepared.definitions.map(definition => [definition.contract.name, definition]));
|
|
227
|
+
for (const entry of entries) entry.definition = byName.get(entry.definition.contract.name)!;
|
|
228
|
+
}
|
|
229
|
+
|
|
199
230
|
/** 一次性汇总输出:逐条 warn 会淹没在 dev 服务器的滚动输出里 */
|
|
200
231
|
function reportWarnings(
|
|
201
232
|
rootDir: string,
|