@andorra-labs/code 0.1.8 → 0.1.10
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/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/src/account-presentation.d.ts +11 -0
- package/dist/src/account-presentation.js +29 -2
- package/dist/src/agent-execution.js +57 -4
- package/dist/src/agent-mcp.d.ts +12 -0
- package/dist/src/agent-mcp.js +81 -2
- package/dist/src/app-server/protocol.d.ts +120 -1
- package/dist/src/app-server/protocol.js +8 -1
- package/dist/src/app-server/reasoning.d.ts +0 -8
- package/dist/src/app-server/reasoning.js +15 -28
- package/dist/src/app-server.d.ts +32 -0
- package/dist/src/app-server.js +214 -21
- package/dist/src/auth/AuthManager.d.ts +15 -0
- package/dist/src/auth/AuthManager.js +66 -7
- package/dist/src/auth/index.d.ts +1 -1
- package/dist/src/auth/index.js +1 -1
- package/dist/src/auth/store.d.ts +17 -1
- package/dist/src/auth/store.js +25 -2
- package/dist/src/browser-runner.js +1 -2
- package/dist/src/browser-server.js +10 -2
- package/dist/src/browser-session.js +6 -2
- package/dist/src/browser-stealth.d.ts +29 -0
- package/dist/src/browser-stealth.js +166 -0
- package/dist/src/browser-ui/app.js +123 -28
- package/dist/src/browser-ui/icons/chevron-right.svg +8 -0
- package/dist/src/browser-ui/index.html +8 -8
- package/dist/src/browser-ui/style.css +199 -171
- package/dist/src/browser-ui/tokens.css +198 -0
- package/dist/src/browser-view.d.ts +57 -9
- package/dist/src/browser-view.js +187 -36
- package/dist/src/cli.js +31 -9
- package/dist/src/coding-tools.js +9 -5
- package/dist/src/command-screens.js +4 -4
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +3 -2
- package/dist/src/completion-gates.d.ts +35 -0
- package/dist/src/completion-gates.js +25 -0
- package/dist/src/completion.d.ts +7 -1
- package/dist/src/completion.js +37 -4
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/context-budget.d.ts +11 -0
- package/dist/src/context-budget.js +13 -0
- package/dist/src/decision/DecisionEngine.d.ts +5 -1
- package/dist/src/decision/DecisionManager.d.ts +1 -0
- package/dist/src/decision/DecisionManager.js +14 -3
- package/dist/src/decision/FactContinuations.d.ts +6 -0
- package/dist/src/decision/FactContinuations.js +9 -1
- package/dist/src/decision/FactServiceGate.js +1 -1
- package/dist/src/decision/checks.js +1 -1
- package/dist/src/decision/hostedSkills.d.ts +37 -0
- package/dist/src/decision/hostedSkills.js +64 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +10 -2
- package/dist/src/decision/providers/AndorraDecisionProvider.js +121 -10
- package/dist/src/default-graph.d.ts +11 -0
- package/dist/src/default-graph.js +20 -0
- package/dist/src/duration.d.ts +13 -2
- package/dist/src/duration.js +27 -3
- package/dist/src/file-diff.d.ts +105 -0
- package/dist/src/file-diff.js +244 -0
- package/dist/src/graph-manager-chat.d.ts +302 -0
- package/dist/src/graph-manager-chat.js +940 -0
- package/dist/src/graph-runner.js +6 -0
- package/dist/src/graph-server.d.ts +9 -0
- package/dist/src/graph-server.js +171 -20
- package/dist/src/graph-studio-features.js +2 -2
- package/dist/src/graph-sync.js +5 -2
- package/dist/src/graph-ui/app.js +369 -183
- package/dist/src/graph-ui/controls.css +55 -32
- package/dist/src/graph-ui/controls.js +85 -9
- package/dist/src/graph-ui/edge-router.js +114 -13
- package/dist/src/graph-ui/embed.js +32 -17
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +4 -4
- package/dist/src/graph-ui/library.css +4 -10
- package/dist/src/graph-ui/manager-markdown.js +155 -0
- package/dist/src/graph-ui/manager-state.js +191 -0
- package/dist/src/graph-ui/manager.css +161 -0
- package/dist/src/graph-ui/manager.js +700 -0
- package/dist/src/graph-ui/skill-picker.js +6 -6
- package/dist/src/graph-ui/studio-canvas.js +17 -15
- package/dist/src/graph-ui/studio.css +24 -23
- package/dist/src/graph-ui/studio.js +69 -48
- package/dist/src/graph-ui/style.css +128 -93
- package/dist/src/graph-ui/theme.js +2 -2
- package/dist/src/graph-ui/tokens.css +217 -151
- package/dist/src/graphs.d.ts +76 -2
- package/dist/src/graphs.js +172 -9
- package/dist/src/hardened-runtime.js +8 -2
- package/dist/src/mcp.d.ts +75 -0
- package/dist/src/mcp.js +240 -8
- package/dist/src/membership-errors.d.ts +14 -0
- package/dist/src/membership-errors.js +24 -1
- package/dist/src/membership.d.ts +20 -0
- package/dist/src/membership.js +45 -16
- package/dist/src/palette.d.ts +25 -8
- package/dist/src/palette.js +26 -8
- package/dist/src/provider-engine.d.ts +4 -4
- package/dist/src/provider-engine.js +39 -22
- package/dist/src/provider-keys.d.ts +5 -1
- package/dist/src/provider-keys.js +7 -3
- package/dist/src/provider-settings.d.ts +4 -1
- package/dist/src/provider-settings.js +46 -5
- package/dist/src/providers.d.ts +24 -0
- package/dist/src/providers.js +47 -2
- package/dist/src/qa/guidance.d.ts +26 -0
- package/dist/src/qa/guidance.js +46 -0
- package/dist/src/qa/index.d.ts +1 -8
- package/dist/src/qa/index.js +1 -16
- package/dist/src/qa/profile/QaProfile.d.ts +5 -1
- package/dist/src/qa/profile/QaProfile.js +6 -2
- package/dist/src/qa/runtime/ProcessManager.d.ts +20 -2
- package/dist/src/qa/runtime/ProcessManager.js +69 -13
- package/dist/src/qa/tools.d.ts +19 -1
- package/dist/src/qa/tools.js +20 -145
- package/dist/src/react-runtime.d.ts +11 -0
- package/dist/src/react-runtime.js +203 -53
- package/dist/src/remote/engine-pool.js +21 -6
- package/dist/src/run-progress.d.ts +6 -0
- package/dist/src/run-progress.js +7 -0
- package/dist/src/runtime.d.ts +8 -0
- package/dist/src/screen-selection.d.ts +38 -0
- package/dist/src/screen-selection.js +103 -0
- package/dist/src/session-changes.d.ts +117 -0
- package/dist/src/session-changes.js +796 -0
- package/dist/src/session-skills.d.ts +75 -0
- package/dist/src/session-skills.js +151 -0
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +6 -12
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/control-browser/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +8 -0
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/skills/bundled/web-gui-tester/SKILL.md +1 -1
- package/dist/src/stall-recovery.d.ts +33 -0
- package/dist/src/stall-recovery.js +83 -0
- package/dist/src/subagent-run.js +1 -2
- package/dist/src/telemetry/schema.d.ts +1 -1
- package/dist/src/telemetry/schema.js +1 -2
- package/dist/src/terminal-ui.d.ts +66 -22
- package/dist/src/terminal-ui.js +327 -92
- package/dist/src/tool-diff-stats.d.ts +9 -0
- package/dist/src/tool-diff-stats.js +20 -0
- package/dist/src/tool-names.d.ts +1 -1
- package/dist/src/tool-result-filter.js +1 -1
- package/dist/src/tools.js +26 -2
- package/dist/src/transcript.d.ts +11 -0
- package/dist/src/transcript.js +23 -3
- package/dist/src/types.d.ts +24 -4
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +55 -15
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/limits.md +9 -0
- package/docs/guides/desktop-app.md +1 -1
- package/docs/guides/graph-builder.md +16 -1
- package/docs/guides/tui.md +9 -9
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +203 -0
- package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +79 -0
- package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +182 -0
- package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +156 -0
- package/package.json +1 -1
- package/tests/chat-side-panel-test-plan.md +1 -1
- package/dist/src/qa/api/http-runner.d.ts +0 -3
- package/dist/src/qa/api/http-runner.js +0 -47
- package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
- package/dist/src/qa/git/ChangeDetector.js +0 -177
- package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
- package/dist/src/qa/git/DiffReviewer.js +0 -115
- package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
- package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
- package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
- package/dist/src/qa/orchestrator/MergeGate.js +0 -40
- package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
- package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
- package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
- package/dist/src/qa/runners/CommandRunner.js +0 -96
- package/dist/src/qa/runners/TestRunner.d.ts +0 -21
- package/dist/src/qa/runners/TestRunner.js +0 -66
- package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
- package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
- package/dist/src/qa/runtime-detect.d.ts +0 -10
- package/dist/src/qa/runtime-detect.js +0 -72
- package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
- package/dist/src/qa/security/DependencyScanner.js +0 -167
- package/dist/src/qa/security/SecretScanner.d.ts +0 -3
- package/dist/src/qa/security/SecretScanner.js +0 -55
|
@@ -16,14 +16,15 @@ input[type="checkbox"], input[type="radio"] {
|
|
|
16
16
|
cursor: pointer; box-shadow: none;
|
|
17
17
|
transition: background-color var(--dur-1) var(--ease-standard), border-color var(--dur-1) var(--ease-standard);
|
|
18
18
|
}
|
|
19
|
-
input[type="checkbox"] { border-radius:
|
|
20
|
-
input[type="radio"] { border-radius:
|
|
19
|
+
input[type="checkbox"] { border-radius: var(--radius-xs); color: var(--on-accent-fill, var(--on-accent)); }
|
|
20
|
+
input[type="radio"] { border-radius: var(--radius-full); }
|
|
21
21
|
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--text-3); }
|
|
22
|
-
|
|
22
|
+
/* On is the accent fill, as a switch's is. */
|
|
23
|
+
input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate { background: var(--accent-fill, var(--accent)); border-color: var(--accent-fill, var(--accent)); }
|
|
23
24
|
input[type="checkbox"]::before {
|
|
24
25
|
content: ""; width: 10px; height: 10px; background: currentColor;
|
|
25
|
-
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3
|
|
26
|
-
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3
|
|
26
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
27
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
27
28
|
transform: scale(0); transition: transform var(--dur-1) var(--ease-standard);
|
|
28
29
|
}
|
|
29
30
|
input[type="checkbox"]:checked::before { transform: scale(1); }
|
|
@@ -33,13 +34,16 @@ input[type="checkbox"]:indeterminate::before {
|
|
|
33
34
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
|
|
34
35
|
}
|
|
35
36
|
input[type="radio"]::before {
|
|
36
|
-
content: ""; width: 8px; height: 8px; border-radius:
|
|
37
|
+
content: ""; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--accent-fill, var(--accent));
|
|
37
38
|
transform: scale(0); transition: transform var(--dur-1) var(--ease-standard);
|
|
38
39
|
}
|
|
39
|
-
input[type="radio"]:checked { border-color: var(--accent); }
|
|
40
|
+
input[type="radio"]:checked { border-color: var(--accent-fill, var(--accent)); }
|
|
40
41
|
input[type="radio"]:checked::before { transform: scale(1); }
|
|
41
|
-
|
|
42
|
-
input[type="checkbox"]:
|
|
42
|
+
/* Disabled takes the disabled ink for its edge and mark rather than fading the whole control. */
|
|
43
|
+
input[type="checkbox"]:disabled, input[type="radio"]:disabled { cursor: default; border-color: var(--text-disabled); background: var(--bg-card); }
|
|
44
|
+
input[type="checkbox"]:disabled:checked, input[type="checkbox"]:disabled:indeterminate { background: var(--text-disabled); border-color: var(--text-disabled); }
|
|
45
|
+
input[type="radio"]:disabled::before { background: var(--text-disabled); }
|
|
46
|
+
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--focus, var(--accent)); outline-offset: 2px; box-shadow: none; }
|
|
43
47
|
|
|
44
48
|
/* Number and search fields ---------------------------------------------------- */
|
|
45
49
|
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
|
|
@@ -54,38 +58,44 @@ input[type="search"]::-webkit-search-cancel-button {
|
|
|
54
58
|
input[type="search"]::-webkit-search-cancel-button:hover { background: var(--text); }
|
|
55
59
|
|
|
56
60
|
/* Select ------------------------------------------------------------------------ */
|
|
57
|
-
/* The closed select is the app's boxed field with its chevron
|
|
61
|
+
/* The closed select is the app's boxed field with its chevron (Lucide's, on the 1.5 stroke, in each
|
|
62
|
+
appearance's muted ink); the list it opens is the panel below. */
|
|
58
63
|
select:not([multiple]) {
|
|
59
64
|
appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; text-overflow: ellipsis;
|
|
60
|
-
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='
|
|
65
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239a9aa4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
|
61
66
|
background-repeat: no-repeat; background-position: right 10px center;
|
|
62
67
|
}
|
|
68
|
+
:root[data-theme='light'] select:not([multiple]) {
|
|
69
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c5d63' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
|
70
|
+
}
|
|
63
71
|
select:not([multiple])[data-open="true"] { border-color: var(--text-3); }
|
|
64
|
-
select:disabled { cursor: default; color: var(--text-
|
|
72
|
+
select:disabled { cursor: default; color: var(--text-disabled); }
|
|
65
73
|
|
|
74
|
+
/* The dropdown is the app's popover: 8px corners, a 4px inset, rows on the 4px radius at the row
|
|
75
|
+
height that fill one ink tier under the pointer or the keys. Group labels are sentence case. */
|
|
66
76
|
.select-panel {
|
|
67
77
|
position: fixed; z-index: 400; min-width: 160px; max-width: min(420px, calc(100vw - 16px));
|
|
68
78
|
display: flex; flex-direction: column; overflow: hidden;
|
|
69
|
-
background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--
|
|
70
|
-
box-shadow: var(--shadow-menu); padding:
|
|
79
|
+
background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
|
|
80
|
+
box-shadow: var(--shadow-menu); padding: var(--space-1); color: var(--text);
|
|
71
81
|
animation: controls-panel-in var(--dur-1) var(--ease-standard);
|
|
72
82
|
}
|
|
73
83
|
.select-list { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
|
|
74
84
|
.select-option {
|
|
75
|
-
display: flex; align-items: center; gap: 8px; min-height:
|
|
76
|
-
border-radius: var(--
|
|
85
|
+
display: flex; align-items: center; gap: 8px; min-height: var(--row-height); padding: 0 8px; flex: 0 0 auto;
|
|
86
|
+
border-radius: var(--radius-xs); cursor: pointer; color: var(--text); min-width: 0; white-space: nowrap;
|
|
77
87
|
font-size: var(--type-row);
|
|
78
88
|
}
|
|
79
|
-
.select-option:hover, .select-option[data-active="true"] { background: var(--bg-
|
|
80
|
-
.select-option[aria-disabled="true"] { color: var(--text-
|
|
89
|
+
.select-option:hover, .select-option[data-active="true"] { background: var(--hover, var(--bg-hover)); }
|
|
90
|
+
.select-option[aria-disabled="true"] { color: var(--text-disabled); cursor: default; }
|
|
81
91
|
.select-option[aria-disabled="true"]:hover { background: transparent; }
|
|
82
92
|
.select-option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
83
93
|
.select-check { display: inline-flex; flex-shrink: 0; color: var(--accent); }
|
|
84
94
|
.select-group {
|
|
85
95
|
padding: 8px 8px 2px; color: var(--text-3); font-size: var(--type-label); font-weight: var(--weight-strong);
|
|
86
|
-
|
|
96
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 0 auto;
|
|
87
97
|
}
|
|
88
|
-
@keyframes controls-panel-in { from { opacity: 0; transform: translateY(-
|
|
98
|
+
@keyframes controls-panel-in { from { opacity: 0; transform: translateY(calc(-1 * var(--pop-distance) / 2)); } }
|
|
89
99
|
|
|
90
100
|
/* Disclosure ------------------------------------------------------------------ */
|
|
91
101
|
details > summary { list-style: none; cursor: pointer; }
|
|
@@ -93,8 +103,8 @@ details > summary::-webkit-details-marker { display: none; }
|
|
|
93
103
|
details > summary::before {
|
|
94
104
|
content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: 0;
|
|
95
105
|
background: var(--text-3);
|
|
96
|
-
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='
|
|
97
|
-
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='
|
|
106
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
107
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
98
108
|
transition: transform var(--dur-2) var(--ease-standard);
|
|
99
109
|
}
|
|
100
110
|
details[open] > summary::before { transform: rotate(90deg); }
|
|
@@ -102,7 +112,7 @@ details[open] > summary::before { transform: rotate(90deg); }
|
|
|
102
112
|
/* Scrollbars and resize grip ------------------------------------------------- */
|
|
103
113
|
/* Thin bars on the quiet ink, as in the desktop window; the rail keeps its own fade-in bars. */
|
|
104
114
|
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
105
|
-
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius:
|
|
115
|
+
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-xs); }
|
|
106
116
|
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
|
|
107
117
|
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
|
|
108
118
|
::-webkit-resizer {
|
|
@@ -136,15 +146,28 @@ details[open] > summary::before { transform: rotate(90deg); }
|
|
|
136
146
|
|
|
137
147
|
/* Question dialogs ------------------------------------------------------------ */
|
|
138
148
|
.ask-dialog { width: min(440px, calc(100vw - 40px)); }
|
|
139
|
-
.ask-dialog-body { padding:
|
|
149
|
+
.ask-dialog-body { padding: var(--space-5) var(--space-5) var(--space-4); display: flex; flex-direction: column; gap: 8px; }
|
|
140
150
|
.ask-dialog-title { margin: 0; font-size: var(--type-section); font-weight: var(--weight-strong); overflow-wrap: anywhere; }
|
|
141
151
|
.ask-dialog-message { margin: 0; color: var(--text-2); font-size: var(--type-sm); line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
|
|
142
152
|
.ask-dialog-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
|
|
143
|
-
.ask-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
.ask-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--space-3); }
|
|
154
|
+
/* A destructive question confirms with the ordinary primary button, whose label names the action;
|
|
155
|
+
red is never a button's fill (ADR 0022). Cancel takes the first focus instead (controls.js). */
|
|
156
|
+
|
|
157
|
+
/* Entrances and exits --------------------------------------------------------- */
|
|
158
|
+
/* Every floating layer leaves the way it came, quicker and on the exit curve: menus and dropdowns
|
|
159
|
+
over --dur-1, dialogs and their backdrop over --dur-2. controls.js marks a leaving layer
|
|
160
|
+
`data-closing` and removes or closes it when the exit ends (AndorraControls.leave). */
|
|
161
|
+
.studio-dialog[open], .library-dialog[open] { animation: controls-dialog-in var(--dur-2) var(--ease-standard); }
|
|
162
|
+
.studio-dialog[open]::backdrop, .library-dialog[open]::backdrop { animation: controls-fade-in var(--dur-2) var(--ease-standard); }
|
|
163
|
+
@keyframes controls-dialog-in { from { opacity: 0; transform: scale(var(--pop-scale)) translateY(var(--pop-distance)); } }
|
|
164
|
+
@keyframes controls-dialog-out { to { opacity: 0; transform: scale(var(--pop-scale)) translateY(var(--pop-distance)); } }
|
|
165
|
+
@keyframes controls-panel-out { to { opacity: 0; transform: translateY(calc(-1 * var(--pop-distance) / 2)); } }
|
|
166
|
+
@keyframes controls-fade-in { from { opacity: 0; } }
|
|
167
|
+
@keyframes controls-fade-out { to { opacity: 0; } }
|
|
168
|
+
:is(.menu-list, .select-panel)[data-closing] { animation: controls-panel-out var(--dur-1) var(--ease-exit) forwards; pointer-events: none; }
|
|
169
|
+
:is(.studio-dialog, .library-dialog)[open][data-closing] { animation: controls-dialog-out var(--dur-2) var(--ease-exit) forwards; pointer-events: none; }
|
|
170
|
+
:is(.studio-dialog, .library-dialog)[open][data-closing]::backdrop { animation: controls-fade-out var(--dur-2) var(--ease-exit) forwards; }
|
|
148
171
|
/* The keyboard reference: keys on the left as keycaps, what they do on the right. */
|
|
149
172
|
.shortcut-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 4px 0 0; align-items: center; }
|
|
150
173
|
.shortcut-list dt { display: flex; align-items: center; gap: 3px; color: var(--text-3); font-size: var(--type-xs); }
|
|
@@ -152,7 +175,7 @@ details[open] > summary::before { transform: rotate(90deg); }
|
|
|
152
175
|
kbd {
|
|
153
176
|
display: inline-block; min-width: 20px; padding: 1px 6px; text-align: center;
|
|
154
177
|
font-family: var(--font-ui); font-size: var(--type-xs); color: var(--text);
|
|
155
|
-
background: var(--bg-card); border: 1px solid var(--border-strong); border-
|
|
178
|
+
background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
|
|
156
179
|
}
|
|
157
180
|
|
|
158
181
|
/* File drop zone -------------------------------------------------------------- */
|
|
@@ -169,7 +192,7 @@ kbd {
|
|
|
169
192
|
.file-drop[data-state="invalid"] { border-color: color-mix(in srgb, var(--err) 55%, var(--border-strong)); }
|
|
170
193
|
.file-drop-input { display: none; }
|
|
171
194
|
.file-drop-icon {
|
|
172
|
-
flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius:
|
|
195
|
+
flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md);
|
|
173
196
|
background: var(--bg-input); color: var(--text-2); border: 1px solid var(--border);
|
|
174
197
|
}
|
|
175
198
|
.file-drop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -181,7 +204,7 @@ kbd {
|
|
|
181
204
|
|
|
182
205
|
@media (prefers-reduced-motion: reduce) {
|
|
183
206
|
.app-tooltip, .app-tooltip[data-placement="above"] { transform: none; transition: opacity var(--dur-1) linear; }
|
|
184
|
-
.select-panel, .studio-dialog[open] { animation: none; }
|
|
207
|
+
.select-panel, .menu-list, .studio-dialog[open], .library-dialog[open], [data-closing], [data-closing]::backdrop { animation: none; }
|
|
185
208
|
input[type="checkbox"]::before, input[type="radio"]::before, details > summary::before { transition: none; }
|
|
186
209
|
}
|
|
187
210
|
@media (forced-colors: active) {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
* platform's list; choosing a row sets the select's value and fires its `input` and `change`.
|
|
17
17
|
* - Questions. `confirm`, `alert` and `prompt` are the app's dialogs, answered through a promise.
|
|
18
18
|
* - Files. `filePicker` is the app's drop zone and button around a hidden file input.
|
|
19
|
+
* - Exits. A menu, dropdown or dialog leaves the way it came (`leave`, `closeDialog`): it is marked
|
|
20
|
+
* `data-closing`, controls.css plays its exit, and it is removed or closed when that ends, as the
|
|
21
|
+
* desktop's floating layers do (desktop/src/engine/exitMotion.ts).
|
|
19
22
|
*
|
|
20
23
|
* The desktop client draws the same controls (desktop/src/engine/tooltips.ts, Select, ConfirmDialog);
|
|
21
24
|
* the two share tokens, so the editor in the window and the window around it read as one surface.
|
|
@@ -45,6 +48,70 @@
|
|
|
45
48
|
const hostFor = anchor => anchor?.closest?.('dialog[open]') || document.body;
|
|
46
49
|
const escapeKey = event => event.key === 'Escape' && !event.isComposing && event.keyCode !== 229;
|
|
47
50
|
|
|
51
|
+
// ------------------------------------------------------------------ Exits
|
|
52
|
+
|
|
53
|
+
/** The longest a leaving layer is held: a stylesheet without an exit rule must not leave one behind. */
|
|
54
|
+
const EXIT_CEILING_MS = 400;
|
|
55
|
+
const CLOSING = 'data-closing';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Let a floating layer leave the way it came, then run `done` (remove it, hide it, close it).
|
|
59
|
+
*
|
|
60
|
+
* The layer is marked `data-closing`, which starts its exit animation in controls.css; `done` runs
|
|
61
|
+
* when that animation ends, or at once where nothing animates (reduced motion, a harness without
|
|
62
|
+
* animations, a layer with no exit rule), and never later than the ceiling. A leaving layer takes
|
|
63
|
+
* no pointer or focus and gives up its id, so a layer opened again at once does not share one.
|
|
64
|
+
* Returns a function that cancels the exit and keeps the layer, for a menu reopened mid-exit.
|
|
65
|
+
*/
|
|
66
|
+
function leave(layer, done) {
|
|
67
|
+
let finished = false;
|
|
68
|
+
const finish = () => {
|
|
69
|
+
if (finished) return;
|
|
70
|
+
finished = true;
|
|
71
|
+
clearTimeout(ceiling);
|
|
72
|
+
layer?.removeAttribute?.(CLOSING);
|
|
73
|
+
done();
|
|
74
|
+
};
|
|
75
|
+
let ceiling;
|
|
76
|
+
if (!layer?.isConnected || typeof layer.getAnimations !== 'function' || reducedMotion()) { finish(); return () => {}; }
|
|
77
|
+
layer.setAttribute(CLOSING, '');
|
|
78
|
+
const running = layer.getAnimations().filter(animation => animation.playState !== 'finished');
|
|
79
|
+
if (!running.length) { finish(); return () => {}; }
|
|
80
|
+
ceiling = setTimeout(finish, EXIT_CEILING_MS);
|
|
81
|
+
void Promise.allSettled(running.map(animation => animation.finished)).then(finish);
|
|
82
|
+
return () => {
|
|
83
|
+
if (finished) return;
|
|
84
|
+
finished = true;
|
|
85
|
+
clearTimeout(ceiling);
|
|
86
|
+
layer.removeAttribute(CLOSING);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Close a modal dialog the way it opened: its exit plays (with its backdrop) and only then does the
|
|
92
|
+
* platform close it, so `close` listeners still run once and in order. A dialog already leaving is
|
|
93
|
+
* left alone, so a second Escape or click does not close it twice.
|
|
94
|
+
*/
|
|
95
|
+
function closeDialog(dialog, returnValue) {
|
|
96
|
+
if (!dialog?.open || dialog.hasAttribute?.(CLOSING)) return;
|
|
97
|
+
leave(dialog, () => { if (dialog.open) dialog.close(returnValue); });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Escape on a modal dialog leaves with the same motion as its own Close. The platform's `cancel`
|
|
102
|
+
* would close it in one frame, so it is taken over; when the platform does not let it be cancelled
|
|
103
|
+
* (a repeated Escape with no activation between), the dialog simply closes at once.
|
|
104
|
+
*/
|
|
105
|
+
function installDialogExits() {
|
|
106
|
+
document.addEventListener('cancel', event => {
|
|
107
|
+
const dialog = event.target;
|
|
108
|
+
if (!dialog || dialog.tagName !== 'DIALOG' || !dialog.matches?.('.studio-dialog, .library-dialog')) return;
|
|
109
|
+
if (!event.cancelable) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
closeDialog(dialog);
|
|
112
|
+
}, true);
|
|
113
|
+
}
|
|
114
|
+
|
|
48
115
|
/** Where a floating surface goes: below its anchor, above when below has no room and above has more, inside the viewport. */
|
|
49
116
|
function place(anchor, size, viewport, align = 'center') {
|
|
50
117
|
const below = viewport.height - anchor.bottom - GAP - MARGIN;
|
|
@@ -355,7 +422,11 @@
|
|
|
355
422
|
select.removeAttribute('aria-controls');
|
|
356
423
|
select.removeAttribute('aria-activedescendant');
|
|
357
424
|
delete select.dataset.open;
|
|
358
|
-
panel.
|
|
425
|
+
// The panel leaves as it came; a panel opened at once for the same select is a new element.
|
|
426
|
+
panel.removeAttribute('id');
|
|
427
|
+
panel.removeAttribute('role');
|
|
428
|
+
panel.setAttribute('aria-hidden', 'true');
|
|
429
|
+
leave(panel, () => panel.remove());
|
|
359
430
|
},
|
|
360
431
|
};
|
|
361
432
|
position();
|
|
@@ -420,11 +491,13 @@
|
|
|
420
491
|
dialog.setAttribute('role', 'alertdialog');
|
|
421
492
|
if (message) { const text = make('p', 'ask-dialog-message', message); text.id = `${dialog.getAttribute('aria-labelledby')}-message`; dialog.setAttribute('aria-describedby', text.id); body.append(text); }
|
|
422
493
|
let answer = false;
|
|
423
|
-
const cancel = button(cancelLabel, '', () => dialog
|
|
424
|
-
|
|
494
|
+
const cancel = button(cancelLabel, '', () => closeDialog(dialog));
|
|
495
|
+
// A destructive question still confirms with the primary button: its label names the action,
|
|
496
|
+
// and red is never a button's fill. Cancel takes the first focus instead.
|
|
497
|
+
const agree = button(confirmLabel, 'primary', () => { if (dialog.hasAttribute?.(CLOSING)) return; answer = true; closeDialog(dialog); });
|
|
425
498
|
body.append(actions(cancel, agree));
|
|
426
499
|
dialog.addEventListener('close', () => { dialog.remove(); resolve(answer); });
|
|
427
|
-
dialog.addEventListener('click', event => { if (event.target === dialog) dialog
|
|
500
|
+
dialog.addEventListener('click', event => { if (event.target === dialog) closeDialog(dialog); });
|
|
428
501
|
document.body.append(dialog);
|
|
429
502
|
dialog.showModal();
|
|
430
503
|
(tone === 'danger' ? cancel : agree).focus();
|
|
@@ -438,10 +511,10 @@
|
|
|
438
511
|
const { dialog, body } = dialogShell(title);
|
|
439
512
|
if (message) body.append(make('p', 'ask-dialog-message', message));
|
|
440
513
|
if (content) body.append(content);
|
|
441
|
-
const close = button(closeLabel, 'primary', () => dialog
|
|
514
|
+
const close = button(closeLabel, 'primary', () => closeDialog(dialog));
|
|
442
515
|
body.append(actions(close));
|
|
443
516
|
dialog.addEventListener('close', () => { dialog.remove(); resolve(); });
|
|
444
|
-
dialog.addEventListener('click', event => { if (event.target === dialog) dialog
|
|
517
|
+
dialog.addEventListener('click', event => { if (event.target === dialog) closeDialog(dialog); });
|
|
445
518
|
document.body.append(dialog);
|
|
446
519
|
dialog.showModal();
|
|
447
520
|
close.focus();
|
|
@@ -464,14 +537,14 @@
|
|
|
464
537
|
input.spellcheck = false;
|
|
465
538
|
if (maxLength) input.maxLength = maxLength;
|
|
466
539
|
let answer = null;
|
|
467
|
-
const cancel = button(cancelLabel, '', () => dialog
|
|
540
|
+
const cancel = button(cancelLabel, '', () => closeDialog(dialog));
|
|
468
541
|
const agree = make('button', 'primary', confirmLabel);
|
|
469
542
|
agree.type = 'submit';
|
|
470
543
|
form.append(input, actions(cancel, agree));
|
|
471
|
-
form.addEventListener('submit', event => { event.preventDefault(); answer = input.value; dialog
|
|
544
|
+
form.addEventListener('submit', event => { event.preventDefault(); if (dialog.hasAttribute?.(CLOSING)) return; answer = input.value; closeDialog(dialog); });
|
|
472
545
|
body.append(form);
|
|
473
546
|
dialog.addEventListener('close', () => { dialog.remove(); resolve(answer); });
|
|
474
|
-
dialog.addEventListener('click', event => { if (event.target === dialog) dialog
|
|
547
|
+
dialog.addEventListener('click', event => { if (event.target === dialog) closeDialog(dialog); });
|
|
475
548
|
document.body.append(dialog);
|
|
476
549
|
dialog.showModal();
|
|
477
550
|
input.focus();
|
|
@@ -562,6 +635,7 @@
|
|
|
562
635
|
|
|
563
636
|
installTooltips();
|
|
564
637
|
installSelects();
|
|
638
|
+
installDialogExits();
|
|
565
639
|
window.AndorraControls = Object.freeze({
|
|
566
640
|
confirm: confirmDialog,
|
|
567
641
|
alert: alertDialog,
|
|
@@ -569,5 +643,7 @@
|
|
|
569
643
|
filePicker,
|
|
570
644
|
closeSelect: closePanel,
|
|
571
645
|
refreshSelect,
|
|
646
|
+
leave,
|
|
647
|
+
closeDialog,
|
|
572
648
|
});
|
|
573
649
|
})();
|
|
@@ -4,7 +4,60 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
4
4
|
const clear = (a, b, boxes) => !boxes.some(r => a.x === b.x
|
|
5
5
|
? a.x > r.x && a.x < r.x + r.width && Math.max(a.y,b.y) > r.y && Math.min(a.y,b.y) < r.y+r.height
|
|
6
6
|
: a.y > r.y && a.y < r.y+r.height && Math.max(a.x,b.x) > r.x && Math.min(a.x,b.x) < r.x+r.width);
|
|
7
|
-
|
|
7
|
+
// Two connections closer than this read as one line: the stroke and its halo are about 6px wide.
|
|
8
|
+
// It matches the 8px between neighbouring lanes, which therefore still count as apart.
|
|
9
|
+
const GAP = 8;
|
|
10
|
+
// How far a crowded row or shaft is moved, and how many times, before the next corridor is tried.
|
|
11
|
+
const NUDGE = 10, NUDGES = 4;
|
|
12
|
+
/** Whether two orthogonal segments run along (almost) the same line and share a stretch of it. */
|
|
13
|
+
function collinear(a, b, c, d) {
|
|
14
|
+
const shared = (p, q, r, s) => Math.min(Math.max(p,q),Math.max(r,s)) - Math.max(Math.min(p,q),Math.min(r,s)) > 0;
|
|
15
|
+
if (a.y === b.y && c.y === d.y && a.x !== b.x && c.x !== d.x) return Math.abs(a.y-c.y) < GAP && shared(a.x,b.x,c.x,d.x);
|
|
16
|
+
if (a.x === b.x && c.x === d.x && a.y !== b.y && c.y !== d.y) return Math.abs(a.x-c.x) < GAP && shared(a.y,b.y,c.y,d.y);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The segments of the routes drawn so far, filed by the line they run along, so a check looks only
|
|
21
|
+
* at the few segments near one line. Each entry remembers whether it is its route's final run and
|
|
22
|
+
* where that route ends: two routes into the same input port necessarily meet on the last stretch
|
|
23
|
+
* before its arrowhead, so those final runs may coincide; everywhere else routes keep apart.
|
|
24
|
+
*/
|
|
25
|
+
function lineIndex(occupied) {
|
|
26
|
+
const rows = new Map(), columns = new Map();
|
|
27
|
+
for (const route of occupied) for (let i = 1; i < route.length; i++) {
|
|
28
|
+
const a = route[i-1], b = route[i];
|
|
29
|
+
if (a.x === b.x && a.y === b.y) continue;
|
|
30
|
+
const table = a.y === b.y ? rows : columns, line = a.y === b.y ? a.y : a.x, bucket = Math.floor(line / GAP);
|
|
31
|
+
if (!table.has(bucket)) table.set(bucket, []);
|
|
32
|
+
table.get(bucket).push({ a, b, final: i === route.length - 1, end: route.at(-1) });
|
|
33
|
+
}
|
|
34
|
+
return { rows, columns, empty: !occupied.length };
|
|
35
|
+
}
|
|
36
|
+
/** Whether segment a-b runs along a drawn segment; `final` and `end` describe a-b the same way. */
|
|
37
|
+
function along(index, a, b, final = false, end = undefined) {
|
|
38
|
+
if (index.empty || (a.x === b.x && a.y === b.y)) return false;
|
|
39
|
+
const table = a.y === b.y ? index.rows : index.columns, bucket = Math.floor((a.y === b.y ? a.y : a.x) / GAP);
|
|
40
|
+
for (let near = bucket - 1; near <= bucket + 1; near++) for (const other of table.get(near) || []) {
|
|
41
|
+
if (final && other.final && end && other.end.x === end.x && other.end.y === end.y) continue;
|
|
42
|
+
if (collinear(a, b, other.a, other.b)) return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/** Whether a route (source to target) would draw over one of the routes indexed in `index`. */
|
|
47
|
+
function crowdsIndex(points, index) {
|
|
48
|
+
if (index.empty) return false;
|
|
49
|
+
const end = points.at(-1);
|
|
50
|
+
for (let i = 1; i < points.length; i++) if (along(index, points[i-1], points[i], i === points.length - 1, end)) return true;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
/** Whether a route would draw over any of the `occupied` routes. */
|
|
54
|
+
const crowds = (points, occupied) => crowdsIndex(points, lineIndex(occupied));
|
|
55
|
+
/**
|
|
56
|
+
* Routes one connection from an output port (`source`) to an input port (`target`) around the cards.
|
|
57
|
+
* `lane` separates connections that share corridors; `occupied` lists the routes already drawn, in
|
|
58
|
+
* a stable order, and a corridor that would draw over one of them is moved aside when it can be.
|
|
59
|
+
*/
|
|
60
|
+
function routeEdge(source, target, rectangles, lane = 0, padding = 12, occupied = []) {
|
|
8
61
|
const escape = padding + 2, start = {x:source.x+escape,y:source.y}, end = {x:target.x-escape,y:target.y};
|
|
9
62
|
const boxes = rectangles.map(r => ({x:r.x-padding,y:r.y-padding,width:r.width+padding*2,height:r.height+padding*2}));
|
|
10
63
|
const unique = values => [...new Set(values)].sort((a,b)=>a-b);
|
|
@@ -14,8 +67,37 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
14
67
|
const unique=points.filter((p,i)=>!i||p.x!==points[i-1].x||p.y!==points[i-1].y);
|
|
15
68
|
return unique.filter((p,i)=>i===0||i===unique.length-1||!((unique[i-1].x===p.x&&p.x===unique[i+1].x)||(unique[i-1].y===p.y&&p.y===unique[i+1].y)));
|
|
16
69
|
};
|
|
17
|
-
const safe = points => points.every((p,i)=>!i||clear(points[i-1],p,boxes));
|
|
18
70
|
const finish = points => simplify([source,...points,target]);
|
|
71
|
+
const clearOfCards = points => points.every((p,i)=>!i||clear(points[i-1],p,boxes));
|
|
72
|
+
const index = lineIndex(occupied);
|
|
73
|
+
// 'ok' draws; 'crowded' clears every card but lies on a connection already drawn; 'blocked' crosses a card.
|
|
74
|
+
const verdict = points => !clearOfCards(points) ? 'blocked' : crowdsIndex(finish(points), index) ? 'crowded' : 'ok';
|
|
75
|
+
// The row `k` steps aside: rows above every endpoint move up, rows below move down, and a row
|
|
76
|
+
// between them tries both.
|
|
77
|
+
const rowNudges = (y, k) => (y <= Math.min(start.y,end.y) ? [-1] : y >= Math.max(start.y,end.y) ? [1] : [1,-1]).map(way=>y+way*NUDGE*k);
|
|
78
|
+
/**
|
|
79
|
+
* The first variant of a corridor that clears every card and every connection drawn before it.
|
|
80
|
+
* `build(row, dx)` draws the corridor along `row` with its shafts moved `dx` outward. Only a
|
|
81
|
+
* corridor that clears the cards and lies on another connection is moved aside; one that crosses
|
|
82
|
+
* a card is left to the next corridor, as it always was, which keeps a dense graph fast and a
|
|
83
|
+
* lone connection routed exactly as before.
|
|
84
|
+
*/
|
|
85
|
+
// The first corridor that cleared the cards but lay on another connection. When no corridor is
|
|
86
|
+
// free of both, it is the route, as it was before routes kept apart: falling through to the grid
|
|
87
|
+
// search instead costs far more on a dense graph and finds no better line.
|
|
88
|
+
let crowdedFallback;
|
|
89
|
+
const corridor = (build, row) => {
|
|
90
|
+
const base = build(row, 0), first = verdict(base);
|
|
91
|
+
if (first === 'ok') return finish(base);
|
|
92
|
+
if (first === 'blocked') return undefined;
|
|
93
|
+
for (let k = 1; k <= NUDGES; k++) {
|
|
94
|
+
for (const points of [...rowNudges(row,k).map(y=>build(y,0)), build(row,NUDGE*k), ...rowNudges(row,k).map(y=>build(y,NUDGE*k))]) {
|
|
95
|
+
if (verdict(points) === 'ok') return finish(points);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
crowdedFallback ??= finish(base);
|
|
99
|
+
return undefined;
|
|
100
|
+
};
|
|
19
101
|
// Most editor layouts have open rows or columns. Check these bounded,
|
|
20
102
|
// inexpensive candidates before building a visibility-grid search.
|
|
21
103
|
const middleX=(start.x+end.x)/2, middleY=(start.y+end.y)/2;
|
|
@@ -31,17 +113,17 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
31
113
|
// crowded layout may block these wider corridors, in which case the
|
|
32
114
|
// existing obstacle-aware search takes over.
|
|
33
115
|
if (target.x <= source.x) {
|
|
34
|
-
const offset=(lane+1)*8
|
|
116
|
+
const offset=(lane+1)*8;
|
|
35
117
|
for (const y of rowCandidates) {
|
|
36
|
-
const
|
|
37
|
-
if(
|
|
118
|
+
const found=corridor((row,dx)=>{const sx=start.x+offset+dx,tx=end.x-offset-dx;return [start,{x:sx,y:start.y},{x:sx,y:row},{x:tx,y:row},{x:tx,y:end.y},end];},y);
|
|
119
|
+
if(found)return found;
|
|
38
120
|
}
|
|
39
121
|
}
|
|
40
|
-
for(const
|
|
41
|
-
[start,{x:middleX,y:start.y},{x:middleX,y:end.y},end],
|
|
42
|
-
[start,{x:start.x,y:
|
|
43
|
-
...rowCandidates.map(y=>[start,{x:start.x,y},{x:end.x,y},end]),
|
|
44
|
-
])if(
|
|
122
|
+
for(const [build,row] of [
|
|
123
|
+
[(_,dx)=>[start,{x:middleX+dx,y:start.y},{x:middleX+dx,y:end.y},end],middleY],
|
|
124
|
+
[(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],middleY],
|
|
125
|
+
...rowCandidates.map(y=>[(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],y]),
|
|
126
|
+
]){const found=corridor(build,row);if(found)return found;}
|
|
45
127
|
// Find a clear shaft beside each endpoint, then use the nearest clear rows.
|
|
46
128
|
// Endpoint rows cannot cross their own cards, hence right/left constraints.
|
|
47
129
|
// These wider corridors have no lane offset, so a blocked lane shaft still
|
|
@@ -51,14 +133,17 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
51
133
|
for(const y of rowCandidates){
|
|
52
134
|
const sx=right.find(x=>clear({x,y:start.y},{x,y},boxes));
|
|
53
135
|
const tx=left.find(x=>clear({x,y:end.y},{x,y},boxes));
|
|
54
|
-
if(sx!==undefined&&tx!==undefined){const
|
|
136
|
+
if(sx!==undefined&&tx!==undefined){const found=corridor((row,dx)=>[start,{x:sx+dx,y:start.y},{x:sx+dx,y:row},{x:tx-dx,y:row},{x:tx-dx,y:end.y},end],y);if(found)return found;}
|
|
55
137
|
}
|
|
138
|
+
if(crowdedFallback)return crowdedFallback;
|
|
56
139
|
const key=(x,y,dir)=>`${x},${y},${dir}`, heuristic=(x,y)=>Math.abs(xs[x]-end.x)+Math.abs(ys[y]-end.y);
|
|
57
140
|
const heap=[];
|
|
58
141
|
function push(item){heap.push(item);let i=heap.length-1;while(i){const p=(i-1)>>1;if(heap[p].score<=item.score)break;heap[i]=heap[p];i=p;}heap[i]=item;}
|
|
59
142
|
function pop(){const first=heap[0],last=heap.pop();if(heap.length){let i=0;while(i*2+1<heap.length){let j=i*2+1;if(j+1<heap.length&&heap[j+1].score<heap[j].score)j++;if(heap[j].score>=last.score)break;heap[i]=heap[j];i=j;}heap[i]=last;}return first;}
|
|
60
143
|
const initial={x:xs.indexOf(start.x),y:ys.indexOf(start.y),dir:0,cost:0,parent:null};
|
|
61
144
|
const costs=new Map([[key(initial.x,initial.y,0),0]]), visibility=new Map();
|
|
145
|
+
// The grid search is the last resort for a card-crowded layout and ignores the routes drawn
|
|
146
|
+
// before it: weighting their lines made it expand many times as far on a dense graph.
|
|
62
147
|
push({...initial,score:heuristic(initial.x,initial.y)});
|
|
63
148
|
let result;
|
|
64
149
|
let expanded=0;
|
|
@@ -73,7 +158,7 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
73
158
|
if(cost>=(costs.get(id)??Infinity))continue;costs.set(id,cost);push({x,y,dir,cost,score:cost+heuristic(x,y),parent:current});
|
|
74
159
|
}
|
|
75
160
|
}
|
|
76
|
-
if(!result && padding > 0)return routeEdge(source,target,rectangles,lane,0);
|
|
161
|
+
if(!result && padding > 0)return routeEdge(source,target,rectangles,lane,0,occupied);
|
|
77
162
|
// Overlapping nodes can enclose a port completely. Keep such edges visible
|
|
78
163
|
// so users can select them and move the overlapping cards apart.
|
|
79
164
|
let points;
|
|
@@ -82,6 +167,22 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
82
167
|
points=[source,...points,target];
|
|
83
168
|
return simplify(points);
|
|
84
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Routes every connection of a graph in the order given, each one kept off the routes before it,
|
|
172
|
+
* so parallel connections never draw on top of each other. The order is the graph's own (its
|
|
173
|
+
* edge list), never the drawing order, so selecting a connection does not move any route.
|
|
174
|
+
* Each entry is `{source, target}` or null for a connection that cannot be drawn; the result
|
|
175
|
+
* keeps those positions.
|
|
176
|
+
*/
|
|
177
|
+
function routeEdges(entries, rectangles) {
|
|
178
|
+
const occupied=[];
|
|
179
|
+
return entries.map((entry,index)=>{
|
|
180
|
+
if(!entry)return null;
|
|
181
|
+
const points=routeEdge(entry.source,entry.target,rectangles,index,undefined,occupied);
|
|
182
|
+
occupied.push(points);
|
|
183
|
+
return points;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
85
186
|
function path(points){return points.map((p,i)=>`${i?'L':'M'} ${p.x} ${p.y}`).join(' ');}
|
|
86
187
|
// The route stays orthogonal, so it still clears every card, but each elbow is drawn as a quarter
|
|
87
188
|
// curve. The radius shrinks on short segments so two neighbouring corners never overlap.
|
|
@@ -113,5 +214,5 @@ globalThis.AndorraEdgeRouter = (() => {
|
|
|
113
214
|
}
|
|
114
215
|
return best||{x:(points[0].x+points.at(-1).x)/2,y:(points[0].y+points.at(-1).y)/2};
|
|
115
216
|
}
|
|
116
|
-
return {routeEdge,path,roundedPath,labelPoint,clear};
|
|
217
|
+
return {routeEdge,routeEdges,crowds,path,roundedPath,labelPoint,clear};
|
|
117
218
|
})();
|