@pi-outpost/embed 0.23.1 → 0.24.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.
@@ -1,6 +1,7 @@
1
1
  import { i as e, n as t, t as n } from "./rolldown-runtime-DArdT4gl.js";
2
2
  import { a as r, c as i, d as a, f as o, h as s, i as c, l, n as u, o as d, r as f, s as p, t as m, u as h } from "./download-CqPD34Wv.js";
3
- import { a as g, c as _, i as v, n as y, o as ee, r as te, s as ne, t as re } from "./findInPage-BtPAvay_.js";
3
+ import { a as g, i as _, n as v, o as y, r as ee, t as te } from "./workspacePath-CfDl0V4n.js";
4
+ import { n as ne, t as re } from "./findInPage-xFP831JH.js";
4
5
  import { Component as ie, Suspense as ae, createContext as oe, createElement as se, createRef as ce, forwardRef as le, lazy as ue, memo as de, useCallback as fe, useContext as b, useEffect as x, useId as S, useImperativeHandle as pe, useLayoutEffect as me, useMemo as he, useReducer as ge, useRef as C, useState as w } from "react";
5
6
  import { createRoot as _e } from "react-dom/client";
6
7
  import { Fragment as ve, jsx as T, jsxs as E } from "react/jsx-runtime";
@@ -30441,7 +30442,7 @@ function Ch({ item: e, serverUrl: t = "", token: n = null, onOpenFile: r, hideRe
30441
30442
  c.current = r;
30442
30443
  let l = he(() => {
30443
30444
  function e({ src: e, alt: r, ...i }) {
30444
- let a = typeof e == "string" && e !== "" && !v(e) ? ne(t, _("", e), n) : e;
30445
+ let a = typeof e == "string" && e !== "" && !v(e) ? g(t, y("", e), n) : e;
30445
30446
  return /* @__PURE__ */ T("img", {
30446
30447
  ...i,
30447
30448
  src: a,
@@ -30452,7 +30453,7 @@ function Ch({ item: e, serverUrl: t = "", token: n = null, onOpenFile: r, hideRe
30452
30453
  }
30453
30454
  function r({ href: e, children: t, ...n }) {
30454
30455
  if (typeof e == "string" && e !== "" && !v(e) && c.current) {
30455
- let r = _("", e);
30456
+ let r = y("", e);
30456
30457
  return /* @__PURE__ */ T("a", {
30457
30458
  ...n,
30458
30459
  href: e,
@@ -36253,7 +36254,7 @@ function PC(e) {
36253
36254
  return btoa(t);
36254
36255
  }
36255
36256
  function FC(e) {
36256
- return e.type.startsWith("image/") ? "image" : e.type === "application/pdf" || ee(e.name) || te(e.name) ? "extraction-tool" : e.size <= 524288 ? "inline-text" : RC(e) && e.size <= 26214400 ? "extraction-tool" : "unsupported";
36257
+ return e.type.startsWith("image/") ? "image" : e.type === "application/pdf" || _(e.name) || te(e.name) ? "extraction-tool" : e.size <= 524288 ? "inline-text" : RC(e) && e.size <= 26214400 ? "extraction-tool" : "unsupported";
36257
36258
  }
36258
36259
  function IC(e) {
36259
36260
  let t = FC(e);
@@ -37187,29 +37188,32 @@ function kw({ widgets: e, placement: t }) {
37187
37188
  }
37188
37189
  //#endregion
37189
37190
  //#region ../ui/src/components/DocxExportButton.tsx
37190
- function Aw({ text: e, path: t }) {
37191
- let [n, r] = w("idle"), [i, a] = w(null), o = C(!1), s = C(0);
37192
- async function c() {
37193
- if (!(o.current || Date.now() - s.current < 750)) {
37194
- o.current = !0, s.current = Date.now(), r("working"), a(null);
37191
+ function Aw({ text: e, path: t, serverUrl: n, token: r }) {
37192
+ let [i, a] = w("idle"), [o, s] = w(null), c = C(!1), l = C(0);
37193
+ async function u() {
37194
+ if (!(c.current || Date.now() - l.current < 750)) {
37195
+ c.current = !0, l.current = Date.now(), a("working"), s(null);
37195
37196
  try {
37196
- let { downloadDocx: n } = await import("./docxExport-BO9Dyd6M.js");
37197
- await n(e, t), r("idle");
37197
+ let { downloadDocx: i } = await import("./docxExport-_j7ragkM.js");
37198
+ await i(e, t, {
37199
+ serverUrl: n,
37200
+ token: r
37201
+ }), a("idle");
37198
37202
  } catch (e) {
37199
- r("failed"), a(e instanceof Error ? e.message : String(e));
37203
+ a("failed"), s(e instanceof Error ? e.message : String(e));
37200
37204
  } finally {
37201
- o.current = !1;
37205
+ c.current = !1;
37202
37206
  }
37203
37207
  }
37204
37208
  }
37205
37209
  return /* @__PURE__ */ T("button", {
37206
37210
  type: "button",
37207
- onClick: () => void c(),
37208
- disabled: n === "working",
37209
- title: n === "failed" ? `Could not export: ${i ?? "unknown reason"}` : "Download as a Word document",
37211
+ onClick: () => void u(),
37212
+ disabled: i === "working",
37213
+ title: i === "failed" ? `Could not export: ${o ?? "unknown reason"}` : "Download as a Word document",
37210
37214
  "aria-label": "Download as a Word document",
37211
37215
  className: "shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300",
37212
- children: n === "working" ? "… exporting" : n === "failed" ? "⚠ export failed" : "⤓ word"
37216
+ children: i === "working" ? "… exporting" : i === "failed" ? "⚠ export failed" : "⤓ word"
37213
37217
  });
37214
37218
  }
37215
37219
  //#endregion
@@ -37292,7 +37296,7 @@ function Mw({ query: e, onQueryChange: t, matchCount: n, truncated: r = !1, curr
37292
37296
  }
37293
37297
  //#endregion
37294
37298
  //#region ../ui/src/components/FileViewer.tsx
37295
- var Nw = ue(() => import("./PdfViewer-D5anbvST.js")), Pw = 250, Fw = "(min-width: 768px)";
37299
+ var Nw = ue(() => import("./PdfViewer-CDo7oG-p.js")), Pw = 250, Fw = "(min-width: 768px)";
37296
37300
  function Iw() {
37297
37301
  let [e, t] = w(() => window.matchMedia?.(Fw).matches ?? !0);
37298
37302
  return x(() => {
@@ -37324,7 +37328,7 @@ function Vw({ file: e, writableRoot: t, isStreaming: n, onDirtyChange: r, gitSta
37324
37328
  draft: e.content,
37325
37329
  baseContent: e.content,
37326
37330
  baseMtimeMs: e.mtimeMs
37327
- } : null), [me, ge] = w("idle"), _e = C(null), ye = C(null), D = e.status === "loaded" ? e : null, be = D !== null && zw(e.path), xe = g(e.path), Se = ee(e.path), Ce = he(() => D === null ? void 0 : Rx(D.content), [D?.content]), we = Ce?.status === "valid", Te = Ce?.status === "valid" || Ce?.status === "invalid", Ee = Te || be, De = le === "source", ke = Iw(), Ae = Bw(e.path, t) && !Se, je = S !== null && S.draft !== S.baseContent, Me = D?.pendingSave !== void 0, Ne = S !== null && D !== null && D.mtimeMs !== S.baseMtimeMs, Fe = D?.saveError?.conflict === !0 || Ne, Ie = S?.draft ?? D?.content ?? "", Le = Lw(Ie, Pw), Re = he(() => D === null ? void 0 : Rx(Le), [Le, D === null]), [ze, Ve] = w(() => e.status === "loaded" ? Rw(e.content) : void 0);
37331
+ } : null), [me, ge] = w("idle"), _e = C(null), ye = C(null), D = e.status === "loaded" ? e : null, be = D !== null && zw(e.path), xe = ee(e.path), Se = _(e.path), Ce = he(() => D === null ? void 0 : Rx(D.content), [D?.content]), we = Ce?.status === "valid", Te = Ce?.status === "valid" || Ce?.status === "invalid", Ee = Te || be, De = le === "source", ke = Iw(), Ae = Bw(e.path, t) && !Se, je = S !== null && S.draft !== S.baseContent, Me = D?.pendingSave !== void 0, Ne = S !== null && D !== null && D.mtimeMs !== S.baseMtimeMs, Fe = D?.saveError?.conflict === !0 || Ne, Ie = S?.draft ?? D?.content ?? "", Le = Lw(Ie, Pw), Re = he(() => D === null ? void 0 : Rx(Le), [Le, D === null]), [ze, Ve] = w(() => e.status === "loaded" ? Rw(e.content) : void 0);
37328
37332
  x(() => {
37329
37333
  Re?.status === "valid" && Ve(Re.envelope);
37330
37334
  }, [Re]);
@@ -37358,7 +37362,7 @@ function Vw({ file: e, writableRoot: t, isStreaming: n, onDirtyChange: r, gitSta
37358
37362
  return;
37359
37363
  }
37360
37364
  ut.current?.clear();
37361
- let n = y(t, ht);
37365
+ let n = ne(t, ht);
37362
37366
  ut.current = n, dt.current = n.matches, st(n.matches), lt(n.truncated);
37363
37367
  let r = ht !== pt.current;
37364
37368
  pt.current = ht;
@@ -37465,13 +37469,13 @@ function Vw({ file: e, writableRoot: t, isStreaming: n, onDirtyChange: r, gitSta
37465
37469
  }) : /* @__PURE__ */ T("a", {
37466
37470
  href: t,
37467
37471
  onClick: (n) => {
37468
- n.preventDefault(), h(_(e.path, t));
37472
+ n.preventDefault(), h(y(e.path, t));
37469
37473
  },
37470
37474
  ...r,
37471
37475
  children: n
37472
37476
  }),
37473
37477
  img: ({ src: t, alt: n, ...r }) => {
37474
- let i = typeof t == "string" && t !== "" && !/^[a-z][a-z0-9+.-]*:/i.test(t) && !t.startsWith("//") ? ne(te, _(e.path, t), ie) : t;
37478
+ let i = typeof t == "string" && t !== "" && !/^[a-z][a-z0-9+.-]*:/i.test(t) && !t.startsWith("//") ? g(te, y(e.path, t), ie) : t;
37475
37479
  return /* @__PURE__ */ T("img", {
37476
37480
  ...r,
37477
37481
  src: i,
@@ -37601,7 +37605,9 @@ function Vw({ file: e, writableRoot: t, isStreaming: n, onDirtyChange: r, gitSta
37601
37605
  }),
37602
37606
  D && !xe && !Se && !de && /* @__PURE__ */ T(Aw, {
37603
37607
  text: Ie,
37604
- path: e.path
37608
+ path: e.path,
37609
+ serverUrl: te,
37610
+ token: ie
37605
37611
  }),
37606
37612
  D && S === null && /* @__PURE__ */ T(Pe, { text: D.content }),
37607
37613
  D && S === null && !de && Ae && /* @__PURE__ */ T("button", {
@@ -37723,7 +37729,7 @@ function Vw({ file: e, writableRoot: t, isStreaming: n, onDirtyChange: r, gitSta
37723
37729
  xe && S === null && !de && /* @__PURE__ */ T("div", {
37724
37730
  className: "flex h-full items-center justify-center p-4",
37725
37731
  children: /* @__PURE__ */ T("img", {
37726
- src: ne(te, e.path, ie, ce),
37732
+ src: g(te, e.path, ie, ce),
37727
37733
  alt: e.path,
37728
37734
  onLoad: () => oe(e.path),
37729
37735
  className: "max-h-full max-w-full rounded object-contain"
@@ -52732,7 +52738,7 @@ function aF(e = "", t, n = !1, r) {
52732
52738
  x(() => {
52733
52739
  m.current = i.writableRoot;
52734
52740
  }, [i.writableRoot]);
52735
- let h = C(!1), _ = C(/* @__PURE__ */ new Map()), v = C({
52741
+ let h = C(!1), g = C(/* @__PURE__ */ new Map()), v = C({
52736
52742
  workspaceRoot: i.workspace?.root ?? null,
52737
52743
  sessionId: i.sessionId
52738
52744
  });
@@ -52844,22 +52850,22 @@ function aF(e = "", t, n = !1, r) {
52844
52850
  return;
52845
52851
  }
52846
52852
  if (t.type === "terminal_data") {
52847
- let e = _.current.get(t.terminalId);
52853
+ let e = g.current.get(t.terminalId);
52848
52854
  if (e) for (let n of e.onData) n(t.data);
52849
52855
  return;
52850
52856
  }
52851
52857
  if (t.type === "terminal_cwd") {
52852
- let e = _.current.get(t.terminalId);
52858
+ let e = g.current.get(t.terminalId);
52853
52859
  if (e) for (let n of e.onCwd) n(t.cwd);
52854
52860
  return;
52855
52861
  }
52856
52862
  if (t.type === "terminal_exit") {
52857
- let e = _.current.get(t.terminalId);
52863
+ let e = g.current.get(t.terminalId);
52858
52864
  if (e) for (let n of e.onExit) n(t.exitCode);
52859
52865
  return;
52860
52866
  }
52861
52867
  if (t.type === "terminal_error") {
52862
- let e = _.current.get(t.terminalId);
52868
+ let e = g.current.get(t.terminalId);
52863
52869
  if (e) for (let n of e.onError) n(t.message);
52864
52870
  return;
52865
52871
  }
@@ -52900,7 +52906,7 @@ function aF(e = "", t, n = !1, r) {
52900
52906
  oe(), he(t.path);
52901
52907
  let e = d.current;
52902
52908
  if (e !== null && JP(e.path) === t.path) {
52903
- if (g(e.path) || ee(e.path)) a({
52909
+ if (ee(e.path) || _(e.path)) a({
52904
52910
  type: "raw_preview_changed",
52905
52911
  path: e.path
52906
52912
  });
@@ -53387,16 +53393,16 @@ function aF(e = "", t, n = !1, r) {
53387
53393
  y({
53388
53394
  type: "terminal_close",
53389
53395
  terminalId: e
53390
- }), _.current.delete(e);
53396
+ }), g.current.delete(e);
53391
53397
  },
53392
53398
  subscribeTerminal: (e, t) => {
53393
- let n = _.current.get(e);
53399
+ let n = g.current.get(e);
53394
53400
  return n || (n = {
53395
53401
  onData: /* @__PURE__ */ new Set(),
53396
53402
  onCwd: /* @__PURE__ */ new Set(),
53397
53403
  onExit: /* @__PURE__ */ new Set(),
53398
53404
  onError: /* @__PURE__ */ new Set()
53399
- }, _.current.set(e, n)), t.onData && n.onData.add(t.onData), t.onCwd && n.onCwd.add(t.onCwd), t.onExit && n.onExit.add(t.onExit), t.onError && n.onError.add(t.onError), () => {
53405
+ }, g.current.set(e, n)), t.onData && n.onData.add(t.onData), t.onCwd && n.onCwd.add(t.onCwd), t.onExit && n.onExit.add(t.onExit), t.onError && n.onError.add(t.onError), () => {
53400
53406
  t.onData && n?.onData.delete(t.onData), t.onCwd && n?.onCwd.delete(t.onCwd), t.onExit && n?.onExit.delete(t.onExit), t.onError && n?.onError.delete(t.onError);
53401
53407
  };
53402
53408
  }
@@ -53405,7 +53411,7 @@ function aF(e = "", t, n = !1, r) {
53405
53411
  //#endregion
53406
53412
  //#region ../ui/src/App.tsx
53407
53413
  var oF = 120, sF = le(function({ serverUrl: e = "", rootElement: t, initialTheme: n, token: r, workspace: i }, a) {
53408
- let o = t !== void 0, s = t ?? document.documentElement, { state: c, authToken: l, submitToken: u, prompt: d, abort: f, setModel: p, setThinking: m, newSession: h, switchSession: _, deleteSession: v, listSessions: y, renameSession: re, searchSessions: ie, clearSessionSearch: ae, listTree: oe, navigateTree: se, forkSession: ce, editPrompt: le, compact: ue, respondToDialog: de, dismissNotification: b, listDirectory: S, refreshFileTree: me, readFile: ge, writeFile: _e, createFile: ye, createDirectory: be, uploadFile: xe, openNative: Se, renameFile: Ce, deleteFile: we, moveFile: Ee, copyFile: De, closeFilePreview: Oe, searchFiles: ke, clearFileSearch: Ae, fetchGitDiff: je, clearGitDiff: Me, fetchGitLog: Ne, fetchGitShow: Pe, clearGitShow: Fe, fetchGitFileHistory: Ie, closeGitFileHistory: Le, fetchGitFileDiff: Re, clearGitFileDiff: ze, setCredential: Be, declareProvider: Ve, updateConfig: He, suggestAgentResourceClonePath: Ue, cloneAgentResourceRepository: We, enrollAgentResourceRepository: Ge, refreshAgentResourceRepositories: Ke, updateAgentResourceRepository: qe, browseServerDirectory: Je, closeServerBrowser: Ye, switchWorkspace: Xe, openProject: Ze, closeProject: Qe, openTerminal: et, sendTerminalInput: tt, getTerminalCwd: nt, resizeTerminal: rt, closeTerminal: it, subscribeTerminal: at, setOutcomeActive: ot, refreshOutcome: st } = aF(e, r, o, i);
53414
+ let o = t !== void 0, s = t ?? document.documentElement, { state: c, authToken: l, submitToken: u, prompt: d, abort: f, setModel: p, setThinking: m, newSession: h, switchSession: v, deleteSession: y, listSessions: ne, renameSession: re, searchSessions: ie, clearSessionSearch: ae, listTree: oe, navigateTree: se, forkSession: ce, editPrompt: le, compact: ue, respondToDialog: de, dismissNotification: b, listDirectory: S, refreshFileTree: me, readFile: ge, writeFile: _e, createFile: ye, createDirectory: be, uploadFile: xe, openNative: Se, renameFile: Ce, deleteFile: we, moveFile: Ee, copyFile: De, closeFilePreview: Oe, searchFiles: ke, clearFileSearch: Ae, fetchGitDiff: je, clearGitDiff: Me, fetchGitLog: Ne, fetchGitShow: Pe, clearGitShow: Fe, fetchGitFileHistory: Ie, closeGitFileHistory: Le, fetchGitFileDiff: Re, clearGitFileDiff: ze, setCredential: Be, declareProvider: Ve, updateConfig: He, suggestAgentResourceClonePath: Ue, cloneAgentResourceRepository: We, enrollAgentResourceRepository: Ge, refreshAgentResourceRepositories: Ke, updateAgentResourceRepository: qe, browseServerDirectory: Je, closeServerBrowser: Ye, switchWorkspace: Xe, openProject: Ze, closeProject: Qe, openTerminal: et, sendTerminalInput: tt, getTerminalCwd: nt, resizeTerminal: rt, closeTerminal: it, subscribeTerminal: at, setOutcomeActive: ot, refreshOutcome: st } = aF(e, r, o, i);
53409
53415
  $T(c.workspaces, c.workspace?.root ?? null);
53410
53416
  let ct = c.workspace?.root ?? null;
53411
53417
  x(() => {
@@ -53468,10 +53474,10 @@ var oF = 120, sF = le(function({ serverUrl: e = "", rootElement: t, initialTheme
53468
53474
  if (!t) return;
53469
53475
  let n = t.path, r = t.status === "loaded", i = t.status === "error" && t.message === "Binary file — preview not supported" && te(n);
53470
53476
  if (jt.current !== n && (jt.current = n, Mt.current = null, ft((e) => e.filter((e) => e.source !== "preview")), gt(null), O(null), yt(null)), Mt.current === n) return;
53471
- (g(n) || ee(n)) && ft((e) => e.filter((e) => e.source !== "preview"));
53477
+ (ee(n) || _(n)) && ft((e) => e.filter((e) => e.source !== "preview"));
53472
53478
  let a = !1;
53473
53479
  async function o() {
53474
- let t = g(n) ? _t === n ? await XC(n, ne(e, n, l, c.previewRevision)) : null : ee(n) ? vt?.path === n && vt.revision === c.previewRevision ? KC(n) : null : i || r ? GC(n) : null;
53480
+ let t = ee(n) ? _t === n ? await XC(n, g(e, n, l, c.previewRevision)) : null : _(n) ? vt?.path === n && vt.revision === c.previewRevision ? KC(n) : null : i || r ? GC(n) : null;
53475
53481
  if (!(a || t === null || jt.current !== n || Mt.current === n)) {
53476
53482
  if (typeof t == "string") {
53477
53483
  gt(t);
@@ -53729,9 +53735,9 @@ var oF = 120, sF = le(function({ serverUrl: e = "", rootElement: t, initialTheme
53729
53735
  onFilterChange: Lt,
53730
53736
  onToggleTheme: gn,
53731
53737
  onNewSession: h,
53732
- onSwitchSession: _,
53733
- onDeleteSession: v,
53734
- onListSessions: y,
53738
+ onSwitchSession: v,
53739
+ onDeleteSession: y,
53740
+ onListSessions: ne,
53735
53741
  onRenameSession: re,
53736
53742
  onSearchSessions: ie,
53737
53743
  onClearSessionSearch: ae,
@@ -0,0 +1,24 @@
1
+ //#region ../ui/src/util/workspacePath.ts
2
+ function e(e) {
3
+ return /^[a-z][a-z0-9+.-]*:/i.test(e) || e.startsWith("//");
4
+ }
5
+ function t(e, t) {
6
+ let n = t.split(/[?#]/)[0], r = n.startsWith("/") ? n.split("/") : [...e.split("/").slice(0, -1), ...n.split("/")], i = [];
7
+ for (let e of r) e !== "" && e !== "." && (e === ".." ? i.pop() : i.push(e));
8
+ return i.join("/");
9
+ }
10
+ function n(e) {
11
+ return /\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e);
12
+ }
13
+ function r(e) {
14
+ return /\.pdf$/i.test(e);
15
+ }
16
+ function i(e) {
17
+ return /\.(docx|xlsx|pptx)$/i.test(e);
18
+ }
19
+ function a(e, t, n, r) {
20
+ let i = n ? `&token=${encodeURIComponent(n)}` : "", a = r === void 0 ? "" : `&v=${encodeURIComponent(String(r))}`;
21
+ return `${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`;
22
+ }
23
+ //#endregion
24
+ export { a, r as i, e as n, t as o, n as r, i as t };
@@ -0,0 +1 @@
1
+ function e(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function t(e,t){let n=t.split(/[?#]/)[0],r=n.startsWith(`/`)?n.split(`/`):[...e.split(`/`).slice(0,-1),...n.split(`/`)],i=[];for(let e of r)e!==``&&e!==`.`&&(e===`..`?i.pop():i.push(e));return i.join(`/`)}function n(e){return/\.(png|jpe?g|gif|webp|svg|avif)$/i.test(e)}function r(e){return/\.pdf$/i.test(e)}function i(e){return/\.(docx|xlsx|pptx)$/i.test(e)}function a(e,t,n,r){let i=n?`&token=${encodeURIComponent(n)}`:``,a=r===void 0?``:`&v=${encodeURIComponent(String(r))}`;return`${e}/files/raw?path=${encodeURIComponent(t)}${i}${a}`}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-outpost/embed",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "description": "Mount pi-outpost as a Shadow-DOM-isolated widget inside another web app.",
6
6
  "license": "MIT",