@pi-outpost/embed 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/dist/PdfViewer-BBmVq73v.cjs +1 -0
- package/dist/{PdfViewer-Bgsp04sQ.js → PdfViewer-BHP5lV-o.js} +50 -49
- package/dist/pi-outpost-embed.cjs +53 -53
- package/dist/pi-outpost-embed.js +7027 -6683
- package/dist/{workspacePath-BntMOlpq.js → workspacePath-BScUv3M_.js} +3 -3
- package/dist/workspacePath-kqTwbSP1.cjs +1 -0
- package/package.json +1 -1
- package/dist/PdfViewer-Brg-USBu.cjs +0 -1
- package/dist/workspacePath-CueaT8yG.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e } from "./workspacePath-
|
|
1
|
+
import { a as e } from "./workspacePath-BScUv3M_.js";
|
|
2
2
|
import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
|
|
3
3
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
4
|
//#region ../ui/src/components/PdfViewer.tsx
|
|
@@ -23,19 +23,19 @@ function u(e) {
|
|
|
23
23
|
case "unreadable": return "This file could not be read as a PDF.";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
async function d(t, n, r) {
|
|
27
|
-
let
|
|
28
|
-
if (!
|
|
29
|
-
if (
|
|
30
|
-
let e = await
|
|
26
|
+
async function d(t, n, r, i) {
|
|
27
|
+
let a = await fetch(e(t, n, null, i), { headers: r ? { Authorization: `Bearer ${r}` } : {} });
|
|
28
|
+
if (!a.ok) {
|
|
29
|
+
if (a.status === 413) {
|
|
30
|
+
let e = await a.json().catch(() => ({}));
|
|
31
31
|
throw {
|
|
32
32
|
kind: "too-large",
|
|
33
33
|
...typeof e.limit == "number" ? { limitBytes: e.limit } : {}
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
throw
|
|
36
|
+
throw a.status === 401 || a.status === 403 ? { kind: "unauthorized" } : a.status === 404 ? { kind: "not-found" } : { kind: "unreadable" };
|
|
37
37
|
}
|
|
38
|
-
return new Uint8Array(await
|
|
38
|
+
return new Uint8Array(await a.arrayBuffer());
|
|
39
39
|
}
|
|
40
40
|
async function f(e) {
|
|
41
41
|
let t = await import("./pdf-DyDm1M1B.js");
|
|
@@ -147,33 +147,33 @@ function _({ doc: e, pageNumber: t, scale: c, baseSize: l, active: u, registerSl
|
|
|
147
147
|
})] }) : null
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
function v({ path: e, serverUrl: a = "", token: l = null,
|
|
151
|
-
let [
|
|
150
|
+
function v({ path: e, serverUrl: a = "", token: l = null, revision: p = 0, onLoaded: m }) {
|
|
151
|
+
let [v, y] = i(null), [b, x] = i(null), [S, C] = i(1), [w, T] = i(2), [E, D] = i(null), O = r(null), k = r(/* @__PURE__ */ new Map());
|
|
152
152
|
n(() => {
|
|
153
153
|
let t = !1, n = null;
|
|
154
|
-
return
|
|
154
|
+
return y(null), x(null), C(1), D(null), (async () => {
|
|
155
155
|
try {
|
|
156
|
-
let { doc: r, task: i } = await f(await d(a, e, l));
|
|
156
|
+
let { doc: r, task: i } = await f(await d(a, e, l, p));
|
|
157
157
|
if (n = i, t) {
|
|
158
158
|
await i.destroy().catch(() => {});
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
try {
|
|
162
162
|
let e = (await r.getPage(1)).getViewport({ scale: 1 });
|
|
163
|
-
t ||
|
|
163
|
+
t || D({
|
|
164
164
|
width: e.width,
|
|
165
165
|
height: e.height
|
|
166
166
|
});
|
|
167
167
|
} catch {
|
|
168
|
-
t ||
|
|
168
|
+
t || D({
|
|
169
169
|
width: 612,
|
|
170
170
|
height: 792
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
if (t) return;
|
|
174
|
-
|
|
174
|
+
y(r), m?.(e);
|
|
175
175
|
} catch (e) {
|
|
176
|
-
t ||
|
|
176
|
+
t || x(h(e) ? e : { kind: "unreadable" });
|
|
177
177
|
}
|
|
178
178
|
})(), () => {
|
|
179
179
|
t = !0, n?.destroy().catch(() => {});
|
|
@@ -181,33 +181,34 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
181
181
|
}, [
|
|
182
182
|
e,
|
|
183
183
|
a,
|
|
184
|
-
l
|
|
184
|
+
l,
|
|
185
|
+
p
|
|
185
186
|
]);
|
|
186
|
-
let
|
|
187
|
-
t === null ?
|
|
187
|
+
let A = v?.numPages ?? 0, j = t((e, t) => {
|
|
188
|
+
t === null ? k.current.delete(e) : k.current.set(e, t);
|
|
188
189
|
}, []);
|
|
189
190
|
n(() => {
|
|
190
|
-
if (
|
|
191
|
-
let e =
|
|
191
|
+
if (v === null || typeof IntersectionObserver > "u") return;
|
|
192
|
+
let e = O.current;
|
|
192
193
|
if (e === null) return;
|
|
193
194
|
let t = new IntersectionObserver((e) => {
|
|
194
195
|
for (let t of e) {
|
|
195
196
|
if (!t.isIntersecting) continue;
|
|
196
197
|
let e = Number(t.target.dataset.page);
|
|
197
|
-
Number.isFinite(e) &&
|
|
198
|
+
Number.isFinite(e) && C(e);
|
|
198
199
|
}
|
|
199
200
|
}, {
|
|
200
201
|
root: e,
|
|
201
202
|
rootMargin: "-45% 0px -45% 0px",
|
|
202
203
|
threshold: 0
|
|
203
204
|
});
|
|
204
|
-
for (let e of
|
|
205
|
+
for (let e of k.current.values()) t.observe(e);
|
|
205
206
|
return () => t.disconnect();
|
|
206
|
-
}, [
|
|
207
|
-
let
|
|
208
|
-
e < 1 || e >
|
|
209
|
-
}, [
|
|
210
|
-
return
|
|
207
|
+
}, [v, A]);
|
|
208
|
+
let M = t((e) => {
|
|
209
|
+
e < 1 || e > A || (C(e), k.current.get(e)?.scrollIntoView({ block: "start" }));
|
|
210
|
+
}, [A]);
|
|
211
|
+
return b === null ? v === null ? /* @__PURE__ */ o("div", {
|
|
211
212
|
className: "flex h-full items-center justify-center p-6",
|
|
212
213
|
children: /* @__PURE__ */ o("p", {
|
|
213
214
|
className: "text-sm text-zinc-500",
|
|
@@ -216,8 +217,8 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
216
217
|
}) : /* @__PURE__ */ s("div", {
|
|
217
218
|
className: "flex h-full flex-col",
|
|
218
219
|
onKeyDown: (e) => {
|
|
219
|
-
if (e.key === "PageDown" || e.key === "ArrowRight")
|
|
220
|
-
else if (e.key === "PageUp" || e.key === "ArrowLeft")
|
|
220
|
+
if (e.key === "PageDown" || e.key === "ArrowRight") M(S + 1);
|
|
221
|
+
else if (e.key === "PageUp" || e.key === "ArrowLeft") M(S - 1);
|
|
221
222
|
else return;
|
|
222
223
|
e.preventDefault();
|
|
223
224
|
},
|
|
@@ -226,8 +227,8 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
226
227
|
children: [
|
|
227
228
|
/* @__PURE__ */ o("button", {
|
|
228
229
|
type: "button",
|
|
229
|
-
onClick: () =>
|
|
230
|
-
disabled:
|
|
230
|
+
onClick: () => M(S - 1),
|
|
231
|
+
disabled: S <= 1,
|
|
231
232
|
"aria-label": "Previous page",
|
|
232
233
|
className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
233
234
|
children: "‹"
|
|
@@ -236,15 +237,15 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
236
237
|
className: "tabular-nums text-zinc-600 dark:text-zinc-400",
|
|
237
238
|
children: [
|
|
238
239
|
"Page ",
|
|
239
|
-
|
|
240
|
+
S,
|
|
240
241
|
" / ",
|
|
241
|
-
|
|
242
|
+
A
|
|
242
243
|
]
|
|
243
244
|
}),
|
|
244
245
|
/* @__PURE__ */ o("button", {
|
|
245
246
|
type: "button",
|
|
246
|
-
onClick: () =>
|
|
247
|
-
disabled:
|
|
247
|
+
onClick: () => M(S + 1),
|
|
248
|
+
disabled: S >= A,
|
|
248
249
|
"aria-label": "Next page",
|
|
249
250
|
className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
250
251
|
children: "›"
|
|
@@ -254,20 +255,20 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
254
255
|
children: [
|
|
255
256
|
/* @__PURE__ */ o("button", {
|
|
256
257
|
type: "button",
|
|
257
|
-
onClick: () =>
|
|
258
|
-
disabled:
|
|
258
|
+
onClick: () => T((e) => Math.max(0, e - 1)),
|
|
259
|
+
disabled: w === 0,
|
|
259
260
|
"aria-label": "Zoom out",
|
|
260
261
|
className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
261
262
|
children: "−"
|
|
262
263
|
}),
|
|
263
264
|
/* @__PURE__ */ s("span", {
|
|
264
265
|
className: "tabular-nums text-zinc-500",
|
|
265
|
-
children: [Math.round(c[
|
|
266
|
+
children: [Math.round(c[w] * 100), "%"]
|
|
266
267
|
}),
|
|
267
268
|
/* @__PURE__ */ o("button", {
|
|
268
269
|
type: "button",
|
|
269
|
-
onClick: () =>
|
|
270
|
-
disabled:
|
|
270
|
+
onClick: () => T((e) => Math.min(c.length - 1, e + 1)),
|
|
271
|
+
disabled: w === c.length - 1,
|
|
271
272
|
"aria-label": "Zoom in",
|
|
272
273
|
className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
|
|
273
274
|
children: "+"
|
|
@@ -276,22 +277,22 @@ function v({ path: e, serverUrl: a = "", token: l = null, onLoaded: p }) {
|
|
|
276
277
|
})
|
|
277
278
|
]
|
|
278
279
|
}), /* @__PURE__ */ o("div", {
|
|
279
|
-
ref:
|
|
280
|
+
ref: O,
|
|
280
281
|
className: "flex-1 overflow-auto bg-zinc-100 p-4 dark:bg-zinc-950",
|
|
281
|
-
children:
|
|
282
|
-
doc:
|
|
282
|
+
children: E !== null && Array.from({ length: A }, (e, t) => t + 1).map((e) => /* @__PURE__ */ o(_, {
|
|
283
|
+
doc: v,
|
|
283
284
|
pageNumber: e,
|
|
284
|
-
scale: c[
|
|
285
|
-
baseSize:
|
|
286
|
-
active: Math.abs(e -
|
|
287
|
-
registerSlot:
|
|
285
|
+
scale: c[w],
|
|
286
|
+
baseSize: E,
|
|
287
|
+
active: Math.abs(e - S) <= g,
|
|
288
|
+
registerSlot: j
|
|
288
289
|
}, e))
|
|
289
290
|
})]
|
|
290
291
|
}) : /* @__PURE__ */ o("div", {
|
|
291
292
|
className: "flex h-full items-center justify-center p-6",
|
|
292
293
|
children: /* @__PURE__ */ o("p", {
|
|
293
294
|
className: "max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400",
|
|
294
|
-
children: u(
|
|
295
|
+
children: u(b)
|
|
295
296
|
})
|
|
296
297
|
});
|
|
297
298
|
}
|