@inkbar/vue 0.0.0-stage → 0.1.1

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.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -2
  3. package/dist/components/InkAnnotation.js +7 -0
  4. package/dist/components/InkAnnotation.js.map +1 -0
  5. package/dist/components/InkAnnotation.vue.d.ts +22 -0
  6. package/dist/components/InkAnnotation.vue.d.ts.map +1 -0
  7. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js +48 -0
  8. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js.map +1 -0
  9. package/dist/components/InkNotePopover.js +7 -0
  10. package/dist/components/InkNotePopover.js.map +1 -0
  11. package/dist/components/InkNotePopover.vue.d.ts +15 -0
  12. package/dist/components/InkNotePopover.vue.d.ts.map +1 -0
  13. package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js +132 -0
  14. package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
  15. package/dist/components/InkPage.js +7 -0
  16. package/dist/components/InkPage.js.map +1 -0
  17. package/dist/components/InkPage.vue.d.ts +32 -0
  18. package/dist/components/InkPage.vue.d.ts.map +1 -0
  19. package/dist/components/InkPage.vue_vue_type_script_setup_true_lang.js +68 -0
  20. package/dist/components/InkPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
  21. package/dist/components/InkPageCount.js +7 -0
  22. package/dist/components/InkPageCount.js.map +1 -0
  23. package/dist/components/InkPageCount.vue.d.ts +4 -0
  24. package/dist/components/InkPageCount.vue.d.ts.map +1 -0
  25. package/dist/components/InkPageCount.vue_vue_type_script_setup_true_lang.js +18 -0
  26. package/dist/components/InkPageCount.vue_vue_type_script_setup_true_lang.js.map +1 -0
  27. package/dist/components/InkPageInput.js +7 -0
  28. package/dist/components/InkPageInput.js.map +1 -0
  29. package/dist/components/InkPageInput.vue.d.ts +4 -0
  30. package/dist/components/InkPageInput.vue.d.ts.map +1 -0
  31. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js +30 -0
  32. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/components/InkRoot.js +7 -0
  34. package/dist/components/InkRoot.js.map +1 -0
  35. package/dist/components/InkRoot.vue.d.ts +784 -0
  36. package/dist/components/InkRoot.vue.d.ts.map +1 -0
  37. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +162 -0
  38. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -0
  39. package/dist/components/InkSuggestionCard.js +7 -0
  40. package/dist/components/InkSuggestionCard.js.map +1 -0
  41. package/dist/components/InkSuggestionCard.vue.d.ts +16 -0
  42. package/dist/components/InkSuggestionCard.vue.d.ts.map +1 -0
  43. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js +85 -0
  44. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map +1 -0
  45. package/dist/components/InkToolButton.js +7 -0
  46. package/dist/components/InkToolButton.js.map +1 -0
  47. package/dist/components/InkToolButton.vue.d.ts +26 -0
  48. package/dist/components/InkToolButton.vue.d.ts.map +1 -0
  49. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +45 -0
  50. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  51. package/dist/components/InkToolbar.js +7 -0
  52. package/dist/components/InkToolbar.js.map +1 -0
  53. package/dist/components/InkToolbar.vue.d.ts +21 -0
  54. package/dist/components/InkToolbar.vue.d.ts.map +1 -0
  55. package/dist/components/InkToolbar.vue_vue_type_script_setup_true_lang.js +29 -0
  56. package/dist/components/InkToolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  57. package/dist/components/InkViewport.js +7 -0
  58. package/dist/components/InkViewport.js.map +1 -0
  59. package/dist/components/InkViewport.vue.d.ts +39 -0
  60. package/dist/components/InkViewport.vue.d.ts.map +1 -0
  61. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +148 -0
  62. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -0
  63. package/dist/components/InkZoomIn.js +7 -0
  64. package/dist/components/InkZoomIn.js.map +1 -0
  65. package/dist/components/InkZoomIn.vue.d.ts +19 -0
  66. package/dist/components/InkZoomIn.vue.d.ts.map +1 -0
  67. package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js +30 -0
  68. package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js.map +1 -0
  69. package/dist/components/InkZoomOut.js +7 -0
  70. package/dist/components/InkZoomOut.js.map +1 -0
  71. package/dist/components/InkZoomOut.vue.d.ts +19 -0
  72. package/dist/components/InkZoomOut.vue.d.ts.map +1 -0
  73. package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js +30 -0
  74. package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js.map +1 -0
  75. package/dist/components/InkZoomSelect.js +7 -0
  76. package/dist/components/InkZoomSelect.js.map +1 -0
  77. package/dist/components/InkZoomSelect.vue.d.ts +4 -0
  78. package/dist/components/InkZoomSelect.vue.d.ts.map +1 -0
  79. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +39 -0
  80. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -0
  81. package/dist/components/annotation-element.d.ts +5 -0
  82. package/dist/components/annotation-element.d.ts.map +1 -0
  83. package/dist/components/annotation-element.js +18 -0
  84. package/dist/components/annotation-element.js.map +1 -0
  85. package/dist/components/annotation-slot.d.ts +2 -0
  86. package/dist/components/annotation-slot.d.ts.map +1 -0
  87. package/dist/components/popover-focus.d.ts +9 -0
  88. package/dist/components/popover-focus.d.ts.map +1 -0
  89. package/dist/components/popover-focus.js +15 -0
  90. package/dist/components/popover-focus.js.map +1 -0
  91. package/dist/composables/useAnnotations.d.ts +1921 -0
  92. package/dist/composables/useAnnotations.d.ts.map +1 -0
  93. package/dist/composables/useAnnotations.js +27 -0
  94. package/dist/composables/useAnnotations.js.map +1 -0
  95. package/dist/composables/useDocument.d.ts +12 -0
  96. package/dist/composables/useDocument.d.ts.map +1 -0
  97. package/dist/composables/useDocument.js +20 -0
  98. package/dist/composables/useDocument.js.map +1 -0
  99. package/dist/composables/useEmbedded.d.ts +6 -0
  100. package/dist/composables/useEmbedded.d.ts.map +1 -0
  101. package/dist/composables/useEmbedded.js +15 -0
  102. package/dist/composables/useEmbedded.js.map +1 -0
  103. package/dist/composables/useHistory.d.ts +7 -0
  104. package/dist/composables/useHistory.d.ts.map +1 -0
  105. package/dist/composables/useHistory.js +9 -0
  106. package/dist/composables/useHistory.js.map +1 -0
  107. package/dist/composables/usePage.d.ts +10 -0
  108. package/dist/composables/usePage.d.ts.map +1 -0
  109. package/dist/composables/usePage.js +22 -0
  110. package/dist/composables/usePage.js.map +1 -0
  111. package/dist/composables/useSelection.d.ts +6 -0
  112. package/dist/composables/useSelection.d.ts.map +1 -0
  113. package/dist/composables/useSelection.js +14 -0
  114. package/dist/composables/useSelection.js.map +1 -0
  115. package/dist/composables/useTool.d.ts +6 -0
  116. package/dist/composables/useTool.d.ts.map +1 -0
  117. package/dist/composables/useTool.js +13 -0
  118. package/dist/composables/useTool.js.map +1 -0
  119. package/dist/composables/useZoom.d.ts +9 -0
  120. package/dist/composables/useZoom.d.ts.map +1 -0
  121. package/dist/composables/useZoom.js +17 -0
  122. package/dist/composables/useZoom.js.map +1 -0
  123. package/dist/compositions/DefaultToolbar.js +7 -0
  124. package/dist/compositions/DefaultToolbar.js.map +1 -0
  125. package/dist/compositions/DefaultToolbar.vue.d.ts +19 -0
  126. package/dist/compositions/DefaultToolbar.vue.d.ts.map +1 -0
  127. package/dist/compositions/DefaultToolbar.vue_vue_type_script_setup_true_lang.js +100 -0
  128. package/dist/compositions/DefaultToolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  129. package/dist/context.d.ts +50 -0
  130. package/dist/context.d.ts.map +1 -0
  131. package/dist/context.js +13 -0
  132. package/dist/context.js.map +1 -0
  133. package/dist/index.d.ts +29 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +25 -0
  136. package/dist/ref-history.d.ts +18 -0
  137. package/dist/ref-history.d.ts.map +1 -0
  138. package/dist/ref-history.js +25 -0
  139. package/dist/ref-history.js.map +1 -0
  140. package/dist/use-readable.d.ts +5 -0
  141. package/dist/use-readable.d.ts.map +1 -0
  142. package/dist/use-readable.js +16 -0
  143. package/dist/use-readable.js.map +1 -0
  144. package/package.json +52 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkRoot.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkRoot.vue"],"names":[],"mappings":"AA2RA,OAAO,EAAE,QAAQ,EAAgB,MAAM,cAAc,CAAA;AAcrD,OAAO,EAAqB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAI/E,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,SAAS,EACV,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAkB,MAAM,EAAY,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGnF,KAAK,WAAW,GAAG;IACf,GAAG,EAAE,cAAc,GAAG,IAAI,CAAA;IAC1B,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC5B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,C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D,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,162 @@
1
+ import { provideInkContext as e } from "../context.js";
2
+ import { useReadable as t } from "../use-readable.js";
3
+ import { createRefHistory as n } from "../ref-history.js";
4
+ import { computed as r, createBlock as i, defineComponent as a, onBeforeUnmount as o, onMounted as s, onUpdated as c, openBlock as l, ref as u, renderSlot as d, shallowRef as f, unref as p, useTemplateRef as m, watch as h, withCtx as g } from "vue";
5
+ import { InkError as _, openDocument as v } from "@inkbar/core";
6
+ import { cssVariableDefaults as y } from "@inkbar/core/dom";
7
+ import { Primitive as b } from "reka-ui";
8
+ //#region src/components/InkRoot.vue?vue&type=script&setup=true&lang.ts
9
+ var x = /*@__PURE__*/ a({
10
+ __name: "InkRoot",
11
+ props: {
12
+ src: {},
13
+ assets: {},
14
+ password: { default: void 0 },
15
+ defaults: { default: void 0 },
16
+ annotations: { default: void 0 },
17
+ tool: { default: void 0 },
18
+ page: { default: void 0 },
19
+ zoom: { default: void 0 },
20
+ history: {
21
+ type: Boolean,
22
+ default: void 0
23
+ },
24
+ asChild: {
25
+ type: Boolean,
26
+ default: !1
27
+ }
28
+ },
29
+ emits: [
30
+ "update:annotations",
31
+ "change",
32
+ "update:tool",
33
+ "update:page",
34
+ "update:zoom",
35
+ "ready",
36
+ "error",
37
+ "activate"
38
+ ],
39
+ setup(a, { expose: x, emit: S }) {
40
+ let C = a, w = S, T = m("primitive"), E = f(null);
41
+ function D() {
42
+ let e = T.value?.$el;
43
+ E.value = e instanceof HTMLElement ? e : null;
44
+ }
45
+ let O = f(null), k = f(null), A = t(() => O.value?.status ?? null, { state: "idle" }), j = r(() => k.value ?? A.value), M = t(() => O.value?.annotations.list ?? null, []), N = t(() => O.value?.annotations.selection ?? null, []), P = f(null), F = f(null), I = u(C.tool ?? "view"), L = u(null), R = r(() => C.annotations !== void 0);
46
+ function z(e) {
47
+ return e === null ? null : typeof e == "string" ? e : "key" in e ? e.key : e;
48
+ }
49
+ let B = 0;
50
+ function V() {
51
+ O.value?.destroy(), O.value = null;
52
+ }
53
+ async function H() {
54
+ let e = ++B, t = C.src;
55
+ if (V(), U.clear(), t === null) {
56
+ k.value = null;
57
+ return;
58
+ }
59
+ k.value = { state: "loading" }, D();
60
+ let n;
61
+ try {
62
+ n = await v(t, {
63
+ assets: C.assets,
64
+ password: C.password,
65
+ defaults: C.defaults ?? (E.value ? y(E.value) : void 0),
66
+ history: R.value ? !1 : C.history ?? !0,
67
+ annotations: R.value ? {
68
+ mode: "controlled",
69
+ initial: C.annotations ?? [],
70
+ onChange: (e, t) => {
71
+ w("update:annotations", e), w("change", t);
72
+ }
73
+ } : { mode: "uncontrolled" }
74
+ });
75
+ } catch (t) {
76
+ if (e !== B) return;
77
+ let n = t instanceof _ ? t : new _("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
78
+ k.value = {
79
+ state: "error",
80
+ error: n
81
+ }, w("error", n);
82
+ return;
83
+ }
84
+ if (e !== B) {
85
+ n.destroy();
86
+ return;
87
+ }
88
+ n.annotations.mode === "controlled" && C.annotations !== void 0 && n.annotations.setControlledValue(C.annotations), O.value = n, k.value = null;
89
+ let r = n.status.get();
90
+ r.state === "ready" ? w("ready", n) : r.state === "error" && w("error", r.error);
91
+ }
92
+ let U = n({
93
+ source: () => C.annotations,
94
+ apply: (e) => O.value?.annotations.replaceAll(e, "history"),
95
+ enabled: r(() => R.value && C.history === !0)
96
+ }), W = t(() => O.value?.history.canUndo ?? null, !1), G = t(() => O.value?.history.canRedo ?? null, !1), K = {
97
+ canUndo: r(() => R.value ? U.canUndo.value : W.value),
98
+ canRedo: r(() => R.value ? U.canRedo.value : G.value),
99
+ undo: () => R.value ? U.undo() : O.value?.history.undo(),
100
+ redo: () => R.value ? U.redo() : O.value?.history.redo(),
101
+ clear: () => R.value ? U.clear() : O.value?.history.clear(),
102
+ batch: (e) => {
103
+ R.value ? U.batch(e) : O.value ? O.value.history.batch(e) : e();
104
+ }
105
+ };
106
+ s(() => {
107
+ D(), H();
108
+ }), c(D), h([() => z(C.src), () => C.password], () => void H()), h(() => C.annotations, (e) => {
109
+ e && O.value?.annotations.mode === "controlled" && O.value.annotations.setControlledValue(e);
110
+ }), h(() => C.tool, (e) => {
111
+ e && (I.value = e);
112
+ });
113
+ function q(e) {
114
+ I.value = e, w("update:tool", e);
115
+ }
116
+ return o(() => {
117
+ B++, V();
118
+ }), e({
119
+ assets: r(() => C.assets),
120
+ document: O,
121
+ status: j,
122
+ annotations: M,
123
+ selection: N,
124
+ viewport: P,
125
+ tools: F,
126
+ tool: I,
127
+ setTool: q,
128
+ zoomModel: r(() => C.zoom),
129
+ pageModel: r(() => C.page),
130
+ reportZoom: (e) => w("update:zoom", e),
131
+ reportPage: (e) => w("update:page", e),
132
+ activated: L,
133
+ setActivated(e) {
134
+ L.value = e, e && w("activate", e);
135
+ },
136
+ history: K,
137
+ rootEl: E
138
+ }), x({
139
+ document: O,
140
+ status: j,
141
+ rootEl: E,
142
+ history: K
143
+ }), (e, t) => (l(), i(p(b), {
144
+ ref_key: "primitive",
145
+ ref: T,
146
+ "as-child": C.asChild,
147
+ as: "div",
148
+ "data-ink-root": "",
149
+ "data-state": j.value.state
150
+ }, {
151
+ default: g(() => [d(e.$slots, "default", {
152
+ status: j.value,
153
+ document: O.value
154
+ })]),
155
+ _: 3
156
+ }, 8, ["as-child", "data-state"]));
157
+ }
158
+ });
159
+ //#endregion
160
+ export { x as default };
161
+
162
+ //# sourceMappingURL=InkRoot.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkRoot.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_renderSlot","InkRoot_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","tools","internalTool","ref","activated","controlled","identity","src","generation","release","open","gen","refHistory","doc","openDocument","cssVariableDefaults","next","change","cause","error","InkError","s","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","onMounted","onUpdated","watch","t","setTool","id","onBeforeUnmount","provideInkContext","z","p","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { InkError, openDocument } from '@inkbar/core'\nimport { cssVariableDefaults } from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n} from '@inkbar/core'\nimport type { ToolController, ToolId, Viewport, ZoomValue } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst tools = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'view')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n document.value?.destroy()\n document.value = null\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n}\n\n// Open on the client only: on the server InkRoot renders its empty slot.\nonMounted(() => {\n syncRootEl()\n void open()\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools,\n tool: internalTool,\n setTool,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated(id) {\n activated.value = id\n if (id) emit('activate', id)\n },\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAMQ,IAAQC,GA+BRC,IAAOH,GAcPI,IAAYC,EAAiC,WAAW,GACxDC,IAASC,EAA+B,IAAI;EAClD,SAASC,IAAmB;GAC1B,IAAMC,IAAKL,EAAU,OAAO;GAC5B,EAAO,QAAQK,aAAc,cAAcA,IAAK;EAClD;EAEA,IAAMC,IAAWH,EAA+B,IAAI,GAE9CI,IAAWJ,EAA6B,IAAI,GAE5CK,IAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QA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GAEpB,SAAAlB,QAA8C,CAA9CC,EAA8CiE,EAAA,QAAA,WAAA;IAAvC,QAAQhD,EAAA;IAAS,UAAUJ,EAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSuggestionCard.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSuggestionCard.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSuggestionCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSuggestionCard.js","names":["_sfc_main","InkSuggestionCard_vue_vue_type_script_setup_true_lang_default","InkSuggestionCard_default"],"sources":["../../src/components/InkSuggestionCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Review card for a suggested redaction: opens when the activated annotation, or the only\n * selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be\n * dismissed, so they get no Dismiss button. A press on the overlay selects and\n * activates, so a click opens it whatever the tool. Closing clears `activated` and the\n * selection.\n */\nimport { confidenceBucket } from '@inkbar/core'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useAnnotations } from '../composables/useAnnotations'\nimport { injectInkContext } from '../context'\n\nimport { useAnnotationElement } from './annotation-element'\nimport { keepOpenOnAnnotation, useFocusReturn } from './popover-focus'\n\nimport type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'\nimport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\nexport type { ConfidenceBucket } from '@inkbar/core'\n\nexport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\ndefineSlots<{ default?(props: SuggestionCardSlotProps): unknown }>()\n\nconst ctx = injectInkContext()\nconst {\n annotations,\n selection,\n accept: acceptId,\n dismiss: dismissId,\n select,\n} = useAnnotations()\n\nfunction suggestion(id: string | null | undefined): RedactAnnotation | null {\n const a = id ? annotations.value.find((x) => x.id === id) : undefined\n return a?.type === 'redact' && a.origin === 'suggested' ? a : null\n}\n// The activated annotation when it is a suggestion; otherwise the only selected one (a\n// marquee selects without activating).\nconst target = computed<RedactAnnotation | null>(\n () =>\n suggestion(ctx.activated.value) ??\n (selection.value.length === 1 ? suggestion(selection.value[0]) : null)\n)\nconst anchor = useAnnotationElement(\n ctx,\n computed(() => target.value?.id ?? null)\n)\nconst focusReturn = useFocusReturn(ctx)\nconst open = computed(() => target.value !== null && anchor.value !== null)\nconst bucket = computed<ConfidenceBucket | undefined>(() =>\n target.value?.suggestion\n ? confidenceBucket(target.value.suggestion.confidence)\n : undefined\n)\n\nfunction close(): void {\n ctx.setActivated(null)\n select([])\n}\nfunction accept(): void {\n if (target.value) acceptId(target.value.id)\n close()\n}\n/** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */\nfunction dismiss(): void {\n const t = target.value\n if (!t || t.locked) return\n focusReturn.beforeRemove(anchor.value, '[data-origin=\"suggested\"]')\n dismissId(t.id)\n close()\n}\nfunction onOpenChange(next: boolean): void {\n if (!next) close()\n}\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"target && anchor\"\n :reference=\"anchor\"\n class=\"ink-suggestion-card\"\n data-ink-suggestion-card\n side=\"bottom\"\n :side-offset=\"6\"\n :collision-padding=\"8\"\n v-bind=\"{ 'aria-label': 'Suggested redaction' }\"\n @interact-outside=\"keepOpenOnAnnotation\"\n @close-auto-focus=\"focusReturn.onCloseAutoFocus($event, anchor)\"\n >\n <slot\n :annotation=\"target\"\n :suggestion=\"target.suggestion\"\n :bucket=\"bucket\"\n :accept=\"accept\"\n :dismiss=\"dismiss\"\n :close=\"close\"\n >\n <p class=\"ink-suggestion-reason\">\n <strong>{{ target.suggestion?.reason ?? 'Suggested redaction' }}</strong>\n <span\n v-if=\"bucket\"\n class=\"ink-suggestion-confidence\"\n :data-confidence=\"bucket\"\n >\n {{ bucket }} confidence\n </span>\n </p>\n <p v-if=\"target.suggestion?.explanation\" class=\"ink-suggestion-explanation\">\n {{ target.suggestion.explanation }}\n </p>\n <div class=\"ink-suggestion-actions\">\n <button type=\"button\" @click=\"accept\">Accept</button>\n <button v-if=\"!target.locked\" type=\"button\" @click=\"dismiss\">Dismiss</button>\n </div>\n </slot>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { SuggestionCardSlotProps } from '@inkbar/core/dom';
2
+ export type { ConfidenceBucket } from '@inkbar/core';
3
+ export type { SuggestionCardSlotProps } from '@inkbar/core/dom';
4
+ type __VLS_Slots = {
5
+ default?(props: SuggestionCardSlotProps): unknown;
6
+ };
7
+ declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
8
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
16
+ //# sourceMappingURL=InkSuggestionCard.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSuggestionCard.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSuggestionCard.vue"],"names":[],"mappings":"AAiJA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpD,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAA;CAAE,CAAC;AAwMzE,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { injectInkContext as e } from "../context.js";
2
+ import { useAnnotations as t } from "../composables/useAnnotations.js";
3
+ import { useAnnotationElement as n } from "./annotation-element.js";
4
+ import { keepOpenOnAnnotation as r, useFocusReturn as i } from "./popover-focus.js";
5
+ import { computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, mergeProps as f, openBlock as p, renderSlot as m, toDisplayString as h, unref as g, withCtx as _ } from "vue";
6
+ import { confidenceBucket as v } from "@inkbar/core";
7
+ import { PopoverContent as y, PopoverPortal as b, PopoverRoot as x } from "reka-ui";
8
+ //#region src/components/InkSuggestionCard.vue?vue&type=script&setup=true&lang.ts
9
+ var S = { class: "ink-suggestion-reason" }, C = ["data-confidence"], w = {
10
+ key: 0,
11
+ class: "ink-suggestion-explanation"
12
+ }, T = { class: "ink-suggestion-actions" }, E = /*@__PURE__*/ d({
13
+ __name: "InkSuggestionCard",
14
+ setup(d) {
15
+ let E = e(), { annotations: D, selection: O, accept: k, dismiss: A, select: j } = t();
16
+ function M(e) {
17
+ let t = e ? D.value.find((t) => t.id === e) : void 0;
18
+ return t?.type === "redact" && t.origin === "suggested" ? t : null;
19
+ }
20
+ let N = a(() => M(E.activated.value) ?? (O.value.length === 1 ? M(O.value[0]) : null)), P = n(E, a(() => N.value?.id ?? null)), F = i(E), I = a(() => N.value !== null && P.value !== null), L = a(() => N.value?.suggestion ? v(N.value.suggestion.confidence) : void 0);
21
+ function R() {
22
+ E.setActivated(null), j([]);
23
+ }
24
+ function z() {
25
+ N.value && k(N.value.id), R();
26
+ }
27
+ function B() {
28
+ let e = N.value;
29
+ e && !e.locked && (F.beforeRemove(P.value, "[data-origin=\"suggested\"]"), A(e.id), R());
30
+ }
31
+ function V(e) {
32
+ e || R();
33
+ }
34
+ return (e, t) => (p(), o(g(x), {
35
+ open: I.value,
36
+ "onUpdate:open": V
37
+ }, {
38
+ default: _(() => [u(g(b), null, {
39
+ default: _(() => [N.value && g(P) ? (p(), o(g(y), f({
40
+ key: 0,
41
+ reference: g(P),
42
+ class: "ink-suggestion-card",
43
+ "data-ink-suggestion-card": "",
44
+ side: "bottom",
45
+ "side-offset": 6,
46
+ "collision-padding": 8
47
+ }, { "aria-label": "Suggested redaction" }, {
48
+ onInteractOutside: g(r),
49
+ onCloseAutoFocus: t[0] ||= (e) => g(F).onCloseAutoFocus(e, g(P))
50
+ }), {
51
+ default: _(() => [m(e.$slots, "default", {
52
+ annotation: N.value,
53
+ suggestion: N.value.suggestion,
54
+ bucket: L.value,
55
+ accept: z,
56
+ dismiss: B,
57
+ close: R
58
+ }, () => [
59
+ l("p", S, [l("strong", null, h(N.value.suggestion?.reason ?? "Suggested redaction"), 1), L.value ? (p(), c("span", {
60
+ key: 0,
61
+ class: "ink-suggestion-confidence",
62
+ "data-confidence": L.value
63
+ }, h(L.value) + " confidence ", 9, C)) : s("", !0)]),
64
+ N.value.suggestion?.explanation ? (p(), c("p", w, h(N.value.suggestion.explanation), 1)) : s("", !0),
65
+ l("div", T, [l("button", {
66
+ type: "button",
67
+ onClick: z
68
+ }, "Accept"), N.value.locked ? s("", !0) : (p(), c("button", {
69
+ key: 0,
70
+ type: "button",
71
+ onClick: B
72
+ }, "Dismiss"))])
73
+ ])]),
74
+ _: 3
75
+ }, 16, ["reference", "onInteractOutside"])) : s("", !0)]),
76
+ _: 3
77
+ })]),
78
+ _: 3
79
+ }, 8, ["open"]));
80
+ }
81
+ });
82
+ //#endregion
83
+ export { E as default };
84
+
85
+ //# sourceMappingURL=InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSuggestionCard.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_mergeProps","_renderSlot","_createElementVNode","_toDisplayString","_createElementBlock","_createCommentVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","InkSuggestionCard_vue_vue_type_script_setup_true_lang_default","ctx","injectInkContext","acceptId","dismissId","useAnnotations","suggestion","a","id","annotations","x","target","computed","selection","anchor","useAnnotationElement","focusReturn","useFocusReturn","open","bucket","confidenceBucket","close","select","accept","dismiss","t","onOpenChange","next","openBlock","createBlock","unref","PopoverRoot","withCtx","createVNode","PopoverPortal","PopoverContent","mergeProps","keepOpenOnAnnotation","_cache","$event","renderSlot","_ctx","createElementVNode","toDisplayString","createElementBlock","createCommentVNode"],"sources":["../../src/components/InkSuggestionCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Review card for a suggested redaction: opens when the activated annotation, or the only\n * selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be\n * dismissed, so they get no Dismiss button. A press on the overlay selects and\n * activates, so a click opens it whatever the tool. Closing clears `activated` and the\n * selection.\n */\nimport { confidenceBucket } from '@inkbar/core'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useAnnotations } from '../composables/useAnnotations'\nimport { injectInkContext } from '../context'\n\nimport { useAnnotationElement } from './annotation-element'\nimport { keepOpenOnAnnotation, useFocusReturn } from './popover-focus'\n\nimport type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'\nimport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\nexport type { ConfidenceBucket } from '@inkbar/core'\n\nexport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\ndefineSlots<{ default?(props: SuggestionCardSlotProps): unknown }>()\n\nconst ctx = injectInkContext()\nconst {\n annotations,\n selection,\n accept: acceptId,\n dismiss: dismissId,\n select,\n} = useAnnotations()\n\nfunction suggestion(id: string | null | undefined): RedactAnnotation | null {\n const a = id ? annotations.value.find((x) => x.id === id) : undefined\n return a?.type === 'redact' && a.origin === 'suggested' ? a : null\n}\n// The activated annotation when it is a suggestion; otherwise the only selected one (a\n// marquee selects without activating).\nconst target = computed<RedactAnnotation | null>(\n () =>\n suggestion(ctx.activated.value) ??\n (selection.value.length === 1 ? suggestion(selection.value[0]) : null)\n)\nconst anchor = useAnnotationElement(\n ctx,\n computed(() => target.value?.id ?? null)\n)\nconst focusReturn = useFocusReturn(ctx)\nconst open = computed(() => target.value !== null && anchor.value !== null)\nconst bucket = computed<ConfidenceBucket | undefined>(() =>\n target.value?.suggestion\n ? confidenceBucket(target.value.suggestion.confidence)\n : undefined\n)\n\nfunction close(): void {\n ctx.setActivated(null)\n select([])\n}\nfunction accept(): void {\n if (target.value) acceptId(target.value.id)\n close()\n}\n/** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */\nfunction dismiss(): void {\n const t = target.value\n if (!t || t.locked) return\n focusReturn.beforeRemove(anchor.value, '[data-origin=\"suggested\"]')\n dismissId(t.id)\n close()\n}\nfunction onOpenChange(next: boolean): void {\n if (!next) close()\n}\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"target && anchor\"\n :reference=\"anchor\"\n class=\"ink-suggestion-card\"\n data-ink-suggestion-card\n side=\"bottom\"\n :side-offset=\"6\"\n :collision-padding=\"8\"\n v-bind=\"{ 'aria-label': 'Suggested redaction' }\"\n @interact-outside=\"keepOpenOnAnnotation\"\n @close-auto-focus=\"focusReturn.onCloseAutoFocus($event, anchor)\"\n >\n <slot\n :annotation=\"target\"\n :suggestion=\"target.suggestion\"\n :bucket=\"bucket\"\n :accept=\"accept\"\n :dismiss=\"dismiss\"\n :close=\"close\"\n >\n <p class=\"ink-suggestion-reason\">\n <strong>{{ target.suggestion?.reason ?? 'Suggested redaction' }}</strong>\n <span\n v-if=\"bucket\"\n class=\"ink-suggestion-confidence\"\n :data-confidence=\"bucket\"\n >\n {{ bucket }} confidence\n </span>\n </p>\n <p v-if=\"target.suggestion?.explanation\" class=\"ink-suggestion-explanation\">\n {{ target.suggestion.explanation }}\n </p>\n <div class=\"ink-suggestion-actions\">\n <button type=\"button\" @click=\"accept\">Accept</button>\n <button v-if=\"!target.locked\" type=\"button\" @click=\"dismiss\">Dismiss</button>\n </div>\n </slot>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EA2BA,IAAMgB,IAAMC,EAAiB,GACvB,EACJ,gBACA,cACA,QAAQC,GACR,SAASC,GACT,cACEC,EAAe;EAEnB,SAASC,EAAW,GAAwD;GAC1E,IAAMC,IAAIC,IAAKC,EAAY,MAAM,MAAM,MAAMC,EAAE,OAAOF,CAAE,IAAI,KAAA;GAC5D,OAAOD,GAAG,SAAS,YAAYA,EAAE,WAAW,cAAcA,IAAI;EAChE;EAGA,IAAMI,IAASC,QAEXN,EAAWL,EAAI,UAAU,KAAK,MAC7BY,EAAU,MAAM,WAAW,IAAIP,EAAWO,EAAU,MAAM,EAAE,IAAI,KACrE,GACMC,IAASC,EACbd,GACAW,QAAeD,EAAO,OAAO,MAAM,IAAI,CACzC,GACMK,IAAcC,EAAehB,CAAG,GAChCiB,IAAON,QAAeD,EAAO,UAAU,QAAQG,EAAO,UAAU,IAAI,GACpEK,IAASP,QACbD,EAAO,OAAO,aACVS,EAAiBT,EAAO,MAAM,WAAW,UAAU,IACnD,KAAA,CACN;EAEA,SAASU,IAAc;GAErB,AADApB,EAAI,aAAa,IAAI,GACrBqB,EAAO,CAAC,CAAC;EACX;EACA,SAASC,IAAe;GAEtB,AADIZ,EAAO,SAAOR,EAASQ,EAAO,MAAM,EAAE,GAC1CU,EAAM;EACR;EAEA,SAASG,IAAgB;GACvB,IAAMC,IAAId,EAAO;GACjB,AAAKc,KAAK,GAAE,WACZT,EAAY,aAAaF,EAAO,OAAO,6BAA2B,GAClEV,EAAUqB,EAAE,E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O,GAGM,CAFJP,EAAqD,UAAA;OAA7C,MAAK;OAAU,SAAO+B;MAAQ,GAAA,QAAM,GAC7BZ,EAAA,MAAO,SAA8CkC,EAAA,IAAA,EAAA,KAApE5D,EAAA,GAAAS,EAA6E,UAAA;;OAA/C,MAAK;OAAU,SAAO8B;MAAS,GAAA,SAAO,EAAA,CAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkToolButton.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkToolButton.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkToolButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useTool } from '../composables/useTool'\n\nimport type { ToolId } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\nconst name = computed(() => props.label ?? TOOL_LABELS[props.tool])\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n}))\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"attrs\"\n >\n <slot :active=\"active\" :label=\"name\">{{ name }}</slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { ToolId } from '@inkbar/core/dom';
2
+ type __VLS_Props = {
3
+ tool: ToolId;
4
+ label?: string | undefined;
5
+ asChild?: boolean;
6
+ };
7
+ declare var __VLS_7: {
8
+ active: boolean;
9
+ label: string;
10
+ };
11
+ type __VLS_Slots = {} & {
12
+ default?: (props: typeof __VLS_7) => any;
13
+ };
14
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
+ asChild: boolean;
16
+ label: string | undefined;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
21
+ type __VLS_WithSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
26
+ //# sourceMappingURL=InkToolButton.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolButton.vue"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA2DnF,QAAA,IAAI,OAAO;;;CAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { useTool as e } from "../composables/useTool.js";
2
+ import { computed as t, createBlock as n, createTextVNode as r, defineComponent as i, mergeProps as a, openBlock as o, renderSlot as s, toDisplayString as c, unref as l, withCtx as u } from "vue";
3
+ import { TOOL_LABELS as d } from "@inkbar/core/dom";
4
+ import { ToolbarButton as f } from "reka-ui";
5
+ //#region src/components/InkToolButton.vue?vue&type=script&setup=true&lang.ts
6
+ var p = /*@__PURE__*/ i({
7
+ __name: "InkToolButton",
8
+ props: {
9
+ tool: {},
10
+ label: { default: void 0 },
11
+ asChild: {
12
+ type: Boolean,
13
+ default: !1
14
+ }
15
+ },
16
+ setup(i) {
17
+ let p = i, { tool: m, setTool: h } = e(), g = t(() => m.value === p.tool), _ = t(() => p.label ?? d[p.tool]), v = t(() => ({
18
+ "aria-pressed": String(g.value),
19
+ "aria-label": _.value,
20
+ title: _.value,
21
+ onClick: () => h(p.tool)
22
+ }));
23
+ return (e, t) => (o(), n(l(f), a({
24
+ "as-child": i.asChild,
25
+ class: "ink-tool-button",
26
+ "data-ink-tool-button": "",
27
+ "data-tool": i.tool,
28
+ "data-state": g.value ? "on" : "off"
29
+ }, v.value), {
30
+ default: u(() => [s(e.$slots, "default", {
31
+ active: g.value,
32
+ label: _.value
33
+ }, () => [r(c(_.value), 1)])]),
34
+ _: 3
35
+ }, 16, [
36
+ "as-child",
37
+ "data-tool",
38
+ "data-state"
39
+ ]));
40
+ }
41
+ });
42
+ //#endregion
43
+ export { p as default };
44
+
45
+ //# sourceMappingURL=InkToolButton.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","_createTextVNode","_toDisplayString","InkToolButton_vue_vue_type_script_setup_true_lang_default","props","__props","current","useTool","active","computed","name","TOOL_LABELS","attrs","setTool","openBlock","createBlock","unref","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","createTextVNode","toDisplayString"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useTool } from '../composables/useTool'\n\nimport type { ToolId } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\nconst name = computed(() => props.label ?? TOOL_LABELS[props.tool])\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n}))\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"attrs\"\n >\n <slot :active=\"active\" :label=\"name\">{{ name }}</slot>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EASA,IAAMS,IAAQC,GAKR,EAAE,MAAMC,GAAS,eAAYC,EAAQ,GACrCC,IAASC,QAAeH,EAAQ,UAAUF,EAAM,IAAI,GACpDM,IAAOD,QAAeL,EAAM,SAASO,EAAYP,EAAM,KAAK,GAE5DQ,IAAQH,SAAgB;GAC5B,gBAAgB,OAAOD,EAAO,KAAK;GACnC,cAAcE,EAAK;GACnB,OAAOA,EAAK;GACZ,eAAeG,EAAQT,EAAM,IAAI;EACnC,EAAE;oBAIAT,EAAA,GAAAC,EASgBC,EAAAoB,CAAA,GAThBnB,EASgB;GARb,YAAUO,EAAA;GACX,OAAM;GACN,wBAAA;GACC,aAAWA,EAAA;GACX,cAAYG,EAAA,QAAM,OAAA;EACX,GAAAI,EAAA,KAAK,GAAA;GAEb,SAAAb,QAAsD,CAAtDC,EAAsDqB,EAAA,QAAA,WAAA;IAA/C,QAAQb,EAAA;IAAS,OAAOE,EAAA;GAA/B,SAAsD,CAAdT,EAAAC,EAAAQ,EAAA,KAAI,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkToolbar.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkToolbar.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolbar.js","names":["_sfc_main","InkToolbar_vue_vue_type_script_setup_true_lang_default","InkToolbar_default"],"sources":["../../src/components/InkToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ToolbarRoot } from 'reka-ui'\n\nwithDefaults(defineProps<{ label?: string; asChild?: boolean }>(), {\n label: 'Document tools',\n asChild: false,\n})\n</script>\n\n<template>\n <ToolbarRoot\n :as-child=\"asChild\"\n orientation=\"horizontal\"\n v-bind=\"{ 'aria-label': label }\"\n data-ink-toolbar\n class=\"ink-toolbar\"\n >\n <slot />\n </ToolbarRoot>\n</template>\n"],"mappings":""}
@@ -0,0 +1,21 @@
1
+ type __VLS_Props = {
2
+ label?: string;
3
+ asChild?: boolean;
4
+ };
5
+ declare var __VLS_7: {};
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_7) => any;
8
+ };
9
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
+ asChild: boolean;
11
+ label: string;
12
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
13
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
16
+ type __VLS_WithSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
21
+ //# sourceMappingURL=InkToolbar.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolbar.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolbar.vue"],"names":[],"mappings":"AAyBA,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA6CzD,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { createBlock as e, defineComponent as t, mergeProps as n, openBlock as r, renderSlot as i, unref as a, withCtx as o } from "vue";
2
+ import { ToolbarRoot as s } from "reka-ui";
3
+ //#region src/components/InkToolbar.vue?vue&type=script&setup=true&lang.ts
4
+ var c = /*@__PURE__*/ t({
5
+ __name: "InkToolbar",
6
+ props: {
7
+ label: { default: "Document tools" },
8
+ asChild: {
9
+ type: Boolean,
10
+ default: !1
11
+ }
12
+ },
13
+ setup(t) {
14
+ return (c, l) => (r(), e(a(s), n({
15
+ "as-child": t.asChild,
16
+ orientation: "horizontal"
17
+ }, { "aria-label": t.label }, {
18
+ "data-ink-toolbar": "",
19
+ class: "ink-toolbar"
20
+ }), {
21
+ default: o(() => [i(c.$slots, "default")]),
22
+ _: 3
23
+ }, 16, ["as-child"]));
24
+ }
25
+ });
26
+ //#endregion
27
+ export { c as default };
28
+
29
+ //# sourceMappingURL=InkToolbar.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkToolbar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkToolbar_vue_vue_type_script_setup_true_lang_default","openBlock","createBlock","unref","ToolbarRoot","mergeProps","__props","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ToolbarRoot } from 'reka-ui'\n\nwithDefaults(defineProps<{ label?: string; asChild?: boolean }>(), {\n label: 'Document tools',\n asChild: false,\n})\n</script>\n\n<template>\n <ToolbarRoot\n :as-child=\"asChild\"\n orientation=\"horizontal\"\n v-bind=\"{ 'aria-label': label }\"\n data-ink-toolbar\n class=\"ink-toolbar\"\n >\n <slot />\n </ToolbarRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;oBAUEA,EAAA,GAAAC,EAQcC,EAAAQ,CAAA,GARdP,EAQc;GAPX,YAAUS,EAAA;GACX,aAAY;EACY,GAAA,EAAA,cAAAA,EAAA,MAAK,GAAA;GAC7B,oBAAA;GACA,OAAM;;GAEN,SAAAR,QAAQ,CAARC,EAAQU,EAAA,QAAA,SAAA,CAAA,CAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkViewport.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkViewport.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkViewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkViewport.js","names":["_sfc_main","InkViewport_vue_vue_type_script_setup_true_lang_default","InkViewport_default"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\n\nimport InkPage from './InkPage.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n pages.value = []\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n customAnnotations: custom,\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n stops = [vp.zoom.subscribe(reportZoom), vp.currentPage.subscribe(reportPage)]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(teardown)\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { AnnotationSlotProps } from './annotation-slot';
2
+ import { InkError } from '@inkbar/core';
3
+ import { LayoutMode, ViewRotation } from '@inkbar/core/dom';
4
+ type __VLS_Props = {
5
+ mode?: LayoutMode;
6
+ rotation?: ViewRotation;
7
+ /** Gap between pages, CSS px. */
8
+ gap?: number;
9
+ /** Pages kept mounted either side of the visible ones. */
10
+ buffer?: number;
11
+ };
12
+ type __VLS_Slots = {
13
+ loading?(): unknown;
14
+ error?(props: {
15
+ error: InkError;
16
+ }): unknown;
17
+ empty?(): unknown;
18
+ annotation?(props: AnnotationSlotProps): unknown;
19
+ /** Shown inside a page that failed to render. The rest of the document stays usable. */
20
+ 'page-error'?(props: {
21
+ error: InkError;
22
+ page: number;
23
+ }): unknown;
24
+ };
25
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
26
+ mode: LayoutMode;
27
+ rotation: ViewRotation;
28
+ gap: number;
29
+ buffer: number;
30
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
31
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
+ declare const _default: typeof __VLS_export;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
39
+ //# sourceMappingURL=InkViewport.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkViewport.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkViewport.vue"],"names":[],"mappings":"AA4SA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EACV,UAAU,EAGV,YAAY,EAEb,MAAM,kBAAkB,CAAA;AAGzB,KAAK,WAAW,GAAG;IACf,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,IAAI,OAAO,CAAA;IACnB,KAAK,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAA;IAC3C,KAAK,CAAC,IAAI,OAAO,CAAA;IACjB,UAAU,CAAC,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAA;IAChD,wFAAwF;IACxF,YAAY,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAA;CACjE,CAAC;AAuSF,QAAA,MAAM,UAAU;;;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}