@triiiceratops/plugin-annotation-editor 1.0.0-rc.7 → 1.0.0
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 +332 -0
- package/dist/AnnotationStore.svelte.d.ts +25 -26
- package/dist/adapters/types.d.ts +1 -1
- package/dist/catalog.d.ts +3 -4
- package/dist/contextKey.d.ts +3 -3
- package/dist/drawingLayer.d.ts +22 -0
- package/dist/drawingSession.svelte.d.ts +101 -0
- package/dist/editableShape.d.ts +69 -0
- package/dist/geometry.d.ts +310 -0
- package/dist/icons.d.ts +4 -3
- package/dist/identity.d.ts +10 -0
- package/dist/iife.js +1 -1273
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -6022
- package/dist/loader.svelte.d.ts +1 -1
- package/dist/plugin.d.ts +9 -5
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -158
- package/dist/tools.d.ts +16 -0
- package/dist/types.d.ts +12 -15
- package/dist/viewerMirror.svelte.d.ts +47 -7
- package/package.json +10 -17
- package/dist/AnnotationManager.svelte.d.ts +0 -260
- package/dist/styles.d.ts +0 -11
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a persisted annotation's geometry back out for editing, and writing
|
|
3
|
+
* an edited geometry back in — the inverse of the target the drawing layer
|
|
4
|
+
* builds when it commits a new shape.
|
|
5
|
+
*
|
|
6
|
+
* Pure functions over the W3C structure, so the round trip is asserted without
|
|
7
|
+
* a browser. Everything is CANVAS space, the space the store deals in.
|
|
8
|
+
*/
|
|
9
|
+
import type { W3CAnnotation, W3CSelector } from './adapters/types';
|
|
10
|
+
import { type Point, type Rect } from './geometry';
|
|
11
|
+
/**
|
|
12
|
+
* The geometry a shape edits as. A rectangle, a polygon and a point are the
|
|
13
|
+
* three this editor writes: an ellipse is drawn as a bounding box and persisted
|
|
14
|
+
* as a polygon, so it comes back as the polygon it is and edits by its
|
|
15
|
+
* vertices.
|
|
16
|
+
*/
|
|
17
|
+
export type EditableGeometry = {
|
|
18
|
+
kind: 'rect';
|
|
19
|
+
rect: Rect;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'polygon';
|
|
22
|
+
points: Point[];
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'point';
|
|
25
|
+
point: Point;
|
|
26
|
+
};
|
|
27
|
+
/** A persisted shape reduced to the canvas it is on and its canvas-space geometry. */
|
|
28
|
+
export interface EditableShape {
|
|
29
|
+
canvasId: string;
|
|
30
|
+
geometry: EditableGeometry;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The geometry to open for editing, or `null` when this annotation has none
|
|
34
|
+
* this editor can offer control points on — a whole-canvas target, which has no
|
|
35
|
+
* geometry at all, or a shape whose target it does not model.
|
|
36
|
+
*
|
|
37
|
+
* `null` is load-bearing rather than merely defensive: the caller suppresses
|
|
38
|
+
* core's own rendering of whatever it opens, so an annotation it cannot draw
|
|
39
|
+
* must not be opened at all — suppressed and undrawn reads to the reader as
|
|
40
|
+
* data loss.
|
|
41
|
+
*/
|
|
42
|
+
export declare function editableShape(annotation: W3CAnnotation): EditableShape | null;
|
|
43
|
+
/**
|
|
44
|
+
* The same annotation with its geometry replaced. Every other field — bodies,
|
|
45
|
+
* host-specific properties, the selector's own extra keys — is carried through,
|
|
46
|
+
* because an edit to the geometry must not be a rewrite of the record.
|
|
47
|
+
*
|
|
48
|
+
* The selector KIND is carried through too: an edited rectangle stays a
|
|
49
|
+
* fragment and an edited polygon stays an `SvgSelector`, so nothing changes
|
|
50
|
+
* representation behind the reader's back.
|
|
51
|
+
*/
|
|
52
|
+
export declare function withEditedGeometry(annotation: W3CAnnotation, geometry: EditableGeometry): W3CAnnotation;
|
|
53
|
+
/**
|
|
54
|
+
* The selector a geometry is persisted as — the write half of
|
|
55
|
+
* {@link readGeometry}, and the one place a NEW annotation's target kind is
|
|
56
|
+
* decided.
|
|
57
|
+
*
|
|
58
|
+
* The geometry's kind is the whole decision: a box is a media fragment, an
|
|
59
|
+
* outline is an `SvgSelector`, a point is a `PointSelector`. An ellipse has
|
|
60
|
+
* already become the polygon inscribed in its box by the time it arrives here,
|
|
61
|
+
* which is why there is no fourth arm (ADR 0022).
|
|
62
|
+
*/
|
|
63
|
+
export declare function selectorForGeometry(geometry: EditableGeometry): W3CSelector;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a geometry is large enough to persist — the minimum-size guard on a
|
|
66
|
+
* COMMITTED shape, applied to whatever box the geometry spans. A point is
|
|
67
|
+
* exempt: it has no extent to fall below the threshold.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isCommittableGeometry(geometry: EditableGeometry): boolean;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection between the viewer's screen space and a canvas's own coordinate
|
|
3
|
+
* space, for the shapes the drawing layer commits.
|
|
4
|
+
*
|
|
5
|
+
* Pure functions only — no Svelte, no DOM. The caller supplies the projection
|
|
6
|
+
* as a callback (core's `screenToCanvas` / `canvasToScreen` bound to a canvas
|
|
7
|
+
* id), so every geometric claim here is asserted without a browser (story 42).
|
|
8
|
+
*/
|
|
9
|
+
import type { EditableGeometry } from './editableShape';
|
|
10
|
+
export interface Point {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Rect {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Maps a point from one space to the other, or `null` when the viewer cannot
|
|
22
|
+
* answer for the canvas asked about — core's coordinate helpers return `null`
|
|
23
|
+
* rather than a point belonging to a different canvas.
|
|
24
|
+
*/
|
|
25
|
+
export type ProjectPoint = (point: Point) => Point | null;
|
|
26
|
+
/**
|
|
27
|
+
* The smallest region, in CANVAS pixels, that may become an annotation.
|
|
28
|
+
*
|
|
29
|
+
* Canvas pixels rather than screen pixels because the shape is persisted in
|
|
30
|
+
* canvas space: the same drag at 8× zoom and at fit zoom must be judged the same
|
|
31
|
+
* way, and only the canvas-space extent is invariant across the zoom the reader
|
|
32
|
+
* happens to be at. Four is above the two-pixel hand jitter this guard exists to
|
|
33
|
+
* discard (story 7), and far below any region a reader would deliberately draw
|
|
34
|
+
* on a folio-sized canvas — a IIIF canvas of a manuscript page runs to thousands
|
|
35
|
+
* of units across, so four of them are a smudge, not a feature.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MIN_SHAPE_SIZE_CANVAS_PX = 4;
|
|
38
|
+
/** The media-fragment profile a `FragmentSelector`'s `xywh=` conforms to. */
|
|
39
|
+
export declare const MEDIA_FRAGMENT_CONFORMS_TO = "http://www.w3.org/TR/media-frags/";
|
|
40
|
+
/**
|
|
41
|
+
* The axis-aligned box two corners span, in whichever order they were given —
|
|
42
|
+
* a drag up-and-left describes the same region as the same drag reversed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normaliseRect(from: Point, to: Point): Rect;
|
|
45
|
+
/**
|
|
46
|
+
* The canvas-space box a screen-space drag describes.
|
|
47
|
+
*
|
|
48
|
+
* Both corners are projected before they are normalised, so the result is the
|
|
49
|
+
* box in the canvas's own coordinates whatever the viewport's zoom and pan are.
|
|
50
|
+
* `null` when either corner does not project — the drag then belongs to no
|
|
51
|
+
* canvas and nothing may be committed from it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function screenDragToCanvasRect(from: Point, to: Point, toCanvas: ProjectPoint): Rect | null;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a committed region is large enough to persist
|
|
56
|
+
* ({@link MIN_SHAPE_SIZE_CANVAS_PX}). A validity check on a finished shape, not
|
|
57
|
+
* gesture recognition: the armed tool already decided the gesture was a drag.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isDrawableRect(rect: Rect): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* A canvas-space rect as a media-fragment `xywh=` value.
|
|
62
|
+
*
|
|
63
|
+
* Rounded to whole canvas pixels — the unit a IIIF canvas is expressed in, and
|
|
64
|
+
* what every reader of the fragment (core's own target parser included) treats
|
|
65
|
+
* the numbers as. Edges are rounded rather than origin-plus-size so a rect never
|
|
66
|
+
* grows or shrinks by a pixel more than the rounding of its own edges.
|
|
67
|
+
*/
|
|
68
|
+
export declare function fragmentSelectorValue(rect: Rect): string;
|
|
69
|
+
/**
|
|
70
|
+
* A canvas-space point snapped to whole canvas pixels — the unit a
|
|
71
|
+
* `PointSelector`'s `x`/`y` are written in (ADR 0004). Floats were rejected as
|
|
72
|
+
* spurious precision that diffs noisily and diverges from the published IIIF
|
|
73
|
+
* examples, so this is the only rounding a point ever gets.
|
|
74
|
+
*/
|
|
75
|
+
export declare function canvasPixelPoint(point: Point): Point;
|
|
76
|
+
/**
|
|
77
|
+
* The canvas pixel a screen point names — the point tool's ENTIRE geometry, a
|
|
78
|
+
* single click with no extent and so no minimum-size guard to pass.
|
|
79
|
+
*
|
|
80
|
+
* The rounding happens once, here, on the projected canvas point. Rounding an
|
|
81
|
+
* intermediate space instead — the screen point the pointer reported, or an
|
|
82
|
+
* image-space step on the way — lands on a different canvas pixel wherever the
|
|
83
|
+
* canvas is larger in its own coordinates than it is on screen, which is every
|
|
84
|
+
* zoom below 1:1. `null` when the point projects to no canvas.
|
|
85
|
+
*/
|
|
86
|
+
export declare function screenPointToCanvasPixel(point: Point, toCanvas: ProjectPoint): Point | null;
|
|
87
|
+
/**
|
|
88
|
+
* The screen-space box a canvas-space rect currently occupies, for the live
|
|
89
|
+
* preview — recomputed whenever the viewport moves. `null` when the rect's
|
|
90
|
+
* canvas is not one the renderer is placing.
|
|
91
|
+
*/
|
|
92
|
+
export declare function canvasRectToScreenRect(rect: Rect, toScreen: ProjectPoint): Rect | null;
|
|
93
|
+
/** Whether a rect contains a point, edges included. */
|
|
94
|
+
export declare function rectContainsPoint(rect: Rect, point: Point): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The control points a bounding-box shape offers: four corners and four edge
|
|
97
|
+
* midpoints, named by compass direction so a handle's id says which edges it
|
|
98
|
+
* moves — `'nw'` moves the north and west edges, `'n'` only the north one.
|
|
99
|
+
*
|
|
100
|
+
* A polygon's control points are its vertices instead, identified by index, so
|
|
101
|
+
* a handle's id is whatever names the thing it moves.
|
|
102
|
+
*/
|
|
103
|
+
export type HandleId = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
104
|
+
/**
|
|
105
|
+
* The one control point a point annotation offers. Editing a point is moving
|
|
106
|
+
* it, so its handle and its geometry are the same thing — but it goes through
|
|
107
|
+
* the same {@link handleAtPoint} test as every other control point rather than
|
|
108
|
+
* being a parallel mechanism.
|
|
109
|
+
*/
|
|
110
|
+
export declare const POINT_HANDLE_ID = "point";
|
|
111
|
+
export type PointHandleId = typeof POINT_HANDLE_ID;
|
|
112
|
+
export declare const HANDLE_IDS: readonly HandleId[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether a control-point id names a bounding box's compass edge, as opposed to
|
|
115
|
+
* a polygon vertex's index or a point's single handle. The three share one drag
|
|
116
|
+
* and one hit test, so the id is what says which shape's maths to run.
|
|
117
|
+
*/
|
|
118
|
+
export declare function isHandleId(id: unknown): id is HandleId;
|
|
119
|
+
/**
|
|
120
|
+
* How far, in SCREEN pixels, a pointer may be from a handle's centre and still
|
|
121
|
+
* reach it — half of a comfortable touch target rather than the handle's drawn
|
|
122
|
+
* size, so a handle is grabbable slightly beyond the dot the reader sees.
|
|
123
|
+
*
|
|
124
|
+
* Screen pixels because it describes the reader's aim, which does not change
|
|
125
|
+
* with the zoom: the same finger has to hit the same handle at fit zoom and at
|
|
126
|
+
* 8×.
|
|
127
|
+
*/
|
|
128
|
+
export declare const HANDLE_HIT_RADIUS = 12;
|
|
129
|
+
/**
|
|
130
|
+
* A control point on screen. Generic over what identifies it: a compass edge
|
|
131
|
+
* for a bounding box, a vertex index for a polygon. Both go through the same
|
|
132
|
+
* hit test, so nearest-centre-wins is decided in one place for every shape.
|
|
133
|
+
*/
|
|
134
|
+
export interface Handle<Id = HandleId> {
|
|
135
|
+
id: Id;
|
|
136
|
+
x: number;
|
|
137
|
+
y: number;
|
|
138
|
+
}
|
|
139
|
+
/** The eight control points of a rect, in whatever space the rect is in. */
|
|
140
|
+
export declare function rectHandles(rect: Rect): Handle[];
|
|
141
|
+
/**
|
|
142
|
+
* The handle a screen point reaches, or `null` when it reaches none.
|
|
143
|
+
*
|
|
144
|
+
* Nearest centre wins rather than first match, which is the whole reason this
|
|
145
|
+
* is a function and not the DOM's own hit testing: on a small shape the corner
|
|
146
|
+
* and edge handles overlap, and document order would answer with whichever was
|
|
147
|
+
* rendered last rather than with the one under the pointer. Handles are still
|
|
148
|
+
* real focusable elements — they simply do not take the pointer events, so that
|
|
149
|
+
* this decision is made in one place and can be asserted without a browser.
|
|
150
|
+
*/
|
|
151
|
+
export declare function handleAtPoint<Id>(handles: readonly Handle<Id>[], point: Point, radius?: number): Id | null;
|
|
152
|
+
/**
|
|
153
|
+
* The rect a handle dragged to `to` describes. The dragged handle's own edges
|
|
154
|
+
* follow the pointer and the opposite ones stay put; a drag past the opposite
|
|
155
|
+
* edge flips the rect rather than producing a negative extent.
|
|
156
|
+
*/
|
|
157
|
+
export declare function resizeRect(rect: Rect, handle: HandleId, to: Point): Rect;
|
|
158
|
+
/** The same rect translated — a move never changes width or height. */
|
|
159
|
+
export declare function moveRect(rect: Rect, delta: Point): Rect;
|
|
160
|
+
/** A rect grown by `by` on every side, for a box that must contain its handles. */
|
|
161
|
+
export declare function inflateRect(rect: Rect, by: number): Rect;
|
|
162
|
+
/**
|
|
163
|
+
* The rect a media-fragment `xywh=` value names — the read half of
|
|
164
|
+
* {@link fragmentSelectorValue}. `null` for anything that is not a spatial
|
|
165
|
+
* fragment, a temporal `t=` included.
|
|
166
|
+
*/
|
|
167
|
+
export declare function parseFragmentRect(value: unknown): Rect | null;
|
|
168
|
+
/**
|
|
169
|
+
* How many vertices an ellipse's inscribed polygon carries.
|
|
170
|
+
*
|
|
171
|
+
* 64 rather than the more common 32 because this viewer is a deep-zoom one: at
|
|
172
|
+
* the magnifications a reader reaches on a folio, a 32-gon's facets are visibly
|
|
173
|
+
* flat straight edges rather than a curve. Do not lower it — the cost is 64
|
|
174
|
+
* coordinate pairs in a selector, and the benefit is the shape still reading as
|
|
175
|
+
* an ellipse at 8×.
|
|
176
|
+
*/
|
|
177
|
+
export declare const ELLIPSE_VERTEX_COUNT = 64;
|
|
178
|
+
/** The fewest vertices a closed region can have. */
|
|
179
|
+
export declare const MIN_POLYGON_VERTICES = 3;
|
|
180
|
+
/**
|
|
181
|
+
* The polygon inscribed in a bounding box: {@link ELLIPSE_VERTEX_COUNT} vertices
|
|
182
|
+
* on the ellipse the box circumscribes, starting due east and winding clockwise
|
|
183
|
+
* on screen (y grows downward).
|
|
184
|
+
*
|
|
185
|
+
* This is the ellipse tool's ENTIRE output. Nothing downstream records that the
|
|
186
|
+
* polygon was drawn as an ellipse: core's projector has three geometries and its
|
|
187
|
+
* SVG parser already degrades `<ellipse>` into points on read, so an ellipse
|
|
188
|
+
* that persisted as one would lose fidelity on every round trip.
|
|
189
|
+
*/
|
|
190
|
+
export declare function ellipseVertices(rect: Rect): Point[];
|
|
191
|
+
/** The axis-aligned box a set of points spans; `null` for no points. */
|
|
192
|
+
export declare function polygonBounds(points: readonly Point[]): Rect | null;
|
|
193
|
+
/**
|
|
194
|
+
* A closed polygon as an `SvgSelector` value, in the canvas's own coordinates.
|
|
195
|
+
*
|
|
196
|
+
* `<polygon>` inside a root `<svg>`, which is what core's selector parser reads
|
|
197
|
+
* — it runs `DOMParser` over the value and collects `points` attributes, so a
|
|
198
|
+
* bare `<polygon>` with no root element would not parse.
|
|
199
|
+
*/
|
|
200
|
+
export declare function svgPolygonValue(points: readonly Point[]): string;
|
|
201
|
+
/**
|
|
202
|
+
* The vertices an `SvgSelector` value names — the read half of
|
|
203
|
+
* {@link svgPolygonValue}. `null` for anything this editor did not write:
|
|
204
|
+
* curves, multiple shapes, or too few points to close a region.
|
|
205
|
+
*
|
|
206
|
+
* Deliberately narrower than core's parser, which approximates `<circle>`,
|
|
207
|
+
* `<rect>` and `<path>` too. Core degrades those to draw them; this editor
|
|
208
|
+
* would have to WRITE the degraded form back, silently replacing the author's
|
|
209
|
+
* shape, so it declines to open them at all.
|
|
210
|
+
*/
|
|
211
|
+
export declare function parseSvgPolygon(value: unknown): Point[] | null;
|
|
212
|
+
/** A point's single handle, at the point itself. */
|
|
213
|
+
export declare function pointHandles(point: Point): Handle<PointHandleId>[];
|
|
214
|
+
/** The polygon's vertices as handles, each identified by its own index. */
|
|
215
|
+
export declare function polygonHandles(points: readonly Point[]): Handle<number>[];
|
|
216
|
+
/** The same polygon with one vertex moved; every other vertex stays put. */
|
|
217
|
+
export declare function moveVertex(points: readonly Point[], index: number, to: Point): Point[];
|
|
218
|
+
/** The same polygon translated — a move never reshapes the outline. */
|
|
219
|
+
export declare function movePolygon(points: readonly Point[], delta: Point): Point[];
|
|
220
|
+
/** The same polygon with `at` spliced in before vertex `index`. */
|
|
221
|
+
export declare function insertVertex(points: readonly Point[], index: number, at: Point): Point[];
|
|
222
|
+
/**
|
|
223
|
+
* The same polygon without vertex `index`, or `null` when removing it would
|
|
224
|
+
* leave fewer than {@link MIN_POLYGON_VERTICES} — a two-vertex ring is a line
|
|
225
|
+
* segment, which is not a region and which core's parser would close into one
|
|
226
|
+
* anyway.
|
|
227
|
+
*/
|
|
228
|
+
export declare function removeVertex(points: readonly Point[], index: number): Point[] | null;
|
|
229
|
+
/**
|
|
230
|
+
* Where a new vertex belongs for a point pressed on the outline: the index to
|
|
231
|
+
* insert BEFORE, chosen as the end of the closest edge, so the inserted vertex
|
|
232
|
+
* lands between the two it was dragged out from.
|
|
233
|
+
*/
|
|
234
|
+
export declare function nearestEdgeInsertIndex(points: readonly Point[], point: Point): number;
|
|
235
|
+
/**
|
|
236
|
+
* Whether a point is inside a closed polygon, by crossing count. Used to decide
|
|
237
|
+
* whether a press moves the whole shape, so a press in the concave notch of an
|
|
238
|
+
* outline must not count as inside it — which is exactly what testing the
|
|
239
|
+
* bounding box instead would get wrong.
|
|
240
|
+
*/
|
|
241
|
+
export declare function polygonContainsPoint(points: readonly Point[], point: Point): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* The two nudge steps, in CANVAS pixels.
|
|
244
|
+
*
|
|
245
|
+
* Canvas space rather than screen space so a nudge means the same thing at
|
|
246
|
+
* every zoom: a reader who moves a vertex one step at fit zoom and one step at
|
|
247
|
+
* 8× has moved it the same distance across the folio, which is the distance the
|
|
248
|
+
* annotation records. A step in screen pixels would shrink as the reader zoomed
|
|
249
|
+
* in — the opposite of what precision work wants.
|
|
250
|
+
*
|
|
251
|
+
* One canvas pixel is the finest adjustment a canvas-space geometry can carry;
|
|
252
|
+
* ten crosses a folio-sized canvas in a few hundred presses rather than a few
|
|
253
|
+
* thousand.
|
|
254
|
+
*/
|
|
255
|
+
export declare const NUDGE_STEP_CANVAS_PX = 1;
|
|
256
|
+
export declare const NUDGE_LARGE_STEP_CANVAS_PX = 10;
|
|
257
|
+
/**
|
|
258
|
+
* The canvas-space delta an arrow key describes, or `null` for a key that is
|
|
259
|
+
* not an arrow — which is what tells the caller to leave the event alone so it
|
|
260
|
+
* reaches whatever else wants it.
|
|
261
|
+
*/
|
|
262
|
+
export declare function nudgeDelta(key: string, large: boolean): Point | null;
|
|
263
|
+
export declare function translatePoint(point: Point, delta: Point): Point;
|
|
264
|
+
/**
|
|
265
|
+
* How much of the visible box a keyboard-placed default shape spans.
|
|
266
|
+
*
|
|
267
|
+
* A fraction of the CURRENT view rather than a fixed canvas-space size: a
|
|
268
|
+
* default shape has to be visible and grabbable at whatever zoom the reader is
|
|
269
|
+
* at, and a fixed canvas extent is either a speck at fit zoom or larger than
|
|
270
|
+
* the screen at 8×. The reader then sizes it with the ordinary nudge verbs,
|
|
271
|
+
* which are in canvas space because they are adjustments to a stored geometry.
|
|
272
|
+
*/
|
|
273
|
+
export declare const DEFAULT_SHAPE_VIEW_FRACTION = 0.25;
|
|
274
|
+
/** The box of the given extent centred on a point. */
|
|
275
|
+
export declare function centredRect(centre: Point, width: number, height: number): Rect;
|
|
276
|
+
/**
|
|
277
|
+
* The default triangle inscribed in a box: apex at the top edge's midpoint,
|
|
278
|
+
* then the two bottom corners, winding clockwise on screen like
|
|
279
|
+
* {@link ellipseVertices}.
|
|
280
|
+
*
|
|
281
|
+
* The polygon tool's keyboard start. Three vertices because that is the fewest
|
|
282
|
+
* a region can have ({@link MIN_POLYGON_VERTICES}), so every vertex the reader
|
|
283
|
+
* then adds is one they asked for.
|
|
284
|
+
*/
|
|
285
|
+
export declare function triangleVertices(rect: Rect): Point[];
|
|
286
|
+
/**
|
|
287
|
+
* The same polygon with a vertex added just after `index`, at the midpoint of
|
|
288
|
+
* the edge running from it to the next one — so the new vertex is on the
|
|
289
|
+
* outline the reader can see, and lands at `index + 1`.
|
|
290
|
+
*
|
|
291
|
+
* The keyboard's counterpart to the pointer's insert, which takes the position
|
|
292
|
+
* from where the reader double-clicked. A keyboard user has no such position,
|
|
293
|
+
* so the edge's midpoint is the one unambiguous point on it.
|
|
294
|
+
*/
|
|
295
|
+
export declare function insertVertexAfter(points: readonly Point[], index: number): Point[] | null;
|
|
296
|
+
/**
|
|
297
|
+
* Whether two geometries name the same shape, so a commit can refuse to write
|
|
298
|
+
* one that has not changed.
|
|
299
|
+
*
|
|
300
|
+
* Kinds never compare equal across each other: an edit cannot turn a rect into
|
|
301
|
+
* a polygon, so a mismatch here is two different shapes rather than two
|
|
302
|
+
* spellings of one.
|
|
303
|
+
*
|
|
304
|
+
* A point compares at whole canvas pixels, because that IS a point's geometry
|
|
305
|
+
* — {@link canvasPixelPoint} is the only resolution a `PointSelector` is ever
|
|
306
|
+
* written at (ADR 0004), and the raw projection of a pointer resting on a
|
|
307
|
+
* stored point lands somewhere inside the pixel it already occupies. Rects and
|
|
308
|
+
* polygons compare exactly, on the coordinates the caller holds.
|
|
309
|
+
*/
|
|
310
|
+
export declare function geometriesEqual(a: EditableGeometry, b: EditableGeometry): boolean;
|
package/dist/icons.d.ts
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `ICON` is the toolbar glyph descriptor produced by the SDK's `svgIcon` — core
|
|
5
5
|
* owns the rendered `<svg>` wrapper (sizing, `currentColor`, a11y). `GLYPHS` are
|
|
6
|
-
* the raw inner-SVG strings the Svelte panel renders inline via `{@html}`
|
|
7
|
-
*
|
|
8
|
-
* are the same @phosphor-icons/core paths, on the 256×256 viewBox).
|
|
6
|
+
* the raw inner-SVG strings the Svelte panel renders inline via `{@html}`
|
|
7
|
+
* (@phosphor-icons/core paths, on the 256×256 viewBox).
|
|
9
8
|
*/
|
|
10
9
|
import { type IconDescriptor } from '@triiiceratops/plugin-sdk';
|
|
11
10
|
/** Shared phosphor viewBox for every glyph below. */
|
|
@@ -16,11 +15,13 @@ export declare const GLYPHS: {
|
|
|
16
15
|
readonly Warning: "<path d=\"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z\"/>";
|
|
17
16
|
readonly X: "<path d=\"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z\"/>";
|
|
18
17
|
readonly Rectangle: "<path d=\"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200Z\"/>";
|
|
18
|
+
readonly Ellipse: "<path d=\"M128,40c-30.63,0-59.4,7.3-81,20.56C24.05,74.7,11.42,94.06,11.42,115.2v25.6c0,21.14,12.63,40.5,35.58,54.64C68.6,208.7,97.37,216,128,216s59.4-7.3,81-20.56c22.95-14.14,35.58-33.5,35.58-54.64V115.2c0-21.14-12.63-40.5-35.58-54.64C187.4,47.3,158.63,40,128,40Zm0,16c56.24,0,100.58,27.1,100.58,59.2S184.24,174.4,128,174.4,27.42,147.3,27.42,115.2,71.76,56,128,56Z\"/>";
|
|
19
19
|
readonly Polygon: "<path d=\"M230.64,49.36a32,32,0,0,0-45.26,0h0a31.9,31.9,0,0,0-5.16,6.76L152,48.42A32,32,0,0,0,97.37,25.36h0a32.06,32.06,0,0,0-5.76,37.41L57.67,93.32a32.05,32.05,0,0,0-40.31,4.05h0a32,32,0,0,0,42.89,47.41l70,51.36a32,32,0,1,0,47.57-14.69l27.39-77.59q1.38.12,2.76.12a32,32,0,0,0,22.63-54.62Zm-122-12.69h0a16,16,0,1,1,0,22.64A16,16,0,0,1,108.68,36.67Zm-80,94.65a16,16,0,0,1,0-22.64h0a16,16,0,1,1,0,22.64Zm142.65,88a16,16,0,0,1-22.63-22.63h0a16,16,0,1,1,22.63,22.63Zm-8.55-43.18a32,32,0,0,0-23,7.08l-70-51.36a32.17,32.17,0,0,0-1.34-26.65l33.95-30.55a32,32,0,0,0,45.47-10.81L176,71.56a32,32,0,0,0,14.12,27Zm56.56-92.84A16,16,0,1,1,196.7,60.68h0a16,16,0,0,1,22.63,22.63Z\"/>";
|
|
20
20
|
readonly Target: "<path d=\"M221.87,83.16A104.1,104.1,0,1,1,195.67,49l22.67-22.68a8,8,0,0,1,11.32,11.32l-96,96a8,8,0,0,1-11.32-11.32l27.72-27.72a40,40,0,1,0,17.87,31.09,8,8,0,1,1,16-.9,56,56,0,1,1-22.38-41.65L184.3,60.39a87.88,87.88,0,1,0,23.13,29.67,8,8,0,0,1,14.44-6.9Z\"/>";
|
|
21
21
|
readonly ArrowCounterClockwise: "<path d=\"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z\"/>";
|
|
22
22
|
readonly ArrowClockwise: "<path d=\"M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z\"/>";
|
|
23
23
|
readonly Trash: "<path d=\"M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z\"/>";
|
|
24
|
+
readonly WholeCanvas: "<path d=\"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200ZM168,112a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,112Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,144Z\"/>";
|
|
24
25
|
readonly Plus: "<path d=\"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z\"/>";
|
|
25
26
|
readonly Check: "<path d=\"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z\"/>";
|
|
26
27
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This plugin's identity, in one place.
|
|
3
|
+
*
|
|
4
|
+
* The version reaches consumers as the plugin's declared identity, and writing
|
|
5
|
+
* it out at the `definePlugin` site is how it drifted from the package.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLUGIN_META: {
|
|
8
|
+
readonly name: "@triiiceratops/plugin-annotation-editor";
|
|
9
|
+
readonly version: "1.0.0";
|
|
10
|
+
};
|