@inkbar/vue 0.11.0 → 0.12.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/README.md +67 -12
- package/dist/components/InkBack.js +7 -0
- package/dist/components/InkBack.js.map +1 -0
- package/dist/components/InkBack.vue.d.ts +19 -0
- package/dist/components/InkBack.vue.d.ts.map +1 -0
- package/dist/components/InkBack.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/components/InkBack.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkForward.js +7 -0
- package/dist/components/InkForward.js.map +1 -0
- package/dist/components/InkForward.vue.d.ts +19 -0
- package/dist/components/InkForward.vue.d.ts.map +1 -0
- package/dist/components/InkForward.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/components/InkForward.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkOutline.js +7 -0
- package/dist/components/InkOutline.js.map +1 -0
- package/dist/components/InkOutline.vue.d.ts +23 -0
- package/dist/components/InkOutline.vue.d.ts.map +1 -0
- package/dist/components/InkOutline.vue_vue_type_script_setup_true_lang.js +67 -0
- package/dist/components/InkOutline.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkOutlineNodes.js +7 -0
- package/dist/components/InkOutlineNodes.js.map +1 -0
- package/dist/components/InkOutlineNodes.vue.d.ts +27 -0
- package/dist/components/InkOutlineNodes.vue.d.ts.map +1 -0
- package/dist/components/InkOutlineNodes.vue_vue_type_script_setup_true_lang.js +70 -0
- package/dist/components/InkOutlineNodes.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRoot.js.map +1 -1
- package/dist/components/InkRoot.vue.d.ts +16 -6
- package/dist/components/InkRoot.vue.d.ts.map +1 -1
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +163 -155
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkSidebar.js.map +1 -1
- package/dist/components/InkSidebar.vue.d.ts +30 -0
- package/dist/components/InkSidebar.vue.d.ts.map +1 -1
- package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js +88 -50
- package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkViewport.js.map +1 -1
- package/dist/components/InkViewport.vue.d.ts.map +1 -1
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/context.d.ts +15 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -12
- package/package.json +5 -5
|
@@ -2,12 +2,12 @@ import { provideInkContext as e } from "../context.js";
|
|
|
2
2
|
import { registeredToolIds as t } from "../composables/useRegisteredTool.js";
|
|
3
3
|
import { useReadable as n } from "../use-readable.js";
|
|
4
4
|
import { createRefHistory as r } from "../ref-history.js";
|
|
5
|
-
import { computed as i, createBlock as a, defineComponent as o,
|
|
6
|
-
import { InkError as
|
|
7
|
-
import { FONT_FAMILIES as
|
|
8
|
-
import { Primitive as
|
|
5
|
+
import { computed as i, createBlock as a, defineComponent as o, getCurrentInstance as ee, onBeforeUnmount as te, onMounted as ne, onUnmounted as re, onUpdated as ie, openBlock as ae, ref as s, renderSlot as oe, shallowRef as c, unref as se, useTemplateRef as ce, watch as l, withCtx as le } from "vue";
|
|
6
|
+
import { InkError as u, createMemoryStorage as ue, createSignatureLibrary as de, createStorageSignatureStore as fe, openDocument as pe, readonly as d, writable as f } from "@inkbar/core";
|
|
7
|
+
import { FONT_FAMILIES as me, SIGNATURE_FONTS as he, attachFileKeys as ge, attachHistoryKeys as _e, createPluginHost as ve, createSearchController as ye, createToolOptions as be, cssVariableDefaults as xe, handleFindKey as Se, keepHistoryFocus as Ce, pageSelectionText as we, trackToolStyle as Te, unknownTool as Ee, viewerSearchOf as De } from "@inkbar/core/dom";
|
|
8
|
+
import { Primitive as Oe } from "reka-ui";
|
|
9
9
|
//#region src/components/InkRoot.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
-
var
|
|
10
|
+
var p = /*@__PURE__*/ o({
|
|
11
11
|
__name: "InkRoot",
|
|
12
12
|
props: {
|
|
13
13
|
src: {},
|
|
@@ -28,6 +28,7 @@ var h = /*@__PURE__*/ o({
|
|
|
28
28
|
default: void 0
|
|
29
29
|
},
|
|
30
30
|
fonts: { default: void 0 },
|
|
31
|
+
storage: { default: void 0 },
|
|
31
32
|
signatures: { default: void 0 },
|
|
32
33
|
signatureFonts: { default: void 0 },
|
|
33
34
|
page: { default: void 0 },
|
|
@@ -45,6 +46,7 @@ var h = /*@__PURE__*/ o({
|
|
|
45
46
|
"update:annotations",
|
|
46
47
|
"change",
|
|
47
48
|
"update:fields",
|
|
49
|
+
"action",
|
|
48
50
|
"form-action",
|
|
49
51
|
"update:tool",
|
|
50
52
|
"update:page",
|
|
@@ -53,242 +55,248 @@ var h = /*@__PURE__*/ o({
|
|
|
53
55
|
"error",
|
|
54
56
|
"activate"
|
|
55
57
|
],
|
|
56
|
-
setup(o, { expose:
|
|
57
|
-
let
|
|
58
|
-
function
|
|
59
|
-
let e =
|
|
60
|
-
|
|
58
|
+
setup(o, { expose: p, emit: ke }) {
|
|
59
|
+
let m = o, h = ke, Ae = ee(), g = ce("primitive"), _ = c(null);
|
|
60
|
+
function v() {
|
|
61
|
+
let e = g.value?.$el;
|
|
62
|
+
_.value = e instanceof HTMLElement ? e : null;
|
|
61
63
|
}
|
|
62
|
-
let
|
|
63
|
-
function
|
|
64
|
-
|
|
64
|
+
let y = c(null), b = c(null), je = n(() => y.value?.status ?? null, { state: "idle" }), x = i(() => b.value ?? je.value), S = n(() => y.value?.annotations.list ?? null, []), Me = n(() => y.value?.annotations.selection ?? null, []), C = c(null), w = c(null), T = c(null), E = s(m.tool ?? "select-text"), D = s(null), O = i(() => m.annotations !== void 0), Ne = i(() => m.fields !== void 0);
|
|
65
|
+
function k(e) {
|
|
66
|
+
D.value = e, e && h("activate", e);
|
|
65
67
|
}
|
|
66
|
-
let
|
|
67
|
-
function
|
|
68
|
+
let A = () => {};
|
|
69
|
+
function Pe(e) {
|
|
68
70
|
return e === null ? null : typeof e == "string" ? e : "key" in e ? e.key : e;
|
|
69
71
|
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
let e =
|
|
74
|
-
|
|
72
|
+
let j = 0, M = A;
|
|
73
|
+
function N() {
|
|
74
|
+
M(), M = A;
|
|
75
|
+
let e = y.value;
|
|
76
|
+
y.value = null, e?.destroy();
|
|
75
77
|
}
|
|
76
|
-
async function
|
|
77
|
-
let e = ++
|
|
78
|
-
if (
|
|
79
|
-
|
|
78
|
+
async function P() {
|
|
79
|
+
let e = ++j, t = m.src;
|
|
80
|
+
if (N(), F.clear(), t === null) {
|
|
81
|
+
b.value = null;
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
b.value = { state: "loading" }, v();
|
|
83
85
|
let n;
|
|
84
86
|
try {
|
|
85
|
-
n = await
|
|
86
|
-
assets:
|
|
87
|
-
password:
|
|
88
|
-
defaults:
|
|
89
|
-
history:
|
|
90
|
-
annotations:
|
|
87
|
+
n = await pe(t, {
|
|
88
|
+
assets: m.assets,
|
|
89
|
+
password: m.password,
|
|
90
|
+
defaults: m.defaults ?? (_.value ? xe(_.value) : void 0),
|
|
91
|
+
history: O.value ? !1 : m.history ?? !0,
|
|
92
|
+
annotations: O.value ? {
|
|
91
93
|
mode: "controlled",
|
|
92
|
-
initial:
|
|
94
|
+
initial: m.annotations ?? [],
|
|
93
95
|
onChange: (e, t) => {
|
|
94
|
-
|
|
96
|
+
h("update:annotations", e), h("change", t);
|
|
95
97
|
}
|
|
96
98
|
} : { mode: "uncontrolled" },
|
|
97
|
-
fields:
|
|
99
|
+
fields: Ne.value ? {
|
|
98
100
|
mode: "controlled",
|
|
99
|
-
initial:
|
|
100
|
-
onChange: (e, t) =>
|
|
101
|
+
initial: m.fields ?? {},
|
|
102
|
+
onChange: (e, t) => h("update:fields", e, t)
|
|
101
103
|
} : { mode: "uncontrolled" }
|
|
102
104
|
});
|
|
103
105
|
} catch (t) {
|
|
104
|
-
if (e !==
|
|
105
|
-
let n = t instanceof
|
|
106
|
-
|
|
106
|
+
if (e !== j) return;
|
|
107
|
+
let n = t instanceof u ? t : new u("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
|
|
108
|
+
b.value = {
|
|
107
109
|
state: "error",
|
|
108
110
|
error: n
|
|
109
|
-
},
|
|
111
|
+
}, h("error", n);
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
|
-
if (e !==
|
|
114
|
+
if (e !== j) {
|
|
113
115
|
n.destroy();
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
|
-
n.annotations.mode === "controlled" &&
|
|
118
|
+
n.annotations.mode === "controlled" && m.annotations !== void 0 && n.annotations.setControlledValue(m.annotations), m.fields !== void 0 && n.form.setControlledValue(m.fields);
|
|
117
119
|
let r = [];
|
|
118
|
-
|
|
119
|
-
r ? r.push(e) :
|
|
120
|
-
}),
|
|
120
|
+
M = n.form.on("error", (e) => {
|
|
121
|
+
r ? r.push(e) : h("error", e);
|
|
122
|
+
}), y.value = n, b.value = null;
|
|
121
123
|
let i = n.status.get();
|
|
122
|
-
i.state === "ready" ?
|
|
124
|
+
i.state === "ready" ? h("ready", n) : i.state === "error" && h("error", i.error);
|
|
123
125
|
let a = r;
|
|
124
|
-
if (r = void 0, e ===
|
|
126
|
+
if (r = void 0, e === j) for (let e of a) h("error", e);
|
|
125
127
|
}
|
|
126
|
-
let
|
|
127
|
-
source: () =>
|
|
128
|
-
apply: (e) =>
|
|
129
|
-
enabled: i(() =>
|
|
130
|
-
store: () =>
|
|
131
|
-
}),
|
|
132
|
-
canUndo: i(() =>
|
|
133
|
-
canRedo: i(() =>
|
|
134
|
-
undo: () =>
|
|
135
|
-
redo: () =>
|
|
136
|
-
clear: () =>
|
|
128
|
+
let F = r({
|
|
129
|
+
source: () => m.annotations,
|
|
130
|
+
apply: (e) => y.value?.annotations.replaceAll(e, "history"),
|
|
131
|
+
enabled: i(() => O.value && m.history === !0),
|
|
132
|
+
store: () => y.value?.annotations.mode === "controlled" ? y.value.annotations : null
|
|
133
|
+
}), Fe = n(() => y.value?.history.canUndo ?? null, !1), Ie = n(() => y.value?.history.canRedo ?? null, !1), I = {
|
|
134
|
+
canUndo: i(() => O.value ? F.canUndo.value : Fe.value),
|
|
135
|
+
canRedo: i(() => O.value ? F.canRedo.value : Ie.value),
|
|
136
|
+
undo: () => O.value ? F.undo() : y.value?.history.undo(),
|
|
137
|
+
redo: () => O.value ? F.redo() : y.value?.history.redo(),
|
|
138
|
+
clear: () => O.value ? F.clear() : y.value?.history.clear(),
|
|
137
139
|
batch: (e) => {
|
|
138
|
-
|
|
140
|
+
O.value ? F.batch(e) : y.value ? y.value.history.batch(e) : e();
|
|
139
141
|
},
|
|
140
|
-
track: (e) =>
|
|
141
|
-
react: (e) =>
|
|
142
|
+
track: (e) => O.value ? F.track(e) : y.value?.history.track(e) ?? A,
|
|
143
|
+
react: (e) => O.value ? F.react(e) : y.value?.history.react(e) ?? A
|
|
142
144
|
};
|
|
143
|
-
l(
|
|
145
|
+
l(_, (e, t, n) => {
|
|
144
146
|
if (!e) return;
|
|
145
|
-
let r =
|
|
146
|
-
canUndo:
|
|
147
|
-
canRedo:
|
|
148
|
-
undo:
|
|
149
|
-
redo:
|
|
150
|
-
})), i =
|
|
147
|
+
let r = _e(e, () => ({
|
|
148
|
+
canUndo: I.canUndo.value,
|
|
149
|
+
canRedo: I.canRedo.value,
|
|
150
|
+
undo: I.undo,
|
|
151
|
+
redo: I.redo
|
|
152
|
+
})), i = Ce(e, () => e.querySelector("[data-ink-scroll]")), a = ge(e, () => y.value);
|
|
151
153
|
e.addEventListener("keydown", W), n(() => {
|
|
152
154
|
r(), i(), a(), e.removeEventListener("keydown", W);
|
|
153
155
|
});
|
|
154
156
|
}, { immediate: !0 });
|
|
155
|
-
let
|
|
156
|
-
l(
|
|
157
|
-
let
|
|
158
|
-
l(
|
|
159
|
-
let
|
|
160
|
-
l(
|
|
161
|
-
let H = c(null), U = c(null);
|
|
162
|
-
function
|
|
163
|
-
let e =
|
|
164
|
-
document:
|
|
165
|
-
viewport: () =>
|
|
157
|
+
let L = f(null);
|
|
158
|
+
l(y, (e) => L.set(e), { flush: "sync" });
|
|
159
|
+
let R = c(null), z = f(null);
|
|
160
|
+
l(R, (e) => z.set(e), { flush: "sync" });
|
|
161
|
+
let B = f(null);
|
|
162
|
+
l(D, (e) => B.set(e), { flush: "sync" });
|
|
163
|
+
let V = m.storage ?? ue(), H = c(null), U = c(null);
|
|
164
|
+
function Le() {
|
|
165
|
+
let e = ye({
|
|
166
|
+
document: d(L),
|
|
167
|
+
viewport: () => C.value
|
|
166
168
|
});
|
|
167
|
-
U.value = e, H.value =
|
|
168
|
-
plugins:
|
|
169
|
-
document:
|
|
170
|
-
history: () =>
|
|
171
|
-
activated:
|
|
169
|
+
U.value = e, H.value = ve({
|
|
170
|
+
plugins: m.plugins ?? [],
|
|
171
|
+
document: d(L),
|
|
172
|
+
history: () => I,
|
|
173
|
+
activated: d(B),
|
|
172
174
|
setActivated: (e) => {
|
|
173
|
-
(e === null ||
|
|
175
|
+
(e === null || y.value?.annotations.get(e)) && k(e);
|
|
174
176
|
},
|
|
175
|
-
root:
|
|
176
|
-
decorate: () =>
|
|
177
|
-
viewport: () =>
|
|
178
|
-
search:
|
|
177
|
+
root: d(z),
|
|
178
|
+
decorate: () => m.decorateAnnotation,
|
|
179
|
+
viewport: () => C.value,
|
|
180
|
+
search: De(e),
|
|
181
|
+
storage: V
|
|
179
182
|
});
|
|
180
183
|
}
|
|
181
184
|
function W(e) {
|
|
182
185
|
let t = U.value, n = e.currentTarget;
|
|
183
|
-
t && n instanceof HTMLElement &&
|
|
186
|
+
t && n instanceof HTMLElement && Se(e, t, () => we(n));
|
|
184
187
|
}
|
|
185
188
|
let G = c(null), K;
|
|
186
|
-
l(
|
|
189
|
+
l(y, (e) => {
|
|
187
190
|
if (!e) {
|
|
188
191
|
G.value = null, K = void 0;
|
|
189
192
|
return;
|
|
190
193
|
}
|
|
191
|
-
let t =
|
|
194
|
+
let t = Te({
|
|
192
195
|
store: e.annotations,
|
|
193
|
-
history: { batch: (e) =>
|
|
194
|
-
tools: [...
|
|
195
|
-
tool:
|
|
196
|
+
history: { batch: (e) => I.batch(e) },
|
|
197
|
+
tools: [...m.tools ?? [], ...H.value?.tools ?? []],
|
|
198
|
+
tool: E.value
|
|
196
199
|
});
|
|
197
200
|
K = (e) => t.setTool(e), G.value = t.toolStyle;
|
|
198
201
|
}, {
|
|
199
202
|
immediate: !0,
|
|
200
203
|
flush: "sync"
|
|
201
|
-
}), l(
|
|
202
|
-
|
|
204
|
+
}), l(E, (e) => K?.(e)), ne(() => {
|
|
205
|
+
v();
|
|
203
206
|
try {
|
|
204
|
-
|
|
207
|
+
Le();
|
|
205
208
|
} finally {
|
|
206
|
-
q.value = !0,
|
|
209
|
+
q.value = !0, P();
|
|
207
210
|
}
|
|
208
|
-
}),
|
|
209
|
-
e &&
|
|
210
|
-
}), l(() =>
|
|
211
|
-
e &&
|
|
211
|
+
}), ie(v), l([() => Pe(m.src), () => m.password], () => void P()), l(() => m.annotations, (e) => {
|
|
212
|
+
e && y.value?.annotations.mode === "controlled" && y.value.annotations.setControlledValue(e);
|
|
213
|
+
}), l(() => m.fields, (e) => {
|
|
214
|
+
e && y.value?.form.setControlledValue(e);
|
|
212
215
|
});
|
|
213
|
-
let q = s(!1), J = c(null), Y = i(() => t(
|
|
216
|
+
let q = s(!1), J = c(null), Y = i(() => t(m.tools, H.value, J.value)), X = (e) => !q.value || Y.value.includes(e), Z = (e) => console.error(Ee(e, Y.value));
|
|
214
217
|
function Q(e) {
|
|
215
|
-
Z(e),
|
|
218
|
+
Z(e), E.value = "select-text", h("update:tool", "select-text");
|
|
216
219
|
}
|
|
217
|
-
l(() =>
|
|
218
|
-
e && (X(e) ?
|
|
220
|
+
l(() => m.tool, (e) => {
|
|
221
|
+
e && (X(e) ? E.value = e : Q(e));
|
|
219
222
|
}), l([q, Y], () => {
|
|
220
|
-
X(
|
|
223
|
+
X(E.value) || Q(E.value);
|
|
221
224
|
});
|
|
222
|
-
function
|
|
225
|
+
function Re(e) {
|
|
223
226
|
if (!X(e)) {
|
|
224
227
|
Z(e);
|
|
225
228
|
return;
|
|
226
229
|
}
|
|
227
|
-
let t =
|
|
228
|
-
|
|
230
|
+
let t = w.value;
|
|
231
|
+
E.value === e && t?.active.get() === e && t.set(e), E.value = e, h("update:tool", e);
|
|
229
232
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}),
|
|
233
|
+
te(() => {
|
|
234
|
+
j++, N();
|
|
235
|
+
}), re(() => {
|
|
233
236
|
H.value?.destroy(), H.value = null, U.value?.destroy(), U.value = null;
|
|
234
237
|
});
|
|
235
|
-
let $ = i(() =>
|
|
238
|
+
let ze = fe(V), $ = i(() => de(m.signatures ?? ze));
|
|
236
239
|
l($, (e) => void e.refresh(), { immediate: !0 });
|
|
237
|
-
let
|
|
240
|
+
let Be = be();
|
|
238
241
|
return e({
|
|
239
|
-
assets: i(() =>
|
|
240
|
-
document:
|
|
241
|
-
status:
|
|
242
|
-
annotations:
|
|
243
|
-
selection:
|
|
244
|
-
viewport:
|
|
245
|
-
tools:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
242
|
+
assets: i(() => m.assets),
|
|
243
|
+
document: y,
|
|
244
|
+
status: x,
|
|
245
|
+
annotations: S,
|
|
246
|
+
selection: Me,
|
|
247
|
+
viewport: C,
|
|
248
|
+
tools: w,
|
|
249
|
+
navigation: T,
|
|
250
|
+
tool: E,
|
|
251
|
+
setTool: Re,
|
|
252
|
+
hostTools: i(() => m.tools),
|
|
249
253
|
openedToolIds: J,
|
|
250
|
-
decorateAnnotation: i(() =>
|
|
251
|
-
fonts: i(() =>
|
|
252
|
-
toolOptions:
|
|
254
|
+
decorateAnnotation: i(() => m.decorateAnnotation),
|
|
255
|
+
fonts: i(() => m.fonts ?? me),
|
|
256
|
+
toolOptions: Be,
|
|
257
|
+
storage: V,
|
|
253
258
|
signatures: $,
|
|
254
|
-
signatureFonts: i(() =>
|
|
259
|
+
signatureFonts: i(() => m.signatureFonts ?? he),
|
|
255
260
|
toolStyle: G,
|
|
256
|
-
zoomModel: i(() =>
|
|
257
|
-
pageModel: i(() =>
|
|
258
|
-
reportZoom: (e) =>
|
|
259
|
-
reportPage: (e) =>
|
|
260
|
-
activated:
|
|
261
|
-
setActivated:
|
|
261
|
+
zoomModel: i(() => m.zoom),
|
|
262
|
+
pageModel: i(() => m.page),
|
|
263
|
+
reportZoom: (e) => h("update:zoom", e),
|
|
264
|
+
reportPage: (e) => h("update:page", e),
|
|
265
|
+
activated: D,
|
|
266
|
+
setActivated: k,
|
|
262
267
|
pluginHost: H,
|
|
263
268
|
search: U,
|
|
264
|
-
viewportEl:
|
|
265
|
-
history:
|
|
266
|
-
rootEl:
|
|
267
|
-
formHighlight: i(() =>
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
269
|
+
viewportEl: R,
|
|
270
|
+
history: I,
|
|
271
|
+
rootEl: _,
|
|
272
|
+
formHighlight: i(() => m.formHighlight),
|
|
273
|
+
reportAction: (e) => {
|
|
274
|
+
let t = Ae?.vnode.props;
|
|
275
|
+
!t?.onAction && t?.onFormAction ? h("form-action", e) : h("action", e);
|
|
276
|
+
},
|
|
277
|
+
reportError: (e) => h("error", e)
|
|
278
|
+
}), p({
|
|
279
|
+
document: y,
|
|
280
|
+
status: x,
|
|
281
|
+
rootEl: _,
|
|
282
|
+
history: I
|
|
283
|
+
}), (e, t) => (ae(), a(se(Oe), {
|
|
276
284
|
ref_key: "primitive",
|
|
277
|
-
ref:
|
|
278
|
-
"as-child":
|
|
285
|
+
ref: g,
|
|
286
|
+
"as-child": m.asChild,
|
|
279
287
|
as: "div",
|
|
280
288
|
"data-ink-root": "",
|
|
281
|
-
"data-state":
|
|
289
|
+
"data-state": x.value.state
|
|
282
290
|
}, {
|
|
283
|
-
default:
|
|
284
|
-
status:
|
|
285
|
-
document:
|
|
291
|
+
default: le(() => [oe(e.$slots, "default", {
|
|
292
|
+
status: x.value,
|
|
293
|
+
document: y.value
|
|
286
294
|
})]),
|
|
287
295
|
_: 3
|
|
288
296
|
}, 8, ["as-child", "data-state"]));
|
|
289
297
|
}
|
|
290
298
|
});
|
|
291
299
|
//#endregion
|
|
292
|
-
export {
|
|
300
|
+
export { p as default };
|
|
293
301
|
|
|
294
302
|
//# sourceMappingURL=InkRoot.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +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","toolController","internalTool","ref","activated","controlled","fieldsControlled","setActivated","id","noop","identity","src","generation","stopFormErrors","release","doc","open","gen","refHistory","openDocument","cssVariableDefaults","next","change","cause","error","InkError","held","s","early","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","store","stopKeys","attachHistoryKeys","stopFocus","keepHistoryFocus","stopFileKeys","attachFileKeys","onKeydown","onCleanup","hostDocument","writable","viewportEl","hostRoot","hostActivated","pluginHost","search","setUpPlugins","controller","createSearchController","readonly","createPluginHost","viewerSearchOf","root","handleFindKey","pageSelectionText","toolStyle","setStyleTool","watch","tracker","trackToolStyle","onMounted","onUpdated","mounted","openedToolIds","toolIds","registeredToolIds","isRegistered","logUnknownTool","unknownTool","fallBack","t","setTool","tc","onBeforeUnmount","onUnmounted","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","a","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n createMemorySignatureStore,\n createSignatureLibrary,\n InkError,\n openDocument,\n readonly,\n writable,\n} from '@inkbar/core'\nimport {\n attachFileKeys,\n attachHistoryKeys,\n createPluginHost,\n createSearchController,\n createToolOptions,\n handleFindKey,\n pageSelectionText,\n viewerSearchOf,\n cssVariableDefaults,\n FONT_FAMILIES,\n keepHistoryFocus,\n SIGNATURE_FONTS,\n trackToolStyle,\n unknownTool,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onUnmounted,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { registeredToolIds } from '../composables/useRegisteredTool'\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 FieldsChange,\n FieldValues,\n FormAction,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n InkPlugin,\n PluginHost,\n SearchController,\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} 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 /**\n * Pass (with `v-model:fields`) to put the form's field values under the host's control. A\n * commit shows at once and is reported after; the host's push wins. The mode is fixed when\n * a document opens, as for `annotations`.\n */\n fields?: FieldValues | undefined\n /** Tints fillable form fields. Default true. A change applies to the open document in place. */\n formHighlight?: boolean | undefined\n tool?: ToolId | undefined\n /**\n * The creation tools, such as `allTools()` or a pick of the tool factories. `select-text`\n * and `select` are always present; a tool with either id replaces it. They are read when a\n * document opens: a tool added later is usable from the next open, one removed stops at\n * once. When the active tool goes, the viewer switches to `select-text` and emits\n * `update:tool`. A controlled `tool` naming a missing tool is reported back as\n * `select-text` and is not applied again when the tool appears later. Each mounted control\n * for a missing tool logs its own `UnknownTool`.\n */\n tools?: Tool[] | undefined\n /**\n * Plugins, set up once when the root is created; a later change to this prop is not\n * applied. Their tools join `tools`, their decoration and page layers apply to every\n * document, and their commands are placed with `InkCommand` or `useCommand`.\n */\n plugins?: InkPlugin[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where saved signatures live. Default: memory, gone on reload.\n * `createLocalSignatureStore` keeps them in the browser; a host can keep them anywhere.\n * A new store takes effect at once, for the menus and the `signature` tool alike.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | 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 fields: undefined,\n formHighlight: undefined,\n tool: undefined,\n tools: undefined,\n plugins: undefined,\n decorateAnnotation: undefined,\n fonts: undefined,\n signatures: undefined,\n signatureFonts: 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 /** Committed field values, in full, with what changed them. */\n 'update:fields': [next: FieldValues, change: FieldsChange]\n /** The form asked to submit, open a link, send mail, print or prompt. Inkbar does none. */\n 'form-action': [action: FormAction]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n /**\n * Opening failed, or later a form script failed or a signature field refused its signing.\n * An error from while the document opened comes after `ready`.\n */\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 toolController = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\nconst fieldsControlled = computed(() => props.fields !== undefined)\n\nfunction setActivated(id: string | null): void {\n activated.value = id\n if (id) emit('activate', id)\n}\n\nconst noop = () => {}\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\nlet stopFormErrors: () => void = noop\nfunction release(): void {\n stopFormErrors()\n stopFormErrors = noop\n // Cleared first, so the plugins close their stores while the document is still alive.\n const doc = document.value\n document.value = null\n doc?.destroy()\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 fields: fieldsControlled.value\n ? {\n mode: 'controlled',\n initial: props.fields ?? {},\n onChange: (next, change) => emit('update:fields', next, change),\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 // The same for the fields; a document whose fields opened uncontrolled ignores the push.\n if (props.fields !== undefined) doc.form.setControlledValue(props.fields)\n // A form script that fails leaves the form fillable; the failure goes to `error`. Subscribed\n // before anyone hears of the document, so the form replays the errors from while it opened\n // here, not to a listener added in `ready`; they are held until `ready` has gone out.\n let held: InkError[] | undefined = []\n stopFormErrors = doc.form.on('error', (e) => {\n if (held) held.push(e)\n else emit('error', e)\n })\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 const early = held\n held = undefined\n if (gen === generation) for (const e of early) emit('error', e)\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 store: () =>\n document.value?.annotations.mode === 'controlled' ? document.value.annotations : null,\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 track: (store) =>\n controlled.value\n ? refHistory.track(store)\n : (document.value?.history.track(store) ?? noop),\n react: (fn) =>\n controlled.value ? refHistory.react(fn) : (document.value?.history.react(fn) ?? noop),\n}\n\n// The undo and redo keys anywhere in the root do what InkUndo and InkRedo do. When either\n// button undoes or redoes the last step and disables itself, focus goes back to the document.\n// The find key listens here too.\nwatch(\n rootEl,\n (el, _prev, onCleanup) => {\n if (!el) return\n const stopKeys = attachHistoryKeys(el, () => ({\n canUndo: inkHistory.canUndo.value,\n canRedo: inkHistory.canRedo.value,\n undo: inkHistory.undo,\n redo: inkHistory.redo,\n }))\n const stopFocus = keepHistoryFocus(el, () =>\n el.querySelector<HTMLElement>('[data-ink-scroll]')\n )\n // Ctrl or Cmd+P prints and +S downloads, as InkPrintButton and InkDownloadButton do.\n const stopFileKeys = attachFileKeys(el, () => document.value)\n // Not a template listener: Vue leaves those on the element when it unmounts.\n el.addEventListener('keydown', onKeydown)\n onCleanup(() => {\n stopKeys()\n stopFocus()\n stopFileKeys()\n el.removeEventListener('keydown', onKeydown)\n })\n },\n { immediate: true }\n)\n\n/*\n * One plugin host for the root's life, built once mounted so that no `setup` runs on the\n * server, where nothing would clean it up. Until then `pluginHost` is null, and InkCommand\n * renders its command disabled. The host follows `hostDocument`, which is set after `document`\n * (a sync watch): when the host reads `inkHistory` for a new document, it is that document's\n * history.\n */\nconst hostDocument = writable<InkDocument | null>(null)\nwatch(document, (doc) => hostDocument.set(doc), { flush: 'sync' })\nconst viewportEl = shallowRef<HTMLElement | null>(null)\nconst hostRoot = writable<HTMLElement | null>(null)\nwatch(viewportEl, (el) => hostRoot.set(el), { flush: 'sync' })\nconst hostActivated = writable<string | null>(null)\nwatch(activated, (id) => hostActivated.set(id), { flush: 'sync' })\nconst pluginHost = shallowRef<PluginHost | null>(null)\n/** One search controller for the root's life, built with the plugin host that shares it. */\nconst search = shallowRef<SearchController | null>(null)\nfunction setUpPlugins(): void {\n const controller = createSearchController({\n document: readonly(hostDocument),\n viewport: () => viewport.value,\n })\n search.value = controller\n pluginHost.value = createPluginHost({\n plugins: props.plugins ?? [],\n document: readonly(hostDocument),\n history: () => inkHistory,\n activated: readonly(hostActivated),\n // As in `createViewer`: an id not in the open document is ignored.\n setActivated: (id) => {\n if (id === null || document.value?.annotations.get(id)) setActivated(id)\n },\n root: readonly(hostRoot),\n decorate: () => props.decorateAnnotation,\n viewport: () => viewport.value,\n search: viewerSearchOf(controller),\n })\n}\n\n/** Ctrl/Cmd+F while focus is in the root and a find bar is mounted; else the browser's. */\nfunction onKeydown(e: KeyboardEvent): void {\n const controller = search.value\n const root = e.currentTarget\n if (controller && root instanceof HTMLElement)\n handleFindKey(e, controller, () => pageSelectionText(root))\n}\n\n/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n // The plugins' tools too, so a plugin tool's style group applies (the host is set by now:\n // it is built on mount, before the first document opens).\n tools: [...(props.tools ?? []), ...(pluginHost.value?.tools ?? [])],\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\n\n// Plugins and the document on the client only: on the server InkRoot renders its empty slot.\n// The plugins first, so the first document opens with their stores and reactions.\nonMounted(() => {\n syncRootEl()\n // A plugin whose setup throws still leaves the document to open; the error then goes to\n // Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`).\n try {\n setUpPlugins()\n } finally {\n mounted.value = true\n void open()\n }\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.fields,\n (next) => {\n if (next) document.value?.form.setControlledValue(next)\n }\n)\n\n/*\n * The tools are known once the plugins are set up on mount. A tool id nobody registered is\n * logged as `UnknownTool`; as the active tool, from a `tool` prop or because it left `tools`,\n * it falls back to `select-text`, reported through `update:tool`. A controlled `tool` that\n * stays on the missing id is not applied again.\n */\nconst mounted = ref(false)\n/** The ids of the tools the current viewer was built with; InkViewport sets them. */\nconst openedToolIds = shallowRef<readonly ToolId[] | null>(null)\nconst toolIds = computed(() =>\n registeredToolIds(props.tools, pluginHost.value, openedToolIds.value)\n)\nconst isRegistered = (id: ToolId): boolean => !mounted.value || toolIds.value.includes(id)\nconst logUnknownTool = (id: ToolId): void => console.error(unknownTool(id, toolIds.value))\n\nfunction fallBack(id: ToolId): void {\n logUnknownTool(id)\n internalTool.value = 'select-text'\n emit('update:tool', 'select-text')\n}\n\nwatch(\n () => props.tool,\n (t) => {\n if (!t) return\n if (isRegistered(t)) internalTool.value = t\n else fallBack(t)\n }\n)\nwatch([mounted, toolIds], () => {\n if (!isRegistered(internalTool.value)) fallBack(internalTool.value)\n})\n\nfunction setTool(id: ToolId): void {\n // As the tool controller does: a missing tool is logged and nothing changes.\n if (!isRegistered(id)) {\n logUnknownTool(id)\n return\n }\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\n// After the children: InkViewport's engine, and the plugin layers with it, are gone by now, as\n// in `createViewer`, so no layer `destroy` runs after the plugins' cleanups.\nonUnmounted(() => {\n pluginHost.value?.destroy()\n pluginHost.value = null\n search.value?.destroy()\n search.value = null\n})\n\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? createMemorySignatureStore())\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n openedToolIds,\n decorateAnnotation: computed(() => props.decorateAnnotation),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\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,\n pluginHost,\n search,\n viewportEl,\n history: inkHistory,\n rootEl,\n formHighlight: computed(() => props.formHighlight),\n reportFormAction: (a) => emit('form-action', a),\n reportError: (e) => emit('error', e),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEA,IAAMQ,IAAQC,GAmFRC,IAAOH,GAsBPI,IAAYC,GAAiC,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,KAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,GAAe,KAAK,GACzEI,KAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,KAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAeC,EAAYpB,EAAM,QAAQ,aAAa,GACt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;GAClD;GACA;GACA,gBAAgB1F,QAAed,EAAM,kBAAkByG,EAAe;GACtE;GACA,WAAW3F,QAAed,EAAM,IAAI;GACpC,WAAWc,QAAed,EAAM,IAAI;GACpC,aAAa,MAAME,EAAK,eAAewG,CAAC;GACxC,aAAa,MAAMxG,EAAK,eAAeyG,CAAC;GACxC;GACA;GACA;GACA;GACA;GACA,SAASzD;GACT;GACA,eAAepC,QAAed,EAAM,aAAa;GACjD,mBAAmB,MAAME,EAAK,eAAe0G,CAAC;GAC9C,cAAc,MAAM1G,EAAK,SAAS,CAAC;EACrC,CAAC,GAIDJ,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAASoD;EAAW,CAAC,cAI5D1D,GAAA,GAAAC,EAQYC,GAAAsH,EAAA,GAAA;GAPN,SAAA;GAAJ,KAAI7G;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,QAA8C,CAA9CC,GAA8CuH,EAAA,QAAA,WAAA;IAAvC,QAAQtG,EAAA;IAAS,UAAUJ,EAAA"}
|
|
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","instance","getCurrentInstance","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","toolController","navigation","internalTool","ref","activated","controlled","fieldsControlled","setActivated","id","noop","identity","src","generation","stopFormErrors","release","doc","open","gen","refHistory","openDocument","cssVariableDefaults","next","change","cause","error","InkError","held","s","early","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","store","stopKeys","attachHistoryKeys","stopFocus","keepHistoryFocus","stopFileKeys","attachFileKeys","onKeydown","onCleanup","hostDocument","writable","viewportEl","hostRoot","hostActivated","storage","createMemoryStorage","pluginHost","search","setUpPlugins","controller","createSearchController","readonly","createPluginHost","viewerSearchOf","root","handleFindKey","pageSelectionText","toolStyle","setStyleTool","watch","tracker","trackToolStyle","onMounted","onUpdated","mounted","openedToolIds","toolIds","registeredToolIds","isRegistered","logUnknownTool","unknownTool","fallBack","t","setTool","tc","onBeforeUnmount","onUnmounted","storageSignatures","createStorageSignatureStore","signatures","createSignatureLibrary","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","listeners","a","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n createMemoryStorage,\n createSignatureLibrary,\n createStorageSignatureStore,\n InkError,\n openDocument,\n readonly,\n writable,\n} from '@inkbar/core'\nimport {\n attachFileKeys,\n attachHistoryKeys,\n createPluginHost,\n createSearchController,\n createToolOptions,\n handleFindKey,\n pageSelectionText,\n viewerSearchOf,\n cssVariableDefaults,\n FONT_FAMILIES,\n keepHistoryFocus,\n SIGNATURE_FONTS,\n trackToolStyle,\n unknownTool,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n getCurrentInstance,\n onBeforeUnmount,\n onUnmounted,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { registeredToolIds } from '../composables/useRegisteredTool'\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 FieldsChange,\n FieldValues,\n ViewerAction,\n InkDocument,\n InkStorage,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n InkPlugin,\n Navigation,\n PluginHost,\n SearchController,\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} 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 /**\n * Pass (with `v-model:fields`) to put the form's field values under the host's control. A\n * commit shows at once and is reported after; the host's push wins. The mode is fixed when\n * a document opens, as for `annotations`.\n */\n fields?: FieldValues | undefined\n /** Tints fillable form fields. Default true. A change applies to the open document in place. */\n formHighlight?: boolean | undefined\n tool?: ToolId | undefined\n /**\n * The creation tools, such as `allTools()` or a pick of the tool factories. `select-text`\n * and `select` are always present; a tool with either id replaces it. They are read when a\n * document opens: a tool added later is usable from the next open, one removed stops at\n * once. When the active tool goes, the viewer switches to `select-text` and emits\n * `update:tool`. A controlled `tool` naming a missing tool is reported back as\n * `select-text` and is not applied again when the tool appears later. Each mounted control\n * for a missing tool logs its own `UnknownTool`.\n */\n tools?: Tool[] | undefined\n /**\n * Plugins, set up once when the root is created; a later change to this prop is not\n * applied. Their tools join `tools`, their decoration and page layers apply to every\n * document, and their commands are placed with `InkCommand` or `useCommand`.\n */\n plugins?: InkPlugin[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where the viewer keeps what lasts between visits: saved signatures, each `InkSidebar`'s\n * width and the plugins' settings. Default: memory, gone on reload. `createLocalStorage`\n * keeps them in the browser; a host can keep them anywhere. Read once, when the root is\n * created.\n */\n storage?: InkStorage | undefined\n /**\n * Where saved signatures live, in place of `storage`. A new store takes effect at once, for\n * the menus and the `signature` tool alike.\n * @deprecated Pass `storage`; signatures are kept in it under `signatures`. Removed in 0.13.0.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | 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 fields: undefined,\n formHighlight: undefined,\n tool: undefined,\n tools: undefined,\n plugins: undefined,\n decorateAnnotation: undefined,\n fonts: undefined,\n storage: undefined,\n signatures: undefined,\n signatureFonts: 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 /** Committed field values, in full, with what changed them. */\n 'update:fields': [next: FieldValues, change: FieldsChange]\n /**\n * The viewer asked the host to submit a form, open a link, send mail, print or prompt. Inkbar\n * does none of these.\n */\n action: [action: ViewerAction]\n /** @deprecated Use `action`. Removed in 0.13.0. Not emitted when `action` has a listener. */\n 'form-action': [action: ViewerAction]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n /**\n * Opening failed, or later a form script failed or a signature field refused its signing.\n * An error from while the document opened comes after `ready`.\n */\n error: [error: InkError]\n activate: [id: string]\n}>()\nconst instance = getCurrentInstance()\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 toolController = shallowRef<ToolController | null>(null)\nconst navigation = shallowRef<Navigation | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\nconst fieldsControlled = computed(() => props.fields !== undefined)\n\nfunction setActivated(id: string | null): void {\n activated.value = id\n if (id) emit('activate', id)\n}\n\nconst noop = () => {}\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\nlet stopFormErrors: () => void = noop\nfunction release(): void {\n stopFormErrors()\n stopFormErrors = noop\n // Cleared first, so the plugins close their stores while the document is still alive.\n const doc = document.value\n document.value = null\n doc?.destroy()\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 fields: fieldsControlled.value\n ? {\n mode: 'controlled',\n initial: props.fields ?? {},\n onChange: (next, change) => emit('update:fields', next, change),\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 // The same for the fields; a document whose fields opened uncontrolled ignores the push.\n if (props.fields !== undefined) doc.form.setControlledValue(props.fields)\n // A form script that fails leaves the form fillable; the failure goes to `error`. Subscribed\n // before anyone hears of the document, so the form replays the errors from while it opened\n // here, not to a listener added in `ready`; they are held until `ready` has gone out.\n let held: InkError[] | undefined = []\n stopFormErrors = doc.form.on('error', (e) => {\n if (held) held.push(e)\n else emit('error', e)\n })\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 const early = held\n held = undefined\n if (gen === generation) for (const e of early) emit('error', e)\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 store: () =>\n document.value?.annotations.mode === 'controlled' ? document.value.annotations : null,\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 track: (store) =>\n controlled.value\n ? refHistory.track(store)\n : (document.value?.history.track(store) ?? noop),\n react: (fn) =>\n controlled.value ? refHistory.react(fn) : (document.value?.history.react(fn) ?? noop),\n}\n\n// The undo and redo keys anywhere in the root do what InkUndo and InkRedo do. When either\n// button undoes or redoes the last step and disables itself, focus goes back to the document.\n// The find key listens here too.\nwatch(\n rootEl,\n (el, _prev, onCleanup) => {\n if (!el) return\n const stopKeys = attachHistoryKeys(el, () => ({\n canUndo: inkHistory.canUndo.value,\n canRedo: inkHistory.canRedo.value,\n undo: inkHistory.undo,\n redo: inkHistory.redo,\n }))\n const stopFocus = keepHistoryFocus(el, () =>\n el.querySelector<HTMLElement>('[data-ink-scroll]')\n )\n // Ctrl or Cmd+P prints and +S downloads, as InkPrintButton and InkDownloadButton do.\n const stopFileKeys = attachFileKeys(el, () => document.value)\n // Not a template listener: Vue leaves those on the element when it unmounts.\n el.addEventListener('keydown', onKeydown)\n onCleanup(() => {\n stopKeys()\n stopFocus()\n stopFileKeys()\n el.removeEventListener('keydown', onKeydown)\n })\n },\n { immediate: true }\n)\n\n/*\n * One plugin host for the root's life, built once mounted so that no `setup` runs on the\n * server, where nothing would clean it up. Until then `pluginHost` is null, and InkCommand\n * renders its command disabled. The host follows `hostDocument`, which is set after `document`\n * (a sync watch): when the host reads `inkHistory` for a new document, it is that document's\n * history.\n */\nconst hostDocument = writable<InkDocument | null>(null)\nwatch(document, (doc) => hostDocument.set(doc), { flush: 'sync' })\nconst viewportEl = shallowRef<HTMLElement | null>(null)\nconst hostRoot = writable<HTMLElement | null>(null)\nwatch(viewportEl, (el) => hostRoot.set(el), { flush: 'sync' })\nconst hostActivated = writable<string | null>(null)\nwatch(activated, (id) => hostActivated.set(id), { flush: 'sync' })\n/** Read once, like `plugins`: the sidebars and the plugins load from it as they are created. */\nconst storage = props.storage ?? createMemoryStorage()\nconst pluginHost = shallowRef<PluginHost | null>(null)\n/** One search controller for the root's life, built with the plugin host that shares it. */\nconst search = shallowRef<SearchController | null>(null)\nfunction setUpPlugins(): void {\n const controller = createSearchController({\n document: readonly(hostDocument),\n viewport: () => viewport.value,\n })\n search.value = controller\n pluginHost.value = createPluginHost({\n plugins: props.plugins ?? [],\n document: readonly(hostDocument),\n history: () => inkHistory,\n activated: readonly(hostActivated),\n // As in `createViewer`: an id not in the open document is ignored.\n setActivated: (id) => {\n if (id === null || document.value?.annotations.get(id)) setActivated(id)\n },\n root: readonly(hostRoot),\n decorate: () => props.decorateAnnotation,\n viewport: () => viewport.value,\n search: viewerSearchOf(controller),\n storage,\n })\n}\n\n/** Ctrl/Cmd+F while focus is in the root and a find bar is mounted; else the browser's. */\nfunction onKeydown(e: KeyboardEvent): void {\n const controller = search.value\n const root = e.currentTarget\n if (controller && root instanceof HTMLElement)\n handleFindKey(e, controller, () => pageSelectionText(root))\n}\n\n/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n // The plugins' tools too, so a plugin tool's style group applies (the host is set by now:\n // it is built on mount, before the first document opens).\n tools: [...(props.tools ?? []), ...(pluginHost.value?.tools ?? [])],\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\n\n// Plugins and the document on the client only: on the server InkRoot renders its empty slot.\n// The plugins first, so the first document opens with their stores and reactions.\nonMounted(() => {\n syncRootEl()\n // A plugin whose setup throws still leaves the document to open; the error then goes to\n // Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`).\n try {\n setUpPlugins()\n } finally {\n mounted.value = true\n void open()\n }\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.fields,\n (next) => {\n if (next) document.value?.form.setControlledValue(next)\n }\n)\n\n/*\n * The tools are known once the plugins are set up on mount. A tool id nobody registered is\n * logged as `UnknownTool`; as the active tool, from a `tool` prop or because it left `tools`,\n * it falls back to `select-text`, reported through `update:tool`. A controlled `tool` that\n * stays on the missing id is not applied again.\n */\nconst mounted = ref(false)\n/** The ids of the tools the current viewer was built with; InkViewport sets them. */\nconst openedToolIds = shallowRef<readonly ToolId[] | null>(null)\nconst toolIds = computed(() =>\n registeredToolIds(props.tools, pluginHost.value, openedToolIds.value)\n)\nconst isRegistered = (id: ToolId): boolean => !mounted.value || toolIds.value.includes(id)\nconst logUnknownTool = (id: ToolId): void => console.error(unknownTool(id, toolIds.value))\n\nfunction fallBack(id: ToolId): void {\n logUnknownTool(id)\n internalTool.value = 'select-text'\n emit('update:tool', 'select-text')\n}\n\nwatch(\n () => props.tool,\n (t) => {\n if (!t) return\n if (isRegistered(t)) internalTool.value = t\n else fallBack(t)\n }\n)\nwatch([mounted, toolIds], () => {\n if (!isRegistered(internalTool.value)) fallBack(internalTool.value)\n})\n\nfunction setTool(id: ToolId): void {\n // As the tool controller does: a missing tool is logged and nothing changes.\n if (!isRegistered(id)) {\n logUnknownTool(id)\n return\n }\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\n// After the children: InkViewport's engine, and the plugin layers with it, are gone by now, as\n// in `createViewer`, so no layer `destroy` runs after the plugins' cleanups.\nonUnmounted(() => {\n pluginHost.value?.destroy()\n pluginHost.value = null\n search.value?.destroy()\n search.value = null\n})\n\nconst storageSignatures = createStorageSignatureStore(storage)\n// The deprecated `signatures` wins when both are given.\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? storageSignatures)\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n navigation,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n openedToolIds,\n decorateAnnotation: computed(() => props.decorateAnnotation),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n storage,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\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,\n pluginHost,\n search,\n viewportEl,\n history: inkHistory,\n rootEl,\n formHighlight: computed(() => props.formHighlight),\n reportAction: (a) => {\n // Emits cannot say who listens, so ask the vnode: `@action` wins over `@form-action`.\n const listeners = instance?.vnode.props\n if (!listeners?.onAction && listeners?.onFormAction) emit('form-action', a)\n else emit('action', a)\n },\n reportError: (e) => emit('error', e),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwEA,IAAMQ,IAAQC,GA2FRC,IAAOH,IAuBPI,KAAWC,GAAmB,GAK9BC,IAAYC,GAAiC,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,KAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,GAAe,KAAK,GACzEI,IAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,KAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAab,EAA8B,IAAI,GAC/Cc,IAAeC,EAAYvB,EAAM,QAAQ,aAAa,GACtDwB,IAAYD,EAAmB,IAAI,GAEnCE,IAAaT,QAAehB,EAAM,gBAAgB,KAAA,CAAS,GAC3D0B,KAAmBV,QAAehB,EAAM,WAAW,KAAA,CAAS;EAElE,SAAS2B,EAAa,GAAyB;GAE7C,AADA,EAAU,QAAQC,GACdA,KAAI1B,EAAK,YAAY0B,CAAE;EAC7B;EAEA,IAAMC,UAAa,CAAC;EAGpB,SAASC,GAAS,GAAqC;GAIrD,OAHIC,MAAQ,OAAa,OACrB,OAAOA,KAAQ,WAAiBA,IAChC,SAASA,IAAYA,EAAI,MACtBA;EACT;EAOA,IAAIC,IAAa,GACbC,IAA6BJ;EACjC,SAASK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