soma-core 1.6.0 → 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/core/build/compiler/soma-precompile.js +182 -15
- package/core/build/eject/component-eject.ts +1 -0
- package/core/client/adaptive/observer-pool.ts +122 -8
- package/core/client/compiler/manifest-compiler.ts +46 -5
- package/core/client/component/component-defaults.ts +1 -1
- package/core/client/component/component-expander.ts +1 -1
- package/core/client/component/component-manager.ts +784 -35
- package/core/client/component/component-pack.ts +1 -1
- package/core/client/component/component-registry.ts +1 -1
- package/core/client/container/SomaContainerAdapter.ts +103 -2
- package/core/client/data/data-object-resolver.ts +45 -1
- package/core/client/engine/dom-renderer.ts +432 -29
- package/core/client/engine/event-engine.ts +301 -13
- 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 +118 -11
- package/core/client/engine/scope-resolver.ts +3 -3
- package/core/client/engine/soma-bootstrap.ts +31 -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 +44 -1
- 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 +1 -1
- package/core/client/pipes/pipe-registry.ts +45 -4
- 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 +1 -1
- package/core/server/mock/node/cli.mjs +3 -3
- package/core/shared/path-algebra.ts +1 -1
- package/core/shared/types/event.types.ts +8 -4
- package/dist/core/index.cjs +5411 -3507
- package/dist/lsp/component-tree.cjs +701 -511
- 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/component-manager.d.ts +86 -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 +110 -2
- package/dist/types/client/engine/event-engine.d.ts +61 -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 +54 -3
- 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/pipes/pipe-registry.d.ts +39 -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/shared/types/event.types.d.ts +8 -4
- package/package.json +4 -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
|
}
|
|
@@ -4405,7 +4405,7 @@ var VALID_KEY_MODIFIER_NAMES = new Set(Object.keys(SOMA_KEY_MODIFIERS));
|
|
|
4405
4405
|
// core/client/parser/pipeline-parser.ts
|
|
4406
4406
|
var SomaEventParseError = class extends Error {
|
|
4407
4407
|
constructor(message, rawExpression) {
|
|
4408
|
-
super(`[
|
|
4408
|
+
super(`[soma-core][\u5F15\u64CE] ${message} \u2014 \u539F\u59CB\u8868\u8FBE\u5F0F: "${rawExpression}"`);
|
|
4409
4409
|
this.name = "SomaEventParseError";
|
|
4410
4410
|
this.rawExpression = rawExpression;
|
|
4411
4411
|
}
|
|
@@ -4424,6 +4424,8 @@ var VALID_DOM_EVENTS = /* @__PURE__ */ new Set([
|
|
|
4424
4424
|
"change",
|
|
4425
4425
|
"blur",
|
|
4426
4426
|
"focus",
|
|
4427
|
+
"focusin",
|
|
4428
|
+
"focusout",
|
|
4427
4429
|
"mouseenter",
|
|
4428
4430
|
"mouseleave",
|
|
4429
4431
|
"submit",
|
|
@@ -4440,6 +4442,54 @@ var VALID_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
4440
4442
|
"select"
|
|
4441
4443
|
]);
|
|
4442
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
|
+
]);
|
|
4443
4493
|
function isStepsDeclaration(value) {
|
|
4444
4494
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.steps);
|
|
4445
4495
|
}
|
|
@@ -4461,7 +4511,26 @@ function collectWhenRoots(steps) {
|
|
|
4461
4511
|
}
|
|
4462
4512
|
var CONFIRM_PREFIX = "confirm:";
|
|
4463
4513
|
var PERMISSION_PREFIX = "permission:";
|
|
4514
|
+
var ACTION_PREFIX = "action:";
|
|
4464
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
|
+
}
|
|
4465
4534
|
var VALID_KEY_MODIFIERS = VALID_KEY_MODIFIER_NAMES;
|
|
4466
4535
|
function parseSelector(selector) {
|
|
4467
4536
|
const parts = selector.split(".");
|
|
@@ -4482,6 +4551,12 @@ function parseSelector(selector) {
|
|
|
4482
4551
|
selector
|
|
4483
4552
|
);
|
|
4484
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
|
+
}
|
|
4485
4560
|
return { somaId, domEvent };
|
|
4486
4561
|
}
|
|
4487
4562
|
if (parts.length === 3) {
|
|
@@ -4512,6 +4587,7 @@ function splitOptionalSegments(parts) {
|
|
|
4512
4587
|
let confirm;
|
|
4513
4588
|
let refreshForce = false;
|
|
4514
4589
|
let permission;
|
|
4590
|
+
let action;
|
|
4515
4591
|
const segments = [];
|
|
4516
4592
|
for (let index = 0; index < parts.length; index++) {
|
|
4517
4593
|
const part = parts[index];
|
|
@@ -4535,17 +4611,67 @@ function splitOptionalSegments(parts) {
|
|
|
4535
4611
|
permission = code;
|
|
4536
4612
|
continue;
|
|
4537
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
|
+
}
|
|
4538
4625
|
segments.push(part);
|
|
4539
4626
|
}
|
|
4540
|
-
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
|
+
}
|
|
4541
4645
|
}
|
|
4542
4646
|
function parsePipelineBody(expression) {
|
|
4543
4647
|
const rawParts = expression.split("|").map((s) => s.trim());
|
|
4544
|
-
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
|
+
}
|
|
4545
4658
|
const type2 = parts[0];
|
|
4546
4659
|
if (!VALID_TYPES.has(type2)) {
|
|
4547
4660
|
throw new SomaEventParseError(
|
|
4548
|
-
`\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`,
|
|
4549
4675
|
expression
|
|
4550
4676
|
);
|
|
4551
4677
|
}
|
|
@@ -4595,7 +4721,13 @@ function parsePipelineBody(expression) {
|
|
|
4595
4721
|
result.targetId = parts[1] || void 0;
|
|
4596
4722
|
result.funcPath = parts[2] || null;
|
|
4597
4723
|
{
|
|
4598
|
-
|
|
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";
|
|
4599
4731
|
if (!VALID_ACTIONS.has(action)) {
|
|
4600
4732
|
throw new SomaEventParseError(
|
|
4601
4733
|
`\u4E0D\u652F\u6301\u7684\u4EA4\u4E92\u52A8\u4F5C "${action}"\uFF0C\u652F\u6301\u7684\u52A8\u4F5C: ${[...VALID_ACTIONS].join(", ")}`,
|
|
@@ -4669,7 +4801,7 @@ function parseEventConfig(config, parentPath = []) {
|
|
|
4669
4801
|
// core/client/parser/timer-parser.ts
|
|
4670
4802
|
var SomaTimerParseError = class extends Error {
|
|
4671
4803
|
constructor(message) {
|
|
4672
|
-
super(`[
|
|
4804
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
4673
4805
|
this.name = "SomaTimerParseError";
|
|
4674
4806
|
}
|
|
4675
4807
|
};
|
|
@@ -4718,7 +4850,7 @@ function parseTimers(raw) {
|
|
|
4718
4850
|
// core/client/parser/trigger-parser.ts
|
|
4719
4851
|
var SomaTriggerParseError = class extends Error {
|
|
4720
4852
|
constructor(message) {
|
|
4721
|
-
super(`[
|
|
4853
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
4722
4854
|
this.name = "SomaTriggerParseError";
|
|
4723
4855
|
}
|
|
4724
4856
|
};
|
|
@@ -4784,7 +4916,7 @@ function splitEventConfigRaw(raw) {
|
|
|
4784
4916
|
var SomaStyleConfigError = class extends Error {
|
|
4785
4917
|
constructor(message, path = "", kind) {
|
|
4786
4918
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
4787
|
-
super(`[
|
|
4919
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
4788
4920
|
this.name = "SomaStyleConfigError";
|
|
4789
4921
|
this.path = path;
|
|
4790
4922
|
this.kind = kind;
|
|
@@ -5151,8 +5283,44 @@ var SomaPipeRegistry = class {
|
|
|
5151
5283
|
}
|
|
5152
5284
|
}
|
|
5153
5285
|
}
|
|
5154
|
-
/**
|
|
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
|
+
*/
|
|
5155
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) {
|
|
5156
5324
|
let current = value;
|
|
5157
5325
|
for (const pipe of pipes) {
|
|
5158
5326
|
const fn = this.fns.get(pipe.name);
|
|
@@ -5167,11 +5335,10 @@ var SomaPipeRegistry = class {
|
|
|
5167
5335
|
try {
|
|
5168
5336
|
current = fn(current, args, ctx);
|
|
5169
5337
|
} catch (error) {
|
|
5170
|
-
|
|
5171
|
-
return String(value ?? "");
|
|
5338
|
+
return { ok: false, pipeName: pipe.name, error };
|
|
5172
5339
|
}
|
|
5173
5340
|
}
|
|
5174
|
-
return String(current ?? "");
|
|
5341
|
+
return { ok: true, value: String(current ?? "") };
|
|
5175
5342
|
}
|
|
5176
5343
|
};
|
|
5177
5344
|
function localeText(ctx, key, fallback) {
|
|
@@ -6444,7 +6611,7 @@ function dictHash(fields) {
|
|
|
6444
6611
|
var SomaDataConfigError = class extends Error {
|
|
6445
6612
|
constructor(message, path = "") {
|
|
6446
6613
|
const prefix = path ? ` (\u8DEF\u5F84: ${path})` : "";
|
|
6447
|
-
super(`[
|
|
6614
|
+
super(`[soma-core][\u6570\u636E] ${message}${prefix}`);
|
|
6448
6615
|
this.name = "SomaDataConfigError";
|
|
6449
6616
|
this.path = path;
|
|
6450
6617
|
}
|
|
@@ -91,6 +91,7 @@ const IMPORT_REWRITES: Array<{ test: RegExp; to: (match: RegExpMatchArray) => st
|
|
|
91
91
|
// Host 安装,只有 package exports 中明确承诺的入口才能存活。未知内部模块在
|
|
92
92
|
// 这里 fail-closed,而不是为了当前本仓链接方便而悄悄变成公共 API。
|
|
93
93
|
{ test: /^\.\.\/adaptive\/(?:density-arbiter|layout-primitives)$/, to: () => 'soma-ui/adaptive' },
|
|
94
|
+
{ test: /^\.\.\/adaptive\/layout-constants$/, to: () => 'soma-ui/adaptive/layout-constants' },
|
|
94
95
|
{ test: /^\.\.\/adaptive\/field-components$/, to: () => 'soma-ui/adaptive/field-components' },
|
|
95
96
|
{ test: /^\.\.\/adaptive\/shape-infer$/, to: () => 'soma-ui/adaptive/shape-infer' },
|
|
96
97
|
{ test: /^\.\.\/adaptive\/shorthand-columns$/, to: () => 'soma-ui/adaptive/shorthand-columns' },
|
|
@@ -4,9 +4,18 @@
|
|
|
4
4
|
// 为什么不是每个作用域一个 RO:RO 实例本身有固定开销,几十个作用域就是几十个
|
|
5
5
|
// 独立的观察循环与几十次回调调度;单例把它们合并成一次回调、一个批次。
|
|
6
6
|
//
|
|
7
|
-
// 零主动测量:尺寸只来自回调自带的 contentRect
|
|
7
|
+
// 零主动测量:尺寸只来自回调自带的 entry(contentRect / borderBoxSize)。
|
|
8
8
|
// **不提供任何补测 API**——提供 getBoundingClientRect 之类的入口,
|
|
9
9
|
// 等于在性能契约上开了一个强制回流的口子,而口子一旦开就必然被用。
|
|
10
|
+
//
|
|
11
|
+
// 两个盒模型,两条独立的观察通道(`observe` 的 `box` 选项):
|
|
12
|
+
// * 内容盒(默认,不传即是,行为与历史逐字一致)——自适应作用域按它判档,
|
|
13
|
+
// 内边距不该算进"能摆多少内容"的可用宽度;
|
|
14
|
+
// * 边框盒(`{ box: 'border-box' }`)——虚拟列表按它算滚动几何,
|
|
15
|
+
// 一行在滚动条上占多少像素,就是它的边框盒那么多,内边距与边框一个都不能漏。
|
|
16
|
+
// 为什么不统一成一个:两者是**不同的量**,合成一个必然长期错着其中一边。
|
|
17
|
+
// 上一轮 VirtualList 就栽在这里——池子只给内容盒,行一有块向内边距,
|
|
18
|
+
// 记录的行高就比真实行盒小一圈,垫片、滚动条比例、跳转位置跟着一起偏。
|
|
10
19
|
|
|
11
20
|
export interface SomaAdaptiveSize {
|
|
12
21
|
width: number;
|
|
@@ -16,8 +25,17 @@ export interface SomaAdaptiveSize {
|
|
|
16
25
|
export type SomaAdaptiveSizeCallback = (size: SomaAdaptiveSize) => void;
|
|
17
26
|
|
|
18
27
|
export interface SomaAdaptiveObserverPool {
|
|
19
|
-
/**
|
|
20
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 订阅元素尺寸;返回退订函数(幂等,重复调用不抛错)。
|
|
30
|
+
* `options.box` 选盒模型:省略 = 内容盒(默认);`'border-box'` = 含内边距与边框的行盒。
|
|
31
|
+
* 选项类型就地写在签名里而不另立导出名:池子对外只该有一个 `observe`,
|
|
32
|
+
* 多一个导出符号就多一份要跟着走的对外契约。
|
|
33
|
+
*/
|
|
34
|
+
observe(
|
|
35
|
+
target: Element,
|
|
36
|
+
onSize: SomaAdaptiveSizeCallback,
|
|
37
|
+
options?: { box?: 'content-box' | 'border-box' },
|
|
38
|
+
): () => void;
|
|
21
39
|
}
|
|
22
40
|
|
|
23
41
|
const NOOP_UNSUBSCRIBE = (): void => {};
|
|
@@ -42,7 +60,80 @@ export function createAdaptiveObserverPool(): SomaAdaptiveObserverPool {
|
|
|
42
60
|
return singleton;
|
|
43
61
|
}
|
|
44
62
|
|
|
45
|
-
|
|
63
|
+
/** 通道的键:订阅方要的是哪个盒。一批回调里只算被订阅的那一种,另一种连读都不读。 */
|
|
64
|
+
type BoxKind = 'content-box' | 'border-box';
|
|
65
|
+
|
|
66
|
+
/** 内容盒:RO 自带,一字未动——这是历史上唯一的口径。 */
|
|
67
|
+
function contentBoxSizeOf(entry: ResizeObserverEntry): SomaAdaptiveSize {
|
|
68
|
+
const rect = entry.contentRect;
|
|
69
|
+
return { width: rect.width, height: rect.height };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 边框盒:优先用 `borderBoxSize`(Chrome 84+ / Firefox 92+ / Safari 15.4+,
|
|
74
|
+
* 也是本库目标浏览器的全部),拿不到再走计算样式降级。
|
|
75
|
+
*
|
|
76
|
+
* 逻辑轴 → 物理轴:RO 给的是 `inlineSize`/`blockSize`(随书写方向翻转),
|
|
77
|
+
* 池子对外给的是 `width`/`height`。判据不额外读样式,用同一个 entry 里的
|
|
78
|
+
* `contentBoxSize` 与 `contentRect` 对表:inlineSize 对不上物理宽度就是竖排,两轴互换。
|
|
79
|
+
*/
|
|
80
|
+
function borderBoxSizeOf(entry: ResizeObserverEntry): SomaAdaptiveSize {
|
|
81
|
+
const rect = entry.contentRect;
|
|
82
|
+
// 类型上这两个数组属性必有,实现上可能没有(老浏览器、单测里的假 RO),所以按可选读。
|
|
83
|
+
const optional = entry as unknown as {
|
|
84
|
+
borderBoxSize?: ReadonlyArray<{ inlineSize: number; blockSize: number }>;
|
|
85
|
+
contentBoxSize?: ReadonlyArray<{ inlineSize: number; blockSize: number }>;
|
|
86
|
+
};
|
|
87
|
+
// 注:Chrome 84–89 / Firefox 69–91 的 borderBoxSize 是单个对象而不是数组,这里按"拿不到"处理,
|
|
88
|
+
// 走下面的计算样式降级——结果一样对,只是多读一次样式,不值得为两个历史版本多一条分支。
|
|
89
|
+
const border = optional.borderBoxSize?.[0];
|
|
90
|
+
if (!border) return borderBoxFromStyle(entry.target, rect);
|
|
91
|
+
const content = optional.contentBoxSize?.[0];
|
|
92
|
+
const vertical = content !== undefined && Math.abs(content.inlineSize - rect.width) > 0.5;
|
|
93
|
+
return vertical
|
|
94
|
+
? { width: border.blockSize, height: border.inlineSize }
|
|
95
|
+
: { width: border.inlineSize, height: border.blockSize };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 降级路径(没有 `borderBoxSize` 时):内容盒 + 计算样式里的内边距与边框 = 边框盒。
|
|
100
|
+
*
|
|
101
|
+
* 命中的是两类环境:① 老浏览器(Safari < 15.4、Chrome < 84)——它们同样不认
|
|
102
|
+
* `observe(target, { box })`,于是只在内容盒变化时触发;单改内边距那一帧收不到通知,
|
|
103
|
+
* 下一次尺寸变化会补上,行高在此期间偏小,但不会错得比改动之前更多。
|
|
104
|
+
* ② 单测里的假 RO(jsdom 本身没有 RO,走的是上面的空池)——假 RO 通常只喂 contentRect。
|
|
105
|
+
*
|
|
106
|
+
* 为什么这里读计算样式不违反"零主动测量":RO 回调发生在布局之后,样式此刻是干净的,
|
|
107
|
+
* 读它不触发重排;本文件又把"先读完整批、再逐个回调"定死,回调里的写不会让同批次后面的读变贵。
|
|
108
|
+
* 连 getComputedStyle 都没有的环境退回内容盒——偏小,但与本次改动之前的行为一致,不抛错。
|
|
109
|
+
*/
|
|
110
|
+
function borderBoxFromStyle(target: Element, rect: DOMRectReadOnly): SomaAdaptiveSize {
|
|
111
|
+
// 内容盒为 0 = 元素当下没有盒(display:none、还没布局)。这种时候**不能**拿内边距与边框
|
|
112
|
+
// 凑出一个非零高度:调用方按"高度 > 0"判断行是否渲染完成(ERR-08),凭空给出 1px
|
|
113
|
+
// 会把一行没渲染的行当成量准了,几何直接被污染。现代浏览器的 borderBoxSize 此时也报 0。
|
|
114
|
+
if (rect.width === 0 && rect.height === 0) return { width: 0, height: 0 };
|
|
115
|
+
const view = target.ownerDocument?.defaultView;
|
|
116
|
+
if (!view || typeof view.getComputedStyle !== 'function') return { width: rect.width, height: rect.height };
|
|
117
|
+
const style = view.getComputedStyle(target);
|
|
118
|
+
const px = (value: string): number => {
|
|
119
|
+
const parsed = Number.parseFloat(value);
|
|
120
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
width: rect.width + px(style.paddingLeft) + px(style.paddingRight)
|
|
124
|
+
+ px(style.borderLeftWidth) + px(style.borderRightWidth),
|
|
125
|
+
height: rect.height + px(style.paddingTop) + px(style.paddingBottom)
|
|
126
|
+
+ px(style.borderTopWidth) + px(style.borderBottomWidth),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 一个盒模型一条通道:各自一个 RO、一张订阅表。
|
|
132
|
+
* 为什么不共用一个 RO:`observe(target, { box })` 是**按元素**记的,同一元素再 observe 一次
|
|
133
|
+
* 会覆盖上一次的盒模型——两类调用方撞到同一个元素时,后订阅的会把先订阅的触发口径改掉。
|
|
134
|
+
* 分成两条通道后互不相干,单例的成本承诺也还在(最多两个 RO,不随作用域数量增长)。
|
|
135
|
+
*/
|
|
136
|
+
function createBoxChannel(box: BoxKind): { observe(target: Element, onSize: SomaAdaptiveSizeCallback): () => void } {
|
|
46
137
|
/** 元素 → 该元素上的全部回调。WeakMap:元素被卸载即随之回收,无需调用方清场 */
|
|
47
138
|
const subscribers = new WeakMap<Element, Set<SomaAdaptiveSizeCallback>>();
|
|
48
139
|
let observer: ResizeObserver | null = null;
|
|
@@ -50,13 +141,20 @@ function createDomPool(): SomaAdaptiveObserverPool {
|
|
|
50
141
|
const ensureObserver = (): ResizeObserver => {
|
|
51
142
|
if (observer) return observer;
|
|
52
143
|
observer = new ResizeObserver((entries) => {
|
|
144
|
+
// 先把整批的尺寸读完,再逐个回调:回调里同步写样式是常见写法,
|
|
145
|
+
// 边读边发会让后面的读撞上被改脏的布局(边框盒的计算样式降级路径尤其吃这一下)。
|
|
146
|
+
const batch: Array<{ callbacks: SomaAdaptiveSizeCallback[]; size: SomaAdaptiveSize }> = [];
|
|
53
147
|
for (const entry of entries) {
|
|
54
148
|
const callbacks = subscribers.get(entry.target);
|
|
55
149
|
if (!callbacks || callbacks.size === 0) continue;
|
|
56
|
-
const rect = entry.contentRect;
|
|
57
|
-
const size: SomaAdaptiveSize = { width: rect.width, height: rect.height };
|
|
58
150
|
// 拷贝一份再遍历:回调里退订自己是常见写法,直接遍历原 Set 会漏掉后续项
|
|
59
|
-
|
|
151
|
+
batch.push({
|
|
152
|
+
callbacks: [...callbacks],
|
|
153
|
+
size: box === 'border-box' ? borderBoxSizeOf(entry) : contentBoxSizeOf(entry),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
for (const item of batch) {
|
|
157
|
+
for (const callback of item.callbacks) callback(item.size);
|
|
60
158
|
}
|
|
61
159
|
});
|
|
62
160
|
return observer;
|
|
@@ -69,7 +167,10 @@ function createDomPool(): SomaAdaptiveObserverPool {
|
|
|
69
167
|
if (!callbacks) {
|
|
70
168
|
callbacks = new Set();
|
|
71
169
|
subscribers.set(target, callbacks);
|
|
72
|
-
|
|
170
|
+
// 内容盒是 observe 的默认盒,仍按历史调用不传第二参(老引擎连选项字典都不认);
|
|
171
|
+
// 边框盒必须显式声明,否则"只改内边距、边框盒变了而内容盒没变"的一帧收不到通知。
|
|
172
|
+
if (box === 'border-box') ro.observe(target, { box: 'border-box' });
|
|
173
|
+
else ro.observe(target);
|
|
73
174
|
}
|
|
74
175
|
callbacks.add(onSize);
|
|
75
176
|
|
|
@@ -88,3 +189,16 @@ function createDomPool(): SomaAdaptiveObserverPool {
|
|
|
88
189
|
},
|
|
89
190
|
};
|
|
90
191
|
}
|
|
192
|
+
|
|
193
|
+
function createDomPool(): SomaAdaptiveObserverPool {
|
|
194
|
+
const channels: Record<BoxKind, ReturnType<typeof createBoxChannel>> = {
|
|
195
|
+
'content-box': createBoxChannel('content-box'),
|
|
196
|
+
'border-box': createBoxChannel('border-box'),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
observe(target, onSize, options): () => void {
|
|
201
|
+
return channels[options?.box === 'border-box' ? 'border-box' : 'content-box'].observe(target, onSize);
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -89,6 +89,35 @@ function compileEvents(eventConfig: ParsedEvent[]): {
|
|
|
89
89
|
return { events, eventIndex };
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* 列表行 / 对象作用域里的 model 的拒收文案。
|
|
94
|
+
*
|
|
95
|
+
* 引擎为什么不做这件事(两种写法两个原因,文案分开给,免得改法也跟着含混):
|
|
96
|
+
* - 行变量打头(`item.qty`):行数据是数组元素,数组不经响应式代理,回写行字段既不触发重渲、
|
|
97
|
+
* 上层也不会知道——组件那一侧对同一个写法的拒收(component-manager 的 rowVariableRefusal)同因同源;
|
|
98
|
+
* - 页面路径打头(`page.kw`):写回本身走得通(行内组件实例的 model prop 就是这么回写的),
|
|
99
|
+
* 但渲染器在行 / 对象作用域里根本不建 model 绑定:控件不按数据选中、整表同步(syncModels)
|
|
100
|
+
* 只认编译出来的绑定表,行内控件的值到不了处理器。要补齐得连回写、同屏刷新、
|
|
101
|
+
* 无键列表重建时的焦点一起解决,不是在这里加一行能了的事。
|
|
102
|
+
*
|
|
103
|
+
* 所以这里只拒收,不猜:编译期抛错,页面起不来,作者立刻知道;
|
|
104
|
+
* 而不是让一个看着正常的控件在用户手上失效。
|
|
105
|
+
*/
|
|
106
|
+
function scopedModelRefusal(where: string, model: string, resolver: SomaScopeResolver): string {
|
|
107
|
+
const first = model.split('.')[0];
|
|
108
|
+
const rowRooted = resolver.hasVar(first) && resolver.getVarPath(first) !== '';
|
|
109
|
+
const why = rowRooted
|
|
110
|
+
? `"${first}" 是行 / 嵌套作用域变量,行数据不在响应式代理里(数组靠整体替换触发更新),写进去上层不会知道`
|
|
111
|
+
: '渲染器在行 / 对象作用域里不建 model 绑定:控件既不按数据选中,改了也不回写,整表同步同样看不见它';
|
|
112
|
+
return `[soma-core][引擎] ${where}.model: ${model} —— 列表行 / 对象作用域里不支持 model(${why})。`
|
|
113
|
+
+ '改法二选一:'
|
|
114
|
+
+ '① 显示值用单向绑定(`item.x`、`item.x@value` / `@checked`),改值走事件——'
|
|
115
|
+
+ '处理器第一个实参就是当前行数据、第二个是 DOM 事件,在处理器里按引用替换写回页面数据'
|
|
116
|
+
+ '(如 this.items = this.items.map(...));'
|
|
117
|
+
+ '② 换成带 model prop 的组件实例,props 里把它绑到页面路径(`page.x`)——'
|
|
118
|
+
+ '行内实例的 model 回写经页面响应式代理落地,是引擎支持的那条路。';
|
|
119
|
+
}
|
|
120
|
+
|
|
92
121
|
export class SomaManifestCompiler {
|
|
93
122
|
compile(input: SomaManifestCompilerInput): SomaRuntimeManifest {
|
|
94
123
|
const bindings: SomaCompiledBinding[] = [];
|
|
@@ -140,7 +169,7 @@ export class SomaManifestCompiler {
|
|
|
140
169
|
const element = input.adapter.findAnchor(input.container, rawKey);
|
|
141
170
|
const role = element ? input.adapter.readRole(element) : null;
|
|
142
171
|
const dataPath = input.resolver.resolvePath(showValue.bind.obj);
|
|
143
|
-
this.
|
|
172
|
+
this.validateScopedDeclarations(showValue.show, rawKey, input);
|
|
144
173
|
bindings.push({
|
|
145
174
|
id: `${rawKey}:${bindings.length}`,
|
|
146
175
|
somaId: rawKey,
|
|
@@ -280,8 +309,17 @@ export class SomaManifestCompiler {
|
|
|
280
309
|
return parsed;
|
|
281
310
|
}
|
|
282
311
|
|
|
283
|
-
/**
|
|
284
|
-
|
|
312
|
+
/**
|
|
313
|
+
* 列表 / 对象子作用域配置的编译期闸门:管道白名单预校验 + model 拒收。
|
|
314
|
+
*
|
|
315
|
+
* 行内绑定是解释执行的(不经这里编译成 BindingEntry),编译期不看就只剩运行时才发现。
|
|
316
|
+
* 两件事都在这一趟走完:管道名不在白名单 → fail fast;行 / 对象作用域里写了 model → 拒收。
|
|
317
|
+
* model 那条从渲染器的挂载期告警移上来(原 SomaDomRenderer.reportScopedModels):
|
|
318
|
+
* 告警发生在绑定表建好之后,页面照常上屏,控件却既不按数据选中、改了也不回写——
|
|
319
|
+
* 一个看着正常、实则失效的表单控件,比页面起不来危险得多。页面与组件实例都经这一趟编译,
|
|
320
|
+
* 两边同一道闸(组件实例不过契约校验器,只有这里拦得住)。
|
|
321
|
+
*/
|
|
322
|
+
private validateScopedDeclarations(
|
|
285
323
|
show: ShowMapping,
|
|
286
324
|
where: string,
|
|
287
325
|
input: SomaManifestCompilerInput,
|
|
@@ -292,15 +330,18 @@ export class SomaManifestCompiler {
|
|
|
292
330
|
continue;
|
|
293
331
|
}
|
|
294
332
|
if (this.isNestedShowMapping(value)) {
|
|
295
|
-
this.
|
|
333
|
+
this.validateScopedDeclarations(value.show, `${where}.${rawKey}.show`, input);
|
|
296
334
|
continue;
|
|
297
335
|
}
|
|
298
336
|
if (this.isExtendedShowValue(value)) {
|
|
337
|
+
if (typeof value.model === 'string') {
|
|
338
|
+
throw new Error(scopedModelRefusal(`${where}.${rawKey}`, value.model, input.resolver));
|
|
339
|
+
}
|
|
299
340
|
if (value.text) {
|
|
300
341
|
this.parsePipes(value.text, `${where}.${rawKey}.text`, input);
|
|
301
342
|
}
|
|
302
343
|
if (value.show) {
|
|
303
|
-
this.
|
|
344
|
+
this.validateScopedDeclarations(value.show, `${where}.${rawKey}.show`, input);
|
|
304
345
|
}
|
|
305
346
|
}
|
|
306
347
|
}
|
|
@@ -14,7 +14,7 @@ import type { SomaComponentDefinition } from './component-definition.types';
|
|
|
14
14
|
|
|
15
15
|
export class SomaComponentDefaultsError extends Error {
|
|
16
16
|
constructor(message: string) {
|
|
17
|
-
super(`[
|
|
17
|
+
super(`[soma-core][组件] ${message}`);
|
|
18
18
|
this.name = 'SomaComponentDefaultsError';
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -27,7 +27,7 @@ export const SOMA_CHILD_COMPONENT_ID_ATTR = 'data-soma-child-id';
|
|
|
27
27
|
|
|
28
28
|
export class SomaComponentExpandError extends Error {
|
|
29
29
|
constructor(message: string) {
|
|
30
|
-
super(`[
|
|
30
|
+
super(`[soma-core][组件] ${message}`);
|
|
31
31
|
this.name = 'SomaComponentExpandError';
|
|
32
32
|
}
|
|
33
33
|
}
|