termdock 1.4.45 → 1.4.46
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/.desktop-dist/main.js +95 -27
- package/dist/client/assets/{abnfDiagram-VRR7QNED-Bt36T7gE.js → abnfDiagram-VRR7QNED-In9dJ8xk.js} +1 -1
- package/dist/client/assets/{arc-DhZtXG4q.js → arc-OgDXNUfC.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZJ3FMSHR-C4BLot_l.js → architectureDiagram-ZJ3FMSHR-CUHWXG-6.js} +1 -1
- package/dist/client/assets/{blockDiagram-677ZJIJ3-BG8NrPiD.js → blockDiagram-677ZJIJ3-D6iMCZrE.js} +1 -1
- package/dist/client/assets/{c4Diagram-LMCZKHZV-m3lWYsQI.js → c4Diagram-LMCZKHZV-BQIYSHIO.js} +1 -1
- package/dist/client/assets/channel-DR9ZrrsH.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-BiBc5Uv0.js → chunk-2Q5K7J3B-VrJ2oEjG.js} +1 -1
- package/dist/client/assets/{chunk-32BRIVSS-C1g4c11U.js → chunk-32BRIVSS-DgE4tlwU.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Ctw1x2FG.js → chunk-5VM5RSS4-DPL1VUbd.js} +1 -1
- package/dist/client/assets/{chunk-EX3LRPZG-BdI4v3f4.js → chunk-EX3LRPZG-Cnzcl0zo.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-K8nPht_5.js → chunk-JWPE2WC7-BwjoHnSm.js} +1 -1
- package/dist/client/assets/{chunk-MOJQB5TN-DWsVsFoK.js → chunk-MOJQB5TN-Q1VspcHf.js} +1 -1
- package/dist/client/assets/{chunk-RYQCIY6F-0MHmqGNs.js → chunk-RYQCIY6F-C3B0hROO.js} +1 -1
- package/dist/client/assets/{chunk-V7JOEXUC-BjQQBzKq.js → chunk-V7JOEXUC-CT1WyL44.js} +1 -1
- package/dist/client/assets/{chunk-VR4S4FIN-Bau1q0xN.js → chunk-VR4S4FIN-RHg32W0I.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-BIzI5y55.js → chunk-XXDRQBXY-B8nloyVH.js} +1 -1
- package/dist/client/assets/classDiagram-OUVF2IWQ-CSyi0dnm.js +1 -0
- package/dist/client/assets/classDiagram-v2-EOCWNBFH-CSyi0dnm.js +1 -0
- package/dist/client/assets/{cose-bilkent-JH36ORCC-C_6nPODG.js → cose-bilkent-JH36ORCC-DM9b-HC2.js} +1 -1
- package/dist/client/assets/{cynefin-VYW2F7L2-DZfIXs6F.js → cynefin-VYW2F7L2-DyfTbIta.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-TSTJHNR4-Cwtffn_E.js → cynefinDiagram-TSTJHNR4-B0TfoSKo.js} +1 -1
- package/dist/client/assets/{dagre-VKFMJZFB-n2L4piqF.js → dagre-VKFMJZFB-DoYxgTE_.js} +1 -1
- package/dist/client/assets/{diagram-FQU43EPY-DYc1Xsf9.js → diagram-FQU43EPY-BhdYoO5s.js} +1 -1
- package/dist/client/assets/{diagram-G47NLZAW-Bty2-g6M.js → diagram-G47NLZAW-DU-PG20h.js} +1 -1
- package/dist/client/assets/{diagram-NH7WQ7WH-B7NwHUrU.js → diagram-NH7WQ7WH-WcnJXUD6.js} +1 -1
- package/dist/client/assets/{diagram-OA4YK3LP-BB8nlvCx.js → diagram-OA4YK3LP-N1S0AWUf.js} +1 -1
- package/dist/client/assets/{diagram-WEI45ONY-2hoKf8a6.js → diagram-WEI45ONY-DBhEABdQ.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-CCIWWBDH-BARVSv3m.js → ebnfDiagram-CCIWWBDH-CPhAEOjW.js} +1 -1
- package/dist/client/assets/{erDiagram-Q63AITRT-5jgm5Ksi.js → erDiagram-Q63AITRT-416GnX06.js} +1 -1
- package/dist/client/assets/{flowDiagram-23GEKE2U-BqCA33p5.js → flowDiagram-23GEKE2U-CQY7Be4e.js} +1 -1
- package/dist/client/assets/{ganttDiagram-NO4QXBWP-BL1NGUYm.js → ganttDiagram-NO4QXBWP-CCdUVGY1.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-IHSO6WYX-D9Qw6ov4.js → gitGraphDiagram-IHSO6WYX-DihTneNH.js} +1 -1
- package/dist/client/assets/{index-BYpFR_L5.js → index-SiGQTF6y.js} +79 -79
- package/dist/client/assets/{infoDiagram-FWYZ7A6U-ZrovoSsZ.js → infoDiagram-FWYZ7A6U-DxVtT8XS.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-FXEZZL3T-uFSMTzKn.js → ishikawaDiagram-FXEZZL3T-CI04eDRq.js} +1 -1
- package/dist/client/assets/{journeyDiagram-5HDEW3XC-DNXNzmef.js → journeyDiagram-5HDEW3XC-Dku9Ke-J.js} +1 -1
- package/dist/client/assets/{kanban-definition-HUTT4EX6-Db2NpkWT.js → kanban-definition-HUTT4EX6-X-7cHaWp.js} +1 -1
- package/dist/client/assets/{linear-DjF6fII5.js → linear-BfhGmqE2.js} +1 -1
- package/dist/client/assets/{mermaid.core-BXI9ENYY.js → mermaid.core-lwiCvpBd.js} +4 -4
- package/dist/client/assets/{mindmap-definition-LN4V7U3C-CjcF3QgK.js → mindmap-definition-LN4V7U3C-DI3swXAM.js} +1 -1
- package/dist/client/assets/{pegDiagram-2B236MQR-BckzTuEj.js → pegDiagram-2B236MQR-ByBkCa7g.js} +1 -1
- package/dist/client/assets/{pieDiagram-ENE6RG2P-Ch2Ty0Y2.js → pieDiagram-ENE6RG2P-CAbocCk6.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-ABIIQ3AL-DvXeQj4a.js → quadrantDiagram-ABIIQ3AL-lE4NNIct.js} +1 -1
- package/dist/client/assets/{railroadDiagram-RFXS5EU6-BUurE4S_.js → railroadDiagram-RFXS5EU6-DVG7K2hA.js} +1 -1
- package/dist/client/assets/{requirementDiagram-TGXJPOKE-CfnNu5HR.js → requirementDiagram-TGXJPOKE-BhjZccsb.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-HTMAVEWB-BfpeK6jA.js → sankeyDiagram-HTMAVEWB-BROBV7xf.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-DBY2YBRQ-CmkcMlBD.js → sequenceDiagram-DBY2YBRQ-DCiUXSQK.js} +1 -1
- package/dist/client/assets/{sizeCapture-X5ZJPWSS-BvnnE9Ev.js → sizeCapture-X5ZJPWSS-wCRp1dLA.js} +1 -1
- package/dist/client/assets/{stateDiagram-2N3HPSRC-D-gs0yW-.js → stateDiagram-2N3HPSRC-GnItAgu1.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-6OUMAXLB-DodZ2p7d.js +1 -0
- package/dist/client/assets/{swimlanes-5IMT3BWC-BW65nQch.js → swimlanes-5IMT3BWC-DbXlO1IP.js} +2 -2
- package/dist/client/assets/swimlanesDiagram-G3AALYLV-Dh3DdtaE.js +8 -0
- package/dist/client/assets/{timeline-definition-FHXFAJF6-Mj3zCwTc.js → timeline-definition-FHXFAJF6-CQjgTVIW.js} +1 -1
- package/dist/client/assets/{vennDiagram-L72KCM5P-gXnoVb66.js → vennDiagram-L72KCM5P-Bz_Lzf5a.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-EHGQE667-Cgbh1_F7.js → wardleyDiagram-EHGQE667-Cgw3S7By.js} +1 -1
- package/dist/client/assets/{xychartDiagram-FW5EYKEG-DQW7oknN.js → xychartDiagram-FW5EYKEG-IyZJ_VfA.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/sw.js +1 -1
- package/dist/server/entry.js +31 -12
- package/dist/server/utils/runtimeClient.js +41 -0
- package/package.json +5 -2
- package/runtime-manifest.json +12 -0
- package/scripts/classify-release.mjs +88 -0
- package/scripts/generate-runtime-manifest.mjs +77 -0
- package/scripts/prepare-desktop-runtime.mjs +27 -3
- package/dist/client/assets/channel-Ck9tD_4_.js +0 -1
- package/dist/client/assets/classDiagram-OUVF2IWQ-CtEpUyds.js +0 -1
- package/dist/client/assets/classDiagram-v2-EOCWNBFH-CtEpUyds.js +0 -1
- package/dist/client/assets/stateDiagram-v2-6OUMAXLB-gXYMxyju.js +0 -1
- package/dist/client/assets/swimlanesDiagram-G3AALYLV-DmhG9XuP.js +0 -8
package/.desktop-dist/main.js
CHANGED
|
@@ -6,7 +6,8 @@ import os from 'node:os';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { promisify } from 'node:util';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { checkForDesktopUpdates, configureDesktopUpdater } from './updater.js';
|
|
9
|
+
import { checkForDesktopUpdates, configureDesktopUpdater, ensureLatestRuntime, } from './updater.js';
|
|
10
|
+
import { resolvePackagedRuntime, rollbackDownloadedRuntime, } from './runtime.js';
|
|
10
11
|
const execFileAsync = promisify(execFile);
|
|
11
12
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
12
13
|
const projectRoot = path.resolve(currentDir, '..');
|
|
@@ -17,6 +18,13 @@ const DEFAULT_LOCAL_URL = 'http://localhost:9834';
|
|
|
17
18
|
const PROTOCOL_VERSION = 1;
|
|
18
19
|
const HEALTH_TIMEOUT_MS = 3_500;
|
|
19
20
|
const START_TIMEOUT_MS = 90_000;
|
|
21
|
+
/** Delivered-but-unseen desktop notifications, mirrored into the Dock badge. */
|
|
22
|
+
const activeNotifications = new Map();
|
|
23
|
+
let unreadNotificationCount = 0;
|
|
24
|
+
function clearUnreadNotifications() {
|
|
25
|
+
unreadNotificationCount = 0;
|
|
26
|
+
app.setBadgeCount(0);
|
|
27
|
+
}
|
|
20
28
|
let mainWindow = null;
|
|
21
29
|
let activeServiceOrigin = null;
|
|
22
30
|
let isQuitting = false;
|
|
@@ -217,18 +225,25 @@ async function getLocalServiceStatus() {
|
|
|
217
225
|
}
|
|
218
226
|
function runtimePaths() {
|
|
219
227
|
if (app.isPackaged) {
|
|
228
|
+
const selected = resolvePackagedRuntime({
|
|
229
|
+
appVersion: app.getVersion(),
|
|
230
|
+
resourcesPath: process.resourcesPath,
|
|
231
|
+
});
|
|
220
232
|
return {
|
|
233
|
+
...selected,
|
|
221
234
|
node: path.join(process.resourcesPath, 'runtime', 'bin', 'node'),
|
|
222
|
-
cli: path.join(process.resourcesPath, 'server', 'dist', 'server', 'cli.js'),
|
|
223
235
|
launcher: path.join(process.resourcesPath, 'cli', 'td'),
|
|
224
236
|
toolchainBin: path.join(process.resourcesPath, 'toolchain', 'bin'),
|
|
225
237
|
};
|
|
226
238
|
}
|
|
227
239
|
return {
|
|
228
240
|
node: process.env.TERMDOCK_NODE_BIN || 'node',
|
|
241
|
+
serverRoot: projectRoot,
|
|
229
242
|
cli: path.join(projectRoot, 'dist', 'server', 'cli.js'),
|
|
230
243
|
launcher: path.join(projectRoot, 'desktop', 'cli', 'td'),
|
|
231
244
|
toolchainBin: path.join(projectRoot, '.desktop-runtime', 'toolchain', 'bin'),
|
|
245
|
+
version: app.getVersion(),
|
|
246
|
+
source: 'development',
|
|
232
247
|
};
|
|
233
248
|
}
|
|
234
249
|
async function executableVersion(executable) {
|
|
@@ -285,7 +300,7 @@ async function bundledCliVersion() {
|
|
|
285
300
|
const { stdout } = await execFileAsync(runtime.node, [runtime.cli, '--version'], {
|
|
286
301
|
timeout: 5_000,
|
|
287
302
|
maxBuffer: 128 * 1024,
|
|
288
|
-
env: desktopRuntimeEnv(),
|
|
303
|
+
env: desktopRuntimeEnv(runtime),
|
|
289
304
|
});
|
|
290
305
|
return stdout.trim() || app.getVersion();
|
|
291
306
|
}
|
|
@@ -302,6 +317,7 @@ async function snapshot() {
|
|
|
302
317
|
]);
|
|
303
318
|
return {
|
|
304
319
|
appVersion: app.getVersion(),
|
|
320
|
+
runtimeVersion: cliVersion,
|
|
305
321
|
packaged: app.isPackaged,
|
|
306
322
|
bundledCliVersion: cliVersion,
|
|
307
323
|
cliInstallations,
|
|
@@ -310,8 +326,7 @@ async function snapshot() {
|
|
|
310
326
|
lastConnectionUrl: config.lastConnectionUrl,
|
|
311
327
|
};
|
|
312
328
|
}
|
|
313
|
-
function desktopRuntimeEnv() {
|
|
314
|
-
const runtime = runtimePaths();
|
|
329
|
+
function desktopRuntimeEnv(runtime = runtimePaths()) {
|
|
315
330
|
const currentPath = process.env.PATH ?? '/usr/bin:/bin:/usr/sbin:/sbin';
|
|
316
331
|
return {
|
|
317
332
|
...process.env,
|
|
@@ -320,13 +335,14 @@ function desktopRuntimeEnv() {
|
|
|
320
335
|
.join(path.delimiter),
|
|
321
336
|
TERMDOCK_DESKTOP: '1',
|
|
322
337
|
TERMDOCK_BUNDLED_RUNTIME: app.isPackaged ? '1' : '0',
|
|
323
|
-
TERMDOCK_VERSION:
|
|
338
|
+
TERMDOCK_VERSION: runtime.version,
|
|
339
|
+
TERMDOCK_DESKTOP_SHELL_VERSION: app.getVersion(),
|
|
324
340
|
TMUX_BIN: fs.existsSync(path.join(runtime.toolchainBin, 'tmux'))
|
|
325
341
|
? path.join(runtime.toolchainBin, 'tmux')
|
|
326
342
|
: process.env.TMUX_BIN,
|
|
327
343
|
};
|
|
328
344
|
}
|
|
329
|
-
async function waitForLocalService() {
|
|
345
|
+
async function waitForLocalService(childPid) {
|
|
330
346
|
const deadline = Date.now() + START_TIMEOUT_MS;
|
|
331
347
|
let lastProbe = { ok: false, url: DEFAULT_LOCAL_URL, error: '服务尚未启动' };
|
|
332
348
|
while (Date.now() < deadline) {
|
|
@@ -335,6 +351,9 @@ async function waitForLocalService() {
|
|
|
335
351
|
lastProbe = await probeService(url);
|
|
336
352
|
if (lastProbe.ok)
|
|
337
353
|
return lastProbe;
|
|
354
|
+
if (childPid && !isProcessRunning(childPid)) {
|
|
355
|
+
return { ...lastProbe, error: '服务进程在健康检查通过前退出' };
|
|
356
|
+
}
|
|
338
357
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
339
358
|
}
|
|
340
359
|
return lastProbe;
|
|
@@ -386,33 +405,54 @@ async function startLocalService() {
|
|
|
386
405
|
return existing.probe ?? { ok: true, url: stateUrl(existing.state) };
|
|
387
406
|
}
|
|
388
407
|
}
|
|
389
|
-
|
|
408
|
+
if (app.isPackaged) {
|
|
409
|
+
try {
|
|
410
|
+
await ensureLatestRuntime();
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
console.error('[desktop-runtime] update check failed; using the current runtime', error);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
let runtime = runtimePaths();
|
|
390
417
|
if (!fs.existsSync(runtime.cli)) {
|
|
391
418
|
throw new Error('未找到 Termdock 服务端构建,请先运行 npm run build');
|
|
392
419
|
}
|
|
393
420
|
if (app.isPackaged && !fs.existsSync(runtime.node)) {
|
|
394
421
|
throw new Error('安装包缺少内嵌 Node Runtime');
|
|
395
422
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
423
|
+
const startRuntime = async (selected) => {
|
|
424
|
+
fs.mkdirSync(termdockDir, { recursive: true, mode: 0o700 });
|
|
425
|
+
const logPath = path.join(termdockDir, 'server.log');
|
|
426
|
+
const logFd = fs.openSync(logPath, 'a');
|
|
427
|
+
const child = spawn(selected.node, [
|
|
428
|
+
selected.cli,
|
|
429
|
+
'--foreground',
|
|
430
|
+
'--host',
|
|
431
|
+
'0.0.0.0',
|
|
432
|
+
'--port',
|
|
433
|
+
'9834',
|
|
434
|
+
], {
|
|
435
|
+
detached: true,
|
|
436
|
+
stdio: ['ignore', logFd, logFd],
|
|
437
|
+
env: desktopRuntimeEnv(selected),
|
|
438
|
+
});
|
|
439
|
+
fs.closeSync(logFd);
|
|
440
|
+
child.unref();
|
|
441
|
+
return waitForLocalService(child.pid);
|
|
442
|
+
};
|
|
443
|
+
let probe = await startRuntime(runtime);
|
|
444
|
+
if (!probe.ok && app.isPackaged && runtime.source === 'downloaded') {
|
|
445
|
+
if (rollbackDownloadedRuntime({
|
|
446
|
+
appVersion: app.getVersion(),
|
|
447
|
+
resourcesPath: process.resourcesPath,
|
|
448
|
+
}, runtime.version)) {
|
|
449
|
+
console.error(`[desktop-runtime] ${runtime.version} failed to start; rolled back`);
|
|
450
|
+
runtime = runtimePaths();
|
|
451
|
+
probe = await startRuntime(runtime);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
414
454
|
if (!probe.ok) {
|
|
415
|
-
throw new Error(`桌面版服务启动失败:${probe.error ?? '未知错误'}。日志:${
|
|
455
|
+
throw new Error(`桌面版服务启动失败:${probe.error ?? '未知错误'}。日志:${path.join(termdockDir, 'server.log')}`);
|
|
416
456
|
}
|
|
417
457
|
await connectWindow(probe.url);
|
|
418
458
|
return probe;
|
|
@@ -570,6 +610,10 @@ function createMainWindow() {
|
|
|
570
610
|
if (mainWindow === window)
|
|
571
611
|
mainWindow = null;
|
|
572
612
|
});
|
|
613
|
+
window.on('focus', () => {
|
|
614
|
+
// User is looking at the app — the Dock badge has served its purpose.
|
|
615
|
+
clearUnreadNotifications();
|
|
616
|
+
});
|
|
573
617
|
window.on('close', (event) => {
|
|
574
618
|
if (process.platform === 'darwin' && !isQuitting) {
|
|
575
619
|
event.preventDefault();
|
|
@@ -617,11 +661,28 @@ function installIpcHandlers() {
|
|
|
617
661
|
ipcMain.handle('desktop:show-notification', (_event, payload) => {
|
|
618
662
|
if (!Notification.isSupported() || typeof payload?.title !== 'string')
|
|
619
663
|
return false;
|
|
664
|
+
// Web Notification tag semantics: a new notification with the same tag
|
|
665
|
+
// replaces the previous one instead of stacking.
|
|
666
|
+
const tag = typeof payload.tag === 'string' && payload.tag ? payload.tag : null;
|
|
667
|
+
if (tag) {
|
|
668
|
+
const previous = activeNotifications.get(tag);
|
|
669
|
+
if (previous) {
|
|
670
|
+
previous.close();
|
|
671
|
+
activeNotifications.delete(tag);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
620
674
|
const notification = new Notification({
|
|
621
675
|
title: payload.title.slice(0, 160),
|
|
622
676
|
body: typeof payload.body === 'string' ? payload.body.slice(0, 1000) : undefined,
|
|
623
677
|
silent: payload.silent === true,
|
|
624
678
|
});
|
|
679
|
+
if (tag) {
|
|
680
|
+
activeNotifications.set(tag, notification);
|
|
681
|
+
notification.on('close', () => {
|
|
682
|
+
if (activeNotifications.get(tag) === notification)
|
|
683
|
+
activeNotifications.delete(tag);
|
|
684
|
+
});
|
|
685
|
+
}
|
|
625
686
|
notification.on('click', () => {
|
|
626
687
|
mainWindow?.show();
|
|
627
688
|
mainWindow?.focus();
|
|
@@ -630,6 +691,13 @@ function installIpcHandlers() {
|
|
|
630
691
|
}
|
|
631
692
|
});
|
|
632
693
|
notification.show();
|
|
694
|
+
unreadNotificationCount += 1;
|
|
695
|
+
app.setBadgeCount(unreadNotificationCount);
|
|
696
|
+
// macOS banners auto-dismiss even for "persistent" alerts; bounce the Dock
|
|
697
|
+
// icon so the signal survives until the user looks at the app.
|
|
698
|
+
if (payload.persistent === true && !mainWindow?.isFocused()) {
|
|
699
|
+
app.dock?.bounce('informational');
|
|
700
|
+
}
|
|
633
701
|
return true;
|
|
634
702
|
});
|
|
635
703
|
}
|
package/dist/client/assets/{abnfDiagram-VRR7QNED-Bt36T7gE.js → abnfDiagram-VRR7QNED-In9dJ8xk.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as n}from"./chunk-MOJQB5TN-
|
|
1
|
+
import{g as p,r as u,d as n}from"./chunk-MOJQB5TN-Q1VspcHf.js";import{p as f}from"./chunk-JWPE2WC7-BwjoHnSm.js";import{b as a,aE as o}from"./mermaid.core-lwiCvpBd.js";import{M as c,c as d}from"./cynefin-VYW2F7L2-DyfTbIta.js";import"./index-SiGQTF6y.js";import"./react-XDCjal2T.js";import"./dnd-BCFAPC0L.js";import"./terminal-C7X98Amf.js";import"./purify.es-CC4Brkr_.js";var v=d().RailroadAbnf.parser.LangiumParser,i=a(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=a(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=a(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=a(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=a(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=a(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=a(e=>{f(e,n),e.title&&n.setTitle(e.title),e.rules.map(r=>n.addRule(P(r)))},"populateDb"),R={parse:a(e=>{n.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:n}},D={parser:R,db:n,renderer:u,styles:p};export{D as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bn as ln,aQ as an,H as X,b9 as w,F as K,ai as un,X as y,be as tn,ba as C,aK as _,c as rn,m as o,aI as on,j as sn,d as fn}from"./mermaid.core-
|
|
1
|
+
import{bn as ln,aQ as an,H as X,b9 as w,F as K,ai as un,X as y,be as tn,ba as C,aK as _,c as rn,m as o,aI as on,j as sn,d as fn}from"./mermaid.core-lwiCvpBd.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,I,v,A,O,a){var D=q-l,i=I-h,n=O-v,d=a-A,u=d*D-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*D,h+u*i]}function U(l,h,q,I,v,A,O){var a=l-q,D=h-I,i=(O?A:-A)/C(a*a+D*D),n=i*D,d=-i*a,u=l+n,s=h+d,f=q+n,c=I+d,Q=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,E=(g<0?-1:1)*C(on(0,T*T*R-P*P)),F=(P*g-m*E)/R,H=(-P*m-g*E)/R,b=(P*g+m*E)/R,p=(-P*m+g*E)/R,x=F-Q,e=H-t,r=b-Q,S=p-t;return x*x+e*e>r*r+S*S&&(F=b,H=p),{cx:F,cy:H,x01:-n,y01:-d,x11:F*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=K(0),I=null,v=gn,A=dn,O=mn,a=null,D=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,Q=rn(c-f),t=c>f;if(a||(a=n=D()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(Q>tn-y)a.moveTo(s*X(f),s*w(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*X(c),u*w(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=Q,E=Q,F=O.apply(this,arguments)/2,H=F>y&&(I?+I.apply(this,arguments):C(u*u+s*s)),b=_(rn(s-u)/2,+q.apply(this,arguments)),p=b,x=b,e,r;if(H>y){var S=sn(H/u*w(F)),G=sn(H/s*w(F));(P-=S*2)>y?(S*=t?1:-1,R+=S,T-=S):(P=0,R=T=(f+c)/2),(E-=G*2)>y?(G*=t?1:-1,m+=G,g-=G):(E=0,m=g=(f+c)/2)}var z=s*X(m),B=s*w(m),J=u*X(T),L=u*w(T);if(b>y){var M=s*X(g),N=s*w(g),V=u*X(R),W=u*w(R),j;if(Q<an)if(j=pn(z,B,V,W,M,N,J,L)){var Y=z-j[0],Z=B-j[1],$=M-j[0],k=N-j[1],nn=1/w(fn((Y*$+Z*k)/(C(Y*Y+Z*Z)*C($*$+k*k)))/2),en=C(j[0]*j[0]+j[1]*j[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=U(V,W,z,B,s,x,t),r=U(M,N,J,L,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(z,B),a.arc(0,0,s,m,g,!t)):a.moveTo(z,B),!(u>y)||!(P>y)?a.lineTo(J,L):p>y?(e=U(J,L,M,N,u,-p,t),r=U(z,B,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[X(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:K(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:K(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:K(+n),i):q},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:K(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:K(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:K(+n),i):A},i.padAngle=function(n){return arguments.length?(O=typeof n=="function"?n:K(+n),i):O},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|