soma-core 1.4.2 → 1.5.1
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/bin/component.cjs +240 -0
- package/bin/eject.cjs +174 -0
- package/bin/migrate.cjs +362 -0
- package/core/build/blocks/block-compile.ts +143 -17
- package/core/build/blocks/migrate-flat.ts +118 -25
- package/core/build/compiler/page-declaration-compiler.ts +149 -5
- package/core/build/compiler/route-builder.ts +0 -4
- package/core/build/compiler/soma-precompile.js +431 -26
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +18 -4
- package/core/build/eject/component-eject.ts +8 -2
- package/core/build/layout/constraint-solver.ts +131 -16
- package/core/build/layout/css-emitter.ts +29 -10
- package/core/build/ooui/artifact/artifact.types.ts +275 -0
- package/core/build/ooui/artifact/emit-artifact.ts +269 -0
- package/core/build/ooui/artifact/emit-html.ts +204 -0
- package/core/build/ooui/artifact/index.ts +53 -0
- package/core/build/ooui/artifact/spatial-tree.ts +268 -0
- package/core/build/ooui/artifact/utility-class.ts +83 -0
- package/core/build/ooui/composition/candidate.types.ts +323 -0
- package/core/build/ooui/composition/control-model.ts +114 -0
- package/core/build/ooui/composition/registry.ts +520 -0
- package/core/build/ooui/composition/select.ts +232 -0
- package/core/build/ooui/diagnostics/codes.ts +230 -0
- package/core/build/ooui/diagnostics/error.ts +235 -0
- package/core/build/ooui/diagnostics/format.ts +106 -0
- package/core/build/ooui/diagnostics/index.ts +62 -0
- package/core/build/ooui/diagnostics/issue.types.ts +112 -0
- package/core/build/ooui/engine-slot.ts +184 -0
- package/core/build/ooui/index.ts +1427 -0
- package/core/build/ooui/intent/derive-intent.ts +450 -0
- package/core/build/ooui/intent/field-rules.ts +330 -0
- package/core/build/ooui/intent/intent.types.ts +476 -0
- package/core/build/ooui/intent/verb-events.ts +285 -0
- package/core/build/ooui/page/budget.ts +503 -0
- package/core/build/ooui/page/compose-page.ts +736 -0
- package/core/build/ooui/page/index.ts +66 -0
- package/core/build/ooui/page/page.types.ts +402 -0
- package/core/build/ooui/page/region-row.ts +241 -0
- package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
- package/core/build/ooui/semantic/kernel.types.ts +187 -0
- package/core/build/ooui/semantic/normalize.ts +784 -0
- package/core/build/ooui/semantic/origin.types.ts +211 -0
- package/core/build/ooui/semantic/role-alias.ts +154 -0
- package/core/build/ooui/semantic/shorthand.ts +233 -0
- package/core/build/ooui/semantic/surface.types.ts +78 -0
- package/core/build/ooui/semantic/validate-request.ts +267 -0
- package/core/build/ooui/spatial/emit-utility.ts +480 -0
- package/core/build/ooui/spatial/ir.types.ts +443 -0
- package/core/build/ooui/spatial/registry.ts +565 -0
- package/core/build/ooui/spatial/solve.ts +769 -0
- package/core/build/ooui/spatial/utility.types.ts +242 -0
- package/core/build/ooui/trace/index.ts +40 -0
- package/core/build/ooui/trace/render.ts +190 -0
- package/core/build/ooui/trace/source.types.ts +69 -0
- package/core/build/ooui/trace/trace.types.ts +326 -0
- package/core/client/component/component-expander.ts +18 -3
- package/core/client/component/component-manager.ts +4 -0
- package/core/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- package/core/client/component/verify-pack.ts +43 -0
- package/core/client/data/data-object-resolver.ts +27 -8
- package/core/client/diagnostics/telemetry-context.ts +0 -4
- package/core/client/engine/asset-resolver.ts +0 -1
- package/core/client/engine/event-engine.ts +7 -3
- package/core/client/engine/soma-bootstrap.ts +292 -34
- package/core/client/engine/style-binder.ts +0 -1
- package/core/client/infra/http/IHttpClient.ts +0 -6
- package/core/client/infra/http/SomaHttpService.ts +4 -1
- package/core/client/infra/notify/DomNotifyService.ts +1 -1
- package/core/client/infra/router/router-path.ts +0 -6
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/namespace.ts +30 -5
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +266 -46
- package/core/client/parser/data-config-parser.ts +71 -3
- package/core/client/parser/layout-parser.ts +4 -3
- package/core/client/parser/reaction-parser.ts +0 -1
- package/core/client/parser/ui-config-parser.ts +212 -74
- package/core/client/theme/scene-tokens.ts +9 -3
- package/core/client/theme/theme-axes.ts +74 -16
- package/core/client/theme/theme-engine.ts +341 -70
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +24 -5
- package/core/server/api/load-host-service.ts +8 -2
- package/core/server/declaration-safety.ts +11 -0
- package/core/server/host/page-response-request.ts +0 -2
- package/core/server/host/published-page-artifact-cache.ts +244 -0
- package/core/server/host/published-page-assets.ts +44 -5
- package/core/server/mock/node/cli.mjs +0 -1
- package/core/server/mock/node/schema-generator.mjs +0 -1
- package/core/server/ooui.ts +34 -0
- package/core/server/page-assets.ts +8 -0
- package/core/server/page-declaration.ts +18 -0
- package/core/server/registry/asset-store.ts +327 -0
- package/core/server/registry/declaration-precompiler.ts +49 -6
- package/core/server/registry/index.ts +47 -1
- package/core/server/registry/page-registry-repository.ts +6 -2
- package/core/server/registry/page-registry-store.ts +133 -19
- package/core/server/registry/publish-asset-pin.ts +557 -0
- package/core/server/registry/services/pages/List.ts +15 -3
- package/core/server/registry/validation/compile-gate.ts +180 -8
- package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
- package/core/shared/component/derive-sample.ts +201 -16
- package/core/shared/component/field-lines.ts +98 -8
- package/core/shared/container-breakpoints.ts +46 -0
- package/core/shared/object-semantics.ts +240 -0
- package/core/shared/ooui-declaration.ts +235 -0
- package/core/shared/types/component-contract.types.ts +7 -6
- package/core/shared/types/data-config.types.ts +95 -0
- package/core/shared/types/domain.types.ts +0 -24
- package/core/shared/types/engine.types.ts +0 -5
- package/core/shared/types/layout-constraint.types.ts +16 -0
- package/core/shared/types/ui-config.types.ts +163 -13
- package/dist/cli/soma.js +24 -11
- package/dist/core/index.cjs +1829 -1028
- package/dist/types/build/blocks/block-compile.d.ts +16 -1
- package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/component/component-graph.d.ts +17 -53
- package/dist/types/build/component/package-loader.d.ts +8 -1
- package/dist/types/build/layout/constraint-solver.d.ts +46 -4
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
- package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
- package/dist/types/build/ooui/artifact/index.d.ts +5 -0
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
- package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
- package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
- package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
- package/dist/types/build/ooui/composition/registry.d.ts +66 -0
- package/dist/types/build/ooui/composition/select.d.ts +63 -0
- package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
- package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
- package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
- package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
- package/dist/types/build/ooui/engine-slot.d.ts +41 -0
- package/dist/types/build/ooui/index.d.ts +286 -0
- package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
- package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
- package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
- package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
- package/dist/types/build/ooui/page/budget.d.ts +28 -0
- package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
- package/dist/types/build/ooui/page/index.d.ts +4 -0
- package/dist/types/build/ooui/page/page.types.d.ts +264 -0
- package/dist/types/build/ooui/page/region-row.d.ts +16 -0
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
- package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
- package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
- package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
- package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
- package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
- package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
- package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
- package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
- package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
- package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
- package/dist/types/build/ooui/trace/index.d.ts +3 -0
- package/dist/types/build/ooui/trace/render.d.ts +42 -0
- package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
- package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
- package/dist/types/client/component/component-expander.d.ts +1 -0
- package/dist/types/client/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- package/dist/types/client/data/data-object-resolver.d.ts +10 -2
- package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
- package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
- package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/router/router-path.d.ts +0 -2
- package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
- package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
- package/dist/types/client/parser/data-config-parser.d.ts +13 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
- package/dist/types/client/theme/scene-tokens.d.ts +9 -3
- package/dist/types/client/theme/theme-axes.d.ts +64 -1
- package/dist/types/client/theme/theme-engine.d.ts +13 -8
- package/dist/types/client/theme/tone-solver.d.ts +9 -5
- package/dist/types/index.d.ts +4 -6
- package/dist/types/server/declaration-safety.d.ts +7 -0
- package/dist/types/server/host/page-response-request.d.ts +0 -1
- package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
- package/dist/types/server/ooui.d.ts +18 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +14 -0
- package/dist/types/server/registry/asset-store.d.ts +112 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
- package/dist/types/server/registry/index.d.ts +3 -1
- package/dist/types/server/registry/page-registry-store.d.ts +57 -4
- package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
- package/dist/types/server/registry/services/pages/List.d.ts +9 -3
- package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
- package/dist/types/shared/component/derive-sample.d.ts +14 -0
- package/dist/types/shared/container-breakpoints.d.ts +42 -0
- package/dist/types/shared/object-semantics.d.ts +42 -0
- package/dist/types/shared/ooui-declaration.d.ts +135 -0
- package/dist/types/shared/types/component-contract.types.d.ts +7 -6
- package/dist/types/shared/types/data-config.types.d.ts +86 -0
- package/dist/types/shared/types/domain.types.d.ts +0 -21
- package/dist/types/shared/types/engine.types.d.ts +0 -4
- package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +157 -12
- package/next.config.js +106 -13
- package/package.json +29 -2
- package/core/client/host-bridge/index.ts +0 -27
- package/core/client/parser/yaml-loader.ts +0 -36
- package/core/shared/manifest/manifest-contract.ts +0 -12
- package/dist/types/client/host-bridge/index.d.ts +0 -9
- package/dist/types/client/parser/yaml-loader.d.ts +0 -21
- package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
package/dist/core/index.cjs
CHANGED
|
@@ -48,6 +48,8 @@ __export(index_exports, {
|
|
|
48
48
|
SOMA_AGGREGATE_FNS: () => SOMA_AGGREGATE_FNS,
|
|
49
49
|
SOMA_DATA_FIELD_TYPES: () => SOMA_DATA_FIELD_TYPES,
|
|
50
50
|
SOMA_DATA_FIELD_TYPE_ALIASES: () => SOMA_DATA_FIELD_TYPE_ALIASES,
|
|
51
|
+
SOMA_DATA_OBJECT_ROLES: () => SOMA_DATA_OBJECT_ROLES,
|
|
52
|
+
SOMA_DATA_RELATION_CARDINALITIES: () => SOMA_DATA_RELATION_CARDINALITIES,
|
|
51
53
|
SOMA_DEFAULT_HYSTERESIS: () => SOMA_DEFAULT_HYSTERESIS,
|
|
52
54
|
SOMA_FIELD_DISPLAYS: () => SOMA_FIELD_DISPLAYS,
|
|
53
55
|
SOMA_FIELD_PATTERNS: () => SOMA_FIELD_PATTERNS,
|
|
@@ -107,7 +109,6 @@ __export(index_exports, {
|
|
|
107
109
|
collectPredicateFields: () => collectPredicateFields,
|
|
108
110
|
compileAdaptive: () => compileAdaptive,
|
|
109
111
|
compileFieldSugar: () => compileFieldSugar,
|
|
110
|
-
compilePageAssets: () => compilePageAssets,
|
|
111
112
|
compileSomaBlocks: () => compileSomaBlocks,
|
|
112
113
|
componentTokenPrefix: () => componentTokenPrefix,
|
|
113
114
|
componentTokenVar: () => componentTokenVar,
|
|
@@ -123,6 +124,7 @@ __export(index_exports, {
|
|
|
123
124
|
createWindow: () => createWindow,
|
|
124
125
|
decodePageState: () => decodePageState,
|
|
125
126
|
defaultPipeRegistry: () => defaultPipeRegistry,
|
|
127
|
+
deriveContractPreviewSample: () => deriveContractPreviewSample,
|
|
126
128
|
deriveContractSample: () => deriveContractSample,
|
|
127
129
|
deriveFieldSample: () => deriveFieldSample,
|
|
128
130
|
deriveKeyboardMatrix: () => deriveKeyboardMatrix,
|
|
@@ -212,7 +214,6 @@ __export(index_exports, {
|
|
|
212
214
|
setSomaHtmlSanitizer: () => setSomaHtmlSanitizer,
|
|
213
215
|
somaEmits: () => somaEmits,
|
|
214
216
|
somaFields: () => somaFields,
|
|
215
|
-
somaRollupPlugin: () => somaRollupPlugin,
|
|
216
217
|
somaSlots: () => somaSlots,
|
|
217
218
|
startBootTimings: () => startBootTimings,
|
|
218
219
|
themeRootAttributes: () => themeRootAttributes,
|
|
@@ -4267,8 +4268,8 @@ function requireDumper() {
|
|
|
4267
4268
|
return state2.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
4268
4269
|
}
|
|
4269
4270
|
}
|
|
4270
|
-
const
|
|
4271
|
-
const lineWidth = state2.lineWidth === -1 ? -1 : Math.max(Math.min(state2.lineWidth, 40), state2.lineWidth -
|
|
4271
|
+
const indent = state2.indent * Math.max(1, level);
|
|
4272
|
+
const lineWidth = state2.lineWidth === -1 ? -1 : Math.max(Math.min(state2.lineWidth, 40), state2.lineWidth - indent);
|
|
4272
4273
|
const singleLineOnly = iskey || // No block styles in flow mode.
|
|
4273
4274
|
state2.flowLevel > -1 && level >= state2.flowLevel;
|
|
4274
4275
|
function testAmbiguity(string2) {
|
|
@@ -4289,9 +4290,9 @@ function requireDumper() {
|
|
|
4289
4290
|
case STYLE_SINGLE:
|
|
4290
4291
|
return "'" + string.replace(/'/g, "''") + "'";
|
|
4291
4292
|
case STYLE_LITERAL:
|
|
4292
|
-
return "|" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(string,
|
|
4293
|
+
return "|" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(string, indent));
|
|
4293
4294
|
case STYLE_FOLDED:
|
|
4294
|
-
return ">" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(foldString(string, lineWidth),
|
|
4295
|
+
return ">" + blockHeader(string, state2.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
4295
4296
|
case STYLE_DOUBLE:
|
|
4296
4297
|
return '"' + escapeString(string) + '"';
|
|
4297
4298
|
default:
|
|
@@ -4630,7 +4631,7 @@ function requireDumper() {
|
|
|
4630
4631
|
}
|
|
4631
4632
|
}
|
|
4632
4633
|
}
|
|
4633
|
-
function
|
|
4634
|
+
function dump2(input, options) {
|
|
4634
4635
|
options = options || {};
|
|
4635
4636
|
const state2 = new State(options);
|
|
4636
4637
|
if (!state2.noRefs) getDuplicateReferences(input, state2);
|
|
@@ -4641,7 +4642,7 @@ function requireDumper() {
|
|
|
4641
4642
|
if (writeNode(state2, 0, value, true, true)) return state2.dump + "\n";
|
|
4642
4643
|
return "";
|
|
4643
4644
|
}
|
|
4644
|
-
dumper.dump =
|
|
4645
|
+
dumper.dump = dump2;
|
|
4645
4646
|
return dumper;
|
|
4646
4647
|
}
|
|
4647
4648
|
var hasRequiredJsYaml;
|
|
@@ -5110,9 +5111,9 @@ function producesArray(pipelineType) {
|
|
|
5110
5111
|
}
|
|
5111
5112
|
function parseSteps(input, deps) {
|
|
5112
5113
|
const { raw: raw2, payloadFields, path } = input;
|
|
5113
|
-
const
|
|
5114
|
+
const fail = deps.fail;
|
|
5114
5115
|
if (!Array.isArray(raw2) || raw2.length === 0) {
|
|
5115
|
-
|
|
5116
|
+
fail("steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4", path);
|
|
5116
5117
|
}
|
|
5117
5118
|
const slots = {};
|
|
5118
5119
|
const edges = [];
|
|
@@ -5123,22 +5124,22 @@ function parseSteps(input, deps) {
|
|
|
5123
5124
|
for (const field of collectPredicateFields(when)) {
|
|
5124
5125
|
const root = field.split(".")[0];
|
|
5125
5126
|
if (!payloadFields.includes(root) && slots[root] === void 0) {
|
|
5126
|
-
|
|
5127
|
+
fail(
|
|
5127
5128
|
`${at} \u5F15\u7528\u4E86 "${root}"\uFF0C\u4F46\u5B83\u65E2\u4E0D\u662F\u4E8B\u4EF6\u8F7D\u8377\u5B57\u6BB5\uFF08${payloadFields.join(" / ") || "\u65E0"}\uFF09\uFF0C\u4E5F\u4E0D\u662F\u5148\u4E8E\u672C\u6B65\u58F0\u660E\u7684\u8F93\u51FA\u69FD\uFF08${Object.keys(slots).join(" / ") || "\u65E0"}\uFF09`,
|
|
5128
5129
|
at
|
|
5129
5130
|
);
|
|
5130
5131
|
}
|
|
5131
5132
|
}
|
|
5132
5133
|
const issues = validatePredicate(when, scopeKeys(), at, {});
|
|
5133
|
-
if (issues.length > 0)
|
|
5134
|
+
if (issues.length > 0) fail(issues.join("\uFF1B"), at);
|
|
5134
5135
|
};
|
|
5135
5136
|
const declareSlot = (name, at, index, pipelineType) => {
|
|
5136
5137
|
const slot = String(name ?? "");
|
|
5137
5138
|
if (!SLOT_NAME_PATTERN.test(slot)) {
|
|
5138
|
-
|
|
5139
|
+
fail(`${at}.output "${slot}" \u4E0D\u662F\u5408\u6CD5\u69FD\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u4E0B\u5212\u7EBF\u5206\u9694\uFF09`, `${at}.output`);
|
|
5139
5140
|
}
|
|
5140
5141
|
if (slots[slot] !== void 0) {
|
|
5141
|
-
|
|
5142
|
+
fail(
|
|
5142
5143
|
`${at}.output \u69FD\u540D "${slot}" \u4E0E\u7B2C ${slots[slot].declaredAt + 1} \u6B65\u91CD\u540D\u2014\u2014\u540C\u540D\u69FD\u7684\u540E\u5199\u4F1A\u8986\u76D6\u524D\u5199\uFF0C\u800C\u5F15\u7528\u5B83\u7684\u6761\u4EF6\u8BFB\u5230\u54EA\u4E00\u4E2A\u53D6\u51B3\u4E8E\u6B65\u9AA4\u6B21\u5E8F`,
|
|
5143
5144
|
`${at}.output`
|
|
5144
5145
|
);
|
|
@@ -5148,12 +5149,12 @@ function parseSteps(input, deps) {
|
|
|
5148
5149
|
};
|
|
5149
5150
|
const parsePipe = (expression, at) => {
|
|
5150
5151
|
if (typeof expression !== "string" || expression.trim() === "") {
|
|
5151
|
-
|
|
5152
|
+
fail(`${at}.do \u5FC5\u987B\u662F\u7BA1\u9053\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32`, `${at}.do`);
|
|
5152
5153
|
}
|
|
5153
5154
|
try {
|
|
5154
5155
|
return deps.parsePipeline(expression);
|
|
5155
5156
|
} catch (error) {
|
|
5156
|
-
|
|
5157
|
+
fail(error instanceof Error ? error.message : String(error), `${at}.do`);
|
|
5157
5158
|
}
|
|
5158
5159
|
};
|
|
5159
5160
|
const parseOnError = (value, at, total, index) => {
|
|
@@ -5162,17 +5163,17 @@ function parseSteps(input, deps) {
|
|
|
5162
5163
|
if (raw22 === "stop" || raw22 === "continue") return raw22;
|
|
5163
5164
|
const match = /^goto:(\d+)$/.exec(raw22);
|
|
5164
5165
|
if (!match) {
|
|
5165
|
-
|
|
5166
|
+
fail(`${at}.on_error \u53EA\u80FD\u662F stop / continue / goto:<\u6B65\u9AA4\u5E8F\u53F7>\uFF08\u6536\u5230 "${raw22}"\uFF09`, `${at}.on_error`);
|
|
5166
5167
|
}
|
|
5167
5168
|
const target = Number(match[1]);
|
|
5168
5169
|
if (target <= index + 1) {
|
|
5169
|
-
|
|
5170
|
+
fail(
|
|
5170
5171
|
`${at}.on_error \u7684 goto:${target} \u6307\u5411\u7B2C ${target} \u6B65\uFF0C\u4E0D\u5728\u672C\u6B65\uFF08\u7B2C ${index + 1} \u6B65\uFF09\u4E4B\u540E\u2014\u2014\u53EA\u8BB8\u5411\u540E\u8DF3\uFF0C\u5426\u5219\u7F16\u6392\u53EF\u4EE5\u4E0D\u7EC8\u6B62`,
|
|
5171
5172
|
`${at}.on_error`
|
|
5172
5173
|
);
|
|
5173
5174
|
}
|
|
5174
5175
|
if (target > total) {
|
|
5175
|
-
|
|
5176
|
+
fail(`${at}.on_error \u7684 goto:${target} \u8D8A\u8FC7\u4E86\u672B\u6B65\uFF08\u5171 ${total} \u6B65\uFF09`, `${at}.on_error`);
|
|
5176
5177
|
}
|
|
5177
5178
|
return `goto:${target}`;
|
|
5178
5179
|
};
|
|
@@ -5181,10 +5182,10 @@ function parseSteps(input, deps) {
|
|
|
5181
5182
|
const parallelLocalSlots = [];
|
|
5182
5183
|
list.forEach((entry, position) => {
|
|
5183
5184
|
const stepAt = `${at}[${position}]`;
|
|
5184
|
-
if (!isPlainObject(entry))
|
|
5185
|
+
if (!isPlainObject(entry)) fail(`${stepAt} \u5FC5\u987B\u662F\u6620\u5C04`, stepAt);
|
|
5185
5186
|
for (const key of Object.keys(entry)) {
|
|
5186
5187
|
if (!STEP_KEYS.has(key)) {
|
|
5187
|
-
|
|
5188
|
+
fail(`${stepAt} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...STEP_KEYS].join(" / ")}\uFF09`, `${stepAt}.${key}`);
|
|
5188
5189
|
}
|
|
5189
5190
|
}
|
|
5190
5191
|
const index = counter;
|
|
@@ -5192,7 +5193,7 @@ function parseSteps(input, deps) {
|
|
|
5192
5193
|
if (out.length > 0) edges.push([out[out.length - 1].index, index]);
|
|
5193
5194
|
if (entry.parallel !== void 0) {
|
|
5194
5195
|
if (!Array.isArray(entry.parallel) || entry.parallel.length < 2) {
|
|
5195
|
-
|
|
5196
|
+
fail(`${stepAt}.parallel \u81F3\u5C11\u8981\u4E24\u4E2A\u5206\u652F\uFF08\u4E00\u4E2A\u5206\u652F\u7684\u5E76\u884C\u5C31\u662F\u987A\u5E8F\uFF09`, `${stepAt}.parallel`);
|
|
5196
5197
|
}
|
|
5197
5198
|
const before = new Set(Object.keys(slots));
|
|
5198
5199
|
const children = walk(entry.parallel, `${stepAt}.parallel`, depth, true);
|
|
@@ -5203,34 +5204,34 @@ function parseSteps(input, deps) {
|
|
|
5203
5204
|
}
|
|
5204
5205
|
if (entry.for_each !== void 0) {
|
|
5205
5206
|
if (depth + 1 > MAX_FOR_EACH_DEPTH) {
|
|
5206
|
-
|
|
5207
|
+
fail(
|
|
5207
5208
|
`${stepAt}.for_each \u5D4C\u5957\u8D85\u8FC7 ${MAX_FOR_EACH_DEPTH} \u5C42\u2014\u2014\u4E09\u5C42\u904D\u5386\u5728\u58F0\u660E\u5C42\u51E0\u4E4E\u80AF\u5B9A\u662F\u6570\u636E\u7ED3\u6784\u6CA1\u8BBE\u8BA1\u5BF9`,
|
|
5208
5209
|
`${stepAt}.for_each`
|
|
5209
5210
|
);
|
|
5210
5211
|
}
|
|
5211
5212
|
const box = entry.for_each;
|
|
5212
|
-
if (!isPlainObject(box))
|
|
5213
|
+
if (!isPlainObject(box)) fail(`${stepAt}.for_each \u5FC5\u987B\u662F { over, as, steps }`, `${stepAt}.for_each`);
|
|
5213
5214
|
const over = String(box.over ?? "");
|
|
5214
5215
|
const as = String(box.as ?? "");
|
|
5215
5216
|
const isPayload = payloadFields.includes(over);
|
|
5216
5217
|
const slot = slots[over];
|
|
5217
5218
|
if (!isPayload && slot === void 0) {
|
|
5218
|
-
|
|
5219
|
+
fail(
|
|
5219
5220
|
`${stepAt}.for_each.over "${over}" \u65E2\u4E0D\u662F\u4E8B\u4EF6\u8F7D\u8377\u5B57\u6BB5\uFF0C\u4E5F\u4E0D\u662F\u5148\u4E8E\u672C\u6B65\u58F0\u660E\u7684\u8F93\u51FA\u69FD`,
|
|
5220
5221
|
`${stepAt}.for_each.over`
|
|
5221
5222
|
);
|
|
5222
5223
|
}
|
|
5223
5224
|
if (slot !== void 0 && !slot.bounded) {
|
|
5224
|
-
|
|
5225
|
+
fail(
|
|
5225
5226
|
`${stepAt}.for_each.over "${over}" \u6765\u81EA ${slot.producedBy}\uFF0C\u5B83\u4E0D\u8FD4\u56DE\u6570\u7EC4\u2014\u2014\u904D\u5386\u4E00\u4E2A\u4E0D\u662F\u6570\u7EC4\u7684\u4E1C\u897F\uFF0C\u6B65\u6570\u5C31\u6CA1\u6709\u4E0A\u754C\u4E86`,
|
|
5226
5227
|
`${stepAt}.for_each.over`
|
|
5227
5228
|
);
|
|
5228
5229
|
}
|
|
5229
5230
|
if (!SLOT_NAME_PATTERN.test(as)) {
|
|
5230
|
-
|
|
5231
|
+
fail(`${stepAt}.for_each.as "${as}" \u4E0D\u662F\u5408\u6CD5\u9879\u540D`, `${stepAt}.for_each.as`);
|
|
5231
5232
|
}
|
|
5232
5233
|
if (!Array.isArray(box.steps) || box.steps.length === 0) {
|
|
5233
|
-
|
|
5234
|
+
fail(`${stepAt}.for_each.steps \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${stepAt}.for_each.steps`);
|
|
5234
5235
|
}
|
|
5235
5236
|
slots[as] = { declaredAt: index, producedBy: "for_each", bounded: false };
|
|
5236
5237
|
const children = walk(box.steps, `${stepAt}.for_each.steps`, depth + 1, inParallel);
|
|
@@ -5240,30 +5241,30 @@ function parseSteps(input, deps) {
|
|
|
5240
5241
|
}
|
|
5241
5242
|
if (entry.switch !== void 0) {
|
|
5242
5243
|
if (!Array.isArray(entry.switch) || entry.switch.length === 0) {
|
|
5243
|
-
|
|
5244
|
+
fail(`${stepAt}.switch \u5FC5\u987B\u662F\u975E\u7A7A\u5206\u652F\u6570\u7EC4`, `${stepAt}.switch`);
|
|
5244
5245
|
}
|
|
5245
5246
|
checkWhen(entry.when, `${stepAt}.when`);
|
|
5246
5247
|
const list2 = entry.switch;
|
|
5247
5248
|
const branches = [];
|
|
5248
5249
|
const otherwiseAt = list2.map((branch, position2) => isPlainObject(branch) && branch.otherwise === true ? position2 : -1).filter((position2) => position2 !== -1);
|
|
5249
5250
|
if (otherwiseAt.length > 1) {
|
|
5250
|
-
|
|
5251
|
+
fail(
|
|
5251
5252
|
`${stepAt}.switch \u6709 ${otherwiseAt.length} \u4E2A otherwise \u5206\u652F\uFF08\u7B2C ${otherwiseAt.map((n) => n + 1).join(" / ")} \u4E2A\uFF09\u2014\u2014\u515C\u5E95\u53EA\u80FD\u6709\u4E00\u4E2A`,
|
|
5252
5253
|
`${stepAt}.switch`
|
|
5253
5254
|
);
|
|
5254
5255
|
}
|
|
5255
5256
|
if (otherwiseAt.length === 1 && otherwiseAt[0] !== list2.length - 1) {
|
|
5256
|
-
|
|
5257
|
+
fail(
|
|
5257
5258
|
`${stepAt}.switch[${otherwiseAt[0]}] \u7684 otherwise \u5FC5\u987B\u662F\u6700\u540E\u4E00\u4E2A\u5206\u652F\uFF08\u5B83\u662F\u515C\u5E95\uFF0C\u540E\u9762\u7684\u5206\u652F\u6C38\u8FDC\u8D70\u4E0D\u5230\uFF09`,
|
|
5258
5259
|
`${stepAt}.switch[${otherwiseAt[0]}]`
|
|
5259
5260
|
);
|
|
5260
5261
|
}
|
|
5261
5262
|
list2.forEach((branchRaw, branchIndex) => {
|
|
5262
5263
|
const branchAt = `${stepAt}.switch[${branchIndex}]`;
|
|
5263
|
-
if (!isPlainObject(branchRaw))
|
|
5264
|
+
if (!isPlainObject(branchRaw)) fail(`${branchAt} \u5FC5\u987B\u662F\u6620\u5C04`, branchAt);
|
|
5264
5265
|
const otherwise = branchRaw.otherwise === true;
|
|
5265
5266
|
if (!otherwise && branchRaw.when === void 0) {
|
|
5266
|
-
|
|
5267
|
+
fail(`${branchAt} \u65E2\u6CA1\u6709 when \u4E5F\u4E0D\u662F otherwise\u2014\u2014\u5B83\u4F1A\u65E0\u6761\u4EF6\u547D\u4E2D\u5E76\u5403\u6389\u540E\u9762\u7684\u5206\u652F`, branchAt);
|
|
5267
5268
|
}
|
|
5268
5269
|
if (!otherwise) checkWhen(branchRaw.when, `${branchAt}.when`);
|
|
5269
5270
|
const pipeline2 = parsePipe(branchRaw.do, branchAt);
|
|
@@ -5303,7 +5304,7 @@ function parseSteps(input, deps) {
|
|
|
5303
5304
|
if (!parallelLocalSlots.includes(root)) continue;
|
|
5304
5305
|
const owner = out.findIndex((other) => other.output === root);
|
|
5305
5306
|
if (owner !== -1 && owner !== position) {
|
|
5306
|
-
|
|
5307
|
+
fail(
|
|
5307
5308
|
`${at}[${position}] \u7684 when \u5F15\u7528\u4E86\u540C\u4E00\u4E2A parallel \u91CC\u53E6\u4E00\u4E2A\u5206\u652F\u7684\u8F93\u51FA\u69FD "${root}"\u2014\u2014\u5E76\u884C\u5206\u652F\u4E4B\u95F4\u4E0D\u8BB8\u4E92\u5F15\uFF1A\u4E92\u5F15\u5C31\u610F\u5473\u7740\u6709\u987A\u5E8F\uFF0C\u90A3\u5B83\u5C31\u4E0D\u8BE5\u5199\u6210 parallel`,
|
|
5308
5309
|
`${at}[${position}].when`
|
|
5309
5310
|
);
|
|
@@ -5326,7 +5327,7 @@ function parseSteps(input, deps) {
|
|
|
5326
5327
|
if (pipe.type !== "ACTION") continue;
|
|
5327
5328
|
const name = String(pipe.funcPath ?? "");
|
|
5328
5329
|
if (!known.has(name)) {
|
|
5329
|
-
|
|
5330
|
+
fail(
|
|
5330
5331
|
`do: ACTION | ${name} \u2014\u2014 \u672A\u6CE8\u518C\u7684\u5177\u540D\u52A8\u4F5C\uFF08\u5DF2\u6CE8\u518C\uFF1A${[...known].join(" / ") || "\u65E0"}\uFF09\u3002\u5177\u540D\u52A8\u4F5C\u5728 bootstrap \u7684 options.actions \u91CC\u767B\u8BB0\uFF0C\u8FD9\u662F custom(script) \u7684\u66FF\u4EE3\uFF1A\u5B9E\u73B0\u5728 Host \u4EE3\u7801\u91CC\u3001\u6709\u540D\u5B57\u3001\u53EF\u5BA1\u8BA1\u3002`,
|
|
5331
5332
|
path
|
|
5332
5333
|
);
|
|
@@ -6027,6 +6028,82 @@ function parseStyleConfig(raw2) {
|
|
|
6027
6028
|
};
|
|
6028
6029
|
}
|
|
6029
6030
|
|
|
6031
|
+
// core/shared/types/layout-constraint.types.ts
|
|
6032
|
+
var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
|
|
6033
|
+
var SIZING_SET = {
|
|
6034
|
+
fixed: true,
|
|
6035
|
+
hug: true,
|
|
6036
|
+
fill: true
|
|
6037
|
+
};
|
|
6038
|
+
var SOMA_LAYOUT_SIZINGS = Object.keys(SIZING_SET);
|
|
6039
|
+
var SOMA_LAYOUT_ALIGNS = [
|
|
6040
|
+
"start",
|
|
6041
|
+
"center",
|
|
6042
|
+
"end",
|
|
6043
|
+
"baseline",
|
|
6044
|
+
"space_between",
|
|
6045
|
+
"space_evenly",
|
|
6046
|
+
"space_around"
|
|
6047
|
+
];
|
|
6048
|
+
|
|
6049
|
+
// core/shared/ooui-declaration.ts
|
|
6050
|
+
var SOMA_OOUI_ANCHOR_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
6051
|
+
var SOMA_OOUI_ANCHOR_GRAMMAR = "\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF0C\u5176\u4F59\u53EF\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u4E0E _";
|
|
6052
|
+
var REQUEST_KEY_SET = {
|
|
6053
|
+
object: true,
|
|
6054
|
+
verb: true,
|
|
6055
|
+
focus: true,
|
|
6056
|
+
through: true,
|
|
6057
|
+
form: true,
|
|
6058
|
+
bound_to: true,
|
|
6059
|
+
layout: true
|
|
6060
|
+
};
|
|
6061
|
+
var SOMA_OOUI_REQUEST_KEYS = Object.keys(REQUEST_KEY_SET);
|
|
6062
|
+
var LAYOUT_VALUE_TYPES = {
|
|
6063
|
+
sizing: "string",
|
|
6064
|
+
width: "string",
|
|
6065
|
+
min: "string",
|
|
6066
|
+
max: "string",
|
|
6067
|
+
priority: "number"
|
|
6068
|
+
};
|
|
6069
|
+
var SOMA_OOUI_LAYOUT_KEYS = Object.keys(LAYOUT_VALUE_TYPES);
|
|
6070
|
+
var SOMA_OOUI_SIZINGS = SOMA_LAYOUT_SIZINGS;
|
|
6071
|
+
function isOouiSizing(value) {
|
|
6072
|
+
return typeof value === "string" && SOMA_OOUI_SIZINGS.includes(value);
|
|
6073
|
+
}
|
|
6074
|
+
function isOouiMap(value) {
|
|
6075
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6076
|
+
}
|
|
6077
|
+
function isOouiText(value) {
|
|
6078
|
+
return typeof value === "string" && value.trim() !== "";
|
|
6079
|
+
}
|
|
6080
|
+
function isOouiFocus(value) {
|
|
6081
|
+
return Array.isArray(value) && value.length > 0 && value.every((item) => isOouiText(item));
|
|
6082
|
+
}
|
|
6083
|
+
var BINDING_KEY_SET = {
|
|
6084
|
+
region: true,
|
|
6085
|
+
as: true
|
|
6086
|
+
};
|
|
6087
|
+
var SOMA_OOUI_BINDING_KEYS = Object.keys(BINDING_KEY_SET);
|
|
6088
|
+
function findOouiBindingUnknownKey(binding) {
|
|
6089
|
+
return Object.keys(binding).find((key) => !SOMA_OOUI_BINDING_KEYS.includes(key));
|
|
6090
|
+
}
|
|
6091
|
+
function isOouiBinding(value) {
|
|
6092
|
+
return isOouiMap(value) && findOouiBindingUnknownKey(value) === void 0 && isOouiText(value.region) && isOouiText(value.as);
|
|
6093
|
+
}
|
|
6094
|
+
function findOouiLayoutProblem(layout) {
|
|
6095
|
+
for (const [key, value] of Object.entries(layout)) {
|
|
6096
|
+
if (!SOMA_OOUI_LAYOUT_KEYS.includes(key)) return { key, kind: "unknown-key" };
|
|
6097
|
+
const expected = LAYOUT_VALUE_TYPES[key];
|
|
6098
|
+
if (typeof value !== expected) return { key, kind: "value-type", expected };
|
|
6099
|
+
if (key === "sizing" && !isOouiSizing(value)) return { key, kind: "sizing-unknown" };
|
|
6100
|
+
}
|
|
6101
|
+
return void 0;
|
|
6102
|
+
}
|
|
6103
|
+
function isOouiLayout(value) {
|
|
6104
|
+
return isOouiMap(value) && findOouiLayoutProblem(value) === void 0;
|
|
6105
|
+
}
|
|
6106
|
+
|
|
6030
6107
|
// core/shared/types/adaptive.types.ts
|
|
6031
6108
|
var SOMA_ADAPTIVE_PROFILES = ["dashboard", "form", "list", "console"];
|
|
6032
6109
|
var SOMA_ADAPTIVE_MAX_LADDER = 5;
|
|
@@ -6207,24 +6284,24 @@ function isPlainObject2(value) {
|
|
|
6207
6284
|
}
|
|
6208
6285
|
function parsePageState(input, deps) {
|
|
6209
6286
|
const { raw: raw2, objectNames, anchorIds, path } = input;
|
|
6210
|
-
const
|
|
6211
|
-
if (!isPlainObject2(raw2))
|
|
6287
|
+
const fail = deps.fail;
|
|
6288
|
+
if (!isPlainObject2(raw2)) fail("state \u5FC5\u987B\u662F\u6620\u5C04", path);
|
|
6212
6289
|
for (const key of Object.keys(raw2)) {
|
|
6213
6290
|
if (!CONFIG_KEYS.has(key)) {
|
|
6214
|
-
|
|
6291
|
+
fail(`\u672A\u77E5\u7684 state \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
|
|
6215
6292
|
}
|
|
6216
6293
|
}
|
|
6217
6294
|
const version = raw2.version;
|
|
6218
6295
|
if (!Number.isInteger(version) || version < 1) {
|
|
6219
|
-
|
|
6296
|
+
fail("state.version \u5FC5\u586B\uFF0C\u4E14\u5FC5\u987B\u662F \u2265 1 \u7684\u6574\u6570\uFF08\u5B83\u51B3\u5B9A\u4E00\u4EFD\u65E7\u72B6\u6001\u8BE5\u4E0D\u8BE5\u88AB\u4E22\u5F03\uFF09", `${path}.version`);
|
|
6220
6297
|
}
|
|
6221
6298
|
const names = (value, at, allowed, what) => {
|
|
6222
6299
|
if (value === void 0) return [];
|
|
6223
|
-
if (!Array.isArray(value))
|
|
6300
|
+
if (!Array.isArray(value)) fail(`${at} \u5FC5\u987B\u662F\u540D\u5B57\u6570\u7EC4`, at);
|
|
6224
6301
|
return value.map((entry) => {
|
|
6225
6302
|
const name = String(entry);
|
|
6226
6303
|
if (!allowed.includes(name)) {
|
|
6227
|
-
|
|
6304
|
+
fail(`${at} \u91CC\u7684 "${name}" \u4E0D\u662F${what}\uFF08\u53EF\u9009\uFF1A${allowed.join(" / ") || "\u65E0"}\uFF09`, at);
|
|
6228
6305
|
}
|
|
6229
6306
|
return name;
|
|
6230
6307
|
});
|
|
@@ -6238,12 +6315,12 @@ function parsePageState(input, deps) {
|
|
|
6238
6315
|
if (raw2.expanded !== void 0) config.expanded = raw2.expanded === true;
|
|
6239
6316
|
if (raw2.url !== void 0) config.url = raw2.url === true;
|
|
6240
6317
|
if (raw2.initial_state !== void 0) {
|
|
6241
|
-
config.initial_state = parseStateValue(raw2.initial_state, `${path}.initial_state`, config,
|
|
6318
|
+
config.initial_state = parseStateValue(raw2.initial_state, `${path}.initial_state`, config, fail);
|
|
6242
6319
|
}
|
|
6243
6320
|
return config;
|
|
6244
6321
|
}
|
|
6245
|
-
function parseStateValue(raw2, path, config,
|
|
6246
|
-
if (!isPlainObject2(raw2))
|
|
6322
|
+
function parseStateValue(raw2, path, config, fail) {
|
|
6323
|
+
if (!isPlainObject2(raw2)) fail(`${path} \u5FC5\u987B\u662F\u6620\u5C04`, path);
|
|
6247
6324
|
const state2 = { version: config.version };
|
|
6248
6325
|
if (raw2.version !== void 0 && raw2.version !== config.version) {
|
|
6249
6326
|
state2.version = raw2.version;
|
|
@@ -6298,20 +6375,7 @@ function decodePageState(encoded) {
|
|
|
6298
6375
|
}
|
|
6299
6376
|
}
|
|
6300
6377
|
|
|
6301
|
-
// core/shared/types/layout-constraint.types.ts
|
|
6302
|
-
var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
|
|
6303
|
-
var SOMA_LAYOUT_ALIGNS = [
|
|
6304
|
-
"start",
|
|
6305
|
-
"center",
|
|
6306
|
-
"end",
|
|
6307
|
-
"baseline",
|
|
6308
|
-
"space_between",
|
|
6309
|
-
"space_evenly",
|
|
6310
|
-
"space_around"
|
|
6311
|
-
];
|
|
6312
|
-
|
|
6313
6378
|
// core/client/parser/layout-parser.ts
|
|
6314
|
-
var SIZINGS = /* @__PURE__ */ new Set(["fixed", "hug", "fill"]);
|
|
6315
6379
|
var WRAPS = /* @__PURE__ */ new Set(["none", "below", "reel"]);
|
|
6316
6380
|
var NODE_KEYS = /* @__PURE__ */ new Set(["sizing", "width", "min", "max", "priority"]);
|
|
6317
6381
|
var SECTION_KEYS = /* @__PURE__ */ new Set(["gap", "wrap", "align", "container_name", "nodes"]);
|
|
@@ -6321,8 +6385,8 @@ function isPlainObject3(value) {
|
|
|
6321
6385
|
}
|
|
6322
6386
|
function parseLayoutConstraint(input, deps) {
|
|
6323
6387
|
const { raw: raw2, path } = input;
|
|
6324
|
-
const
|
|
6325
|
-
if (!isPlainObject3(raw2))
|
|
6388
|
+
const fail = deps.fail;
|
|
6389
|
+
if (!isPlainObject3(raw2)) fail("layout \u5FC5\u987B\u662F\u6620\u5C04", path);
|
|
6326
6390
|
const explicit = isPlainObject3(raw2.nodes) ? raw2.nodes : null;
|
|
6327
6391
|
const source = explicit ?? Object.fromEntries(
|
|
6328
6392
|
Object.entries(raw2).filter(([key]) => !SECTION_KEYS.has(key))
|
|
@@ -6331,7 +6395,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6331
6395
|
for (const key of Object.keys(raw2)) {
|
|
6332
6396
|
if (SECTION_KEYS.has(key)) continue;
|
|
6333
6397
|
if (!NAME_PATTERN.test(key)) {
|
|
6334
|
-
|
|
6398
|
+
fail(
|
|
6335
6399
|
`${path}.${key} \u65E2\u4E0D\u662F\u6BB5\u7EA7\u952E\uFF08${[...SECTION_KEYS].join(" / ")}\uFF09\uFF0C\u4E5F\u4E0D\u662F\u5408\u6CD5\u5B50\u9879\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u4E0B\u5212\u7EBF\u5206\u9694\uFF09`,
|
|
6336
6400
|
`${path}.${key}`
|
|
6337
6401
|
);
|
|
@@ -6341,16 +6405,16 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6341
6405
|
const nodes = {};
|
|
6342
6406
|
for (const [name, rawNode] of Object.entries(source)) {
|
|
6343
6407
|
const at = `${path}.${name}`;
|
|
6344
|
-
if (!isPlainObject3(rawNode))
|
|
6408
|
+
if (!isPlainObject3(rawNode)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
|
|
6345
6409
|
for (const key of Object.keys(rawNode)) {
|
|
6346
6410
|
if (!NODE_KEYS.has(key)) {
|
|
6347
|
-
|
|
6411
|
+
fail(`${at} \u6709\u672A\u77E5\u952E "${key}"\uFF08\u652F\u6301: ${[...NODE_KEYS].join(" / ")}\uFF09`, `${at}.${key}`);
|
|
6348
6412
|
}
|
|
6349
6413
|
}
|
|
6350
6414
|
const sizing = String(rawNode.sizing ?? "");
|
|
6351
|
-
if (!
|
|
6352
|
-
|
|
6353
|
-
`${at}.sizing \u53EA\u80FD\u662F ${
|
|
6415
|
+
if (!SOMA_LAYOUT_SIZINGS.includes(sizing)) {
|
|
6416
|
+
fail(
|
|
6417
|
+
`${at}.sizing \u53EA\u80FD\u662F ${SOMA_LAYOUT_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(rawNode.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"`,
|
|
6354
6418
|
`${at}.sizing`
|
|
6355
6419
|
);
|
|
6356
6420
|
}
|
|
@@ -6359,7 +6423,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6359
6423
|
if (rawNode[key] === void 0) continue;
|
|
6360
6424
|
const literal = String(rawNode[key]);
|
|
6361
6425
|
if (!/^\d+(?:\.\d+)?(rem|%|cqi)$/.test(literal)) {
|
|
6362
|
-
|
|
6426
|
+
fail(
|
|
6363
6427
|
`${at}.${key} \u7684\u957F\u5EA6 "${literal}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`,
|
|
6364
6428
|
`${at}.${key}`
|
|
6365
6429
|
);
|
|
@@ -6369,7 +6433,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6369
6433
|
if (rawNode.priority !== void 0) {
|
|
6370
6434
|
const priority = Number(rawNode.priority);
|
|
6371
6435
|
if (!SOMA_LAYOUT_PRIORITIES.includes(priority)) {
|
|
6372
|
-
|
|
6436
|
+
fail(
|
|
6373
6437
|
`${at}.priority \u53EA\u80FD\u662F ${SOMA_LAYOUT_PRIORITIES.join(" / ")}\uFF08\u6536\u5230 ${String(rawNode.priority)}\uFF09\u2014\u2014250 \u662F"\u6211\u613F\u610F\u88AB\u62C9\u5927"\uFF0C750 \u662F"\u6211\u4E0D\u613F\u610F\u88AB\u538B\u5C0F"\uFF0C1000 \u662F\u4E0D\u53EF\u8FDD\u53CD`,
|
|
6374
6438
|
`${at}.priority`
|
|
6375
6439
|
);
|
|
@@ -6379,27 +6443,27 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6379
6443
|
nodes[name] = node;
|
|
6380
6444
|
}
|
|
6381
6445
|
if (Object.keys(nodes).length === 0) {
|
|
6382
|
-
|
|
6446
|
+
fail(`${path} \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B50\u9879`, path);
|
|
6383
6447
|
}
|
|
6384
6448
|
const constraint = { nodes };
|
|
6385
6449
|
if (raw2.gap !== void 0) {
|
|
6386
6450
|
const gap = String(raw2.gap);
|
|
6387
6451
|
if (!/^\d+(?:\.\d+)?(rem|%|cqi)$/.test(gap)) {
|
|
6388
|
-
|
|
6452
|
+
fail(`${path}.gap \u7684\u957F\u5EA6 "${gap}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi`, `${path}.gap`);
|
|
6389
6453
|
}
|
|
6390
6454
|
constraint.gap = gap;
|
|
6391
6455
|
}
|
|
6392
6456
|
if (raw2.wrap !== void 0) {
|
|
6393
6457
|
const wrap = String(raw2.wrap);
|
|
6394
6458
|
if (!WRAPS.has(wrap)) {
|
|
6395
|
-
|
|
6459
|
+
fail(`${path}.wrap \u53EA\u80FD\u662F ${[...WRAPS].join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(raw2.wrap)}\uFF09`, `${path}.wrap`);
|
|
6396
6460
|
}
|
|
6397
6461
|
constraint.wrap = wrap;
|
|
6398
6462
|
}
|
|
6399
6463
|
if (raw2.align !== void 0) {
|
|
6400
6464
|
const align = String(raw2.align);
|
|
6401
6465
|
if (!SOMA_LAYOUT_ALIGNS.includes(align)) {
|
|
6402
|
-
|
|
6466
|
+
fail(
|
|
6403
6467
|
`${path}.align \u53EA\u80FD\u662F ${SOMA_LAYOUT_ALIGNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(raw2.align)}\uFF09`,
|
|
6404
6468
|
`${path}.align`
|
|
6405
6469
|
);
|
|
@@ -6409,7 +6473,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
6409
6473
|
if (raw2.container_name !== void 0) {
|
|
6410
6474
|
const containerName = String(raw2.container_name);
|
|
6411
6475
|
if (!/^[a-z][a-z0-9-]*$/.test(containerName)) {
|
|
6412
|
-
|
|
6476
|
+
fail(
|
|
6413
6477
|
`${path}.container_name "${containerName}" \u4E0D\u662F\u5408\u6CD5\u7684\u5BB9\u5668\u540D\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\u3001\u8FDE\u5B57\u7B26\u5206\u9694\uFF1B\u5B83\u8981\u51FA\u73B0\u5728 CSS \u7684 container-name \u4E0A\uFF09`,
|
|
6414
6478
|
`${path}.container_name`
|
|
6415
6479
|
);
|
|
@@ -6666,8 +6730,148 @@ function parseUiConfig(raw2, options) {
|
|
|
6666
6730
|
}
|
|
6667
6731
|
config.layoutCss = raw2.layout_css;
|
|
6668
6732
|
}
|
|
6733
|
+
if ("ooui" in raw2 && raw2.ooui !== void 0) {
|
|
6734
|
+
config.ooui = parseOouiSection(raw2.ooui);
|
|
6735
|
+
}
|
|
6736
|
+
if ("ooui_artifact" in raw2 && raw2.ooui_artifact !== void 0) {
|
|
6737
|
+
config.oouiArtifact = parseOouiArtifact(raw2.ooui_artifact);
|
|
6738
|
+
}
|
|
6669
6739
|
return config;
|
|
6670
6740
|
}
|
|
6741
|
+
var OOUI_CSS_KEY_PATTERN = /^ooui:[0-9a-f]{8}$/;
|
|
6742
|
+
function parseOouiSection(raw2) {
|
|
6743
|
+
if (!isOouiMap(raw2)) {
|
|
6744
|
+
throw new SomaUiConfigError(
|
|
6745
|
+
"ooui \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { object: <data \u5BF9\u8C61\u540D>, verb: <\u52A8\u8BCD> } }",
|
|
6746
|
+
"ooui"
|
|
6747
|
+
);
|
|
6748
|
+
}
|
|
6749
|
+
const out = {};
|
|
6750
|
+
for (const [anchor, spec] of Object.entries(raw2)) {
|
|
6751
|
+
const path = `ooui.${anchor}`;
|
|
6752
|
+
if (!SOMA_OOUI_ANCHOR_PATTERN.test(anchor)) {
|
|
6753
|
+
throw new SomaUiConfigError(
|
|
6754
|
+
`ooui \u7684\u952E\u5FC5\u987B\u662F\u951A\u70B9 id\uFF08data-soma-id\uFF0C${SOMA_OOUI_ANCHOR_GRAMMAR}\uFF09\uFF0C\u6536\u5230 "${anchor}"`,
|
|
6755
|
+
path
|
|
6756
|
+
);
|
|
6757
|
+
}
|
|
6758
|
+
if (!isOouiMap(spec)) {
|
|
6759
|
+
throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u81F3\u5C11\u542B object \u4E0E verb\uFF09", path);
|
|
6760
|
+
}
|
|
6761
|
+
for (const key of Object.keys(spec)) {
|
|
6762
|
+
if (!SOMA_OOUI_REQUEST_KEYS.includes(key)) {
|
|
6763
|
+
throw new SomaUiConfigError(
|
|
6764
|
+
`\u6F14\u7ECE\u8BF7\u6C42\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_REQUEST_KEYS.join(" / ")}\uFF09`,
|
|
6765
|
+
`${path}.${key}`
|
|
6766
|
+
);
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
const { object, verb, focus, through, form, bound_to: bound, layout } = spec;
|
|
6770
|
+
if (!isOouiText(object)) {
|
|
6771
|
+
throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 object\uFF08\u9875\u9762 data: \u6BB5\u91CC\u7684\u5BF9\u8C61\u540D\uFF09", `${path}.object`);
|
|
6772
|
+
}
|
|
6773
|
+
if (!isOouiText(verb)) {
|
|
6774
|
+
throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 verb\uFF08\u516B\u52A8\u8BCD\u4E4B\u4E00\uFF09", `${path}.verb`);
|
|
6775
|
+
}
|
|
6776
|
+
const declaration = { object, verb };
|
|
6777
|
+
if (focus !== void 0) {
|
|
6778
|
+
if (!isOouiFocus(focus)) {
|
|
6779
|
+
throw new SomaUiConfigError("focus \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\u6570\u7EC4\uFF08\u7701\u7565\u5B83\u624D\u8868\u793A\u5168\u90E8\u5B57\u6BB5\uFF09", `${path}.focus`);
|
|
6780
|
+
}
|
|
6781
|
+
declaration.focus = [...focus];
|
|
6782
|
+
}
|
|
6783
|
+
if (through !== void 0) {
|
|
6784
|
+
if (!isOouiText(through)) {
|
|
6785
|
+
throw new SomaUiConfigError("through \u5FC5\u987B\u662F\u5BF9\u8C61 relations \u91CC\u7684\u5173\u7CFB\u540D", `${path}.through`);
|
|
6786
|
+
}
|
|
6787
|
+
declaration.through = through;
|
|
6788
|
+
}
|
|
6789
|
+
if (form !== void 0) {
|
|
6790
|
+
if (!isOouiText(form)) {
|
|
6791
|
+
throw new SomaUiConfigError("form \u5FC5\u987B\u662F\u5F62\u6001\u540D\uFF08\u9003\u751F\u95E8\uFF0C\u7701\u7565\u5219\u7531\u52A8\u8BCD\u5206\u6D3E\uFF09", `${path}.form`);
|
|
6792
|
+
}
|
|
6793
|
+
declaration.form = form;
|
|
6794
|
+
}
|
|
6795
|
+
if (bound !== void 0) {
|
|
6796
|
+
const unknownKey = isOouiMap(bound) ? findOouiBindingUnknownKey(bound) : void 0;
|
|
6797
|
+
if (unknownKey !== void 0) {
|
|
6798
|
+
throw new SomaUiConfigError(
|
|
6799
|
+
`bound_to \u4E0D\u652F\u6301\u952E "${unknownKey}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_BINDING_KEYS.join(" / ")}\uFF09\u2014\u2014\u8054\u52A8\u53EA\u8BA4\u6E90\u533A\u57DF\u4E0E\u8BED\u4E49\u4E8B\u4EF6\u4E24\u9879\uFF0C\u591A\u5199\u7684\u952E\u4E0D\u4F1A\u88AB\u4EFB\u4F55\u4E00\u5C42\u8BFB\u5230`,
|
|
6800
|
+
`${path}.bound_to.${unknownKey}`
|
|
6801
|
+
);
|
|
6802
|
+
}
|
|
6803
|
+
if (!isOouiBinding(bound)) {
|
|
6804
|
+
throw new SomaUiConfigError(
|
|
6805
|
+
"bound_to \u5FC5\u987B\u662F { region, as } \u4E24\u9879\u4FF1\u5168\u7684\u6620\u5C04\uFF08region \u662F\u53E6\u4E00\u4E2A\u951A\u70B9\u540D\uFF0Cas \u662F\u8BED\u4E49\u4E8B\u4EF6\u540D\uFF09",
|
|
6806
|
+
`${path}.bound_to`
|
|
6807
|
+
);
|
|
6808
|
+
}
|
|
6809
|
+
declaration.bound_to = { region: bound.region, as: bound.as };
|
|
6810
|
+
}
|
|
6811
|
+
if (layout !== void 0) {
|
|
6812
|
+
if (!isOouiLayout(layout)) {
|
|
6813
|
+
const problem = isOouiMap(layout) ? findOouiLayoutProblem(layout) : void 0;
|
|
6814
|
+
throw new SomaUiConfigError(
|
|
6815
|
+
oouiLayoutProblemMessage(layout, problem),
|
|
6816
|
+
problem === void 0 ? `${path}.layout` : `${path}.layout.${problem.key}`
|
|
6817
|
+
);
|
|
6818
|
+
}
|
|
6819
|
+
declaration.layout = layout;
|
|
6820
|
+
}
|
|
6821
|
+
out[anchor] = declaration;
|
|
6822
|
+
}
|
|
6823
|
+
return out;
|
|
6824
|
+
}
|
|
6825
|
+
function oouiLayoutProblemMessage(layout, problem) {
|
|
6826
|
+
if (problem === void 0) return `layout \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53EF\u7528\u952E\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
|
|
6827
|
+
if (problem.kind === "unknown-key") {
|
|
6828
|
+
return `layout \u4E0D\u652F\u6301\u952E "${problem.key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
|
|
6829
|
+
}
|
|
6830
|
+
if (problem.kind === "sizing-unknown") {
|
|
6831
|
+
return `layout.sizing \u53EA\u80FD\u662F ${SOMA_OOUI_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(layout.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"\uFF1B\u7701\u7565\u5373 fill`;
|
|
6832
|
+
}
|
|
6833
|
+
return `layout.${problem.key} \u5FC5\u987B\u662F ${problem.expected === "number" ? "\u6570\u5B57" : "\u5B57\u7B26\u4E32"}`;
|
|
6834
|
+
}
|
|
6835
|
+
function parseOouiArtifact(raw2) {
|
|
6836
|
+
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
6837
|
+
throw new SomaUiConfigError("ooui_artifact \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u6784\u5EFA\u671F\u6F14\u7ECE\u4EA7\u7269\uFF0C\u4E0D\u624B\u5199\uFF09", "ooui_artifact");
|
|
6838
|
+
}
|
|
6839
|
+
const entry = raw2;
|
|
6840
|
+
if (entry.version !== 1) {
|
|
6841
|
+
throw new SomaUiConfigError(
|
|
6842
|
+
`ooui_artifact.version \u5FC5\u987B\u662F 1\uFF0C\u6536\u5230 ${JSON.stringify(entry.version)}\u2014\u2014\u7248\u672C\u5BF9\u4E0D\u4E0A\u7684\u4EA7\u7269\u6574\u4EFD\u4E0D\u53EF\u4FE1\uFF0C\u6309\u65E7\u5B57\u6BB5\u540D\u8BFB\u51FA\u6765\u7684\u754C\u9762\u662F\u8C01\u90FD\u6CA1\u8BBE\u8BA1\u8FC7\u7684\u6837\u5B50`,
|
|
6843
|
+
"ooui_artifact.version"
|
|
6844
|
+
);
|
|
6845
|
+
}
|
|
6846
|
+
if (!Array.isArray(entry.regions)) {
|
|
6847
|
+
throw new SomaUiConfigError("ooui_artifact.regions \u5FC5\u987B\u662F\u6570\u7EC4", "ooui_artifact.regions");
|
|
6848
|
+
}
|
|
6849
|
+
for (const [index, region] of entry.regions.entries()) {
|
|
6850
|
+
if (!region || typeof region !== "object" || Array.isArray(region) || typeof region.anchor !== "string") {
|
|
6851
|
+
throw new SomaUiConfigError("\u6BCF\u4E2A region \u5FC5\u987B\u662F\u6620\u5C04\u4E14\u5E26 anchor\uFF08\u951A\u70B9 id\uFF09", `ooui_artifact.regions[${index}]`);
|
|
6852
|
+
}
|
|
6853
|
+
}
|
|
6854
|
+
const artifact = {
|
|
6855
|
+
version: 1,
|
|
6856
|
+
regions: entry.regions
|
|
6857
|
+
};
|
|
6858
|
+
const hasCss = typeof entry.css === "string" && entry.css.trim() !== "";
|
|
6859
|
+
if (entry.css !== void 0 && typeof entry.css !== "string") {
|
|
6860
|
+
throw new SomaUiConfigError("ooui_artifact.css \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", "ooui_artifact.css");
|
|
6861
|
+
}
|
|
6862
|
+
if (hasCss) {
|
|
6863
|
+
const key = entry.css_key;
|
|
6864
|
+
if (typeof key !== "string" || !OOUI_CSS_KEY_PATTERN.test(key)) {
|
|
6865
|
+
throw new SomaUiConfigError(
|
|
6866
|
+
`ooui_artifact.css \u5B58\u5728\u65F6\u5FC5\u987B\u5E26\u5185\u5BB9\u54C8\u5E0C\u952E css_key\uFF08\u5F62\u5982 ooui:0a1b2c3d\uFF09\uFF0C\u6536\u5230 ${JSON.stringify(key)}\u2014\u2014\u6837\u5F0F\u6CE8\u5165\u6CA1\u6709\u5185\u5BB9\u51B2\u7A81\u68C0\u6D4B\uFF0C\u8BED\u4E49\u540D\u4F1A\u8BA9 SPA \u8DEF\u7531\u5207\u9875\u65F6\u9759\u9ED8\u6CBF\u7528\u4E0A\u4E00\u9875\u7684 CSS`,
|
|
6867
|
+
"ooui_artifact.css_key"
|
|
6868
|
+
);
|
|
6869
|
+
}
|
|
6870
|
+
artifact.css = entry.css;
|
|
6871
|
+
artifact.css_key = key;
|
|
6872
|
+
}
|
|
6873
|
+
return artifact;
|
|
6874
|
+
}
|
|
6671
6875
|
function parseLayoutSection(raw2) {
|
|
6672
6876
|
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
6673
6877
|
throw new SomaUiConfigError("layout \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { gap, wrap, <\u5B50\u9879>: { sizing, \u2026 } } }", "layout");
|
|
@@ -7978,7 +8182,7 @@ var SomaEventEngine = class {
|
|
|
7978
8182
|
* 避免点击 product_name 等子节点时,closest 停在无事件的子 id 上。
|
|
7979
8183
|
*/
|
|
7980
8184
|
resolveEventBinding(eventType, start, domEvent) {
|
|
7981
|
-
let el = start instanceof
|
|
8185
|
+
let el = start instanceof Element ? start : null;
|
|
7982
8186
|
while (el && el !== this.container) {
|
|
7983
8187
|
const somaId = this.adapter.getAnchorId(el);
|
|
7984
8188
|
if (somaId) {
|
|
@@ -11090,6 +11294,152 @@ var SOMA_DATA_FIELD_TYPES = [
|
|
|
11090
11294
|
"cascade",
|
|
11091
11295
|
...Object.keys(SOMA_DATA_FIELD_TYPE_ALIASES)
|
|
11092
11296
|
];
|
|
11297
|
+
var SOMA_DATA_OBJECT_ROLES = [
|
|
11298
|
+
"id",
|
|
11299
|
+
"title",
|
|
11300
|
+
"subtitle",
|
|
11301
|
+
"status",
|
|
11302
|
+
"timestamp",
|
|
11303
|
+
"amount",
|
|
11304
|
+
"baseline"
|
|
11305
|
+
];
|
|
11306
|
+
var SOMA_DATA_RELATION_CARDINALITIES = [
|
|
11307
|
+
"one",
|
|
11308
|
+
"many"
|
|
11309
|
+
];
|
|
11310
|
+
|
|
11311
|
+
// core/shared/object-semantics.ts
|
|
11312
|
+
var IDENTIFIER = /^[a-zA-Z_]\w*$/;
|
|
11313
|
+
var RELATION_KEYS = ["name", "to", "cardinality", "via"];
|
|
11314
|
+
function isPlainObject4(value) {
|
|
11315
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11316
|
+
}
|
|
11317
|
+
function fieldList(fieldKeys) {
|
|
11318
|
+
return fieldKeys.length > 0 ? fieldKeys.join(" / ") : "\uFF08\u7A7A\uFF09";
|
|
11319
|
+
}
|
|
11320
|
+
function validateObjectRoles(raw2, fieldKeys) {
|
|
11321
|
+
if (raw2 === void 0 || raw2 === null) return [];
|
|
11322
|
+
if (!isPlainObject4(raw2)) {
|
|
11323
|
+
return ["roles \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u89D2\u8272\u540D \u2192 \u5B57\u6BB5\u540D\uFF09\uFF0C\u5982 `roles: { title: no, status: state }`"];
|
|
11324
|
+
}
|
|
11325
|
+
const entries = Object.entries(raw2);
|
|
11326
|
+
if (entries.length === 0) {
|
|
11327
|
+
return ["roles \u662F\u7A7A\u6620\u5C04\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u4E2A\u89D2\u8272"];
|
|
11328
|
+
}
|
|
11329
|
+
if (fieldKeys.length === 0) {
|
|
11330
|
+
return [
|
|
11331
|
+
"roles \u7684\u503C\u662F\u5B57\u6BB5\u540D\uFF0C\u4F46\u672C\u5BF9\u8C61\u6CA1\u6709\u58F0\u660E fields\uFF0C\u4EFB\u4F55\u89D2\u8272\u90FD\u65E0\u4ECE\u5BF9\u8D26\u2014\u2014\u8BF7\u5148\u8865 `fields:` \u5B57\u6BB5\u5B57\u5178\uFF0C\u518D\u58F0\u660E roles"
|
|
11332
|
+
];
|
|
11333
|
+
}
|
|
11334
|
+
const issues = [];
|
|
11335
|
+
const known = SOMA_DATA_OBJECT_ROLES;
|
|
11336
|
+
for (const [role, target] of entries) {
|
|
11337
|
+
if (!known.includes(role)) {
|
|
11338
|
+
issues.push(
|
|
11339
|
+
`\u672A\u77E5\u7684\u89D2\u8272 "${role}"\uFF08\u5C01\u95ED\u96C6\uFF1A${known.join(" / ")}\uFF09\u2014\u2014\u89D2\u8272\u8868\u662F\u5C01\u95ED\u96C6\uFF0C\u52A0\u4E00\u4E2A\u89D2\u8272\u662F\u4E00\u6B21\u4F53\u7CFB\u51B3\u7B56\uFF0C\u4E0D\u5728\u58F0\u660E\u91CC\u4E34\u65F6\u6269`
|
|
11340
|
+
);
|
|
11341
|
+
continue;
|
|
11342
|
+
}
|
|
11343
|
+
if (typeof target !== "string" || target.trim() === "") {
|
|
11344
|
+
issues.push(`\u89D2\u8272 "${role}" \u7684\u503C\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
|
|
11345
|
+
continue;
|
|
11346
|
+
}
|
|
11347
|
+
if (!fieldKeys.includes(target)) {
|
|
11348
|
+
issues.push(
|
|
11349
|
+
`\u89D2\u8272 "${role}" \u6307\u5411\u5B57\u6BB5 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(fieldKeys)}\uFF09\u2014\u2014\u6307\u9519\u7684\u540E\u679C\u662F\u90A3\u4E00\u4F4D\u9759\u9ED8\u7559\u7A7A\uFF0C\u9875\u9762\u7167\u5E38\u6E32\u67D3`
|
|
11350
|
+
);
|
|
11351
|
+
}
|
|
11352
|
+
}
|
|
11353
|
+
return issues;
|
|
11354
|
+
}
|
|
11355
|
+
function validateObjectRelations(raw2, ctx) {
|
|
11356
|
+
if (raw2 === void 0 || raw2 === null) return [];
|
|
11357
|
+
if (!Array.isArray(raw2)) {
|
|
11358
|
+
return [
|
|
11359
|
+
"relations \u5FC5\u987B\u662F\u6570\u7EC4\uFF0C\u5982 `relations: [{ name: items, to: order_item, cardinality: many, via: order_no }]`"
|
|
11360
|
+
];
|
|
11361
|
+
}
|
|
11362
|
+
if (raw2.length === 0) {
|
|
11363
|
+
return ["relations \u662F\u7A7A\u6570\u7EC4\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u6761\u5173\u7CFB"];
|
|
11364
|
+
}
|
|
11365
|
+
const issues = [];
|
|
11366
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11367
|
+
const cardinalities = SOMA_DATA_RELATION_CARDINALITIES;
|
|
11368
|
+
raw2.forEach((entry, index) => {
|
|
11369
|
+
const at = `relations[${index}]`;
|
|
11370
|
+
if (!isPlainObject4(entry)) {
|
|
11371
|
+
issues.push(`${at} \u5FC5\u987B\u662F\u5BF9\u8C61\uFF08name / to / cardinality / via\uFF09`);
|
|
11372
|
+
return;
|
|
11373
|
+
}
|
|
11374
|
+
for (const key of Object.keys(entry)) {
|
|
11375
|
+
if (!RELATION_KEYS.includes(key)) {
|
|
11376
|
+
issues.push(`${at} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${RELATION_KEYS.join(" / ")}\uFF09`);
|
|
11377
|
+
}
|
|
11378
|
+
}
|
|
11379
|
+
const { name, to, cardinality, via } = entry;
|
|
11380
|
+
if (typeof name !== "string" || !IDENTIFIER.test(name)) {
|
|
11381
|
+
issues.push(`${at}.name \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD/\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(name)}`);
|
|
11382
|
+
} else if (seen.has(name)) {
|
|
11383
|
+
issues.push(
|
|
11384
|
+
`${at}.name "${name}" \u4E0E\u524D\u9762\u7684\u5173\u7CFB\u91CD\u540D\u2014\u2014\`through\` \u6309\u540D\u5B57\u5F15\u7528\u5173\u7CFB\uFF0C\u91CD\u540D\u7B49\u4E8E\u8BA9\u5B83\u6307\u5411\u4E24\u4E2A\u5730\u65B9`
|
|
11385
|
+
);
|
|
11386
|
+
} else {
|
|
11387
|
+
seen.add(name);
|
|
11388
|
+
}
|
|
11389
|
+
if (typeof to !== "string" || !IDENTIFIER.test(to)) {
|
|
11390
|
+
issues.push(`${at}.to \u5FC5\u987B\u662F\u6570\u636E\u5BF9\u8C61\u540D\uFF08\u6807\u8BC6\u7B26\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(to)}`);
|
|
11391
|
+
} else if (ctx.objectNames !== void 0 && !ctx.objectNames.includes(to)) {
|
|
11392
|
+
issues.push(
|
|
11393
|
+
`${at}.to \u6307\u5411\u672A\u58F0\u660E\u7684\u6570\u636E\u5BF9\u8C61 "${to}"\uFF08\u672C\u6B21\u58F0\u660E\u91CC\u6709\uFF1A${ctx.objectNames.length > 0 ? ctx.objectNames.join(" / ") : "\uFF08\u7A7A\uFF09"}\uFF09\u2014\u2014\u628A\u76EE\u6807\u5BF9\u8C61\u4E5F\u58F0\u660E\u8FDB data\uFF0C\u6216\u5220\u6389\u8FD9\u6761\u5173\u7CFB\uFF1B\u7559\u7740\u5B83\u4F1A\u8BA9 navigate / compare \u53D6\u4E0D\u5230\u76EE\u6807\u5B57\u5178\uFF0C\u6F14\u7ECE\u51FA\u4E00\u7247\u7A7A\u767D\u800C\u4E0D\u662F\u62A5\u9519`
|
|
11394
|
+
);
|
|
11395
|
+
}
|
|
11396
|
+
if (typeof cardinality !== "string" || !cardinalities.includes(cardinality)) {
|
|
11397
|
+
issues.push(
|
|
11398
|
+
`${at}.cardinality \u5FC5\u987B\u662F ${cardinalities.join(" / ")}\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(cardinality)}\u2014\u2014\u57FA\u6570\u51B3\u5B9A\u7684\u662F"\u6F14\u7ECE\u6210\u4E00\u683C\u8FD8\u662F\u4E00\u5217"\uFF0C\u731C\u4E0D\u5F97`
|
|
11399
|
+
);
|
|
11400
|
+
}
|
|
11401
|
+
if (via !== void 0) {
|
|
11402
|
+
if (typeof via !== "string" || via.trim() === "") {
|
|
11403
|
+
issues.push(`${at}.via \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(via)}`);
|
|
11404
|
+
} else if (!ctx.fieldKeys.includes(via)) {
|
|
11405
|
+
issues.push(
|
|
11406
|
+
`${at}.via \u6307\u5411\u5B57\u6BB5 "${via}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(ctx.fieldKeys)}\uFF09`
|
|
11407
|
+
);
|
|
11408
|
+
}
|
|
11409
|
+
}
|
|
11410
|
+
});
|
|
11411
|
+
return issues;
|
|
11412
|
+
}
|
|
11413
|
+
function validateFieldModifies(fields) {
|
|
11414
|
+
const issues = [];
|
|
11415
|
+
const keys = Object.keys(fields);
|
|
11416
|
+
for (const key of keys) {
|
|
11417
|
+
const target = fields[key]?.modifies;
|
|
11418
|
+
if (target === void 0) continue;
|
|
11419
|
+
if (typeof target !== "string" || target.trim() === "") {
|
|
11420
|
+
issues.push(`\u5B57\u6BB5 "${key}" \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
|
|
11421
|
+
continue;
|
|
11422
|
+
}
|
|
11423
|
+
if (target === key) {
|
|
11424
|
+
issues.push(
|
|
11425
|
+
`\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411\u5B83\u81EA\u5DF1\u2014\u2014\u4FEE\u9970\u5173\u7CFB\u8BF4\u7684\u662F"\u6211\u662F\u522B\u4EBA\u7684\u8BED\u6C14/\u5355\u4F4D/\u56FE\u6807"\uFF0C\u81EA\u6307\u6CA1\u6709\u53EF\u6267\u884C\u542B\u4E49`
|
|
11426
|
+
);
|
|
11427
|
+
continue;
|
|
11428
|
+
}
|
|
11429
|
+
if (!(target in fields)) {
|
|
11430
|
+
issues.push(
|
|
11431
|
+
`\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(keys)}\uFF09\u2014\u2014\u6307\u9519\u5219\u672C\u5B57\u6BB5\u4E0D\u4F1A\u88AB\u5E76\u5165\u88AB\u4FEE\u9970\u8005\uFF0C\u800C\u662F\u81EA\u5DF1\u5360\u4E00\u683C\uFF0C\u9875\u9762\u4E0A\u591A\u51FA\u4E00\u884C\u7A7A\u503C`
|
|
11432
|
+
);
|
|
11433
|
+
continue;
|
|
11434
|
+
}
|
|
11435
|
+
if (fields[target].modifies !== void 0) {
|
|
11436
|
+
issues.push(
|
|
11437
|
+
`\u5B57\u6BB5 "${key}" \u4FEE\u9970 "${target}"\uFF0C\u800C "${target}" \u81EA\u5DF1\u4E5F\u5E26 modifies\u2014\u2014\u4FEE\u9970\u4E0D\u53EF\u7EA7\u8054\uFF08\u8BF7\u8BA9 "${key}" \u76F4\u63A5\u6307\u5411\u6700\u7EC8\u88AB\u4FEE\u9970\u7684\u90A3\u4E2A\u5B57\u6BB5\uFF09`
|
|
11438
|
+
);
|
|
11439
|
+
}
|
|
11440
|
+
}
|
|
11441
|
+
return issues;
|
|
11442
|
+
}
|
|
11093
11443
|
|
|
11094
11444
|
// core/shared/types/reaction.types.ts
|
|
11095
11445
|
var SOMA_REACTION_PHASES = [
|
|
@@ -11140,7 +11490,7 @@ var DIGIT = /[0-9]/;
|
|
|
11140
11490
|
function tokenize(source) {
|
|
11141
11491
|
const tokens = [];
|
|
11142
11492
|
let i = 0;
|
|
11143
|
-
const
|
|
11493
|
+
const fail = (message, from, to) => {
|
|
11144
11494
|
throw new SomaCalcSyntaxError(message, source, [from, to]);
|
|
11145
11495
|
};
|
|
11146
11496
|
while (i < source.length) {
|
|
@@ -11150,19 +11500,19 @@ function tokenize(source) {
|
|
|
11150
11500
|
continue;
|
|
11151
11501
|
}
|
|
11152
11502
|
if (char === "\n" || char === "\r") {
|
|
11153
|
-
|
|
11503
|
+
fail("\u8868\u8FBE\u5F0F\u4E0D\u80FD\u6362\u884C\uFF08\u5B83\u662F\u4E00\u4E2A YAML \u6807\u91CF\uFF0C\u4E0D\u662F\u5757\uFF09", i, i + 1);
|
|
11154
11504
|
}
|
|
11155
11505
|
const start = i;
|
|
11156
11506
|
if (char === "[") {
|
|
11157
11507
|
i += 1;
|
|
11158
11508
|
const nameStart = i;
|
|
11159
11509
|
while (i < source.length && source[i] !== "]") i += 1;
|
|
11160
|
-
if (i >= source.length)
|
|
11510
|
+
if (i >= source.length) fail('\u5B57\u6BB5\u5F15\u7528\u7F3A\u5C11\u95ED\u5408\u7684 "]"', start, source.length);
|
|
11161
11511
|
const name = source.slice(nameStart, i);
|
|
11162
11512
|
i += 1;
|
|
11163
|
-
if (name === "")
|
|
11513
|
+
if (name === "") fail("\u5B57\u6BB5\u5F15\u7528\u4E0D\u80FD\u4E3A\u7A7A\uFF08\u5199\u6210 [\u5B57\u6BB5\u540D]\uFF09", start, i);
|
|
11164
11514
|
if (!IDENT_START.test(name[0]) || ![...name].every((c) => IDENT_PART.test(c))) {
|
|
11165
|
-
|
|
11515
|
+
fail(`\u5B57\u6BB5\u540D "${name}" \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF1B\u6D3E\u751F\u5217\u53EA\u80FD\u5F15\u7528\u540C\u5C42\u5B57\u6BB5\uFF0C\u4E0D\u652F\u6301 . \u6DF1\u53D6`, start, i);
|
|
11166
11516
|
}
|
|
11167
11517
|
tokens.push({ kind: "ref", value: name, pos: [start, i] });
|
|
11168
11518
|
continue;
|
|
@@ -11171,12 +11521,12 @@ function tokenize(source) {
|
|
|
11171
11521
|
i += 1;
|
|
11172
11522
|
const textStart = i;
|
|
11173
11523
|
while (i < source.length && source[i] !== "#") i += 1;
|
|
11174
|
-
if (i >= source.length)
|
|
11524
|
+
if (i >= source.length) fail('\u65E5\u671F\u5B57\u9762\u91CF\u7F3A\u5C11\u95ED\u5408\u7684 "#"', start, source.length);
|
|
11175
11525
|
const text = source.slice(textStart, i);
|
|
11176
11526
|
i += 1;
|
|
11177
11527
|
const ms = parseDateLiteral(text);
|
|
11178
11528
|
if (ms === null) {
|
|
11179
|
-
|
|
11529
|
+
fail(`\u65E5\u671F\u5B57\u9762\u91CF "${text}" \u4E0D\u5408\u6CD5\uFF08\u53EA\u8BA4 #YYYY-MM-DD# \u4E0E #YYYY-MM-DDTHH:mm#\uFF09`, start, i);
|
|
11180
11530
|
}
|
|
11181
11531
|
tokens.push({ kind: "date", value: ms, pos: [start, i] });
|
|
11182
11532
|
continue;
|
|
@@ -11185,11 +11535,11 @@ function tokenize(source) {
|
|
|
11185
11535
|
i += 1;
|
|
11186
11536
|
let text = "";
|
|
11187
11537
|
while (i < source.length && source[i] !== '"') {
|
|
11188
|
-
if (source[i] === "\n")
|
|
11538
|
+
if (source[i] === "\n") fail("\u5B57\u7B26\u4E32\u4E0D\u80FD\u8DE8\u884C", start, i);
|
|
11189
11539
|
if (source[i] === "\\") {
|
|
11190
11540
|
const next = source[i + 1];
|
|
11191
11541
|
if (next !== '"' && next !== "\\") {
|
|
11192
|
-
|
|
11542
|
+
fail(`\u5B57\u7B26\u4E32\u91CC\u53EA\u5141\u8BB8 \\" \u4E0E \\\\ \u4E24\u79CD\u8F6C\u4E49\uFF0C\u6536\u5230 "\\${String(next ?? "")}"`, i, i + 2);
|
|
11193
11543
|
}
|
|
11194
11544
|
text += next;
|
|
11195
11545
|
i += 2;
|
|
@@ -11198,7 +11548,7 @@ function tokenize(source) {
|
|
|
11198
11548
|
text += source[i];
|
|
11199
11549
|
i += 1;
|
|
11200
11550
|
}
|
|
11201
|
-
if (i >= source.length)
|
|
11551
|
+
if (i >= source.length) fail("\u5B57\u7B26\u4E32\u7F3A\u5C11\u95ED\u5408\u7684\u53CC\u5F15\u53F7", start, source.length);
|
|
11202
11552
|
i += 1;
|
|
11203
11553
|
tokens.push({ kind: "string", value: text, pos: [start, i] });
|
|
11204
11554
|
continue;
|
|
@@ -11207,11 +11557,11 @@ function tokenize(source) {
|
|
|
11207
11557
|
while (i < source.length && DIGIT.test(source[i])) i += 1;
|
|
11208
11558
|
if (source[i] === ".") {
|
|
11209
11559
|
i += 1;
|
|
11210
|
-
if (!DIGIT.test(source[i] ?? ""))
|
|
11560
|
+
if (!DIGIT.test(source[i] ?? "")) fail("\u5C0F\u6570\u70B9\u540E\u7F3A\u5C11\u6570\u5B57", start, i + 1);
|
|
11211
11561
|
while (i < source.length && DIGIT.test(source[i])) i += 1;
|
|
11212
11562
|
}
|
|
11213
11563
|
if (source[i] === "e" || source[i] === "E") {
|
|
11214
|
-
|
|
11564
|
+
fail("\u4E0D\u652F\u6301\u79D1\u5B66\u8BA1\u6570\u6CD5\u2014\u2014\u6D3E\u751F\u5217\u7684\u6570\u503C\u5E94\u5F53\u662F\u4EBA\u80FD\u4E00\u773C\u8BFB\u61C2\u7684\u5B57\u9762\u91CF", start, i + 1);
|
|
11215
11565
|
}
|
|
11216
11566
|
tokens.push({ kind: "number", value: Number(source.slice(start, i)), pos: [start, i] });
|
|
11217
11567
|
continue;
|
|
@@ -11227,7 +11577,7 @@ function tokenize(source) {
|
|
|
11227
11577
|
tokens.push({ kind: "ident", value: word, pos: [start, i] });
|
|
11228
11578
|
continue;
|
|
11229
11579
|
}
|
|
11230
|
-
|
|
11580
|
+
fail(
|
|
11231
11581
|
`\u672A\u77E5\u7684\u6807\u8BC6\u7B26 "${word}"\u3002\u5B57\u6BB5\u8981\u5199\u6210 [${word}]\uFF1B\u51FD\u6570\u53EA\u6709 ${CALC_FUNCTIONS.join(" / ")}`,
|
|
11232
11582
|
start,
|
|
11233
11583
|
i
|
|
@@ -11255,7 +11605,7 @@ function tokenize(source) {
|
|
|
11255
11605
|
continue;
|
|
11256
11606
|
}
|
|
11257
11607
|
const hint = char === "=" ? "\u5224\u65AD\u76F8\u7B49\u8981\u5199 ==" : char === "&" ? "\u5E76\u4E14\u8981\u5199\u6210 IF \u7684\u5D4C\u5957\uFF1Bcalc \u4E0D\u652F\u6301\u903B\u8F91\u8FD0\u7B97\u7B26" : char === "|" ? "\u6216\u8005\u8981\u5199\u6210 IF \u7684\u5D4C\u5957\uFF1Bcalc \u4E0D\u652F\u6301\u903B\u8F91\u8FD0\u7B97\u7B26" : char === "!" ? "\u4E0D\u7B49\u8981\u5199 !=" : char === "'" ? "\u5B57\u7B26\u4E32\u8981\u7528\u53CC\u5F15\u53F7\uFF08\u5355\u5F15\u53F7\u662F YAML \u7684\u5F15\u53F7\uFF09" : "\u5B83\u4E0D\u5728 calc \u7684\u8BCD\u6CD5\u8868\u91CC";
|
|
11258
|
-
|
|
11608
|
+
fail(`\u65E0\u6CD5\u8BC6\u522B\u7684\u5B57\u7B26 "${char}"\u2014\u2014${hint}`, start, i + 1);
|
|
11259
11609
|
}
|
|
11260
11610
|
tokens.push({ kind: "eof", value: "", pos: [source.length, source.length] });
|
|
11261
11611
|
return tokens;
|
|
@@ -11291,12 +11641,12 @@ function parseCalc(source) {
|
|
|
11291
11641
|
let at = 0;
|
|
11292
11642
|
const peek = () => tokens[at];
|
|
11293
11643
|
const next = () => tokens[at++];
|
|
11294
|
-
const
|
|
11644
|
+
const fail = (message, token) => {
|
|
11295
11645
|
throw new SomaCalcSyntaxError(message, source, token.pos);
|
|
11296
11646
|
};
|
|
11297
11647
|
const expect = (kind, what) => {
|
|
11298
11648
|
const token = peek();
|
|
11299
|
-
if (token.kind !== kind)
|
|
11649
|
+
if (token.kind !== kind) fail(`\u7F3A\u5C11${what}`, token);
|
|
11300
11650
|
return next();
|
|
11301
11651
|
};
|
|
11302
11652
|
const parseCmp = () => {
|
|
@@ -11307,7 +11657,7 @@ function parseCalc(source) {
|
|
|
11307
11657
|
const right = parseSum();
|
|
11308
11658
|
const after = peek();
|
|
11309
11659
|
if (after.kind === "op" && CMP_OPS.includes(String(after.value))) {
|
|
11310
|
-
|
|
11660
|
+
fail("\u6BD4\u8F83\u4E0D\u80FD\u8FDE\u5199\uFF08a < b < c \u51E0\u4E4E\u603B\u662F\u5199\u9519\u4E86\u610F\u601D\uFF09\u2014\u2014\u8BF7\u62C6\u6210\u4E24\u4E2A IF \u6216\u6539\u7528 between \u8C13\u8BCD", after);
|
|
11311
11661
|
}
|
|
11312
11662
|
return { k: "bin", op: String(token.value), left, right, pos: [left.pos[0], right.pos[1]] };
|
|
11313
11663
|
}
|
|
@@ -11363,11 +11713,11 @@ function parseCalc(source) {
|
|
|
11363
11713
|
case "ident":
|
|
11364
11714
|
return parseCall(token);
|
|
11365
11715
|
case "op":
|
|
11366
|
-
return
|
|
11716
|
+
return fail(`\u8FD0\u7B97\u7B26 "${String(token.value)}" \u524D\u9762\u7F3A\u5C11\u64CD\u4F5C\u6570`, token);
|
|
11367
11717
|
case "eof":
|
|
11368
|
-
return
|
|
11718
|
+
return fail("\u8868\u8FBE\u5F0F\u4E0D\u5B8C\u6574", token);
|
|
11369
11719
|
default:
|
|
11370
|
-
return
|
|
11720
|
+
return fail(`\u610F\u5916\u7684 "${String(token.value)}"`, token);
|
|
11371
11721
|
}
|
|
11372
11722
|
};
|
|
11373
11723
|
const parseCall = (name) => {
|
|
@@ -11381,7 +11731,7 @@ function parseCalc(source) {
|
|
|
11381
11731
|
if (fn === "ROUND" && args.length === 1) {
|
|
11382
11732
|
const digits = peek();
|
|
11383
11733
|
if (digits.kind !== "number" || !Number.isInteger(digits.value) || digits.value < 0 || digits.value > 6) {
|
|
11384
|
-
|
|
11734
|
+
fail("ROUND \u7684\u7B2C\u4E8C\u53C2\u5FC5\u987B\u662F 0~6 \u7684\u6574\u6570\u5B57\u9762\u91CF", digits);
|
|
11385
11735
|
}
|
|
11386
11736
|
next();
|
|
11387
11737
|
args.push({ k: "num", v: digits.value, pos: digits.pos });
|
|
@@ -11394,14 +11744,14 @@ function parseCalc(source) {
|
|
|
11394
11744
|
const [min, max] = ARITY[fn];
|
|
11395
11745
|
if (args.length < min || args.length > max) {
|
|
11396
11746
|
const want = max === Infinity ? `\u81F3\u5C11 ${min} \u4E2A` : min === max ? `${min} \u4E2A` : `${min}~${max} \u4E2A`;
|
|
11397
|
-
|
|
11747
|
+
fail(`${fn} \u9700\u8981${want}\u53C2\u6570\uFF0C\u6536\u5230 ${args.length} \u4E2A`, name);
|
|
11398
11748
|
}
|
|
11399
11749
|
return { k: "call", fn, args, pos: [name.pos[0], close.pos[1]] };
|
|
11400
11750
|
};
|
|
11401
11751
|
const ast = parseCmp();
|
|
11402
11752
|
const rest = peek();
|
|
11403
11753
|
if (rest.kind !== "eof") {
|
|
11404
|
-
|
|
11754
|
+
fail(`\u8868\u8FBE\u5F0F\u5728\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E86\uFF0C\u540E\u9762\u7684 "${String(rest.value)}" \u662F\u591A\u4F59\u7684`, rest);
|
|
11405
11755
|
}
|
|
11406
11756
|
return ast;
|
|
11407
11757
|
}
|
|
@@ -11686,8 +12036,8 @@ var CONFIG_KEYS2 = /* @__PURE__ */ new Set(["when", "depends", "on", "target", "
|
|
|
11686
12036
|
var CALC_WRITABLE = /* @__PURE__ */ new Set(["int", "float", "money", "percent", "progress", "text", "url", "enum", "date", "datetime"]);
|
|
11687
12037
|
function parseReactions(input, deps) {
|
|
11688
12038
|
const { raw: raw2, fields, named, path } = input;
|
|
11689
|
-
const { fail
|
|
11690
|
-
if (!Array.isArray(raw2))
|
|
12039
|
+
const { fail } = deps;
|
|
12040
|
+
if (!Array.isArray(raw2)) fail("reactions \u5FC5\u987B\u662F\u6570\u7EC4", path);
|
|
11691
12041
|
const list = raw2;
|
|
11692
12042
|
const fieldKeys = Object.keys(fields);
|
|
11693
12043
|
const fieldTypes = Object.fromEntries(
|
|
@@ -11697,50 +12047,50 @@ function parseReactions(input, deps) {
|
|
|
11697
12047
|
list.forEach((entry, index) => {
|
|
11698
12048
|
const at = `${path}[${index}]`;
|
|
11699
12049
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
11700
|
-
|
|
12050
|
+
fail("\u6BCF\u6761\u53CD\u5E94\u5FC5\u987B\u662F\u5BF9\u8C61", at);
|
|
11701
12051
|
}
|
|
11702
12052
|
const box = entry;
|
|
11703
12053
|
for (const key of Object.keys(box)) {
|
|
11704
12054
|
if (!CONFIG_KEYS2.has(key)) {
|
|
11705
|
-
|
|
12055
|
+
fail(`\u672A\u77E5\u7684\u53CD\u5E94\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS2].join(" / ")}\uFF09`, `${at}.${key}`);
|
|
11706
12056
|
}
|
|
11707
12057
|
}
|
|
11708
12058
|
const phaseRaw = box.on === void 0 ? "field_value_change" : String(box.on);
|
|
11709
12059
|
if (!PHASES.has(phaseRaw)) {
|
|
11710
|
-
|
|
12060
|
+
fail(`\u672A\u77E5\u7684\u89E6\u53D1\u65F6\u673A "${phaseRaw}"\uFF08\u652F\u6301: ${SOMA_REACTION_PHASES.join(" / ")}\uFF09`, `${at}.on`);
|
|
11711
12061
|
}
|
|
11712
12062
|
const phase = phaseRaw;
|
|
11713
12063
|
const reads = /* @__PURE__ */ new Set();
|
|
11714
12064
|
if (box.when !== void 0) {
|
|
11715
12065
|
const issues = validatePredicate(box.when, fieldKeys, `${at}.when`, { fieldTypes, named });
|
|
11716
|
-
if (issues.length > 0)
|
|
12066
|
+
if (issues.length > 0) fail(issues.join("\uFF1B"), `${at}.when`);
|
|
11717
12067
|
for (const field of collectPredicateFields(box.when, named)) reads.add(field);
|
|
11718
12068
|
}
|
|
11719
12069
|
if (box.depends !== void 0) {
|
|
11720
|
-
if (!Array.isArray(box.depends))
|
|
12070
|
+
if (!Array.isArray(box.depends)) fail("depends \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4", `${at}.depends`);
|
|
11721
12071
|
for (const item of box.depends) {
|
|
11722
12072
|
const field = String(item ?? "");
|
|
11723
12073
|
if (!fieldKeys.includes(field)) {
|
|
11724
|
-
|
|
12074
|
+
fail(`depends \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${field}"`, `${at}.depends`);
|
|
11725
12075
|
}
|
|
11726
12076
|
reads.add(field);
|
|
11727
12077
|
}
|
|
11728
12078
|
}
|
|
11729
12079
|
if (box.when === void 0 && box.depends === void 0) {
|
|
11730
|
-
|
|
12080
|
+
fail(
|
|
11731
12081
|
"when \u4E0E depends \u81F3\u5C11\u8981\u7ED9\u4E00\u4E2A\u2014\u2014\u4E24\u4E2A\u90FD\u6CA1\u6709\u7684\u53CD\u5E94\u4E0D\u77E5\u9053\u4F55\u65F6\u8BE5\u8DD1\uFF0C\u5B83\u65E2\u4E0D\u4F1A\u751F\u6548\u4E5F\u4E0D\u4F1A\u62A5\u9519\uFF0C\u662F\u6700\u96BE\u53D1\u73B0\u7684\u4E00\u7C7B\u7A7A\u58F0\u660E",
|
|
11732
12082
|
at
|
|
11733
12083
|
);
|
|
11734
12084
|
}
|
|
11735
12085
|
if (box.target !== void 0) {
|
|
11736
12086
|
const target = String(box.target);
|
|
11737
|
-
if (!fieldKeys.includes(target))
|
|
12087
|
+
if (!fieldKeys.includes(target)) fail(`target \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${target}"`, `${at}.target`);
|
|
11738
12088
|
if (!phase.startsWith("field_validate")) {
|
|
11739
|
-
|
|
12089
|
+
fail('target \u53EA\u5728 on: field_validate_* \u65F6\u6709\u610F\u4E49\uFF08\u5176\u4F59\u65F6\u673A\u6CA1\u6709"\u54EA\u4E2A\u5B57\u6BB5"\u8FD9\u4E2A\u6982\u5FF5\uFF09', `${at}.target`);
|
|
11740
12090
|
}
|
|
11741
12091
|
reads.add(target);
|
|
11742
12092
|
} else if (phase.startsWith("field_validate")) {
|
|
11743
|
-
|
|
12093
|
+
fail(`on: ${phase} \u5FC5\u987B\u7ED9 target\uFF08\u76EF\u7740\u54EA\u4E2A\u5B57\u6BB5\u7684\u6821\u9A8C\u7ED3\u679C\uFF09`, at);
|
|
11744
12094
|
}
|
|
11745
12095
|
const writes = /* @__PURE__ */ new Set();
|
|
11746
12096
|
const calcAsts = {};
|
|
@@ -11748,18 +12098,18 @@ function parseReactions(input, deps) {
|
|
|
11748
12098
|
const value = box[branch];
|
|
11749
12099
|
if (value === void 0) continue;
|
|
11750
12100
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
11751
|
-
|
|
12101
|
+
fail(`${branch} \u5FC5\u987B\u662F { \u5B57\u6BB5\u540D: patch } \u5BF9\u8C61`, `${at}.${branch}`);
|
|
11752
12102
|
}
|
|
11753
12103
|
for (const [target, patchRaw] of Object.entries(value)) {
|
|
11754
12104
|
const patchPath = `${at}.${branch}.${target}`;
|
|
11755
12105
|
if (target === SOMA_REACTION_FORM_KEY) {
|
|
11756
|
-
checkFormPatch(patchRaw, patchPath,
|
|
12106
|
+
checkFormPatch(patchRaw, patchPath, fail);
|
|
11757
12107
|
continue;
|
|
11758
12108
|
}
|
|
11759
12109
|
if (!fieldKeys.includes(target)) {
|
|
11760
|
-
|
|
12110
|
+
fail(`${branch} \u7684\u76EE\u6807 "${target}" \u4E0D\u662F\u5B57\u5178\u91CC\u7684\u5B57\u6BB5`, patchPath);
|
|
11761
12111
|
}
|
|
11762
|
-
const ast = checkFieldPatch(patchRaw, target, fields[target], fieldKeys, fieldTypes, patchPath,
|
|
12112
|
+
const ast = checkFieldPatch(patchRaw, target, fields[target], fieldKeys, fieldTypes, patchPath, fail);
|
|
11763
12113
|
if (ast) {
|
|
11764
12114
|
calcAsts[`${branch}:${target}`] = ast.node;
|
|
11765
12115
|
for (const ref of ast.refs) reads.add(ref);
|
|
@@ -11768,7 +12118,7 @@ function parseReactions(input, deps) {
|
|
|
11768
12118
|
}
|
|
11769
12119
|
}
|
|
11770
12120
|
if (box.fulfill === void 0 && box.otherwise === void 0) {
|
|
11771
|
-
|
|
12121
|
+
fail("fulfill \u4E0E otherwise \u81F3\u5C11\u8981\u7ED9\u4E00\u4E2A\uFF08\u4E00\u6761\u4EC0\u4E48\u90FD\u4E0D\u505A\u7684\u53CD\u5E94\u6CA1\u6709\u610F\u4E49\uFF09", at);
|
|
11772
12122
|
}
|
|
11773
12123
|
parsed.push({
|
|
11774
12124
|
config: box,
|
|
@@ -11779,7 +12129,7 @@ function parseReactions(input, deps) {
|
|
|
11779
12129
|
declaredAt: index
|
|
11780
12130
|
});
|
|
11781
12131
|
});
|
|
11782
|
-
const order = topoSort(parsed, path,
|
|
12132
|
+
const order = topoSort(parsed, path, fail);
|
|
11783
12133
|
const reactions = order.map((declaredAt, position) => {
|
|
11784
12134
|
const item = parsed[declaredAt];
|
|
11785
12135
|
return {
|
|
@@ -11804,57 +12154,57 @@ function parseReactions(input, deps) {
|
|
|
11804
12154
|
provenance: buildProvenance(reactions, fieldKeys, input.sourceApiOf ?? {})
|
|
11805
12155
|
};
|
|
11806
12156
|
}
|
|
11807
|
-
function checkFormPatch(raw2, path,
|
|
12157
|
+
function checkFormPatch(raw2, path, fail) {
|
|
11808
12158
|
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
11809
|
-
|
|
12159
|
+
fail("submit \u7684 patch \u5FC5\u987B\u662F\u5BF9\u8C61 { disabled: \u5E03\u5C14 }", path);
|
|
11810
12160
|
}
|
|
11811
12161
|
const box = raw2;
|
|
11812
12162
|
for (const key of Object.keys(box)) {
|
|
11813
|
-
if (key !== "disabled")
|
|
12163
|
+
if (key !== "disabled") fail(`submit \u53EA\u652F\u6301 disabled\uFF0C\u6536\u5230 "${key}"`, `${path}.${key}`);
|
|
11814
12164
|
}
|
|
11815
12165
|
if (box.disabled !== void 0 && typeof box.disabled !== "boolean") {
|
|
11816
|
-
|
|
12166
|
+
fail("submit.disabled \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.disabled`);
|
|
11817
12167
|
}
|
|
11818
12168
|
}
|
|
11819
|
-
function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path,
|
|
12169
|
+
function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail) {
|
|
11820
12170
|
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
11821
|
-
|
|
12171
|
+
fail("patch \u5FC5\u987B\u662F\u5BF9\u8C61", path);
|
|
11822
12172
|
}
|
|
11823
12173
|
const patch = raw2;
|
|
11824
12174
|
for (const key of Object.keys(patch)) {
|
|
11825
12175
|
if (!PATCH_KEYS.has(key)) {
|
|
11826
|
-
|
|
12176
|
+
fail(`\u672A\u77E5\u7684 patch \u952E "${key}"\uFF08\u652F\u6301: ${[...PATCH_KEYS].join(" / ")}\uFF09`, `${path}.${key}`);
|
|
11827
12177
|
}
|
|
11828
12178
|
}
|
|
11829
12179
|
if (patch.visible !== void 0 && typeof patch.visible !== "boolean") {
|
|
11830
|
-
|
|
12180
|
+
fail("visible \u5FC5\u987B\u662F\u5E03\u5C14\uFF08\u8981\u8FDE\u6570\u636E\u4E00\u8D77\u6458\u9664\u8BF7\u5199 display: none\uFF09", `${path}.visible`);
|
|
11831
12181
|
}
|
|
11832
12182
|
if (patch.visible !== void 0 && patch.display !== void 0) {
|
|
11833
|
-
|
|
12183
|
+
fail("visible \u4E0E display \u53EA\u80FD\u7ED9\u4E00\u4E2A\u2014\u2014visible \u672C\u6765\u5C31\u662F display \u7684\u8BED\u6CD5\u7CD6", path);
|
|
11834
12184
|
}
|
|
11835
12185
|
if (patch.display !== void 0 && !DISPLAYS.has(String(patch.display))) {
|
|
11836
|
-
|
|
12186
|
+
fail(`display \u53EA\u80FD\u662F ${SOMA_FIELD_DISPLAYS.join(" / ")}`, `${path}.display`);
|
|
11837
12187
|
}
|
|
11838
12188
|
if (patch.pattern !== void 0 && !PATTERNS.has(String(patch.pattern))) {
|
|
11839
|
-
|
|
12189
|
+
fail(`pattern \u53EA\u80FD\u662F ${SOMA_FIELD_PATTERNS.join(" / ")}`, `${path}.pattern`);
|
|
11840
12190
|
}
|
|
11841
12191
|
if (patch.required !== void 0 && typeof patch.required !== "boolean") {
|
|
11842
|
-
|
|
12192
|
+
fail("required \u5FC5\u987B\u662F\u5E03\u5C14", `${path}.required`);
|
|
11843
12193
|
}
|
|
11844
12194
|
if (patch.message !== void 0 && typeof patch.message !== "string") {
|
|
11845
|
-
|
|
12195
|
+
fail("message \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", `${path}.message`);
|
|
11846
12196
|
}
|
|
11847
12197
|
if (patch.options !== void 0) {
|
|
11848
12198
|
const from = patch.options.from;
|
|
11849
12199
|
if (typeof from !== "string" || !/^[A-Za-z_]\w*\.[A-Za-z_]\w*$/.test(from)) {
|
|
11850
|
-
|
|
12200
|
+
fail("options.from \u5FC5\u987B\u662F '<\u5BF9\u8C61>.<\u5B57\u6BB5>' \u5F62\u6001", `${path}.options`);
|
|
11851
12201
|
}
|
|
11852
12202
|
if (field.type !== "enum") {
|
|
11853
|
-
|
|
12203
|
+
fail(`options \u53EA\u80FD\u5199\u5728 enum \u5B57\u6BB5\u4E0A\uFF0C"${target}" \u662F ${field.type ?? "text"}`, `${path}.options`);
|
|
11854
12204
|
}
|
|
11855
12205
|
}
|
|
11856
12206
|
if (patch.value !== void 0 && field.permission === "r") {
|
|
11857
|
-
|
|
12207
|
+
fail(
|
|
11858
12208
|
`"${target}" \u662F\u53EA\u8BFB\u5B57\u6BB5\uFF08permission: r\uFF09\uFF0C\u53CD\u5E94\u4E0D\u80FD\u7ED9\u5B83\u5199\u503C\u2014\u2014\u53EA\u8BFB\u662F\u6570\u636E\u5C42\u7684\u88C1\u51B3\uFF0C\u8054\u52A8\u7ED5\u8FC7\u5B83\u5C31\u7B49\u4E8E\u6CA1\u6709\u88C1\u51B3`,
|
|
11859
12209
|
`${path}.value`
|
|
11860
12210
|
);
|
|
@@ -11863,14 +12213,14 @@ function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail2
|
|
|
11863
12213
|
if (patch.value === "clear") return null;
|
|
11864
12214
|
if (typeof patch.value === "object" && patch.value !== null && "from" in patch.value) {
|
|
11865
12215
|
const from = String(patch.value.from);
|
|
11866
|
-
if (!fieldKeys.includes(from))
|
|
12216
|
+
if (!fieldKeys.includes(from)) fail(`value.from \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${from}"`, `${path}.value`);
|
|
11867
12217
|
return { node: null, refs: [from] };
|
|
11868
12218
|
}
|
|
11869
12219
|
if (typeof patch.value === "object" && patch.value !== null && "calc" in patch.value) {
|
|
11870
12220
|
const source = String(patch.value.calc);
|
|
11871
12221
|
const declared = field.type ?? "text";
|
|
11872
12222
|
if (!CALC_WRITABLE.has(declared)) {
|
|
11873
|
-
|
|
12223
|
+
fail(`calc \u4E0D\u80FD\u5199\u8FDB ${declared} \u7C7B\u578B\u7684\u5B57\u6BB5 "${target}"`, `${path}.value`);
|
|
11874
12224
|
}
|
|
11875
12225
|
try {
|
|
11876
12226
|
const node = parseCalc(source);
|
|
@@ -11880,14 +12230,14 @@ function checkFieldPatch(raw2, target, field, fieldKeys, fieldTypes, path, fail2
|
|
|
11880
12230
|
return { node, refs: collectCalcRefs(node) };
|
|
11881
12231
|
} catch (error) {
|
|
11882
12232
|
if (error instanceof SomaCalcSyntaxError || error instanceof SomaCalcTypeError) {
|
|
11883
|
-
|
|
12233
|
+
fail(error.message, `${path}.value`);
|
|
11884
12234
|
}
|
|
11885
12235
|
throw error;
|
|
11886
12236
|
}
|
|
11887
12237
|
}
|
|
11888
|
-
return
|
|
12238
|
+
return fail("value \u53EA\u80FD\u662F 'clear' / { from: \u5B57\u6BB5 } / { calc: \u8868\u8FBE\u5F0F }", `${path}.value`);
|
|
11889
12239
|
}
|
|
11890
|
-
function topoSort(parsed, path,
|
|
12240
|
+
function topoSort(parsed, path, fail) {
|
|
11891
12241
|
const n = parsed.length;
|
|
11892
12242
|
const writerOf = /* @__PURE__ */ new Map();
|
|
11893
12243
|
parsed.forEach((item, index) => {
|
|
@@ -11928,7 +12278,7 @@ function topoSort(parsed, path, fail2) {
|
|
|
11928
12278
|
const remaining = /* @__PURE__ */ new Set();
|
|
11929
12279
|
for (let i = 0; i < n; i += 1) if (!order.includes(i)) remaining.add(i);
|
|
11930
12280
|
const cycle = traceCycle(remaining, edges);
|
|
11931
|
-
|
|
12281
|
+
fail(
|
|
11932
12282
|
`\u53CD\u5E94\u4E4B\u95F4\u6210\u73AF\uFF1A${cycle.map((i) => `#${i + 1}`).join(" \u2192 ")} \u2192 #${cycle[0] + 1}\uFF08\u7F16\u53F7\u662F\u58F0\u660E\u5E8F\uFF09\u3002\u6210\u73AF\u7684\u53CD\u5E94\u4F1A\u5728\u4E00\u6B21\u8F93\u5165\u91CC\u6765\u56DE\u6539\u540C\u4E00\u6279\u5B57\u6BB5\uFF0C\u8868\u73B0\u662F\u8F93\u5165\u6846\u81EA\u5DF1\u8DF3\uFF1B\u8BF7\u628A\u5176\u4E2D\u4E00\u6761\u6539\u6210\u5355\u5411\uFF0C\u6216\u628A\u4E2D\u95F4\u7ED3\u679C\u505A\u6210\u4E00\u4E2A\u771F\u5B9E\u5B57\u6BB5`,
|
|
11933
12283
|
path
|
|
11934
12284
|
);
|
|
@@ -12000,10 +12350,10 @@ var SOMA_AGGREGATE_FNS = ["sum", "avg", "min", "max", "count"];
|
|
|
12000
12350
|
var SOMA_SELECT_ALL_MODES = ["all", "filtered", "current_page"];
|
|
12001
12351
|
|
|
12002
12352
|
// core/client/parser/duration.ts
|
|
12003
|
-
function parseDuration(raw2, where,
|
|
12353
|
+
function parseDuration(raw2, where, fail) {
|
|
12004
12354
|
const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(raw2.trim());
|
|
12005
12355
|
if (!match) {
|
|
12006
|
-
|
|
12356
|
+
fail(`${where} \u7684\u65F6\u957F "${raw2}" \u975E\u6CD5\u2014\u2014\u5F62\u5982 500ms / 30s / 5m\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`);
|
|
12007
12357
|
}
|
|
12008
12358
|
const value = Number(match[1]);
|
|
12009
12359
|
const unit = match[2];
|
|
@@ -12026,22 +12376,22 @@ var CONFIG_KEYS3 = /* @__PURE__ */ new Set([
|
|
|
12026
12376
|
]);
|
|
12027
12377
|
var NUMERIC_TYPES = /* @__PURE__ */ new Set(["int", "float", "money", "percent", "progress"]);
|
|
12028
12378
|
var DEFAULT_BLOCK = { size: 100, max_blocks: 10, debounce_ms: 120 };
|
|
12029
|
-
function
|
|
12379
|
+
function isPlainObject5(value) {
|
|
12030
12380
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12031
12381
|
}
|
|
12032
12382
|
function parseWindow(input, deps) {
|
|
12033
12383
|
const { raw: raw2, fields, path } = input;
|
|
12034
|
-
const
|
|
12035
|
-
if (!
|
|
12384
|
+
const fail = deps.fail;
|
|
12385
|
+
if (!isPlainObject5(raw2)) fail("window \u5FC5\u987B\u662F\u6620\u5C04", path);
|
|
12036
12386
|
const section = raw2;
|
|
12037
12387
|
for (const key of Object.keys(section)) {
|
|
12038
12388
|
if (!CONFIG_KEYS3.has(key)) {
|
|
12039
|
-
|
|
12389
|
+
fail(`\u672A\u77E5\u7684 window \u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${[...CONFIG_KEYS3].join(" / ")}\uFF09`, `${path}.${key}`);
|
|
12040
12390
|
}
|
|
12041
12391
|
}
|
|
12042
12392
|
const mode = section.mode === void 0 ? "server" : String(section.mode);
|
|
12043
12393
|
if (mode !== "server") {
|
|
12044
|
-
|
|
12394
|
+
fail(`window.mode \u53EA\u80FD\u662F server\uFF08\u6536\u5230 "${mode}"\uFF09\u2014\u2014\u5BA2\u6237\u7AEF\u7A97\u53E3\u4E0D\u505A\uFF0C\u89C1\u300A\u6570\u636E\u5BF9\u8C61\u5C42\u300B\xA711`, `${path}.mode`);
|
|
12045
12395
|
}
|
|
12046
12396
|
const fieldKeys = Object.keys(fields);
|
|
12047
12397
|
const fieldTypes = Object.fromEntries(
|
|
@@ -12050,23 +12400,23 @@ function parseWindow(input, deps) {
|
|
|
12050
12400
|
const requireField = (name, at) => {
|
|
12051
12401
|
const key = String(name ?? "");
|
|
12052
12402
|
if (!fieldKeys.includes(key)) {
|
|
12053
|
-
|
|
12403
|
+
fail(`${at} \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5 "${key}"\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldKeys.join(" / ") || "\u7A7A"}\uFF09`, at);
|
|
12054
12404
|
}
|
|
12055
12405
|
return key;
|
|
12056
12406
|
};
|
|
12057
12407
|
const parseFilter = (node, at, depth) => {
|
|
12058
12408
|
if (depth > MAX_FILTER_DEPTH) {
|
|
12059
|
-
|
|
12409
|
+
fail(`${at} \u7684\u8FC7\u6EE4\u6761\u4EF6\u5D4C\u5957\u8D85\u8FC7 ${MAX_FILTER_DEPTH} \u5C42\u2014\u2014\u518D\u6DF1\u5C31\u6CA1\u4EBA\u8BFB\u5F97\u61C2\u4E86`, at);
|
|
12060
12410
|
}
|
|
12061
|
-
if (!
|
|
12411
|
+
if (!isPlainObject5(node)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
|
|
12062
12412
|
if ("join" in node || "conditions" in node) {
|
|
12063
12413
|
const branch = node;
|
|
12064
12414
|
const join = String(branch.join ?? "");
|
|
12065
12415
|
if (join !== "and" && join !== "or") {
|
|
12066
|
-
|
|
12416
|
+
fail(`${at}.join \u53EA\u80FD\u662F and / or\uFF08\u6536\u5230 ${JSON.stringify(branch.join)}\uFF09`, `${at}.join`);
|
|
12067
12417
|
}
|
|
12068
12418
|
if (!Array.isArray(branch.conditions) || branch.conditions.length === 0) {
|
|
12069
|
-
|
|
12419
|
+
fail(`${at}.conditions \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.conditions`);
|
|
12070
12420
|
}
|
|
12071
12421
|
return {
|
|
12072
12422
|
join,
|
|
@@ -12076,7 +12426,7 @@ function parseWindow(input, deps) {
|
|
|
12076
12426
|
};
|
|
12077
12427
|
}
|
|
12078
12428
|
const issues = validatePredicate(node, fieldKeys, at, { fieldTypes });
|
|
12079
|
-
if (issues.length > 0)
|
|
12429
|
+
if (issues.length > 0) fail(issues.join("\uFF1B"), at);
|
|
12080
12430
|
const leaf = node;
|
|
12081
12431
|
return {
|
|
12082
12432
|
field: String(leaf.field),
|
|
@@ -12087,13 +12437,13 @@ function parseWindow(input, deps) {
|
|
|
12087
12437
|
const filter = section.filter === void 0 || section.filter === null ? null : parseFilter(section.filter, `${path}.filter`, 1);
|
|
12088
12438
|
const sort = [];
|
|
12089
12439
|
if (section.sort !== void 0) {
|
|
12090
|
-
if (!Array.isArray(section.sort))
|
|
12440
|
+
if (!Array.isArray(section.sort)) fail(`${path}.sort \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.sort`);
|
|
12091
12441
|
section.sort.forEach((entry, index) => {
|
|
12092
12442
|
const at = `${path}.sort[${index}]`;
|
|
12093
|
-
if (!
|
|
12443
|
+
if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, order }`, at);
|
|
12094
12444
|
const order = String(entry.order ?? "asc");
|
|
12095
12445
|
if (order !== "asc" && order !== "desc") {
|
|
12096
|
-
|
|
12446
|
+
fail(`${at}.order \u53EA\u80FD\u662F asc / desc\uFF08\u6536\u5230 ${JSON.stringify(entry.order)}\uFF09`, `${at}.order`);
|
|
12097
12447
|
}
|
|
12098
12448
|
sort.push({ field: requireField(entry.field, `${at}.field`), order });
|
|
12099
12449
|
});
|
|
@@ -12101,13 +12451,13 @@ function parseWindow(input, deps) {
|
|
|
12101
12451
|
let group = null;
|
|
12102
12452
|
if (section.group !== void 0 && section.group !== null) {
|
|
12103
12453
|
const at = `${path}.group`;
|
|
12104
|
-
if (!
|
|
12454
|
+
if (!isPlainObject5(section.group)) fail(`${at} \u5FC5\u987B\u662F { by, keys? }`, at);
|
|
12105
12455
|
const by = section.group.by;
|
|
12106
|
-
if (!Array.isArray(by) || by.length === 0)
|
|
12456
|
+
if (!Array.isArray(by) || by.length === 0) fail(`${at}.by \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.by`);
|
|
12107
12457
|
const keys = section.group.keys ?? [];
|
|
12108
|
-
if (!Array.isArray(keys))
|
|
12458
|
+
if (!Array.isArray(keys)) fail(`${at}.keys \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.keys`);
|
|
12109
12459
|
if (keys.length > by.length) {
|
|
12110
|
-
|
|
12460
|
+
fail(
|
|
12111
12461
|
`${at}.keys \u6709 ${keys.length} \u6BB5\uFF0C\u4F46\u53EA\u6309 ${by.length} \u4E2A\u5B57\u6BB5\u5206\u7EC4\u2014\u2014\u5C55\u5F00\u8DEF\u5F84\u4E0D\u53EF\u80FD\u6BD4\u5206\u7EC4\u5C42\u6570\u6DF1`,
|
|
12112
12462
|
`${at}.keys`
|
|
12113
12463
|
);
|
|
@@ -12119,18 +12469,18 @@ function parseWindow(input, deps) {
|
|
|
12119
12469
|
}
|
|
12120
12470
|
const aggregate = [];
|
|
12121
12471
|
if (section.aggregate !== void 0) {
|
|
12122
|
-
if (!Array.isArray(section.aggregate))
|
|
12472
|
+
if (!Array.isArray(section.aggregate)) fail(`${path}.aggregate \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.aggregate`);
|
|
12123
12473
|
section.aggregate.forEach((entry, index) => {
|
|
12124
12474
|
const at = `${path}.aggregate[${index}]`;
|
|
12125
|
-
if (!
|
|
12475
|
+
if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, fn }`, at);
|
|
12126
12476
|
const fn = String(entry.fn ?? "");
|
|
12127
12477
|
if (!SOMA_AGGREGATE_FNS.includes(fn)) {
|
|
12128
|
-
|
|
12478
|
+
fail(`${at}.fn \u53EA\u80FD\u662F ${SOMA_AGGREGATE_FNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(entry.fn)}\uFF09`, `${at}.fn`);
|
|
12129
12479
|
}
|
|
12130
12480
|
const field = requireField(entry.field, `${at}.field`);
|
|
12131
12481
|
const type2 = fieldTypes[field] ?? "";
|
|
12132
12482
|
if (fn !== "count" && !NUMERIC_TYPES.has(type2)) {
|
|
12133
|
-
|
|
12483
|
+
fail(
|
|
12134
12484
|
`${at}.fn=${fn} \u4E0D\u80FD\u7528\u5728 ${type2 || "\u672A\u58F0\u660E\u7C7B\u578B"} \u7684\u5B57\u6BB5 "${field}" \u4E0A\uFF08\u53EA\u6709 ${[...NUMERIC_TYPES].join(" / ")} \u80FD\u6C42\u548C\u6C42\u5747\uFF1B\u8981\u6570\u884C\u6570\u8BF7\u7528 count\uFF09`,
|
|
12135
12485
|
`${at}.fn`
|
|
12136
12486
|
);
|
|
@@ -12141,24 +12491,24 @@ function parseWindow(input, deps) {
|
|
|
12141
12491
|
let selection = { base: "none", toggled: [] };
|
|
12142
12492
|
if (section.selection !== void 0) {
|
|
12143
12493
|
const at = `${path}.selection`;
|
|
12144
|
-
if (!
|
|
12494
|
+
if (!isPlainObject5(section.selection)) fail(`${at} \u5FC5\u987B\u662F { base, toggled }`, at);
|
|
12145
12495
|
const base = String(section.selection.base ?? "none");
|
|
12146
12496
|
if (base !== "none" && base !== "all") {
|
|
12147
|
-
|
|
12497
|
+
fail(`${at}.base \u53EA\u80FD\u662F none / all\uFF08\u6536\u5230 ${JSON.stringify(section.selection.base)}\uFF09`, `${at}.base`);
|
|
12148
12498
|
}
|
|
12149
12499
|
const toggled = section.selection.toggled ?? [];
|
|
12150
|
-
if (!Array.isArray(toggled))
|
|
12500
|
+
if (!Array.isArray(toggled)) fail(`${at}.toggled \u5FC5\u987B\u662F\u6570\u7EC4`, `${at}.toggled`);
|
|
12151
12501
|
selection = { base, toggled: toggled.map((id) => String(id)) };
|
|
12152
12502
|
}
|
|
12153
12503
|
const selectAll = String(section.select_all ?? "filtered");
|
|
12154
12504
|
if (!SOMA_SELECT_ALL_MODES.includes(selectAll)) {
|
|
12155
|
-
|
|
12505
|
+
fail(
|
|
12156
12506
|
`${path}.select_all \u53EA\u80FD\u662F ${SOMA_SELECT_ALL_MODES.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(section.select_all)}\uFF09`,
|
|
12157
12507
|
`${path}.select_all`
|
|
12158
12508
|
);
|
|
12159
12509
|
}
|
|
12160
12510
|
if (selectAll === "current_page" && selection.base === "all") {
|
|
12161
|
-
|
|
12511
|
+
fail(
|
|
12162
12512
|
`${path}.select_all=current_page \u4E0E selection.base=all \u51B2\u7A81\u2014\u2014\u53EA\u9009\u5F53\u524D\u9875\u65F6\u57FA\u7EBF\u53EA\u80FD\u662F none\uFF08\u5426\u5219"\u5168\u9009"\u5230\u5E95\u6307\u54EA\u4E9B\u884C\u8BF4\u4E0D\u6E05\uFF09`,
|
|
12163
12513
|
`${path}.select_all`
|
|
12164
12514
|
);
|
|
@@ -12166,29 +12516,29 @@ function parseWindow(input, deps) {
|
|
|
12166
12516
|
const block = { ...DEFAULT_BLOCK };
|
|
12167
12517
|
if (section.block !== void 0) {
|
|
12168
12518
|
const at = `${path}.block`;
|
|
12169
|
-
if (!
|
|
12519
|
+
if (!isPlainObject5(section.block)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
|
|
12170
12520
|
const positive = (raw22, key, fallback) => {
|
|
12171
12521
|
if (raw22 === void 0) return fallback;
|
|
12172
12522
|
const value = Number(raw22);
|
|
12173
12523
|
if (!Number.isInteger(value) || value <= 0) {
|
|
12174
|
-
|
|
12524
|
+
fail(`${at}.${key} \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230 ${JSON.stringify(raw22)}\uFF09`, `${at}.${key}`);
|
|
12175
12525
|
}
|
|
12176
12526
|
return value;
|
|
12177
12527
|
};
|
|
12178
12528
|
block.size = positive(section.block.size, "size", DEFAULT_BLOCK.size);
|
|
12179
12529
|
block.max_blocks = positive(section.block.max_blocks, "max_blocks", DEFAULT_BLOCK.max_blocks);
|
|
12180
|
-
block.debounce_ms = section.block.debounce === void 0 ? DEFAULT_BLOCK.debounce_ms : parseDuration(String(section.block.debounce), `${at}.debounce`, (m) =>
|
|
12530
|
+
block.debounce_ms = section.block.debounce === void 0 ? DEFAULT_BLOCK.debounce_ms : parseDuration(String(section.block.debounce), `${at}.debounce`, (m) => fail(m, `${at}.debounce`));
|
|
12181
12531
|
}
|
|
12182
12532
|
const cache = { ttl_ms: null, keep_previous: false };
|
|
12183
12533
|
if (section.cache !== void 0) {
|
|
12184
12534
|
const at = `${path}.cache`;
|
|
12185
|
-
if (!
|
|
12535
|
+
if (!isPlainObject5(section.cache)) fail(`${at} \u5FC5\u987B\u662F { ttl?, keep_previous? }`, at);
|
|
12186
12536
|
if (section.cache.ttl !== void 0) {
|
|
12187
|
-
cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) =>
|
|
12537
|
+
cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) => fail(m, `${at}.ttl`));
|
|
12188
12538
|
}
|
|
12189
12539
|
cache.keep_previous = section.cache.keep_previous === true;
|
|
12190
12540
|
}
|
|
12191
|
-
const revalidateMs = section.revalidate === void 0 ? null : parseDuration(String(section.revalidate), `${path}.revalidate`, (m) =>
|
|
12541
|
+
const revalidateMs = section.revalidate === void 0 ? null : parseDuration(String(section.revalidate), `${path}.revalidate`, (m) => fail(m, `${path}.revalidate`));
|
|
12192
12542
|
return {
|
|
12193
12543
|
mode: "server",
|
|
12194
12544
|
block,
|
|
@@ -12224,6 +12574,29 @@ var SomaDataConfigError = class extends Error {
|
|
|
12224
12574
|
};
|
|
12225
12575
|
var VALID_FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
|
|
12226
12576
|
var VALID_PERMISSIONS = /* @__PURE__ */ new Set(["r", "w"]);
|
|
12577
|
+
var SOMA_DATA_OBJECT_KEYS = [
|
|
12578
|
+
"from",
|
|
12579
|
+
"transform",
|
|
12580
|
+
"fields",
|
|
12581
|
+
"mock",
|
|
12582
|
+
"write",
|
|
12583
|
+
"predicates",
|
|
12584
|
+
"reactions",
|
|
12585
|
+
"window",
|
|
12586
|
+
// REQ-014 期 2'.1:对象界面演绎的语义位与关系
|
|
12587
|
+
"roles",
|
|
12588
|
+
"relations"
|
|
12589
|
+
];
|
|
12590
|
+
var SOMA_DATA_FIELD_KEYS = [
|
|
12591
|
+
"name",
|
|
12592
|
+
"type",
|
|
12593
|
+
"permission",
|
|
12594
|
+
"rules",
|
|
12595
|
+
"options",
|
|
12596
|
+
"calc",
|
|
12597
|
+
// REQ-014 期 2'.1:修饰关系(`status_tone` 修饰 `status_text`)
|
|
12598
|
+
"modifies"
|
|
12599
|
+
];
|
|
12227
12600
|
var RULE_VALUE_TYPES = {
|
|
12228
12601
|
required: "boolean",
|
|
12229
12602
|
max_len: "number",
|
|
@@ -12433,9 +12806,14 @@ function parseField(raw2, path) {
|
|
|
12433
12806
|
throw new SomaDataConfigError("calc \u5FC5\u987B\u662F\u975E\u7A7A\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32", `${path}.calc`);
|
|
12434
12807
|
}
|
|
12435
12808
|
field.calc = value;
|
|
12809
|
+
} else if (key === "modifies") {
|
|
12810
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
12811
|
+
throw new SomaDataConfigError("modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D", `${path}.modifies`);
|
|
12812
|
+
}
|
|
12813
|
+
field.modifies = value;
|
|
12436
12814
|
} else {
|
|
12437
12815
|
throw new SomaDataConfigError(
|
|
12438
|
-
`\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301:
|
|
12816
|
+
`\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_FIELD_KEYS.join(" / ")}\uFF09`,
|
|
12439
12817
|
`${path}.${key}`
|
|
12440
12818
|
);
|
|
12441
12819
|
}
|
|
@@ -12635,6 +13013,8 @@ function parseObject(name, raw2, path, objectNames) {
|
|
|
12635
13013
|
let predicatesRaw;
|
|
12636
13014
|
let reactionsRaw;
|
|
12637
13015
|
let windowRaw;
|
|
13016
|
+
let rolesRaw;
|
|
13017
|
+
let relationsRaw;
|
|
12638
13018
|
for (const [key, value] of Object.entries(raw2)) {
|
|
12639
13019
|
if (key === "from") {
|
|
12640
13020
|
if (!Array.isArray(value) || value.length === 0) {
|
|
@@ -12652,6 +13032,10 @@ function parseObject(name, raw2, path, objectNames) {
|
|
|
12652
13032
|
fields2[fieldName] = parseField(fieldRaw, `${path}.fields.${fieldName}`);
|
|
12653
13033
|
}
|
|
12654
13034
|
validateDerivedFields(fields2, `${path}.fields`);
|
|
13035
|
+
const modifiesIssues = validateFieldModifies(fields2);
|
|
13036
|
+
if (modifiesIssues.length > 0) {
|
|
13037
|
+
throw new SomaDataConfigError(modifiesIssues.join("\uFF1B"), `${path}.fields`);
|
|
13038
|
+
}
|
|
12655
13039
|
config.fields = fields2;
|
|
12656
13040
|
} else if (key === "mock") {
|
|
12657
13041
|
config.mock = value;
|
|
@@ -12663,13 +13047,35 @@ function parseObject(name, raw2, path, objectNames) {
|
|
|
12663
13047
|
reactionsRaw = value;
|
|
12664
13048
|
} else if (key === "window") {
|
|
12665
13049
|
windowRaw = value;
|
|
13050
|
+
} else if (key === "roles") {
|
|
13051
|
+
rolesRaw = value;
|
|
13052
|
+
} else if (key === "relations") {
|
|
13053
|
+
relationsRaw = value;
|
|
12666
13054
|
} else {
|
|
12667
13055
|
throw new SomaDataConfigError(
|
|
12668
|
-
`\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301:
|
|
13056
|
+
`\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_OBJECT_KEYS.join(" / ")}\uFF09`,
|
|
12669
13057
|
`${path}.${key}`
|
|
12670
13058
|
);
|
|
12671
13059
|
}
|
|
12672
13060
|
}
|
|
13061
|
+
if (rolesRaw !== void 0) {
|
|
13062
|
+
const issues = validateObjectRoles(rolesRaw, Object.keys(config.fields ?? {}));
|
|
13063
|
+
if (issues.length > 0) {
|
|
13064
|
+
throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.roles`);
|
|
13065
|
+
}
|
|
13066
|
+
config.roles = rolesRaw;
|
|
13067
|
+
}
|
|
13068
|
+
if (relationsRaw !== void 0) {
|
|
13069
|
+
const issues = validateObjectRelations(relationsRaw, {
|
|
13070
|
+
fieldKeys: Object.keys(config.fields ?? {}),
|
|
13071
|
+
objectNames: [...objectNames],
|
|
13072
|
+
selfName: name
|
|
13073
|
+
});
|
|
13074
|
+
if (issues.length > 0) {
|
|
13075
|
+
throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.relations`);
|
|
13076
|
+
}
|
|
13077
|
+
config.relations = relationsRaw;
|
|
13078
|
+
}
|
|
12673
13079
|
if (writeRaw !== void 0) {
|
|
12674
13080
|
config.write = parseWrite(writeRaw, config.fields ?? {}, `${path}.write`, objectNames);
|
|
12675
13081
|
}
|
|
@@ -13093,7 +13499,7 @@ function isSomaMockEnabled() {
|
|
|
13093
13499
|
const envFlag = typeof process !== "undefined" ? process.env?.SOMA_MOCK_ENABLED : void 0;
|
|
13094
13500
|
return envFlag === "1" || envFlag === "true";
|
|
13095
13501
|
}
|
|
13096
|
-
function
|
|
13502
|
+
function isPlainObject6(value) {
|
|
13097
13503
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13098
13504
|
}
|
|
13099
13505
|
function readPath2(root, segments) {
|
|
@@ -13116,22 +13522,22 @@ function referencesObject(value, objectName) {
|
|
|
13116
13522
|
if (Array.isArray(value)) {
|
|
13117
13523
|
return value.some((item) => referencesObject(item, objectName));
|
|
13118
13524
|
}
|
|
13119
|
-
if (
|
|
13525
|
+
if (isPlainObject6(value)) {
|
|
13120
13526
|
return Object.values(value).some((item) => referencesObject(item, objectName));
|
|
13121
13527
|
}
|
|
13122
13528
|
return false;
|
|
13123
13529
|
}
|
|
13124
13530
|
function extractErrorPayload(error) {
|
|
13125
13531
|
const candidates = [error];
|
|
13126
|
-
if (
|
|
13532
|
+
if (isPlainObject6(error)) {
|
|
13127
13533
|
candidates.push(error.response, error.data, error.body);
|
|
13128
|
-
if (
|
|
13534
|
+
if (isPlainObject6(error.response)) candidates.push(error.response.data);
|
|
13129
13535
|
}
|
|
13130
13536
|
for (const candidate of candidates) {
|
|
13131
|
-
if (!
|
|
13537
|
+
if (!isPlainObject6(candidate)) continue;
|
|
13132
13538
|
const rawFieldErrors = candidate.fieldErrors ?? candidate.field_errors ?? candidate.errors;
|
|
13133
13539
|
const message = typeof candidate.message === "string" ? candidate.message : void 0;
|
|
13134
|
-
if (
|
|
13540
|
+
if (isPlainObject6(rawFieldErrors)) {
|
|
13135
13541
|
const fieldErrors = {};
|
|
13136
13542
|
for (const [key, value] of Object.entries(rawFieldErrors)) {
|
|
13137
13543
|
if (typeof value === "string") fieldErrors[key] = value;
|
|
@@ -13343,7 +13749,7 @@ var SomaDataObjectResolver = class {
|
|
|
13343
13749
|
if (!write.update) return "create";
|
|
13344
13750
|
if (!write.create) return "update";
|
|
13345
13751
|
const current = this.objects[name];
|
|
13346
|
-
const hasRecord =
|
|
13752
|
+
const hasRecord = isPlainObject6(current) && Object.keys(current).length > 0;
|
|
13347
13753
|
return hasRecord ? "update" : "create";
|
|
13348
13754
|
}
|
|
13349
13755
|
/** 构造请求体:剔除只读字段 → map 改名 → 补乐观锁位 */
|
|
@@ -13359,7 +13765,7 @@ var SomaDataObjectResolver = class {
|
|
|
13359
13765
|
}
|
|
13360
13766
|
if (write.version && !(write.version in model)) {
|
|
13361
13767
|
const current = this.objects[decl.name];
|
|
13362
|
-
const versionValue =
|
|
13768
|
+
const versionValue = isPlainObject6(current) ? current[write.version] : void 0;
|
|
13363
13769
|
if (versionValue !== void 0) {
|
|
13364
13770
|
body[write.map?.[write.version] ?? write.version] = versionValue;
|
|
13365
13771
|
}
|
|
@@ -13503,12 +13909,12 @@ var SomaDataObjectResolver = class {
|
|
|
13503
13909
|
/** 聚合来源结果:into 写入子键;缺省浅合并进根(非对象结果整体替换) */
|
|
13504
13910
|
mergeSource(current, source, data) {
|
|
13505
13911
|
if (source.into) {
|
|
13506
|
-
const target =
|
|
13912
|
+
const target = isPlainObject6(current) ? current : {};
|
|
13507
13913
|
target[source.into] = data;
|
|
13508
13914
|
return target;
|
|
13509
13915
|
}
|
|
13510
|
-
if (
|
|
13511
|
-
if (
|
|
13916
|
+
if (isPlainObject6(data)) {
|
|
13917
|
+
if (isPlainObject6(current)) {
|
|
13512
13918
|
Object.assign(current, data);
|
|
13513
13919
|
return current;
|
|
13514
13920
|
}
|
|
@@ -13544,7 +13950,7 @@ var SomaDataObjectResolver = class {
|
|
|
13544
13950
|
if (Array.isArray(raw2)) {
|
|
13545
13951
|
return raw2.map((item) => this.resolveParamValue(item, selfName, selfValue));
|
|
13546
13952
|
}
|
|
13547
|
-
if (
|
|
13953
|
+
if (isPlainObject6(raw2)) {
|
|
13548
13954
|
const result = {};
|
|
13549
13955
|
for (const [key, item] of Object.entries(raw2)) {
|
|
13550
13956
|
result[key] = this.resolveParamValue(item, selfName, selfValue);
|
|
@@ -13580,7 +13986,7 @@ var SomaDataObjectResolver = class {
|
|
|
13580
13986
|
}
|
|
13581
13987
|
applyTransform(value, decl) {
|
|
13582
13988
|
if (!decl.transform) return value;
|
|
13583
|
-
if (!
|
|
13989
|
+
if (!isPlainObject6(value)) {
|
|
13584
13990
|
console.warn(`[soma-core][\u6570\u636E] \u5BF9\u8C61 "${decl.name}" \u4E0D\u662F\u5BF9\u8C61\u7ED3\u6784\uFF0Ctransform \u6D3E\u751F\u5B57\u6BB5\u88AB\u8DF3\u8FC7`);
|
|
13585
13991
|
return value;
|
|
13586
13992
|
}
|
|
@@ -13635,20 +14041,39 @@ var SomaDataObjectResolver = class {
|
|
|
13635
14041
|
for (const key of order) row[key] = evaluateCalc(asts.get(key), row);
|
|
13636
14042
|
};
|
|
13637
14043
|
if (Array.isArray(value)) {
|
|
13638
|
-
for (const row of value) if (
|
|
14044
|
+
for (const row of value) if (isPlainObject6(row)) fill(row);
|
|
13639
14045
|
return value;
|
|
13640
14046
|
}
|
|
13641
|
-
if (
|
|
14047
|
+
if (isPlainObject6(value)) {
|
|
13642
14048
|
fill(value);
|
|
13643
14049
|
for (const nested of Object.values(value)) {
|
|
13644
14050
|
if (Array.isArray(nested)) {
|
|
13645
|
-
for (const row of nested) if (
|
|
14051
|
+
for (const row of nested) if (isPlainObject6(row)) fill(row);
|
|
13646
14052
|
}
|
|
13647
14053
|
}
|
|
13648
14054
|
}
|
|
13649
14055
|
return value;
|
|
13650
14056
|
}
|
|
13651
14057
|
};
|
|
14058
|
+
function createSomaDataPort(currentResolver) {
|
|
14059
|
+
const noResolver = (action) => ({
|
|
14060
|
+
ok: false,
|
|
14061
|
+
message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u58F0\u660E *_data.yaml\uFF09`
|
|
14062
|
+
});
|
|
14063
|
+
return {
|
|
14064
|
+
getObject: (name) => currentResolver()?.getObject(name),
|
|
14065
|
+
getDict: (name) => currentResolver()?.getDict(name) ?? {},
|
|
14066
|
+
getReactions: (name) => currentResolver()?.getReactions(name) ?? null,
|
|
14067
|
+
window: (name) => currentResolver()?.window(name) ?? null,
|
|
14068
|
+
submit: async (name, model, mode) => {
|
|
14069
|
+
const resolver = currentResolver();
|
|
14070
|
+
return resolver ? resolver.submit(name, model, mode) : noResolver(`\u63D0\u4EA4 "${name}"`);
|
|
14071
|
+
},
|
|
14072
|
+
reload: async (names) => {
|
|
14073
|
+
await currentResolver()?.reload(names);
|
|
14074
|
+
}
|
|
14075
|
+
};
|
|
14076
|
+
}
|
|
13652
14077
|
|
|
13653
14078
|
// core/shared/types/component-contract.types.ts
|
|
13654
14079
|
function findNestedMutableContractDefault(value) {
|
|
@@ -13895,9 +14320,7 @@ var SomaComponentExpander = class {
|
|
|
13895
14320
|
}
|
|
13896
14321
|
host.innerHTML = def.templateHtml;
|
|
13897
14322
|
this.scopeAnchors(host, scopeId);
|
|
13898
|
-
const outlets =
|
|
13899
|
-
host.querySelectorAll(`[${SOMA_SLOT_OUTLET_ATTR}]`)
|
|
13900
|
-
);
|
|
14323
|
+
const outlets = this.collectSlotOutlets(host);
|
|
13901
14324
|
for (const outlet of outlets) {
|
|
13902
14325
|
const slotName = outlet.getAttribute(SOMA_SLOT_OUTLET_ATTR);
|
|
13903
14326
|
const content = slotContent.get(slotName);
|
|
@@ -13935,6 +14358,15 @@ var SomaComponentExpander = class {
|
|
|
13935
14358
|
this.scopeAnchors(tpl.content, scopeId);
|
|
13936
14359
|
});
|
|
13937
14360
|
}
|
|
14361
|
+
collectSlotOutlets(root) {
|
|
14362
|
+
const outlets = Array.from(
|
|
14363
|
+
root.querySelectorAll(`[${SOMA_SLOT_OUTLET_ATTR}]`)
|
|
14364
|
+
);
|
|
14365
|
+
for (const template of Array.from(root.querySelectorAll("template"))) {
|
|
14366
|
+
outlets.push(...this.collectSlotOutlets(template.content));
|
|
14367
|
+
}
|
|
14368
|
+
return outlets;
|
|
14369
|
+
}
|
|
13938
14370
|
};
|
|
13939
14371
|
|
|
13940
14372
|
// core/client/component/style-features.ts
|
|
@@ -14032,7 +14464,7 @@ var SomaComponentManager = class {
|
|
|
14032
14464
|
prepare(container, uiConfig) {
|
|
14033
14465
|
this.propsIndex = collectPagePropsDecls(uiConfig.show);
|
|
14034
14466
|
this.staticDecls = [];
|
|
14035
|
-
for (let
|
|
14467
|
+
for (let round = 0; round < MAX_EXPANSION_ROUNDS + 1; round++) {
|
|
14036
14468
|
const pending2 = Array.from(
|
|
14037
14469
|
container.querySelectorAll(`[${SOMA_COMPONENT_ATTR}]`)
|
|
14038
14470
|
).filter(
|
|
@@ -14041,7 +14473,7 @@ var SomaComponentManager = class {
|
|
|
14041
14473
|
if (pending2.length === 0) {
|
|
14042
14474
|
return;
|
|
14043
14475
|
}
|
|
14044
|
-
if (
|
|
14476
|
+
if (round === MAX_EXPANSION_ROUNDS) {
|
|
14045
14477
|
throw new SomaComponentExpandError(
|
|
14046
14478
|
`\u7EC4\u4EF6\u5D4C\u5957\u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650 ${MAX_EXPANSION_ROUNDS}\uFF08\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\uFF09`
|
|
14047
14479
|
);
|
|
@@ -14054,6 +14486,7 @@ var SomaComponentManager = class {
|
|
|
14054
14486
|
}
|
|
14055
14487
|
const def = this.registry.get(name);
|
|
14056
14488
|
this.expander.expand(host, def);
|
|
14489
|
+
this.expandNestedTemplates(host);
|
|
14057
14490
|
this.staticDecls.push({
|
|
14058
14491
|
host,
|
|
14059
14492
|
instanceId,
|
|
@@ -14239,7 +14672,7 @@ var SomaComponentManager = class {
|
|
|
14239
14672
|
* 未注册的组件名在此静默跳过(不阻塞收敛),照旧由 applyChildComponent 抛错点名。
|
|
14240
14673
|
*/
|
|
14241
14674
|
expandNestedTemplates(root) {
|
|
14242
|
-
for (let
|
|
14675
|
+
for (let round = 0; round < MAX_EXPANSION_ROUNDS + 1; round++) {
|
|
14243
14676
|
const pending2 = Array.from(
|
|
14244
14677
|
root.querySelectorAll(`[${SOMA_CHILD_COMPONENT_ID_ATTR}]`)
|
|
14245
14678
|
).filter((host) => {
|
|
@@ -14250,7 +14683,7 @@ var SomaComponentManager = class {
|
|
|
14250
14683
|
if (pending2.length === 0) {
|
|
14251
14684
|
return;
|
|
14252
14685
|
}
|
|
14253
|
-
if (
|
|
14686
|
+
if (round === MAX_EXPANSION_ROUNDS) {
|
|
14254
14687
|
throw new SomaComponentExpandError(
|
|
14255
14688
|
`\u7EC4\u4EF6\u5D4C\u5957\u6DF1\u5EA6\u8D85\u8FC7\u4E0A\u9650 ${MAX_EXPANSION_ROUNDS}\uFF08\u53EF\u80FD\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\uFF09`
|
|
14256
14689
|
);
|
|
@@ -14776,13 +15209,13 @@ var CHROMA_MUL = {
|
|
|
14776
15209
|
vivid: 1.35
|
|
14777
15210
|
};
|
|
14778
15211
|
var CONTRAST_TARGETS = {
|
|
14779
|
-
soft: { toneOnPage:
|
|
14780
|
-
standard: { toneOnPage:
|
|
15212
|
+
soft: { toneOnPage: 1.2, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
15213
|
+
standard: { toneOnPage: 1.6, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
14781
15214
|
strong: { toneOnPage: 5.5, fgOnTone: 7, textOnPage: 7 }
|
|
14782
15215
|
};
|
|
14783
15216
|
var DARK_CONTRAST_TARGETS = {
|
|
14784
|
-
soft: { toneOnPage:
|
|
14785
|
-
standard: { toneOnPage: 3
|
|
15217
|
+
soft: { toneOnPage: 2.8, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
15218
|
+
standard: { toneOnPage: 3, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
14786
15219
|
strong: { toneOnPage: 5, fgOnTone: 7, textOnPage: 7 }
|
|
14787
15220
|
};
|
|
14788
15221
|
var SOFT_LIGHTNESS_BAND = [0.7, 0.86];
|
|
@@ -14984,6 +15417,14 @@ function applySeparationGuard(anchors, brandHue, brandLightness, toneLightness,
|
|
|
14984
15417
|
// core/client/theme/tone-solver.ts
|
|
14985
15418
|
var MAX_SOLVE_ITER = 16;
|
|
14986
15419
|
var STEP = 0.04;
|
|
15420
|
+
function pushLightnessUntil(color, satisfied, direction, maxIter = MAX_SOLVE_ITER) {
|
|
15421
|
+
let current = color;
|
|
15422
|
+
const delta = direction === "lighten" ? STEP : -STEP;
|
|
15423
|
+
for (let i = 0; i < maxIter && !satisfied(current); i += 1) {
|
|
15424
|
+
current = { ...current, l: current.l + delta };
|
|
15425
|
+
}
|
|
15426
|
+
return current;
|
|
15427
|
+
}
|
|
14987
15428
|
function ensureContrast(bg, deps, minRatio = 4.5, maxIter = MAX_SOLVE_ITER, forceDirection) {
|
|
14988
15429
|
let current = bg;
|
|
14989
15430
|
let fg = deps.bestFg(current);
|
|
@@ -14995,6 +15436,21 @@ function ensureContrast(bg, deps, minRatio = 4.5, maxIter = MAX_SOLVE_ITER, forc
|
|
|
14995
15436
|
}
|
|
14996
15437
|
return { bg: current, fg };
|
|
14997
15438
|
}
|
|
15439
|
+
function solveTone(seed, pageHex, target, band, deps) {
|
|
15440
|
+
const meets = (candidate) => deps.contrastRatio(deps.oklchToHex(candidate), pageHex) >= target.toneOnPage;
|
|
15441
|
+
let start = seed;
|
|
15442
|
+
let bandBroken = false;
|
|
15443
|
+
if (band) {
|
|
15444
|
+
start = { ...seed, l: Math.min(band[1], Math.max(band[0], seed.l)) };
|
|
15445
|
+
}
|
|
15446
|
+
const pageL = deps.hexToOklch(pageHex).l;
|
|
15447
|
+
const direction = start.l > pageL ? "lighten" : "darken";
|
|
15448
|
+
const solved = pushLightnessUntil(start, meets, direction);
|
|
15449
|
+
if (band && (solved.l < band[0] - 1e-6 || solved.l > band[1] + 1e-6)) {
|
|
15450
|
+
bandBroken = true;
|
|
15451
|
+
}
|
|
15452
|
+
return { tone: solved, bandBroken };
|
|
15453
|
+
}
|
|
14998
15454
|
|
|
14999
15455
|
// core/client/theme/scene-tokens.ts
|
|
15000
15456
|
var SIGNAL_IDLE = {
|
|
@@ -15021,6 +15477,17 @@ function sceneStructureTokens(axes) {
|
|
|
15021
15477
|
...signal
|
|
15022
15478
|
};
|
|
15023
15479
|
}
|
|
15480
|
+
function glassTokens(dark) {
|
|
15481
|
+
return dark ? {
|
|
15482
|
+
"--soma-surface-glass": "rgba(255, 255, 255, 0.06)",
|
|
15483
|
+
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.1)",
|
|
15484
|
+
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.04)"
|
|
15485
|
+
} : {
|
|
15486
|
+
"--soma-surface-glass": "rgba(255, 255, 255, 0.72)",
|
|
15487
|
+
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.88)",
|
|
15488
|
+
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.52)"
|
|
15489
|
+
};
|
|
15490
|
+
}
|
|
15024
15491
|
function sceneColorTokens(finalVars, axes, alphas, hexWithAlpha2, scale, rescale) {
|
|
15025
15492
|
const out = {};
|
|
15026
15493
|
if (!alphas) {
|
|
@@ -15180,6 +15647,40 @@ function enforceContrastPairs(vars) {
|
|
|
15180
15647
|
vars[foregroundKey] = ["#000000", "#ffffff", "#111827"].sort((left, right) => contrastRatio(backgroundHex, right) - contrastRatio(backgroundHex, left))[0];
|
|
15181
15648
|
}
|
|
15182
15649
|
}
|
|
15650
|
+
var READABLE_TEXT_KEYS = [
|
|
15651
|
+
"--soma-text-strong",
|
|
15652
|
+
"--soma-text-primary",
|
|
15653
|
+
"--soma-text-secondary",
|
|
15654
|
+
"--soma-text-muted",
|
|
15655
|
+
"--soma-text-link"
|
|
15656
|
+
];
|
|
15657
|
+
var NEUTRAL_SURFACE_KEYS = [
|
|
15658
|
+
"--soma-bg-page",
|
|
15659
|
+
"--soma-bg-container",
|
|
15660
|
+
"--soma-surface-card",
|
|
15661
|
+
"--soma-bg-elevated",
|
|
15662
|
+
"--soma-bg-hover"
|
|
15663
|
+
];
|
|
15664
|
+
var READABLE_TEXT_TARGET = 4.52;
|
|
15665
|
+
function enforceReadableText(vars) {
|
|
15666
|
+
const surfaces = NEUTRAL_SURFACE_KEYS.map((key) => contrastColorToHex(vars[key] ?? "")).filter((hex) => hex !== null);
|
|
15667
|
+
if (surfaces.length === 0) return;
|
|
15668
|
+
const surfaceLum = Math.min(...surfaces.map((hex) => hexToOklch(hex).l));
|
|
15669
|
+
for (const key of READABLE_TEXT_KEYS) {
|
|
15670
|
+
let tone = contrastColorToHex(vars[key] ?? "");
|
|
15671
|
+
if (!tone) continue;
|
|
15672
|
+
const worst = (hex) => Math.min(...surfaces.map((surface) => contrastRatio(surface, hex)));
|
|
15673
|
+
if (worst(tone) >= READABLE_TEXT_TARGET) continue;
|
|
15674
|
+
const direction = hexToOklch(tone).l < surfaceLum ? -1 : 1;
|
|
15675
|
+
for (let i = 0; i < 40 && worst(tone) < READABLE_TEXT_TARGET; i++) {
|
|
15676
|
+
const cur = hexToOklch(tone);
|
|
15677
|
+
const next = Math.max(0, Math.min(1, cur.l + direction * 0.02));
|
|
15678
|
+
if (next === cur.l) break;
|
|
15679
|
+
tone = oklchToHex({ ...cur, l: next });
|
|
15680
|
+
}
|
|
15681
|
+
vars[key] = tone;
|
|
15682
|
+
}
|
|
15683
|
+
}
|
|
15183
15684
|
var SOFT_TONES = ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "danger"];
|
|
15184
15685
|
var SOFT_AA_TARGET = 4.52;
|
|
15185
15686
|
var SOFT_SURFACE_KEYS = [
|
|
@@ -15230,7 +15731,7 @@ function deriveOnSoftTokens(vars, dark) {
|
|
|
15230
15731
|
const backdropLuminance = [];
|
|
15231
15732
|
for (const surface of surfaces) {
|
|
15232
15733
|
const once = compositeOver(soft, surface);
|
|
15233
|
-
backdropLuminance.push(luminanceRgba(once), luminanceRgba(compositeOver(soft, once)));
|
|
15734
|
+
backdropLuminance.push(luminanceRgba(surface), luminanceRgba(once), luminanceRgba(compositeOver(soft, once)));
|
|
15234
15735
|
}
|
|
15235
15736
|
const worst = (hex) => {
|
|
15236
15737
|
const fgLuminance = luminanceHex(hex);
|
|
@@ -15289,7 +15790,7 @@ function chartSeries(hue, chroma, lightness, anchors) {
|
|
|
15289
15790
|
return vars;
|
|
15290
15791
|
}
|
|
15291
15792
|
var STATIC_TOKENS = {
|
|
15292
|
-
// 字体排印:系统栈 + 八档字号 + AntD 标准行高 +
|
|
15793
|
+
// 字体排印:系统栈 + 八档字号 + AntD 标准行高 + 四档字重
|
|
15293
15794
|
"--soma-font-family": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif",
|
|
15294
15795
|
"--soma-font-size-xs": "0.75rem",
|
|
15295
15796
|
// 12px
|
|
@@ -15322,6 +15823,13 @@ var STATIC_TOKENS = {
|
|
|
15322
15823
|
"--soma-font-weight-normal": "400",
|
|
15323
15824
|
"--soma-font-weight-medium": "500",
|
|
15324
15825
|
"--soma-font-weight-bold": "600",
|
|
15826
|
+
// 展示档(2026-09-12 补):把字形当**图形**用的位置——头像/角标的首字母牌、
|
|
15827
|
+
// 序号与勾选标记、KPI 大数字、倒计时格、hero 标题、金额主数字。
|
|
15828
|
+
// 它不是文本层次的第四级(层次到 bold 就封顶,见排版册"层次三维"),
|
|
15829
|
+
// 所以不参与"页题→脚注"六级;单列一档是因为这些位置此前各写各的裸值
|
|
15830
|
+
// (650/700/750/800 混用,同一个 `__eyebrow` 在三个卡片工厂里是三个数),
|
|
15831
|
+
// 没有令牌可引就只能硬编码,换肤对它们永远无效。
|
|
15832
|
+
"--soma-font-weight-heavy": "800",
|
|
15325
15833
|
// 间距:4px 基准;0 贴合,9=48px,10=56px(文档 space.0~16,未一次铺满)
|
|
15326
15834
|
"--soma-space-0": "0rem",
|
|
15327
15835
|
"--soma-space-1": "0.25rem",
|
|
@@ -15392,6 +15900,7 @@ var STEPS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"
|
|
|
15392
15900
|
var LIGHTNESS = [0.985, 0.955, 0.91, 0.85, 0.78, 0.7, 0.62, 0.54, 0.46, 0.38, 0.3];
|
|
15393
15901
|
var CHROMA_CURVE = [0.14, 0.28, 0.48, 0.68, 0.85, 1, 1, 0.92, 0.8, 0.66, 0.52];
|
|
15394
15902
|
var SOLVER_DEPS = { oklchToHex, hexToOklch, contrastRatio, bestFg };
|
|
15903
|
+
var AWAY_FROM_LIGHT_PAGE = "darken";
|
|
15395
15904
|
function deriveTheme(input) {
|
|
15396
15905
|
const brand = hexToOklch(input.brand);
|
|
15397
15906
|
const { axes, params } = resolveAxes(input);
|
|
@@ -15404,6 +15913,8 @@ function deriveTheme(input) {
|
|
|
15404
15913
|
const grayHue = input.mode === "warm" ? 60 : input.mode === "cool" ? 250 : brand.h;
|
|
15405
15914
|
const grayChroma = input.mode === "neutral" || !input.mode ? 8e-3 : 0.014;
|
|
15406
15915
|
const gray = (l) => oklchToHex({ l, c: grayChroma, h: grayHue });
|
|
15916
|
+
const bgPage = gray(0.965);
|
|
15917
|
+
const darkBgPage = gray(0.18);
|
|
15407
15918
|
const primaryIdx = Math.max(4, Math.min(7, brandSlot));
|
|
15408
15919
|
const primary = scale[STEPS[primaryIdx]];
|
|
15409
15920
|
const hover = oklchToHex({ ...hexToOklch(primary), l: hexToOklch(primary).l - 0.06 });
|
|
@@ -15417,12 +15928,45 @@ function deriveTheme(input) {
|
|
|
15417
15928
|
const band = params.softLightnessBand;
|
|
15418
15929
|
return band ? Math.min(band[1], Math.max(band[0], l)) : l;
|
|
15419
15930
|
};
|
|
15931
|
+
const bandBroken = /* @__PURE__ */ new Set();
|
|
15932
|
+
const solveOnPage = (record, seed, pageHex, target, band) => {
|
|
15933
|
+
const solved = solveTone(seed, pageHex, target, band, SOLVER_DEPS);
|
|
15934
|
+
if (record && solved.bandBroken) bandBroken.add(record);
|
|
15935
|
+
return {
|
|
15936
|
+
tone: solved.tone,
|
|
15937
|
+
hex: oklchToHex(solved.tone),
|
|
15938
|
+
pushed: Math.abs(solved.tone.l - seed.l) > 1e-9
|
|
15939
|
+
};
|
|
15940
|
+
};
|
|
15941
|
+
const dirAfter = (solved, away) => solved.pushed ? away : void 0;
|
|
15420
15942
|
const solveSemantics = (hues) => {
|
|
15421
|
-
const
|
|
15943
|
+
const band = params.softLightnessBand;
|
|
15944
|
+
const seed = (l, mul, h) => solveOnPage(
|
|
15945
|
+
null,
|
|
15946
|
+
{ l: banded(l), c: toneChroma(mul), h },
|
|
15947
|
+
bgPage,
|
|
15948
|
+
params.targets,
|
|
15949
|
+
band
|
|
15950
|
+
);
|
|
15951
|
+
const danger2 = seed(0.6, 0.95, hues.danger);
|
|
15952
|
+
const success2 = seed(0.58, 0.85, hues.success);
|
|
15953
|
+
const warning2 = seed(0.72, 0.9, hues.warning);
|
|
15422
15954
|
return {
|
|
15423
|
-
danger: { bg:
|
|
15424
|
-
success: ensureContrast(
|
|
15425
|
-
|
|
15955
|
+
danger: { bg: danger2.hex, fg: "#ffffff", l: danger2.tone.l },
|
|
15956
|
+
success: ensureContrast(
|
|
15957
|
+
success2.hex,
|
|
15958
|
+
SOLVER_DEPS,
|
|
15959
|
+
params.targets.fgOnTone,
|
|
15960
|
+
void 0,
|
|
15961
|
+
dirAfter(success2, AWAY_FROM_LIGHT_PAGE)
|
|
15962
|
+
),
|
|
15963
|
+
warning: ensureContrast(
|
|
15964
|
+
warning2.hex,
|
|
15965
|
+
SOLVER_DEPS,
|
|
15966
|
+
params.targets.fgOnTone,
|
|
15967
|
+
void 0,
|
|
15968
|
+
dirAfter(warning2, AWAY_FROM_LIGHT_PAGE)
|
|
15969
|
+
)
|
|
15426
15970
|
};
|
|
15427
15971
|
};
|
|
15428
15972
|
const firstPass = solveSemantics(anchors0.tones);
|
|
@@ -15458,40 +16002,110 @@ function deriveTheme(input) {
|
|
|
15458
16002
|
const clamped = need.direction > 0 ? Math.max(current.l, floor) : Math.min(current.l, floor);
|
|
15459
16003
|
return Math.abs(clamped - current.l) < 1e-6 ? hex : oklchToHex({ ...current, l: clamped });
|
|
15460
16004
|
};
|
|
15461
|
-
const solveDir = (tone) => {
|
|
16005
|
+
const solveDir = (tone, solved) => {
|
|
15462
16006
|
const need = guard.lightnessSeparation[tone];
|
|
15463
|
-
|
|
16007
|
+
if (need) return need.direction > 0 ? "lighten" : "darken";
|
|
16008
|
+
return dirAfter(solved, AWAY_FROM_LIGHT_PAGE);
|
|
15464
16009
|
};
|
|
15465
|
-
const
|
|
15466
|
-
const
|
|
15467
|
-
|
|
15468
|
-
|
|
16010
|
+
const bandFor = (tone) => guard.lightnessSeparation[tone] ? null : params.softLightnessBand;
|
|
16011
|
+
const dangerSolved = solveOnPage(
|
|
16012
|
+
"danger",
|
|
16013
|
+
{ l: separatedL("danger", banded(0.6)), c: toneChroma(0.95), h: anchors.tones.danger },
|
|
16014
|
+
bgPage,
|
|
16015
|
+
params.targets,
|
|
16016
|
+
bandFor("danger")
|
|
16017
|
+
);
|
|
16018
|
+
const danger = clampSeparatedHex("danger", dangerSolved.hex);
|
|
16019
|
+
const successSolved = solveOnPage(
|
|
16020
|
+
"success",
|
|
16021
|
+
{ l: separatedL("success", banded(0.58)), c: toneChroma(0.85), h: anchors.tones.success },
|
|
16022
|
+
bgPage,
|
|
16023
|
+
params.targets,
|
|
16024
|
+
bandFor("success")
|
|
16025
|
+
);
|
|
16026
|
+
const success = successSolved.hex;
|
|
16027
|
+
const warningSolved = solveOnPage(
|
|
16028
|
+
"warning",
|
|
16029
|
+
{ l: separatedL("warning", banded(0.72)), c: toneChroma(0.9), h: anchors.tones.warning },
|
|
16030
|
+
bgPage,
|
|
16031
|
+
params.targets,
|
|
16032
|
+
bandFor("warning")
|
|
16033
|
+
);
|
|
16034
|
+
const warning = warningSolved.hex;
|
|
15469
16035
|
void firstPass;
|
|
16036
|
+
const infoOnPage = solveOnPage(
|
|
16037
|
+
"info",
|
|
16038
|
+
{ l: banded(0.6), c: toneChroma(0.9), h: anchors.tones.info },
|
|
16039
|
+
bgPage,
|
|
16040
|
+
params.targets,
|
|
16041
|
+
params.softLightnessBand
|
|
16042
|
+
);
|
|
15470
16043
|
const infoSolved = ensureContrast(
|
|
15471
|
-
|
|
15472
|
-
SOLVER_DEPS
|
|
16044
|
+
infoOnPage.hex,
|
|
16045
|
+
SOLVER_DEPS,
|
|
16046
|
+
params.targets.fgOnTone,
|
|
16047
|
+
void 0,
|
|
16048
|
+
dirAfter(infoOnPage, AWAY_FROM_LIGHT_PAGE)
|
|
15473
16049
|
);
|
|
15474
16050
|
const info = infoSolved.bg;
|
|
15475
16051
|
const infoFg = infoSolved.fg;
|
|
15476
|
-
const ensureBrandTone = (
|
|
15477
|
-
const solved = ensureContrast(
|
|
16052
|
+
const ensureBrandTone = (seedHex, forceDirection) => {
|
|
16053
|
+
const solved = ensureContrast(
|
|
16054
|
+
seedHex,
|
|
16055
|
+
SOLVER_DEPS,
|
|
16056
|
+
params.targets.fgOnTone,
|
|
16057
|
+
void 0,
|
|
16058
|
+
forceDirection
|
|
16059
|
+
);
|
|
15478
16060
|
return { bg: solved.bg, fg: solved.fg, soft: hexWithAlpha(solved.bg, 0.12) };
|
|
15479
16061
|
};
|
|
15480
|
-
const
|
|
15481
|
-
l:
|
|
16062
|
+
const secondarySeed = {
|
|
16063
|
+
l: Math.min(0.72, Math.max(0.45, brand.l + 0.04)),
|
|
15482
16064
|
c: Math.max(brand.c, 0.1) * 0.9 * params.chromaMul,
|
|
15483
16065
|
h: anchors.tones.secondary
|
|
15484
|
-
}
|
|
15485
|
-
const
|
|
15486
|
-
l:
|
|
16066
|
+
};
|
|
16067
|
+
const accentSeed = {
|
|
16068
|
+
l: Math.min(0.78, Math.max(0.48, brand.l + 0.08)),
|
|
15487
16069
|
c: Math.max(brand.c, 0.1) * 0.85 * params.chromaMul,
|
|
15488
16070
|
h: anchors.tones.accent
|
|
15489
|
-
}
|
|
15490
|
-
const
|
|
16071
|
+
};
|
|
16072
|
+
const secondaryOnPage = solveOnPage(
|
|
16073
|
+
"secondary",
|
|
16074
|
+
{ ...secondarySeed, l: banded(secondarySeed.l) },
|
|
16075
|
+
bgPage,
|
|
16076
|
+
params.targets,
|
|
16077
|
+
params.softLightnessBand
|
|
16078
|
+
);
|
|
16079
|
+
const secondaryTone = ensureBrandTone(
|
|
16080
|
+
secondaryOnPage.hex,
|
|
16081
|
+
dirAfter(secondaryOnPage, AWAY_FROM_LIGHT_PAGE)
|
|
16082
|
+
);
|
|
16083
|
+
const accentOnPage = solveOnPage(
|
|
16084
|
+
"accent",
|
|
16085
|
+
{ ...accentSeed, l: banded(accentSeed.l) },
|
|
16086
|
+
bgPage,
|
|
16087
|
+
params.targets,
|
|
16088
|
+
params.softLightnessBand
|
|
16089
|
+
);
|
|
16090
|
+
const accentTone = ensureBrandTone(
|
|
16091
|
+
accentOnPage.hex,
|
|
16092
|
+
dirAfter(accentOnPage, AWAY_FROM_LIGHT_PAGE)
|
|
16093
|
+
);
|
|
16094
|
+
const secondaryDarkBase = ensureContrast(
|
|
16095
|
+
oklchToHex(secondarySeed),
|
|
16096
|
+
SOLVER_DEPS,
|
|
16097
|
+
params.targets.fgOnTone
|
|
16098
|
+
).bg;
|
|
16099
|
+
const accentDarkBase = ensureContrast(
|
|
16100
|
+
oklchToHex(accentSeed),
|
|
16101
|
+
SOLVER_DEPS,
|
|
16102
|
+
params.targets.fgOnTone
|
|
16103
|
+
).bg;
|
|
16104
|
+
const neutralTone = ensureBrandTone(oklchToHex({
|
|
15491
16105
|
l: 0.18,
|
|
15492
16106
|
c: grayChroma * 1.4,
|
|
15493
16107
|
h: grayHue
|
|
15494
|
-
});
|
|
16108
|
+
}));
|
|
15495
16109
|
const clampSeparated = (tone, solved) => {
|
|
15496
16110
|
const need = guard.lightnessSeparation[tone];
|
|
15497
16111
|
if (!need) return solved;
|
|
@@ -15504,13 +16118,12 @@ function deriveTheme(input) {
|
|
|
15504
16118
|
};
|
|
15505
16119
|
const successFg = clampSeparated(
|
|
15506
16120
|
"success",
|
|
15507
|
-
ensureContrast(success, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("success"))
|
|
16121
|
+
ensureContrast(success, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("success", successSolved))
|
|
15508
16122
|
);
|
|
15509
16123
|
const warningFg = clampSeparated(
|
|
15510
16124
|
"warning",
|
|
15511
|
-
ensureContrast(warning, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("warning"))
|
|
16125
|
+
ensureContrast(warning, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("warning", warningSolved))
|
|
15512
16126
|
);
|
|
15513
|
-
const bgPage = gray(0.965);
|
|
15514
16127
|
let textPrimary = gray(0.25);
|
|
15515
16128
|
for (let i = 0; i < 16 && contrastRatio(bgPage, textPrimary) < params.targets.textOnPage; i++) {
|
|
15516
16129
|
const cur = hexToOklch(textPrimary);
|
|
@@ -15519,10 +16132,8 @@ function deriveTheme(input) {
|
|
|
15519
16132
|
const glassShadow = hexWithAlpha(scale["500"], 0.14);
|
|
15520
16133
|
const glassShadowSoft = hexWithAlpha(scale["500"], 0.09);
|
|
15521
16134
|
const cssVars = {
|
|
15522
|
-
//
|
|
15523
|
-
|
|
15524
|
-
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.88)",
|
|
15525
|
-
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.52)",
|
|
16135
|
+
// 玻璃材质:面/强面/高光边/彩色投影。玻璃三档的值只住在 scene-tokens 的 glassTokens 一处
|
|
16136
|
+
...glassTokens(false),
|
|
15526
16137
|
"--soma-edge-highlight": "rgba(255, 255, 255, 0.72)",
|
|
15527
16138
|
"--soma-shadow-tinted": `0 24px 70px ${glassShadow}`,
|
|
15528
16139
|
"--soma-shadow-tinted-soft": `0 16px 36px ${glassShadowSoft}`,
|
|
@@ -15608,21 +16219,21 @@ function deriveTheme(input) {
|
|
|
15608
16219
|
}
|
|
15609
16220
|
const darkHover = oklchToHex({ ...hexToOklch(darkPrimary), l: hexToOklch(darkPrimary).l + 0.05 });
|
|
15610
16221
|
const darkToneHues = axes.palette.harmony === "functional" && axes.palette.semantics === "faithful" && axes.palette.chroma === "balanced" && axes.palette.accents.length === 0 ? FUNCTIONAL_HUES : anchors.tones;
|
|
15611
|
-
const darkDanger =
|
|
16222
|
+
const darkDanger = solveOnPage("danger", {
|
|
15612
16223
|
l: 0.68,
|
|
15613
16224
|
c: Math.max(brand.c, 0.12) * 0.9 * params.chromaMul,
|
|
15614
16225
|
h: darkToneHues.danger
|
|
15615
|
-
});
|
|
15616
|
-
const darkSuccess =
|
|
16226
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
16227
|
+
const darkSuccess = solveOnPage("success", {
|
|
15617
16228
|
l: 0.66,
|
|
15618
16229
|
c: Math.max(brand.c, 0.12) * 0.8 * params.chromaMul,
|
|
15619
16230
|
h: darkToneHues.success
|
|
15620
|
-
});
|
|
15621
|
-
const darkWarning =
|
|
16231
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
16232
|
+
const darkWarning = solveOnPage("warning", {
|
|
15622
16233
|
l: 0.76,
|
|
15623
16234
|
c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
|
|
15624
16235
|
h: darkToneHues.warning
|
|
15625
|
-
});
|
|
16236
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
15626
16237
|
const darkSuccessEnsured = (() => {
|
|
15627
16238
|
let bg = darkSuccess;
|
|
15628
16239
|
let fg2 = bestFg(bg);
|
|
@@ -15643,18 +16254,25 @@ function deriveTheme(input) {
|
|
|
15643
16254
|
}
|
|
15644
16255
|
return { bg, fg: fg2 };
|
|
15645
16256
|
})();
|
|
15646
|
-
let darkInfo =
|
|
16257
|
+
let darkInfo = solveOnPage("info", {
|
|
15647
16258
|
l: 0.68,
|
|
15648
16259
|
c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
|
|
15649
16260
|
h: darkToneHues.info
|
|
15650
|
-
});
|
|
16261
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
15651
16262
|
let darkInfoFg = bestFg(darkInfo);
|
|
15652
16263
|
for (let i = 0; i < 16 && contrastRatio(darkInfo, darkInfoFg) < params.darkTargets.fgOnTone; i++) {
|
|
15653
16264
|
const cur = hexToOklch(darkInfo);
|
|
15654
16265
|
darkInfo = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
15655
16266
|
darkInfoFg = bestFg(darkInfo);
|
|
15656
16267
|
}
|
|
15657
|
-
const
|
|
16268
|
+
const darkSecondary = solveOnPage("secondary", {
|
|
16269
|
+
...hexToOklch(secondaryDarkBase),
|
|
16270
|
+
l: Math.min(0.78, hexToOklch(secondaryDarkBase).l + 0.08)
|
|
16271
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
16272
|
+
const darkAccent = solveOnPage("accent", {
|
|
16273
|
+
...hexToOklch(accentDarkBase),
|
|
16274
|
+
l: Math.min(0.82, hexToOklch(accentDarkBase).l + 0.08)
|
|
16275
|
+
}, darkBgPage, params.darkTargets, null).hex;
|
|
15658
16276
|
let darkTextPrimary = gray(0.92);
|
|
15659
16277
|
for (let i = 0; i < 16 && contrastRatio(darkBgPage, darkTextPrimary) < params.darkTargets.textOnPage; i++) {
|
|
15660
16278
|
const cur = hexToOklch(darkTextPrimary);
|
|
@@ -15667,11 +16285,11 @@ function deriveTheme(input) {
|
|
|
15667
16285
|
"--soma-c-primary-active": oklchToHex({ ...hexToOklch(darkPrimary), l: hexToOklch(darkPrimary).l + 0.1 }),
|
|
15668
16286
|
"--soma-c-primary-fg": darkFg,
|
|
15669
16287
|
"--soma-c-primary-soft": hexWithAlpha(scale["400"], 0.14),
|
|
15670
|
-
"--soma-c-secondary":
|
|
15671
|
-
"--soma-c-secondary-fg": bestFg(
|
|
16288
|
+
"--soma-c-secondary": darkSecondary,
|
|
16289
|
+
"--soma-c-secondary-fg": bestFg(darkSecondary),
|
|
15672
16290
|
"--soma-c-secondary-soft": hexWithAlpha(secondaryTone.bg, 0.18),
|
|
15673
|
-
"--soma-c-accent":
|
|
15674
|
-
"--soma-c-accent-fg": bestFg(
|
|
16291
|
+
"--soma-c-accent": darkAccent,
|
|
16292
|
+
"--soma-c-accent-fg": bestFg(darkAccent),
|
|
15675
16293
|
"--soma-c-accent-soft": hexWithAlpha(accentTone.bg, 0.18),
|
|
15676
16294
|
"--soma-c-danger": darkDanger,
|
|
15677
16295
|
"--soma-c-success": darkSuccessEnsured.bg,
|
|
@@ -15698,11 +16316,9 @@ function deriveTheme(input) {
|
|
|
15698
16316
|
"--soma-c-info-soft": hexWithAlpha(darkInfo, 0.16),
|
|
15699
16317
|
// 暗色下的阴影:亮色那套 rgba(0,0,0,.06~.16) 落在深底上等于不存在,
|
|
15700
16318
|
// 层级会整个塌掉。加深并加大扩散,让浮层仍然"浮"得起来
|
|
15701
|
-
//
|
|
15702
|
-
//
|
|
15703
|
-
|
|
15704
|
-
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.1)",
|
|
15705
|
-
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.04)",
|
|
16319
|
+
// 暗色玻璃:仍是白,但 alpha 只有 4%~10%(亮色是 52%~88%)——高 alpha 的白玻璃
|
|
16320
|
+
// 落在深底上会变成一块发光的板,层级反而糊掉。高光边同理减弱,只留一线。
|
|
16321
|
+
...glassTokens(true),
|
|
15706
16322
|
"--soma-edge-highlight": "rgba(255, 255, 255, 0.12)",
|
|
15707
16323
|
"--soma-shadow-tinted": "0 24px 70px rgba(0, 0, 0, 0.55)",
|
|
15708
16324
|
"--soma-shadow-tinted-soft": "0 16px 36px rgba(0, 0, 0, 0.45)",
|
|
@@ -15742,6 +16358,8 @@ function deriveTheme(input) {
|
|
|
15742
16358
|
syncSoftWithOverrides(darkCssVars, darkMerged);
|
|
15743
16359
|
enforceContrastPairs(cssVars);
|
|
15744
16360
|
enforceContrastPairs(darkCssVars);
|
|
16361
|
+
enforceReadableText(cssVars);
|
|
16362
|
+
enforceReadableText(darkCssVars);
|
|
15745
16363
|
deriveOnSoftTokens(cssVars, false);
|
|
15746
16364
|
deriveOnSoftTokens(darkCssVars, true);
|
|
15747
16365
|
const makeRescale = (tokens) => tokens?.["--soma-c-primary"] ? (primaryHex) => {
|
|
@@ -15778,6 +16396,8 @@ function deriveTheme(input) {
|
|
|
15778
16396
|
axes,
|
|
15779
16397
|
separationApplied: guard.applied,
|
|
15780
16398
|
pushed: guard.pushed,
|
|
16399
|
+
// 排序保证确定性:meta 也要满足"同输入必同输出"
|
|
16400
|
+
bandBroken: [...bandBroken].sort(),
|
|
15781
16401
|
componentTokens: Object.keys({ ...lightComponentTokens, ...darkComponentTokens }).sort()
|
|
15782
16402
|
}
|
|
15783
16403
|
};
|
|
@@ -15888,12 +16508,37 @@ function writeTokensBatch(el, vars) {
|
|
|
15888
16508
|
style.cssText = `${parts.join("; ")};`;
|
|
15889
16509
|
}
|
|
15890
16510
|
|
|
15891
|
-
// core/client/
|
|
15892
|
-
function
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
|
|
16511
|
+
// core/client/component/theme-component-tokens.ts
|
|
16512
|
+
function validateThemeComponentTokens(input, components) {
|
|
16513
|
+
const issues = [];
|
|
16514
|
+
for (const segment of [input.components, input.darkComponents]) {
|
|
16515
|
+
if (!segment) continue;
|
|
16516
|
+
for (const [componentName, tokens] of Object.entries(segment)) {
|
|
16517
|
+
const definition = Object.hasOwn(components, componentName) ? components[componentName] : void 0;
|
|
16518
|
+
if (!definition) {
|
|
16519
|
+
issues.push(`\u672A\u77E5\u7EC4\u4EF6 "${componentName}"`);
|
|
16520
|
+
continue;
|
|
16521
|
+
}
|
|
16522
|
+
const declared = definition.contract.tokens ?? {};
|
|
16523
|
+
for (const key of Object.keys(tokens ?? {})) {
|
|
16524
|
+
if (!(key in declared)) {
|
|
16525
|
+
const available = Object.keys(declared);
|
|
16526
|
+
issues.push(
|
|
16527
|
+
`"${componentName}" \u6CA1\u6709\u58F0\u660E\u53EF\u8C03\u4EE4\u724C "${key}"` + (available.length > 0 ? `\uFF08\u5B83\u58F0\u660E\u7684\u662F\uFF1A${available.join(" / ")}\uFF09` : "\uFF08\u5B83\u4E00\u4E2A\u53EF\u8C03\u4EE4\u724C\u90FD\u6CA1\u58F0\u660E\u2014\u2014\u7EC4\u4EF6\u4EE4\u724C\u662F\u7EC4\u4EF6\u81EA\u5DF1\u7684\u627F\u8BFA\uFF0C\u4E0D\u80FD\u7531\u5916\u9762\u51ED\u7A7A\u6307\u5B9A\uFF09")
|
|
16528
|
+
);
|
|
16529
|
+
}
|
|
16530
|
+
}
|
|
16531
|
+
}
|
|
16532
|
+
}
|
|
16533
|
+
return issues;
|
|
16534
|
+
}
|
|
16535
|
+
|
|
16536
|
+
// core/client/observability/error-reporter.ts
|
|
16537
|
+
function safePath() {
|
|
16538
|
+
if (typeof location === "undefined") {
|
|
16539
|
+
return void 0;
|
|
16540
|
+
}
|
|
16541
|
+
return location.pathname;
|
|
15897
16542
|
}
|
|
15898
16543
|
function toMessage(value) {
|
|
15899
16544
|
if (value instanceof Error) {
|
|
@@ -15991,6 +16636,44 @@ function isSomaDeclarationSource(value) {
|
|
|
15991
16636
|
return text === "{{";
|
|
15992
16637
|
});
|
|
15993
16638
|
}
|
|
16639
|
+
var SOMA_OOUI_REGION_ATTR = "data-soma-ooui";
|
|
16640
|
+
var SOMA_OOUI_ALLOWED_TAGS = /* @__PURE__ */ new Set(["DIV", "SPAN"]);
|
|
16641
|
+
var SOMA_OOUI_ALLOWED_ATTRS = /* @__PURE__ */ new Set([
|
|
16642
|
+
"class",
|
|
16643
|
+
"data-soma-node",
|
|
16644
|
+
"data-soma-id",
|
|
16645
|
+
"data-soma-component"
|
|
16646
|
+
]);
|
|
16647
|
+
function findOouiDomOffence(fragment) {
|
|
16648
|
+
const roots = fragment.children;
|
|
16649
|
+
if (roots.length !== 1) {
|
|
16650
|
+
return `\u9876\u5C42\u5143\u7D20\u6709 ${roots.length} \u4E2A\uFF0C\u4EA7\u7269\u6052\u4E3A\u5355\u4E2A\u533A\u57DF\u5916\u58F3`;
|
|
16651
|
+
}
|
|
16652
|
+
for (const node of Array.from(fragment.childNodes)) {
|
|
16653
|
+
if (node.nodeType !== 1 && (node.textContent ?? "").trim() !== "") {
|
|
16654
|
+
return `\u9876\u5C42\u6DF7\u6709\u5143\u7D20\u4EE5\u5916\u7684\u8282\u70B9\uFF08nodeType ${node.nodeType}\uFF09`;
|
|
16655
|
+
}
|
|
16656
|
+
}
|
|
16657
|
+
for (const element of Array.from(fragment.querySelectorAll("*"))) {
|
|
16658
|
+
if (!SOMA_OOUI_ALLOWED_TAGS.has(element.tagName)) {
|
|
16659
|
+
return `\u6807\u7B7E <${element.tagName.toLowerCase()}>`;
|
|
16660
|
+
}
|
|
16661
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
16662
|
+
if (!SOMA_OOUI_ALLOWED_ATTRS.has(attribute.name)) {
|
|
16663
|
+
return `\u5C5E\u6027 ${attribute.name}`;
|
|
16664
|
+
}
|
|
16665
|
+
}
|
|
16666
|
+
}
|
|
16667
|
+
return null;
|
|
16668
|
+
}
|
|
16669
|
+
function oouiHtmlFingerprint(html) {
|
|
16670
|
+
let hash = 2166136261;
|
|
16671
|
+
for (let index = 0; index < html.length; index += 1) {
|
|
16672
|
+
hash ^= html.charCodeAt(index);
|
|
16673
|
+
hash = Math.imul(hash, 16777619);
|
|
16674
|
+
}
|
|
16675
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
16676
|
+
}
|
|
15994
16677
|
function reportToConsole(event) {
|
|
15995
16678
|
console.error(`[soma-core][\u53EF\u89C2\u6D4B] ${JSON.stringify(event)}`);
|
|
15996
16679
|
}
|
|
@@ -16062,6 +16745,7 @@ var SomaBootstrap = class {
|
|
|
16062
16745
|
this.assets = { ...assets };
|
|
16063
16746
|
const parsed = this.assetResolver.resolve(this.assets);
|
|
16064
16747
|
this.adapter.mount(container, this.assets.html, this.assets.includes);
|
|
16748
|
+
this.installOouiHtml(container, parsed.uiConfig);
|
|
16065
16749
|
this.setupComponentManager(container, this.assets, parsed.uiConfig);
|
|
16066
16750
|
this.applyHostTheme(parsed.appConfig);
|
|
16067
16751
|
this.domainInstance = this.createDomainInstance(assets.DomainClass, parsed, assets.routerPath);
|
|
@@ -16107,6 +16791,7 @@ var SomaBootstrap = class {
|
|
|
16107
16791
|
this.componentManager?.destroy();
|
|
16108
16792
|
this.componentManager = null;
|
|
16109
16793
|
this.adapter.mount(this.container, merged.html, merged.includes);
|
|
16794
|
+
this.installOouiHtml(this.container, parsed.uiConfig);
|
|
16110
16795
|
this.setupComponentManager(this.container, merged, parsed.uiConfig);
|
|
16111
16796
|
if (overrides.DomainClass) {
|
|
16112
16797
|
this.proxy?.dispose();
|
|
@@ -16383,6 +17068,7 @@ var SomaBootstrap = class {
|
|
|
16383
17068
|
if (!theme?.brand) {
|
|
16384
17069
|
return;
|
|
16385
17070
|
}
|
|
17071
|
+
this.reconcileThemeComponentTokens(theme);
|
|
16386
17072
|
try {
|
|
16387
17073
|
applyTheme(theme);
|
|
16388
17074
|
} catch (error) {
|
|
@@ -16390,6 +17076,37 @@ var SomaBootstrap = class {
|
|
|
16390
17076
|
this.captureEngineError(error);
|
|
16391
17077
|
}
|
|
16392
17078
|
}
|
|
17079
|
+
/**
|
|
17080
|
+
* 组件令牌对账(REQ-009 M-1):`components: { Buton: { radius: … } }` 这样一个
|
|
17081
|
+
* 拼写错误,不对账时的表现是**"改了没反应"**——变量确实写进了 :root,
|
|
17082
|
+
* 只是没有任何组件读它。这类错误的排查成本远高于报错。
|
|
17083
|
+
*
|
|
17084
|
+
* 判据住在 `component/theme-component-tokens.ts`,而它此前**一个调用者都没有**
|
|
17085
|
+
* (由 `verify:reachable` 查出)。这里是全仓唯一同时持有「主题输入」与
|
|
17086
|
+
* 「这一页实际可用的组件表」的地方,所以对账只能发生在这一点上。
|
|
17087
|
+
*
|
|
17088
|
+
* 两条边界:
|
|
17089
|
+
* · **只告警、不阻断换装**。主题是 app 级、全部页面共享的,组件表却是逐页的;
|
|
17090
|
+
* 曾经对账与 applyTheme 同在一个 try 里,一条对不上就把整份品牌主题一起丢掉
|
|
17091
|
+
* (全页回落默认令牌 + 一条"主题派生失败"),与"一个令牌没人读"的后果不成比例。
|
|
17092
|
+
* · **组件表 = Host 级 + 页面级**,与 setupComponentManager 实际装配的那张表同一口径
|
|
17093
|
+
* (页面同名胜出)。只看 Host 级的话,只在页面资产里注册的组件会被误报成未知组件。
|
|
17094
|
+
* 拿不到组件表时(纯预览场景)按设计跳过,不猜。
|
|
17095
|
+
*/
|
|
17096
|
+
reconcileThemeComponentTokens(theme) {
|
|
17097
|
+
const components = { ...this.hostComponents, ...this.assets?.components ?? {} };
|
|
17098
|
+
if (Object.keys(components).length === 0) {
|
|
17099
|
+
return;
|
|
17100
|
+
}
|
|
17101
|
+
const issues = validateThemeComponentTokens(theme, components);
|
|
17102
|
+
if (issues.length === 0) {
|
|
17103
|
+
return;
|
|
17104
|
+
}
|
|
17105
|
+
const message = `\u4E3B\u9898\u7684\u7EC4\u4EF6\u4EE4\u724C\u6BB5\u6709 ${issues.length} \u5904\u5BF9\u4E0D\u4E0A\u7EC4\u4EF6\u5951\u7EA6\uFF08\u4E3B\u9898\u7167\u5E38\u751F\u6548\uFF1B\u8FD9\u4E9B\u4EE4\u724C\u4F1A\u5199\u8FDB :root\uFF0C\u4F46\u5F53\u524D\u9875\u6CA1\u6709\u7EC4\u4EF6\u8BFB\u5B83\u4EEC\uFF09\uFF1A
|
|
17106
|
+
${issues.map((issue) => ` \xB7 ${issue}`).join("\n")}`;
|
|
17107
|
+
console.warn(`[soma-core][\u4E3B\u9898] ${message}`);
|
|
17108
|
+
this.diagnostics.recordValidation("warning", `[\u4E3B\u9898\u7EC4\u4EF6\u4EE4\u724C] ${message}`);
|
|
17109
|
+
}
|
|
16393
17110
|
/**
|
|
16394
17111
|
* 组件可见的服务表:页面运行时服务 + data 端口(M-5)。
|
|
16395
17112
|
*
|
|
@@ -16402,17 +17119,6 @@ var SomaBootstrap = class {
|
|
|
16402
17119
|
if (!base) return void 0;
|
|
16403
17120
|
return { ...base, data: this.createStableDataPort() };
|
|
16404
17121
|
}
|
|
16405
|
-
/**
|
|
16406
|
-
* 页面态装配(REQ-010 F-37)。
|
|
16407
|
-
*
|
|
16408
|
-
* 三个来源按优先级取:**URL > initial_state > 空**。
|
|
16409
|
-
* URL 在最前是因为它是"用户此刻明确要求看到的那一屏"(分享链接、书签、回退按钮),
|
|
16410
|
-
* 而 `initial_state` 只是作者写的缺省。反过来的话,分享链接打开后会被缺省覆盖,
|
|
16411
|
-
* 而那正是分享链接唯一的用途。
|
|
16412
|
-
*
|
|
16413
|
-
* 版本对不上的 URL 状态整份丢弃并 warn 一次:恢复一份旧结构的状态会让界面进入
|
|
16414
|
-
* 一个谁都没设计过的样子,而那种坏法是静默的(列还在、但顺序是乱的)。
|
|
16415
|
-
*/
|
|
16416
17122
|
/**
|
|
16417
17123
|
* 约束布局产物注入(REQ-011 接线 / CL-4)。
|
|
16418
17124
|
*
|
|
@@ -16436,6 +17142,120 @@ var SomaBootstrap = class {
|
|
|
16436
17142
|
);
|
|
16437
17143
|
}
|
|
16438
17144
|
}
|
|
17145
|
+
/**
|
|
17146
|
+
* OOUI 演绎产物的 DOM 落点(REQ-014 最后一公里)。
|
|
17147
|
+
*
|
|
17148
|
+
* ── 为什么"没有这一步"是一种静默失败 ─────────────────────────────
|
|
17149
|
+
* 在它之前,整条演绎链止于 `deduce()` 的返回值:六层全绿、`ooui_artifact`
|
|
17150
|
+
* 在资产里、样式表也注入了,**页面上什么都没有**。而"锚点空着"与
|
|
17151
|
+
* "这块本来就没写内容"在浏览器里长得一模一样——没有异常、没有日志、
|
|
17152
|
+
* 截图里也分不开。这是最像成功的那种失败,所以落点必须有断言守着。
|
|
17153
|
+
*
|
|
17154
|
+
* ── 运行时收到产物就用,收到声明就拒绝代算 ───────────────────────
|
|
17155
|
+
* 与 `installLayoutCss` / `installOouiArtifact` 同一条范式:本方法**只搬运**。
|
|
17156
|
+
* 它不认识形态、不认识候选表、不认识组件契约——那些词汇住在 soma-ui,
|
|
17157
|
+
* 浏览器手里根本没有,代算出来的只会是一份猜的界面。
|
|
17158
|
+
*
|
|
17159
|
+
* ── 为什么"引擎生成的"不等于"可信的"(架构 §24.1)───────────────
|
|
17160
|
+
* 这串 html 随 `_ui.yaml` 走。发布期的注入面静态扫描(`declaration-safety-scan.ts`)
|
|
17161
|
+
* 如今对 YAML 面也跑 html 那四条判据(禁用标签 / on\* 处理器 / srcdoc / 伪协议),
|
|
17162
|
+
* 门口已经拦得住一份被改过的 `_ui.yaml`。但门口只守 Registry 这一条写路径:
|
|
17163
|
+
* 文件态 Host 的资产、预览器直接喂进来的资产都不经过它;而 innerHTML 插入的
|
|
17164
|
+
* `<script>` 虽然不执行,`<img onerror=…>` 却会立刻执行。所以注入前必须再核一道——
|
|
17165
|
+
* 这是纵深防御的最后一层,不因门口补齐而省掉。
|
|
17166
|
+
*
|
|
17167
|
+
* 核的方式是**允许集**不是禁用集:`emitRegionHtml` 今天只产出
|
|
17168
|
+
* `div` / `span` 两种标签与四个 `class` / `data-soma-*` 属性,
|
|
17169
|
+
* 把这个全集写死,任何多出来的东西一律拒收。禁用集在这种两标签的产物上
|
|
17170
|
+
* 严格更差——它只挡得住今天想得到的那几样。发射器哪天真加了新标签,
|
|
17171
|
+
* 这里会**当场红**(而不是静默放行),红在写下的那天,这正是要的。
|
|
17172
|
+
*
|
|
17173
|
+
* 解析走 `<template>`:template 的内容是**惰性的**——不加载图片、不跑脚本,
|
|
17174
|
+
* 所以"先解析再检查"这个顺序本身不会触发任何东西。检查通过之后才搬进文档。
|
|
17175
|
+
*/
|
|
17176
|
+
installOouiHtml(container, uiConfig) {
|
|
17177
|
+
const artifact = uiConfig.oouiArtifact;
|
|
17178
|
+
if (!artifact || artifact.regions.length === 0) return;
|
|
17179
|
+
const doc = container.ownerDocument ?? globalThis.document ?? null;
|
|
17180
|
+
if (!doc || typeof doc.createElement !== "function") {
|
|
17181
|
+
console.warn(
|
|
17182
|
+
`[soma-core][\u6F14\u7ECE] \u9875\u9762 "${uiConfig.bind.obj}" \u6709 ${artifact.regions.length} \u4E2A\u6F14\u7ECE\u533A\u57DF\uFF0C\u4F46\u5F53\u524D\u5BB9\u5668\u6CA1\u6709 document\uFF0C\u6F14\u7ECE DOM \u65E0\u6CD5\u843D\u5730\u2014\u2014\u6F14\u7ECE\u4EA7\u7269\u4ECA\u5929\u53EA\u652F\u6301 Web \u5BB9\u5668\uFF08DOM \u7531 <template> \u60F0\u6027\u89E3\u6790\u540E\u642C\u5165\uFF09\u3002`
|
|
17183
|
+
);
|
|
17184
|
+
return;
|
|
17185
|
+
}
|
|
17186
|
+
for (const region of artifact.regions) {
|
|
17187
|
+
const host = this.adapter.findAnchor(container, region.anchor);
|
|
17188
|
+
if (!host) {
|
|
17189
|
+
console.warn(
|
|
17190
|
+
`[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u5728\u9875\u9762 HTML \u91CC\u627E\u4E0D\u5230\u951A\u70B9\uFF08data-soma-id\uFF09\u2014\u2014html \u4E0E _ui.yaml \u4E0D\u662F\u540C\u4E00\u6B21\u7F16\u8BD1\u7684\u4EA7\u7269\u3002\u8FD9\u4E00\u5757\u4E0D\u4F1A\u6709\u4EFB\u4F55\u5185\u5BB9\u3002`
|
|
17191
|
+
);
|
|
17192
|
+
continue;
|
|
17193
|
+
}
|
|
17194
|
+
const html = typeof region.html === "string" ? region.html : "";
|
|
17195
|
+
if (html.trim() === "") {
|
|
17196
|
+
console.warn(
|
|
17197
|
+
`[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u7684\u4EA7\u7269\u91CC\u6CA1\u6709 html\u2014\u2014\u8FD9\u662F\u4E00\u4EFD\u65E7\u683C\u5F0F\uFF08\u6216\u624B\u5199\uFF09\u7684 ooui_artifact\u3002\u91CD\u65B0\u8DD1\u4E00\u6B21\u6784\u5EFA\u671F\u7F16\u8BD1\uFF08compilePageDeclaration\uFF09\u5373\u53EF\uFF0C\u8FD0\u884C\u65F6\u4E0D\u4EE3\u4E3A\u6F14\u7ECE\u3002`
|
|
17198
|
+
);
|
|
17199
|
+
continue;
|
|
17200
|
+
}
|
|
17201
|
+
const fingerprint = oouiHtmlFingerprint(html);
|
|
17202
|
+
if (host.getAttribute(SOMA_OOUI_REGION_ATTR) === fingerprint) continue;
|
|
17203
|
+
const template = doc.createElement("template");
|
|
17204
|
+
template.innerHTML = html;
|
|
17205
|
+
const offence = findOouiDomOffence(template.content);
|
|
17206
|
+
if (offence !== null) {
|
|
17207
|
+
console.error(
|
|
17208
|
+
`[soma-core][\u6F14\u7ECE] \u6F14\u7ECE\u533A\u57DF "${region.anchor}" \u7684\u4EA7\u7269 DOM \u4E0D\u5728\u5141\u8BB8\u96C6\u5185\uFF08${offence}\uFF09\uFF0C\u5DF2\u62D2\u7EDD\u6CE8\u5165\u3002\u4EA7\u7269\u968F _ui.yaml \u8D70\uFF0C\u800C\u90A3\u4EFD\u8D44\u4EA7\u53EF\u4EE5\u88AB\u624B\u5199\u3001\u88AB\u6539\uFF1A\u53D1\u5E03\u671F\u7684\u6CE8\u5165\u9762\u626B\u63CF\u867D\u7136\u4E5F\u626B YAML \u9762\uFF0C\u4F46\u5B83\u53EA\u5B88"\u5199\u8FDB\u58F0\u660E\u4ED3\u5E93"\u8FD9\u4E2A\u5165\u53E3\uFF0C\u7ED5\u8FC7 Registry \u7684\u6784\u5EFA\u4E0E\u53D1\u5E03\u540E\u6539\u8D44\u4EA7\u90FD\u4E0D\u7ECF\u8FC7\u5B83\u3002\u6240\u4EE5\u6CE8\u5165\u524D\u8FD9\u9053\u7ED3\u6784\u95F8\u95E8\u662F\u6700\u540E\u4E00\u5173\u2014\u2014\u653E\u884C\u4E00\u6B21\u5C31\u7B49\u4E8E\u628A innerHTML \u4EA4\u4E86\u51FA\u53BB\u3002\u6B63\u5E38\u4EA7\u7269\u53EA\u542B div/span \u4E0E class/data-soma-node/data-soma-id/data-soma-component\u3002\u82E5\u8FD9\u662F\u53D1\u5C04\u5668\u65B0\u52A0\u7684\u5408\u6CD5\u5F62\u72B6\uFF0C\u8BF7\u540C\u6B65 soma-bootstrap.ts \u7684 SOMA_OOUI_ALLOWED_TAGS / _ATTRS\uFF1B\u5426\u5219\u8BF7\u91CD\u65B0\u8DD1\u4E00\u6B21 compilePageDeclaration \u751F\u6210\u4EA7\u7269\uFF0C\u4E0D\u8981\u624B\u5199 ooui_artifact\u3002`
|
|
17209
|
+
);
|
|
17210
|
+
continue;
|
|
17211
|
+
}
|
|
17212
|
+
while (host.firstChild) host.removeChild(host.firstChild);
|
|
17213
|
+
host.appendChild(template.content);
|
|
17214
|
+
host.setAttribute(SOMA_OOUI_REGION_ATTR, fingerprint);
|
|
17215
|
+
}
|
|
17216
|
+
}
|
|
17217
|
+
/**
|
|
17218
|
+
* OOUI 演绎产物注入(REQ-014 接线)。
|
|
17219
|
+
*
|
|
17220
|
+
* 与 `installLayoutCss` 逐点同构:运行时只认**产物**,收到声明本身只告警。
|
|
17221
|
+
* 演绎链住在 core/build/ooui/,进 client 就等于把「运行期零演绎」这条
|
|
17222
|
+
* 结构性承诺撤回去——而且浏览器手里根本没有候选表与组件契约,
|
|
17223
|
+
* 代算出来的只会是一份猜的界面。
|
|
17224
|
+
*
|
|
17225
|
+
* 注入键用产物自带的**内容哈希**(`ooui:<sha256 前 8 位>`),不用页面名:
|
|
17226
|
+
* `injectStyleOnce` 没有内容冲突检测(同键不同内容静默保留第一份),
|
|
17227
|
+
* 按页面名命名的话,SPA 内路由切到同名不同产物的页面会继续用上一页的 CSS,
|
|
17228
|
+
* 页面看着渲染正常、间距全错、控制台一行都没有。
|
|
17229
|
+
* 位置紧接 `installLayoutCss`——都在组件实例挂载**之前**,级联顺序才稳定。
|
|
17230
|
+
*/
|
|
17231
|
+
installOouiArtifact(uiConfig) {
|
|
17232
|
+
const artifact = uiConfig.oouiArtifact;
|
|
17233
|
+
if (artifact?.css && artifact.css_key) {
|
|
17234
|
+
injectStyleOnce(
|
|
17235
|
+
artifact.css_key,
|
|
17236
|
+
artifact.css,
|
|
17237
|
+
{ nonce: this.componentStyleNonce ?? null }
|
|
17238
|
+
);
|
|
17239
|
+
return;
|
|
17240
|
+
}
|
|
17241
|
+
if (artifact) return;
|
|
17242
|
+
if (uiConfig.ooui && Object.keys(uiConfig.ooui).length > 0) {
|
|
17243
|
+
console.warn(
|
|
17244
|
+
`[soma-core][\u6F14\u7ECE] \u9875\u9762 "${uiConfig.bind.obj}" \u58F0\u660E\u4E86 ooui: \u6BB5\u4F46\u6CA1\u6709\u6784\u5EFA\u671F\u4EA7\u7269\uFF08ooui_artifact\uFF09\u2014\u2014\u58F0\u660E\u672A\u7ECF compilePageDeclaration \u6F14\u7ECE\uFF0C\u672C\u9875\u4E0D\u4F1A\u4EA7\u751F\u4EFB\u4F55\u6F14\u7ECE\u754C\u9762\u3002\u6F14\u7ECE\u53EA\u5728\u6784\u5EFA\u671F\u53D1\u751F\uFF08Registry \u53D1\u5E03 / Host \u9884\u7F16\u8BD1\uFF09\uFF0C\u8FD0\u884C\u65F6\u4E0D\u4EE3\u7B97\u3002`
|
|
17245
|
+
);
|
|
17246
|
+
}
|
|
17247
|
+
}
|
|
17248
|
+
/**
|
|
17249
|
+
* 页面态装配(REQ-010 F-37)。
|
|
17250
|
+
*
|
|
17251
|
+
* 三个来源按优先级取:**URL > initial_state > 空**。
|
|
17252
|
+
* URL 在最前是因为它是"用户此刻明确要求看到的那一屏"(分享链接、书签、回退按钮),
|
|
17253
|
+
* 而 `initial_state` 只是作者写的缺省。反过来的话,分享链接打开后会被缺省覆盖,
|
|
17254
|
+
* 而那正是分享链接唯一的用途。
|
|
17255
|
+
*
|
|
17256
|
+
* 版本对不上的 URL 状态整份丢弃并 warn 一次:恢复一份旧结构的状态会让界面进入
|
|
17257
|
+
* 一个谁都没设计过的样子,而那种坏法是静默的(列还在、但顺序是乱的)。
|
|
17258
|
+
*/
|
|
16439
17259
|
installPageState(config) {
|
|
16440
17260
|
const instance = this.domainInstance;
|
|
16441
17261
|
if (!instance) return;
|
|
@@ -16523,22 +17343,12 @@ ${lines}
|
|
|
16523
17343
|
\u5728 configureSomaBootstrap \u7684 options.actions \u91CC\u767B\u8BB0\u5B83\u4EEC\u3002\u5177\u540D\u52A8\u4F5C\u662F custom(script) \u7684\u66FF\u4EE3\uFF1A\u5B9E\u73B0\u5728 Host \u4EE3\u7801\u91CC\u3001\u6709\u540D\u5B57\u3001\u53EF\u5BA1\u8BA1\u3002`
|
|
16524
17344
|
);
|
|
16525
17345
|
}
|
|
16526
|
-
/**
|
|
17346
|
+
/**
|
|
17347
|
+
* 稳定的 data 端口壳:每次调用现取当前解析器(解析器暂缺时的兜底住在 createSomaDataPort 里,
|
|
17348
|
+
* 与端口的方法面同一处——测试守的就是这里注入的那一个端口)。
|
|
17349
|
+
*/
|
|
16527
17350
|
createStableDataPort() {
|
|
16528
|
-
|
|
16529
|
-
ok: false,
|
|
16530
|
-
message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u58F0\u660E *_data.yaml\uFF09`
|
|
16531
|
-
});
|
|
16532
|
-
return {
|
|
16533
|
-
getObject: (name) => this.dataResolver?.getObject(name),
|
|
16534
|
-
getDict: (name) => this.dataResolver?.getDict(name) ?? {},
|
|
16535
|
-
getReactions: (name) => this.dataResolver?.getReactions(name) ?? null,
|
|
16536
|
-
window: (name) => this.dataResolver?.window(name) ?? null,
|
|
16537
|
-
submit: async (name, model, mode) => this.dataResolver ? this.dataResolver.submit(name, model, mode) : noResolver(`\u63D0\u4EA4 "${name}"`),
|
|
16538
|
-
reload: async (names) => {
|
|
16539
|
-
await this.dataResolver?.reload(names);
|
|
16540
|
-
}
|
|
16541
|
-
};
|
|
17351
|
+
return createSomaDataPort(() => this.dataResolver);
|
|
16542
17352
|
}
|
|
16543
17353
|
/** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
|
|
16544
17354
|
setupComponentManager(container, assets, uiConfig) {
|
|
@@ -16609,6 +17419,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
16609
17419
|
this.assertNamedActionsResolvable(parsed.eventConfig);
|
|
16610
17420
|
this.installPageState(parsed.uiConfig.state);
|
|
16611
17421
|
this.installLayoutCss(parsed.uiConfig);
|
|
17422
|
+
this.installOouiArtifact(parsed.uiConfig);
|
|
16612
17423
|
this.styleBinder = runtime.styleBinder;
|
|
16613
17424
|
this.propertyWatcher = runtime.propertyWatcher;
|
|
16614
17425
|
this.onChangeEngine = runtime.onChangeEngine;
|
|
@@ -16924,8 +17735,43 @@ function parseType(raw2, line) {
|
|
|
16924
17735
|
}
|
|
16925
17736
|
return { type: text };
|
|
16926
17737
|
}
|
|
17738
|
+
function isValueClosed(value) {
|
|
17739
|
+
const text = value.trim();
|
|
17740
|
+
const head = text[0];
|
|
17741
|
+
if (head === '"' || head === "'") return text.length >= 2 && text.endsWith(head);
|
|
17742
|
+
if (head !== "[" && head !== "{") return true;
|
|
17743
|
+
let depth = 0;
|
|
17744
|
+
let quote = null;
|
|
17745
|
+
for (const ch of text) {
|
|
17746
|
+
if (quote) {
|
|
17747
|
+
if (ch === quote) quote = null;
|
|
17748
|
+
continue;
|
|
17749
|
+
}
|
|
17750
|
+
if (ch === '"' || ch === "'") quote = ch;
|
|
17751
|
+
else if (ch === "[" || ch === "{") depth += 1;
|
|
17752
|
+
else if (ch === "]" || ch === "}") depth -= 1;
|
|
17753
|
+
}
|
|
17754
|
+
return depth <= 0 && quote === null;
|
|
17755
|
+
}
|
|
16927
17756
|
function splitSegments(rest, line) {
|
|
16928
|
-
const
|
|
17757
|
+
const raw2 = rest.split(", ");
|
|
17758
|
+
const parts = [];
|
|
17759
|
+
for (let index = 0; index < raw2.length; index += 1) {
|
|
17760
|
+
let part = raw2[index];
|
|
17761
|
+
const trimmed = part.trimStart();
|
|
17762
|
+
if (trimmed.startsWith("\u9ED8\u8BA4 ") && !isValueClosed(trimmed.slice("\u9ED8\u8BA4 ".length))) {
|
|
17763
|
+
let merged = part;
|
|
17764
|
+
for (let next = index + 1; next < raw2.length; next += 1) {
|
|
17765
|
+
merged = `${merged}, ${raw2[next]}`;
|
|
17766
|
+
if (isValueClosed(merged.trimStart().slice("\u9ED8\u8BA4 ".length))) {
|
|
17767
|
+
part = merged;
|
|
17768
|
+
index = next;
|
|
17769
|
+
break;
|
|
17770
|
+
}
|
|
17771
|
+
}
|
|
17772
|
+
}
|
|
17773
|
+
parts.push(part);
|
|
17774
|
+
}
|
|
16929
17775
|
const exampleAt = parts.findIndex((part) => part.startsWith("\u793A\u4F8B ") || part === "\u793A\u4F8B");
|
|
16930
17776
|
if (exampleAt < 0) return parts.map((part) => part.trim());
|
|
16931
17777
|
const head = parts.slice(0, exampleAt).map((part) => part.trim());
|
|
@@ -17043,14 +17889,27 @@ function parseSlotLines(text) {
|
|
|
17043
17889
|
}
|
|
17044
17890
|
return out;
|
|
17045
17891
|
}
|
|
17046
|
-
|
|
17892
|
+
var SCALAR_LOOKALIKE = /^(?:null|~|true|false|-?\d+(?:\.\d+)?)$/;
|
|
17893
|
+
var FLOW_SYNTAX = /[,[\]{}"']/;
|
|
17894
|
+
function quoteText(text) {
|
|
17895
|
+
const mark = !text.includes('"') ? '"' : !text.includes("'") ? "'" : '"';
|
|
17896
|
+
return `${mark}${text}${mark}`;
|
|
17897
|
+
}
|
|
17898
|
+
function renderString(text, site) {
|
|
17899
|
+
const needsQuote = text === "" || text !== text.trim() || SCALAR_LOOKALIKE.test(text) || /^["'[{]/.test(text) || site === "default" && text.includes(", ") || site === "flow" && FLOW_SYNTAX.test(text);
|
|
17900
|
+
return needsQuote ? quoteText(text) : text;
|
|
17901
|
+
}
|
|
17902
|
+
function renderFlowKey(key) {
|
|
17903
|
+
return key === "" || key !== key.trim() || FLOW_SYNTAX.test(key) ? quoteText(key) : key;
|
|
17904
|
+
}
|
|
17905
|
+
function renderValue(value, site) {
|
|
17047
17906
|
if (value === null) return "null";
|
|
17048
|
-
if (typeof value === "string") return value
|
|
17049
|
-
if (Array.isArray(value)) return `[${value.map(renderValue).join(", ")}]`;
|
|
17907
|
+
if (typeof value === "string") return renderString(value, site);
|
|
17908
|
+
if (Array.isArray(value)) return `[${value.map((item) => renderValue(item, "flow")).join(", ")}]`;
|
|
17050
17909
|
if (typeof value === "object") {
|
|
17051
17910
|
const entries = Object.entries(value);
|
|
17052
17911
|
if (entries.length === 0) return "{}";
|
|
17053
|
-
return `{ ${entries.map(([key, item]) => `${key}: ${renderValue(item)}`).join(", ")} }`;
|
|
17912
|
+
return `{ ${entries.map(([key, item]) => `${renderFlowKey(key)}: ${renderValue(item, "flow")}`).join(", ")} }`;
|
|
17054
17913
|
}
|
|
17055
17914
|
return String(value);
|
|
17056
17915
|
}
|
|
@@ -17066,9 +17925,9 @@ function renderFieldNode(name, field, depth, out) {
|
|
|
17066
17925
|
const segments = [renderTypeLabel(field)];
|
|
17067
17926
|
if (field.desc) segments.push(field.desc);
|
|
17068
17927
|
if (field.required === true) segments.push("\u5FC5\u586B");
|
|
17069
|
-
else if (field.default !== void 0) segments.push(`\u9ED8\u8BA4 ${renderValue(field.default)}`);
|
|
17070
|
-
if (field.example !== void 0) segments.push(`\u793A\u4F8B ${renderValue(field.example)}`);
|
|
17928
|
+
else if (field.default !== void 0) segments.push(`\u9ED8\u8BA4 ${renderValue(field.default, "default")}`);
|
|
17071
17929
|
if (field.mode === "model") segments.push("\u53CC\u5411");
|
|
17930
|
+
if (field.example !== void 0) segments.push(`\u793A\u4F8B ${renderValue(field.example, "example")}`);
|
|
17072
17931
|
out.push(`${" ".repeat(depth * INDENT_UNIT)}${name}: ${segments.join(", ")}`);
|
|
17073
17932
|
const children = field.type === "array" ? field.items?.fields : field.fields;
|
|
17074
17933
|
for (const [childName, child] of Object.entries(children ?? {})) {
|
|
@@ -17105,14 +17964,14 @@ function somaSlots(strings, ...values) {
|
|
|
17105
17964
|
}
|
|
17106
17965
|
|
|
17107
17966
|
// core/shared/component/derive-sample.ts
|
|
17108
|
-
function
|
|
17967
|
+
function walkField(field, path, strategy) {
|
|
17109
17968
|
if (field.example !== void 0) return clone(field.example);
|
|
17110
17969
|
if (field.type === "object") {
|
|
17111
17970
|
const fields = field.fields;
|
|
17112
17971
|
if (fields && Object.keys(fields).length > 0) {
|
|
17113
17972
|
const out = {};
|
|
17114
17973
|
for (const [name, child] of Object.entries(fields)) {
|
|
17115
|
-
const value =
|
|
17974
|
+
const value = walkField(child, `${path}.${name}`, strategy);
|
|
17116
17975
|
if (value !== void 0) out[name] = value;
|
|
17117
17976
|
}
|
|
17118
17977
|
return out;
|
|
@@ -17121,21 +17980,37 @@ function deriveField(field, path, gaps) {
|
|
|
17121
17980
|
if (field.type === "array") {
|
|
17122
17981
|
const items = field.items;
|
|
17123
17982
|
if (items) {
|
|
17124
|
-
const element =
|
|
17983
|
+
const element = walkField(items, `${path}[]`, strategy);
|
|
17125
17984
|
if (element !== void 0) return [element];
|
|
17126
17985
|
}
|
|
17127
17986
|
}
|
|
17128
|
-
if (field.default !== void 0) return clone(field.default);
|
|
17987
|
+
if (field.default !== void 0 && strategy.useDefault(field, path)) return clone(field.default);
|
|
17129
17988
|
if (field.type === "enum" && field.values && field.values.length > 0) {
|
|
17130
17989
|
return field.values[0];
|
|
17131
17990
|
}
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17991
|
+
return strategy.fallback(field, path);
|
|
17992
|
+
}
|
|
17993
|
+
function walkProps(contract, strategy) {
|
|
17994
|
+
const props = {};
|
|
17995
|
+
for (const [name, prop] of Object.entries(contract.props ?? {})) {
|
|
17996
|
+
const value = walkField(prop, name, strategy);
|
|
17997
|
+
if (value !== void 0) props[name] = value;
|
|
17137
17998
|
}
|
|
17138
|
-
return
|
|
17999
|
+
return props;
|
|
18000
|
+
}
|
|
18001
|
+
function sampleStrategy(gaps) {
|
|
18002
|
+
return {
|
|
18003
|
+
useDefault: () => true,
|
|
18004
|
+
fallback(field, path) {
|
|
18005
|
+
if (field.required === true) {
|
|
18006
|
+
gaps.push({
|
|
18007
|
+
path,
|
|
18008
|
+
reason: "\u5FC5\u586B\u5B57\u6BB5\u65E2\u6CA1\u6709 \u793A\u4F8B \u4E5F\u6CA1\u6709 \u9ED8\u8BA4\u2014\u2014\u6837\u5F20\u6E32\u67D3\u4E0D\u51FA\u8FD9\u4E00\u683C"
|
|
18009
|
+
});
|
|
18010
|
+
}
|
|
18011
|
+
return void 0;
|
|
18012
|
+
}
|
|
18013
|
+
};
|
|
17139
18014
|
}
|
|
17140
18015
|
function clone(value) {
|
|
17141
18016
|
if (value === null || typeof value !== "object") return value;
|
|
@@ -17143,15 +18018,125 @@ function clone(value) {
|
|
|
17143
18018
|
}
|
|
17144
18019
|
function deriveContractSample(contract) {
|
|
17145
18020
|
const gaps = [];
|
|
17146
|
-
const props =
|
|
17147
|
-
for (const [name, prop] of Object.entries(contract.props ?? {})) {
|
|
17148
|
-
const value = deriveField(prop, name, gaps);
|
|
17149
|
-
if (value !== void 0) props[name] = value;
|
|
17150
|
-
}
|
|
18021
|
+
const props = walkProps(contract, sampleStrategy(gaps));
|
|
17151
18022
|
return { props, gaps };
|
|
17152
18023
|
}
|
|
18024
|
+
function previewFieldName(path) {
|
|
18025
|
+
const segments = path.replace(/\[\]/gu, "").split(".");
|
|
18026
|
+
return (segments[segments.length - 1] ?? "").toLocaleLowerCase();
|
|
18027
|
+
}
|
|
18028
|
+
function previewString(path) {
|
|
18029
|
+
const name = previewFieldName(path);
|
|
18030
|
+
if (/(?:^|_)(?:id|key|code|sku)(?:$|_)/u.test(name)) return "sample-item";
|
|
18031
|
+
if (/(?:date|day)$/u.test(name)) return "2026-01-15";
|
|
18032
|
+
if (/(?:time|hour)$/u.test(name)) return "09:30";
|
|
18033
|
+
if (/(?:email|mail)$/u.test(name)) return "demo@example.test";
|
|
18034
|
+
if (/(?:phone|tel|mobile)$/u.test(name)) return "138 0000 0000";
|
|
18035
|
+
if (/(?:url|href|link)$/u.test(name)) return "#";
|
|
18036
|
+
if (/(?:src|image|avatar|cover|icon)$/u.test(name)) return "";
|
|
18037
|
+
if (/(?:color|colour)$/u.test(name)) return "var(--soma-c-primary)";
|
|
18038
|
+
if (/(?:placeholder)$/u.test(name)) return "\u8BF7\u8F93\u5165\u5185\u5BB9";
|
|
18039
|
+
if (/(?:label|action|button|cta)$/u.test(name)) return "\u793A\u4F8B\u64CD\u4F5C";
|
|
18040
|
+
if (/(?:title|name|heading)$/u.test(name)) return "\u793A\u4F8B\u6807\u9898";
|
|
18041
|
+
if (/(?:description|summary|message|hint|help|text|content|subtitle)$/u.test(name)) {
|
|
18042
|
+
return "\u8FD9\u662F\u4E00\u6BB5\u6765\u81EA\u7EC4\u4EF6\u5951\u7EA6\u7684\u9884\u89C8\u5185\u5BB9";
|
|
18043
|
+
}
|
|
18044
|
+
if (/(?:status|state)$/u.test(name)) return "active";
|
|
18045
|
+
return "\u793A\u4F8B\u503C";
|
|
18046
|
+
}
|
|
18047
|
+
function previewNumber(path) {
|
|
18048
|
+
const name = previewFieldName(path);
|
|
18049
|
+
if (/(?:percent|ratio|rate|progress)$/u.test(name)) return 68;
|
|
18050
|
+
if (/(?:quantity|qty|count|index|page|step)$/u.test(name)) return 2;
|
|
18051
|
+
if (/(?:price|amount|total|cost|value)$/u.test(name)) return 1280;
|
|
18052
|
+
return 42;
|
|
18053
|
+
}
|
|
18054
|
+
function previewBoolean(path) {
|
|
18055
|
+
const name = previewFieldName(path);
|
|
18056
|
+
if (/(?:open|visible|expanded|selected|checked|active)$/u.test(name)) return true;
|
|
18057
|
+
return false;
|
|
18058
|
+
}
|
|
18059
|
+
function previewRecord() {
|
|
18060
|
+
return {
|
|
18061
|
+
id: "sample-item",
|
|
18062
|
+
key: "sample-item",
|
|
18063
|
+
name: "\u793A\u4F8B\u540D\u79F0",
|
|
18064
|
+
label: "\u793A\u4F8B\u6807\u7B7E",
|
|
18065
|
+
title: "\u793A\u4F8B\u6807\u9898",
|
|
18066
|
+
subtitle: "\u7528\u4E8E\u7EC4\u4EF6\u9884\u89C8\u7684\u8F85\u52A9\u8BF4\u660E",
|
|
18067
|
+
description: "\u8FD9\u662F\u4E00\u6BB5\u6765\u81EA\u7EC4\u4EF6\u5951\u7EA6\u7684\u9884\u89C8\u5185\u5BB9",
|
|
18068
|
+
value: "sample-value",
|
|
18069
|
+
text: "\u793A\u4F8B\u5185\u5BB9",
|
|
18070
|
+
status: "active",
|
|
18071
|
+
amount: 1280,
|
|
18072
|
+
count: 12,
|
|
18073
|
+
quantity: 2
|
|
18074
|
+
};
|
|
18075
|
+
}
|
|
18076
|
+
function previewArrayFallback(path) {
|
|
18077
|
+
const name = previewFieldName(path);
|
|
18078
|
+
if (/(?:ids?|keys?|values?|dates?|tags?)$/u.test(name)) return [previewString(path)];
|
|
18079
|
+
return [previewRecord()];
|
|
18080
|
+
}
|
|
18081
|
+
var PRESENTATIONAL_EMPTY_ARRAY_FIELDS = /* @__PURE__ */ new Set([
|
|
18082
|
+
"accounts",
|
|
18083
|
+
"actions",
|
|
18084
|
+
"balances",
|
|
18085
|
+
"blockers",
|
|
18086
|
+
"breadcrumb",
|
|
18087
|
+
"candidates",
|
|
18088
|
+
"checks",
|
|
18089
|
+
"columns",
|
|
18090
|
+
"data",
|
|
18091
|
+
"detail",
|
|
18092
|
+
"downstream",
|
|
18093
|
+
"entries",
|
|
18094
|
+
"events",
|
|
18095
|
+
"evidence",
|
|
18096
|
+
"facts",
|
|
18097
|
+
"files",
|
|
18098
|
+
"items",
|
|
18099
|
+
"lab_panels",
|
|
18100
|
+
"lines",
|
|
18101
|
+
"messages",
|
|
18102
|
+
"presets",
|
|
18103
|
+
"products",
|
|
18104
|
+
"records",
|
|
18105
|
+
"rows",
|
|
18106
|
+
"stats",
|
|
18107
|
+
"steps",
|
|
18108
|
+
"tabs",
|
|
18109
|
+
"tags",
|
|
18110
|
+
"upstream"
|
|
18111
|
+
]);
|
|
18112
|
+
function shouldSynthesizeEmptyArrayPreview(field, path) {
|
|
18113
|
+
return field.required === true || field.items !== void 0 || PRESENTATIONAL_EMPTY_ARRAY_FIELDS.has(previewFieldName(path));
|
|
18114
|
+
}
|
|
18115
|
+
function previewStrategy(synthesized) {
|
|
18116
|
+
return {
|
|
18117
|
+
// A product-facing empty array is often the correct default. Only recognised
|
|
18118
|
+
// visual collections may reach the deterministic preview fallback: arbitrary
|
|
18119
|
+
// configuration arrays must stay empty so a generic record cannot enable an
|
|
18120
|
+
// invalid reaction/rule/condition in the component preview.
|
|
18121
|
+
useDefault: (field, path) => !(field.type === "array" && Array.isArray(field.default) && field.default.length === 0 && shouldSynthesizeEmptyArrayPreview(field, path)),
|
|
18122
|
+
fallback(field, path) {
|
|
18123
|
+
synthesized.push(path);
|
|
18124
|
+
if (field.type === "string") return previewString(path);
|
|
18125
|
+
if (field.type === "number") return previewNumber(path);
|
|
18126
|
+
if (field.type === "boolean") return previewBoolean(path);
|
|
18127
|
+
if (field.type === "array") return previewArrayFallback(path);
|
|
18128
|
+
if (field.type === "object") return previewRecord();
|
|
18129
|
+
return void 0;
|
|
18130
|
+
}
|
|
18131
|
+
};
|
|
18132
|
+
}
|
|
18133
|
+
function deriveContractPreviewSample(contract) {
|
|
18134
|
+
const synthesized = [];
|
|
18135
|
+
const props = walkProps(contract, previewStrategy(synthesized));
|
|
18136
|
+
return { props, synthesized };
|
|
18137
|
+
}
|
|
17153
18138
|
function deriveFieldSample(field) {
|
|
17154
|
-
return
|
|
18139
|
+
return walkField(field, "", sampleStrategy([]));
|
|
17155
18140
|
}
|
|
17156
18141
|
function hasRenderableSample(contract) {
|
|
17157
18142
|
const seen = (field) => {
|
|
@@ -17855,252 +18840,63 @@ function rawTier(value, bounds) {
|
|
|
17855
18840
|
return tier;
|
|
17856
18841
|
}
|
|
17857
18842
|
|
|
17858
|
-
// core/
|
|
17859
|
-
var
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
18843
|
+
// core/client/quality/SomaQualityRegistry.ts
|
|
18844
|
+
var SomaQualityRegistry = class _SomaQualityRegistry {
|
|
18845
|
+
static {
|
|
18846
|
+
this.qualityPillars = [
|
|
18847
|
+
{ id: "contract", name: "Contract validation", carrier: "SomaContractValidator", description: "Validate host anchors and func paths before mount" },
|
|
18848
|
+
{ id: "diagnostics", name: "Runtime diagnostics", carrier: "SomaDiagnostics", description: "Track mutation/render/event/validation/scheduler records" },
|
|
18849
|
+
{ id: "snapshot", name: "State snapshots", carrier: "SomaSnapshotStore", description: "Deep-clone capture/restore for time-travel debugging" },
|
|
18850
|
+
{ id: "dev-guard", name: "Array mutation warnings", carrier: "SomaReactiveProxy", description: "Warn on in-place array mutations in dev mode" }
|
|
18851
|
+
];
|
|
17866
18852
|
}
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
const text = lines[i].trim();
|
|
17876
|
-
if (text === "" || text.startsWith("#")) continue;
|
|
17877
|
-
if (text !== "{{") {
|
|
17878
|
-
throw new SomaBlockParseError("\u5757\u58F0\u660E\u5FC5\u987B\u4EE5 `{{` \u5F00\u5173\u884C\u5F00\u5934");
|
|
17879
|
-
}
|
|
17880
|
-
openIndex = i;
|
|
17881
|
-
break;
|
|
18853
|
+
static {
|
|
18854
|
+
this.performanceLayers = [
|
|
18855
|
+
{ id: "manifest", name: "Compiled manifest", carrier: "SomaManifestCompiler", description: "O(1) bindingIndex and eventIndex lookups" },
|
|
18856
|
+
{ id: "scheduler", name: "Task scheduler", carrier: "SomaScheduler", description: "Three-priority queue with microtask flush" },
|
|
18857
|
+
{ id: "parallel-patch", name: "Parallel patch", carrier: "SomaRenderEngine", description: "Concurrent render for multiple paths in one batch" },
|
|
18858
|
+
{ id: "lis", name: "Keyed list diff", carrier: "lis.ts + DomRenderer", description: "O(n log n) LIS minimal DOM moves" },
|
|
18859
|
+
{ id: "cache", name: "Parse cache", carrier: "SomaAssetResolver", description: "LRU cache for YAML parse results" }
|
|
18860
|
+
];
|
|
17882
18861
|
}
|
|
17883
|
-
|
|
17884
|
-
|
|
18862
|
+
static {
|
|
18863
|
+
// 可注册扩展面(Host 注入)。主题故意不在此列:令牌派生是引擎内建,见 theme-engine.ts。
|
|
18864
|
+
this.extensibilityDimensions = [
|
|
18865
|
+
{ id: "components", name: "Component registry", carrier: "SomaComponentRegistry", description: "Host/page register SomaComponentDefinition; not theme" },
|
|
18866
|
+
{ id: "pipes", name: "Format pipes", carrier: "SomaPipeRegistry", description: "Host register pure format pipes; merge with builtins" },
|
|
18867
|
+
{ id: "adapter", name: "Container adapter", carrier: "SomaContainerAdapter", description: "Isolate DOM ops for cross-platform hosts" },
|
|
18868
|
+
{ id: "middleware", name: "Middleware chains", carrier: "SomaMiddlewareChain", description: "Onion-model hooks for render and event engines" },
|
|
18869
|
+
{ id: "hotswap", name: "Hot swap", carrier: "SomaBootstrap.hotSwap", description: "Replace ui/event/style/DomainClass at runtime" },
|
|
18870
|
+
{ id: "services", name: "Runtime services", carrier: "SomaRuntimeServices", description: "Inject router/http/notify and other infra into domain" },
|
|
18871
|
+
{ id: "aot", name: "AOT precompile", carrier: "soma-precompile + bundler plugins", description: "Compile YAML to JS at build time" }
|
|
18872
|
+
];
|
|
17885
18873
|
}
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
}
|
|
17893
|
-
closeIndex = i;
|
|
17894
|
-
break;
|
|
18874
|
+
getSummary() {
|
|
18875
|
+
return {
|
|
18876
|
+
quality: _SomaQualityRegistry.qualityPillars,
|
|
18877
|
+
performance: _SomaQualityRegistry.performanceLayers,
|
|
18878
|
+
extensibility: _SomaQualityRegistry.extensibilityDimensions
|
|
18879
|
+
};
|
|
17895
18880
|
}
|
|
17896
|
-
|
|
17897
|
-
|
|
18881
|
+
computeHealthScore(snapshot) {
|
|
18882
|
+
const errors = snapshot.events.filter((e) => e.status === "error").length + snapshot.validations.length;
|
|
18883
|
+
const total = snapshot.counters.events + snapshot.counters.validations + 1;
|
|
18884
|
+
return Math.max(0, Math.round(100 - errors / total * 100));
|
|
17898
18885
|
}
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
throw new SomaBlockParseError(`YAML \u89E3\u6790\u5931\u8D25: ${error.message}`);
|
|
18886
|
+
};
|
|
18887
|
+
|
|
18888
|
+
// core/client/container/ReactNativeContainerAdapter.ts
|
|
18889
|
+
var ReactNativeContainerAdapter = class {
|
|
18890
|
+
constructor() {
|
|
18891
|
+
this.platform = "react-native";
|
|
18892
|
+
this.root = { somaId: null, tag: "View", props: {}, children: [] };
|
|
18893
|
+
this.navigateHandler = null;
|
|
18894
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
18895
|
+
/** 桥接用 DOM 容器(测试 / 混合渲染) */
|
|
18896
|
+
this.domBridge = null;
|
|
17911
18897
|
}
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
}
|
|
17915
|
-
if (typeof doc !== "object" || Array.isArray(doc)) {
|
|
17916
|
-
throw new SomaBlockParseError("\u5F00\u5173\u5185\u5FC5\u987B\u662F\u5757\u6620\u5C04\uFF08\u9876\u5C42\u952E = \u5757 id\uFF09");
|
|
17917
|
-
}
|
|
17918
|
-
for (const [blockId, body] of Object.entries(doc)) {
|
|
17919
|
-
if (body === null || body === void 0) {
|
|
17920
|
-
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId);
|
|
17921
|
-
}
|
|
17922
|
-
if (typeof body !== "object" || Array.isArray(body)) {
|
|
17923
|
-
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId);
|
|
17924
|
-
}
|
|
17925
|
-
}
|
|
17926
|
-
return { doc, inner, offset };
|
|
17927
|
-
}
|
|
17928
|
-
function loadSomaFile(input) {
|
|
17929
|
-
const { doc, inner, offset } = parseSomaBlockContainer(input.uiYamlRaw);
|
|
17930
|
-
if (Object.keys(doc).length === 0) return [];
|
|
17931
|
-
const innerLines = inner.split("\n");
|
|
17932
|
-
const lineOfKey = (key) => {
|
|
17933
|
-
const index = innerLines.findIndex((line) => line.startsWith(`${key}:`));
|
|
17934
|
-
return index === -1 ? offset : offset + index + 1;
|
|
17935
|
-
};
|
|
17936
|
-
const blocks = [];
|
|
17937
|
-
const seen = /* @__PURE__ */ new Set();
|
|
17938
|
-
for (const [blockId, body] of Object.entries(doc)) {
|
|
17939
|
-
const line = lineOfKey(blockId);
|
|
17940
|
-
assertBlockId(blockId, input.htmlIndex, line);
|
|
17941
|
-
if (seen.has(blockId)) {
|
|
17942
|
-
throw new SomaBlockParseError(`\u5757 "${blockId}" \u91CD\u590D\u58F0\u660E`, blockId, line);
|
|
17943
|
-
}
|
|
17944
|
-
if (body === null || body === void 0) {
|
|
17945
|
-
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId, line);
|
|
17946
|
-
}
|
|
17947
|
-
if (typeof body !== "object" || Array.isArray(body)) {
|
|
17948
|
-
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId, line);
|
|
17949
|
-
}
|
|
17950
|
-
seen.add(blockId);
|
|
17951
|
-
blocks.push({ blockId, body, line, source: "inline" });
|
|
17952
|
-
}
|
|
17953
|
-
for (const [blockId, raw2] of input.externalBlocks ?? /* @__PURE__ */ new Map()) {
|
|
17954
|
-
assertBlockId(blockId, input.htmlIndex, 0);
|
|
17955
|
-
if (seen.has(blockId)) {
|
|
17956
|
-
throw new SomaBlockParseError(
|
|
17957
|
-
`\u5757 "${blockId}" \u540C\u65F6\u5B58\u5728\u4E8E _ui.yaml \u4E0E blocks/${blockId}.yaml\u2014\u2014\u4E00\u4E2A\u5B9E\u4F8B\u53EA\u80FD\u6709\u4E00\u4E2A\u58F0\u660E\u5904`,
|
|
17958
|
-
blockId
|
|
17959
|
-
);
|
|
17960
|
-
}
|
|
17961
|
-
let body;
|
|
17962
|
-
try {
|
|
17963
|
-
body = yaml.load(raw2);
|
|
17964
|
-
} catch (error) {
|
|
17965
|
-
throw new SomaBlockParseError(
|
|
17966
|
-
`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u89E3\u6790\u5931\u8D25: ${error.message}`,
|
|
17967
|
-
blockId
|
|
17968
|
-
);
|
|
17969
|
-
}
|
|
17970
|
-
if (body === null || body === void 0) {
|
|
17971
|
-
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u4E3A\u7A7A`, blockId);
|
|
17972
|
-
}
|
|
17973
|
-
if (typeof body !== "object" || Array.isArray(body)) {
|
|
17974
|
-
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u5FC5\u987B\u662F\u6620\u5C04`, blockId);
|
|
17975
|
-
}
|
|
17976
|
-
seen.add(blockId);
|
|
17977
|
-
blocks.push({ blockId, body, line: 1, source: "external" });
|
|
17978
|
-
}
|
|
17979
|
-
return blocks;
|
|
17980
|
-
}
|
|
17981
|
-
function assertBlockId(blockId, htmlIndex, line) {
|
|
17982
|
-
if (blockId === PAGE_BLOCK_ID) return;
|
|
17983
|
-
if (htmlIndex.instances.has(blockId)) return;
|
|
17984
|
-
if (htmlIndex.anchors.has(blockId)) {
|
|
17985
|
-
throw new SomaBlockParseError(
|
|
17986
|
-
`"${blockId}" \u662F\u666E\u901A\u951A\u70B9\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u7EC4\u4EF6\u5757\u2014\u2014\u7EC4\u4EF6\u5757\u53EA\u80FD\u6302\u5728\u5E26 data-soma-component \u7684\u5B9E\u4F8B\u951A\u70B9\u4E0A\uFF1B\u666E\u901A\u951A\u70B9\u7684\u7ED1\u5B9A\u5199\u5728 page \u5757\u7684 ui: \u6BB5`,
|
|
17987
|
-
blockId,
|
|
17988
|
-
line
|
|
17989
|
-
);
|
|
17990
|
-
}
|
|
17991
|
-
const known = [...htmlIndex.instances].slice(0, 8).join("\u3001");
|
|
17992
|
-
throw new SomaBlockParseError(
|
|
17993
|
-
`HTML \u91CC\u6CA1\u6709\u5B9E\u4F8B\u951A\u70B9 "${blockId}"${known ? `\uFF08\u73B0\u6709\u5B9E\u4F8B\uFF1A${known}\uFF09` : ""}`,
|
|
17994
|
-
blockId,
|
|
17995
|
-
line
|
|
17996
|
-
);
|
|
17997
|
-
}
|
|
17998
|
-
|
|
17999
|
-
// core/build/compiler/soma-precompile.ts
|
|
18000
|
-
function precompileUiModule(yamlStr) {
|
|
18001
|
-
parseSomaBlockContainer(yamlStr);
|
|
18002
|
-
return "null";
|
|
18003
|
-
}
|
|
18004
|
-
function compileEventConfigFromRaw(raw2) {
|
|
18005
|
-
const { eventsRaw, triggers, timers } = splitEventConfigRaw(raw2);
|
|
18006
|
-
return {
|
|
18007
|
-
events: parseEventConfig(eventsRaw),
|
|
18008
|
-
triggers,
|
|
18009
|
-
timers
|
|
18010
|
-
};
|
|
18011
|
-
}
|
|
18012
|
-
function compileDataConfig(yamlStr) {
|
|
18013
|
-
if (!yamlStr.trim()) {
|
|
18014
|
-
return { objects: {} };
|
|
18015
|
-
}
|
|
18016
|
-
return parseDataConfig(yaml.load(yamlStr));
|
|
18017
|
-
}
|
|
18018
|
-
function precompileYaml(yamlStr) {
|
|
18019
|
-
const obj = yaml.load(yamlStr);
|
|
18020
|
-
return JSON.stringify(obj ?? {});
|
|
18021
|
-
}
|
|
18022
|
-
|
|
18023
|
-
// core/build/compiler/rollup-plugin-soma.ts
|
|
18024
|
-
function somaRollupPlugin(options = {}) {
|
|
18025
|
-
const uiSuffix = options.uiSuffix ?? "_ui.yaml";
|
|
18026
|
-
return {
|
|
18027
|
-
name: "rollup-plugin-soma",
|
|
18028
|
-
transform(code, id) {
|
|
18029
|
-
if (!id.endsWith(".yaml") && !id.endsWith(".yml")) {
|
|
18030
|
-
return null;
|
|
18031
|
-
}
|
|
18032
|
-
try {
|
|
18033
|
-
if (id.endsWith(uiSuffix)) {
|
|
18034
|
-
return { code: `export default ${precompileUiModule(code)};`, map: { mappings: "" } };
|
|
18035
|
-
}
|
|
18036
|
-
if (/_((event)|(style)|(data))\.ya?ml$/.test(id)) {
|
|
18037
|
-
throw new Error("\u9875\u9762\u4FA7\u8F66\u5DF2\u9000\u5F79\uFF1B\u4E8B\u4EF6\u3001\u6837\u5F0F\u72B6\u6001\u4E0E\u6570\u636E\u5BF9\u8C61\u5FC5\u987B\u5E76\u5165\u540C\u4E00\u4EFD SOMA DSL \u58F0\u660E");
|
|
18038
|
-
}
|
|
18039
|
-
return { code: `export default ${precompileYaml(code)};`, map: { mappings: "" } };
|
|
18040
|
-
} catch (err) {
|
|
18041
|
-
throw new Error(`[rollup-plugin-soma] Failed to compile ${id}: ${err}`);
|
|
18042
|
-
}
|
|
18043
|
-
}
|
|
18044
|
-
};
|
|
18045
|
-
}
|
|
18046
|
-
|
|
18047
|
-
// core/client/quality/SomaQualityRegistry.ts
|
|
18048
|
-
var SomaQualityRegistry = class _SomaQualityRegistry {
|
|
18049
|
-
static {
|
|
18050
|
-
this.qualityPillars = [
|
|
18051
|
-
{ id: "contract", name: "Contract validation", carrier: "SomaContractValidator", description: "Validate host anchors and func paths before mount" },
|
|
18052
|
-
{ id: "diagnostics", name: "Runtime diagnostics", carrier: "SomaDiagnostics", description: "Track mutation/render/event/validation/scheduler records" },
|
|
18053
|
-
{ id: "snapshot", name: "State snapshots", carrier: "SomaSnapshotStore", description: "Deep-clone capture/restore for time-travel debugging" },
|
|
18054
|
-
{ id: "dev-guard", name: "Array mutation warnings", carrier: "SomaReactiveProxy", description: "Warn on in-place array mutations in dev mode" }
|
|
18055
|
-
];
|
|
18056
|
-
}
|
|
18057
|
-
static {
|
|
18058
|
-
this.performanceLayers = [
|
|
18059
|
-
{ id: "manifest", name: "Compiled manifest", carrier: "SomaManifestCompiler", description: "O(1) bindingIndex and eventIndex lookups" },
|
|
18060
|
-
{ id: "scheduler", name: "Task scheduler", carrier: "SomaScheduler", description: "Three-priority queue with microtask flush" },
|
|
18061
|
-
{ id: "parallel-patch", name: "Parallel patch", carrier: "SomaRenderEngine", description: "Concurrent render for multiple paths in one batch" },
|
|
18062
|
-
{ id: "lis", name: "Keyed list diff", carrier: "lis.ts + DomRenderer", description: "O(n log n) LIS minimal DOM moves" },
|
|
18063
|
-
{ id: "cache", name: "Parse cache", carrier: "SomaAssetResolver", description: "LRU cache for YAML parse results" }
|
|
18064
|
-
];
|
|
18065
|
-
}
|
|
18066
|
-
static {
|
|
18067
|
-
// 可注册扩展面(Host 注入)。主题故意不在此列:令牌派生是引擎内建,见 theme-engine.ts。
|
|
18068
|
-
this.extensibilityDimensions = [
|
|
18069
|
-
{ id: "components", name: "Component registry", carrier: "SomaComponentRegistry", description: "Host/page register SomaComponentDefinition; not theme" },
|
|
18070
|
-
{ id: "pipes", name: "Format pipes", carrier: "SomaPipeRegistry", description: "Host register pure format pipes; merge with builtins" },
|
|
18071
|
-
{ id: "adapter", name: "Container adapter", carrier: "SomaContainerAdapter", description: "Isolate DOM ops for cross-platform hosts" },
|
|
18072
|
-
{ id: "middleware", name: "Middleware chains", carrier: "SomaMiddlewareChain", description: "Onion-model hooks for render and event engines" },
|
|
18073
|
-
{ id: "hotswap", name: "Hot swap", carrier: "SomaBootstrap.hotSwap", description: "Replace ui/event/style/DomainClass at runtime" },
|
|
18074
|
-
{ id: "services", name: "Runtime services", carrier: "SomaRuntimeServices", description: "Inject router/http/notify and other infra into domain" },
|
|
18075
|
-
{ id: "aot", name: "AOT precompile", carrier: "soma-precompile + bundler plugins", description: "Compile YAML to JS at build time" }
|
|
18076
|
-
];
|
|
18077
|
-
}
|
|
18078
|
-
getSummary() {
|
|
18079
|
-
return {
|
|
18080
|
-
quality: _SomaQualityRegistry.qualityPillars,
|
|
18081
|
-
performance: _SomaQualityRegistry.performanceLayers,
|
|
18082
|
-
extensibility: _SomaQualityRegistry.extensibilityDimensions
|
|
18083
|
-
};
|
|
18084
|
-
}
|
|
18085
|
-
computeHealthScore(snapshot) {
|
|
18086
|
-
const errors = snapshot.events.filter((e) => e.status === "error").length + snapshot.validations.length;
|
|
18087
|
-
const total = snapshot.counters.events + snapshot.counters.validations + 1;
|
|
18088
|
-
return Math.max(0, Math.round(100 - errors / total * 100));
|
|
18089
|
-
}
|
|
18090
|
-
};
|
|
18091
|
-
|
|
18092
|
-
// core/client/container/ReactNativeContainerAdapter.ts
|
|
18093
|
-
var ReactNativeContainerAdapter = class {
|
|
18094
|
-
constructor() {
|
|
18095
|
-
this.platform = "react-native";
|
|
18096
|
-
this.root = { somaId: null, tag: "View", props: {}, children: [] };
|
|
18097
|
-
this.navigateHandler = null;
|
|
18098
|
-
this.listeners = /* @__PURE__ */ new Map();
|
|
18099
|
-
/** 桥接用 DOM 容器(测试 / 混合渲染) */
|
|
18100
|
-
this.domBridge = null;
|
|
18101
|
-
}
|
|
18102
|
-
setNavigateHandler(handler) {
|
|
18103
|
-
this.navigateHandler = handler;
|
|
18898
|
+
setNavigateHandler(handler) {
|
|
18899
|
+
this.navigateHandler = handler;
|
|
18104
18900
|
}
|
|
18105
18901
|
mount(container, html, includes) {
|
|
18106
18902
|
this.domBridge = container;
|
|
@@ -19349,6 +20145,9 @@ function verifyStyleDiscipline(pack) {
|
|
|
19349
20145
|
`[\u989C\u8272] ${label} \u51FA\u73B0\u88F8\u8272\u503C ${color}\u2014\u2014\u989C\u8272\u53EA\u5141\u8BB8\u5728 var(--soma-*, \u56DE\u9000\u503C) \u7684\u56DE\u9000\u4F4D;\u88F8\u8272\u503C\u4F1A\u8BA9\u6362\u80A4\u5BF9\u8FD9\u4E2A\u7EC4\u4EF6\u5931\u6548,\u800C\u4E14\u4E0D\u62A5\u9519`
|
|
19350
20146
|
);
|
|
19351
20147
|
}
|
|
20148
|
+
for (const problem of colorRolePairing(css)) {
|
|
20149
|
+
issues.push(`[\u914D\u8272] ${label} ${problem}`);
|
|
20150
|
+
}
|
|
19352
20151
|
for (const property of physicalDirections(css)) {
|
|
19353
20152
|
issues.push(
|
|
19354
20153
|
`[RTL] ${label} \u4F7F\u7528\u7269\u7406\u65B9\u5411\u5C5E\u6027 ${property}\u2014\u2014\u8BF7\u6539\u7528\u903B\u8F91\u5C5E\u6027(margin-inline-start / padding-inline-end / inset-inline-*);RTL \u4E0B\u7269\u7406\u65B9\u5411\u4F1A\u8BA9\u95F4\u8DDD\u8DD1\u5230\u53E6\u4E00\u8FB9,\u540C\u6837\u4E0D\u62A5\u9519\u3002\u786E\u5B9E\u5FC5\u8981\u5C31\u5728\u540C\u4E00\u884C\u5199 /* soma-allow-physical: \u7406\u7531 */`
|
|
@@ -19357,6 +20156,33 @@ function verifyStyleDiscipline(pack) {
|
|
|
19357
20156
|
}
|
|
19358
20157
|
return issues;
|
|
19359
20158
|
}
|
|
20159
|
+
var TONE = "(primary|secondary|accent|neutral|info|success|warning|danger)";
|
|
20160
|
+
function colorRolePairing(css) {
|
|
20161
|
+
const found = /* @__PURE__ */ new Set();
|
|
20162
|
+
const flat = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
20163
|
+
for (const match of flat.matchAll(/([^{}@]+)\{([^{}]*)\}/g)) {
|
|
20164
|
+
const selector = match[1].trim().slice(0, 60);
|
|
20165
|
+
const body = match[2];
|
|
20166
|
+
const color = /(?:^|;)\s*color\s*:\s*([^;]+)/.exec(body)?.[1]?.trim() ?? "";
|
|
20167
|
+
const fillAsText = new RegExp(`^var\\(--soma-c-${TONE}\\s*[,)]`).exec(color);
|
|
20168
|
+
if (fillAsText) {
|
|
20169
|
+
found.add(`${selector} \u628A\u586B\u5145\u8272 --soma-c-${fillAsText[1]} \u5F53\u6587\u5B57\u8272\u2014\u2014\u5F69\u8272\u6587\u5B57\u7528 var(--soma-c-${fillAsText[1]}-on-soft, \u56DE\u9000)`);
|
|
20170
|
+
}
|
|
20171
|
+
const solid = new RegExp(`background(?:-color)?\\s*:\\s*var\\(--soma-c-${TONE}\\s*[,)]`).exec(body);
|
|
20172
|
+
if (solid && color && !/^(inherit|currentColor|transparent)$/.test(color) && !new RegExp(`^var\\(--soma-(c-${solid[1]}-fg|ui-tone-fg)\\b`).test(color)) {
|
|
20173
|
+
found.add(`${selector} \u5B9E\u5FC3\u5E95 --soma-c-${solid[1]} \u4E0A\u7684\u5B57\u8272\u5FC5\u987B\u662F var(--soma-c-${solid[1]}-fg, \u56DE\u9000)`);
|
|
20174
|
+
}
|
|
20175
|
+
const soft = new RegExp(`background(?:-color)?\\s*:\\s*var\\(--soma-c-${TONE}-soft\\s*[,)]`).exec(body);
|
|
20176
|
+
if (soft && new RegExp(`^var\\(--soma-c-${soft[1]}(-fg)?\\s*[,)]`).test(color)) {
|
|
20177
|
+
found.add(`${selector} \u6DE1\u5E95 --soma-c-${soft[1]}-soft \u4E0A\u7684\u5B57\u8272\u5FC5\u987B\u662F var(--soma-c-${soft[1]}-on-soft, \u56DE\u9000)`);
|
|
20178
|
+
}
|
|
20179
|
+
for (const gradient of body.matchAll(/gradient\(([^;]+)/g)) {
|
|
20180
|
+
const tones = new Set([...gradient[1].matchAll(new RegExp(`--soma-c-${TONE}\\b`, "g"))].map((item) => item[1]));
|
|
20181
|
+
if (tones.size > 1) found.add(`${selector} \u6E10\u53D8\u6DF7\u7528\u4E86 ${[...tones].join(" / ")} \u4E24\u79CD\u8BED\u6C14\u2014\u2014\u540C\u8272\u76F8\u7528 color-mix \u8C03\u660E\u5EA6`);
|
|
20182
|
+
}
|
|
20183
|
+
}
|
|
20184
|
+
return [...found];
|
|
20185
|
+
}
|
|
19360
20186
|
function nakedColors(css) {
|
|
19361
20187
|
const found = /* @__PURE__ */ new Set();
|
|
19362
20188
|
const stripped = css.replace(/var\(\s*--[\w-]+\s*(?:,[^()]*(?:\([^()]*\)[^()]*)*)?\)/g, " ");
|
|
@@ -19625,6 +20451,147 @@ function describeNode(node) {
|
|
|
19625
20451
|
}
|
|
19626
20452
|
}
|
|
19627
20453
|
|
|
20454
|
+
// core/shared/block-errors.ts
|
|
20455
|
+
var SomaBlockParseError = class extends Error {
|
|
20456
|
+
constructor(message, blockId, line) {
|
|
20457
|
+
const where = blockId ? `\uFF08\u5757: ${blockId}${line ? `\uFF0C\u7B2C ${line} \u884C` : ""}\uFF09` : "";
|
|
20458
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${where}`);
|
|
20459
|
+
this.blockId = blockId;
|
|
20460
|
+
this.line = line;
|
|
20461
|
+
this.name = "SomaBlockParseError";
|
|
20462
|
+
}
|
|
20463
|
+
};
|
|
20464
|
+
|
|
20465
|
+
// core/build/blocks/block-container.ts
|
|
20466
|
+
var PAGE_BLOCK_ID = "page";
|
|
20467
|
+
function stripSwitch(uiYamlRaw) {
|
|
20468
|
+
const lines = uiYamlRaw.split("\n");
|
|
20469
|
+
let openIndex = -1;
|
|
20470
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
20471
|
+
const text = lines[i].trim();
|
|
20472
|
+
if (text === "" || text.startsWith("#")) continue;
|
|
20473
|
+
if (text !== "{{") {
|
|
20474
|
+
throw new SomaBlockParseError("\u5757\u58F0\u660E\u5FC5\u987B\u4EE5 `{{` \u5F00\u5173\u884C\u5F00\u5934");
|
|
20475
|
+
}
|
|
20476
|
+
openIndex = i;
|
|
20477
|
+
break;
|
|
20478
|
+
}
|
|
20479
|
+
if (openIndex === -1) {
|
|
20480
|
+
throw new SomaBlockParseError("\u6587\u4EF6\u4E3A\u7A7A\u6216\u53EA\u6709\u6CE8\u91CA\uFF0C\u627E\u4E0D\u5230 `{{` \u5F00\u5173\u884C");
|
|
20481
|
+
}
|
|
20482
|
+
let closeIndex = -1;
|
|
20483
|
+
for (let i = lines.length - 1; i > openIndex; i -= 1) {
|
|
20484
|
+
const text = lines[i].trim();
|
|
20485
|
+
if (text === "") continue;
|
|
20486
|
+
if (text !== "}}") {
|
|
20487
|
+
throw new SomaBlockParseError("\u5757\u58F0\u660E\u5FC5\u987B\u4EE5 `}}` \u6536\u53E3\u884C\u7ED3\u5C3E\uFF08\u5F00\u5173\u6210\u5BF9\uFF0C\u6574\u6587\u4EF6\u4E00\u5BF9\uFF09");
|
|
20488
|
+
}
|
|
20489
|
+
closeIndex = i;
|
|
20490
|
+
break;
|
|
20491
|
+
}
|
|
20492
|
+
if (closeIndex === -1) {
|
|
20493
|
+
throw new SomaBlockParseError("`{{` \u5F00\u5173\u672A\u95ED\u5408\u2014\u2014\u7F3A\u5C11 `}}` \u6536\u53E3\u884C");
|
|
20494
|
+
}
|
|
20495
|
+
return {
|
|
20496
|
+
inner: lines.slice(openIndex + 1, closeIndex).join("\n"),
|
|
20497
|
+
offset: openIndex + 1
|
|
20498
|
+
};
|
|
20499
|
+
}
|
|
20500
|
+
function parseSomaBlockContainer(uiYamlRaw) {
|
|
20501
|
+
const { inner, offset } = stripSwitch(uiYamlRaw);
|
|
20502
|
+
let doc;
|
|
20503
|
+
try {
|
|
20504
|
+
doc = yaml.load(inner);
|
|
20505
|
+
} catch (error) {
|
|
20506
|
+
throw new SomaBlockParseError(`YAML \u89E3\u6790\u5931\u8D25: ${error.message}`);
|
|
20507
|
+
}
|
|
20508
|
+
if (doc === null || doc === void 0) {
|
|
20509
|
+
return { doc: {}, inner, offset };
|
|
20510
|
+
}
|
|
20511
|
+
if (typeof doc !== "object" || Array.isArray(doc)) {
|
|
20512
|
+
throw new SomaBlockParseError("\u5F00\u5173\u5185\u5FC5\u987B\u662F\u5757\u6620\u5C04\uFF08\u9876\u5C42\u952E = \u5757 id\uFF09");
|
|
20513
|
+
}
|
|
20514
|
+
for (const [blockId, body] of Object.entries(doc)) {
|
|
20515
|
+
if (body === null || body === void 0) {
|
|
20516
|
+
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId);
|
|
20517
|
+
}
|
|
20518
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
20519
|
+
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId);
|
|
20520
|
+
}
|
|
20521
|
+
}
|
|
20522
|
+
return { doc, inner, offset };
|
|
20523
|
+
}
|
|
20524
|
+
function loadSomaFile(input) {
|
|
20525
|
+
const { doc, inner, offset } = parseSomaBlockContainer(input.uiYamlRaw);
|
|
20526
|
+
if (Object.keys(doc).length === 0) return [];
|
|
20527
|
+
const innerLines = inner.split("\n");
|
|
20528
|
+
const lineOfKey = (key) => {
|
|
20529
|
+
const index = innerLines.findIndex((line) => line.startsWith(`${key}:`));
|
|
20530
|
+
return index === -1 ? offset : offset + index + 1;
|
|
20531
|
+
};
|
|
20532
|
+
const blocks = [];
|
|
20533
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20534
|
+
for (const [blockId, body] of Object.entries(doc)) {
|
|
20535
|
+
const line = lineOfKey(blockId);
|
|
20536
|
+
assertBlockId(blockId, input.htmlIndex, line);
|
|
20537
|
+
if (seen.has(blockId)) {
|
|
20538
|
+
throw new SomaBlockParseError(`\u5757 "${blockId}" \u91CD\u590D\u58F0\u660E`, blockId, line);
|
|
20539
|
+
}
|
|
20540
|
+
if (body === null || body === void 0) {
|
|
20541
|
+
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId, line);
|
|
20542
|
+
}
|
|
20543
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
20544
|
+
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId, line);
|
|
20545
|
+
}
|
|
20546
|
+
seen.add(blockId);
|
|
20547
|
+
blocks.push({ blockId, body, line, source: "inline" });
|
|
20548
|
+
}
|
|
20549
|
+
for (const [blockId, raw2] of input.externalBlocks ?? /* @__PURE__ */ new Map()) {
|
|
20550
|
+
assertBlockId(blockId, input.htmlIndex, 0);
|
|
20551
|
+
if (seen.has(blockId)) {
|
|
20552
|
+
throw new SomaBlockParseError(
|
|
20553
|
+
`\u5757 "${blockId}" \u540C\u65F6\u5B58\u5728\u4E8E _ui.yaml \u4E0E blocks/${blockId}.yaml\u2014\u2014\u4E00\u4E2A\u5B9E\u4F8B\u53EA\u80FD\u6709\u4E00\u4E2A\u58F0\u660E\u5904`,
|
|
20554
|
+
blockId
|
|
20555
|
+
);
|
|
20556
|
+
}
|
|
20557
|
+
let body;
|
|
20558
|
+
try {
|
|
20559
|
+
body = yaml.load(raw2);
|
|
20560
|
+
} catch (error) {
|
|
20561
|
+
throw new SomaBlockParseError(
|
|
20562
|
+
`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u89E3\u6790\u5931\u8D25: ${error.message}`,
|
|
20563
|
+
blockId
|
|
20564
|
+
);
|
|
20565
|
+
}
|
|
20566
|
+
if (body === null || body === void 0) {
|
|
20567
|
+
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u4E3A\u7A7A`, blockId);
|
|
20568
|
+
}
|
|
20569
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
20570
|
+
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u5FC5\u987B\u662F\u6620\u5C04`, blockId);
|
|
20571
|
+
}
|
|
20572
|
+
seen.add(blockId);
|
|
20573
|
+
blocks.push({ blockId, body, line: 1, source: "external" });
|
|
20574
|
+
}
|
|
20575
|
+
return blocks;
|
|
20576
|
+
}
|
|
20577
|
+
function assertBlockId(blockId, htmlIndex, line) {
|
|
20578
|
+
if (blockId === PAGE_BLOCK_ID) return;
|
|
20579
|
+
if (htmlIndex.instances.has(blockId)) return;
|
|
20580
|
+
if (htmlIndex.anchors.has(blockId)) {
|
|
20581
|
+
throw new SomaBlockParseError(
|
|
20582
|
+
`"${blockId}" \u662F\u666E\u901A\u951A\u70B9\uFF0C\u4E0D\u80FD\u4F5C\u4E3A\u7EC4\u4EF6\u5757\u2014\u2014\u7EC4\u4EF6\u5757\u53EA\u80FD\u6302\u5728\u5E26 data-soma-component \u7684\u5B9E\u4F8B\u951A\u70B9\u4E0A\uFF1B\u666E\u901A\u951A\u70B9\u7684\u7ED1\u5B9A\u5199\u5728 page \u5757\u7684 ui: \u6BB5`,
|
|
20583
|
+
blockId,
|
|
20584
|
+
line
|
|
20585
|
+
);
|
|
20586
|
+
}
|
|
20587
|
+
const known = [...htmlIndex.instances].slice(0, 8).join("\u3001");
|
|
20588
|
+
throw new SomaBlockParseError(
|
|
20589
|
+
`HTML \u91CC\u6CA1\u6709\u5B9E\u4F8B\u951A\u70B9 "${blockId}"${known ? `\uFF08\u73B0\u6709\u5B9E\u4F8B\uFF1A${known}\uFF09` : ""}`,
|
|
20590
|
+
blockId,
|
|
20591
|
+
line
|
|
20592
|
+
);
|
|
20593
|
+
}
|
|
20594
|
+
|
|
19628
20595
|
// core/build/blocks/html-index.ts
|
|
19629
20596
|
var ANCHOR_RE = /data-soma-id=["']([^"']+)["']/g;
|
|
19630
20597
|
var COMPONENT_NEAR_RE = /data-soma-component=["']([^"']+)["']/;
|
|
@@ -19698,6 +20665,9 @@ var SomaScopeError = class extends Error {
|
|
|
19698
20665
|
};
|
|
19699
20666
|
var RESERVED = /* @__PURE__ */ new Set(["page", "p", "ctrl"]);
|
|
19700
20667
|
var NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
20668
|
+
function blockDataObjectName(blockId, localName) {
|
|
20669
|
+
return `${blockId}__${localName}`;
|
|
20670
|
+
}
|
|
19701
20671
|
function buildBlockScope(input) {
|
|
19702
20672
|
const blockId = input.blockId;
|
|
19703
20673
|
const dataNames = new Set(input.dataNames ?? []);
|
|
@@ -19761,7 +20731,7 @@ function resolvePath(raw2, scope) {
|
|
|
19761
20731
|
const hits = [inData, inRow, isPage].filter(Boolean).length;
|
|
19762
20732
|
if (hits > 1) {
|
|
19763
20733
|
const candidates = [
|
|
19764
|
-
inData ?
|
|
20734
|
+
inData ? `\u672C\u5757 data \u540D ${head}` : "",
|
|
19765
20735
|
inRow ? `\u884C\u53D8\u91CF ${head}` : "",
|
|
19766
20736
|
isPage ? "\u9875\u9762\u53D8\u91CF page" : ""
|
|
19767
20737
|
].filter(Boolean);
|
|
@@ -19771,7 +20741,8 @@ function resolvePath(raw2, scope) {
|
|
|
19771
20741
|
);
|
|
19772
20742
|
}
|
|
19773
20743
|
if (inData) {
|
|
19774
|
-
|
|
20744
|
+
const base = scope.dataPaths?.get(head) ?? `${scope.blockId}.${head}`;
|
|
20745
|
+
return { kind: "data", full: [base, ...segments.slice(1)].join(".") };
|
|
19775
20746
|
}
|
|
19776
20747
|
if (inRow) return { kind: "row", full: text };
|
|
19777
20748
|
if (isPage) return { kind: "page", full: text };
|
|
@@ -19827,57 +20798,82 @@ var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
|
19827
20798
|
// 只有测试里直接喂平铺 YAML 的路径能用。文档承诺了一件真实页面做不到的事。
|
|
19828
20799
|
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
19829
20800
|
"state",
|
|
19830
|
-
"layout"
|
|
20801
|
+
"layout",
|
|
20802
|
+
// ooui(REQ-014 演绎接线):第三个平铺 UiConfig 保留键的直通。
|
|
20803
|
+
//
|
|
20804
|
+
// 少了这一条,块声明页写 `ooui:` 会当场收到「page 块不支持键 "ooui"」——
|
|
20805
|
+
// 而**真实发布的页面只有块声明这一条路**(compilePageDeclaration 只收块声明),
|
|
20806
|
+
// 于是整条演绎链只在"直接喂平铺 YAML"的测试路径上活着,生产页面一次都用不上。
|
|
20807
|
+
// 这与上面 state / layout 那次踩的是同一个坑,不再重踩第三次。
|
|
20808
|
+
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
20809
|
+
"ooui",
|
|
20810
|
+
// objects(REQ-014 表层语义,§38.5 断线 ②):**面向人书写的那一层对象声明**。
|
|
20811
|
+
//
|
|
20812
|
+
// `data:` 是核心层——完备、显式、机器好翻译(`{ type: text, rules: [{ required: true }] }`)。
|
|
20813
|
+
// 表层是同一件事的人写形态(`no: text!`)。两层的转换点只有一个
|
|
20814
|
+
// (`build/ooui/semantic/normalize.ts`),而在此之前**它一个生产调用者都没有**:
|
|
20815
|
+
// 表层类型、展开器、台账三样都写完了,页面上却没有任何地方能写出表层来。
|
|
20816
|
+
//
|
|
20817
|
+
// 不接这一条的后果不是"少个语法糖",是**来历台账永远是空的**:
|
|
20818
|
+
// 系统按默认补的值(如 `permission: r`)与作者显式写的值在产物里长得一模一样,
|
|
20819
|
+
// 于是 `OOUI-SEM-EDIT-ALL-READONLY` 只能说"你写错了",说不出"我按默认补的、
|
|
20820
|
+
// 你需要显式写 permission: w"——同一条错误,两种修法,指向两个人(§34.2)。
|
|
20821
|
+
//
|
|
20822
|
+
// 这里只直通原文;展开与校验在 compilePageDeclaration(构建期)做一次。
|
|
20823
|
+
"objects"
|
|
19831
20824
|
]);
|
|
19832
20825
|
var SUFFIXES = ["when", "model", "class"];
|
|
19833
20826
|
function parsePageBlock(input) {
|
|
19834
20827
|
const { body } = input;
|
|
19835
|
-
const
|
|
20828
|
+
const fail = (message) => {
|
|
19836
20829
|
throw new SomaBlockParseError(message, "page");
|
|
19837
20830
|
};
|
|
19838
20831
|
for (const key of Object.keys(body)) {
|
|
19839
20832
|
if (!PAGE_KEYS.has(key)) {
|
|
19840
|
-
|
|
20833
|
+
fail(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
|
|
19841
20834
|
}
|
|
19842
20835
|
}
|
|
19843
20836
|
const domain = body.domain;
|
|
19844
20837
|
if (typeof domain !== "string" || domain.trim() === "") {
|
|
19845
|
-
|
|
20838
|
+
fail("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
|
|
19846
20839
|
}
|
|
19847
20840
|
const scope = buildBlockScope({
|
|
19848
20841
|
blockId: "page",
|
|
19849
|
-
dataNames:
|
|
20842
|
+
dataNames: [.../* @__PURE__ */ new Set([
|
|
20843
|
+
...Object.keys(body.data ?? {}),
|
|
20844
|
+
...Object.keys(body.objects ?? {})
|
|
20845
|
+
])],
|
|
19850
20846
|
aliasRaw: body.alias
|
|
19851
20847
|
});
|
|
19852
20848
|
const show = {};
|
|
19853
20849
|
const locale = body.locale;
|
|
19854
20850
|
if (locale !== void 0) {
|
|
19855
|
-
if (!Array.isArray(locale))
|
|
20851
|
+
if (!Array.isArray(locale)) fail("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
|
|
19856
20852
|
for (const item of locale) {
|
|
19857
20853
|
const key = String(item);
|
|
19858
20854
|
if (!input.anchors.has(key)) {
|
|
19859
|
-
|
|
20855
|
+
fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
|
|
19860
20856
|
}
|
|
19861
20857
|
if (input.localeKeys && !input.localeKeys.has(key)) {
|
|
19862
|
-
|
|
20858
|
+
fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
|
|
19863
20859
|
}
|
|
19864
20860
|
show[key] = `page._locale.${key}`;
|
|
19865
20861
|
}
|
|
19866
20862
|
}
|
|
19867
20863
|
const uiRaw = body.ui ?? {};
|
|
19868
|
-
if (typeof uiRaw !== "object" || Array.isArray(uiRaw))
|
|
20864
|
+
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
19869
20865
|
parseShowLevel(uiRaw, show, scope, input, "page");
|
|
19870
20866
|
const bind = { obj: String(domain), var: "page" };
|
|
19871
20867
|
const watch = body.watch;
|
|
19872
20868
|
if (watch !== void 0) {
|
|
19873
|
-
if (!Array.isArray(watch))
|
|
20869
|
+
if (!Array.isArray(watch)) fail("watch \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
19874
20870
|
const rules = [];
|
|
19875
20871
|
for (const item of watch) {
|
|
19876
|
-
if (!item || typeof item !== "object")
|
|
20872
|
+
if (!item || typeof item !== "object") fail("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
|
|
19877
20873
|
const path = item.path;
|
|
19878
20874
|
const call = item.call;
|
|
19879
|
-
if (typeof path !== "string" || path.trim() === "")
|
|
19880
|
-
if (typeof call !== "string" || call.trim() === "")
|
|
20875
|
+
if (typeof path !== "string" || path.trim() === "") fail("watch \u9879\u7F3A\u5C11 path");
|
|
20876
|
+
if (typeof call !== "string" || call.trim() === "") fail("watch \u9879\u7F3A\u5C11 call");
|
|
19881
20877
|
const rule = {
|
|
19882
20878
|
condition: expandPath(String(path), scope),
|
|
19883
20879
|
callback: String(call).includes(".") ? String(call) : `page.${call}`
|
|
@@ -19891,7 +20887,7 @@ function parsePageBlock(input) {
|
|
|
19891
20887
|
const ui = { bind, show };
|
|
19892
20888
|
if (body.initProps !== void 0) {
|
|
19893
20889
|
if (body.initProps === null || typeof body.initProps !== "object" || Array.isArray(body.initProps)) {
|
|
19894
|
-
|
|
20890
|
+
fail("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
|
|
19895
20891
|
}
|
|
19896
20892
|
ui.initProps = body.initProps;
|
|
19897
20893
|
}
|
|
@@ -19904,28 +20900,32 @@ function parsePageBlock(input) {
|
|
|
19904
20900
|
if (body.layout !== void 0) {
|
|
19905
20901
|
ui.layout = body.layout;
|
|
19906
20902
|
}
|
|
19907
|
-
|
|
20903
|
+
if (body.ooui !== void 0) {
|
|
20904
|
+
ui.ooui = body.ooui;
|
|
20905
|
+
}
|
|
20906
|
+
const eventRaw = normalizeEventSection(body.event, input, fail);
|
|
19908
20907
|
return {
|
|
19909
20908
|
ui,
|
|
19910
20909
|
eventRaw,
|
|
19911
20910
|
...body.data ? { dataRaw: body.data } : {},
|
|
20911
|
+
...body.objects ? { surfaceRaw: body.objects } : {},
|
|
19912
20912
|
scope
|
|
19913
20913
|
};
|
|
19914
20914
|
}
|
|
19915
20915
|
function parseShowLevel(raw2, target, scope, input, where) {
|
|
19916
|
-
const
|
|
20916
|
+
const fail = (message) => {
|
|
19917
20917
|
throw new SomaBlockParseError(message, "page");
|
|
19918
20918
|
};
|
|
19919
20919
|
for (const [key, value] of Object.entries(raw2)) {
|
|
19920
20920
|
if (key === "each") continue;
|
|
19921
20921
|
const { anchor, suffix, attr } = splitKey(key);
|
|
19922
20922
|
if (input.instances.has(anchor)) {
|
|
19923
|
-
|
|
20923
|
+
fail(
|
|
19924
20924
|
`"${anchor}" \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u951A\u70B9\uFF0C\u4E0D\u80FD\u5199\u5728 page \u5757\u7684 ui \u6BB5\u2014\u2014\u7EC4\u4EF6\u7684\u4E00\u5207\u58F0\u660E\u4F4F\u5728\u5B83\u81EA\u5DF1\u7684\u5757\u91CC\uFF08\u9876\u5C42\u5199 ${anchor}:\uFF09`
|
|
19925
20925
|
);
|
|
19926
20926
|
}
|
|
19927
20927
|
if (!input.anchors.has(anchor)) {
|
|
19928
|
-
|
|
20928
|
+
fail(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
|
|
19929
20929
|
}
|
|
19930
20930
|
if (isEachBlock(value)) {
|
|
19931
20931
|
target[anchor] = parseEachBlock(value, scope, input, anchor);
|
|
@@ -19933,23 +20933,23 @@ function parseShowLevel(raw2, target, scope, input, where) {
|
|
|
19933
20933
|
}
|
|
19934
20934
|
if (suffix) {
|
|
19935
20935
|
const existing2 = asExtended(target[anchor]);
|
|
19936
|
-
applySuffix(existing2, suffix, value, scope,
|
|
20936
|
+
applySuffix(existing2, suffix, value, scope, fail);
|
|
19937
20937
|
target[anchor] = existing2;
|
|
19938
20938
|
continue;
|
|
19939
20939
|
}
|
|
19940
20940
|
if (attr) {
|
|
19941
20941
|
if (value !== null && typeof value === "object") {
|
|
19942
|
-
|
|
20942
|
+
fail(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
|
|
19943
20943
|
}
|
|
19944
|
-
target[`${anchor}@${attr}`] = expandValue(value, scope,
|
|
20944
|
+
target[`${anchor}@${attr}`] = expandValue(value, scope, fail);
|
|
19945
20945
|
continue;
|
|
19946
20946
|
}
|
|
19947
20947
|
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
19948
|
-
|
|
20948
|
+
fail(
|
|
19949
20949
|
`"${key}" \u7684\u503C\u662F\u6620\u5C04\uFF0C\u4F46 ui \u6BB5\u53EA\u5141\u8BB8\u5E73\u94FA\u5199\u6CD5\uFF08\u663E\u9690\u7528 \u951A\u70B9.when\u3001\u6761\u4EF6\u7C7B\u7528 \u951A\u70B9.class\u3001\u5217\u8868\u7528 each\uFF09`
|
|
19950
20950
|
);
|
|
19951
20951
|
}
|
|
19952
|
-
const expanded = expandValue(value, scope,
|
|
20952
|
+
const expanded = expandValue(value, scope, fail);
|
|
19953
20953
|
const existing = target[anchor];
|
|
19954
20954
|
if (existing !== void 0 && typeof existing === "object" && !Array.isArray(existing)) {
|
|
19955
20955
|
existing.text = expanded;
|
|
@@ -19962,13 +20962,13 @@ function isEachBlock(value) {
|
|
|
19962
20962
|
return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.each === "string";
|
|
19963
20963
|
}
|
|
19964
20964
|
function parseEachBlock(block, scope, input, anchor) {
|
|
19965
|
-
const
|
|
20965
|
+
const fail = (message) => {
|
|
19966
20966
|
throw new SomaBlockParseError(message, "page");
|
|
19967
20967
|
};
|
|
19968
20968
|
const raw2 = String(block.each);
|
|
19969
20969
|
const match = /^(\S+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw2.trim());
|
|
19970
20970
|
if (!match) {
|
|
19971
|
-
|
|
20971
|
+
fail(`each \u8BED\u6CD5\u9519\u8BEF: "${raw2}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
|
|
19972
20972
|
}
|
|
19973
20973
|
const [, sourcePath, rowVar, byPath] = match;
|
|
19974
20974
|
const bind = {
|
|
@@ -20008,10 +21008,10 @@ function asExtended(current) {
|
|
|
20008
21008
|
if (typeof current === "string") return { text: current };
|
|
20009
21009
|
return current;
|
|
20010
21010
|
}
|
|
20011
|
-
function applySuffix(target, suffix, value, scope,
|
|
21011
|
+
function applySuffix(target, suffix, value, scope, fail) {
|
|
20012
21012
|
if (suffix === "class") {
|
|
20013
21013
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
20014
|
-
|
|
21014
|
+
fail(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
|
|
20015
21015
|
}
|
|
20016
21016
|
const map2 = {};
|
|
20017
21017
|
for (const [cls, cond] of Object.entries(value)) {
|
|
@@ -20032,30 +21032,30 @@ function expandCondition(raw2, scope) {
|
|
|
20032
21032
|
const bare = negated ? text.slice(1).trim() : text;
|
|
20033
21033
|
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
20034
21034
|
}
|
|
20035
|
-
function expandValue(value, scope,
|
|
20036
|
-
if (value === null || value === void 0)
|
|
21035
|
+
function expandValue(value, scope, fail) {
|
|
21036
|
+
if (value === null || value === void 0) fail("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
|
|
20037
21037
|
if (typeof value !== "string") return String(value);
|
|
20038
21038
|
const segments = String(value).split(/\s+\|\s+/);
|
|
20039
21039
|
segments[0] = expandPath(segments[0], scope);
|
|
20040
21040
|
return segments.join(" | ");
|
|
20041
21041
|
}
|
|
20042
|
-
function normalizeEventSection(raw2, input,
|
|
21042
|
+
function normalizeEventSection(raw2, input, fail) {
|
|
20043
21043
|
if (raw2 === void 0) return {};
|
|
20044
21044
|
if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
20045
|
-
|
|
21045
|
+
fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
|
|
20046
21046
|
}
|
|
20047
21047
|
const section = raw2;
|
|
20048
21048
|
for (const key of Object.keys(section)) {
|
|
20049
21049
|
if (!["on", "timers", "triggers"].includes(key)) {
|
|
20050
|
-
|
|
21050
|
+
fail(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
|
|
20051
21051
|
}
|
|
20052
21052
|
}
|
|
20053
21053
|
const on = section.on ?? {};
|
|
20054
|
-
if (typeof on !== "object" || Array.isArray(on))
|
|
21054
|
+
if (typeof on !== "object" || Array.isArray(on)) fail("event.on \u5FC5\u987B\u662F\u6620\u5C04");
|
|
20055
21055
|
for (const key of Object.keys(on)) {
|
|
20056
21056
|
const anchor = key.split(".")[0];
|
|
20057
21057
|
if (input.instances.has(anchor)) {
|
|
20058
|
-
|
|
21058
|
+
fail(
|
|
20059
21059
|
`"${key}" \u7684\u951A\u70B9 "${anchor}" \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u2014\u2014\u7EC4\u4EF6\u4E8B\u4EF6\uFF08emit \u8DEF\u7531\uFF09\u4F4F\u5728\u8BE5\u7EC4\u4EF6\u5757\u7684 event.on \u6BB5\uFF0Cpage \u5757\u7684 event \u53EA\u9762\u5411 DOM \u4E8B\u4EF6`
|
|
20060
21060
|
);
|
|
20061
21061
|
}
|
|
@@ -20068,7 +21068,22 @@ function normalizeEventSection(raw2, input, fail2) {
|
|
|
20068
21068
|
|
|
20069
21069
|
// core/client/parser/blocks/use-parser.ts
|
|
20070
21070
|
var BLOCK_KEYS = /* @__PURE__ */ new Set(["component", "alias", "when", "data", "ui", "event"]);
|
|
20071
|
-
var
|
|
21071
|
+
var USE_BLOCK_DATA_OBJECT_KEYS = [
|
|
21072
|
+
"from",
|
|
21073
|
+
"save",
|
|
21074
|
+
"fields",
|
|
21075
|
+
"roles",
|
|
21076
|
+
"relations"
|
|
21077
|
+
];
|
|
21078
|
+
var DATA_OBJECT_KEYS = new Set(USE_BLOCK_DATA_OBJECT_KEYS);
|
|
21079
|
+
var RETIRED_DATA_OBJECT_KEYS = /* @__PURE__ */ new Map([
|
|
21080
|
+
["refresh", "\u6570\u636E\u5BF9\u8C61\u5C42\u4E0D\u505A\u5468\u671F\u91CD\u53D6\uFF0C\u5199\u4E86\u4E5F\u4E0D\u4F1A\u8F6E\u8BE2\u2014\u2014\u8981\u5B9A\u65F6\u91CD\u53D6\uFF0C\u5728 page \u5757 event.timers \u6302\u4E00\u4E2A tick \u8C03 Domain \u65B9\u6CD5\uFF0C\u65B9\u6CD5\u91CC\u8C03 this.reloadData()"],
|
|
21081
|
+
["reload_on", "\u6570\u636E\u5BF9\u8C61\u5C42\u4E0D\u76D1\u542C\u8DEF\u5F84\u53D8\u5316\uFF0C\u5199\u4E86\u4E5F\u4E0D\u4F1A\u91CD\u53D6\u2014\u2014\u8981\u4F9D\u8D56\u53D8\u5316\u540E\u91CD\u53D6\uFF0C\u5728 page \u5757 watch \u91CC\u5199 { path, call }\uFF0C\u88AB\u8C03\u7684 Domain \u65B9\u6CD5\u91CC\u8C03 this.reloadData()"]
|
|
21082
|
+
]);
|
|
21083
|
+
var FROM_KEYS = /* @__PURE__ */ new Set(["api", "params"]);
|
|
21084
|
+
var SAVE_KEYS = /* @__PURE__ */ new Set(["api", "method", "key", "fields"]);
|
|
21085
|
+
var DATA_OBJECT_NAME_RE = /^[A-Za-z_]\w*$/;
|
|
21086
|
+
var PARAM_PATH_RE = /^[A-Za-z_]\w*(?:\.\w+)*$/;
|
|
20072
21087
|
var EVENT_KEYS = /* @__PURE__ */ new Set(["actions", "on"]);
|
|
20073
21088
|
var ACTION_KEYS = /* @__PURE__ */ new Set([
|
|
20074
21089
|
"label",
|
|
@@ -20080,47 +21095,80 @@ var ACTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
20080
21095
|
"when",
|
|
20081
21096
|
"disabled_reason"
|
|
20082
21097
|
]);
|
|
20083
|
-
var
|
|
21098
|
+
var USE_BLOCK_FIELD_KEYS = [
|
|
21099
|
+
"name",
|
|
21100
|
+
"type",
|
|
21101
|
+
"values",
|
|
21102
|
+
"permission",
|
|
21103
|
+
"rules",
|
|
21104
|
+
"modifies"
|
|
21105
|
+
];
|
|
21106
|
+
var FIELD_KEYS = new Set(USE_BLOCK_FIELD_KEYS);
|
|
20084
21107
|
var FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
|
|
20085
21108
|
function parseUseBlock(input) {
|
|
20086
21109
|
const { blockId, body } = input;
|
|
20087
|
-
const
|
|
21110
|
+
const fail = (message) => {
|
|
20088
21111
|
throw new SomaBlockParseError(message, blockId);
|
|
20089
21112
|
};
|
|
20090
21113
|
for (const key of Object.keys(body)) {
|
|
20091
21114
|
if (!BLOCK_KEYS.has(key)) {
|
|
20092
|
-
|
|
21115
|
+
fail(`\u7EC4\u4EF6\u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...BLOCK_KEYS].join("/")}\uFF09`);
|
|
20093
21116
|
}
|
|
20094
21117
|
}
|
|
20095
21118
|
const component = body.component === void 0 ? void 0 : String(body.component);
|
|
20096
21119
|
if (component && input.htmlComponent && component !== input.htmlComponent) {
|
|
20097
|
-
|
|
21120
|
+
fail(
|
|
20098
21121
|
`component \u58F0\u660E\u4E3A "${component}"\uFF0C\u4F46 HTML \u91CC\u662F "${input.htmlComponent}"\u2014\u2014\u4E24\u5904\u5FC5\u987B\u4E00\u81F4\uFF08\u6539\u4E86\u4E00\u5904\u5FD8\u4E86\u53E6\u4E00\u5904\u65F6\uFF0C\u9875\u9762\u6E32\u67D3\u7684\u662F\u54EA\u4E2A\u53EA\u80FD\u9760\u731C\uFF09`
|
|
20099
21122
|
);
|
|
20100
21123
|
}
|
|
20101
21124
|
const dataRaw = body.data ?? {};
|
|
20102
|
-
if (typeof dataRaw !== "object" || Array.isArray(dataRaw))
|
|
20103
|
-
const
|
|
21125
|
+
if (typeof dataRaw !== "object" || Array.isArray(dataRaw)) fail("data \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
21126
|
+
const baseScope = buildBlockScope({
|
|
20104
21127
|
blockId,
|
|
20105
21128
|
dataNames: Object.keys(dataRaw),
|
|
20106
21129
|
aliasRaw: body.alias,
|
|
20107
21130
|
rowVars: input.rowVars
|
|
20108
21131
|
});
|
|
20109
|
-
const
|
|
20110
|
-
const dataObjects = [];
|
|
21132
|
+
const dataPaths = /* @__PURE__ */ new Map();
|
|
20111
21133
|
const dataImports = [];
|
|
20112
21134
|
for (const [localName, raw2] of Object.entries(dataRaw)) {
|
|
20113
21135
|
if (typeof raw2 === "string") {
|
|
20114
|
-
|
|
21136
|
+
const target = resolvePath(raw2, { ...baseScope, dataNames: /* @__PURE__ */ new Set() });
|
|
21137
|
+
if (target.kind === "literal") {
|
|
21138
|
+
fail(
|
|
21139
|
+
`data.${localName} \u7684\u5F15\u5165\u8DEF\u5F84 "${raw2}" \u4E0D\u5728\u4EFB\u4F55\u4F5C\u7528\u57DF\u5185\u2014\u2014\u5F15\u5165\u53EA\u80FD\u6307\u5411 page.*\uFF08\u5982 page.data.profile\uFF09\u3001\u884C\u53D8\u91CF\u6216\u8DEF\u5F84\u522B\u540D`
|
|
21140
|
+
);
|
|
21141
|
+
}
|
|
21142
|
+
const targetPath = target.full;
|
|
21143
|
+
dataPaths.set(localName, targetPath);
|
|
21144
|
+
dataImports.push({ localName, targetPath });
|
|
20115
21145
|
continue;
|
|
20116
21146
|
}
|
|
20117
21147
|
if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
20118
|
-
|
|
21148
|
+
fail(`data.${localName} \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u58F0\u660E\uFF09\u6216\u5B57\u7B26\u4E32\u8DEF\u5F84\uFF08\u5F15\u5165\uFF09`);
|
|
21149
|
+
}
|
|
21150
|
+
if (input.inRowTemplate) {
|
|
21151
|
+
fail(
|
|
21152
|
+
`data.${localName} \u662F\u5757\u79C1\u6709\u6570\u636E\u5BF9\u8C61\uFF0C\u4F46\u5B9E\u4F8B "${blockId}" \u4F4D\u4E8E\u5217\u8868\u884C\u6A21\u677F\u5185\u2014\u2014\u884C\u6A21\u677F\u6BCF\u884C\u6E32\u67D3\u4E00\u4E2A\u5B9E\u4F8B\uFF0C\u6570\u636E\u5BF9\u8C61\u5C42\u6CA1\u6709\u300C\u6BCF\u884C\u4E00\u4E2A\u5BF9\u8C61\u300D\u7684\u8868\u8FBE\uFF1B\u8BF7\u628A\u5BF9\u8C61\u58F0\u660E\u5230 page \u5757\u7684 data:\uFF0C\u884C\u5185\u7528\u884C\u53D8\u91CF\u6216\u5F15\u5165\uFF08\u540D: \u8DEF\u5F84\uFF09\u53D6\u503C`
|
|
21153
|
+
);
|
|
20119
21154
|
}
|
|
20120
|
-
|
|
21155
|
+
const fullName = blockDataObjectName(blockId, localName);
|
|
21156
|
+
if (!DATA_OBJECT_NAME_RE.test(fullName)) {
|
|
21157
|
+
fail(
|
|
21158
|
+
`\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${localName}" \u7684\u5168\u5C40\u540D "${fullName}" \u4E0D\u662F\u6807\u8BC6\u7B26\u2014\u2014\u5757 id "${blockId}" \u542B\u5B57\u6BCD/\u6570\u5B57/\u4E0B\u5212\u7EBF\u4EE5\u5916\u7684\u5B57\u7B26\uFF0C\u800C\u6570\u636E\u5BF9\u8C61\u5C42\u7684\u5BF9\u8C61\u540D\u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF1B\u8BF7\u628A\u8BE5\u5B9E\u4F8B\u7684 data-soma-id \u6539\u6210\u4E0B\u5212\u7EBF\u5199\u6CD5`
|
|
21159
|
+
);
|
|
21160
|
+
}
|
|
21161
|
+
dataPaths.set(localName, `page.data.${fullName}`);
|
|
21162
|
+
}
|
|
21163
|
+
const scope = { ...baseScope, dataPaths };
|
|
21164
|
+
const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail);
|
|
21165
|
+
const dataObjects = [];
|
|
21166
|
+
for (const [localName, raw2] of Object.entries(dataRaw)) {
|
|
21167
|
+
if (typeof raw2 === "string") continue;
|
|
21168
|
+
dataObjects.push(parseDataObject(localName, raw2, blockId, scope, fail));
|
|
20121
21169
|
}
|
|
20122
21170
|
const uiRaw = body.ui ?? {};
|
|
20123
|
-
if (typeof uiRaw !== "object" || Array.isArray(uiRaw))
|
|
21171
|
+
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
20124
21172
|
const when = body.when === void 0 ? void 0 : expandCondition2(String(body.when), scope);
|
|
20125
21173
|
const ast = {
|
|
20126
21174
|
blockId,
|
|
@@ -20140,127 +21188,200 @@ function parseUseBlock(input) {
|
|
|
20140
21188
|
};
|
|
20141
21189
|
return ast;
|
|
20142
21190
|
}
|
|
20143
|
-
function parseDataObject(localName, raw2, blockId, scope,
|
|
21191
|
+
function parseDataObject(localName, raw2, blockId, scope, fail) {
|
|
20144
21192
|
for (const key of Object.keys(raw2)) {
|
|
21193
|
+
const retired = RETIRED_DATA_OBJECT_KEYS.get(key);
|
|
21194
|
+
if (retired !== void 0) {
|
|
21195
|
+
fail(`data.${localName}.${key} \u6CA1\u6709\u8FD0\u884C\u65F6\u5BF9\u5E94\u7269\uFF1A${retired}`);
|
|
21196
|
+
}
|
|
20145
21197
|
if (!DATA_OBJECT_KEYS.has(key)) {
|
|
20146
|
-
|
|
21198
|
+
fail(`data.${localName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...DATA_OBJECT_KEYS].join("/")}\uFF09`);
|
|
20147
21199
|
}
|
|
20148
21200
|
}
|
|
20149
|
-
const decl = { localName, fullName:
|
|
21201
|
+
const decl = { localName, fullName: blockDataObjectName(blockId, localName) };
|
|
20150
21202
|
const from = raw2.from;
|
|
20151
21203
|
if (from !== void 0) {
|
|
20152
|
-
if (typeof from !== "object" || Array.isArray(from))
|
|
20153
|
-
|
|
20154
|
-
|
|
21204
|
+
if (from === null || typeof from !== "object" || Array.isArray(from)) {
|
|
21205
|
+
fail(`data.${localName}.from \u5FC5\u987B\u662F\u6620\u5C04 { api, params }\uFF08\u5757\u79C1\u6709\u5BF9\u8C61\u53EA\u6709\u4E00\u4E2A\u53D6\u6570\u6765\u6E90\uFF09`);
|
|
21206
|
+
}
|
|
21207
|
+
const source = from;
|
|
21208
|
+
for (const key of Object.keys(source)) {
|
|
21209
|
+
if (!FROM_KEYS.has(key)) {
|
|
21210
|
+
fail(`data.${localName}.from \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FROM_KEYS].join("/")}\uFF09`);
|
|
21211
|
+
}
|
|
21212
|
+
}
|
|
21213
|
+
const api = source.api;
|
|
21214
|
+
if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.from \u7F3A\u5C11 api`);
|
|
21215
|
+
const paramsRaw = source.params ?? {};
|
|
21216
|
+
if (paramsRaw === null || typeof paramsRaw !== "object" || Array.isArray(paramsRaw)) {
|
|
21217
|
+
fail(`data.${localName}.from.params \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53C2\u6570\u540D \u2192 \u8DEF\u5F84\u6216\u5B57\u9762\u91CF\uFF09`);
|
|
21218
|
+
}
|
|
20155
21219
|
const params = {};
|
|
20156
|
-
for (const [key, value] of Object.entries(
|
|
20157
|
-
params[key] =
|
|
21220
|
+
for (const [key, value] of Object.entries(paramsRaw)) {
|
|
21221
|
+
params[key] = toDataParam(value, `data.${localName}.from.params.${key}`, scope, fail);
|
|
20158
21222
|
}
|
|
20159
21223
|
decl.from = { api: resolveApiRef(String(api), scope), params };
|
|
20160
21224
|
}
|
|
20161
21225
|
const save = raw2.save;
|
|
20162
21226
|
if (save !== void 0) {
|
|
20163
|
-
if (typeof save !== "object" || Array.isArray(save))
|
|
20164
|
-
|
|
20165
|
-
|
|
20166
|
-
|
|
20167
|
-
|
|
20168
|
-
|
|
20169
|
-
|
|
20170
|
-
|
|
20171
|
-
|
|
20172
|
-
|
|
20173
|
-
|
|
20174
|
-
|
|
21227
|
+
if (save === null || typeof save !== "object" || Array.isArray(save)) {
|
|
21228
|
+
fail(`data.${localName}.save \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
21229
|
+
}
|
|
21230
|
+
const channel = save;
|
|
21231
|
+
for (const key of Object.keys(channel)) {
|
|
21232
|
+
if (key === "trigger") {
|
|
21233
|
+
fail(
|
|
21234
|
+
`data.${localName}.save.trigger \u6CA1\u6709\u8FD0\u884C\u65F6\u5BF9\u5E94\u7269\uFF1A\u5199\u901A\u9053\u6CA1\u6709\u300C\u54EA\u4E2A\u52A8\u4F5C\u89E6\u53D1\u63D0\u4EA4\u300D\u8FD9\u4E00\u73AF\u2014\u2014\u63D0\u4EA4\u7531\u6D88\u8D39\u8BE5\u5BF9\u8C61\u7684\u7EC4\u4EF6\u7ECF data \u7AEF\u53E3\u53D1\u8D77\uFF08\u5982 FormConsole \u7684 data_object: ${decl.fullName}\uFF09\uFF0C\u5220\u6389 trigger`
|
|
21235
|
+
);
|
|
21236
|
+
}
|
|
21237
|
+
if (!SAVE_KEYS.has(key)) {
|
|
21238
|
+
fail(`data.${localName}.save \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...SAVE_KEYS].join("/")}\uFF09`);
|
|
21239
|
+
}
|
|
21240
|
+
}
|
|
21241
|
+
const api = channel.api;
|
|
21242
|
+
if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.save \u7F3A\u5C11 api`);
|
|
21243
|
+
if (channel.fields !== void 0 && (!Array.isArray(channel.fields) || channel.fields.some((item) => typeof item !== "string"))) {
|
|
21244
|
+
fail(`data.${localName}.save.fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4`);
|
|
20175
21245
|
}
|
|
20176
21246
|
decl.save = {
|
|
20177
21247
|
api: resolveApiRef(String(api), scope),
|
|
20178
|
-
method: String(
|
|
20179
|
-
|
|
20180
|
-
...
|
|
20181
|
-
...Array.isArray(save.fields) ? { fields: save.fields.map(String) } : {}
|
|
21248
|
+
method: String(channel.method ?? "POST").toUpperCase(),
|
|
21249
|
+
...channel.key !== void 0 ? { key: String(channel.key) } : {},
|
|
21250
|
+
...channel.fields !== void 0 ? { fields: [...channel.fields] } : {}
|
|
20182
21251
|
};
|
|
20183
21252
|
}
|
|
20184
|
-
if (raw2.refresh !== void 0) decl.refreshMs = parseDuration(String(raw2.refresh), localName, fail2);
|
|
20185
|
-
if (raw2.reload_on !== void 0) {
|
|
20186
|
-
if (!Array.isArray(raw2.reload_on)) fail2(`data.${localName}.reload_on \u5FC5\u987B\u662F\u6570\u7EC4`);
|
|
20187
|
-
decl.reloadOn = raw2.reload_on.map((item) => expandPath(String(item), scope));
|
|
20188
|
-
}
|
|
20189
21253
|
if (raw2.fields !== void 0) {
|
|
20190
21254
|
const fieldsRaw = raw2.fields;
|
|
20191
|
-
if (typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
|
|
20192
|
-
|
|
21255
|
+
if (fieldsRaw === null || typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
|
|
21256
|
+
fail(`data.${localName}.fields \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
20193
21257
|
}
|
|
20194
21258
|
const fields = {};
|
|
20195
21259
|
for (const [fieldName, fieldRaw] of Object.entries(fieldsRaw)) {
|
|
20196
|
-
fields[fieldName] = parseField2(localName, fieldName, fieldRaw,
|
|
21260
|
+
fields[fieldName] = parseField2(localName, fieldName, fieldRaw, fail);
|
|
20197
21261
|
}
|
|
21262
|
+
const modifiesIssues = validateFieldModifies(fields);
|
|
21263
|
+
if (modifiesIssues.length > 0) fail(`data.${localName}.fields\uFF1A${modifiesIssues.join("\uFF1B")}`);
|
|
20198
21264
|
decl.fields = fields;
|
|
20199
21265
|
}
|
|
21266
|
+
const fieldKeys = Object.keys(decl.fields ?? {});
|
|
21267
|
+
if (raw2.roles !== void 0) {
|
|
21268
|
+
const issues = validateObjectRoles(raw2.roles, fieldKeys);
|
|
21269
|
+
if (issues.length > 0) fail(`data.${localName}.roles\uFF1A${issues.join("\uFF1B")}`);
|
|
21270
|
+
decl.roles = raw2.roles;
|
|
21271
|
+
}
|
|
21272
|
+
if (raw2.relations !== void 0) {
|
|
21273
|
+
const issues = validateObjectRelations(raw2.relations, { fieldKeys, selfName: localName });
|
|
21274
|
+
if (issues.length > 0) fail(`data.${localName}.relations\uFF1A${issues.join("\uFF1B")}`);
|
|
21275
|
+
decl.relations = raw2.relations;
|
|
21276
|
+
}
|
|
20200
21277
|
return decl;
|
|
20201
21278
|
}
|
|
20202
|
-
function
|
|
21279
|
+
function toDataParam(raw2, where, scope, fail) {
|
|
21280
|
+
if (raw2 === null || typeof raw2 === "object") {
|
|
21281
|
+
fail(`${where} \u5FC5\u987B\u662F\u6807\u91CF\u6216\u8DEF\u5F84\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw2)}`);
|
|
21282
|
+
}
|
|
21283
|
+
const text = String(raw2).trim();
|
|
21284
|
+
if (text.startsWith("$")) return text;
|
|
21285
|
+
const resolved = resolvePath(text, scope);
|
|
21286
|
+
if (resolved.kind === "literal") return text;
|
|
21287
|
+
if (!PARAM_PATH_RE.test(text)) {
|
|
21288
|
+
fail(`${where} \u7684\u503C "${text}" \u4E0D\u662F\u5355\u4E00\u8DEF\u5F84\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684 \`$\` \u5F15\u7528\u53EA\u53D6\u4E00\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u5E26\u7BA1\u9053\u4E0E\u7B97\u672F`);
|
|
21289
|
+
}
|
|
21290
|
+
const segments = resolved.full.split(".");
|
|
21291
|
+
if (resolved.kind === "row" || segments[0] !== "page") {
|
|
21292
|
+
fail(`${where} \u5F15\u7528\u4E86\u884C\u53D8\u91CF "${text}"\u2014\u2014\u6570\u636E\u5BF9\u8C61\u4E0D\u968F\u884C\u91CD\u590D\uFF0C\u53D6\u6570\u53C2\u6570\u91CC\u6CA1\u6709\u884C\u53D8\u91CF`);
|
|
21293
|
+
}
|
|
21294
|
+
if (segments[1] === "data" && segments.length >= 3) {
|
|
21295
|
+
if (segments.length === 3) {
|
|
21296
|
+
fail(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A\u6570\u636E\u5BF9\u8C61 "${segments[2]}"\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6\u5BF9\u8C61\u7684\u67D0\u4E2A\u5B57\u6BB5\uFF08\u5199 ${text}.<\u5B57\u6BB5>\uFF09`);
|
|
21297
|
+
}
|
|
21298
|
+
return `$${segments.slice(2).join(".")}`;
|
|
21299
|
+
}
|
|
21300
|
+
if (segments.length === 1) {
|
|
21301
|
+
fail(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A page\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6 page \u4E0A\u7684\u67D0\u4E2A\u5B57\u6BB5`);
|
|
21302
|
+
}
|
|
21303
|
+
return `$page.${segments.slice(1).join(".")}`;
|
|
21304
|
+
}
|
|
21305
|
+
function parseField2(objectName, fieldName, raw2, fail) {
|
|
20203
21306
|
if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
20204
|
-
|
|
21307
|
+
fail(`\u5B57\u6BB5\u5B57\u5178 ${objectName}.${fieldName} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
20205
21308
|
}
|
|
20206
21309
|
const field = raw2;
|
|
20207
21310
|
for (const key of Object.keys(field)) {
|
|
20208
21311
|
if (!FIELD_KEYS.has(key)) {
|
|
20209
|
-
|
|
21312
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
|
|
20210
21313
|
}
|
|
20211
21314
|
}
|
|
20212
21315
|
const declaredType = String(field.type ?? "");
|
|
20213
21316
|
const type2 = SOMA_DATA_FIELD_TYPE_ALIASES[declaredType] ?? declaredType;
|
|
20214
21317
|
if (!FIELD_TYPES.has(declaredType)) {
|
|
20215
|
-
|
|
21318
|
+
fail(
|
|
20216
21319
|
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${declaredType}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
|
|
20217
21320
|
);
|
|
20218
21321
|
}
|
|
20219
21322
|
if (type2 === "enum") {
|
|
20220
21323
|
const values = field.values;
|
|
20221
21324
|
if (values === null || typeof values !== "object" || Array.isArray(values) || Object.keys(values).length === 0) {
|
|
20222
|
-
|
|
21325
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u662F enum\uFF0C\u5FC5\u987B\u63D0\u4F9B\u975E\u7A7A values \u6620\u5C04\uFF08\u5B83\u540C\u65F6\u662F\u7FFB\u8BD1\u8868\u4E0E\u9009\u9879\u8868\uFF09`);
|
|
20223
21326
|
}
|
|
20224
21327
|
}
|
|
21328
|
+
if (field.values !== void 0 && (field.values === null || typeof field.values !== "object" || Array.isArray(field.values))) {
|
|
21329
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 values \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u503C \u2192 \u663E\u793A\u6587\u6848\uFF09`);
|
|
21330
|
+
}
|
|
20225
21331
|
const permission = field.permission === void 0 ? "r" : String(field.permission);
|
|
20226
21332
|
if (permission !== "r" && permission !== "w") {
|
|
20227
|
-
|
|
21333
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 permission \u53EA\u80FD\u662F r \u6216 w`);
|
|
20228
21334
|
}
|
|
20229
21335
|
if (field.rules !== void 0 && !Array.isArray(field.rules)) {
|
|
20230
|
-
|
|
21336
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules \u5FC5\u987B\u662F\u6570\u7EC4`);
|
|
21337
|
+
}
|
|
21338
|
+
(field.rules ?? []).forEach((rule, index) => {
|
|
21339
|
+
if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
|
|
21340
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u4E00\u4E2A\u6761\u4EF6 + message\uFF09`);
|
|
21341
|
+
}
|
|
21342
|
+
const message = rule.message;
|
|
21343
|
+
if (typeof message !== "string" || message.trim() === "") {
|
|
21344
|
+
fail(
|
|
21345
|
+
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u7F3A\u5C11 message\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u8981\u6C42\u6BCF\u6761\u89C4\u5219\u90FD\u5E26\u6821\u9A8C\u4E0D\u901A\u8FC7\u65F6\u7684\u63D0\u793A\u6587\u6848\uFF0C\u5982 { max_len: 200, message: \u5907\u6CE8\u6700\u591A 200 \u5B57 }`
|
|
21346
|
+
);
|
|
21347
|
+
}
|
|
21348
|
+
});
|
|
21349
|
+
if (field.modifies !== void 0 && (typeof field.modifies !== "string" || field.modifies.trim() === "")) {
|
|
21350
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D`);
|
|
20231
21351
|
}
|
|
20232
21352
|
return {
|
|
20233
21353
|
type: type2,
|
|
20234
21354
|
permission,
|
|
20235
21355
|
...field.name !== void 0 ? { name: String(field.name) } : {},
|
|
20236
21356
|
...field.values ? { values: field.values } : {},
|
|
20237
|
-
...field.rules ? { rules: field.rules } : {}
|
|
21357
|
+
...field.rules ? { rules: field.rules } : {},
|
|
21358
|
+
...field.modifies !== void 0 ? { modifies: String(field.modifies) } : {}
|
|
20238
21359
|
};
|
|
20239
21360
|
}
|
|
20240
|
-
function parseEventSection(raw2, blockId, scope,
|
|
21361
|
+
function parseEventSection(raw2, blockId, scope, fail) {
|
|
20241
21362
|
const actions = /* @__PURE__ */ new Map();
|
|
20242
21363
|
const emitRoutes = {};
|
|
20243
21364
|
if (raw2 === void 0) return { actions, emitRoutes };
|
|
20244
21365
|
if (raw2 === null || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
20245
|
-
|
|
21366
|
+
fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E actions / on\uFF09");
|
|
20246
21367
|
}
|
|
20247
21368
|
const section = raw2;
|
|
20248
21369
|
for (const key of Object.keys(section)) {
|
|
20249
21370
|
if (!EVENT_KEYS.has(key)) {
|
|
20250
|
-
|
|
21371
|
+
fail(`event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aactions / on\uFF09\u2014\u2014\u5B9A\u4E49\u4E0E\u8DEF\u7531\u5206\u5F00\u4F4F\uFF0C\u4E0D\u9760\u503C\u5F62\u72B6\u731C`);
|
|
20251
21372
|
}
|
|
20252
21373
|
}
|
|
20253
21374
|
for (const [id, actionRaw] of Object.entries(section.actions ?? {})) {
|
|
20254
21375
|
if (actionRaw === null || typeof actionRaw !== "object" || Array.isArray(actionRaw)) {
|
|
20255
|
-
|
|
21376
|
+
fail(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
20256
21377
|
}
|
|
20257
21378
|
const action = actionRaw;
|
|
20258
21379
|
for (const key of Object.keys(action)) {
|
|
20259
21380
|
if (!ACTION_KEYS.has(key)) {
|
|
20260
|
-
|
|
21381
|
+
fail(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
|
|
20261
21382
|
}
|
|
20262
21383
|
}
|
|
20263
|
-
if (action.label === void 0)
|
|
21384
|
+
if (action.label === void 0) fail(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
|
|
20264
21385
|
actions.set(id, {
|
|
20265
21386
|
id,
|
|
20266
21387
|
label: String(action.label),
|
|
@@ -20275,7 +21396,7 @@ function parseEventSection(raw2, blockId, scope, fail2) {
|
|
|
20275
21396
|
}
|
|
20276
21397
|
for (const [emitName, expr] of Object.entries(section.on ?? {})) {
|
|
20277
21398
|
if (emitName.includes(".")) {
|
|
20278
|
-
|
|
21399
|
+
fail(
|
|
20279
21400
|
`event.on \u7684\u952E "${emitName}" \u542B\u70B9\u53F7\u2014\u2014\u7EC4\u4EF6\u5757\u53EA\u8BA2\u9605\u672C\u5B9E\u4F8B\u7684\u5951\u7EA6 emit\uFF08\u76F4\u63A5\u5199 emit \u540D\uFF09\uFF0CDOM \u4E8B\u4EF6\u5199\u5728 page \u5757\u7684 event.on`
|
|
20280
21401
|
);
|
|
20281
21402
|
}
|
|
@@ -20354,6 +21475,13 @@ function compileSomaBlocks(input) {
|
|
|
20354
21475
|
for (const [name, decl] of Object.entries(page.dataRaw ?? {})) {
|
|
20355
21476
|
data[name] = decl;
|
|
20356
21477
|
}
|
|
21478
|
+
const dataOwners = /* @__PURE__ */ new Map();
|
|
21479
|
+
for (const name of Object.keys(page.dataRaw ?? {})) {
|
|
21480
|
+
dataOwners.set(name, "page \u5757 data: \u91CC\u7684\u540C\u540D\u5BF9\u8C61");
|
|
21481
|
+
}
|
|
21482
|
+
for (const name of Object.keys(page.surfaceRaw ?? {})) {
|
|
21483
|
+
if (!dataOwners.has(name)) dataOwners.set(name, "page \u5757 objects: \u91CC\u7684\u540C\u540D\u5BF9\u8C61");
|
|
21484
|
+
}
|
|
20357
21485
|
const blocks = /* @__PURE__ */ new Map();
|
|
20358
21486
|
for (const raw2 of rawBlocks) {
|
|
20359
21487
|
if (raw2.blockId === PAGE_BLOCK_ID) continue;
|
|
@@ -20362,32 +21490,78 @@ function compileSomaBlocks(input) {
|
|
|
20362
21490
|
blockId: raw2.blockId,
|
|
20363
21491
|
body: raw2.body,
|
|
20364
21492
|
...info?.component ? { htmlComponent: info.component } : {},
|
|
20365
|
-
rowVars: rowVarsFor(raw2.blockId, htmlIndex, ui)
|
|
21493
|
+
rowVars: rowVarsFor(raw2.blockId, htmlIndex, ui),
|
|
21494
|
+
inRowTemplate: info?.inRowTemplate === true
|
|
20366
21495
|
});
|
|
20367
21496
|
blocks.set(raw2.blockId, ast);
|
|
20368
21497
|
attachInstance(ui, raw2.blockId, ast, htmlIndex);
|
|
20369
21498
|
for (const [emitName, expr] of Object.entries(ast.emitRoutes)) {
|
|
20370
21499
|
event[`${raw2.blockId}.${emitName}`] = expr;
|
|
20371
21500
|
}
|
|
21501
|
+
const flatNames = new Map(ast.dataObjects.map((object) => [object.localName, object.fullName]));
|
|
20372
21502
|
for (const object of ast.dataObjects) {
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
}
|
|
21503
|
+
const owner = dataOwners.get(object.fullName);
|
|
21504
|
+
if (owner) {
|
|
21505
|
+
throw new SomaBlockParseError(
|
|
21506
|
+
`\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${object.localName}" \u7684\u5168\u5C40\u540D "${object.fullName}" \u4E0E ${owner} \u649E\u540D\u2014\u2014\u4E24\u8005\u4F1A\u843D\u5230\u540C\u4E00\u4E2A page.data \u952E\u4E0A\uFF0C\u540E\u5199\u7684\u9759\u9ED8\u76D6\u6389\u5148\u5199\u7684\uFF1B\u8BF7\u7ED9\u5176\u4E2D\u4E00\u65B9\u6539\u540D`,
|
|
21507
|
+
raw2.blockId
|
|
21508
|
+
);
|
|
21509
|
+
}
|
|
21510
|
+
dataOwners.set(object.fullName, `\u5757 "${raw2.blockId}" \u7684\u79C1\u6709\u5BF9\u8C61 "${object.localName}"`);
|
|
21511
|
+
data[object.fullName] = toDataObjectConfig(object, flatNames, raw2.blockId);
|
|
20380
21512
|
}
|
|
20381
21513
|
}
|
|
20382
|
-
return {
|
|
21514
|
+
return {
|
|
21515
|
+
ui,
|
|
21516
|
+
event,
|
|
21517
|
+
data,
|
|
21518
|
+
...page.surfaceRaw ? { surface: page.surfaceRaw } : {},
|
|
21519
|
+
blocks,
|
|
21520
|
+
htmlIndex
|
|
21521
|
+
};
|
|
21522
|
+
}
|
|
21523
|
+
function toDataObjectConfig(object, flatNames, blockId) {
|
|
21524
|
+
if (!object.from) {
|
|
21525
|
+
throw new SomaBlockParseError(
|
|
21526
|
+
`\u79C1\u6709\u6570\u636E\u5BF9\u8C61 "${object.localName}" \u7F3A\u5C11 from\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684\u5BF9\u8C61\u5FC5\u987B\u6709\u53D6\u6570\u6765\u6E90\uFF08\u5757\u58F0\u660E\u6CA1\u6709 mock \u6837\u672C\u4F4D\uFF09\uFF0C\u8BF7\u8865 from: { api, params }`,
|
|
21527
|
+
blockId
|
|
21528
|
+
);
|
|
21529
|
+
}
|
|
21530
|
+
const params = Object.keys(object.from.params).length > 0 ? { params: object.from.params } : {};
|
|
21531
|
+
return {
|
|
21532
|
+
from: [{ api: object.from.api, ...params }],
|
|
21533
|
+
...object.save ? { write: normalizeSave(object.save) } : {},
|
|
21534
|
+
...object.fields ? { fields: toDataFields(object.fields) } : {},
|
|
21535
|
+
// REQ-014 期 2'.1:对象级角色与关系必须一路带下去。
|
|
21536
|
+
// use-parser 已经解析并校验了它们,这里不带 = 「解析了、引擎不消费」——
|
|
21537
|
+
// 那正是 `save:` 归一之前踩过的坑(见下方 normalizeSave 的注释):
|
|
21538
|
+
// 语法检查通过、声明看起来生效了,运行期没有任何东西读它。
|
|
21539
|
+
...object.roles ? { roles: object.roles } : {},
|
|
21540
|
+
...object.relations ? { relations: flattenRelationTargets(object.relations, flatNames) } : {}
|
|
21541
|
+
};
|
|
21542
|
+
}
|
|
21543
|
+
function toDataFields(fields) {
|
|
21544
|
+
const result = {};
|
|
21545
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
21546
|
+
const { values, ...rest } = field;
|
|
21547
|
+
result[key] = {
|
|
21548
|
+
...rest,
|
|
21549
|
+
...values ? { options: Object.entries(values).map(([value, label]) => ({ key: value, label: String(label) })) } : {}
|
|
21550
|
+
};
|
|
21551
|
+
}
|
|
21552
|
+
return result;
|
|
21553
|
+
}
|
|
21554
|
+
function flattenRelationTargets(relations, flatNames) {
|
|
21555
|
+
return relations.map((relation) => {
|
|
21556
|
+
const flat = flatNames.get(relation.to);
|
|
21557
|
+
return flat ? { ...relation, to: flat } : relation;
|
|
21558
|
+
});
|
|
20383
21559
|
}
|
|
20384
21560
|
function normalizeSave(save) {
|
|
20385
21561
|
return {
|
|
20386
21562
|
update: { api: save.api, method: save.method },
|
|
20387
21563
|
...save.key !== void 0 ? { version: save.key } : {},
|
|
20388
|
-
...save.fields !== void 0 ? { only: save.fields } : {}
|
|
20389
|
-
// 触发动作:等 AO 动作编排(S4)接手,届时编译成一条 `do: DATA | commit` 步骤
|
|
20390
|
-
trigger: save.trigger
|
|
21564
|
+
...save.fields !== void 0 ? { only: save.fields } : {}
|
|
20391
21565
|
};
|
|
20392
21566
|
}
|
|
20393
21567
|
function rowVarsFor(blockId, htmlIndex, ui) {
|
|
@@ -20445,380 +21619,6 @@ function findListShow(show, listAnchor) {
|
|
|
20445
21619
|
}
|
|
20446
21620
|
return void 0;
|
|
20447
21621
|
}
|
|
20448
|
-
|
|
20449
|
-
// core/build/compiler/html-include-expander.ts
|
|
20450
|
-
var SomaHtmlIncludeError = class extends Error {
|
|
20451
|
-
constructor(message) {
|
|
20452
|
-
super(`[soma-core][HTML include] ${message}`);
|
|
20453
|
-
this.name = "SomaHtmlIncludeError";
|
|
20454
|
-
}
|
|
20455
|
-
};
|
|
20456
|
-
var INCLUDE_ATTRIBUTE = /\sdata-soma-include\s*=\s*(["'])([^"']+)\1/i;
|
|
20457
|
-
var OPEN_TAG = /<([A-Za-z][A-Za-z0-9:-]*)(\s[^<>]*?)?>/g;
|
|
20458
|
-
function expandSomaHtmlIncludes(html, includes) {
|
|
20459
|
-
if (!includes || Object.keys(includes).length === 0 || !html.includes("data-soma-include")) {
|
|
20460
|
-
return html;
|
|
20461
|
-
}
|
|
20462
|
-
const expand = (source, chain) => source.replace(
|
|
20463
|
-
OPEN_TAG,
|
|
20464
|
-
(full, tagName, attributes) => {
|
|
20465
|
-
const rawAttributes = attributes ?? "";
|
|
20466
|
-
const matched = INCLUDE_ATTRIBUTE.exec(rawAttributes);
|
|
20467
|
-
if (!matched) return full;
|
|
20468
|
-
const includeName = matched[2];
|
|
20469
|
-
if (!Object.prototype.hasOwnProperty.call(includes, includeName)) {
|
|
20470
|
-
throw new SomaHtmlIncludeError(`\u627E\u4E0D\u5230\u5171\u4EAB\u7247\u6BB5 "${includeName}"`);
|
|
20471
|
-
}
|
|
20472
|
-
if (chain.includes(includeName)) {
|
|
20473
|
-
throw new SomaHtmlIncludeError(`\u68C0\u6D4B\u5230\u5FAA\u73AF\u5F15\u7528\uFF1A${[...chain, includeName].join(" -> ")}`);
|
|
20474
|
-
}
|
|
20475
|
-
const withoutInclude = rawAttributes.replace(INCLUDE_ATTRIBUTE, "");
|
|
20476
|
-
const expandedFragment = expand(includes[includeName], [...chain, includeName]);
|
|
20477
|
-
return `<${tagName}${withoutInclude}>${expandedFragment}`;
|
|
20478
|
-
}
|
|
20479
|
-
);
|
|
20480
|
-
return expand(html, []);
|
|
20481
|
-
}
|
|
20482
|
-
|
|
20483
|
-
// core/build/layout/constraint-solver.ts
|
|
20484
|
-
var CONTAINER_STEPS = [
|
|
20485
|
-
["cqXs", 20],
|
|
20486
|
-
["cqSm", 24],
|
|
20487
|
-
["cqMd", 28],
|
|
20488
|
-
["cqLg", 36],
|
|
20489
|
-
["cqXl", 40],
|
|
20490
|
-
["cq2xl", 48],
|
|
20491
|
-
["cq3xl", 56],
|
|
20492
|
-
["cq4xl", 64]
|
|
20493
|
-
];
|
|
20494
|
-
var SomaLayoutConstraintError = class extends Error {
|
|
20495
|
-
constructor(message, conflict) {
|
|
20496
|
-
super(`[SOMA Layout] ${message}`);
|
|
20497
|
-
this.name = "SomaLayoutConstraintError";
|
|
20498
|
-
this.conflict = conflict;
|
|
20499
|
-
}
|
|
20500
|
-
};
|
|
20501
|
-
function toRem(literal, containerRem, where) {
|
|
20502
|
-
const text = String(literal).trim();
|
|
20503
|
-
const match = /^(-?\d+(?:\.\d+)?)(rem|%|cqi)$/.exec(text);
|
|
20504
|
-
if (!match) {
|
|
20505
|
-
throw new SomaLayoutConstraintError(
|
|
20506
|
-
`${where} \u7684\u957F\u5EA6 "${text}" \u975E\u6CD5\u2014\u2014\u53EA\u8BA4 rem / % / cqi\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`,
|
|
20507
|
-
[where, text]
|
|
20508
|
-
);
|
|
20509
|
-
}
|
|
20510
|
-
const value = Number(match[1]);
|
|
20511
|
-
if (value < 0) {
|
|
20512
|
-
throw new SomaLayoutConstraintError(`${where} \u7684\u957F\u5EA6\u4E0D\u80FD\u662F\u8D1F\u6570\uFF08\u6536\u5230 ${text}\uFF09`, [where, text]);
|
|
20513
|
-
}
|
|
20514
|
-
return match[2] === "rem" ? value : value / 100 * containerRem;
|
|
20515
|
-
}
|
|
20516
|
-
function validateConstraint(constraint, path) {
|
|
20517
|
-
const names = Object.keys(constraint.nodes ?? {});
|
|
20518
|
-
if (names.length === 0) {
|
|
20519
|
-
throw new SomaLayoutConstraintError(`${path} \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u5B50\u9879`, [path, "nodes"]);
|
|
20520
|
-
}
|
|
20521
|
-
for (const name of names) {
|
|
20522
|
-
const node = constraint.nodes[name];
|
|
20523
|
-
const at = `${path}.${name}`;
|
|
20524
|
-
if (node.priority !== void 0 && !SOMA_LAYOUT_PRIORITIES.includes(node.priority)) {
|
|
20525
|
-
throw new SomaLayoutConstraintError(
|
|
20526
|
-
`${at}.priority \u53EA\u80FD\u662F ${SOMA_LAYOUT_PRIORITIES.join(" / ")}\uFF08\u6536\u5230 ${node.priority}\uFF09\u2014\u2014\u4F18\u5148\u7EA7\u53EA\u5728\u76F8\u5BF9\u6B21\u5E8F\u4E0A\u6709\u610F\u4E49\uFF0C\u5F00\u653E\u6210\u4EFB\u610F\u6574\u6570\u53EA\u4F1A\u8BA9\u4EBA\u5199\u51FA\u81EA\u5DF1\u4E5F\u8BF4\u4E0D\u6E05\u5DEE\u522B\u7684\u503C`,
|
|
20527
|
-
[at, String(node.priority)]
|
|
20528
|
-
);
|
|
20529
|
-
}
|
|
20530
|
-
if (node.sizing === "fixed" && node.width === void 0) {
|
|
20531
|
-
throw new SomaLayoutConstraintError(
|
|
20532
|
-
`${at} \u662F fixed \u5374\u6CA1\u7ED9 width\u2014\u2014"\u56FA\u5B9A"\u56FA\u5B9A\u5230\u591A\u5C11\u5FC5\u987B\u8BF4\u51FA\u6765`,
|
|
20533
|
-
[at, "sizing: fixed"]
|
|
20534
|
-
);
|
|
20535
|
-
}
|
|
20536
|
-
if (node.sizing === "hug" && (node.min !== void 0 || node.max !== void 0)) {
|
|
20537
|
-
throw new SomaLayoutConstraintError(
|
|
20538
|
-
`${at} \u662F hug\uFF0C\u4E0D\u80FD\u540C\u65F6\u7ED9 min / max\u2014\u2014hug \u7684\u5BBD\u5EA6\u7531\u5185\u5BB9\u51B3\u5B9A\uFF0C\u518D\u52A0\u4E0A\u4E0B\u754C\u7B49\u4E8E\u8BA9\u4E24\u4E2A\u6765\u6E90\u4E89\u540C\u4E00\u4E2A\u6570\u3002\u8981\u5939\u5728\u533A\u95F4\u91CC\u8BF7\u6539\u7528 fill \u6216 fixed`,
|
|
20539
|
-
[at, "sizing: hug"]
|
|
20540
|
-
);
|
|
20541
|
-
}
|
|
20542
|
-
if (node.min !== void 0 && node.max !== void 0) {
|
|
20543
|
-
const minRem = /rem$/.test(node.min) ? Number.parseFloat(node.min) : NaN;
|
|
20544
|
-
const maxRem = /rem$/.test(node.max) ? Number.parseFloat(node.max) : NaN;
|
|
20545
|
-
if (Number.isFinite(minRem) && Number.isFinite(maxRem) && minRem > maxRem) {
|
|
20546
|
-
throw new SomaLayoutConstraintError(
|
|
20547
|
-
`${at} \u7684 min (${node.min}) \u5927\u4E8E max (${node.max})\u2014\u2014\u8FD9\u6761\u7EA6\u675F\u65E0\u89E3`,
|
|
20548
|
-
[`${at}.min`, `${at}.max`]
|
|
20549
|
-
);
|
|
20550
|
-
}
|
|
20551
|
-
}
|
|
20552
|
-
}
|
|
20553
|
-
}
|
|
20554
|
-
function solveStep(constraint, containerRem, breakpoint, path) {
|
|
20555
|
-
const names = Object.keys(constraint.nodes);
|
|
20556
|
-
const gap = constraint.gap === void 0 ? 0 : toRem(constraint.gap, containerRem, `${path}.gap`);
|
|
20557
|
-
const available = containerRem - gap * Math.max(0, names.length - 1);
|
|
20558
|
-
const at = (name) => `${path}.${name}`;
|
|
20559
|
-
const bounds = names.map((name) => {
|
|
20560
|
-
const node = constraint.nodes[name];
|
|
20561
|
-
const min = node.min === void 0 ? 0 : toRem(node.min, containerRem, `${at(name)}.min`);
|
|
20562
|
-
const max = node.max === void 0 ? Number.POSITIVE_INFINITY : toRem(node.max, containerRem, `${at(name)}.max`);
|
|
20563
|
-
if (min > max) {
|
|
20564
|
-
throw new SomaLayoutConstraintError(
|
|
20565
|
-
`${at(name)} \u5728 ${breakpoint}\uFF08\u5BB9\u5668 ${containerRem}rem\uFF09\u6863\u4E0A min (${min}rem) \u5927\u4E8E max (${max}rem)\u2014\u2014\u6DF7\u7528 rem \u4E0E % \u65F6\uFF0C\u4E24\u8005\u7684\u5927\u5C0F\u5173\u7CFB\u4F1A\u968F\u6863\u53D8\u5316\uFF0C\u8FD9\u4E00\u6863\u7FFB\u8FC7\u6765\u4E86`,
|
|
20566
|
-
[`${at(name)}.min`, `${at(name)}.max`]
|
|
20567
|
-
);
|
|
20568
|
-
}
|
|
20569
|
-
const base = node.sizing === "fixed" ? toRem(node.width, containerRem, `${at(name)}.width`) : min;
|
|
20570
|
-
return {
|
|
20571
|
-
name,
|
|
20572
|
-
node,
|
|
20573
|
-
min,
|
|
20574
|
-
max,
|
|
20575
|
-
priority: node.priority ?? 500,
|
|
20576
|
-
width: Math.min(Math.max(base, min), max)
|
|
20577
|
-
};
|
|
20578
|
-
});
|
|
20579
|
-
let total = bounds.reduce((sum, item) => sum + item.width, 0);
|
|
20580
|
-
if (total > available) {
|
|
20581
|
-
for (const priority of SOMA_LAYOUT_PRIORITIES) {
|
|
20582
|
-
if (total <= available) break;
|
|
20583
|
-
if (priority === 1e3) break;
|
|
20584
|
-
const group = bounds.filter((item) => item.priority === priority && item.width > item.min);
|
|
20585
|
-
const slack = group.reduce((sum, item) => sum + (item.width - item.min), 0);
|
|
20586
|
-
if (slack <= 0) continue;
|
|
20587
|
-
const need = Math.min(total - available, slack);
|
|
20588
|
-
for (const item of group) {
|
|
20589
|
-
const share = (item.width - item.min) / slack * need;
|
|
20590
|
-
item.width -= share;
|
|
20591
|
-
}
|
|
20592
|
-
total -= need;
|
|
20593
|
-
}
|
|
20594
|
-
}
|
|
20595
|
-
const wrapped = total > available + 1e-9;
|
|
20596
|
-
if (wrapped && (constraint.wrap ?? "none") === "none") {
|
|
20597
|
-
const sorted = [...bounds].sort((a, b) => b.min - a.min);
|
|
20598
|
-
throw new SomaLayoutConstraintError(
|
|
20599
|
-
`${path} \u5728 ${breakpoint}\uFF08\u5BB9\u5668 ${containerRem}rem\uFF09\u6863\u4E0A\u653E\u4E0D\u4E0B\uFF1A\u5404\u9879 min \u4E4B\u548C ${total.toFixed(2)}rem \u5DF2\u8D85\u8FC7\u53EF\u7528 ${available.toFixed(2)}rem\u3002\u6700\u6324\u7684\u4E24\u9879\u662F "${sorted[0]?.name}"(min ${sorted[0]?.min}rem) \u4E0E "${sorted[1]?.name}"(min ${sorted[1]?.min ?? 0}rem)\u3002\u628A\u5176\u4E2D\u4E00\u4E2A\u7684 min \u8C03\u5C0F\uFF0C\u6216\u58F0\u660E wrap: below \u8BA9\u5B83\u4EEC\u5728\u7A84\u6863\u7AD6\u6392\u3002`,
|
|
20600
|
-
[at(sorted[0]?.name ?? ""), at(sorted[1]?.name ?? "")]
|
|
20601
|
-
);
|
|
20602
|
-
}
|
|
20603
|
-
if (!wrapped && total < available) {
|
|
20604
|
-
for (const priority of SOMA_LAYOUT_PRIORITIES) {
|
|
20605
|
-
const rest = available - total;
|
|
20606
|
-
if (rest <= 1e-9) break;
|
|
20607
|
-
const group = bounds.filter(
|
|
20608
|
-
(item) => item.priority === priority && item.node.sizing === "fill" && item.width < item.max
|
|
20609
|
-
);
|
|
20610
|
-
if (group.length === 0) continue;
|
|
20611
|
-
const room = group.reduce((sum, item) => sum + (item.max - item.width), 0);
|
|
20612
|
-
const give = Math.min(rest, room);
|
|
20613
|
-
for (const item of group) {
|
|
20614
|
-
const share = room === Number.POSITIVE_INFINITY ? give / group.length : (item.max - item.width) / room * give;
|
|
20615
|
-
item.width += share;
|
|
20616
|
-
}
|
|
20617
|
-
total += give;
|
|
20618
|
-
}
|
|
20619
|
-
}
|
|
20620
|
-
const widths = {};
|
|
20621
|
-
for (const item of bounds) widths[item.name] = round(item.width);
|
|
20622
|
-
return { breakpoint, containerRem, widths, wrapped };
|
|
20623
|
-
}
|
|
20624
|
-
function solveLayout(constraint, path) {
|
|
20625
|
-
validateConstraint(constraint, path);
|
|
20626
|
-
const solutions = CONTAINER_STEPS.map(
|
|
20627
|
-
([name, rem]) => solveStep(constraint, rem, name, path)
|
|
20628
|
-
);
|
|
20629
|
-
return { constraint, solutions };
|
|
20630
|
-
}
|
|
20631
|
-
function round(value) {
|
|
20632
|
-
return Math.round(value * 1e4) / 1e4;
|
|
20633
|
-
}
|
|
20634
|
-
|
|
20635
|
-
// core/build/layout/css-emitter.ts
|
|
20636
|
-
var ALIGN_MAIN = {
|
|
20637
|
-
space_between: "space-between",
|
|
20638
|
-
space_evenly: "space-evenly",
|
|
20639
|
-
space_around: "space-around"
|
|
20640
|
-
};
|
|
20641
|
-
var ALIGN_CROSS = {
|
|
20642
|
-
start: "flex-start",
|
|
20643
|
-
center: "center",
|
|
20644
|
-
end: "flex-end",
|
|
20645
|
-
baseline: "baseline"
|
|
20646
|
-
};
|
|
20647
|
-
function emitLayoutCss(plan, options) {
|
|
20648
|
-
const { root } = options;
|
|
20649
|
-
const selectorOf = options.selectorOf ?? ((name) => `${root} > [data-soma-slot="${name}"]`);
|
|
20650
|
-
const wrap = plan.constraint.wrap ?? "none";
|
|
20651
|
-
const align = plan.constraint.align;
|
|
20652
|
-
const gap = plan.constraint.gap;
|
|
20653
|
-
const containerRule = [
|
|
20654
|
-
`${root} {`,
|
|
20655
|
-
" display: flex;",
|
|
20656
|
-
// 具名容器(§5.4):子孙的 `@container <name> (…)` 靠它寻址
|
|
20657
|
-
plan.constraint.container_name === void 0 ? " container-type: inline-size;" : ` container: ${plan.constraint.container_name} / inline-size;`,
|
|
20658
|
-
gap === void 0 ? null : ` gap: ${gap};`,
|
|
20659
|
-
align !== void 0 && ALIGN_MAIN[align] !== void 0 ? ` justify-content: ${ALIGN_MAIN[align]};` : null,
|
|
20660
|
-
align !== void 0 && ALIGN_CROSS[align] !== void 0 ? ` align-items: ${ALIGN_CROSS[align]};` : null,
|
|
20661
|
-
wrap === "reel" ? " overflow-inline: auto;" : null,
|
|
20662
|
-
"}"
|
|
20663
|
-
].filter((line) => line !== null).join("\n");
|
|
20664
|
-
const ruleFor = (index) => {
|
|
20665
|
-
const solution = plan.solutions[index];
|
|
20666
|
-
const lines = [];
|
|
20667
|
-
if (solution.wrapped && wrap === "below") {
|
|
20668
|
-
lines.push(`${root} { flex-wrap: wrap; }`);
|
|
20669
|
-
} else if (wrap !== "reel") {
|
|
20670
|
-
lines.push(`${root} { flex-wrap: nowrap; }`);
|
|
20671
|
-
}
|
|
20672
|
-
for (const [name, width] of Object.entries(solution.widths)) {
|
|
20673
|
-
const node = plan.constraint.nodes[name];
|
|
20674
|
-
const selector = selectorOf(name);
|
|
20675
|
-
if (node.sizing === "hug") {
|
|
20676
|
-
lines.push(`${selector} { flex: 0 0 auto; }`);
|
|
20677
|
-
continue;
|
|
20678
|
-
}
|
|
20679
|
-
const basis = `${width}rem`;
|
|
20680
|
-
const grow = node.sizing === "fill" ? "1 1" : "0 0";
|
|
20681
|
-
const bounds = [
|
|
20682
|
-
node.min === void 0 ? null : `min-inline-size: ${node.min};`,
|
|
20683
|
-
node.max === void 0 ? null : `max-inline-size: ${node.max};`
|
|
20684
|
-
].filter((part) => part !== null).join(" ");
|
|
20685
|
-
const declaration = solution.wrapped && wrap === "below" ? `flex: 1 1 100%;` : `flex: ${grow} ${basis};`;
|
|
20686
|
-
lines.push(`${selector} { ${declaration}${bounds === "" ? "" : ` ${bounds}`} }`);
|
|
20687
|
-
}
|
|
20688
|
-
return lines.join("\n");
|
|
20689
|
-
};
|
|
20690
|
-
const blocks = [containerRule, ruleFor(0)];
|
|
20691
|
-
for (let index = 1; index < plan.solutions.length; index += 1) {
|
|
20692
|
-
const [, rem] = CONTAINER_STEPS[index];
|
|
20693
|
-
const body = ruleFor(index);
|
|
20694
|
-
if (body === ruleFor(index - 1)) continue;
|
|
20695
|
-
blocks.push(`@container (min-width: ${rem}rem) {
|
|
20696
|
-
${indent(body)}
|
|
20697
|
-
}`);
|
|
20698
|
-
}
|
|
20699
|
-
return blocks.join("\n");
|
|
20700
|
-
}
|
|
20701
|
-
function indent(text) {
|
|
20702
|
-
return text.split("\n").map((line) => line === "" ? line : ` ${line}`).join("\n");
|
|
20703
|
-
}
|
|
20704
|
-
|
|
20705
|
-
// core/build/layout/page-layout.ts
|
|
20706
|
-
var SomaPageLayoutError = class extends Error {
|
|
20707
|
-
constructor(message, path) {
|
|
20708
|
-
super(`[soma-core][\u5E03\u5C40] ${message}\uFF08${path}\uFF09`);
|
|
20709
|
-
this.path = path;
|
|
20710
|
-
this.name = "SomaPageLayoutError";
|
|
20711
|
-
}
|
|
20712
|
-
};
|
|
20713
|
-
var fail = (message, path) => {
|
|
20714
|
-
throw new SomaPageLayoutError(message, path);
|
|
20715
|
-
};
|
|
20716
|
-
function anchorSelector(hostClass, anchor) {
|
|
20717
|
-
return `[data-soma-host="${hostClass}"] [data-soma-id="${anchor}"]`;
|
|
20718
|
-
}
|
|
20719
|
-
function compilePageLayout(input) {
|
|
20720
|
-
const { raw: raw2, htmlIndex, hostClass } = input;
|
|
20721
|
-
if (!raw2 || typeof raw2 !== "object" || Array.isArray(raw2)) {
|
|
20722
|
-
fail("layout \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { gap, wrap, <\u5B50\u9879>: { sizing, \u2026 } } }", "layout");
|
|
20723
|
-
}
|
|
20724
|
-
const constraints = {};
|
|
20725
|
-
const chunks = [];
|
|
20726
|
-
for (const [anchor, spec] of Object.entries(raw2)) {
|
|
20727
|
-
const path = `layout.${anchor}`;
|
|
20728
|
-
if (!htmlIndex.anchors.has(anchor)) {
|
|
20729
|
-
fail(`\u951A\u70B9 "${anchor}" \u4E0D\u5B58\u5728\u4E8E HTML\uFF08data-soma-id\uFF09`, path);
|
|
20730
|
-
}
|
|
20731
|
-
const constraint = parseLayoutConstraint({ raw: spec, path }, { fail });
|
|
20732
|
-
for (const child of Object.keys(constraint.nodes)) {
|
|
20733
|
-
if (!htmlIndex.anchors.has(child)) {
|
|
20734
|
-
fail(`\u5B50\u9879 "${child}" \u4E0D\u662F\u9875\u9762\u951A\u70B9\u2014\u2014\u5B83\u5FC5\u987B\u662F "${anchor}" \u7684\u76F4\u63A5\u5B50\u5143\u7D20\u4E14\u5E26 data-soma-id`, `${path}.${child}`);
|
|
20735
|
-
}
|
|
20736
|
-
}
|
|
20737
|
-
const plan = solveLayout(constraint, path);
|
|
20738
|
-
const root = anchorSelector(hostClass, anchor);
|
|
20739
|
-
chunks.push(emitLayoutCss(plan, {
|
|
20740
|
-
root,
|
|
20741
|
-
selectorOf: (name) => `${root} > [data-soma-id="${name}"]`
|
|
20742
|
-
}));
|
|
20743
|
-
constraints[anchor] = constraint;
|
|
20744
|
-
}
|
|
20745
|
-
return { constraints, css: chunks.join("\n") };
|
|
20746
|
-
}
|
|
20747
|
-
|
|
20748
|
-
// core/build/compiler/page-declaration-compiler.ts
|
|
20749
|
-
var dump2 = (value) => yaml.dump(value, { lineWidth: 120, noRefs: true, quotingType: '"' });
|
|
20750
|
-
function compilePageDeclaration(input) {
|
|
20751
|
-
const eventYaml = input.eventYaml ?? "";
|
|
20752
|
-
const styleYaml = input.styleYaml ?? "";
|
|
20753
|
-
const dataYaml = input.dataYaml ?? "";
|
|
20754
|
-
const sidecars = [
|
|
20755
|
-
eventYaml.trim() ? "eventYaml / *_event.yaml" : "",
|
|
20756
|
-
styleYaml.trim() ? "styleYaml / *_style.yaml" : "",
|
|
20757
|
-
dataYaml.trim() ? "dataYaml / *_data.yaml" : ""
|
|
20758
|
-
].filter(Boolean);
|
|
20759
|
-
if (sidecars.length > 0) {
|
|
20760
|
-
throw new Error(
|
|
20761
|
-
`[soma-core][SOMA DSL] \u9875\u9762\u4FA7\u8F66\u5DF2\u9000\u5F79\uFF1A${sidecars.join("\u3001")}\u3002\u4E8B\u4EF6\u3001\u6837\u5F0F\u72B6\u6001\u4E0E\u6570\u636E\u5BF9\u8C61\u5FC5\u987B\u5199\u8FDB\u540C\u4E00\u4EFD SOMA DSL \u58F0\u660E\u3002`
|
|
20762
|
-
);
|
|
20763
|
-
}
|
|
20764
|
-
const compiled = compileSomaBlocks({
|
|
20765
|
-
html: expandSomaHtmlIncludes(input.html, input.includes),
|
|
20766
|
-
uiYamlRaw: input.uiYaml,
|
|
20767
|
-
...input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}
|
|
20768
|
-
});
|
|
20769
|
-
const eventBundle = compileEventConfigFromRaw(compiled.event);
|
|
20770
|
-
const embeddedDataYaml = Object.keys(compiled.data).length > 0 ? dump2({ data: compiled.data }) : "";
|
|
20771
|
-
if (compiled.ui.state !== void 0) {
|
|
20772
|
-
compiled.ui.state = parsePageState(
|
|
20773
|
-
{
|
|
20774
|
-
raw: compiled.ui.state,
|
|
20775
|
-
objectNames: Object.keys(compiled.data),
|
|
20776
|
-
anchorIds: [...compiled.htmlIndex.anchors.keys()],
|
|
20777
|
-
path: "page.state"
|
|
20778
|
-
},
|
|
20779
|
-
{ fail(message, path) {
|
|
20780
|
-
throw new Error(`[soma-core][\u9875\u9762\u6001] ${message}\uFF08${path}\uFF09`);
|
|
20781
|
-
} }
|
|
20782
|
-
);
|
|
20783
|
-
}
|
|
20784
|
-
const layout = compiled.ui.layout !== void 0 ? compilePageLayout({ raw: compiled.ui.layout, htmlIndex: compiled.htmlIndex, hostClass: compiled.ui.bind.obj }) : null;
|
|
20785
|
-
if (layout) compiled.ui.layout = layout.constraints;
|
|
20786
|
-
const { layout: _layoutDecl, ...runtimeUi } = compiled.ui;
|
|
20787
|
-
const runtimeUiWithCss = layout ? { ...runtimeUi, layout_css: layout.css } : runtimeUi;
|
|
20788
|
-
return {
|
|
20789
|
-
uiConfig: layout ? { ...compiled.ui, layoutCss: layout.css } : compiled.ui,
|
|
20790
|
-
eventConfig: eventBundle.events,
|
|
20791
|
-
triggers: eventBundle.triggers,
|
|
20792
|
-
timers: eventBundle.timers,
|
|
20793
|
-
...embeddedDataYaml ? { dataConfig: compileDataConfig(embeddedDataYaml) } : {},
|
|
20794
|
-
...layout ? { layoutCss: layout.css } : {},
|
|
20795
|
-
runtimeAssets: {
|
|
20796
|
-
uiYaml: dump2(runtimeUiWithCss),
|
|
20797
|
-
eventYaml: Object.keys(compiled.event).length > 0 ? dump2(compiled.event) : "",
|
|
20798
|
-
styleYaml: "",
|
|
20799
|
-
...embeddedDataYaml ? { dataYaml: embeddedDataYaml } : {}
|
|
20800
|
-
}
|
|
20801
|
-
};
|
|
20802
|
-
}
|
|
20803
|
-
|
|
20804
|
-
// core/build/compiler/page-assets.ts
|
|
20805
|
-
function compilePageAssets(assets) {
|
|
20806
|
-
const compiled = compilePageDeclaration({
|
|
20807
|
-
html: assets.html ?? "",
|
|
20808
|
-
uiYaml: assets.uiYaml ?? "",
|
|
20809
|
-
...assets.eventYaml ? { eventYaml: assets.eventYaml } : {},
|
|
20810
|
-
...assets.styleYaml ? { styleYaml: assets.styleYaml } : {},
|
|
20811
|
-
...assets.dataYaml ? { dataYaml: assets.dataYaml } : {},
|
|
20812
|
-
...assets.declarationBlocks ? { externalBlocks: assets.declarationBlocks } : {}
|
|
20813
|
-
});
|
|
20814
|
-
return {
|
|
20815
|
-
...assets,
|
|
20816
|
-
uiYaml: compiled.runtimeAssets.uiYaml,
|
|
20817
|
-
eventYaml: compiled.runtimeAssets.eventYaml,
|
|
20818
|
-
styleYaml: "",
|
|
20819
|
-
...compiled.runtimeAssets.dataYaml ? { dataYaml: compiled.runtimeAssets.dataYaml } : { dataYaml: void 0 }
|
|
20820
|
-
};
|
|
20821
|
-
}
|
|
20822
21622
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20823
21623
|
0 && (module.exports = {
|
|
20824
21624
|
CALC_FUNCTIONS,
|
|
@@ -20839,6 +21639,8 @@ function compilePageAssets(assets) {
|
|
|
20839
21639
|
SOMA_AGGREGATE_FNS,
|
|
20840
21640
|
SOMA_DATA_FIELD_TYPES,
|
|
20841
21641
|
SOMA_DATA_FIELD_TYPE_ALIASES,
|
|
21642
|
+
SOMA_DATA_OBJECT_ROLES,
|
|
21643
|
+
SOMA_DATA_RELATION_CARDINALITIES,
|
|
20842
21644
|
SOMA_DEFAULT_HYSTERESIS,
|
|
20843
21645
|
SOMA_FIELD_DISPLAYS,
|
|
20844
21646
|
SOMA_FIELD_PATTERNS,
|
|
@@ -20898,7 +21700,6 @@ function compilePageAssets(assets) {
|
|
|
20898
21700
|
collectPredicateFields,
|
|
20899
21701
|
compileAdaptive,
|
|
20900
21702
|
compileFieldSugar,
|
|
20901
|
-
compilePageAssets,
|
|
20902
21703
|
compileSomaBlocks,
|
|
20903
21704
|
componentTokenPrefix,
|
|
20904
21705
|
componentTokenVar,
|
|
@@ -20914,6 +21715,7 @@ function compilePageAssets(assets) {
|
|
|
20914
21715
|
createWindow,
|
|
20915
21716
|
decodePageState,
|
|
20916
21717
|
defaultPipeRegistry,
|
|
21718
|
+
deriveContractPreviewSample,
|
|
20917
21719
|
deriveContractSample,
|
|
20918
21720
|
deriveFieldSample,
|
|
20919
21721
|
deriveKeyboardMatrix,
|
|
@@ -21003,7 +21805,6 @@ function compilePageAssets(assets) {
|
|
|
21003
21805
|
setSomaHtmlSanitizer,
|
|
21004
21806
|
somaEmits,
|
|
21005
21807
|
somaFields,
|
|
21006
|
-
somaRollupPlugin,
|
|
21007
21808
|
somaSlots,
|
|
21008
21809
|
startBootTimings,
|
|
21009
21810
|
themeRootAttributes,
|