@inkbar/core 0.5.0 → 0.6.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as pdfColorToHex, $t as StampAnnotation, A as TextItem, At as LineAnnotation, B as createHistory, Bt as NoteSchema, C as DocumentInfo, Cn as rectFromPoints, Ct as GLOSS_FORMAT, D as OpenOptions, Dn as translateRect, Dt as IMAGE_DATA_URL, E as InkStatus, En as translateQuad, Et as GLOSS_VERSION, F as ImportOptions, Ft as LoupeSchema, G as createAnnotationStore, Gt as PolylineSchema, H as AnnotationStore, Ht as PolyAnnotation, I as ImportResult, It as MaskAnnotation, J as EmbeddedSummary, Jt as RedactAnnotation, K as deriveRect, Kt as QuadSchema, L as exportAnnotations, Lt as MaskSchema, M as InkError, Mt as LineEndingSchema, N as InkErrorCode, Nt as LineSchema, O as openDocument, On as unionRects, Ot as InkAnnotation, P as isInkError, Pt as LoupeAnnotation, Q as importedId, Qt as SquareSchema, R as importAnnotations, Rt as NoteAnnotation, S as createToolStyle, Sn as rectContainsPoint, St as FreeTextStyleSchema, T as InkDocument, Tn as rectsIntersect, Tt as GLOSS_SCHEMA_ID, U as StoreMode, Ut as PolySchema, V as AnnotationChange, Vt as PointSchema, W as StoreOptions, Wt as PolygonSchema, X as SUPPORTED_SUBTYPES, Xt as ShapeAnnotation, Y as EmbeddedTarget, Yt as RedactSchema, Z as importEmbeddedPage, Zt as ShapeSchema, _ as StyleGroup, _n as invertMatrix, _t as ExportedAnnotationSchema, a as SignatureStore, an as derived, at as normalizeColor, b as ToolStyle, bn as quadFromRect, bt as FreeTextSchema, c as createInkTemplate, cn as PageInfo, ct as AnnotationDocument, d as createSignatureLibrary, dn as Matrix, dt as AnnotationOfType, en as StampSchema, et as summarise, f as normaliseInk, fn as Point, ft as AnnotationPatch, g as ScopedToolStyle, gn as approxEqual, gt as ExportedAnnotation, h as STYLE_GROUPS, hn as applyMatrix, ht as CircleSchema, i as SignatureOptions, in as Writable, it as cssVariableDefaults, j as DocumentSource, jt as LineEnding, k as TextContent, kt as InkSchema, l as createLocalSignatureStore, ln as PageRotation, lt as AnnotationDocumentSchema, m as CurrentStyle, mn as Rect, mt as AnnotationType, n as SIGNATURE_INK_WIDTH, nn as TextMarkupSchema, nt as FringeSchema, o as SignatureTemplate, on as readonly, ot as staticDefaults, p as placeSignature, pn as Quad, pt as AnnotationSchema, q as EmbeddedFieldPatch, qt as RectSchema, r as SignatureLibrary, rn as Readable, rt as AnnotationDefaults, s as createImageTemplate, sn as writable, st as Annotation, t as DEFAULT_SIGNATURE_WIDTH, tn as TextMarkupAnnotation, tt as Fringe, u as createMemorySignatureStore, un as PdfAssets, ut as AnnotationInput, v as StyleKey, vn as multiplyMatrix, vt as ForeignAnnotation, w as DocumentStatus, wn as rectFromQuad, wt as GLOSS_MEDIA_TYPE, x as ToolStyleDeps, xn as quadsFromFlat, xt as FreeTextStyle, y as StyleProps, yn as pointsFromFlat, yt as FreeTextAnnotation, z as History, zt as NoteIconSchema } from "./signatures-BwaXi7C8.mjs";
1
+ import { $ as createRecordStore, $t as QuadSchema, A as TextItem, An as rectContainsPoint, At as GLOSS_FORMAT, B as PluginHistory, Bt as LineSchema, C as DocumentInfo, Cn as approxEqual, Ct as ExportedAnnotation, D as OpenOptions, Dn as quadFromRect, Dt as FreeTextSchema, E as InkStatus, En as pointsFromFlat, Et as FreeTextAnnotation, F as ImportOptions, Fn as translateQuad, Ft as InkAnnotation, G as StoreMode, Gt as NoteAnnotation, H as AnnotationChange, Ht as LoupeSchema, I as ImportResult, In as translateRect, It as InkSchema, J as deriveRect, Jt as PointSchema, K as StoreOptions, Kt as NoteIconSchema, L as exportAnnotations, Ln as unionRects, Lt as LineAnnotation, M as InkError, Mn as rectFromQuad, Mt as GLOSS_SCHEMA_ID, N as InkErrorCode, Nn as rectFromQuads, Nt as GLOSS_VERSION, O as openDocument, On as quadsFromFlat, Ot as FreeTextStyle, P as isInkError, Pn as rectsIntersect, Pt as IMAGE_DATA_URL, Q as RecordStoreOptions, Qt as PolylineSchema, R as importAnnotations, Rt as LineEnding, S as createToolStyle, Sn as applyMatrix, St as CircleSchema, T as InkDocument, Tn as multiplyMatrix, Tt as ForeignAnnotation, U as AnnotationEdit, Ut as MaskAnnotation, V as createHistory, Vt as LoupeAnnotation, W as AnnotationStore, Wt as MaskSchema, X as RecordChange, Xt as PolySchema, Y as RecordBase, Yt as PolyAnnotation, Z as RecordStore, Zt as PolygonSchema, _ as StyleGroup, _n as PdfAssets, _t as AnnotationInput, a as SignatureStore, an as SquareSchema, at as importedId, b as ToolStyle, bn as Quad, bt as AnnotationSchema, c as createInkTemplate, cn as TextMarkupAnnotation, ct as Fringe, d as createSignatureLibrary, dn as Writable, dt as cssVariableDefaults, en as RectSchema, et as EmbeddedFieldPatch, f as normaliseInk, fn as derived, ft as normalizeColor, g as ScopedToolStyle, gn as PageRotation, gt as AnnotationDocumentSchema, h as STYLE_GROUPS, hn as PageInfo, ht as AnnotationDocument, i as SignatureOptions, in as ShapeSchema, it as importEmbeddedPage, j as DocumentSource, jn as rectFromPoints, jt as GLOSS_MEDIA_TYPE, k as TextContent, kn as quadsFromRect, kt as FreeTextStyleSchema, l as createLocalSignatureStore, ln as TextMarkupSchema, lt as FringeSchema, m as CurrentStyle, mn as writable, mt as Annotation, n as SIGNATURE_INK_WIDTH, nn as RedactSchema, nt as EmbeddedTarget, o as SignatureTemplate, on as StampAnnotation, ot as pdfColorToHex, p as placeSignature, pn as readonly, pt as staticDefaults, q as createAnnotationStore, qt as NoteSchema, r as SignatureLibrary, rn as ShapeAnnotation, rt as SUPPORTED_SUBTYPES, s as createImageTemplate, sn as StampSchema, st as summarise, t as DEFAULT_SIGNATURE_WIDTH, tn as RedactAnnotation, tt as EmbeddedSummary, u as createMemorySignatureStore, un as Readable, ut as AnnotationDefaults, v as StyleKey, vn as Matrix, vt as AnnotationOfType, w as DocumentStatus, wn as invertMatrix, wt as ExportedAnnotationSchema, x as ToolStyleDeps, xn as Rect, xt as AnnotationType, y as StyleProps, yn as Point, yt as AnnotationPatch, z as History, zt as LineEndingSchema } from "./signatures-By4B40DP.mjs";
2
2
  import { INTENTS, LINE_ENDINGS, NOTE_ICONS, PDF_NAME } from "gloss-format";
3
3
  import { z } from "zod";
4
4
  //#region src/model/events.d.ts
@@ -72,8 +72,15 @@ interface SnapshotHistoryOptions {
72
72
  * framework calls `observe` whenever the host's list changes; every change is a step. Undo and
73
73
  * redo propose an earlier list through `apply` and move the stacks only once the host applies
74
74
  * it. `canUndo` and `canRedo` report stack sizes; the framework ANDs them with its own flag.
75
+ *
76
+ * Tracked record stores belong to their plugins, not the host, so a step also snapshots each of
77
+ * them. Undo and redo put records back at once (`replaceAll(list, 'history')`) and propose the
78
+ * annotations as above; a step whose annotations did not change moves the stacks at once. A
79
+ * record change outside a batch opens one, so the change and the host's list that follows in
80
+ * the same macrotask are one step. A record store's `reset` takes its records out of every step
81
+ * and drops the steps left with nothing to undo; the others still undo and redo, as in History.
75
82
  */
76
- interface SnapshotHistory {
83
+ interface SnapshotHistory extends PluginHistory {
77
84
  readonly canUndo: Readable<boolean>;
78
85
  readonly canRedo: Readable<boolean>;
79
86
  undo(): void;
@@ -101,6 +108,12 @@ interface SnapshotHistory {
101
108
  * supported.
102
109
  */
103
110
  batch(fn: () => void): void;
111
+ /**
112
+ * Runs the reactions for each of the store's user edits inside a batch, so what they change
113
+ * joins the edit's step. Undo and redo reach the store as a `replace`, which reacts to nothing.
114
+ * The binding attaches each opened document's store. Returns a function that detaches it.
115
+ */
116
+ attach(store: AnnotationStore): () => void;
104
117
  }
105
118
  export declare function createSnapshotHistory(opts: SnapshotHistoryOptions): SnapshotHistory;
106
119
  //#endregion
@@ -177,5 +190,5 @@ export declare function recogniseStroke(points: readonly Point[]): {
177
190
  /** The @inkbar/core version, from its package.json. */
178
191
  export declare const version: string;
179
192
  //#endregion
180
- export { Annotation, AnnotationChange, AnnotationDefaults, AnnotationDocument, AnnotationDocumentSchema, AnnotationInput, AnnotationOfType, AnnotationPatch, AnnotationSchema, AnnotationStore, AnnotationType, CircleSchema, type CurrentStyle, DEFAULT_SIGNATURE_WIDTH, type DocumentInfo, type DocumentSource, type DocumentStatus, EmbeddedFieldPatch, EmbeddedSummary, EmbeddedTarget, ExportedAnnotation, ExportedAnnotationSchema, ForeignAnnotation, FreeTextAnnotation, FreeTextSchema, FreeTextStyle, FreeTextStyleSchema, type Fringe, FringeSchema, GLOSS_FORMAT, GLOSS_MEDIA_TYPE, GLOSS_SCHEMA_ID, GLOSS_VERSION, History, IMAGE_DATA_URL, INTENTS, type ImportOptions, type ImportResult, InkAnnotation, type InkDocument, InkError, InkErrorCode, InkSchema, type InkStatus, LINE_ENDINGS, LineAnnotation, LineEnding, LineEndingSchema, LineSchema, LoupeAnnotation, LoupeSchema, MaskAnnotation, MaskSchema, Matrix, NOTE_ICONS, NoteAnnotation, NoteIconSchema, NoteSchema, type OpenOptions, PDF_NAME, type PageInfo, type PageRotation, type PdfAssets, Point, PointSchema, PolyAnnotation, PolySchema, PolygonSchema, PolylineSchema, Quad, QuadSchema, Readable, type Recognised, Rect, RectSchema, RedactAnnotation, RedactSchema, SIGNATURE_INK_WIDTH, STYLE_GROUPS, SUPPORTED_SUBTYPES, type ScopedToolStyle, ShapeAnnotation, ShapeSchema, type SignatureLibrary, type SignatureOptions, type SignatureStore, type SignatureTemplate, type SnapshotHistory, type SnapshotHistoryOptions, SquareSchema, StampAnnotation, StampSchema, StoreMode, StoreOptions, type StyleGroup, type StyleKey, type StyleProps, type TextContent, type TextItem, TextMarkupAnnotation, TextMarkupSchema, type ThreadRoot, type ToolStyle, type ToolStyleDeps, Writable, applyMatrix, approxEqual, createAnnotationStore, createHistory, createImageTemplate, createInkTemplate, createLocalSignatureStore, createMemorySignatureStore, createSignatureLibrary, createToolStyle, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isInkError, multiplyMatrix, normaliseInk, normalizeColor, openDocument, pdfColorToHex, placeSignature, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, staticDefaults, summarise, translateQuad, translateRect, unionRects, writable };
193
+ export { Annotation, AnnotationChange, AnnotationDefaults, AnnotationDocument, AnnotationDocumentSchema, AnnotationEdit, AnnotationInput, AnnotationOfType, AnnotationPatch, AnnotationSchema, AnnotationStore, AnnotationType, CircleSchema, type CurrentStyle, DEFAULT_SIGNATURE_WIDTH, type DocumentInfo, type DocumentSource, type DocumentStatus, EmbeddedFieldPatch, EmbeddedSummary, EmbeddedTarget, ExportedAnnotation, ExportedAnnotationSchema, ForeignAnnotation, FreeTextAnnotation, FreeTextSchema, FreeTextStyle, FreeTextStyleSchema, type Fringe, FringeSchema, GLOSS_FORMAT, GLOSS_MEDIA_TYPE, GLOSS_SCHEMA_ID, GLOSS_VERSION, History, IMAGE_DATA_URL, INTENTS, type ImportOptions, type ImportResult, InkAnnotation, type InkDocument, InkError, InkErrorCode, InkSchema, type InkStatus, LINE_ENDINGS, LineAnnotation, LineEnding, LineEndingSchema, LineSchema, LoupeAnnotation, LoupeSchema, MaskAnnotation, MaskSchema, Matrix, NOTE_ICONS, NoteAnnotation, NoteIconSchema, NoteSchema, type OpenOptions, PDF_NAME, type PageInfo, type PageRotation, type PdfAssets, PluginHistory, Point, PointSchema, PolyAnnotation, PolySchema, PolygonSchema, PolylineSchema, Quad, QuadSchema, Readable, type Recognised, RecordBase, RecordChange, RecordStore, RecordStoreOptions, Rect, RectSchema, RedactAnnotation, RedactSchema, SIGNATURE_INK_WIDTH, STYLE_GROUPS, SUPPORTED_SUBTYPES, type ScopedToolStyle, ShapeAnnotation, ShapeSchema, type SignatureLibrary, type SignatureOptions, type SignatureStore, type SignatureTemplate, type SnapshotHistory, type SnapshotHistoryOptions, SquareSchema, StampAnnotation, StampSchema, StoreMode, StoreOptions, type StyleGroup, type StyleKey, type StyleProps, type TextContent, type TextItem, TextMarkupAnnotation, TextMarkupSchema, type ThreadRoot, type ToolStyle, type ToolStyleDeps, Writable, applyMatrix, approxEqual, createAnnotationStore, createHistory, createImageTemplate, createInkTemplate, createLocalSignatureStore, createMemorySignatureStore, createRecordStore, createSignatureLibrary, createToolStyle, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isInkError, multiplyMatrix, normaliseInk, normalizeColor, openDocument, pdfColorToHex, placeSignature, pointsFromFlat, quadFromRect, quadsFromFlat, quadsFromRect, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectFromQuads, rectsIntersect, staticDefaults, summarise, translateQuad, translateRect, unionRects, writable };
181
194
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["StyleKey"],"sources":["../src/model/events.ts","../src/model/selection.ts","../src/model/annotations/pdf-names.ts","../src/model/annotations/style-map.ts","../src/model/annotations/snapshot-history.ts","../src/model/annotations/threads.ts","../src/model/pdf-date.ts","../src/model/recognise.ts","../src/index.ts"],"mappings":";;;;YAAY,SAAS,MAAM,SAAS;qBAEvB,QAAQ,eAAe;UAC1B;EAER,GAAG,gBAAgB,QAAQ,OAAO,GAAG,IAAI,SAAS,OAAO;EAYzD,KAAK,gBAAgB,QAAQ,OAAO,GAAG,SAAS,OAAO;EAMvD;;;;;;;;;;;wBCKc,eACd,gBAAgB,QAChB,oBACA,eACC;;;;;;;wBCvBa,iBAAiB,0CAA0C,OAAO,IAKzE,EAAE,QAAQ,2BAA2B;;wBAI9B,QAAQ,6BAA6B,MAAM,GAAG,YAAY,KAAK;;;KCZ1EA,mBAAiB;;;;;wBAqHN,aACd,GAAG,KAAK;EAAwB;GAChC,MAAMA,aACL;;wBAYa,cACd,GAAG,KAAK;EAAwB;IAC/B;;wBAYa,aAAa,OAAO,aAAa;;wBAKjC,iBAAiB,MAAM,iBAAiB;;wBAKxC,eAAe,MAAM,iBAAiB,YAAYA;;;;;;;wBAuBlD,SAAS,MAAM,gBAAgB,OAAO,aAAa;;wBAmBnD,eAAe,GAAG,aAAa;;;UCvM9B;;EAEf,QAAQ,MAAM;;EAEd;;EAEA;;;;;;;;UASe;WACN,SAAS;WACT,SAAS;EAClB;EACA;EACA;;;;;;EAMA,QAAQ,eAAe;;;;;;;;;;;;;;;;EAgBvB,MAAM;;wBAMQ,sBAAsB,MAAM,yBAAyB;;;;KChDzD,aAAa,iBAAiB;wBAE1B,aAAa,GAAG,aAAa,KAAK;;;;;wBAQlC,QAAQ,GAAG,YAAY,eAAe;;wBAOtC,eAAe,eAAe,eAAe;;wBAM7C,UAAU,eAAe,cAAc,aAAa;;;;;;wBAWpD,WACd,eAAe,cACf,OAAO,aACN;;wBAea,SAAS,eAAe,cAAc,MAAM,aAAa;;;;;wBAmBzD,gBAAgB,GAAG,YAAY,eAAe;;;;wBC3E9C,aAAa,kCAAkC;;;KCsBnD;EACN;EAAc,OAAO;EAAO,KAAK;;EACjC;EAAe,OAAO;EAAO,KAAK;;EAClC;EAAmB,MAAM;;EACzB;EAAiB,MAAM;;;;EAEvB;EAAiB,UAAU;;;;EAE3B;EAAc,UAAU;;;qBAGjB;;;;;;wBA6dG,gBACd,iBAAiB;EACd,OAAO;EAAY;;;;;qBC7fX"}
1
+ {"version":3,"file":"index.d.mts","names":["StyleKey"],"sources":["../src/model/events.ts","../src/model/selection.ts","../src/model/annotations/pdf-names.ts","../src/model/annotations/style-map.ts","../src/model/annotations/snapshot-history.ts","../src/model/annotations/threads.ts","../src/model/pdf-date.ts","../src/model/recognise.ts","../src/index.ts"],"mappings":";;;;YAAY,SAAS,MAAM,SAAS;qBAEvB,QAAQ,eAAe;UAC1B;EAER,GAAG,gBAAgB,QAAQ,OAAO,GAAG,IAAI,SAAS,OAAO;EAYzD,KAAK,gBAAgB,QAAQ,OAAO,GAAG,SAAS,OAAO;EAMvD;;;;;;;;;;;wBCKc,eACd,gBAAgB,QAChB,oBACA,eAC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, $t as readonly, A as styleGroupOf, At as RectSchema, C as repliesTo, Ct as NoteIconSchema, D as STYLE_GROUPS, Dt as PolygonSchema, E as withoutReplies, Et as PolySchema, F as typesInGroup, Ft as TextMarkupSchema, Gt as isKnown, Ht as LINE_ENDINGS, It as FringeSchema, Jt as cssVariableDefaults, Kt as pdfNameSet, M as styleGroupsOf, Mt as ShapeSchema, N as supportedProps, Nt as SquareSchema, O as createToolStyle, Ot as PolylineSchema, P as toFields, Pt as StampSchema, Q as exportAnnotations, Qt as derived, S as isThreadRoot, St as MaskSchema, T as threadRoot, Tt as PointSchema, Ut as NOTE_ICONS, Vt as INTENTS, Wt as PDF_NAME, X as createAnnotationStore, Xt as staticDefaults, Y as openDocument, Yt as normalizeColor, Z as deriveRect, Zt as mergeLineRects, _n as isInkError, _t as IMAGE_DATA_URL, a as createLocalSignatureStore, an as pointsFromFlat, at as pdfColorToHex, b as isAbandonedNote, bt as LineSchema, c as normaliseInk, cn as rectContainsPoint, ct as AnnotationSchema, d as recogniseStroke, dn as rectsIntersect, dt as FreeTextSchema, en as writable, et as createHistory, fn as translateQuad, ft as FreeTextStyleSchema, gn as InkError, gt as GLOSS_VERSION, hn as Emitter, ht as GLOSS_SCHEMA_ID, i as createInkTemplate, in as multiplyMatrix, it as importedId, j as styleGroupOfType, jt as RedactSchema, k as fromAnnotation, kt as QuadSchema, l as placeSignature, ln as rectFromPoints, lt as CircleSchema, mn as unionRects, mt as GLOSS_MEDIA_TYPE, n as SIGNATURE_INK_WIDTH, nn as approxEqual, nt as SUPPORTED_SUBTYPES, o as createMemorySignatureStore, on as quadFromRect, ot as summarise, pn as translateRect, pt as GLOSS_FORMAT, qt as parsePdfDate, r as createImageTemplate, rn as invertMatrix, rt as importEmbeddedPage, s as createSignatureLibrary, sn as quadsFromFlat, st as AnnotationDocumentSchema, t as DEFAULT_SIGNATURE_WIDTH, tn as applyMatrix, tt as isProduction, u as RECOGNISE_THRESHOLD, un as rectFromQuad, ut as ExportedAnnotationSchema, vt as InkSchema, w as threadOf, wt as NoteSchema, x as isReply, xt as LoupeSchema, yt as LineEndingSchema } from "./signatures-CMapTKrC.mjs";
1
+ import { $ as importAnnotations, $t as derived, A as styleGroupOf, At as RectSchema, C as repliesTo, Ct as NoteIconSchema, D as STYLE_GROUPS, Dt as PolygonSchema, E as withoutReplies, Et as PolySchema, F as typesInGroup, Ft as TextMarkupSchema, Gt as isKnown, Ht as LINE_ENDINGS, It as FringeSchema, Jt as cssVariableDefaults, Kt as pdfNameSet, M as styleGroupsOf, Mt as ShapeSchema, N as supportedProps, Nt as SquareSchema, O as createToolStyle, Ot as PolylineSchema, P as toFields, Pt as StampSchema, Q as exportAnnotations, Qt as createRecordStore, S as isThreadRoot, St as MaskSchema, T as threadRoot, Tt as PointSchema, Ut as NOTE_ICONS, Vt as INTENTS, Wt as PDF_NAME, X as createAnnotationStore, Xt as staticDefaults, Y as openDocument, Yt as normalizeColor, Z as deriveRect, Zt as mergeLineRects, _n as unionRects, _t as IMAGE_DATA_URL, a as createLocalSignatureStore, an as multiplyMatrix, at as pdfColorToHex, b as isAbandonedNote, bn as isInkError, bt as LineSchema, c as normaliseInk, cn as quadsFromFlat, ct as AnnotationSchema, d as recogniseStroke, dn as rectFromPoints, dt as FreeTextSchema, en as readonly, et as createHistory, fn as rectFromQuad, ft as FreeTextStyleSchema, gn as translateRect, gt as GLOSS_VERSION, hn as translateQuad, ht as GLOSS_SCHEMA_ID, i as createInkTemplate, in as invertMatrix, it as importedId, j as styleGroupOfType, jt as RedactSchema, k as fromAnnotation, kt as QuadSchema, l as placeSignature, ln as quadsFromRect, lt as CircleSchema, mn as rectsIntersect, mt as GLOSS_MEDIA_TYPE, n as SIGNATURE_INK_WIDTH, nn as applyMatrix, nt as SUPPORTED_SUBTYPES, o as createMemorySignatureStore, on as pointsFromFlat, ot as summarise, pn as rectFromQuads, pt as GLOSS_FORMAT, qt as parsePdfDate, r as createImageTemplate, rn as approxEqual, rt as importEmbeddedPage, s as createSignatureLibrary, sn as quadFromRect, st as AnnotationDocumentSchema, t as DEFAULT_SIGNATURE_WIDTH, tn as writable, tt as isProduction, u as RECOGNISE_THRESHOLD, un as rectContainsPoint, ut as ExportedAnnotationSchema, vn as Emitter, vt as InkSchema, w as threadOf, wt as NoteSchema, x as isReply, xt as LoupeSchema, yn as InkError, yt as LineEndingSchema } from "./signatures-D68fuLlt.mjs";
2
2
  //#region src/model/annotations/snapshot-history.ts
3
+ const noop = () => {};
3
4
  function createSnapshotHistory(opts) {
4
5
  const limit = Math.max(1, opts.limit ?? 200);
5
6
  const past = writable([]);
@@ -10,27 +11,99 @@ function createSnapshotHistory(opts) {
10
11
  /** Open `batch` calls, and whether the batch is waiting out the task for late observes. */
11
12
  let depth = 0;
12
13
  let settling = null;
13
- /** The host's list when the outermost batch opened. */
14
+ /** The state when the outermost batch opened; `undefined` while no list has been seen. */
14
15
  let from;
16
+ /** Each tracked store with its list as of the last change history saw. */
17
+ const tracked = /* @__PURE__ */ new Map();
18
+ const reactions = /* @__PURE__ */ new Set();
19
+ /** Each attached store with its `edit` unsubscribe. */
20
+ const attached = /* @__PURE__ */ new Map();
21
+ /** Set while undo or redo puts records back, so those changes are not steps. */
22
+ let replaying = false;
23
+ function records() {
24
+ return new Map([...tracked].map(([s, t]) => [s, t.previous]));
25
+ }
26
+ function state() {
27
+ return current === void 0 ? void 0 : {
28
+ annotations: current,
29
+ records: records()
30
+ };
31
+ }
32
+ function push(step) {
33
+ past.set([...past.get(), step].slice(-limit));
34
+ future.set([]);
35
+ }
36
+ /** Moves the stacks for an undo or redo that has landed; `prev` is the state it left. */
37
+ function move(kind, prev) {
38
+ if (kind === "undo") {
39
+ past.set(past.get().slice(0, -1));
40
+ future.set([...future.get(), prev]);
41
+ } else {
42
+ future.set(future.get().slice(0, -1));
43
+ past.set([...past.get(), prev]);
44
+ }
45
+ }
46
+ /**
47
+ * After `store`'s reset: drops the steps that changed nothing but `store`, and gives every
48
+ * remaining snapshot its new `list`, so undo and redo leave its records alone while a step
49
+ * that also changed annotations or another store still undoes those, as in History. `was` is
50
+ * its list just before the reset. Undo targets lose the snapshot before a dropped step, redo
51
+ * targets the one after it.
52
+ */
53
+ function dropSteps(store, was, list) {
54
+ const now = current && {
55
+ annotations: current,
56
+ records: records().set(store, was)
57
+ };
58
+ /** Whether the step from `a` to `b` changed only this store, so nothing is left of it. */
59
+ const onlyStore = (a, b) => {
60
+ if (!b) return false;
61
+ const x = a.records.get(store);
62
+ const y = b.records.get(store);
63
+ if (x === void 0 || y === void 0 || sameRecords(x, y)) return false;
64
+ if (!sameList(a.annotations, b.annotations)) return false;
65
+ return [...a.records].every(([s, list]) => s === store || sameRecords(list, b.records.get(s) ?? list));
66
+ };
67
+ const renewed = /* @__PURE__ */ new Map();
68
+ const renew = (step) => {
69
+ const next = step.records.has(store) ? {
70
+ ...step,
71
+ records: new Map(step.records).set(store, list)
72
+ } : step;
73
+ renewed.set(step, next);
74
+ return next;
75
+ };
76
+ const p = past.get();
77
+ past.set(p.filter((step, i) => !onlyStore(step, p[i + 1] ?? now)).map(renew));
78
+ const f = future.get();
79
+ future.set(f.filter((step, i) => !onlyStore(step, f[i + 1] ?? now)).map(renew));
80
+ const target = pending && renewed.get(pending.target);
81
+ pending = pending && target ? {
82
+ ...pending,
83
+ target,
84
+ records: new Map(pending.records).set(store, list)
85
+ } : null;
86
+ }
87
+ /** Opens the outermost batch from the current state. */
88
+ function open() {
89
+ if (settling !== null) endBatch();
90
+ pending = null;
91
+ from = state();
92
+ }
15
93
  function endBatch() {
16
94
  if (settling !== null) clearTimeout(settling);
17
95
  settling = null;
18
96
  const start = from;
19
97
  from = void 0;
20
- if (!opts.enabled() || !start || !current || sameList(current, start)) return;
21
- past.set([...past.get(), start].slice(-limit));
22
- future.set([]);
98
+ if (!opts.enabled() || !start || !current) return;
99
+ if (!(sameList(current, start.annotations) && [...start.records].every(([s, list]) => sameRecords(list, tracked.get(s)?.previous ?? list)))) push(start);
23
100
  }
24
101
  function batch(fn) {
25
102
  if (!opts.enabled()) {
26
103
  fn();
27
104
  return;
28
105
  }
29
- if (depth === 0) {
30
- if (settling !== null) endBatch();
31
- pending = null;
32
- from = current;
33
- }
106
+ if (depth === 0) open();
34
107
  depth++;
35
108
  try {
36
109
  const result = fn();
@@ -60,26 +133,82 @@ function createSnapshotHistory(opts) {
60
133
  if (sameList(next, prev)) return;
61
134
  const step = pending;
62
135
  pending = null;
63
- if (step && sameList(next, step.target)) {
64
- if (step.kind === "undo") {
65
- past.set(past.get().slice(0, -1));
66
- future.set([...future.get(), prev]);
67
- } else {
68
- future.set(future.get().slice(0, -1));
69
- past.set([...past.get(), prev]);
70
- }
136
+ if (step && sameList(next, step.target.annotations)) {
137
+ move(step.kind, {
138
+ annotations: prev,
139
+ records: step.records
140
+ });
71
141
  return;
72
142
  }
73
- past.set([...past.get(), prev].slice(-limit));
74
- future.set([]);
143
+ push({
144
+ annotations: prev,
145
+ records: records()
146
+ });
75
147
  }
76
148
  function propose(kind, target) {
77
149
  if (!opts.enabled() || !target) return;
150
+ const before = pending && pending.kind === kind && pending.target === target ? pending.records : records();
151
+ replaying = true;
152
+ try {
153
+ for (const [s, list] of target.records) {
154
+ const t = tracked.get(s);
155
+ if (t && !sameRecords(t.previous, list)) s.replaceAll([...list], "history");
156
+ }
157
+ } finally {
158
+ replaying = false;
159
+ }
160
+ if (current !== void 0 && sameList(current, target.annotations)) {
161
+ move(kind, {
162
+ annotations: current,
163
+ records: before
164
+ });
165
+ return;
166
+ }
78
167
  pending = {
79
168
  kind,
80
- target
169
+ target,
170
+ records: before
171
+ };
172
+ opts.apply(clone(target.annotations));
173
+ }
174
+ function track(store) {
175
+ if (tracked.has(store)) return noop;
176
+ const unsubscribe = store.on("change", (change) => {
177
+ const t = tracked.get(store);
178
+ if (!t) return;
179
+ const list = store.list.get();
180
+ if (replaying || change.kind === "replace" && change.reason === "history") {
181
+ t.previous = list;
182
+ return;
183
+ }
184
+ if (!opts.enabled()) {
185
+ t.previous = list;
186
+ if (past.get().length > 0 || future.get().length > 0 || pending) clear();
187
+ return;
188
+ }
189
+ if (change.kind === "replace") {
190
+ dropSteps(store, t.previous, list);
191
+ t.previous = list;
192
+ from?.records.set(store, list);
193
+ return;
194
+ }
195
+ if (from === void 0 && depth === 0 && current !== void 0) {
196
+ open();
197
+ settling = setTimeout(endBatch, 0);
198
+ }
199
+ t.previous = list;
200
+ });
201
+ tracked.set(store, {
202
+ previous: store.list.get(),
203
+ unsubscribe
204
+ });
205
+ from?.records.set(store, store.list.get());
206
+ return () => {
207
+ if (tracked.get(store)?.unsubscribe !== unsubscribe) return;
208
+ unsubscribe();
209
+ tracked.delete(store);
210
+ from?.records.delete(store);
81
211
  };
82
- opts.apply(clone(target));
83
212
  }
84
213
  return {
85
214
  canUndo: derived(past, (p) => p.length > 0),
@@ -94,9 +223,36 @@ function createSnapshotHistory(opts) {
94
223
  },
95
224
  clear,
96
225
  observe,
97
- batch
226
+ batch,
227
+ track,
228
+ react(fn) {
229
+ const run = (edit) => fn(edit);
230
+ reactions.add(run);
231
+ return () => {
232
+ reactions.delete(run);
233
+ };
234
+ },
235
+ attach(store) {
236
+ if (attached.has(store)) return noop;
237
+ const off = store.on("edit", (edit) => {
238
+ if (reactions.size === 0) return;
239
+ batch(() => {
240
+ for (const fn of [...reactions]) fn(edit);
241
+ });
242
+ });
243
+ attached.set(store, off);
244
+ return () => {
245
+ if (attached.get(store) !== off) return;
246
+ attached.delete(store);
247
+ off();
248
+ };
249
+ }
98
250
  };
99
251
  }
252
+ /** The same records in the same order; records are frozen, so identity is enough. */
253
+ function sameRecords(a, b) {
254
+ return a === b || a.length === b.length && a.every((x, i) => x === b[i]);
255
+ }
100
256
  function snapshot(list) {
101
257
  return list === void 0 ? void 0 : clone(list);
102
258
  }
@@ -129,8 +285,8 @@ function presentKeys(o) {
129
285
  //#endregion
130
286
  //#region src/index.ts
131
287
  /** The @inkbar/core version, from its package.json. */
132
- const version = "0.5.0";
288
+ const version = "0.6.0";
133
289
  //#endregion
134
- export { AnnotationDocumentSchema, AnnotationSchema, CircleSchema, DEFAULT_SIGNATURE_WIDTH, Emitter, ExportedAnnotationSchema, FreeTextSchema, FreeTextStyleSchema, FringeSchema, GLOSS_FORMAT, GLOSS_MEDIA_TYPE, GLOSS_SCHEMA_ID, GLOSS_VERSION, IMAGE_DATA_URL, INTENTS, InkError, InkSchema, LINE_ENDINGS, LineEndingSchema, LineSchema, LoupeSchema, MaskSchema, NOTE_ICONS, NoteIconSchema, NoteSchema, PDF_NAME, PointSchema, PolySchema, PolygonSchema, PolylineSchema, QuadSchema, RECOGNISE_THRESHOLD, RectSchema, RedactSchema, SIGNATURE_INK_WIDTH, STYLE_GROUPS, SUPPORTED_SUBTYPES, ShapeSchema, SquareSchema, StampSchema, TextMarkupSchema, applyMatrix, approxEqual, createAnnotationStore, createHistory, createImageTemplate, createInkTemplate, createLocalSignatureStore, createMemorySignatureStore, createSignatureLibrary, createSnapshotHistory, createToolStyle, cssVariableDefaults, deriveRect, derived, exportAnnotations, fromAnnotation, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isAbandonedNote, isInkError, isKnown, isReply, isThreadRoot, mergeLineRects, multiplyMatrix, normaliseInk, normalizeColor, openDocument, parsePdfDate, pdfColorToHex, pdfNameSet, placeSignature, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, recogniseStroke, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, repliesTo, staticDefaults, styleGroupOf, styleGroupOfType, styleGroupsOf, summarise, supportedProps, threadOf, threadRoot, toFields, translateQuad, translateRect, typesInGroup, unionRects, version, withoutReplies, writable };
290
+ export { AnnotationDocumentSchema, AnnotationSchema, CircleSchema, DEFAULT_SIGNATURE_WIDTH, Emitter, ExportedAnnotationSchema, FreeTextSchema, FreeTextStyleSchema, FringeSchema, GLOSS_FORMAT, GLOSS_MEDIA_TYPE, GLOSS_SCHEMA_ID, GLOSS_VERSION, IMAGE_DATA_URL, INTENTS, InkError, InkSchema, LINE_ENDINGS, LineEndingSchema, LineSchema, LoupeSchema, MaskSchema, NOTE_ICONS, NoteIconSchema, NoteSchema, PDF_NAME, PointSchema, PolySchema, PolygonSchema, PolylineSchema, QuadSchema, RECOGNISE_THRESHOLD, RectSchema, RedactSchema, SIGNATURE_INK_WIDTH, STYLE_GROUPS, SUPPORTED_SUBTYPES, ShapeSchema, SquareSchema, StampSchema, TextMarkupSchema, applyMatrix, approxEqual, createAnnotationStore, createHistory, createImageTemplate, createInkTemplate, createLocalSignatureStore, createMemorySignatureStore, createRecordStore, createSignatureLibrary, createSnapshotHistory, createToolStyle, cssVariableDefaults, deriveRect, derived, exportAnnotations, fromAnnotation, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isAbandonedNote, isInkError, isKnown, isReply, isThreadRoot, mergeLineRects, multiplyMatrix, normaliseInk, normalizeColor, openDocument, parsePdfDate, pdfColorToHex, pdfNameSet, placeSignature, pointsFromFlat, quadFromRect, quadsFromFlat, quadsFromRect, readonly, recogniseStroke, rectContainsPoint, rectFromPoints, rectFromQuad, rectFromQuads, rectsIntersect, repliesTo, staticDefaults, styleGroupOf, styleGroupOfType, styleGroupsOf, summarise, supportedProps, threadOf, threadRoot, toFields, translateQuad, translateRect, typesInGroup, unionRects, version, withoutReplies, writable };
135
291
 
136
292
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/model/annotations/snapshot-history.ts","../src/index.ts"],"sourcesContent":["import { isProduction } from '../env'\nimport { derived, writable, type Readable } from '../readable'\n\nimport type { Annotation } from './types'\n\nexport interface SnapshotHistoryOptions {\n /** Proposes a list to the host. The step counts once the host applies it (seen by `observe`). */\n apply: (list: Annotation[]) => void\n /** Read on every observed change and every undo or redo. */\n enabled: () => boolean\n /** Steps kept. Default 200. */\n limit?: number | undefined\n}\n\n/**\n * Snapshot undo and redo over a host-owned annotation list, for controlled hosts. The\n * framework calls `observe` whenever the host's list changes; every change is a step. Undo and\n * redo propose an earlier list through `apply` and move the stacks only once the host applies\n * it. `canUndo` and `canRedo` report stack sizes; the framework ANDs them with its own flag.\n */\nexport interface SnapshotHistory {\n readonly canUndo: Readable<boolean>\n readonly canRedo: Readable<boolean>\n undo(): void\n redo(): void\n clear(): void\n /**\n * The host's current list, or `undefined` when the host does not control it. The first list\n * seeds the history; each later list that differs is a step. An `undefined` neither seeds\n * nor records, and the next list after one starts again without a step.\n */\n observe(list: readonly Annotation[] | undefined): void\n /**\n * Runs `fn` and records the host's changes that follow as one step. A framework may hand the\n * host's list back after `fn` returns, one list per proposal, so the batch stays open until\n * the current macrotask ends (`setTimeout(0)`) and then pushes a single step from the list\n * before `fn` to the latest one. Limit: an unrelated change the host makes in that same window\n * is folded into the step. Nested calls join; a throwing `fn` still closes the batch; when\n * history is disabled `fn` only runs. `fn` must be synchronous; a dev build warns when it\n * returns a promise.\n *\n * A batch opened while an earlier one is still settling closes the earlier one first, so the\n * two are two steps. An undo or redo still in flight (proposed, but not yet applied by the\n * host) when a batch opens is dropped: the host's list that follows counts toward the batch.\n * Undo and redo close a settling batch first. Calling `undo()` or `redo()` inside `fn` is not\n * supported.\n */\n batch(fn: () => void): void\n}\n\ntype Snapshot = readonly Annotation[]\ntype Pending = { kind: 'undo' | 'redo'; target: Snapshot }\n\nexport function createSnapshotHistory(opts: SnapshotHistoryOptions): SnapshotHistory {\n const limit = Math.max(1, opts.limit ?? 200)\n const past = writable<Snapshot[]>([])\n const future = writable<Snapshot[]>([])\n let pending: Pending | null = null\n /** Copy of the host's list as of its last change; `undefined` before the first list. */\n let current: Snapshot | undefined\n /** Open `batch` calls, and whether the batch is waiting out the task for late observes. */\n let depth = 0\n let settling: ReturnType<typeof setTimeout> | null = null\n /** The host's list when the outermost batch opened. */\n let from: Snapshot | undefined\n\n function endBatch(): void {\n if (settling !== null) clearTimeout(settling)\n settling = null\n const start = from\n from = undefined\n if (!opts.enabled() || !start || !current || sameList(current, start)) return\n past.set([...past.get(), start].slice(-limit))\n future.set([])\n }\n\n function batch(fn: () => void): void {\n if (!opts.enabled()) {\n fn()\n return\n }\n if (depth === 0) {\n // A batch still settling is closed first, so two batches are two steps.\n if (settling !== null) endBatch()\n // An undo or redo still in flight would be folded into this step; drop it.\n pending = null\n from = current\n }\n depth++\n try {\n const result: unknown = fn()\n if (\n result !== null &&\n typeof result === 'object' &&\n typeof (result as { then?: unknown }).then === 'function' &&\n !isProduction()\n ) {\n console.warn(\n '[inkbar] history.batch(fn): fn returned a promise. Changes after its first await are not part of the batch.'\n )\n }\n } finally {\n depth--\n if (depth === 0) settling = setTimeout(endBatch, 0)\n }\n }\n\n function clear(): void {\n past.set([])\n future.set([])\n pending = null\n from = undefined\n if (settling !== null) clearTimeout(settling)\n settling = null\n }\n\n function observe(next: readonly Annotation[] | undefined): void {\n const prev = current\n current = snapshot(next)\n if (!opts.enabled()) {\n // Steps taken while disabled are unknown to the stacks, which would undo to stale lists.\n if (past.get().length > 0 || future.get().length > 0 || pending) clear()\n return\n }\n // The first list only seeds; there is no step from or to an undefined list.\n if (next === undefined || prev === undefined) return\n // Inside a batch, or while it settles, changes only move `current`; `endBatch` pushes the step.\n if (from !== undefined) return\n // A new array with the same content is not a step, and leaves a pending step alone.\n if (sameList(next, prev)) return\n const step = pending\n pending = null\n if (step && sameList(next, step.target)) {\n if (step.kind === 'undo') {\n past.set(past.get().slice(0, -1))\n future.set([...future.get(), prev])\n } else {\n future.set(future.get().slice(0, -1))\n past.set([...past.get(), prev])\n }\n return\n }\n past.set([...past.get(), prev].slice(-limit))\n future.set([])\n }\n\n function propose(kind: Pending['kind'], target: Snapshot | undefined): void {\n if (!opts.enabled() || !target) return\n pending = { kind, target }\n opts.apply(clone(target) as Annotation[])\n }\n\n return {\n canUndo: derived(past, (p) => p.length > 0),\n canRedo: derived(future, (f) => f.length > 0),\n undo: () => {\n if (from !== undefined && depth === 0) endBatch()\n propose('undo', past.get().at(-1))\n },\n redo: () => {\n if (from !== undefined && depth === 0) endBatch()\n propose('redo', future.get().at(-1))\n },\n clear,\n observe,\n batch,\n }\n}\n\nfunction snapshot(list: readonly Annotation[] | undefined): Snapshot | undefined {\n return list === undefined ? undefined : clone(list)\n}\n\n/** Annotations are JSON values; this also strips framework proxies and `undefined` members. */\nfunction clone<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T\n}\n\n/** Same annotations in the same order, compared by payload; `modifiedAt` may be re-stamped. */\nfunction sameList(a: readonly Annotation[], b: readonly Annotation[]): boolean {\n return a.length === b.length && a.every((x, i) => sameIgnoringModifiedAt(x, b[i]!))\n}\n\nfunction sameIgnoringModifiedAt(a: Annotation, b: Annotation): boolean {\n const { modifiedAt: _a, ...restA } = a\n const { modifiedAt: _b, ...restB } = b\n return deepEqual(restA, restB)\n}\n\n/** Structural equality over JSON values; keys whose value is `undefined` count as absent. */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)\n return false\n if (Array.isArray(a) !== Array.isArray(b)) return false\n const ka = presentKeys(a)\n const kb = presentKeys(b)\n if (ka.length !== kb.length) return false\n return ka.every(\n (k) =>\n kb.includes(k) &&\n deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k])\n )\n}\n\nfunction presentKeys(o: object): string[] {\n return Object.keys(o).filter((k) => (o as Record<string, unknown>)[k] !== undefined)\n}\n","/** Replaced at build time (tsdown) and in tests (vitest) with package.json's version. */\ndeclare const __INKBAR_VERSION__: string\n\n/** The @inkbar/core version, from its package.json. */\nexport const version: string = __INKBAR_VERSION__\n\nexport * from './model/errors'\nexport * from './model/events'\nexport * from './model/geometry'\nexport * from './model/readable'\nexport { mergeLineRects } from './model/selection'\n\nexport { openDocument } from './model/document'\nexport type {\n DocumentInfo,\n DocumentStatus,\n InkDocument,\n InkStatus,\n OpenOptions,\n} from './model/document'\nexport type { DocumentSource } from './model/source'\nexport type { PageInfo, PageRotation } from './model/pages'\nexport type { TextContent, TextItem } from './model/text'\nexport type { PdfAssets } from './pdfjs/types'\nexport * from './model/annotations/types'\nexport { FringeSchema, type Fringe } from './model/annotations/callout'\nexport * from './model/annotations/pdf-names'\nexport * from './model/annotations/defaults'\nexport * from './model/annotations/store'\nexport * from './model/annotations/history'\nexport { createToolStyle, STYLE_GROUPS } from './model/annotations/tool-style'\nexport type {\n CurrentStyle,\n ScopedToolStyle,\n StyleGroup,\n StyleKey,\n StyleProps,\n ToolStyle,\n ToolStyleDeps,\n} from './model/annotations/tool-style'\nexport {\n fromAnnotation,\n styleGroupOf,\n styleGroupOfType,\n styleGroupsOf,\n supportedProps,\n toFields,\n typesInGroup,\n} from './model/annotations/style-map'\nexport { createSnapshotHistory } from './model/annotations/snapshot-history'\nexport type {\n SnapshotHistory,\n SnapshotHistoryOptions,\n} from './model/annotations/snapshot-history'\nexport {\n isAbandonedNote,\n isReply,\n isThreadRoot,\n repliesTo,\n threadOf,\n threadRoot,\n withoutReplies,\n} from './model/annotations/threads'\nexport type { ThreadRoot } from './model/annotations/threads'\nexport * from './model/annotations/embedded'\nexport { parsePdfDate } from './model/pdf-date'\nexport { exportAnnotations, importAnnotations } from './model/annotations/json'\nexport { recogniseStroke, RECOGNISE_THRESHOLD } from './model/recognise'\nexport type { Recognised } from './model/recognise'\nexport type { ImportOptions, ImportResult } from './model/annotations/json'\nexport {\n createImageTemplate,\n createInkTemplate,\n createLocalSignatureStore,\n createMemorySignatureStore,\n createSignatureLibrary,\n DEFAULT_SIGNATURE_WIDTH,\n normaliseInk,\n placeSignature,\n SIGNATURE_INK_WIDTH,\n} from './model/signatures'\nexport type {\n SignatureLibrary,\n SignatureOptions,\n SignatureStore,\n SignatureTemplate,\n} from './model/signatures'\n"],"mappings":";;AAqDA,SAAgB,sBAAsB,MAA+C;CACnF,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,SAAS,GAAG;CAC3C,MAAM,OAAO,SAAqB,CAAC,CAAC;CACpC,MAAM,SAAS,SAAqB,CAAC,CAAC;CACtC,IAAI,UAA0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AAK,UAAU,KAAK,CAAC;AACzC;;AAGA,SAAS,SAAS,GAA0B,GAAmC;CAC7E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,uBAAuB,GAAG,EAAE,EAAG,CAAC;AACpF;AAEA,SAAS,uBAAuB,GAAe,GAAwB;CACrE,MAAM,EAAE,YAAY,IAAI,GAAG,UAAU;CACrC,MAAM,EAAE,YAAY,IAAI,GAAG,UAAU;CACrC,OAAO,UAAU,OAAO,KAAK;AAC/B;;AAGA,SAAS,UAAU,GAAY,GAAqB;CAClD,IAAI,OAAO,GAAG,GAAG,CAAC,GAAG,OAAO;CAC5B,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MACxE,OAAO;CACT,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,MAAM,KAAK,YAAY,CAAC;CACxB,MAAM,KAAK,YAAY,CAAC;CACxB,IAAI,GAAG,WAAW,GAAG,QAAQ,OAAO;CACpC,OAAO,GAAG,OACP,MACC,GAAG,SAAS,CAAC,KACb,UAAW,EAA8B,IAAK,EAA8B,EAAE,CAClF;AACF;AAEA,SAAS,YAAY,GAAqB;CACxC,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,MAAO,EAA8B,OAAO,KAAA,CAAS;AACrF;;;;AC3MA,MAAa,UAAA"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/model/annotations/snapshot-history.ts","../src/index.ts"],"sourcesContent":["import { isProduction } from '../env'\nimport { derived, writable, type Readable } from '../readable'\n\nimport type { RecordBase, RecordStore } from '../records'\nimport type { PluginHistory } from './history'\nimport type { AnnotationEdit, AnnotationStore } from './store'\nimport type { Annotation } from './types'\n\nexport interface SnapshotHistoryOptions {\n /** Proposes a list to the host. The step counts once the host applies it (seen by `observe`). */\n apply: (list: Annotation[]) => void\n /** Read on every observed change and every undo or redo. */\n enabled: () => boolean\n /** Steps kept. Default 200. */\n limit?: number | undefined\n}\n\n/**\n * Snapshot undo and redo over a host-owned annotation list, for controlled hosts. The\n * framework calls `observe` whenever the host's list changes; every change is a step. Undo and\n * redo propose an earlier list through `apply` and move the stacks only once the host applies\n * it. `canUndo` and `canRedo` report stack sizes; the framework ANDs them with its own flag.\n *\n * Tracked record stores belong to their plugins, not the host, so a step also snapshots each of\n * them. Undo and redo put records back at once (`replaceAll(list, 'history')`) and propose the\n * annotations as above; a step whose annotations did not change moves the stacks at once. A\n * record change outside a batch opens one, so the change and the host's list that follows in\n * the same macrotask are one step. A record store's `reset` takes its records out of every step\n * and drops the steps left with nothing to undo; the others still undo and redo, as in History.\n */\nexport interface SnapshotHistory extends PluginHistory {\n readonly canUndo: Readable<boolean>\n readonly canRedo: Readable<boolean>\n undo(): void\n redo(): void\n clear(): void\n /**\n * The host's current list, or `undefined` when the host does not control it. The first list\n * seeds the history; each later list that differs is a step. An `undefined` neither seeds\n * nor records, and the next list after one starts again without a step.\n */\n observe(list: readonly Annotation[] | undefined): void\n /**\n * Runs `fn` and records the host's changes that follow as one step. A framework may hand the\n * host's list back after `fn` returns, one list per proposal, so the batch stays open until\n * the current macrotask ends (`setTimeout(0)`) and then pushes a single step from the list\n * before `fn` to the latest one. Limit: an unrelated change the host makes in that same window\n * is folded into the step. Nested calls join; a throwing `fn` still closes the batch; when\n * history is disabled `fn` only runs. `fn` must be synchronous; a dev build warns when it\n * returns a promise.\n *\n * A batch opened while an earlier one is still settling closes the earlier one first, so the\n * two are two steps. An undo or redo still in flight (proposed, but not yet applied by the\n * host) when a batch opens is dropped: the host's list that follows counts toward the batch.\n * Undo and redo close a settling batch first. Calling `undo()` or `redo()` inside `fn` is not\n * supported.\n */\n batch(fn: () => void): void\n /**\n * Runs the reactions for each of the store's user edits inside a batch, so what they change\n * joins the edit's step. Undo and redo reach the store as a `replace`, which reacts to nothing.\n * The binding attaches each opened document's store. Returns a function that detaches it.\n */\n attach(store: AnnotationStore): () => void\n}\n\ntype Records = Map<RecordStore<RecordBase>, readonly RecordBase[]>\n/** The host's list and each tracked store's list at one point. */\ninterface Snapshot {\n annotations: readonly Annotation[]\n records: Records\n}\n/** An undo or redo waiting for the host, with the records as they stood before it. */\ntype Pending = { kind: 'undo' | 'redo'; target: Snapshot; records: Records }\n\nconst noop = () => {}\n\nexport function createSnapshotHistory(opts: SnapshotHistoryOptions): SnapshotHistory {\n const limit = Math.max(1, opts.limit ?? 200)\n const past = writable<Snapshot[]>([])\n const future = writable<Snapshot[]>([])\n let pending: Pending | null = null\n /** Copy of the host's list as of its last change; `undefined` before the first list. */\n let current: readonly Annotation[] | undefined\n /** Open `batch` calls, and whether the batch is waiting out the task for late observes. */\n let depth = 0\n let settling: ReturnType<typeof setTimeout> | null = null\n /** The state when the outermost batch opened; `undefined` while no list has been seen. */\n let from: Snapshot | undefined\n /** Each tracked store with its list as of the last change history saw. */\n const tracked = new Map<\n RecordStore<RecordBase>,\n { previous: readonly RecordBase[]; unsubscribe: () => void }\n >()\n const reactions = new Set<(edit: AnnotationEdit) => void>()\n /** Each attached store with its `edit` unsubscribe. */\n const attached = new Map<AnnotationStore, () => void>()\n /** Set while undo or redo puts records back, so those changes are not steps. */\n let replaying = false\n\n function records(): Records {\n return new Map([...tracked].map(([s, t]) => [s, t.previous]))\n }\n\n function state(): Snapshot | undefined {\n return current === undefined\n ? undefined\n : { annotations: current, records: records() }\n }\n\n function push(step: Snapshot): void {\n past.set([...past.get(), step].slice(-limit))\n future.set([])\n }\n\n /** Moves the stacks for an undo or redo that has landed; `prev` is the state it left. */\n function move(kind: Pending['kind'], prev: Snapshot): void {\n if (kind === 'undo') {\n past.set(past.get().slice(0, -1))\n future.set([...future.get(), prev])\n } else {\n future.set(future.get().slice(0, -1))\n past.set([...past.get(), prev])\n }\n }\n\n /**\n * After `store`'s reset: drops the steps that changed nothing but `store`, and gives every\n * remaining snapshot its new `list`, so undo and redo leave its records alone while a step\n * that also changed annotations or another store still undoes those, as in History. `was` is\n * its list just before the reset. Undo targets lose the snapshot before a dropped step, redo\n * targets the one after it.\n */\n function dropSteps(\n store: RecordStore<RecordBase>,\n was: readonly RecordBase[],\n list: readonly RecordBase[]\n ): void {\n // The state now, with the store's list from before the reset.\n const now = current && { annotations: current, records: records().set(store, was) }\n /** Whether the step from `a` to `b` changed only this store, so nothing is left of it. */\n const onlyStore = (a: Snapshot, b: Snapshot | undefined) => {\n if (!b) return false\n const x = a.records.get(store)\n const y = b.records.get(store)\n if (x === undefined || y === undefined || sameRecords(x, y)) return false\n if (!sameList(a.annotations, b.annotations)) return false\n return [...a.records].every(\n ([s, list]) => s === store || sameRecords(list, b.records.get(s) ?? list)\n )\n }\n const renewed = new Map<Snapshot, Snapshot>()\n const renew = (step: Snapshot): Snapshot => {\n const next = step.records.has(store)\n ? { ...step, records: new Map(step.records).set(store, list) }\n : step\n renewed.set(step, next)\n return next\n }\n // Oldest first, then the state now: each undo target is the snapshot before a step.\n const p = past.get()\n past.set(p.filter((step, i) => !onlyStore(step, p[i + 1] ?? now)).map(renew))\n // Next redo last: each redo target is the snapshot after a step.\n const f = future.get()\n future.set(f.filter((step, i) => !onlyStore(step, f[i + 1] ?? now)).map(renew))\n // An undo or redo in flight still lands when its target survived.\n const target = pending && renewed.get(pending.target)\n pending =\n pending && target\n ? { ...pending, target, records: new Map(pending.records).set(store, list) }\n : null\n }\n\n /** Opens the outermost batch from the current state. */\n function open(): void {\n // A batch still settling is closed first, so two batches are two steps.\n if (settling !== null) endBatch()\n // An undo or redo still in flight would be folded into this step; drop it.\n pending = null\n from = state()\n }\n\n function endBatch(): void {\n if (settling !== null) clearTimeout(settling)\n settling = null\n const start = from\n from = undefined\n if (!opts.enabled() || !start || !current) return\n const unchanged =\n sameList(current, start.annotations) &&\n [...start.records].every(([s, list]) =>\n sameRecords(list, tracked.get(s)?.previous ?? list)\n )\n if (!unchanged) push(start)\n }\n\n function batch(fn: () => void): void {\n if (!opts.enabled()) {\n fn()\n return\n }\n if (depth === 0) open()\n depth++\n try {\n const result: unknown = fn()\n if (\n result !== null &&\n typeof result === 'object' &&\n typeof (result as { then?: unknown }).then === 'function' &&\n !isProduction()\n ) {\n console.warn(\n '[inkbar] history.batch(fn): fn returned a promise. Changes after its first await are not part of the batch.'\n )\n }\n } finally {\n depth--\n if (depth === 0) settling = setTimeout(endBatch, 0)\n }\n }\n\n function clear(): void {\n past.set([])\n future.set([])\n pending = null\n from = undefined\n if (settling !== null) clearTimeout(settling)\n settling = null\n }\n\n function observe(next: readonly Annotation[] | undefined): void {\n const prev = current\n current = snapshot(next)\n if (!opts.enabled()) {\n // Steps taken while disabled are unknown to the stacks, which would undo to stale lists.\n if (past.get().length > 0 || future.get().length > 0 || pending) clear()\n return\n }\n // The first list only seeds; there is no step from or to an undefined list.\n if (next === undefined || prev === undefined) return\n // Inside a batch, or while it settles, changes only move `current`; `endBatch` pushes the step.\n if (from !== undefined) return\n // A new array with the same content is not a step, and leaves a pending step alone.\n if (sameList(next, prev)) return\n const step = pending\n pending = null\n if (step && sameList(next, step.target.annotations)) {\n move(step.kind, { annotations: prev, records: step.records })\n return\n }\n push({ annotations: prev, records: records() })\n }\n\n function propose(kind: Pending['kind'], target: Snapshot | undefined): void {\n if (!opts.enabled() || !target) return\n // The same undo or redo again before the host applies: the records were already put back,\n // so the state it leaves is the one the first call saw.\n const before =\n pending && pending.kind === kind && pending.target === target\n ? pending.records\n : records()\n replaying = true\n try {\n // Stores no longer tracked keep their records.\n for (const [s, list] of target.records) {\n const t = tracked.get(s)\n if (t && !sameRecords(t.previous, list)) s.replaceAll([...list], 'history')\n }\n } finally {\n replaying = false\n }\n // Nothing for the host to apply: the step moves now.\n if (current !== undefined && sameList(current, target.annotations)) {\n move(kind, { annotations: current, records: before })\n return\n }\n pending = { kind, target, records: before }\n opts.apply(clone(target.annotations) as Annotation[])\n }\n\n function track(store: RecordStore<RecordBase>): () => void {\n if (tracked.has(store)) return noop\n const unsubscribe = store.on('change', (change) => {\n const t = tracked.get(store)\n if (!t) return\n const list = store.list.get()\n // Our own replays (and any other history replace) never become steps.\n if (replaying || (change.kind === 'replace' && change.reason === 'history')) {\n t.previous = list\n return\n }\n if (!opts.enabled()) {\n t.previous = list\n // As in `observe`: steps taken while disabled would leave the stacks stale.\n if (past.get().length > 0 || future.get().length > 0 || pending) clear()\n return\n }\n if (change.kind === 'replace') {\n // A reset starts the store over, so no older step holding its records can be replayed.\n dropSteps(store, t.previous, list)\n t.previous = list\n from?.records.set(store, list)\n return\n }\n // On its own, a change opens a batch from the state before it, which waits out the task\n // for the host's list.\n if (from === undefined && depth === 0 && current !== undefined) {\n open()\n settling = setTimeout(endBatch, 0)\n }\n t.previous = list\n })\n tracked.set(store, { previous: store.list.get(), unsubscribe })\n // Tracked inside an open batch: the batch covers it from here.\n from?.records.set(store, store.list.get())\n return () => {\n if (tracked.get(store)?.unsubscribe !== unsubscribe) return\n unsubscribe()\n tracked.delete(store)\n from?.records.delete(store)\n }\n }\n\n return {\n canUndo: derived(past, (p) => p.length > 0),\n canRedo: derived(future, (f) => f.length > 0),\n undo: () => {\n if (from !== undefined && depth === 0) endBatch()\n propose('undo', past.get().at(-1))\n },\n redo: () => {\n if (from !== undefined && depth === 0) endBatch()\n propose('redo', future.get().at(-1))\n },\n clear,\n observe,\n batch,\n track,\n react(fn) {\n // Wrapped, so the same function added twice runs twice and each handle removes its own.\n const run = (edit: AnnotationEdit) => fn(edit)\n reactions.add(run)\n return () => {\n reactions.delete(run)\n }\n },\n attach(store) {\n if (attached.has(store)) return noop\n const off = store.on('edit', (edit) => {\n if (reactions.size === 0) return\n batch(() => {\n for (const fn of [...reactions]) fn(edit)\n })\n })\n attached.set(store, off)\n // An old handle never detaches a later attachment of the same store.\n return () => {\n if (attached.get(store) !== off) return\n attached.delete(store)\n off()\n }\n },\n }\n}\n\n/** The same records in the same order; records are frozen, so identity is enough. */\nfunction sameRecords(a: readonly RecordBase[], b: readonly RecordBase[]): boolean {\n return a === b || (a.length === b.length && a.every((x, i) => x === b[i]))\n}\n\nfunction snapshot(\n list: readonly Annotation[] | undefined\n): readonly Annotation[] | undefined {\n return list === undefined ? undefined : clone(list)\n}\n\n/** Annotations are JSON values; this also strips framework proxies and `undefined` members. */\nfunction clone<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T\n}\n\n/** Same annotations in the same order, compared by payload; `modifiedAt` may be re-stamped. */\nfunction sameList(a: readonly Annotation[], b: readonly Annotation[]): boolean {\n return a.length === b.length && a.every((x, i) => sameIgnoringModifiedAt(x, b[i]!))\n}\n\nfunction sameIgnoringModifiedAt(a: Annotation, b: Annotation): boolean {\n const { modifiedAt: _a, ...restA } = a\n const { modifiedAt: _b, ...restB } = b\n return deepEqual(restA, restB)\n}\n\n/** Structural equality over JSON values; keys whose value is `undefined` count as absent. */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)\n return false\n if (Array.isArray(a) !== Array.isArray(b)) return false\n const ka = presentKeys(a)\n const kb = presentKeys(b)\n if (ka.length !== kb.length) return false\n return ka.every(\n (k) =>\n kb.includes(k) &&\n deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k])\n )\n}\n\nfunction presentKeys(o: object): string[] {\n return Object.keys(o).filter((k) => (o as Record<string, unknown>)[k] !== undefined)\n}\n","/** Replaced at build time (tsdown) and in tests (vitest) with package.json's version. */\ndeclare const __INKBAR_VERSION__: string\n\n/** The @inkbar/core version, from its package.json. */\nexport const version: string = __INKBAR_VERSION__\n\nexport * from './model/errors'\nexport * from './model/events'\nexport * from './model/geometry'\nexport * from './model/readable'\nexport * from './model/records'\nexport { mergeLineRects } from './model/selection'\n\nexport { openDocument } from './model/document'\nexport type {\n DocumentInfo,\n DocumentStatus,\n InkDocument,\n InkStatus,\n OpenOptions,\n} from './model/document'\nexport type { DocumentSource } from './model/source'\nexport type { PageInfo, PageRotation } from './model/pages'\nexport type { TextContent, TextItem } from './model/text'\nexport type { PdfAssets } from './pdfjs/types'\nexport * from './model/annotations/types'\nexport { FringeSchema, type Fringe } from './model/annotations/callout'\nexport * from './model/annotations/pdf-names'\nexport * from './model/annotations/defaults'\nexport * from './model/annotations/store'\nexport * from './model/annotations/history'\nexport { createToolStyle, STYLE_GROUPS } from './model/annotations/tool-style'\nexport type {\n CurrentStyle,\n ScopedToolStyle,\n StyleGroup,\n StyleKey,\n StyleProps,\n ToolStyle,\n ToolStyleDeps,\n} from './model/annotations/tool-style'\nexport {\n fromAnnotation,\n styleGroupOf,\n styleGroupOfType,\n styleGroupsOf,\n supportedProps,\n toFields,\n typesInGroup,\n} from './model/annotations/style-map'\nexport { createSnapshotHistory } from './model/annotations/snapshot-history'\nexport type {\n SnapshotHistory,\n SnapshotHistoryOptions,\n} from './model/annotations/snapshot-history'\nexport {\n isAbandonedNote,\n isReply,\n isThreadRoot,\n repliesTo,\n threadOf,\n threadRoot,\n withoutReplies,\n} from './model/annotations/threads'\nexport type { ThreadRoot } from './model/annotations/threads'\nexport * from './model/annotations/embedded'\nexport { parsePdfDate } from './model/pdf-date'\nexport { exportAnnotations, importAnnotations } from './model/annotations/json'\nexport { recogniseStroke, RECOGNISE_THRESHOLD } from './model/recognise'\nexport type { Recognised } from './model/recognise'\nexport type { ImportOptions, ImportResult } from './model/annotations/json'\nexport {\n createImageTemplate,\n createInkTemplate,\n createLocalSignatureStore,\n createMemorySignatureStore,\n createSignatureLibrary,\n DEFAULT_SIGNATURE_WIDTH,\n normaliseInk,\n placeSignature,\n SIGNATURE_INK_WIDTH,\n} from './model/signatures'\nexport type {\n SignatureLibrary,\n SignatureOptions,\n SignatureStore,\n SignatureTemplate,\n} from './model/signatures'\n"],"mappings":";;AA2EA,MAAM,aAAa,CAAC;AAEpB,SAAgB,sBAAsB,MAA+C;CACnF,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,SAAS,GAAG;CAC3C,MAAM,OAAO,SAAqB,CAAC,CAAC;CACpC,MAAM,SAAS,SAAqB,CAA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,6 +30,10 @@ declare function approxEqual(a: number, b: number, eps?: number): boolean;
30
30
  declare function rectFromPoints(a: Point$1, b: Point$1): Rect$1;
31
31
  declare function rectFromQuad(q: Quad): Rect$1;
32
32
  declare function quadFromRect(r: Rect$1): Quad;
33
+ /** One quad covering `r`, in the corner order of `quadFromRect`. */
34
+ declare function quadsFromRect(r: Rect$1): Quad[];
35
+ /** The bounding box of every corner of `quads`. */
36
+ declare function rectFromQuads(quads: readonly Quad[]): Rect$1;
33
37
  declare function unionRects(rects: readonly Rect$1[]): Rect$1;
34
38
  declare function rectsIntersect(a: Rect$1, b: Rect$1): boolean;
35
39
  declare function rectContainsPoint(r: Rect$1, p: Point$1): boolean;
@@ -1824,6 +1828,56 @@ declare function importEmbeddedPage(page: number, raw: PdfjsAnnotationData[], im
1824
1828
  };
1825
1829
  declare function summarise(perPage: Record<string, number>[]): EmbeddedSummary[];
1826
1830
  //#endregion
1831
+ //#region src/model/records.d.ts
1832
+ interface RecordBase {
1833
+ readonly id: string;
1834
+ }
1835
+ type RecordChange<T> = {
1836
+ kind: 'add';
1837
+ record: T;
1838
+ } | {
1839
+ kind: 'update';
1840
+ id: string;
1841
+ before: T;
1842
+ after: T;
1843
+ } | {
1844
+ kind: 'remove';
1845
+ record: T;
1846
+ } | {
1847
+ kind: 'replace';
1848
+ reason: 'history' | 'reset';
1849
+ /** Ids of the records the replace added, changed and dropped, in list order. */
1850
+ added: string[];
1851
+ updated: string[];
1852
+ removed: string[];
1853
+ };
1854
+ interface RecordStore<T extends RecordBase> {
1855
+ /** The slot name the store is registered under. */
1856
+ readonly key: string;
1857
+ readonly list: Readable<readonly T[]>;
1858
+ get(id: string): T | undefined;
1859
+ /** Returns the stored (frozen) record. Throws `InkError('DuplicateId')` when the id is taken. */
1860
+ add(record: T): T;
1861
+ /** `id` cannot be patched. Returns `undefined`, emitting nothing, for an unknown id. */
1862
+ update(id: string, patch: Partial<Omit<T, 'id'>>): T | undefined;
1863
+ /** Returns the removed record, or `undefined`, emitting nothing, for an unknown id. */
1864
+ remove(id: string): T | undefined;
1865
+ replaceAll(list: readonly T[], reason: 'history' | 'reset'): void;
1866
+ on(event: 'change', fn: (change: RecordChange<T>) => void): () => void;
1867
+ /** Drops the listeners. Writes after it change nothing and emit nothing. */
1868
+ destroy(): void;
1869
+ }
1870
+ interface RecordStoreOptions<T extends RecordBase> {
1871
+ initial?: readonly T[];
1872
+ /** Called after every change, `replace` included, with the list as it now stands. */
1873
+ onChange?: (list: readonly T[], change: RecordChange<T>) => void;
1874
+ }
1875
+ /**
1876
+ * A keyed list of plain records. Records are stored as frozen copies, so a change's `before` and `after` can be
1877
+ * kept as history entries without copying.
1878
+ */
1879
+ declare function createRecordStore<T extends RecordBase>(key: string, opts?: RecordStoreOptions<T>): RecordStore<T>;
1880
+ //#endregion
1827
1881
  //#region src/model/annotations/store.d.ts
1828
1882
  type AnnotationChange = {
1829
1883
  kind: 'add';
@@ -1849,6 +1903,10 @@ type AnnotationChange = {
1849
1903
  /** What was merged into each annotation, by id. */
1850
1904
  fields: ReadonlyMap<string, EmbeddedFieldPatch>;
1851
1905
  };
1906
+ /** The changes `edit` reports: one per `add`, `update` or `remove` call that changed something. */
1907
+ type AnnotationEdit = Extract<AnnotationChange, {
1908
+ kind: 'add' | 'update' | 'remove';
1909
+ }>;
1852
1910
  type StoreMode = {
1853
1911
  mode: 'uncontrolled';
1854
1912
  initial?: Annotation$1[];
@@ -1910,6 +1968,12 @@ interface AnnotationStore {
1910
1968
  _getProposed(id: string): Annotation$1 | undefined;
1911
1969
  completeInput(input: AnnotationInput): Annotation$1;
1912
1970
  on(event: 'change', fn: (change: AnnotationChange) => void): () => void;
1971
+ /**
1972
+ * Fires synchronously for every `add`, `update` and `remove` that changes something, in both
1973
+ * modes, before the list is set (uncontrolled) or `onChange` is called (controlled). Never
1974
+ * for `replace`.
1975
+ */
1976
+ on(event: 'edit', fn: (change: AnnotationEdit) => void): () => void;
1913
1977
  destroy(): void;
1914
1978
  }
1915
1979
  interface StoreOptions {
@@ -1922,7 +1986,23 @@ declare function deriveRect(input: AnnotationInput): Rect$1;
1922
1986
  declare function createAnnotationStore(opts: StoreOptions): AnnotationStore;
1923
1987
  //#endregion
1924
1988
  //#region src/model/annotations/history.d.ts
1925
- interface History {
1989
+ /** The part of a history plugins use: one undo step across annotations and record stores. */
1990
+ interface PluginHistory {
1991
+ batch(fn: () => void): void;
1992
+ /**
1993
+ * Makes the store's changes undo steps: on their own, or joining the open batch or edit. The
1994
+ * returned function stops tracking; existing entries keep their snapshot of the store but undo
1995
+ * and redo no longer replay it.
1996
+ */
1997
+ track(store: RecordStore<RecordBase>): () => void;
1998
+ /**
1999
+ * Runs `fn` synchronously for every user `add`, `update` and `remove` of an annotation, inside
2000
+ * that edit's undo entry, so whatever `fn` changes undoes with the edit. Never runs for
2001
+ * `replace`, so never for undo and redo. Returns a function that removes `fn`.
2002
+ */
2003
+ react(fn: (edit: AnnotationEdit) => void): () => void;
2004
+ }
2005
+ interface History extends PluginHistory {
1926
2006
  readonly canUndo: Readable<boolean>;
1927
2007
  readonly canRedo: Readable<boolean>;
1928
2008
  undo(): void;
@@ -1993,7 +2073,7 @@ declare function exportAnnotations(store: AnnotationStore, preserved?: readonly
1993
2073
  declare function importAnnotations(store: AnnotationStore, data: AnnotationDocument | string, opts: ImportOptions): ImportResult;
1994
2074
  //#endregion
1995
2075
  //#region src/model/errors.d.ts
1996
- type InkErrorCode = 'PasswordRequired' | 'InvalidPdf' | 'SourceFetchFailed' | 'AssetConfigMissing' | 'AssetLoadFailed' | 'EngineUnavailable' | 'ControlledMutationIgnored' | 'DocumentDestroyed' | 'PageOutOfRange';
2076
+ type InkErrorCode = 'PasswordRequired' | 'InvalidPdf' | 'SourceFetchFailed' | 'AssetConfigMissing' | 'AssetLoadFailed' | 'EngineUnavailable' | 'ControlledMutationIgnored' | 'DocumentDestroyed' | 'PageOutOfRange' | 'DuplicateId' | 'DuplicatePlugin' | 'InvalidPluginId' | 'InvalidCommandLabel' | 'UnknownCommand';
1997
2077
  declare class InkError extends Error {
1998
2078
  readonly name = "InkError";
1999
2079
  readonly code: InkErrorCode;
@@ -2077,6 +2157,8 @@ interface InkDocument {
2077
2157
  readonly pages: readonly PageInfo[];
2078
2158
  readonly info: DocumentInfo;
2079
2159
  text(page: number): Promise<TextContent>;
2160
+ /** The page's text items joined with a single space. */
2161
+ pageText(page: number): Promise<string>;
2080
2162
  /**
2081
2163
  * Annotations embedded in the file arrive here as `source: 'pdf'`, `locked: true` before
2082
2164
  * `ready` resolves. They stay in `list` in both modes and cannot be removed; in controlled
@@ -2280,5 +2362,5 @@ interface SignatureLibrary {
2280
2362
  }
2281
2363
  declare function createSignatureLibrary(store: SignatureStore): SignatureLibrary;
2282
2364
  //#endregion
2283
- export { pdfColorToHex as $, StampAnnotation as $t, TextItem as A, LineAnnotation as At, createHistory as B, NoteSchema as Bt, DocumentInfo as C, rectFromPoints as Cn, GLOSS_FORMAT$1 as Ct, OpenOptions as D, translateRect as Dn, IMAGE_DATA_URL as Dt, InkStatus as E, translateQuad as En, GLOSS_VERSION$1 as Et, ImportOptions as F, LoupeSchema as Ft, createAnnotationStore as G, PolylineSchema as Gt, AnnotationStore as H, PolyAnnotation as Ht, ImportResult as I, MaskAnnotation as It, EmbeddedSummary as J, RedactAnnotation as Jt, deriveRect as K, QuadSchema as Kt, exportAnnotations as L, MaskSchema as Lt, InkError as M, LineEndingSchema as Mt, InkErrorCode as N, LineSchema as Nt, openDocument as O, unionRects as On, InkAnnotation as Ot, isInkError as P, LoupeAnnotation as Pt, importedId as Q, SquareSchema as Qt, importAnnotations as R, NoteAnnotation as Rt, createToolStyle as S, rectContainsPoint as Sn, FreeTextStyleSchema as St, InkDocument as T, rectsIntersect as Tn, GLOSS_SCHEMA_ID as Tt, StoreMode as U, PolySchema as Ut, AnnotationChange as V, PointSchema as Vt, StoreOptions as W, PolygonSchema as Wt, SUPPORTED_SUBTYPES as X, ShapeAnnotation as Xt, EmbeddedTarget as Y, RedactSchema as Yt, importEmbeddedPage as Z, ShapeSchema as Zt, StyleGroup as _, invertMatrix as _n, ExportedAnnotationSchema as _t, SignatureStore as a, derived as an, normalizeColor as at, ToolStyle as b, quadFromRect as bn, FreeTextSchema as bt, createInkTemplate as c, PageInfo as cn, AnnotationDocument as ct, createSignatureLibrary as d, Matrix as dn, AnnotationOfType as dt, StampSchema as en, summarise as et, normaliseInk as f, Point$1 as fn, AnnotationPatch as ft, ScopedToolStyle as g, approxEqual as gn, ExportedAnnotation as gt, STYLE_GROUPS as h, applyMatrix as hn, CircleSchema as ht, SignatureOptions as i, Writable as in, cssVariableDefaults as it, DocumentSource as j, LineEnding$1 as jt, TextContent as k, InkSchema as kt, createLocalSignatureStore as l, PageRotation as ln, AnnotationDocumentSchema as lt, CurrentStyle as m, Rect$1 as mn, AnnotationType as mt, SIGNATURE_INK_WIDTH as n, TextMarkupSchema as nn, FringeSchema as nt, SignatureTemplate as o, readonly as on, staticDefaults as ot, placeSignature as p, Quad as pn, AnnotationSchema as pt, EmbeddedFieldPatch as q, RectSchema as qt, SignatureLibrary as r, Readable as rn, AnnotationDefaults as rt, createImageTemplate as s, writable as sn, Annotation$1 as st, DEFAULT_SIGNATURE_WIDTH as t, TextMarkupAnnotation as tn, Fringe$1 as tt, createMemorySignatureStore as u, PdfAssets as un, AnnotationInput as ut, StyleKey as v, multiplyMatrix as vn, ForeignAnnotation as vt, DocumentStatus as w, rectFromQuad as wn, GLOSS_MEDIA_TYPE as wt, ToolStyleDeps as x, quadsFromFlat as xn, FreeTextStyle$1 as xt, StyleProps as y, pointsFromFlat as yn, FreeTextAnnotation as yt, History as z, NoteIconSchema as zt };
2284
- //# sourceMappingURL=signatures-BwaXi7C8.d.mts.map
2365
+ export { createRecordStore as $, QuadSchema as $t, TextItem as A, rectContainsPoint as An, GLOSS_FORMAT$1 as At, PluginHistory as B, LineSchema as Bt, DocumentInfo as C, approxEqual as Cn, ExportedAnnotation as Ct, OpenOptions as D, quadFromRect as Dn, FreeTextSchema as Dt, InkStatus as E, pointsFromFlat as En, FreeTextAnnotation as Et, ImportOptions as F, translateQuad as Fn, InkAnnotation as Ft, StoreMode as G, NoteAnnotation as Gt, AnnotationChange as H, LoupeSchema as Ht, ImportResult as I, translateRect as In, InkSchema as It, deriveRect as J, PointSchema as Jt, StoreOptions as K, NoteIconSchema as Kt, exportAnnotations as L, unionRects as Ln, LineAnnotation as Lt, InkError as M, rectFromQuad as Mn, GLOSS_SCHEMA_ID as Mt, InkErrorCode as N, rectFromQuads as Nn, GLOSS_VERSION$1 as Nt, openDocument as O, quadsFromFlat as On, FreeTextStyle$1 as Ot, isInkError as P, rectsIntersect as Pn, IMAGE_DATA_URL as Pt, RecordStoreOptions as Q, PolylineSchema as Qt, importAnnotations as R, LineEnding$1 as Rt, createToolStyle as S, applyMatrix as Sn, CircleSchema as St, InkDocument as T, multiplyMatrix as Tn, ForeignAnnotation as Tt, AnnotationEdit as U, MaskAnnotation as Ut, createHistory as V, LoupeAnnotation as Vt, AnnotationStore as W, MaskSchema as Wt, RecordChange as X, PolySchema as Xt, RecordBase as Y, PolyAnnotation as Yt, RecordStore as Z, PolygonSchema as Zt, StyleGroup as _, PdfAssets as _n, AnnotationInput as _t, SignatureStore as a, SquareSchema as an, importedId as at, ToolStyle as b, Quad as bn, AnnotationSchema as bt, createInkTemplate as c, TextMarkupAnnotation as cn, Fringe$1 as ct, createSignatureLibrary as d, Writable as dn, cssVariableDefaults as dt, RectSchema as en, EmbeddedFieldPatch as et, normaliseInk as f, derived as fn, normalizeColor as ft, ScopedToolStyle as g, PageRotation as gn, AnnotationDocumentSchema as gt, STYLE_GROUPS as h, PageInfo as hn, AnnotationDocument as ht, SignatureOptions as i, ShapeSchema as in, importEmbeddedPage as it, DocumentSource as j, rectFromPoints as jn, GLOSS_MEDIA_TYPE as jt, TextContent as k, quadsFromRect as kn, FreeTextStyleSchema as kt, createLocalSignatureStore as l, TextMarkupSchema as ln, FringeSchema as lt, CurrentStyle as m, writable as mn, Annotation$1 as mt, SIGNATURE_INK_WIDTH as n, RedactSchema as nn, EmbeddedTarget as nt, SignatureTemplate as o, StampAnnotation as on, pdfColorToHex as ot, placeSignature as p, readonly as pn, staticDefaults as pt, createAnnotationStore as q, NoteSchema as qt, SignatureLibrary as r, ShapeAnnotation as rn, SUPPORTED_SUBTYPES as rt, createImageTemplate as s, StampSchema as sn, summarise as st, DEFAULT_SIGNATURE_WIDTH as t, RedactAnnotation as tn, EmbeddedSummary as tt, createMemorySignatureStore as u, Readable as un, AnnotationDefaults as ut, StyleKey as v, Matrix as vn, AnnotationOfType as vt, DocumentStatus as w, invertMatrix as wn, ExportedAnnotationSchema as wt, ToolStyleDeps as x, Rect$1 as xn, AnnotationType as xt, StyleProps as y, Point$1 as yn, AnnotationPatch as yt, History as z, LineEndingSchema as zt };
2366
+ //# sourceMappingURL=signatures-By4B40DP.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures-By4B40DP.d.mts","names":["Point","Rect","Rect","Annotation","FreeTextStyle","LineEnding","GlossAnnotation","Fringe","Point","Fringe","Annotation","Annotation","Rect","Rect","LineEnding","Point"],"sources":["../src/model/geometry.ts","../src/pdfjs/types.ts","../src/model/pages.ts","../src/model/readable.ts","../src/model/annotations/types.ts","../src/model/annotations/defaults.ts","../src/model/annotations/callout.ts","../src/model/annotations/embedded.ts","../src/model/records.ts","../src/model/annotations/store.ts","../src/model/annotations/history.ts","../src/model/annotations/json.ts","../src/model/errors.ts","../src/model/source.ts","../src/model/text.ts","../src/model/document.ts","../src/model/annotations/tool-style.ts","../src/model/signatures.ts"],"mappings":";;;;;;;;UAIiBA;EACf;EACA;;;UAIeC;EACf;EACA;EACA;EACA;;;UAIe;EACf,IAAID;EACJ,IAAIA;EACJ,IAAIA;EACJ,IAAIA;;;KAIM;iBAEI,YAAY,WAAW,WAAW;iBAIlC,eAAe,GAAGA,SAAO,GAAGA,UAAQC;iBAMpC,aAAa,GAAG,OAAOA;iBAQvB,aAAa,GAAGA,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