dsh-edge 0.18.0 → 0.19.0-alpha.2
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.i18n.yaml +2 -2
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/THIRD_PARTY_NOTICES.md +2011 -449
- package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
- package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
- package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
- package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
- package/dist/assets/index-Cq6ljTv2.css +1 -0
- package/dist/assets/index-Dy0OhsZ5.js +127 -0
- package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
- package/dist/assets/langs/bat-BkioyH1T.js +2 -0
- package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
- package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
- package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
- package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
- package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
- package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
- package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
- package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
- package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
- package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
- package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
- package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
- package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
- package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
- package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
- package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
- package/dist/assets/langs/html-fwsONPVS.js +2 -0
- package/dist/assets/langs/http-DcV90OkR.js +2 -0
- package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
- package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
- package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
- package/dist/assets/langs/log-2UxHyX5q.js +2 -0
- package/dist/assets/langs/make-CHLpvVh8.js +2 -0
- package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
- package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
- package/dist/assets/langs/php-LEPfNACG.js +2 -0
- package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
- package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
- package/dist/assets/langs/r-Dspwwk_N.js +2 -0
- package/dist/assets/langs/rst-BbocfKWr.js +2 -0
- package/dist/assets/langs/ruby-R292Iif0.js +2 -0
- package/dist/assets/langs/scala-C151Ov-r.js +2 -0
- package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
- package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
- package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
- package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
- package/dist/assets/langs/vue-Dq2x6432.js +2 -0
- package/dist/favicon-dark.svg +3 -0
- package/dist/favicon.svg +0 -5
- package/dist/index.html +5 -4
- package/dist/manifest.webmanifest +3 -4
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
- package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
- package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
- package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
- package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
- package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
- package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
- package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
- package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
- package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
- package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
- package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
- package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
- package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
- package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
- package/package.json +96 -86
- package/scripts/cli.mjs +16 -4
- package/scripts/install.d.mts +12 -2
- package/scripts/install.mjs +36 -9
- package/scripts/legal-files.mjs +15 -0
- package/worker/direct/index.js +2564 -1822
- package/worker/isolated/index.js +2144 -1402
- package/dist/assets/index-BKQ_L1z6.js +0 -117
- package/dist/assets/index-DPX2bQLO.css +0 -1
- package/dist/assets/langs/html-CfGypltT.js +0 -2
- package/dist/assets/langs/php-DJl5gRdb.js +0 -2
- package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
- package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
|
@@ -55,10 +55,11 @@ window.__ModuleLoader__.load({
|
|
|
55
55
|
this.name = "RemoteError";
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Browser-relative form of {@link FILE_UPLOAD_PATH}; see
|
|
60
|
+
* .agents/notes/implemented/architecture/2026-09-14-web-document-relative-app-routes.md.
|
|
61
|
+
*/
|
|
62
|
+
const FILE_UPLOAD_ROUTE = "/api/session/uploadFileBinary".slice(1);
|
|
62
63
|
//#endregion
|
|
63
64
|
//#region lib/types/client/runtime.js
|
|
64
65
|
/** Background browser upload implementation for Blob and byte-stream bodies. */
|
|
@@ -151,13 +152,11 @@ window.__ModuleLoader__.load({
|
|
|
151
152
|
}
|
|
152
153
|
/** Cordis service that owns one background carrier per upload operation. */
|
|
153
154
|
var FileUploadRuntime = class extends _deepseek_ai_cordis.Service {
|
|
154
|
-
available;
|
|
155
155
|
transport;
|
|
156
156
|
/** @param ctx - providing Client context. */
|
|
157
157
|
constructor(ctx) {
|
|
158
158
|
super(ctx, "fileUpload");
|
|
159
159
|
const hook = globalThis.__DSH_FILE_UPLOAD__;
|
|
160
|
-
this.available = hook !== void 0 || !isFixturePage();
|
|
161
160
|
this.transport = hook === void 0 ? workerTransport() : customTransport(hook.fetch);
|
|
162
161
|
}
|
|
163
162
|
/**
|
|
@@ -166,7 +165,6 @@ window.__ModuleLoader__.load({
|
|
|
166
165
|
* @returns the response status and text body.
|
|
167
166
|
*/
|
|
168
167
|
post(request) {
|
|
169
|
-
if (!this.available) return Promise.reject(/* @__PURE__ */ new Error("background upload is unavailable in fixture mode"));
|
|
170
168
|
return this.transport.post(request);
|
|
171
169
|
}
|
|
172
170
|
/**
|
|
@@ -179,11 +177,11 @@ window.__ModuleLoader__.load({
|
|
|
179
177
|
* @returns the staged receipt and durable file reference, or a business error.
|
|
180
178
|
*/
|
|
181
179
|
async upload(sessionId, data, name, signal, onProgress) {
|
|
182
|
-
if (!(data instanceof Uint8Array)
|
|
180
|
+
if (!(data instanceof Uint8Array)) {
|
|
183
181
|
const query = new URLSearchParams({ sessionId });
|
|
184
182
|
if (name !== void 0) query.set("name", name);
|
|
185
183
|
const response = await this.post({
|
|
186
|
-
path: `${
|
|
184
|
+
path: `${FILE_UPLOAD_ROUTE}?${query.toString()}`,
|
|
187
185
|
body: data,
|
|
188
186
|
headers: { "content-type": "application/octet-stream" },
|
|
189
187
|
...signal === void 0 ? {} : { signal },
|
|
@@ -192,10 +190,8 @@ window.__ModuleLoader__.load({
|
|
|
192
190
|
if (response.status !== 200) throw new Error(`file upload transport failed with HTTP ${String(response.status)}`);
|
|
193
191
|
return parseFileUploadResult(response.body);
|
|
194
192
|
}
|
|
195
|
-
if (!(data instanceof Uint8Array) && !(data instanceof Blob)) throw new Error("stream file upload requires a background carrier");
|
|
196
|
-
const bytes = data instanceof Uint8Array ? data : new Uint8Array(await data.arrayBuffer());
|
|
197
193
|
return this.ctx.remote.fileUploads.upload(sessionId, {
|
|
198
|
-
data: bytesToBase64(
|
|
194
|
+
data: bytesToBase64(data),
|
|
199
195
|
...name === void 0 ? {} : { name }
|
|
200
196
|
}, signal);
|
|
201
197
|
}
|
|
@@ -209,7 +205,7 @@ window.__ModuleLoader__.load({
|
|
|
209
205
|
...request.body instanceof ReadableStream ? { duplex: "half" } : {},
|
|
210
206
|
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
211
207
|
};
|
|
212
|
-
const response = await customFetch(
|
|
208
|
+
const response = await customFetch(request.path, init);
|
|
213
209
|
return {
|
|
214
210
|
status: response.status,
|
|
215
211
|
body: await response.text()
|
|
@@ -264,7 +260,7 @@ window.__ModuleLoader__.load({
|
|
|
264
260
|
}
|
|
265
261
|
request.signal?.addEventListener("abort", abort, { once: true });
|
|
266
262
|
const message = {
|
|
267
|
-
url:
|
|
263
|
+
url: new URL(request.path, document.baseURI).href,
|
|
268
264
|
body: request.body,
|
|
269
265
|
headers: request.headers ?? {}
|
|
270
266
|
};
|
|
@@ -273,15 +269,6 @@ window.__ModuleLoader__.load({
|
|
|
273
269
|
});
|
|
274
270
|
} };
|
|
275
271
|
}
|
|
276
|
-
function resolveUrl(path) {
|
|
277
|
-
const pageLocation = Reflect.get(globalThis, "location");
|
|
278
|
-
const origin = typeof pageLocation === "object" && pageLocation !== null && "origin" in pageLocation && typeof pageLocation.origin === "string" ? pageLocation.origin : void 0;
|
|
279
|
-
return new URL(path, origin === void 0 || origin === "null" ? "http://dsh.internal" : origin);
|
|
280
|
-
}
|
|
281
|
-
function isFixturePage() {
|
|
282
|
-
const pageLocation = Reflect.get(globalThis, "location");
|
|
283
|
-
return typeof pageLocation === "object" && pageLocation !== null && "search" in pageLocation && typeof pageLocation.search === "string" && new URLSearchParams(pageLocation.search).has("fixture");
|
|
284
|
-
}
|
|
285
272
|
function parseFileUploadResult(body) {
|
|
286
273
|
const value = JSON.parse(body);
|
|
287
274
|
if (!isRecord(value) || typeof value.ok !== "boolean") throw new TypeError("file upload transport returned an invalid result");
|
|
@@ -8,7 +8,22 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react = require("react");
|
|
9
9
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
10
|
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
11
|
-
//#region
|
|
11
|
+
//#region lib/types/client/bootstrap.js
|
|
12
|
+
/** Locale initialization supplied by a native shell before its Client tree mounts. */
|
|
13
|
+
/**
|
|
14
|
+
* Validate initialization data returned over the preload IPC bridge.
|
|
15
|
+
* @param value - untrusted IPC response.
|
|
16
|
+
* @returns language initialization with no persistence side effects.
|
|
17
|
+
*/
|
|
18
|
+
function parseLocaleBootstrap(value) {
|
|
19
|
+
if (typeof value !== "object" || value === null || !("languages" in value) || !Array.isArray(value.languages) || !value.languages.every((language) => typeof language === "string") || !("preference" in value) || value.preference !== null && typeof value.preference !== "string") throw new TypeError("locale: invalid native initialization data");
|
|
20
|
+
return {
|
|
21
|
+
languages: value.languages,
|
|
22
|
+
preference: value.preference
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../../../vendor/cosmokit/lib/index.js
|
|
12
27
|
/** Return true when a value is `null` or `undefined`. */
|
|
13
28
|
function isNullable(value) {
|
|
14
29
|
return value === null || value === void 0;
|
|
@@ -32,8 +47,43 @@ window.__ModuleLoader__.load({
|
|
|
32
47
|
for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
|
|
33
48
|
return result;
|
|
34
49
|
}
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
51
|
+
const write = Symbol.for("cosmokit.volatile.write");
|
|
52
|
+
function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
53
|
+
if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
|
|
54
|
+
if (value === null || typeof value !== "object") return value;
|
|
55
|
+
if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
|
|
56
|
+
ancestors.add(value);
|
|
57
|
+
try {
|
|
58
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
|
|
59
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
|
|
60
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
|
|
61
|
+
} finally {
|
|
62
|
+
ancestors.delete(value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a detached reference containing an immutable copy of the supplied data.
|
|
67
|
+
* @param value - validated config data; class instances and functions are unsupported.
|
|
68
|
+
* @returns a reference whose value is updated only by its owning runtime.
|
|
69
|
+
*/
|
|
70
|
+
function createVolatile(value) {
|
|
71
|
+
let current = snapshot(value);
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
get: () => current,
|
|
74
|
+
[write]: (value) => {
|
|
75
|
+
current = value;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Identify references across ESM/CJS copies of the shared library.
|
|
81
|
+
* @param value - a parsed config value.
|
|
82
|
+
* @returns whether the value implements the shared reference protocol.
|
|
83
|
+
*/
|
|
84
|
+
function isVolatile(value) {
|
|
85
|
+
return typeof value === "object" && value !== null && write in value;
|
|
86
|
+
}
|
|
37
87
|
/** Test values using `instanceof` with a `toStringTag` fallback. */
|
|
38
88
|
function is(type, value) {
|
|
39
89
|
if (arguments.length === 1) return (value) => is(type, value);
|
|
@@ -45,15 +95,16 @@ window.__ModuleLoader__.load({
|
|
|
45
95
|
function isArrayBufferSource(value) {
|
|
46
96
|
return isArrayBufferLike(value) || ArrayBuffer.isView(value);
|
|
47
97
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
98
|
+
/** Binary source detection and base64/hex conversion helpers. */
|
|
99
|
+
var Binary;
|
|
100
|
+
(function(Binary) {
|
|
101
|
+
Binary.is = isArrayBufferLike;
|
|
102
|
+
Binary.isSource = isArrayBufferSource;
|
|
52
103
|
function fromSource(source) {
|
|
53
104
|
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
54
105
|
else return source;
|
|
55
106
|
}
|
|
56
|
-
|
|
107
|
+
Binary.fromSource = fromSource;
|
|
57
108
|
function toBase64(source) {
|
|
58
109
|
source = fromSource(source);
|
|
59
110
|
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
|
|
@@ -62,18 +113,18 @@ window.__ModuleLoader__.load({
|
|
|
62
113
|
for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
|
|
63
114
|
return btoa(binary);
|
|
64
115
|
}
|
|
65
|
-
|
|
116
|
+
Binary.toBase64 = toBase64;
|
|
66
117
|
function fromBase64(source) {
|
|
67
118
|
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
|
|
68
119
|
return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
|
|
69
120
|
}
|
|
70
|
-
|
|
121
|
+
Binary.fromBase64 = fromBase64;
|
|
71
122
|
function toHex(source) {
|
|
72
123
|
source = fromSource(source);
|
|
73
124
|
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
|
|
74
125
|
return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
75
126
|
}
|
|
76
|
-
|
|
127
|
+
Binary.toHex = toHex;
|
|
77
128
|
function fromHex(source) {
|
|
78
129
|
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
|
|
79
130
|
const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
|
|
@@ -81,7 +132,7 @@ window.__ModuleLoader__.load({
|
|
|
81
132
|
for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
|
|
82
133
|
return Uint8Array.from(buffer).buffer;
|
|
83
134
|
}
|
|
84
|
-
|
|
135
|
+
Binary.fromHex = fromHex;
|
|
85
136
|
})(Binary || (Binary = {}));
|
|
86
137
|
Binary.fromBase64;
|
|
87
138
|
Binary.toBase64;
|
|
@@ -113,58 +164,78 @@ window.__ModuleLoader__.load({
|
|
|
113
164
|
}
|
|
114
165
|
return result;
|
|
115
166
|
}
|
|
116
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Compare values recursively, treating two volatile references as equal regardless of value.
|
|
169
|
+
* Strict comparison distinguishes null/undefined, treats opaque objects by identity,
|
|
170
|
+
* compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
|
|
171
|
+
* @param a - first value.
|
|
172
|
+
* @param b - second value.
|
|
173
|
+
* @param strict - whether to require strict data equality outside volatile references.
|
|
174
|
+
* @returns whether the values compare equal.
|
|
175
|
+
*/
|
|
117
176
|
function deepEqual(a, b, strict) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
177
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
178
|
+
function compare(a, b) {
|
|
179
|
+
if (a === b) return true;
|
|
180
|
+
if (isVolatile(a) || isVolatile(b)) return isVolatile(a) && isVolatile(b);
|
|
181
|
+
if (!strict && isNullable(a) && isNullable(b)) return true;
|
|
182
|
+
if (typeof a !== typeof b || typeof a !== "object" || !a || !b) return false;
|
|
183
|
+
if (ancestors.has(a)) return false;
|
|
184
|
+
function check(test, then) {
|
|
185
|
+
return test(a) ? test(b) ? then(a, b) : false : test(b) ? false : void 0;
|
|
186
|
+
}
|
|
187
|
+
ancestors.add(a);
|
|
188
|
+
try {
|
|
189
|
+
return check(Array.isArray, (a, b) => {
|
|
190
|
+
if (a.length !== b.length) return false;
|
|
191
|
+
for (let index = 0; index < a.length; index++) if (!compare(a[index], b[index])) return false;
|
|
192
|
+
return true;
|
|
193
|
+
}) ?? check(is("Date"), (a, b) => a.valueOf() === b.valueOf()) ?? check(is("URL"), (a, b) => a.href === b.href) ?? check(is("RegExp"), (a, b) => a.source === b.source && a.flags === b.flags) ?? check(isArrayBufferLike, (a, b) => {
|
|
194
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
195
|
+
const viewA = new Uint8Array(a);
|
|
196
|
+
const viewB = new Uint8Array(b);
|
|
197
|
+
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
198
|
+
return true;
|
|
199
|
+
}) ?? ((!strict || [a, b].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
|
|
200
|
+
...a,
|
|
201
|
+
...b
|
|
202
|
+
}).every((key) => compare(a[key], b[key])));
|
|
203
|
+
} finally {
|
|
204
|
+
ancestors.delete(a);
|
|
205
|
+
}
|
|
125
206
|
}
|
|
126
|
-
return
|
|
127
|
-
if (a.byteLength !== b.byteLength) return false;
|
|
128
|
-
const viewA = new Uint8Array(a);
|
|
129
|
-
const viewB = new Uint8Array(b);
|
|
130
|
-
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
131
|
-
return true;
|
|
132
|
-
}) ?? Object.keys({
|
|
133
|
-
...a,
|
|
134
|
-
...b
|
|
135
|
-
}).every((key) => deepEqual(a[key], b[key], strict));
|
|
207
|
+
return compare(a, b);
|
|
136
208
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const week = _Time.week = day * 7;
|
|
209
|
+
/** Time constants plus parsing and formatting helpers. */
|
|
210
|
+
var Time;
|
|
211
|
+
(function(Time) {
|
|
212
|
+
Time.millisecond = 1;
|
|
213
|
+
Time.second = 1e3;
|
|
214
|
+
Time.minute = Time.second * 60;
|
|
215
|
+
Time.hour = Time.minute * 60;
|
|
216
|
+
Time.day = Time.hour * 24;
|
|
217
|
+
Time.week = Time.day * 7;
|
|
147
218
|
let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
148
219
|
function setTimezoneOffset(offset) {
|
|
149
220
|
timezoneOffset = offset;
|
|
150
221
|
}
|
|
151
|
-
|
|
222
|
+
Time.setTimezoneOffset = setTimezoneOffset;
|
|
152
223
|
function getTimezoneOffset() {
|
|
153
224
|
return timezoneOffset;
|
|
154
225
|
}
|
|
155
|
-
|
|
226
|
+
Time.getTimezoneOffset = getTimezoneOffset;
|
|
156
227
|
function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
|
|
157
228
|
if (typeof date === "number") date = new Date(date);
|
|
158
229
|
if (offset === void 0) offset = timezoneOffset;
|
|
159
|
-
return Math.floor((date.valueOf() / minute - offset) / 1440);
|
|
230
|
+
return Math.floor((date.valueOf() / Time.minute - offset) / 1440);
|
|
160
231
|
}
|
|
161
|
-
|
|
232
|
+
Time.getDateNumber = getDateNumber;
|
|
162
233
|
function fromDateNumber(value, offset) {
|
|
163
|
-
const date = new Date(value * day);
|
|
234
|
+
const date = new Date(value * Time.day);
|
|
164
235
|
if (offset === void 0) offset = timezoneOffset;
|
|
165
|
-
return new Date(+date + offset * minute);
|
|
236
|
+
return new Date(+date + offset * Time.minute);
|
|
166
237
|
}
|
|
167
|
-
|
|
238
|
+
Time.fromDateNumber = fromDateNumber;
|
|
168
239
|
const numeric = /\d+(?:\.\d+)?/.source;
|
|
169
240
|
const timeRegExp = new RegExp(`^${[
|
|
170
241
|
"w(?:eek(?:s)?)?",
|
|
@@ -176,9 +247,9 @@ window.__ModuleLoader__.load({
|
|
|
176
247
|
function parseTime(source) {
|
|
177
248
|
const capture = timeRegExp.exec(source);
|
|
178
249
|
if (!capture) return 0;
|
|
179
|
-
return (parseFloat(capture[1]) * week || 0) + (parseFloat(capture[2]) * day || 0) + (parseFloat(capture[3]) * hour || 0) + (parseFloat(capture[4]) * minute || 0) + (parseFloat(capture[5]) * second || 0);
|
|
250
|
+
return (parseFloat(capture[1]) * Time.week || 0) + (parseFloat(capture[2]) * Time.day || 0) + (parseFloat(capture[3]) * Time.hour || 0) + (parseFloat(capture[4]) * Time.minute || 0) + (parseFloat(capture[5]) * Time.second || 0);
|
|
180
251
|
}
|
|
181
|
-
|
|
252
|
+
Time.parseTime = parseTime;
|
|
182
253
|
function parseDate(date) {
|
|
183
254
|
const parsed = parseTime(date);
|
|
184
255
|
if (parsed) date = Date.now() + parsed;
|
|
@@ -186,27 +257,27 @@ window.__ModuleLoader__.load({
|
|
|
186
257
|
else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
|
|
187
258
|
return date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
188
259
|
}
|
|
189
|
-
|
|
260
|
+
Time.parseDate = parseDate;
|
|
190
261
|
function format(ms) {
|
|
191
262
|
const abs = Math.abs(ms);
|
|
192
|
-
if (abs >= day - hour / 2) return Math.round(ms / day) + "d";
|
|
193
|
-
else if (abs >= hour - minute / 2) return Math.round(ms / hour) + "h";
|
|
194
|
-
else if (abs >= minute - second / 2) return Math.round(ms / minute) + "m";
|
|
195
|
-
else if (abs >= second) return Math.round(ms / second) + "s";
|
|
263
|
+
if (abs >= Time.day - Time.hour / 2) return Math.round(ms / Time.day) + "d";
|
|
264
|
+
else if (abs >= Time.hour - Time.minute / 2) return Math.round(ms / Time.hour) + "h";
|
|
265
|
+
else if (abs >= Time.minute - Time.second / 2) return Math.round(ms / Time.minute) + "m";
|
|
266
|
+
else if (abs >= Time.second) return Math.round(ms / Time.second) + "s";
|
|
196
267
|
return ms + "ms";
|
|
197
268
|
}
|
|
198
|
-
|
|
269
|
+
Time.format = format;
|
|
199
270
|
function toDigits(source, length = 2) {
|
|
200
271
|
return source.toString().padStart(length, "0");
|
|
201
272
|
}
|
|
202
|
-
|
|
273
|
+
Time.toDigits = toDigits;
|
|
203
274
|
function template(template, time = /* @__PURE__ */ new Date()) {
|
|
204
275
|
return template.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
|
|
205
276
|
}
|
|
206
|
-
|
|
277
|
+
Time.template = template;
|
|
207
278
|
})(Time || (Time = {}));
|
|
208
279
|
//#endregion
|
|
209
|
-
//#region ../../../vendor/schemastery/
|
|
280
|
+
//#region ../../../vendor/schemastery/lib/index.mjs
|
|
210
281
|
const kSchema = Symbol.for("schemastery");
|
|
211
282
|
const kValidationError = Symbol.for("ValidationError");
|
|
212
283
|
globalThis.__schemastery_index__ ??= 0;
|
|
@@ -382,6 +453,7 @@ window.__ModuleLoader__.load({
|
|
|
382
453
|
return schema;
|
|
383
454
|
};
|
|
384
455
|
Schema.prototype.simplify = function simplify(value) {
|
|
456
|
+
if (isVolatile(value)) value = value.get();
|
|
385
457
|
if (deepEqual(value, this.meta.default, this.type === "dict")) return null;
|
|
386
458
|
if (isNullable(value)) return value;
|
|
387
459
|
if (this.type === "object" || this.type === "dict") {
|
|
@@ -438,12 +510,49 @@ window.__ModuleLoader__.load({
|
|
|
438
510
|
};
|
|
439
511
|
return schema;
|
|
440
512
|
} });
|
|
513
|
+
Schema.prototype.volatile = function volatile() {
|
|
514
|
+
if (this.meta.volatile) throw new TypeError("volatile schema is already wrapped");
|
|
515
|
+
return this.extra("volatile", true);
|
|
516
|
+
};
|
|
441
517
|
const resolvers = {};
|
|
518
|
+
const checkedVolatile = Symbol("checked-volatile-schema");
|
|
519
|
+
function validateVolatileSchema(schema, path = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
|
|
520
|
+
const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
|
|
521
|
+
if (states.has(blocked)) return;
|
|
522
|
+
states.add(blocked);
|
|
523
|
+
seen.set(schema, states);
|
|
524
|
+
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path });
|
|
525
|
+
const nested = blocked || !!schema.meta?.volatile;
|
|
526
|
+
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path, key], nested, seen);
|
|
527
|
+
if (schema.sKey) validateVolatileSchema(schema.sKey, [...path, "<key>"], true, seen);
|
|
528
|
+
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path, "*"], true, seen);
|
|
529
|
+
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path, String(index)], true, seen);
|
|
530
|
+
}
|
|
442
531
|
Schema.extend = function extend(type, resolve) {
|
|
443
532
|
resolvers[type] = resolve;
|
|
444
533
|
};
|
|
445
534
|
Schema.resolve = function resolve(data, schema, options = {}, strict = false) {
|
|
446
535
|
if (!schema) return [data];
|
|
536
|
+
if (!options[checkedVolatile]) {
|
|
537
|
+
validateVolatileSchema(schema, options.path);
|
|
538
|
+
options = {
|
|
539
|
+
...options,
|
|
540
|
+
[checkedVolatile]: true
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
if (schema.meta?.volatile) {
|
|
544
|
+
const inner = Schema(schema);
|
|
545
|
+
inner.meta = {
|
|
546
|
+
...schema.meta,
|
|
547
|
+
volatile: false
|
|
548
|
+
};
|
|
549
|
+
const [value, adapted] = Schema.resolve(data, inner, options, strict);
|
|
550
|
+
try {
|
|
551
|
+
return [createVolatile(value), adapted];
|
|
552
|
+
} catch (error) {
|
|
553
|
+
throw new ValidationError(error instanceof Error ? error.message : String(error), options);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
447
556
|
if (options.ignore?.(data, schema)) return [data];
|
|
448
557
|
if (isNullable(data) && schema.type !== "lazy") {
|
|
449
558
|
if (schema.meta.required) throw new ValidationError(`missing required value`, options);
|
|
@@ -546,6 +655,7 @@ window.__ModuleLoader__.load({
|
|
|
546
655
|
...schema.meta,
|
|
547
656
|
...schema.inner.meta
|
|
548
657
|
};
|
|
658
|
+
validateVolatileSchema(schema.inner, options.path, true);
|
|
549
659
|
}
|
|
550
660
|
return Schema.resolve(data, schema.inner, options, strict);
|
|
551
661
|
});
|
|
@@ -645,7 +755,7 @@ window.__ModuleLoader__.load({
|
|
|
645
755
|
} catch (e) {
|
|
646
756
|
if (!options?.autofix) throw e;
|
|
647
757
|
delete data[key];
|
|
648
|
-
return schema.meta.default;
|
|
758
|
+
return schema.meta.volatile ? createVolatile(schema.meta.default) : schema.meta.default;
|
|
649
759
|
}
|
|
650
760
|
}
|
|
651
761
|
Schema.extend("array", (data, { inner, meta }, options) => {
|
|
@@ -810,7 +920,9 @@ window.__ModuleLoader__.load({
|
|
|
810
920
|
const LOCALE_ID_PATTERN = /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/u;
|
|
811
921
|
/** Locale identifiers shipped by the browser client. */
|
|
812
922
|
const LOCALE_IDS = ["zh", "en"];
|
|
813
|
-
|
|
923
|
+
/** Durable locale schema; also the wire envelope the browser scope validates against. */
|
|
924
|
+
const LocaleSettingsFields = { [LOCALE_PREFERENCE_FIELD]: Schema.string().pattern(LOCALE_ID_PATTERN).required(false) };
|
|
925
|
+
Schema.object(LocaleSettingsFields);
|
|
814
926
|
//#endregion
|
|
815
927
|
//#region lib/types/locales/zh.js
|
|
816
928
|
/** zh base dictionary for the common namespace: cross-feature standard words. */
|
|
@@ -820,6 +932,9 @@ window.__ModuleLoader__.load({
|
|
|
820
932
|
"close": "关闭",
|
|
821
933
|
"copy": "复制",
|
|
822
934
|
"copied": "复制成功",
|
|
935
|
+
"codeBlock.title": "代码块",
|
|
936
|
+
"codeBlock.wrap": "自动换行",
|
|
937
|
+
"codeBlock.unwrap": "取消自动换行",
|
|
823
938
|
"copy.failed": "复制失败",
|
|
824
939
|
"copy.value": "复制值",
|
|
825
940
|
"copy.json": "复制 JSON",
|
|
@@ -844,11 +959,10 @@ window.__ModuleLoader__.load({
|
|
|
844
959
|
"expand": "展开",
|
|
845
960
|
"back": "返回",
|
|
846
961
|
"brand.localBuild": "DSH 本地构建",
|
|
962
|
+
"workspace.defaultName": "默认工作区",
|
|
847
963
|
"unknown": "未知",
|
|
848
964
|
"none": "无",
|
|
849
965
|
"truncated": "已截断",
|
|
850
|
-
"json.collapseNode": "收起 JSON 节点",
|
|
851
|
-
"json.expandNode": "展开 JSON 节点",
|
|
852
966
|
"json.label": "JSON",
|
|
853
967
|
"markdown.footnotes": "脚注",
|
|
854
968
|
"markdown.truncatedCharacters": "… 已截断,共 {total} 字符",
|
|
@@ -864,6 +978,9 @@ window.__ModuleLoader__.load({
|
|
|
864
978
|
"close": "Close",
|
|
865
979
|
"copy": "Copy",
|
|
866
980
|
"copied": "Copied",
|
|
981
|
+
"codeBlock.title": "Code block",
|
|
982
|
+
"codeBlock.wrap": "Wrap lines",
|
|
983
|
+
"codeBlock.unwrap": "Do not wrap lines",
|
|
867
984
|
"copy.failed": "Copy failed",
|
|
868
985
|
"copy.value": "Copy value",
|
|
869
986
|
"copy.json": "Copy JSON",
|
|
@@ -888,11 +1005,10 @@ window.__ModuleLoader__.load({
|
|
|
888
1005
|
"expand": "Expand",
|
|
889
1006
|
"back": "Back",
|
|
890
1007
|
"brand.localBuild": "DSH Local Build",
|
|
1008
|
+
"workspace.defaultName": "Default workspace",
|
|
891
1009
|
"unknown": "Unknown",
|
|
892
1010
|
"none": "None",
|
|
893
1011
|
"truncated": "Truncated",
|
|
894
|
-
"json.collapseNode": "Collapse JSON node",
|
|
895
|
-
"json.expandNode": "Expand JSON node",
|
|
896
1012
|
"json.label": "JSON",
|
|
897
1013
|
"markdown.footnotes": "Footnotes",
|
|
898
1014
|
"markdown.truncatedCharacters": "… truncated at {total} characters",
|
|
@@ -908,7 +1024,7 @@ window.__ModuleLoader__.load({
|
|
|
908
1024
|
const en = { "language.title": "Language" };
|
|
909
1025
|
//#endregion
|
|
910
1026
|
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/locale/src/client/LanguageRow.module.css.mjs
|
|
911
|
-
const css = ".hVGvvW_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.hVGvvW_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.hVGvvW_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.hVGvvW_selector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;
|
|
1027
|
+
const css = ".hVGvvW_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.hVGvvW_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.hVGvvW_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.hVGvvW_selector{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.hVGvvW_selector:hover{background:var(--dsw-alias-interactive-bg-hover)}.hVGvvW_chevron{flex:none}";
|
|
912
1028
|
const tagId = "@deepseek-ai/dsh-client-locale/LanguageRow.module.css";
|
|
913
1029
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
914
1030
|
const tag = document.createElement("style");
|
|
@@ -974,7 +1090,7 @@ window.__ModuleLoader__.load({
|
|
|
974
1090
|
onClick: () => {
|
|
975
1091
|
setOpen((v) => !v);
|
|
976
1092
|
},
|
|
977
|
-
children: [activeLabel, (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.
|
|
1093
|
+
children: [activeLabel, (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { className: LanguageRow_module_css_default.chevron })]
|
|
978
1094
|
})
|
|
979
1095
|
})]
|
|
980
1096
|
});
|
|
@@ -1055,7 +1171,8 @@ window.__ModuleLoader__.load({
|
|
|
1055
1171
|
*/
|
|
1056
1172
|
function syncDocumentLanguage(snapshot) {
|
|
1057
1173
|
if (typeof document === "undefined") return;
|
|
1058
|
-
|
|
1174
|
+
const language = snapshot.active === "zh" ? "zh-CN" : snapshot.active;
|
|
1175
|
+
if (document.documentElement.lang !== language) document.documentElement.lang = language;
|
|
1059
1176
|
}
|
|
1060
1177
|
/**
|
|
1061
1178
|
* Dictionary registry plus locale preference. Lookup walks the active
|
|
@@ -1068,6 +1185,7 @@ window.__ModuleLoader__.load({
|
|
|
1068
1185
|
* `ctx.slots.installLocale`.
|
|
1069
1186
|
*/
|
|
1070
1187
|
var LocaleRuntime = class {
|
|
1188
|
+
bootstrap;
|
|
1071
1189
|
dicts = /* @__PURE__ */ new Map();
|
|
1072
1190
|
bound = /* @__PURE__ */ new Map();
|
|
1073
1191
|
catalog = /* @__PURE__ */ new Map();
|
|
@@ -1085,15 +1203,18 @@ window.__ModuleLoader__.load({
|
|
|
1085
1203
|
* listener is released through ctx.effect on dispose).
|
|
1086
1204
|
* @param host - durable preference scope owned by the providing plugin;
|
|
1087
1205
|
* absent compositions (standalone dictionary registries) stay process-local.
|
|
1206
|
+
* @param bootstrap - native initialization; absent in ordinary browsers.
|
|
1088
1207
|
*/
|
|
1089
|
-
constructor(ctx, host) {
|
|
1208
|
+
constructor(ctx, host, bootstrap) {
|
|
1209
|
+
this.bootstrap = bootstrap;
|
|
1090
1210
|
this.ctx = ctx;
|
|
1091
1211
|
this.host = host;
|
|
1092
1212
|
for (const locale of BUILT_IN_LOCALES) this.catalog.set(localeKey(locale.id), locale);
|
|
1093
1213
|
const locales = this.localeList();
|
|
1094
|
-
this.provisional = resolveInitialLocale(locales);
|
|
1214
|
+
this.provisional = resolveInitialLocale(locales, bootstrap?.languages);
|
|
1215
|
+
this.preference = bootstrap?.preference ?? void 0;
|
|
1095
1216
|
this.snapshot = Object.freeze({
|
|
1096
|
-
active: this.
|
|
1217
|
+
active: this.resolveActive(),
|
|
1097
1218
|
locales,
|
|
1098
1219
|
revision: 0
|
|
1099
1220
|
});
|
|
@@ -1112,6 +1233,16 @@ window.__ModuleLoader__.load({
|
|
|
1112
1233
|
return this.snapshot;
|
|
1113
1234
|
}
|
|
1114
1235
|
/**
|
|
1236
|
+
* Resolve package text through the active language's declared fallback chain.
|
|
1237
|
+
* Plain strings stay verbatim; maps do not consult registered dictionaries.
|
|
1238
|
+
* @param text - package text whose locale keys are lowercase and include English.
|
|
1239
|
+
* @returns the first available translation, including an empty string.
|
|
1240
|
+
*/
|
|
1241
|
+
resolveText(text) {
|
|
1242
|
+
if (typeof text === "string") return text;
|
|
1243
|
+
return this.fallbackChain(this.snapshot.active).reduceRight((resolved, locale) => text[localeKey(locale)] ?? resolved, text.en);
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1115
1246
|
* LocaleFace getSnapshot: the current snapshot (carries `revision`; stable
|
|
1116
1247
|
* reference between changes, uSES-safe).
|
|
1117
1248
|
* @returns the current snapshot.
|
|
@@ -1204,7 +1335,7 @@ window.__ModuleLoader__.load({
|
|
|
1204
1335
|
publishCatalog() {
|
|
1205
1336
|
this.fallbackChains.clear();
|
|
1206
1337
|
const locales = this.localeList();
|
|
1207
|
-
this.provisional = resolveInitialLocale(locales);
|
|
1338
|
+
this.provisional = resolveInitialLocale(locales, this.bootstrap?.languages);
|
|
1208
1339
|
const active = this.resolveActive();
|
|
1209
1340
|
this.publish(active, active !== this.snapshot.active, locales);
|
|
1210
1341
|
}
|
|
@@ -1327,8 +1458,8 @@ window.__ModuleLoader__.load({
|
|
|
1327
1458
|
* The browser's own language wins over {@link FALLBACK_LOCALE}; an explicit
|
|
1328
1459
|
* Host preference may replace this provisional value after plugin activation.
|
|
1329
1460
|
*/
|
|
1330
|
-
function resolveInitialLocale(locales) {
|
|
1331
|
-
return detectBrowserLocale(locales) ?? "en";
|
|
1461
|
+
function resolveInitialLocale(locales, languages) {
|
|
1462
|
+
return detectBrowserLocale(locales, languages) ?? "en";
|
|
1332
1463
|
}
|
|
1333
1464
|
/**
|
|
1334
1465
|
* The first registered locale the browser asks for. Each browser tag first
|
|
@@ -1339,12 +1470,15 @@ window.__ModuleLoader__.load({
|
|
|
1339
1470
|
* locale for non-browser runs. `navigator.language` trails the ordered
|
|
1340
1471
|
* `languages` list and covers hosts exposing only the single tag.
|
|
1341
1472
|
* @param locales - definitions currently available to the browser.
|
|
1473
|
+
* @param languages - native system language order, when supplied by a shell.
|
|
1342
1474
|
* @returns the first matching locale id, or undefined.
|
|
1343
1475
|
*/
|
|
1344
|
-
function detectBrowserLocale(locales) {
|
|
1345
|
-
if (
|
|
1346
|
-
|
|
1347
|
-
|
|
1476
|
+
function detectBrowserLocale(locales, languages) {
|
|
1477
|
+
if (languages === void 0) {
|
|
1478
|
+
if (typeof window === "undefined") return void 0;
|
|
1479
|
+
languages = [...navigator.languages ?? [], navigator.language];
|
|
1480
|
+
}
|
|
1481
|
+
for (const tag of languages) {
|
|
1348
1482
|
const requested = localeKey(tag);
|
|
1349
1483
|
const exact = locales.find((locale) => localeKey(locale.id) === requested);
|
|
1350
1484
|
if (exact !== void 0) return exact.id;
|
|
@@ -1357,16 +1491,30 @@ window.__ModuleLoader__.load({
|
|
|
1357
1491
|
const inject = [
|
|
1358
1492
|
"slots",
|
|
1359
1493
|
"remote",
|
|
1360
|
-
"
|
|
1494
|
+
"configForms"
|
|
1361
1495
|
];
|
|
1362
1496
|
/**
|
|
1363
1497
|
* Client plugin body: provide the locale service with base dictionaries and
|
|
1364
1498
|
* register the feature-owned Language preference row into the General
|
|
1365
1499
|
* section's item slot (a feature owns its settings surface).
|
|
1366
1500
|
* @param ctx - client cordis context.
|
|
1501
|
+
* @returns resolves after native language initialization and plugin registration.
|
|
1367
1502
|
*/
|
|
1368
|
-
function apply(ctx) {
|
|
1369
|
-
const
|
|
1503
|
+
async function apply(ctx) {
|
|
1504
|
+
const bridge = globalThis.__DSH_LOCALE__;
|
|
1505
|
+
let bootstrap;
|
|
1506
|
+
if (bridge !== void 0) {
|
|
1507
|
+
let value;
|
|
1508
|
+
try {
|
|
1509
|
+
value = await bridge.read();
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
if (ctx.fiber.uid === null) return;
|
|
1512
|
+
throw error;
|
|
1513
|
+
}
|
|
1514
|
+
if (ctx.fiber.uid === null) return;
|
|
1515
|
+
bootstrap = parseLocaleBootstrap(value);
|
|
1516
|
+
}
|
|
1517
|
+
const locale = new LocaleRuntime(ctx, ctx.configForms.get(LOCALE_SETTINGS_NAMESPACE), bootstrap);
|
|
1370
1518
|
locale.register(COMMON_NS, {
|
|
1371
1519
|
zh: zh$1,
|
|
1372
1520
|
en: en$1
|
|
@@ -1376,6 +1524,12 @@ window.__ModuleLoader__.load({
|
|
|
1376
1524
|
en
|
|
1377
1525
|
});
|
|
1378
1526
|
ctx.provide("locale", locale);
|
|
1527
|
+
if (bridge !== void 0) {
|
|
1528
|
+
ctx.on("locale/change", (snapshot) => {
|
|
1529
|
+
bridge.onChange(snapshot.active);
|
|
1530
|
+
});
|
|
1531
|
+
bridge.onChange(locale.getSnapshot().active);
|
|
1532
|
+
}
|
|
1379
1533
|
ctx.slots.installLocale(locale);
|
|
1380
1534
|
const store = createLanguageRowStore();
|
|
1381
1535
|
let bound;
|