soma-core 2.2.6 → 2.2.7
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 +66 -10
- package/core/client/container/IContainerAdapter.ts +4 -0
- package/core/client/container/SomaContainerAdapter.ts +43 -2
- package/core/client/data/data-object-resolver.ts +7 -3
- package/core/client/engine/event-engine.ts +28 -3
- package/core/client/engine/soma-bootstrap.ts +2 -1
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
- package/core/client/parser/confirm-spec.ts +99 -6
- package/core/client/parser/data-config-parser.ts +1 -1
- package/core/client/parser/pipeline-parser.ts +2 -1
- package/core/client/render-ports/hide-transition.ts +9 -0
- package/core/client/render-ports/index.ts +4 -0
- package/core/client/render-ports/notify-renderer.ts +2 -1
- package/core/index.ts +16 -4
- package/core/server/api/load-host-service.ts +3 -0
- package/core/server/api/paged-list.ts +259 -0
- package/core/server/host/empty-host-bootstrap.mjs +3 -0
- package/core/server/host/host-assembly.ts +3 -0
- package/core/server/host/source-aliases.cjs +345 -0
- package/core/server/host/source-aliases.ts +32 -0
- package/core/server/host/source-packages.cjs +1 -0
- package/core/server/infra/cache/ServerFileCache.ts +4 -1
- package/core/server/node.ts +10 -0
- package/core/server/runtime-space/inject.ts +4 -1
- package/core/shared/core-diagnostic-codes.ts +6 -0
- package/core/shared/data-declaration-checks.ts +29 -3
- package/core/shared/registry-generated/diagnostic-registry-index.ts +5 -0
- package/core/shared/registry-generated/diagnostic-registry.ts +35 -0
- package/core/shared/registry-generated/limits.ts +18 -2
- package/core/shared/registry-generated/std-grammar.ts +1 -1
- package/core/shared/types/data-config.types.ts +3 -1
- package/core/shared/types/event.types.ts +9 -0
- package/dist/browser/soma-runtime.js +169 -19
- package/dist/core/index.cjs +190 -19
- package/dist/host-native/aot-builder.cjs +284 -0
- package/dist/host-native/native-server.cjs +344 -10
- package/dist/lsp/component-tree.cjs +66 -10
- package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
- package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
- package/dist/types/client/data/data-object-resolver.d.ts +2 -0
- package/dist/types/client/parser/confirm-spec.d.ts +27 -3
- package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
- package/dist/types/client/render-ports/index.d.ts +4 -0
- package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/server/api/paged-list.d.ts +101 -0
- package/dist/types/server/host/source-aliases.d.cts +53 -0
- package/dist/types/server/host/source-aliases.d.ts +30 -0
- package/dist/types/server/host/source-packages.d.cts +2 -0
- package/dist/types/server/node.d.ts +1 -0
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +30 -0
- package/dist/types/shared/registry-generated/limits.d.ts +14 -0
- package/dist/types/shared/registry-generated/std-grammar.d.ts +1 -1
- package/dist/types/shared/types/data-config.types.d.ts +3 -1
- package/dist/types/shared/types/event.types.d.ts +8 -0
- package/host-native/src/aot-builder.ts +23 -0
- package/host-native/styles/globals.css +30 -28
- package/package.json +13 -2
|
@@ -3934,11 +3934,12 @@ ${formatScopeIssues(issues)}`, issues[0].path.startsWith("scopes") ? `${path.sli
|
|
|
3934
3934
|
var NOTIFY_LEVELS = ["success", "info", "warning", "error", "alert", "announce"];
|
|
3935
3935
|
var NOTIFY_POLITENESS = ["polite", "assertive"];
|
|
3936
3936
|
var SOMA_CONFIRM_LEVELS = ["plain", "typed", "consent"];
|
|
3937
|
+
var SOMA_CONFIRM_TONES = ["default", "danger"];
|
|
3937
3938
|
|
|
3938
3939
|
// core/client/parser/confirm-spec.ts
|
|
3939
3940
|
var SOMA_CONFIRM_REJECTED_PREFIX = "soma-confirm:";
|
|
3940
3941
|
var SOMA_CONFIRM_TEXT_MAX = 1e3;
|
|
3941
|
-
var SPEC_KEYS = ["level", "text", "phrase", "impact"];
|
|
3942
|
+
var SPEC_KEYS = ["level", "text", "phrase", "impact", "tone"];
|
|
3942
3943
|
function boundedText(value, key) {
|
|
3943
3944
|
if (typeof value !== "string" || value.trim() === "") return `confirm.${key} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(value)}`;
|
|
3944
3945
|
if (value.length > SOMA_CONFIRM_TEXT_MAX) return `confirm.${key} \u8FC7\u957F\uFF08\u4E0A\u9650 ${SOMA_CONFIRM_TEXT_MAX} \u5B57\u7B26\uFF09`;
|
|
@@ -3946,7 +3947,7 @@ function boundedText(value, key) {
|
|
|
3946
3947
|
}
|
|
3947
3948
|
function checkConfirmSpec(raw) {
|
|
3948
3949
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
3949
|
-
return { ok: false, error: `confirm \u7ED3\u6784\u5FC5\u987B\u662F { level, text, phrase?, impact? } \u5BF9\u8C61\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}` };
|
|
3950
|
+
return { ok: false, error: `confirm \u7ED3\u6784\u5FC5\u987B\u662F { level, text, phrase?, impact?, tone? } \u5BF9\u8C61\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(raw)}` };
|
|
3950
3951
|
}
|
|
3951
3952
|
const record = raw;
|
|
3952
3953
|
const extra = Object.keys(record).find((key) => !SPEC_KEYS.includes(key));
|
|
@@ -3957,6 +3958,9 @@ function checkConfirmSpec(raw) {
|
|
|
3957
3958
|
if (typeof level !== "string" || !SOMA_CONFIRM_LEVELS.includes(level)) {
|
|
3958
3959
|
return { ok: false, error: `confirm.level \u5FC5\u987B\u662F ${SOMA_CONFIRM_LEVELS.join(" / ")} \u4E4B\u4E00\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(level)}` };
|
|
3959
3960
|
}
|
|
3961
|
+
if (record.tone !== void 0 && (typeof record.tone !== "string" || !SOMA_CONFIRM_TONES.includes(record.tone))) {
|
|
3962
|
+
return { ok: false, error: `confirm.tone \u5FC5\u987B\u662F ${SOMA_CONFIRM_TONES.join(" / ")} \u4E4B\u4E00\uFF08\u4E0D\u5199 = default\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(record.tone)}` };
|
|
3963
|
+
}
|
|
3960
3964
|
const textProblem = boundedText(record.text, "text");
|
|
3961
3965
|
if (textProblem !== null) return { ok: false, error: textProblem };
|
|
3962
3966
|
for (const key of ["phrase", "impact"]) {
|
|
@@ -3984,7 +3988,8 @@ function checkConfirmSpec(raw) {
|
|
|
3984
3988
|
level: lv,
|
|
3985
3989
|
text,
|
|
3986
3990
|
...lv === "typed" ? { phrase: record.phrase.trim() } : {},
|
|
3987
|
-
...lv !== "plain" && record.impact !== void 0 ? { impact: record.impact.trim() } : {}
|
|
3991
|
+
...lv !== "plain" && record.impact !== void 0 ? { impact: record.impact.trim() } : {},
|
|
3992
|
+
...record.tone === "danger" ? { tone: "danger" } : {}
|
|
3988
3993
|
}
|
|
3989
3994
|
};
|
|
3990
3995
|
}
|
|
@@ -4205,7 +4210,7 @@ function splitOptionalSegments(parts) {
|
|
|
4205
4210
|
const segment = parseConfirmSegment(message);
|
|
4206
4211
|
if ("error" in segment) throw new SomaEventParseError(segment.error, parts.join(" | "));
|
|
4207
4212
|
confirm = segment.spec.text;
|
|
4208
|
-
confirmSpec = segment.spec.level === "plain" ? void 0 : segment.spec;
|
|
4213
|
+
confirmSpec = segment.spec.level === "plain" && segment.spec.tone === void 0 ? void 0 : segment.spec;
|
|
4209
4214
|
continue;
|
|
4210
4215
|
}
|
|
4211
4216
|
if (index > 0 && part.startsWith(PERMISSION_PREFIX)) {
|
|
@@ -4843,14 +4848,16 @@ function inspectSourceRequire(raw, paramNames) {
|
|
|
4843
4848
|
}
|
|
4844
4849
|
const issues = [];
|
|
4845
4850
|
const seen = /* @__PURE__ */ new Set();
|
|
4846
|
-
|
|
4847
|
-
const at = `require[${index}]`;
|
|
4851
|
+
const checkName = (name, at, inGroup) => {
|
|
4848
4852
|
if (typeof name !== "string" || name.trim() === "") {
|
|
4849
4853
|
issues.push({ path: at, message: `require \u91CC\u7684\u53C2\u6570\u540D\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C: ${show(name)}` });
|
|
4850
4854
|
return;
|
|
4851
4855
|
}
|
|
4852
4856
|
if (seen.has(name)) {
|
|
4853
|
-
issues.push({
|
|
4857
|
+
issues.push({
|
|
4858
|
+
path: at,
|
|
4859
|
+
message: inGroup ? `require \u91CC\u6709\u91CD\u590D\u7684\u53C2\u6570\u540D "${name}"\uFF08\u540C\u540D\u4E0D\u80FD\u5728\u5355\u9879\u4E0E\u5206\u7EC4\u91CC\u3001\u6216\u4E24\u4E2A\u5206\u7EC4\u91CC\u91CD\u590D\u51FA\u73B0\uFF09` : `require \u91CC\u6709\u91CD\u590D\u7684\u53C2\u6570\u540D "${name}"`
|
|
4860
|
+
});
|
|
4854
4861
|
return;
|
|
4855
4862
|
}
|
|
4856
4863
|
seen.add(name);
|
|
@@ -4860,6 +4867,28 @@ function inspectSourceRequire(raw, paramNames) {
|
|
|
4860
4867
|
message: `require \u91CC\u7684 "${name}" \u6CA1\u6709\u51FA\u73B0\u5728\u540C\u4E00\u6765\u6E90\u7684 params \u91CC\uFF08params \u6709: ${paramNames.join(" / ") || "\u65E0"}\uFF09`
|
|
4861
4868
|
});
|
|
4862
4869
|
}
|
|
4870
|
+
};
|
|
4871
|
+
raw.forEach((entry, index) => {
|
|
4872
|
+
const at = `require[${index}]`;
|
|
4873
|
+
if (!Array.isArray(entry)) {
|
|
4874
|
+
checkName(entry, at, false);
|
|
4875
|
+
return;
|
|
4876
|
+
}
|
|
4877
|
+
if (entry.length < 2) {
|
|
4878
|
+
issues.push({
|
|
4879
|
+
path: at,
|
|
4880
|
+
message: `require \u91CC\u7684\u300C\u81F3\u5C11\u4E00\u4E2A\u300D\u5206\u7EC4\u81F3\u5C11\u8981 2 \u4E2A\u53C2\u6570\u540D\uFF08\u5355\u4E2A\u53C2\u6570\u76F4\u63A5\u5199\u540D\u5B57\uFF09\uFF0C\u5F53\u524D\u503C: ${show(entry)}`
|
|
4881
|
+
});
|
|
4882
|
+
return;
|
|
4883
|
+
}
|
|
4884
|
+
entry.forEach((member, memberIndex) => {
|
|
4885
|
+
const memberAt = `${at}[${memberIndex}]`;
|
|
4886
|
+
if (Array.isArray(member)) {
|
|
4887
|
+
issues.push({ path: memberAt, message: `require \u7684\u5206\u7EC4\u53EA\u8BB8\u4E00\u5C42\uFF0C\u4E0D\u80FD\u518D\u5D4C\u5957\u6570\u7EC4\uFF0C\u5F53\u524D\u503C: ${show(member)}` });
|
|
4888
|
+
return;
|
|
4889
|
+
}
|
|
4890
|
+
checkName(member, memberAt, true);
|
|
4891
|
+
});
|
|
4863
4892
|
});
|
|
4864
4893
|
return issues;
|
|
4865
4894
|
}
|
|
@@ -6214,6 +6243,11 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6214
6243
|
"file": "core/server/registry/registry-file-lock.ts",
|
|
6215
6244
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6216
6245
|
},
|
|
6246
|
+
{
|
|
6247
|
+
"module": "soma-core",
|
|
6248
|
+
"file": "core/server/api/paged-list.ts",
|
|
6249
|
+
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6250
|
+
},
|
|
6217
6251
|
{
|
|
6218
6252
|
"module": "soma-core",
|
|
6219
6253
|
"file": "core/server/registry/registry-write-pipeline.ts",
|
|
@@ -6229,6 +6263,11 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6229
6263
|
"file": "core/server/registry/source/version-store.ts",
|
|
6230
6264
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6231
6265
|
},
|
|
6266
|
+
{
|
|
6267
|
+
"module": "soma-core",
|
|
6268
|
+
"file": "core/server/runtime-space/inject.ts",
|
|
6269
|
+
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6270
|
+
},
|
|
6232
6271
|
{
|
|
6233
6272
|
"module": "soma-ui",
|
|
6234
6273
|
"file": "src/compiler/bdl/registry/archive.ts",
|
|
@@ -6577,7 +6616,8 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6577
6616
|
"watchFailLimit": 2,
|
|
6578
6617
|
"serverFileMaxEntries": 512,
|
|
6579
6618
|
"serverFileMaxBytes": 33554432,
|
|
6580
|
-
"serverDirMaxEntries": 256
|
|
6619
|
+
"serverDirMaxEntries": 256,
|
|
6620
|
+
"sourceRootAliasCapacity": 64
|
|
6581
6621
|
},
|
|
6582
6622
|
"runtimeCache": {
|
|
6583
6623
|
"basis": "runtime \u7A7A\u95F4 L1 \u5185\u5B58 LRU \u7684\u6761\u76EE\u5BB9\u91CF\uFF08\u7F16\u8BD1\u7ED3\u679C\u4E0E\u6807\u51C6\u683C\u5F0F\u4EA7\u7269\u5404\u4E00\u6761\u76EE\uFF09\u4E0E\u9759\u6001\u9875\u5730\u5740\u6E05\u5355\u7684\u5F00\u53D1\u6001\u590D\u6838\u95F4\u9694\uFF1B\u5BB9\u91CF\u4E0D\u5C0F\u4E8E\u53D1\u5E03\u9875\u4EA7\u7269\u7F13\u5B58\u5BB9\u91CF\uFF08cache.publishedArtifactCapacity\uFF09\uFF0C\u56E0\u4E3A L1 \u8981\u5BB9\u5F97\u4E0B\u5DF2\u53D1\u5E03\u9875\u52A0\u4E0A\u8FD0\u884C\u671F\u6309 URL \u6CE8\u5165\u7684\u9875\uFF1B\u590D\u6838\u95F4\u9694\u8BA9\u65B0\u589E\u9759\u6001\u9875\u6700\u8FDF\u8FD9\u4E2A\u6BEB\u79D2\u6570\u540E\u8FDB\u5165\u5199\u5165\u671F\u51B2\u7A81\u5224\u5B9A\uFF08\u751F\u4EA7\u6001\u4E0D\u8FC7\u671F\uFF09\u3002\u8FC1\u5165\u524D\u662F soma-core store.ts \u7684 SOMA_RUNTIME_CACHE_ENTRIES_DEFAULT \u4E0E static-source.ts \u7684 DEV_TTL_MS",
|
|
@@ -6595,6 +6635,10 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6595
6635
|
"maxWaitMs": 5e3,
|
|
6596
6636
|
"waitSliceMs": 15
|
|
6597
6637
|
},
|
|
6638
|
+
"pagedList": {
|
|
6639
|
+
"pageSizeDefault": 10,
|
|
6640
|
+
"pageSizeMax": 500
|
|
6641
|
+
},
|
|
6598
6642
|
"writeRate": {
|
|
6599
6643
|
"limit": 120,
|
|
6600
6644
|
"windowMs": 6e4
|
|
@@ -6605,7 +6649,8 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6605
6649
|
"defaultDebounceMs": 300
|
|
6606
6650
|
},
|
|
6607
6651
|
"inject": {
|
|
6608
|
-
"pageMaxBytes": 4194304
|
|
6652
|
+
"pageMaxBytes": 4194304,
|
|
6653
|
+
"batchFailureMessageMaxChars": 2e3
|
|
6609
6654
|
},
|
|
6610
6655
|
"execution": {
|
|
6611
6656
|
"maxNodes": 128,
|
|
@@ -6888,7 +6933,7 @@ function parseSource(raw, path, objectNames, selfName, deps) {
|
|
|
6888
6933
|
SOMA_FROM_REQUIRE_CODE
|
|
6889
6934
|
);
|
|
6890
6935
|
}
|
|
6891
|
-
source.require = [...
|
|
6936
|
+
source.require = requireRaw.map((entry) => Array.isArray(entry) ? [...entry] : entry);
|
|
6892
6937
|
}
|
|
6893
6938
|
return source;
|
|
6894
6939
|
}
|
|
@@ -7504,6 +7549,17 @@ var SOMA_CORE_DIAGNOSTIC_CODES = [
|
|
|
7504
7549
|
// 时间:ready() 前调同步方法
|
|
7505
7550
|
"CORE-TEMPORAL-ZONE",
|
|
7506
7551
|
// 时间:时区标识非法
|
|
7552
|
+
// 宿主源码别名(产生点 core/server/host/source-aliases.cjs,CJS 不能 import 本表,码字面量两处各一份,由本表对账测试与注册表一致)
|
|
7553
|
+
"CORE-HOST-ALIAS-INVALID",
|
|
7554
|
+
// 别名声明形状不对 / 路径越界或不存在 / 别名名字非法(error)
|
|
7555
|
+
"CORE-HOST-ALIAS-RESERVED",
|
|
7556
|
+
// 别名占了保留名(soma / soma-*、server-only、node_modules、带子路径的 Node 内置)(error)
|
|
7557
|
+
"CORE-HOST-ALIAS-SHADOW",
|
|
7558
|
+
// 宿主 node_modules/<别名> 已存在且不是指向别名目录的软链(warning,别名仍生效)
|
|
7559
|
+
"CORE-HOST-ALIAS-DUPLICATE",
|
|
7560
|
+
// 多个源码根里同名别名,先声明者胜(warning)
|
|
7561
|
+
"CORE-HOST-ALIAS-TSCONFIG-DRIFT",
|
|
7562
|
+
// tsconfig.json 的 baseUrl 与第一个源码根不一致(warning)
|
|
7507
7563
|
"CORE-DND-SPEC",
|
|
7508
7564
|
// 拖放:getData 返回非对象 / 同元素重复登记
|
|
7509
7565
|
"CORE-ALGO-DIFF-INPUT",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HideTransition } from '../render-ports/hide-transition';
|
|
2
|
+
|
|
1
3
|
/** 容器适配层协议 — 端口:Web 适配器为缺省实现,其他容器由调用方实现 */
|
|
2
4
|
export interface SomaAnchorStats {
|
|
3
5
|
anchors: Set<string>;
|
|
@@ -33,5 +35,7 @@ export interface IContainerAdapter {
|
|
|
33
35
|
/** `options.replace`:替换当前历史条目(管道 `NAV_* | … | replace`) */
|
|
34
36
|
navigate(url: string, options?: { replace?: boolean }): void;
|
|
35
37
|
now(): number;
|
|
38
|
+
/** 注入隐藏前过渡钩子(`renderPorts.hideTransition`);传 null 清除。未注入时 setVisibility 立即写 hidden */
|
|
39
|
+
setHideTransition?(hook: HideTransition | null): void;
|
|
36
40
|
setNavigateHandler?(handler: (url: string, options?: { replace?: boolean }) => void): void;
|
|
37
41
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IContainerAdapter, SomaAnchorStats } from './IContainerAdapter';
|
|
2
|
+
import type { HideTransition } from '../render-ports/hide-transition';
|
|
2
3
|
import { hasBlockedScheme, sanitizeAttributeWrite } from '../security/url-guard';
|
|
3
4
|
import { shouldRemoveAttribute } from '../security/attribute-presence';
|
|
4
5
|
import { sanitizeSomaHtml } from '../security/html-sanitizer';
|
|
@@ -8,6 +9,9 @@ export type { SomaAnchorStats } from './IContainerAdapter';
|
|
|
8
9
|
|
|
9
10
|
export class SomaContainerAdapter implements IContainerAdapter {
|
|
10
11
|
private navigateHandler: ((url: string, options?: { replace?: boolean }) => void) | null = null;
|
|
12
|
+
private hideTransition: HideTransition | null = null;
|
|
13
|
+
/** 正在「隐藏前过渡」的元素 -> 取消控制器(显示时 abort,作废旧 Promise) */
|
|
14
|
+
private readonly pendingHides = new WeakMap<HTMLElement, AbortController>();
|
|
11
15
|
|
|
12
16
|
/** 注入自定义导航处理器(如 SomaRouter + Next.js 路由) */
|
|
13
17
|
setNavigateHandler(handler: (url: string, options?: { replace?: boolean }) => void): void {
|
|
@@ -120,11 +124,48 @@ export class SomaContainerAdapter implements IContainerAdapter {
|
|
|
120
124
|
|
|
121
125
|
/** 显隐只有 `hidden` 属性这一个机制:不写内联样式、不切类名;元素自带的 display 规则压不过 `[hidden]`,见 host-next/app/globals.css(宿主壳样式) */
|
|
122
126
|
setVisibility(element: HTMLElement, visible: boolean): void {
|
|
123
|
-
|
|
127
|
+
const pending = this.pendingHides.get(element);
|
|
128
|
+
if (visible) {
|
|
129
|
+
if (pending) {
|
|
130
|
+
this.pendingHides.delete(element);
|
|
131
|
+
pending.abort();
|
|
132
|
+
}
|
|
133
|
+
element.hidden = false;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const hook = this.hideTransition;
|
|
137
|
+
// 未注册钩子 / 已隐藏 / 正在过渡:与以前一致(直接写,或不重复触发)
|
|
138
|
+
if (!hook || element.hidden || pending) {
|
|
139
|
+
if (!pending) element.hidden = true;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const controller = new AbortController();
|
|
143
|
+
let result: Promise<void> | void;
|
|
144
|
+
try {
|
|
145
|
+
result = hook(element, controller.signal);
|
|
146
|
+
} catch {
|
|
147
|
+
element.hidden = true;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!result || typeof (result as Promise<void>).then !== 'function') {
|
|
151
|
+
element.hidden = true;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.pendingHides.set(element, controller);
|
|
155
|
+
const settle = (): void => {
|
|
156
|
+
if (this.pendingHides.get(element) !== controller || controller.signal.aborted) return;
|
|
157
|
+
this.pendingHides.delete(element);
|
|
158
|
+
element.hidden = true;
|
|
159
|
+
};
|
|
160
|
+
(result as Promise<void>).then(settle, settle);
|
|
124
161
|
}
|
|
125
162
|
|
|
126
163
|
isVisible(element: HTMLElement): boolean {
|
|
127
|
-
return !element.hidden;
|
|
164
|
+
return !element.hidden && !this.pendingHides.has(element);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setHideTransition(hook: HideTransition | null): void {
|
|
168
|
+
this.hideTransition = hook;
|
|
128
169
|
}
|
|
129
170
|
|
|
130
171
|
toggleClasses(element: HTMLElement, classes: string[], enabled: boolean): void {
|
|
@@ -58,7 +58,8 @@ export class SomaDataCycleError extends Error {
|
|
|
58
58
|
|
|
59
59
|
/** 解析器需要的最小 http 能力(结构兼容 IHttpClient / SomaHttpService) */
|
|
60
60
|
export interface SomaDataHttpLike {
|
|
61
|
-
|
|
61
|
+
/** `silentErrorToast`:读失败已由读状态在内容区内联呈现,请求层不再全局弹 toast(避免同一错误出现两次) */
|
|
62
|
+
get<T = unknown>(url: string, config?: { params?: Record<string, string>; silentErrorToast?: boolean; onResponse?: (info: { status: number }) => void }): Promise<T>;
|
|
62
63
|
/** 写通道:不实现时 submit 抛「本 Host 的 http 不支持写」而不是静默失败 */
|
|
63
64
|
post?<T = unknown>(url: string, body?: unknown, config?: { onResponse?: (info: { status: number }) => void; timeout?: number; signal?: AbortSignal }): Promise<T>;
|
|
64
65
|
put?<T = unknown>(url: string, body?: unknown, config?: { onResponse?: (info: { status: number }) => void; timeout?: number; signal?: AbortSignal }): Promise<T>;
|
|
@@ -1438,7 +1439,10 @@ export class SomaDataObjectResolver {
|
|
|
1438
1439
|
const params = this.resolveParams(source.params, selfName, selfValue);
|
|
1439
1440
|
// `$user.*` 解不出:不发请求,来源按空列表处理,诊断已写
|
|
1440
1441
|
if (params === null) return { skipped: false, data: [] };
|
|
1441
|
-
|
|
1442
|
+
const blank = (name: string): boolean => isRequiredParamBlank(params?.[name]);
|
|
1443
|
+
if (source.require?.some((entry) => (Array.isArray(entry) ? entry.every(blank) : blank(entry)))) {
|
|
1444
|
+
return { skipped: true };
|
|
1445
|
+
}
|
|
1442
1446
|
return { skipped: false, data: await this.requestSource(source, selfName, params) };
|
|
1443
1447
|
}
|
|
1444
1448
|
|
|
@@ -1449,7 +1453,7 @@ export class SomaDataObjectResolver {
|
|
|
1449
1453
|
): Promise<unknown> {
|
|
1450
1454
|
// 观测:整对象取数没有窗口,region 记对象名,window 记空窗口
|
|
1451
1455
|
try { this.onFetch?.({ region: selfName, object: selfName, window: { offset: 0, limit: 0 }, query: params ?? {} }); } catch { /* 观测异常不影响取数 */ }
|
|
1452
|
-
const request = this.http.get(source.api, params ? { params } :
|
|
1456
|
+
const request = this.http.get(source.api, params ? { params, silentErrorToast: true } : { silentErrorToast: true });
|
|
1453
1457
|
if (source.failWhen === undefined) return request;
|
|
1454
1458
|
return Promise.resolve(request).then((data) => {
|
|
1455
1459
|
const refusal = envelopeFailureOf(data, { failWhen: source.failWhen!, messagePath: source.messagePath }, '服务端拒绝了该请求');
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { recordMetric } from '../diagnostics/telemetry-context';
|
|
2
2
|
import type { IContainerAdapter } from '../container/IContainerAdapter';
|
|
3
3
|
import { SomaRowScope, readRowPath } from './row-scope';
|
|
4
|
+
import {
|
|
5
|
+
confirmContextOf,
|
|
6
|
+
resolveConfirmSpec,
|
|
7
|
+
warnConfirmMissing,
|
|
8
|
+
type SomaConfirmContext,
|
|
9
|
+
} from '../parser/confirm-spec';
|
|
4
10
|
import { SOMA_KEY_MODIFIERS } from '../../shared/types/keyboard.types';
|
|
5
11
|
import type { SomaDiagnostics } from '../diagnostics/SomaDiagnostics';
|
|
6
12
|
import { SomaMiddlewareChain } from '../middleware/SomaMiddlewareChain';
|
|
@@ -256,7 +262,15 @@ export class SomaEventEngine<TContext extends Record<string, unknown> = Record<s
|
|
|
256
262
|
return false;
|
|
257
263
|
};
|
|
258
264
|
if (!isCurrent()) return;
|
|
259
|
-
const preChecked = this.preCheck(
|
|
265
|
+
const preChecked = this.preCheck(
|
|
266
|
+
config,
|
|
267
|
+
config.somaId,
|
|
268
|
+
element,
|
|
269
|
+
confirmContextOf(
|
|
270
|
+
isSomaEmitEvent(originalEvent) ? originalEvent.payload : undefined,
|
|
271
|
+
rowContext instanceof SomaRowScope ? rowContext.data : undefined,
|
|
272
|
+
),
|
|
273
|
+
);
|
|
260
274
|
if (!(preChecked instanceof Promise ? await preChecked : preChecked)) {
|
|
261
275
|
runtime.status = 'blocked';
|
|
262
276
|
runtime.message = 'pre-check rejected';
|
|
@@ -591,13 +605,24 @@ export class SomaEventEngine<TContext extends Record<string, unknown> = Record<s
|
|
|
591
605
|
return this.adapter.confirm(spec.text);
|
|
592
606
|
}
|
|
593
607
|
|
|
594
|
-
private preCheck(
|
|
608
|
+
private preCheck(
|
|
609
|
+
config: SomaCompiledEvent,
|
|
610
|
+
somaId: string,
|
|
611
|
+
element: HTMLElement,
|
|
612
|
+
confirmContext: SomaConfirmContext,
|
|
613
|
+
): boolean | Promise<boolean> {
|
|
595
614
|
if (this.getContext(element) instanceof SomaRowScope ? this.pendingRows.has(element) : this.pendingSet.has(somaId)) {
|
|
596
615
|
return false;
|
|
597
616
|
}
|
|
598
617
|
|
|
599
618
|
if (config.confirm) {
|
|
600
|
-
|
|
619
|
+
// 确认文案占位(`{字段}` / `{n}`)在触发时代入:只替换 text / impact,permission / roles 顺序与确认级别不受影响
|
|
620
|
+
const spec = resolveConfirmSpec(
|
|
621
|
+
config.confirmSpec ?? { level: 'plain', text: config.confirm },
|
|
622
|
+
confirmContext,
|
|
623
|
+
(name) => warnConfirmMissing(name, `${somaId}.${config.domEvent}`),
|
|
624
|
+
);
|
|
625
|
+
return this.askConfirm(spec);
|
|
601
626
|
}
|
|
602
627
|
|
|
603
628
|
return true;
|
|
@@ -795,6 +795,7 @@ export class SomaBootstrap {
|
|
|
795
795
|
...(shortcutsDesign()?.sequenceTimeoutMs !== undefined ? { sequenceTimeoutMs: shortcutsDesign()!.sequenceTimeoutMs } : {}),
|
|
796
796
|
});
|
|
797
797
|
this.renderPorts = options.renderPorts;
|
|
798
|
+
if (options.renderPorts?.hideTransition) this.adapter.setHideTransition?.(options.renderPorts.hideTransition);
|
|
798
799
|
this.engines = options.engines ?? {};
|
|
799
800
|
this.localeOptions = options.locale ?? {};
|
|
800
801
|
this.preferredLocale = this.localeOptions.initial;
|
|
@@ -1630,7 +1631,7 @@ export class SomaBootstrap {
|
|
|
1630
1631
|
(fn as (u: string, b?: unknown) => Promise<T>).call(services.http, strip(url), body);
|
|
1631
1632
|
};
|
|
1632
1633
|
const http = {
|
|
1633
|
-
get: <T,>(url: string, requestConfig?: { params?: Record<string, string
|
|
1634
|
+
get: <T,>(url: string, requestConfig?: { params?: Record<string, string>; silentErrorToast?: boolean }) =>
|
|
1634
1635
|
services.http.get<T>(strip(url), requestConfig),
|
|
1635
1636
|
// 写通道(M-5):Host 的 http 没实现某个动词时留 undefined,
|
|
1636
1637
|
// resolver.submit 会给出「本 Host 的 http 不支持它」而不是静默失败
|
|
@@ -62,8 +62,8 @@ export class DefaultNotifyService implements INotifyService {
|
|
|
62
62
|
return this.renderer.confirm({
|
|
63
63
|
message: spec.text,
|
|
64
64
|
...(title === undefined ? {} : { title }),
|
|
65
|
-
// plain
|
|
66
|
-
...(spec.level === 'plain' ? {} : { spec }),
|
|
65
|
+
// plain 且无语气不带 spec:旧渲染器与旧测试看到的请求逐字不变
|
|
66
|
+
...(spec.level === 'plain' && spec.tone === undefined ? {} : { spec }),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
return this.confirmResult;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
//
|
|
3
3
|
// · 普通文案 `confirm:确认删除?` -> plain 级(旧写法逐字不变,不产 confirmSpec);
|
|
4
4
|
// · 结构化(JSON) `confirm:{"level":"typed","text":"删除订单","phrase":"DELETE"}`
|
|
5
|
-
// 严格对象:键闭集 level / text / phrase / impact,level 必写之一,text 必写非空;
|
|
6
|
-
// typed 必写 phrase,consent 必写 impact,phrase 只有 typed
|
|
5
|
+
// 严格对象:键闭集 level / text / phrase / impact / tone,level 必写之一,text 必写非空;
|
|
6
|
+
// typed 必写 phrase,consent 必写 impact,phrase 只有 typed 可写;tone 取 default / danger(不写 = default,
|
|
7
|
+
// danger 给渲染端口:确认钮警示呈现、初始焦点落「取消」,各级都可写,包括 plain)。段里不能含 `|`(管道分隔符);
|
|
7
8
|
// · 过渡编码 `confirm:soma-confirm:<level>:…` 已退役,拒收(不折算、不告警)。
|
|
8
9
|
//
|
|
9
10
|
// 判据只有这一份:`checkConfirmSpec`(对象形态)与 `parseConfirmSegment`(段文本形态);执行(弹框、键入比对、勾选)
|
|
@@ -11,20 +12,22 @@
|
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
14
|
SOMA_CONFIRM_LEVELS,
|
|
15
|
+
SOMA_CONFIRM_TONES,
|
|
14
16
|
type SomaConfirmLevel,
|
|
15
17
|
type SomaConfirmSpec,
|
|
18
|
+
type SomaConfirmTone,
|
|
16
19
|
} from '../../shared/types/event.types';
|
|
17
20
|
import { isImeProcessing } from '../keyboard/ime';
|
|
18
21
|
|
|
19
|
-
export { SOMA_CONFIRM_LEVELS };
|
|
20
|
-
export type { SomaConfirmLevel, SomaConfirmSpec };
|
|
22
|
+
export { SOMA_CONFIRM_LEVELS, SOMA_CONFIRM_TONES };
|
|
23
|
+
export type { SomaConfirmLevel, SomaConfirmSpec, SomaConfirmTone };
|
|
21
24
|
|
|
22
25
|
/** 过渡编码前缀:以它开头的 confirm 段一律拒收 */
|
|
23
26
|
const SOMA_CONFIRM_REJECTED_PREFIX = 'soma-confirm:';
|
|
24
27
|
/** 确认文案 / 键入串 / 影响说明的长度上限(与执行编排的确认文案上限同口径) */
|
|
25
28
|
export const SOMA_CONFIRM_TEXT_MAX = 1000;
|
|
26
29
|
|
|
27
|
-
const SPEC_KEYS = ['level', 'text', 'phrase', 'impact'] as const;
|
|
30
|
+
const SPEC_KEYS = ['level', 'text', 'phrase', 'impact', 'tone'] as const;
|
|
28
31
|
|
|
29
32
|
export type SomaConfirmCheck =
|
|
30
33
|
| { readonly ok: true; readonly spec: SomaConfirmSpec }
|
|
@@ -39,7 +42,7 @@ function boundedText(value: unknown, key: string): string | null {
|
|
|
39
42
|
/** 对象形态的唯一判据:闭集键、level 取值、各级必写 / 禁写的键 */
|
|
40
43
|
export function checkConfirmSpec(raw: unknown): SomaConfirmCheck {
|
|
41
44
|
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
42
|
-
return { ok: false, error: `confirm 结构必须是 { level, text, phrase?, impact? } 对象,当前值: ${JSON.stringify(raw)}` };
|
|
45
|
+
return { ok: false, error: `confirm 结构必须是 { level, text, phrase?, impact?, tone? } 对象,当前值: ${JSON.stringify(raw)}` };
|
|
43
46
|
}
|
|
44
47
|
const record = raw as Record<string, unknown>;
|
|
45
48
|
const extra = Object.keys(record).find((key) => !(SPEC_KEYS as readonly string[]).includes(key));
|
|
@@ -50,6 +53,9 @@ export function checkConfirmSpec(raw: unknown): SomaConfirmCheck {
|
|
|
50
53
|
if (typeof level !== 'string' || !(SOMA_CONFIRM_LEVELS as readonly string[]).includes(level)) {
|
|
51
54
|
return { ok: false, error: `confirm.level 必须是 ${SOMA_CONFIRM_LEVELS.join(' / ')} 之一,当前值: ${JSON.stringify(level)}` };
|
|
52
55
|
}
|
|
56
|
+
if (record.tone !== undefined && (typeof record.tone !== 'string' || !(SOMA_CONFIRM_TONES as readonly string[]).includes(record.tone))) {
|
|
57
|
+
return { ok: false, error: `confirm.tone 必须是 ${SOMA_CONFIRM_TONES.join(' / ')} 之一(不写 = default),当前值: ${JSON.stringify(record.tone)}` };
|
|
58
|
+
}
|
|
53
59
|
const textProblem = boundedText(record.text, 'text');
|
|
54
60
|
if (textProblem !== null) return { ok: false, error: textProblem };
|
|
55
61
|
for (const key of ['phrase', 'impact'] as const) {
|
|
@@ -78,6 +84,7 @@ export function checkConfirmSpec(raw: unknown): SomaConfirmCheck {
|
|
|
78
84
|
text,
|
|
79
85
|
...(lv === 'typed' ? { phrase: (record.phrase as string).trim() } : {}),
|
|
80
86
|
...(lv !== 'plain' && record.impact !== undefined ? { impact: (record.impact as string).trim() } : {}),
|
|
87
|
+
...(record.tone === 'danger' ? { tone: 'danger' as const } : {}),
|
|
81
88
|
},
|
|
82
89
|
};
|
|
83
90
|
}
|
|
@@ -108,6 +115,92 @@ export function parseConfirmSegment(message: string): SomaConfirmSegment | { rea
|
|
|
108
115
|
return { spec: { level: 'plain', text } };
|
|
109
116
|
}
|
|
110
117
|
|
|
118
|
+
// ---- 确认文案占位(触发时代入,纯字段替换,不是表达式)
|
|
119
|
+
//
|
|
120
|
+
// · 语法:`{名字}`,名字 = `[A-Za-z_][A-Za-z0-9_]*`(标识符,不含点、不含路径、不含格式化函数);
|
|
121
|
+
// `{{` 是字面 `{`,`}}` 是字面 `}`;不符合标识符语法的花括号原样保留(不是占位)。
|
|
122
|
+
// · 作用位置:确认的 `text` 与 `impact`(`phrase` 是要用户键入的比对串,永远是字面量,不代入)。
|
|
123
|
+
// · 取值:`{n}` 是保留名 = 本次触发的已选行数(载荷 `rows` 数组的长度);其余名字取载荷 `row`(对象)的同名字段,
|
|
124
|
+
// 行内触发而载荷没带 `row` 时取所在行的数据(与具名动作载荷同口径)。
|
|
125
|
+
// · 值一律转成纯文本:字符串原样、数字 / 布尔 String();对象 / 数组 / null / undefined / 缺字段 / 无行可取 = 缺失。
|
|
126
|
+
// · 失败模式(确定、不抛):缺失的占位代入 `—`(SOMA_CONFIRM_MISSING),并在开发期 console.warn 一次(按占位名去重);
|
|
127
|
+
// 宁可让用户看到「—」也不能把没代入的 `{字段}` 原样弹给用户,更不能因为文案取值失败而放行 / 吞掉确认。
|
|
128
|
+
// · 没有任何花括号的文案原样返回(同一引用的规格),不改既有页面的输出。
|
|
129
|
+
|
|
130
|
+
/** 缺失占位的代入串 */
|
|
131
|
+
export const SOMA_CONFIRM_MISSING = '—';
|
|
132
|
+
/** 保留占位名:已选行数 */
|
|
133
|
+
export const SOMA_CONFIRM_COUNT_NAME = 'n';
|
|
134
|
+
|
|
135
|
+
/** 占位取值的来源(触发时由事件引擎按载荷与所在行给出) */
|
|
136
|
+
export interface SomaConfirmContext {
|
|
137
|
+
/** 触发行 / 记录(载荷 `row`,或行内触发的所在行数据) */
|
|
138
|
+
readonly row?: unknown;
|
|
139
|
+
/** 已选行数(载荷 `rows` 数组的长度);没有批量载荷时不给 */
|
|
140
|
+
readonly count?: number;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const CONFIRM_TOKEN = /\{\{|\}\}|\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
144
|
+
const warnedMissing = new Set<string>();
|
|
145
|
+
|
|
146
|
+
/** 文案里出现的占位名(按出现顺序去重;`{{` / `}}` 转义不算)。方言编译期据此静态核对用,运行期不依赖 */
|
|
147
|
+
export function listConfirmPlaceholders(text: string): string[] {
|
|
148
|
+
const names: string[] = [];
|
|
149
|
+
for (const m of text.matchAll(CONFIRM_TOKEN)) {
|
|
150
|
+
if (m[1] !== undefined && !names.includes(m[1])) names.push(m[1]);
|
|
151
|
+
}
|
|
152
|
+
return names;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function scalarText(value: unknown): string | null {
|
|
156
|
+
if (typeof value === 'string') return value;
|
|
157
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return String(value);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** 代入一段确认文案里的占位;`onMissing` 收到每个缺失的占位名(引擎用它记开发期告警) */
|
|
162
|
+
export function substituteConfirmText(text: string, context: SomaConfirmContext, onMissing?: (name: string) => void): string {
|
|
163
|
+
if (!text.includes('{') && !text.includes('}')) return text;
|
|
164
|
+
const row = context.row !== null && typeof context.row === 'object' && !Array.isArray(context.row)
|
|
165
|
+
? (context.row as Record<string, unknown>)
|
|
166
|
+
: undefined;
|
|
167
|
+
return text.replace(CONFIRM_TOKEN, (token, name: string | undefined) => {
|
|
168
|
+
if (name === undefined) return token === '{{' ? '{' : '}';
|
|
169
|
+
const value = name === SOMA_CONFIRM_COUNT_NAME ? context.count : row?.[name];
|
|
170
|
+
const plain = scalarText(value);
|
|
171
|
+
if (plain !== null) return plain;
|
|
172
|
+
onMissing?.(name);
|
|
173
|
+
return SOMA_CONFIRM_MISSING;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** 把确认规格的 text / impact 代入占位;无花括号时返回原规格(同一引用) */
|
|
178
|
+
export function resolveConfirmSpec(spec: SomaConfirmSpec, context: SomaConfirmContext, onMissing?: (name: string) => void): SomaConfirmSpec {
|
|
179
|
+
const text = substituteConfirmText(spec.text, context, onMissing);
|
|
180
|
+
const impact = spec.impact === undefined ? undefined : substituteConfirmText(spec.impact, context, onMissing);
|
|
181
|
+
if (text === spec.text && impact === spec.impact) return spec;
|
|
182
|
+
return { ...spec, text, ...(impact !== undefined ? { impact } : {}) };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** 开发期告警(按占位名去重;生产构建不输出) */
|
|
186
|
+
export function warnConfirmMissing(name: string, where: string): void {
|
|
187
|
+
if (warnedMissing.has(name)) return;
|
|
188
|
+
warnedMissing.add(name);
|
|
189
|
+
const dev = typeof process === 'undefined' || process.env?.NODE_ENV !== 'production';
|
|
190
|
+
if (dev) console.warn(`[soma-core][引擎] ${where} 的确认文案占位 {${name}} 取不到值,已代入「${SOMA_CONFIRM_MISSING}」(占位只取载荷 row 的字段,{n} 取已选行数;字面花括号写 {{ }})`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 从事件载荷与所在行取占位来源:`row` 取载荷 `row`(没有则取所在行数据);`count` 取载荷 `rows` 数组长度。
|
|
195
|
+
* 载荷不是对象时按空载荷处理。
|
|
196
|
+
*/
|
|
197
|
+
export function confirmContextOf(payload: unknown, rowData?: unknown): SomaConfirmContext {
|
|
198
|
+
const record = payload !== null && typeof payload === 'object' && !Array.isArray(payload) ? (payload as Record<string, unknown>) : undefined;
|
|
199
|
+
const row = record !== undefined && 'row' in record ? record.row : rowData;
|
|
200
|
+
const count = Array.isArray(record?.rows) ? (record!.rows as unknown[]).length : undefined;
|
|
201
|
+
return { ...(row !== undefined ? { row } : {}), ...(count !== undefined ? { count } : {}) };
|
|
202
|
+
}
|
|
203
|
+
|
|
111
204
|
export interface SomaConfirmInput {
|
|
112
205
|
/** typed 级已键入的串 */
|
|
113
206
|
readonly typed: string;
|
|
@@ -281,7 +281,7 @@ function parseSource(
|
|
|
281
281
|
SOMA_FROM_REQUIRE_CODE,
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
|
-
source.require =
|
|
284
|
+
source.require = (requireRaw as Array<string | string[]>).map((entry) => (Array.isArray(entry) ? [...entry] : entry));
|
|
285
285
|
}
|
|
286
286
|
return source;
|
|
287
287
|
}
|
|
@@ -214,7 +214,8 @@ function splitOptionalSegments(parts: string[]): {
|
|
|
214
214
|
const segment = parseConfirmSegment(message);
|
|
215
215
|
if ('error' in segment) throw new SomaEventParseError(segment.error, parts.join(' | '));
|
|
216
216
|
confirm = segment.spec.text;
|
|
217
|
-
|
|
217
|
+
// plain 且无语气 = 只有 confirm 文案(旧写法逐字不变);有分级或 tone: danger 才带规格
|
|
218
|
+
confirmSpec = segment.spec.level === 'plain' && segment.spec.tone === undefined ? undefined : segment.spec;
|
|
218
219
|
continue;
|
|
219
220
|
}
|
|
220
221
|
if (index > 0 && part.startsWith(PERMISSION_PREFIX)) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 隐藏前过渡端口(UI 体系注入,经 `renderPorts.hideTransition`;方言中性)。
|
|
3
|
+
* core 的显隐唯一出口 `setVisibility(el, false)` 在真正写 `hidden` 之前调用它:
|
|
4
|
+
* - 返回 `void`(或抛错):立即隐藏,与未注册时完全一致;
|
|
5
|
+
* - 返回 Promise:等它 resolve 后才隐藏;等待期间 core 视该元素为「已隐藏」(`isVisible` 为 false,重复隐藏不再调用钩子);
|
|
6
|
+
* - 等待期间该元素被再次显示:core 先触发 `signal` 的 abort(实现据此撤销过渡状态),再直接显示,旧 Promise 的结果作废。
|
|
7
|
+
* 钩子只在元素当前可见时被调用;是否做过渡、做什么、多久,全由实现自己决定,core 不认识动画。
|
|
8
|
+
*/
|
|
9
|
+
export type HideTransition = (element: HTMLElement, signal: AbortSignal) => Promise<void> | void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { NotifyRenderer } from './notify-renderer';
|
|
2
2
|
import type { RegionFallbackRenderer } from './region-fallback';
|
|
3
|
+
import type { HideTransition } from './hide-transition';
|
|
3
4
|
|
|
4
5
|
export type { NotifyEntry, NotifyRenderer } from './notify-renderer';
|
|
5
6
|
export type { RegionFallbackRenderer } from './region-fallback';
|
|
7
|
+
export type { HideTransition } from './hide-transition';
|
|
6
8
|
export { TOAST_CONFIG_ERROR, createToastScheduler } from './scheduling/toast-scheduler';
|
|
7
9
|
export type { ToastClock, ToastItemState, ToastPhase, ToastScheduler, ToastTimingConfig } from './scheduling/toast-scheduler';
|
|
8
10
|
export { createPromptQueue } from './scheduling/prompt-queue';
|
|
@@ -12,6 +14,8 @@ export type { PromptOptions, PromptQueue } from './scheduling/prompt-queue';
|
|
|
12
14
|
export interface SomaRenderPorts {
|
|
13
15
|
notify?: NotifyRenderer;
|
|
14
16
|
regionFallback?: RegionFallbackRenderer;
|
|
17
|
+
/** 隐藏前过渡:core 写 `hidden` 之前先等它(缺省立即隐藏) */
|
|
18
|
+
hideTransition?: HideTransition;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export { confirmSatisfied, confirmKeyAccepts } from '../parser/confirm-spec';
|
|
@@ -23,7 +23,8 @@ export interface NotifyEntry {
|
|
|
23
23
|
export interface NotifyRenderer {
|
|
24
24
|
show(entry: NotifyEntry): { dismiss(): void };
|
|
25
25
|
/**
|
|
26
|
-
* 确认。`spec` 只在 typed / consent
|
|
26
|
+
* 确认。`spec` 只在 typed / consent 级或 `tone: 'danger'` 时出现(plain 且无语气不带),`message` 恒等于 `spec.text`,不认识分级的渲染器照旧显示一句话。
|
|
27
|
+
* `spec.tone === 'danger'`(破坏性确认):渲染器应给确认钮警示呈现,并把初始焦点放在「取消」;typed / consent 的放行规则不变。
|
|
27
28
|
* 认识分级的渲染器必须用 `confirmSatisfied(spec, { typed, consented })` 决定确认钮此刻能不能点:
|
|
28
29
|
* typed 要键入 `phrase`、consent 要先勾选同意(`impact` 是勾选旁的影响说明);
|
|
29
30
|
* 键入框里输入法组字(`isImeProcessing`)期间的 Enter 是选词,不算确认;取消 / Esc / 点遮罩一律 resolve(false)。
|
package/core/index.ts
CHANGED
|
@@ -318,14 +318,26 @@ export type { IRealtimeTransport, RealtimeMessageHandler } from './client/infra/
|
|
|
318
318
|
export type { IRealtimeService, RealtimeSubscribeOptions } from './client/infra/realtime/IRealtimeService';
|
|
319
319
|
export { SseRealtimeTransport } from './client/infra/realtime/SseRealtimeTransport';
|
|
320
320
|
export { WebSocketRealtimeTransport } from './client/infra/realtime/WebSocketRealtimeTransport';
|
|
321
|
-
export type { NotifyEntry, NotifyRenderer, RegionFallbackRenderer, SomaRenderPorts } from './client/render-ports';
|
|
321
|
+
export type { HideTransition, NotifyEntry, NotifyRenderer, RegionFallbackRenderer, SomaRenderPorts } from './client/render-ports';
|
|
322
322
|
export type { SomaEngineAdapters, SomaEngineId } from './client/engines/engine-adapters';
|
|
323
323
|
export type { INotifyService, NotifyOptions, NotifyLevel, NotifyCarrier, NotifyAction } from './client/infra/notify/INotifyService';
|
|
324
324
|
export { DefaultNotifyService, createNotifyService } from './client/infra/notify/DefaultNotifyService';
|
|
325
325
|
// 确认分级(R-23):规格类型、对象 / 段文本判据、确认钮判定与键盘判定(渲染端口共用)
|
|
326
|
-
export type { SomaConfirmSpec, SomaConfirmLevel } from './shared/types/event.types';
|
|
327
|
-
export {
|
|
328
|
-
|
|
326
|
+
export type { SomaConfirmSpec, SomaConfirmLevel, SomaConfirmTone } from './shared/types/event.types';
|
|
327
|
+
export {
|
|
328
|
+
SOMA_CONFIRM_TONES,
|
|
329
|
+
checkConfirmSpec,
|
|
330
|
+
parseConfirmSegment,
|
|
331
|
+
confirmSatisfied,
|
|
332
|
+
confirmKeyAccepts,
|
|
333
|
+
confirmContextOf,
|
|
334
|
+
listConfirmPlaceholders,
|
|
335
|
+
resolveConfirmSpec,
|
|
336
|
+
substituteConfirmText,
|
|
337
|
+
SOMA_CONFIRM_MISSING,
|
|
338
|
+
SOMA_CONFIRM_COUNT_NAME,
|
|
339
|
+
} from './client/parser/confirm-spec';
|
|
340
|
+
export type { SomaConfirmInput, SomaConfirmCheck, SomaConfirmSegment, SomaConfirmContext } from './client/parser/confirm-spec';
|
|
329
341
|
export { SomaRealtimeService } from './client/infra/realtime/SomaRealtimeService';
|
|
330
342
|
export { SomaMiddlewareChain } from './client/middleware/SomaMiddlewareChain';
|
|
331
343
|
export { createPermissionMiddleware } from './client/middleware/createPermissionMiddleware';
|