mesurer 0.2.6 → 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;
@@ -148,23 +164,6 @@ type DistanceOverlay = {
148
164
  type ToolMode = "none" | "select" | "selection" | "guides" | "xray" | "rulers" | "arrows" | "pen" | "text" | "comments";
149
165
  type PersistentToolMode = Exclude<ToolMode, "none" | "xray" | "rulers">;
150
166
 
151
- type Point = {
152
- x: number;
153
- y: number;
154
- };
155
- type ToolbarPlacement = Point & {
156
- edge?: ToolbarSide | null;
157
- align?: DockAlign;
158
- vertical?: boolean;
159
- };
160
- type DockAlign = "start" | "center" | "end";
161
-
162
- type TextFont = "handwritten" | "code" | "serif" | "sans-serif";
163
- type TextStyleSettings = {
164
- font: TextFont;
165
- color: string;
166
- };
167
-
168
167
  type LayoutGuideKind = "columns" | "rows" | "grid";
169
168
  type LayoutGuideAlign = "stretch" | "min" | "center" | "max";
170
169
  type LayoutGuide = {
@@ -180,6 +179,185 @@ type LayoutGuide = {
180
179
  align: LayoutGuideAlign;
181
180
  };
182
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
+
183
361
  declare const MESURER_STORAGE_VERSION = 2;
184
362
  type GuidePattern = "solid" | "dashed" | "dotted";
185
363
  type InfoCardMode = "hover" | "click";
@@ -208,6 +386,8 @@ type MesurerStoredSettings = {
208
386
  toolbarPosition?: ToolbarPlacement;
209
387
  toolbarDock?: ToolbarDock;
210
388
  toolbarAutoHide?: boolean;
389
+ penKind?: PenChoice;
390
+ penSettings?: PenSettings;
211
391
  highlightColor?: string;
212
392
  guideColor?: string;
213
393
  arrowColor?: string;
@@ -247,7 +427,7 @@ type MesurerPageArtifacts = {
247
427
  selectedPenStrokeIds?: string[];
248
428
  selectedTextIds?: string[];
249
429
  penStrokes: PenStroke[];
250
- textAnnotations: TextAnnotation[];
430
+ textAnnotations: TextAnnotation$1[];
251
431
  measurements: Measurement[];
252
432
  activeMeasurement: Measurement | null;
253
433
  heldDistances: DistanceOverlay[];
@@ -262,6 +442,7 @@ declare const isPagedWorkspaceStore: (value: unknown) => value is PagedWorkspace
262
442
  type MesurerPersistenceSnapshot = {
263
443
  settings: MesurerStoredSettings;
264
444
  workspace: MesurerStoredWorkspace | PagedWorkspaceStore | null;
445
+ revision?: PersistenceRevision;
265
446
  };
266
447
  type PersistenceChangeSource = {
267
448
  settings?: boolean;
@@ -281,11 +462,64 @@ declare const normalizeStoredWorkspace: (value: unknown) => MesurerStoredWorkspa
281
462
  declare const createLocalStoragePersistence: (ownerWindow: Window, workspaceKey: string, settingsKey?: string, legacyKey?: string) => MesurerPersistence;
282
463
  declare const createPageScopedPersistence: (base: MesurerPersistence, getPageKey: () => string) => MesurerPersistence;
283
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
+
284
513
  type MesurerFeatures = {
285
514
  screenshot?: boolean;
286
515
  rulers?: boolean;
287
516
  settings?: boolean;
288
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;
289
523
  };
290
524
 
291
525
  type ExtensionRecordingSession = {
@@ -337,9 +571,21 @@ type MesurerProps = {
337
571
  persistence?: MesurerPersistence;
338
572
  onPersistenceError?: (error: unknown) => void;
339
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;
340
585
  extensionRecording?: ExtensionRecordingSession;
341
586
  extensionRecordingPlayer?: string;
342
587
  features?: MesurerFeatures;
588
+ reviewState?: ReviewState;
343
589
  initialState?: {
344
590
  enabled?: boolean;
345
591
  minimized?: boolean;
@@ -406,4 +652,4 @@ type TextInspectorOptions = {
406
652
  declare const createTextInspector: (options?: TextInspectorOptions, legacy?: boolean) => TextInspectorAPI;
407
653
  declare const TextInspector: TextInspectorAPI;
408
654
 
409
- 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 };