dsh-inkmap 0.3.3 → 0.3.5
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/client.js +13 -2
- package/host.js +160 -40
- package/package.json +1 -1
- package/web/assets/{abnfDiagram-S7VZAUFO-DCzUGFRF.js → abnfDiagram-S7VZAUFO-DrBW4zqH.js} +1 -1
- package/web/assets/{architectureDiagram-YGSQEFNW-DCDp7B_s.js → architectureDiagram-YGSQEFNW-4RpnlRN0.js} +1 -1
- package/web/assets/{blockDiagram-APKKGZFW-Dp98xzjW.js → blockDiagram-APKKGZFW-ComZi7YM.js} +1 -1
- package/web/assets/{c4Diagram-KJ2TOQU5-CxPOkxbV.js → c4Diagram-KJ2TOQU5-DZN7GFIA.js} +1 -1
- package/web/assets/{chunk-2Q5K7J3B-BMceFX8f.js → chunk-2Q5K7J3B-Bekhmc45.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-C9Qw2XEx.js → chunk-5VM5RSS4-Bn7d1ail.js} +1 -1
- package/web/assets/{chunk-HFQBQIA3-CnMYAsuk.js → chunk-HFQBQIA3-I1fDLjcG.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-BSqiGtEr.js → chunk-JWPE2WC7-DKPUknl1.js} +1 -1
- package/web/assets/{chunk-KQLB2F66-Crtz58vF.js → chunk-KQLB2F66-Dc9hSZPH.js} +2 -2
- package/web/assets/{chunk-KS47KZWR-Dv5wN_u7.js → chunk-KS47KZWR-BSi29bPZ.js} +1 -1
- package/web/assets/{chunk-OY52VR5R-C8pYN-C4.js → chunk-OY52VR5R-YW_Djx_D.js} +1 -1
- package/web/assets/{chunk-TU62E6Q5-CFoEpZGl.js → chunk-TU62E6Q5-CAuvwT2i.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-D4qfiWHi.js → chunk-XXDRQBXY-BZGRjo08.js} +1 -1
- package/web/assets/{classDiagram-v2-L25IHNXF-BpUzliMF.js → classDiagram-v2-L25IHNXF-0TyBb_pv.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-O-0rZBHt.js → cose-bilkent-JH36ORCC-CcTqfrZk.js} +1 -1
- package/web/assets/{cynefin-EF2NZ3EQ-DDFv76G2.js → cynefin-EF2NZ3EQ-D-58ofeg.js} +1 -1
- package/web/assets/{cynefinDiagram-L36ESFBY-Bqq6kFZK.js → cynefinDiagram-L36ESFBY-Cwzf_0sG.js} +1 -1
- package/web/assets/{dagre-SPEB5RXH-DMnAnp6O.js → dagre-SPEB5RXH-Dfrad5zU.js} +1 -1
- package/web/assets/{diagram-3B7GL73J-CGrQKQaU.js → diagram-3B7GL73J-TLJFMh7T.js} +1 -1
- package/web/assets/{diagram-DNEMPZML-Bkae5AE1.js → diagram-DNEMPZML-BD-e0XcL.js} +1 -1
- package/web/assets/{diagram-L3MUGCDN-BGWxbw_y.js → diagram-L3MUGCDN-Dv3914hI.js} +1 -1
- package/web/assets/{diagram-LA4NIPWU-BtnLKThN.js → diagram-LA4NIPWU-Dy_k7atN.js} +1 -1
- package/web/assets/{diagram-MHCOC4E2-Cvp57UMh.js → diagram-MHCOC4E2-Ct1d9mjt.js} +1 -1
- package/web/assets/{diagram-XPFHEONP-Cvho1yP_.js → diagram-XPFHEONP-BVj8qfpm.js} +1 -1
- package/web/assets/{ebnfDiagram-UZSYDL2S-CvU-EhVB.js → ebnfDiagram-UZSYDL2S-CtDLif8p.js} +1 -1
- package/web/assets/{elk-XV6XMXQE-DrGf1_tu.js → elk-XV6XMXQE-esY_zUO9.js} +1 -1
- package/web/assets/{erDiagram-EYBAPDEH-BnO8m7Bv.js → erDiagram-EYBAPDEH-BhU-QeBo.js} +1 -1
- package/web/assets/{flowDiagram-MALGAFMO-D87SYE69.js → flowDiagram-MALGAFMO-DaeyL7Oo.js} +1 -1
- package/web/assets/{ganttDiagram-23REXITY-BBYnxsjP.js → ganttDiagram-23REXITY-CyZIKg4-.js} +1 -1
- package/web/assets/{gitGraphDiagram-STJD7YCW-DqsbpPW5.js → gitGraphDiagram-STJD7YCW-RuvoysGE.js} +1 -1
- package/web/assets/{index-Dzbmi6PZ.css → index-BZG1D6oJ.css} +1 -1
- package/web/assets/index-CL1mygUK.js +648 -0
- package/web/assets/{infoDiagram-KBXO4MBG-Dxx-5YUy.js → infoDiagram-KBXO4MBG-FYckP-GR.js} +1 -1
- package/web/assets/{ishikawaDiagram-M35NCXHK-5sFCM32b.js → ishikawaDiagram-M35NCXHK-BJ2ECR8m.js} +1 -1
- package/web/assets/{journeyDiagram-OPLOXDXO-B7LH-gFu.js → journeyDiagram-OPLOXDXO-CwEsqAcw.js} +1 -1
- package/web/assets/{kanban-definition-BZKZHSQY-BMVXBGIk.js → kanban-definition-BZKZHSQY-KdpXmjwS.js} +1 -1
- package/web/assets/{mermaid.core-CD6VFwtI.js → mermaid.core-BA0ZnaVT.js} +4 -4
- package/web/assets/{mindmap-definition-I2QAS2VK-gQHH0qKH.js → mindmap-definition-I2QAS2VK-B56-W6EZ.js} +1 -1
- package/web/assets/{pegDiagram-FD4XPPHP-BuGYbf1-.js → pegDiagram-FD4XPPHP-C2pErj_o.js} +1 -1
- package/web/assets/{pieDiagram-J4AKIIQI-C5JF9vSK.js → pieDiagram-J4AKIIQI-Ch3pN-sc.js} +1 -1
- package/web/assets/{quadrantDiagram-XTYBLID2-DgU9d7wQ.js → quadrantDiagram-XTYBLID2-BkKchXfV.js} +1 -1
- package/web/assets/{railroadDiagram-MRQ6NCDL-44C0bWJw.js → railroadDiagram-MRQ6NCDL-D0nzZjcw.js} +1 -1
- package/web/assets/{requirementDiagram-Y7LWUY3S-CBp6AUBf.js → requirementDiagram-Y7LWUY3S-Cx4R38Ct.js} +1 -1
- package/web/assets/{sankeyDiagram-WGJFYUXA-C1Y-Bxdt.js → sankeyDiagram-WGJFYUXA-Bl4YFoH4.js} +1 -1
- package/web/assets/{sequenceDiagram-5NDRBG5M-BABmlKjV.js → sequenceDiagram-5NDRBG5M-BitjQ1-f.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-DfwsWa78.js → sizeCapture-INFHLROL-CLe0SHId.js} +1 -1
- package/web/assets/{stateDiagram-v2-FJ4FJNEA-BYGt7M38.js → stateDiagram-v2-FJ4FJNEA-DHcT6Szc.js} +1 -1
- package/web/assets/{swimlanes-UMQ2AFYF-Dz5f-g49.js → swimlanes-UMQ2AFYF-B8ILeqek.js} +1 -1
- package/web/assets/swimlanesDiagram-OMPLPG4O-BsX6cLme.js +8 -0
- package/web/assets/{timeline-definition-SEUHKTQE-BJnwE8wH.js → timeline-definition-SEUHKTQE-BSJfLIzK.js} +1 -1
- package/web/assets/{usecaseDiagram-AFA6YXN4-D2RoWXSY.js → usecaseDiagram-AFA6YXN4-DtFbmFlO.js} +1 -1
- package/web/assets/{vennDiagram-NNMJR3RB-DuoZW-lM.js → vennDiagram-NNMJR3RB-DA9eosKB.js} +1 -1
- package/web/assets/{wardleyDiagram-S7YFUSEH-Cug9e2FD.js → wardleyDiagram-S7YFUSEH-BvLf_vHO.js} +1 -1
- package/web/assets/{xychartDiagram-GGNKY7IX-MQVbHA6N.js → xychartDiagram-GGNKY7IX-DiGDuK2u.js} +1 -1
- package/web/index.html +10 -43
- package/web/assets/index-CfSzSt6G.js +0 -648
- package/web/assets/swimlanesDiagram-OMPLPG4O-DVEAjyOD.js +0 -8
package/client.js
CHANGED
|
@@ -65,7 +65,18 @@ function selectedFile(address) {
|
|
|
65
65
|
|
|
66
66
|
// packages/harness/src/client.mjs
|
|
67
67
|
var inject = ["slots", "sidebarRight", "sidebarRightTabs"];
|
|
68
|
-
var zh = () =>
|
|
68
|
+
var zh = () => {
|
|
69
|
+
const docLang = typeof document !== "undefined" ? document.documentElement?.lang || "" : "";
|
|
70
|
+
const navLang = typeof navigator !== "undefined" ? navigator.language || "" : "";
|
|
71
|
+
if (/^zh\b/i.test(docLang || navLang)) return true;
|
|
72
|
+
try {
|
|
73
|
+
const opts = Intl.DateTimeFormat().resolvedOptions();
|
|
74
|
+
if (/^zh\b/i.test(opts.locale || "")) return true;
|
|
75
|
+
if (/^(Asia\/(Shanghai|Chongqing|Chungking|Harbin|Urumqi|Beijing)|PRC)$/i.test(opts.timeZone || "")) return true;
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
69
80
|
var label = () => zh() ? "\u7528 Inkmap \u6253\u5F00" : "Open in Inkmap";
|
|
70
81
|
var desktop = () => location.protocol === "dsh-app:" && location.hostname === "app";
|
|
71
82
|
var actionClass = "inkmap-harness-open";
|
|
@@ -183,7 +194,7 @@ function apply(ctx) {
|
|
|
183
194
|
src: desktop() ? `${view.url}?account-navigation=host` : view.url,
|
|
184
195
|
title: "Inkmap",
|
|
185
196
|
referrerPolicy: "no-referrer",
|
|
186
|
-
sandbox: "allow-scripts allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox",
|
|
197
|
+
sandbox: "allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox",
|
|
187
198
|
style: { display: "block", width: "100%", height: "100%", border: 0 }
|
|
188
199
|
});
|
|
189
200
|
}
|
package/host.js
CHANGED
|
@@ -54,10 +54,60 @@ function sanitizeViewState(raw) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// packages/cli/dist/license.js
|
|
57
|
+
import { execFileSync } from "node:child_process";
|
|
57
58
|
import { link, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
58
59
|
import { randomUUID } from "node:crypto";
|
|
59
60
|
import { homedir } from "node:os";
|
|
60
61
|
import { dirname, join } from "node:path";
|
|
62
|
+
var cachedOsLocale;
|
|
63
|
+
function detectOsLocale() {
|
|
64
|
+
const explicit = (process.env.INKMAP_LOCALE || "").trim();
|
|
65
|
+
if (/^zh\b/i.test(explicit))
|
|
66
|
+
return "zh";
|
|
67
|
+
if (/^en\b/i.test(explicit))
|
|
68
|
+
return "en";
|
|
69
|
+
if (cachedOsLocale)
|
|
70
|
+
return cachedOsLocale;
|
|
71
|
+
let domestic = false;
|
|
72
|
+
try {
|
|
73
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
74
|
+
if (/^(Asia\/(Shanghai|Chongqing|Chungking|Harbin|Urumqi|Beijing)|PRC)$/i.test(tz)) {
|
|
75
|
+
domestic = true;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
if (!domestic) {
|
|
80
|
+
if (process.platform === "darwin") {
|
|
81
|
+
try {
|
|
82
|
+
const out = execFileSync("defaults", ["read", "-g", "AppleLanguages"], {
|
|
83
|
+
encoding: "utf8",
|
|
84
|
+
timeout: 800,
|
|
85
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
86
|
+
});
|
|
87
|
+
const firstLang = /"([^"]+)"/.exec(out)?.[1] ?? "";
|
|
88
|
+
if (/^zh\b/i.test(firstLang))
|
|
89
|
+
domestic = true;
|
|
90
|
+
} catch {
|
|
91
|
+
const raw = (process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "").trim();
|
|
92
|
+
if (/^zh\b/i.test(raw))
|
|
93
|
+
domestic = true;
|
|
94
|
+
}
|
|
95
|
+
} else if (process.platform === "win32") {
|
|
96
|
+
try {
|
|
97
|
+
const loc = Intl.DateTimeFormat().resolvedOptions().locale || "";
|
|
98
|
+
if (/^zh\b/i.test(loc))
|
|
99
|
+
domestic = true;
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
const raw = (process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "").trim();
|
|
104
|
+
if (/^zh\b/i.test(raw))
|
|
105
|
+
domestic = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
cachedOsLocale = domestic ? "zh" : "en";
|
|
109
|
+
return cachedOsLocale;
|
|
110
|
+
}
|
|
61
111
|
function billingOrigin(raw) {
|
|
62
112
|
if (!raw)
|
|
63
113
|
throw new Error("Inkmap checkout is not configured.");
|
|
@@ -86,6 +136,13 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
86
136
|
let pendingWrite = Promise.resolve();
|
|
87
137
|
let pendingCheckout;
|
|
88
138
|
let cachedOrder;
|
|
139
|
+
let magicPollTimer;
|
|
140
|
+
let magicSession = 0;
|
|
141
|
+
function stopMagicPoll() {
|
|
142
|
+
++magicSession;
|
|
143
|
+
clearTimeout(magicPollTimer);
|
|
144
|
+
magicPollTimer = void 0;
|
|
145
|
+
}
|
|
89
146
|
function mergeCookies(existing, response) {
|
|
90
147
|
const map = /* @__PURE__ */ new Map();
|
|
91
148
|
if (existing) {
|
|
@@ -115,19 +172,13 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
115
172
|
}
|
|
116
173
|
return /^1\d{10}$/.test(clean) ? `${clean.slice(0, 3)}****${clean.slice(7)}` : clean.slice(0, 32);
|
|
117
174
|
}
|
|
118
|
-
function clientLocale() {
|
|
119
|
-
const
|
|
120
|
-
if (/^zh\b/i.test(
|
|
175
|
+
function clientLocale(hint) {
|
|
176
|
+
const h = (hint || "").trim();
|
|
177
|
+
if (/^zh\b/i.test(h))
|
|
121
178
|
return "zh";
|
|
122
|
-
if (/^en\b/i.test(
|
|
179
|
+
if (/^en\b/i.test(h))
|
|
123
180
|
return "en";
|
|
124
|
-
|
|
125
|
-
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
126
|
-
if (/^Asia\/(Shanghai|Chongqing|Harbin|Urumqi)$/i.test(tz))
|
|
127
|
-
return "zh";
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
return "en";
|
|
181
|
+
return detectOsLocale();
|
|
131
182
|
}
|
|
132
183
|
function writeSession(operation) {
|
|
133
184
|
const next = pendingWrite.then(operation);
|
|
@@ -136,16 +187,18 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
136
187
|
});
|
|
137
188
|
return next;
|
|
138
189
|
}
|
|
139
|
-
async function createCheckoutFlow(origin, existingToken, existingCookie) {
|
|
190
|
+
async function createCheckoutFlow(origin, existingToken, existingCookie, localeHint) {
|
|
191
|
+
const loc = clientLocale(localeHint);
|
|
140
192
|
const response = await fetch(origin + "/billing/v1/connections", {
|
|
141
193
|
method: "POST",
|
|
142
194
|
headers: {
|
|
143
195
|
"content-type": "application/json",
|
|
196
|
+
"x-inkmap-locale": loc,
|
|
144
197
|
...existingToken && { authorization: "Bearer " + existingToken },
|
|
145
198
|
...existingCookie && { cookie: existingCookie }
|
|
146
199
|
},
|
|
147
200
|
redirect: "error",
|
|
148
|
-
body: JSON.stringify({ product: PRODUCT.id, mode: "buy" }),
|
|
201
|
+
body: JSON.stringify({ product: PRODUCT.id, mode: "buy", locale: loc }),
|
|
149
202
|
signal: AbortSignal.timeout(8e3)
|
|
150
203
|
});
|
|
151
204
|
if (!response.ok)
|
|
@@ -158,11 +211,13 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
158
211
|
}
|
|
159
212
|
return { origin, url, token: data.token, ...cookie && { cookie } };
|
|
160
213
|
}
|
|
161
|
-
function checkoutPost(checkoutUrl, action, origin, body, token, cookie) {
|
|
214
|
+
function checkoutPost(checkoutUrl, action, origin, body, token, cookie, localeHint) {
|
|
215
|
+
const loc = clientLocale(localeHint);
|
|
162
216
|
return fetch(checkoutUrl + "/" + action, {
|
|
163
217
|
method: "POST",
|
|
164
218
|
headers: {
|
|
165
219
|
"content-type": "application/json",
|
|
220
|
+
"x-inkmap-locale": loc,
|
|
166
221
|
origin,
|
|
167
222
|
...token && { authorization: "Bearer " + token },
|
|
168
223
|
...cookie && { cookie }
|
|
@@ -172,13 +227,14 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
172
227
|
signal: AbortSignal.timeout(12e3)
|
|
173
228
|
});
|
|
174
229
|
}
|
|
175
|
-
function phoneRequest(origin, action, phone, code) {
|
|
230
|
+
function phoneRequest(origin, action, phone, code, localeHint) {
|
|
176
231
|
const isEmail = phone.includes("@");
|
|
177
|
-
const locale = clientLocale();
|
|
232
|
+
const locale = clientLocale(localeHint);
|
|
178
233
|
return fetch(origin + "/billing/v1/phone-sign-in/" + action, {
|
|
179
234
|
method: "POST",
|
|
180
235
|
headers: {
|
|
181
236
|
"content-type": "application/json",
|
|
237
|
+
"x-inkmap-locale": locale,
|
|
182
238
|
"accept-language": locale === "zh" ? "zh-CN,zh;q=0.9" : "en-US,en;q=0.9"
|
|
183
239
|
},
|
|
184
240
|
redirect: "error",
|
|
@@ -283,7 +339,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
283
339
|
if (version !== generation || disposed)
|
|
284
340
|
return;
|
|
285
341
|
applyEntitlement(state);
|
|
286
|
-
delay = state.active !== true && state.pending === true ?
|
|
342
|
+
delay = state.active !== true && state.pending === true ? 2500 : 6e4;
|
|
287
343
|
} catch {
|
|
288
344
|
if (version === generation && Date.now() - lastCheck > 15 * 6e4)
|
|
289
345
|
update(false);
|
|
@@ -296,6 +352,49 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
296
352
|
});
|
|
297
353
|
return connection;
|
|
298
354
|
}
|
|
355
|
+
function startMagicPoll(origin, pendingToken) {
|
|
356
|
+
stopMagicPoll();
|
|
357
|
+
const id = magicSession;
|
|
358
|
+
const deadline = Date.now() + 10 * 6e4;
|
|
359
|
+
const poll = () => {
|
|
360
|
+
if (disposed || id !== magicSession || Date.now() >= deadline)
|
|
361
|
+
return;
|
|
362
|
+
magicPollTimer = setTimeout(async () => {
|
|
363
|
+
if (disposed || id !== magicSession)
|
|
364
|
+
return;
|
|
365
|
+
try {
|
|
366
|
+
const res = await entitlement(origin, pendingToken);
|
|
367
|
+
if (disposed || id !== magicSession)
|
|
368
|
+
return;
|
|
369
|
+
if (res.status === 401) {
|
|
370
|
+
stopMagicPoll();
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (res.ok) {
|
|
374
|
+
const body = await res.json();
|
|
375
|
+
if (body?.connected === true && body.entitlement === PRODUCT.entitlement) {
|
|
376
|
+
stopMagicPoll();
|
|
377
|
+
await writeSession(async () => {
|
|
378
|
+
if (disposed || origin !== billingOrigin(getOrigin()))
|
|
379
|
+
return;
|
|
380
|
+
await storage.write(JSON.stringify({ origin, token: pendingToken }));
|
|
381
|
+
++generation;
|
|
382
|
+
activeOrigin = origin;
|
|
383
|
+
applyEntitlement(body);
|
|
384
|
+
schedule(body.active === true ? 6e4 : 2500);
|
|
385
|
+
});
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
} catch {
|
|
390
|
+
}
|
|
391
|
+
if (!disposed && id === magicSession && Date.now() < deadline)
|
|
392
|
+
poll();
|
|
393
|
+
}, 2e3);
|
|
394
|
+
magicPollTimer.unref();
|
|
395
|
+
};
|
|
396
|
+
poll();
|
|
397
|
+
}
|
|
299
398
|
return {
|
|
300
399
|
async state() {
|
|
301
400
|
await (trial ??= startTrial());
|
|
@@ -303,10 +402,11 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
303
402
|
await refresh();
|
|
304
403
|
return current;
|
|
305
404
|
},
|
|
306
|
-
async connect(mode) {
|
|
405
|
+
async connect(mode, localeHint) {
|
|
307
406
|
if (loginOnly && mode !== "restore")
|
|
308
407
|
throw new Error("Only Yunfan account sign-in is available.");
|
|
309
408
|
const origin = billingOrigin(getOrigin());
|
|
409
|
+
const loc = clientLocale(localeHint);
|
|
310
410
|
const version = generation;
|
|
311
411
|
let existingToken;
|
|
312
412
|
try {
|
|
@@ -322,6 +422,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
322
422
|
method: "POST",
|
|
323
423
|
headers: {
|
|
324
424
|
"content-type": "application/json",
|
|
425
|
+
"x-inkmap-locale": loc,
|
|
325
426
|
...existingToken && { authorization: "Bearer " + existingToken }
|
|
326
427
|
},
|
|
327
428
|
redirect: "error",
|
|
@@ -329,10 +430,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
329
430
|
signal: AbortSignal.timeout(8e3)
|
|
330
431
|
});
|
|
331
432
|
let legacy = false;
|
|
332
|
-
let response = await (mode === "restore" ? create("restore-connections", { product: PRODUCT.id }) : create("connections", { product: PRODUCT.id, mode }));
|
|
433
|
+
let response = await (mode === "restore" ? create("restore-connections", { product: PRODUCT.id }) : create("connections", { product: PRODUCT.id, mode, locale: loc }));
|
|
333
434
|
if (mode === "restore" && !loginOnly && response.status === 404) {
|
|
334
435
|
legacy = true;
|
|
335
|
-
response = await create("connections", { product: PRODUCT.id, mode });
|
|
436
|
+
response = await create("connections", { product: PRODUCT.id, mode, locale: loc });
|
|
336
437
|
}
|
|
337
438
|
if (!response.ok)
|
|
338
439
|
throw new Error("Unable to start the Yunfan account flow.");
|
|
@@ -354,7 +455,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
354
455
|
});
|
|
355
456
|
return url;
|
|
356
457
|
},
|
|
357
|
-
async orderPro() {
|
|
458
|
+
async orderPro(localeHint) {
|
|
358
459
|
if (loginOnly)
|
|
359
460
|
throw new Error("Only Yunfan account sign-in is available.");
|
|
360
461
|
const origin = billingOrigin(getOrigin());
|
|
@@ -373,7 +474,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
373
474
|
} catch {
|
|
374
475
|
}
|
|
375
476
|
const requestOrder = async (checkoutUrl, token, cookie, persist) => {
|
|
376
|
-
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie);
|
|
477
|
+
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie, localeHint);
|
|
377
478
|
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 410)
|
|
378
479
|
return null;
|
|
379
480
|
if (!res.ok)
|
|
@@ -423,31 +524,31 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
423
524
|
return existing;
|
|
424
525
|
}
|
|
425
526
|
const existingToken = record?.origin === origin && typeof record.token === "string" ? record.token : void 0;
|
|
426
|
-
const flow = await createCheckoutFlow(origin, existingToken, existingCookie);
|
|
527
|
+
const flow = await createCheckoutFlow(origin, existingToken, existingCookie, localeHint);
|
|
427
528
|
const ordered = await requestOrder(flow.url, flow.token, flow.cookie, true);
|
|
428
529
|
if (ordered)
|
|
429
530
|
return ordered;
|
|
430
531
|
pendingCheckout = flow;
|
|
431
532
|
return { status: "needsPhone" };
|
|
432
533
|
},
|
|
433
|
-
async sendPhoneCode(phone) {
|
|
534
|
+
async sendPhoneCode(phone, localeHint) {
|
|
434
535
|
if (typeof phone !== "string" || !phone.trim() || phone.length > 254)
|
|
435
536
|
return phoneFailure(400);
|
|
436
537
|
const isEmail = phone.includes("@");
|
|
437
|
-
const locale = clientLocale();
|
|
538
|
+
const locale = clientLocale(localeHint);
|
|
438
539
|
try {
|
|
439
540
|
const origin = billingOrigin(getOrigin());
|
|
440
541
|
if (!loginOnly) {
|
|
441
542
|
try {
|
|
442
543
|
if (!pendingCheckout || pendingCheckout.origin !== origin) {
|
|
443
|
-
pendingCheckout = await createCheckoutFlow(origin);
|
|
544
|
+
pendingCheckout = await createCheckoutFlow(origin, void 0, void 0, locale);
|
|
444
545
|
}
|
|
445
546
|
const sendAction = isEmail ? "email/send" : "sms";
|
|
446
547
|
const sendBody = isEmail ? { email: phone, locale } : { phone };
|
|
447
|
-
let smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie);
|
|
548
|
+
let smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie, locale);
|
|
448
549
|
if (smsRes.status === 410 || smsRes.status === 404) {
|
|
449
|
-
pendingCheckout = await createCheckoutFlow(origin);
|
|
450
|
-
smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie);
|
|
550
|
+
pendingCheckout = await createCheckoutFlow(origin, void 0, void 0, locale);
|
|
551
|
+
smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie, locale);
|
|
451
552
|
}
|
|
452
553
|
pendingCheckout.cookie = mergeCookies(pendingCheckout.cookie, smsRes);
|
|
453
554
|
return smsRes.status === 204 ? { ok: true, value: void 0 } : phoneFailure(smsRes.status);
|
|
@@ -455,8 +556,15 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
455
556
|
pendingCheckout = void 0;
|
|
456
557
|
}
|
|
457
558
|
}
|
|
458
|
-
const response = await phoneRequest(origin, "send", phone);
|
|
459
|
-
|
|
559
|
+
const response = await phoneRequest(origin, "send", phone, void 0, locale);
|
|
560
|
+
if (response.status === 204) {
|
|
561
|
+
const pendingToken = response.headers.get("x-inkmap-pending-token")?.trim();
|
|
562
|
+
if (pendingToken && /^[A-Za-z0-9_-]{43}$/.test(pendingToken)) {
|
|
563
|
+
startMagicPoll(origin, pendingToken);
|
|
564
|
+
}
|
|
565
|
+
return { ok: true, value: void 0 };
|
|
566
|
+
}
|
|
567
|
+
return phoneFailure(response.status);
|
|
460
568
|
} catch {
|
|
461
569
|
return phoneFailure();
|
|
462
570
|
}
|
|
@@ -540,6 +648,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
540
648
|
return await writeSession(async () => {
|
|
541
649
|
if (version !== generation || disposed || origin !== billingOrigin(getOrigin()))
|
|
542
650
|
return phoneFailure();
|
|
651
|
+
stopMagicPoll();
|
|
543
652
|
await storage.write(JSON.stringify({ origin, token, ...checkoutUrl && { checkoutUrl }, ...cookie && { cookie } }));
|
|
544
653
|
++generation;
|
|
545
654
|
activeOrigin = origin;
|
|
@@ -554,6 +663,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
554
663
|
}
|
|
555
664
|
},
|
|
556
665
|
async deactivate() {
|
|
666
|
+
stopMagicPoll();
|
|
557
667
|
pendingCheckout = void 0;
|
|
558
668
|
cachedOrder = void 0;
|
|
559
669
|
const saved = await writeSession(async () => {
|
|
@@ -631,7 +741,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
631
741
|
installId: id,
|
|
632
742
|
host: hostName,
|
|
633
743
|
os,
|
|
634
|
-
version: "0.3.
|
|
744
|
+
version: "0.3.5",
|
|
635
745
|
locale: clientLocale(),
|
|
636
746
|
tier,
|
|
637
747
|
events
|
|
@@ -645,6 +755,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
645
755
|
},
|
|
646
756
|
dispose() {
|
|
647
757
|
disposed = true;
|
|
758
|
+
stopMagicPoll();
|
|
648
759
|
clearTimeout(trialTimer);
|
|
649
760
|
clearTimeout(timer);
|
|
650
761
|
clearTimeout(telemetryTimer);
|
|
@@ -902,7 +1013,7 @@ function within(root, rel) {
|
|
|
902
1013
|
return full.startsWith(base) ? full : null;
|
|
903
1014
|
}
|
|
904
1015
|
async function serve({ source: initialSource, webRoot: webRoot2, port = 4377, host = "127.0.0.1", log = () => {
|
|
905
|
-
}, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, loginOnly = false, ideWorkspace = false }) {
|
|
1016
|
+
}, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, loginOnly = false, ideWorkspace = false, workspaceRoots = [] }) {
|
|
906
1017
|
if (sidebar && host !== "127.0.0.1")
|
|
907
1018
|
throw new Error("The sidebar bridge requires loopback.");
|
|
908
1019
|
const prefix2 = sidebar ? `/s/${randomBytes(24).toString("hex")}/` : "/";
|
|
@@ -961,7 +1072,7 @@ data: ${JSON.stringify(data)}
|
|
|
961
1072
|
const projRoot = await realpath(await findProjectRoot(realKey)).catch(() => dirname2(realKey));
|
|
962
1073
|
roots.set(projRoot, { path: projRoot, name: basename(projRoot), active: true });
|
|
963
1074
|
}
|
|
964
|
-
const envRoots = (process.env.INKMAP_WORKSPACES || "").split(delimiter).filter(Boolean);
|
|
1075
|
+
const envRoots = [...workspaceRoots, ...(process.env.INKMAP_WORKSPACES || "").split(delimiter)].filter(Boolean);
|
|
965
1076
|
for (const raw of envRoots) {
|
|
966
1077
|
const real = await realpath(resolve(raw)).catch(() => null);
|
|
967
1078
|
if (real && !roots.has(real)) {
|
|
@@ -1045,8 +1156,16 @@ data: ${JSON.stringify(data)}
|
|
|
1045
1156
|
if (!full)
|
|
1046
1157
|
return json2(res, 403, { error: "forbidden" });
|
|
1047
1158
|
try {
|
|
1159
|
+
const ext = extname(full).toLowerCase();
|
|
1160
|
+
if (ext === ".html") {
|
|
1161
|
+
const osLoc = detectOsLocale();
|
|
1162
|
+
const htmlText = (await readFile2(full, "utf8")).replace(/<html\b([^>]*)>/i, `<html lang="${osLoc === "zh" ? "zh-CN" : "en"}" data-os-locale="${osLoc}">`);
|
|
1163
|
+
res.writeHead(200, { "content-type": TYPES[".html"], "cache-control": "no-store" });
|
|
1164
|
+
res.end(htmlText, "utf8");
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1048
1167
|
const body = await readFile2(full);
|
|
1049
|
-
res.writeHead(200, { "content-type": TYPES[
|
|
1168
|
+
res.writeHead(200, { "content-type": TYPES[ext] ?? "application/octet-stream", "cache-control": sidebar ? "no-store" : "no-cache" });
|
|
1050
1169
|
res.end(body);
|
|
1051
1170
|
} catch {
|
|
1052
1171
|
json2(res, 404, { error: "not found" });
|
|
@@ -1147,14 +1266,14 @@ data: ${JSON.stringify(data)}
|
|
|
1147
1266
|
if (url.pathname === "/api/checkout" && req.method === "POST") {
|
|
1148
1267
|
if (!sameOriginPost())
|
|
1149
1268
|
return json2(res, 403, { error: "forbidden" });
|
|
1150
|
-
const { mode } = JSON.parse(await readBody2(req));
|
|
1269
|
+
const { mode, locale } = JSON.parse(await readBody2(req));
|
|
1151
1270
|
if (mode !== "buy" && mode !== "restore")
|
|
1152
1271
|
return json2(res, 400, { error: "invalid checkout mode" });
|
|
1153
1272
|
if (!canPurchase && mode === "buy")
|
|
1154
1273
|
return json2(res, 403, { error: "forbidden" });
|
|
1155
1274
|
if (!license)
|
|
1156
1275
|
return json2(res, 503, { error: "Inkmap checkout is unavailable." });
|
|
1157
|
-
return json2(res, 200, { url: await license.connect(mode) });
|
|
1276
|
+
return json2(res, 200, { url: await (typeof locale === "string" ? license.connect(mode, locale) : license.connect(mode)) });
|
|
1158
1277
|
}
|
|
1159
1278
|
if (url.pathname === "/api/order-pro" && req.method === "POST") {
|
|
1160
1279
|
if (!sameOriginPost())
|
|
@@ -1165,15 +1284,16 @@ data: ${JSON.stringify(data)}
|
|
|
1165
1284
|
return json2(res, 503, { error: "Inkmap checkout is unavailable." });
|
|
1166
1285
|
if (typeof license.orderPro !== "function")
|
|
1167
1286
|
return json2(res, 501, { fallback: true });
|
|
1168
|
-
|
|
1287
|
+
const { locale } = JSON.parse(await readBody2(req) || "{}");
|
|
1288
|
+
return json2(res, 200, { result: await (typeof locale === "string" ? license.orderPro(locale) : license.orderPro()) });
|
|
1169
1289
|
}
|
|
1170
1290
|
if (url.pathname === "/api/phone-send" && req.method === "POST") {
|
|
1171
1291
|
if (!sameOriginPost())
|
|
1172
1292
|
return json2(res, 403, { error: "forbidden" });
|
|
1173
1293
|
if (!license || typeof license.sendPhoneCode !== "function")
|
|
1174
1294
|
return json2(res, 501, { fallback: true });
|
|
1175
|
-
const { phone } = JSON.parse(await readBody2(req));
|
|
1176
|
-
return json2(res, 200, { result: await license.sendPhoneCode(String(phone ?? "")) });
|
|
1295
|
+
const { phone, locale } = JSON.parse(await readBody2(req));
|
|
1296
|
+
return json2(res, 200, { result: await (typeof locale === "string" ? license.sendPhoneCode(String(phone ?? ""), locale) : license.sendPhoneCode(String(phone ?? ""))) });
|
|
1177
1297
|
}
|
|
1178
1298
|
if (url.pathname === "/api/phone-verify" && req.method === "POST") {
|
|
1179
1299
|
if (!sameOriginPost())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-inkmap",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Inkmap 思维导图 — 在 DeepSeek Harness 中将本地 Markdown 实时渲染为可双向编辑的思维导图 (Markmap) 与 Mermaid 流程图 / Interactive two-way Markdown mind map & Mermaid flowchart editor for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.svg",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-OY52VR5R-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-OY52VR5R-YW_Djx_D.js";import{p as f}from"./chunk-JWPE2WC7-DKPUknl1.js";import{_ as n,l as o}from"./mermaid.core-BA0ZnaVT.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-D-58ofeg.js";import"./index-CL1mygUK.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
|