@grida/svg-editor 1.0.0-alpha.13 → 1.0.0-alpha.14

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.
@@ -0,0 +1,114 @@
1
+ import { c as SvgEditor, p as Gestures, s as SurfaceHandle, w as Camera } from "./editor-YQwdWHBb.mjs";
2
+ import cmath from "@grida/cmath";
3
+ import { guide } from "@grida/cmath/_snap";
4
+
5
+ //#region src/core/snap/options.d.ts
6
+ type SnapOptions = {
7
+ /** When false, snap behavior and snap-guide rendering are both off. */enabled: boolean;
8
+ /** Snap threshold in HUD canvas pixels (container CSS px in svg-editor;
9
+ * whatever space the consumer feeds in). Constant across zoom because
10
+ * the input rects are already in screen-equivalent units. */
11
+ threshold_px: number;
12
+ };
13
+ declare const DEFAULT_SNAP_OPTIONS: SnapOptions;
14
+ //#endregion
15
+ //#region src/dom.d.ts
16
+ type DomSurfaceOptions = {
17
+ /** Mount the SVG inside this container. */container: HTMLElement;
18
+ /**
19
+ * Install the default gesture set (wheel-pan/zoom, space-drag, middle-mouse,
20
+ * keyboard zoom). Default `true`. Pass `false` to start blank and bind à la
21
+ * carte via `handle.gestures.bind(...)`.
22
+ */
23
+ gestures?: boolean;
24
+ /**
25
+ * Auto-fit the document into the viewport on initial attach. Default
26
+ * `false`. Mirrors Excalidraw's `initialData.scrollToContent`.
27
+ * Subsequent `editor.load()` calls do NOT re-fit — call
28
+ * `handle.camera.fit("<root>")` yourself if you want that behavior.
29
+ */
30
+ fit?: boolean;
31
+ /**
32
+ * Initial camera transform. Default `cmath.transform.identity`. Ignored
33
+ * when `fit: true`.
34
+ */
35
+ initial_camera?: cmath.Transform;
36
+ };
37
+ /**
38
+ * Surface handle for the DOM surface. Extends the editor's core
39
+ * `SurfaceHandle` with the viewport-scoped concerns: pan/zoom (`camera`)
40
+ * and pointer/wheel/keyboard gesture bindings (`gestures`).
41
+ *
42
+ * Camera + gestures are **surface-scoped**: detaching the surface drops
43
+ * both. They never appear on the headless `SvgEditor`.
44
+ */
45
+ type DomSurfaceHandle = SurfaceHandle & {
46
+ camera: Camera;
47
+ gestures: Gestures;
48
+ };
49
+ /**
50
+ * Attach a DOM surface to a headless editor. Returns a `DomSurfaceHandle`
51
+ * whose `detach()` is the inverse — DOM cleared, listeners removed,
52
+ * gestures uninstalled.
53
+ *
54
+ * Usage is one-shot per container: the surface owns the container's children
55
+ * for its lifetime, and `detach()` restores it to empty.
56
+ */
57
+ declare function attach_dom_surface(editor: SvgEditor, options: DomSurfaceOptions): DomSurfaceHandle;
58
+ /**
59
+ * Affine projection of a point through a 2×3 CTM, then offset by a
60
+ * container origin (in page CSS-px). Mirrors how `line_endpoints_in_container`
61
+ * and `shape_of` (transformed branch) bridge from local SVG coords to the
62
+ * HUD's container-CSS-px space (HUD keeps its own transform at identity;
63
+ * the SVG carries the camera as a CSS transform, which getScreenCTM
64
+ * folds in).
65
+ *
66
+ * Exported for headless test coverage — pure function, no DOM types.
67
+ */
68
+ declare function project_point_through_ctm(px: number, py: number, ctm: {
69
+ a: number;
70
+ b: number;
71
+ c: number;
72
+ d: number;
73
+ e: number;
74
+ f: number;
75
+ }, container_offset: readonly [number, number]): [number, number];
76
+ /**
77
+ * Inverse of the CTM's linear part applied to a delta vector. Drops
78
+ * translation. Used to convert a HUD-reported container-space drag delta
79
+ * back to the path's local coord space for `PathModel.translateVertices`.
80
+ *
81
+ * Throws on a degenerate (det = 0) matrix — the caller is expected to
82
+ * have a non-singular CTM for any visible element.
83
+ */
84
+ declare function project_delta_inverse_ctm(dx: number, dy: number, ctm: {
85
+ a: number;
86
+ b: number;
87
+ c: number;
88
+ d: number;
89
+ }): [number, number];
90
+ /**
91
+ * Inverse-project a doc-space rect through a CTM + container offset back
92
+ * into the element's local frame. The output is the AABB of the four
93
+ * inverse-projected corners — when the CTM has a rotation component the
94
+ * AABB is an approximation, but it matches what the user visually
95
+ * expects from a screen-aligned marquee drag.
96
+ *
97
+ * Returns `null` when the CTM's linear part is singular (degenerate
98
+ * camera) — the caller should skip any test that needs the local rect.
99
+ */
100
+ declare function inverse_project_rect(rect: {
101
+ x: number;
102
+ y: number;
103
+ width: number;
104
+ height: number;
105
+ }, ctm: {
106
+ a: number;
107
+ b: number;
108
+ c: number;
109
+ d: number;
110
+ e: number;
111
+ f: number;
112
+ }, offset: readonly [number, number]): cmath.Rectangle | null;
113
+ //#endregion
114
+ export { project_delta_inverse_ctm as a, SnapOptions as c, inverse_project_rect as i, DomSurfaceOptions as n, project_point_through_ctm as o, attach_dom_surface as r, DEFAULT_SNAP_OPTIONS as s, DomSurfaceHandle as t };
package/dist/dom.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { b as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, v as BoundsResolver, x as CameraOptions, y as Camera } from "./editor-BH03X8cX.mjs";
2
- import { a as SnapOptions, i as DEFAULT_SNAP_OPTIONS, n as DomSurfaceOptions, r as attach_dom_surface, t as DomSurfaceHandle } from "./dom-DgB4f-TE.mjs";
3
- export { BoundsResolver, Camera, CameraConstraints, CameraOptions, DEFAULT_SNAP_OPTIONS, DomComputedPaint, DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, GeometryProvider, GeometrySignals, GestureBinding, GestureContext, GestureId, Gestures, MemoizedGeometryProvider, SnapOptions, attach_dom_surface };
1
+ import { C as BoundsResolver, E as CameraOptions, T as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, w as Camera } from "./editor-YQwdWHBb.mjs";
2
+ import { a as project_delta_inverse_ctm, c as SnapOptions, i as inverse_project_rect, n as DomSurfaceOptions, o as project_point_through_ctm, r as attach_dom_surface, s as DEFAULT_SNAP_OPTIONS, t as DomSurfaceHandle } from "./dom-Dz_V6q0Y.mjs";
3
+ export { type BoundsResolver, Camera, type CameraConstraints, type CameraOptions, DEFAULT_SNAP_OPTIONS, type DomComputedPaint, type DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, type GeometryProvider, type GeometrySignals, type GestureBinding, type GestureContext, type GestureId, Gestures, MemoizedGeometryProvider, type SnapOptions, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
package/dist/dom.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { b as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, v as BoundsResolver, x as CameraOptions, y as Camera } from "./editor-Bd4-VCEJ.js";
2
- import { a as SnapOptions, i as DEFAULT_SNAP_OPTIONS, n as DomSurfaceOptions, r as attach_dom_surface, t as DomSurfaceHandle } from "./dom-DCX-a8Kr.js";
3
- export { BoundsResolver, Camera, CameraConstraints, CameraOptions, DEFAULT_SNAP_OPTIONS, DomComputedPaint, DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, GeometryProvider, GeometrySignals, GestureBinding, GestureContext, GestureId, Gestures, MemoizedGeometryProvider, SnapOptions, attach_dom_surface };
1
+ import { C as BoundsResolver, E as CameraOptions, T as CameraConstraints, d as GestureContext, f as GestureId, g as MemoizedGeometryProvider, h as GeometrySignals, i as DomComputedResolver, m as GeometryProvider, p as Gestures, r as DomComputedPaint, u as GestureBinding, w as Camera } from "./editor-CJ2KuRh5.js";
2
+ import { a as project_delta_inverse_ctm, c as SnapOptions, i as inverse_project_rect, n as DomSurfaceOptions, o as project_point_through_ctm, r as attach_dom_surface, s as DEFAULT_SNAP_OPTIONS, t as DomSurfaceHandle } from "./dom-D4dy6kq5.js";
3
+ export { type BoundsResolver, Camera, type CameraConstraints, type CameraOptions, DEFAULT_SNAP_OPTIONS, type DomComputedPaint, type DomComputedResolver, DomSurfaceHandle, DomSurfaceOptions, type GeometryProvider, type GeometrySignals, type GestureBinding, type GestureContext, type GestureId, Gestures, MemoizedGeometryProvider, type SnapOptions, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };
package/dist/dom.js CHANGED
@@ -1,7 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dom = require("./dom-Cvm9Towu.js");
2
+ const require_dom = require("./dom-BuD8TKmL.js");
3
3
  exports.Camera = require_dom.Camera;
4
4
  exports.DEFAULT_SNAP_OPTIONS = require_dom.DEFAULT_SNAP_OPTIONS;
5
5
  exports.Gestures = require_dom.Gestures;
6
6
  exports.MemoizedGeometryProvider = require_dom.MemoizedGeometryProvider;
7
7
  exports.attach_dom_surface = require_dom.attach_dom_surface;
8
+ exports.inverse_project_rect = require_dom.inverse_project_rect;
9
+ exports.project_delta_inverse_ctm = require_dom.project_delta_inverse_ctm;
10
+ exports.project_point_through_ctm = require_dom.project_point_through_ctm;
package/dist/dom.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as Camera, i as MemoizedGeometryProvider, n as Gestures, r as DEFAULT_SNAP_OPTIONS, t as attach_dom_surface } from "./dom-BlMk07oX.mjs";
2
- export { Camera, DEFAULT_SNAP_OPTIONS, Gestures, MemoizedGeometryProvider, attach_dom_surface };
1
+ import { a as Gestures, c as Camera, i as project_point_through_ctm, n as inverse_project_rect, o as DEFAULT_SNAP_OPTIONS, r as project_delta_inverse_ctm, s as MemoizedGeometryProvider, t as attach_dom_surface } from "./dom-DSjfCllZ.mjs";
2
+ export { Camera, DEFAULT_SNAP_OPTIONS, Gestures, MemoizedGeometryProvider, attach_dom_surface, inverse_project_rect, project_delta_inverse_ctm, project_point_through_ctm };