@jmfederico/pi-web 1.202610.4 → 1.202610.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/dist/cli.js +1 -1
- package/dist/client/assets/classic-CyM97Akm.css +54 -0
- package/dist/client/assets/graphite-DquaqFXU.css +54 -0
- package/dist/client/assets/index-DPS1kTH7.js +4389 -0
- package/dist/client/assets/paper-CB1oLuRr.css +54 -0
- package/dist/client/assets/pi-web-dark-D_KtbM95.css +54 -0
- package/dist/client/assets/pi-web-light-DSNLMIBI.css +54 -0
- package/dist/client/index.html +2 -2
- package/dist/config.js +56 -0
- package/dist/config.js.map +1 -1
- package/dist/pi-packages/captains-log/dist/browser/index.js +13 -17
- package/dist/pi-packages/captains-log/dist/browser/panel.js +7 -11
- package/dist/pi-packages/relays/pi-web-plugin.js +21 -1
- package/dist/pi-packages/relays/relaysPanelElement.js +36 -32
- package/dist/pi-packages/workflows/browser/pi-web-plugin.js +35 -27
- package/dist/pi-packages/workflows/browser/worktreeDialog.js +156 -0
- package/dist/pi-packages/workflows/package.json +1 -0
- package/dist/pi-packages/workflows/prompts/worktree.md +11 -2
- package/dist/pi-packages/workflows/server-plugin.js +579 -0
- package/dist/pi-packages/workflows/vite.config.mjs +17 -0
- package/dist/pi-web-plugins/code-highlight/browser/pi-web-plugin.js +22 -0
- package/dist/pi-web-plugins/code-highlight/package.json +13 -0
- package/dist/pi-web-plugins/files/browser/pi-web-plugin.js +119 -162
- package/dist/pi-web-plugins/git/browser/git-panel.js +61 -46
- package/dist/pi-web-plugins/git/browser/pi-web-plugin.js +25 -3
- package/dist/pi-web-plugins/git/git-backend.js +13 -1
- package/dist/pi-web-plugins/git/server-plugin.js +8 -1
- package/dist/pi-web-plugins/mermaid/browser/pi-web-plugin.js +8 -3
- package/dist/pi-web-plugins/terminal/browser/pi-web-plugin.js +50 -29
- package/dist/pi-web-plugins/updates/pi-web-plugin.js +11 -11
- package/dist/pi-web-plugins/workspace-tasks/pi-web-plugin.js +21 -1
- package/dist/pi-web-plugins/workspace-tasks/tasksPanelElement.js +35 -19
- package/dist/piWebUpdate.js +32 -9
- package/dist/piWebUpdate.js.map +1 -1
- package/dist/plugin-api.d.ts +174 -45
- package/dist/server/browserMessageProjection.js +1 -1
- package/dist/server/browserMessageProjection.js.map +1 -1
- package/dist/server/configRoutes.js +7 -1
- package/dist/server/configRoutes.js.map +1 -1
- package/dist/server/machines/machineProxyRoutes.js +3 -2
- package/dist/server/machines/machineProxyRoutes.js.map +1 -1
- package/dist/server/piWebPluginService.js +7 -1
- package/dist/server/piWebPluginService.js.map +1 -1
- package/dist/server/plugins/pluginBackendChannelProxyAdmission.js +1 -1
- package/dist/server/plugins/pluginBackendChannelProxyAdmission.js.map +1 -1
- package/dist/server/plugins/pluginBackendChannelProxyRoutes.js +31 -38
- package/dist/server/plugins/pluginBackendChannelProxyRoutes.js.map +1 -1
- package/dist/server/plugins/pluginBackendProxyRoutes.js +38 -45
- package/dist/server/plugins/pluginBackendProxyRoutes.js.map +1 -1
- package/dist/server/plugins/pluginBackendRegistry.js +58 -34
- package/dist/server/plugins/pluginBackendRegistry.js.map +1 -1
- package/dist/server/plugins/serverPluginCatalogCapability.js +106 -0
- package/dist/server/plugins/serverPluginCatalogCapability.js.map +1 -0
- package/dist/server/plugins/serverPluginRuntime.js +21 -8
- package/dist/server/plugins/serverPluginRuntime.js.map +1 -1
- package/dist/server/sessiond/pluginBackendChannelRoutes.js +24 -14
- package/dist/server/sessiond/pluginBackendChannelRoutes.js.map +1 -1
- package/dist/server/sessiond/pluginBackendRoutes.js +51 -47
- package/dist/server/sessiond/pluginBackendRoutes.js.map +1 -1
- package/dist/server/sessiond/pluginCatalogRoutes.js +37 -0
- package/dist/server/sessiond/pluginCatalogRoutes.js.map +1 -0
- package/dist/server/sessiond/sessionProxyRoutes.js +17 -0
- package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
- package/dist/server/sessiond/sessionServiceDependencies.js +1 -0
- package/dist/server/sessiond/sessionServiceDependencies.js.map +1 -1
- package/dist/server/sessiond.js +24 -4
- package/dist/server/sessiond.js.map +1 -1
- package/dist/server/sessions/authRoutes.js +1 -0
- package/dist/server/sessions/authRoutes.js.map +1 -1
- package/dist/server/sessions/authService.js +13 -0
- package/dist/server/sessions/authService.js.map +1 -1
- package/dist/server/sessions/builtinExtensionFactories.js +15 -1
- package/dist/server/sessions/builtinExtensionFactories.js.map +1 -1
- package/dist/server/sessions/companionBackend.js +286 -0
- package/dist/server/sessions/companionBackend.js.map +1 -0
- package/dist/server/sessions/mcpAuthFlowService.js +237 -0
- package/dist/server/sessions/mcpAuthFlowService.js.map +1 -0
- package/dist/server/sessions/mcpAuthRoutes.js +76 -0
- package/dist/server/sessions/mcpAuthRoutes.js.map +1 -0
- package/dist/server/sessions/messageHistoryTarget.js +18 -1
- package/dist/server/sessions/messageHistoryTarget.js.map +1 -1
- package/dist/server/sessions/piSessionEventConnections.js +5 -2
- package/dist/server/sessions/piSessionEventConnections.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +279 -22
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionCommandService.js +3 -17
- package/dist/server/sessions/sessionCommandService.js.map +1 -1
- package/dist/server/sessions/sessionNameGenerator.js +4 -4
- package/dist/server/sessions/sessionNameGenerator.js.map +1 -1
- package/dist/server-plugin-api.d.ts +65 -15
- package/dist/server-plugin-api.js +25 -0
- package/dist/server-plugin-api.js.map +1 -1
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/federatedRoutes.js +17 -5
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/dist/shared/pluginApiTypes.d.ts +53 -0
- package/dist/shared/pluginBackendProtocol.js +56 -1
- package/dist/shared/pluginBackendProtocol.js.map +1 -1
- package/dist/shared/pluginCatalogTypes.d.ts +49 -0
- package/dist/shared/pluginCatalogTypes.js +156 -0
- package/dist/shared/pluginCatalogTypes.js.map +1 -0
- package/docs/config.md +68 -2
- package/docs/plugins.md +382 -20
- package/examples/session-bridge-plugin/src/browser/index.ts +1 -1
- package/package.json +7 -12
- package/dist/client/assets/index-BAl5IbYx.js +0 -4429
|
@@ -13,13 +13,13 @@ const GIT_WORKSPACE_STATE_LIMIT = 8;
|
|
|
13
13
|
const activityElementTag = "pi-web-git-panel-activity";
|
|
14
14
|
const EMPTY_LIST_MODEL = { submodules: [], files: [] };
|
|
15
15
|
const EMPTY_VIEW_STATE = { nodes: [], listModel: EMPTY_LIST_MODEL, expandablePaths: [] };
|
|
16
|
-
export function createGitBrowserContributions(sourcePluginId, runtimePluginId, html, svg) {
|
|
16
|
+
export function createGitBrowserContributions(sourcePluginId, runtimePluginId, html, svg, stylesheetIntegration) {
|
|
17
17
|
const panelId = `${runtimePluginId}:${GIT_PANEL_LOCAL_ID}`;
|
|
18
18
|
const controller = new GitUiController(sourcePluginId, createGitDiffRoute(panelId));
|
|
19
19
|
defineGitPanelActivityElement();
|
|
20
20
|
return {
|
|
21
21
|
actions: createGitActions(panelId, controller),
|
|
22
|
-
workspacePanels: [createGitPanel(html, svg, controller)],
|
|
22
|
+
workspacePanels: [createGitPanel(html, svg, controller, stylesheetIntegration)],
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
class GitUiController {
|
|
@@ -34,8 +34,9 @@ class GitUiController {
|
|
|
34
34
|
this.sourcePluginId = sourcePluginId;
|
|
35
35
|
this.route = route;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
return workspace
|
|
37
|
+
canInspectWorkspace(workspace) {
|
|
38
|
+
return workspace !== undefined &&
|
|
39
|
+
(workspace.provider === undefined || workspace.provider.pluginId === this.sourcePluginId);
|
|
39
40
|
}
|
|
40
41
|
state(context) {
|
|
41
42
|
return this.stateFor(context);
|
|
@@ -73,7 +74,7 @@ class GitUiController {
|
|
|
73
74
|
void this.refresh(context, true);
|
|
74
75
|
}
|
|
75
76
|
invalidate(context) {
|
|
76
|
-
if (!this.
|
|
77
|
+
if (!this.canInspectWorkspace(context.workspace))
|
|
77
78
|
return Promise.resolve();
|
|
78
79
|
const state = this.stateFor(context);
|
|
79
80
|
state.stale = state.status !== undefined;
|
|
@@ -309,7 +310,7 @@ class GitUiController {
|
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
function createGitActions(panelId, controller) {
|
|
312
|
-
const hasGitWorkspace = (context) => controller.
|
|
313
|
+
const hasGitWorkspace = (context) => controller.canInspectWorkspace(context.state.selectedWorkspace);
|
|
313
314
|
return [
|
|
314
315
|
{
|
|
315
316
|
id: "view.git",
|
|
@@ -331,7 +332,7 @@ function createGitActions(panelId, controller) {
|
|
|
331
332
|
},
|
|
332
333
|
];
|
|
333
334
|
}
|
|
334
|
-
function createGitPanel(html, svg, controller) {
|
|
335
|
+
function createGitPanel(html, svg, controller, stylesheetIntegration) {
|
|
335
336
|
return {
|
|
336
337
|
id: GIT_PANEL_LOCAL_ID,
|
|
337
338
|
title: "Git",
|
|
@@ -346,9 +347,9 @@ function createGitPanel(html, svg, controller) {
|
|
|
346
347
|
</svg>
|
|
347
348
|
`,
|
|
348
349
|
order: 20,
|
|
349
|
-
visible: (context) => controller.
|
|
350
|
+
visible: (context) => controller.canInspectWorkspace(context.workspace),
|
|
350
351
|
onInvalidate: (context) => controller.invalidate(context),
|
|
351
|
-
render: (context) => renderGitPanel(html, controller, context),
|
|
352
|
+
render: (context) => renderGitPanel(html, controller, context, stylesheetIntegration()),
|
|
352
353
|
};
|
|
353
354
|
}
|
|
354
355
|
function requestGitBackend(context, operation, input) {
|
|
@@ -357,25 +358,25 @@ function requestGitBackend(context, operation, input) {
|
|
|
357
358
|
}
|
|
358
359
|
return context.peer.request(operation, input);
|
|
359
360
|
}
|
|
360
|
-
function renderGitPanel(html, controller, context) {
|
|
361
|
+
function renderGitPanel(html, controller, context, stylesheetIntegration) {
|
|
361
362
|
const state = controller.state(context);
|
|
362
363
|
const viewState = controller.viewState(state);
|
|
363
364
|
return html `
|
|
364
365
|
<section class="git-panel">
|
|
365
|
-
<style .textContent=${gitPanelStyles}></style>
|
|
366
|
-
<pi-web-git-panel-activity .controller=${controller} .context=${context}></pi-web-git-panel-activity>
|
|
367
|
-
<section class="git-toolbar">
|
|
366
|
+
<style data-git-styles .textContent=${gitPanelStyles}></style>
|
|
367
|
+
<pi-web-git-panel-activity .stylesheetIntegration=${stylesheetIntegration} .controller=${controller} .context=${context}></pi-web-git-panel-activity>
|
|
368
|
+
<section class="ui-toolbar git-toolbar">
|
|
368
369
|
<strong>Git</strong>
|
|
369
370
|
${state.stale ? html `<span class="git-stale">stale</span>` : null}
|
|
370
|
-
<div class="git-toolbar-actions">
|
|
371
|
+
<div class="ui-toolbar-group git-toolbar-actions">
|
|
371
372
|
${viewState.expandablePaths.length === 0 ? null : renderExpandCollapseAll(html, controller, context, state, viewState.expandablePaths)}
|
|
372
373
|
${renderViewToggle(html, controller, context)}
|
|
373
|
-
<button type="button" ?disabled=${state.statusLoading} @click=${() => { void controller.refresh(context); }}>Refresh</button>
|
|
374
|
+
<button type="button" class="ui-button" ?disabled=${state.statusLoading} @click=${() => { void controller.refresh(context); }}>Refresh</button>
|
|
374
375
|
</div>
|
|
375
376
|
</section>
|
|
376
377
|
${state.error === undefined ? null : html `<div class="git-error" role="alert">${state.error}</div>`}
|
|
377
378
|
<section class="git-split">
|
|
378
|
-
<div class="git-file-list">${renderFileList(html, controller, context, state, viewState)}</div>
|
|
379
|
+
<div class="ui-file-list git-file-list">${renderFileList(html, controller, context, state, viewState)}</div>
|
|
379
380
|
<div class="git-viewer">${renderDiffViewer(html, state)}</div>
|
|
380
381
|
</section>
|
|
381
382
|
</section>
|
|
@@ -383,7 +384,7 @@ function renderGitPanel(html, controller, context) {
|
|
|
383
384
|
}
|
|
384
385
|
function renderViewToggle(html, controller, context) {
|
|
385
386
|
return html `
|
|
386
|
-
<div class="
|
|
387
|
+
<div class="ui-toolbar-group" role="group" aria-label="Changed files view">
|
|
387
388
|
${renderViewToggleButton(html, controller, context, "list", "List")}
|
|
388
389
|
${renderViewToggleButton(html, controller, context, "tree", "Tree")}
|
|
389
390
|
</div>
|
|
@@ -391,11 +392,11 @@ function renderViewToggle(html, controller, context) {
|
|
|
391
392
|
}
|
|
392
393
|
function renderViewToggleButton(html, controller, context, view, label) {
|
|
393
394
|
const active = controller.currentView() === view;
|
|
394
|
-
return html `<button type="button" class
|
|
395
|
+
return html `<button type="button" class="ui-button" aria-pressed=${String(active)} @click=${() => { controller.setView(context, view); }}>${label}</button>`;
|
|
395
396
|
}
|
|
396
397
|
function renderExpandCollapseAll(html, controller, context, state, expandablePaths) {
|
|
397
398
|
const allExpanded = expandablePaths.every((path) => state.expandedDirectories.has(path));
|
|
398
|
-
return html `<button type="button" @click=${() => { controller.toggleExpandAll(context, expandablePaths, allExpanded); }}>${allExpanded ? "Collapse all" : "Expand all"}</button>`;
|
|
399
|
+
return html `<button type="button" class="ui-button" @click=${() => { controller.toggleExpandAll(context, expandablePaths, allExpanded); }}>${allExpanded ? "Collapse all" : "Expand all"}</button>`;
|
|
399
400
|
}
|
|
400
401
|
function renderFileList(html, controller, context, state, viewState) {
|
|
401
402
|
const status = state.status;
|
|
@@ -420,9 +421,9 @@ function renderListBody(html, controller, context, state, model) {
|
|
|
420
421
|
function renderSubmoduleGroup(html, controller, context, state, group) {
|
|
421
422
|
const expanded = state.expandedDirectories.has(group.path);
|
|
422
423
|
return html `
|
|
423
|
-
<button type="button" class="
|
|
424
|
-
<span class="
|
|
425
|
-
<span>${group.name}${submoduleBadge(html)}</span>
|
|
424
|
+
<button type="button" class="ui-button ui-file-row" style="--depth:0" title=${group.path} aria-expanded=${String(expanded)} @click=${() => { controller.toggleDirectory(context, group.path); }}>
|
|
425
|
+
<span class="ui-file-leading" aria-hidden="true">${expanded ? "▾" : "▸"}</span>
|
|
426
|
+
<span class="ui-file-label">${group.name}${submoduleBadge(html)}</span>
|
|
426
427
|
</button>
|
|
427
428
|
${expanded ? html `
|
|
428
429
|
${group.pointer === undefined ? null : renderSelectableRow(html, controller, context, state, group.path, group.pointer.name, group.pointer.file, 1)}
|
|
@@ -437,9 +438,9 @@ function renderTreeNode(html, controller, context, state, node, depth) {
|
|
|
437
438
|
if (node.kind === "directory") {
|
|
438
439
|
const expanded = state.expandedDirectories.has(node.path);
|
|
439
440
|
return html `
|
|
440
|
-
<button type="button" class="
|
|
441
|
-
<span class="
|
|
442
|
-
<span>${node.name}${node.isSubmodule === true ? submoduleBadge(html) : null}</span>
|
|
441
|
+
<button type="button" class="ui-button ui-file-row" style=${`--depth:${String(depth)}`} title=${node.path} aria-expanded=${String(expanded)} @click=${() => { controller.toggleDirectory(context, node.path); }}>
|
|
442
|
+
<span class="ui-file-leading" aria-hidden="true">${expanded ? "▾" : "▸"}</span>
|
|
443
|
+
<span class="ui-file-label">${node.name}${node.isSubmodule === true ? submoduleBadge(html) : null}</span>
|
|
443
444
|
</button>
|
|
444
445
|
${expanded ? node.children.map((child) => renderTreeNode(html, controller, context, state, child, depth + 1)) : null}
|
|
445
446
|
`;
|
|
@@ -452,9 +453,10 @@ function renderFileRow(html, controller, context, state, file) {
|
|
|
452
453
|
function renderSelectableRow(html, controller, context, state, path, label, file, depth) {
|
|
453
454
|
const selected = state.selectedDiffPath === path;
|
|
454
455
|
return html `
|
|
455
|
-
<button type="button" class=${selected ? "
|
|
456
|
-
<span
|
|
457
|
-
<span>${label}</span>
|
|
456
|
+
<button type="button" class=${selected ? "ui-button ui-file-row selected" : "ui-button ui-file-row"} style=${`--depth:${String(depth)}`} title=${path} aria-current=${selected ? "page" : "false"} @click=${() => { controller.selectDiff(context, path); }}>
|
|
457
|
+
<span class="ui-file-leading" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z"></path><path d="M14 2v6h6"></path></svg></span>
|
|
458
|
+
<span class="ui-file-label">${label}</span>
|
|
459
|
+
<span class="ui-file-meta">${stateLabel(file.index, file.workingTree)}</span>
|
|
458
460
|
</button>
|
|
459
461
|
`;
|
|
460
462
|
}
|
|
@@ -516,6 +518,24 @@ function defineGitPanelActivityElement() {
|
|
|
516
518
|
controllerValue;
|
|
517
519
|
contextValue;
|
|
518
520
|
pollTimer;
|
|
521
|
+
integration;
|
|
522
|
+
releaseStyles;
|
|
523
|
+
set stylesheetIntegration(value) {
|
|
524
|
+
if (this.integration === value)
|
|
525
|
+
return;
|
|
526
|
+
this.releaseStyles?.();
|
|
527
|
+
this.releaseStyles = undefined;
|
|
528
|
+
this.integration = value;
|
|
529
|
+
this.registerStyles();
|
|
530
|
+
}
|
|
531
|
+
registerStyles() {
|
|
532
|
+
if (!this.isConnected || this.releaseStyles !== undefined)
|
|
533
|
+
return;
|
|
534
|
+
const root = this.getRootNode();
|
|
535
|
+
// The activity element shares the host panel's root; it owns only this opt-in.
|
|
536
|
+
if (root instanceof ShadowRoot)
|
|
537
|
+
this.releaseStyles = this.integration?.registerRoot(root, { sharedUi: true });
|
|
538
|
+
}
|
|
519
539
|
set controller(value) {
|
|
520
540
|
if (this.controllerValue === value)
|
|
521
541
|
return;
|
|
@@ -529,10 +549,13 @@ function defineGitPanelActivityElement() {
|
|
|
529
549
|
this.restart();
|
|
530
550
|
}
|
|
531
551
|
connectedCallback() {
|
|
552
|
+
this.registerStyles();
|
|
532
553
|
window.addEventListener("popstate", this.onPopState);
|
|
533
554
|
this.restart();
|
|
534
555
|
}
|
|
535
556
|
disconnectedCallback() {
|
|
557
|
+
this.releaseStyles?.();
|
|
558
|
+
this.releaseStyles = undefined;
|
|
536
559
|
window.removeEventListener("popstate", this.onPopState);
|
|
537
560
|
if (this.controllerValue !== undefined && this.contextValue !== undefined)
|
|
538
561
|
this.controllerValue.disconnect(this.contextValue);
|
|
@@ -592,28 +615,20 @@ function errorMessage(error) {
|
|
|
592
615
|
return error instanceof Error ? error.message : String(error);
|
|
593
616
|
}
|
|
594
617
|
const gitPanelStyles = `
|
|
595
|
-
.git-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; color: var(--pi-text); background: var(--pi-bg); font: 13px system-ui, sans-serif; }
|
|
618
|
+
.git-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; color: var(--pi-text); background: var(--pi-bg); font: 13px var(--pi-font, system-ui, sans-serif); }
|
|
596
619
|
.git-panel ${activityElementTag} { display: none; }
|
|
597
|
-
.git-panel button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; cursor: pointer; }
|
|
598
|
-
.git-panel button:disabled { cursor: wait; opacity: .65; }
|
|
599
620
|
.git-panel small, .git-panel .git-muted { color: var(--pi-muted); }
|
|
600
621
|
.git-panel p { margin: 10px; }
|
|
601
|
-
.git-panel .git-toolbar { flex: 0 0 auto;
|
|
602
|
-
.git-panel .git-toolbar-actions {
|
|
603
|
-
.git-panel .git-
|
|
604
|
-
.git-panel .git-
|
|
605
|
-
.git-panel .git-
|
|
606
|
-
.git-panel .git-
|
|
607
|
-
.git-panel .git-view-toggle button.is-selected { position: relative; z-index: 1; border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
608
|
-
.git-panel .git-stale { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); padding: 1px 6px; font-size: 12px; }
|
|
622
|
+
.git-panel .git-toolbar { flex: 0 0 auto; border-bottom: 1px solid var(--pi-border-muted); font-size: 12px; color: var(--pi-muted); }
|
|
623
|
+
.git-panel .git-toolbar-actions { margin-left: auto; }
|
|
624
|
+
.git-panel .git-toolbar > strong { display: flex; align-items: center; padding-inline: 10px; font-weight: 500; }
|
|
625
|
+
.git-panel .git-toolbar .ui-button { white-space: nowrap; }
|
|
626
|
+
.git-panel .git-toolbar .ui-button[aria-pressed="true"] { background: var(--pi-surface-hover); color: var(--pi-text); }
|
|
627
|
+
.git-panel .git-stale { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); padding: 1px 6px; font-size: 12px; align-self: center; }
|
|
609
628
|
.git-panel .git-error { flex: 0 0 auto; margin: 8px; border: 1px solid var(--pi-danger); border-radius: 7px; color: var(--pi-danger); padding: 8px; }
|
|
610
629
|
.git-panel .git-split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(160px, 34%) minmax(0, 1fr); }
|
|
611
|
-
.git-panel .git-file-list {
|
|
612
|
-
.git-panel .git-
|
|
613
|
-
.git-panel .git-row:hover, .git-panel .git-row.is-selected { background: var(--pi-selection-bg); }
|
|
614
|
-
.git-panel .git-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
615
|
-
.git-panel .git-twisty { color: var(--pi-dim, var(--pi-muted)); }
|
|
616
|
-
.git-panel .git-summary { margin: 4px 6px 8px; color: var(--pi-muted); }
|
|
630
|
+
.git-panel .git-file-list { border-bottom: 1px solid var(--pi-border); }
|
|
631
|
+
.git-panel .git-summary { margin: 10px 12px 8px; color: var(--pi-muted); }
|
|
617
632
|
.git-panel .submodule-badge { display: inline-block; margin-left: 6px; border: 1px solid var(--pi-border); border-radius: 999px; color: var(--pi-muted); padding: 0 5px; font-size: 11px; font-weight: 400; vertical-align: baseline; }
|
|
618
633
|
.git-panel .git-viewer { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
|
|
619
634
|
.git-panel .git-diffs { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
|
|
@@ -623,7 +638,7 @@ const gitPanelStyles = `
|
|
|
623
638
|
.git-panel .git-viewer-header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
624
639
|
.git-panel .git-viewer-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
625
640
|
.git-panel .git-diff-scroller { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--pi-bg); }
|
|
626
|
-
.git-panel .git-diff-grid { display: grid; grid-template-columns: max-content max-content 2ch max-content; width: max-content; min-width: 100%; padding: 6px 0; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
641
|
+
.git-panel .git-diff-grid { display: grid; grid-template-columns: max-content max-content 2ch max-content; width: max-content; min-width: 100%; padding: 6px 0; font: 12px var(--pi-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace); line-height: 1.45; }
|
|
627
642
|
.git-panel .git-diff-line { display: contents; }
|
|
628
643
|
.git-panel .git-diff-cell { min-height: 1.45em; white-space: pre; }
|
|
629
644
|
.git-panel .git-line-number { min-width: 4ch; padding: 0 8px; border-right: 1px solid var(--pi-border-muted); color: var(--pi-dim); text-align: right; user-select: none; }
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
// Generated from pi-web-plugins/git/browser/pi-web-plugin.ts. Do not edit directly.
|
|
2
2
|
import { createGitBrowserContributions } from "./git-panel.js";
|
|
3
|
+
const stylesheetIntegrationCapability = {
|
|
4
|
+
pluginId: "pi-web", id: "stylesheet-integration", version: 1,
|
|
5
|
+
parse: (value) => {
|
|
6
|
+
if (!isStylesheetIntegration(value)) {
|
|
7
|
+
throw new Error("Invalid PI WEB stylesheet integration capability v1");
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
function isStylesheetIntegration(value) {
|
|
13
|
+
return typeof value === "object" && value !== null
|
|
14
|
+
&& "registerRoot" in value && typeof value.registerRoot === "function"
|
|
15
|
+
&& "subscribe" in value && typeof value.subscribe === "function"
|
|
16
|
+
&& "createController" in value && typeof value.createController === "function";
|
|
17
|
+
}
|
|
3
18
|
const plugin = {
|
|
4
19
|
apiVersion: 4,
|
|
5
20
|
name: "Git",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
requires: [stylesheetIntegrationCapability],
|
|
22
|
+
activate: ({ pluginId, runtimePluginId, html, svg }) => {
|
|
23
|
+
let stylesheetIntegration;
|
|
24
|
+
return {
|
|
25
|
+
start: ({ capabilities }) => {
|
|
26
|
+
stylesheetIntegration = capabilities.resolve(stylesheetIntegrationCapability);
|
|
27
|
+
},
|
|
28
|
+
contributions: createGitBrowserContributions(pluginId, runtimePluginId, html, svg, () => stylesheetIntegration),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
9
31
|
};
|
|
10
32
|
export default plugin;
|
|
@@ -35,7 +35,7 @@ async function gitStatusWithRunner(runGit, cwd) {
|
|
|
35
35
|
if (result.code !== 0)
|
|
36
36
|
return { isGitRepo: false, hash: hash(result.stdout + result.stderr), files: [], submodules: [] };
|
|
37
37
|
const parsed = parseStatus(result.stdout, { deferSubmodules: true });
|
|
38
|
-
return expandSubmodules(runGit, cwd, parsed, result.stdout);
|
|
38
|
+
return expandSubmodules(runGit, await gitWorktreeRoot(runGit, cwd), parsed, result.stdout);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Merge each dirty submodule's own changes into the flat file list. A moved
|
|
@@ -122,6 +122,9 @@ async function gitDiffWithRunner(runGit, cwd, options) {
|
|
|
122
122
|
let path;
|
|
123
123
|
if (options.path !== undefined && options.path !== "")
|
|
124
124
|
path = normalizeRelativePath(options.path);
|
|
125
|
+
// Status paths and every diff belong to the enclosing repository, not the
|
|
126
|
+
// registered project directory. Keep the session's cwd unchanged.
|
|
127
|
+
cwd = await gitWorktreeRoot(runGit, cwd);
|
|
125
128
|
if (path !== undefined) {
|
|
126
129
|
const owner = await submoduleForPath(runGit, cwd, path);
|
|
127
130
|
if (owner !== undefined)
|
|
@@ -167,6 +170,15 @@ async function submoduleDiff(runGit, owner, path, staged) {
|
|
|
167
170
|
}
|
|
168
171
|
return { path, staged, hash: hash(result.stdout), diff: result.stdout, truncated: result.truncated };
|
|
169
172
|
}
|
|
173
|
+
async function gitWorktreeRoot(runGit, cwd) {
|
|
174
|
+
const result = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
175
|
+
if (result.code !== 0)
|
|
176
|
+
throw new Error(result.stderr.trim() || "Cannot resolve Git worktree root");
|
|
177
|
+
const root = result.stdout.replace(/\r?\n$/u, "");
|
|
178
|
+
if (!isAbsolute(root))
|
|
179
|
+
throw new Error("Git returned an invalid worktree root");
|
|
180
|
+
return root;
|
|
181
|
+
}
|
|
170
182
|
async function isUntracked(runGit, cwd, path) {
|
|
171
183
|
const result = await runGit(cwd, ["ls-files", "--others", "--exclude-standard", "-z", "--", path]);
|
|
172
184
|
return result.code === 0 && result.stdout.split("\0").includes(path);
|
|
@@ -41,7 +41,14 @@ export function createGitWorkspaceProvider(context, instanceNamespace = "") {
|
|
|
41
41
|
throw new Error(`git repository probe ended from signal ${result.signal}`);
|
|
42
42
|
if (result.exitCode !== 0)
|
|
43
43
|
return "pass";
|
|
44
|
-
|
|
44
|
+
if (result.stdout.trim() !== "true")
|
|
45
|
+
return "pass";
|
|
46
|
+
const root = await requireGit(runGit(context, project.path, ["rev-parse", "--show-toplevel"], signal), "resolve the Git worktree root");
|
|
47
|
+
if (root.stdout.trim() === "")
|
|
48
|
+
throw new Error("Git returned an empty worktree root");
|
|
49
|
+
// Folder projects keep their exact working directory; only checkout
|
|
50
|
+
// roots opt into worktree discovery and management.
|
|
51
|
+
return resolve(root.stdout.trim()) === resolve(project.path) ? "claim" : "pass";
|
|
45
52
|
},
|
|
46
53
|
async list(project, signal) {
|
|
47
54
|
const rootResult = await requireGit(runGit(context, project.path, ["rev-parse", "--show-toplevel"], signal), "resolve the Git worktree root");
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
var e=globalThis,t=e.ShadowRoot&&(e.ShadyCSS===void 0||e.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,n=Symbol(),r=new WeakMap,i=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,n=this.t;if(t&&e===void 0){let t=n!==void 0&&n.length===1;t&&(e=r.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&r.set(n,e))}return e}toString(){return this.cssText}},a=e=>new i(typeof e==`string`?e:e+``,void 0,n),o=(e,...t)=>new i(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,n),s=(n,r)=>{if(t)n.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let t of r){let r=document.createElement(`style`),i=e.litNonce;i!==void 0&&r.setAttribute(`nonce`,i),r.textContent=t.cssText,n.appendChild(r)}},c=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return a(t)})(e):e,{is:l,defineProperty:u,getOwnPropertyDescriptor:d,getOwnPropertyNames:
|
|
2
|
-
\f\r]`,A=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,M=/>/g,N=RegExp(`>|${k}(?:([^\\s"'>=/]+)(${k}*=${k}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),P=/'/g,F=/"/g,I=/^(?:script|style|textarea|title)$/i,L=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),R=Symbol.for(`lit-noChange`),z=Symbol.for(`lit-nothing`),B=new WeakMap,V=T.createTreeWalker(T,129);function H(e,t){if(!O(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return x===void 0?t:x.createHTML(t)}var ce=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=A;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===A?c[1]===`!--`?o=j:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=N):(I.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=N):o=M:o===N?c[0]===`>`?(o=i??A,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?N:c[3]===`"`?F:P):o===F||o===P?o=N:o===j||o===M?o=A:(o=N,i=void 0);let d=o===N&&e[t+1].startsWith(`/>`)?` `:``;a+=o===A?n+oe:l>=0?(r.push(s),n.slice(0,l)+S+n.slice(l)+C+d):n+C+(l===-2?t:d)}return[H(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},U=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=ce(t,n);if(this.el=e.createElement(l,r),V.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=V.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(S)){let t=u[o++],n=i.getAttribute(e).split(C),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?ue:r[1]===`?`?de:r[1]===`@`?fe:K}),i.removeAttribute(e)}else e.startsWith(C)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(I.test(i.tagName)){let e=i.textContent.split(C),t=e.length-1;if(t>0){i.textContent=b?b.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],E()),V.nextNode(),c.push({type:2,index:++a});i.append(e[t],E())}}}else if(i.nodeType===8){if(i.data===w)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(C,e+1))!==-1;)c.push({type:7,index:a}),e+=C.length-1}}a++}}static createElement(e,t){let n=T.createElement(`template`);return n.innerHTML=e,n}};function W(e,t,n=e,r){if(t===R)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=D(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=W(e,i._$AS(e,t.values),i,r)),t}var le=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??T).importNode(t,!0);V.currentNode=r;let i=V.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new G(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new pe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=V.nextNode(),a++)}return V.currentNode=T,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},G=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=W(this,e,t),D(e)?e===z||e==null||e===``?(this._$AH!==z&&this._$AR(),this._$AH=z):e!==this._$AH&&e!==R&&this._(e):e._$litType$===void 0?e.nodeType===void 0?se(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==z&&D(this._$AH)?this._$AA.nextSibling.data=e:this.T(T.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=U.createElement(H(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new le(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return t===void 0&&B.set(e.strings,t=new U(e)),t}k(t){O(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(E()),this.O(E()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=y(e).nextSibling;y(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},K=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=z,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=z}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=W(this,e,t,0),a=!D(e)||e!==this._$AH&&e!==R,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=W(this,r[n+o],t,o),s===R&&(s=this._$AH[o]),a||=!D(s)||s!==this._$AH[o],s===z?e=z:e!==z&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},ue=class extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===z?void 0:e}},de=class extends K{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==z)}},fe=class extends K{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=W(this,e,t,0)??z)===R)return;let n=this._$AH,r=e===z&&n!==z||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==z&&(n===z||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},pe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){W(this,e)}},me=v.litHtmlPolyfillSupport;me?.(U,G),(v.litHtmlVersions??=[]).push(`3.3.3`);var he=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new G(t.insertBefore(E(),e),e,void 0,n??{})}return i._$AI(e),i},q=globalThis,J=class extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=he(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};J._$litElement$=!0,J.finalized=!0,q.litElementHydrateSupport?.({LitElement:J});var ge=q.litElementPolyfillSupport;ge?.({LitElement:J}),(q.litElementVersions??=[]).push(`4.2.2`);var _e={attribute:!0,type:String,converter:m,reflect:!1,hasChanged:h},ve=(e=_e,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function Y(e){return(t,n)=>typeof n==`object`?ve(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function X(e){return Y({...e,state:!0,attribute:!1})}function Z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Q;function ye(){return Q??=fetch(new URL(`./mermaid-engine.js`,import.meta.url),{signal:AbortSignal.timeout(3e4)}).then(async e=>{if(!e.ok)throw Error(`Mermaid engine unavailable (${String(e.status)})`);return e.text()}).catch(e=>{throw Q=void 0,e}),Q}function be(e){return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><style>body{margin:0}svg{max-width:100%;height:auto;display:block;margin:auto}</style></head><body><script>${e.replace(/<\/script/giu,`<\\/script`)}<\/script></body></html>`}var $=class extends J{constructor(...e){super(...e),this.loadEngine=ye,this.height=300,this.generation=0}updated(e){(e.has(`input`)||e.has(`loadEngine`))&&this.draw()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.draw()}disconnectedCallback(){super.disconnectedCallback(),this.generation+=1,this.cleanup?.(),this.document=void 0}async draw(){this.cleanup?.(),this.document=void 0;let e=this.input,t=++this.generation;if(e===void 0||e.signal.aborted)return;let n=()=>this.isConnected&&!e.signal.aborted&&t===this.generation,r=t=>{let r=this.renderRoot.querySelector(`iframe`);if(!n()||t.source!==r?.contentWindow)return;let i=t.data;typeof i==`object`&&i&&`type`in i&&(i.type===`mermaid-ready`?r.contentWindow?.postMessage({type:`mermaid-render`,text:e.text},`*`):i.type===`mermaid-error`?(e.fail(Error(`Mermaid could not render this source`)),window.clearTimeout(a)):i.type===`mermaid-rendered`&&`height`in i&&typeof i.height==`number`&&Number.isFinite(i.height)&&(window.clearTimeout(a),this.height=Math.min(1600,Math.max(120,i.height+24))))},i=()=>{this.document=void 0,o()},a=window.setTimeout(()=>{n()&&(this.generation+=1,this.document=void 0,e.fail(Error(`Mermaid preview timed out`))),o()},3e4),o=()=>{window.clearTimeout(a),window.removeEventListener(`message`,r),e.signal.removeEventListener(`abort`,i)};this.cleanup=o,window.addEventListener(`message`,r),e.signal.addEventListener(`abort`,i,{once:!0});try{let e=await this.loadEngine();n()&&(this.document=be(e))}catch(t){n()&&e.fail(t),o()}}render(){return this.document===void 0?L`<p role="status">Rendering diagram…</p>`:L`<iframe title="Mermaid diagram" sandbox="allow-scripts" referrerpolicy="no-referrer" .srcdoc=${this.document} style=${`height:${String(this.height)}px`}></iframe>`}static{this.styles=o`
|
|
1
|
+
var e=globalThis,t=e.ShadowRoot&&(e.ShadyCSS===void 0||e.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,n=Symbol(),r=new WeakMap,i=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,n=this.t;if(t&&e===void 0){let t=n!==void 0&&n.length===1;t&&(e=r.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&r.set(n,e))}return e}toString(){return this.cssText}},a=e=>new i(typeof e==`string`?e:e+``,void 0,n),o=(e,...t)=>new i(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,n),s=(n,r)=>{if(t)n.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let t of r){let r=document.createElement(`style`),i=e.litNonce;i!==void 0&&r.setAttribute(`nonce`,i),r.textContent=t.cssText,n.appendChild(r)}},c=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return a(t)})(e):e,{is:l,defineProperty:u,getOwnPropertyDescriptor:d,getOwnPropertyNames:f,getOwnPropertySymbols:ee,getPrototypeOf:te}=Object,p=globalThis,m=p.trustedTypes,ne=m?m.emptyScript:``,re=p.reactiveElementPolyfillSupport,h=(e,t)=>e,g={toAttribute(e,t){switch(t){case Boolean:e=e?ne:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},_=(e,t)=>!l(e,t),v={attribute:!0,type:String,converter:g,reflect:!1,useDefault:!1,hasChanged:_};Symbol.metadata??=Symbol(`metadata`),p.litPropertyMetadata??=new WeakMap;var y=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=v){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&u(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=d(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??v}static _$Ei(){if(this.hasOwnProperty(h(`elementProperties`)))return;let e=te(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(h(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(h(`properties`))){let e=this.properties,t=[...f(e),...ee(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(c(e))}else e!==void 0&&t.push(c(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?g:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?g:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??_)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};y.elementStyles=[],y.shadowRootOptions={mode:`open`},y[h(`elementProperties`)]=new Map,y[h(`finalized`)]=new Map,re?.({ReactiveElement:y}),(p.reactiveElementVersions??=[]).push(`2.1.2`);var b=globalThis,x=e=>e,S=b.trustedTypes,C=S?S.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,w=`$lit$`,T=`lit$${Math.random().toFixed(9).slice(2)}$`,E=`?`+T,ie=`<${E}>`,D=document,O=()=>D.createComment(``),k=e=>e===null||typeof e!=`object`&&typeof e!=`function`,A=Array.isArray,ae=e=>A(e)||typeof e?.[Symbol.iterator]==`function`,j=`[
|
|
2
|
+
\f\r]`,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,N=/-->/g,oe=/>/g,P=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),se=/'/g,F=/"/g,I=/^(?:script|style|textarea|title)$/i,L=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),R=Symbol.for(`lit-noChange`),z=Symbol.for(`lit-nothing`),B=new WeakMap,V=D.createTreeWalker(D,129);function H(e,t){if(!A(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return C===void 0?t:C.createHTML(t)}var ce=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=M;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===M?c[1]===`!--`?o=N:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=P):(I.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=P):o=oe:o===P?c[0]===`>`?(o=i??M,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?P:c[3]===`"`?F:se):o===F||o===se?o=P:o===N||o===oe?o=M:(o=P,i=void 0);let d=o===P&&e[t+1].startsWith(`/>`)?` `:``;a+=o===M?n+ie:l>=0?(r.push(s),n.slice(0,l)+w+n.slice(l)+T+d):n+T+(l===-2?t:d)}return[H(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},U=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=ce(t,n);if(this.el=e.createElement(l,r),V.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=V.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(w)){let t=u[o++],n=i.getAttribute(e).split(T),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?ue:r[1]===`?`?de:r[1]===`@`?fe:K}),i.removeAttribute(e)}else e.startsWith(T)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(I.test(i.tagName)){let e=i.textContent.split(T),t=e.length-1;if(t>0){i.textContent=S?S.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],O()),V.nextNode(),c.push({type:2,index:++a});i.append(e[t],O())}}}else if(i.nodeType===8){if(i.data===E)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(T,e+1))!==-1;)c.push({type:7,index:a}),e+=T.length-1}}a++}}static createElement(e,t){let n=D.createElement(`template`);return n.innerHTML=e,n}};function W(e,t,n=e,r){if(t===R)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=k(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=W(e,i._$AS(e,t.values),i,r)),t}var le=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??D).importNode(t,!0);V.currentNode=r;let i=V.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new G(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new pe(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=V.nextNode(),a++)}return V.currentNode=D,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},G=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=z,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=W(this,e,t),k(e)?e===z||e==null||e===``?(this._$AH!==z&&this._$AR(),this._$AH=z):e!==this._$AH&&e!==R&&this._(e):e._$litType$===void 0?e.nodeType===void 0?ae(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==z&&k(this._$AH)?this._$AA.nextSibling.data=e:this.T(D.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=U.createElement(H(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new le(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=B.get(e.strings);return t===void 0&&B.set(e.strings,t=new U(e)),t}k(t){A(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(O()),this.O(O()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=x(e).nextSibling;x(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},K=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=z,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=z}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=W(this,e,t,0),a=!k(e)||e!==this._$AH&&e!==R,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=W(this,r[n+o],t,o),s===R&&(s=this._$AH[o]),a||=!k(s)||s!==this._$AH[o],s===z?e=z:e!==z&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===z?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},ue=class extends K{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===z?void 0:e}},de=class extends K{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==z)}},fe=class extends K{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=W(this,e,t,0)??z)===R)return;let n=this._$AH,r=e===z&&n!==z||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==z&&(n===z||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},pe=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){W(this,e)}},me=b.litHtmlPolyfillSupport;me?.(U,G),(b.litHtmlVersions??=[]).push(`3.3.3`);var he=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new G(t.insertBefore(O(),e),e,void 0,n??{})}return i._$AI(e),i},q=globalThis,J=class extends y{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=he(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return R}};J._$litElement$=!0,J.finalized=!0,q.litElementHydrateSupport?.({LitElement:J});var ge=q.litElementPolyfillSupport;ge?.({LitElement:J}),(q.litElementVersions??=[]).push(`4.2.2`);var _e={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:_},ve=(e=_e,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function Y(e){return(t,n)=>typeof n==`object`?ve(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function X(e){return Y({...e,state:!0,attribute:!1})}function Z(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Q;function ye(){return Q??=fetch(new URL(`./mermaid-engine.js`,import.meta.url),{signal:AbortSignal.timeout(3e4)}).then(async e=>{if(!e.ok)throw Error(`Mermaid engine unavailable (${String(e.status)})`);return e.text()}).catch(e=>{throw Q=void 0,e}),Q}function be(e){return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><style>body{margin:0}svg{max-width:100%;height:auto;display:block;margin:auto}</style></head><body><script>${e.replace(/<\/script/giu,`<\\/script`)}<\/script></body></html>`}var $=class extends J{constructor(...e){super(...e),this.loadEngine=ye,this.height=300,this.generation=0}get stylesheetIntegration(){return this.integration}set stylesheetIntegration(e){e!==this.integration&&(this.releaseStyles?.(),this.releaseStyles=void 0,this.integration=e,this.isConnected&&this.renderRoot instanceof ShadowRoot&&(this.releaseStyles=e?.registerRoot(this.renderRoot)))}updated(e){(e.has(`input`)||e.has(`loadEngine`))&&this.draw()}connectedCallback(){super.connectedCallback(),this.renderRoot instanceof ShadowRoot&&(this.releaseStyles??=this.integration?.registerRoot(this.renderRoot)),this.hasUpdated&&this.draw()}disconnectedCallback(){this.releaseStyles?.(),this.releaseStyles=void 0,super.disconnectedCallback(),this.generation+=1,this.cleanup?.(),this.document=void 0}async draw(){this.cleanup?.(),this.document=void 0;let e=this.input,t=++this.generation;if(e===void 0||e.signal.aborted)return;let n=()=>this.isConnected&&!e.signal.aborted&&t===this.generation,r=t=>{let r=this.renderRoot.querySelector(`iframe`);if(!n()||t.source!==r?.contentWindow)return;let i=t.data;typeof i==`object`&&i&&`type`in i&&(i.type===`mermaid-ready`?r.contentWindow?.postMessage({type:`mermaid-render`,text:e.text},`*`):i.type===`mermaid-error`?(e.fail(Error(`Mermaid could not render this source`)),window.clearTimeout(a)):i.type===`mermaid-rendered`&&`height`in i&&typeof i.height==`number`&&Number.isFinite(i.height)&&(window.clearTimeout(a),this.height=Math.min(1600,Math.max(120,i.height+24))))},i=()=>{this.document=void 0,o()},a=window.setTimeout(()=>{n()&&(this.generation+=1,this.document=void 0,e.fail(Error(`Mermaid preview timed out`))),o()},3e4),o=()=>{window.clearTimeout(a),window.removeEventListener(`message`,r),e.signal.removeEventListener(`abort`,i)};this.cleanup=o,window.addEventListener(`message`,r),e.signal.addEventListener(`abort`,i,{once:!0});try{let e=await this.loadEngine();n()&&(this.document=be(e))}catch(t){n()&&e.fail(t),o()}}render(){return this.document===void 0?L`<p role="status">Rendering diagram…</p>`:L`<iframe title="Mermaid diagram" sandbox="allow-scripts" referrerpolicy="no-referrer" .srcdoc=${this.document} style=${`height:${String(this.height)}px`}></iframe>`}static{this.styles=o`
|
|
3
3
|
:host { display: block; }
|
|
4
4
|
iframe { display: block; width: 100%; border: 0; background: white; }
|
|
5
5
|
p { color: var(--pi-muted); }
|
|
6
|
-
`}};Z([Y({attribute:!1})],$.prototype,`input`,void 0),Z([Y({attribute:!1})],$.prototype,`loadEngine`,void 0),Z([X()],$.prototype,`document`,void 0),Z([X()],$.prototype,`height`,void 0);var xe=
|
|
6
|
+
`}};Z([Y({attribute:!1})],$.prototype,`stylesheetIntegration`,null),Z([Y({attribute:!1})],$.prototype,`input`,void 0),Z([Y({attribute:!1})],$.prototype,`loadEngine`,void 0),Z([X()],$.prototype,`document`,void 0),Z([X()],$.prototype,`height`,void 0);var xe=new Set(`flowchart.graph.sequenceDiagram.classDiagram.stateDiagram.stateDiagram-v2.erDiagram.gantt.pie.journey.gitGraph.mindmap.timeline.quadrantChart.requirementDiagram.C4Context.C4Container.C4Component.C4Dynamic.C4Deployment.xychart-beta.block-beta.packet-beta.architecture-beta.kanban.sankey-beta.zenuml`.split(`.`)),Se=new Set(`subgraph.end.direction.style.classDef.class.click.linkStyle.participant.actor.as.activate.deactivate.autonumber.Note.note.over.left.right.of.loop.alt.else.opt.par.and.rect.critical.option.break.create.destroy.box.links.properties.title.accTitle.accDescr.section.dateFormat.axisFormat.excludes.includes.todayMarker.state.hide.namespace.annotation.commit.branch.checkout.switch.merge.cherry-pick.reset.tag.showData.strict.callback.link.cssClass.TB.TD.BT.RL.LR`.split(`.`)),Ce=new Set([`TB`,`TD`,`BT`,`RL`,`LR`]);function we({text:e,signal:t}){t.throwIfAborted();let n=[],r=/[A-Za-z_]\w*(?:-\w+)*/y,i=/\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/y,a=/(?:[<|o*x}]{0,2}(?:-\.+-|-+|={2,}|\.{2})(?:\|[>|]|>>?|[ox*)])?|:::{0,1}|[+=<>~])/y,o=``,s=!0,c=0,l=(e,t,r)=>n.push({from:e,to:t,kind:r});function u(n){let r=e[n],i=n+1;for(;i<e.length&&e[i]!==`\r`&&e[i]!==`
|
|
7
|
+
`;){if(t.throwIfAborted(),e[i]===r)return i+1;e[i]===`\\`&&i+1<e.length&&!/[\r\n]/u.test(e.charAt(i+1))&&i++,i++}return i}for(;c<e.length;){t.throwIfAborted();let n=c,d=e.charAt(c);if(/\s/u.test(d))(d===`
|
|
8
|
+
`||d===`\r`)&&(s=!0),c++;else if(e.startsWith(`%%`,c)){let r=e.startsWith(`%%{`,c),i=r?e.indexOf(`}%%`,c+3):-1;if(r)c=i<0?e.length:i+3;else for(;c<e.length&&e[c]!==`
|
|
9
|
+
`&&e[c]!==`\r`;)t.throwIfAborted(),c++;l(n,c,r?`meta`:`comment`)}else{if(d===`"`||d===`'`)c=u(c),l(n,c,`string`);else if((o===`flowchart`||o===`graph`)&&`[({|`.includes(d)){let r=[d===`|`?`|`:d===`[`?`]`:d===`(`?`)`:`}`];for(c++;c<e.length&&e[c]!==`
|
|
10
|
+
`&&e[c]!==`\r`&&r.length>0;){t.throwIfAborted();let n=e.charAt(c);n===`"`||n===`'`?c=u(c):(n===r[r.length-1]?r.pop():d!==`|`&&`[({`.includes(n)&&r.push(n===`[`?`]`:n===`(`?`)`:`}`),c++)}l(n,c,`string`)}else if(o===`sequenceDiagram`&&d===`:`){l(c,++c,`punctuation`);let n=c;for(;c<e.length&&e[c]!==`\r`&&e[c]!==`
|
|
11
|
+
`;)t.throwIfAborted(),c++;c>n&&l(n,c,`string`)}else{r.lastIndex=c,i.lastIndex=c,a.lastIndex=c;let t=a.exec(e)?.[0],u=t===void 0?r.exec(e)?.[0]:void 0,f=t!==void 0||u!==void 0?void 0:i.exec(e)?.[0];u===void 0?f!==void 0||t!==void 0?(c+=(f??t??``).length,l(n,c,f===void 0?`operator`:`number`)):(c++,`[](){}:;,.|`.includes(d)&&l(n,c,`punctuation`)):(c+=u.length,s&&xe.has(u)?(o=u,l(n,c,`keyword`)):Ce.has(u)?l(n,c,`literal`):Se.has(u)&&l(n,c,`keyword`))}s=!1}}return t.throwIfAborted(),n}var Te={id:`syntax`,languages:[`mermaid`],fileExtensions:[`mmd`,`mermaid`],highlight:we},Ee={pluginId:`pi-web`,id:`stylesheet-integration`,version:1,parse(e){if(!De(e))throw Error(`Stylesheet integration capability v1 requires registerRoot and createController`);return e}};function De(e){return typeof e==`object`&&!!e&&`registerRoot`in e&&typeof e.registerRoot==`function`&&`createController`in e&&typeof e.createController==`function`&&`subscribe`in e&&typeof e.subscribe==`function`}var Oe={apiVersion:5,name:`Mermaid`,requires:[Ee,{pluginId:`pi-web`,id:`content-rendering`,version:1,parse:()=>void 0}],activate:({html:e})=>{customElements.get(`pi-web-mermaid-preview`)===void 0&&customElements.define(`pi-web-mermaid-preview`,$);let t;return{start:({capabilities:e})=>{t=e.resolve(Ee)},contributions:{syntaxHighlighters:[Te],contentRenderers:[{id:`diagram`,title:`Diagram`,languages:[`mermaid`],fileExtensions:[`mmd`,`mermaid`],render:n=>e`<pi-web-mermaid-preview .stylesheetIntegration=${t} .input=${n} .loadEngine=${ye}></pi-web-mermaid-preview>`}]}}}};export{Oe as default};
|