@pi-outpost/embed 0.54.0 → 0.56.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.
Files changed (27) hide show
  1. package/README.md +1 -1
  2. package/dist/{CodeEditor-Dei7wUOV.js → CodeEditor-C2mtBAxz.js} +21 -21
  3. package/dist/{CodeEditor-CIWnYOMo.cjs → CodeEditor-CHKp59kP.cjs} +3 -3
  4. package/dist/{PdfViewer-HG_qT5b4.js → PdfViewer-DOE0n8FV.js} +94 -73
  5. package/dist/{PdfViewer-CCav_nmm.cjs → PdfViewer-SiwxJfzA.cjs} +1 -1
  6. package/dist/{conversationExport-CPhTW6Ko.cjs → conversationExport-CE0UTxEg.cjs} +2 -2
  7. package/dist/{conversationExport-BlW4R5hL.js → conversationExport-DojQkOLk.js} +45 -45
  8. package/dist/conversationHistory-DdjP3rjR.cjs +537 -0
  9. package/dist/{conversationHistory-wmxP-e7h.js → conversationHistory-g6h0_Fjx.js} +21044 -17852
  10. package/dist/{dist-CUml8Wzk.js → dist-B9wvGgxB.js} +1 -1
  11. package/dist/{dist-BB8DIy0-.cjs → dist-BMzIUMhf.cjs} +1 -1
  12. package/dist/{dist-DU0BjKn0.cjs → dist-BawiB8yE.cjs} +1 -1
  13. package/dist/{dist-BXKM-sMu.cjs → dist-BjxwUutQ.cjs} +1 -1
  14. package/dist/{dist-CuX47mx0.js → dist-Bk3hLKgL.js} +1 -1
  15. package/dist/{dist-CqvTKR3J.cjs → dist-Bnsp4Y3i.cjs} +1 -1
  16. package/dist/{dist-0gxsdPHi.cjs → dist-CM2l_BHt.cjs} +1 -1
  17. package/dist/{dist-CDuDYc3h.js → dist-CvxwObne.js} +1 -1
  18. package/dist/{dist-BhRuhsmx.js → dist-DUziszL2.js} +1 -1
  19. package/dist/{dist-DNzYo4it.cjs → dist-F6qtkv2Q.cjs} +1 -1
  20. package/dist/{dist-CV2qXUTt.js → dist-LBUs7dVk.js} +1 -1
  21. package/dist/{dist-Ccs3Mpvk.js → dist-VWDOErn8.js} +1 -1
  22. package/dist/{dist-BAXGE-5E.cjs → dist-kpPXlS4A.cjs} +1 -1
  23. package/dist/{dist-Bt2YslBF.js → dist-nQ2aeIgK.js} +2 -2
  24. package/dist/pi-outpost-embed.cjs +36 -33
  25. package/dist/pi-outpost-embed.js +3328 -2858
  26. package/package.json +1 -1
  27. package/dist/conversationHistory-DVdpMO_m.cjs +0 -424
@@ -193,39 +193,41 @@ function ne({ doc: e, pageNumber: t, scale: n, baseSize: r, active: i, registerS
193
193
  })] }) : null
194
194
  });
195
195
  }
196
- var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l, revision: f = 0, onLoaded: g, findQuery: y = "", onFindStateChange: b }, x) {
197
- let [S, w] = c(null), [T, E] = c(null), [D, O] = c(1), [k, A] = c(2), [re, j] = c(null), M = s(null), N = s(/* @__PURE__ */ new Map()), [P, F] = c(/* @__PURE__ */ new Map()), [I, L] = c(!1), [R, z] = c([]), [B, V] = c(-1), H = s(null), U = s(!1), W = s(y), G = s(/* @__PURE__ */ new Map()), K = s(null), q = s([]), J = s(-1), Y = s(y);
196
+ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l, revision: f = 0, onLoaded: g, findQuery: y = "", onFindStateChange: b, startAt: x }, S) {
197
+ let [w, re] = c(null), [ie, ae] = c(null), [T, E] = c(1), [D, O] = c(2), [k, A] = c(null), oe = s(null), j = s(/* @__PURE__ */ new Map()), [M, N] = c(/* @__PURE__ */ new Map()), [P, F] = c(!1), [I, L] = c([]), [R, z] = c(-1), B = s(null), V = s(!1), [H, U] = c(!1), W = s(y), G = s(x?.page ?? null), K = s(x);
198
+ K.current !== x && (K.current = x, G.current = x?.page ?? null);
199
+ let q = s(/* @__PURE__ */ new Map()), J = s(null), Y = s([]), se = s(-1), ce = s(y);
198
200
  a(() => {
199
- q.current = R;
201
+ Y.current = I;
202
+ }, [I]), a(() => {
203
+ se.current = R;
200
204
  }, [R]), a(() => {
201
- J.current = B;
202
- }, [B]), a(() => {
203
- Y.current = y;
205
+ ce.current = y;
204
206
  }, [y]);
205
207
  let X = i(() => {
206
- K.current?.result.clear(), K.current = null;
208
+ J.current?.result.clear(), J.current = null;
207
209
  }, []), Z = i((e, n) => {
208
210
  X();
209
- let r = t(n, Y.current);
210
- K.current = {
211
+ let r = t(n, ce.current);
212
+ J.current = {
211
213
  page: e.page,
212
214
  result: r
213
215
  };
214
216
  let i = r.matches[e.ordinalOnPage]?.marks ?? [];
215
217
  for (let e of i) e.classList.add("find-match-current");
216
218
  i[0]?.scrollIntoView({ block: "center" });
217
- }, [X]), ie = i((e, t) => {
219
+ }, [X]), le = i((e, t) => {
218
220
  if (t === null) {
219
- G.current.delete(e);
221
+ q.current.delete(e);
220
222
  return;
221
223
  }
222
- G.current.set(e, t);
223
- let n = q.current[J.current];
224
+ q.current.set(e, t);
225
+ let n = Y.current[se.current];
224
226
  n !== void 0 && n.page === e && Z(n, t);
225
227
  }, [Z]);
226
228
  a(() => {
227
229
  let t = !1, i = null;
228
- return w(null), E(null), O(1), j(null), H.current?.cancel(), H.current = null, U.current = !1, F(/* @__PURE__ */ new Map()), L(!1), z([]), V(-1), X(), G.current.clear(), (async () => {
230
+ return re(null), ae(null), E(1), A(null), B.current?.cancel(), B.current = null, V.current = !1, U(!1), N(/* @__PURE__ */ new Map()), F(!1), L([]), z(-1), X(), q.current.clear(), (async () => {
229
231
  try {
230
232
  let { doc: a, task: o } = await ee(await v(n, e, r, f, l));
231
233
  if (i = o, t) {
@@ -234,20 +236,20 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
234
236
  }
235
237
  try {
236
238
  let e = (await a.getPage(1)).getViewport({ scale: 1 });
237
- t || j({
239
+ t || A({
238
240
  width: e.width,
239
241
  height: e.height
240
242
  });
241
243
  } catch {
242
- t || j({
244
+ t || A({
243
245
  width: 612,
244
246
  height: 792
245
247
  });
246
248
  }
247
249
  if (t) return;
248
- w(a), g?.(e);
250
+ re(a), g?.(e);
249
251
  } catch (e) {
250
- t || E(te(e) ? e : { kind: "unreadable" });
252
+ t || ae(te(e) ? e : { kind: "unreadable" });
251
253
  }
252
254
  })(), () => {
253
255
  t = !0, i?.destroy().catch(() => {});
@@ -259,83 +261,102 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
259
261
  l,
260
262
  f
261
263
  ]);
262
- let Q = S?.numPages ?? 0, ae = i((e, t) => {
263
- t === null ? N.current.delete(e) : N.current.set(e, t);
264
+ let Q = w?.numPages ?? 0, ue = i((e, t) => {
265
+ t === null ? j.current.delete(e) : j.current.set(e, t);
264
266
  }, []);
265
267
  a(() => {
266
- if (S === null || y === "" || U.current) return;
267
- U.current = !0, L(!0);
268
- let e = S, t = {
268
+ if (w === null || y === "" || V.current) return;
269
+ V.current = !0, F(!0);
270
+ let e = w, t = {
269
271
  numPages: e.numPages,
270
272
  getPageText: async (t) => {
271
273
  let n = await e.getPage(t);
272
274
  return n.getTextContent === void 0 ? "" : (await n.getTextContent()).items.map((e) => typeof e.str == "string" ? e.str : "").join("");
273
275
  }
274
276
  };
275
- H.current = p(t, D, (e, t) => F((n) => {
277
+ B.current = p(t, G.current ?? T, (e, t) => N((n) => {
276
278
  let r = new Map(n);
277
279
  return r.set(e, t), r;
278
- }), () => L(!1));
279
- }, [S, y]), a(() => () => {
280
- H.current?.cancel(), H.current = null;
281
- }, [S]), a(() => {
282
- let e = m(P, S?.numPages ?? 0, y), t = y !== W.current;
283
- W.current = y, z(e), V((n) => e.length === 0 ? -1 : t || n === -1 ? 0 : Math.min(n, e.length - 1));
280
+ }), () => {
281
+ F(!1), U(!0);
282
+ });
283
+ }, [w, y]), a(() => () => {
284
+ B.current?.cancel(), B.current = null;
285
+ }, [w]), a(() => {
286
+ let e = m(M, w?.numPages ?? 0, y), t = y !== W.current;
287
+ W.current = y, L(e);
288
+ let n = G.current;
289
+ if (n !== null && y !== "") {
290
+ H && (G.current = null);
291
+ let t = e.findIndex((e) => e.page === n);
292
+ if (t !== -1) {
293
+ z(t);
294
+ return;
295
+ }
296
+ if (H) {
297
+ let t = e.findIndex((e) => e.page > n);
298
+ z(e.length === 0 ? -1 : t === -1 ? 0 : t);
299
+ return;
300
+ }
301
+ z(-1);
302
+ } else z((n) => e.length === 0 ? -1 : t || n === -1 ? 0 : Math.min(n, e.length - 1));
284
303
  }, [
285
- P,
304
+ M,
286
305
  y,
287
- S
306
+ w,
307
+ H,
308
+ x
288
309
  ]), a(() => {
289
- if (B === -1 || R.length === 0) {
310
+ if (R === -1 || I.length === 0) {
290
311
  X();
291
312
  return;
292
313
  }
293
- let e = R[B];
294
- if (K.current !== null && K.current.page !== e.page && X(), Math.abs(e.page - D) > C) {
314
+ let e = I[R];
315
+ if (J.current !== null && J.current.page !== e.page && X(), Math.abs(e.page - T) > C) {
295
316
  $(e.page);
296
317
  return;
297
318
  }
298
- let t = G.current.get(e.page);
319
+ let t = q.current.get(e.page);
299
320
  t !== void 0 && Z(e, t);
300
- }, [B, R]), o(x, () => ({
321
+ }, [R, I]), o(S, () => ({
301
322
  findNext() {
302
- q.current.length !== 0 && V((e) => (e + 1) % q.current.length);
323
+ G.current = null, Y.current.length !== 0 && z((e) => (e + 1) % Y.current.length);
303
324
  },
304
325
  findPrevious() {
305
- q.current.length !== 0 && V((e) => (e - 1 + q.current.length) % q.current.length);
326
+ G.current = null, Y.current.length !== 0 && z((e) => (e - 1 + Y.current.length) % Y.current.length);
306
327
  }
307
328
  }), []), a(() => {
308
329
  b?.({
309
- matchCount: R.length,
310
- currentIndex: B,
311
- searching: I
330
+ matchCount: I.length,
331
+ currentIndex: R,
332
+ searching: P
312
333
  });
313
334
  }, [
314
- R.length,
315
- B,
316
- I
335
+ I.length,
336
+ R,
337
+ P
317
338
  ]), a(() => {
318
- if (S === null || typeof IntersectionObserver > "u") return;
319
- let e = M.current;
339
+ if (w === null || typeof IntersectionObserver > "u") return;
340
+ let e = oe.current;
320
341
  if (e === null) return;
321
342
  let t = new IntersectionObserver((e) => {
322
343
  for (let t of e) {
323
344
  if (!t.isIntersecting) continue;
324
345
  let e = Number(t.target.dataset.page);
325
- Number.isFinite(e) && O(e);
346
+ Number.isFinite(e) && E(e);
326
347
  }
327
348
  }, {
328
349
  root: e,
329
350
  rootMargin: "-45% 0px -45% 0px",
330
351
  threshold: 0
331
352
  });
332
- for (let e of N.current.values()) t.observe(e);
353
+ for (let e of j.current.values()) t.observe(e);
333
354
  return () => t.disconnect();
334
- }, [S, Q]);
355
+ }, [w, Q]);
335
356
  let $ = i((e) => {
336
- e < 1 || e > Q || (O(e), N.current.get(e)?.scrollIntoView({ block: "start" }));
357
+ e < 1 || e > Q || (E(e), j.current.get(e)?.scrollIntoView({ block: "start" }));
337
358
  }, [Q]);
338
- return T === null ? S === null ? /* @__PURE__ */ u("div", {
359
+ return ie === null ? w === null ? /* @__PURE__ */ u("div", {
339
360
  className: "flex h-full items-center justify-center p-6",
340
361
  children: /* @__PURE__ */ u("p", {
341
362
  className: "text-sm text-zinc-500",
@@ -344,8 +365,8 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
344
365
  }) : /* @__PURE__ */ d("div", {
345
366
  className: "flex h-full flex-col",
346
367
  onKeyDown: (e) => {
347
- if (e.key === "PageDown" || e.key === "ArrowRight") $(D + 1);
348
- else if (e.key === "PageUp" || e.key === "ArrowLeft") $(D - 1);
368
+ if (e.key === "PageDown" || e.key === "ArrowRight") $(T + 1);
369
+ else if (e.key === "PageUp" || e.key === "ArrowLeft") $(T - 1);
349
370
  else return;
350
371
  e.preventDefault();
351
372
  },
@@ -354,8 +375,8 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
354
375
  children: [
355
376
  /* @__PURE__ */ u("button", {
356
377
  type: "button",
357
- onClick: () => $(D - 1),
358
- disabled: D <= 1,
378
+ onClick: () => $(T - 1),
379
+ disabled: T <= 1,
359
380
  "aria-label": "Previous page",
360
381
  className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
361
382
  children: "‹"
@@ -364,15 +385,15 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
364
385
  className: "tabular-nums text-zinc-600 dark:text-zinc-400",
365
386
  children: [
366
387
  "Page ",
367
- D,
388
+ T,
368
389
  " / ",
369
390
  Q
370
391
  ]
371
392
  }),
372
393
  /* @__PURE__ */ u("button", {
373
394
  type: "button",
374
- onClick: () => $(D + 1),
375
- disabled: D >= Q,
395
+ onClick: () => $(T + 1),
396
+ disabled: T >= Q,
376
397
  "aria-label": "Next page",
377
398
  className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
378
399
  children: "›"
@@ -382,20 +403,20 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
382
403
  children: [
383
404
  /* @__PURE__ */ u("button", {
384
405
  type: "button",
385
- onClick: () => A((e) => Math.max(0, e - 1)),
386
- disabled: k === 0,
406
+ onClick: () => O((e) => Math.max(0, e - 1)),
407
+ disabled: D === 0,
387
408
  "aria-label": "Zoom out",
388
409
  className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
389
410
  children: "−"
390
411
  }),
391
412
  /* @__PURE__ */ d("span", {
392
413
  className: "tabular-nums text-zinc-500",
393
- children: [Math.round(h[k] * 100), "%"]
414
+ children: [Math.round(h[D] * 100), "%"]
394
415
  }),
395
416
  /* @__PURE__ */ u("button", {
396
417
  type: "button",
397
- onClick: () => A((e) => Math.min(h.length - 1, e + 1)),
398
- disabled: k === h.length - 1,
418
+ onClick: () => O((e) => Math.min(h.length - 1, e + 1)),
419
+ disabled: D === h.length - 1,
399
420
  "aria-label": "Zoom in",
400
421
  className: "rounded px-2 py-1 hover:bg-zinc-100 disabled:opacity-40 dark:hover:bg-zinc-800",
401
422
  children: "+"
@@ -404,23 +425,23 @@ var w = r(function({ path: e, serverUrl: n = "", token: r = null, workspace: l,
404
425
  })
405
426
  ]
406
427
  }), /* @__PURE__ */ u("div", {
407
- ref: M,
428
+ ref: oe,
408
429
  className: "flex-1 overflow-auto bg-zinc-100 p-4 dark:bg-zinc-950",
409
- children: re !== null && Array.from({ length: Q }, (e, t) => t + 1).map((e) => /* @__PURE__ */ u(ne, {
410
- doc: S,
430
+ children: k !== null && Array.from({ length: Q }, (e, t) => t + 1).map((e) => /* @__PURE__ */ u(ne, {
431
+ doc: w,
411
432
  pageNumber: e,
412
- scale: h[k],
413
- baseSize: re,
414
- active: Math.abs(e - D) <= C,
415
- registerSlot: ae,
416
- onTextLayerReady: ie
433
+ scale: h[D],
434
+ baseSize: k,
435
+ active: Math.abs(e - T) <= C,
436
+ registerSlot: ue,
437
+ onTextLayerReady: le
417
438
  }, e))
418
439
  })]
419
440
  }) : /* @__PURE__ */ u("div", {
420
441
  className: "flex h-full items-center justify-center p-6",
421
442
  children: /* @__PURE__ */ u("p", {
422
443
  className: "max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400",
423
- children: _(T)
444
+ children: _(ie)
424
445
  })
425
446
  });
426
447
  });