soma-core 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/app/SomaPageClient.tsx +2 -72
- package/bin/soma-lsp.cjs +1 -4
- package/core/build/compiler/full-manifest-builder.ts +17 -26
- package/core/build/compiler/html-include-expander.ts +56 -0
- package/core/build/compiler/page-assets.ts +26 -0
- package/core/build/compiler/page-declaration-compiler.ts +85 -0
- package/core/build/compiler/rollup-plugin-soma.ts +4 -19
- package/core/build/compiler/route-builder.ts +0 -2
- package/core/build/compiler/rspack-plugin-soma.js +1 -10
- package/core/build/compiler/soma-manifest-webpack-plugin.js +54 -13
- package/core/build/compiler/soma-precompile.js +74 -0
- package/core/build/compiler/soma-precompile.ts +13 -0
- package/core/build/compiler/soma-rspack-yaml-loader.js +5 -11
- package/core/build/compiler/soma-webpack-loader.js +6 -21
- package/core/build/compiler/vite-plugin-soma.ts +9 -31
- package/core/build/component/pack-from-dir.ts +58 -0
- package/core/build/component/package-loader.ts +158 -12
- package/core/build/eject/plan-eject.ts +15 -21
- package/core/build/lsp/cross-file-diagnostics.cjs +82 -113
- package/core/build/lsp/extra-completion.cjs +14 -8
- package/core/build/lsp/lsp-navigation.cjs +50 -43
- package/core/build/lsp/soma-declaration.cjs +85 -0
- package/core/build/lsp/ui-yaml-completion.cjs +98 -104
- package/core/build/v2/block-compile.ts +200 -0
- package/core/build/v2/block-loader.ts +33 -0
- package/core/build/v2/html-index.ts +120 -0
- package/core/build/v2/migrate-v1.ts +370 -0
- package/core/build/v2/soma-file-loader.ts +216 -0
- package/core/client/component/ai-catalog.ts +15 -0
- package/core/client/component/component-pack.ts +205 -31
- package/core/client/component/contract-compat.ts +132 -0
- package/core/client/component/example-v2.ts +132 -0
- package/core/client/engine/dom-renderer.ts +14 -8
- package/core/client/engine/reactive-proxy.ts +8 -7
- package/core/client/engine/soma-bootstrap.ts +23 -5
- package/core/client/parser/v2/namespace.ts +182 -0
- package/core/client/parser/v2/page-parser.ts +359 -0
- package/core/client/parser/v2/use-parser.ts +412 -0
- package/core/client/parser/value-lang.ts +340 -0
- package/core/client/pipes/pipe-registry.ts +1 -1
- package/core/client/registry/declaration-renderer.ts +17 -15
- package/core/client/theme/harmony.ts +307 -0
- package/core/client/theme/scene-tokens.ts +134 -0
- package/core/client/theme/theme-axes.ts +228 -0
- package/core/client/theme/theme-engine.ts +333 -73
- package/core/client/theme/tone-solver.ts +118 -0
- package/core/index.ts +74 -2
- package/core/server/host/server-page-assets.ts +33 -16
- package/core/server/host/soma-page-compile.ts +33 -0
- package/core/server/index.ts +15 -0
- package/core/server/registry/declaration-precompiler.ts +24 -54
- package/core/server/registry/page-registry-store.ts +38 -9
- package/core/server/registry/services/pages/Get.ts +19 -9
- package/core/server/registry/validation/compile-gate.ts +14 -31
- package/core/server/registry/validation/cross-check.ts +7 -17
- package/core/server/registry/validation/declaration-safety-scan.ts +2 -2
- package/core/shared/types/component-contract.types.ts +10 -0
- package/dist/core/index.cjs +2138 -154
- package/dist/types/build/compiler/full-manifest-builder.d.ts +4 -4
- package/dist/types/build/compiler/html-include-expander.d.ts +19 -0
- package/dist/types/build/compiler/page-assets.d.ts +3 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +33 -0
- package/dist/types/build/compiler/rollup-plugin-soma.d.ts +0 -3
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/compiler/soma-precompile.d.ts +8 -0
- package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -10
- package/dist/types/build/component/pack-from-dir.d.ts +17 -0
- package/dist/types/build/component/package-loader.d.ts +33 -2
- package/dist/types/build/v2/block-compile.d.ts +28 -0
- package/dist/types/build/v2/block-loader.d.ts +9 -0
- package/dist/types/build/v2/html-index.d.ts +37 -0
- package/dist/types/build/v2/migrate-v1.d.ts +32 -0
- package/dist/types/build/v2/soma-file-loader.d.ts +45 -0
- package/dist/types/client/component/component-pack.d.ts +23 -3
- package/dist/types/client/component/contract-compat.d.ts +16 -0
- package/dist/types/client/component/example-v2.d.ts +9 -0
- package/dist/types/client/engine/dom-renderer.d.ts +2 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +3 -1
- package/dist/types/client/parser/v2/namespace.d.ts +52 -0
- package/dist/types/client/parser/v2/page-parser.d.ts +21 -0
- package/dist/types/client/parser/v2/use-parser.d.ts +72 -0
- package/dist/types/client/parser/value-lang.d.ts +63 -0
- package/dist/types/client/registry/declaration-renderer.d.ts +1 -2
- package/dist/types/client/theme/harmony.d.ts +77 -0
- package/dist/types/client/theme/scene-tokens.d.ts +25 -0
- package/dist/types/client/theme/theme-axes.d.ts +81 -0
- package/dist/types/client/theme/theme-engine.d.ts +29 -1
- package/dist/types/client/theme/tone-solver.d.ts +47 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/server/host/server-page-assets.d.ts +1 -4
- package/dist/types/server/host/soma-page-compile.d.ts +7 -0
- package/dist/types/server/index.d.ts +3 -1
- package/dist/types/server/registry/declaration-precompiler.d.ts +3 -3
- package/dist/types/server/registry/page-registry-store.d.ts +4 -4
- package/dist/types/server/registry/validation/compile-gate.d.ts +2 -0
- package/dist/types/server/registry/validation/cross-check.d.ts +4 -4
- package/dist/types/shared/types/component-contract.types.d.ts +10 -0
- package/editor/vscode/package.json +1 -24
- package/global.d.ts +1 -11
- package/next.config.js +32 -50
- package/package.json +3 -2
- package/tailwind.config.ts +0 -1
- package/core/build/lsp/event-yaml-completion.cjs +0 -106
- package/core/client/host-bridge/empty-host/data/README.md +0 -17
- package/editor/vscode/syntaxes/soma-event-yaml.tmLanguage.json +0 -30
package/dist/core/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
Locale: () => Locale,
|
|
36
36
|
MiniProgramContainerAdapter: () => MiniProgramContainerAdapter,
|
|
37
37
|
PACK_NAME_PATTERN: () => PACK_NAME_PATTERN,
|
|
38
|
+
PAGE_BLOCK_ID: () => PAGE_BLOCK_ID,
|
|
38
39
|
Page: () => Page,
|
|
39
40
|
ReactNativeContainerAdapter: () => ReactNativeContainerAdapter,
|
|
40
41
|
SOMA_ADAPTIVE_MAX_LADDER: () => SOMA_ADAPTIVE_MAX_LADDER,
|
|
@@ -64,8 +65,11 @@ __export(index_exports, {
|
|
|
64
65
|
SomaPipeRegistry: () => SomaPipeRegistry,
|
|
65
66
|
SomaQualityRegistry: () => SomaQualityRegistry,
|
|
66
67
|
SomaRealtimeService: () => SomaRealtimeService,
|
|
68
|
+
SomaScopeError: () => SomaScopeError,
|
|
67
69
|
SomaTelemetry: () => SomaTelemetry,
|
|
70
|
+
SomaV2ParseError: () => SomaV2ParseError,
|
|
68
71
|
SomaValidator: () => SomaValidator,
|
|
72
|
+
SomaValueLangError: () => SomaValueLangError,
|
|
69
73
|
SseRealtimeTransport: () => SseRealtimeTransport,
|
|
70
74
|
THEME_SWITCHING_CLASS: () => THEME_SWITCHING_CLASS,
|
|
71
75
|
TYPOGRAPHY_BASE_CSS: () => TYPOGRAPHY_BASE_CSS,
|
|
@@ -74,8 +78,13 @@ __export(index_exports, {
|
|
|
74
78
|
applyLocaleMetadata: () => applyLocaleMetadata,
|
|
75
79
|
applyTheme: () => applyTheme,
|
|
76
80
|
attachPackStyles: () => attachPackStyles,
|
|
81
|
+
buildBlockScope: () => buildBlockScope,
|
|
77
82
|
buildCatalogEntry: () => buildCatalogEntry,
|
|
83
|
+
buildHtmlAnchorIndex: () => buildHtmlAnchorIndex,
|
|
84
|
+
checkOverrideCompat: () => checkOverrideCompat,
|
|
78
85
|
compileAdaptive: () => compileAdaptive,
|
|
86
|
+
compilePageAssets: () => compilePageAssets,
|
|
87
|
+
compileSomaV2: () => compileSomaV2,
|
|
79
88
|
composeComponentPacks: () => composeComponentPacks,
|
|
80
89
|
contrastRatio: () => contrastRatio,
|
|
81
90
|
createAdaptiveObserverPool: () => createAdaptiveObserverPool,
|
|
@@ -87,8 +96,11 @@ __export(index_exports, {
|
|
|
87
96
|
createSomaPageLifecycle: () => createSomaPageLifecycle,
|
|
88
97
|
defaultPipeRegistry: () => defaultPipeRegistry,
|
|
89
98
|
deriveTheme: () => deriveTheme,
|
|
99
|
+
describeNode: () => describeNode,
|
|
90
100
|
ensurePackBaseStyles: () => ensurePackBaseStyles,
|
|
91
101
|
escapeSomaHtml: () => escapeSomaHtml,
|
|
102
|
+
evaluateValueNode: () => evaluateValueNode,
|
|
103
|
+
expandPath: () => expandPath,
|
|
92
104
|
extractConfigFromDomainClass: () => extractConfigFromDomainClass,
|
|
93
105
|
findNestedMutableContractDefault: () => findNestedMutableContractDefault,
|
|
94
106
|
findSomaDomainLoader: () => findSomaDomainLoader,
|
|
@@ -102,10 +114,13 @@ __export(index_exports, {
|
|
|
102
114
|
hasBlockedScheme: () => hasBlockedScheme,
|
|
103
115
|
hasPageMetadata: () => hasPageMetadata,
|
|
104
116
|
installSomaErrorReporter: () => installSomaErrorReporter,
|
|
117
|
+
isArithSegment: () => isArithSegment,
|
|
105
118
|
isBootTimingsEnabled: () => isBootTimingsEnabled,
|
|
106
119
|
isEventHandlerAttribute: () => isEventHandlerAttribute,
|
|
120
|
+
isPlainPath: () => isPlainPath,
|
|
107
121
|
isSomaMockEnabled: () => isSomaMockEnabled,
|
|
108
122
|
loadSomaDomainModuleFromRegistry: () => loadSomaDomainModuleFromRegistry,
|
|
123
|
+
loadSomaFile: () => loadSomaFile,
|
|
109
124
|
markBootPhase: () => markBootPhase,
|
|
110
125
|
matchGlobPath: () => matchGlobPath,
|
|
111
126
|
maybeStartBootTimings: () => maybeStartBootTimings,
|
|
@@ -114,22 +129,29 @@ __export(index_exports, {
|
|
|
114
129
|
parseDataConfig: () => parseDataConfig,
|
|
115
130
|
parseDataRef: () => parseDataRef,
|
|
116
131
|
parseDataYaml: () => parseDataYaml,
|
|
132
|
+
parsePageBlock: () => parsePageBlock,
|
|
133
|
+
parseUseBlock: () => parseUseBlock,
|
|
134
|
+
parseValueSegment: () => parseValueSegment,
|
|
117
135
|
readBootTimings: () => readBootTimings,
|
|
118
136
|
recordMetric: () => recordMetric,
|
|
119
137
|
renderPublishedPage: () => renderPublishedPage,
|
|
120
138
|
resetBootTimings: () => resetBootTimings,
|
|
121
139
|
resetPackStyleInjection: () => resetPackStyleInjection,
|
|
140
|
+
resolveApiRef: () => resolveApiRef,
|
|
122
141
|
resolveHostBootstrapOptions: () => resolveHostBootstrapOptions,
|
|
142
|
+
resolvePath: () => resolvePath,
|
|
123
143
|
resolveSomaHtmlSanitizer: () => resolveSomaHtmlSanitizer,
|
|
124
144
|
resolveTierWithHysteresis: () => resolveTierWithHysteresis,
|
|
125
145
|
runAsync: () => runAsync,
|
|
126
146
|
sanitizeAttributeWrite: () => sanitizeAttributeWrite,
|
|
127
147
|
sanitizeSomaHtml: () => sanitizeSomaHtml,
|
|
128
148
|
scheduleAdaptiveFlush: () => scheduleAdaptiveFlush,
|
|
149
|
+
scopeHasVar: () => scopeHasVar,
|
|
129
150
|
setActiveTelemetry: () => setActiveTelemetry,
|
|
130
151
|
setSomaHtmlSanitizer: () => setSomaHtmlSanitizer,
|
|
131
152
|
somaRollupPlugin: () => somaRollupPlugin,
|
|
132
153
|
startBootTimings: () => startBootTimings,
|
|
154
|
+
themeRootAttributes: () => themeRootAttributes,
|
|
133
155
|
verifyComponentPack: () => verifyComponentPack
|
|
134
156
|
});
|
|
135
157
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -4466,7 +4488,7 @@ function requireDumper() {
|
|
|
4466
4488
|
}
|
|
4467
4489
|
}
|
|
4468
4490
|
}
|
|
4469
|
-
function
|
|
4491
|
+
function dump22(input, options) {
|
|
4470
4492
|
options = options || {};
|
|
4471
4493
|
const state2 = new State(options);
|
|
4472
4494
|
if (!state2.noRefs) getDuplicateReferences(input, state2);
|
|
@@ -4477,7 +4499,7 @@ function requireDumper() {
|
|
|
4477
4499
|
if (writeNode(state2, 0, value, true, true)) return state2.dump + "\n";
|
|
4478
4500
|
return "";
|
|
4479
4501
|
}
|
|
4480
|
-
dumper.dump =
|
|
4502
|
+
dumper.dump = dump22;
|
|
4481
4503
|
return dumper;
|
|
4482
4504
|
}
|
|
4483
4505
|
var hasRequiredJsYaml;
|
|
@@ -5865,8 +5887,8 @@ var SomaReactiveProxy = class {
|
|
|
5865
5887
|
const self = this;
|
|
5866
5888
|
return {
|
|
5867
5889
|
get(target, prop, receiver) {
|
|
5868
|
-
if (typeof prop === "symbol") return Reflect.get(target, prop,
|
|
5869
|
-
const value = Reflect.get(target, prop,
|
|
5890
|
+
if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
|
|
5891
|
+
const value = Reflect.get(target, prop, receiver);
|
|
5870
5892
|
if (prop === "_services" || prop === "_config") {
|
|
5871
5893
|
return value;
|
|
5872
5894
|
}
|
|
@@ -5889,14 +5911,15 @@ var SomaReactiveProxy = class {
|
|
|
5889
5911
|
}
|
|
5890
5912
|
return value;
|
|
5891
5913
|
},
|
|
5892
|
-
set(target, prop, value) {
|
|
5914
|
+
set(target, prop, value, receiver) {
|
|
5893
5915
|
const key = String(prop);
|
|
5894
5916
|
const path = basePath ? `${basePath}.${key}` : key;
|
|
5895
|
-
const oldValue = target
|
|
5917
|
+
const oldValue = Reflect.get(target, prop, receiver);
|
|
5896
5918
|
if (oldValue != null && typeof oldValue === "object") {
|
|
5897
5919
|
self.childProxyCache.delete(oldValue);
|
|
5898
5920
|
}
|
|
5899
|
-
target
|
|
5921
|
+
const assigned = Reflect.set(target, prop, value, receiver);
|
|
5922
|
+
if (!assigned) return false;
|
|
5900
5923
|
try {
|
|
5901
5924
|
self.diagnostics?.recordMutation(path, value);
|
|
5902
5925
|
if (self.batchDepth > 0) {
|
|
@@ -7238,6 +7261,15 @@ var SomaDomRenderer = class {
|
|
|
7238
7261
|
setModelWriteBack(fn) {
|
|
7239
7262
|
this.modelWriteBack = fn;
|
|
7240
7263
|
}
|
|
7264
|
+
/** 模型回写必须在绑定表创建时附着,不能依赖首帧渲染是否走到该项。 */
|
|
7265
|
+
ensureModelListener(element, dataPath) {
|
|
7266
|
+
if (!this.adapter || !this.modelWriteBack || this.modelListeners.has(element)) return;
|
|
7267
|
+
this.modelListeners.add(element);
|
|
7268
|
+
const writeModel = () => this.modelWriteBack?.(dataPath, this.adapter.getValue(element));
|
|
7269
|
+
for (const eventType of ["input", "change", "blur"]) {
|
|
7270
|
+
this.adapter.listen(element, eventType, writeModel, this.modelAbort.signal);
|
|
7271
|
+
}
|
|
7272
|
+
}
|
|
7241
7273
|
bindEntry(binding, container) {
|
|
7242
7274
|
if (!this.adapter) {
|
|
7243
7275
|
return null;
|
|
@@ -7262,6 +7294,9 @@ var SomaDomRenderer = class {
|
|
|
7262
7294
|
pipes: binding.pipes
|
|
7263
7295
|
};
|
|
7264
7296
|
entry.compiledRender = this.compileRenderFn(entry);
|
|
7297
|
+
if (entry.type === "model") {
|
|
7298
|
+
this.ensureModelListener(entry.element, entry.dataPath);
|
|
7299
|
+
}
|
|
7265
7300
|
return entry;
|
|
7266
7301
|
}
|
|
7267
7302
|
/**
|
|
@@ -7309,7 +7344,6 @@ var SomaDomRenderer = class {
|
|
|
7309
7344
|
const modelAdapter = adapter;
|
|
7310
7345
|
const modelListeners = this.modelListeners;
|
|
7311
7346
|
const modelWriteBack = this.modelWriteBack;
|
|
7312
|
-
const modelAbort = this.modelAbort;
|
|
7313
7347
|
const dataPath = entry.dataPath;
|
|
7314
7348
|
const self = this;
|
|
7315
7349
|
return (v) => {
|
|
@@ -7318,13 +7352,7 @@ var SomaDomRenderer = class {
|
|
|
7318
7352
|
modelAdapter.setValue(modelEl, strValue);
|
|
7319
7353
|
}
|
|
7320
7354
|
if (modelWriteBack && !modelListeners.has(modelEl)) {
|
|
7321
|
-
|
|
7322
|
-
const writeModel = () => {
|
|
7323
|
-
modelWriteBack(dataPath, modelAdapter.getValue(modelEl));
|
|
7324
|
-
};
|
|
7325
|
-
for (const eventType of ["input", "change", "blur"]) {
|
|
7326
|
-
modelAdapter.listen(modelEl, eventType, writeModel, modelAbort.signal);
|
|
7327
|
-
}
|
|
7355
|
+
self.ensureModelListener(modelEl, dataPath);
|
|
7328
7356
|
}
|
|
7329
7357
|
};
|
|
7330
7358
|
}
|
|
@@ -11294,6 +11322,292 @@ function isNested(value) {
|
|
|
11294
11322
|
return typeof value === "object" && value !== null && "bind" in value && "show" in value;
|
|
11295
11323
|
}
|
|
11296
11324
|
|
|
11325
|
+
// core/client/theme/theme-axes.ts
|
|
11326
|
+
var SomaThemeAxisError = class extends Error {
|
|
11327
|
+
constructor(message) {
|
|
11328
|
+
super(`[soma-core][\u4E3B\u9898] ${message}`);
|
|
11329
|
+
this.name = "SomaThemeAxisError";
|
|
11330
|
+
}
|
|
11331
|
+
};
|
|
11332
|
+
var HARMONY_K = {
|
|
11333
|
+
functional: 0,
|
|
11334
|
+
analogous: 0.72,
|
|
11335
|
+
monochrome: 1,
|
|
11336
|
+
complementary: 0.72
|
|
11337
|
+
};
|
|
11338
|
+
var CHROMA_MUL = {
|
|
11339
|
+
muted: 0.6,
|
|
11340
|
+
balanced: 1,
|
|
11341
|
+
vivid: 1.35
|
|
11342
|
+
};
|
|
11343
|
+
var CONTRAST_TARGETS = {
|
|
11344
|
+
soft: { toneOnPage: 3.2, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
11345
|
+
standard: { toneOnPage: 4, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
11346
|
+
strong: { toneOnPage: 5.5, fgOnTone: 7, textOnPage: 7 }
|
|
11347
|
+
};
|
|
11348
|
+
var DARK_CONTRAST_TARGETS = {
|
|
11349
|
+
soft: { toneOnPage: 3, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
11350
|
+
standard: { toneOnPage: 3.6, fgOnTone: 4.5, textOnPage: 4.5 },
|
|
11351
|
+
strong: { toneOnPage: 5, fgOnTone: 7, textOnPage: 7 }
|
|
11352
|
+
};
|
|
11353
|
+
var SOFT_LIGHTNESS_BAND = [0.7, 0.86];
|
|
11354
|
+
var FIELD_ALPHAS = {
|
|
11355
|
+
tinted: [0.18, 0.12, 0.1],
|
|
11356
|
+
aurora: [0.42, 0.28, 0.26]
|
|
11357
|
+
};
|
|
11358
|
+
var INTENSITY_MUL = {
|
|
11359
|
+
whisper: 0.45,
|
|
11360
|
+
soft: 1,
|
|
11361
|
+
bold: 1.35
|
|
11362
|
+
};
|
|
11363
|
+
var HEX_SHAPE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
11364
|
+
var MAX_ACCENTS = 3;
|
|
11365
|
+
function resolveAxes(input) {
|
|
11366
|
+
const p = input.palette ?? {};
|
|
11367
|
+
const s = input.scene ?? {};
|
|
11368
|
+
const accents = p.accents ?? [];
|
|
11369
|
+
if (accents.length > MAX_ACCENTS) {
|
|
11370
|
+
throw new SomaThemeAxisError(
|
|
11371
|
+
`accents \u6700\u591A ${MAX_ACCENTS} \u4E2A\uFF08\u4F9D\u6B21\u9501 secondary/accent/info \u7684\u8272\u76F8\u951A\uFF09\uFF0C\u6536\u5230 ${accents.length} \u4E2A\u3002\u8981\u7CBE\u8C03\u66F4\u591A\u989C\u8272\u8BF7\u8D70 overrides \u9010\u4EE4\u724C\u901A\u9053\u3002`
|
|
11372
|
+
);
|
|
11373
|
+
}
|
|
11374
|
+
for (const hex of accents) {
|
|
11375
|
+
if (!HEX_SHAPE.test(hex)) {
|
|
11376
|
+
throw new SomaThemeAxisError(`accents \u91CC\u7684 "${hex}" \u4E0D\u662F\u5408\u6CD5\u989C\u8272\uFF08#rgb \u6216 #rrggbb\uFF09`);
|
|
11377
|
+
}
|
|
11378
|
+
}
|
|
11379
|
+
const axes = {
|
|
11380
|
+
palette: {
|
|
11381
|
+
harmony: p.harmony ?? "functional",
|
|
11382
|
+
semantics: p.semantics ?? "faithful",
|
|
11383
|
+
chroma: p.chroma ?? "balanced",
|
|
11384
|
+
contrast: p.contrast ?? "standard",
|
|
11385
|
+
accents
|
|
11386
|
+
},
|
|
11387
|
+
scene: {
|
|
11388
|
+
// 缺省是 aurora/soft 而不是 flat:**今天的引擎产出的就是这一档的值**
|
|
11389
|
+
// (G1 的 `hexWithAlpha(scale300, .42)` 等三行),缺省若给 flat 就等于
|
|
11390
|
+
// 把存量页面的 .soma-ambient 类清零——那是破坏,不是收编。
|
|
11391
|
+
// flat 因此是一个**显式的退出档**:主题明说"这一页不要场"。
|
|
11392
|
+
field: s.field ?? "aurora",
|
|
11393
|
+
intensity: s.intensity ?? "soft",
|
|
11394
|
+
material: s.material ?? "solid"
|
|
11395
|
+
}
|
|
11396
|
+
};
|
|
11397
|
+
const { harmony, chroma, contrast, field, intensity, semantics } = {
|
|
11398
|
+
...axes.palette,
|
|
11399
|
+
...axes.scene
|
|
11400
|
+
};
|
|
11401
|
+
const alphas = field === "flat" ? null : FIELD_ALPHAS[field].map((a) => a * INTENSITY_MUL[intensity]);
|
|
11402
|
+
return {
|
|
11403
|
+
axes,
|
|
11404
|
+
params: {
|
|
11405
|
+
harmonyK: HARMONY_K[harmony],
|
|
11406
|
+
accentComplement: harmony === "complementary",
|
|
11407
|
+
chromaMul: CHROMA_MUL[chroma],
|
|
11408
|
+
targets: CONTRAST_TARGETS[contrast],
|
|
11409
|
+
darkTargets: DARK_CONTRAST_TARGETS[contrast],
|
|
11410
|
+
softLightnessBand: contrast === "soft" ? SOFT_LIGHTNESS_BAND : null,
|
|
11411
|
+
fieldAlphas: alphas,
|
|
11412
|
+
glassEnabled: axes.scene.material === "glass",
|
|
11413
|
+
signalEnabled: semantics === "immersive"
|
|
11414
|
+
}
|
|
11415
|
+
};
|
|
11416
|
+
}
|
|
11417
|
+
|
|
11418
|
+
// core/client/theme/harmony.ts
|
|
11419
|
+
var FUNCTIONAL_HUES = { info: 230, success: 150, warning: 75, danger: 27 };
|
|
11420
|
+
var EXPRESSIVE_OFFSETS = { secondary: 48, accent: 160 };
|
|
11421
|
+
var SEPARATION_THRESHOLD = { hue: 30, lightness: 0.12 };
|
|
11422
|
+
var SEMANTIC_ZONES = {
|
|
11423
|
+
danger: [12, 45],
|
|
11424
|
+
warning: [58, 100],
|
|
11425
|
+
success: [125, 178]
|
|
11426
|
+
};
|
|
11427
|
+
var PUSH_MARGIN = 1.15;
|
|
11428
|
+
var TINTED_MIN_SEPARATION = 40;
|
|
11429
|
+
var PUSH_STEP = 6;
|
|
11430
|
+
var PUSH_MAX = 16;
|
|
11431
|
+
var LADDER_BANDWIDTH = 120;
|
|
11432
|
+
function angDiff(a, b) {
|
|
11433
|
+
let d = (a - b) % 360;
|
|
11434
|
+
if (d > 180) d -= 360;
|
|
11435
|
+
if (d <= -180) d += 360;
|
|
11436
|
+
return d;
|
|
11437
|
+
}
|
|
11438
|
+
function norm(h) {
|
|
11439
|
+
return (h % 360 + 360) % 360;
|
|
11440
|
+
}
|
|
11441
|
+
function compress(hue, brandHue, k) {
|
|
11442
|
+
return norm(brandHue + angDiff(hue, brandHue) * (1 - k));
|
|
11443
|
+
}
|
|
11444
|
+
function resolveHueAnchors(brandHue, axes, params, accentHues = []) {
|
|
11445
|
+
const { harmonyK, accentComplement } = params;
|
|
11446
|
+
const { semantics } = axes.palette;
|
|
11447
|
+
const secondarySeed = norm(brandHue + EXPRESSIVE_OFFSETS.secondary);
|
|
11448
|
+
const accentSeed = accentComplement ? norm(brandHue + 180) : norm(brandHue + EXPRESSIVE_OFFSETS.accent);
|
|
11449
|
+
const tones = {
|
|
11450
|
+
primary: brandHue,
|
|
11451
|
+
secondary: accentHues[0] ?? compress(secondarySeed, brandHue, harmonyK),
|
|
11452
|
+
accent: accentHues[1] ?? (accentComplement ? accentSeed : compress(accentSeed, brandHue, harmonyK)),
|
|
11453
|
+
info: accentHues[2] ?? compress(FUNCTIONAL_HUES.info, brandHue, harmonyK),
|
|
11454
|
+
success: semanticHue(FUNCTIONAL_HUES.success, brandHue, harmonyK, semantics),
|
|
11455
|
+
warning: semanticHue(FUNCTIONAL_HUES.warning, brandHue, harmonyK, semantics),
|
|
11456
|
+
danger: semanticHue(FUNCTIONAL_HUES.danger, brandHue, harmonyK, semantics)
|
|
11457
|
+
};
|
|
11458
|
+
const bandwidth = hueBandwidth(Object.values(tones));
|
|
11459
|
+
return {
|
|
11460
|
+
tones,
|
|
11461
|
+
chart: chartAnchors(brandHue, bandwidth),
|
|
11462
|
+
chartLightnessLadder: bandwidth < LADDER_BANDWIDTH
|
|
11463
|
+
};
|
|
11464
|
+
}
|
|
11465
|
+
function semanticHue(functional, brandHue, k, semantics) {
|
|
11466
|
+
if (semantics === "faithful") return functional;
|
|
11467
|
+
const compressed = compress(functional, brandHue, k);
|
|
11468
|
+
if (semantics === "immersive") return compressed;
|
|
11469
|
+
const gap = Math.abs(angDiff(compressed, brandHue));
|
|
11470
|
+
if (gap >= TINTED_MIN_SEPARATION) return compressed;
|
|
11471
|
+
const away = angDiff(compressed, brandHue) >= 0 ? 1 : -1;
|
|
11472
|
+
return norm(brandHue + away * TINTED_MIN_SEPARATION);
|
|
11473
|
+
}
|
|
11474
|
+
function hueBandwidth(hues) {
|
|
11475
|
+
const sorted = [...hues].map(norm).sort((a, b) => a - b);
|
|
11476
|
+
if (sorted.length <= 1) return 0;
|
|
11477
|
+
let widestGap = sorted[0] + 360 - sorted[sorted.length - 1];
|
|
11478
|
+
for (let i = 1; i < sorted.length; i += 1) {
|
|
11479
|
+
widestGap = Math.max(widestGap, sorted[i] - sorted[i - 1]);
|
|
11480
|
+
}
|
|
11481
|
+
return 360 - widestGap;
|
|
11482
|
+
}
|
|
11483
|
+
function chartAnchors(brandHue, bandwidth) {
|
|
11484
|
+
const span = bandwidth < 1 ? 0 : Math.min(bandwidth, 360);
|
|
11485
|
+
const start = norm(brandHue - span / 2);
|
|
11486
|
+
return Array.from({ length: 8 }, (_, i) => norm(start + span * i / 8));
|
|
11487
|
+
}
|
|
11488
|
+
function applySeparationGuard(anchors, brandHue, brandLightness, toneLightness, semantics) {
|
|
11489
|
+
if (semantics === "immersive") {
|
|
11490
|
+
return { anchors, applied: false, pushed: [], lightnessSeparation: {} };
|
|
11491
|
+
}
|
|
11492
|
+
const pushed = [];
|
|
11493
|
+
const lightnessSeparation = {};
|
|
11494
|
+
const tones = { ...anchors.tones };
|
|
11495
|
+
for (const tone of ["success", "warning", "danger"]) {
|
|
11496
|
+
const hueGap = Math.abs(angDiff(tones[tone], brandHue));
|
|
11497
|
+
const lightGap = Math.abs((toneLightness[tone] ?? 0) - brandLightness);
|
|
11498
|
+
const hueBar = SEPARATION_THRESHOLD.hue * PUSH_MARGIN;
|
|
11499
|
+
const lightBar = SEPARATION_THRESHOLD.lightness * PUSH_MARGIN;
|
|
11500
|
+
if (hueGap >= hueBar || lightGap >= lightBar) continue;
|
|
11501
|
+
const siblings = ["success", "warning", "danger"].filter((other) => other !== tone).map((other) => tones[other]);
|
|
11502
|
+
const scoreOf = (hue) => Math.min(
|
|
11503
|
+
Math.abs(angDiff(hue, brandHue)),
|
|
11504
|
+
...siblings.map((sibling) => Math.abs(angDiff(hue, sibling)))
|
|
11505
|
+
);
|
|
11506
|
+
const [zoneLow, zoneHigh] = SEMANTIC_ZONES[tone];
|
|
11507
|
+
const inZone = (hue) => {
|
|
11508
|
+
const h = norm(hue);
|
|
11509
|
+
return zoneLow <= zoneHigh ? h >= zoneLow && h <= zoneHigh : h >= zoneLow || h <= zoneHigh;
|
|
11510
|
+
};
|
|
11511
|
+
const target = SEPARATION_THRESHOLD.hue * PUSH_MARGIN;
|
|
11512
|
+
const candidateFor = (direction) => {
|
|
11513
|
+
let hue = tones[tone];
|
|
11514
|
+
for (let i = 0; i < PUSH_MAX; i += 1) {
|
|
11515
|
+
if (Math.abs(angDiff(hue, brandHue)) >= target) return hue;
|
|
11516
|
+
const next = norm(hue + direction * PUSH_STEP);
|
|
11517
|
+
if (!inZone(next)) return null;
|
|
11518
|
+
hue = next;
|
|
11519
|
+
}
|
|
11520
|
+
return Math.abs(angDiff(hue, brandHue)) >= target ? hue : null;
|
|
11521
|
+
};
|
|
11522
|
+
const candidates = [candidateFor(1), candidateFor(-1)].filter((hue) => hue !== null);
|
|
11523
|
+
if (candidates.length === 0) {
|
|
11524
|
+
const direction = (toneLightness[tone] ?? 0) >= brandLightness ? 1 : -1;
|
|
11525
|
+
lightnessSeparation[tone] = { direction, minGap: SEPARATION_THRESHOLD.lightness };
|
|
11526
|
+
pushed.push(tone);
|
|
11527
|
+
continue;
|
|
11528
|
+
}
|
|
11529
|
+
candidates.sort((a, b) => scoreOf(b) - scoreOf(a));
|
|
11530
|
+
tones[tone] = candidates[0];
|
|
11531
|
+
pushed.push(tone);
|
|
11532
|
+
}
|
|
11533
|
+
if (pushed.length === 0) {
|
|
11534
|
+
return { anchors, applied: false, pushed: [], lightnessSeparation: {} };
|
|
11535
|
+
}
|
|
11536
|
+
const bandwidth = hueBandwidth(Object.values(tones));
|
|
11537
|
+
return {
|
|
11538
|
+
anchors: {
|
|
11539
|
+
tones,
|
|
11540
|
+
chart: chartAnchors(brandHue, bandwidth),
|
|
11541
|
+
chartLightnessLadder: bandwidth < LADDER_BANDWIDTH
|
|
11542
|
+
},
|
|
11543
|
+
applied: true,
|
|
11544
|
+
pushed,
|
|
11545
|
+
lightnessSeparation
|
|
11546
|
+
};
|
|
11547
|
+
}
|
|
11548
|
+
|
|
11549
|
+
// core/client/theme/tone-solver.ts
|
|
11550
|
+
var MAX_SOLVE_ITER = 16;
|
|
11551
|
+
var STEP = 0.04;
|
|
11552
|
+
function ensureContrast(bg, deps, minRatio = 4.5, maxIter = MAX_SOLVE_ITER, forceDirection) {
|
|
11553
|
+
let current = bg;
|
|
11554
|
+
let fg = deps.bestFg(current);
|
|
11555
|
+
for (let i = 0; i < maxIter && deps.contrastRatio(current, fg) < minRatio; i += 1) {
|
|
11556
|
+
const cur = deps.hexToOklch(current);
|
|
11557
|
+
const lighten = forceDirection ? forceDirection === "lighten" : cur.l > 0.55;
|
|
11558
|
+
current = deps.oklchToHex({ ...cur, l: lighten ? cur.l + STEP : cur.l - STEP });
|
|
11559
|
+
fg = deps.bestFg(current);
|
|
11560
|
+
}
|
|
11561
|
+
return { bg: current, fg };
|
|
11562
|
+
}
|
|
11563
|
+
|
|
11564
|
+
// core/client/theme/scene-tokens.ts
|
|
11565
|
+
var SIGNAL_IDLE = {
|
|
11566
|
+
"--soma-signal-edge": "none",
|
|
11567
|
+
"--soma-signal-glow": "none",
|
|
11568
|
+
"--soma-signal-pulse-duration": "0s",
|
|
11569
|
+
"--soma-signal-pulse-duration-calm": "0s",
|
|
11570
|
+
"--soma-signal-edge-duration": "0s"
|
|
11571
|
+
};
|
|
11572
|
+
var SIGNAL_DURATIONS = { urgent: "2.8s", calm: "4.9s", edge: "2.4s" };
|
|
11573
|
+
var AMBIENT_DURATION = "12s";
|
|
11574
|
+
function sceneStructureTokens(axes) {
|
|
11575
|
+
const signal = axes.palette.semantics === "immersive" ? {
|
|
11576
|
+
...SIGNAL_IDLE,
|
|
11577
|
+
"--soma-signal-pulse-duration": SIGNAL_DURATIONS.urgent,
|
|
11578
|
+
"--soma-signal-pulse-duration-calm": SIGNAL_DURATIONS.calm,
|
|
11579
|
+
"--soma-signal-edge-duration": SIGNAL_DURATIONS.edge
|
|
11580
|
+
} : { ...SIGNAL_IDLE };
|
|
11581
|
+
return {
|
|
11582
|
+
// 环境光球时长:motion 轴(soma-ui recipe)会覆盖它——
|
|
11583
|
+
// `motion: 'none'` 的主题里光球因此自动静止,与 prefers-reduced-motion
|
|
11584
|
+
// 走同一条退化路径,一份实现两个触发源
|
|
11585
|
+
"--soma-ambient-duration": AMBIENT_DURATION,
|
|
11586
|
+
...signal
|
|
11587
|
+
};
|
|
11588
|
+
}
|
|
11589
|
+
function sceneColorTokens(finalVars, axes, alphas, hexWithAlpha2, scale, rescale) {
|
|
11590
|
+
const out = {};
|
|
11591
|
+
if (!alphas) {
|
|
11592
|
+
out["--soma-ambient-1"] = "transparent";
|
|
11593
|
+
out["--soma-ambient-2"] = "transparent";
|
|
11594
|
+
out["--soma-ambient-3"] = "transparent";
|
|
11595
|
+
} else {
|
|
11596
|
+
const effective = rescale ? rescale(finalVars["--soma-c-primary"]) : scale;
|
|
11597
|
+
const seeds = [effective["300"], effective["500"], effective["400"]];
|
|
11598
|
+
seeds.forEach((seed, i) => {
|
|
11599
|
+
out[`--soma-ambient-${i + 1}`] = seed ? hexWithAlpha2(seed, alphas[i]) : "transparent";
|
|
11600
|
+
});
|
|
11601
|
+
}
|
|
11602
|
+
const tint = finalVars["--soma-c-primary"] ?? "#4f8cff";
|
|
11603
|
+
out["--soma-signal-tint"] = tint;
|
|
11604
|
+
if (axes.palette.semantics === "immersive") {
|
|
11605
|
+
out["--soma-signal-glow"] = `0 0 0 6px ${hexWithAlpha2(tint, 0.25)}`;
|
|
11606
|
+
out["--soma-signal-edge"] = `linear-gradient(90deg, transparent, ${hexWithAlpha2(tint, 0.86)}, transparent)`;
|
|
11607
|
+
}
|
|
11608
|
+
return out;
|
|
11609
|
+
}
|
|
11610
|
+
|
|
11297
11611
|
// core/client/theme/theme-engine.ts
|
|
11298
11612
|
function srgbToLinear(c) {
|
|
11299
11613
|
return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
@@ -11518,15 +11832,24 @@ function deriveOnSoftTokens(vars, dark) {
|
|
|
11518
11832
|
if (onSoftMemo.size >= ON_SOFT_MEMO_LIMIT) onSoftMemo.clear();
|
|
11519
11833
|
onSoftMemo.set(memoKey, SOFT_TONES.map((tone) => vars[`--soma-c-${tone}-on-soft`]));
|
|
11520
11834
|
}
|
|
11521
|
-
function chartSeries(hue, chroma, lightness) {
|
|
11522
|
-
const offsets = [0, 200, 130, 45, 275, 95, 320, 165];
|
|
11835
|
+
function chartSeries(hue, chroma, lightness, anchors) {
|
|
11523
11836
|
const vars = {};
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11837
|
+
if (anchors?.chartLightnessLadder) {
|
|
11838
|
+
const span = 0.34;
|
|
11839
|
+
const start = lightness - span / 2;
|
|
11840
|
+
anchors.chart.forEach((h, index) => {
|
|
11841
|
+
vars[`--soma-chart-${index + 1}`] = oklchToHex({
|
|
11842
|
+
l: Math.max(0.28, Math.min(0.88, start + span * index / 7)),
|
|
11843
|
+
c: chroma,
|
|
11844
|
+
h
|
|
11845
|
+
});
|
|
11529
11846
|
});
|
|
11847
|
+
return vars;
|
|
11848
|
+
}
|
|
11849
|
+
const offsets = [0, 200, 130, 45, 275, 95, 320, 165];
|
|
11850
|
+
const hues = anchors && anchors.chart.length === 8 ? anchors.chart : offsets.map((offset) => (hue + offset) % 360);
|
|
11851
|
+
hues.forEach((h, index) => {
|
|
11852
|
+
vars[`--soma-chart-${index + 1}`] = oklchToHex({ l: lightness, c: chroma, h });
|
|
11530
11853
|
});
|
|
11531
11854
|
return vars;
|
|
11532
11855
|
}
|
|
@@ -11583,6 +11906,16 @@ var STATIC_TOKENS = {
|
|
|
11583
11906
|
// 圆角:记名**不 rem 化**。圆角是描边级光学属性,跟着字号缩放会失真;
|
|
11584
11907
|
// `9999px` 是"胶囊"的语义值,缩放它没有意义。阴影偏移与 1px 描边同理。
|
|
11585
11908
|
// (radius-control/overlay 仍单列在语义组)
|
|
11909
|
+
// 材质档(REQ-006 G1):玻璃拟态需要的几何与模糊量。
|
|
11910
|
+
// 与既有 radius 同理不 rem 化——它们是描边级光学属性。
|
|
11911
|
+
"--soma-radius-plush": "22px",
|
|
11912
|
+
// 玻璃面的"厚实"圆角(参照实测 22~26px)
|
|
11913
|
+
"--soma-surface-blur": "18px",
|
|
11914
|
+
// backdrop-filter 模糊半径
|
|
11915
|
+
"--soma-surface-saturate": "140%",
|
|
11916
|
+
// 模糊同时提饱和,避免背景透上来发灰
|
|
11917
|
+
"--soma-lift-hover": "translateY(-2px)",
|
|
11918
|
+
// 悬停位移量(reduced-motion 下由组件退化)
|
|
11586
11919
|
"--soma-radius-none": "0px",
|
|
11587
11920
|
"--soma-radius-sm": "4px",
|
|
11588
11921
|
"--soma-radius-md": "8px",
|
|
@@ -11617,8 +11950,11 @@ var STATIC_TOKENS = {
|
|
|
11617
11950
|
var STEPS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
|
|
11618
11951
|
var LIGHTNESS = [0.985, 0.955, 0.91, 0.85, 0.78, 0.7, 0.62, 0.54, 0.46, 0.38, 0.3];
|
|
11619
11952
|
var CHROMA_CURVE = [0.14, 0.28, 0.48, 0.68, 0.85, 1, 1, 0.92, 0.8, 0.66, 0.52];
|
|
11953
|
+
var SOLVER_DEPS = { oklchToHex, hexToOklch, contrastRatio, bestFg };
|
|
11620
11954
|
function deriveTheme(input) {
|
|
11621
11955
|
const brand = hexToOklch(input.brand);
|
|
11956
|
+
const { axes, params } = resolveAxes(input);
|
|
11957
|
+
const accentHues = axes.palette.accents.map((hex) => hexToOklch(hex).h);
|
|
11622
11958
|
const brandSlot = nearestIndex(LIGHTNESS, brand.l);
|
|
11623
11959
|
const scale = {};
|
|
11624
11960
|
STEPS.forEach((step, i) => {
|
|
@@ -11631,75 +11967,128 @@ function deriveTheme(input) {
|
|
|
11631
11967
|
const primary = scale[STEPS[primaryIdx]];
|
|
11632
11968
|
const hover = oklchToHex({ ...hexToOklch(primary), l: hexToOklch(primary).l - 0.06 });
|
|
11633
11969
|
const active2 = oklchToHex({ ...hexToOklch(primary), l: hexToOklch(primary).l - 0.11 });
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
const
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
}
|
|
11970
|
+
const primarySolved = ensureContrast(primary, SOLVER_DEPS, params.targets.fgOnTone);
|
|
11971
|
+
const ensuredPrimary = primarySolved.bg;
|
|
11972
|
+
const fg = primarySolved.fg;
|
|
11973
|
+
const anchors0 = resolveHueAnchors(brand.h, axes, params, accentHues);
|
|
11974
|
+
const toneChroma = (mul) => Math.max(brand.c, 0.12) * mul * params.chromaMul;
|
|
11975
|
+
const banded = (l) => {
|
|
11976
|
+
const band = params.softLightnessBand;
|
|
11977
|
+
return band ? Math.min(band[1], Math.max(band[0], l)) : l;
|
|
11978
|
+
};
|
|
11979
|
+
const solveSemantics = (hues) => {
|
|
11980
|
+
const dangerHex = oklchToHex({ l: banded(0.6), c: toneChroma(0.95), h: hues.danger });
|
|
11981
|
+
return {
|
|
11982
|
+
danger: { bg: dangerHex, fg: "#ffffff", l: banded(0.6) },
|
|
11983
|
+
success: ensureContrast(oklchToHex({ l: banded(0.58), c: toneChroma(0.85), h: hues.success }), SOLVER_DEPS),
|
|
11984
|
+
warning: ensureContrast(oklchToHex({ l: banded(0.72), c: toneChroma(0.9), h: hues.warning }), SOLVER_DEPS)
|
|
11985
|
+
};
|
|
11986
|
+
};
|
|
11987
|
+
const firstPass = solveSemantics(anchors0.tones);
|
|
11988
|
+
const primaryFinal = hexToOklch(ensuredPrimary);
|
|
11989
|
+
const guard = applySeparationGuard(
|
|
11990
|
+
anchors0,
|
|
11991
|
+
primaryFinal.h,
|
|
11992
|
+
primaryFinal.l,
|
|
11993
|
+
{
|
|
11994
|
+
primary: primaryFinal.l,
|
|
11995
|
+
secondary: primaryFinal.l,
|
|
11996
|
+
accent: primaryFinal.l,
|
|
11997
|
+
info: 0.6,
|
|
11998
|
+
success: hexToOklch(firstPass.success.bg).l,
|
|
11999
|
+
warning: hexToOklch(firstPass.warning.bg).l,
|
|
12000
|
+
danger: firstPass.danger.l
|
|
12001
|
+
},
|
|
12002
|
+
axes.palette.semantics
|
|
12003
|
+
);
|
|
12004
|
+
const anchors = guard.anchors;
|
|
12005
|
+
const chartAnchorsOrNull = axes.palette.harmony === "functional" ? void 0 : anchors;
|
|
12006
|
+
const separatedL = (tone, base) => {
|
|
12007
|
+
const need = guard.lightnessSeparation[tone];
|
|
12008
|
+
if (!need) return base;
|
|
12009
|
+
const target = brand.l + need.direction * need.minGap * 1.15;
|
|
12010
|
+
return need.direction > 0 ? Math.max(base, target) : Math.min(base, target);
|
|
12011
|
+
};
|
|
12012
|
+
const clampSeparatedHex = (tone, hex) => {
|
|
12013
|
+
const need = guard.lightnessSeparation[tone];
|
|
12014
|
+
if (!need) return hex;
|
|
12015
|
+
const current = hexToOklch(hex);
|
|
12016
|
+
const floor = primaryFinal.l + need.direction * need.minGap * 1.15;
|
|
12017
|
+
const clamped = need.direction > 0 ? Math.max(current.l, floor) : Math.min(current.l, floor);
|
|
12018
|
+
return Math.abs(clamped - current.l) < 1e-6 ? hex : oklchToHex({ ...current, l: clamped });
|
|
12019
|
+
};
|
|
12020
|
+
const solveDir = (tone) => {
|
|
12021
|
+
const need = guard.lightnessSeparation[tone];
|
|
12022
|
+
return need ? need.direction > 0 ? "lighten" : "darken" : void 0;
|
|
12023
|
+
};
|
|
12024
|
+
const dangerSeed = oklchToHex({ l: separatedL("danger", banded(0.6)), c: toneChroma(0.95), h: anchors.tones.danger });
|
|
12025
|
+
const danger = clampSeparatedHex("danger", dangerSeed);
|
|
12026
|
+
const success = oklchToHex({ l: separatedL("success", banded(0.58)), c: toneChroma(0.85), h: anchors.tones.success });
|
|
12027
|
+
const warning = oklchToHex({ l: separatedL("warning", banded(0.72)), c: toneChroma(0.9), h: anchors.tones.warning });
|
|
12028
|
+
void firstPass;
|
|
12029
|
+
const infoSolved = ensureContrast(
|
|
12030
|
+
oklchToHex({ l: banded(0.6), c: toneChroma(0.9), h: anchors.tones.info }),
|
|
12031
|
+
SOLVER_DEPS
|
|
12032
|
+
);
|
|
12033
|
+
const info = infoSolved.bg;
|
|
12034
|
+
const infoFg = infoSolved.fg;
|
|
11651
12035
|
const ensureBrandTone = (seed) => {
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
for (let i = 0; i < 16 && contrastRatio(bg, toneFg) < 4.5; i++) {
|
|
11655
|
-
const cur = hexToOklch(bg);
|
|
11656
|
-
bg = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
11657
|
-
toneFg = bestFg(bg);
|
|
11658
|
-
}
|
|
11659
|
-
return { bg, fg: toneFg, soft: hexWithAlpha(bg, 0.12) };
|
|
12036
|
+
const solved = ensureContrast(oklchToHex(seed), SOLVER_DEPS);
|
|
12037
|
+
return { bg: solved.bg, fg: solved.fg, soft: hexWithAlpha(solved.bg, 0.12) };
|
|
11660
12038
|
};
|
|
11661
12039
|
const secondaryTone = ensureBrandTone({
|
|
11662
|
-
l: Math.min(0.72, Math.max(0.45, brand.l + 0.04)),
|
|
11663
|
-
c: Math.max(brand.c, 0.1) * 0.9,
|
|
11664
|
-
h:
|
|
12040
|
+
l: banded(Math.min(0.72, Math.max(0.45, brand.l + 0.04))),
|
|
12041
|
+
c: Math.max(brand.c, 0.1) * 0.9 * params.chromaMul,
|
|
12042
|
+
h: anchors.tones.secondary
|
|
11665
12043
|
});
|
|
11666
12044
|
const accentTone = ensureBrandTone({
|
|
11667
|
-
l: Math.min(0.78, Math.max(0.48, brand.l + 0.08)),
|
|
11668
|
-
c: Math.max(brand.c, 0.1) * 0.85,
|
|
11669
|
-
h:
|
|
12045
|
+
l: banded(Math.min(0.78, Math.max(0.48, brand.l + 0.08))),
|
|
12046
|
+
c: Math.max(brand.c, 0.1) * 0.85 * params.chromaMul,
|
|
12047
|
+
h: anchors.tones.accent
|
|
11670
12048
|
});
|
|
11671
12049
|
const neutralTone = ensureBrandTone({
|
|
11672
12050
|
l: 0.18,
|
|
11673
12051
|
c: grayChroma * 1.4,
|
|
11674
12052
|
h: grayHue
|
|
11675
12053
|
});
|
|
11676
|
-
const
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
}
|
|
11684
|
-
return { bg, fg:
|
|
11685
|
-
}
|
|
11686
|
-
const
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
return { bg, fg: fg2 };
|
|
11695
|
-
})();
|
|
12054
|
+
const clampSeparated = (tone, solved) => {
|
|
12055
|
+
const need = guard.lightnessSeparation[tone];
|
|
12056
|
+
if (!need) return solved;
|
|
12057
|
+
const current = hexToOklch(solved.bg);
|
|
12058
|
+
const floor = primaryFinal.l + need.direction * need.minGap * 1.15;
|
|
12059
|
+
const clamped = need.direction > 0 ? Math.max(current.l, floor) : Math.min(current.l, floor);
|
|
12060
|
+
if (Math.abs(clamped - current.l) < 1e-6) return solved;
|
|
12061
|
+
const bg = oklchToHex({ ...current, l: clamped });
|
|
12062
|
+
return { bg, fg: bestFg(bg) };
|
|
12063
|
+
};
|
|
12064
|
+
const successFg = clampSeparated(
|
|
12065
|
+
"success",
|
|
12066
|
+
ensureContrast(success, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("success"))
|
|
12067
|
+
);
|
|
12068
|
+
const warningFg = clampSeparated(
|
|
12069
|
+
"warning",
|
|
12070
|
+
ensureContrast(warning, SOLVER_DEPS, params.targets.fgOnTone, void 0, solveDir("warning"))
|
|
12071
|
+
);
|
|
11696
12072
|
const bgPage = gray(0.965);
|
|
11697
12073
|
let textPrimary = gray(0.25);
|
|
11698
|
-
for (let i = 0; i < 16 && contrastRatio(bgPage, textPrimary) <
|
|
12074
|
+
for (let i = 0; i < 16 && contrastRatio(bgPage, textPrimary) < params.targets.textOnPage; i++) {
|
|
11699
12075
|
const cur = hexToOklch(textPrimary);
|
|
11700
12076
|
textPrimary = oklchToHex({ ...cur, l: cur.l - 0.04 });
|
|
11701
12077
|
}
|
|
12078
|
+
const glassShadow = hexWithAlpha(scale["500"], 0.14);
|
|
12079
|
+
const glassShadowSoft = hexWithAlpha(scale["500"], 0.09);
|
|
11702
12080
|
const cssVars = {
|
|
12081
|
+
// 玻璃材质:面/强面/高光边/彩色投影
|
|
12082
|
+
"--soma-surface-glass": "rgba(255, 255, 255, 0.72)",
|
|
12083
|
+
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.88)",
|
|
12084
|
+
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.52)",
|
|
12085
|
+
"--soma-edge-highlight": "rgba(255, 255, 255, 0.72)",
|
|
12086
|
+
"--soma-shadow-tinted": `0 24px 70px ${glassShadow}`,
|
|
12087
|
+
"--soma-shadow-tinted-soft": `0 16px 36px ${glassShadowSoft}`,
|
|
12088
|
+
// 环境光(--soma-ambient-1/2/3)不在这里产:它取自**最终生效**的色板,
|
|
12089
|
+
// 必须排在 ⑥ 的 overrides 之后(S7′),否则 daisy × aurora 会出现
|
|
12090
|
+
// "表面一个色系、光球另一个色系"——与 ⑥.1 修过的是同一类病
|
|
12091
|
+
...sceneStructureTokens(axes),
|
|
11703
12092
|
"--soma-c-primary": ensuredPrimary,
|
|
11704
12093
|
"--soma-c-primary-hover": hover,
|
|
11705
12094
|
"--soma-c-primary-active": active2,
|
|
@@ -11763,7 +12152,7 @@ function deriveTheme(input) {
|
|
|
11763
12152
|
"--soma-shadow-overlay": "0 20px 40px rgba(0, 0, 0, 0.2)",
|
|
11764
12153
|
"--soma-marquee-duration": "18s",
|
|
11765
12154
|
// 图表序列色板:亮色下压暗一档,保证在白底上足够沉稳
|
|
11766
|
-
...chartSeries(brand.h, Math.max(brand.c, 0.12), 0.62)
|
|
12155
|
+
...chartSeries(brand.h, Math.max(brand.c, 0.12), 0.62, chartAnchorsOrNull)
|
|
11767
12156
|
};
|
|
11768
12157
|
STEPS.forEach((step) => {
|
|
11769
12158
|
cssVars[`--soma-brand-${step}`] = scale[step];
|
|
@@ -11771,19 +12160,32 @@ function deriveTheme(input) {
|
|
|
11771
12160
|
const darkPrimaryIdx = Math.max(3, primaryIdx - 1);
|
|
11772
12161
|
let darkPrimary = scale[STEPS[darkPrimaryIdx]];
|
|
11773
12162
|
let darkFg = bestFg(darkPrimary);
|
|
11774
|
-
for (let i = 0; i < 16 && contrastRatio(darkPrimary, darkFg) <
|
|
12163
|
+
for (let i = 0; i < 16 && contrastRatio(darkPrimary, darkFg) < params.darkTargets.fgOnTone; i++) {
|
|
11775
12164
|
const cur = hexToOklch(darkPrimary);
|
|
11776
12165
|
darkPrimary = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
11777
12166
|
darkFg = bestFg(darkPrimary);
|
|
11778
12167
|
}
|
|
11779
12168
|
const darkHover = oklchToHex({ ...hexToOklch(darkPrimary), l: hexToOklch(darkPrimary).l + 0.05 });
|
|
11780
|
-
const
|
|
11781
|
-
const
|
|
11782
|
-
|
|
12169
|
+
const darkToneHues = axes.palette.harmony === "functional" && axes.palette.semantics === "faithful" && axes.palette.chroma === "balanced" && axes.palette.accents.length === 0 ? FUNCTIONAL_HUES : anchors.tones;
|
|
12170
|
+
const darkDanger = oklchToHex({
|
|
12171
|
+
l: 0.68,
|
|
12172
|
+
c: Math.max(brand.c, 0.12) * 0.9 * params.chromaMul,
|
|
12173
|
+
h: darkToneHues.danger
|
|
12174
|
+
});
|
|
12175
|
+
const darkSuccess = oklchToHex({
|
|
12176
|
+
l: 0.66,
|
|
12177
|
+
c: Math.max(brand.c, 0.12) * 0.8 * params.chromaMul,
|
|
12178
|
+
h: darkToneHues.success
|
|
12179
|
+
});
|
|
12180
|
+
const darkWarning = oklchToHex({
|
|
12181
|
+
l: 0.76,
|
|
12182
|
+
c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
|
|
12183
|
+
h: darkToneHues.warning
|
|
12184
|
+
});
|
|
11783
12185
|
const darkSuccessEnsured = (() => {
|
|
11784
12186
|
let bg = darkSuccess;
|
|
11785
12187
|
let fg2 = bestFg(bg);
|
|
11786
|
-
for (let i = 0; i < 16 && contrastRatio(bg, fg2) <
|
|
12188
|
+
for (let i = 0; i < 16 && contrastRatio(bg, fg2) < params.darkTargets.fgOnTone; i++) {
|
|
11787
12189
|
const cur = hexToOklch(bg);
|
|
11788
12190
|
bg = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
11789
12191
|
fg2 = bestFg(bg);
|
|
@@ -11793,23 +12195,27 @@ function deriveTheme(input) {
|
|
|
11793
12195
|
const darkWarningEnsured = (() => {
|
|
11794
12196
|
let bg = darkWarning;
|
|
11795
12197
|
let fg2 = bestFg(bg);
|
|
11796
|
-
for (let i = 0; i < 16 && contrastRatio(bg, fg2) <
|
|
12198
|
+
for (let i = 0; i < 16 && contrastRatio(bg, fg2) < params.darkTargets.fgOnTone; i++) {
|
|
11797
12199
|
const cur = hexToOklch(bg);
|
|
11798
12200
|
bg = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
11799
12201
|
fg2 = bestFg(bg);
|
|
11800
12202
|
}
|
|
11801
12203
|
return { bg, fg: fg2 };
|
|
11802
12204
|
})();
|
|
11803
|
-
let darkInfo = oklchToHex({
|
|
12205
|
+
let darkInfo = oklchToHex({
|
|
12206
|
+
l: 0.68,
|
|
12207
|
+
c: Math.max(brand.c, 0.12) * 0.85 * params.chromaMul,
|
|
12208
|
+
h: darkToneHues.info
|
|
12209
|
+
});
|
|
11804
12210
|
let darkInfoFg = bestFg(darkInfo);
|
|
11805
|
-
for (let i = 0; i < 16 && contrastRatio(darkInfo, darkInfoFg) <
|
|
12211
|
+
for (let i = 0; i < 16 && contrastRatio(darkInfo, darkInfoFg) < params.darkTargets.fgOnTone; i++) {
|
|
11806
12212
|
const cur = hexToOklch(darkInfo);
|
|
11807
12213
|
darkInfo = oklchToHex({ ...cur, l: cur.l > 0.55 ? cur.l + 0.04 : cur.l - 0.04 });
|
|
11808
12214
|
darkInfoFg = bestFg(darkInfo);
|
|
11809
12215
|
}
|
|
11810
12216
|
const darkBgPage = gray(0.18);
|
|
11811
12217
|
let darkTextPrimary = gray(0.92);
|
|
11812
|
-
for (let i = 0; i < 16 && contrastRatio(darkBgPage, darkTextPrimary) <
|
|
12218
|
+
for (let i = 0; i < 16 && contrastRatio(darkBgPage, darkTextPrimary) < params.darkTargets.textOnPage; i++) {
|
|
11813
12219
|
const cur = hexToOklch(darkTextPrimary);
|
|
11814
12220
|
darkTextPrimary = oklchToHex({ ...cur, l: cur.l + 0.04 });
|
|
11815
12221
|
}
|
|
@@ -11851,6 +12257,14 @@ function deriveTheme(input) {
|
|
|
11851
12257
|
"--soma-c-info-soft": hexWithAlpha(darkInfo, 0.16),
|
|
11852
12258
|
// 暗色下的阴影:亮色那套 rgba(0,0,0,.06~.16) 落在深底上等于不存在,
|
|
11853
12259
|
// 层级会整个塌掉。加深并加大扩散,让浮层仍然"浮"得起来
|
|
12260
|
+
// 暗色玻璃:半透明**黑**而不是白——白玻璃落在深底上会变成一块发光的板,
|
|
12261
|
+
// 层级反而糊掉。高光边同理减弱,只留一线。
|
|
12262
|
+
"--soma-surface-glass": "rgba(255, 255, 255, 0.06)",
|
|
12263
|
+
"--soma-surface-glass-strong": "rgba(255, 255, 255, 0.1)",
|
|
12264
|
+
"--soma-surface-glass-weak": "rgba(255, 255, 255, 0.04)",
|
|
12265
|
+
"--soma-edge-highlight": "rgba(255, 255, 255, 0.12)",
|
|
12266
|
+
"--soma-shadow-tinted": "0 24px 70px rgba(0, 0, 0, 0.55)",
|
|
12267
|
+
"--soma-shadow-tinted-soft": "0 16px 36px rgba(0, 0, 0, 0.45)",
|
|
11854
12268
|
"--soma-shadow-sm": "0 1px 2px rgba(0, 0, 0, 0.5)",
|
|
11855
12269
|
"--soma-shadow-md": "0 6px 16px rgba(0, 0, 0, 0.55)",
|
|
11856
12270
|
"--soma-shadow-lg": "0 16px 40px rgba(0, 0, 0, 0.6)",
|
|
@@ -11860,7 +12274,7 @@ function deriveTheme(input) {
|
|
|
11860
12274
|
"--soma-text-secondary": gray(0.72),
|
|
11861
12275
|
"--soma-text-disabled": gray(0.45),
|
|
11862
12276
|
// 图表序列色板(暗色):提亮一档,深底上才看得清;色相与亮色一一对应,换模式不会"换了一张图"
|
|
11863
|
-
...chartSeries(brand.h, Math.max(brand.c, 0.12), 0.72),
|
|
12277
|
+
...chartSeries(brand.h, Math.max(brand.c, 0.12), 0.72, chartAnchorsOrNull),
|
|
11864
12278
|
"--soma-text-inverse": gray(0.2),
|
|
11865
12279
|
"--soma-text-link": darkPrimary,
|
|
11866
12280
|
"--soma-text-link-hover": darkHover,
|
|
@@ -11886,6 +12300,20 @@ function deriveTheme(input) {
|
|
|
11886
12300
|
enforceContrastPairs(darkCssVars);
|
|
11887
12301
|
deriveOnSoftTokens(cssVars, false);
|
|
11888
12302
|
deriveOnSoftTokens(darkCssVars, true);
|
|
12303
|
+
const rescale = input.overrides?.["--soma-c-primary"] ? (primaryHex) => {
|
|
12304
|
+
const p = hexToOklch(primaryHex);
|
|
12305
|
+
const rebuilt = {};
|
|
12306
|
+
STEPS.forEach((step, i) => {
|
|
12307
|
+
rebuilt[step] = oklchToHex({
|
|
12308
|
+
l: LIGHTNESS[i],
|
|
12309
|
+
c: Math.max(p.c, 0.02) * CHROMA_CURVE[i],
|
|
12310
|
+
h: p.h
|
|
12311
|
+
});
|
|
12312
|
+
});
|
|
12313
|
+
return rebuilt;
|
|
12314
|
+
} : null;
|
|
12315
|
+
Object.assign(cssVars, sceneColorTokens(cssVars, axes, params.fieldAlphas, hexWithAlpha, scale, rescale));
|
|
12316
|
+
Object.assign(darkCssVars, sceneColorTokens(darkCssVars, axes, params.fieldAlphas, hexWithAlpha, scale, rescale));
|
|
11889
12317
|
return {
|
|
11890
12318
|
scale,
|
|
11891
12319
|
cssVars,
|
|
@@ -11893,7 +12321,14 @@ function deriveTheme(input) {
|
|
|
11893
12321
|
contrast: {
|
|
11894
12322
|
primaryFg: contrastRatio(cssVars["--soma-c-primary"], cssVars["--soma-c-primary-fg"]),
|
|
11895
12323
|
darkPrimaryFg: contrastRatio(darkCssVars["--soma-c-primary"], darkCssVars["--soma-c-primary-fg"])
|
|
11896
|
-
}
|
|
12324
|
+
},
|
|
12325
|
+
meta: { axes, separationApplied: guard.applied, pushed: guard.pushed }
|
|
12326
|
+
};
|
|
12327
|
+
}
|
|
12328
|
+
function themeRootAttributes(theme) {
|
|
12329
|
+
return {
|
|
12330
|
+
"data-soma-semantics": theme.meta.axes.palette.semantics,
|
|
12331
|
+
"data-soma-field": theme.meta.axes.scene.field
|
|
11897
12332
|
};
|
|
11898
12333
|
}
|
|
11899
12334
|
function nearestIndex(ladder, value) {
|
|
@@ -11920,6 +12355,9 @@ function applyTheme(input, root) {
|
|
|
11920
12355
|
el.classList.add(THEME_SWITCHING_CLASS);
|
|
11921
12356
|
try {
|
|
11922
12357
|
writeTokensBatch(el, input.dark ? theme.darkCssVars : theme.cssVars);
|
|
12358
|
+
for (const [name, value] of Object.entries(themeRootAttributes(theme))) {
|
|
12359
|
+
el.setAttribute(name, value);
|
|
12360
|
+
}
|
|
11923
12361
|
} finally {
|
|
11924
12362
|
scheduleThemeTransitionRelease(el);
|
|
11925
12363
|
}
|
|
@@ -12056,6 +12494,13 @@ function installSomaErrorReporter(options) {
|
|
|
12056
12494
|
}
|
|
12057
12495
|
|
|
12058
12496
|
// core/client/engine/soma-bootstrap.ts
|
|
12497
|
+
function isSomaDeclarationSource(value) {
|
|
12498
|
+
return value.split("\n").some((line) => {
|
|
12499
|
+
const text = line.trim();
|
|
12500
|
+
if (!text || text.startsWith("#")) return false;
|
|
12501
|
+
return text === "{{";
|
|
12502
|
+
});
|
|
12503
|
+
}
|
|
12059
12504
|
function reportToConsole(event) {
|
|
12060
12505
|
console.error(`[soma-core][\u53EF\u89C2\u6D4B] ${JSON.stringify(event)}`);
|
|
12061
12506
|
}
|
|
@@ -12111,10 +12556,15 @@ var SomaBootstrap = class {
|
|
|
12111
12556
|
this.scheduler.setDiagnostics(this.diagnostics);
|
|
12112
12557
|
}
|
|
12113
12558
|
this.container = container;
|
|
12559
|
+
if (assets.uiYaml && isSomaDeclarationSource(assets.uiYaml)) {
|
|
12560
|
+
throw new Error(
|
|
12561
|
+
"[SomaBootstrap] \u6536\u5230\u672A\u7F16\u8BD1\u7684 SOMA DSL \u6E90\u58F0\u660E\u3002\u8BF7\u5148\u7528 compilePageAssets\uFF08\u6784\u5EFA/\u6D4B\u8BD5\uFF09\u6216 Host \u9875\u9762\u7F16\u8BD1\u5165\u53E3\u751F\u6210\u8FD0\u884C\u65F6\u8D44\u4EA7\u3002"
|
|
12562
|
+
);
|
|
12563
|
+
}
|
|
12114
12564
|
this.assets = { ...assets };
|
|
12115
|
-
const parsed = this.assetResolver.resolve(assets);
|
|
12116
|
-
this.adapter.mount(container, assets.html, assets.includes);
|
|
12117
|
-
this.setupComponentManager(container, assets, parsed.uiConfig);
|
|
12565
|
+
const parsed = this.assetResolver.resolve(this.assets);
|
|
12566
|
+
this.adapter.mount(container, this.assets.html, this.assets.includes);
|
|
12567
|
+
this.setupComponentManager(container, this.assets, parsed.uiConfig);
|
|
12118
12568
|
this.applyHostTheme(parsed.appConfig);
|
|
12119
12569
|
this.domainInstance = this.createDomainInstance(assets.DomainClass, parsed, assets.routerPath);
|
|
12120
12570
|
this.prepareDataLayer(this.domainInstance, assets);
|
|
@@ -12565,6 +13015,65 @@ var SomaBootstrap = class {
|
|
|
12565
13015
|
}
|
|
12566
13016
|
};
|
|
12567
13017
|
|
|
13018
|
+
// core/client/component/example-v2.ts
|
|
13019
|
+
var UI_PREFIX = "ui:";
|
|
13020
|
+
var EVENT_PREFIX = "event:";
|
|
13021
|
+
function balancedSlice(text, start) {
|
|
13022
|
+
let depth = 1;
|
|
13023
|
+
for (let i = start; i < text.length; i += 1) {
|
|
13024
|
+
const ch = text[i];
|
|
13025
|
+
if (ch === "{" || ch === "[") depth += 1;
|
|
13026
|
+
else if (ch === "}" || ch === "]") {
|
|
13027
|
+
depth -= 1;
|
|
13028
|
+
if (depth === 0) return text.slice(start, i).trim();
|
|
13029
|
+
}
|
|
13030
|
+
}
|
|
13031
|
+
return null;
|
|
13032
|
+
}
|
|
13033
|
+
function lineAfter(lines, prefix) {
|
|
13034
|
+
const hit = lines.find((line) => line.trimStart().startsWith(prefix));
|
|
13035
|
+
return hit ? hit.trimStart().slice(prefix.length).trim() : null;
|
|
13036
|
+
}
|
|
13037
|
+
function parseV1Example(example) {
|
|
13038
|
+
const lines = example.split("\n");
|
|
13039
|
+
const ui = lineAfter(lines, UI_PREFIX);
|
|
13040
|
+
if (!ui) return null;
|
|
13041
|
+
const head = /^([A-Za-z_][\w-]*)\s*:\s*\{\s*props\s*:\s*\{/.exec(ui);
|
|
13042
|
+
if (!head) return null;
|
|
13043
|
+
const [, anchor] = head;
|
|
13044
|
+
const propsBody = balancedSlice(ui, head[0].length);
|
|
13045
|
+
if (propsBody === null) return null;
|
|
13046
|
+
const emits = [];
|
|
13047
|
+
const event = lineAfter(lines, EVENT_PREFIX);
|
|
13048
|
+
if (event && !event.startsWith("\uFF08") && event !== "") {
|
|
13049
|
+
const at = event.indexOf(":");
|
|
13050
|
+
if (at > 0) {
|
|
13051
|
+
const key = event.slice(0, at).trim();
|
|
13052
|
+
const expr = event.slice(at + 1).trim();
|
|
13053
|
+
const dot = key.indexOf(".");
|
|
13054
|
+
if (dot > 0 && key.slice(0, dot) === anchor) {
|
|
13055
|
+
emits.push([key.slice(dot + 1), expr]);
|
|
13056
|
+
}
|
|
13057
|
+
}
|
|
13058
|
+
}
|
|
13059
|
+
return { anchor, propsBody: propsBody.trim(), emits };
|
|
13060
|
+
}
|
|
13061
|
+
function deriveV2Example(componentName, example) {
|
|
13062
|
+
const parsed = parseV1Example(example);
|
|
13063
|
+
if (!parsed) return null;
|
|
13064
|
+
const lines = [
|
|
13065
|
+
`${parsed.anchor}:`,
|
|
13066
|
+
` component: ${componentName}`,
|
|
13067
|
+
" ui: { \u2026\u540C\u4E0A props\u2026 }"
|
|
13068
|
+
];
|
|
13069
|
+
if (parsed.emits.length > 0) {
|
|
13070
|
+
lines.push(" event:");
|
|
13071
|
+
lines.push(" on:");
|
|
13072
|
+
for (const [name, expr] of parsed.emits) lines.push(` ${name}: ${expr}`);
|
|
13073
|
+
}
|
|
13074
|
+
return lines.join("\n");
|
|
13075
|
+
}
|
|
13076
|
+
|
|
12568
13077
|
// core/client/component/ai-catalog.ts
|
|
12569
13078
|
function inferGeometryFamily(contract) {
|
|
12570
13079
|
const name = contract.name;
|
|
@@ -12714,6 +13223,14 @@ function renderMarkdown(entries, conventions) {
|
|
|
12714
13223
|
lines.push("```");
|
|
12715
13224
|
lines.push(entry.ai.example.trimEnd());
|
|
12716
13225
|
lines.push("```");
|
|
13226
|
+
const v2 = deriveV2Example(entry.name, entry.ai.example);
|
|
13227
|
+
if (v2) {
|
|
13228
|
+
lines.push("");
|
|
13229
|
+
lines.push("v2\uFF08html \u540C\u4E0A\uFF0C_ui.yaml \u6539\u5757\u58F0\u660E\uFF09\uFF1A");
|
|
13230
|
+
lines.push("```");
|
|
13231
|
+
lines.push(v2);
|
|
13232
|
+
lines.push("```");
|
|
13233
|
+
}
|
|
12717
13234
|
}
|
|
12718
13235
|
if (entry.ai?.antiPatterns?.length) {
|
|
12719
13236
|
lines.push("");
|
|
@@ -12864,25 +13381,149 @@ function rawTier(value, bounds) {
|
|
|
12864
13381
|
return tier;
|
|
12865
13382
|
}
|
|
12866
13383
|
|
|
12867
|
-
// core/build/
|
|
12868
|
-
var
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
13384
|
+
// core/build/v2/soma-file-loader.ts
|
|
13385
|
+
var SomaV2ParseError = class extends Error {
|
|
13386
|
+
constructor(message, blockId, line) {
|
|
13387
|
+
const where = blockId ? `\uFF08\u5757: ${blockId}${line ? `\uFF0C\u7B2C ${line} \u884C` : ""}\uFF09` : "";
|
|
13388
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${where}`);
|
|
13389
|
+
this.blockId = blockId;
|
|
13390
|
+
this.line = line;
|
|
13391
|
+
this.name = "SomaV2ParseError";
|
|
13392
|
+
}
|
|
13393
|
+
};
|
|
13394
|
+
var PAGE_BLOCK_ID = "page";
|
|
13395
|
+
function stripSwitch(uiYamlRaw) {
|
|
13396
|
+
const lines = uiYamlRaw.split("\n");
|
|
13397
|
+
let openIndex = -1;
|
|
13398
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
13399
|
+
const text = lines[i].trim();
|
|
13400
|
+
if (text === "" || text.startsWith("#")) continue;
|
|
13401
|
+
if (text !== "{{") {
|
|
13402
|
+
throw new SomaV2ParseError("v2 \u58F0\u660E\u5FC5\u987B\u4EE5 `{{` \u5F00\u5173\u884C\u5F00\u5934");
|
|
13403
|
+
}
|
|
13404
|
+
openIndex = i;
|
|
13405
|
+
break;
|
|
13406
|
+
}
|
|
13407
|
+
if (openIndex === -1) {
|
|
13408
|
+
throw new SomaV2ParseError("\u6587\u4EF6\u4E3A\u7A7A\u6216\u53EA\u6709\u6CE8\u91CA\uFF0C\u627E\u4E0D\u5230 `{{` \u5F00\u5173\u884C");
|
|
13409
|
+
}
|
|
13410
|
+
let closeIndex = -1;
|
|
13411
|
+
for (let i = lines.length - 1; i > openIndex; i -= 1) {
|
|
13412
|
+
const text = lines[i].trim();
|
|
13413
|
+
if (text === "") continue;
|
|
13414
|
+
if (text !== "}}") {
|
|
13415
|
+
throw new SomaV2ParseError("v2 \u58F0\u660E\u5FC5\u987B\u4EE5 `}}` \u6536\u53E3\u884C\u7ED3\u5C3E\uFF08\u5F00\u5173\u6210\u5BF9\uFF0C\u6574\u6587\u4EF6\u4E00\u5BF9\uFF09");
|
|
13416
|
+
}
|
|
13417
|
+
closeIndex = i;
|
|
13418
|
+
break;
|
|
13419
|
+
}
|
|
13420
|
+
if (closeIndex === -1) {
|
|
13421
|
+
throw new SomaV2ParseError("`{{` \u5F00\u5173\u672A\u95ED\u5408\u2014\u2014\u7F3A\u5C11 `}}` \u6536\u53E3\u884C");
|
|
12883
13422
|
}
|
|
12884
|
-
|
|
12885
|
-
|
|
13423
|
+
return {
|
|
13424
|
+
inner: lines.slice(openIndex + 1, closeIndex).join("\n"),
|
|
13425
|
+
offset: openIndex + 1
|
|
13426
|
+
};
|
|
13427
|
+
}
|
|
13428
|
+
function parseSomaV2Container(uiYamlRaw) {
|
|
13429
|
+
const { inner, offset } = stripSwitch(uiYamlRaw);
|
|
13430
|
+
let doc;
|
|
13431
|
+
try {
|
|
13432
|
+
doc = yaml.load(inner);
|
|
13433
|
+
} catch (error) {
|
|
13434
|
+
throw new SomaV2ParseError(`YAML \u89E3\u6790\u5931\u8D25: ${error.message}`);
|
|
13435
|
+
}
|
|
13436
|
+
if (doc === null || doc === void 0) {
|
|
13437
|
+
return { doc: {}, inner, offset };
|
|
13438
|
+
}
|
|
13439
|
+
if (typeof doc !== "object" || Array.isArray(doc)) {
|
|
13440
|
+
throw new SomaV2ParseError("\u5F00\u5173\u5185\u5FC5\u987B\u662F\u5757\u6620\u5C04\uFF08\u9876\u5C42\u952E = \u5757 id\uFF09");
|
|
13441
|
+
}
|
|
13442
|
+
for (const [blockId, body] of Object.entries(doc)) {
|
|
13443
|
+
if (body === null || body === void 0) {
|
|
13444
|
+
throw new SomaV2ParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId);
|
|
13445
|
+
}
|
|
13446
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13447
|
+
throw new SomaV2ParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId);
|
|
13448
|
+
}
|
|
13449
|
+
}
|
|
13450
|
+
return { doc, inner, offset };
|
|
13451
|
+
}
|
|
13452
|
+
function loadSomaFile(input) {
|
|
13453
|
+
const { doc, inner, offset } = parseSomaV2Container(input.uiYamlRaw);
|
|
13454
|
+
if (Object.keys(doc).length === 0) return [];
|
|
13455
|
+
const innerLines = inner.split("\n");
|
|
13456
|
+
const lineOfKey = (key) => {
|
|
13457
|
+
const index = innerLines.findIndex((line) => line.startsWith(`${key}:`));
|
|
13458
|
+
return index === -1 ? offset : offset + index + 1;
|
|
13459
|
+
};
|
|
13460
|
+
const blocks = [];
|
|
13461
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13462
|
+
for (const [blockId, body] of Object.entries(doc)) {
|
|
13463
|
+
const line = lineOfKey(blockId);
|
|
13464
|
+
assertBlockId(blockId, input.htmlIndex, line);
|
|
13465
|
+
if (seen.has(blockId)) {
|
|
13466
|
+
throw new SomaV2ParseError(`\u5757 "${blockId}" \u91CD\u590D\u58F0\u660E`, blockId, line);
|
|
13467
|
+
}
|
|
13468
|
+
if (body === null || body === void 0) {
|
|
13469
|
+
throw new SomaV2ParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId, line);
|
|
13470
|
+
}
|
|
13471
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13472
|
+
throw new SomaV2ParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId, line);
|
|
13473
|
+
}
|
|
13474
|
+
seen.add(blockId);
|
|
13475
|
+
blocks.push({ blockId, body, line, source: "inline" });
|
|
13476
|
+
}
|
|
13477
|
+
for (const [blockId, raw] of input.externalBlocks ?? /* @__PURE__ */ new Map()) {
|
|
13478
|
+
assertBlockId(blockId, input.htmlIndex, 0);
|
|
13479
|
+
if (seen.has(blockId)) {
|
|
13480
|
+
throw new SomaV2ParseError(
|
|
13481
|
+
`\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`,
|
|
13482
|
+
blockId
|
|
13483
|
+
);
|
|
13484
|
+
}
|
|
13485
|
+
let body;
|
|
13486
|
+
try {
|
|
13487
|
+
body = yaml.load(raw);
|
|
13488
|
+
} catch (error) {
|
|
13489
|
+
throw new SomaV2ParseError(
|
|
13490
|
+
`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u89E3\u6790\u5931\u8D25: ${error.message}`,
|
|
13491
|
+
blockId
|
|
13492
|
+
);
|
|
13493
|
+
}
|
|
13494
|
+
if (body === null || body === void 0) {
|
|
13495
|
+
throw new SomaV2ParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u4E3A\u7A7A`, blockId);
|
|
13496
|
+
}
|
|
13497
|
+
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13498
|
+
throw new SomaV2ParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u5FC5\u987B\u662F\u6620\u5C04`, blockId);
|
|
13499
|
+
}
|
|
13500
|
+
seen.add(blockId);
|
|
13501
|
+
blocks.push({ blockId, body, line: 1, source: "external" });
|
|
13502
|
+
}
|
|
13503
|
+
return blocks;
|
|
13504
|
+
}
|
|
13505
|
+
function assertBlockId(blockId, htmlIndex, line) {
|
|
13506
|
+
if (blockId === PAGE_BLOCK_ID) return;
|
|
13507
|
+
if (htmlIndex.instances.has(blockId)) return;
|
|
13508
|
+
if (htmlIndex.anchors.has(blockId)) {
|
|
13509
|
+
throw new SomaV2ParseError(
|
|
13510
|
+
`"${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`,
|
|
13511
|
+
blockId,
|
|
13512
|
+
line
|
|
13513
|
+
);
|
|
13514
|
+
}
|
|
13515
|
+
const known = [...htmlIndex.instances].slice(0, 8).join("\u3001");
|
|
13516
|
+
throw new SomaV2ParseError(
|
|
13517
|
+
`HTML \u91CC\u6CA1\u6709\u5B9E\u4F8B\u951A\u70B9 "${blockId}"${known ? `\uFF08\u73B0\u6709\u5B9E\u4F8B\uFF1A${known}\uFF09` : ""}`,
|
|
13518
|
+
blockId,
|
|
13519
|
+
line
|
|
13520
|
+
);
|
|
13521
|
+
}
|
|
13522
|
+
|
|
13523
|
+
// core/build/compiler/soma-precompile.ts
|
|
13524
|
+
function precompileUiModule(yamlStr) {
|
|
13525
|
+
parseSomaV2Container(yamlStr);
|
|
13526
|
+
return "null";
|
|
12886
13527
|
}
|
|
12887
13528
|
function compileEventConfigFromRaw(raw) {
|
|
12888
13529
|
const { eventsRaw, triggers, timers } = splitEventConfigRaw(raw);
|
|
@@ -12898,9 +13539,6 @@ function compileDataConfig(yamlStr) {
|
|
|
12898
13539
|
}
|
|
12899
13540
|
return parseDataConfig(yaml.load(yamlStr));
|
|
12900
13541
|
}
|
|
12901
|
-
function precompileDataYaml(yamlStr) {
|
|
12902
|
-
return JSON.stringify(compileDataConfig(yamlStr));
|
|
12903
|
-
}
|
|
12904
13542
|
function precompileYaml(yamlStr) {
|
|
12905
13543
|
const obj = yaml.load(yamlStr);
|
|
12906
13544
|
return JSON.stringify(obj ?? {});
|
|
@@ -12909,9 +13547,6 @@ function precompileYaml(yamlStr) {
|
|
|
12909
13547
|
// core/build/compiler/rollup-plugin-soma.ts
|
|
12910
13548
|
function somaRollupPlugin(options = {}) {
|
|
12911
13549
|
const uiSuffix = options.uiSuffix ?? "_ui.yaml";
|
|
12912
|
-
const eventSuffix = options.eventSuffix ?? "_event.yaml";
|
|
12913
|
-
const styleSuffix = options.styleSuffix ?? "_style.yaml";
|
|
12914
|
-
const dataSuffix = options.dataSuffix ?? "_data.yaml";
|
|
12915
13550
|
return {
|
|
12916
13551
|
name: "rollup-plugin-soma",
|
|
12917
13552
|
transform(code, id) {
|
|
@@ -12920,16 +13555,10 @@ function somaRollupPlugin(options = {}) {
|
|
|
12920
13555
|
}
|
|
12921
13556
|
try {
|
|
12922
13557
|
if (id.endsWith(uiSuffix)) {
|
|
12923
|
-
return { code: `export default ${
|
|
12924
|
-
}
|
|
12925
|
-
if (id.endsWith(eventSuffix)) {
|
|
12926
|
-
return { code: `export default ${precompileEventYaml(code)};`, map: { mappings: "" } };
|
|
12927
|
-
}
|
|
12928
|
-
if (id.endsWith(styleSuffix)) {
|
|
12929
|
-
return { code: `export default ${precompileStyleYaml(code)};`, map: { mappings: "" } };
|
|
13558
|
+
return { code: `export default ${precompileUiModule(code)};`, map: { mappings: "" } };
|
|
12930
13559
|
}
|
|
12931
|
-
if (
|
|
12932
|
-
|
|
13560
|
+
if (/_((event)|(style)|(data))\.ya?ml$/.test(id)) {
|
|
13561
|
+
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");
|
|
12933
13562
|
}
|
|
12934
13563
|
return { code: `export default ${precompileYaml(code)};`, map: { mappings: "" } };
|
|
12935
13564
|
} catch (err) {
|
|
@@ -13386,19 +14015,23 @@ function createGeneratedPagePreview(target, components, options = {}) {
|
|
|
13386
14015
|
} : {}
|
|
13387
14016
|
});
|
|
13388
14017
|
const usable = compiled !== void 0 && compiled.uiConfig !== void 0 && compiled.eventConfig !== void 0;
|
|
14018
|
+
if (!usable) {
|
|
14019
|
+
throw new Error(
|
|
14020
|
+
"[soma-core][\u58F0\u660E\u6E32\u67D3] \u7F3A\u5C11\u5B8C\u6574\u7684\u670D\u52A1\u7AEF\u7F16\u8BD1\u4EA7\u7269\u3002\u6D4F\u89C8\u5668\u4E0D\u89E3\u6790 SOMA DSL \u6E90\u58F0\u660E\uFF1B\u8BF7\u7531\u751F\u6210/\u6CE8\u518C\u670D\u52A1\u8FD4\u56DE compiled \u8D44\u4EA7\u3002"
|
|
14021
|
+
);
|
|
14022
|
+
}
|
|
13389
14023
|
await next.mount(container, {
|
|
13390
14024
|
html: decl.html,
|
|
13391
|
-
uiYaml:
|
|
13392
|
-
eventYaml:
|
|
13393
|
-
styleYaml:
|
|
14025
|
+
uiYaml: "",
|
|
14026
|
+
eventYaml: "",
|
|
14027
|
+
styleYaml: "",
|
|
13394
14028
|
DomainClass: getPreviewPageRoot(),
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
} : {}
|
|
14029
|
+
uiConfig: compiled.uiConfig,
|
|
14030
|
+
eventConfig: compiled.eventConfig,
|
|
14031
|
+
triggerConfig: compiled.triggerConfig,
|
|
14032
|
+
timerConfig: compiled.timerConfig,
|
|
14033
|
+
...compiled.styleConfig !== void 0 ? { styleConfig: compiled.styleConfig } : {},
|
|
14034
|
+
...compiled.dataConfig !== void 0 ? { dataConfig: compiled.dataConfig } : {}
|
|
13402
14035
|
});
|
|
13403
14036
|
bootstrap = next;
|
|
13404
14037
|
},
|
|
@@ -13609,6 +14242,79 @@ function ensurePackBaseStyles(composed, options = {}) {
|
|
|
13609
14242
|
});
|
|
13610
14243
|
}
|
|
13611
14244
|
|
|
14245
|
+
// core/client/component/contract-compat.ts
|
|
14246
|
+
function checkOverrideCompat(winner, base) {
|
|
14247
|
+
const issues = [];
|
|
14248
|
+
const winnerProps = winner.props ?? {};
|
|
14249
|
+
const baseProps = base.props ?? {};
|
|
14250
|
+
for (const [name, baseProp] of Object.entries(baseProps)) {
|
|
14251
|
+
const winnerProp = winnerProps[name];
|
|
14252
|
+
if (!winnerProp) {
|
|
14253
|
+
issues.push({
|
|
14254
|
+
kind: "prop-missing",
|
|
14255
|
+
member: name,
|
|
14256
|
+
detail: `\u7F3A\u5C11 prop "${name}"\uFF08${describeProp(baseProp)}\uFF09\u2014\u2014\u5B58\u91CF\u9875\u9762\u4ECD\u4F1A\u4F20\u5B83\uFF0C\u8986\u76D6\u540E\u8FD9\u4E2A\u503C\u65E0\u5904\u53EF\u53BB`
|
|
14257
|
+
});
|
|
14258
|
+
continue;
|
|
14259
|
+
}
|
|
14260
|
+
if (winnerProp.type !== baseProp.type) {
|
|
14261
|
+
issues.push({
|
|
14262
|
+
kind: "prop-type-changed",
|
|
14263
|
+
member: name,
|
|
14264
|
+
detail: `prop "${name}" \u7684 type \u4ECE "${baseProp.type}" \u53D8\u6210 "${winnerProp.type}"\u2014\u2014\u9875\u9762\u4F20\u4E0B\u6765\u7684\u503C\u5F62\u72B6\u4E0D\u53D8\uFF0C\u8BFB\u6CD5\u5374\u53D8\u4E86`
|
|
14265
|
+
});
|
|
14266
|
+
continue;
|
|
14267
|
+
}
|
|
14268
|
+
if (winnerProp.required === true && baseProp.required !== true) {
|
|
14269
|
+
issues.push({
|
|
14270
|
+
kind: "prop-required-tightened",
|
|
14271
|
+
member: name,
|
|
14272
|
+
detail: `prop "${name}" \u4ECE\u53EF\u9009\u6536\u7D27\u4E3A\u5FC5\u586B\u2014\u2014\u5B58\u91CF\u9875\u9762\u6CA1\u4F20\u5B83\u7684\u5730\u65B9\u4F1A\u7F3A\u5FC5\u586B`
|
|
14273
|
+
});
|
|
14274
|
+
continue;
|
|
14275
|
+
}
|
|
14276
|
+
if (baseProp.required !== true && !sameDefault(winnerProp.default, baseProp.default)) {
|
|
14277
|
+
issues.push({
|
|
14278
|
+
kind: "prop-default-diverged",
|
|
14279
|
+
member: name,
|
|
14280
|
+
detail: `\u53EF\u9009 prop "${name}" \u7684 default \u4ECE ${formatValue(baseProp.default)} \u53D8\u6210 ${formatValue(winnerProp.default)}\u2014\u2014\u7ED3\u6784\u517C\u5BB9\u4F46\u884C\u4E3A\u4F1A\u9759\u9ED8\u6539\u53D8\uFF1A\u5B58\u91CF\u9875\u9762\u6CA1\u4F20\u8FD9\u4E2A prop \u7684\u5730\u65B9\uFF0C\u6E32\u67D3\u7ED3\u679C\u76F4\u63A5\u8DDF\u7740\u53D8`
|
|
14281
|
+
});
|
|
14282
|
+
}
|
|
14283
|
+
}
|
|
14284
|
+
const baseEmits = Object.keys(base.emits ?? {});
|
|
14285
|
+
const winnerEmits = new Set(Object.keys(winner.emits ?? {}));
|
|
14286
|
+
for (const name of baseEmits) {
|
|
14287
|
+
if (!winnerEmits.has(name)) {
|
|
14288
|
+
issues.push({
|
|
14289
|
+
kind: "emit-missing",
|
|
14290
|
+
member: name,
|
|
14291
|
+
detail: `\u7F3A\u5C11 emit "${name}"\u2014\u2014\u5B58\u91CF\u9875\u9762\u7684 _event.yaml \u4ECD\u8BA2\u9605\u7740\u5B83\uFF0C\u8986\u76D6\u540E\u70B9\u4E86\u6CA1\u53CD\u5E94`
|
|
14292
|
+
});
|
|
14293
|
+
}
|
|
14294
|
+
}
|
|
14295
|
+
return issues;
|
|
14296
|
+
}
|
|
14297
|
+
function sameDefault(a, b) {
|
|
14298
|
+
if (a === b) return true;
|
|
14299
|
+
if (a === void 0 || b === void 0) return false;
|
|
14300
|
+
try {
|
|
14301
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
14302
|
+
} catch {
|
|
14303
|
+
return false;
|
|
14304
|
+
}
|
|
14305
|
+
}
|
|
14306
|
+
function describeProp(prop) {
|
|
14307
|
+
return prop.required === true ? `${prop.type}\uFF0C\u5FC5\u586B` : `${prop.type}\uFF0C\u53EF\u9009`;
|
|
14308
|
+
}
|
|
14309
|
+
function formatValue(value) {
|
|
14310
|
+
if (value === void 0) return "\u672A\u8BBE\u7F6E";
|
|
14311
|
+
try {
|
|
14312
|
+
return JSON.stringify(value) ?? String(value);
|
|
14313
|
+
} catch {
|
|
14314
|
+
return String(value);
|
|
14315
|
+
}
|
|
14316
|
+
}
|
|
14317
|
+
|
|
13612
14318
|
// core/client/component/component-pack.ts
|
|
13613
14319
|
var PACK_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
13614
14320
|
var ComponentPackError = class extends Error {
|
|
@@ -13654,33 +14360,52 @@ function composeComponentPacks(packs, options = {}) {
|
|
|
13654
14360
|
);
|
|
13655
14361
|
}
|
|
13656
14362
|
}
|
|
14363
|
+
const { table: overrideTable, source: overrideSource } = resolveOverrideTable(packs, allowOverride);
|
|
14364
|
+
const versionOf = new Map(packs.map((pack) => [pack.name, pack.version]));
|
|
14365
|
+
const providers = /* @__PURE__ */ new Map();
|
|
13657
14366
|
for (const pack of packs) {
|
|
13658
14367
|
for (const [name, definition] of Object.entries(pack.components)) {
|
|
13659
|
-
const
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
14368
|
+
const list = providers.get(name) ?? [];
|
|
14369
|
+
list.push({ pack: pack.name, definition });
|
|
14370
|
+
providers.set(name, list);
|
|
14371
|
+
}
|
|
14372
|
+
}
|
|
14373
|
+
for (const [name, list] of providers) {
|
|
14374
|
+
if (list.length === 1) {
|
|
14375
|
+
components[name] = list[0].definition;
|
|
14376
|
+
provenance[name] = list[0].pack;
|
|
14377
|
+
continue;
|
|
14378
|
+
}
|
|
14379
|
+
const winnerName = overrideTable[name];
|
|
14380
|
+
if (winnerName === void 0) {
|
|
14381
|
+
const [first, second] = list;
|
|
14382
|
+
throw new ComponentPackError(
|
|
14383
|
+
`\u7EC4\u4EF6\u540D\u51B2\u7A81\uFF1A"${name}" \u540C\u65F6\u6765\u81EA\u5305 ${list.map((item) => `"${item.pack}"`).join(" \u4E0E ")}\u3002
|
|
13669
14384
|
\u5408\u6210\u9ED8\u8BA4\u62D2\u7EDD\u91CD\u540D\u2014\u2014\u9759\u9ED8\u8986\u76D6\u4F1A\u8BA9"\u9875\u9762\u7528\u7684\u662F\u54EA\u4E2A\u7EC4\u4EF6"\u53EA\u80FD\u9760\u987A\u5E8F\u731C\u3002
|
|
13670
|
-
\u786E\u5B9E\u8981\u8986\u76D6\
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
provenance[name] = winner;
|
|
13681
|
-
overrides[name] = record;
|
|
14385
|
+
\u786E\u5B9E\u8981\u8986\u76D6\uFF0C\u4E24\u6761\u5199\u6CD5\u4E8C\u9009\u4E00\uFF1A
|
|
14386
|
+
\u2460 \u5728\u8986\u76D6\u65B9\u7684\u5951\u7EA6\u91CC\u58F0\u660E\uFF1Aoverrides: '${first.pack}'\uFF08\u610F\u56FE\u4E0E\u7EC4\u4EF6\u540C\u5904\uFF0C\u63A8\u8350\uFF09
|
|
14387
|
+
\u2461 \u5728\u5BBF\u4E3B bootstrap \u91CC\u88C1\u51B3\uFF1AcomposeComponentPacks(..., { allowOverride: { ${name}: '${second.pack}' } })`
|
|
14388
|
+
);
|
|
14389
|
+
}
|
|
14390
|
+
const winner = list.find((item) => item.pack === winnerName);
|
|
14391
|
+
if (!winner) {
|
|
14392
|
+
throw new ComponentPackError(
|
|
14393
|
+
`"${name}" \u7684\u8986\u76D6\u88C1\u51B3\u6307\u5411\u5305 "${winnerName}"\uFF0C\u4F46\u8BE5\u5305\u6CA1\u6709\u63D0\u4F9B\u8FD9\u4E2A\u7EC4\u4EF6`
|
|
14394
|
+
);
|
|
13682
14395
|
}
|
|
14396
|
+
const shadowed = list.filter((item) => item.pack !== winnerName);
|
|
14397
|
+
for (const loser of shadowed) {
|
|
14398
|
+
assertOverrideCompat(name, winnerName, loser.pack, winner.definition, loser.definition);
|
|
14399
|
+
}
|
|
14400
|
+
components[name] = winner.definition;
|
|
14401
|
+
provenance[name] = winnerName;
|
|
14402
|
+
overrides[name] = {
|
|
14403
|
+
winner: winnerName,
|
|
14404
|
+
shadowed: shadowed.map((item) => item.pack),
|
|
14405
|
+
source: overrideSource[name] ?? "allowOverride"
|
|
14406
|
+
};
|
|
13683
14407
|
}
|
|
14408
|
+
reportOverrides(overrides, versionOf, options.onOverride);
|
|
13684
14409
|
const composed = {
|
|
13685
14410
|
components,
|
|
13686
14411
|
provenance,
|
|
@@ -13694,6 +14419,86 @@ function composeComponentPacks(packs, options = {}) {
|
|
|
13694
14419
|
components: attachPackStyles(composed, { nonce: options.styleNonce ?? null })
|
|
13695
14420
|
};
|
|
13696
14421
|
}
|
|
14422
|
+
function resolveOverrideTable(packs, allowOverride) {
|
|
14423
|
+
const table = {};
|
|
14424
|
+
const source = {};
|
|
14425
|
+
const packByName = new Map(packs.map((pack) => [pack.name, pack]));
|
|
14426
|
+
for (const pack of packs) {
|
|
14427
|
+
for (const [name, definition] of Object.entries(pack.components)) {
|
|
14428
|
+
const target = definition?.contract?.overrides;
|
|
14429
|
+
if (!target) continue;
|
|
14430
|
+
if (target === pack.name) {
|
|
14431
|
+
throw new ComponentPackError(
|
|
14432
|
+
`\u5305 "${pack.name}" \u7684\u7EC4\u4EF6 "${name}" \u58F0\u660E overrides: "${target}" \u6307\u5411\u81EA\u5DF1\u2014\u2014\u8986\u76D6\u662F\u8DE8\u5305\u7684\u4E8B\uFF0C\u540C\u5305\u5185\u91CD\u540D\u8BF7\u76F4\u63A5\u6539\u540D`
|
|
14433
|
+
);
|
|
14434
|
+
}
|
|
14435
|
+
const targetPack = packByName.get(target);
|
|
14436
|
+
if (!targetPack) {
|
|
14437
|
+
throw new ComponentPackError(
|
|
14438
|
+
`\u7EC4\u4EF6 "${name}"\uFF08\u6765\u81EA\u5305 "${pack.name}"\uFF09\u58F0\u660E overrides: "${target}"\uFF0C\u4F46\u5305 "${target}" \u4E0D\u5728\u672C\u6B21\u5408\u6210\u91CC\u3002
|
|
14439
|
+
\u58F0\u660E\u5931\u6548\u591A\u534A\u610F\u5473\u7740\u5305\u540D\u5199\u9519\u6216\u8BE5\u5305\u6CA1\u88AB\u5F15\u5165\u2014\u2014\u9759\u9ED8\u5FFD\u7565\u4F1A\u8BA9\u4F60\u4EE5\u4E3A\u8986\u76D6\u751F\u6548\u4E86`
|
|
14440
|
+
);
|
|
14441
|
+
}
|
|
14442
|
+
if (!(name in targetPack.components)) {
|
|
14443
|
+
throw new ComponentPackError(
|
|
14444
|
+
`\u7EC4\u4EF6 "${name}"\uFF08\u6765\u81EA\u5305 "${pack.name}"\uFF09\u58F0\u660E overrides: "${target}"\uFF0C\u4F46\u5305 "${target}" \u91CC\u6CA1\u6709\u53EB "${name}" \u7684\u7EC4\u4EF6\u3002
|
|
14445
|
+
\u591A\u534A\u662F\u88AB\u8986\u76D6\u7684\u7EC4\u4EF6\u6539\u4E86\u540D\u2014\u2014\u8BF7\u5BF9\u9F50\u7EC4\u4EF6\u540D\uFF0C\u6216\u5220\u6389\u8FD9\u6761 overrides \u58F0\u660E`
|
|
14446
|
+
);
|
|
14447
|
+
}
|
|
14448
|
+
const existing = table[name];
|
|
14449
|
+
if (existing !== void 0 && existing !== pack.name) {
|
|
14450
|
+
if (allowOverride[name] === void 0) {
|
|
14451
|
+
throw new ComponentPackError(
|
|
14452
|
+
`\u7EC4\u4EF6 "${name}" \u6709\u4E24\u4E2A\u8986\u76D6\u8005\uFF1A\u5305 "${existing}" \u4E0E\u5305 "${pack.name}" \u90FD\u58F0\u660E\u8981\u8986\u76D6\u5B83\u3002
|
|
14453
|
+
\u5E73\u53F0\u4E0D\u66FF\u4F60\u9009\u8FB9\u2014\u2014\u8BF7\u5728\u5BBF\u4E3B bootstrap \u91CC\u88C1\u51B3\uFF1A
|
|
14454
|
+
composeComponentPacks(..., { allowOverride: { ${name}: '\u5305\u540D' } })`
|
|
14455
|
+
);
|
|
14456
|
+
}
|
|
14457
|
+
continue;
|
|
14458
|
+
}
|
|
14459
|
+
table[name] = pack.name;
|
|
14460
|
+
source[name] = "contract";
|
|
14461
|
+
}
|
|
14462
|
+
}
|
|
14463
|
+
for (const [name, winner] of Object.entries(allowOverride)) {
|
|
14464
|
+
table[name] = winner;
|
|
14465
|
+
source[name] = "allowOverride";
|
|
14466
|
+
}
|
|
14467
|
+
return { table, source };
|
|
14468
|
+
}
|
|
14469
|
+
function assertOverrideCompat(name, winnerPack, loserPack, winnerDefinition, loserDefinition) {
|
|
14470
|
+
const winnerContract = winnerDefinition?.contract;
|
|
14471
|
+
const loserContract = loserDefinition?.contract;
|
|
14472
|
+
if (!winnerContract || !loserContract) return;
|
|
14473
|
+
const issues = checkOverrideCompat(winnerContract, loserContract);
|
|
14474
|
+
if (issues.length === 0) return;
|
|
14475
|
+
throw new ComponentPackError(
|
|
14476
|
+
`\u5305 "${winnerPack}" \u7684 "${name}" \u8986\u76D6\u5305 "${loserPack}" \u7684\u540C\u540D\u7EC4\u4EF6\uFF0C\u4F46\u5951\u7EA6\u4E0D\u517C\u5BB9\uFF1A
|
|
14477
|
+
${issues.map((issue) => ` \xB7 ${issue.detail}`).join("\n")}
|
|
14478
|
+
\u5B58\u91CF\u9875\u9762\u662F\u5BF9\u7740\u88AB\u8986\u76D6\u8005\u7684\u5951\u7EA6\u5199\u7684\u2014\u2014\u8986\u76D6\u8005\u5FC5\u987B\u6536\u5F97\u4E0B\u5B83\u4EEC\u4F20\u7684 props\u3001\u53D1\u5F97\u51FA\u5B83\u4EEC\u8BA2\u9605\u7684 emit\u3002
|
|
14479
|
+
\uFF08\u95F8\u95E8\u53EA\u4FDD\u8BC1\u7ED3\u6784\u517C\u5BB9\uFF0C\u4E0D\u4FDD\u8BC1\u884C\u4E3A\u7B49\u4EF7\uFF1A\u6E32\u67D3\u7EC6\u8282\u4ECD\u9700\u4F60\u81EA\u5DF1\u7684\u6D4B\u8BD5\u515C\u5E95\uFF09`
|
|
14480
|
+
);
|
|
14481
|
+
}
|
|
14482
|
+
function reportOverrides(overrides, versionOf, onOverride) {
|
|
14483
|
+
for (const [name, record] of Object.entries(overrides)) {
|
|
14484
|
+
const event = {
|
|
14485
|
+
name,
|
|
14486
|
+
winner: record.winner,
|
|
14487
|
+
winnerVersion: versionOf.get(record.winner) ?? "?",
|
|
14488
|
+
shadowed: record.shadowed.map((pack) => ({ pack, version: versionOf.get(pack) ?? "?" })),
|
|
14489
|
+
source: record.source
|
|
14490
|
+
};
|
|
14491
|
+
if (onOverride) {
|
|
14492
|
+
onOverride(event);
|
|
14493
|
+
continue;
|
|
14494
|
+
}
|
|
14495
|
+
const shadowed = event.shadowed.map((item) => `${item.pack}@${item.version}`).join("\u3001");
|
|
14496
|
+
const via = event.source === "contract" ? "\u5951\u7EA6\u58F0\u660E" : "allowOverride";
|
|
14497
|
+
console.info(
|
|
14498
|
+
`[soma-core][\u7EC4\u4EF6] ${name}: ${event.winner}@${event.winnerVersion} \u8986\u76D6 ${shadowed}\uFF08${via}\uFF09`
|
|
14499
|
+
);
|
|
14500
|
+
}
|
|
14501
|
+
}
|
|
13697
14502
|
function composeStyles(packs, provenance) {
|
|
13698
14503
|
const components = {};
|
|
13699
14504
|
const shared = {};
|
|
@@ -13932,6 +14737,1163 @@ function physicalDirections(css) {
|
|
|
13932
14737
|
}
|
|
13933
14738
|
return [...found];
|
|
13934
14739
|
}
|
|
14740
|
+
|
|
14741
|
+
// core/client/parser/value-lang.ts
|
|
14742
|
+
var SomaValueLangError = class extends Error {
|
|
14743
|
+
constructor(message, raw) {
|
|
14744
|
+
super(`[soma-core][\u5F15\u64CE] ${message}\uFF08\u503C: "${raw}"\uFF09`);
|
|
14745
|
+
this.raw = raw;
|
|
14746
|
+
this.name = "SomaValueLangError";
|
|
14747
|
+
}
|
|
14748
|
+
};
|
|
14749
|
+
var ARITH_HINT = /[+\-*/()]/;
|
|
14750
|
+
var FORBIDDEN = /(>=|<=|==|!=|&&|\|\||[<>?])/;
|
|
14751
|
+
var PATH_SHAPE = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z0-9_]+)*$/;
|
|
14752
|
+
function tokenize(raw, source) {
|
|
14753
|
+
const tokens = [];
|
|
14754
|
+
let i = 0;
|
|
14755
|
+
while (i < raw.length) {
|
|
14756
|
+
const ch = raw[i];
|
|
14757
|
+
if (ch === " " || ch === " ") {
|
|
14758
|
+
i += 1;
|
|
14759
|
+
continue;
|
|
14760
|
+
}
|
|
14761
|
+
if (ch === "(" || ch === ")") {
|
|
14762
|
+
tokens.push({ t: ch });
|
|
14763
|
+
i += 1;
|
|
14764
|
+
continue;
|
|
14765
|
+
}
|
|
14766
|
+
if (ch === "+" || ch === "-" || ch === "*" || ch === "/") {
|
|
14767
|
+
tokens.push({ t: "op", v: ch });
|
|
14768
|
+
i += 1;
|
|
14769
|
+
continue;
|
|
14770
|
+
}
|
|
14771
|
+
if (/[0-9]/.test(ch)) {
|
|
14772
|
+
let j = i;
|
|
14773
|
+
while (j < raw.length && /[0-9.]/.test(raw[j])) j += 1;
|
|
14774
|
+
const text = raw.slice(i, j);
|
|
14775
|
+
const value = Number(text);
|
|
14776
|
+
if (!Number.isFinite(value)) {
|
|
14777
|
+
throw new SomaValueLangError(`\u6570\u5B57\u5B57\u9762\u91CF\u975E\u6CD5: "${text}"`, source);
|
|
14778
|
+
}
|
|
14779
|
+
tokens.push({ t: "num", v: value });
|
|
14780
|
+
i = j;
|
|
14781
|
+
continue;
|
|
14782
|
+
}
|
|
14783
|
+
if (/[A-Za-z_]/.test(ch)) {
|
|
14784
|
+
let j = i;
|
|
14785
|
+
while (j < raw.length && /[A-Za-z0-9_.]/.test(raw[j])) j += 1;
|
|
14786
|
+
tokens.push({ t: "id", v: raw.slice(i, j) });
|
|
14787
|
+
i = j;
|
|
14788
|
+
continue;
|
|
14789
|
+
}
|
|
14790
|
+
throw new SomaValueLangError(
|
|
14791
|
+
`\u65E0\u6CD5\u8BC6\u522B\u7684\u5B57\u7B26 "${ch}"\u2014\u2014\u7B97\u672F\u53EA\u652F\u6301\u8DEF\u5F84\u3001\u6570\u5B57\u3001+ - * / \u4E0E\u62EC\u53F7`,
|
|
14792
|
+
source
|
|
14793
|
+
);
|
|
14794
|
+
}
|
|
14795
|
+
return tokens;
|
|
14796
|
+
}
|
|
14797
|
+
var Parser = class {
|
|
14798
|
+
constructor(tokens, source, hasVar, paths) {
|
|
14799
|
+
this.tokens = tokens;
|
|
14800
|
+
this.source = source;
|
|
14801
|
+
this.hasVar = hasVar;
|
|
14802
|
+
this.paths = paths;
|
|
14803
|
+
this.pos = 0;
|
|
14804
|
+
}
|
|
14805
|
+
parse() {
|
|
14806
|
+
const node = this.expression();
|
|
14807
|
+
if (this.pos < this.tokens.length) {
|
|
14808
|
+
throw new SomaValueLangError("\u7B97\u672F\u8868\u8FBE\u5F0F\u6709\u591A\u4F59\u8BCD\u5143\uFF08\u62EC\u53F7\u662F\u5426\u914D\u5BF9\uFF1F\uFF09", this.source);
|
|
14809
|
+
}
|
|
14810
|
+
return node;
|
|
14811
|
+
}
|
|
14812
|
+
/** 表达式 := 项 { ("+"|"-") 项 } */
|
|
14813
|
+
expression() {
|
|
14814
|
+
let left = this.term();
|
|
14815
|
+
for (; ; ) {
|
|
14816
|
+
const token = this.tokens[this.pos];
|
|
14817
|
+
if (token?.t === "op" && (token.v === "+" || token.v === "-")) {
|
|
14818
|
+
this.pos += 1;
|
|
14819
|
+
left = { kind: "arith", op: token.v, left, right: this.term() };
|
|
14820
|
+
continue;
|
|
14821
|
+
}
|
|
14822
|
+
return left;
|
|
14823
|
+
}
|
|
14824
|
+
}
|
|
14825
|
+
/** 项 := 因子 { ("*"|"/") 因子 } */
|
|
14826
|
+
term() {
|
|
14827
|
+
let left = this.factor();
|
|
14828
|
+
for (; ; ) {
|
|
14829
|
+
const token = this.tokens[this.pos];
|
|
14830
|
+
if (token?.t === "op" && (token.v === "*" || token.v === "/")) {
|
|
14831
|
+
this.pos += 1;
|
|
14832
|
+
left = { kind: "arith", op: token.v, left, right: this.factor() };
|
|
14833
|
+
continue;
|
|
14834
|
+
}
|
|
14835
|
+
return left;
|
|
14836
|
+
}
|
|
14837
|
+
}
|
|
14838
|
+
/** 因子 := 路径 | 数字 | "(" 表达式 ")" | "-" 因子 */
|
|
14839
|
+
factor() {
|
|
14840
|
+
const token = this.tokens[this.pos];
|
|
14841
|
+
if (!token) {
|
|
14842
|
+
throw new SomaValueLangError("\u7B97\u672F\u8868\u8FBE\u5F0F\u4E0D\u5B8C\u6574\uFF08\u7F3A\u5C11\u8FD0\u7B97\u6570\uFF09", this.source);
|
|
14843
|
+
}
|
|
14844
|
+
if (token.t === "op" && token.v === "-") {
|
|
14845
|
+
this.pos += 1;
|
|
14846
|
+
return { kind: "neg", operand: this.factor() };
|
|
14847
|
+
}
|
|
14848
|
+
if (token.t === "num") {
|
|
14849
|
+
this.pos += 1;
|
|
14850
|
+
return { kind: "lit", value: token.v };
|
|
14851
|
+
}
|
|
14852
|
+
if (token.t === "id") {
|
|
14853
|
+
this.pos += 1;
|
|
14854
|
+
return this.pathNode(token.v);
|
|
14855
|
+
}
|
|
14856
|
+
if (token.t === "(") {
|
|
14857
|
+
this.pos += 1;
|
|
14858
|
+
const inner = this.expression();
|
|
14859
|
+
if (this.tokens[this.pos]?.t !== ")") {
|
|
14860
|
+
throw new SomaValueLangError("\u62EC\u53F7\u672A\u95ED\u5408", this.source);
|
|
14861
|
+
}
|
|
14862
|
+
this.pos += 1;
|
|
14863
|
+
return inner;
|
|
14864
|
+
}
|
|
14865
|
+
throw new SomaValueLangError("\u7B97\u672F\u8868\u8FBE\u5F0F\u4E2D\u51FA\u73B0\u610F\u5916\u8BCD\u5143", this.source);
|
|
14866
|
+
}
|
|
14867
|
+
pathNode(text) {
|
|
14868
|
+
if (text === "true" || text === "false") {
|
|
14869
|
+
return { kind: "lit", value: text === "true" };
|
|
14870
|
+
}
|
|
14871
|
+
const head = text.split(".")[0];
|
|
14872
|
+
if (!this.hasVar(head)) {
|
|
14873
|
+
throw new SomaValueLangError(
|
|
14874
|
+
`\u8DEF\u5F84 "${text}" \u7684\u9996\u6BB5 "${head}" \u4E0D\u5728\u5F53\u524D\u4F5C\u7528\u57DF\u2014\u2014\u7B97\u672F\u53EA\u63A5\u53D7\u7ED1\u5B9A\u8DEF\u5F84\u4E0E\u6570\u5B57`,
|
|
14875
|
+
this.source
|
|
14876
|
+
);
|
|
14877
|
+
}
|
|
14878
|
+
this.paths.push(text);
|
|
14879
|
+
return { kind: "path", path: text };
|
|
14880
|
+
}
|
|
14881
|
+
};
|
|
14882
|
+
function isArithSegment(segment) {
|
|
14883
|
+
return ARITH_HINT.test(segment);
|
|
14884
|
+
}
|
|
14885
|
+
function parseValueSegment(segment, hasVar, position = "display", source = segment) {
|
|
14886
|
+
const raw = segment.trim();
|
|
14887
|
+
if (!raw) {
|
|
14888
|
+
throw new SomaValueLangError("\u503C\u6BB5\u4E3A\u7A7A", source);
|
|
14889
|
+
}
|
|
14890
|
+
const forbidden = raw.match(FORBIDDEN);
|
|
14891
|
+
if (forbidden) {
|
|
14892
|
+
throw new SomaValueLangError(
|
|
14893
|
+
`\u4E0D\u652F\u6301\u7684\u8FD0\u7B97\u7B26 "${forbidden[0]}"\u2014\u2014\u6BD4\u8F83\u4E0E\u5E03\u5C14\u8FD0\u7B97\u4E0D\u8FDB DSL\uFF0C\u5224\u65AD\u5199\u8FDB Domain\uFF08\u663E\u9690\u7528 when + ! \u524D\u7F00\uFF0C\u591A\u5206\u652F\u7528 match \u7BA1\u9053\u6216\u7EC4\u4EF6\u591A\u6001\uFF09`,
|
|
14894
|
+
source
|
|
14895
|
+
);
|
|
14896
|
+
}
|
|
14897
|
+
if (!isArithSegment(raw)) {
|
|
14898
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) {
|
|
14899
|
+
return { node: { kind: "lit", value: Number(raw) }, paths: [] };
|
|
14900
|
+
}
|
|
14901
|
+
if (raw === "true" || raw === "false") {
|
|
14902
|
+
return { node: { kind: "lit", value: raw === "true" }, paths: [] };
|
|
14903
|
+
}
|
|
14904
|
+
const head = raw.split(/[.\s]/)[0];
|
|
14905
|
+
if (hasVar(head)) {
|
|
14906
|
+
if (!PATH_SHAPE.test(raw)) {
|
|
14907
|
+
throw new SomaValueLangError(
|
|
14908
|
+
`\u8DEF\u5F84 "${raw}" \u542B\u975E\u6CD5\u5B57\u7B26\u2014\u2014\u8DEF\u5F84\u53EA\u5141\u8BB8\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u4E0E\u70B9\uFF08\u82E5\u672C\u610F\u662F\u5B57\u9762\u91CF\u6587\u6848\uFF0C\u8BF7\u6362\u4E00\u4E2A\u4E0D\u4EE5\u4F5C\u7528\u57DF\u53D8\u91CF\u5F00\u5934\u7684\u5199\u6CD5\u6216\u52A0\u5F15\u53F7\uFF09`,
|
|
14909
|
+
source
|
|
14910
|
+
);
|
|
14911
|
+
}
|
|
14912
|
+
return { node: { kind: "path", path: raw }, paths: [raw] };
|
|
14913
|
+
}
|
|
14914
|
+
return { node: { kind: "lit", value: raw }, paths: [] };
|
|
14915
|
+
}
|
|
14916
|
+
if (position !== "display") {
|
|
14917
|
+
throw new SomaValueLangError(
|
|
14918
|
+
`\u7B97\u672F\u53EA\u5141\u8BB8\u51FA\u73B0\u5728\u5C55\u793A\u503C\u4F4D\uFF0C\u5F53\u524D\u4F4D\u7F6E\u662F ${position}\u2014\u2014\u7B97\u51FA\u6765\u7684\u503C\u4E0D\u9A71\u52A8\u884C\u4E3A\uFF0C\u4E1A\u52A1\u5224\u65AD\u7559\u5728 Domain`,
|
|
14919
|
+
source
|
|
14920
|
+
);
|
|
14921
|
+
}
|
|
14922
|
+
const paths = [];
|
|
14923
|
+
const node = new Parser(tokenize(raw, source), source, hasVar, paths).parse();
|
|
14924
|
+
return { node, paths };
|
|
14925
|
+
}
|
|
14926
|
+
function isPlainPath(node) {
|
|
14927
|
+
return node.kind === "path";
|
|
14928
|
+
}
|
|
14929
|
+
function evaluateValueNode(node, read, options = {}) {
|
|
14930
|
+
switch (node.kind) {
|
|
14931
|
+
case "lit":
|
|
14932
|
+
return node.value;
|
|
14933
|
+
case "path":
|
|
14934
|
+
return read(node.path);
|
|
14935
|
+
case "neg": {
|
|
14936
|
+
const operand = toNumber(evaluateValueNode(node.operand, read, options), node, options);
|
|
14937
|
+
return operand === null ? null : -operand;
|
|
14938
|
+
}
|
|
14939
|
+
case "arith": {
|
|
14940
|
+
const left = toNumber(evaluateValueNode(node.left, read, options), node, options);
|
|
14941
|
+
const right = toNumber(evaluateValueNode(node.right, read, options), node, options);
|
|
14942
|
+
if (left === null || right === null) return null;
|
|
14943
|
+
if (node.op === "/" && right === 0) {
|
|
14944
|
+
if (options.dev) {
|
|
14945
|
+
throw new SomaValueLangError("\u9664\u6570\u4E3A 0", describeNode(node));
|
|
14946
|
+
}
|
|
14947
|
+
return null;
|
|
14948
|
+
}
|
|
14949
|
+
switch (node.op) {
|
|
14950
|
+
case "+":
|
|
14951
|
+
return left + right;
|
|
14952
|
+
case "-":
|
|
14953
|
+
return left - right;
|
|
14954
|
+
case "*":
|
|
14955
|
+
return left * right;
|
|
14956
|
+
case "/":
|
|
14957
|
+
return left / right;
|
|
14958
|
+
}
|
|
14959
|
+
}
|
|
14960
|
+
}
|
|
14961
|
+
return null;
|
|
14962
|
+
}
|
|
14963
|
+
function toNumber(value, node, options) {
|
|
14964
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
14965
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
14966
|
+
const parsed = Number(value);
|
|
14967
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
14968
|
+
}
|
|
14969
|
+
if (options.dev) {
|
|
14970
|
+
throw new SomaValueLangError(
|
|
14971
|
+
`\u7B97\u672F\u8FD0\u7B97\u6570\u4E0D\u662F\u6570\u503C: ${JSON.stringify(value)}`,
|
|
14972
|
+
describeNode(node)
|
|
14973
|
+
);
|
|
14974
|
+
}
|
|
14975
|
+
return null;
|
|
14976
|
+
}
|
|
14977
|
+
function describeNode(node) {
|
|
14978
|
+
switch (node.kind) {
|
|
14979
|
+
case "lit":
|
|
14980
|
+
return String(node.value);
|
|
14981
|
+
case "path":
|
|
14982
|
+
return node.path;
|
|
14983
|
+
case "neg":
|
|
14984
|
+
return `-${describeNode(node.operand)}`;
|
|
14985
|
+
case "arith":
|
|
14986
|
+
return `${describeNode(node.left)} ${node.op} ${describeNode(node.right)}`;
|
|
14987
|
+
}
|
|
14988
|
+
}
|
|
14989
|
+
|
|
14990
|
+
// core/build/v2/html-index.ts
|
|
14991
|
+
var ANCHOR_RE = /data-soma-id=["']([^"']+)["']/g;
|
|
14992
|
+
var COMPONENT_NEAR_RE = /data-soma-component=["']([^"']+)["']/;
|
|
14993
|
+
var HOST_RE = /data-soma-host=["']([^"']+)["']/;
|
|
14994
|
+
var TEMPLATE_OPEN_RE = /<template[^>]*data-soma-role=["']([^"']+)["'][^>]*>/gi;
|
|
14995
|
+
function buildHtmlAnchorIndex(html) {
|
|
14996
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
14997
|
+
const instances = /* @__PURE__ */ new Set();
|
|
14998
|
+
const duplicates = [];
|
|
14999
|
+
const templateRanges = [];
|
|
15000
|
+
for (const match of html.matchAll(TEMPLATE_OPEN_RE)) {
|
|
15001
|
+
const start = match.index ?? 0;
|
|
15002
|
+
const closeIndex = html.indexOf("</template>", start);
|
|
15003
|
+
templateRanges.push({
|
|
15004
|
+
start,
|
|
15005
|
+
end: closeIndex === -1 ? html.length : closeIndex,
|
|
15006
|
+
role: match[1]
|
|
15007
|
+
});
|
|
15008
|
+
}
|
|
15009
|
+
const lineAt = (index) => html.slice(0, index).split("\n").length;
|
|
15010
|
+
const roleAt = (index) => templateRanges.find((range) => index > range.start && index < range.end)?.role;
|
|
15011
|
+
const ownerListAt = (index) => {
|
|
15012
|
+
const range = templateRanges.find((r) => index > r.start && index < r.end);
|
|
15013
|
+
if (!range) return void 0;
|
|
15014
|
+
const before = html.slice(0, range.start);
|
|
15015
|
+
const matches = [...before.matchAll(/<[a-zA-Z][^>]*data-soma-id=["']([^"']+)["'][^>]*>/g)];
|
|
15016
|
+
return matches.length > 0 ? matches[matches.length - 1][1] : void 0;
|
|
15017
|
+
};
|
|
15018
|
+
const tagRe = /<[a-zA-Z][^>]*>/g;
|
|
15019
|
+
for (const tagMatch of html.matchAll(tagRe)) {
|
|
15020
|
+
const tag = tagMatch[0];
|
|
15021
|
+
const tagIndex = tagMatch.index ?? 0;
|
|
15022
|
+
ANCHOR_RE.lastIndex = 0;
|
|
15023
|
+
const idMatch = ANCHOR_RE.exec(tag);
|
|
15024
|
+
if (!idMatch) continue;
|
|
15025
|
+
const somaId = idMatch[1];
|
|
15026
|
+
if (anchors.has(somaId)) {
|
|
15027
|
+
if (!duplicates.includes(somaId)) duplicates.push(somaId);
|
|
15028
|
+
continue;
|
|
15029
|
+
}
|
|
15030
|
+
const componentMatch = COMPONENT_NEAR_RE.exec(tag);
|
|
15031
|
+
const role = roleAt(tagIndex);
|
|
15032
|
+
const owner = role !== void 0 ? ownerListAt(tagIndex) : void 0;
|
|
15033
|
+
const info = {
|
|
15034
|
+
somaId,
|
|
15035
|
+
line: lineAt(tagIndex),
|
|
15036
|
+
inRowTemplate: role !== void 0,
|
|
15037
|
+
...role ? { rowRole: role } : {},
|
|
15038
|
+
...owner ? { ownerList: owner } : {},
|
|
15039
|
+
...componentMatch ? { component: componentMatch[1] } : {}
|
|
15040
|
+
};
|
|
15041
|
+
anchors.set(somaId, info);
|
|
15042
|
+
if (componentMatch) instances.add(somaId);
|
|
15043
|
+
}
|
|
15044
|
+
const hostMatch = HOST_RE.exec(html);
|
|
15045
|
+
return {
|
|
15046
|
+
anchors,
|
|
15047
|
+
instances,
|
|
15048
|
+
duplicates,
|
|
15049
|
+
...hostMatch ? { host: hostMatch[1] } : {}
|
|
15050
|
+
};
|
|
15051
|
+
}
|
|
15052
|
+
|
|
15053
|
+
// core/client/parser/v2/namespace.ts
|
|
15054
|
+
var SomaScopeError = class extends Error {
|
|
15055
|
+
constructor(message, blockId) {
|
|
15056
|
+
super(`[soma-core][\u5F15\u64CE] ${message}\uFF08\u5757: ${blockId}\uFF09`);
|
|
15057
|
+
this.blockId = blockId;
|
|
15058
|
+
this.name = "SomaScopeError";
|
|
15059
|
+
}
|
|
15060
|
+
};
|
|
15061
|
+
var RESERVED = /* @__PURE__ */ new Set(["page", "p", "ctrl"]);
|
|
15062
|
+
var NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
15063
|
+
function buildBlockScope(input) {
|
|
15064
|
+
const blockId = input.blockId;
|
|
15065
|
+
const dataNames = new Set(input.dataNames ?? []);
|
|
15066
|
+
const rowVars = new Set(input.rowVars ?? []);
|
|
15067
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
15068
|
+
for (const name of dataNames) {
|
|
15069
|
+
if (RESERVED.has(name)) {
|
|
15070
|
+
throw new SomaScopeError(`data \u5BF9\u8C61\u540D "${name}" \u662F\u4FDD\u7559\u540D\uFF08page/p/ctrl\uFF09`, blockId);
|
|
15071
|
+
}
|
|
15072
|
+
if (!NAME_RE.test(name)) {
|
|
15073
|
+
throw new SomaScopeError(`data \u5BF9\u8C61\u540D "${name}" \u975E\u6CD5\uFF08\u5B57\u6BCD\u5F00\u5934\uFF0C\u5B57\u6BCD\u6570\u5B57\u4E0B\u5212\u7EBF\uFF09`, blockId);
|
|
15074
|
+
}
|
|
15075
|
+
if (rowVars.has(name)) {
|
|
15076
|
+
throw new SomaScopeError(
|
|
15077
|
+
`data \u5BF9\u8C61\u540D "${name}" \u4E0E\u884C\u53D8\u91CF\u540C\u540D\u2014\u2014\u540C\u4E00\u4E2A\u540D\u5B57\u4E24\u79CD\u542B\u4E49\uFF0C\u89E3\u6790\u65F6\u65E0\u6CD5\u5224\u5B9A`,
|
|
15078
|
+
blockId
|
|
15079
|
+
);
|
|
15080
|
+
}
|
|
15081
|
+
}
|
|
15082
|
+
for (const [name, raw] of Object.entries(input.aliasRaw ?? {})) {
|
|
15083
|
+
if (typeof raw !== "string" || raw.trim() === "") {
|
|
15084
|
+
throw new SomaScopeError(`alias "${name}" \u7684\u503C\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`, blockId);
|
|
15085
|
+
}
|
|
15086
|
+
if (!NAME_RE.test(name)) {
|
|
15087
|
+
throw new SomaScopeError(`alias \u540D "${name}" \u975E\u6CD5\uFF08\u5B57\u6BCD\u5F00\u5934\uFF0C\u5B57\u6BCD\u6570\u5B57\u4E0B\u5212\u7EBF\uFF09`, blockId);
|
|
15088
|
+
}
|
|
15089
|
+
if (RESERVED.has(name) || dataNames.has(name) || rowVars.has(name)) {
|
|
15090
|
+
throw new SomaScopeError(
|
|
15091
|
+
`alias "${name}" \u906E\u853D\u4E86\u5DF2\u6709\u540D\u5B57\uFF08\u4FDD\u7559\u540D/data \u5BF9\u8C61/\u884C\u53D8\u91CF\uFF09\u2014\u2014\u522B\u540D\u4E0D\u5F97\u6539\u53D8\u65E2\u6709\u540D\u5B57\u7684\u542B\u4E49`,
|
|
15092
|
+
blockId
|
|
15093
|
+
);
|
|
15094
|
+
}
|
|
15095
|
+
const target = raw.trim();
|
|
15096
|
+
const kind = target.startsWith("/") ? "api" : "path";
|
|
15097
|
+
if (kind === "path") {
|
|
15098
|
+
const head = target.split(".")[0];
|
|
15099
|
+
if (aliases.has(head)) {
|
|
15100
|
+
throw new SomaScopeError(
|
|
15101
|
+
`alias "${name}" \u6307\u5411\u53E6\u4E00\u4E2A\u522B\u540D "${head}"\u2014\u2014\u522B\u540D\u4E0D\u5F97\u9012\u5F52\uFF08\u5C55\u5F00\u987A\u5E8F\u4F1A\u53D8\u6210\u9690\u85CF\u89C4\u5219\uFF09`,
|
|
15102
|
+
blockId
|
|
15103
|
+
);
|
|
15104
|
+
}
|
|
15105
|
+
}
|
|
15106
|
+
aliases.set(name, { kind, target });
|
|
15107
|
+
}
|
|
15108
|
+
return { blockId, dataNames, aliases, rowVars, pageVar: "page" };
|
|
15109
|
+
}
|
|
15110
|
+
function resolvePath(raw, scope) {
|
|
15111
|
+
const text = raw.trim();
|
|
15112
|
+
if (text === "") return { kind: "literal" };
|
|
15113
|
+
const segments = text.split(".");
|
|
15114
|
+
const head = segments[0];
|
|
15115
|
+
const alias = scope.aliases.get(head);
|
|
15116
|
+
if (alias?.kind === "path") {
|
|
15117
|
+
const expanded = [alias.target, ...segments.slice(1)].join(".");
|
|
15118
|
+
return resolvePath(expanded, { ...scope, aliases: /* @__PURE__ */ new Map() });
|
|
15119
|
+
}
|
|
15120
|
+
const inData = scope.dataNames.has(head);
|
|
15121
|
+
const inRow = scope.rowVars.has(head);
|
|
15122
|
+
const isPage = head === scope.pageVar;
|
|
15123
|
+
const hits = [inData, inRow, isPage].filter(Boolean).length;
|
|
15124
|
+
if (hits > 1) {
|
|
15125
|
+
const candidates = [
|
|
15126
|
+
inData ? `data \u5BF9\u8C61 ${scope.blockId}.${head}` : "",
|
|
15127
|
+
inRow ? `\u884C\u53D8\u91CF ${head}` : "",
|
|
15128
|
+
isPage ? "\u9875\u9762\u53D8\u91CF page" : ""
|
|
15129
|
+
].filter(Boolean);
|
|
15130
|
+
throw new SomaScopeError(
|
|
15131
|
+
`\u540D\u5B57 "${head}" \u6709\u6B67\u4E49\uFF0C\u540C\u65F6\u5339\u914D ${candidates.join(" / ")}\u2014\u2014\u8BF7\u6539\u540D\u4EE5\u6D88\u9664\u6B67\u4E49`,
|
|
15132
|
+
scope.blockId
|
|
15133
|
+
);
|
|
15134
|
+
}
|
|
15135
|
+
if (inData) {
|
|
15136
|
+
return { kind: "data", full: [`${scope.blockId}.${head}`, ...segments.slice(1)].join(".") };
|
|
15137
|
+
}
|
|
15138
|
+
if (inRow) return { kind: "row", full: text };
|
|
15139
|
+
if (isPage) return { kind: "page", full: text };
|
|
15140
|
+
return { kind: "literal" };
|
|
15141
|
+
}
|
|
15142
|
+
function resolveApiRef(raw, scope) {
|
|
15143
|
+
const text = raw.trim();
|
|
15144
|
+
const alias = scope.aliases.get(text);
|
|
15145
|
+
if (alias) {
|
|
15146
|
+
if (alias.kind !== "api") {
|
|
15147
|
+
throw new SomaScopeError(
|
|
15148
|
+
`"${text}" \u662F\u8DEF\u5F84\u522B\u540D\uFF0C\u4E0D\u80FD\u7528\u5728 api \u4F4D\uFF08API \u522B\u540D\u7684\u503C\u987B\u4EE5 / \u5F00\u5934\uFF09`,
|
|
15149
|
+
scope.blockId
|
|
15150
|
+
);
|
|
15151
|
+
}
|
|
15152
|
+
return alias.target;
|
|
15153
|
+
}
|
|
15154
|
+
return text;
|
|
15155
|
+
}
|
|
15156
|
+
function scopeHasVar(scope) {
|
|
15157
|
+
return (segment) => {
|
|
15158
|
+
const alias = scope.aliases.get(segment);
|
|
15159
|
+
if (alias?.kind === "path") return true;
|
|
15160
|
+
return scope.dataNames.has(segment) || scope.rowVars.has(segment) || segment === scope.pageVar;
|
|
15161
|
+
};
|
|
15162
|
+
}
|
|
15163
|
+
function expandPath(raw, scope) {
|
|
15164
|
+
const resolved = resolvePath(raw, scope);
|
|
15165
|
+
return resolved.kind === "literal" ? raw.trim() : resolved.full;
|
|
15166
|
+
}
|
|
15167
|
+
|
|
15168
|
+
// core/client/parser/v2/page-parser.ts
|
|
15169
|
+
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
15170
|
+
"domain",
|
|
15171
|
+
"locale",
|
|
15172
|
+
"ui",
|
|
15173
|
+
"watch",
|
|
15174
|
+
"event",
|
|
15175
|
+
"data",
|
|
15176
|
+
"adaptive",
|
|
15177
|
+
"alias",
|
|
15178
|
+
// initProps:引擎启动前写入的初始值(v1 UiConfig 同名字段的直通)。
|
|
15179
|
+
//
|
|
15180
|
+
// v2 是照**手写页面**设计的——那里文案住 HTML、初值住 Domain,声明里不需要它。
|
|
15181
|
+
// 但 v2 产的是 v1 等价物,而生成链的页面把字面文案内联在 initProps 里
|
|
15182
|
+
// (模型出的是组织意图,没有 Domain 可写)。少了这个键,AI 产的页面
|
|
15183
|
+
// 就永远迈不过 v2 的门槛——不是"用不上 v2",是"表达不了"。
|
|
15184
|
+
"initProps"
|
|
15185
|
+
]);
|
|
15186
|
+
var SUFFIXES = ["when", "model", "class"];
|
|
15187
|
+
function parsePageBlock(input) {
|
|
15188
|
+
const { body } = input;
|
|
15189
|
+
const fail = (message) => {
|
|
15190
|
+
throw new SomaV2ParseError(message, "page");
|
|
15191
|
+
};
|
|
15192
|
+
for (const key of Object.keys(body)) {
|
|
15193
|
+
if (!PAGE_KEYS.has(key)) {
|
|
15194
|
+
fail(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
|
|
15195
|
+
}
|
|
15196
|
+
}
|
|
15197
|
+
const domain = body.domain;
|
|
15198
|
+
if (typeof domain !== "string" || domain.trim() === "") {
|
|
15199
|
+
fail("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
|
|
15200
|
+
}
|
|
15201
|
+
const scope = buildBlockScope({
|
|
15202
|
+
blockId: "page",
|
|
15203
|
+
dataNames: Object.keys(body.data ?? {}),
|
|
15204
|
+
aliasRaw: body.alias
|
|
15205
|
+
});
|
|
15206
|
+
const show = {};
|
|
15207
|
+
const locale = body.locale;
|
|
15208
|
+
if (locale !== void 0) {
|
|
15209
|
+
if (!Array.isArray(locale)) fail("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
|
|
15210
|
+
for (const item of locale) {
|
|
15211
|
+
const key = String(item);
|
|
15212
|
+
if (!input.anchors.has(key)) {
|
|
15213
|
+
fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
|
|
15214
|
+
}
|
|
15215
|
+
if (input.localeKeys && !input.localeKeys.has(key)) {
|
|
15216
|
+
fail(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
|
|
15217
|
+
}
|
|
15218
|
+
show[key] = `page._locale.${key}`;
|
|
15219
|
+
}
|
|
15220
|
+
}
|
|
15221
|
+
const uiRaw = body.ui ?? {};
|
|
15222
|
+
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
15223
|
+
parseShowLevel(uiRaw, show, scope, input, "page");
|
|
15224
|
+
const bind = { obj: String(domain), var: "page" };
|
|
15225
|
+
const watch = body.watch;
|
|
15226
|
+
if (watch !== void 0) {
|
|
15227
|
+
if (!Array.isArray(watch)) fail("watch \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
15228
|
+
const rules = [];
|
|
15229
|
+
for (const item of watch) {
|
|
15230
|
+
if (!item || typeof item !== "object") fail("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
|
|
15231
|
+
const path = item.path;
|
|
15232
|
+
const call = item.call;
|
|
15233
|
+
if (typeof path !== "string" || path.trim() === "") fail("watch \u9879\u7F3A\u5C11 path");
|
|
15234
|
+
if (typeof call !== "string" || call.trim() === "") fail("watch \u9879\u7F3A\u5C11 call");
|
|
15235
|
+
const rule = {
|
|
15236
|
+
condition: expandPath(String(path), scope),
|
|
15237
|
+
callback: String(call).includes(".") ? String(call) : `page.${call}`
|
|
15238
|
+
};
|
|
15239
|
+
if (typeof item.debounce === "number") rule.debounce = item.debounce;
|
|
15240
|
+
if (typeof item.refresh === "boolean") rule.refresh = item.refresh;
|
|
15241
|
+
rules.push(rule);
|
|
15242
|
+
}
|
|
15243
|
+
if (rules.length > 0) bind.onChange = rules;
|
|
15244
|
+
}
|
|
15245
|
+
const ui = { bind, show };
|
|
15246
|
+
if (body.initProps !== void 0) {
|
|
15247
|
+
if (body.initProps === null || typeof body.initProps !== "object" || Array.isArray(body.initProps)) {
|
|
15248
|
+
fail("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
|
|
15249
|
+
}
|
|
15250
|
+
ui.initProps = body.initProps;
|
|
15251
|
+
}
|
|
15252
|
+
if (body.adaptive !== void 0) {
|
|
15253
|
+
ui.adaptive = body.adaptive;
|
|
15254
|
+
}
|
|
15255
|
+
const eventRaw = normalizeEventSection(body.event, input, fail);
|
|
15256
|
+
return {
|
|
15257
|
+
ui,
|
|
15258
|
+
eventRaw,
|
|
15259
|
+
...body.data ? { dataRaw: body.data } : {},
|
|
15260
|
+
scope
|
|
15261
|
+
};
|
|
15262
|
+
}
|
|
15263
|
+
function parseShowLevel(raw, target, scope, input, where) {
|
|
15264
|
+
const fail = (message) => {
|
|
15265
|
+
throw new SomaV2ParseError(message, "page");
|
|
15266
|
+
};
|
|
15267
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
15268
|
+
if (key === "each") continue;
|
|
15269
|
+
const { anchor, suffix, attr } = splitKey(key);
|
|
15270
|
+
if (input.instances.has(anchor)) {
|
|
15271
|
+
fail(
|
|
15272
|
+
`"${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`
|
|
15273
|
+
);
|
|
15274
|
+
}
|
|
15275
|
+
if (!input.anchors.has(anchor)) {
|
|
15276
|
+
fail(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
|
|
15277
|
+
}
|
|
15278
|
+
if (isEachBlock(value)) {
|
|
15279
|
+
target[anchor] = parseEachBlock(value, scope, input, anchor);
|
|
15280
|
+
continue;
|
|
15281
|
+
}
|
|
15282
|
+
if (suffix) {
|
|
15283
|
+
const existing2 = asExtended(target[anchor]);
|
|
15284
|
+
applySuffix(existing2, suffix, value, scope, fail);
|
|
15285
|
+
target[anchor] = existing2;
|
|
15286
|
+
continue;
|
|
15287
|
+
}
|
|
15288
|
+
if (attr) {
|
|
15289
|
+
if (value !== null && typeof value === "object") {
|
|
15290
|
+
fail(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
|
|
15291
|
+
}
|
|
15292
|
+
target[`${anchor}@${attr}`] = expandValue(value, scope, fail);
|
|
15293
|
+
continue;
|
|
15294
|
+
}
|
|
15295
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
15296
|
+
fail(
|
|
15297
|
+
`"${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`
|
|
15298
|
+
);
|
|
15299
|
+
}
|
|
15300
|
+
const expanded = expandValue(value, scope, fail);
|
|
15301
|
+
const existing = target[anchor];
|
|
15302
|
+
if (existing !== void 0 && typeof existing === "object" && !Array.isArray(existing)) {
|
|
15303
|
+
existing.text = expanded;
|
|
15304
|
+
} else {
|
|
15305
|
+
target[anchor] = expanded;
|
|
15306
|
+
}
|
|
15307
|
+
}
|
|
15308
|
+
}
|
|
15309
|
+
function isEachBlock(value) {
|
|
15310
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.each === "string";
|
|
15311
|
+
}
|
|
15312
|
+
function parseEachBlock(block, scope, input, anchor) {
|
|
15313
|
+
const fail = (message) => {
|
|
15314
|
+
throw new SomaV2ParseError(message, "page");
|
|
15315
|
+
};
|
|
15316
|
+
const raw = String(block.each);
|
|
15317
|
+
const match = /^(\S+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw.trim());
|
|
15318
|
+
if (!match) {
|
|
15319
|
+
fail(`each \u8BED\u6CD5\u9519\u8BEF: "${raw}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
|
|
15320
|
+
}
|
|
15321
|
+
const [, sourcePath, rowVar, byPath] = match;
|
|
15322
|
+
const bind = {
|
|
15323
|
+
obj: expandPath(sourcePath, scope),
|
|
15324
|
+
var: rowVar
|
|
15325
|
+
};
|
|
15326
|
+
if (byPath) bind.role_by = byPath;
|
|
15327
|
+
const rowScope = {
|
|
15328
|
+
...scope,
|
|
15329
|
+
rowVars: /* @__PURE__ */ new Set([...scope.rowVars, rowVar])
|
|
15330
|
+
};
|
|
15331
|
+
const childShow = {};
|
|
15332
|
+
const nested = {};
|
|
15333
|
+
for (const [key, value] of Object.entries(block)) {
|
|
15334
|
+
if (key === "each") continue;
|
|
15335
|
+
nested[key] = value;
|
|
15336
|
+
}
|
|
15337
|
+
parseShowLevel(nested, childShow, rowScope, input, `\u5217\u8868 ${anchor}`);
|
|
15338
|
+
return { bind, show: childShow };
|
|
15339
|
+
}
|
|
15340
|
+
function splitKey(key) {
|
|
15341
|
+
const atIndex = key.indexOf("@");
|
|
15342
|
+
if (atIndex > 0) {
|
|
15343
|
+
return { anchor: key.slice(0, atIndex), attr: key.slice(atIndex + 1) };
|
|
15344
|
+
}
|
|
15345
|
+
const dotIndex = key.lastIndexOf(".");
|
|
15346
|
+
if (dotIndex > 0) {
|
|
15347
|
+
const tail = key.slice(dotIndex + 1);
|
|
15348
|
+
if (SUFFIXES.includes(tail)) {
|
|
15349
|
+
return { anchor: key.slice(0, dotIndex), suffix: tail };
|
|
15350
|
+
}
|
|
15351
|
+
}
|
|
15352
|
+
return { anchor: key };
|
|
15353
|
+
}
|
|
15354
|
+
function asExtended(current) {
|
|
15355
|
+
if (current === void 0) return {};
|
|
15356
|
+
if (typeof current === "string") return { text: current };
|
|
15357
|
+
return current;
|
|
15358
|
+
}
|
|
15359
|
+
function applySuffix(target, suffix, value, scope, fail) {
|
|
15360
|
+
if (suffix === "class") {
|
|
15361
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
15362
|
+
fail(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
|
|
15363
|
+
}
|
|
15364
|
+
const map2 = {};
|
|
15365
|
+
for (const [cls, cond] of Object.entries(value)) {
|
|
15366
|
+
map2[cls] = expandCondition(String(cond), scope);
|
|
15367
|
+
}
|
|
15368
|
+
target.class = map2;
|
|
15369
|
+
return;
|
|
15370
|
+
}
|
|
15371
|
+
if (suffix === "when") {
|
|
15372
|
+
target.when = expandCondition(String(value), scope);
|
|
15373
|
+
return;
|
|
15374
|
+
}
|
|
15375
|
+
target.model = expandPath(String(value), scope);
|
|
15376
|
+
}
|
|
15377
|
+
function expandCondition(raw, scope) {
|
|
15378
|
+
const text = raw.trim();
|
|
15379
|
+
const negated = text.startsWith("!");
|
|
15380
|
+
const bare = negated ? text.slice(1).trim() : text;
|
|
15381
|
+
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
15382
|
+
}
|
|
15383
|
+
function expandValue(value, scope, fail) {
|
|
15384
|
+
if (value === null || value === void 0) fail("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
|
|
15385
|
+
if (typeof value !== "string") return String(value);
|
|
15386
|
+
const segments = String(value).split(/\s+\|\s+/);
|
|
15387
|
+
segments[0] = expandPath(segments[0], scope);
|
|
15388
|
+
return segments.join(" | ");
|
|
15389
|
+
}
|
|
15390
|
+
function normalizeEventSection(raw, input, fail) {
|
|
15391
|
+
if (raw === void 0) return {};
|
|
15392
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
15393
|
+
fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
|
|
15394
|
+
}
|
|
15395
|
+
const section = raw;
|
|
15396
|
+
for (const key of Object.keys(section)) {
|
|
15397
|
+
if (!["on", "timers", "triggers"].includes(key)) {
|
|
15398
|
+
fail(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
|
|
15399
|
+
}
|
|
15400
|
+
}
|
|
15401
|
+
const on = section.on ?? {};
|
|
15402
|
+
if (typeof on !== "object" || Array.isArray(on)) fail("event.on \u5FC5\u987B\u662F\u6620\u5C04");
|
|
15403
|
+
for (const key of Object.keys(on)) {
|
|
15404
|
+
const anchor = key.split(".")[0];
|
|
15405
|
+
if (input.instances.has(anchor)) {
|
|
15406
|
+
fail(
|
|
15407
|
+
`"${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`
|
|
15408
|
+
);
|
|
15409
|
+
}
|
|
15410
|
+
}
|
|
15411
|
+
const result = { ...on };
|
|
15412
|
+
if (section.timers !== void 0) result.timers = section.timers;
|
|
15413
|
+
if (section.triggers !== void 0) result.triggers = section.triggers;
|
|
15414
|
+
return result;
|
|
15415
|
+
}
|
|
15416
|
+
|
|
15417
|
+
// core/client/parser/v2/use-parser.ts
|
|
15418
|
+
var BLOCK_KEYS = /* @__PURE__ */ new Set(["component", "alias", "when", "data", "ui", "event"]);
|
|
15419
|
+
var DATA_OBJECT_KEYS = /* @__PURE__ */ new Set(["from", "save", "refresh", "reload_on", "fields"]);
|
|
15420
|
+
var EVENT_KEYS = /* @__PURE__ */ new Set(["actions", "on"]);
|
|
15421
|
+
var ACTION_KEYS = /* @__PURE__ */ new Set([
|
|
15422
|
+
"label",
|
|
15423
|
+
"handler",
|
|
15424
|
+
"change",
|
|
15425
|
+
"confirm",
|
|
15426
|
+
"permission",
|
|
15427
|
+
"tone",
|
|
15428
|
+
"when",
|
|
15429
|
+
"disabled_reason"
|
|
15430
|
+
]);
|
|
15431
|
+
var FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "values", "permission", "rules"]);
|
|
15432
|
+
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
15433
|
+
"text",
|
|
15434
|
+
"int",
|
|
15435
|
+
"number",
|
|
15436
|
+
"money",
|
|
15437
|
+
"date",
|
|
15438
|
+
"enum",
|
|
15439
|
+
"bool",
|
|
15440
|
+
"percent",
|
|
15441
|
+
// progress 与 percent 同数据两种读法:前者出进度条,后者出文字(见 soma-ui 类型渲染表)
|
|
15442
|
+
"progress"
|
|
15443
|
+
]);
|
|
15444
|
+
function parseUseBlock(input) {
|
|
15445
|
+
const { blockId, body } = input;
|
|
15446
|
+
const fail = (message) => {
|
|
15447
|
+
throw new SomaV2ParseError(message, blockId);
|
|
15448
|
+
};
|
|
15449
|
+
for (const key of Object.keys(body)) {
|
|
15450
|
+
if (!BLOCK_KEYS.has(key)) {
|
|
15451
|
+
fail(`\u7EC4\u4EF6\u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...BLOCK_KEYS].join("/")}\uFF09`);
|
|
15452
|
+
}
|
|
15453
|
+
}
|
|
15454
|
+
const component = body.component === void 0 ? void 0 : String(body.component);
|
|
15455
|
+
if (component && input.htmlComponent && component !== input.htmlComponent) {
|
|
15456
|
+
fail(
|
|
15457
|
+
`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`
|
|
15458
|
+
);
|
|
15459
|
+
}
|
|
15460
|
+
const dataRaw = body.data ?? {};
|
|
15461
|
+
if (typeof dataRaw !== "object" || Array.isArray(dataRaw)) fail("data \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
15462
|
+
const scope = buildBlockScope({
|
|
15463
|
+
blockId,
|
|
15464
|
+
dataNames: Object.keys(dataRaw),
|
|
15465
|
+
aliasRaw: body.alias,
|
|
15466
|
+
rowVars: input.rowVars
|
|
15467
|
+
});
|
|
15468
|
+
const { actions, emitRoutes } = parseEventSection(body.event, blockId, scope, fail);
|
|
15469
|
+
const dataObjects = [];
|
|
15470
|
+
const dataImports = [];
|
|
15471
|
+
for (const [localName, raw] of Object.entries(dataRaw)) {
|
|
15472
|
+
if (typeof raw === "string") {
|
|
15473
|
+
dataImports.push({ localName, targetPath: expandPath(raw, { ...scope, dataNames: /* @__PURE__ */ new Set() }) });
|
|
15474
|
+
continue;
|
|
15475
|
+
}
|
|
15476
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
15477
|
+
fail(`data.${localName} \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u58F0\u660E\uFF09\u6216\u5B57\u7B26\u4E32\u8DEF\u5F84\uFF08\u5F15\u5165\uFF09`);
|
|
15478
|
+
}
|
|
15479
|
+
dataObjects.push(parseDataObject(localName, raw, blockId, scope, actions, fail));
|
|
15480
|
+
}
|
|
15481
|
+
const uiRaw = body.ui ?? {};
|
|
15482
|
+
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
15483
|
+
const when = body.when === void 0 ? void 0 : expandCondition2(String(body.when), scope);
|
|
15484
|
+
const ast = {
|
|
15485
|
+
blockId,
|
|
15486
|
+
...component ? { component } : {},
|
|
15487
|
+
...when ? { when } : {},
|
|
15488
|
+
dataObjects,
|
|
15489
|
+
dataImports,
|
|
15490
|
+
uiRaw: expandUiPaths(uiRaw, scope),
|
|
15491
|
+
actions,
|
|
15492
|
+
emitRoutes,
|
|
15493
|
+
scope,
|
|
15494
|
+
toShowValue() {
|
|
15495
|
+
const value = { props: this.uiRaw };
|
|
15496
|
+
if (this.when) value.when = this.when;
|
|
15497
|
+
return value;
|
|
15498
|
+
}
|
|
15499
|
+
};
|
|
15500
|
+
return ast;
|
|
15501
|
+
}
|
|
15502
|
+
function parseDataObject(localName, raw, blockId, scope, actions, fail) {
|
|
15503
|
+
for (const key of Object.keys(raw)) {
|
|
15504
|
+
if (!DATA_OBJECT_KEYS.has(key)) {
|
|
15505
|
+
fail(`data.${localName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...DATA_OBJECT_KEYS].join("/")}\uFF09`);
|
|
15506
|
+
}
|
|
15507
|
+
}
|
|
15508
|
+
const decl = { localName, fullName: `${blockId}.${localName}` };
|
|
15509
|
+
const from = raw.from;
|
|
15510
|
+
if (from !== void 0) {
|
|
15511
|
+
if (typeof from !== "object" || Array.isArray(from)) fail(`data.${localName}.from \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
15512
|
+
const api = from.api;
|
|
15513
|
+
if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.from \u7F3A\u5C11 api`);
|
|
15514
|
+
const params = {};
|
|
15515
|
+
for (const [key, value] of Object.entries(from.params ?? {})) {
|
|
15516
|
+
params[key] = expandPath(String(value), scope);
|
|
15517
|
+
}
|
|
15518
|
+
decl.from = { api: resolveApiRef(String(api), scope), params };
|
|
15519
|
+
}
|
|
15520
|
+
const save = raw.save;
|
|
15521
|
+
if (save !== void 0) {
|
|
15522
|
+
if (typeof save !== "object" || Array.isArray(save)) fail(`data.${localName}.save \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
15523
|
+
const api = save.api;
|
|
15524
|
+
const trigger = save.trigger;
|
|
15525
|
+
if (typeof api !== "string" || api.trim() === "") fail(`data.${localName}.save \u7F3A\u5C11 api`);
|
|
15526
|
+
if (typeof trigger !== "string" || trigger.trim() === "") {
|
|
15527
|
+
fail(`data.${localName}.save \u7F3A\u5C11 trigger\uFF08\u7531\u54EA\u4E2A\u52A8\u4F5C\u89E6\u53D1\u56DE\u5199\uFF09`);
|
|
15528
|
+
}
|
|
15529
|
+
if (!actions.has(String(trigger))) {
|
|
15530
|
+
const known = [...actions.keys()].join("/") || "\uFF08\u672C\u5757\u672A\u5B9A\u4E49\u4EFB\u4F55\u52A8\u4F5C\uFF09";
|
|
15531
|
+
fail(
|
|
15532
|
+
`data.${localName}.save.trigger \u6307\u5411\u672A\u5B9A\u4E49\u7684\u52A8\u4F5C "${trigger}"\u2014\u2014\u8BF7\u5728 event.actions \u91CC\u5B9A\u4E49\u5B83\uFF08\u73B0\u6709\uFF1A${known}\uFF09`
|
|
15533
|
+
);
|
|
15534
|
+
}
|
|
15535
|
+
decl.save = {
|
|
15536
|
+
api: resolveApiRef(String(api), scope),
|
|
15537
|
+
method: String(save.method ?? "POST").toUpperCase(),
|
|
15538
|
+
trigger: String(trigger),
|
|
15539
|
+
...save.key !== void 0 ? { key: String(save.key) } : {},
|
|
15540
|
+
...Array.isArray(save.fields) ? { fields: save.fields.map(String) } : {}
|
|
15541
|
+
};
|
|
15542
|
+
}
|
|
15543
|
+
if (raw.refresh !== void 0) decl.refreshMs = parseDuration(String(raw.refresh), localName, fail);
|
|
15544
|
+
if (raw.reload_on !== void 0) {
|
|
15545
|
+
if (!Array.isArray(raw.reload_on)) fail(`data.${localName}.reload_on \u5FC5\u987B\u662F\u6570\u7EC4`);
|
|
15546
|
+
decl.reloadOn = raw.reload_on.map((item) => expandPath(String(item), scope));
|
|
15547
|
+
}
|
|
15548
|
+
if (raw.fields !== void 0) {
|
|
15549
|
+
const fieldsRaw = raw.fields;
|
|
15550
|
+
if (typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
|
|
15551
|
+
fail(`data.${localName}.fields \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
15552
|
+
}
|
|
15553
|
+
const fields = {};
|
|
15554
|
+
for (const [fieldName, fieldRaw] of Object.entries(fieldsRaw)) {
|
|
15555
|
+
fields[fieldName] = parseField2(localName, fieldName, fieldRaw, fail);
|
|
15556
|
+
}
|
|
15557
|
+
decl.fields = fields;
|
|
15558
|
+
}
|
|
15559
|
+
return decl;
|
|
15560
|
+
}
|
|
15561
|
+
function parseField2(objectName, fieldName, raw, fail) {
|
|
15562
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
15563
|
+
fail(`\u5B57\u6BB5\u5B57\u5178 ${objectName}.${fieldName} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
15564
|
+
}
|
|
15565
|
+
const field = raw;
|
|
15566
|
+
for (const key of Object.keys(field)) {
|
|
15567
|
+
if (!FIELD_KEYS.has(key)) {
|
|
15568
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
|
|
15569
|
+
}
|
|
15570
|
+
}
|
|
15571
|
+
const type2 = String(field.type ?? "");
|
|
15572
|
+
if (!FIELD_TYPES.has(type2)) {
|
|
15573
|
+
fail(
|
|
15574
|
+
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${type2}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
|
|
15575
|
+
);
|
|
15576
|
+
}
|
|
15577
|
+
if (type2 === "enum") {
|
|
15578
|
+
const values = field.values;
|
|
15579
|
+
if (values === null || typeof values !== "object" || Array.isArray(values) || Object.keys(values).length === 0) {
|
|
15580
|
+
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`);
|
|
15581
|
+
}
|
|
15582
|
+
}
|
|
15583
|
+
const permission = field.permission === void 0 ? "r" : String(field.permission);
|
|
15584
|
+
if (permission !== "r" && permission !== "w") {
|
|
15585
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 permission \u53EA\u80FD\u662F r \u6216 w`);
|
|
15586
|
+
}
|
|
15587
|
+
if (field.rules !== void 0 && !Array.isArray(field.rules)) {
|
|
15588
|
+
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules \u5FC5\u987B\u662F\u6570\u7EC4`);
|
|
15589
|
+
}
|
|
15590
|
+
return {
|
|
15591
|
+
type: type2,
|
|
15592
|
+
permission,
|
|
15593
|
+
...field.name !== void 0 ? { name: String(field.name) } : {},
|
|
15594
|
+
...field.values ? { values: field.values } : {},
|
|
15595
|
+
...field.rules ? { rules: field.rules } : {}
|
|
15596
|
+
};
|
|
15597
|
+
}
|
|
15598
|
+
function parseDuration(raw, where, fail) {
|
|
15599
|
+
const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(raw.trim());
|
|
15600
|
+
if (!match) {
|
|
15601
|
+
fail(`${where} \u7684\u65F6\u957F "${raw}" \u975E\u6CD5\u2014\u2014\u5F62\u5982 500ms / 30s / 5m\uFF08\u5355\u4F4D\u5FC5\u586B\uFF0C\u4E0D\u731C\uFF09`);
|
|
15602
|
+
}
|
|
15603
|
+
const value = Number(match[1]);
|
|
15604
|
+
const unit = match[2];
|
|
15605
|
+
return unit === "ms" ? value : unit === "s" ? value * 1e3 : value * 6e4;
|
|
15606
|
+
}
|
|
15607
|
+
function parseEventSection(raw, blockId, scope, fail) {
|
|
15608
|
+
const actions = /* @__PURE__ */ new Map();
|
|
15609
|
+
const emitRoutes = {};
|
|
15610
|
+
if (raw === void 0) return { actions, emitRoutes };
|
|
15611
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
15612
|
+
fail("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E actions / on\uFF09");
|
|
15613
|
+
}
|
|
15614
|
+
const section = raw;
|
|
15615
|
+
for (const key of Object.keys(section)) {
|
|
15616
|
+
if (!EVENT_KEYS.has(key)) {
|
|
15617
|
+
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`);
|
|
15618
|
+
}
|
|
15619
|
+
}
|
|
15620
|
+
for (const [id, actionRaw] of Object.entries(section.actions ?? {})) {
|
|
15621
|
+
if (actionRaw === null || typeof actionRaw !== "object" || Array.isArray(actionRaw)) {
|
|
15622
|
+
fail(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
15623
|
+
}
|
|
15624
|
+
const action = actionRaw;
|
|
15625
|
+
for (const key of Object.keys(action)) {
|
|
15626
|
+
if (!ACTION_KEYS.has(key)) {
|
|
15627
|
+
fail(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
|
|
15628
|
+
}
|
|
15629
|
+
}
|
|
15630
|
+
if (action.label === void 0) fail(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
|
|
15631
|
+
actions.set(id, {
|
|
15632
|
+
id,
|
|
15633
|
+
label: String(action.label),
|
|
15634
|
+
...action.handler !== void 0 ? { handler: withPageDefault(String(action.handler)) } : {},
|
|
15635
|
+
...action.change !== void 0 ? { change: withPageDefault(String(action.change)) } : {},
|
|
15636
|
+
...action.confirm !== void 0 ? { confirm: String(action.confirm) } : {},
|
|
15637
|
+
...action.permission !== void 0 ? { permission: String(action.permission) } : {},
|
|
15638
|
+
...action.tone !== void 0 ? { tone: String(action.tone) } : {},
|
|
15639
|
+
...action.when !== void 0 ? { when: expandCondition2(String(action.when), scope) } : {},
|
|
15640
|
+
...action.disabled_reason !== void 0 ? { disabled_reason: expandPath(String(action.disabled_reason), scope) } : {}
|
|
15641
|
+
});
|
|
15642
|
+
}
|
|
15643
|
+
for (const [emitName, expr] of Object.entries(section.on ?? {})) {
|
|
15644
|
+
if (emitName.includes(".")) {
|
|
15645
|
+
fail(
|
|
15646
|
+
`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`
|
|
15647
|
+
);
|
|
15648
|
+
}
|
|
15649
|
+
emitRoutes[emitName] = withPageDefaultInPipeline(String(expr));
|
|
15650
|
+
}
|
|
15651
|
+
return { actions, emitRoutes };
|
|
15652
|
+
}
|
|
15653
|
+
function withPageDefault(funcPath) {
|
|
15654
|
+
return funcPath.includes(".") ? funcPath : `page.${funcPath}`;
|
|
15655
|
+
}
|
|
15656
|
+
function withPageDefaultInPipeline(expr) {
|
|
15657
|
+
const parts = expr.split("|").map((part) => part.trim());
|
|
15658
|
+
const verb = parts[0];
|
|
15659
|
+
const handlerIndex = verb === "UI_INTERACT" ? 2 : verb === "NAV_STATIC" ? -1 : ["UI_REFRESH", "NAV_ACTION"].includes(verb) ? 1 : 0;
|
|
15660
|
+
if (handlerIndex >= 0 && parts[handlerIndex] && /^[A-Za-z_][A-Za-z0-9_]*$/.test(parts[handlerIndex])) {
|
|
15661
|
+
parts[handlerIndex] = `page.${parts[handlerIndex]}`;
|
|
15662
|
+
}
|
|
15663
|
+
return parts.reduce(
|
|
15664
|
+
(result, part, index) => index === 0 ? part : `${result} |${part ? ` ${part}` : ""}`,
|
|
15665
|
+
""
|
|
15666
|
+
);
|
|
15667
|
+
}
|
|
15668
|
+
function expandCondition2(raw, scope) {
|
|
15669
|
+
const text = raw.trim();
|
|
15670
|
+
const negated = text.startsWith("!");
|
|
15671
|
+
const bare = negated ? text.slice(1).trim() : text;
|
|
15672
|
+
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
15673
|
+
}
|
|
15674
|
+
function expandUiPaths(value, scope) {
|
|
15675
|
+
const walk = (node) => {
|
|
15676
|
+
if (typeof node === "string") {
|
|
15677
|
+
const segments = node.split(/\s+\|\s+/);
|
|
15678
|
+
segments[0] = expandPath(segments[0], scope);
|
|
15679
|
+
return segments.join(" | ");
|
|
15680
|
+
}
|
|
15681
|
+
if (Array.isArray(node)) return node.map(walk);
|
|
15682
|
+
if (node !== null && typeof node === "object") {
|
|
15683
|
+
const out = {};
|
|
15684
|
+
for (const [key, child] of Object.entries(node)) {
|
|
15685
|
+
out[key] = walk(child);
|
|
15686
|
+
}
|
|
15687
|
+
return out;
|
|
15688
|
+
}
|
|
15689
|
+
return node;
|
|
15690
|
+
};
|
|
15691
|
+
return walk(value);
|
|
15692
|
+
}
|
|
15693
|
+
|
|
15694
|
+
// core/build/v2/block-compile.ts
|
|
15695
|
+
function compileSomaV2(input) {
|
|
15696
|
+
const htmlIndex = buildHtmlAnchorIndex(input.html);
|
|
15697
|
+
if (htmlIndex.duplicates.length > 0) {
|
|
15698
|
+
throw new SomaV2ParseError(
|
|
15699
|
+
`HTML \u951A\u70B9\u91CD\u590D\uFF1A${htmlIndex.duplicates.join("\u3001")}\u2014\u2014\u9875\u9762\u5185 data-soma-id \u5FC5\u987B\u552F\u4E00`
|
|
15700
|
+
);
|
|
15701
|
+
}
|
|
15702
|
+
const rawBlocks = loadSomaFile({
|
|
15703
|
+
uiYamlRaw: input.uiYamlRaw,
|
|
15704
|
+
htmlIndex,
|
|
15705
|
+
...input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}
|
|
15706
|
+
});
|
|
15707
|
+
const pageRaw = rawBlocks.find((block) => block.blockId === PAGE_BLOCK_ID);
|
|
15708
|
+
if (!pageRaw) {
|
|
15709
|
+
throw new SomaV2ParseError("\u7F3A\u5C11 page \u5757\uFF08\u9875\u9762\u5FC5\u987B\u58F0\u660E domain\uFF09");
|
|
15710
|
+
}
|
|
15711
|
+
const anchors = new Set(htmlIndex.anchors.keys());
|
|
15712
|
+
const page = parsePageBlock({
|
|
15713
|
+
body: pageRaw.body,
|
|
15714
|
+
anchors,
|
|
15715
|
+
instances: htmlIndex.instances,
|
|
15716
|
+
...input.localeKeys ? { localeKeys: input.localeKeys } : {}
|
|
15717
|
+
});
|
|
15718
|
+
const ui = page.ui;
|
|
15719
|
+
const event = { ...page.eventRaw };
|
|
15720
|
+
const data = {};
|
|
15721
|
+
for (const [name, decl] of Object.entries(page.dataRaw ?? {})) {
|
|
15722
|
+
data[name] = decl;
|
|
15723
|
+
}
|
|
15724
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
15725
|
+
for (const raw of rawBlocks) {
|
|
15726
|
+
if (raw.blockId === PAGE_BLOCK_ID) continue;
|
|
15727
|
+
const info = htmlIndex.anchors.get(raw.blockId);
|
|
15728
|
+
const ast = parseUseBlock({
|
|
15729
|
+
blockId: raw.blockId,
|
|
15730
|
+
body: raw.body,
|
|
15731
|
+
...info?.component ? { htmlComponent: info.component } : {},
|
|
15732
|
+
rowVars: rowVarsFor(raw.blockId, htmlIndex, ui)
|
|
15733
|
+
});
|
|
15734
|
+
blocks.set(raw.blockId, ast);
|
|
15735
|
+
attachInstance(ui, raw.blockId, ast, htmlIndex);
|
|
15736
|
+
for (const [emitName, expr] of Object.entries(ast.emitRoutes)) {
|
|
15737
|
+
event[`${raw.blockId}.${emitName}`] = expr;
|
|
15738
|
+
}
|
|
15739
|
+
for (const object of ast.dataObjects) {
|
|
15740
|
+
data[object.fullName] = {
|
|
15741
|
+
...object.from ? { from: object.from } : {},
|
|
15742
|
+
...object.save ? { save: object.save } : {},
|
|
15743
|
+
...object.refreshMs !== void 0 ? { refreshMs: object.refreshMs } : {},
|
|
15744
|
+
...object.reloadOn ? { reloadOn: object.reloadOn } : {},
|
|
15745
|
+
...object.fields ? { fields: object.fields } : {}
|
|
15746
|
+
};
|
|
15747
|
+
}
|
|
15748
|
+
}
|
|
15749
|
+
return { ui, event, data, blocks, htmlIndex };
|
|
15750
|
+
}
|
|
15751
|
+
function rowVarsFor(blockId, htmlIndex, ui) {
|
|
15752
|
+
const info = htmlIndex.anchors.get(blockId);
|
|
15753
|
+
if (!info?.inRowTemplate || !info.ownerList) return [];
|
|
15754
|
+
const chain = [];
|
|
15755
|
+
const walk = (show, ancestors) => {
|
|
15756
|
+
for (const [key, value] of Object.entries(show)) {
|
|
15757
|
+
if (value === null || typeof value !== "object") continue;
|
|
15758
|
+
const node = value;
|
|
15759
|
+
const nextAncestors = node.bind?.var ? [...ancestors, node.bind.var] : ancestors;
|
|
15760
|
+
if (key === info.ownerList && node.bind?.var) {
|
|
15761
|
+
chain.push(...nextAncestors);
|
|
15762
|
+
return true;
|
|
15763
|
+
}
|
|
15764
|
+
if (node.show && walk(node.show, nextAncestors)) return true;
|
|
15765
|
+
}
|
|
15766
|
+
return false;
|
|
15767
|
+
};
|
|
15768
|
+
walk(ui.show, []);
|
|
15769
|
+
return chain;
|
|
15770
|
+
}
|
|
15771
|
+
function attachInstance(ui, blockId, ast, htmlIndex) {
|
|
15772
|
+
const value = ast.toShowValue();
|
|
15773
|
+
const info = htmlIndex.anchors.get(blockId);
|
|
15774
|
+
if (!info?.inRowTemplate) {
|
|
15775
|
+
ui.show[blockId] = value;
|
|
15776
|
+
return;
|
|
15777
|
+
}
|
|
15778
|
+
const owner = info.ownerList;
|
|
15779
|
+
if (!owner) {
|
|
15780
|
+
throw new SomaV2ParseError(
|
|
15781
|
+
`\u5B9E\u4F8B "${blockId}" \u4F4D\u4E8E\u884C\u6A21\u677F\u5185\uFF0C\u4F46 HTML \u91CC\u627E\u4E0D\u5230\u5B83\u6240\u5C5E\u7684\u5217\u8868\u951A\u70B9`,
|
|
15782
|
+
blockId
|
|
15783
|
+
);
|
|
15784
|
+
}
|
|
15785
|
+
const target = findListShow(ui.show, owner);
|
|
15786
|
+
if (!target) {
|
|
15787
|
+
throw new SomaV2ParseError(
|
|
15788
|
+
`\u5B9E\u4F8B "${blockId}" \u5C5E\u4E8E\u5217\u8868 "${owner}"\uFF0C\u4F46 page \u5757\u6CA1\u6709\u4E3A\u8BE5\u5217\u8868\u58F0\u660E each \u4F5C\u7528\u57DF`,
|
|
15789
|
+
blockId
|
|
15790
|
+
);
|
|
15791
|
+
}
|
|
15792
|
+
target[blockId] = value;
|
|
15793
|
+
}
|
|
15794
|
+
function findListShow(show, listAnchor) {
|
|
15795
|
+
for (const [key, node] of Object.entries(show)) {
|
|
15796
|
+
if (node === null || typeof node !== "object") continue;
|
|
15797
|
+
const nested = node;
|
|
15798
|
+
if (key === listAnchor && nested.bind && nested.show) return nested.show;
|
|
15799
|
+
if (nested.show) {
|
|
15800
|
+
const found = findListShow(nested.show, listAnchor);
|
|
15801
|
+
if (found) return found;
|
|
15802
|
+
}
|
|
15803
|
+
}
|
|
15804
|
+
return void 0;
|
|
15805
|
+
}
|
|
15806
|
+
|
|
15807
|
+
// core/build/compiler/html-include-expander.ts
|
|
15808
|
+
var SomaHtmlIncludeError = class extends Error {
|
|
15809
|
+
constructor(message) {
|
|
15810
|
+
super(`[soma-core][HTML include] ${message}`);
|
|
15811
|
+
this.name = "SomaHtmlIncludeError";
|
|
15812
|
+
}
|
|
15813
|
+
};
|
|
15814
|
+
var INCLUDE_ATTRIBUTE = /\sdata-soma-include\s*=\s*(["'])([^"']+)\1/i;
|
|
15815
|
+
var OPEN_TAG = /<([A-Za-z][A-Za-z0-9:-]*)(\s[^<>]*?)?>/g;
|
|
15816
|
+
function expandSomaHtmlIncludes(html, includes) {
|
|
15817
|
+
if (!includes || Object.keys(includes).length === 0 || !html.includes("data-soma-include")) {
|
|
15818
|
+
return html;
|
|
15819
|
+
}
|
|
15820
|
+
const expand = (source, chain) => source.replace(
|
|
15821
|
+
OPEN_TAG,
|
|
15822
|
+
(full, tagName, attributes) => {
|
|
15823
|
+
const rawAttributes = attributes ?? "";
|
|
15824
|
+
const matched = INCLUDE_ATTRIBUTE.exec(rawAttributes);
|
|
15825
|
+
if (!matched) return full;
|
|
15826
|
+
const includeName = matched[2];
|
|
15827
|
+
if (!Object.prototype.hasOwnProperty.call(includes, includeName)) {
|
|
15828
|
+
throw new SomaHtmlIncludeError(`\u627E\u4E0D\u5230\u5171\u4EAB\u7247\u6BB5 "${includeName}"`);
|
|
15829
|
+
}
|
|
15830
|
+
if (chain.includes(includeName)) {
|
|
15831
|
+
throw new SomaHtmlIncludeError(`\u68C0\u6D4B\u5230\u5FAA\u73AF\u5F15\u7528\uFF1A${[...chain, includeName].join(" -> ")}`);
|
|
15832
|
+
}
|
|
15833
|
+
const withoutInclude = rawAttributes.replace(INCLUDE_ATTRIBUTE, "");
|
|
15834
|
+
const expandedFragment = expand(includes[includeName], [...chain, includeName]);
|
|
15835
|
+
return `<${tagName}${withoutInclude}>${expandedFragment}`;
|
|
15836
|
+
}
|
|
15837
|
+
);
|
|
15838
|
+
return expand(html, []);
|
|
15839
|
+
}
|
|
15840
|
+
|
|
15841
|
+
// core/build/compiler/page-declaration-compiler.ts
|
|
15842
|
+
var dump2 = (value) => yaml.dump(value, { lineWidth: 120, noRefs: true, quotingType: '"' });
|
|
15843
|
+
function compilePageDeclaration(input) {
|
|
15844
|
+
const eventYaml = input.eventYaml ?? "";
|
|
15845
|
+
const styleYaml = input.styleYaml ?? "";
|
|
15846
|
+
const dataYaml = input.dataYaml ?? "";
|
|
15847
|
+
const sidecars = [
|
|
15848
|
+
eventYaml.trim() ? "eventYaml / *_event.yaml" : "",
|
|
15849
|
+
styleYaml.trim() ? "styleYaml / *_style.yaml" : "",
|
|
15850
|
+
dataYaml.trim() ? "dataYaml / *_data.yaml" : ""
|
|
15851
|
+
].filter(Boolean);
|
|
15852
|
+
if (sidecars.length > 0) {
|
|
15853
|
+
throw new Error(
|
|
15854
|
+
`[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`
|
|
15855
|
+
);
|
|
15856
|
+
}
|
|
15857
|
+
const compiled = compileSomaV2({
|
|
15858
|
+
html: expandSomaHtmlIncludes(input.html, input.includes),
|
|
15859
|
+
uiYamlRaw: input.uiYaml,
|
|
15860
|
+
...input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}
|
|
15861
|
+
});
|
|
15862
|
+
const eventBundle = compileEventConfigFromRaw(compiled.event);
|
|
15863
|
+
const embeddedDataYaml = Object.keys(compiled.data).length > 0 ? dump2({ data: compiled.data }) : "";
|
|
15864
|
+
return {
|
|
15865
|
+
uiConfig: compiled.ui,
|
|
15866
|
+
eventConfig: eventBundle.events,
|
|
15867
|
+
triggers: eventBundle.triggers,
|
|
15868
|
+
timers: eventBundle.timers,
|
|
15869
|
+
...embeddedDataYaml ? { dataConfig: compileDataConfig(embeddedDataYaml) } : {},
|
|
15870
|
+
runtimeAssets: {
|
|
15871
|
+
uiYaml: dump2(compiled.ui),
|
|
15872
|
+
eventYaml: Object.keys(compiled.event).length > 0 ? dump2(compiled.event) : "",
|
|
15873
|
+
styleYaml: "",
|
|
15874
|
+
...embeddedDataYaml ? { dataYaml: embeddedDataYaml } : {}
|
|
15875
|
+
}
|
|
15876
|
+
};
|
|
15877
|
+
}
|
|
15878
|
+
|
|
15879
|
+
// core/build/compiler/page-assets.ts
|
|
15880
|
+
function compilePageAssets(assets) {
|
|
15881
|
+
const compiled = compilePageDeclaration({
|
|
15882
|
+
html: assets.html ?? "",
|
|
15883
|
+
uiYaml: assets.uiYaml ?? "",
|
|
15884
|
+
...assets.eventYaml ? { eventYaml: assets.eventYaml } : {},
|
|
15885
|
+
...assets.styleYaml ? { styleYaml: assets.styleYaml } : {},
|
|
15886
|
+
...assets.dataYaml ? { dataYaml: assets.dataYaml } : {},
|
|
15887
|
+
...assets.declarationBlocks ? { externalBlocks: assets.declarationBlocks } : {}
|
|
15888
|
+
});
|
|
15889
|
+
return {
|
|
15890
|
+
...assets,
|
|
15891
|
+
uiYaml: compiled.runtimeAssets.uiYaml,
|
|
15892
|
+
eventYaml: compiled.runtimeAssets.eventYaml,
|
|
15893
|
+
styleYaml: "",
|
|
15894
|
+
...compiled.runtimeAssets.dataYaml ? { dataYaml: compiled.runtimeAssets.dataYaml } : { dataYaml: void 0 }
|
|
15895
|
+
};
|
|
15896
|
+
}
|
|
13935
15897
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13936
15898
|
0 && (module.exports = {
|
|
13937
15899
|
ComponentPackError,
|
|
@@ -13939,6 +15901,7 @@ function physicalDirections(css) {
|
|
|
13939
15901
|
Locale,
|
|
13940
15902
|
MiniProgramContainerAdapter,
|
|
13941
15903
|
PACK_NAME_PATTERN,
|
|
15904
|
+
PAGE_BLOCK_ID,
|
|
13942
15905
|
Page,
|
|
13943
15906
|
ReactNativeContainerAdapter,
|
|
13944
15907
|
SOMA_ADAPTIVE_MAX_LADDER,
|
|
@@ -13968,8 +15931,11 @@ function physicalDirections(css) {
|
|
|
13968
15931
|
SomaPipeRegistry,
|
|
13969
15932
|
SomaQualityRegistry,
|
|
13970
15933
|
SomaRealtimeService,
|
|
15934
|
+
SomaScopeError,
|
|
13971
15935
|
SomaTelemetry,
|
|
15936
|
+
SomaV2ParseError,
|
|
13972
15937
|
SomaValidator,
|
|
15938
|
+
SomaValueLangError,
|
|
13973
15939
|
SseRealtimeTransport,
|
|
13974
15940
|
THEME_SWITCHING_CLASS,
|
|
13975
15941
|
TYPOGRAPHY_BASE_CSS,
|
|
@@ -13978,8 +15944,13 @@ function physicalDirections(css) {
|
|
|
13978
15944
|
applyLocaleMetadata,
|
|
13979
15945
|
applyTheme,
|
|
13980
15946
|
attachPackStyles,
|
|
15947
|
+
buildBlockScope,
|
|
13981
15948
|
buildCatalogEntry,
|
|
15949
|
+
buildHtmlAnchorIndex,
|
|
15950
|
+
checkOverrideCompat,
|
|
13982
15951
|
compileAdaptive,
|
|
15952
|
+
compilePageAssets,
|
|
15953
|
+
compileSomaV2,
|
|
13983
15954
|
composeComponentPacks,
|
|
13984
15955
|
contrastRatio,
|
|
13985
15956
|
createAdaptiveObserverPool,
|
|
@@ -13991,8 +15962,11 @@ function physicalDirections(css) {
|
|
|
13991
15962
|
createSomaPageLifecycle,
|
|
13992
15963
|
defaultPipeRegistry,
|
|
13993
15964
|
deriveTheme,
|
|
15965
|
+
describeNode,
|
|
13994
15966
|
ensurePackBaseStyles,
|
|
13995
15967
|
escapeSomaHtml,
|
|
15968
|
+
evaluateValueNode,
|
|
15969
|
+
expandPath,
|
|
13996
15970
|
extractConfigFromDomainClass,
|
|
13997
15971
|
findNestedMutableContractDefault,
|
|
13998
15972
|
findSomaDomainLoader,
|
|
@@ -14006,10 +15980,13 @@ function physicalDirections(css) {
|
|
|
14006
15980
|
hasBlockedScheme,
|
|
14007
15981
|
hasPageMetadata,
|
|
14008
15982
|
installSomaErrorReporter,
|
|
15983
|
+
isArithSegment,
|
|
14009
15984
|
isBootTimingsEnabled,
|
|
14010
15985
|
isEventHandlerAttribute,
|
|
15986
|
+
isPlainPath,
|
|
14011
15987
|
isSomaMockEnabled,
|
|
14012
15988
|
loadSomaDomainModuleFromRegistry,
|
|
15989
|
+
loadSomaFile,
|
|
14013
15990
|
markBootPhase,
|
|
14014
15991
|
matchGlobPath,
|
|
14015
15992
|
maybeStartBootTimings,
|
|
@@ -14018,21 +15995,28 @@ function physicalDirections(css) {
|
|
|
14018
15995
|
parseDataConfig,
|
|
14019
15996
|
parseDataRef,
|
|
14020
15997
|
parseDataYaml,
|
|
15998
|
+
parsePageBlock,
|
|
15999
|
+
parseUseBlock,
|
|
16000
|
+
parseValueSegment,
|
|
14021
16001
|
readBootTimings,
|
|
14022
16002
|
recordMetric,
|
|
14023
16003
|
renderPublishedPage,
|
|
14024
16004
|
resetBootTimings,
|
|
14025
16005
|
resetPackStyleInjection,
|
|
16006
|
+
resolveApiRef,
|
|
14026
16007
|
resolveHostBootstrapOptions,
|
|
16008
|
+
resolvePath,
|
|
14027
16009
|
resolveSomaHtmlSanitizer,
|
|
14028
16010
|
resolveTierWithHysteresis,
|
|
14029
16011
|
runAsync,
|
|
14030
16012
|
sanitizeAttributeWrite,
|
|
14031
16013
|
sanitizeSomaHtml,
|
|
14032
16014
|
scheduleAdaptiveFlush,
|
|
16015
|
+
scopeHasVar,
|
|
14033
16016
|
setActiveTelemetry,
|
|
14034
16017
|
setSomaHtmlSanitizer,
|
|
14035
16018
|
somaRollupPlugin,
|
|
14036
16019
|
startBootTimings,
|
|
16020
|
+
themeRootAttributes,
|
|
14037
16021
|
verifyComponentPack
|
|
14038
16022
|
});
|