@inkbar/core 0.1.1 → 0.3.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 NoteAnnotation, A as summarise, At as multiplyMatrix, B as AnnotationInput, Bt as unionRects, C as createAnnotationStore, Ct as Matrix, D as importEmbeddedPage, Dt as applyMatrix, E as SUPPORTED_SUBTYPES, Et as Rect, F as ANNOTATION_FORMAT, Ft as rectFromPoints, G as ForeignAnnotation, H as AnnotationSchema, I as ANNOTATION_VERSION, It as rectFromQuad, J as InkAnnotation, K as FreeTextAnnotation, L as Annotation, Lt as rectsIntersect, M as cssVariableDefaults, Mt as quadFromRect, N as normalizeColor, Nt as quadsFromFlat, O as importedId, Ot as approxEqual, P as staticDefaults, Pt as rectContainsPoint, Q as LineSchema, R as AnnotationDocument, Rt as translateQuad, S as StoreOptions, St as PdfAssets, T as EmbeddedSummary, Tt as Quad, U as AnnotationType, V as AnnotationOfType, W as ConfidenceBucket, X as LineAnnotation, Y as InkSchema, Z as LineEndingSchema, _ as History, _t as derived, a as OpenOptions, at as RectSchema, b as AnnotationStore, bt as PageInfo, c as TextItem, ct as ShapeAnnotation, d as InkErrorCode, dt as SuggestionSchema, et as NoteSchema, f as isInkError, ft as TextMarkupAnnotation, g as importAnnotations, gt as Writable, h as exportAnnotations, ht as Readable, i as InkStatus, it as QuadSchema, j as AnnotationDefaults, jt as pointsFromFlat, k as pdfColorToHex, kt as invertMatrix, l as DocumentSource, lt as ShapeSchema, m as ImportResult, mt as confidenceBucket, n as DocumentStatus, nt as PolyAnnotation, o as openDocument, ot as RedactAnnotation, p as ImportOptions, pt as TextMarkupSchema, q as FreeTextSchema, r as InkDocument, rt as PolySchema, s as TextContent, st as RedactSchema, t as DocumentInfo, tt as PointSchema, u as InkError, ut as Suggestion, v as createHistory, vt as readonly, w as deriveRect, wt as Point, x as StoreMode, xt as PageRotation, y as AnnotationChange, yt as writable, z as AnnotationDocumentSchema, zt as translateRect } from "./document-Cywnv8Sz.mjs";
1
+ import { $ as LineEndingSchema, A as summarise, At as approxEqual, B as AnnotationInput, Bt as translateQuad, C as createAnnotationStore, Ct as PageRotation, D as importEmbeddedPage, Dt as Quad, E as SUPPORTED_SUBTYPES, Et as Point, F as ANNOTATION_FORMAT, Ft as quadsFromFlat, G as ExportedAnnotation, H as AnnotationSchema, Ht as unionRects, I as ANNOTATION_VERSION, It as rectContainsPoint, J as FreeTextAnnotation, K as ExportedAnnotationSchema, L as Annotation, Lt as rectFromPoints, M as cssVariableDefaults, Mt as multiplyMatrix, N as normalizeColor, Nt as pointsFromFlat, O as importedId, Ot as Rect, P as staticDefaults, Pt as quadFromRect, Q as LineAnnotation, R as AnnotationDocument, Rt as rectFromQuad, S as StoreOptions, St as PageInfo, T as EmbeddedSummary, Tt as Matrix, U as AnnotationType, V as AnnotationOfType, Vt as translateRect, W as ConfidenceBucket, X as InkAnnotation, Y as FreeTextSchema, Z as InkSchema, _ as History, _t as Readable, a as OpenOptions, at as PolySchema, b as AnnotationStore, bt as readonly, c as TextItem, ct as RedactAnnotation, d as InkErrorCode, dt as ShapeSchema, et as LineSchema, f as isInkError, ft as Suggestion, g as importAnnotations, gt as confidenceBucket, h as exportAnnotations, ht as TextMarkupSchema, i as InkStatus, it as PolyAnnotation, j as AnnotationDefaults, jt as invertMatrix, k as pdfColorToHex, kt as applyMatrix, l as DocumentSource, lt as RedactSchema, m as ImportResult, mt as TextMarkupAnnotation, n as DocumentStatus, nt as NoteSchema, o as openDocument, ot as QuadSchema, p as ImportOptions, pt as SuggestionSchema, q as ForeignAnnotation, r as InkDocument, rt as PointSchema, s as TextContent, st as RectSchema, t as DocumentInfo, tt as NoteAnnotation, u as InkError, ut as ShapeAnnotation, v as createHistory, vt as Writable, w as deriveRect, wt as PdfAssets, x as StoreMode, xt as writable, y as AnnotationChange, yt as derived, z as AnnotationDocumentSchema, zt as rectsIntersect } from "./document-BftlPZKU.mjs";
2
2
  //#region src/model/events.d.ts
3
3
  export type Listener<T> = (payload: T) => void;
4
4
  export declare class Emitter<Events extends Record<string, unknown>> {
@@ -95,5 +95,5 @@ export declare function parsePdfDate(value: string | null | undefined, fallback:
95
95
  /** The @inkbar/core version, from its package.json. */
96
96
  export declare const version: string;
97
97
  //#endregion
98
- export { ANNOTATION_FORMAT, ANNOTATION_VERSION, Annotation, AnnotationChange, AnnotationDefaults, AnnotationDocument, AnnotationDocumentSchema, AnnotationInput, AnnotationOfType, AnnotationSchema, AnnotationStore, AnnotationType, ConfidenceBucket, type DocumentInfo, type DocumentSource, type DocumentStatus, EmbeddedSummary, ForeignAnnotation, FreeTextAnnotation, FreeTextSchema, History, type ImportOptions, type ImportResult, InkAnnotation, type InkDocument, InkError, InkErrorCode, InkSchema, type InkStatus, LineAnnotation, LineEndingSchema, LineSchema, Matrix, NoteAnnotation, NoteSchema, type OpenOptions, type PageInfo, type PageRotation, type PdfAssets, Point, PointSchema, PolyAnnotation, PolySchema, Quad, QuadSchema, Readable, Rect, RectSchema, RedactAnnotation, RedactSchema, SUPPORTED_SUBTYPES, ShapeAnnotation, ShapeSchema, type SnapshotHistory, type SnapshotHistoryOptions, StoreMode, StoreOptions, Suggestion, SuggestionSchema, type TextContent, type TextItem, TextMarkupAnnotation, TextMarkupSchema, Writable, applyMatrix, approxEqual, confidenceBucket, createAnnotationStore, createHistory, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isInkError, multiplyMatrix, normalizeColor, openDocument, pdfColorToHex, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, staticDefaults, summarise, translateQuad, translateRect, unionRects, writable };
98
+ export { ANNOTATION_FORMAT, ANNOTATION_VERSION, Annotation, AnnotationChange, AnnotationDefaults, AnnotationDocument, AnnotationDocumentSchema, AnnotationInput, AnnotationOfType, AnnotationSchema, AnnotationStore, AnnotationType, ConfidenceBucket, type DocumentInfo, type DocumentSource, type DocumentStatus, EmbeddedSummary, ExportedAnnotation, ExportedAnnotationSchema, ForeignAnnotation, FreeTextAnnotation, FreeTextSchema, History, type ImportOptions, type ImportResult, InkAnnotation, type InkDocument, InkError, InkErrorCode, InkSchema, type InkStatus, LineAnnotation, LineEndingSchema, LineSchema, Matrix, NoteAnnotation, NoteSchema, type OpenOptions, type PageInfo, type PageRotation, type PdfAssets, Point, PointSchema, PolyAnnotation, PolySchema, Quad, QuadSchema, Readable, Rect, RectSchema, RedactAnnotation, RedactSchema, SUPPORTED_SUBTYPES, ShapeAnnotation, ShapeSchema, type SnapshotHistory, type SnapshotHistoryOptions, StoreMode, StoreOptions, Suggestion, SuggestionSchema, type TextContent, type TextItem, TextMarkupAnnotation, TextMarkupSchema, Writable, applyMatrix, approxEqual, confidenceBucket, createAnnotationStore, createHistory, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isInkError, multiplyMatrix, normalizeColor, openDocument, pdfColorToHex, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, staticDefaults, summarise, translateQuad, translateRect, unionRects, writable };
99
99
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as rectFromQuad, A as RectSchema, B as mergeLineRects, C as InkSchema, D as PointSchema, E as NoteSchema, F as confidenceBucket, G as approxEqual, H as readonly, I as parsePdfDate, J as pointsFromFlat, K as invertMatrix, L as cssVariableDefaults, M as ShapeSchema, N as SuggestionSchema, O as PolySchema, P as TextMarkupSchema, Q as rectFromPoints, R as normalizeColor, S as FreeTextSchema, T as LineSchema, U as writable, V as derived, W as applyMatrix, X as quadsFromFlat, Y as quadFromRect, Z as rectContainsPoint, _ as summarise, a as acceptSuggestion, at as InkError, b as AnnotationDocumentSchema, c as deriveRect, d as createHistory, et as rectsIntersect, f as isProduction, g as pdfColorToHex, h as importedId, i as threadRoot, it as Emitter, j as RedactSchema, k as QuadSchema, l as exportAnnotations, m as importEmbeddedPage, n as repliesTo, nt as translateRect, o as openDocument, ot as isInkError, p as SUPPORTED_SUBTYPES, q as multiplyMatrix, r as threadOf, rt as unionRects, s as createAnnotationStore, t as isAbandonedNote, tt as translateQuad, u as importAnnotations, v as ANNOTATION_FORMAT, w as LineEndingSchema, x as AnnotationSchema, y as ANNOTATION_VERSION, z as staticDefaults } from "./threads-BtvtrAhL.mjs";
1
+ import { $ as rectFromPoints, A as QuadSchema, B as staticDefaults, C as FreeTextSchema, D as NoteSchema, E as LineSchema, F as TextMarkupSchema, G as applyMatrix, H as derived, I as confidenceBucket, J as multiplyMatrix, K as approxEqual, L as parsePdfDate, M as RedactSchema, N as ShapeSchema, O as PointSchema, P as SuggestionSchema, Q as rectContainsPoint, R as cssVariableDefaults, S as ExportedAnnotationSchema, T as LineEndingSchema, U as readonly, V as mergeLineRects, W as writable, X as quadFromRect, Y as pointsFromFlat, Z as quadsFromFlat, _ as summarise, a as acceptSuggestion, at as Emitter, b as AnnotationDocumentSchema, c as deriveRect, d as createHistory, et as rectFromQuad, f as isProduction, g as pdfColorToHex, h as importedId, i as threadRoot, it as unionRects, j as RectSchema, k as PolySchema, l as exportAnnotations, m as importEmbeddedPage, n as repliesTo, nt as translateQuad, o as openDocument, ot as InkError, p as SUPPORTED_SUBTYPES, q as invertMatrix, r as threadOf, rt as translateRect, s as createAnnotationStore, st as isInkError, t as isAbandonedNote, tt as rectsIntersect, u as importAnnotations, v as ANNOTATION_FORMAT, w as InkSchema, x as AnnotationSchema, y as ANNOTATION_VERSION, z as normalizeColor } from "./threads-2USvyGpX.mjs";
2
2
  //#region src/model/annotations/snapshot-history.ts
3
3
  function createSnapshotHistory(opts) {
4
4
  const limit = Math.max(1, opts.limit ?? 200);
@@ -129,8 +129,8 @@ function presentKeys(o) {
129
129
  //#endregion
130
130
  //#region src/index.ts
131
131
  /** The @inkbar/core version, from its package.json. */
132
- const version = "0.1.1";
132
+ const version = "0.3.0";
133
133
  //#endregion
134
- export { ANNOTATION_FORMAT, ANNOTATION_VERSION, AnnotationDocumentSchema, AnnotationSchema, Emitter, FreeTextSchema, InkError, InkSchema, LineEndingSchema, LineSchema, NoteSchema, PointSchema, PolySchema, QuadSchema, RectSchema, RedactSchema, SUPPORTED_SUBTYPES, ShapeSchema, SuggestionSchema, TextMarkupSchema, acceptSuggestion, applyMatrix, approxEqual, confidenceBucket, createAnnotationStore, createHistory, createSnapshotHistory, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isAbandonedNote, isInkError, mergeLineRects, multiplyMatrix, normalizeColor, openDocument, parsePdfDate, pdfColorToHex, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, repliesTo, staticDefaults, summarise, threadOf, threadRoot, translateQuad, translateRect, unionRects, version, writable };
134
+ export { ANNOTATION_FORMAT, ANNOTATION_VERSION, AnnotationDocumentSchema, AnnotationSchema, Emitter, ExportedAnnotationSchema, FreeTextSchema, InkError, InkSchema, LineEndingSchema, LineSchema, NoteSchema, PointSchema, PolySchema, QuadSchema, RectSchema, RedactSchema, SUPPORTED_SUBTYPES, ShapeSchema, SuggestionSchema, TextMarkupSchema, acceptSuggestion, applyMatrix, approxEqual, confidenceBucket, createAnnotationStore, createHistory, createSnapshotHistory, cssVariableDefaults, deriveRect, derived, exportAnnotations, importAnnotations, importEmbeddedPage, importedId, invertMatrix, isAbandonedNote, isInkError, mergeLineRects, multiplyMatrix, normalizeColor, openDocument, parsePdfDate, pdfColorToHex, pointsFromFlat, quadFromRect, quadsFromFlat, readonly, rectContainsPoint, rectFromPoints, rectFromQuad, rectsIntersect, repliesTo, staticDefaults, summarise, threadOf, threadRoot, translateQuad, translateRect, unionRects, version, writable };
135
135
 
136
136
  //# sourceMappingURL=index.mjs.map
@@ -409,8 +409,8 @@ const COLORS = {
409
409
  underline: "#2B5A9E",
410
410
  strikeout: "#C0392B",
411
411
  squiggly: "#1F7A4D",
412
- note: "#F2C230",
413
- freeText: "#151820",
412
+ text: "#F2C230",
413
+ freetext: "#151820",
414
414
  square: "#C0392B",
415
415
  circle: "#C0392B",
416
416
  line: "#151820",
@@ -439,8 +439,8 @@ const VARIABLES = {
439
439
  underline: "--ink-underline",
440
440
  strikeout: "--ink-strikeout",
441
441
  squiggly: "--ink-squiggly",
442
- note: "--ink-note",
443
- freeText: "--ink-free-text",
442
+ text: "--ink-note",
443
+ freetext: "--ink-free-text",
444
444
  square: "--ink-shape",
445
445
  circle: "--ink-shape",
446
446
  line: "--ink-shape",
@@ -533,11 +533,13 @@ const Base = z.object({
533
533
  contents: z.string().optional(),
534
534
  /** Id of the parent note; replies form threads. */
535
535
  inReplyTo: z.string().optional(),
536
- createdAt: z.string(),
537
- modifiedAt: z.string(),
538
- /** Created in this session, or imported from the file. */
536
+ /** ISO 8601 date-time. */
537
+ createdAt: z.iso.datetime({ offset: true }),
538
+ /** ISO 8601 date-time. */
539
+ modifiedAt: z.iso.datetime({ offset: true }),
540
+ /** Created in this session, or imported from the file. Viewer state, never exported. */
539
541
  source: z.enum(["session", "pdf"]),
540
- /** Embedded annotations are locked until the engine can rewrite the file. */
542
+ /** Embedded annotations are locked until the engine can rewrite the file. Viewer state, never exported. */
541
543
  locked: z.boolean().optional(),
542
544
  /** Host data. Preserved, never interpreted. */
543
545
  custom: z.record(z.string(), z.unknown()).optional()
@@ -552,7 +554,7 @@ const TextMarkupSchema = Base.extend({
552
554
  quads: z.array(QuadSchema).min(1)
553
555
  });
554
556
  const NoteSchema = Base.extend({
555
- type: z.literal("note"),
557
+ type: z.literal("text"),
556
558
  icon: z.enum([
557
559
  "comment",
558
560
  "note",
@@ -563,8 +565,9 @@ const NoteSchema = Base.extend({
563
565
  ]).default("comment")
564
566
  });
565
567
  const FreeTextSchema = Base.extend({
566
- type: z.literal("freeText"),
567
- text: z.string(),
568
+ type: z.literal("freetext"),
569
+ /** The text shown on the page. */
570
+ contents: z.string(),
568
571
  fontSize: z.number().positive().default(12),
569
572
  fontFamily: z.string().default("Helvetica"),
570
573
  align: z.enum([
@@ -576,8 +579,8 @@ const FreeTextSchema = Base.extend({
576
579
  });
577
580
  const ShapeSchema = Base.extend({
578
581
  type: z.enum(["square", "circle"]),
579
- strokeWidth: z.number().nonnegative().default(1),
580
- fill: Hex.optional()
582
+ width: z.number().nonnegative().default(1),
583
+ interiorColor: Hex.optional()
581
584
  });
582
585
  const LineEndingSchema = z.enum([
583
586
  "none",
@@ -593,19 +596,20 @@ const LineSchema = Base.extend({
593
596
  type: z.literal("line"),
594
597
  start: PointSchema,
595
598
  end: PointSchema,
596
- strokeWidth: z.number().nonnegative().default(1),
597
- endings: z.tuple([LineEndingSchema, LineEndingSchema]).optional()
599
+ width: z.number().nonnegative().default(1),
600
+ head: LineEndingSchema.optional(),
601
+ tail: LineEndingSchema.optional()
598
602
  });
599
603
  const PolySchema = Base.extend({
600
604
  type: z.enum(["polyline", "polygon"]),
601
605
  vertices: z.array(PointSchema).min(2),
602
- strokeWidth: z.number().nonnegative().default(1),
603
- fill: Hex.optional()
606
+ width: z.number().nonnegative().default(1),
607
+ interiorColor: Hex.optional()
604
608
  });
605
609
  const InkSchema = Base.extend({
606
610
  type: z.literal("ink"),
607
- paths: z.array(z.array(PointSchema).min(1)).min(1),
608
- strokeWidth: z.number().nonnegative().default(2)
611
+ inklist: z.array(z.array(PointSchema).min(1)).min(1),
612
+ width: z.number().nonnegative().default(2)
609
613
  });
610
614
  const SuggestionSchema = z.object({
611
615
  jobId: z.string().optional(),
@@ -626,7 +630,7 @@ const RedactSchema = Base.extend({
626
630
  suggestion: SuggestionSchema.optional(),
627
631
  overlayText: z.string().optional(),
628
632
  /** Colour the redaction will be filled with when applied. */
629
- fill: Hex
633
+ interiorColor: Hex
630
634
  });
631
635
  const AnnotationSchema = z.discriminatedUnion("type", [
632
636
  TextMarkupSchema,
@@ -638,6 +642,22 @@ const AnnotationSchema = z.discriminatedUnion("type", [
638
642
  InkSchema,
639
643
  RedactSchema
640
644
  ]);
645
+ /** The viewer's own state on an annotation, left out of exports. */
646
+ const VIEWER_STATE = {
647
+ source: true,
648
+ locked: true
649
+ };
650
+ /** One exported annotation: the stored annotation without its viewer state. */
651
+ const ExportedAnnotationSchema = z.discriminatedUnion("type", [
652
+ TextMarkupSchema.omit(VIEWER_STATE),
653
+ NoteSchema.omit(VIEWER_STATE),
654
+ FreeTextSchema.omit(VIEWER_STATE),
655
+ ShapeSchema.omit(VIEWER_STATE),
656
+ LineSchema.omit(VIEWER_STATE),
657
+ PolySchema.omit(VIEWER_STATE),
658
+ InkSchema.omit(VIEWER_STATE),
659
+ RedactSchema.omit(VIEWER_STATE)
660
+ ]);
641
661
  const AnnotationDocumentSchema = z.object({
642
662
  format: z.literal(ANNOTATION_FORMAT),
643
663
  version: z.literal(1),
@@ -758,7 +778,7 @@ function convert(page, d, importedAt) {
758
778
  source: "pdf",
759
779
  locked: true
760
780
  });
761
- const fillOf = (c) => c && c.length >= 3 ? { fill: pdfColorToHex(c, "#FFFFFF") } : {};
781
+ const fillOf = (c) => c && c.length >= 3 ? { interiorColor: pdfColorToHex(c, "#FFFFFF") } : {};
762
782
  let candidate;
763
783
  switch (d.subtype) {
764
784
  case "Highlight":
@@ -776,17 +796,17 @@ function convert(page, d, importedAt) {
776
796
  }
777
797
  case "Text":
778
798
  candidate = {
779
- ...base("note"),
780
- type: "note",
799
+ ...base("text"),
800
+ type: "text",
781
801
  icon: ICONS[(d.name ?? "comment").toLowerCase()] ?? "comment"
782
802
  };
783
803
  break;
784
804
  case "FreeText": {
785
805
  const da = d.defaultAppearanceData;
786
806
  candidate = {
787
- ...base("freeText", pdfColorToHex(da?.fontColor, staticDefaults.color("freeText"))),
788
- type: "freeText",
789
- text: contents ?? "",
807
+ ...base("freetext", pdfColorToHex(da?.fontColor, staticDefaults.color("freetext"))),
808
+ type: "freetext",
809
+ contents: contents ?? "",
790
810
  ...da && da.fontSize > 0 ? { fontSize: da.fontSize } : {}
791
811
  };
792
812
  break;
@@ -797,7 +817,7 @@ function convert(page, d, importedAt) {
797
817
  candidate = {
798
818
  ...base(type),
799
819
  type,
800
- strokeWidth: stroke,
820
+ width: stroke,
801
821
  ...fillOf(d.interiorColor)
802
822
  };
803
823
  break;
@@ -821,8 +841,11 @@ function convert(page, d, importedAt) {
821
841
  x: l[2],
822
842
  y: l[3]
823
843
  },
824
- strokeWidth: stroke,
825
- ...endings && endings.length === 2 && endings.some((e) => e !== "none") ? { endings } : {}
844
+ width: stroke,
845
+ ...endings && endings.length === 2 && endings.some((e) => e !== "none") ? {
846
+ head: endings[0],
847
+ tail: endings[1]
848
+ } : {}
826
849
  };
827
850
  break;
828
851
  }
@@ -835,19 +858,19 @@ function convert(page, d, importedAt) {
835
858
  ...base(type),
836
859
  type,
837
860
  vertices,
838
- strokeWidth: stroke,
861
+ width: stroke,
839
862
  ...fillOf(d.interiorColor)
840
863
  };
841
864
  break;
842
865
  }
843
866
  case "Ink": {
844
- const paths = (d.inkLists ?? []).map((p) => pointsFromFlat(p)).filter((p) => p.length > 0);
845
- if (paths.length === 0) return void 0;
867
+ const inklist = (d.inkLists ?? []).map((p) => pointsFromFlat(p)).filter((p) => p.length > 0);
868
+ if (inklist.length === 0) return void 0;
846
869
  candidate = {
847
870
  ...base("ink"),
848
871
  type: "ink",
849
- paths,
850
- strokeWidth: stroke
872
+ inklist,
873
+ width: stroke
851
874
  };
852
875
  break;
853
876
  }
@@ -856,7 +879,7 @@ function convert(page, d, importedAt) {
856
879
  ...base("redact"),
857
880
  type: "redact",
858
881
  origin: "user",
859
- fill: pdfColorToHex(d.interiorColor, staticDefaults.fill()),
882
+ interiorColor: pdfColorToHex(d.interiorColor, staticDefaults.fill()),
860
883
  ...quads.length > 0 ? { quads } : {}
861
884
  };
862
885
  break;
@@ -1012,10 +1035,10 @@ function sameAnnotations(a, b) {
1012
1035
  }
1013
1036
  //#endregion
1014
1037
  //#region src/model/annotations/json.ts
1015
- const KNOWN_TYPES = new Set(AnnotationSchema.options.flatMap((o) => [...o.shape.type._zod.values]));
1038
+ const KNOWN_TYPES = new Set(ExportedAnnotationSchema.options.flatMap((o) => [...o.shape.type._zod.values]));
1016
1039
  /**
1017
1040
  * Session annotations plus any preserved foreign items. Embedded (`source: 'pdf'`) ones stay in
1018
- * the file.
1041
+ * the file. `source` and `locked` are viewer state and are left out.
1019
1042
  *
1020
1043
  * The result is a JSON copy (`JSON.parse(JSON.stringify(...))`), the same data a serialised
1021
1044
  * export would carry: editing it never touches the store, and values JSON cannot hold, such as
@@ -1026,7 +1049,7 @@ const KNOWN_TYPES = new Set(AnnotationSchema.options.flatMap((o) => [...o.shape.
1026
1049
  * describes only the types it knows.
1027
1050
  */
1028
1051
  function exportAnnotations(store, preserved = [], documentKey) {
1029
- const session = store.list.get().filter((a) => a.source === "session");
1052
+ const session = store.list.get().filter((a) => a.source === "session").map(({ source: _source, locked: _locked, ...rest }) => rest);
1030
1053
  return {
1031
1054
  format: ANNOTATION_FORMAT,
1032
1055
  version: 1,
@@ -1102,7 +1125,7 @@ function planImport(store, data, opts) {
1102
1125
  else if (claim(item.id, index)) result.unknown.push(item);
1103
1126
  return;
1104
1127
  }
1105
- const parsed = AnnotationSchema.safeParse(item);
1128
+ const parsed = ExportedAnnotationSchema.safeParse(item);
1106
1129
  if (!parsed.success) {
1107
1130
  result.errors.push({
1108
1131
  index,
@@ -1150,7 +1173,7 @@ const LOCKED_KEYS = /* @__PURE__ */ new Set([
1150
1173
  "page",
1151
1174
  "rect",
1152
1175
  "quads",
1153
- "paths",
1176
+ "inklist",
1154
1177
  "start",
1155
1178
  "end",
1156
1179
  "vertices",
@@ -1186,8 +1209,8 @@ function deriveRect(input) {
1186
1209
  if (input.quads) return unionRects(input.quads.map(rectFromQuad));
1187
1210
  break;
1188
1211
  case "ink": {
1189
- const pad = (input.strokeWidth ?? 2) / 2;
1190
- const r = bounds(input.paths.flat());
1212
+ const pad = (input.width ?? 2) / 2;
1213
+ const r = bounds(input.inklist.flat());
1191
1214
  return {
1192
1215
  x: r.x - pad,
1193
1216
  y: r.y - pad,
@@ -1277,7 +1300,7 @@ function createAnnotationStore(opts) {
1277
1300
  source: "session"
1278
1301
  };
1279
1302
  if (input.type === "redact") {
1280
- if (input.fill === void 0) candidate.fill = opts.defaults.fill();
1303
+ if (input.interiorColor === void 0) candidate.interiorColor = opts.defaults.fill();
1281
1304
  if (input.origin === "suggested" && input.suggestion && input.color === void 0) candidate.color = opts.defaults.suggestion(confidenceBucket(input.suggestion.confidence));
1282
1305
  }
1283
1306
  return AnnotationSchema.parse(candidate);
@@ -1845,7 +1868,7 @@ function threadRoot(list, start) {
1845
1868
  let current = start;
1846
1869
  while (current.inReplyTo) {
1847
1870
  const parent = list.find((a) => a.id === current.inReplyTo);
1848
- if (parent?.type !== "note" || seen.has(parent.id)) break;
1871
+ if (parent?.type !== "text" || seen.has(parent.id)) break;
1849
1872
  seen.add(parent.id);
1850
1873
  current = parent;
1851
1874
  }
@@ -1869,10 +1892,10 @@ function threadOf(list, root) {
1869
1892
  /** An unlocked root note with no text and no replies: nothing a reader would miss. */
1870
1893
  function isAbandonedNote(list, id) {
1871
1894
  const a = list.find((x) => x.id === id);
1872
- if (a?.type !== "note" || a.locked || a.inReplyTo || a.contents?.trim()) return false;
1895
+ if (a?.type !== "text" || a.locked || a.inReplyTo || a.contents?.trim()) return false;
1873
1896
  return repliesTo(list, id).length === 0;
1874
1897
  }
1875
1898
  //#endregion
1876
- export { rectFromQuad as $, RectSchema as A, mergeLineRects as B, InkSchema as C, PointSchema as D, NoteSchema as E, confidenceBucket as F, approxEqual as G, readonly as H, parsePdfDate as I, pointsFromFlat as J, invertMatrix as K, cssVariableDefaults as L, ShapeSchema as M, SuggestionSchema as N, PolySchema as O, TextMarkupSchema as P, rectFromPoints as Q, normalizeColor as R, FreeTextSchema as S, LineSchema as T, writable as U, derived as V, applyMatrix as W, quadsFromFlat as X, quadFromRect as Y, rectContainsPoint as Z, summarise as _, acceptSuggestion as a, InkError as at, AnnotationDocumentSchema as b, deriveRect as c, createHistory as d, rectsIntersect as et, isProduction as f, pdfColorToHex as g, importedId as h, threadRoot as i, Emitter as it, RedactSchema as j, QuadSchema as k, exportAnnotations as l, importEmbeddedPage as m, repliesTo as n, translateRect as nt, openDocument as o, isInkError as ot, SUPPORTED_SUBTYPES as p, multiplyMatrix as q, threadOf as r, unionRects as rt, createAnnotationStore as s, isAbandonedNote as t, translateQuad as tt, importAnnotations as u, ANNOTATION_FORMAT as v, LineEndingSchema as w, AnnotationSchema as x, ANNOTATION_VERSION as y, staticDefaults as z };
1899
+ export { rectFromPoints as $, QuadSchema as A, staticDefaults as B, FreeTextSchema as C, NoteSchema as D, LineSchema as E, TextMarkupSchema as F, applyMatrix as G, derived as H, confidenceBucket as I, multiplyMatrix as J, approxEqual as K, parsePdfDate as L, RedactSchema as M, ShapeSchema as N, PointSchema as O, SuggestionSchema as P, rectContainsPoint as Q, cssVariableDefaults as R, ExportedAnnotationSchema as S, LineEndingSchema as T, readonly as U, mergeLineRects as V, writable as W, quadFromRect as X, pointsFromFlat as Y, quadsFromFlat as Z, summarise as _, acceptSuggestion as a, Emitter as at, AnnotationDocumentSchema as b, deriveRect as c, createHistory as d, rectFromQuad as et, isProduction as f, pdfColorToHex as g, importedId as h, threadRoot as i, unionRects as it, RectSchema as j, PolySchema as k, exportAnnotations as l, importEmbeddedPage as m, repliesTo as n, translateQuad as nt, openDocument as o, InkError as ot, SUPPORTED_SUBTYPES as p, invertMatrix as q, threadOf as r, translateRect as rt, createAnnotationStore as s, isInkError as st, isAbandonedNote as t, rectsIntersect as tt, importAnnotations as u, ANNOTATION_FORMAT as v, InkSchema as w, AnnotationSchema as x, ANNOTATION_VERSION as y, normalizeColor as z };
1877
1900
 
1878
- //# sourceMappingURL=threads-BtvtrAhL.mjs.map
1901
+ //# sourceMappingURL=threads-2USvyGpX.mjs.map