soma-core 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/app/SomaPageClient.tsx +4 -4
- package/app/components/SomaHostPage.tsx +5 -5
- package/app/components/SomaHydrationShell.tsx +4 -7
- package/app/globals.css +126 -3
- package/app/soma/page/route.ts +17 -2
- package/core/build/{v2 → blocks}/block-compile.ts +17 -17
- package/core/build/{v2/soma-file-loader.ts → blocks/block-container.ts} +28 -28
- package/core/build/{v2 → blocks}/block-loader.ts +1 -1
- package/core/build/{v2 → blocks}/html-index.ts +1 -1
- package/core/build/{v2/migrate-v1.ts → blocks/migrate-flat.ts} +28 -28
- package/core/build/compiler/host-config-sync.cjs +2 -9
- package/core/build/compiler/page-declaration-compiler.ts +2 -2
- package/core/build/compiler/soma-manifest-webpack-plugin.js +1 -1
- package/core/build/compiler/soma-precompile.js +17 -17
- package/core/build/compiler/soma-precompile.ts +2 -2
- package/core/client/component/ai-catalog.ts +4 -4
- package/core/client/component/contract-compat.ts +32 -3
- package/core/client/component/{example-v2.ts → example-blocks.ts} +19 -19
- package/core/client/engine/soma-bootstrap.ts +21 -2
- package/core/client/engine/style-binder.ts +1 -1
- package/core/client/infra/notify/DomNotifyService.ts +2 -1
- package/core/client/infra/notify/INotifyTheme.ts +1 -1
- package/core/client/parser/{v2 → blocks}/namespace.ts +1 -1
- package/core/client/parser/{v2 → blocks}/page-parser.ts +16 -16
- package/core/client/parser/{v2 → blocks}/use-parser.ts +20 -14
- package/core/client/parser/style-config-parser.ts +7 -7
- package/core/client/parser/value-lang.ts +1 -1
- package/core/client/registry/index.ts +8 -0
- package/core/client/registry/page-lifecycle.ts +1 -1
- package/core/client/security/attribute-presence.ts +16 -1
- package/core/client/theme/theme-engine.ts +42 -14
- package/core/client/typography/typography-base.ts +1 -1
- package/core/index.ts +25 -13
- package/core/server/host/csp-nonce-metadata.ts +1 -1
- package/core/server/host/published-page-assets.ts +30 -0
- package/core/server/host/soma-page-compile.ts +1 -1
- package/core/server/index.ts +2 -2
- package/core/server/registry/page-registry-store.ts +1 -1
- package/core/shared/published-page-route.ts +61 -0
- package/core/shared/types/adaptive.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +30 -2
- package/core/shared/types/scope-manifest.types.ts +11 -15
- package/core/shared/types/style-config.types.ts +4 -4
- package/dist/cli/soma.js +15 -2
- package/dist/core/index.cjs +171 -77
- package/dist/types/build/{v2 → blocks}/block-compile.d.ts +7 -7
- package/dist/types/build/{v2/soma-file-loader.d.ts → blocks/block-container.d.ts} +6 -6
- package/dist/types/build/{v2/migrate-v1.d.ts → blocks/migrate-flat.d.ts} +6 -6
- package/dist/types/client/component/contract-compat.d.ts +2 -2
- package/dist/types/client/component/example-blocks.d.ts +9 -0
- package/dist/types/client/infra/notify/DomNotifyService.d.ts +2 -1
- package/dist/types/client/infra/notify/INotifyTheme.d.ts +1 -1
- package/dist/types/client/parser/{v2 → blocks}/page-parser.d.ts +2 -2
- package/dist/types/client/parser/{v2 → blocks}/use-parser.d.ts +1 -1
- package/dist/types/client/parser/style-config-parser.d.ts +1 -1
- package/dist/types/client/registry/index.d.ts +1 -0
- package/dist/types/client/theme/theme-engine.d.ts +11 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/server/host/published-page-assets.d.ts +20 -0
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/registry/page-registry-store.d.ts +1 -1
- package/dist/types/shared/published-page-route.d.ts +21 -0
- package/dist/types/shared/types/data-config.types.d.ts +18 -2
- package/dist/types/shared/types/scope-manifest.types.d.ts +11 -11
- package/dist/types/shared/types/style-config.types.d.ts +4 -4
- package/package.json +1 -6
- package/tsconfig.json +20 -7
- package/dist/types/client/component/example-v2.d.ts +0 -9
- package/postcss.config.js +0 -6
- package/tailwind.config.ts +0 -43
- /package/dist/types/build/{v2 → blocks}/block-loader.d.ts +0 -0
- /package/dist/types/build/{v2 → blocks}/html-index.d.ts +0 -0
- /package/dist/types/client/parser/{v2 → blocks}/namespace.d.ts +0 -0
package/dist/core/index.cjs
CHANGED
|
@@ -36,17 +36,22 @@ __export(index_exports, {
|
|
|
36
36
|
MiniProgramContainerAdapter: () => MiniProgramContainerAdapter,
|
|
37
37
|
PACK_NAME_PATTERN: () => PACK_NAME_PATTERN,
|
|
38
38
|
PAGE_BLOCK_ID: () => PAGE_BLOCK_ID,
|
|
39
|
+
PUBLISHED_PAGE_SLUG_PATTERN: () => PUBLISHED_PAGE_SLUG_PATTERN,
|
|
39
40
|
Page: () => Page,
|
|
41
|
+
RESERVED_PUBLISHED_PAGE_SLUGS: () => RESERVED_PUBLISHED_PAGE_SLUGS,
|
|
40
42
|
ReactNativeContainerAdapter: () => ReactNativeContainerAdapter,
|
|
41
43
|
SOMA_ADAPTIVE_MAX_LADDER: () => SOMA_ADAPTIVE_MAX_LADDER,
|
|
42
44
|
SOMA_ADAPTIVE_PROFILES: () => SOMA_ADAPTIVE_PROFILES,
|
|
43
45
|
SOMA_ADAPTIVE_PROFILE_ATTR: () => SOMA_ADAPTIVE_PROFILE_ATTR,
|
|
46
|
+
SOMA_DATA_FIELD_TYPES: () => SOMA_DATA_FIELD_TYPES,
|
|
47
|
+
SOMA_DATA_FIELD_TYPE_ALIASES: () => SOMA_DATA_FIELD_TYPE_ALIASES,
|
|
44
48
|
SOMA_DEFAULT_HYSTERESIS: () => SOMA_DEFAULT_HYSTERESIS,
|
|
45
49
|
SOMA_PURIFY_PROFILE: () => SOMA_PURIFY_PROFILE,
|
|
46
50
|
Show: () => Show,
|
|
47
51
|
ShowList: () => ShowList,
|
|
48
52
|
SomaAdaptiveConfigError: () => SomaAdaptiveConfigError,
|
|
49
53
|
SomaApi: () => SomaApi,
|
|
54
|
+
SomaBlockParseError: () => SomaBlockParseError,
|
|
50
55
|
SomaBootstrap: () => SomaBootstrap,
|
|
51
56
|
SomaComponentManager: () => SomaComponentManager,
|
|
52
57
|
SomaComponentRegistry: () => SomaComponentRegistry,
|
|
@@ -67,7 +72,6 @@ __export(index_exports, {
|
|
|
67
72
|
SomaRealtimeService: () => SomaRealtimeService,
|
|
68
73
|
SomaScopeError: () => SomaScopeError,
|
|
69
74
|
SomaTelemetry: () => SomaTelemetry,
|
|
70
|
-
SomaV2ParseError: () => SomaV2ParseError,
|
|
71
75
|
SomaValidator: () => SomaValidator,
|
|
72
76
|
SomaValueLangError: () => SomaValueLangError,
|
|
73
77
|
SseRealtimeTransport: () => SseRealtimeTransport,
|
|
@@ -84,7 +88,7 @@ __export(index_exports, {
|
|
|
84
88
|
checkOverrideCompat: () => checkOverrideCompat,
|
|
85
89
|
compileAdaptive: () => compileAdaptive,
|
|
86
90
|
compilePageAssets: () => compilePageAssets,
|
|
87
|
-
|
|
91
|
+
compileSomaBlocks: () => compileSomaBlocks,
|
|
88
92
|
composeComponentPacks: () => composeComponentPacks,
|
|
89
93
|
contrastRatio: () => contrastRatio,
|
|
90
94
|
createAdaptiveObserverPool: () => createAdaptiveObserverPool,
|
|
@@ -118,6 +122,7 @@ __export(index_exports, {
|
|
|
118
122
|
isBootTimingsEnabled: () => isBootTimingsEnabled,
|
|
119
123
|
isEventHandlerAttribute: () => isEventHandlerAttribute,
|
|
120
124
|
isPlainPath: () => isPlainPath,
|
|
125
|
+
isPublishedPageSlug: () => isPublishedPageSlug,
|
|
121
126
|
isSomaMockEnabled: () => isSomaMockEnabled,
|
|
122
127
|
loadSomaDomainModuleFromRegistry: () => loadSomaDomainModuleFromRegistry,
|
|
123
128
|
loadSomaFile: () => loadSomaFile,
|
|
@@ -125,6 +130,7 @@ __export(index_exports, {
|
|
|
125
130
|
matchGlobPath: () => matchGlobPath,
|
|
126
131
|
maybeStartBootTimings: () => maybeStartBootTimings,
|
|
127
132
|
normalizeDataPipeValue: () => normalizeDataPipeValue,
|
|
133
|
+
normalizePublishedPageSlug: () => normalizePublishedPageSlug,
|
|
128
134
|
parseAdaptiveConfig: () => parseAdaptiveConfig,
|
|
129
135
|
parseDataConfig: () => parseDataConfig,
|
|
130
136
|
parseDataRef: () => parseDataRef,
|
|
@@ -132,6 +138,8 @@ __export(index_exports, {
|
|
|
132
138
|
parsePageBlock: () => parsePageBlock,
|
|
133
139
|
parseUseBlock: () => parseUseBlock,
|
|
134
140
|
parseValueSegment: () => parseValueSegment,
|
|
141
|
+
publishedPagePath: () => publishedPagePath,
|
|
142
|
+
publishedPageSlugFromPath: () => publishedPageSlugFromPath,
|
|
135
143
|
readBootTimings: () => readBootTimings,
|
|
136
144
|
recordMetric: () => recordMetric,
|
|
137
145
|
renderPublishedPage: () => renderPublishedPage,
|
|
@@ -758,9 +766,14 @@ var ABSENT_WHEN_EMPTY_ARIA = /* @__PURE__ */ new Set([
|
|
|
758
766
|
// 表单控件在非错误态下写空串等于凭空宣告"这个字段填错了"。
|
|
759
767
|
"aria-invalid"
|
|
760
768
|
]);
|
|
769
|
+
var ABSENT_WHEN_EMPTY_RESOURCE = /* @__PURE__ */ new Set([
|
|
770
|
+
"src",
|
|
771
|
+
"srcset",
|
|
772
|
+
"poster"
|
|
773
|
+
]);
|
|
761
774
|
function isAbsentWhenEmpty(attrName) {
|
|
762
775
|
const name = attrName.toLowerCase();
|
|
763
|
-
return BOOLEAN_ATTRS.has(name) || ABSENT_WHEN_EMPTY_ARIA.has(name);
|
|
776
|
+
return BOOLEAN_ATTRS.has(name) || ABSENT_WHEN_EMPTY_ARIA.has(name) || ABSENT_WHEN_EMPTY_RESOURCE.has(name);
|
|
764
777
|
}
|
|
765
778
|
function shouldRemoveAttribute(attrName, value) {
|
|
766
779
|
return value === "" && isAbsentWhenEmpty(attrName);
|
|
@@ -5035,7 +5048,7 @@ function parseBase(raw, path) {
|
|
|
5035
5048
|
validateSomaId(somaId, `${path}.${somaId}`);
|
|
5036
5049
|
if (typeof classes !== "string") {
|
|
5037
5050
|
throw new SomaStyleConfigError(
|
|
5038
|
-
`base \u7684\u503C\u5FC5\u987B\u662F
|
|
5051
|
+
`base \u7684\u503C\u5FC5\u987B\u662F CSS \u7C7B\u540D\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(classes)}`,
|
|
5039
5052
|
`${path}.${somaId}`
|
|
5040
5053
|
);
|
|
5041
5054
|
}
|
|
@@ -5072,7 +5085,7 @@ function parseStateRule(raw, path) {
|
|
|
5072
5085
|
}
|
|
5073
5086
|
if (!obj.apply || typeof obj.apply !== "string") {
|
|
5074
5087
|
throw new SomaStyleConfigError(
|
|
5075
|
-
`apply \u5FC5\u987B\u662F\u975E\u7A7A
|
|
5088
|
+
`apply \u5FC5\u987B\u662F\u975E\u7A7A CSS \u7C7B\u540D\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(obj.apply)}`,
|
|
5076
5089
|
path
|
|
5077
5090
|
);
|
|
5078
5091
|
}
|
|
@@ -5122,7 +5135,7 @@ function parseTransition(raw, somaId, path) {
|
|
|
5122
5135
|
}
|
|
5123
5136
|
if (!obj.apply || typeof obj.apply !== "string") {
|
|
5124
5137
|
throw new SomaStyleConfigError(
|
|
5125
|
-
`apply \u5FC5\u987B\u662F\u975E\u7A7A
|
|
5138
|
+
`apply \u5FC5\u987B\u662F\u975E\u7A7A CSS \u7C7B\u540D\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(obj.apply)}`,
|
|
5126
5139
|
path
|
|
5127
5140
|
);
|
|
5128
5141
|
}
|
|
@@ -5215,7 +5228,7 @@ function parseTheme(raw, themeName, path) {
|
|
|
5215
5228
|
} else {
|
|
5216
5229
|
if (typeof value !== "string") {
|
|
5217
5230
|
throw new SomaStyleConfigError(
|
|
5218
|
-
`\u4E3B\u9898\u57FA\u7840\u8986\u76D6\u7684\u503C\u5FC5\u987B\u662F
|
|
5231
|
+
`\u4E3B\u9898\u57FA\u7840\u8986\u76D6\u7684\u503C\u5FC5\u987B\u662F CSS \u7C7B\u540D\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(value)}`,
|
|
5219
5232
|
`${path}.${key}`
|
|
5220
5233
|
);
|
|
5221
5234
|
}
|
|
@@ -12290,17 +12303,20 @@ function deriveTheme(input) {
|
|
|
12290
12303
|
// ── 焦点环(暗色主色,透明度略高以在深底可见)──
|
|
12291
12304
|
"--soma-focus-ring": `0 0 0 3px ${hexWithAlpha(darkPrimary, 0.35)}`
|
|
12292
12305
|
};
|
|
12306
|
+
const darkMerged = input.darkOverrides ? { ...input.overrides, ...input.darkOverrides } : input.overrides;
|
|
12293
12307
|
if (input.overrides) {
|
|
12294
12308
|
Object.assign(cssVars, input.overrides);
|
|
12295
|
-
|
|
12309
|
+
}
|
|
12310
|
+
if (darkMerged) {
|
|
12311
|
+
Object.assign(darkCssVars, darkMerged);
|
|
12296
12312
|
}
|
|
12297
12313
|
syncSoftWithOverrides(cssVars, input.overrides);
|
|
12298
|
-
syncSoftWithOverrides(darkCssVars,
|
|
12314
|
+
syncSoftWithOverrides(darkCssVars, darkMerged);
|
|
12299
12315
|
enforceContrastPairs(cssVars);
|
|
12300
12316
|
enforceContrastPairs(darkCssVars);
|
|
12301
12317
|
deriveOnSoftTokens(cssVars, false);
|
|
12302
12318
|
deriveOnSoftTokens(darkCssVars, true);
|
|
12303
|
-
const
|
|
12319
|
+
const makeRescale = (tokens) => tokens?.["--soma-c-primary"] ? (primaryHex) => {
|
|
12304
12320
|
const p = hexToOklch(primaryHex);
|
|
12305
12321
|
const rebuilt = {};
|
|
12306
12322
|
STEPS.forEach((step, i) => {
|
|
@@ -12312,8 +12328,10 @@ function deriveTheme(input) {
|
|
|
12312
12328
|
});
|
|
12313
12329
|
return rebuilt;
|
|
12314
12330
|
} : null;
|
|
12331
|
+
const rescale = makeRescale(input.overrides);
|
|
12332
|
+
const darkRescale = makeRescale(darkMerged);
|
|
12315
12333
|
Object.assign(cssVars, sceneColorTokens(cssVars, axes, params.fieldAlphas, hexWithAlpha, scale, rescale));
|
|
12316
|
-
Object.assign(darkCssVars, sceneColorTokens(darkCssVars, axes, params.fieldAlphas, hexWithAlpha, scale,
|
|
12334
|
+
Object.assign(darkCssVars, sceneColorTokens(darkCssVars, axes, params.fieldAlphas, hexWithAlpha, scale, darkRescale));
|
|
12317
12335
|
return {
|
|
12318
12336
|
scale,
|
|
12319
12337
|
cssVars,
|
|
@@ -12882,7 +12900,15 @@ var SomaBootstrap = class {
|
|
|
12882
12900
|
setupComponentManager(container, assets, uiConfig) {
|
|
12883
12901
|
this.componentManager?.destroy();
|
|
12884
12902
|
this.componentManager = null;
|
|
12885
|
-
const
|
|
12903
|
+
const pageComponents = assets.components ?? {};
|
|
12904
|
+
const shadowed = Object.keys(pageComponents).filter((name) => Object.hasOwn(this.hostComponents, name));
|
|
12905
|
+
if (shadowed.length > 0) {
|
|
12906
|
+
this.diagnostics.recordValidation(
|
|
12907
|
+
"warning",
|
|
12908
|
+
`[\u7EC4\u4EF6\u8986\u76D6] \u9875\u9762\u7EA7\u8D44\u4EA7\u8986\u76D6\u4E86 Host \u7EA7\u540C\u540D\u7EC4\u4EF6\uFF1A${shadowed.join("\u3001")}\u3002\u9875\u9762\u7EA7\u80DC\u51FA\u662F\u65E2\u5B9A\u884C\u4E3A\uFF0C\u4F46\u8986\u76D6\u4E0D\u5E94\u662F\u610F\u5916\u2014\u2014\u82E5\u975E\u672C\u610F\uFF0C\u8BF7\u6539\u540D\u6216\u5728\u7EC4\u4EF6\u5305\u4FA7\u7528 overrides / allowOverride \u663E\u5F0F\u8868\u8FBE\u88C1\u51B3\u3002`
|
|
12909
|
+
);
|
|
12910
|
+
}
|
|
12911
|
+
const defs = { ...this.hostComponents, ...pageComponents };
|
|
12886
12912
|
if (Object.keys(defs).length === 0) {
|
|
12887
12913
|
return;
|
|
12888
12914
|
}
|
|
@@ -13015,7 +13041,7 @@ var SomaBootstrap = class {
|
|
|
13015
13041
|
}
|
|
13016
13042
|
};
|
|
13017
13043
|
|
|
13018
|
-
// core/client/component/example-
|
|
13044
|
+
// core/client/component/example-blocks.ts
|
|
13019
13045
|
var UI_PREFIX = "ui:";
|
|
13020
13046
|
var EVENT_PREFIX = "event:";
|
|
13021
13047
|
function balancedSlice(text, start) {
|
|
@@ -13034,7 +13060,7 @@ function lineAfter(lines, prefix) {
|
|
|
13034
13060
|
const hit = lines.find((line) => line.trimStart().startsWith(prefix));
|
|
13035
13061
|
return hit ? hit.trimStart().slice(prefix.length).trim() : null;
|
|
13036
13062
|
}
|
|
13037
|
-
function
|
|
13063
|
+
function parseFlatExample(example) {
|
|
13038
13064
|
const lines = example.split("\n");
|
|
13039
13065
|
const ui = lineAfter(lines, UI_PREFIX);
|
|
13040
13066
|
if (!ui) return null;
|
|
@@ -13058,8 +13084,8 @@ function parseV1Example(example) {
|
|
|
13058
13084
|
}
|
|
13059
13085
|
return { anchor, propsBody: propsBody.trim(), emits };
|
|
13060
13086
|
}
|
|
13061
|
-
function
|
|
13062
|
-
const parsed =
|
|
13087
|
+
function deriveBlockExample(componentName, example) {
|
|
13088
|
+
const parsed = parseFlatExample(example);
|
|
13063
13089
|
if (!parsed) return null;
|
|
13064
13090
|
const lines = [
|
|
13065
13091
|
`${parsed.anchor}:`,
|
|
@@ -13223,10 +13249,10 @@ function renderMarkdown(entries, conventions) {
|
|
|
13223
13249
|
lines.push("```");
|
|
13224
13250
|
lines.push(entry.ai.example.trimEnd());
|
|
13225
13251
|
lines.push("```");
|
|
13226
|
-
const v2 =
|
|
13252
|
+
const v2 = deriveBlockExample(entry.name, entry.ai.example);
|
|
13227
13253
|
if (v2) {
|
|
13228
13254
|
lines.push("");
|
|
13229
|
-
lines.push("
|
|
13255
|
+
lines.push("\u5757\u5199\u6CD5\uFF08html \u540C\u4E0A\uFF0C_ui.yaml \u6539\u4E3A\u5757\u58F0\u660E\uFF09\uFF1A");
|
|
13230
13256
|
lines.push("```");
|
|
13231
13257
|
lines.push(v2);
|
|
13232
13258
|
lines.push("```");
|
|
@@ -13244,6 +13270,27 @@ function renderMarkdown(entries, conventions) {
|
|
|
13244
13270
|
return lines.join("\n");
|
|
13245
13271
|
}
|
|
13246
13272
|
|
|
13273
|
+
// core/shared/types/data-config.types.ts
|
|
13274
|
+
var SOMA_DATA_FIELD_TYPE_ALIASES = {
|
|
13275
|
+
number: "float"
|
|
13276
|
+
};
|
|
13277
|
+
var SOMA_DATA_FIELD_TYPES = [
|
|
13278
|
+
"text",
|
|
13279
|
+
"int",
|
|
13280
|
+
"float",
|
|
13281
|
+
"money",
|
|
13282
|
+
"bool",
|
|
13283
|
+
"enum",
|
|
13284
|
+
"date",
|
|
13285
|
+
"datetime",
|
|
13286
|
+
"image",
|
|
13287
|
+
"url",
|
|
13288
|
+
"richtext",
|
|
13289
|
+
"percent",
|
|
13290
|
+
"progress",
|
|
13291
|
+
...Object.keys(SOMA_DATA_FIELD_TYPE_ALIASES)
|
|
13292
|
+
];
|
|
13293
|
+
|
|
13247
13294
|
// core/client/typography/typography-base.ts
|
|
13248
13295
|
var TYPOGRAPHY_BASE_CSS = `[data-soma-host] {
|
|
13249
13296
|
text-autospace: normal;
|
|
@@ -13381,14 +13428,14 @@ function rawTier(value, bounds) {
|
|
|
13381
13428
|
return tier;
|
|
13382
13429
|
}
|
|
13383
13430
|
|
|
13384
|
-
// core/build/
|
|
13385
|
-
var
|
|
13431
|
+
// core/build/blocks/block-container.ts
|
|
13432
|
+
var SomaBlockParseError = class extends Error {
|
|
13386
13433
|
constructor(message, blockId, line) {
|
|
13387
13434
|
const where = blockId ? `\uFF08\u5757: ${blockId}${line ? `\uFF0C\u7B2C ${line} \u884C` : ""}\uFF09` : "";
|
|
13388
13435
|
super(`[soma-core][\u5F15\u64CE] ${message}${where}`);
|
|
13389
13436
|
this.blockId = blockId;
|
|
13390
13437
|
this.line = line;
|
|
13391
|
-
this.name = "
|
|
13438
|
+
this.name = "SomaBlockParseError";
|
|
13392
13439
|
}
|
|
13393
13440
|
};
|
|
13394
13441
|
var PAGE_BLOCK_ID = "page";
|
|
@@ -13399,58 +13446,58 @@ function stripSwitch(uiYamlRaw) {
|
|
|
13399
13446
|
const text = lines[i].trim();
|
|
13400
13447
|
if (text === "" || text.startsWith("#")) continue;
|
|
13401
13448
|
if (text !== "{{") {
|
|
13402
|
-
throw new
|
|
13449
|
+
throw new SomaBlockParseError("\u5757\u58F0\u660E\u5FC5\u987B\u4EE5 `{{` \u5F00\u5173\u884C\u5F00\u5934");
|
|
13403
13450
|
}
|
|
13404
13451
|
openIndex = i;
|
|
13405
13452
|
break;
|
|
13406
13453
|
}
|
|
13407
13454
|
if (openIndex === -1) {
|
|
13408
|
-
throw new
|
|
13455
|
+
throw new SomaBlockParseError("\u6587\u4EF6\u4E3A\u7A7A\u6216\u53EA\u6709\u6CE8\u91CA\uFF0C\u627E\u4E0D\u5230 `{{` \u5F00\u5173\u884C");
|
|
13409
13456
|
}
|
|
13410
13457
|
let closeIndex = -1;
|
|
13411
13458
|
for (let i = lines.length - 1; i > openIndex; i -= 1) {
|
|
13412
13459
|
const text = lines[i].trim();
|
|
13413
13460
|
if (text === "") continue;
|
|
13414
13461
|
if (text !== "}}") {
|
|
13415
|
-
throw new
|
|
13462
|
+
throw new SomaBlockParseError("\u5757\u58F0\u660E\u5FC5\u987B\u4EE5 `}}` \u6536\u53E3\u884C\u7ED3\u5C3E\uFF08\u5F00\u5173\u6210\u5BF9\uFF0C\u6574\u6587\u4EF6\u4E00\u5BF9\uFF09");
|
|
13416
13463
|
}
|
|
13417
13464
|
closeIndex = i;
|
|
13418
13465
|
break;
|
|
13419
13466
|
}
|
|
13420
13467
|
if (closeIndex === -1) {
|
|
13421
|
-
throw new
|
|
13468
|
+
throw new SomaBlockParseError("`{{` \u5F00\u5173\u672A\u95ED\u5408\u2014\u2014\u7F3A\u5C11 `}}` \u6536\u53E3\u884C");
|
|
13422
13469
|
}
|
|
13423
13470
|
return {
|
|
13424
13471
|
inner: lines.slice(openIndex + 1, closeIndex).join("\n"),
|
|
13425
13472
|
offset: openIndex + 1
|
|
13426
13473
|
};
|
|
13427
13474
|
}
|
|
13428
|
-
function
|
|
13475
|
+
function parseSomaBlockContainer(uiYamlRaw) {
|
|
13429
13476
|
const { inner, offset } = stripSwitch(uiYamlRaw);
|
|
13430
13477
|
let doc;
|
|
13431
13478
|
try {
|
|
13432
13479
|
doc = yaml.load(inner);
|
|
13433
13480
|
} catch (error) {
|
|
13434
|
-
throw new
|
|
13481
|
+
throw new SomaBlockParseError(`YAML \u89E3\u6790\u5931\u8D25: ${error.message}`);
|
|
13435
13482
|
}
|
|
13436
13483
|
if (doc === null || doc === void 0) {
|
|
13437
13484
|
return { doc: {}, inner, offset };
|
|
13438
13485
|
}
|
|
13439
13486
|
if (typeof doc !== "object" || Array.isArray(doc)) {
|
|
13440
|
-
throw new
|
|
13487
|
+
throw new SomaBlockParseError("\u5F00\u5173\u5185\u5FC5\u987B\u662F\u5757\u6620\u5C04\uFF08\u9876\u5C42\u952E = \u5757 id\uFF09");
|
|
13441
13488
|
}
|
|
13442
13489
|
for (const [blockId, body] of Object.entries(doc)) {
|
|
13443
13490
|
if (body === null || body === void 0) {
|
|
13444
|
-
throw new
|
|
13491
|
+
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId);
|
|
13445
13492
|
}
|
|
13446
13493
|
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13447
|
-
throw new
|
|
13494
|
+
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId);
|
|
13448
13495
|
}
|
|
13449
13496
|
}
|
|
13450
13497
|
return { doc, inner, offset };
|
|
13451
13498
|
}
|
|
13452
13499
|
function loadSomaFile(input) {
|
|
13453
|
-
const { doc, inner, offset } =
|
|
13500
|
+
const { doc, inner, offset } = parseSomaBlockContainer(input.uiYamlRaw);
|
|
13454
13501
|
if (Object.keys(doc).length === 0) return [];
|
|
13455
13502
|
const innerLines = inner.split("\n");
|
|
13456
13503
|
const lineOfKey = (key) => {
|
|
@@ -13463,13 +13510,13 @@ function loadSomaFile(input) {
|
|
|
13463
13510
|
const line = lineOfKey(blockId);
|
|
13464
13511
|
assertBlockId(blockId, input.htmlIndex, line);
|
|
13465
13512
|
if (seen.has(blockId)) {
|
|
13466
|
-
throw new
|
|
13513
|
+
throw new SomaBlockParseError(`\u5757 "${blockId}" \u91CD\u590D\u58F0\u660E`, blockId, line);
|
|
13467
13514
|
}
|
|
13468
13515
|
if (body === null || body === void 0) {
|
|
13469
|
-
throw new
|
|
13516
|
+
throw new SomaBlockParseError("\u5757\u4F53\u4E3A\u7A7A\u2014\u2014\u4E0D\u9700\u8981\u58F0\u660E\u7684\u7EC4\u4EF6\u8BF7\u76F4\u63A5\u5220\u6389\u8FD9\u4E2A\u5757", blockId, line);
|
|
13470
13517
|
}
|
|
13471
13518
|
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13472
|
-
throw new
|
|
13519
|
+
throw new SomaBlockParseError("\u5757\u4F53\u5FC5\u987B\u662F\u6620\u5C04\uFF08ui/data/event \u4E09\u6BB5\uFF09", blockId, line);
|
|
13473
13520
|
}
|
|
13474
13521
|
seen.add(blockId);
|
|
13475
13522
|
blocks.push({ blockId, body, line, source: "inline" });
|
|
@@ -13477,7 +13524,7 @@ function loadSomaFile(input) {
|
|
|
13477
13524
|
for (const [blockId, raw] of input.externalBlocks ?? /* @__PURE__ */ new Map()) {
|
|
13478
13525
|
assertBlockId(blockId, input.htmlIndex, 0);
|
|
13479
13526
|
if (seen.has(blockId)) {
|
|
13480
|
-
throw new
|
|
13527
|
+
throw new SomaBlockParseError(
|
|
13481
13528
|
`\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
13529
|
blockId
|
|
13483
13530
|
);
|
|
@@ -13486,16 +13533,16 @@ function loadSomaFile(input) {
|
|
|
13486
13533
|
try {
|
|
13487
13534
|
body = yaml.load(raw);
|
|
13488
13535
|
} catch (error) {
|
|
13489
|
-
throw new
|
|
13536
|
+
throw new SomaBlockParseError(
|
|
13490
13537
|
`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u89E3\u6790\u5931\u8D25: ${error.message}`,
|
|
13491
13538
|
blockId
|
|
13492
13539
|
);
|
|
13493
13540
|
}
|
|
13494
13541
|
if (body === null || body === void 0) {
|
|
13495
|
-
throw new
|
|
13542
|
+
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u4E3A\u7A7A`, blockId);
|
|
13496
13543
|
}
|
|
13497
13544
|
if (typeof body !== "object" || Array.isArray(body)) {
|
|
13498
|
-
throw new
|
|
13545
|
+
throw new SomaBlockParseError(`\u5916\u7F6E\u5757 blocks/${blockId}.yaml \u5FC5\u987B\u662F\u6620\u5C04`, blockId);
|
|
13499
13546
|
}
|
|
13500
13547
|
seen.add(blockId);
|
|
13501
13548
|
blocks.push({ blockId, body, line: 1, source: "external" });
|
|
@@ -13506,14 +13553,14 @@ function assertBlockId(blockId, htmlIndex, line) {
|
|
|
13506
13553
|
if (blockId === PAGE_BLOCK_ID) return;
|
|
13507
13554
|
if (htmlIndex.instances.has(blockId)) return;
|
|
13508
13555
|
if (htmlIndex.anchors.has(blockId)) {
|
|
13509
|
-
throw new
|
|
13556
|
+
throw new SomaBlockParseError(
|
|
13510
13557
|
`"${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
13558
|
blockId,
|
|
13512
13559
|
line
|
|
13513
13560
|
);
|
|
13514
13561
|
}
|
|
13515
13562
|
const known = [...htmlIndex.instances].slice(0, 8).join("\u3001");
|
|
13516
|
-
throw new
|
|
13563
|
+
throw new SomaBlockParseError(
|
|
13517
13564
|
`HTML \u91CC\u6CA1\u6709\u5B9E\u4F8B\u951A\u70B9 "${blockId}"${known ? `\uFF08\u73B0\u6709\u5B9E\u4F8B\uFF1A${known}\uFF09` : ""}`,
|
|
13518
13565
|
blockId,
|
|
13519
13566
|
line
|
|
@@ -13522,7 +13569,7 @@ function assertBlockId(blockId, htmlIndex, line) {
|
|
|
13522
13569
|
|
|
13523
13570
|
// core/build/compiler/soma-precompile.ts
|
|
13524
13571
|
function precompileUiModule(yamlStr) {
|
|
13525
|
-
|
|
13572
|
+
parseSomaBlockContainer(yamlStr);
|
|
13526
13573
|
return "null";
|
|
13527
13574
|
}
|
|
13528
13575
|
function compileEventConfigFromRaw(raw) {
|
|
@@ -14194,6 +14241,36 @@ function isPublishedPageRecord(value) {
|
|
|
14194
14241
|
return typeof record.name === "string" && typeof record.version === "number" && !!record.declaration && typeof record.declaration === "object" && typeof record.declaration.html === "string" && typeof record.declaration.uiYaml === "string";
|
|
14195
14242
|
}
|
|
14196
14243
|
|
|
14244
|
+
// core/shared/published-page-route.ts
|
|
14245
|
+
var PUBLISHED_PAGE_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
14246
|
+
var RESERVED_PUBLISHED_PAGE_SLUGS = /* @__PURE__ */ new Set([
|
|
14247
|
+
"api",
|
|
14248
|
+
"soma",
|
|
14249
|
+
"pages",
|
|
14250
|
+
"workbench",
|
|
14251
|
+
"_next"
|
|
14252
|
+
]);
|
|
14253
|
+
function isPublishedPageSlug(value) {
|
|
14254
|
+
return typeof value === "string" && PUBLISHED_PAGE_SLUG_PATTERN.test(value) && !RESERVED_PUBLISHED_PAGE_SLUGS.has(value);
|
|
14255
|
+
}
|
|
14256
|
+
function normalizePublishedPageSlug(value) {
|
|
14257
|
+
if (typeof value !== "string") return null;
|
|
14258
|
+
const normalized = value.trim().toLowerCase().replace(/^\/+|\/+$/g, "").replace(/[\s_]+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 64).replace(/-$/g, "");
|
|
14259
|
+
return isPublishedPageSlug(normalized) ? normalized : null;
|
|
14260
|
+
}
|
|
14261
|
+
function publishedPagePath(slug) {
|
|
14262
|
+
if (!isPublishedPageSlug(slug)) {
|
|
14263
|
+
throw new Error(`Invalid published page slug: ${slug}`);
|
|
14264
|
+
}
|
|
14265
|
+
return `/${slug}`;
|
|
14266
|
+
}
|
|
14267
|
+
function publishedPageSlugFromPath(pagePath) {
|
|
14268
|
+
const legacy = pagePath.match(/^\/pages\/([^/]+)$/)?.[1];
|
|
14269
|
+
if (legacy && isPublishedPageSlug(legacy)) return legacy;
|
|
14270
|
+
const root = pagePath.match(/^\/([^/]+)$/)?.[1];
|
|
14271
|
+
return root && isPublishedPageSlug(root) ? root : null;
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14197
14274
|
// core/client/component/pack-styles.ts
|
|
14198
14275
|
var injected2 = /* @__PURE__ */ new Set();
|
|
14199
14276
|
function resetPackStyleInjection() {
|
|
@@ -14292,6 +14369,25 @@ function checkOverrideCompat(winner, base) {
|
|
|
14292
14369
|
});
|
|
14293
14370
|
}
|
|
14294
14371
|
}
|
|
14372
|
+
const winnerSlots = winner.slots ?? {};
|
|
14373
|
+
for (const [name, baseSlot] of Object.entries(base.slots ?? {})) {
|
|
14374
|
+
const winnerSlot = winnerSlots[name];
|
|
14375
|
+
if (!winnerSlot) {
|
|
14376
|
+
issues.push({
|
|
14377
|
+
kind: "slot-missing",
|
|
14378
|
+
member: name,
|
|
14379
|
+
detail: `\u7F3A\u5C11\u63D2\u69FD "${name}"\u2014\u2014\u5B58\u91CF\u9875\u9762\u4ECD\u5728\u5F80\u8FD9\u4E2A\u69FD\u6295\u5F71\u5185\u5BB9\uFF0C\u8986\u76D6\u540E\u4E0D\u662F\u5C11\u4E00\u5757\u5185\u5BB9\uFF0C\u800C\u662F\u6302\u8F7D\u65F6\u76F4\u63A5\u629B SomaComponentExpandError\uFF08\u6574\u9875\u5D29\uFF09`
|
|
14380
|
+
});
|
|
14381
|
+
continue;
|
|
14382
|
+
}
|
|
14383
|
+
if (winnerSlot.required === true && baseSlot.required !== true) {
|
|
14384
|
+
issues.push({
|
|
14385
|
+
kind: "slot-required-tightened",
|
|
14386
|
+
member: name,
|
|
14387
|
+
detail: `\u63D2\u69FD "${name}" \u4ECE\u53EF\u9009\u6536\u7D27\u4E3A\u5FC5\u586B\u2014\u2014\u5B58\u91CF\u9875\u9762\u6CA1\u7ED9\u8FD9\u4E2A\u69FD\u7684\u5730\u65B9\u4F1A\u5728\u6302\u8F7D\u65F6\u629B\u9519`
|
|
14388
|
+
});
|
|
14389
|
+
}
|
|
14390
|
+
}
|
|
14295
14391
|
return issues;
|
|
14296
14392
|
}
|
|
14297
14393
|
function sameDefault(a, b) {
|
|
@@ -14987,7 +15083,7 @@ function describeNode(node) {
|
|
|
14987
15083
|
}
|
|
14988
15084
|
}
|
|
14989
15085
|
|
|
14990
|
-
// core/build/
|
|
15086
|
+
// core/build/blocks/html-index.ts
|
|
14991
15087
|
var ANCHOR_RE = /data-soma-id=["']([^"']+)["']/g;
|
|
14992
15088
|
var COMPONENT_NEAR_RE = /data-soma-component=["']([^"']+)["']/;
|
|
14993
15089
|
var HOST_RE = /data-soma-host=["']([^"']+)["']/;
|
|
@@ -15050,7 +15146,7 @@ function buildHtmlAnchorIndex(html) {
|
|
|
15050
15146
|
};
|
|
15051
15147
|
}
|
|
15052
15148
|
|
|
15053
|
-
// core/client/parser/
|
|
15149
|
+
// core/client/parser/blocks/namespace.ts
|
|
15054
15150
|
var SomaScopeError = class extends Error {
|
|
15055
15151
|
constructor(message, blockId) {
|
|
15056
15152
|
super(`[soma-core][\u5F15\u64CE] ${message}\uFF08\u5757: ${blockId}\uFF09`);
|
|
@@ -15165,7 +15261,7 @@ function expandPath(raw, scope) {
|
|
|
15165
15261
|
return resolved.kind === "literal" ? raw.trim() : resolved.full;
|
|
15166
15262
|
}
|
|
15167
15263
|
|
|
15168
|
-
// core/client/parser/
|
|
15264
|
+
// core/client/parser/blocks/page-parser.ts
|
|
15169
15265
|
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
15170
15266
|
"domain",
|
|
15171
15267
|
"locale",
|
|
@@ -15175,19 +15271,19 @@ var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
|
15175
15271
|
"data",
|
|
15176
15272
|
"adaptive",
|
|
15177
15273
|
"alias",
|
|
15178
|
-
// initProps
|
|
15274
|
+
// initProps:引擎启动前写入的初始值(平铺 UiConfig 同名字段的直通)。
|
|
15179
15275
|
//
|
|
15180
|
-
//
|
|
15181
|
-
//
|
|
15276
|
+
// 块声明是照**手写页面**设计的——那里文案住 HTML、初值住 Domain,声明里不需要它。
|
|
15277
|
+
// 但块声明产的是平铺等价物,而生成链的页面把字面文案内联在 initProps 里
|
|
15182
15278
|
// (模型出的是组织意图,没有 Domain 可写)。少了这个键,AI 产的页面
|
|
15183
|
-
//
|
|
15279
|
+
// 就永远迈不过块声明的门槛——不是"用不上块声明",是"表达不了"。
|
|
15184
15280
|
"initProps"
|
|
15185
15281
|
]);
|
|
15186
15282
|
var SUFFIXES = ["when", "model", "class"];
|
|
15187
15283
|
function parsePageBlock(input) {
|
|
15188
15284
|
const { body } = input;
|
|
15189
15285
|
const fail = (message) => {
|
|
15190
|
-
throw new
|
|
15286
|
+
throw new SomaBlockParseError(message, "page");
|
|
15191
15287
|
};
|
|
15192
15288
|
for (const key of Object.keys(body)) {
|
|
15193
15289
|
if (!PAGE_KEYS.has(key)) {
|
|
@@ -15262,7 +15358,7 @@ function parsePageBlock(input) {
|
|
|
15262
15358
|
}
|
|
15263
15359
|
function parseShowLevel(raw, target, scope, input, where) {
|
|
15264
15360
|
const fail = (message) => {
|
|
15265
|
-
throw new
|
|
15361
|
+
throw new SomaBlockParseError(message, "page");
|
|
15266
15362
|
};
|
|
15267
15363
|
for (const [key, value] of Object.entries(raw)) {
|
|
15268
15364
|
if (key === "each") continue;
|
|
@@ -15311,7 +15407,7 @@ function isEachBlock(value) {
|
|
|
15311
15407
|
}
|
|
15312
15408
|
function parseEachBlock(block, scope, input, anchor) {
|
|
15313
15409
|
const fail = (message) => {
|
|
15314
|
-
throw new
|
|
15410
|
+
throw new SomaBlockParseError(message, "page");
|
|
15315
15411
|
};
|
|
15316
15412
|
const raw = String(block.each);
|
|
15317
15413
|
const match = /^(\S+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw.trim());
|
|
@@ -15414,7 +15510,7 @@ function normalizeEventSection(raw, input, fail) {
|
|
|
15414
15510
|
return result;
|
|
15415
15511
|
}
|
|
15416
15512
|
|
|
15417
|
-
// core/client/parser/
|
|
15513
|
+
// core/client/parser/blocks/use-parser.ts
|
|
15418
15514
|
var BLOCK_KEYS = /* @__PURE__ */ new Set(["component", "alias", "when", "data", "ui", "event"]);
|
|
15419
15515
|
var DATA_OBJECT_KEYS = /* @__PURE__ */ new Set(["from", "save", "refresh", "reload_on", "fields"]);
|
|
15420
15516
|
var EVENT_KEYS = /* @__PURE__ */ new Set(["actions", "on"]);
|
|
@@ -15429,22 +15525,11 @@ var ACTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
15429
15525
|
"disabled_reason"
|
|
15430
15526
|
]);
|
|
15431
15527
|
var FIELD_KEYS = /* @__PURE__ */ new Set(["name", "type", "values", "permission", "rules"]);
|
|
15432
|
-
var FIELD_TYPES =
|
|
15433
|
-
"text",
|
|
15434
|
-
"int",
|
|
15435
|
-
"number",
|
|
15436
|
-
"money",
|
|
15437
|
-
"date",
|
|
15438
|
-
"enum",
|
|
15439
|
-
"bool",
|
|
15440
|
-
"percent",
|
|
15441
|
-
// progress 与 percent 同数据两种读法:前者出进度条,后者出文字(见 soma-ui 类型渲染表)
|
|
15442
|
-
"progress"
|
|
15443
|
-
]);
|
|
15528
|
+
var FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
|
|
15444
15529
|
function parseUseBlock(input) {
|
|
15445
15530
|
const { blockId, body } = input;
|
|
15446
15531
|
const fail = (message) => {
|
|
15447
|
-
throw new
|
|
15532
|
+
throw new SomaBlockParseError(message, blockId);
|
|
15448
15533
|
};
|
|
15449
15534
|
for (const key of Object.keys(body)) {
|
|
15450
15535
|
if (!BLOCK_KEYS.has(key)) {
|
|
@@ -15568,10 +15653,11 @@ function parseField2(objectName, fieldName, raw, fail) {
|
|
|
15568
15653
|
fail(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
|
|
15569
15654
|
}
|
|
15570
15655
|
}
|
|
15571
|
-
const
|
|
15572
|
-
|
|
15656
|
+
const declaredType = String(field.type ?? "");
|
|
15657
|
+
const type2 = SOMA_DATA_FIELD_TYPE_ALIASES[declaredType] ?? declaredType;
|
|
15658
|
+
if (!FIELD_TYPES.has(declaredType)) {
|
|
15573
15659
|
fail(
|
|
15574
|
-
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${
|
|
15660
|
+
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${declaredType}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
|
|
15575
15661
|
);
|
|
15576
15662
|
}
|
|
15577
15663
|
if (type2 === "enum") {
|
|
@@ -15691,11 +15777,11 @@ function expandUiPaths(value, scope) {
|
|
|
15691
15777
|
return walk(value);
|
|
15692
15778
|
}
|
|
15693
15779
|
|
|
15694
|
-
// core/build/
|
|
15695
|
-
function
|
|
15780
|
+
// core/build/blocks/block-compile.ts
|
|
15781
|
+
function compileSomaBlocks(input) {
|
|
15696
15782
|
const htmlIndex = buildHtmlAnchorIndex(input.html);
|
|
15697
15783
|
if (htmlIndex.duplicates.length > 0) {
|
|
15698
|
-
throw new
|
|
15784
|
+
throw new SomaBlockParseError(
|
|
15699
15785
|
`HTML \u951A\u70B9\u91CD\u590D\uFF1A${htmlIndex.duplicates.join("\u3001")}\u2014\u2014\u9875\u9762\u5185 data-soma-id \u5FC5\u987B\u552F\u4E00`
|
|
15700
15786
|
);
|
|
15701
15787
|
}
|
|
@@ -15706,7 +15792,7 @@ function compileSomaV2(input) {
|
|
|
15706
15792
|
});
|
|
15707
15793
|
const pageRaw = rawBlocks.find((block) => block.blockId === PAGE_BLOCK_ID);
|
|
15708
15794
|
if (!pageRaw) {
|
|
15709
|
-
throw new
|
|
15795
|
+
throw new SomaBlockParseError("\u7F3A\u5C11 page \u5757\uFF08\u9875\u9762\u5FC5\u987B\u58F0\u660E domain\uFF09");
|
|
15710
15796
|
}
|
|
15711
15797
|
const anchors = new Set(htmlIndex.anchors.keys());
|
|
15712
15798
|
const page = parsePageBlock({
|
|
@@ -15777,14 +15863,14 @@ function attachInstance(ui, blockId, ast, htmlIndex) {
|
|
|
15777
15863
|
}
|
|
15778
15864
|
const owner = info.ownerList;
|
|
15779
15865
|
if (!owner) {
|
|
15780
|
-
throw new
|
|
15866
|
+
throw new SomaBlockParseError(
|
|
15781
15867
|
`\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
15868
|
blockId
|
|
15783
15869
|
);
|
|
15784
15870
|
}
|
|
15785
15871
|
const target = findListShow(ui.show, owner);
|
|
15786
15872
|
if (!target) {
|
|
15787
|
-
throw new
|
|
15873
|
+
throw new SomaBlockParseError(
|
|
15788
15874
|
`\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
15875
|
blockId
|
|
15790
15876
|
);
|
|
@@ -15854,7 +15940,7 @@ function compilePageDeclaration(input) {
|
|
|
15854
15940
|
`[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
15941
|
);
|
|
15856
15942
|
}
|
|
15857
|
-
const compiled =
|
|
15943
|
+
const compiled = compileSomaBlocks({
|
|
15858
15944
|
html: expandSomaHtmlIncludes(input.html, input.includes),
|
|
15859
15945
|
uiYamlRaw: input.uiYaml,
|
|
15860
15946
|
...input.externalBlocks ? { externalBlocks: input.externalBlocks } : {}
|
|
@@ -15902,17 +15988,22 @@ function compilePageAssets(assets) {
|
|
|
15902
15988
|
MiniProgramContainerAdapter,
|
|
15903
15989
|
PACK_NAME_PATTERN,
|
|
15904
15990
|
PAGE_BLOCK_ID,
|
|
15991
|
+
PUBLISHED_PAGE_SLUG_PATTERN,
|
|
15905
15992
|
Page,
|
|
15993
|
+
RESERVED_PUBLISHED_PAGE_SLUGS,
|
|
15906
15994
|
ReactNativeContainerAdapter,
|
|
15907
15995
|
SOMA_ADAPTIVE_MAX_LADDER,
|
|
15908
15996
|
SOMA_ADAPTIVE_PROFILES,
|
|
15909
15997
|
SOMA_ADAPTIVE_PROFILE_ATTR,
|
|
15998
|
+
SOMA_DATA_FIELD_TYPES,
|
|
15999
|
+
SOMA_DATA_FIELD_TYPE_ALIASES,
|
|
15910
16000
|
SOMA_DEFAULT_HYSTERESIS,
|
|
15911
16001
|
SOMA_PURIFY_PROFILE,
|
|
15912
16002
|
Show,
|
|
15913
16003
|
ShowList,
|
|
15914
16004
|
SomaAdaptiveConfigError,
|
|
15915
16005
|
SomaApi,
|
|
16006
|
+
SomaBlockParseError,
|
|
15916
16007
|
SomaBootstrap,
|
|
15917
16008
|
SomaComponentManager,
|
|
15918
16009
|
SomaComponentRegistry,
|
|
@@ -15933,7 +16024,6 @@ function compilePageAssets(assets) {
|
|
|
15933
16024
|
SomaRealtimeService,
|
|
15934
16025
|
SomaScopeError,
|
|
15935
16026
|
SomaTelemetry,
|
|
15936
|
-
SomaV2ParseError,
|
|
15937
16027
|
SomaValidator,
|
|
15938
16028
|
SomaValueLangError,
|
|
15939
16029
|
SseRealtimeTransport,
|
|
@@ -15950,7 +16040,7 @@ function compilePageAssets(assets) {
|
|
|
15950
16040
|
checkOverrideCompat,
|
|
15951
16041
|
compileAdaptive,
|
|
15952
16042
|
compilePageAssets,
|
|
15953
|
-
|
|
16043
|
+
compileSomaBlocks,
|
|
15954
16044
|
composeComponentPacks,
|
|
15955
16045
|
contrastRatio,
|
|
15956
16046
|
createAdaptiveObserverPool,
|
|
@@ -15984,6 +16074,7 @@ function compilePageAssets(assets) {
|
|
|
15984
16074
|
isBootTimingsEnabled,
|
|
15985
16075
|
isEventHandlerAttribute,
|
|
15986
16076
|
isPlainPath,
|
|
16077
|
+
isPublishedPageSlug,
|
|
15987
16078
|
isSomaMockEnabled,
|
|
15988
16079
|
loadSomaDomainModuleFromRegistry,
|
|
15989
16080
|
loadSomaFile,
|
|
@@ -15991,6 +16082,7 @@ function compilePageAssets(assets) {
|
|
|
15991
16082
|
matchGlobPath,
|
|
15992
16083
|
maybeStartBootTimings,
|
|
15993
16084
|
normalizeDataPipeValue,
|
|
16085
|
+
normalizePublishedPageSlug,
|
|
15994
16086
|
parseAdaptiveConfig,
|
|
15995
16087
|
parseDataConfig,
|
|
15996
16088
|
parseDataRef,
|
|
@@ -15998,6 +16090,8 @@ function compilePageAssets(assets) {
|
|
|
15998
16090
|
parsePageBlock,
|
|
15999
16091
|
parseUseBlock,
|
|
16000
16092
|
parseValueSegment,
|
|
16093
|
+
publishedPagePath,
|
|
16094
|
+
publishedPageSlugFromPath,
|
|
16001
16095
|
readBootTimings,
|
|
16002
16096
|
recordMetric,
|
|
16003
16097
|
renderPublishedPage,
|