mesurer 0.2.5 → 0.2.7

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/index.d.cts CHANGED
@@ -1,11 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- type ColorPickerFormat = "hex" | "rgb" | "hsl" | "oklch";
4
- type ColorSample = {
5
- red: number;
6
- green: number;
7
- blue: number;
8
- alpha: number;
3
+ type TextFont = "handwritten" | "code" | "serif" | "sans-serif";
4
+ type TextBackground = "none" | "label" | "outline";
5
+ type TextStyleSettings = {
6
+ font: TextFont;
7
+ color: string;
8
+ background: TextBackground;
9
+ /** The colour of the label, or of the outline. */
10
+ backgroundColor: string;
9
11
  };
10
12
 
11
13
  type Point$1 = {
@@ -21,14 +23,26 @@ type Arrow = {
21
23
  width: number;
22
24
  rotation?: number;
23
25
  };
26
+ type PenPoint = Point$1 & {
27
+ w?: number;
28
+ };
29
+ type PenKind = "ink" | "marker";
30
+ type PenChoice = PenKind | "eraser";
24
31
  type PenStroke = {
25
32
  id: string;
26
- points: Point$1[];
33
+ /** The pen it was drawn with. One drawn before there were several was drawn in ink. */
34
+ kind?: PenKind;
35
+ /**
36
+ * Its points are the line the ink follows, as it is drawn, and are not smoothed again. Set on
37
+ * what the eraser leaves of a stroke, so that rubbing part of it out moves none of the rest.
38
+ */
39
+ fixed?: boolean;
40
+ points: PenPoint[];
27
41
  color: string;
28
42
  width: number;
29
43
  rotation?: number;
30
44
  };
31
- type TextAnnotation = {
45
+ type TextAnnotation$1 = {
32
46
  id: string;
33
47
  x: number;
34
48
  y: number;
@@ -36,6 +50,8 @@ type TextAnnotation = {
36
50
  scale?: number;
37
51
  rotation?: number;
38
52
  boxWidth?: number;
53
+ /** What the note was written in. A note keeps its own, whatever the next one is set to. */
54
+ style?: TextStyleSettings;
39
55
  };
40
56
  type CommentMessage = {
41
57
  id: string;
@@ -56,6 +72,15 @@ type CommentTarget = {
56
72
  rect: Rect;
57
73
  documentPoint: Point$1;
58
74
  anchor?: Point$1;
75
+ /** The address of the page the element was on when it was commented on. */
76
+ url?: string;
77
+ /** The size, in CSS px, of the window that page was in. */
78
+ viewport?: {
79
+ width: number;
80
+ height: number;
81
+ };
82
+ /** That window was a responsive preview of this size, not the page itself. */
83
+ preview?: boolean;
59
84
  };
60
85
  type CommentThread = {
61
86
  id: string;
@@ -139,23 +164,6 @@ type DistanceOverlay = {
139
164
  type ToolMode = "none" | "select" | "selection" | "guides" | "xray" | "rulers" | "arrows" | "pen" | "text" | "comments";
140
165
  type PersistentToolMode = Exclude<ToolMode, "none" | "xray" | "rulers">;
141
166
 
142
- type Point = {
143
- x: number;
144
- y: number;
145
- };
146
- type ToolbarPlacement = Point & {
147
- edge?: ToolbarSide | null;
148
- align?: DockAlign;
149
- vertical?: boolean;
150
- };
151
- type DockAlign = "start" | "center" | "end";
152
-
153
- type TextFont = "handwritten" | "code" | "serif" | "sans-serif";
154
- type TextStyleSettings = {
155
- font: TextFont;
156
- color: string;
157
- };
158
-
159
167
  type LayoutGuideKind = "columns" | "rows" | "grid";
160
168
  type LayoutGuideAlign = "stretch" | "min" | "center" | "max";
161
169
  type LayoutGuide = {
@@ -171,6 +179,185 @@ type LayoutGuide = {
171
179
  align: LayoutGuideAlign;
172
180
  };
173
181
 
182
+ declare const REVIEW_STATE_SCHEMA_VERSION = 1;
183
+ type ReviewId = string;
184
+ type PageId = string;
185
+ type PageVersionId = string;
186
+ type DomTargetId = string;
187
+ type ViewportSnapshot = {
188
+ width: number;
189
+ height: number;
190
+ devicePixelRatio: number;
191
+ };
192
+ type ScrollSnapshot = Point$1;
193
+ type ScreenshotAsset = {
194
+ id: string;
195
+ mimeType: "image/png" | "image/jpeg" | "image/webp";
196
+ width: number;
197
+ height: number;
198
+ dataUrl?: string;
199
+ storageKey?: string;
200
+ };
201
+ type PageSnapshot = {
202
+ url: string;
203
+ title?: string;
204
+ capturedAt: number;
205
+ viewport: ViewportSnapshot;
206
+ scroll: ScrollSnapshot;
207
+ screenshot?: ScreenshotAsset;
208
+ };
209
+ type DomAccessibilityFingerprint = {
210
+ role?: string;
211
+ name?: string;
212
+ label?: string;
213
+ };
214
+ type DomFingerprint = {
215
+ selector?: string;
216
+ domPath?: string[];
217
+ framePath?: string[];
218
+ frameShadowPaths?: string[][];
219
+ shadowPath?: string[];
220
+ tagName: string;
221
+ id?: string;
222
+ attributes: Record<string, string>;
223
+ text?: string;
224
+ nearbyText?: string;
225
+ htmlPreview?: string;
226
+ accessibility?: DomAccessibilityFingerprint;
227
+ bounds: Rect;
228
+ styles?: Record<string, string>;
229
+ };
230
+ type DomContext = {
231
+ fingerprints: Record<DomTargetId, DomFingerprint>;
232
+ };
233
+ type PageVersion = {
234
+ id: PageVersionId;
235
+ pageId: PageId;
236
+ number: number;
237
+ createdAt: number;
238
+ snapshot: PageSnapshot;
239
+ domContext: DomContext;
240
+ };
241
+ type ReviewComment = {
242
+ id: string;
243
+ targetId?: DomTargetId;
244
+ text: string;
245
+ messages: CommentMessage[];
246
+ position: Point$1;
247
+ status: "open" | "resolved";
248
+ createdVersion: PageVersionId;
249
+ createdAt: number;
250
+ updatedAt: number;
251
+ };
252
+ type ArrowAnnotation = Arrow & {
253
+ type: "arrow";
254
+ };
255
+ type PenAnnotation = PenStroke & {
256
+ type: "pen";
257
+ };
258
+ type RectangleAnnotation = {
259
+ type: "rectangle";
260
+ id: string;
261
+ rect: Rect;
262
+ color: string;
263
+ width: number;
264
+ rotation?: number;
265
+ };
266
+ type TextAnnotation = TextAnnotation$1 & {
267
+ type: "text";
268
+ };
269
+ type ReviewMeasurement = Omit<Measurement, "elementRef">;
270
+ type MeasurementAnnotation = ReviewMeasurement & {
271
+ type: "measurement";
272
+ kind: "element";
273
+ targetId?: DomTargetId;
274
+ };
275
+ type ReviewDistance = Omit<DistanceOverlay, "elementRefA" | "elementRefB" | "pinTargetRef">;
276
+ type DistanceMeasurementAnnotation = ReviewDistance & {
277
+ type: "measurement";
278
+ kind: "distance";
279
+ targetIds?: {
280
+ a?: DomTargetId;
281
+ b?: DomTargetId;
282
+ pin?: DomTargetId;
283
+ };
284
+ };
285
+ type GuideAnnotation = Guide & {
286
+ type: "guide";
287
+ };
288
+ type ReviewAnnotation = ArrowAnnotation | PenAnnotation | RectangleAnnotation | TextAnnotation | MeasurementAnnotation | DistanceMeasurementAnnotation | GuideAnnotation;
289
+ type ReviewWorkspace = {
290
+ guides: Guide[];
291
+ arrows: Arrow[];
292
+ penStrokes: PenStroke[];
293
+ textAnnotations: TextAnnotation$1[];
294
+ measurements: ReviewMeasurement[];
295
+ heldDistances: ReviewDistance[];
296
+ comments: ReviewComment[];
297
+ layoutGuides: LayoutGuide[];
298
+ textStyle?: TextStyleSettings;
299
+ };
300
+ type Review = {
301
+ id: ReviewId;
302
+ pageId: PageId;
303
+ createdAt: number;
304
+ updatedAt: number;
305
+ comments: ReviewComment[];
306
+ annotations: ReviewAnnotation[];
307
+ textStyle?: TextStyleSettings;
308
+ workspace?: ReviewWorkspace;
309
+ };
310
+ type ReviewPage = {
311
+ id: PageId;
312
+ projectId: string;
313
+ url: string;
314
+ title?: string;
315
+ versionIds: PageVersionId[];
316
+ };
317
+ type ReviewProject = {
318
+ id: string;
319
+ name: string;
320
+ };
321
+ type ReviewState = {
322
+ schemaVersion: typeof REVIEW_STATE_SCHEMA_VERSION;
323
+ project: ReviewProject;
324
+ page: ReviewPage;
325
+ versions: PageVersion[];
326
+ review: Review;
327
+ };
328
+
329
+ type ColorPickerFormat = "hex" | "rgb" | "hsl" | "oklch";
330
+ type ColorSample = {
331
+ red: number;
332
+ green: number;
333
+ blue: number;
334
+ alpha: number;
335
+ };
336
+
337
+ /** What a pen was last set to. Kept for each pen, so each is found as it was left. */
338
+ type PenSetting = {
339
+ width?: number;
340
+ color?: string;
341
+ };
342
+ type PenSettings = Partial<Record<PenKind | "eraser", PenSetting>>;
343
+
344
+ type Point = {
345
+ x: number;
346
+ y: number;
347
+ };
348
+ type ToolbarPlacement = Point & {
349
+ edge?: ToolbarSide | null;
350
+ align?: DockAlign;
351
+ vertical?: boolean;
352
+ };
353
+ type DockAlign = "start" | "center" | "end";
354
+
355
+ type PersistenceRevision = {
356
+ counter: number;
357
+ writerId: string;
358
+ mutationId: string;
359
+ };
360
+
174
361
  declare const MESURER_STORAGE_VERSION = 2;
175
362
  type GuidePattern = "solid" | "dashed" | "dotted";
176
363
  type InfoCardMode = "hover" | "click";
@@ -199,6 +386,8 @@ type MesurerStoredSettings = {
199
386
  toolbarPosition?: ToolbarPlacement;
200
387
  toolbarDock?: ToolbarDock;
201
388
  toolbarAutoHide?: boolean;
389
+ penKind?: PenChoice;
390
+ penSettings?: PenSettings;
202
391
  highlightColor?: string;
203
392
  guideColor?: string;
204
393
  arrowColor?: string;
@@ -238,7 +427,7 @@ type MesurerPageArtifacts = {
238
427
  selectedPenStrokeIds?: string[];
239
428
  selectedTextIds?: string[];
240
429
  penStrokes: PenStroke[];
241
- textAnnotations: TextAnnotation[];
430
+ textAnnotations: TextAnnotation$1[];
242
431
  measurements: Measurement[];
243
432
  activeMeasurement: Measurement | null;
244
433
  heldDistances: DistanceOverlay[];
@@ -253,6 +442,7 @@ declare const isPagedWorkspaceStore: (value: unknown) => value is PagedWorkspace
253
442
  type MesurerPersistenceSnapshot = {
254
443
  settings: MesurerStoredSettings;
255
444
  workspace: MesurerStoredWorkspace | PagedWorkspaceStore | null;
445
+ revision?: PersistenceRevision;
256
446
  };
257
447
  type PersistenceChangeSource = {
258
448
  settings?: boolean;
@@ -272,10 +462,64 @@ declare const normalizeStoredWorkspace: (value: unknown) => MesurerStoredWorkspa
272
462
  declare const createLocalStoragePersistence: (ownerWindow: Window, workspaceKey: string, settingsKey?: string, legacyKey?: string) => MesurerPersistence;
273
463
  declare const createPageScopedPersistence: (base: MesurerPersistence, getPageKey: () => string) => MesurerPersistence;
274
464
 
465
+ type CapturedReviewImage = {
466
+ blob: Blob;
467
+ width: number;
468
+ height: number;
469
+ mimeType: "image/png" | "image/jpeg" | "image/webp";
470
+ origin: {
471
+ x: number;
472
+ y: number;
473
+ };
474
+ cssWidth: number;
475
+ cssHeight: number;
476
+ scale: number;
477
+ /** The capture as an SVG document that loads, from their own address, the images that could
478
+ * not be read into `blob`. Present only when there are some. */
479
+ live?: string;
480
+ };
481
+
482
+ type ReviewSnapshotCapture = {
483
+ blob: Blob;
484
+ width: number;
485
+ height: number;
486
+ mimeType: "image/png" | "image/jpeg" | "image/webp";
487
+ origin?: {
488
+ x: number;
489
+ y: number;
490
+ };
491
+ cssWidth?: number;
492
+ cssHeight?: number;
493
+ scale?: number;
494
+ live?: string;
495
+ };
496
+
497
+ type EphemeralReviewUrl = {
498
+ url: string;
499
+ state: ReviewState;
500
+ html: string;
501
+ };
502
+ declare const createEphemeralReviewUrl: (state: ReviewState, capture: ReviewSnapshotCapture, ownerWindow: Window) => Promise<EphemeralReviewUrl>;
503
+
504
+ type CreateReviewViewer = typeof createEphemeralReviewUrl;
505
+
506
+ type ReviewPublication = {
507
+ id: string;
508
+ html: string;
509
+ state: ReviewState;
510
+ screenshot: Blob;
511
+ };
512
+
275
513
  type MesurerFeatures = {
276
514
  screenshot?: boolean;
277
515
  rulers?: boolean;
278
516
  settings?: boolean;
517
+ responsive?: boolean;
518
+ /**
519
+ * Saving a review. Off unless asked for: reviews are not kept anywhere yet but on the machine
520
+ * they are saved from, so the Save button is not shown to everyone.
521
+ */
522
+ review?: boolean;
279
523
  };
280
524
 
281
525
  type ExtensionRecordingSession = {
@@ -327,9 +571,21 @@ type MesurerProps = {
327
571
  persistence?: MesurerPersistence;
328
572
  onPersistenceError?: (error: unknown) => void;
329
573
  captureVisibleTab?: () => Promise<Blob>;
574
+ captureDom?: ((ownerDocument: Document, ownerWindow: Window) => Promise<CapturedReviewImage>) | false;
575
+ /** Builds a saved review's viewer page, for a host that loads that code on demand. */
576
+ createReviewViewer?: CreateReviewViewer;
577
+ /**
578
+ * Keeps a saved review, and gives the address it opens at. Without it the review's own page
579
+ * is kept in this site's storage and opened on this site, which only a site that serves the
580
+ * viewer can do.
581
+ */
582
+ publishReview?: (review: ReviewPublication) => Promise<string>;
583
+ /** Fills the tab a review will open in while it is made, for a host that loads that code on demand. */
584
+ showReviewLoading?: (view: Window) => void;
330
585
  extensionRecording?: ExtensionRecordingSession;
331
586
  extensionRecordingPlayer?: string;
332
587
  features?: MesurerFeatures;
588
+ reviewState?: ReviewState;
333
589
  initialState?: {
334
590
  enabled?: boolean;
335
591
  minimized?: boolean;
@@ -357,7 +613,7 @@ type MesurerProps = {
357
613
  };
358
614
  };
359
615
 
360
- declare function Mesurer({ highlightColor, guideColor, arrowColor, guideHighlightEnabled, hoverHighlightEnabled, layoutDetailsEnabled, persistOnReload, persistSession, shortcutsEnabled, theme, portalTarget, persistKey, colorPickerFormats, colorPickerClickFormat, snapEnabled, snapGuidesEnabled, snapArrowsEnabled, arrowClickToPlace, selectNewGuideEnabled, multiMeasureEnabled, guideStyle, rulerSettings, textStyle, persistence, onPersistenceError, captureVisibleTab, extensionRecording, extensionRecordingPlayer, features, initialState, }: MesurerProps): react_jsx_runtime.JSX.Element | null;
616
+ declare function Mesurer(props: MesurerProps): react_jsx_runtime.JSX.Element;
361
617
 
362
618
  type TypographyRow = {
363
619
  label: string;
@@ -396,4 +652,4 @@ type TextInspectorOptions = {
396
652
  declare const createTextInspector: (options?: TextInspectorOptions, legacy?: boolean) => TextInspectorAPI;
397
653
  declare const TextInspector: TextInspectorAPI;
398
654
 
399
- export { type Arrow, type ColorPickerFormat, type ColorSample, type GuidePattern, type GuideStyle, MESURER_STORAGE_VERSION, Mesurer, type MesurerFeatures, type MesurerPageArtifacts, type MesurerPersistence, type MesurerPersistenceSnapshot, type MesurerProps, type MesurerSessionChrome, type MesurerStoredSettings, type MesurerStoredWorkspace, type PagedWorkspaceStore, type PenStroke, type Point$1 as Point, type RulerSettings, type ScreenshotSettings, type ShareMode, type TextAnnotation, type TextFont, TextInspector, type TextInspectorAPI, type TextInspectorOptions, type TextStyleSettings, type TypographyInfo, type TypographyRow, createLocalStoragePersistence, createPageScopedPersistence, createTextInspector, isPagedWorkspaceStore, normalizeStoredSettings, normalizeStoredWorkspace };
655
+ export { type Arrow, type ColorPickerFormat, type ColorSample, type GuidePattern, type GuideStyle, MESURER_STORAGE_VERSION, Mesurer, type MesurerFeatures, type MesurerPageArtifacts, type MesurerPersistence, type MesurerPersistenceSnapshot, type MesurerProps, type MesurerSessionChrome, type MesurerStoredSettings, type MesurerStoredWorkspace, type PagedWorkspaceStore, type PenStroke, type Point$1 as Point, type RulerSettings, type ScreenshotSettings, type ShareMode, type TextAnnotation$1 as TextAnnotation, type TextBackground, type TextFont, TextInspector, type TextInspectorAPI, type TextInspectorOptions, type TextStyleSettings, type TypographyInfo, type TypographyRow, createLocalStoragePersistence, createPageScopedPersistence, createTextInspector, isPagedWorkspaceStore, normalizeStoredSettings, normalizeStoredWorkspace };