@grida/hud 0.1.0 → 0.2.1
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/README.md +657 -28
- package/dist/core/index.d.mts +181 -0
- package/dist/core/index.d.ts +181 -0
- package/dist/core/index.js +301 -0
- package/dist/core/index.mjs +291 -0
- package/dist/cursor-CxS8EMvm.d.mts +64 -0
- package/dist/cursor-CxS8EMvm.d.ts +64 -0
- package/dist/cursor-DW-uAPVE.mjs +57 -0
- package/dist/cursor-FGiJBdU-.js +80 -0
- package/dist/cursors/index.d.mts +98 -0
- package/dist/cursors/index.d.ts +98 -0
- package/dist/cursors/index.js +188 -0
- package/dist/cursors/index.mjs +185 -0
- package/dist/index-BrfEdWbQ.d.ts +3140 -0
- package/dist/index-Cmbe2X5b.d.mts +3140 -0
- package/dist/index.d.mts +107 -2
- package/dist/index.d.ts +107 -2
- package/dist/index.js +66 -1
- package/dist/index.mjs +3 -2
- package/dist/overlay-CVV4s3IL.d.ts +241 -0
- package/dist/overlay-dsG32baA.d.mts +241 -0
- package/dist/primitives/bedrock.d.mts +47 -0
- package/dist/primitives/bedrock.d.ts +47 -0
- package/dist/primitives/bedrock.js +71 -0
- package/dist/primitives/bedrock.mjs +65 -0
- package/dist/react.d.mts +3 -2
- package/dist/react.d.ts +2 -1
- package/dist/react.js +8 -3
- package/dist/react.mjs +8 -3
- package/dist/surface-BHQVvRFC.js +7356 -0
- package/dist/surface-NHSzUR8r.mjs +6902 -0
- package/dist/types-3wwFisZs.d.mts +296 -0
- package/dist/types-3wwFisZs.d.ts +296 -0
- package/package.json +18 -2
- package/dist/index-CBqCh-ZM.d.mts +0 -734
- package/dist/index-DRBeSiI2.d.ts +0 -734
- package/dist/surface-CNlBaEXn.js +0 -1890
- package/dist/surface-hUEeEVdL.mjs +0 -1808
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as HUDPaintStripes, c as HUDRect, d as HUDSemantic, f as HUDSemanticGroup, i as HUDPaintSolid, l as HUDRule, n as HUDLine, o as HUDPoint, r as HUDPaint, s as HUDPolyline, t as HUDDraw, u as HUDScreenRect } from "./types-3wwFisZs.mjs";
|
|
2
|
+
import { a as cursorEquals, i as RotationCorner, n as CursorRenderer, o as cursorToCss, r as ResizeDirection, t as CursorIcon } from "./cursor-CxS8EMvm.mjs";
|
|
3
|
+
import { $ as computeStripesTileGeometry, $t as DEFAULT_RULER_STRIP, A as TransformBoxHover, At as resolveCenterDragAnchor, B as PointerButton, Bt as compose, C as MIN_CHROME_VISIBLE_SIZE, Ct as DrawCornerRadiusParams, D as VectorHover, Dt as cornerRadiusHandlePosRect, E as RenderShape, Et as cornerRadiusHandlePosLine, F as Intent, Ft as SelectionShape, G as measurementToHUDDraw, Gt as DEFAULT_RULER_ACCENT_BACKGROUND, H as SurfaceResponse, Ht as decompose, I as IntentPhase, It as AffineTransform, J as DEFAULT_STRIPES_ANGLE_DEG, Jt as DEFAULT_RULER_COLOR, K as snapGuideToHUDDraw, Kt as DEFAULT_RULER_ACCENT_COLOR, L as SelectMode, Lt as TransformBoxAction, M as PaddingHover, Mt as Rect, N as PaddingOverlayInput, Nt as SurfaceGesture, O as VectorSubSelection, Ot as cornerRadiusLayoutGroups, P as HUDStyle, Pt as SelectionGroup, Q as buildStripesTile, Qt as DEFAULT_RULER_STEPS, R as Modifiers, Rt as TransformBoxCorners, S as HitShape, St as DEFAULT_CORNER_RADIUS_HIT_SIZE, T as OverlayElement, Tt as cornerRadiusAnchorSign, U as lassoToHUDDraw, Ut as getTransformBoxCorners, V as SurfaceEvent, Vt as cornersToBoxTransform, W as marqueeToHUDDraw, Wt as reduceTransformBox, X as DEFAULT_STRIPES_THICKNESS_PX, Xt as DEFAULT_RULER_FONT, Y as DEFAULT_STRIPES_SPACING_PX, Yt as DEFAULT_RULER_DRAG_THRESHOLD, Z as ResolvedPaint, Zt as DEFAULT_RULER_OVERLAP_THRESHOLD, _ as PADDING_HANDLE_PRIORITY, _t as CornerRadiusHandleLayout, a as SurfaceVisibilityPolicy, an as RulerMark, at as DEFAULT_PARAMETRIC_HIT_SIZE, b as VectorOverlay, bt as DEFAULT_CORNER_RADIUS_HANDLE_INSET, c as VectorSelectionMode, cn as DEFAULT_PIXEL_GRID_COLOR, ct as ParametricHandleGroup, d as TRANSFORM_BOX_CORNER_HIT_SIZE, dn as PixelGridConfig, dt as computeParametricHandleLayout, en as DEFAULT_RULER_TEXT_SIDE_OFFSET, et as resolvePaint, f as TRANSFORM_BOX_CORNER_PRIORITY, fn as drawPixelGrid, ft as drawParametricHandles, g as PADDING_HANDLE_LENGTH, gt as CornerRadiusAnchor, h as buildPaddingOverlay, ht as resolveParametricHandleByDirection, i as SurfaceVisibilityContext, in as RulerConfig, it as DEFAULT_PARAMETRIC_HANDLE_SIZE, j as TransformBoxInput, jt as resolveCornerDragAnchor, k as TransformBoxActiveOp, kt as drawCornerRadius, l as buildTransformBox, ln as DEFAULT_PIXEL_GRID_STEPS, lt as ParametricHandleInput, m as TRANSFORM_BOX_SIDE_PRIORITY, mt as projectParametricHandleValue, n as SurfaceOptions, nn as DrawRulerParams, nt as HUDCanvasOptions, o as VectorBendMode, on as RulerRange, ot as DrawParametricHandlesParams, p as TRANSFORM_BOX_SIDE_HIT_THICKNESS, pt as parametricHandleLayoutGroups, q as filterHUDDrawByGroup, qt as DEFAULT_RULER_BACKGROUND, r as SurfaceVisibility, rn as RulerAxis, rt as DEFAULT_PARAMETRIC_HANDLE_INSET, s as VectorInsertionMode, sn as drawRuler, st as ParametricHandle, t as Surface, tn as DEFAULT_RULER_TICK_HEIGHT, tt as HUDCanvas, u as TRANSFORM_BOX_BODY_PRIORITY, un as DrawPixelGridParams, ut as ParametricHandleLayout, v as PADDING_HANDLE_THICKNESS, vt as CornerRadiusInput, w as MIN_HIT_SIZE, wt as computeCornerRadiusLayout, x as SurfaceChromeGroups, xt as DEFAULT_CORNER_RADIUS_HANDLE_SIZE, y as PADDING_REGION_PRIORITY, yt as CornerRadiusRectangular, z as NO_MODS, zt as TransformBoxOptions } from "./index-Cmbe2X5b.mjs";
|
|
4
|
+
|
|
5
|
+
//#region event/selection-controls.d.ts
|
|
6
|
+
declare const HUDHitPriority: {
|
|
7
|
+
/** Line endpoints — sole resize affordance on lines; nothing outranks them. */readonly ENDPOINT_HANDLE: 10;
|
|
8
|
+
/** Edge priority when promoted (parallel axis violated). Edge strip
|
|
9
|
+
* extends into the body interior on the perpendicular axis when that
|
|
10
|
+
* axis is comfortable; in that case the edge must outrank the
|
|
11
|
+
* (also-promoted) body to keep the resize affordance. */
|
|
12
|
+
readonly RESIZE_HANDLE_EDGE_SMALL: 22;
|
|
13
|
+
/** Body priority when promoted (any axis violated). Lets the user drag
|
|
14
|
+
* from anywhere inside small selections (instead of the corner
|
|
15
|
+
* extension stealing the interior). */
|
|
16
|
+
readonly TRANSLATE_BODY_SMALL: 25;
|
|
17
|
+
/** Side resize handles (N/S/W/E). Lower than corner so that on the 1-px
|
|
18
|
+
* shared boundary between an edge strip and an adjacent corner slot,
|
|
19
|
+
* edge wins ("sides take priority over corners"). */
|
|
20
|
+
readonly RESIZE_HANDLE_EDGE: 30; /** Corner resize handles (NW/NE/SE/SW). */
|
|
21
|
+
readonly RESIZE_HANDLE_CORNER: 31; /** Translate-body — default value. */
|
|
22
|
+
readonly TRANSLATE_BODY: 40;
|
|
23
|
+
/** Rotation halo wraps each resize corner — the rotation hit rect
|
|
24
|
+
* overlaps body, edges, and the resize corner itself, but has the
|
|
25
|
+
* LOWEST priority of any selection-control zone. It only "wins"
|
|
26
|
+
* (becomes the topmost hit) where no other affordance claims the
|
|
27
|
+
* pixel: the L-strip immediately outside the resize-corner outer
|
|
28
|
+
* edges. This is what gives rotation a gap-free wrap around the
|
|
29
|
+
* corner with zero pixel-overlap on the cursor, without ever
|
|
30
|
+
* intruding on the body, the edge resize strips, or the corner
|
|
31
|
+
* resize knob. Do not place anything below this. */
|
|
32
|
+
readonly ROTATE_HANDLE: 50;
|
|
33
|
+
};
|
|
34
|
+
/** The principle constant — the minimum guaranteed length for the body
|
|
35
|
+
* interior on each axis AND for each side strip along its parallel
|
|
36
|
+
* axis. Tunable; everything else derives. */
|
|
37
|
+
declare const MIN_GUARANTEED_INTERACTIVE_DIM = 20;
|
|
38
|
+
/** Below this axis dim, body promotes above corner. Derived from the
|
|
39
|
+
* principle. */
|
|
40
|
+
declare const BODY_FLIP_THRESHOLD: number;
|
|
41
|
+
type SelectionControlRole = {
|
|
42
|
+
kind: "translate";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "resize_corner";
|
|
45
|
+
direction: "nw" | "ne" | "se" | "sw";
|
|
46
|
+
} | {
|
|
47
|
+
kind: "resize_edge";
|
|
48
|
+
direction: "n" | "e" | "s" | "w";
|
|
49
|
+
} | {
|
|
50
|
+
kind: "rotate";
|
|
51
|
+
corner: RotationCorner;
|
|
52
|
+
};
|
|
53
|
+
interface SelectionControlZone {
|
|
54
|
+
rect: Rect;
|
|
55
|
+
priority: number;
|
|
56
|
+
role: SelectionControlRole;
|
|
57
|
+
/** Stable semantic identifier; matches the OverlayElement.label that
|
|
58
|
+
* the chrome builder forwards downstream. */
|
|
59
|
+
label: string;
|
|
60
|
+
}
|
|
61
|
+
interface SelectionControlLayout {
|
|
62
|
+
/** Zones in declaration order. Hit-test resolution is by priority; order
|
|
63
|
+
* serves as tie-break only. */
|
|
64
|
+
zones: SelectionControlZone[];
|
|
65
|
+
/** Whether knobs render visually. False below MIN_CHROME_VISIBLE_SIZE.
|
|
66
|
+
* The body zone exists and is hit-able regardless. */
|
|
67
|
+
controls_visible: boolean;
|
|
68
|
+
/** True when at least one axis is shorter than BODY_FLIP_THRESHOLD,
|
|
69
|
+
* promoting body above corner. */
|
|
70
|
+
small_mode: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @returns { corner, edge } — lengths in screen-px summing to `total`
|
|
74
|
+
* (corner * 2 + edge === total). Each is `>= 0`.
|
|
75
|
+
*
|
|
76
|
+
* Three phases:
|
|
77
|
+
* - **comfortable** (`total >= 2 * corner_preferred + edge_min`):
|
|
78
|
+
* corners at preferred, edge takes the surplus.
|
|
79
|
+
* - **squeezed** (`total >= edge_min`): edge at its min, corners share
|
|
80
|
+
* the remainder.
|
|
81
|
+
* - **tiny** (`total < edge_min`): edge takes everything, corners 0.
|
|
82
|
+
*/
|
|
83
|
+
declare function negotiateAxis(total: number, corner_preferred: number, edge_min: number): {
|
|
84
|
+
corner: number;
|
|
85
|
+
edge: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Compute the selection control layout for a screen-space rect.
|
|
89
|
+
*
|
|
90
|
+
* Pure: no DOM, no global state. Same inputs → same zones.
|
|
91
|
+
*
|
|
92
|
+
* The perimeter ring straddles the bbox edge with `extension =
|
|
93
|
+
* hit_size / 2` overhang outside. Along each axis the run of length
|
|
94
|
+
* `axis_dim + 2 * extension` is split via {@link negotiateAxis} into
|
|
95
|
+
* `[corner | edge | corner]`. The 4 corners and 4 edges in 2D then tile
|
|
96
|
+
* the ring as a strict 3×3 grid of cells — **non-overlapping**. Body
|
|
97
|
+
* sits at rect_screen and may overlap with the ring's inside-bbox half
|
|
98
|
+
* in comfortable mode; priority resolves those overlaps.
|
|
99
|
+
*
|
|
100
|
+
* See the comment block in this file for the full principle.
|
|
101
|
+
*/
|
|
102
|
+
declare function computeSelectionControlLayout(rect_screen: Rect, opts: {
|
|
103
|
+
handle_size: number;
|
|
104
|
+
show_rotation: boolean;
|
|
105
|
+
}): SelectionControlLayout;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { type AffineTransform, BODY_FLIP_THRESHOLD, type CornerRadiusAnchor, type CornerRadiusHandleLayout, type CornerRadiusInput, type CornerRadiusRectangular, type CursorIcon, type CursorRenderer, DEFAULT_CORNER_RADIUS_HANDLE_INSET, DEFAULT_CORNER_RADIUS_HANDLE_SIZE, DEFAULT_CORNER_RADIUS_HIT_SIZE, DEFAULT_PARAMETRIC_HANDLE_INSET, DEFAULT_PARAMETRIC_HANDLE_SIZE, DEFAULT_PARAMETRIC_HIT_SIZE, DEFAULT_PIXEL_GRID_COLOR, DEFAULT_PIXEL_GRID_STEPS, DEFAULT_RULER_ACCENT_BACKGROUND, DEFAULT_RULER_ACCENT_COLOR, DEFAULT_RULER_BACKGROUND, DEFAULT_RULER_COLOR, DEFAULT_RULER_DRAG_THRESHOLD, DEFAULT_RULER_FONT, DEFAULT_RULER_OVERLAP_THRESHOLD, DEFAULT_RULER_STEPS, DEFAULT_RULER_STRIP, DEFAULT_RULER_TEXT_SIDE_OFFSET, DEFAULT_RULER_TICK_HEIGHT, DEFAULT_STRIPES_ANGLE_DEG, DEFAULT_STRIPES_SPACING_PX, DEFAULT_STRIPES_THICKNESS_PX, type DrawCornerRadiusParams, type DrawParametricHandlesParams, type DrawPixelGridParams, type DrawRulerParams, HUDCanvas, type HUDCanvasOptions, type HUDDraw, HUDHitPriority, type HUDLine, type HUDPaint, type HUDPaintSolid, type HUDPaintStripes, type HUDPoint, type HUDPolyline, type HUDRect, type HUDRule, type HUDScreenRect, type HUDSemantic, type HUDSemanticGroup, type HUDStyle, type HitShape, type Intent, type IntentPhase, MIN_CHROME_VISIBLE_SIZE, MIN_GUARANTEED_INTERACTIVE_DIM, MIN_HIT_SIZE, type Modifiers, NO_MODS, type OverlayElement, PADDING_HANDLE_LENGTH, PADDING_HANDLE_PRIORITY, PADDING_HANDLE_THICKNESS, PADDING_REGION_PRIORITY, type PaddingHover, type PaddingOverlayInput, type ParametricHandle, type ParametricHandleGroup, type ParametricHandleInput, type ParametricHandleLayout, type PixelGridConfig, type PointerButton, type RenderShape, type ResizeDirection, type ResolvedPaint, type RotationCorner, type RulerAxis, type RulerConfig, type RulerMark, type RulerRange, type SelectMode, type SelectionControlLayout, type SelectionControlRole, type SelectionControlZone, type SelectionGroup, type SelectionShape, Surface, type SurfaceChromeGroups, type SurfaceEvent, type SurfaceGesture, type SurfaceOptions, type SurfaceResponse, type SurfaceVisibility, type SurfaceVisibilityContext, type SurfaceVisibilityPolicy, TRANSFORM_BOX_BODY_PRIORITY, TRANSFORM_BOX_CORNER_HIT_SIZE, TRANSFORM_BOX_CORNER_PRIORITY, TRANSFORM_BOX_SIDE_HIT_THICKNESS, TRANSFORM_BOX_SIDE_PRIORITY, type TransformBoxAction, type TransformBoxActiveOp, type TransformBoxCorners, type TransformBoxHover, type TransformBoxInput, type TransformBoxOptions, type VectorBendMode, type VectorHover, type VectorInsertionMode, type VectorOverlay, type VectorSelectionMode, type VectorSubSelection, buildPaddingOverlay, buildStripesTile, buildTransformBox, compose as composeTransformBox, computeCornerRadiusLayout, computeParametricHandleLayout, computeSelectionControlLayout, computeStripesTileGeometry, cornerRadiusAnchorSign, cornerRadiusHandlePosLine, cornerRadiusHandlePosRect, cornerRadiusLayoutGroups, cornersToBoxTransform, cursorEquals, cursorToCss, decompose as decomposeTransformBox, drawCornerRadius, drawParametricHandles, drawPixelGrid, drawRuler, filterHUDDrawByGroup, getTransformBoxCorners, lassoToHUDDraw, marqueeToHUDDraw, measurementToHUDDraw, negotiateAxis, parametricHandleLayoutGroups, projectParametricHandleValue, reduceTransformBox, resolveCenterDragAnchor, resolveCornerDragAnchor, resolvePaint, resolveParametricHandleByDirection, snapGuideToHUDDraw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as HUDPaintStripes, c as HUDRect, d as HUDSemantic, f as HUDSemanticGroup, i as HUDPaintSolid, l as HUDRule, n as HUDLine, o as HUDPoint, r as HUDPaint, s as HUDPolyline, t as HUDDraw, u as HUDScreenRect } from "./types-3wwFisZs.js";
|
|
2
|
+
import { a as cursorEquals, i as RotationCorner, n as CursorRenderer, o as cursorToCss, r as ResizeDirection, t as CursorIcon } from "./cursor-CxS8EMvm.js";
|
|
3
|
+
import { $ as computeStripesTileGeometry, $t as DEFAULT_RULER_STRIP, A as TransformBoxHover, At as resolveCenterDragAnchor, B as PointerButton, Bt as compose, C as MIN_CHROME_VISIBLE_SIZE, Ct as DrawCornerRadiusParams, D as VectorHover, Dt as cornerRadiusHandlePosRect, E as RenderShape, Et as cornerRadiusHandlePosLine, F as Intent, Ft as SelectionShape, G as measurementToHUDDraw, Gt as DEFAULT_RULER_ACCENT_BACKGROUND, H as SurfaceResponse, Ht as decompose, I as IntentPhase, It as AffineTransform, J as DEFAULT_STRIPES_ANGLE_DEG, Jt as DEFAULT_RULER_COLOR, K as snapGuideToHUDDraw, Kt as DEFAULT_RULER_ACCENT_COLOR, L as SelectMode, Lt as TransformBoxAction, M as PaddingHover, Mt as Rect, N as PaddingOverlayInput, Nt as SurfaceGesture, O as VectorSubSelection, Ot as cornerRadiusLayoutGroups, P as HUDStyle, Pt as SelectionGroup, Q as buildStripesTile, Qt as DEFAULT_RULER_STEPS, R as Modifiers, Rt as TransformBoxCorners, S as HitShape, St as DEFAULT_CORNER_RADIUS_HIT_SIZE, T as OverlayElement, Tt as cornerRadiusAnchorSign, U as lassoToHUDDraw, Ut as getTransformBoxCorners, V as SurfaceEvent, Vt as cornersToBoxTransform, W as marqueeToHUDDraw, Wt as reduceTransformBox, X as DEFAULT_STRIPES_THICKNESS_PX, Xt as DEFAULT_RULER_FONT, Y as DEFAULT_STRIPES_SPACING_PX, Yt as DEFAULT_RULER_DRAG_THRESHOLD, Z as ResolvedPaint, Zt as DEFAULT_RULER_OVERLAP_THRESHOLD, _ as PADDING_HANDLE_PRIORITY, _t as CornerRadiusHandleLayout, a as SurfaceVisibilityPolicy, an as RulerMark, at as DEFAULT_PARAMETRIC_HIT_SIZE, b as VectorOverlay, bt as DEFAULT_CORNER_RADIUS_HANDLE_INSET, c as VectorSelectionMode, cn as DEFAULT_PIXEL_GRID_COLOR, ct as ParametricHandleGroup, d as TRANSFORM_BOX_CORNER_HIT_SIZE, dn as PixelGridConfig, dt as computeParametricHandleLayout, en as DEFAULT_RULER_TEXT_SIDE_OFFSET, et as resolvePaint, f as TRANSFORM_BOX_CORNER_PRIORITY, fn as drawPixelGrid, ft as drawParametricHandles, g as PADDING_HANDLE_LENGTH, gt as CornerRadiusAnchor, h as buildPaddingOverlay, ht as resolveParametricHandleByDirection, i as SurfaceVisibilityContext, in as RulerConfig, it as DEFAULT_PARAMETRIC_HANDLE_SIZE, j as TransformBoxInput, jt as resolveCornerDragAnchor, k as TransformBoxActiveOp, kt as drawCornerRadius, l as buildTransformBox, ln as DEFAULT_PIXEL_GRID_STEPS, lt as ParametricHandleInput, m as TRANSFORM_BOX_SIDE_PRIORITY, mt as projectParametricHandleValue, n as SurfaceOptions, nn as DrawRulerParams, nt as HUDCanvasOptions, o as VectorBendMode, on as RulerRange, ot as DrawParametricHandlesParams, p as TRANSFORM_BOX_SIDE_HIT_THICKNESS, pt as parametricHandleLayoutGroups, q as filterHUDDrawByGroup, qt as DEFAULT_RULER_BACKGROUND, r as SurfaceVisibility, rn as RulerAxis, rt as DEFAULT_PARAMETRIC_HANDLE_INSET, s as VectorInsertionMode, sn as drawRuler, st as ParametricHandle, t as Surface, tn as DEFAULT_RULER_TICK_HEIGHT, tt as HUDCanvas, u as TRANSFORM_BOX_BODY_PRIORITY, un as DrawPixelGridParams, ut as ParametricHandleLayout, v as PADDING_HANDLE_THICKNESS, vt as CornerRadiusInput, w as MIN_HIT_SIZE, wt as computeCornerRadiusLayout, x as SurfaceChromeGroups, xt as DEFAULT_CORNER_RADIUS_HANDLE_SIZE, y as PADDING_REGION_PRIORITY, yt as CornerRadiusRectangular, z as NO_MODS, zt as TransformBoxOptions } from "./index-BrfEdWbQ.js";
|
|
4
|
+
|
|
5
|
+
//#region event/selection-controls.d.ts
|
|
6
|
+
declare const HUDHitPriority: {
|
|
7
|
+
/** Line endpoints — sole resize affordance on lines; nothing outranks them. */readonly ENDPOINT_HANDLE: 10;
|
|
8
|
+
/** Edge priority when promoted (parallel axis violated). Edge strip
|
|
9
|
+
* extends into the body interior on the perpendicular axis when that
|
|
10
|
+
* axis is comfortable; in that case the edge must outrank the
|
|
11
|
+
* (also-promoted) body to keep the resize affordance. */
|
|
12
|
+
readonly RESIZE_HANDLE_EDGE_SMALL: 22;
|
|
13
|
+
/** Body priority when promoted (any axis violated). Lets the user drag
|
|
14
|
+
* from anywhere inside small selections (instead of the corner
|
|
15
|
+
* extension stealing the interior). */
|
|
16
|
+
readonly TRANSLATE_BODY_SMALL: 25;
|
|
17
|
+
/** Side resize handles (N/S/W/E). Lower than corner so that on the 1-px
|
|
18
|
+
* shared boundary between an edge strip and an adjacent corner slot,
|
|
19
|
+
* edge wins ("sides take priority over corners"). */
|
|
20
|
+
readonly RESIZE_HANDLE_EDGE: 30; /** Corner resize handles (NW/NE/SE/SW). */
|
|
21
|
+
readonly RESIZE_HANDLE_CORNER: 31; /** Translate-body — default value. */
|
|
22
|
+
readonly TRANSLATE_BODY: 40;
|
|
23
|
+
/** Rotation halo wraps each resize corner — the rotation hit rect
|
|
24
|
+
* overlaps body, edges, and the resize corner itself, but has the
|
|
25
|
+
* LOWEST priority of any selection-control zone. It only "wins"
|
|
26
|
+
* (becomes the topmost hit) where no other affordance claims the
|
|
27
|
+
* pixel: the L-strip immediately outside the resize-corner outer
|
|
28
|
+
* edges. This is what gives rotation a gap-free wrap around the
|
|
29
|
+
* corner with zero pixel-overlap on the cursor, without ever
|
|
30
|
+
* intruding on the body, the edge resize strips, or the corner
|
|
31
|
+
* resize knob. Do not place anything below this. */
|
|
32
|
+
readonly ROTATE_HANDLE: 50;
|
|
33
|
+
};
|
|
34
|
+
/** The principle constant — the minimum guaranteed length for the body
|
|
35
|
+
* interior on each axis AND for each side strip along its parallel
|
|
36
|
+
* axis. Tunable; everything else derives. */
|
|
37
|
+
declare const MIN_GUARANTEED_INTERACTIVE_DIM = 20;
|
|
38
|
+
/** Below this axis dim, body promotes above corner. Derived from the
|
|
39
|
+
* principle. */
|
|
40
|
+
declare const BODY_FLIP_THRESHOLD: number;
|
|
41
|
+
type SelectionControlRole = {
|
|
42
|
+
kind: "translate";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "resize_corner";
|
|
45
|
+
direction: "nw" | "ne" | "se" | "sw";
|
|
46
|
+
} | {
|
|
47
|
+
kind: "resize_edge";
|
|
48
|
+
direction: "n" | "e" | "s" | "w";
|
|
49
|
+
} | {
|
|
50
|
+
kind: "rotate";
|
|
51
|
+
corner: RotationCorner;
|
|
52
|
+
};
|
|
53
|
+
interface SelectionControlZone {
|
|
54
|
+
rect: Rect;
|
|
55
|
+
priority: number;
|
|
56
|
+
role: SelectionControlRole;
|
|
57
|
+
/** Stable semantic identifier; matches the OverlayElement.label that
|
|
58
|
+
* the chrome builder forwards downstream. */
|
|
59
|
+
label: string;
|
|
60
|
+
}
|
|
61
|
+
interface SelectionControlLayout {
|
|
62
|
+
/** Zones in declaration order. Hit-test resolution is by priority; order
|
|
63
|
+
* serves as tie-break only. */
|
|
64
|
+
zones: SelectionControlZone[];
|
|
65
|
+
/** Whether knobs render visually. False below MIN_CHROME_VISIBLE_SIZE.
|
|
66
|
+
* The body zone exists and is hit-able regardless. */
|
|
67
|
+
controls_visible: boolean;
|
|
68
|
+
/** True when at least one axis is shorter than BODY_FLIP_THRESHOLD,
|
|
69
|
+
* promoting body above corner. */
|
|
70
|
+
small_mode: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @returns { corner, edge } — lengths in screen-px summing to `total`
|
|
74
|
+
* (corner * 2 + edge === total). Each is `>= 0`.
|
|
75
|
+
*
|
|
76
|
+
* Three phases:
|
|
77
|
+
* - **comfortable** (`total >= 2 * corner_preferred + edge_min`):
|
|
78
|
+
* corners at preferred, edge takes the surplus.
|
|
79
|
+
* - **squeezed** (`total >= edge_min`): edge at its min, corners share
|
|
80
|
+
* the remainder.
|
|
81
|
+
* - **tiny** (`total < edge_min`): edge takes everything, corners 0.
|
|
82
|
+
*/
|
|
83
|
+
declare function negotiateAxis(total: number, corner_preferred: number, edge_min: number): {
|
|
84
|
+
corner: number;
|
|
85
|
+
edge: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Compute the selection control layout for a screen-space rect.
|
|
89
|
+
*
|
|
90
|
+
* Pure: no DOM, no global state. Same inputs → same zones.
|
|
91
|
+
*
|
|
92
|
+
* The perimeter ring straddles the bbox edge with `extension =
|
|
93
|
+
* hit_size / 2` overhang outside. Along each axis the run of length
|
|
94
|
+
* `axis_dim + 2 * extension` is split via {@link negotiateAxis} into
|
|
95
|
+
* `[corner | edge | corner]`. The 4 corners and 4 edges in 2D then tile
|
|
96
|
+
* the ring as a strict 3×3 grid of cells — **non-overlapping**. Body
|
|
97
|
+
* sits at rect_screen and may overlap with the ring's inside-bbox half
|
|
98
|
+
* in comfortable mode; priority resolves those overlaps.
|
|
99
|
+
*
|
|
100
|
+
* See the comment block in this file for the full principle.
|
|
101
|
+
*/
|
|
102
|
+
declare function computeSelectionControlLayout(rect_screen: Rect, opts: {
|
|
103
|
+
handle_size: number;
|
|
104
|
+
show_rotation: boolean;
|
|
105
|
+
}): SelectionControlLayout;
|
|
106
|
+
//#endregion
|
|
107
|
+
export { type AffineTransform, BODY_FLIP_THRESHOLD, type CornerRadiusAnchor, type CornerRadiusHandleLayout, type CornerRadiusInput, type CornerRadiusRectangular, type CursorIcon, type CursorRenderer, DEFAULT_CORNER_RADIUS_HANDLE_INSET, DEFAULT_CORNER_RADIUS_HANDLE_SIZE, DEFAULT_CORNER_RADIUS_HIT_SIZE, DEFAULT_PARAMETRIC_HANDLE_INSET, DEFAULT_PARAMETRIC_HANDLE_SIZE, DEFAULT_PARAMETRIC_HIT_SIZE, DEFAULT_PIXEL_GRID_COLOR, DEFAULT_PIXEL_GRID_STEPS, DEFAULT_RULER_ACCENT_BACKGROUND, DEFAULT_RULER_ACCENT_COLOR, DEFAULT_RULER_BACKGROUND, DEFAULT_RULER_COLOR, DEFAULT_RULER_DRAG_THRESHOLD, DEFAULT_RULER_FONT, DEFAULT_RULER_OVERLAP_THRESHOLD, DEFAULT_RULER_STEPS, DEFAULT_RULER_STRIP, DEFAULT_RULER_TEXT_SIDE_OFFSET, DEFAULT_RULER_TICK_HEIGHT, DEFAULT_STRIPES_ANGLE_DEG, DEFAULT_STRIPES_SPACING_PX, DEFAULT_STRIPES_THICKNESS_PX, type DrawCornerRadiusParams, type DrawParametricHandlesParams, type DrawPixelGridParams, type DrawRulerParams, HUDCanvas, type HUDCanvasOptions, type HUDDraw, HUDHitPriority, type HUDLine, type HUDPaint, type HUDPaintSolid, type HUDPaintStripes, type HUDPoint, type HUDPolyline, type HUDRect, type HUDRule, type HUDScreenRect, type HUDSemantic, type HUDSemanticGroup, type HUDStyle, type HitShape, type Intent, type IntentPhase, MIN_CHROME_VISIBLE_SIZE, MIN_GUARANTEED_INTERACTIVE_DIM, MIN_HIT_SIZE, type Modifiers, NO_MODS, type OverlayElement, PADDING_HANDLE_LENGTH, PADDING_HANDLE_PRIORITY, PADDING_HANDLE_THICKNESS, PADDING_REGION_PRIORITY, type PaddingHover, type PaddingOverlayInput, type ParametricHandle, type ParametricHandleGroup, type ParametricHandleInput, type ParametricHandleLayout, type PixelGridConfig, type PointerButton, type RenderShape, type ResizeDirection, type ResolvedPaint, type RotationCorner, type RulerAxis, type RulerConfig, type RulerMark, type RulerRange, type SelectMode, type SelectionControlLayout, type SelectionControlRole, type SelectionControlZone, type SelectionGroup, type SelectionShape, Surface, type SurfaceChromeGroups, type SurfaceEvent, type SurfaceGesture, type SurfaceOptions, type SurfaceResponse, type SurfaceVisibility, type SurfaceVisibilityContext, type SurfaceVisibilityPolicy, TRANSFORM_BOX_BODY_PRIORITY, TRANSFORM_BOX_CORNER_HIT_SIZE, TRANSFORM_BOX_CORNER_PRIORITY, TRANSFORM_BOX_SIDE_HIT_THICKNESS, TRANSFORM_BOX_SIDE_PRIORITY, type TransformBoxAction, type TransformBoxActiveOp, type TransformBoxCorners, type TransformBoxHover, type TransformBoxInput, type TransformBoxOptions, type VectorBendMode, type VectorHover, type VectorInsertionMode, type VectorOverlay, type VectorSelectionMode, type VectorSubSelection, buildPaddingOverlay, buildStripesTile, buildTransformBox, compose as composeTransformBox, computeCornerRadiusLayout, computeParametricHandleLayout, computeSelectionControlLayout, computeStripesTileGeometry, cornerRadiusAnchorSign, cornerRadiusHandlePosLine, cornerRadiusHandlePosRect, cornerRadiusLayoutGroups, cornersToBoxTransform, cursorEquals, cursorToCss, decompose as decomposeTransformBox, drawCornerRadius, drawParametricHandles, drawPixelGrid, drawRuler, filterHUDDrawByGroup, getTransformBoxCorners, lassoToHUDDraw, marqueeToHUDDraw, measurementToHUDDraw, negotiateAxis, parametricHandleLayoutGroups, projectParametricHandleValue, reduceTransformBox, resolveCenterDragAnchor, resolveCornerDragAnchor, resolvePaint, resolveParametricHandleByDirection, snapGuideToHUDDraw };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,76 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_surface = require("./surface-
|
|
2
|
+
const require_surface = require("./surface-BHQVvRFC.js");
|
|
3
|
+
const require_cursor = require("./cursor-FGiJBdU-.js");
|
|
4
|
+
exports.BODY_FLIP_THRESHOLD = require_surface.BODY_FLIP_THRESHOLD;
|
|
5
|
+
exports.DEFAULT_CORNER_RADIUS_HANDLE_INSET = require_surface.DEFAULT_CORNER_RADIUS_HANDLE_INSET;
|
|
6
|
+
exports.DEFAULT_CORNER_RADIUS_HANDLE_SIZE = require_surface.DEFAULT_CORNER_RADIUS_HANDLE_SIZE;
|
|
7
|
+
exports.DEFAULT_CORNER_RADIUS_HIT_SIZE = require_surface.DEFAULT_CORNER_RADIUS_HIT_SIZE;
|
|
8
|
+
exports.DEFAULT_PARAMETRIC_HANDLE_INSET = require_surface.DEFAULT_PARAMETRIC_HANDLE_INSET;
|
|
9
|
+
exports.DEFAULT_PARAMETRIC_HANDLE_SIZE = require_surface.DEFAULT_PARAMETRIC_HANDLE_SIZE;
|
|
10
|
+
exports.DEFAULT_PARAMETRIC_HIT_SIZE = require_surface.DEFAULT_PARAMETRIC_HIT_SIZE;
|
|
11
|
+
exports.DEFAULT_PIXEL_GRID_COLOR = require_surface.DEFAULT_PIXEL_GRID_COLOR;
|
|
12
|
+
exports.DEFAULT_PIXEL_GRID_STEPS = require_surface.DEFAULT_PIXEL_GRID_STEPS;
|
|
13
|
+
exports.DEFAULT_RULER_ACCENT_BACKGROUND = require_surface.DEFAULT_RULER_ACCENT_BACKGROUND;
|
|
14
|
+
exports.DEFAULT_RULER_ACCENT_COLOR = require_surface.DEFAULT_RULER_ACCENT_COLOR;
|
|
15
|
+
exports.DEFAULT_RULER_BACKGROUND = require_surface.DEFAULT_RULER_BACKGROUND;
|
|
16
|
+
exports.DEFAULT_RULER_COLOR = require_surface.DEFAULT_RULER_COLOR;
|
|
17
|
+
exports.DEFAULT_RULER_DRAG_THRESHOLD = require_surface.DEFAULT_RULER_DRAG_THRESHOLD;
|
|
18
|
+
exports.DEFAULT_RULER_FONT = require_surface.DEFAULT_RULER_FONT;
|
|
19
|
+
exports.DEFAULT_RULER_OVERLAP_THRESHOLD = require_surface.DEFAULT_RULER_OVERLAP_THRESHOLD;
|
|
20
|
+
exports.DEFAULT_RULER_STEPS = require_surface.DEFAULT_RULER_STEPS;
|
|
21
|
+
exports.DEFAULT_RULER_STRIP = require_surface.DEFAULT_RULER_STRIP;
|
|
22
|
+
exports.DEFAULT_RULER_TEXT_SIDE_OFFSET = require_surface.DEFAULT_RULER_TEXT_SIDE_OFFSET;
|
|
23
|
+
exports.DEFAULT_RULER_TICK_HEIGHT = require_surface.DEFAULT_RULER_TICK_HEIGHT;
|
|
24
|
+
exports.DEFAULT_STRIPES_ANGLE_DEG = require_surface.DEFAULT_STRIPES_ANGLE_DEG;
|
|
25
|
+
exports.DEFAULT_STRIPES_SPACING_PX = require_surface.DEFAULT_STRIPES_SPACING_PX;
|
|
26
|
+
exports.DEFAULT_STRIPES_THICKNESS_PX = require_surface.DEFAULT_STRIPES_THICKNESS_PX;
|
|
3
27
|
exports.HUDCanvas = require_surface.HUDCanvas;
|
|
28
|
+
exports.HUDHitPriority = require_surface.HUDHitPriority;
|
|
4
29
|
exports.MIN_CHROME_VISIBLE_SIZE = require_surface.MIN_CHROME_VISIBLE_SIZE;
|
|
30
|
+
exports.MIN_GUARANTEED_INTERACTIVE_DIM = require_surface.MIN_GUARANTEED_INTERACTIVE_DIM;
|
|
5
31
|
exports.MIN_HIT_SIZE = require_surface.MIN_HIT_SIZE;
|
|
6
32
|
exports.NO_MODS = require_surface.NO_MODS;
|
|
33
|
+
exports.PADDING_HANDLE_LENGTH = require_surface.PADDING_HANDLE_LENGTH;
|
|
34
|
+
exports.PADDING_HANDLE_PRIORITY = require_surface.PADDING_HANDLE_PRIORITY;
|
|
35
|
+
exports.PADDING_HANDLE_THICKNESS = require_surface.PADDING_HANDLE_THICKNESS;
|
|
36
|
+
exports.PADDING_REGION_PRIORITY = require_surface.PADDING_REGION_PRIORITY;
|
|
7
37
|
exports.Surface = require_surface.Surface;
|
|
38
|
+
exports.TRANSFORM_BOX_BODY_PRIORITY = require_surface.TRANSFORM_BOX_BODY_PRIORITY;
|
|
39
|
+
exports.TRANSFORM_BOX_CORNER_HIT_SIZE = require_surface.TRANSFORM_BOX_CORNER_HIT_SIZE;
|
|
40
|
+
exports.TRANSFORM_BOX_CORNER_PRIORITY = require_surface.TRANSFORM_BOX_CORNER_PRIORITY;
|
|
41
|
+
exports.TRANSFORM_BOX_SIDE_HIT_THICKNESS = require_surface.TRANSFORM_BOX_SIDE_HIT_THICKNESS;
|
|
42
|
+
exports.TRANSFORM_BOX_SIDE_PRIORITY = require_surface.TRANSFORM_BOX_SIDE_PRIORITY;
|
|
43
|
+
exports.buildPaddingOverlay = require_surface.buildPaddingOverlay;
|
|
44
|
+
exports.buildStripesTile = require_surface.buildStripesTile;
|
|
45
|
+
exports.buildTransformBox = require_surface.buildTransformBox;
|
|
46
|
+
exports.composeTransformBox = require_surface.compose;
|
|
47
|
+
exports.computeCornerRadiusLayout = require_surface.computeCornerRadiusLayout;
|
|
48
|
+
exports.computeParametricHandleLayout = require_surface.computeParametricHandleLayout;
|
|
49
|
+
exports.computeSelectionControlLayout = require_surface.computeSelectionControlLayout;
|
|
50
|
+
exports.computeStripesTileGeometry = require_surface.computeStripesTileGeometry;
|
|
51
|
+
exports.cornerRadiusAnchorSign = require_surface.cornerRadiusAnchorSign;
|
|
52
|
+
exports.cornerRadiusHandlePosLine = require_surface.cornerRadiusHandlePosLine;
|
|
53
|
+
exports.cornerRadiusHandlePosRect = require_surface.cornerRadiusHandlePosRect;
|
|
54
|
+
exports.cornerRadiusLayoutGroups = require_surface.cornerRadiusLayoutGroups;
|
|
55
|
+
exports.cornersToBoxTransform = require_surface.cornersToBoxTransform;
|
|
56
|
+
exports.cursorEquals = require_cursor.cursorEquals;
|
|
57
|
+
exports.cursorToCss = require_cursor.cursorToCss;
|
|
58
|
+
exports.decomposeTransformBox = require_surface.decompose;
|
|
59
|
+
exports.drawCornerRadius = require_surface.drawCornerRadius;
|
|
60
|
+
exports.drawParametricHandles = require_surface.drawParametricHandles;
|
|
61
|
+
exports.drawPixelGrid = require_surface.drawPixelGrid;
|
|
62
|
+
exports.drawRuler = require_surface.drawRuler;
|
|
63
|
+
exports.filterHUDDrawByGroup = require_surface.filterHUDDrawByGroup;
|
|
64
|
+
exports.getTransformBoxCorners = require_surface.getTransformBoxCorners;
|
|
8
65
|
exports.lassoToHUDDraw = require_surface.lassoToHUDDraw;
|
|
9
66
|
exports.marqueeToHUDDraw = require_surface.marqueeToHUDDraw;
|
|
10
67
|
exports.measurementToHUDDraw = require_surface.measurementToHUDDraw;
|
|
68
|
+
exports.negotiateAxis = require_surface.negotiateAxis;
|
|
69
|
+
exports.parametricHandleLayoutGroups = require_surface.parametricHandleLayoutGroups;
|
|
70
|
+
exports.projectParametricHandleValue = require_surface.projectParametricHandleValue;
|
|
71
|
+
exports.reduceTransformBox = require_surface.reduceTransformBox;
|
|
72
|
+
exports.resolveCenterDragAnchor = require_surface.resolveCenterDragAnchor;
|
|
73
|
+
exports.resolveCornerDragAnchor = require_surface.resolveCornerDragAnchor;
|
|
74
|
+
exports.resolvePaint = require_surface.resolvePaint;
|
|
75
|
+
exports.resolveParametricHandleByDirection = require_surface.resolveParametricHandleByDirection;
|
|
11
76
|
exports.snapGuideToHUDDraw = require_surface.snapGuideToHUDDraw;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { $ as DEFAULT_RULER_BACKGROUND, A as filterHUDDrawByGroup, B as drawCornerRadius, C as PADDING_REGION_PRIORITY, D as marqueeToHUDDraw, E as lassoToHUDDraw, F as computeCornerRadiusLayout, G as DEFAULT_PARAMETRIC_HIT_SIZE, H as resolveCornerDragAnchor, I as cornerRadiusAnchorSign, J as parametricHandleLayoutGroups, K as computeParametricHandleLayout, L as cornerRadiusHandlePosLine, M as DEFAULT_CORNER_RADIUS_HANDLE_INSET, N as DEFAULT_CORNER_RADIUS_HANDLE_SIZE, O as measurementToHUDDraw, P as DEFAULT_CORNER_RADIUS_HIT_SIZE, Q as DEFAULT_RULER_ACCENT_COLOR, R as cornerRadiusHandlePosRect, S as PADDING_HANDLE_THICKNESS, T as MIN_HIT_SIZE, U as DEFAULT_PARAMETRIC_HANDLE_INSET, V as resolveCenterDragAnchor, W as DEFAULT_PARAMETRIC_HANDLE_SIZE, X as resolveParametricHandleByDirection, Y as projectParametricHandleValue, Z as DEFAULT_RULER_ACCENT_BACKGROUND, _ as getTransformBoxCorners, _t as resolvePaint, a as computeSelectionControlLayout, at as DEFAULT_RULER_STRIP, b as PADDING_HANDLE_LENGTH, c as buildTransformBox, ct as drawRuler, d as TRANSFORM_BOX_CORNER_PRIORITY, dt as drawPixelGrid, et as DEFAULT_RULER_COLOR, f as TRANSFORM_BOX_SIDE_HIT_THICKNESS, ft as DEFAULT_STRIPES_ANGLE_DEG, g as decompose, gt as computeStripesTileGeometry, h as cornersToBoxTransform, ht as buildStripesTile, i as MIN_GUARANTEED_INTERACTIVE_DIM, it as DEFAULT_RULER_STEPS, j as HUDCanvas, k as snapGuideToHUDDraw, l as TRANSFORM_BOX_BODY_PRIORITY, lt as DEFAULT_PIXEL_GRID_COLOR, m as compose, mt as DEFAULT_STRIPES_THICKNESS_PX, n as BODY_FLIP_THRESHOLD, nt as DEFAULT_RULER_FONT, o as negotiateAxis, ot as DEFAULT_RULER_TEXT_SIDE_OFFSET, p as TRANSFORM_BOX_SIDE_PRIORITY, pt as DEFAULT_STRIPES_SPACING_PX, q as drawParametricHandles, r as HUDHitPriority, rt as DEFAULT_RULER_OVERLAP_THRESHOLD, s as NO_MODS, st as DEFAULT_RULER_TICK_HEIGHT, t as Surface, tt as DEFAULT_RULER_DRAG_THRESHOLD, u as TRANSFORM_BOX_CORNER_HIT_SIZE, ut as DEFAULT_PIXEL_GRID_STEPS, v as reduceTransformBox, w as MIN_CHROME_VISIBLE_SIZE, x as PADDING_HANDLE_PRIORITY, y as buildPaddingOverlay, z as cornerRadiusLayoutGroups } from "./surface-NHSzUR8r.mjs";
|
|
2
|
+
import { i as cursorToCss, r as cursorEquals } from "./cursor-DW-uAPVE.mjs";
|
|
3
|
+
export { BODY_FLIP_THRESHOLD, DEFAULT_CORNER_RADIUS_HANDLE_INSET, DEFAULT_CORNER_RADIUS_HANDLE_SIZE, DEFAULT_CORNER_RADIUS_HIT_SIZE, DEFAULT_PARAMETRIC_HANDLE_INSET, DEFAULT_PARAMETRIC_HANDLE_SIZE, DEFAULT_PARAMETRIC_HIT_SIZE, DEFAULT_PIXEL_GRID_COLOR, DEFAULT_PIXEL_GRID_STEPS, DEFAULT_RULER_ACCENT_BACKGROUND, DEFAULT_RULER_ACCENT_COLOR, DEFAULT_RULER_BACKGROUND, DEFAULT_RULER_COLOR, DEFAULT_RULER_DRAG_THRESHOLD, DEFAULT_RULER_FONT, DEFAULT_RULER_OVERLAP_THRESHOLD, DEFAULT_RULER_STEPS, DEFAULT_RULER_STRIP, DEFAULT_RULER_TEXT_SIDE_OFFSET, DEFAULT_RULER_TICK_HEIGHT, DEFAULT_STRIPES_ANGLE_DEG, DEFAULT_STRIPES_SPACING_PX, DEFAULT_STRIPES_THICKNESS_PX, HUDCanvas, HUDHitPriority, MIN_CHROME_VISIBLE_SIZE, MIN_GUARANTEED_INTERACTIVE_DIM, MIN_HIT_SIZE, NO_MODS, PADDING_HANDLE_LENGTH, PADDING_HANDLE_PRIORITY, PADDING_HANDLE_THICKNESS, PADDING_REGION_PRIORITY, Surface, TRANSFORM_BOX_BODY_PRIORITY, TRANSFORM_BOX_CORNER_HIT_SIZE, TRANSFORM_BOX_CORNER_PRIORITY, TRANSFORM_BOX_SIDE_HIT_THICKNESS, TRANSFORM_BOX_SIDE_PRIORITY, buildPaddingOverlay, buildStripesTile, buildTransformBox, compose as composeTransformBox, computeCornerRadiusLayout, computeParametricHandleLayout, computeSelectionControlLayout, computeStripesTileGeometry, cornerRadiusAnchorSign, cornerRadiusHandlePosLine, cornerRadiusHandlePosRect, cornerRadiusLayoutGroups, cornersToBoxTransform, cursorEquals, cursorToCss, decompose as decomposeTransformBox, drawCornerRadius, drawParametricHandles, drawPixelGrid, drawRuler, filterHUDDrawByGroup, getTransformBoxCorners, lassoToHUDDraw, marqueeToHUDDraw, measurementToHUDDraw, negotiateAxis, parametricHandleLayoutGroups, projectParametricHandleValue, reduceTransformBox, resolveCenterDragAnchor, resolveCornerDragAnchor, resolvePaint, resolveParametricHandleByDirection, snapGuideToHUDDraw };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { f as HUDSemanticGroup, r as HUDPaint } from "./types-3wwFisZs.js";
|
|
2
|
+
import cmath from "@grida/cmath";
|
|
3
|
+
|
|
4
|
+
//#region primitives/cursor.d.ts
|
|
5
|
+
/** 8 cardinal/diagonal resize directions. */
|
|
6
|
+
type ResizeDirection = "n" | "ne" | "e" | "se" | "s" | "sw" | "w" | "nw";
|
|
7
|
+
/** 4 corner positions for rotation handles. */
|
|
8
|
+
type RotationCorner = "nw" | "ne" | "se" | "sw";
|
|
9
|
+
/**
|
|
10
|
+
* Logical cursor icon names.
|
|
11
|
+
*
|
|
12
|
+
* `baseAngle` (radians) tilts the rendered arrow by an additional
|
|
13
|
+
* amount on top of the variant's canonical orientation; the
|
|
14
|
+
* orchestrator sets it when a gesture rotates a selection so the
|
|
15
|
+
* cursor tracks live rotation.
|
|
16
|
+
*/
|
|
17
|
+
type CursorIcon = "default" | "pointer" | "move" | "crosshair" | "grab" | "grabbing" | "text" | {
|
|
18
|
+
kind: "resize";
|
|
19
|
+
direction: ResizeDirection;
|
|
20
|
+
baseAngle?: number;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "rotate";
|
|
23
|
+
corner: RotationCorner;
|
|
24
|
+
baseAngle?: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Angle quantization bucket — 0.5° in radians. Two rotated cursors
|
|
28
|
+
* compare equal when their `baseAngle`s round to the same bucket.
|
|
29
|
+
*
|
|
30
|
+
* 0.5° is below human perception for cursor orientation, so the
|
|
31
|
+
* quantization is visually free.
|
|
32
|
+
*/
|
|
33
|
+
declare const CURSOR_ANGLE_BUCKET_RAD: number;
|
|
34
|
+
/** Quantize an angle (radians) to its `CURSOR_ANGLE_BUCKET_RAD` bucket. */
|
|
35
|
+
declare function angleBucket(rad: number | undefined): number;
|
|
36
|
+
/**
|
|
37
|
+
* Pluggable cursor renderer — maps a logical `CursorIcon` to a CSS
|
|
38
|
+
* `cursor:` value. Bedrock ships {@link cursorToCss} as the default;
|
|
39
|
+
* hosts compose their own to substitute SVG data-URLs or platform
|
|
40
|
+
* extensions.
|
|
41
|
+
*/
|
|
42
|
+
type CursorRenderer = (icon: CursorIcon) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Default mapping from `CursorIcon` to CSS `cursor` value.
|
|
45
|
+
*/
|
|
46
|
+
declare function cursorToCss(c: CursorIcon): string;
|
|
47
|
+
/**
|
|
48
|
+
* Cursor equality with `baseAngle` bucketing.
|
|
49
|
+
*
|
|
50
|
+
* Lets a hot path (a rotate-in-progress gesture's per-frame setCursor)
|
|
51
|
+
* emit `cursorChanged` only on visible motion (≥ one bucket of
|
|
52
|
+
* rotation).
|
|
53
|
+
*/
|
|
54
|
+
declare function cursorEquals(a: CursorIcon, b: CursorIcon): boolean;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region primitives/overlay.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Minimum hit-target size in screen-px.
|
|
59
|
+
*
|
|
60
|
+
* Visual knobs are typically 8px; the hit region is 16px so the user
|
|
61
|
+
* does not need pixel-perfect aim (Fitts'). Bedrock constant — value
|
|
62
|
+
* mirrors the legacy `event/overlay.ts` constant during the additive
|
|
63
|
+
* migration.
|
|
64
|
+
*/
|
|
65
|
+
declare const MIN_HIT_SIZE = 16;
|
|
66
|
+
/**
|
|
67
|
+
* Below this selection size (in screen-px on either axis), chrome is
|
|
68
|
+
* suppressed — both the visual handles AND the hit regions. The
|
|
69
|
+
* consumer enforces this when computing per-frame `HUDObject`s.
|
|
70
|
+
*/
|
|
71
|
+
declare const MIN_CHROME_VISIBLE_SIZE = 12;
|
|
72
|
+
/**
|
|
73
|
+
* The hit region of a `HUDObject`. Always screen-space; the variants
|
|
74
|
+
* differ on how the region is anchored.
|
|
75
|
+
*
|
|
76
|
+
* **Variants** (closed taxonomy — no host extension):
|
|
77
|
+
*
|
|
78
|
+
* - `screen_rect_at_doc` — fixed screen-pixel rect, anchored to a
|
|
79
|
+
* doc-space point. The hit region tracks the document under camera
|
|
80
|
+
* changes; dimensions stay constant in CSS px. Used by handles.
|
|
81
|
+
*
|
|
82
|
+
* - `screen_aabb` — pre-projected screen-space AABB. Used for
|
|
83
|
+
* overlays whose layout is already screen-space (edge strips).
|
|
84
|
+
*
|
|
85
|
+
* - `screen_obb` — oriented bounding box. `rect` is axis-aligned in
|
|
86
|
+
* a shadow space; `inverse_transform` maps screen → shadow. Lets
|
|
87
|
+
* rotated chrome stay exact without AABB inflation.
|
|
88
|
+
*
|
|
89
|
+
* - `screen_circle_at_doc` — fixed screen-pixel circle, anchored to a
|
|
90
|
+
* doc-space point. Used by vector-handle dots and parametric-handle
|
|
91
|
+
* knobs where a square hit region would feel wrong at the corners.
|
|
92
|
+
*
|
|
93
|
+
* - `screen_polygon` — pre-projected screen-space polygon. Used by
|
|
94
|
+
* curved zones (variable-width controls, lasso previews) where AABB
|
|
95
|
+
* plus a `customHitTest` callback would otherwise leak host code
|
|
96
|
+
* into bedrock.
|
|
97
|
+
*/
|
|
98
|
+
type HitShape = {
|
|
99
|
+
readonly kind: "screen_rect_at_doc";
|
|
100
|
+
readonly anchor_doc: cmath.Vector2; /** Screen-space size in CSS px. */
|
|
101
|
+
readonly width: number;
|
|
102
|
+
readonly height: number; /** Which point of the rect sits on the anchor. Default: "center". */
|
|
103
|
+
readonly placement?: "center" | "tl" | "tr" | "bl" | "br";
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: "screen_aabb";
|
|
106
|
+
readonly rect: cmath.Rectangle;
|
|
107
|
+
} | {
|
|
108
|
+
readonly kind: "screen_obb"; /** Axis-aligned rect in shadow space. */
|
|
109
|
+
readonly rect: cmath.Rectangle; /** screen → shadow. Applied to the pointer before AABB containment. */
|
|
110
|
+
readonly inverse_transform: cmath.Transform;
|
|
111
|
+
} | {
|
|
112
|
+
readonly kind: "screen_circle_at_doc";
|
|
113
|
+
readonly anchor_doc: cmath.Vector2; /** Radius in screen CSS px. */
|
|
114
|
+
readonly radius: number;
|
|
115
|
+
} | {
|
|
116
|
+
readonly kind: "screen_polygon"; /** Pre-projected screen-space polygon vertices. */
|
|
117
|
+
readonly points: ReadonlyArray<readonly [number, number]>;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The visual representation of a `HUDObject`. Maps directly onto the
|
|
121
|
+
* primitive layer's `HUDDraw` entries; the consumer (or the deferred
|
|
122
|
+
* orchestrator) fans these into one merged `HUDDraw` per frame.
|
|
123
|
+
*
|
|
124
|
+
* Closed taxonomy — same set as the legacy `OverlayElement.render`
|
|
125
|
+
* union (`screen_rect`, `doc_rect`, `doc_line`, `doc_polyline`). No
|
|
126
|
+
* new variants in bedrock; new render kinds land here only with ≥2
|
|
127
|
+
* internal consumers shaped (sdk-design promotion bar).
|
|
128
|
+
*/
|
|
129
|
+
type RenderShape = {
|
|
130
|
+
readonly kind: "screen_rect";
|
|
131
|
+
readonly anchor_doc: cmath.Vector2;
|
|
132
|
+
readonly width: number;
|
|
133
|
+
readonly height: number;
|
|
134
|
+
readonly placement?: "center" | "tl" | "tr" | "bl" | "br";
|
|
135
|
+
readonly fill?: boolean;
|
|
136
|
+
readonly stroke?: boolean;
|
|
137
|
+
readonly fillColor?: string;
|
|
138
|
+
readonly strokeColor?: string;
|
|
139
|
+
readonly angle?: number;
|
|
140
|
+
readonly shape?: "rect" | "circle";
|
|
141
|
+
} | {
|
|
142
|
+
readonly kind: "doc_rect";
|
|
143
|
+
readonly x: number;
|
|
144
|
+
readonly y: number;
|
|
145
|
+
readonly width: number;
|
|
146
|
+
readonly height: number;
|
|
147
|
+
readonly stroke?: boolean;
|
|
148
|
+
readonly fill?: boolean;
|
|
149
|
+
readonly fillOpacity?: number;
|
|
150
|
+
readonly dashed?: boolean;
|
|
151
|
+
} | {
|
|
152
|
+
readonly kind: "doc_line";
|
|
153
|
+
readonly x1: number;
|
|
154
|
+
readonly y1: number;
|
|
155
|
+
readonly x2: number;
|
|
156
|
+
readonly y2: number;
|
|
157
|
+
readonly dashed?: boolean;
|
|
158
|
+
readonly strokeWidth?: number;
|
|
159
|
+
readonly color?: string;
|
|
160
|
+
} | {
|
|
161
|
+
readonly kind: "doc_polyline";
|
|
162
|
+
readonly points: ReadonlyArray<readonly [number, number]>;
|
|
163
|
+
readonly stroke?: boolean;
|
|
164
|
+
readonly fill?: boolean;
|
|
165
|
+
readonly fillOpacity?: number;
|
|
166
|
+
readonly strokeOpacity?: number;
|
|
167
|
+
readonly strokeWidth?: number;
|
|
168
|
+
readonly dashed?: boolean;
|
|
169
|
+
readonly color?: string;
|
|
170
|
+
readonly fillPaint?: HUDPaint;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Fields common to every `HUDObject` variant.
|
|
174
|
+
*/
|
|
175
|
+
interface HUDObjectCommon {
|
|
176
|
+
/** Optional debug label. Stable semantic identifier, e.g.
|
|
177
|
+
* `"resize_handle:nw"`, `"my-class:knob"`. */
|
|
178
|
+
readonly label?: string;
|
|
179
|
+
/** Semantic group, used by the consumer for visibility filtering. */
|
|
180
|
+
readonly group?: HUDSemanticGroup;
|
|
181
|
+
/** Lower wins on overlap. The consumer assigns the integer; bedrock
|
|
182
|
+
* treats it opaquely (sort key only). */
|
|
183
|
+
readonly priority: number;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Paint-only object: visual chrome that is never hit-tested.
|
|
187
|
+
* `render` is required; `hit`, `intent`, `cursor` are forbidden.
|
|
188
|
+
*/
|
|
189
|
+
interface HUDObjectPaintOnly extends HUDObjectCommon {
|
|
190
|
+
readonly render: RenderShape;
|
|
191
|
+
readonly hit?: never;
|
|
192
|
+
readonly intent?: never;
|
|
193
|
+
readonly cursor?: never;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Interactive object: hit-testable; may also paint, carry an intent,
|
|
197
|
+
* and a cursor. `hit` is required; the rest are optional.
|
|
198
|
+
*
|
|
199
|
+
* Sub-states (none enforced; documented for readers):
|
|
200
|
+
* - `intent` absent → silent / hover-only.
|
|
201
|
+
* - `intent` present → fully interactive.
|
|
202
|
+
* - `render` absent → silent affordance (invisible hit padding around
|
|
203
|
+
* a pre-painted target).
|
|
204
|
+
*/
|
|
205
|
+
interface HUDObjectInteractive<I = unknown> extends HUDObjectCommon {
|
|
206
|
+
readonly hit: HitShape;
|
|
207
|
+
readonly render?: RenderShape;
|
|
208
|
+
readonly intent?: I;
|
|
209
|
+
readonly cursor?: CursorIcon;
|
|
210
|
+
/**
|
|
211
|
+
* Optional refinement applied AFTER `hit` containment passes. Return
|
|
212
|
+
* `false` to reject the hit even though the shape contained the point.
|
|
213
|
+
*
|
|
214
|
+
* The point passed is the same screen-space point handed to
|
|
215
|
+
* `HitRegistry.queryPoint`. Used by curve-shaped affordances (a path
|
|
216
|
+
* segment's hit region is the bezier's bbox; the refinement asks "are
|
|
217
|
+
* you actually near the curve in screen-px?") — the one real case that
|
|
218
|
+
* an AABB/circle/polygon cannot express on its own.
|
|
219
|
+
*
|
|
220
|
+
* This is a deliberate, narrow escape hatch, restored after the
|
|
221
|
+
* vector-path consumer proved an AABB-only hit model drops the
|
|
222
|
+
* curve-near refinement. It is NOT a general "host runs arbitrary code
|
|
223
|
+
* in the hit loop" door: it only *narrows* a shape that already
|
|
224
|
+
* matched; it cannot widen one.
|
|
225
|
+
*/
|
|
226
|
+
readonly refine?: (p: cmath.Vector2) => boolean;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The canonical bedrock primitive — the value type a consumer
|
|
230
|
+
* constructs to participate in HUD.
|
|
231
|
+
*
|
|
232
|
+
* Generic over the opaque intent type `I` the consumer supplies; both
|
|
233
|
+
* bedrock and `HitRegistry<I>` propagate `I` unchanged.
|
|
234
|
+
*
|
|
235
|
+
* The discriminated union enforces the (`render` ∨ `hit`) invariant
|
|
236
|
+
* at compile time: an object with neither field is not assignable to
|
|
237
|
+
* either variant.
|
|
238
|
+
*/
|
|
239
|
+
type HUDObject<I = unknown> = HUDObjectPaintOnly | HUDObjectInteractive<I>;
|
|
240
|
+
//#endregion
|
|
241
|
+
export { MIN_CHROME_VISIBLE_SIZE as a, CURSOR_ANGLE_BUCKET_RAD as c, ResizeDirection as d, RotationCorner as f, cursorToCss as h, HitShape as i, CursorIcon as l, cursorEquals as m, HUDObjectInteractive as n, MIN_HIT_SIZE as o, angleBucket as p, HUDObjectPaintOnly as r, RenderShape as s, HUDObject as t, CursorRenderer as u };
|