@celestia-island/hikari 0.55.512 → 0.55.514
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/types/components/HkBoard.d.ts +45 -1
- package/dist/types/components/HkDirectionalSwap.d.ts +27 -0
- package/dist/types/components/HkMermaidDiagram.d.ts +101 -21
- package/dist/types/components/HkMinimap.d.ts +1 -1
- package/dist/types/composables/useBoardCamera.d.ts +11 -1
- package/dist/types/mermaid/layout.d.ts +32 -0
- package/dist/types/utils/boardCamera.d.ts +30 -6
- package/package.json +1 -1
- package/src/components/HkAffixPicker.scss +1 -1
- package/src/components/HkBadge.scss +1 -1
- package/src/components/HkBoard.arrows.test.tsx +116 -4
- package/src/components/HkBoard.percentZoom.test.tsx +122 -0
- package/src/components/HkBoard.scss +49 -13
- package/src/components/HkBoard.tsx +96 -38
- package/src/components/HkBoard3D.scss +2 -1
- package/src/components/HkCurrencySelect.scss +1 -1
- package/src/components/HkDebugFloat.scss +1 -1
- package/src/components/HkDirectionalSwap.scss +19 -1
- package/src/components/HkDirectionalSwap.test.tsx +297 -0
- package/src/components/HkDirectionalSwap.tsx +116 -4
- package/src/components/HkFileBrowserDialog.scss +2 -2
- package/src/components/HkJsonTree.edit.scss +2 -2
- package/src/components/HkJsonTree.scss +2 -2
- package/src/components/HkLogWindow.scss +1 -1
- package/src/components/HkMarkdownEditor.scss +1 -1
- package/src/components/HkMarkdownRenderer.mermaid.test.tsx +13 -0
- package/src/components/HkMarkdownRenderer.tsx +5 -3
- package/src/components/HkMermaidDiagram.loading.test.tsx +61 -0
- package/src/components/HkMermaidDiagram.scss +14 -27
- package/src/components/HkMermaidDiagram.styles.test.ts +13 -22
- package/src/components/HkMermaidDiagram.test.tsx +83 -13
- package/src/components/HkMermaidDiagram.tsx +74 -74
- package/src/components/HkMinimap.scss +2 -2
- package/src/components/HkPersistentToast.scss +2 -2
- package/src/components/HkSecretRevealModal.scss +1 -1
- package/src/components/HkSelectionControls.styles.test.ts +13 -1
- package/src/components/HkSerpentineUnlock.scss +1 -1
- package/src/components/HkSettingsDialog.scss +1 -1
- package/src/components/HkStatusPill.scss +1 -1
- package/src/components/HkTabs.scss +1 -1
- package/src/components/HkTimePicker.scss +3 -3
- package/src/components/__tests__/hkMermaidLayout.test.ts +230 -1
- package/src/composables/useBoardCamera.ts +41 -5
- package/src/errorLandingStandalone/error-landing.html +2 -2
- package/src/mermaid/layout.ts +77 -4
- package/src/plugins/bootLandingDetailsCss.js +1 -1
- package/src/utils/boardCamera.test.ts +90 -0
- package/src/utils/boardCamera.ts +69 -5
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* arrangement, it only standardizes how things connect and move.
|
|
29
29
|
*/
|
|
30
30
|
import { type PropType } from "vue";
|
|
31
|
-
import { type BoardCamera } from "../utils/boardCamera";
|
|
31
|
+
import { type BoardCamera, type BoardZoomLadder } from "../utils/boardCamera";
|
|
32
32
|
import { type BoardAnchorMode, type BoardEdgeStyle } from "../utils/boardEdges";
|
|
33
33
|
import "./HkBoard.scss";
|
|
34
34
|
/**
|
|
@@ -115,6 +115,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
115
115
|
type: BooleanConstructor;
|
|
116
116
|
default: boolean;
|
|
117
117
|
};
|
|
118
|
+
/** Let the overview fold to its map-icon affordance. */
|
|
119
|
+
minimapCollapsible: {
|
|
120
|
+
type: BooleanConstructor;
|
|
121
|
+
default: boolean;
|
|
122
|
+
};
|
|
123
|
+
/** Existing scene boards stay geometric; document diagrams can request
|
|
124
|
+
* exact linear percent rungs. */
|
|
125
|
+
zoomLadder: {
|
|
126
|
+
type: PropType<BoardZoomLadder>;
|
|
127
|
+
default: string;
|
|
128
|
+
};
|
|
129
|
+
zoomStepPercent: {
|
|
130
|
+
type: NumberConstructor;
|
|
131
|
+
default: number;
|
|
132
|
+
};
|
|
118
133
|
/** `"clamp"` (default): content smaller than the viewport re-centers,
|
|
119
134
|
* so a fitted board cannot be dragged. `"float"`: it may be dragged
|
|
120
135
|
* while half of it stays in view — a diagram is content a reader
|
|
@@ -139,6 +154,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
139
154
|
type: NumberConstructor;
|
|
140
155
|
default: undefined;
|
|
141
156
|
};
|
|
157
|
+
/** End-edge safe-area reserve for overlay chrome such as a minimap. */
|
|
158
|
+
fitEndReserve: {
|
|
159
|
+
type: NumberConstructor;
|
|
160
|
+
default: number;
|
|
161
|
+
};
|
|
142
162
|
animated: {
|
|
143
163
|
type: BooleanConstructor;
|
|
144
164
|
default: boolean;
|
|
@@ -177,6 +197,21 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
177
197
|
type: BooleanConstructor;
|
|
178
198
|
default: boolean;
|
|
179
199
|
};
|
|
200
|
+
/** Let the overview fold to its map-icon affordance. */
|
|
201
|
+
minimapCollapsible: {
|
|
202
|
+
type: BooleanConstructor;
|
|
203
|
+
default: boolean;
|
|
204
|
+
};
|
|
205
|
+
/** Existing scene boards stay geometric; document diagrams can request
|
|
206
|
+
* exact linear percent rungs. */
|
|
207
|
+
zoomLadder: {
|
|
208
|
+
type: PropType<BoardZoomLadder>;
|
|
209
|
+
default: string;
|
|
210
|
+
};
|
|
211
|
+
zoomStepPercent: {
|
|
212
|
+
type: NumberConstructor;
|
|
213
|
+
default: number;
|
|
214
|
+
};
|
|
180
215
|
/** `"clamp"` (default): content smaller than the viewport re-centers,
|
|
181
216
|
* so a fitted board cannot be dragged. `"float"`: it may be dragged
|
|
182
217
|
* while half of it stays in view — a diagram is content a reader
|
|
@@ -201,6 +236,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
201
236
|
type: NumberConstructor;
|
|
202
237
|
default: undefined;
|
|
203
238
|
};
|
|
239
|
+
/** End-edge safe-area reserve for overlay chrome such as a minimap. */
|
|
240
|
+
fitEndReserve: {
|
|
241
|
+
type: NumberConstructor;
|
|
242
|
+
default: number;
|
|
243
|
+
};
|
|
204
244
|
animated: {
|
|
205
245
|
type: BooleanConstructor;
|
|
206
246
|
default: boolean;
|
|
@@ -220,10 +260,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
220
260
|
minK: number;
|
|
221
261
|
maxK: number;
|
|
222
262
|
fitCap: number;
|
|
263
|
+
fitEndReserve: number;
|
|
264
|
+
zoomLadder: BoardZoomLadder;
|
|
265
|
+
zoomStepPercent: number;
|
|
223
266
|
nodes: BoardNodeInput[];
|
|
224
267
|
interactive: boolean;
|
|
225
268
|
gridSize: number;
|
|
226
269
|
minimap: boolean;
|
|
270
|
+
minimapCollapsible: boolean;
|
|
227
271
|
pan: BoardPanMode;
|
|
228
272
|
fitOnMount: boolean;
|
|
229
273
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -38,6 +38,20 @@
|
|
|
38
38
|
* - A STALL WATCHDOG, same shape as HkCrossfade's: if the browser wedges
|
|
39
39
|
* the Transition engine (rAF frozen), the frozen leaving item is swept
|
|
40
40
|
* and the wrapper is dropped so keys apply synchronously from then on.
|
|
41
|
+
* - `animateHeight` (OPT-IN, default off) softens the one geometry this
|
|
42
|
+
* grid cannot express: the cell keeps the TALLER generation's height
|
|
43
|
+
* for the whole exchange, so a swap between different-height panes
|
|
44
|
+
* still snaps — taller the moment the exchange starts, shorter the
|
|
45
|
+
* frame it ends (measured on the docs shell's preview/source card,
|
|
46
|
+
* 2026-11-29: 360px → 278px in ONE frame). With the prop on, the
|
|
47
|
+
* wrapper freezes at its rendered height, transitions to the incoming
|
|
48
|
+
* generation's height over the same duration/easing as the travel,
|
|
49
|
+
* and releases back to auto on settle. Reduced motion (duration 0)
|
|
50
|
+
* keeps the snap — the instant change IS that preference. A faster
|
|
51
|
+
* follow-up swap interrupts the running exchange: Vue cancels the
|
|
52
|
+
* enter (which releases), and the next freeze reads the cell's
|
|
53
|
+
* CURRENT rendered height — the interrupted tween's mid-state —
|
|
54
|
+
* never the old start.
|
|
41
55
|
*/
|
|
42
56
|
import { type PropType } from "vue";
|
|
43
57
|
import "./HkDirectionalSwap.scss";
|
|
@@ -88,6 +102,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
88
102
|
type: BooleanConstructor;
|
|
89
103
|
default: boolean;
|
|
90
104
|
};
|
|
105
|
+
/** Animate the wrapper's height across the exchange (see the module
|
|
106
|
+
* note). Default off: every existing host keeps the grid's snap. */
|
|
107
|
+
animateHeight: {
|
|
108
|
+
type: BooleanConstructor;
|
|
109
|
+
default: boolean;
|
|
110
|
+
};
|
|
91
111
|
tag: {
|
|
92
112
|
type: StringConstructor;
|
|
93
113
|
default: string;
|
|
@@ -136,6 +156,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
136
156
|
type: BooleanConstructor;
|
|
137
157
|
default: boolean;
|
|
138
158
|
};
|
|
159
|
+
/** Animate the wrapper's height across the exchange (see the module
|
|
160
|
+
* note). Default off: every existing host keeps the grid's snap. */
|
|
161
|
+
animateHeight: {
|
|
162
|
+
type: BooleanConstructor;
|
|
163
|
+
default: boolean;
|
|
164
|
+
};
|
|
139
165
|
tag: {
|
|
140
166
|
type: StringConstructor;
|
|
141
167
|
default: string;
|
|
@@ -153,5 +179,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
153
179
|
tag: string;
|
|
154
180
|
duration: number;
|
|
155
181
|
travel: number;
|
|
182
|
+
animateHeight: boolean;
|
|
156
183
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
157
184
|
export default _default;
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* gives syntax highlighting). No engine, or a parse failure, or an
|
|
10
10
|
* unsupported diagram type → the source falls back to a plain code
|
|
11
11
|
* block — never a broken surface.
|
|
12
|
-
* - the caller decides the chrome: `minimap`
|
|
13
|
-
* `interactive` gates canvas
|
|
14
|
-
* straight through).
|
|
12
|
+
* - the caller decides the chrome: `minimap` toggles HkBoard's full overview
|
|
13
|
+
* (map + viewport + zoom controls), `interactive` gates canvas gestures.
|
|
15
14
|
*
|
|
16
15
|
* Layout lives in ../mermaid/layout.ts (pure, deterministic); this file
|
|
17
16
|
* only adapts the laid-out model into HkBoard nodes/edges and paints
|
|
@@ -25,15 +24,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
25
24
|
type: StringConstructor;
|
|
26
25
|
required: true;
|
|
27
26
|
};
|
|
28
|
-
/** Show
|
|
29
|
-
*
|
|
30
|
-
* board's own bottom-right dock is an overlay, and at fit zoom it
|
|
31
|
-
* covered the last node of every wide diagram (measured on
|
|
32
|
-
* docs.celestia.world 2026-11-27). */
|
|
27
|
+
/** Show HkBoard's complete bottom-right minimap: node overview, live
|
|
28
|
+
* viewport rectangle, pan gesture and the zoom controls. */
|
|
33
29
|
minimap: {
|
|
34
30
|
type: BooleanConstructor;
|
|
35
31
|
default: boolean;
|
|
36
32
|
};
|
|
33
|
+
/** The full map can fold to its standard map-icon button. */
|
|
34
|
+
minimapCollapsible: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** End-edge space excluded from fit/reset so the default camera does not
|
|
39
|
+
* place nodes beneath the overview. Set 0 to reclaim it. */
|
|
40
|
+
minimapFitReserve: {
|
|
41
|
+
type: NumberConstructor;
|
|
42
|
+
default: number;
|
|
43
|
+
};
|
|
37
44
|
/** Allow dragging / wheel-zooming the canvas (HkBoard pass-through;
|
|
38
45
|
* node taps keep working either way). */
|
|
39
46
|
interactive: {
|
|
@@ -45,16 +52,45 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
45
52
|
type: BooleanConstructor;
|
|
46
53
|
default: boolean;
|
|
47
54
|
};
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
55
|
+
/** Explicit stage height. In auto mode the layout suggestion is capped
|
|
56
|
+
* by maxHeight instead of letting a tall graph take the whole page. */
|
|
50
57
|
height: {
|
|
51
58
|
type: PropType<number | "auto">;
|
|
52
59
|
default: string;
|
|
53
60
|
};
|
|
54
|
-
/**
|
|
61
|
+
/** Auto-height ceiling: px number or any CSS length. Default 40vh;
|
|
62
|
+
* "none" opts out; "auto" keeps the default. An explicit height already
|
|
63
|
+
* expresses the host's size. */
|
|
64
|
+
maxHeight: {
|
|
65
|
+
type: PropType<number | string>;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
68
|
+
/** Linear percent governance. Defaults are deliberately readable: a tall
|
|
69
|
+
* graph pans at 50% rather than auto-fitting into unreadable miniature. */
|
|
70
|
+
minZoomPercent: {
|
|
71
|
+
type: NumberConstructor;
|
|
72
|
+
default: number;
|
|
73
|
+
};
|
|
74
|
+
maxZoomPercent: {
|
|
75
|
+
type: NumberConstructor;
|
|
76
|
+
default: number;
|
|
77
|
+
};
|
|
78
|
+
zoomStepPercent: {
|
|
79
|
+
type: NumberConstructor;
|
|
80
|
+
default: number;
|
|
81
|
+
};
|
|
82
|
+
/** Fit-zoom ceiling; 1 prevents small diagrams from being enlarged. Reset
|
|
83
|
+
* uses the same governance: a long graph returns to its readable floor,
|
|
84
|
+
* not to an arbitrary tiny whole-graph containment scale. */
|
|
55
85
|
fitCap: {
|
|
56
86
|
type: NumberConstructor;
|
|
57
|
-
default:
|
|
87
|
+
default: number;
|
|
88
|
+
};
|
|
89
|
+
/** Standalone diagrams keep a frame. Embedded cards pass false so the
|
|
90
|
+
* outer card owns the only border/radius. */
|
|
91
|
+
framed: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
58
94
|
};
|
|
59
95
|
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
60
96
|
[key: string]: any;
|
|
@@ -64,15 +100,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
64
100
|
type: StringConstructor;
|
|
65
101
|
required: true;
|
|
66
102
|
};
|
|
67
|
-
/** Show
|
|
68
|
-
*
|
|
69
|
-
* board's own bottom-right dock is an overlay, and at fit zoom it
|
|
70
|
-
* covered the last node of every wide diagram (measured on
|
|
71
|
-
* docs.celestia.world 2026-11-27). */
|
|
103
|
+
/** Show HkBoard's complete bottom-right minimap: node overview, live
|
|
104
|
+
* viewport rectangle, pan gesture and the zoom controls. */
|
|
72
105
|
minimap: {
|
|
73
106
|
type: BooleanConstructor;
|
|
74
107
|
default: boolean;
|
|
75
108
|
};
|
|
109
|
+
/** The full map can fold to its standard map-icon button. */
|
|
110
|
+
minimapCollapsible: {
|
|
111
|
+
type: BooleanConstructor;
|
|
112
|
+
default: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** End-edge space excluded from fit/reset so the default camera does not
|
|
115
|
+
* place nodes beneath the overview. Set 0 to reclaim it. */
|
|
116
|
+
minimapFitReserve: {
|
|
117
|
+
type: NumberConstructor;
|
|
118
|
+
default: number;
|
|
119
|
+
};
|
|
76
120
|
/** Allow dragging / wheel-zooming the canvas (HkBoard pass-through;
|
|
77
121
|
* node taps keep working either way). */
|
|
78
122
|
interactive: {
|
|
@@ -84,22 +128,58 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
84
128
|
type: BooleanConstructor;
|
|
85
129
|
default: boolean;
|
|
86
130
|
};
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
131
|
+
/** Explicit stage height. In auto mode the layout suggestion is capped
|
|
132
|
+
* by maxHeight instead of letting a tall graph take the whole page. */
|
|
89
133
|
height: {
|
|
90
134
|
type: PropType<number | "auto">;
|
|
91
135
|
default: string;
|
|
92
136
|
};
|
|
93
|
-
/**
|
|
137
|
+
/** Auto-height ceiling: px number or any CSS length. Default 40vh;
|
|
138
|
+
* "none" opts out; "auto" keeps the default. An explicit height already
|
|
139
|
+
* expresses the host's size. */
|
|
140
|
+
maxHeight: {
|
|
141
|
+
type: PropType<number | string>;
|
|
142
|
+
default: string;
|
|
143
|
+
};
|
|
144
|
+
/** Linear percent governance. Defaults are deliberately readable: a tall
|
|
145
|
+
* graph pans at 50% rather than auto-fitting into unreadable miniature. */
|
|
146
|
+
minZoomPercent: {
|
|
147
|
+
type: NumberConstructor;
|
|
148
|
+
default: number;
|
|
149
|
+
};
|
|
150
|
+
maxZoomPercent: {
|
|
151
|
+
type: NumberConstructor;
|
|
152
|
+
default: number;
|
|
153
|
+
};
|
|
154
|
+
zoomStepPercent: {
|
|
155
|
+
type: NumberConstructor;
|
|
156
|
+
default: number;
|
|
157
|
+
};
|
|
158
|
+
/** Fit-zoom ceiling; 1 prevents small diagrams from being enlarged. Reset
|
|
159
|
+
* uses the same governance: a long graph returns to its readable floor,
|
|
160
|
+
* not to an arbitrary tiny whole-graph containment scale. */
|
|
94
161
|
fitCap: {
|
|
95
162
|
type: NumberConstructor;
|
|
96
|
-
default:
|
|
163
|
+
default: number;
|
|
164
|
+
};
|
|
165
|
+
/** Standalone diagrams keep a frame. Embedded cards pass false so the
|
|
166
|
+
* outer card owns the only border/radius. */
|
|
167
|
+
framed: {
|
|
168
|
+
type: BooleanConstructor;
|
|
169
|
+
default: boolean;
|
|
97
170
|
};
|
|
98
171
|
}>> & Readonly<{}>, {
|
|
99
172
|
height: number | "auto";
|
|
100
173
|
grid: boolean;
|
|
174
|
+
maxHeight: string | number;
|
|
101
175
|
fitCap: number;
|
|
176
|
+
zoomStepPercent: number;
|
|
177
|
+
minZoomPercent: number;
|
|
178
|
+
maxZoomPercent: number;
|
|
102
179
|
interactive: boolean;
|
|
103
180
|
minimap: boolean;
|
|
181
|
+
minimapCollapsible: boolean;
|
|
182
|
+
minimapFitReserve: number;
|
|
183
|
+
framed: boolean;
|
|
104
184
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
105
185
|
export default _default;
|
|
@@ -306,6 +306,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
306
306
|
onReset: () => void;
|
|
307
307
|
zoom: number;
|
|
308
308
|
collapsed: boolean;
|
|
309
|
+
zoomStepPercent: number;
|
|
309
310
|
boxes: MinimapBox[];
|
|
310
311
|
hubPos: {
|
|
311
312
|
x: number;
|
|
@@ -321,7 +322,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
321
322
|
zoomPercent: number;
|
|
322
323
|
canZoomIn: boolean;
|
|
323
324
|
canZoomOut: boolean;
|
|
324
|
-
zoomStepPercent: number;
|
|
325
325
|
minZoomPercent: number;
|
|
326
326
|
maxZoomPercent: number;
|
|
327
327
|
showReset: boolean;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* The component wires DOM events; this composable stays input-agnostic.
|
|
16
16
|
*/
|
|
17
17
|
import { type MaybeRefOrGetter, type Ref } from "vue";
|
|
18
|
-
import { type BoardCamera, type BoardPoint, type BoardRect, type BoardSmallContentPan, type BoardViewport } from "../utils/boardCamera";
|
|
18
|
+
import { type BoardCamera, type BoardPoint, type BoardRect, type BoardSmallContentPan, type BoardViewport, type BoardZoomLadder, type BoardWritingDirection } from "../utils/boardCamera";
|
|
19
19
|
export interface UseBoardCameraOptions {
|
|
20
20
|
/** The viewport element (screen space) — used for anchor math. */
|
|
21
21
|
viewportSize: MaybeRefOrGetter<BoardViewport>;
|
|
@@ -30,6 +30,16 @@ export interface UseBoardCameraOptions {
|
|
|
30
30
|
* library's default cap (BOARD_FIT_CAP). Unset keeps the default; the
|
|
31
31
|
* camera clamp still honours maxK. */
|
|
32
32
|
fitCap?: number;
|
|
33
|
+
/** Logical-pixel reserve at the viewport's end edge (a minimap dock). The
|
|
34
|
+
* fit/reset camera centers content in the remaining safe area. */
|
|
35
|
+
fitEndReserve?: number;
|
|
36
|
+
/** Live writing direction used to place that logical end reserve. */
|
|
37
|
+
fitWritingDirection?: MaybeRefOrGetter<BoardWritingDirection>;
|
|
38
|
+
/** Existing boards keep the geometric 1.05ⁿ ladder. Document diagrams opt
|
|
39
|
+
* into exact linear percent rungs (50%, 55%, 60%…). */
|
|
40
|
+
zoomLadder?: BoardZoomLadder;
|
|
41
|
+
/** Linear rung size; ignored by the geometric ladder. */
|
|
42
|
+
zoomStepPercent?: number;
|
|
33
43
|
/** What a drag does with content smaller than the viewport: `"center"`
|
|
34
44
|
* (default) pins a fitted board, `"keep"` lets it be dragged while half
|
|
35
45
|
* of it stays in view (see BoardSmallContentPan). */
|
|
@@ -79,6 +79,34 @@ export declare function heuristicTextWidth(text: string, fontSize: number, opts?
|
|
|
79
79
|
/** Canvas-backed measure with heuristic fallback (happy-dom has no 2D
|
|
80
80
|
* canvas → the fallback keeps tests deterministic). */
|
|
81
81
|
export declare function createCanvasMeasureText(): MeasureText;
|
|
82
|
+
/** ── Edge-caption width budget (2026-11-29) ──────────────────────────
|
|
83
|
+
* A caption wider than the rank band spilled over the neighbouring
|
|
84
|
+
* rank's node boxes and was painted UNDER them (the caption is board
|
|
85
|
+
* chrome, the boxes are HTML nodes above it) — the chest docs defect:
|
|
86
|
+
* "models and keys" readable only up to the 模型网关 box's edge. Two
|
|
87
|
+
* halves, both keyed off this constant:
|
|
88
|
+
*
|
|
89
|
+
* 1. THE CAP. The board renders captions as HTML chips clamped to
|
|
90
|
+
* `EDGE_LABEL_MAX_W` (world px) with an ellipsis; the full text
|
|
91
|
+
* rides the `title` attribute (the family tooltip bridge upgrades
|
|
92
|
+
* hover, the touch bridge upgrades long-press).
|
|
93
|
+
* 2. THE RESERVATION. Every rank band a captioned edge crosses widens
|
|
94
|
+
* its main-axis gap to `labelW + 2 × EDGE_LABEL_GAP_PAD`, so the
|
|
95
|
+
* chip paints in empty band, not under boxes. Vertical stacks
|
|
96
|
+
* (TD/BT) already clear a caption's HEIGHT inside `GAP_RANK`; only
|
|
97
|
+
* the horizontal directions need real widening. */
|
|
98
|
+
export declare const EDGE_LABEL_MAX_W = 180;
|
|
99
|
+
/** Clearance around a caption chip inside a widened band, per side. The
|
|
100
|
+
* chip itself is wider than its text: 8px padding each side + a 1px
|
|
101
|
+
* border = 18px of chrome, and `translate(-50%,-50%)` centers THAT box
|
|
102
|
+
* on the band midpoint — so the band must clear the chrome too (the R1
|
|
103
|
+
* finding: a caption at the 180 cap poked 9px into the neighbour rank).
|
|
104
|
+
* 24 = 9 (half chrome) + 15 of air. */
|
|
105
|
+
export declare const EDGE_LABEL_GAP_PAD = 24;
|
|
106
|
+
/** The caption's font size — the board's `.hk-board-edge-label` paints
|
|
107
|
+
* 12px; the measurement must use the same size or the reservation and
|
|
108
|
+
* the visible chip disagree. */
|
|
109
|
+
export declare const EDGE_LABEL_FONT = 12;
|
|
82
110
|
interface GraphItem {
|
|
83
111
|
id: string;
|
|
84
112
|
w: number;
|
|
@@ -113,9 +141,13 @@ export declare function feedbackArcSet(items: GraphItem[], edges: RankedEdge[]):
|
|
|
113
141
|
export interface GraphLayoutInput {
|
|
114
142
|
/** World-rect size per node id (already includes card chrome). */
|
|
115
143
|
items: GraphItem[];
|
|
144
|
+
/** `labelW` = the edge caption's CAPPED width (the caller measures and
|
|
145
|
+
* clamps to `EDGE_LABEL_MAX_W`). Bands the edge crosses reserve room
|
|
146
|
+
* for it — see `EDGE_LABEL_GAP_PAD` below. */
|
|
116
147
|
edges: Array<{
|
|
117
148
|
from: string;
|
|
118
149
|
to: string;
|
|
150
|
+
labelW?: number;
|
|
119
151
|
}>;
|
|
120
152
|
direction: MermaidDirection;
|
|
121
153
|
/** Cross-axis gap between same-rank siblings, world px. Cluster frames pad
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* view (half a viewport of slack on each side); content smaller than
|
|
16
16
|
* the viewport re-centers;
|
|
17
17
|
* - `boardFit` fits the whole bbox (pad + cap) and may shrink as far as
|
|
18
|
-
* needed to show the whole board
|
|
19
|
-
* ladder
|
|
18
|
+
* needed to show the whole board on the default geometric ladder; the
|
|
19
|
+
* opt-in percent ladder instead respects its readable minimum and pans;
|
|
20
20
|
* - `boardTweenCam` eases between two cameras with an ease-out curve and
|
|
21
21
|
* GEOMETRIC k interpolation (log-space lerp) so animated zooms still
|
|
22
22
|
* land exactly on ladder rungs.
|
|
@@ -57,6 +57,28 @@ export declare const boardKOf: (level: number) => number;
|
|
|
57
57
|
export declare const boardClampK: (k: number) => number;
|
|
58
58
|
/** Clamp a raw zoom into the legal ladder, snapped to a 5% rung. */
|
|
59
59
|
export declare function quantizeBoardK(k: number): number;
|
|
60
|
+
/** Zoom governance is opt-in per board. Existing scene boards keep the
|
|
61
|
+
* geometric ladder; document diagrams use exact linear percent rungs. */
|
|
62
|
+
export type BoardZoomLadder = "geometric" | "percent";
|
|
63
|
+
export type BoardWritingDirection = "ltr" | "rtl";
|
|
64
|
+
export interface BoardFitOptions {
|
|
65
|
+
pad?: number;
|
|
66
|
+
cap?: number;
|
|
67
|
+
/** Reserve on the LOGICAL inline end (right in LTR, left in RTL). */
|
|
68
|
+
endReserve?: number;
|
|
69
|
+
writingDirection?: BoardWritingDirection;
|
|
70
|
+
}
|
|
71
|
+
export interface BoardPercentZoomOptions {
|
|
72
|
+
/** Linear increment in displayed percent (5 means 50%, 55%, 60%…). */
|
|
73
|
+
stepPercent: number;
|
|
74
|
+
minK: number;
|
|
75
|
+
maxK: number;
|
|
76
|
+
/** Fit rounds DOWN so quantizing never crops content that used to fit. */
|
|
77
|
+
direction?: "nearest" | "floor";
|
|
78
|
+
}
|
|
79
|
+
/** Snap to exact linear percent rungs, not `1.05ⁿ` (whose labels become
|
|
80
|
+
* 110%, 116%, 122%…). The host's own min/max apply here as well. */
|
|
81
|
+
export declare function quantizeBoardPercentK(k: number, options: BoardPercentZoomOptions): number;
|
|
60
82
|
/**
|
|
61
83
|
* Quantize a zoom CHANGE (relative rung ladder anchored at `base`):
|
|
62
84
|
* base·ratio stays exactly on `base·1.05ⁿ`, so a pinch always feels like
|
|
@@ -115,10 +137,12 @@ export declare function boardClampPan(cam: BoardCamera, content: BoardRect, view
|
|
|
115
137
|
* vanished. Zero is the honest answer for "no room"; the host re-fits
|
|
116
138
|
* once a real viewport exists (HkBoard's ResizeObserver path).
|
|
117
139
|
*/
|
|
118
|
-
export declare function boardFit(content: BoardRect, viewport: BoardViewport, opts?:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
140
|
+
export declare function boardFit(content: BoardRect, viewport: BoardViewport, opts?: BoardFitOptions): BoardCamera;
|
|
141
|
+
/** Fit on the linear percent ladder. Rounding down preserves the old fit's
|
|
142
|
+
* guarantee when a rung exists; when even the minimum cannot contain the
|
|
143
|
+
* content, the minimum wins and the board becomes pannable instead of
|
|
144
|
+
* shrinking into illegibility. */
|
|
145
|
+
export declare function boardFitPercent(content: BoardRect, viewport: BoardViewport, opts: BoardPercentZoomOptions & BoardFitOptions): BoardCamera;
|
|
122
146
|
export declare const boardEaseOutCubic: (t: number) => number;
|
|
123
147
|
/**
|
|
124
148
|
* Interpolate between two cameras for an animated transition. Pan lerps
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
padding: var(--space-4, 4px) var(--space-16, 16px);
|
|
105
105
|
border: 1px solid var(--border-subtle);
|
|
106
106
|
border-radius: var(--radius-md);
|
|
107
|
-
background:
|
|
107
|
+
background: var(--hi-color-bg-subtle);
|
|
108
108
|
transition: border-color 0.12s ease, background 0.12s ease;
|
|
109
109
|
|
|
110
110
|
&:hover {
|
|
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
|
2
2
|
import { createApp, defineComponent, h, nextTick } from "vue";
|
|
3
3
|
|
|
4
4
|
import HkBoard, { type BoardEdgeInput, type BoardNodeInput } from "./HkBoard";
|
|
5
|
+
import { EDGE_LABEL_GAP_PAD } from "../mermaid/layout";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* HkBoard — what a diagram needs from the board beyond "it draws".
|
|
@@ -235,9 +236,16 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
235
236
|
expect(c2y).toBeLessThan(ey);
|
|
236
237
|
expect(path.getAttribute("marker-end")).toMatch(/^url\(#hk-board-ah-/);
|
|
237
238
|
// The caption rides the curve's own midpoint.
|
|
238
|
-
const label = board.container.querySelector(".hk-board-edge-label")!;
|
|
239
|
+
const label = board.container.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
239
240
|
expect(label.textContent).toBe("go");
|
|
240
|
-
|
|
241
|
+
// The caption is an HTML chip now (SVG text cannot be width-clamped):
|
|
242
|
+
// its position reads off the world-coord left/top, centered by the
|
|
243
|
+
// stylesheet's translate(-50%, -50%).
|
|
244
|
+
const chipAt = (el: HTMLElement): [number, number] => [
|
|
245
|
+
Number.parseFloat(el.style.left),
|
|
246
|
+
Number.parseFloat(el.style.top),
|
|
247
|
+
];
|
|
248
|
+
expect(chipAt(label)).toEqual([50, 80]);
|
|
241
249
|
board.unmount();
|
|
242
250
|
});
|
|
243
251
|
|
|
@@ -278,8 +286,11 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
278
286
|
expect(c2x).toBe(ex);
|
|
279
287
|
expect(c2y).toBeLessThan(ey);
|
|
280
288
|
// the middle via is the caption anchor
|
|
281
|
-
const label = board.container.querySelector(".hk-board-edge-label")!;
|
|
282
|
-
expect([
|
|
289
|
+
const label = board.container.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
290
|
+
expect([
|
|
291
|
+
Number.parseFloat(label.style.left),
|
|
292
|
+
Number.parseFloat(label.style.top),
|
|
293
|
+
]).toEqual([40, 113]);
|
|
283
294
|
board.unmount();
|
|
284
295
|
});
|
|
285
296
|
|
|
@@ -357,3 +368,104 @@ describe("HkBoard — arrows arrive head-on", () => {
|
|
|
357
368
|
c.remove();
|
|
358
369
|
});
|
|
359
370
|
});
|
|
371
|
+
|
|
372
|
+
// MUT:board-edge-caption-chips — captions are HTML chips, not SVG text:
|
|
373
|
+
// an SVG caption cannot be width-clamped, so a long one sprawled across
|
|
374
|
+
// the neighbouring rank and painted UNDER the node boxes (the chest docs
|
|
375
|
+
// defect). The chip carries the full text in `title` (family hover
|
|
376
|
+
// bridge → house bubble, touch bridge → long-press bar, bare host →
|
|
377
|
+
// native tooltip) and clamps via the CSS-var max-width whose fallback is
|
|
378
|
+
// the layout's own cap constant — reservation and ellipsis must agree.
|
|
379
|
+
describe("HkBoard — edge caption chips", () => {
|
|
380
|
+
it("renders the caption as a clamped, titled chip above the node layer", async () => {
|
|
381
|
+
const nodes: BoardNodeInput[] = [
|
|
382
|
+
{ id: "a", x: 0, y: 0, w: 100, h: 40, label: "A" },
|
|
383
|
+
{ id: "b", x: 400, y: 0, w: 100, h: 40, label: "B" },
|
|
384
|
+
];
|
|
385
|
+
const edges: BoardEdgeInput[] = [{ id: "e", from: "a", to: "b", label: "models and keys" }];
|
|
386
|
+
const board = mountBoard({ nodes, edges });
|
|
387
|
+
const c = board.container;
|
|
388
|
+
const chip = c.querySelector<HTMLElement>(".hk-board-edge-label")!;
|
|
389
|
+
expect(chip, "the caption chip").toBeTruthy();
|
|
390
|
+
expect(chip.tagName).toBe("DIV");
|
|
391
|
+
expect(chip.textContent).toBe("models and keys");
|
|
392
|
+
// The full text rides `title` for the tooltip bridges — EVERY caption
|
|
393
|
+
// gets one, truncated or not (the user direction: 全部都带 tooltip).
|
|
394
|
+
expect(chip.getAttribute("title")).toBe("models and keys");
|
|
395
|
+
// The clamp is the CSS var whose fallback IS the layout's reservation
|
|
396
|
+
// constant: retuning the var retunes the chip without code changes.
|
|
397
|
+
expect(chip.style.maxWidth).toBe("var(--hk-board-edge-label-max-w, 180px)");
|
|
398
|
+
// The chip layer paints AFTER the nodes (DOM order = paint order):
|
|
399
|
+
// a caption must never again lose a hiding contest with a box.
|
|
400
|
+
const world = c.querySelector(".hk-board-world")!;
|
|
401
|
+
const firstNode = world.querySelector(".hk-board-node")!;
|
|
402
|
+
const layer = chip.parentElement!;
|
|
403
|
+
expect(layer.className).toBe("hk-board-labels");
|
|
404
|
+
expect(
|
|
405
|
+
firstNode.compareDocumentPosition(layer) & Node.DOCUMENT_POSITION_FOLLOWING,
|
|
406
|
+
"the label layer follows the nodes in DOM order",
|
|
407
|
+
).toBeTruthy();
|
|
408
|
+
board.unmount();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("renders end captions (class multiplicities) as titled chips too", async () => {
|
|
412
|
+
const nodes: BoardNodeInput[] = [
|
|
413
|
+
{ id: "a", x: 0, y: 0, w: 100, h: 40, label: "A" },
|
|
414
|
+
{ id: "b", x: 400, y: 0, w: 100, h: 40, label: "B" },
|
|
415
|
+
];
|
|
416
|
+
const edges: BoardEdgeInput[] = [
|
|
417
|
+
{ id: "e", from: "a", to: "b", labelFrom: "1..*", labelTo: "0..1" },
|
|
418
|
+
];
|
|
419
|
+
const board = mountBoard({ nodes, edges });
|
|
420
|
+
const c = board.container;
|
|
421
|
+
const from = c.querySelector<HTMLElement>(".hk-board-edge-endlabel")!;
|
|
422
|
+
expect(from).toBeTruthy();
|
|
423
|
+
expect(from.getAttribute("title")).toBe("1..*");
|
|
424
|
+
const all = [...c.querySelectorAll<HTMLElement>(".hk-board-edge-endlabel")];
|
|
425
|
+
expect(all.map((el) => el.getAttribute("title")).sort()).toEqual(["0..1", "1..*"]);
|
|
426
|
+
// Each end chip clamps on ITS OWN var (default 120), not the caption's
|
|
427
|
+
// (180): a host retuning the caption width must not resize the
|
|
428
|
+
// multiplicities, and a code-only regression that reuses the caption
|
|
429
|
+
// var here turns this red (R1 S3-1).
|
|
430
|
+
for (const chip of all) {
|
|
431
|
+
expect(chip.style.maxWidth).toBe("var(--hk-board-edge-endlabel-max-w, 120px)");
|
|
432
|
+
}
|
|
433
|
+
board.unmount();
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// MUT:board-caption-sheet — the chip's chrome arithmetic backs the
|
|
438
|
+
// layout's band reservation (EDGE_LABEL_GAP_PAD 24 per side clears the
|
|
439
|
+
// 9px half-chrome with air): the sheet must keep the chip's horizontal
|
|
440
|
+
// padding/border at that size, and the two max-width vars stay separate
|
|
441
|
+
// so tuning one caption kind cannot resize the other (R1 S3-1).
|
|
442
|
+
const captionSheet = (await import("node:fs")).readFileSync(
|
|
443
|
+
(await import("node:path")).resolve(__dirname, "./HkBoard.scss"),
|
|
444
|
+
"utf8",
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
describe("HkBoard — caption chip sheet contract", () => {
|
|
448
|
+
const sheet = captionSheet;
|
|
449
|
+
const stripped = sheet.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/[^\n]*/g, "$1");
|
|
450
|
+
const ruleBody = (selector: string): string | null => {
|
|
451
|
+
const at = stripped.indexOf(selector);
|
|
452
|
+
if (at < 0) return null;
|
|
453
|
+
const open = stripped.indexOf("{", at);
|
|
454
|
+
const close = stripped.indexOf("}", open);
|
|
455
|
+
return close > open ? stripped.slice(open + 1, close) : null;
|
|
456
|
+
};
|
|
457
|
+
it("keeps the chip chrome inside the reservation budget", () => {
|
|
458
|
+
const body = ruleBody(".hk-board-edge-label {")!;
|
|
459
|
+
expect(body).toMatch(/padding:\s*2px 8px/);
|
|
460
|
+
expect(body).toMatch(/border:\s*1px solid/);
|
|
461
|
+
expect(body).toMatch(/max-width:\s*var\(--hk-board-edge-label-max-w/);
|
|
462
|
+
// 9 (half chrome: 8px padding + 1px border, per side) must stay under
|
|
463
|
+
// the layout's per-side clearance, or a capped chip pokes into the
|
|
464
|
+
// neighbouring rank again (R1 measured the 9px poke at the cap).
|
|
465
|
+
expect(EDGE_LABEL_GAP_PAD).toBeGreaterThan(9);
|
|
466
|
+
});
|
|
467
|
+
it("endlabels carry their own width var, not the caption's", () => {
|
|
468
|
+
const body = ruleBody(".hk-board-edge-endlabel {")!;
|
|
469
|
+
expect(body).toMatch(/max-width:\s*var\(--hk-board-edge-endlabel-max-w,\s*120px\)/);
|
|
470
|
+
});
|
|
471
|
+
});
|