soma-core 2.1.4 → 2.1.6
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 +11 -1
- package/core/client/base/SomaHttpClient.ts +85 -12
- package/core/client/data/data-object-resolver.ts +12 -1
- package/core/client/engine/event-engine.ts +3 -3
- package/core/client/engine/soma-bootstrap.ts +30 -30
- package/core/client/host-bridge/load-host-domain-class.ts +74 -20
- package/core/client/host-bridge/resolve-host-bootstrap.ts +125 -23
- package/core/client/infra/http/IHttpClient.ts +3 -1
- package/core/client/infra/http/SomaHttpService.ts +15 -6
- package/core/client/parser/data-config-parser.ts +6 -1
- package/core/shared/registry-generated/error-codes.ts +5 -0
- package/core/shared/registry-generated/limits.ts +5 -0
- package/core/shared/types/data-config.types.ts +2 -0
- package/dist/browser/soma-runtime.js +197 -49
- package/dist/core/index.cjs +284 -64
- package/dist/lsp/component-tree.cjs +11 -1
- package/dist/types/client/base/SomaHttpClient.d.ts +1 -8
- package/dist/types/client/data/data-object-resolver.d.ts +1 -0
- package/dist/types/client/engine/event-engine.d.ts +2 -2
- package/dist/types/client/engine/soma-bootstrap.d.ts +3 -2
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +1 -0
- package/dist/types/client/host-bridge/resolve-host-bootstrap.d.ts +20 -0
- package/dist/types/client/infra/http/IHttpClient.d.ts +2 -0
- package/dist/types/shared/registry-generated/error-codes.d.ts +4 -0
- package/dist/types/shared/registry-generated/limits.d.ts +4 -0
- package/dist/types/shared/types/data-config.types.d.ts +2 -0
- package/host-next/next.config.js +10 -0
- package/package.json +2 -2
|
@@ -82,8 +82,12 @@ export class SomaHttpService implements IHttpClient {
|
|
|
82
82
|
try {
|
|
83
83
|
const res = await fetch(fullUrl, { method: 'POST', body: form, signal: controller.signal });
|
|
84
84
|
if (!res.ok) {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const body = typeof res.text === 'function'
|
|
86
|
+
? await res.text().catch(() => '')
|
|
87
|
+
: '';
|
|
88
|
+
const readable = describeHttpErrorBody(body, res.statusText, res.status);
|
|
89
|
+
this.onHttpError?.(res.status, readable);
|
|
90
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
87
91
|
}
|
|
88
92
|
onProgress?.(100);
|
|
89
93
|
return (await res.json()) as T;
|
|
@@ -122,8 +126,10 @@ export class SomaHttpService implements IHttpClient {
|
|
|
122
126
|
reject(new Error('Invalid JSON response'));
|
|
123
127
|
}
|
|
124
128
|
} else {
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
const body = xhr.responseText ?? '';
|
|
130
|
+
const readable = describeHttpErrorBody(body, xhr.statusText, xhr.status);
|
|
131
|
+
this.onHttpError?.(xhr.status, readable);
|
|
132
|
+
reject(new Error(`HTTP ${xhr.status}: ${readable}`));
|
|
127
133
|
}
|
|
128
134
|
});
|
|
129
135
|
xhr.addEventListener('error', () => {
|
|
@@ -197,8 +203,11 @@ export class SomaHttpService implements IHttpClient {
|
|
|
197
203
|
const body = typeof res.text === 'function'
|
|
198
204
|
? await res.text().catch(() => '')
|
|
199
205
|
: '';
|
|
200
|
-
|
|
201
|
-
|
|
206
|
+
const readable = describeHttpErrorBody(body, res.statusText, res.status);
|
|
207
|
+
if (config?.silentErrorToast !== true) {
|
|
208
|
+
this.onHttpError?.(res.status, readable);
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
202
211
|
}
|
|
203
212
|
|
|
204
213
|
try { config?.onResponse?.({ status: res.status }); } catch { /* 状态回调抛错不影响请求结果 */ }
|
|
@@ -274,8 +274,13 @@ function parseSource(
|
|
|
274
274
|
source.failWhen = value as SomaFieldPredicate;
|
|
275
275
|
} else if (key === 'messagePath') {
|
|
276
276
|
source.messagePath = value as string;
|
|
277
|
+
} else if (key === 'dataPath') {
|
|
278
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
279
|
+
throw new SomaDataConfigError(`dataPath 必须是非空的响应体点路径`, `${path}.dataPath`);
|
|
280
|
+
}
|
|
281
|
+
source.dataPath = value.trim();
|
|
277
282
|
} else {
|
|
278
|
-
throw new SomaDataConfigError(`未知的来源字段 "${key}"(支持: api / params / into / require / failWhen / messagePath)`, `${path}.${key}`);
|
|
283
|
+
throw new SomaDataConfigError(`未知的来源字段 "${key}"(支持: api / params / into / require / failWhen / messagePath / dataPath)`, `${path}.${key}`);
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
if (source.failWhen !== undefined || source.messagePath !== undefined) {
|
|
@@ -34,6 +34,11 @@ export const SOMA_PIPELINE_ERROR_CODES = {
|
|
|
34
34
|
"module": "soma-ai-page",
|
|
35
35
|
"file": "src/versions/errors.ts",
|
|
36
36
|
"symbol": "SOMA_PIPELINE_ERROR_CODES_AI_PAGE"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"module": "soma-robot",
|
|
40
|
+
"file": "src/common/errors.ts",
|
|
41
|
+
"symbol": "SOMA_PIPELINE_ERROR_CODES_AI_ROBOT"
|
|
37
42
|
}
|
|
38
43
|
],
|
|
39
44
|
"families": {
|
|
@@ -439,6 +439,11 @@ export const SOMA_PIPELINE_LIMITS = {
|
|
|
439
439
|
"module": "soma-lite",
|
|
440
440
|
"file": "src/app/server/provenance-limit.ts",
|
|
441
441
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"module": "soma-robot",
|
|
445
|
+
"file": "src/common/limits.ts",
|
|
446
|
+
"symbol": "SOMA_PIPELINE_LIMITS_AI_ROBOT"
|
|
442
447
|
}
|
|
443
448
|
],
|
|
444
449
|
"registry": {
|
|
@@ -20720,7 +20720,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
|
|
|
20720
20720
|
var paddingH = padding ? padding[1] + padding[3] : 0;
|
|
20721
20721
|
var paddingV = padding ? padding[0] + padding[2] : 0;
|
|
20722
20722
|
var font = style.font;
|
|
20723
|
-
var
|
|
20723
|
+
var truncate2 = overflow === "truncate";
|
|
20724
20724
|
var calculatedLineHeight = getLineHeight(font);
|
|
20725
20725
|
var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
|
|
20726
20726
|
var truncateLineOverflow = style.lineOverflow === "truncate";
|
|
@@ -20749,7 +20749,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
|
|
|
20749
20749
|
lines = lines.slice(0, lineCount);
|
|
20750
20750
|
contentHeight = lines.length * lineHeight;
|
|
20751
20751
|
}
|
|
20752
|
-
if (text2 &&
|
|
20752
|
+
if (text2 && truncate2 && width != null) {
|
|
20753
20753
|
var options = prepareTruncateOptions(width, font, style.ellipsis, {
|
|
20754
20754
|
minChar: style.truncateMinChar,
|
|
20755
20755
|
placeholder: style.placeholder
|
|
@@ -20821,7 +20821,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
|
|
|
20821
20821
|
var pendingList = [];
|
|
20822
20822
|
var calculatedHeight = 0;
|
|
20823
20823
|
var calculatedWidth = 0;
|
|
20824
|
-
var
|
|
20824
|
+
var truncate2 = overflow === "truncate";
|
|
20825
20825
|
var truncateLine = style.lineOverflow === "truncate";
|
|
20826
20826
|
var tmpTruncateOut = {};
|
|
20827
20827
|
function finishLine(line2, lineWidth2, lineHeight2) {
|
|
@@ -20877,7 +20877,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
|
|
|
20877
20877
|
}
|
|
20878
20878
|
}
|
|
20879
20879
|
}
|
|
20880
|
-
var remainTruncWidth =
|
|
20880
|
+
var remainTruncWidth = truncate2 && topWidth != null ? topWidth - lineWidth : null;
|
|
20881
20881
|
if (remainTruncWidth != null && remainTruncWidth < token.width) {
|
|
20882
20882
|
if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {
|
|
20883
20883
|
token.text = "";
|
|
@@ -28223,7 +28223,7 @@ var init_time = __esm({
|
|
|
28223
28223
|
});
|
|
28224
28224
|
|
|
28225
28225
|
// ../node_modules/echarts/lib/legacy/getTextRect.js
|
|
28226
|
-
function getTextRect(text2, font, align, verticalAlign, padding, rich,
|
|
28226
|
+
function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate2, lineHeight) {
|
|
28227
28227
|
var textEl = new Text_default({
|
|
28228
28228
|
style: {
|
|
28229
28229
|
text: text2,
|
|
@@ -28232,7 +28232,7 @@ function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate,
|
|
|
28232
28232
|
verticalAlign,
|
|
28233
28233
|
padding,
|
|
28234
28234
|
rich,
|
|
28235
|
-
overflow:
|
|
28235
|
+
overflow: truncate2 ? "truncate" : null,
|
|
28236
28236
|
lineHeight
|
|
28237
28237
|
}
|
|
28238
28238
|
});
|
|
@@ -96034,7 +96034,30 @@ function checkFieldAll(rules, value, context = {}) {
|
|
|
96034
96034
|
// ../soma-foundation/dist/esm/values/collection-payload.js
|
|
96035
96035
|
var ROW_KEYS = ["items", "rows", "list"];
|
|
96036
96036
|
var META_KEYS = /* @__PURE__ */ new Set([...ROW_KEYS, "total", "page", "pageSize", "cursor", "hasMore", "pages", "facets", "cap", "truncated", "meta"]);
|
|
96037
|
-
var WRAPPER_KEYS = /* @__PURE__ */ new Set([
|
|
96037
|
+
var WRAPPER_KEYS = /* @__PURE__ */ new Set([
|
|
96038
|
+
"ret",
|
|
96039
|
+
"success",
|
|
96040
|
+
"ok",
|
|
96041
|
+
"code",
|
|
96042
|
+
"message",
|
|
96043
|
+
"msg",
|
|
96044
|
+
"data",
|
|
96045
|
+
"traceId",
|
|
96046
|
+
"trace_id",
|
|
96047
|
+
"requestId",
|
|
96048
|
+
"request_id",
|
|
96049
|
+
"timestamp",
|
|
96050
|
+
"ts",
|
|
96051
|
+
"time",
|
|
96052
|
+
"cost",
|
|
96053
|
+
"status",
|
|
96054
|
+
"errMsg",
|
|
96055
|
+
"err_msg",
|
|
96056
|
+
"errmsg",
|
|
96057
|
+
"error",
|
|
96058
|
+
"reason",
|
|
96059
|
+
"detail"
|
|
96060
|
+
]);
|
|
96038
96061
|
function isPlain(value) {
|
|
96039
96062
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
96040
96063
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -105115,9 +105138,9 @@ var SomaEventEngine = class {
|
|
|
105115
105138
|
}
|
|
105116
105139
|
return void 0;
|
|
105117
105140
|
}
|
|
105118
|
-
/**
|
|
105141
|
+
/** 分级确认的唯一出口:注入了执行口 -> 执行口(plain / consent / typed 全级别);否则安全回退 adapter.confirm(spec.text) */
|
|
105119
105142
|
askConfirm(spec) {
|
|
105120
|
-
if (
|
|
105143
|
+
if (this.confirmGraded) return this.confirmGraded(spec);
|
|
105121
105144
|
return this.adapter.confirm(spec.text);
|
|
105122
105145
|
}
|
|
105123
105146
|
preCheck(config, somaId, element) {
|
|
@@ -107851,19 +107874,74 @@ var SomaLocaleOnlyPageRoot = class extends SomaPageRootBase {
|
|
|
107851
107874
|
|
|
107852
107875
|
// core/client/base/SomaHttpClient.ts
|
|
107853
107876
|
var ERROR_BODY_MAX_LENGTH = 500;
|
|
107854
|
-
|
|
107877
|
+
var CANDIDATE_KEYS = [
|
|
107878
|
+
"error",
|
|
107879
|
+
"message",
|
|
107880
|
+
"msg",
|
|
107881
|
+
"errMsg",
|
|
107882
|
+
"err_msg",
|
|
107883
|
+
"errmsg",
|
|
107884
|
+
"reason",
|
|
107885
|
+
"detail"
|
|
107886
|
+
];
|
|
107887
|
+
function pickMessageField(record2) {
|
|
107888
|
+
for (const key of CANDIDATE_KEYS) {
|
|
107889
|
+
const val = record2[key];
|
|
107890
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
107891
|
+
return val.trim();
|
|
107892
|
+
}
|
|
107893
|
+
}
|
|
107894
|
+
return void 0;
|
|
107895
|
+
}
|
|
107896
|
+
function extractHtmlTitle(text2) {
|
|
107897
|
+
const match = text2.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
107898
|
+
if (!match) return void 0;
|
|
107899
|
+
const plain = match[1].replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
107900
|
+
if (plain === "") return void 0;
|
|
107901
|
+
return plain.length > 120 ? `${plain.slice(0, 120)}\u2026` : plain;
|
|
107902
|
+
}
|
|
107903
|
+
function describeHttpErrorBody(body, statusText, status) {
|
|
107855
107904
|
const text2 = (body ?? "").trim();
|
|
107856
|
-
|
|
107857
|
-
|
|
107905
|
+
const fallbackStatus = statusText.trim() || (status ? `\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status}\uFF09` : "\u8BF7\u6C42\u5931\u8D25");
|
|
107906
|
+
if (text2 === "") return fallbackStatus;
|
|
107907
|
+
if (/^\s*<(?:!doctype\s+html|html)/i.test(text2)) {
|
|
107908
|
+
const title = extractHtmlTitle(text2);
|
|
107909
|
+
if (title) return title;
|
|
107910
|
+
return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
|
|
107911
|
+
}
|
|
107858
107912
|
try {
|
|
107859
107913
|
const parsed = JSON.parse(text2);
|
|
107860
107914
|
if (parsed && typeof parsed === "object") {
|
|
107861
|
-
|
|
107862
|
-
|
|
107915
|
+
if (!Array.isArray(parsed)) {
|
|
107916
|
+
const obj = parsed;
|
|
107917
|
+
const top2 = pickMessageField(obj);
|
|
107918
|
+
if (top2) return truncate(top2);
|
|
107919
|
+
if (obj.error && typeof obj.error === "object" && !Array.isArray(obj.error)) {
|
|
107920
|
+
const nested = pickMessageField(obj.error);
|
|
107921
|
+
if (nested) return truncate(nested);
|
|
107922
|
+
}
|
|
107923
|
+
if (obj.data && typeof obj.data === "object" && !Array.isArray(obj.data)) {
|
|
107924
|
+
const nested = pickMessageField(obj.data);
|
|
107925
|
+
if (nested) return truncate(nested);
|
|
107926
|
+
}
|
|
107927
|
+
if (typeof obj.code === "string" && obj.code.trim() !== "" && obj.code.trim().length <= 40) {
|
|
107928
|
+
return truncate(obj.code.trim());
|
|
107929
|
+
}
|
|
107930
|
+
}
|
|
107931
|
+
return fallbackStatus;
|
|
107863
107932
|
}
|
|
107864
107933
|
} catch {
|
|
107934
|
+
if (text2.startsWith("<")) {
|
|
107935
|
+
const title = extractHtmlTitle(text2);
|
|
107936
|
+
if (title) return title;
|
|
107937
|
+
return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
|
|
107938
|
+
}
|
|
107939
|
+
return truncate(text2);
|
|
107865
107940
|
}
|
|
107866
|
-
return
|
|
107941
|
+
return fallbackStatus;
|
|
107942
|
+
}
|
|
107943
|
+
function truncate(msg) {
|
|
107944
|
+
return msg.length > ERROR_BODY_MAX_LENGTH ? `${msg.slice(0, ERROR_BODY_MAX_LENGTH)}\u2026` : msg;
|
|
107867
107945
|
}
|
|
107868
107946
|
var SomaHttpClient = class {
|
|
107869
107947
|
baseURL;
|
|
@@ -107938,7 +108016,7 @@ var SomaHttpClient = class {
|
|
|
107938
108016
|
const res = await fetch(url, options);
|
|
107939
108017
|
if (!res.ok) {
|
|
107940
108018
|
const errorBody = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
107941
|
-
throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText)}`);
|
|
108019
|
+
throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText, res.status)}`);
|
|
107942
108020
|
}
|
|
107943
108021
|
return await res.json();
|
|
107944
108022
|
} finally {
|
|
@@ -108002,8 +108080,10 @@ var SomaHttpService = class {
|
|
|
108002
108080
|
try {
|
|
108003
108081
|
const res = await fetch(fullUrl, { method: "POST", body: form, signal: controller.signal });
|
|
108004
108082
|
if (!res.ok) {
|
|
108005
|
-
|
|
108006
|
-
|
|
108083
|
+
const body = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
108084
|
+
const readable = describeHttpErrorBody(body, res.statusText, res.status);
|
|
108085
|
+
this.onHttpError?.(res.status, readable);
|
|
108086
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
108007
108087
|
}
|
|
108008
108088
|
onProgress?.(100);
|
|
108009
108089
|
return await res.json();
|
|
@@ -108033,8 +108113,10 @@ var SomaHttpService = class {
|
|
|
108033
108113
|
reject(new Error("Invalid JSON response"));
|
|
108034
108114
|
}
|
|
108035
108115
|
} else {
|
|
108036
|
-
|
|
108037
|
-
|
|
108116
|
+
const body = xhr.responseText ?? "";
|
|
108117
|
+
const readable = describeHttpErrorBody(body, xhr.statusText, xhr.status);
|
|
108118
|
+
this.onHttpError?.(xhr.status, readable);
|
|
108119
|
+
reject(new Error(`HTTP ${xhr.status}: ${readable}`));
|
|
108038
108120
|
}
|
|
108039
108121
|
});
|
|
108040
108122
|
xhr.addEventListener("error", () => {
|
|
@@ -108087,8 +108169,11 @@ var SomaHttpService = class {
|
|
|
108087
108169
|
const res = await fetch(fullUrl, options);
|
|
108088
108170
|
if (!res.ok) {
|
|
108089
108171
|
const body2 = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
108090
|
-
|
|
108091
|
-
|
|
108172
|
+
const readable = describeHttpErrorBody(body2, res.statusText, res.status);
|
|
108173
|
+
if (config?.silentErrorToast !== true) {
|
|
108174
|
+
this.onHttpError?.(res.status, readable);
|
|
108175
|
+
}
|
|
108176
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
108092
108177
|
}
|
|
108093
108178
|
try {
|
|
108094
108179
|
config?.onResponse?.({ status: res.status });
|
|
@@ -112581,6 +112666,11 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
112581
112666
|
"module": "soma-lite",
|
|
112582
112667
|
"file": "src/app/server/provenance-limit.ts",
|
|
112583
112668
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
112669
|
+
},
|
|
112670
|
+
{
|
|
112671
|
+
"module": "soma-robot",
|
|
112672
|
+
"file": "src/common/limits.ts",
|
|
112673
|
+
"symbol": "SOMA_PIPELINE_LIMITS_AI_ROBOT"
|
|
112584
112674
|
}
|
|
112585
112675
|
],
|
|
112586
112676
|
"registry": {
|
|
@@ -112891,8 +112981,13 @@ function parseSource(raw, path, objectNames, selfName, deps) {
|
|
|
112891
112981
|
source.failWhen = value;
|
|
112892
112982
|
} else if (key === "messagePath") {
|
|
112893
112983
|
source.messagePath = value;
|
|
112984
|
+
} else if (key === "dataPath") {
|
|
112985
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
112986
|
+
throw new SomaDataConfigError(`dataPath \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u54CD\u5E94\u4F53\u70B9\u8DEF\u5F84`, `${path}.dataPath`);
|
|
112987
|
+
}
|
|
112988
|
+
source.dataPath = value.trim();
|
|
112894
112989
|
} else {
|
|
112895
|
-
throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath\uFF09`, `${path}.${key}`);
|
|
112990
|
+
throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath / dataPath\uFF09`, `${path}.${key}`);
|
|
112896
112991
|
}
|
|
112897
112992
|
}
|
|
112898
112993
|
if (source.failWhen !== void 0 || source.messagePath !== void 0) {
|
|
@@ -114598,14 +114693,24 @@ var SomaDataObjectResolver = class {
|
|
|
114598
114693
|
return data;
|
|
114599
114694
|
});
|
|
114600
114695
|
}
|
|
114696
|
+
pickDotted(root, path) {
|
|
114697
|
+
let current = root;
|
|
114698
|
+
for (const segment2 of path.split(".")) {
|
|
114699
|
+
if (segment2 === "") continue;
|
|
114700
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
114701
|
+
current = current[segment2];
|
|
114702
|
+
}
|
|
114703
|
+
return current;
|
|
114704
|
+
}
|
|
114601
114705
|
/** 聚合来源结果:into 写入子键;缺省先解开宿主信封,再浅合并进根(数组整体替换) */
|
|
114602
114706
|
mergeSource(current, source, data) {
|
|
114603
|
-
const payload = source.into ? data : unwrapHostPayload(data);
|
|
114604
114707
|
if (source.into) {
|
|
114605
114708
|
const target = isPlainObject7(current) ? current : {};
|
|
114606
114709
|
target[source.into] = data;
|
|
114607
114710
|
return target;
|
|
114608
114711
|
}
|
|
114712
|
+
const rawData = source.dataPath ? this.pickDotted(data, source.dataPath) : data;
|
|
114713
|
+
const payload = unwrapHostPayload(rawData);
|
|
114609
114714
|
if (isPlainObject7(payload)) {
|
|
114610
114715
|
if (isPlainObject7(current)) {
|
|
114611
114716
|
Object.assign(current, payload);
|
|
@@ -114772,6 +114877,53 @@ var SomaDataObjectResolver = class {
|
|
|
114772
114877
|
return value;
|
|
114773
114878
|
}
|
|
114774
114879
|
};
|
|
114880
|
+
function createSomaDataPort(currentResolver, hostState = createDataPortHostState()) {
|
|
114881
|
+
const noResolver = (action) => ({
|
|
114882
|
+
ok: false,
|
|
114883
|
+
message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u5728\u9875\u9762\u5757\u58F0\u660E data:\uFF09`
|
|
114884
|
+
});
|
|
114885
|
+
return {
|
|
114886
|
+
getObject: (name2) => currentResolver()?.getObject(name2),
|
|
114887
|
+
getObjectStatus: (name2) => currentResolver()?.getObjectStatus(name2),
|
|
114888
|
+
getDict: (name2) => currentResolver()?.getDict(name2) ?? {},
|
|
114889
|
+
submit: async (name2, model, mode, options) => {
|
|
114890
|
+
const resolver = currentResolver();
|
|
114891
|
+
return resolver ? resolver.submit(name2, model, mode, options) : noResolver(`\u63D0\u4EA4 "${name2}"`);
|
|
114892
|
+
},
|
|
114893
|
+
remove: async (name2, target) => {
|
|
114894
|
+
const resolver = currentResolver();
|
|
114895
|
+
return resolver ? resolver.remove(name2, target) : { ok: false, message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u5220\u9664 "${name2}" \u7684\u8BB0\u5F55` };
|
|
114896
|
+
},
|
|
114897
|
+
reload: async (names) => {
|
|
114898
|
+
await currentResolver()?.reload(names);
|
|
114899
|
+
},
|
|
114900
|
+
validate: (name2, model, trigger3) => currentResolver()?.validate(name2, model, trigger3) ?? {},
|
|
114901
|
+
writeOutcome: (scope) => hostState.writeOutcomes().get(scope),
|
|
114902
|
+
onWriteOutcome: (listener) => hostState.writeOutcomes().subscribe(listener),
|
|
114903
|
+
clearWriteOptimistic: (scope, key) => hostState.writeOutcomes().clearOptimistic(scope, key),
|
|
114904
|
+
clearOutcome: (scope) => hostState.writeOutcomes().clear(scope),
|
|
114905
|
+
dispatch: (name2, payload) => hostState.dispatchAction(name2, payload)
|
|
114906
|
+
};
|
|
114907
|
+
}
|
|
114908
|
+
function createDataPortHostState() {
|
|
114909
|
+
const outcomes = createWriteOutcomeStore();
|
|
114910
|
+
let dispatcher;
|
|
114911
|
+
return {
|
|
114912
|
+
writeOutcomes: () => outcomes,
|
|
114913
|
+
setActionDispatcher(next) {
|
|
114914
|
+
dispatcher = next;
|
|
114915
|
+
},
|
|
114916
|
+
async dispatchAction(name2, payload) {
|
|
114917
|
+
if (dispatcher === void 0) {
|
|
114918
|
+
const scope = typeof payload.scope === "string" ? payload.scope : String(payload.object ?? "");
|
|
114919
|
+
const seq2 = outcomes.begin(scope);
|
|
114920
|
+
outcomes.settle(scope, seq2, { ok: false, message: "\u9875\u9762\u6CA1\u6709\u4E8B\u4EF6\u5F15\u64CE\uFF0C\u5199\u5165\u4E8B\u4EF6\u65E0\u5904\u6267\u884C" });
|
|
114921
|
+
return;
|
|
114922
|
+
}
|
|
114923
|
+
await dispatcher(name2, payload);
|
|
114924
|
+
}
|
|
114925
|
+
};
|
|
114926
|
+
}
|
|
114775
114927
|
|
|
114776
114928
|
// core/client/data/data-subscriptions.ts
|
|
114777
114929
|
function parseInvalidation(message) {
|
|
@@ -118191,8 +118343,11 @@ var SomaBootstrap = class {
|
|
|
118191
118343
|
dataResolver = null;
|
|
118192
118344
|
dataLoadEpoch = 0;
|
|
118193
118345
|
dataOwnerEpoch = 0;
|
|
118194
|
-
/**
|
|
118195
|
-
|
|
118346
|
+
/** 数据端口宿主状态(单一真源):持有写入结果存储与写入事件执行口,端口重建同寿 */
|
|
118347
|
+
dataPortHostState = createDataPortHostState();
|
|
118348
|
+
get writeOutcomeStore() {
|
|
118349
|
+
return this.dataPortHostState.writeOutcomes();
|
|
118350
|
+
}
|
|
118196
118351
|
/** 快捷键注册中心(C-r18):唯一一份,`services.shortcuts` 直通 */
|
|
118197
118352
|
shortcutsInstance;
|
|
118198
118353
|
componentStyleNonce;
|
|
@@ -119214,36 +119369,26 @@ ${lines}
|
|
|
119214
119369
|
createStableDataPort() {
|
|
119215
119370
|
const owner = this.dataOwnerEpoch;
|
|
119216
119371
|
const current = () => owner === this.dataOwnerEpoch ? this.dataResolver : null;
|
|
119217
|
-
const
|
|
119218
|
-
|
|
119219
|
-
|
|
119220
|
-
});
|
|
119221
|
-
const port = {
|
|
119222
|
-
getObject: (name2) => current()?.getObject(name2),
|
|
119223
|
-
getObjectStatus: (name2) => current()?.getObjectStatus(name2),
|
|
119224
|
-
getDict: (name2) => current()?.getDict(name2) ?? {},
|
|
119372
|
+
const base2 = createSomaDataPort(current, this.dataPortHostState);
|
|
119373
|
+
return {
|
|
119374
|
+
...base2,
|
|
119225
119375
|
submit: async (name2, model, mode, options) => {
|
|
119226
|
-
const
|
|
119227
|
-
if (
|
|
119228
|
-
|
|
119229
|
-
|
|
119376
|
+
const result = await base2.submit(name2, model, mode, options);
|
|
119377
|
+
if (current()) {
|
|
119378
|
+
this.dataPolling?.arm();
|
|
119379
|
+
}
|
|
119230
119380
|
return result;
|
|
119231
119381
|
},
|
|
119232
|
-
remove: async (name2, target) => {
|
|
119233
|
-
const resolver = current();
|
|
119234
|
-
return resolver ? resolver.remove(name2, target) : notReady(`\u5220\u9664 "${name2}" \u7684\u8BB0\u5F55`);
|
|
119235
|
-
},
|
|
119236
119382
|
reload: async (names) => {
|
|
119237
|
-
await
|
|
119383
|
+
await base2.reload(names);
|
|
119238
119384
|
this.dataPolling?.arm();
|
|
119239
119385
|
},
|
|
119240
|
-
|
|
119241
|
-
|
|
119242
|
-
|
|
119243
|
-
|
|
119244
|
-
|
|
119386
|
+
dispatch: async (name2, payload) => {
|
|
119387
|
+
if (owner !== this.dataOwnerEpoch) return;
|
|
119388
|
+
await base2.dispatch(name2, payload);
|
|
119389
|
+
this.dataPolling?.arm();
|
|
119390
|
+
}
|
|
119245
119391
|
};
|
|
119246
|
-
return port;
|
|
119247
119392
|
}
|
|
119248
119393
|
/** 推送失效 → 刷新:对象 reload(依赖它的下游随 DAG 一起重取) */
|
|
119249
119394
|
async refreshDataObjects(owner, names) {
|
|
@@ -119454,6 +119599,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
119454
119599
|
async buildRuntime(parsed) {
|
|
119455
119600
|
if (!this.container || !this.domainInstance) return;
|
|
119456
119601
|
this.stopDeclarativeTimers();
|
|
119602
|
+
this.dataPortHostState.setActionDispatcher(void 0);
|
|
119457
119603
|
this.eventEngine?.destroy();
|
|
119458
119604
|
this.renderEngine?.destroy();
|
|
119459
119605
|
this.styleBinder?.destroy();
|
|
@@ -119488,6 +119634,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
119488
119634
|
const writeEngine = this.eventEngine;
|
|
119489
119635
|
const builtinActions = createDataWriteActions({ resolver: () => this.dataResolver, store: this.writeOutcomeStore });
|
|
119490
119636
|
writeEngine.setBuiltinActions(builtinActions);
|
|
119637
|
+
this.dataPortHostState.setActionDispatcher((name2, payload) => writeEngine.dispatchAction(name2, payload));
|
|
119491
119638
|
this.eventEngine.setScopeHandler(this.createScopeEventHandler());
|
|
119492
119639
|
this.eventEngine.setRoleGate((roles) => this.domainInstance?._services?.permission?.hasAnyRole([...roles]) === true);
|
|
119493
119640
|
this.assertNamedActionsResolvable(parsed.eventConfig, this.domainInstance, builtinActions);
|
|
@@ -119633,6 +119780,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
119633
119780
|
this.componentManager?.destroy();
|
|
119634
119781
|
this.componentManager = null;
|
|
119635
119782
|
this.proxy?.dispose();
|
|
119783
|
+
this.dataPortHostState.setActionDispatcher(void 0);
|
|
119636
119784
|
this.eventEngine?.destroy();
|
|
119637
119785
|
this.renderEngine?.destroy();
|
|
119638
119786
|
this.styleBinder?.destroy();
|