soma-core 1.6.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/build/compiler/soma-precompile.js +182 -15
- package/core/build/eject/component-eject.ts +1 -0
- package/core/client/adaptive/observer-pool.ts +122 -8
- package/core/client/compiler/manifest-compiler.ts +46 -5
- package/core/client/component/component-defaults.ts +1 -1
- package/core/client/component/component-expander.ts +1 -1
- package/core/client/component/component-manager.ts +784 -35
- package/core/client/component/component-pack.ts +1 -1
- package/core/client/component/component-registry.ts +1 -1
- package/core/client/container/SomaContainerAdapter.ts +103 -2
- package/core/client/data/data-object-resolver.ts +45 -1
- package/core/client/engine/dom-renderer.ts +432 -29
- package/core/client/engine/event-engine.ts +301 -13
- package/core/client/engine/property-watcher.ts +164 -18
- package/core/client/engine/reactive-proxy.ts +194 -23
- package/core/client/engine/render-engine.ts +118 -11
- package/core/client/engine/scope-resolver.ts +3 -3
- package/core/client/engine/soma-bootstrap.ts +31 -17
- package/core/client/parser/adaptive-parser.ts +1 -1
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +21 -6
- package/core/client/parser/data-config-parser.ts +1 -1
- package/core/client/parser/pipeline-parser.ts +252 -15
- package/core/client/parser/style-config-parser.ts +1 -1
- package/core/client/parser/timer-parser.ts +1 -1
- package/core/client/parser/trigger-parser.ts +1 -1
- package/core/client/parser/ui-config-parser.ts +1 -1
- package/core/client/pipes/pipe-registry.ts +45 -4
- package/core/client/runtime/SomaSnapshotStore.ts +1 -1
- package/core/client/scheduler/SomaScheduler.ts +1 -1
- package/core/client/security/attribute-presence.ts +3 -0
- package/core/client/theme/harmony.ts +135 -13
- package/core/client/theme/scene-tokens.ts +17 -2
- package/core/client/theme/theme-axes.ts +43 -6
- package/core/client/theme/theme-engine.ts +921 -126
- package/core/client/validation/contract-validator.ts +1 -1
- package/core/server/mock/node/cli.mjs +3 -3
- package/core/shared/path-algebra.ts +1 -1
- package/core/shared/types/event.types.ts +8 -4
- package/dist/core/index.cjs +5411 -3507
- package/dist/lsp/component-tree.cjs +701 -511
- package/dist/types/client/adaptive/observer-pool.d.ts +9 -2
- package/dist/types/client/compiler/manifest-compiler.d.ts +11 -2
- package/dist/types/client/component/component-manager.d.ts +86 -0
- package/dist/types/client/container/SomaContainerAdapter.d.ts +8 -0
- package/dist/types/client/data/data-object-resolver.d.ts +19 -0
- package/dist/types/client/engine/dom-renderer.d.ts +110 -2
- package/dist/types/client/engine/event-engine.d.ts +61 -3
- package/dist/types/client/engine/property-watcher.d.ts +41 -1
- package/dist/types/client/engine/reactive-proxy.d.ts +42 -2
- package/dist/types/client/engine/render-engine.d.ts +54 -3
- package/dist/types/client/parser/blocks/use-parser.d.ts +18 -0
- package/dist/types/client/parser/pipeline-parser.d.ts +12 -4
- package/dist/types/client/pipes/pipe-registry.d.ts +39 -1
- package/dist/types/client/theme/harmony.d.ts +44 -2
- package/dist/types/client/theme/scene-tokens.d.ts +11 -1
- package/dist/types/client/theme/theme-axes.d.ts +36 -6
- package/dist/types/shared/types/event.types.d.ts +8 -4
- package/package.json +4 -4
- package/dist/preview-export.cjs +0 -3401
|
@@ -3779,304 +3779,6 @@ function expandPath(raw, scope) {
|
|
|
3779
3779
|
return resolved.kind === "literal" ? raw.trim() : resolved.full;
|
|
3780
3780
|
}
|
|
3781
3781
|
|
|
3782
|
-
// core/client/parser/blocks/page-parser.ts
|
|
3783
|
-
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
3784
|
-
"domain",
|
|
3785
|
-
"locale",
|
|
3786
|
-
"ui",
|
|
3787
|
-
"watch",
|
|
3788
|
-
"event",
|
|
3789
|
-
"data",
|
|
3790
|
-
"adaptive",
|
|
3791
|
-
"alias",
|
|
3792
|
-
// initProps:引擎启动前写入的初始值(平铺 UiConfig 同名字段的直通)。
|
|
3793
|
-
//
|
|
3794
|
-
// 块声明是照**手写页面**设计的——那里文案住 HTML、初值住 Domain,声明里不需要它。
|
|
3795
|
-
// 但块声明产的是平铺等价物,而生成链的页面把字面文案内联在 initProps 里
|
|
3796
|
-
// (模型出的是组织意图,没有 Domain 可写)。少了这个键,AI 产的页面
|
|
3797
|
-
// 就永远迈不过块声明的门槛——不是"用不上块声明",是"表达不了"。
|
|
3798
|
-
"initProps",
|
|
3799
|
-
// state / layout(REQ-010 F-37 / S3,REQ-011 补接线):两个平铺 UiConfig 保留键的直通。
|
|
3800
|
-
//
|
|
3801
|
-
// 此前 PAGE_KEYS 没有它们——而 compilePageDeclaration 只收块声明,于是《声明语法手册》
|
|
3802
|
-
// 里写着的 `state:` 在任何一张真正发布的页面上都写不进去("page 块不支持键 state"),
|
|
3803
|
-
// 只有测试里直接喂平铺 YAML 的路径能用。文档承诺了一件真实页面做不到的事。
|
|
3804
|
-
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
3805
|
-
"state",
|
|
3806
|
-
"layout",
|
|
3807
|
-
// ooui(REQ-014 演绎接线):第三个平铺 UiConfig 保留键的直通。
|
|
3808
|
-
//
|
|
3809
|
-
// 少了这一条,块声明页写 `ooui:` 会当场收到「page 块不支持键 "ooui"」——
|
|
3810
|
-
// 而**真实发布的页面只有块声明这一条路**(compilePageDeclaration 只收块声明),
|
|
3811
|
-
// 于是整条演绎链只在"直接喂平铺 YAML"的测试路径上活着,生产页面一次都用不上。
|
|
3812
|
-
// 这与上面 state / layout 那次踩的是同一个坑,不再重踩第三次。
|
|
3813
|
-
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
3814
|
-
"ooui",
|
|
3815
|
-
// objects(REQ-014 表层语义,§38.5 断线 ②):**面向人书写的那一层对象声明**。
|
|
3816
|
-
//
|
|
3817
|
-
// `data:` 是核心层——完备、显式、机器好翻译(`{ type: text, rules: [{ required: true }] }`)。
|
|
3818
|
-
// 表层是同一件事的人写形态(`no: text!`)。两层的转换点只有一个
|
|
3819
|
-
// (`build/ooui/semantic/normalize.ts`),而在此之前**它一个生产调用者都没有**:
|
|
3820
|
-
// 表层类型、展开器、台账三样都写完了,页面上却没有任何地方能写出表层来。
|
|
3821
|
-
//
|
|
3822
|
-
// 不接这一条的后果不是"少个语法糖",是**来历台账永远是空的**:
|
|
3823
|
-
// 系统按默认补的值(如 `permission: r`)与作者显式写的值在产物里长得一模一样,
|
|
3824
|
-
// 于是 `OOUI-SEM-EDIT-ALL-READONLY` 只能说"你写错了",说不出"我按默认补的、
|
|
3825
|
-
// 你需要显式写 permission: w"——同一条错误,两种修法,指向两个人(§34.2)。
|
|
3826
|
-
//
|
|
3827
|
-
// 这里只直通原文;展开与校验在 compilePageDeclaration(构建期)做一次。
|
|
3828
|
-
"objects"
|
|
3829
|
-
]);
|
|
3830
|
-
var SUFFIXES = ["when", "model", "class"];
|
|
3831
|
-
function parsePageBlock(input) {
|
|
3832
|
-
const { body } = input;
|
|
3833
|
-
const fail6 = (message) => {
|
|
3834
|
-
throw new SomaBlockParseError(message, "page");
|
|
3835
|
-
};
|
|
3836
|
-
for (const key of Object.keys(body)) {
|
|
3837
|
-
if (!PAGE_KEYS.has(key)) {
|
|
3838
|
-
fail6(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
|
|
3839
|
-
}
|
|
3840
|
-
}
|
|
3841
|
-
const domain = body.domain;
|
|
3842
|
-
if (typeof domain !== "string" || domain.trim() === "") {
|
|
3843
|
-
fail6("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
|
|
3844
|
-
}
|
|
3845
|
-
const scope = buildBlockScope({
|
|
3846
|
-
blockId: "page",
|
|
3847
|
-
dataNames: [.../* @__PURE__ */ new Set([
|
|
3848
|
-
...Object.keys(body.data ?? {}),
|
|
3849
|
-
...Object.keys(body.objects ?? {})
|
|
3850
|
-
])],
|
|
3851
|
-
aliasRaw: body.alias
|
|
3852
|
-
});
|
|
3853
|
-
const show = {};
|
|
3854
|
-
const locale = body.locale;
|
|
3855
|
-
if (locale !== void 0) {
|
|
3856
|
-
if (!Array.isArray(locale)) fail6("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
|
|
3857
|
-
for (const item of locale) {
|
|
3858
|
-
const key = String(item);
|
|
3859
|
-
if (!input.anchors.has(key)) {
|
|
3860
|
-
fail6(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
|
|
3861
|
-
}
|
|
3862
|
-
if (input.localeKeys && !input.localeKeys.has(key)) {
|
|
3863
|
-
fail6(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
|
|
3864
|
-
}
|
|
3865
|
-
show[key] = `page._locale.${key}`;
|
|
3866
|
-
}
|
|
3867
|
-
}
|
|
3868
|
-
const uiRaw = body.ui ?? {};
|
|
3869
|
-
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail6("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
3870
|
-
parseShowLevel(uiRaw, show, scope, input, "page");
|
|
3871
|
-
const bind = { obj: String(domain), var: "page" };
|
|
3872
|
-
const watch = body.watch;
|
|
3873
|
-
if (watch !== void 0) {
|
|
3874
|
-
if (!Array.isArray(watch)) fail6("watch \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
3875
|
-
const rules = [];
|
|
3876
|
-
for (const item of watch) {
|
|
3877
|
-
if (!item || typeof item !== "object") fail6("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
|
|
3878
|
-
const path2 = item.path;
|
|
3879
|
-
const call = item.call;
|
|
3880
|
-
if (typeof path2 !== "string" || path2.trim() === "") fail6("watch \u9879\u7F3A\u5C11 path");
|
|
3881
|
-
if (typeof call !== "string" || call.trim() === "") fail6("watch \u9879\u7F3A\u5C11 call");
|
|
3882
|
-
const rule = {
|
|
3883
|
-
condition: expandPath(String(path2), scope),
|
|
3884
|
-
callback: String(call).includes(".") ? String(call) : `page.${call}`
|
|
3885
|
-
};
|
|
3886
|
-
if (typeof item.debounce === "number") rule.debounce = item.debounce;
|
|
3887
|
-
if (typeof item.refresh === "boolean") rule.refresh = item.refresh;
|
|
3888
|
-
rules.push(rule);
|
|
3889
|
-
}
|
|
3890
|
-
if (rules.length > 0) bind.onChange = rules;
|
|
3891
|
-
}
|
|
3892
|
-
const ui = { bind, show };
|
|
3893
|
-
if (body.initProps !== void 0) {
|
|
3894
|
-
if (body.initProps === null || typeof body.initProps !== "object" || Array.isArray(body.initProps)) {
|
|
3895
|
-
fail6("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
|
|
3896
|
-
}
|
|
3897
|
-
ui.initProps = body.initProps;
|
|
3898
|
-
}
|
|
3899
|
-
if (body.adaptive !== void 0) {
|
|
3900
|
-
ui.adaptive = body.adaptive;
|
|
3901
|
-
}
|
|
3902
|
-
if (body.state !== void 0) {
|
|
3903
|
-
ui.state = body.state;
|
|
3904
|
-
}
|
|
3905
|
-
if (body.layout !== void 0) {
|
|
3906
|
-
ui.layout = body.layout;
|
|
3907
|
-
}
|
|
3908
|
-
if (body.ooui !== void 0) {
|
|
3909
|
-
ui.ooui = body.ooui;
|
|
3910
|
-
}
|
|
3911
|
-
const eventRaw = normalizeEventSection(body.event, input, fail6);
|
|
3912
|
-
return {
|
|
3913
|
-
ui,
|
|
3914
|
-
eventRaw,
|
|
3915
|
-
...body.data ? { dataRaw: body.data } : {},
|
|
3916
|
-
...body.objects ? { surfaceRaw: body.objects } : {},
|
|
3917
|
-
scope
|
|
3918
|
-
};
|
|
3919
|
-
}
|
|
3920
|
-
function parseShowLevel(raw, target, scope, input, where) {
|
|
3921
|
-
const fail6 = (message) => {
|
|
3922
|
-
throw new SomaBlockParseError(message, "page");
|
|
3923
|
-
};
|
|
3924
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
3925
|
-
if (key === "each") continue;
|
|
3926
|
-
const { anchor, suffix, attr: attr2 } = splitKey(key);
|
|
3927
|
-
if (input.instances.has(anchor)) {
|
|
3928
|
-
fail6(
|
|
3929
|
-
`"${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`
|
|
3930
|
-
);
|
|
3931
|
-
}
|
|
3932
|
-
if (!input.anchors.has(anchor)) {
|
|
3933
|
-
fail6(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
|
|
3934
|
-
}
|
|
3935
|
-
if (isEachBlock(value)) {
|
|
3936
|
-
target[anchor] = parseEachBlock(value, scope, input, anchor);
|
|
3937
|
-
continue;
|
|
3938
|
-
}
|
|
3939
|
-
if (suffix) {
|
|
3940
|
-
const existing2 = asExtended(target[anchor]);
|
|
3941
|
-
applySuffix(existing2, suffix, value, scope, fail6);
|
|
3942
|
-
target[anchor] = existing2;
|
|
3943
|
-
continue;
|
|
3944
|
-
}
|
|
3945
|
-
if (attr2) {
|
|
3946
|
-
if (value !== null && typeof value === "object") {
|
|
3947
|
-
fail6(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
|
|
3948
|
-
}
|
|
3949
|
-
target[`${anchor}@${attr2}`] = expandValue(value, scope, fail6);
|
|
3950
|
-
continue;
|
|
3951
|
-
}
|
|
3952
|
-
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
3953
|
-
fail6(
|
|
3954
|
-
`"${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`
|
|
3955
|
-
);
|
|
3956
|
-
}
|
|
3957
|
-
const expanded = expandValue(value, scope, fail6);
|
|
3958
|
-
const existing = target[anchor];
|
|
3959
|
-
if (existing !== void 0 && typeof existing === "object" && !Array.isArray(existing)) {
|
|
3960
|
-
existing.text = expanded;
|
|
3961
|
-
} else {
|
|
3962
|
-
target[anchor] = expanded;
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
function isEachBlock(value) {
|
|
3967
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.each === "string";
|
|
3968
|
-
}
|
|
3969
|
-
function parseEachBlock(block, scope, input, anchor) {
|
|
3970
|
-
const fail6 = (message) => {
|
|
3971
|
-
throw new SomaBlockParseError(message, "page");
|
|
3972
|
-
};
|
|
3973
|
-
const raw = String(block.each);
|
|
3974
|
-
const match = /^(\S+)\s+as\s+([$A-Z_a-z][$\w]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw.trim());
|
|
3975
|
-
if (!match) {
|
|
3976
|
-
fail6(`each \u8BED\u6CD5\u9519\u8BEF: "${raw}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
|
|
3977
|
-
}
|
|
3978
|
-
const [, sourcePath, rowVar, byPath, keyPath] = match;
|
|
3979
|
-
const bind = {
|
|
3980
|
-
obj: expandPath(sourcePath, scope),
|
|
3981
|
-
var: rowVar
|
|
3982
|
-
};
|
|
3983
|
-
if (byPath) bind.role_by = byPath;
|
|
3984
|
-
if (keyPath) {
|
|
3985
|
-
bind.key = keyPath.includes(".") ? keyPath : `${rowVar}.${keyPath}`;
|
|
3986
|
-
if (!bind.key.startsWith(`${rowVar}.`) || !/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)+$/.test(bind.key) || bind.key.split(".").some((part) => ["__proto__", "prototype", "constructor"].includes(part))) {
|
|
3987
|
-
fail6("each key \u5FC5\u987B\u662F\u5F53\u524D\u884C\u53D8\u91CF\u7684\u5B89\u5168\u5B57\u6BB5\u8DEF\u5F84");
|
|
3988
|
-
}
|
|
3989
|
-
}
|
|
3990
|
-
const rowScope = {
|
|
3991
|
-
...scope,
|
|
3992
|
-
rowVars: /* @__PURE__ */ new Set([...scope.rowVars, rowVar])
|
|
3993
|
-
};
|
|
3994
|
-
const childShow = {};
|
|
3995
|
-
const nested = {};
|
|
3996
|
-
for (const [key, value] of Object.entries(block)) {
|
|
3997
|
-
if (key === "each") continue;
|
|
3998
|
-
nested[key] = value;
|
|
3999
|
-
}
|
|
4000
|
-
parseShowLevel(nested, childShow, rowScope, input, `\u5217\u8868 ${anchor}`);
|
|
4001
|
-
return { bind, show: childShow };
|
|
4002
|
-
}
|
|
4003
|
-
function splitKey(key) {
|
|
4004
|
-
const atIndex = key.indexOf("@");
|
|
4005
|
-
if (atIndex > 0) {
|
|
4006
|
-
return { anchor: key.slice(0, atIndex), attr: key.slice(atIndex + 1) };
|
|
4007
|
-
}
|
|
4008
|
-
const dotIndex = key.lastIndexOf(".");
|
|
4009
|
-
if (dotIndex > 0) {
|
|
4010
|
-
const tail = key.slice(dotIndex + 1);
|
|
4011
|
-
if (SUFFIXES.includes(tail)) {
|
|
4012
|
-
return { anchor: key.slice(0, dotIndex), suffix: tail };
|
|
4013
|
-
}
|
|
4014
|
-
}
|
|
4015
|
-
return { anchor: key };
|
|
4016
|
-
}
|
|
4017
|
-
function asExtended(current) {
|
|
4018
|
-
if (current === void 0) return {};
|
|
4019
|
-
if (typeof current === "string") return { text: current };
|
|
4020
|
-
return current;
|
|
4021
|
-
}
|
|
4022
|
-
function applySuffix(target, suffix, value, scope, fail6) {
|
|
4023
|
-
if (suffix === "class") {
|
|
4024
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
4025
|
-
fail6(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
|
|
4026
|
-
}
|
|
4027
|
-
const map2 = {};
|
|
4028
|
-
for (const [cls, cond] of Object.entries(value)) {
|
|
4029
|
-
map2[cls] = expandCondition(String(cond), scope);
|
|
4030
|
-
}
|
|
4031
|
-
target.class = map2;
|
|
4032
|
-
return;
|
|
4033
|
-
}
|
|
4034
|
-
if (suffix === "when") {
|
|
4035
|
-
target.when = expandCondition(String(value), scope);
|
|
4036
|
-
return;
|
|
4037
|
-
}
|
|
4038
|
-
target.model = expandPath(String(value), scope);
|
|
4039
|
-
}
|
|
4040
|
-
function expandCondition(raw, scope) {
|
|
4041
|
-
const text = raw.trim();
|
|
4042
|
-
const negated = text.startsWith("!");
|
|
4043
|
-
const bare = negated ? text.slice(1).trim() : text;
|
|
4044
|
-
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
4045
|
-
}
|
|
4046
|
-
function expandValue(value, scope, fail6) {
|
|
4047
|
-
if (value === null || value === void 0) fail6("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
|
|
4048
|
-
if (typeof value !== "string") return String(value);
|
|
4049
|
-
const segments = String(value).split(/\s+\|\s+/);
|
|
4050
|
-
segments[0] = expandPath(segments[0], scope);
|
|
4051
|
-
return segments.join(" | ");
|
|
4052
|
-
}
|
|
4053
|
-
function normalizeEventSection(raw, input, fail6) {
|
|
4054
|
-
if (raw === void 0) return {};
|
|
4055
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4056
|
-
fail6("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
|
|
4057
|
-
}
|
|
4058
|
-
const section = raw;
|
|
4059
|
-
for (const key of Object.keys(section)) {
|
|
4060
|
-
if (!["on", "timers", "triggers"].includes(key)) {
|
|
4061
|
-
fail6(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
|
|
4062
|
-
}
|
|
4063
|
-
}
|
|
4064
|
-
const on = section.on ?? {};
|
|
4065
|
-
if (typeof on !== "object" || Array.isArray(on)) fail6("event.on \u5FC5\u987B\u662F\u6620\u5C04");
|
|
4066
|
-
for (const key of Object.keys(on)) {
|
|
4067
|
-
const anchor = key.split(".")[0];
|
|
4068
|
-
if (input.instances.has(anchor)) {
|
|
4069
|
-
fail6(
|
|
4070
|
-
`"${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`
|
|
4071
|
-
);
|
|
4072
|
-
}
|
|
4073
|
-
}
|
|
4074
|
-
const result = { ...on };
|
|
4075
|
-
if (section.timers !== void 0) result.timers = section.timers;
|
|
4076
|
-
if (section.triggers !== void 0) result.triggers = section.triggers;
|
|
4077
|
-
return result;
|
|
4078
|
-
}
|
|
4079
|
-
|
|
4080
3782
|
// core/client/parser/duration.ts
|
|
4081
3783
|
function parseDuration(raw, where, fail6) {
|
|
4082
3784
|
const match = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(raw.trim());
|
|
@@ -4362,7 +4064,7 @@ function parseUseBlock(input) {
|
|
|
4362
4064
|
}
|
|
4363
4065
|
const uiRaw = body.ui ?? {};
|
|
4364
4066
|
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail6("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
4365
|
-
const when = body.when === void 0 ? void 0 :
|
|
4067
|
+
const when = body.when === void 0 ? void 0 : expandCondition(String(body.when), scope);
|
|
4366
4068
|
const ast = {
|
|
4367
4069
|
blockId,
|
|
4368
4070
|
...component ? { component } : {},
|
|
@@ -4397,245 +4099,566 @@ function parseDataObject(localName, raw, blockId, scope, fail6) {
|
|
|
4397
4099
|
if (from === null || typeof from !== "object" || Array.isArray(from)) {
|
|
4398
4100
|
fail6(`data.${localName}.from \u5FC5\u987B\u662F\u6620\u5C04 { api, params }\uFF08\u5757\u79C1\u6709\u5BF9\u8C61\u53EA\u6709\u4E00\u4E2A\u53D6\u6570\u6765\u6E90\uFF09`);
|
|
4399
4101
|
}
|
|
4400
|
-
const source = from;
|
|
4401
|
-
for (const key of Object.keys(source)) {
|
|
4402
|
-
if (!FROM_KEYS.has(key)) {
|
|
4403
|
-
fail6(`data.${localName}.from \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FROM_KEYS].join("/")}\uFF09`);
|
|
4102
|
+
const source = from;
|
|
4103
|
+
for (const key of Object.keys(source)) {
|
|
4104
|
+
if (!FROM_KEYS.has(key)) {
|
|
4105
|
+
fail6(`data.${localName}.from \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FROM_KEYS].join("/")}\uFF09`);
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
const api = source.api;
|
|
4109
|
+
if (typeof api !== "string" || api.trim() === "") fail6(`data.${localName}.from \u7F3A\u5C11 api`);
|
|
4110
|
+
const paramsRaw = source.params ?? {};
|
|
4111
|
+
if (paramsRaw === null || typeof paramsRaw !== "object" || Array.isArray(paramsRaw)) {
|
|
4112
|
+
fail6(`data.${localName}.from.params \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53C2\u6570\u540D \u2192 \u8DEF\u5F84\u6216\u5B57\u9762\u91CF\uFF09`);
|
|
4113
|
+
}
|
|
4114
|
+
const params = {};
|
|
4115
|
+
for (const [key, value] of Object.entries(paramsRaw)) {
|
|
4116
|
+
params[key] = toDataParam(value, `data.${localName}.from.params.${key}`, scope, fail6);
|
|
4117
|
+
}
|
|
4118
|
+
decl.from = { api: resolveApiRef(String(api), scope), params };
|
|
4119
|
+
}
|
|
4120
|
+
const save = raw.save;
|
|
4121
|
+
if (save !== void 0) {
|
|
4122
|
+
if (save === null || typeof save !== "object" || Array.isArray(save)) {
|
|
4123
|
+
fail6(`data.${localName}.save \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
4124
|
+
}
|
|
4125
|
+
const channel = save;
|
|
4126
|
+
for (const key of Object.keys(channel)) {
|
|
4127
|
+
if (key === "trigger") {
|
|
4128
|
+
fail6(
|
|
4129
|
+
`data.${localName}.save.trigger \u6CA1\u6709\u8FD0\u884C\u65F6\u5BF9\u5E94\u7269\uFF1A\u5199\u901A\u9053\u6CA1\u6709\u300C\u54EA\u4E2A\u52A8\u4F5C\u89E6\u53D1\u63D0\u4EA4\u300D\u8FD9\u4E00\u73AF\u2014\u2014\u63D0\u4EA4\u7531\u6D88\u8D39\u8BE5\u5BF9\u8C61\u7684\u7EC4\u4EF6\u7ECF data \u7AEF\u53E3\u53D1\u8D77\uFF08\u5982 FormConsole \u7684 data_object: ${decl.fullName}\uFF09\uFF0C\u5220\u6389 trigger`
|
|
4130
|
+
);
|
|
4131
|
+
}
|
|
4132
|
+
if (!SAVE_KEYS.has(key)) {
|
|
4133
|
+
fail6(`data.${localName}.save \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...SAVE_KEYS].join("/")}\uFF09`);
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
const api = channel.api;
|
|
4137
|
+
if (typeof api !== "string" || api.trim() === "") fail6(`data.${localName}.save \u7F3A\u5C11 api`);
|
|
4138
|
+
if (channel.fields !== void 0 && (!Array.isArray(channel.fields) || channel.fields.some((item) => typeof item !== "string"))) {
|
|
4139
|
+
fail6(`data.${localName}.save.fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4`);
|
|
4140
|
+
}
|
|
4141
|
+
decl.save = {
|
|
4142
|
+
api: resolveApiRef(String(api), scope),
|
|
4143
|
+
method: String(channel.method ?? "POST").toUpperCase(),
|
|
4144
|
+
...channel.key !== void 0 ? { key: String(channel.key) } : {},
|
|
4145
|
+
...channel.fields !== void 0 ? { fields: [...channel.fields] } : {}
|
|
4146
|
+
};
|
|
4147
|
+
}
|
|
4148
|
+
if (raw.fields !== void 0) {
|
|
4149
|
+
const fieldsRaw = raw.fields;
|
|
4150
|
+
if (fieldsRaw === null || typeof fieldsRaw !== "object" || Array.isArray(fieldsRaw)) {
|
|
4151
|
+
fail6(`data.${localName}.fields \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
4152
|
+
}
|
|
4153
|
+
const fields = {};
|
|
4154
|
+
for (const [fieldName, fieldRaw] of Object.entries(fieldsRaw)) {
|
|
4155
|
+
fields[fieldName] = parseField(localName, fieldName, fieldRaw, fail6);
|
|
4156
|
+
}
|
|
4157
|
+
const modifiesIssues = validateFieldModifies(fields);
|
|
4158
|
+
if (modifiesIssues.length > 0) fail6(`data.${localName}.fields\uFF1A${modifiesIssues.join("\uFF1B")}`);
|
|
4159
|
+
decl.fields = fields;
|
|
4160
|
+
}
|
|
4161
|
+
const fieldKeys = Object.keys(decl.fields ?? {});
|
|
4162
|
+
if (raw.roles !== void 0) {
|
|
4163
|
+
const issues = validateObjectRoles(raw.roles, fieldKeys);
|
|
4164
|
+
if (issues.length > 0) fail6(`data.${localName}.roles\uFF1A${issues.join("\uFF1B")}`);
|
|
4165
|
+
decl.roles = raw.roles;
|
|
4166
|
+
}
|
|
4167
|
+
if (raw.relations !== void 0) {
|
|
4168
|
+
const issues = validateObjectRelations(raw.relations, { fieldKeys, selfName: localName });
|
|
4169
|
+
if (issues.length > 0) fail6(`data.${localName}.relations\uFF1A${issues.join("\uFF1B")}`);
|
|
4170
|
+
decl.relations = raw.relations;
|
|
4171
|
+
}
|
|
4172
|
+
return decl;
|
|
4173
|
+
}
|
|
4174
|
+
function toDataParam(raw, where, scope, fail6) {
|
|
4175
|
+
if (raw === null || typeof raw === "object") {
|
|
4176
|
+
fail6(`${where} \u5FC5\u987B\u662F\u6807\u91CF\u6216\u8DEF\u5F84\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}`);
|
|
4177
|
+
}
|
|
4178
|
+
const text = String(raw).trim();
|
|
4179
|
+
if (text.startsWith("$")) return text;
|
|
4180
|
+
const resolved = resolvePath(text, scope);
|
|
4181
|
+
if (resolved.kind === "literal") return text;
|
|
4182
|
+
if (!PARAM_PATH_RE.test(text)) {
|
|
4183
|
+
fail6(`${where} \u7684\u503C "${text}" \u4E0D\u662F\u5355\u4E00\u8DEF\u5F84\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684 \`$\` \u5F15\u7528\u53EA\u53D6\u4E00\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u5E26\u7BA1\u9053\u4E0E\u7B97\u672F`);
|
|
4184
|
+
}
|
|
4185
|
+
const segments = resolved.full.split(".");
|
|
4186
|
+
if (resolved.kind === "row" || segments[0] !== "page") {
|
|
4187
|
+
fail6(`${where} \u5F15\u7528\u4E86\u884C\u53D8\u91CF "${text}"\u2014\u2014\u6570\u636E\u5BF9\u8C61\u4E0D\u968F\u884C\u91CD\u590D\uFF0C\u53D6\u6570\u53C2\u6570\u91CC\u6CA1\u6709\u884C\u53D8\u91CF`);
|
|
4188
|
+
}
|
|
4189
|
+
if (segments[1] === "data" && segments.length >= 3) {
|
|
4190
|
+
if (segments.length === 3) {
|
|
4191
|
+
fail6(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A\u6570\u636E\u5BF9\u8C61 "${segments[2]}"\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6\u5BF9\u8C61\u7684\u67D0\u4E2A\u5B57\u6BB5\uFF08\u5199 ${text}.<\u5B57\u6BB5>\uFF09`);
|
|
4192
|
+
}
|
|
4193
|
+
return `$${segments.slice(2).join(".")}`;
|
|
4194
|
+
}
|
|
4195
|
+
if (segments.length === 1) {
|
|
4196
|
+
fail6(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A page\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6 page \u4E0A\u7684\u67D0\u4E2A\u5B57\u6BB5`);
|
|
4197
|
+
}
|
|
4198
|
+
return `$page.${segments.slice(1).join(".")}`;
|
|
4199
|
+
}
|
|
4200
|
+
function parseField(objectName, fieldName, raw, fail6) {
|
|
4201
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4202
|
+
fail6(`\u5B57\u6BB5\u5B57\u5178 ${objectName}.${fieldName} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
4203
|
+
}
|
|
4204
|
+
const field = raw;
|
|
4205
|
+
for (const key of Object.keys(field)) {
|
|
4206
|
+
if (!FIELD_KEYS.has(key)) {
|
|
4207
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...FIELD_KEYS].join("/")}\uFF09`);
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
const declaredType = String(field.type ?? "");
|
|
4211
|
+
const type2 = SOMA_DATA_FIELD_TYPE_ALIASES[declaredType] ?? declaredType;
|
|
4212
|
+
if (!FIELD_TYPES.has(declaredType)) {
|
|
4213
|
+
fail6(
|
|
4214
|
+
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${declaredType}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
4217
|
+
if (type2 === "enum") {
|
|
4218
|
+
const values = field.values;
|
|
4219
|
+
if (values === null || typeof values !== "object" || Array.isArray(values) || Object.keys(values).length === 0) {
|
|
4220
|
+
fail6(`\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`);
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
if (field.values !== void 0 && (field.values === null || typeof field.values !== "object" || Array.isArray(field.values))) {
|
|
4224
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 values \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u503C \u2192 \u663E\u793A\u6587\u6848\uFF09`);
|
|
4225
|
+
}
|
|
4226
|
+
const permission = field.permission === void 0 ? "r" : String(field.permission);
|
|
4227
|
+
if (permission !== "r" && permission !== "w") {
|
|
4228
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 permission \u53EA\u80FD\u662F r \u6216 w`);
|
|
4229
|
+
}
|
|
4230
|
+
if (field.rules !== void 0 && !Array.isArray(field.rules)) {
|
|
4231
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules \u5FC5\u987B\u662F\u6570\u7EC4`);
|
|
4232
|
+
}
|
|
4233
|
+
(field.rules ?? []).forEach((rule, index) => {
|
|
4234
|
+
if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
|
|
4235
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u4E00\u4E2A\u6761\u4EF6 + message\uFF09`);
|
|
4236
|
+
}
|
|
4237
|
+
const message = rule.message;
|
|
4238
|
+
if (typeof message !== "string" || message.trim() === "") {
|
|
4239
|
+
fail6(
|
|
4240
|
+
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u7F3A\u5C11 message\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u8981\u6C42\u6BCF\u6761\u89C4\u5219\u90FD\u5E26\u6821\u9A8C\u4E0D\u901A\u8FC7\u65F6\u7684\u63D0\u793A\u6587\u6848\uFF0C\u5982 { max_len: 200, message: \u5907\u6CE8\u6700\u591A 200 \u5B57 }`
|
|
4241
|
+
);
|
|
4242
|
+
}
|
|
4243
|
+
});
|
|
4244
|
+
if (field.modifies !== void 0 && (typeof field.modifies !== "string" || field.modifies.trim() === "")) {
|
|
4245
|
+
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D`);
|
|
4246
|
+
}
|
|
4247
|
+
return {
|
|
4248
|
+
type: type2,
|
|
4249
|
+
permission,
|
|
4250
|
+
...field.name !== void 0 ? { name: String(field.name) } : {},
|
|
4251
|
+
...field.values ? { values: field.values } : {},
|
|
4252
|
+
...field.rules ? { rules: field.rules } : {},
|
|
4253
|
+
...field.modifies !== void 0 ? { modifies: String(field.modifies) } : {}
|
|
4254
|
+
};
|
|
4255
|
+
}
|
|
4256
|
+
function parseEventSection(raw, blockId, scope, fail6) {
|
|
4257
|
+
const actions = /* @__PURE__ */ new Map();
|
|
4258
|
+
const emitRoutes = {};
|
|
4259
|
+
if (raw === void 0) return { actions, emitRoutes };
|
|
4260
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4261
|
+
fail6("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E actions / on\uFF09");
|
|
4262
|
+
}
|
|
4263
|
+
const section = raw;
|
|
4264
|
+
for (const key of Object.keys(section)) {
|
|
4265
|
+
if (!EVENT_KEYS.has(key)) {
|
|
4266
|
+
fail6(`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`);
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
for (const [id, actionRaw] of Object.entries(section.actions ?? {})) {
|
|
4270
|
+
if (actionRaw === null || typeof actionRaw !== "object" || Array.isArray(actionRaw)) {
|
|
4271
|
+
fail6(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
4272
|
+
}
|
|
4273
|
+
const action = actionRaw;
|
|
4274
|
+
for (const key of Object.keys(action)) {
|
|
4275
|
+
if (!ACTION_KEYS.has(key)) {
|
|
4276
|
+
fail6(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
if (action.label === void 0) fail6(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
|
|
4280
|
+
actions.set(id, {
|
|
4281
|
+
id,
|
|
4282
|
+
label: String(action.label),
|
|
4283
|
+
...action.handler !== void 0 ? { handler: withPageDefault(String(action.handler)) } : {},
|
|
4284
|
+
...action.change !== void 0 ? { change: withPageDefault(String(action.change)) } : {},
|
|
4285
|
+
...action.confirm !== void 0 ? { confirm: String(action.confirm) } : {},
|
|
4286
|
+
...action.permission !== void 0 ? { permission: String(action.permission) } : {},
|
|
4287
|
+
...action.tone !== void 0 ? { tone: String(action.tone) } : {},
|
|
4288
|
+
...action.when !== void 0 ? { when: expandCondition(String(action.when), scope) } : {},
|
|
4289
|
+
...action.disabled_reason !== void 0 ? { disabled_reason: expandPath(String(action.disabled_reason), scope) } : {}
|
|
4290
|
+
});
|
|
4291
|
+
}
|
|
4292
|
+
for (const [emitName, expr] of Object.entries(section.on ?? {})) {
|
|
4293
|
+
if (emitName.includes(".")) {
|
|
4294
|
+
fail6(
|
|
4295
|
+
`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`
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
emitRoutes[emitName] = withPageDefaultInPipeline(String(expr));
|
|
4299
|
+
}
|
|
4300
|
+
return { actions, emitRoutes };
|
|
4301
|
+
}
|
|
4302
|
+
function withPageDefault(funcPath) {
|
|
4303
|
+
return funcPath.includes(".") ? funcPath : `page.${funcPath}`;
|
|
4304
|
+
}
|
|
4305
|
+
function withPageDefaultInPipeline(expr) {
|
|
4306
|
+
const parts = expr.split("|").map((part) => part.trim());
|
|
4307
|
+
const verb = parts[0];
|
|
4308
|
+
const handlerIndex = verb === "UI_INTERACT" ? 2 : verb === "NAV_STATIC" || verb === "ACTION" ? -1 : ["UI_REFRESH", "NAV_ACTION"].includes(verb) ? 1 : 0;
|
|
4309
|
+
const shape = handlerIndex === 0 ? /^[a-z][A-Za-z0-9_]*$/ : /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
4310
|
+
if (handlerIndex >= 0 && parts[handlerIndex] && shape.test(parts[handlerIndex])) {
|
|
4311
|
+
parts[handlerIndex] = `page.${parts[handlerIndex]}`;
|
|
4312
|
+
}
|
|
4313
|
+
return parts.reduce(
|
|
4314
|
+
(result, part, index) => index === 0 ? part : `${result} |${part ? ` ${part}` : ""}`,
|
|
4315
|
+
""
|
|
4316
|
+
);
|
|
4317
|
+
}
|
|
4318
|
+
function expandCondition(raw, scope) {
|
|
4319
|
+
const text = raw.trim();
|
|
4320
|
+
const negated = text.startsWith("!");
|
|
4321
|
+
const bare = negated ? text.slice(1).trim() : text;
|
|
4322
|
+
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
4323
|
+
}
|
|
4324
|
+
function expandUiPaths(value, scope) {
|
|
4325
|
+
const walk2 = (node) => {
|
|
4326
|
+
if (typeof node === "string") {
|
|
4327
|
+
const segments = node.split(/\s+\|\s+/);
|
|
4328
|
+
segments[0] = expandPath(segments[0], scope);
|
|
4329
|
+
return segments.join(" | ");
|
|
4330
|
+
}
|
|
4331
|
+
if (Array.isArray(node)) return node.map(walk2);
|
|
4332
|
+
if (node !== null && typeof node === "object") {
|
|
4333
|
+
const out = {};
|
|
4334
|
+
for (const [key, child] of Object.entries(node)) {
|
|
4335
|
+
out[key] = walk2(child);
|
|
4404
4336
|
}
|
|
4337
|
+
return out;
|
|
4405
4338
|
}
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4339
|
+
return node;
|
|
4340
|
+
};
|
|
4341
|
+
return walk2(value);
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
// core/client/parser/blocks/page-parser.ts
|
|
4345
|
+
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
4346
|
+
"domain",
|
|
4347
|
+
"locale",
|
|
4348
|
+
"ui",
|
|
4349
|
+
"watch",
|
|
4350
|
+
"event",
|
|
4351
|
+
"data",
|
|
4352
|
+
"adaptive",
|
|
4353
|
+
"alias",
|
|
4354
|
+
// initProps:引擎启动前写入的初始值(平铺 UiConfig 同名字段的直通)。
|
|
4355
|
+
//
|
|
4356
|
+
// 块声明是照**手写页面**设计的——那里文案住 HTML、初值住 Domain,声明里不需要它。
|
|
4357
|
+
// 但块声明产的是平铺等价物,而生成链的页面把字面文案内联在 initProps 里
|
|
4358
|
+
// (模型出的是组织意图,没有 Domain 可写)。少了这个键,AI 产的页面
|
|
4359
|
+
// 就永远迈不过块声明的门槛——不是"用不上块声明",是"表达不了"。
|
|
4360
|
+
"initProps",
|
|
4361
|
+
// state / layout(REQ-010 F-37 / S3,REQ-011 补接线):两个平铺 UiConfig 保留键的直通。
|
|
4362
|
+
//
|
|
4363
|
+
// 此前 PAGE_KEYS 没有它们——而 compilePageDeclaration 只收块声明,于是《声明语法手册》
|
|
4364
|
+
// 里写着的 `state:` 在任何一张真正发布的页面上都写不进去("page 块不支持键 state"),
|
|
4365
|
+
// 只有测试里直接喂平铺 YAML 的路径能用。文档承诺了一件真实页面做不到的事。
|
|
4366
|
+
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
4367
|
+
"state",
|
|
4368
|
+
"layout",
|
|
4369
|
+
// ooui(REQ-014 演绎接线):第三个平铺 UiConfig 保留键的直通。
|
|
4370
|
+
//
|
|
4371
|
+
// 少了这一条,块声明页写 `ooui:` 会当场收到「page 块不支持键 "ooui"」——
|
|
4372
|
+
// 而**真实发布的页面只有块声明这一条路**(compilePageDeclaration 只收块声明),
|
|
4373
|
+
// 于是整条演绎链只在"直接喂平铺 YAML"的测试路径上活着,生产页面一次都用不上。
|
|
4374
|
+
// 这与上面 state / layout 那次踩的是同一个坑,不再重踩第三次。
|
|
4375
|
+
// 这里只直通原文;形状校验在 parseUiConfig(运行时)与 compilePageDeclaration(构建期)各做一次。
|
|
4376
|
+
"ooui",
|
|
4377
|
+
// objects(REQ-014 表层语义,§38.5 断线 ②):**面向人书写的那一层对象声明**。
|
|
4378
|
+
//
|
|
4379
|
+
// `data:` 是核心层——完备、显式、机器好翻译(`{ type: text, rules: [{ required: true }] }`)。
|
|
4380
|
+
// 表层是同一件事的人写形态(`no: text!`)。两层的转换点只有一个
|
|
4381
|
+
// (`build/ooui/semantic/normalize.ts`),而在此之前**它一个生产调用者都没有**:
|
|
4382
|
+
// 表层类型、展开器、台账三样都写完了,页面上却没有任何地方能写出表层来。
|
|
4383
|
+
//
|
|
4384
|
+
// 不接这一条的后果不是"少个语法糖",是**来历台账永远是空的**:
|
|
4385
|
+
// 系统按默认补的值(如 `permission: r`)与作者显式写的值在产物里长得一模一样,
|
|
4386
|
+
// 于是 `OOUI-SEM-EDIT-ALL-READONLY` 只能说"你写错了",说不出"我按默认补的、
|
|
4387
|
+
// 你需要显式写 permission: w"——同一条错误,两种修法,指向两个人(§34.2)。
|
|
4388
|
+
//
|
|
4389
|
+
// 这里只直通原文;展开与校验在 compilePageDeclaration(构建期)做一次。
|
|
4390
|
+
"objects"
|
|
4391
|
+
]);
|
|
4392
|
+
var SUFFIXES = ["when", "model", "class"];
|
|
4393
|
+
function parsePageBlock(input) {
|
|
4394
|
+
const { body } = input;
|
|
4395
|
+
const fail6 = (message) => {
|
|
4396
|
+
throw new SomaBlockParseError(message, "page");
|
|
4397
|
+
};
|
|
4398
|
+
for (const key of Object.keys(body)) {
|
|
4399
|
+
if (!PAGE_KEYS.has(key)) {
|
|
4400
|
+
fail6(`page \u5757\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${[...PAGE_KEYS].join("/")}\uFF09`);
|
|
4415
4401
|
}
|
|
4416
|
-
decl.from = { api: resolveApiRef(String(api), scope), params };
|
|
4417
4402
|
}
|
|
4418
|
-
const
|
|
4419
|
-
if (
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4403
|
+
const domain = body.domain;
|
|
4404
|
+
if (typeof domain !== "string" || domain.trim() === "") {
|
|
4405
|
+
fail6("page \u5757\u7F3A\u5C11 domain\uFF08\u9875\u9762 Domain \u7C7B\u540D\uFF0C\u5FC5\u586B\uFF09");
|
|
4406
|
+
}
|
|
4407
|
+
const scope = buildBlockScope({
|
|
4408
|
+
blockId: "page",
|
|
4409
|
+
dataNames: [.../* @__PURE__ */ new Set([
|
|
4410
|
+
...Object.keys(body.data ?? {}),
|
|
4411
|
+
...Object.keys(body.objects ?? {})
|
|
4412
|
+
])],
|
|
4413
|
+
aliasRaw: body.alias
|
|
4414
|
+
});
|
|
4415
|
+
const show = {};
|
|
4416
|
+
const locale = body.locale;
|
|
4417
|
+
if (locale !== void 0) {
|
|
4418
|
+
if (!Array.isArray(locale)) fail6("locale \u5FC5\u987B\u662F\u540D\u5355\u6570\u7EC4");
|
|
4419
|
+
for (const item of locale) {
|
|
4420
|
+
const key = String(item);
|
|
4421
|
+
if (!input.anchors.has(key)) {
|
|
4422
|
+
fail6(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728 HTML \u4E2D\u6CA1\u6709\u5BF9\u5E94\u951A\u70B9`);
|
|
4429
4423
|
}
|
|
4430
|
-
if (!
|
|
4431
|
-
fail6(`
|
|
4424
|
+
if (input.localeKeys && !input.localeKeys.has(key)) {
|
|
4425
|
+
fail6(`locale \u540D\u5355\u91CC\u7684 "${key}" \u5728\u8BCD\u5178\u4E2D\u6CA1\u6709\u5BF9\u5E94\u952E`);
|
|
4432
4426
|
}
|
|
4427
|
+
show[key] = `page._locale.${key}`;
|
|
4433
4428
|
}
|
|
4434
|
-
const api = channel.api;
|
|
4435
|
-
if (typeof api !== "string" || api.trim() === "") fail6(`data.${localName}.save \u7F3A\u5C11 api`);
|
|
4436
|
-
if (channel.fields !== void 0 && (!Array.isArray(channel.fields) || channel.fields.some((item) => typeof item !== "string"))) {
|
|
4437
|
-
fail6(`data.${localName}.save.fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D\u6570\u7EC4`);
|
|
4438
|
-
}
|
|
4439
|
-
decl.save = {
|
|
4440
|
-
api: resolveApiRef(String(api), scope),
|
|
4441
|
-
method: String(channel.method ?? "POST").toUpperCase(),
|
|
4442
|
-
...channel.key !== void 0 ? { key: String(channel.key) } : {},
|
|
4443
|
-
...channel.fields !== void 0 ? { fields: [...channel.fields] } : {}
|
|
4444
|
-
};
|
|
4445
4429
|
}
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4430
|
+
const uiRaw = body.ui ?? {};
|
|
4431
|
+
if (typeof uiRaw !== "object" || Array.isArray(uiRaw)) fail6("ui \u6BB5\u5FC5\u987B\u662F\u6620\u5C04");
|
|
4432
|
+
parseShowLevel(uiRaw, show, scope, input, "page");
|
|
4433
|
+
const bind = { obj: String(domain), var: "page" };
|
|
4434
|
+
const watch = body.watch;
|
|
4435
|
+
if (watch !== void 0) {
|
|
4436
|
+
if (!Array.isArray(watch)) fail6("watch \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
4437
|
+
const rules = [];
|
|
4438
|
+
for (const item of watch) {
|
|
4439
|
+
if (!item || typeof item !== "object") fail6("watch \u9879\u5FC5\u987B\u662F\u6620\u5C04");
|
|
4440
|
+
const path2 = item.path;
|
|
4441
|
+
const call = item.call;
|
|
4442
|
+
if (typeof path2 !== "string" || path2.trim() === "") fail6("watch \u9879\u7F3A\u5C11 path");
|
|
4443
|
+
if (typeof call !== "string" || call.trim() === "") fail6("watch \u9879\u7F3A\u5C11 call");
|
|
4444
|
+
const rule = {
|
|
4445
|
+
condition: expandPath(String(path2), scope),
|
|
4446
|
+
callback: String(call).includes(".") ? String(call) : `page.${call}`
|
|
4447
|
+
};
|
|
4448
|
+
if (typeof item.debounce === "number") rule.debounce = item.debounce;
|
|
4449
|
+
if (typeof item.refresh === "boolean") rule.refresh = item.refresh;
|
|
4450
|
+
rules.push(rule);
|
|
4454
4451
|
}
|
|
4455
|
-
|
|
4456
|
-
if (modifiesIssues.length > 0) fail6(`data.${localName}.fields\uFF1A${modifiesIssues.join("\uFF1B")}`);
|
|
4457
|
-
decl.fields = fields;
|
|
4452
|
+
if (rules.length > 0) bind.onChange = rules;
|
|
4458
4453
|
}
|
|
4459
|
-
const
|
|
4460
|
-
if (
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4454
|
+
const ui = { bind, show };
|
|
4455
|
+
if (body.initProps !== void 0) {
|
|
4456
|
+
if (body.initProps === null || typeof body.initProps !== "object" || Array.isArray(body.initProps)) {
|
|
4457
|
+
fail6("initProps \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u952E\u4E3A var \u522B\u540D\u8DEF\u5F84\uFF0C\u5982 page.title\uFF09");
|
|
4458
|
+
}
|
|
4459
|
+
ui.initProps = body.initProps;
|
|
4464
4460
|
}
|
|
4465
|
-
if (
|
|
4466
|
-
|
|
4467
|
-
if (issues.length > 0) fail6(`data.${localName}.relations\uFF1A${issues.join("\uFF1B")}`);
|
|
4468
|
-
decl.relations = raw.relations;
|
|
4461
|
+
if (body.adaptive !== void 0) {
|
|
4462
|
+
ui.adaptive = body.adaptive;
|
|
4469
4463
|
}
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
function toDataParam(raw, where, scope, fail6) {
|
|
4473
|
-
if (raw === null || typeof raw === "object") {
|
|
4474
|
-
fail6(`${where} \u5FC5\u987B\u662F\u6807\u91CF\u6216\u8DEF\u5F84\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}`);
|
|
4464
|
+
if (body.state !== void 0) {
|
|
4465
|
+
ui.state = body.state;
|
|
4475
4466
|
}
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
const resolved = resolvePath(text, scope);
|
|
4479
|
-
if (resolved.kind === "literal") return text;
|
|
4480
|
-
if (!PARAM_PATH_RE.test(text)) {
|
|
4481
|
-
fail6(`${where} \u7684\u503C "${text}" \u4E0D\u662F\u5355\u4E00\u8DEF\u5F84\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u7684 \`$\` \u5F15\u7528\u53EA\u53D6\u4E00\u4E2A\u5B57\u6BB5\uFF0C\u4E0D\u5E26\u7BA1\u9053\u4E0E\u7B97\u672F`);
|
|
4467
|
+
if (body.layout !== void 0) {
|
|
4468
|
+
ui.layout = body.layout;
|
|
4482
4469
|
}
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
fail6(`${where} \u5F15\u7528\u4E86\u884C\u53D8\u91CF "${text}"\u2014\u2014\u6570\u636E\u5BF9\u8C61\u4E0D\u968F\u884C\u91CD\u590D\uFF0C\u53D6\u6570\u53C2\u6570\u91CC\u6CA1\u6709\u884C\u53D8\u91CF`);
|
|
4470
|
+
if (body.ooui !== void 0) {
|
|
4471
|
+
ui.ooui = body.ooui;
|
|
4486
4472
|
}
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4473
|
+
const eventRaw = normalizeEventSection(body.event, input, fail6);
|
|
4474
|
+
return {
|
|
4475
|
+
ui,
|
|
4476
|
+
eventRaw,
|
|
4477
|
+
...body.data ? { dataRaw: body.data } : {},
|
|
4478
|
+
...body.objects ? { surfaceRaw: body.objects } : {},
|
|
4479
|
+
scope
|
|
4480
|
+
};
|
|
4481
|
+
}
|
|
4482
|
+
function parseShowLevel(raw, target, scope, input, where) {
|
|
4483
|
+
const fail6 = (message) => {
|
|
4484
|
+
throw new SomaBlockParseError(message, "page");
|
|
4485
|
+
};
|
|
4486
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
4487
|
+
if (key === "each") continue;
|
|
4488
|
+
const { anchor, suffix, attr: attr2 } = splitKey(key);
|
|
4489
|
+
if (input.instances.has(anchor)) {
|
|
4490
|
+
fail6(
|
|
4491
|
+
`"${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`
|
|
4492
|
+
);
|
|
4493
|
+
}
|
|
4494
|
+
if (!input.anchors.has(anchor)) {
|
|
4495
|
+
fail6(`${where} \u7684 ui \u5F15\u7528\u4E86 HTML \u4E2D\u4E0D\u5B58\u5728\u7684\u951A\u70B9 "${anchor}"`);
|
|
4496
|
+
}
|
|
4497
|
+
if (isEachBlock(value)) {
|
|
4498
|
+
target[anchor] = parseEachBlock(value, scope, input, anchor);
|
|
4499
|
+
continue;
|
|
4500
|
+
}
|
|
4501
|
+
if (suffix) {
|
|
4502
|
+
const existing2 = asExtended(target[anchor]);
|
|
4503
|
+
applySuffix(existing2, suffix, value, scope, fail6);
|
|
4504
|
+
target[anchor] = existing2;
|
|
4505
|
+
continue;
|
|
4506
|
+
}
|
|
4507
|
+
if (attr2) {
|
|
4508
|
+
if (value !== null && typeof value === "object") {
|
|
4509
|
+
fail6(`"${key}" \u7684\u5C5E\u6027\u7ED1\u5B9A\u503C\u5FC5\u987B\u662F\u6807\u91CF\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5199\u6620\u5C04\u6216\u6570\u7EC4`);
|
|
4510
|
+
}
|
|
4511
|
+
target[`${anchor}@${attr2}`] = expandValue(value, scope, fail6);
|
|
4512
|
+
continue;
|
|
4513
|
+
}
|
|
4514
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
4515
|
+
fail6(
|
|
4516
|
+
`"${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`
|
|
4517
|
+
);
|
|
4518
|
+
}
|
|
4519
|
+
const expanded = expandValue(value, scope, fail6);
|
|
4520
|
+
const existing = target[anchor];
|
|
4521
|
+
if (existing !== void 0 && typeof existing === "object" && !Array.isArray(existing)) {
|
|
4522
|
+
existing.text = expanded;
|
|
4523
|
+
} else {
|
|
4524
|
+
target[anchor] = expanded;
|
|
4490
4525
|
}
|
|
4491
|
-
return `$${segments.slice(2).join(".")}`;
|
|
4492
|
-
}
|
|
4493
|
-
if (segments.length === 1) {
|
|
4494
|
-
fail6(`${where} \u5F15\u7528\u7684\u662F\u6574\u4E2A page\u2014\u2014\u53C2\u6570\u53EA\u80FD\u53D6 page \u4E0A\u7684\u67D0\u4E2A\u5B57\u6BB5`);
|
|
4495
4526
|
}
|
|
4496
|
-
return `$page.${segments.slice(1).join(".")}`;
|
|
4497
4527
|
}
|
|
4498
|
-
function
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
const
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
const type2 = SOMA_DATA_FIELD_TYPE_ALIASES[declaredType] ?? declaredType;
|
|
4510
|
-
if (!FIELD_TYPES.has(declaredType)) {
|
|
4511
|
-
fail6(
|
|
4512
|
-
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 type "${declaredType}" \u975E\u6CD5\uFF08\u5C01\u95ED\u96C6\uFF1A${[...FIELD_TYPES].join("/")}\uFF09`
|
|
4513
|
-
);
|
|
4528
|
+
function isEachBlock(value) {
|
|
4529
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.each === "string";
|
|
4530
|
+
}
|
|
4531
|
+
function parseEachBlock(block, scope, input, anchor) {
|
|
4532
|
+
const fail6 = (message) => {
|
|
4533
|
+
throw new SomaBlockParseError(message, "page");
|
|
4534
|
+
};
|
|
4535
|
+
const raw = String(block.each);
|
|
4536
|
+
const match = /^(\S+)\s+as\s+([$A-Z_a-z][$\w]*)(?:\s+by\s+(\S+))?(?:\s+key\s+(\S+))?$/.exec(raw.trim());
|
|
4537
|
+
if (!match) {
|
|
4538
|
+
fail6(`each \u8BED\u6CD5\u9519\u8BEF: "${raw}"\uFF08\u5E94\u4E3A each: \u8DEF\u5F84 as \u53D8\u91CF [by \u8DEF\u5F84] [key \u5B57\u6BB5]\uFF09`);
|
|
4514
4539
|
}
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4540
|
+
const [, sourcePath, rowVar, byPath, keyPath] = match;
|
|
4541
|
+
const bind = {
|
|
4542
|
+
obj: expandPath(sourcePath, scope),
|
|
4543
|
+
var: rowVar
|
|
4544
|
+
};
|
|
4545
|
+
if (byPath) bind.role_by = byPath;
|
|
4546
|
+
if (keyPath) {
|
|
4547
|
+
bind.key = keyPath.includes(".") ? keyPath : `${rowVar}.${keyPath}`;
|
|
4548
|
+
if (!bind.key.startsWith(`${rowVar}.`) || !/^[$A-Z_a-z][$\w]*(?:\.[$A-Z_a-z][$\w]*)+$/.test(bind.key) || bind.key.split(".").some((part) => ["__proto__", "prototype", "constructor"].includes(part))) {
|
|
4549
|
+
fail6("each key \u5FC5\u987B\u662F\u5F53\u524D\u884C\u53D8\u91CF\u7684\u5B89\u5168\u5B57\u6BB5\u8DEF\u5F84");
|
|
4519
4550
|
}
|
|
4520
4551
|
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4552
|
+
const rowScope = {
|
|
4553
|
+
...scope,
|
|
4554
|
+
rowVars: /* @__PURE__ */ new Set([...scope.rowVars, rowVar])
|
|
4555
|
+
};
|
|
4556
|
+
const childShow = {};
|
|
4557
|
+
const nested = {};
|
|
4558
|
+
for (const [key, value] of Object.entries(block)) {
|
|
4559
|
+
if (key === "each") continue;
|
|
4560
|
+
nested[key] = value;
|
|
4523
4561
|
}
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4562
|
+
parseShowLevel(nested, childShow, rowScope, input, `\u5217\u8868 ${anchor}`);
|
|
4563
|
+
return { bind, show: childShow };
|
|
4564
|
+
}
|
|
4565
|
+
function splitKey(key) {
|
|
4566
|
+
const atIndex = key.indexOf("@");
|
|
4567
|
+
if (atIndex > 0) {
|
|
4568
|
+
return { anchor: key.slice(0, atIndex), attr: key.slice(atIndex + 1) };
|
|
4527
4569
|
}
|
|
4528
|
-
|
|
4529
|
-
|
|
4570
|
+
const dotIndex = key.lastIndexOf(".");
|
|
4571
|
+
if (dotIndex > 0) {
|
|
4572
|
+
const tail = key.slice(dotIndex + 1);
|
|
4573
|
+
if (SUFFIXES.includes(tail)) {
|
|
4574
|
+
return { anchor: key.slice(0, dotIndex), suffix: tail };
|
|
4575
|
+
}
|
|
4530
4576
|
}
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4577
|
+
return { anchor: key };
|
|
4578
|
+
}
|
|
4579
|
+
function asExtended(current) {
|
|
4580
|
+
if (current === void 0) return {};
|
|
4581
|
+
if (typeof current === "string") return { text: current };
|
|
4582
|
+
return current;
|
|
4583
|
+
}
|
|
4584
|
+
function applySuffix(target, suffix, value, scope, fail6) {
|
|
4585
|
+
if (suffix === "class") {
|
|
4586
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
4587
|
+
fail6(".class \u7684\u503C\u5FC5\u987B\u662F { \u7C7B\u540D: \u6761\u4EF6\u8DEF\u5F84 } \u6620\u5C04");
|
|
4534
4588
|
}
|
|
4535
|
-
const
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 rules[${index}] \u7F3A\u5C11 message\u2014\u2014\u6570\u636E\u5BF9\u8C61\u5C42\u8981\u6C42\u6BCF\u6761\u89C4\u5219\u90FD\u5E26\u6821\u9A8C\u4E0D\u901A\u8FC7\u65F6\u7684\u63D0\u793A\u6587\u6848\uFF0C\u5982 { max_len: 200, message: \u5907\u6CE8\u6700\u591A 200 \u5B57 }`
|
|
4539
|
-
);
|
|
4589
|
+
const map2 = {};
|
|
4590
|
+
for (const [cls, cond] of Object.entries(value)) {
|
|
4591
|
+
map2[cls] = expandCondition2(String(cond), scope);
|
|
4540
4592
|
}
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
fail6(`\u5B57\u6BB5 ${objectName}.${fieldName} \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D`);
|
|
4593
|
+
target.class = map2;
|
|
4594
|
+
return;
|
|
4544
4595
|
}
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
...field.rules ? { rules: field.rules } : {},
|
|
4551
|
-
...field.modifies !== void 0 ? { modifies: String(field.modifies) } : {}
|
|
4552
|
-
};
|
|
4596
|
+
if (suffix === "when") {
|
|
4597
|
+
target.when = expandCondition2(String(value), scope);
|
|
4598
|
+
return;
|
|
4599
|
+
}
|
|
4600
|
+
target.model = expandPath(String(value), scope);
|
|
4553
4601
|
}
|
|
4554
|
-
function
|
|
4555
|
-
const
|
|
4556
|
-
const
|
|
4557
|
-
|
|
4602
|
+
function expandCondition2(raw, scope) {
|
|
4603
|
+
const text = raw.trim();
|
|
4604
|
+
const negated = text.startsWith("!");
|
|
4605
|
+
const bare = negated ? text.slice(1).trim() : text;
|
|
4606
|
+
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
4607
|
+
}
|
|
4608
|
+
function expandValue(value, scope, fail6) {
|
|
4609
|
+
if (value === null || value === void 0) fail6("\u7ED1\u5B9A\u503C\u4E0D\u80FD\u4E3A\u7A7A");
|
|
4610
|
+
if (typeof value !== "string") return String(value);
|
|
4611
|
+
const segments = String(value).split(/\s+\|\s+/);
|
|
4612
|
+
segments[0] = expandPath(segments[0], scope);
|
|
4613
|
+
return segments.join(" | ");
|
|
4614
|
+
}
|
|
4615
|
+
function normalizeEventSection(raw, input, fail6) {
|
|
4616
|
+
if (raw === void 0) return {};
|
|
4558
4617
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4559
|
-
fail6("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E
|
|
4618
|
+
fail6("event \u6BB5\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u5B50\u952E on / timers / triggers\uFF09");
|
|
4560
4619
|
}
|
|
4561
4620
|
const section = raw;
|
|
4562
4621
|
for (const key of Object.keys(section)) {
|
|
4563
|
-
if (!
|
|
4564
|
-
fail6(`event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\
|
|
4565
|
-
}
|
|
4566
|
-
}
|
|
4567
|
-
for (const [id, actionRaw] of Object.entries(section.actions ?? {})) {
|
|
4568
|
-
if (actionRaw === null || typeof actionRaw !== "object" || Array.isArray(actionRaw)) {
|
|
4569
|
-
fail6(`event.actions.${id} \u5FC5\u987B\u662F\u6620\u5C04`);
|
|
4570
|
-
}
|
|
4571
|
-
const action = actionRaw;
|
|
4572
|
-
for (const key of Object.keys(action)) {
|
|
4573
|
-
if (!ACTION_KEYS.has(key)) {
|
|
4574
|
-
fail6(`\u52A8\u4F5C ${id} \u4E0D\u652F\u6301\u5B57\u6BB5 "${key}"\uFF08\u53EF\u7528\uFF1A${[...ACTION_KEYS].join("/")}\uFF09`);
|
|
4575
|
-
}
|
|
4622
|
+
if (!["on", "timers", "triggers"].includes(key)) {
|
|
4623
|
+
fail6(`page \u5757\u7684 event \u6BB5\u4E0D\u652F\u6301\u5B50\u952E "${key}"\uFF08\u53EF\u7528\uFF1Aon / timers / triggers\uFF09`);
|
|
4576
4624
|
}
|
|
4577
|
-
if (action.label === void 0) fail6(`\u52A8\u4F5C ${id} \u7F3A\u5C11 label`);
|
|
4578
|
-
actions.set(id, {
|
|
4579
|
-
id,
|
|
4580
|
-
label: String(action.label),
|
|
4581
|
-
...action.handler !== void 0 ? { handler: withPageDefault(String(action.handler)) } : {},
|
|
4582
|
-
...action.change !== void 0 ? { change: withPageDefault(String(action.change)) } : {},
|
|
4583
|
-
...action.confirm !== void 0 ? { confirm: String(action.confirm) } : {},
|
|
4584
|
-
...action.permission !== void 0 ? { permission: String(action.permission) } : {},
|
|
4585
|
-
...action.tone !== void 0 ? { tone: String(action.tone) } : {},
|
|
4586
|
-
...action.when !== void 0 ? { when: expandCondition2(String(action.when), scope) } : {},
|
|
4587
|
-
...action.disabled_reason !== void 0 ? { disabled_reason: expandPath(String(action.disabled_reason), scope) } : {}
|
|
4588
|
-
});
|
|
4589
4625
|
}
|
|
4590
|
-
|
|
4591
|
-
|
|
4626
|
+
const on = section.on ?? {};
|
|
4627
|
+
if (typeof on !== "object" || Array.isArray(on)) fail6("event.on \u5FC5\u987B\u662F\u6620\u5C04");
|
|
4628
|
+
for (const key of Object.keys(on)) {
|
|
4629
|
+
const anchor = key.split(".")[0];
|
|
4630
|
+
if (input.instances.has(anchor)) {
|
|
4592
4631
|
fail6(
|
|
4593
|
-
`
|
|
4632
|
+
`"${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`
|
|
4594
4633
|
);
|
|
4595
4634
|
}
|
|
4596
|
-
emitRoutes[emitName] = withPageDefaultInPipeline(String(expr));
|
|
4597
4635
|
}
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
return
|
|
4636
|
+
const result = withPageDefaultInEventTree(on);
|
|
4637
|
+
if (section.timers !== void 0) result.timers = section.timers;
|
|
4638
|
+
if (section.triggers !== void 0) result.triggers = section.triggers;
|
|
4639
|
+
return result;
|
|
4602
4640
|
}
|
|
4603
|
-
function
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
const
|
|
4607
|
-
if (
|
|
4608
|
-
|
|
4641
|
+
function withPageDefaultInEventTree(node) {
|
|
4642
|
+
if (typeof node === "string") return withPageDefaultInPipeline(node);
|
|
4643
|
+
if (node === null || typeof node !== "object" || Array.isArray(node)) return node;
|
|
4644
|
+
const source = node;
|
|
4645
|
+
if (Array.isArray(source.steps)) {
|
|
4646
|
+
return { ...source, steps: withPageDefaultInSteps(source.steps) };
|
|
4609
4647
|
}
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
function expandCondition2(raw, scope) {
|
|
4616
|
-
const text = raw.trim();
|
|
4617
|
-
const negated = text.startsWith("!");
|
|
4618
|
-
const bare = negated ? text.slice(1).trim() : text;
|
|
4619
|
-
return `${negated ? "!" : ""}${expandPath(bare, scope)}`;
|
|
4648
|
+
const mapped = {};
|
|
4649
|
+
for (const [key, value] of Object.entries(source)) {
|
|
4650
|
+
mapped[key] = withPageDefaultInEventTree(value);
|
|
4651
|
+
}
|
|
4652
|
+
return mapped;
|
|
4620
4653
|
}
|
|
4621
|
-
function
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
if (node !== null && typeof node === "object") {
|
|
4630
|
-
const out = {};
|
|
4631
|
-
for (const [key, child] of Object.entries(node)) {
|
|
4632
|
-
out[key] = walk2(child);
|
|
4633
|
-
}
|
|
4634
|
-
return out;
|
|
4635
|
-
}
|
|
4636
|
-
return node;
|
|
4637
|
-
};
|
|
4638
|
-
return walk2(value);
|
|
4654
|
+
function withPageDefaultInSteps(node) {
|
|
4655
|
+
if (Array.isArray(node)) return node.map(withPageDefaultInSteps);
|
|
4656
|
+
if (node === null || typeof node !== "object") return node;
|
|
4657
|
+
const mapped = {};
|
|
4658
|
+
for (const [key, value] of Object.entries(node)) {
|
|
4659
|
+
mapped[key] = key === "do" && typeof value === "string" ? withPageDefaultInPipeline(value) : withPageDefaultInSteps(value);
|
|
4660
|
+
}
|
|
4661
|
+
return mapped;
|
|
4639
4662
|
}
|
|
4640
4663
|
|
|
4641
4664
|
// core/build/blocks/block-compile.ts
|
|
@@ -4943,7 +4966,7 @@ var SOMA_ADAPTIVE_MAX_LADDER = 5;
|
|
|
4943
4966
|
var SomaAdaptiveConfigError = class extends Error {
|
|
4944
4967
|
constructor(message, path2 = "") {
|
|
4945
4968
|
const prefix = path2 ? ` (\u8DEF\u5F84: ${path2})` : "";
|
|
4946
|
-
super(`[
|
|
4969
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
4947
4970
|
this.name = "SomaAdaptiveConfigError";
|
|
4948
4971
|
this.path = path2;
|
|
4949
4972
|
}
|
|
@@ -5282,7 +5305,7 @@ function parseLayoutConstraint(input, deps) {
|
|
|
5282
5305
|
var SomaUiConfigError = class extends Error {
|
|
5283
5306
|
constructor(message, path2 = "") {
|
|
5284
5307
|
const prefix = path2 ? ` (\u8DEF\u5F84: ${path2})` : "";
|
|
5285
|
-
super(`[
|
|
5308
|
+
super(`[soma-core][\u5F15\u64CE] ${message}${prefix}`);
|
|
5286
5309
|
this.name = "SomaUiConfigError";
|
|
5287
5310
|
this.path = path2;
|
|
5288
5311
|
}
|
|
@@ -6164,7 +6187,7 @@ var VALID_KEY_MODIFIER_NAMES = new Set(Object.keys(SOMA_KEY_MODIFIERS));
|
|
|
6164
6187
|
// core/client/parser/pipeline-parser.ts
|
|
6165
6188
|
var SomaEventParseError = class extends Error {
|
|
6166
6189
|
constructor(message, rawExpression) {
|
|
6167
|
-
super(`[
|
|
6190
|
+
super(`[soma-core][\u5F15\u64CE] ${message} \u2014 \u539F\u59CB\u8868\u8FBE\u5F0F: "${rawExpression}"`);
|
|
6168
6191
|
this.name = "SomaEventParseError";
|
|
6169
6192
|
this.rawExpression = rawExpression;
|
|
6170
6193
|
}
|
|
@@ -6183,6 +6206,8 @@ var VALID_DOM_EVENTS = /* @__PURE__ */ new Set([
|
|
|
6183
6206
|
"change",
|
|
6184
6207
|
"blur",
|
|
6185
6208
|
"focus",
|
|
6209
|
+
"focusin",
|
|
6210
|
+
"focusout",
|
|
6186
6211
|
"mouseenter",
|
|
6187
6212
|
"mouseleave",
|
|
6188
6213
|
"submit",
|
|
@@ -6199,6 +6224,54 @@ var VALID_ACTIONS = /* @__PURE__ */ new Set([
|
|
|
6199
6224
|
"select"
|
|
6200
6225
|
]);
|
|
6201
6226
|
var EMIT_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
6227
|
+
var HOVER_ALTERNATIVE = "\u60AC\u505C\u6837\u5F0F\u7528 Style transitions \u7684 hover\uFF1B\u60AC\u505C\u624D\u51FA\u73B0\u7684\u63D0\u793A\u6216\u9762\u677F\u7528 click\u3001focusin / focusout\uFF0C\u6216 Tooltip \u7EC4\u4EF6";
|
|
6228
|
+
var CONTROLLER_ALTERNATIVE = "\u5C01\u88C5\u6210\u7EC4\u4EF6\uFF0C\u7531\u63A7\u5236\u5668\u628A\u76D1\u542C\u76F4\u63A5\u6302\u5230\u5143\u7D20\u4E0A\uFF0C\u518D\u7ECF\u5951\u7EA6 emit \u4E0A\u62A5";
|
|
6229
|
+
function hintGroup(names, hint) {
|
|
6230
|
+
return names.map((name) => [name, hint]);
|
|
6231
|
+
}
|
|
6232
|
+
var UNLISTED_DOM_EVENT_HINTS = new Map([
|
|
6233
|
+
...hintGroup(
|
|
6234
|
+
["mouseover", "mouseout", "pointerover", "pointerout"],
|
|
6235
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u4F46\u6307\u9488\u5728\u951A\u70B9\u5185\u7684\u5B50\u5143\u7D20\u4E4B\u95F4\u79FB\u52A8\u65F6\u4F1A\u53CD\u590D\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${HOVER_ALTERNATIVE}`
|
|
6236
|
+
),
|
|
6237
|
+
...hintGroup(
|
|
6238
|
+
["pointerenter", "pointerleave"],
|
|
6239
|
+
`\u4E0D\u5192\u6CE1\uFF0C\u5185\u5C42\u951A\u70B9\u4E0A\u7684\u58F0\u660E\u6C38\u8FDC\u4E0D\u4F1A\u6267\u884C\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${HOVER_ALTERNATIVE}`
|
|
6240
|
+
),
|
|
6241
|
+
...hintGroup(
|
|
6242
|
+
["mousedown", "mouseup", "pointerdown", "pointerup", "touchstart", "touchend"],
|
|
6243
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 click\uFF1B\u786E\u5B9E\u8981\u533A\u5206\u6309\u4E0B\u4E0E\u62AC\u8D77\u65F6${CONTROLLER_ALTERNATIVE}`
|
|
6244
|
+
),
|
|
6245
|
+
...hintGroup(
|
|
6246
|
+
["mousemove", "pointermove", "touchmove", "wheel"],
|
|
6247
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u6BCF\u6B21\u6D3E\u53D1\u90FD\u6267\u884C\u4E00\u904D Pipeline\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
6248
|
+
),
|
|
6249
|
+
...hintGroup(
|
|
6250
|
+
[
|
|
6251
|
+
"contextmenu",
|
|
6252
|
+
"auxclick",
|
|
6253
|
+
"pointercancel",
|
|
6254
|
+
"touchcancel",
|
|
6255
|
+
"dragstart",
|
|
6256
|
+
"dragend",
|
|
6257
|
+
"dragenter",
|
|
6258
|
+
"dragleave",
|
|
6259
|
+
"dragover",
|
|
6260
|
+
"animationend",
|
|
6261
|
+
"transitionend"
|
|
6262
|
+
],
|
|
6263
|
+
`\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
6264
|
+
),
|
|
6265
|
+
...hintGroup(
|
|
6266
|
+
["scrollend"],
|
|
6267
|
+
`\u5728\u5143\u7D20\u4E0A\u4E0D\u5192\u6CE1\uFF0C\u5185\u5C42\u951A\u70B9\u4E0A\u7684\u58F0\u660E\u6C38\u8FDC\u4E0D\u4F1A\u6267\u884C\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A${CONTROLLER_ALTERNATIVE}`
|
|
6268
|
+
),
|
|
6269
|
+
...hintGroup(["keypress"], "\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\uFF0C\u4F46\u5DF2\u88AB\u6D4F\u89C8\u5668\u5F03\u7528\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 keydown"),
|
|
6270
|
+
...hintGroup(
|
|
6271
|
+
["beforeinput", "compositionstart", "compositionupdate", "compositionend"],
|
|
6272
|
+
"\u4F1A\u5192\u6CE1\uFF0C\u80FD\u89E6\u53D1\u3002\u66FF\u4EE3\u5199\u6CD5\uFF1A\u6539\u7528 input"
|
|
6273
|
+
)
|
|
6274
|
+
]);
|
|
6202
6275
|
function isStepsDeclaration(value) {
|
|
6203
6276
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.steps);
|
|
6204
6277
|
}
|
|
@@ -6220,7 +6293,26 @@ function collectWhenRoots(steps) {
|
|
|
6220
6293
|
}
|
|
6221
6294
|
var CONFIRM_PREFIX = "confirm:";
|
|
6222
6295
|
var PERMISSION_PREFIX = "permission:";
|
|
6296
|
+
var ACTION_PREFIX = "action:";
|
|
6223
6297
|
var FORCE_SEGMENT = "force";
|
|
6298
|
+
var NAMED_SEGMENT_PREFIXES = [CONFIRM_PREFIX, PERMISSION_PREFIX, ACTION_PREFIX];
|
|
6299
|
+
var NAMED_SEGMENT_SHAPE = /^[a-z][a-z0-9_]*:/;
|
|
6300
|
+
var POSITIONAL_ARITY = {
|
|
6301
|
+
NAV_STATIC: 1,
|
|
6302
|
+
NAV_ACTION: 2,
|
|
6303
|
+
UI_REFRESH: 1,
|
|
6304
|
+
ACTION: 1,
|
|
6305
|
+
UI_INTERACT: 3
|
|
6306
|
+
};
|
|
6307
|
+
var URL_SLOT = /* @__PURE__ */ new Map([
|
|
6308
|
+
["NAV_STATIC", 1],
|
|
6309
|
+
["NAV_ACTION", 2]
|
|
6310
|
+
]);
|
|
6311
|
+
var IMPLICIT_REFRESH_FUNC_PATH = /^[a-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)+$/;
|
|
6312
|
+
function unknownPrefixMessage(segment) {
|
|
6313
|
+
const name = segment.slice(0, segment.indexOf(":") + 1);
|
|
6314
|
+
return `\u672A\u77E5\u7684\u5177\u540D\u6BB5\u524D\u7F00 "${name}"\uFF0C\u53EF\u7528: ${NAMED_SEGMENT_PREFIXES.join(" / ")}\uFF08\u5199\u9519\u524D\u7F00\u7684\u6BB5\u4EE5\u524D\u88AB\u5F53\u6210\u4F4D\u7F6E\u503C\u5403\u6389\uFF1Aconfirm \u62FC\u9519\u4E00\u4E2A\u5B57\u6BCD\u5C31\u7B49\u4E8E\u6574\u6761\u786E\u8BA4\u6846\u6D88\u5931\uFF09`;
|
|
6315
|
+
}
|
|
6224
6316
|
var VALID_KEY_MODIFIERS = VALID_KEY_MODIFIER_NAMES;
|
|
6225
6317
|
function parseSelector(selector) {
|
|
6226
6318
|
const parts = selector.split(".");
|
|
@@ -6241,6 +6333,12 @@ function parseSelector(selector) {
|
|
|
6241
6333
|
selector
|
|
6242
6334
|
);
|
|
6243
6335
|
}
|
|
6336
|
+
const unlistedHint = UNLISTED_DOM_EVENT_HINTS.get(domEvent);
|
|
6337
|
+
if (unlistedHint) {
|
|
6338
|
+
console.warn(
|
|
6339
|
+
`[soma-core][\u5F15\u64CE] \u4E8B\u4EF6\u89E3\u6790 "${selector}"\uFF1A${domEvent} \u4E0D\u5728\u652F\u6301\u7684 DOM \u4E8B\u4EF6\u91CC\uFF0C\u6309\u7EC4\u4EF6\u5951\u7EA6 emit \u540D\u653E\u884C\uFF08\u89E3\u6790\u65F6\u770B\u4E0D\u5230\u7EC4\u4EF6\u6CE8\u518C\u8868\uFF0C\u5206\u4E0D\u6E05 ${somaId} \u662F\u4E0D\u662F\u7EC4\u4EF6\u5B9E\u4F8B\uFF09\u3002${somaId} \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u3001\u5951\u7EA6\u58F0\u660E\u4E86 emit "${domEvent}" \u65F6\u5FFD\u7565\u672C\u63D0\u793A\uFF1B\u5426\u5219\u4E0D\u8D70 emit \u8DEF\u7531\uFF0C\u5F15\u64CE\u6309\u539F\u751F\u4E8B\u4EF6\u540D\u539F\u6837\u59D4\u6258\u2014\u2014${domEvent} ${unlistedHint}\u3002\u652F\u6301\u7684 DOM \u4E8B\u4EF6: ${[...VALID_DOM_EVENTS].join(", ")}`
|
|
6340
|
+
);
|
|
6341
|
+
}
|
|
6244
6342
|
return { somaId, domEvent };
|
|
6245
6343
|
}
|
|
6246
6344
|
if (parts.length === 3) {
|
|
@@ -6271,6 +6369,7 @@ function splitOptionalSegments(parts) {
|
|
|
6271
6369
|
let confirm;
|
|
6272
6370
|
let refreshForce = false;
|
|
6273
6371
|
let permission;
|
|
6372
|
+
let action;
|
|
6274
6373
|
const segments = [];
|
|
6275
6374
|
for (let index = 0; index < parts.length; index++) {
|
|
6276
6375
|
const part = parts[index];
|
|
@@ -6294,17 +6393,67 @@ function splitOptionalSegments(parts) {
|
|
|
6294
6393
|
permission = code;
|
|
6295
6394
|
continue;
|
|
6296
6395
|
}
|
|
6396
|
+
if (index > 0 && part.startsWith(ACTION_PREFIX)) {
|
|
6397
|
+
const name = part.slice(ACTION_PREFIX.length).trim();
|
|
6398
|
+
if (!name) {
|
|
6399
|
+
throw new SomaEventParseError("action segment requires an action name", parts.join(" | "));
|
|
6400
|
+
}
|
|
6401
|
+
if (action !== void 0) {
|
|
6402
|
+
throw new SomaEventParseError(`\u5177\u540D\u6BB5 "action:" \u5199\u4E86\u4E24\u6B21`, parts.join(" | "));
|
|
6403
|
+
}
|
|
6404
|
+
action = name;
|
|
6405
|
+
continue;
|
|
6406
|
+
}
|
|
6297
6407
|
segments.push(part);
|
|
6298
6408
|
}
|
|
6299
|
-
return { segments, confirm, refreshForce, permission };
|
|
6409
|
+
return { segments, confirm, refreshForce, permission, action };
|
|
6410
|
+
}
|
|
6411
|
+
function assertSegmentShape(type2, parts, expression) {
|
|
6412
|
+
const arity = POSITIONAL_ARITY[type2];
|
|
6413
|
+
const urlSlot = URL_SLOT.get(type2);
|
|
6414
|
+
for (let slot2 = 1; slot2 < parts.length; slot2++) {
|
|
6415
|
+
const value = parts[slot2];
|
|
6416
|
+
if (slot2 !== urlSlot && NAMED_SEGMENT_SHAPE.test(value)) {
|
|
6417
|
+
throw new SomaEventParseError(unknownPrefixMessage(value), expression);
|
|
6418
|
+
}
|
|
6419
|
+
if (slot2 <= arity || !value) {
|
|
6420
|
+
continue;
|
|
6421
|
+
}
|
|
6422
|
+
throw new SomaEventParseError(
|
|
6423
|
+
`${type2} \u6700\u591A ${arity} \u4E2A\u53C2\u6570\u6BB5\uFF0C\u7B2C ${slot2} \u6BB5 "${value}" \u6CA1\u6709\u5BF9\u5E94\u7684\u69FD\uFF08\u591A\u5199\u7684\u6BB5\u4EE5\u524D\u88AB\u9759\u9ED8\u4E22\u5F03\uFF0C\u73B0\u5728\u5F53\u573A\u62A5\u9519\uFF09`,
|
|
6424
|
+
expression
|
|
6425
|
+
);
|
|
6426
|
+
}
|
|
6300
6427
|
}
|
|
6301
6428
|
function parsePipelineBody(expression) {
|
|
6302
6429
|
const rawParts = expression.split("|").map((s) => s.trim());
|
|
6303
|
-
const {
|
|
6430
|
+
const {
|
|
6431
|
+
segments: parts,
|
|
6432
|
+
confirm,
|
|
6433
|
+
refreshForce,
|
|
6434
|
+
permission,
|
|
6435
|
+
action: namedAction
|
|
6436
|
+
} = splitOptionalSegments(rawParts);
|
|
6437
|
+
if (!VALID_TYPES.has(parts[0]) && IMPLICIT_REFRESH_FUNC_PATH.test(parts[0])) {
|
|
6438
|
+
parts.unshift("UI_REFRESH");
|
|
6439
|
+
}
|
|
6304
6440
|
const type2 = parts[0];
|
|
6305
6441
|
if (!VALID_TYPES.has(type2)) {
|
|
6306
6442
|
throw new SomaEventParseError(
|
|
6307
|
-
`\u672A\u77E5\u4E8B\u4EF6\u7C7B\u578B "${type2}"\uFF0C\u652F\u6301\u7684\u7C7B\u578B: ${[...VALID_TYPES].join(", ")}`,
|
|
6443
|
+
`\u672A\u77E5\u4E8B\u4EF6\u7C7B\u578B "${type2}"\uFF0C\u652F\u6301\u7684\u7C7B\u578B: ${[...VALID_TYPES].join(", ")}\uFF1B\u7701\u7565\u52A8\u8BCD\u6309 UI_REFRESH \u5904\u7406\uFF0C\u4F46\u9996\u6BB5\u987B\u662F\u5C0F\u5199\u8D77\u5934\u3001\u81F3\u5C11\u4E24\u6BB5\u7684 funcPath\uFF08\u5982 page.save\uFF09`,
|
|
6444
|
+
expression
|
|
6445
|
+
);
|
|
6446
|
+
}
|
|
6447
|
+
assertSegmentShape(type2, parts, expression);
|
|
6448
|
+
if (namedAction !== void 0 && type2 !== "UI_INTERACT") {
|
|
6449
|
+
throw new SomaEventParseError(
|
|
6450
|
+
`\u5177\u540D\u6BB5 "action:" \u53EA\u5C5E\u4E8E UI_INTERACT\uFF0C${type2} \u6CA1\u6709\u52A8\u4F5C\u69FD`,
|
|
6451
|
+
expression
|
|
6452
|
+
);
|
|
6453
|
+
}
|
|
6454
|
+
if (refreshForce && type2 !== "UI_REFRESH") {
|
|
6455
|
+
throw new SomaEventParseError(
|
|
6456
|
+
`\u53EF\u9009\u6BB5 "force" \u53EA\u5C5E\u4E8E UI_REFRESH\uFF08\u5168\u91CF\u6E32\u67D3\uFF09\uFF0C${type2} \u4E0A\u5199\u4E86\u4E0D\u4F1A\u751F\u6548`,
|
|
6308
6457
|
expression
|
|
6309
6458
|
);
|
|
6310
6459
|
}
|
|
@@ -6354,7 +6503,13 @@ function parsePipelineBody(expression) {
|
|
|
6354
6503
|
result.targetId = parts[1] || void 0;
|
|
6355
6504
|
result.funcPath = parts[2] || null;
|
|
6356
6505
|
{
|
|
6357
|
-
|
|
6506
|
+
if (namedAction !== void 0 && parts[3]) {
|
|
6507
|
+
throw new SomaEventParseError(
|
|
6508
|
+
`UI_INTERACT \u7684\u52A8\u4F5C\u540C\u65F6\u5199\u4E86\u5177\u540D\u6BB5 "action:${namedAction}" \u4E0E\u4F4D\u7F6E\u5F0F "${parts[3]}"\uFF0C\u53EA\u80FD\u7559\u4E00\u79CD`,
|
|
6509
|
+
expression
|
|
6510
|
+
);
|
|
6511
|
+
}
|
|
6512
|
+
const action = namedAction || parts[3] || "toggle";
|
|
6358
6513
|
if (!VALID_ACTIONS.has(action)) {
|
|
6359
6514
|
throw new SomaEventParseError(
|
|
6360
6515
|
`\u4E0D\u652F\u6301\u7684\u4EA4\u4E92\u52A8\u4F5C "${action}"\uFF0C\u652F\u6301\u7684\u52A8\u4F5C: ${[...VALID_ACTIONS].join(", ")}`,
|
|
@@ -6428,7 +6583,7 @@ function parseEventConfig(config, parentPath = []) {
|
|
|
6428
6583
|
// core/client/parser/timer-parser.ts
|
|
6429
6584
|
var SomaTimerParseError = class extends Error {
|
|
6430
6585
|
constructor(message) {
|
|
6431
|
-
super(`[
|
|
6586
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
6432
6587
|
this.name = "SomaTimerParseError";
|
|
6433
6588
|
}
|
|
6434
6589
|
};
|
|
@@ -6477,7 +6632,7 @@ function parseTimers(raw) {
|
|
|
6477
6632
|
// core/client/parser/trigger-parser.ts
|
|
6478
6633
|
var SomaTriggerParseError = class extends Error {
|
|
6479
6634
|
constructor(message) {
|
|
6480
|
-
super(`[
|
|
6635
|
+
super(`[soma-core][\u5F15\u64CE] ${message}`);
|
|
6481
6636
|
this.name = "SomaTriggerParseError";
|
|
6482
6637
|
}
|
|
6483
6638
|
};
|
|
@@ -6628,8 +6783,44 @@ var SomaPipeRegistry = class {
|
|
|
6628
6783
|
}
|
|
6629
6784
|
}
|
|
6630
6785
|
}
|
|
6631
|
-
/**
|
|
6786
|
+
/**
|
|
6787
|
+
* 链式应用(从左到右);单个管道异常时降级为原值字符串并告警,不中断渲染。
|
|
6788
|
+
*
|
|
6789
|
+
* **仓内零消费者,保留是因为它是对外公开 API**(`core/index.ts` 导出 `SomaPipeRegistry`,
|
|
6790
|
+
* 1.6.0 已发布)。四条内部路径——页面绑定(`dom-renderer.ts:441`)、行绑定
|
|
6791
|
+
* (`dom-renderer.ts:1351`)、组件 props(`component-manager.ts:1246`)、data transform
|
|
6792
|
+
* (`data-object-resolver.ts:728`)——2026-09 全部改走 `tryApply`,改的理由四处写得一样:
|
|
6793
|
+
* 本方法的告警**不带锚点、不带声明、不带 prop,而且每次重算都打一遍**,
|
|
6794
|
+
* 而失败时上屏的又是一个"看起来像格式化过"的原值字符串。
|
|
6795
|
+
* 谁在什么位置坏了,看控制台是看不出来的。
|
|
6796
|
+
*
|
|
6797
|
+
* 那删不删?**不删**:删它是对外 breaking change,而它的降级**是出声的**
|
|
6798
|
+
* (console.warn),不属于"猜错了还装作正确"那一类,外部 Host 想要"格式化失败也别炸"
|
|
6799
|
+
* 时它仍是一个诚实的选择。两者的差别取舍另见
|
|
6800
|
+
* 《soma 运行时引擎详设》§5.3「管道失败」,那里逐字写明了降级值相同、告警质量不同。
|
|
6801
|
+
*
|
|
6802
|
+
* **但仓内代码一律用 `tryApply`。** 这条规则目前**没有机器面**:
|
|
6803
|
+
* `verify-symbols` 的符号图不收类成员(`scripts/lib/symbol-graph.mjs` 文件头
|
|
6804
|
+
* "类成员不进图:类活着,全部成员体里的引用都算活"),所以它既不会把本方法报成
|
|
6805
|
+
* public-only、也不会拦住谁在仓内重新用起它——换句话说,重新引入这条差路是**不报错**的。
|
|
6806
|
+
* 想让它变成机器判定,最便宜的落点是 `scripts/` 下加一条 grep 式检查
|
|
6807
|
+
* (生产面禁止出现 `.apply(` 接 pipes 的调用),不是在这里加运行时开关。
|
|
6808
|
+
*/
|
|
6632
6809
|
apply(value, pipes, ctx) {
|
|
6810
|
+
const result = this.tryApply(value, pipes, ctx);
|
|
6811
|
+
if (!result.ok) {
|
|
6812
|
+
console.warn(`[soma-core][\u7BA1\u9053] \u7BA1\u9053 "${result.pipeName}" \u6267\u884C\u5931\u8D25:`, result.error);
|
|
6813
|
+
return String(value ?? "");
|
|
6814
|
+
}
|
|
6815
|
+
return result.value;
|
|
6816
|
+
}
|
|
6817
|
+
/**
|
|
6818
|
+
* 与 apply 同一条链式执行,区别只在管道函数抛错时:不告警、不降级,停在出错的那一段,
|
|
6819
|
+
* 把管道名与原始异常作为结果交回。失败的降级值与告警由调用方决定——
|
|
6820
|
+
* 组件 props 管道出错时按 undefined 下发,并点名实例锚点与 prop 告警(component-manager 的 resolvePipedProp)。
|
|
6821
|
+
* 其余与 apply 相同:未注册的管道照样在这里告警并跳过;绑定型实参读取(ctx.read)抛错不算管道失败,照样向外抛。
|
|
6822
|
+
*/
|
|
6823
|
+
tryApply(value, pipes, ctx) {
|
|
6633
6824
|
let current = value;
|
|
6634
6825
|
for (const pipe of pipes) {
|
|
6635
6826
|
const fn = this.fns.get(pipe.name);
|
|
@@ -6644,11 +6835,10 @@ var SomaPipeRegistry = class {
|
|
|
6644
6835
|
try {
|
|
6645
6836
|
current = fn(current, args, ctx);
|
|
6646
6837
|
} catch (error) {
|
|
6647
|
-
|
|
6648
|
-
return String(value ?? "");
|
|
6838
|
+
return { ok: false, pipeName: pipe.name, error };
|
|
6649
6839
|
}
|
|
6650
6840
|
}
|
|
6651
|
-
return String(current ?? "");
|
|
6841
|
+
return { ok: true, value: String(current ?? "") };
|
|
6652
6842
|
}
|
|
6653
6843
|
};
|
|
6654
6844
|
function localeText(ctx, key, fallback) {
|
|
@@ -7739,7 +7929,7 @@ function dictHash(fields) {
|
|
|
7739
7929
|
var SomaDataConfigError = class extends Error {
|
|
7740
7930
|
constructor(message, path2 = "") {
|
|
7741
7931
|
const prefix = path2 ? ` (\u8DEF\u5F84: ${path2})` : "";
|
|
7742
|
-
super(`[
|
|
7932
|
+
super(`[soma-core][\u6570\u636E] ${message}${prefix}`);
|
|
7743
7933
|
this.name = "SomaDataConfigError";
|
|
7744
7934
|
this.path = path2;
|
|
7745
7935
|
}
|