soma-core 2.1.5 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/soma.cjs +1 -1
- package/bin/soma.ts +64 -15
- 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/server/api/dispatch-service-api.ts +212 -0
- package/core/server/api/load-host-service.ts +230 -56
- package/core/server/api/service-path.ts +78 -14
- package/core/server/engines/style/candidate-guard.ts +57 -0
- package/core/server/engines/style/index.ts +1 -1
- package/core/server/engines/style/tailwind-adapter.ts +83 -16
- package/core/server/host/source-packages.cjs +96 -30
- package/core/server/host/source-packages.ts +12 -5
- package/core/server/index.ts +39 -17
- package/core/server/infra/cache/ServerFileCache.ts +138 -25
- package/core/server/node.ts +32 -8
- 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/cli/soma.js +68 -14
- package/dist/core/index.cjs +284 -64
- package/dist/host-native/aot-builder.cjs +850 -0
- package/dist/host-native/native-server.cjs +15338 -0
- 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/server/api/dispatch-service-api.d.ts +18 -0
- package/dist/types/server/api/load-host-service.d.ts +7 -2
- package/dist/types/server/api/service-path.d.ts +21 -1
- package/dist/types/server/engines/style/candidate-guard.d.ts +10 -0
- package/dist/types/server/engines/style/index.d.ts +1 -1
- package/dist/types/server/engines/style/tailwind-adapter.d.ts +12 -0
- package/dist/types/server/host/source-packages.d.cts +13 -1
- package/dist/types/server/host/source-packages.d.ts +7 -4
- package/dist/types/server/index.d.ts +18 -17
- package/dist/types/server/infra/cache/ServerFileCache.d.ts +28 -5
- package/dist/types/server/node.d.ts +10 -7
- 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-native/bin/host-native.cjs +204 -0
- package/host-native/client/browser-entry.ts +499 -0
- package/{host-next/app → host-native/client}/page-access.ts +12 -0
- package/host-native/client/router-bridge.ts +120 -0
- package/host-native/src/aot-builder.ts +486 -0
- package/host-native/src/csp-headers.ts +75 -0
- package/host-native/src/host-prepare.ts +123 -0
- package/{host-next/app/soma/manifest/route.ts → host-native/src/manifest-http.ts} +10 -10
- package/host-native/src/native-server.ts +691 -0
- package/host-native/src/page-http.ts +223 -0
- package/host-native/src/public-packages.cjs +167 -0
- package/{host-next/app/api/soma-registry/[...path]/route.ts → host-native/src/registry-handler.ts} +17 -19
- package/{host-next → host-native}/src/shell-routes.cjs +23 -13
- package/host-native/src/static-file.ts +172 -0
- package/host-native/src/workspace.ts +185 -0
- package/{host-next/app → host-native/styles}/globals.css +2 -2
- package/package.json +13 -32
- package/tsconfig.json +1 -1
- package/host-next/app/SomaPageClient.tsx +0 -359
- package/host-next/app/[...path]/page.tsx +0 -22
- package/host-next/app/api/[...path]/route.ts +0 -98
- package/host-next/app/components/SomaHostPage.tsx +0 -128
- package/host-next/app/components/SomaHydrationShell.tsx +0 -20
- package/host-next/app/components/SomaPageClientBoundary.tsx +0 -13
- package/host-next/app/components/SomaPageForbidden.tsx +0 -19
- package/host-next/app/favicon.ico/route.ts +0 -13
- package/host-next/app/layout.tsx +0 -27
- package/host-next/app/page.tsx +0 -9
- package/host-next/app/router-bridge.ts +0 -42
- package/host-next/app/soma/[...path]/route.ts +0 -9
- package/host-next/app/soma/_shared/host-prepare.ts +0 -33
- package/host-next/app/soma/_shared/page-http.ts +0 -86
- package/host-next/app/soma/page/route.ts +0 -36
- package/host-next/app/soma/route.ts +0 -9
- package/host-next/app/soma-runtime/[...file]/route.ts +0 -21
- package/host-next/app/soma-runtime/_shared/static-file.ts +0 -89
- package/host-next/bin/host-next.cjs +0 -60
- package/host-next/instrumentation.ts +0 -18
- package/host-next/next-env.d.ts +0 -7
- package/host-next/next.config.js +0 -410
- package/host-next/proxy.ts +0 -43
- package/host-next/src/workspace.ts +0 -543
package/dist/core/index.cjs
CHANGED
|
@@ -20722,7 +20722,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
|
|
|
20722
20722
|
var paddingH = padding ? padding[1] + padding[3] : 0;
|
|
20723
20723
|
var paddingV = padding ? padding[0] + padding[2] : 0;
|
|
20724
20724
|
var font = style.font;
|
|
20725
|
-
var
|
|
20725
|
+
var truncate2 = overflow === "truncate";
|
|
20726
20726
|
var calculatedLineHeight = getLineHeight(font);
|
|
20727
20727
|
var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
|
|
20728
20728
|
var truncateLineOverflow = style.lineOverflow === "truncate";
|
|
@@ -20751,7 +20751,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
|
|
|
20751
20751
|
lines = lines.slice(0, lineCount);
|
|
20752
20752
|
contentHeight = lines.length * lineHeight;
|
|
20753
20753
|
}
|
|
20754
|
-
if (text2 &&
|
|
20754
|
+
if (text2 && truncate2 && width != null) {
|
|
20755
20755
|
var options = prepareTruncateOptions(width, font, style.ellipsis, {
|
|
20756
20756
|
minChar: style.truncateMinChar,
|
|
20757
20757
|
placeholder: style.placeholder
|
|
@@ -20823,7 +20823,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
|
|
|
20823
20823
|
var pendingList = [];
|
|
20824
20824
|
var calculatedHeight = 0;
|
|
20825
20825
|
var calculatedWidth = 0;
|
|
20826
|
-
var
|
|
20826
|
+
var truncate2 = overflow === "truncate";
|
|
20827
20827
|
var truncateLine = style.lineOverflow === "truncate";
|
|
20828
20828
|
var tmpTruncateOut = {};
|
|
20829
20829
|
function finishLine(line2, lineWidth2, lineHeight2) {
|
|
@@ -20879,7 +20879,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
|
|
|
20879
20879
|
}
|
|
20880
20880
|
}
|
|
20881
20881
|
}
|
|
20882
|
-
var remainTruncWidth =
|
|
20882
|
+
var remainTruncWidth = truncate2 && topWidth != null ? topWidth - lineWidth : null;
|
|
20883
20883
|
if (remainTruncWidth != null && remainTruncWidth < token.width) {
|
|
20884
20884
|
if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {
|
|
20885
20885
|
token.text = "";
|
|
@@ -28225,7 +28225,7 @@ var init_time = __esm({
|
|
|
28225
28225
|
});
|
|
28226
28226
|
|
|
28227
28227
|
// ../node_modules/echarts/lib/legacy/getTextRect.js
|
|
28228
|
-
function getTextRect(text2, font, align, verticalAlign, padding, rich,
|
|
28228
|
+
function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate2, lineHeight) {
|
|
28229
28229
|
var textEl = new Text_default({
|
|
28230
28230
|
style: {
|
|
28231
28231
|
text: text2,
|
|
@@ -28234,7 +28234,7 @@ function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate,
|
|
|
28234
28234
|
verticalAlign,
|
|
28235
28235
|
padding,
|
|
28236
28236
|
rich,
|
|
28237
|
-
overflow:
|
|
28237
|
+
overflow: truncate2 ? "truncate" : null,
|
|
28238
28238
|
lineHeight
|
|
28239
28239
|
}
|
|
28240
28240
|
});
|
|
@@ -95041,19 +95041,74 @@ var SomaEntity = class {
|
|
|
95041
95041
|
|
|
95042
95042
|
// core/client/base/SomaHttpClient.ts
|
|
95043
95043
|
var ERROR_BODY_MAX_LENGTH = 500;
|
|
95044
|
-
|
|
95044
|
+
var CANDIDATE_KEYS = [
|
|
95045
|
+
"error",
|
|
95046
|
+
"message",
|
|
95047
|
+
"msg",
|
|
95048
|
+
"errMsg",
|
|
95049
|
+
"err_msg",
|
|
95050
|
+
"errmsg",
|
|
95051
|
+
"reason",
|
|
95052
|
+
"detail"
|
|
95053
|
+
];
|
|
95054
|
+
function pickMessageField(record2) {
|
|
95055
|
+
for (const key of CANDIDATE_KEYS) {
|
|
95056
|
+
const val = record2[key];
|
|
95057
|
+
if (typeof val === "string" && val.trim() !== "") {
|
|
95058
|
+
return val.trim();
|
|
95059
|
+
}
|
|
95060
|
+
}
|
|
95061
|
+
return void 0;
|
|
95062
|
+
}
|
|
95063
|
+
function extractHtmlTitle(text2) {
|
|
95064
|
+
const match = text2.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
95065
|
+
if (!match) return void 0;
|
|
95066
|
+
const plain = match[1].replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
95067
|
+
if (plain === "") return void 0;
|
|
95068
|
+
return plain.length > 120 ? `${plain.slice(0, 120)}\u2026` : plain;
|
|
95069
|
+
}
|
|
95070
|
+
function describeHttpErrorBody(body, statusText, status) {
|
|
95045
95071
|
const text2 = (body ?? "").trim();
|
|
95046
|
-
|
|
95047
|
-
|
|
95072
|
+
const fallbackStatus = statusText.trim() || (status ? `\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status}\uFF09` : "\u8BF7\u6C42\u5931\u8D25");
|
|
95073
|
+
if (text2 === "") return fallbackStatus;
|
|
95074
|
+
if (/^\s*<(?:!doctype\s+html|html)/i.test(text2)) {
|
|
95075
|
+
const title = extractHtmlTitle(text2);
|
|
95076
|
+
if (title) return title;
|
|
95077
|
+
return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
|
|
95078
|
+
}
|
|
95048
95079
|
try {
|
|
95049
95080
|
const parsed = JSON.parse(text2);
|
|
95050
95081
|
if (parsed && typeof parsed === "object") {
|
|
95051
|
-
|
|
95052
|
-
|
|
95082
|
+
if (!Array.isArray(parsed)) {
|
|
95083
|
+
const obj = parsed;
|
|
95084
|
+
const top = pickMessageField(obj);
|
|
95085
|
+
if (top) return truncate(top);
|
|
95086
|
+
if (obj.error && typeof obj.error === "object" && !Array.isArray(obj.error)) {
|
|
95087
|
+
const nested = pickMessageField(obj.error);
|
|
95088
|
+
if (nested) return truncate(nested);
|
|
95089
|
+
}
|
|
95090
|
+
if (obj.data && typeof obj.data === "object" && !Array.isArray(obj.data)) {
|
|
95091
|
+
const nested = pickMessageField(obj.data);
|
|
95092
|
+
if (nested) return truncate(nested);
|
|
95093
|
+
}
|
|
95094
|
+
if (typeof obj.code === "string" && obj.code.trim() !== "" && obj.code.trim().length <= 40) {
|
|
95095
|
+
return truncate(obj.code.trim());
|
|
95096
|
+
}
|
|
95097
|
+
}
|
|
95098
|
+
return fallbackStatus;
|
|
95053
95099
|
}
|
|
95054
95100
|
} catch {
|
|
95101
|
+
if (text2.startsWith("<")) {
|
|
95102
|
+
const title = extractHtmlTitle(text2);
|
|
95103
|
+
if (title) return title;
|
|
95104
|
+
return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
|
|
95105
|
+
}
|
|
95106
|
+
return truncate(text2);
|
|
95055
95107
|
}
|
|
95056
|
-
return
|
|
95108
|
+
return fallbackStatus;
|
|
95109
|
+
}
|
|
95110
|
+
function truncate(msg) {
|
|
95111
|
+
return msg.length > ERROR_BODY_MAX_LENGTH ? `${msg.slice(0, ERROR_BODY_MAX_LENGTH)}\u2026` : msg;
|
|
95057
95112
|
}
|
|
95058
95113
|
var SomaHttpClient = class {
|
|
95059
95114
|
baseURL;
|
|
@@ -95128,7 +95183,7 @@ var SomaHttpClient = class {
|
|
|
95128
95183
|
const res = await fetch(url, options);
|
|
95129
95184
|
if (!res.ok) {
|
|
95130
95185
|
const errorBody = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
95131
|
-
throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText)}`);
|
|
95186
|
+
throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText, res.status)}`);
|
|
95132
95187
|
}
|
|
95133
95188
|
return await res.json();
|
|
95134
95189
|
} finally {
|
|
@@ -97139,7 +97194,30 @@ function checkFieldAll(rules, value, context = {}) {
|
|
|
97139
97194
|
// ../soma-foundation/dist/esm/values/collection-payload.js
|
|
97140
97195
|
var ROW_KEYS = ["items", "rows", "list"];
|
|
97141
97196
|
var META_KEYS = /* @__PURE__ */ new Set([...ROW_KEYS, "total", "page", "pageSize", "cursor", "hasMore", "pages", "facets", "cap", "truncated", "meta"]);
|
|
97142
|
-
var WRAPPER_KEYS = /* @__PURE__ */ new Set([
|
|
97197
|
+
var WRAPPER_KEYS = /* @__PURE__ */ new Set([
|
|
97198
|
+
"ret",
|
|
97199
|
+
"success",
|
|
97200
|
+
"ok",
|
|
97201
|
+
"code",
|
|
97202
|
+
"message",
|
|
97203
|
+
"msg",
|
|
97204
|
+
"data",
|
|
97205
|
+
"traceId",
|
|
97206
|
+
"trace_id",
|
|
97207
|
+
"requestId",
|
|
97208
|
+
"request_id",
|
|
97209
|
+
"timestamp",
|
|
97210
|
+
"ts",
|
|
97211
|
+
"time",
|
|
97212
|
+
"cost",
|
|
97213
|
+
"status",
|
|
97214
|
+
"errMsg",
|
|
97215
|
+
"err_msg",
|
|
97216
|
+
"errmsg",
|
|
97217
|
+
"error",
|
|
97218
|
+
"reason",
|
|
97219
|
+
"detail"
|
|
97220
|
+
]);
|
|
97143
97221
|
function isPlain(value) {
|
|
97144
97222
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
97145
97223
|
const proto = Object.getPrototypeOf(value);
|
|
@@ -106255,9 +106333,9 @@ var SomaEventEngine = class {
|
|
|
106255
106333
|
}
|
|
106256
106334
|
return void 0;
|
|
106257
106335
|
}
|
|
106258
|
-
/**
|
|
106336
|
+
/** 分级确认的唯一出口:注入了执行口 -> 执行口(plain / consent / typed 全级别);否则安全回退 adapter.confirm(spec.text) */
|
|
106259
106337
|
askConfirm(spec) {
|
|
106260
|
-
if (
|
|
106338
|
+
if (this.confirmGraded) return this.confirmGraded(spec);
|
|
106261
106339
|
return this.adapter.confirm(spec.text);
|
|
106262
106340
|
}
|
|
106263
106341
|
preCheck(config, somaId, element) {
|
|
@@ -108821,8 +108899,10 @@ var SomaHttpService = class {
|
|
|
108821
108899
|
try {
|
|
108822
108900
|
const res = await fetch(fullUrl, { method: "POST", body: form, signal: controller.signal });
|
|
108823
108901
|
if (!res.ok) {
|
|
108824
|
-
|
|
108825
|
-
|
|
108902
|
+
const body = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
108903
|
+
const readable = describeHttpErrorBody(body, res.statusText, res.status);
|
|
108904
|
+
this.onHttpError?.(res.status, readable);
|
|
108905
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
108826
108906
|
}
|
|
108827
108907
|
onProgress?.(100);
|
|
108828
108908
|
return await res.json();
|
|
@@ -108852,8 +108932,10 @@ var SomaHttpService = class {
|
|
|
108852
108932
|
reject(new Error("Invalid JSON response"));
|
|
108853
108933
|
}
|
|
108854
108934
|
} else {
|
|
108855
|
-
|
|
108856
|
-
|
|
108935
|
+
const body = xhr.responseText ?? "";
|
|
108936
|
+
const readable = describeHttpErrorBody(body, xhr.statusText, xhr.status);
|
|
108937
|
+
this.onHttpError?.(xhr.status, readable);
|
|
108938
|
+
reject(new Error(`HTTP ${xhr.status}: ${readable}`));
|
|
108857
108939
|
}
|
|
108858
108940
|
});
|
|
108859
108941
|
xhr.addEventListener("error", () => {
|
|
@@ -108906,8 +108988,11 @@ var SomaHttpService = class {
|
|
|
108906
108988
|
const res = await fetch(fullUrl, options);
|
|
108907
108989
|
if (!res.ok) {
|
|
108908
108990
|
const body2 = typeof res.text === "function" ? await res.text().catch(() => "") : "";
|
|
108909
|
-
|
|
108910
|
-
|
|
108991
|
+
const readable = describeHttpErrorBody(body2, res.statusText, res.status);
|
|
108992
|
+
if (config?.silentErrorToast !== true) {
|
|
108993
|
+
this.onHttpError?.(res.status, readable);
|
|
108994
|
+
}
|
|
108995
|
+
throw new Error(`HTTP ${res.status}: ${readable}`);
|
|
108911
108996
|
}
|
|
108912
108997
|
try {
|
|
108913
108998
|
config?.onResponse?.({ status: res.status });
|
|
@@ -113517,6 +113602,11 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
113517
113602
|
"module": "soma-lite",
|
|
113518
113603
|
"file": "src/app/server/provenance-limit.ts",
|
|
113519
113604
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
113605
|
+
},
|
|
113606
|
+
{
|
|
113607
|
+
"module": "soma-robot",
|
|
113608
|
+
"file": "src/common/limits.ts",
|
|
113609
|
+
"symbol": "SOMA_PIPELINE_LIMITS_AI_ROBOT"
|
|
113520
113610
|
}
|
|
113521
113611
|
],
|
|
113522
113612
|
"registry": {
|
|
@@ -113827,8 +113917,13 @@ function parseSource(raw, path, objectNames, selfName, deps) {
|
|
|
113827
113917
|
source.failWhen = value;
|
|
113828
113918
|
} else if (key === "messagePath") {
|
|
113829
113919
|
source.messagePath = value;
|
|
113920
|
+
} else if (key === "dataPath") {
|
|
113921
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
113922
|
+
throw new SomaDataConfigError(`dataPath \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u54CD\u5E94\u4F53\u70B9\u8DEF\u5F84`, `${path}.dataPath`);
|
|
113923
|
+
}
|
|
113924
|
+
source.dataPath = value.trim();
|
|
113830
113925
|
} else {
|
|
113831
|
-
throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath\uFF09`, `${path}.${key}`);
|
|
113926
|
+
throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath / dataPath\uFF09`, `${path}.${key}`);
|
|
113832
113927
|
}
|
|
113833
113928
|
}
|
|
113834
113929
|
if (source.failWhen !== void 0 || source.messagePath !== void 0) {
|
|
@@ -115544,14 +115639,24 @@ var SomaDataObjectResolver = class {
|
|
|
115544
115639
|
return data;
|
|
115545
115640
|
});
|
|
115546
115641
|
}
|
|
115642
|
+
pickDotted(root, path) {
|
|
115643
|
+
let current = root;
|
|
115644
|
+
for (const segment2 of path.split(".")) {
|
|
115645
|
+
if (segment2 === "") continue;
|
|
115646
|
+
if (current === null || typeof current !== "object") return void 0;
|
|
115647
|
+
current = current[segment2];
|
|
115648
|
+
}
|
|
115649
|
+
return current;
|
|
115650
|
+
}
|
|
115547
115651
|
/** 聚合来源结果:into 写入子键;缺省先解开宿主信封,再浅合并进根(数组整体替换) */
|
|
115548
115652
|
mergeSource(current, source, data) {
|
|
115549
|
-
const payload = source.into ? data : unwrapHostPayload(data);
|
|
115550
115653
|
if (source.into) {
|
|
115551
115654
|
const target = isPlainObject7(current) ? current : {};
|
|
115552
115655
|
target[source.into] = data;
|
|
115553
115656
|
return target;
|
|
115554
115657
|
}
|
|
115658
|
+
const rawData = source.dataPath ? this.pickDotted(data, source.dataPath) : data;
|
|
115659
|
+
const payload = unwrapHostPayload(rawData);
|
|
115555
115660
|
if (isPlainObject7(payload)) {
|
|
115556
115661
|
if (isPlainObject7(current)) {
|
|
115557
115662
|
Object.assign(current, payload);
|
|
@@ -115718,6 +115823,53 @@ var SomaDataObjectResolver = class {
|
|
|
115718
115823
|
return value;
|
|
115719
115824
|
}
|
|
115720
115825
|
};
|
|
115826
|
+
function createSomaDataPort(currentResolver, hostState = createDataPortHostState()) {
|
|
115827
|
+
const noResolver = (action) => ({
|
|
115828
|
+
ok: false,
|
|
115829
|
+
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`
|
|
115830
|
+
});
|
|
115831
|
+
return {
|
|
115832
|
+
getObject: (name2) => currentResolver()?.getObject(name2),
|
|
115833
|
+
getObjectStatus: (name2) => currentResolver()?.getObjectStatus(name2),
|
|
115834
|
+
getDict: (name2) => currentResolver()?.getDict(name2) ?? {},
|
|
115835
|
+
submit: async (name2, model, mode, options) => {
|
|
115836
|
+
const resolver = currentResolver();
|
|
115837
|
+
return resolver ? resolver.submit(name2, model, mode, options) : noResolver(`\u63D0\u4EA4 "${name2}"`);
|
|
115838
|
+
},
|
|
115839
|
+
remove: async (name2, target) => {
|
|
115840
|
+
const resolver = currentResolver();
|
|
115841
|
+
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` };
|
|
115842
|
+
},
|
|
115843
|
+
reload: async (names) => {
|
|
115844
|
+
await currentResolver()?.reload(names);
|
|
115845
|
+
},
|
|
115846
|
+
validate: (name2, model, trigger3) => currentResolver()?.validate(name2, model, trigger3) ?? {},
|
|
115847
|
+
writeOutcome: (scope) => hostState.writeOutcomes().get(scope),
|
|
115848
|
+
onWriteOutcome: (listener) => hostState.writeOutcomes().subscribe(listener),
|
|
115849
|
+
clearWriteOptimistic: (scope, key) => hostState.writeOutcomes().clearOptimistic(scope, key),
|
|
115850
|
+
clearOutcome: (scope) => hostState.writeOutcomes().clear(scope),
|
|
115851
|
+
dispatch: (name2, payload) => hostState.dispatchAction(name2, payload)
|
|
115852
|
+
};
|
|
115853
|
+
}
|
|
115854
|
+
function createDataPortHostState() {
|
|
115855
|
+
const outcomes = createWriteOutcomeStore();
|
|
115856
|
+
let dispatcher;
|
|
115857
|
+
return {
|
|
115858
|
+
writeOutcomes: () => outcomes,
|
|
115859
|
+
setActionDispatcher(next) {
|
|
115860
|
+
dispatcher = next;
|
|
115861
|
+
},
|
|
115862
|
+
async dispatchAction(name2, payload) {
|
|
115863
|
+
if (dispatcher === void 0) {
|
|
115864
|
+
const scope = typeof payload.scope === "string" ? payload.scope : String(payload.object ?? "");
|
|
115865
|
+
const seq2 = outcomes.begin(scope);
|
|
115866
|
+
outcomes.settle(scope, seq2, { ok: false, message: "\u9875\u9762\u6CA1\u6709\u4E8B\u4EF6\u5F15\u64CE\uFF0C\u5199\u5165\u4E8B\u4EF6\u65E0\u5904\u6267\u884C" });
|
|
115867
|
+
return;
|
|
115868
|
+
}
|
|
115869
|
+
await dispatcher(name2, payload);
|
|
115870
|
+
}
|
|
115871
|
+
};
|
|
115872
|
+
}
|
|
115721
115873
|
function bindDataResolverCapabilities(resolver) {
|
|
115722
115874
|
return {
|
|
115723
115875
|
resolve: () => resolver.resolve(),
|
|
@@ -119266,8 +119418,11 @@ var SomaBootstrap = class {
|
|
|
119266
119418
|
dataResolver = null;
|
|
119267
119419
|
dataLoadEpoch = 0;
|
|
119268
119420
|
dataOwnerEpoch = 0;
|
|
119269
|
-
/**
|
|
119270
|
-
|
|
119421
|
+
/** 数据端口宿主状态(单一真源):持有写入结果存储与写入事件执行口,端口重建同寿 */
|
|
119422
|
+
dataPortHostState = createDataPortHostState();
|
|
119423
|
+
get writeOutcomeStore() {
|
|
119424
|
+
return this.dataPortHostState.writeOutcomes();
|
|
119425
|
+
}
|
|
119271
119426
|
/** 快捷键注册中心(C-r18):唯一一份,`services.shortcuts` 直通 */
|
|
119272
119427
|
shortcutsInstance;
|
|
119273
119428
|
componentStyleNonce;
|
|
@@ -120289,36 +120444,26 @@ ${lines}
|
|
|
120289
120444
|
createStableDataPort() {
|
|
120290
120445
|
const owner = this.dataOwnerEpoch;
|
|
120291
120446
|
const current = () => owner === this.dataOwnerEpoch ? this.dataResolver : null;
|
|
120292
|
-
const
|
|
120293
|
-
|
|
120294
|
-
|
|
120295
|
-
});
|
|
120296
|
-
const port = {
|
|
120297
|
-
getObject: (name2) => current()?.getObject(name2),
|
|
120298
|
-
getObjectStatus: (name2) => current()?.getObjectStatus(name2),
|
|
120299
|
-
getDict: (name2) => current()?.getDict(name2) ?? {},
|
|
120447
|
+
const base2 = createSomaDataPort(current, this.dataPortHostState);
|
|
120448
|
+
return {
|
|
120449
|
+
...base2,
|
|
120300
120450
|
submit: async (name2, model, mode, options) => {
|
|
120301
|
-
const
|
|
120302
|
-
if (
|
|
120303
|
-
|
|
120304
|
-
|
|
120451
|
+
const result = await base2.submit(name2, model, mode, options);
|
|
120452
|
+
if (current()) {
|
|
120453
|
+
this.dataPolling?.arm();
|
|
120454
|
+
}
|
|
120305
120455
|
return result;
|
|
120306
120456
|
},
|
|
120307
|
-
remove: async (name2, target) => {
|
|
120308
|
-
const resolver = current();
|
|
120309
|
-
return resolver ? resolver.remove(name2, target) : notReady(`\u5220\u9664 "${name2}" \u7684\u8BB0\u5F55`);
|
|
120310
|
-
},
|
|
120311
120457
|
reload: async (names) => {
|
|
120312
|
-
await
|
|
120458
|
+
await base2.reload(names);
|
|
120313
120459
|
this.dataPolling?.arm();
|
|
120314
120460
|
},
|
|
120315
|
-
|
|
120316
|
-
|
|
120317
|
-
|
|
120318
|
-
|
|
120319
|
-
|
|
120461
|
+
dispatch: async (name2, payload) => {
|
|
120462
|
+
if (owner !== this.dataOwnerEpoch) return;
|
|
120463
|
+
await base2.dispatch(name2, payload);
|
|
120464
|
+
this.dataPolling?.arm();
|
|
120465
|
+
}
|
|
120320
120466
|
};
|
|
120321
|
-
return port;
|
|
120322
120467
|
}
|
|
120323
120468
|
/** 推送失效 → 刷新:对象 reload(依赖它的下游随 DAG 一起重取) */
|
|
120324
120469
|
async refreshDataObjects(owner, names) {
|
|
@@ -120529,6 +120674,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
120529
120674
|
async buildRuntime(parsed) {
|
|
120530
120675
|
if (!this.container || !this.domainInstance) return;
|
|
120531
120676
|
this.stopDeclarativeTimers();
|
|
120677
|
+
this.dataPortHostState.setActionDispatcher(void 0);
|
|
120532
120678
|
this.eventEngine?.destroy();
|
|
120533
120679
|
this.renderEngine?.destroy();
|
|
120534
120680
|
this.styleBinder?.destroy();
|
|
@@ -120563,6 +120709,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
120563
120709
|
const writeEngine = this.eventEngine;
|
|
120564
120710
|
const builtinActions = createDataWriteActions({ resolver: () => this.dataResolver, store: this.writeOutcomeStore });
|
|
120565
120711
|
writeEngine.setBuiltinActions(builtinActions);
|
|
120712
|
+
this.dataPortHostState.setActionDispatcher((name2, payload) => writeEngine.dispatchAction(name2, payload));
|
|
120566
120713
|
this.eventEngine.setScopeHandler(this.createScopeEventHandler());
|
|
120567
120714
|
this.eventEngine.setRoleGate((roles) => this.domainInstance?._services?.permission?.hasAnyRole([...roles]) === true);
|
|
120568
120715
|
this.assertNamedActionsResolvable(parsed.eventConfig, this.domainInstance, builtinActions);
|
|
@@ -120708,6 +120855,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
|
|
|
120708
120855
|
this.componentManager?.destroy();
|
|
120709
120856
|
this.componentManager = null;
|
|
120710
120857
|
this.proxy?.dispose();
|
|
120858
|
+
this.dataPortHostState.setActionDispatcher(void 0);
|
|
120711
120859
|
this.eventEngine?.destroy();
|
|
120712
120860
|
this.renderEngine?.destroy();
|
|
120713
120861
|
this.styleBinder?.destroy();
|
|
@@ -120937,11 +121085,72 @@ function createPermissionMiddleware(getServices) {
|
|
|
120937
121085
|
}
|
|
120938
121086
|
|
|
120939
121087
|
// core/client/host-bridge/resolve-host-bootstrap.ts
|
|
120940
|
-
|
|
120941
|
-
|
|
120942
|
-
|
|
121088
|
+
var HOST_BOOTSTRAP_MODULE = "@soma-host/bootstrap/soma-bootstrap";
|
|
121089
|
+
function unwrapLoaderError(error2) {
|
|
121090
|
+
if (typeof error2 === "object" && error2 !== null && "cause" in error2) {
|
|
121091
|
+
const cause = error2.cause;
|
|
121092
|
+
if (cause !== void 0 && cause !== null) {
|
|
121093
|
+
return cause;
|
|
121094
|
+
}
|
|
121095
|
+
}
|
|
121096
|
+
return error2;
|
|
121097
|
+
}
|
|
121098
|
+
function hasModuleNotFoundSignature(error2) {
|
|
121099
|
+
const unwrapped = unwrapLoaderError(error2);
|
|
121100
|
+
if (typeof unwrapped !== "object" || unwrapped === null) return false;
|
|
121101
|
+
const { code, message } = unwrapped;
|
|
120943
121102
|
if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND") return true;
|
|
120944
|
-
return typeof message === "string" && /Cannot find module|Module not found
|
|
121103
|
+
return typeof message === "string" && /Cannot find module|Module not found|Can't resolve|Unknown variable dynamic import/i.test(message);
|
|
121104
|
+
}
|
|
121105
|
+
function extractMissingModuleSpecifier(message) {
|
|
121106
|
+
if (!message || typeof message !== "string") return null;
|
|
121107
|
+
const viteMatch = message.match(/Unknown variable dynamic import:\s*(.+)$/i);
|
|
121108
|
+
if (viteMatch && viteMatch[1]) {
|
|
121109
|
+
return viteMatch[1].trim();
|
|
121110
|
+
}
|
|
121111
|
+
const primaryMatch = message.match(
|
|
121112
|
+
/(?:Cannot find (?:module|package)|Can't resolve|Failed to resolve import)\s+['"]([^'"]+)['"]/i
|
|
121113
|
+
);
|
|
121114
|
+
if (primaryMatch && primaryMatch[1]) {
|
|
121115
|
+
return primaryMatch[1];
|
|
121116
|
+
}
|
|
121117
|
+
const quoteMatch = message.match(/['"]([^'"]+)['"]/);
|
|
121118
|
+
if (quoteMatch && quoteMatch[1]) {
|
|
121119
|
+
return quoteMatch[1];
|
|
121120
|
+
}
|
|
121121
|
+
return null;
|
|
121122
|
+
}
|
|
121123
|
+
function matchesEntrySpecifier(spec, expected) {
|
|
121124
|
+
if (spec === expected) return true;
|
|
121125
|
+
const normalizedExpected = expected.replace(/\.(?:ts|js|mjs|cjs)$/, "");
|
|
121126
|
+
const normalizedSpec = spec.replace(/\.(?:ts|js|mjs|cjs)$/, "");
|
|
121127
|
+
if (normalizedSpec === normalizedExpected) return true;
|
|
121128
|
+
const expectedSegments = normalizedExpected.split("/");
|
|
121129
|
+
const expectedBase = expectedSegments[expectedSegments.length - 1];
|
|
121130
|
+
if (!expectedBase) return false;
|
|
121131
|
+
const baseRegex = new RegExp(`(?:^|[\\\\/])${expectedBase}(?:\\.(?:ts|js|mjs|cjs))?$`);
|
|
121132
|
+
if (!baseRegex.test(spec)) {
|
|
121133
|
+
return false;
|
|
121134
|
+
}
|
|
121135
|
+
if (expectedSegments.length > 1) {
|
|
121136
|
+
const parentSegment = expectedSegments[expectedSegments.length - 2];
|
|
121137
|
+
if (normalizedSpec.includes("/") || normalizedSpec.includes("\\")) {
|
|
121138
|
+
const parentRegex = new RegExp(`(?:^|[\\\\/])${parentSegment}[\\\\/]${expectedBase}$`);
|
|
121139
|
+
return parentRegex.test(normalizedSpec);
|
|
121140
|
+
}
|
|
121141
|
+
}
|
|
121142
|
+
return true;
|
|
121143
|
+
}
|
|
121144
|
+
function isOptionalEntryAbsent(error2, expectedSpecifiers) {
|
|
121145
|
+
const unwrapped = unwrapLoaderError(error2);
|
|
121146
|
+
if (!hasModuleNotFoundSignature(unwrapped)) return false;
|
|
121147
|
+
const message = typeof unwrapped?.message === "string" ? unwrapped.message : "";
|
|
121148
|
+
const spec = extractMissingModuleSpecifier(message);
|
|
121149
|
+
if (spec === null) {
|
|
121150
|
+
return true;
|
|
121151
|
+
}
|
|
121152
|
+
const list2 = Array.isArray(expectedSpecifiers) ? expectedSpecifiers : [expectedSpecifiers];
|
|
121153
|
+
return list2.some((expected) => matchesEntrySpecifier(spec, expected));
|
|
120945
121154
|
}
|
|
120946
121155
|
var bootstrapOptionsCache = null;
|
|
120947
121156
|
var bootstrapResolvingPromise = null;
|
|
@@ -120950,20 +121159,21 @@ async function resolveHostBootstrapOptions(getServices, retry) {
|
|
|
120950
121159
|
if (bootstrapResolvingPromise) return bootstrapResolvingPromise;
|
|
120951
121160
|
bootstrapResolvingPromise = (async () => {
|
|
120952
121161
|
try {
|
|
121162
|
+
let mod = null;
|
|
120953
121163
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
120954
121164
|
try {
|
|
120955
|
-
|
|
121165
|
+
mod = await import(
|
|
120956
121166
|
/* webpackChunkName: "soma-host-bootstrap" */
|
|
120957
121167
|
"@soma-host/bootstrap/soma-bootstrap"
|
|
120958
121168
|
);
|
|
120959
|
-
|
|
120960
|
-
|
|
120961
|
-
|
|
120962
|
-
|
|
120963
|
-
|
|
120964
|
-
|
|
120965
|
-
|
|
120966
|
-
|
|
121169
|
+
break;
|
|
121170
|
+
} catch (rawError) {
|
|
121171
|
+
const error2 = unwrapLoaderError(rawError);
|
|
121172
|
+
if (hasModuleNotFoundSignature(error2)) {
|
|
121173
|
+
if (isOptionalEntryAbsent(error2, HOST_BOOTSTRAP_MODULE)) {
|
|
121174
|
+
return {};
|
|
121175
|
+
}
|
|
121176
|
+
console.error("[soma-core][\u5F15\u64CE] \u5BBF\u4E3B\u5F15\u5BFC\u6A21\u5757\u5185\u90E8\u4F9D\u8D56\u7F3A\u5931\uFF0C\u5BBF\u4E3B\u88C5\u914D\u88AB\u6574\u4F53\u8DF3\u8FC7:", error2);
|
|
120967
121177
|
return {};
|
|
120968
121178
|
}
|
|
120969
121179
|
const isChunkError = error2 instanceof Error && (error2.name === "ChunkLoadError" || error2.message.includes("Loading chunk"));
|
|
@@ -120972,13 +121182,23 @@ async function resolveHostBootstrapOptions(getServices, retry) {
|
|
|
120972
121182
|
continue;
|
|
120973
121183
|
}
|
|
120974
121184
|
console.error("[soma-core][\u5F15\u64CE] configureSomaBootstrap \u629B\u51FA\u5F02\u5E38\uFF0C\u5BBF\u4E3B\u88C5\u914D\u88AB\u6574\u4F53\u8DF3\u8FC7:", error2);
|
|
120975
|
-
|
|
121185
|
+
return {};
|
|
121186
|
+
}
|
|
121187
|
+
}
|
|
121188
|
+
if (mod && typeof mod.configureSomaBootstrap === "function") {
|
|
121189
|
+
try {
|
|
121190
|
+
const opts = mod.configureSomaBootstrap({ getServices }) ?? {};
|
|
121191
|
+
bootstrapOptionsCache = opts;
|
|
121192
|
+
return opts;
|
|
121193
|
+
} catch (error2) {
|
|
121194
|
+
console.error("[soma-core][\u5F15\u64CE] configureSomaBootstrap \u629B\u51FA\u5F02\u5E38\uFF0C\u5BBF\u4E3B\u88C5\u914D\u88AB\u6574\u4F53\u8DF3\u8FC7:", error2);
|
|
121195
|
+
return {};
|
|
120976
121196
|
}
|
|
120977
121197
|
}
|
|
121198
|
+
return {};
|
|
120978
121199
|
} finally {
|
|
120979
121200
|
bootstrapResolvingPromise = null;
|
|
120980
121201
|
}
|
|
120981
|
-
return {};
|
|
120982
121202
|
})();
|
|
120983
121203
|
return bootstrapResolvingPromise;
|
|
120984
121204
|
}
|