artifactuse 0.1.28 → 0.1.30

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as s, aJ as r, at as t, J as d, d as c, G as o, a_ as i, am as m, k as l, ar as b, ap as E, ak as n, a6 as p, a7 as g, E as h, ae as M, al as T, m as u, aG as A, X as f, ai as S, aj as C, ad as y, a5 as P, aq as I, a0 as G, a1 as L, N as V, O as D, s as k, af as F, S as z, T as v, a8 as B, V as w, C as K, aO as X, aw as x, au as H, as as O, P as R, a3 as N, _ as U, Y as J, W, aa as Y, ah as _, H as j, I as q, a9 as Q, j as Z, ac as $, l as aa, U as ea, R as sa, ao as ra, y as ta, w as da, z as ca, B as oa, A as ia, L as ma, aZ as la, aI as ba, e as Ea, aL as na, a$ as pa, aT as ga, aB as ha, aW as Ma, aY as Ta, aX as ua, K as Aa, aP as fa, ax as Sa, aM as Ca, h as ya, aS as Pa, aA as Ia, i as Ga, u as La, aQ as Va, ay as Da, aV as ka, n as Fa, p as za, ag as va, F as Ba, a4 as wa, ab as Ka, $ as Xa, q as xa, o as Ha, an as Oa, M as Ra, aN as Na, aU as Ua, av as Ja, aC as Wa, a2 as Ya, Z as _a, Q as ja, aF as qa, x as Qa, t as Za, r as $a, v as ae, aD as ee, aR as se, az as re, aK as te, aH as de, aE as ce } from "./index-D56xsAnF.js";
1
+ import { D as s, aJ as r, at as t, J as d, d as c, G as o, a_ as i, am as m, k as l, ar as b, ap as E, ak as n, a6 as p, a7 as g, E as h, ae as M, al as T, m as u, aG as A, X as f, ai as S, aj as C, ad as y, a5 as P, aq as I, a0 as G, a1 as L, N as V, O as D, s as k, af as F, S as z, T as v, a8 as B, V as w, C as K, aO as X, aw as x, au as H, as as O, P as R, a3 as N, _ as U, Y as J, W, aa as Y, ah as _, H as j, I as q, a9 as Q, j as Z, ac as $, l as aa, U as ea, R as sa, ao as ra, y as ta, w as da, z as ca, B as oa, A as ia, L as ma, aZ as la, aI as ba, e as Ea, aL as na, a$ as pa, aT as ga, aB as ha, aW as Ma, aY as Ta, aX as ua, K as Aa, aP as fa, ax as Sa, aM as Ca, h as ya, aS as Pa, aA as Ia, i as Ga, u as La, aQ as Va, ay as Da, aV as ka, n as Fa, p as za, ag as va, F as Ba, a4 as wa, ab as Ka, $ as Xa, q as xa, o as Ha, an as Oa, M as Ra, aN as Na, aU as Ua, av as Ja, aC as Wa, a2 as Ya, Z as _a, Q as ja, aF as qa, x as Qa, t as Za, r as $a, v as ae, aD as ee, aR as se, az as re, aK as te, aH as de, aE as ce } from "./index-BH35XKmt.js";
2
2
  export {
3
3
  s as DEFAULT_PANELS,
4
4
  r as copyTableToClipboard,
@@ -1,5 +1,5 @@
1
1
  import e, { useState as b, useMemo as T, useCallback as d, useRef as W, useEffect as j, createContext as Bt, useContext as Ft } from "react";
2
- import { g as ze, f as Et, a as et, b as tt, n as Wt, i as dt, c as Vt, D as vt, d as zt } from "../index-D56xsAnF.js";
2
+ import { g as ze, f as Et, a as et, b as tt, n as Wt, i as dt, c as Vt, D as vt, d as zt } from "../index-BH35XKmt.js";
3
3
  import { J as Rt } from "../jszip.min-CdmYyw5L.js";
4
4
  import { createPortal as qt } from "react-dom";
5
5
  function Dt({
@@ -631,7 +631,7 @@ function ca({
631
631
  state: R,
632
632
  getTheme: le,
633
633
  instance: q
634
- } = xe(), ee = W(null), $ = W(null), D = W(null), de = W(l), [ce, ge] = b(""), [fe, te] = b([]), [ie, ne] = b(!1), [oe, o] = b(!1), [_, y] = b("image"), [w, H] = b(""), [ae, Ce] = b(""), [K, Le] = b(""), _e = T(() => typeof le == "function" ? le() : "dark", [le]), ye = (R == null ? void 0 : R.activeArtifactId) || null, Ne = c ?? ((Be = q == null ? void 0 : q.config) == null ? void 0 : Be.inlineCards) ?? !0, Se = T(() => na(ce), [ce]), Ae = T(() => ie || s ? "active" : "inactive", [ie, s]);
634
+ } = xe(), ee = W(null), $ = W(null), D = W(null), de = W(l), [ce, ge] = b(""), [fe, te] = b([]), [ie, ne] = b(!1), [oe, o] = b(!1), [_, y] = b("image"), [w, H] = b(""), [ae, Ce] = b(""), [Y, Le] = b(""), _e = T(() => typeof le == "function" ? le() : "dark", [le]), ye = (R == null ? void 0 : R.activeArtifactId) || null, Ne = c ?? ((Be = q == null ? void 0 : q.config) == null ? void 0 : Be.inlineCards) ?? !0, Se = T(() => na(ce), [ce]), Ae = T(() => ie || s ? "active" : "inactive", [ie, s]);
635
635
  j(() => {
636
636
  l && ne(!0);
637
637
  }, [l]);
@@ -711,7 +711,7 @@ function ca({
711
711
  }), $.current.querySelectorAll(".artifactuse-video-preview-wrapper, .video-preview-wrapper").forEach((P) => {
712
712
  P._clickHandler && (P.removeEventListener("click", P._clickHandler), delete P._clickHandler);
713
713
  });
714
- }, []), Y = d(() => {
714
+ }, []), Q = d(() => {
715
715
  D.current && clearTimeout(D.current), D.current = setTimeout(async () => {
716
716
  if (q != null && q.initializeContent && $.current)
717
717
  try {
@@ -730,17 +730,18 @@ function ca({
730
730
  tabs: p,
731
731
  viewMode: x
732
732
  });
733
- ge(E.html), te(E.artifacts), E.artifacts.length > 0 && i && i(E.artifacts), l || Y();
733
+ ge(E.html), te(E.artifacts), E.artifacts.length > 0 && i && i(E.artifacts), l || Q();
734
734
  }
735
- }, [t, a, se, l, Y, i]), j(() => {
736
- de.current === !0 && l === !1 && Y(), de.current = l;
737
- }, [l, Y]), j(() => (l && ne(!0), l || Y(), () => {
735
+ }, [t, a, se, l, Q, i]), j(() => {
736
+ de.current === !0 && l === !1 && Q(), de.current = l;
737
+ }, [l, Q]), j(() => (l && ne(!0), l || Q(), () => {
738
738
  D.current && clearTimeout(D.current), He();
739
739
  }), []);
740
740
  const qe = d((E) => {
741
- const Q = E.target.closest(".artifactuse-inline-preview");
742
- if (Q) {
743
- const A = Q.dataset.artifactId;
741
+ const Z = E.target.closest(".artifactuse-inline-preview");
742
+ if (Z) {
743
+ if (Z.dataset.nonClickable) return;
744
+ const A = Z.dataset.artifactId;
744
745
  if (A) {
745
746
  const O = R.artifacts.find((P) => P.id === A);
746
747
  O && (M(O), k && k(O));
@@ -760,13 +761,13 @@ function ca({
760
761
  C && C(E);
761
762
  }, [C]), Me = d((E) => {
762
763
  f && f(E);
763
- }, [f]), Ie = (E, Q) => {
764
+ }, [f]), Ie = (E, Z) => {
764
765
  switch (E.type) {
765
766
  case "html":
766
767
  return /* @__PURE__ */ e.createElement(
767
768
  "div",
768
769
  {
769
- key: `html-${Q}`,
770
+ key: `html-${Z}`,
770
771
  dangerouslySetInnerHTML: { __html: E.content }
771
772
  }
772
773
  );
@@ -823,7 +824,7 @@ function ca({
823
824
  type: _,
824
825
  src: w,
825
826
  alt: ae,
826
- caption: K,
827
+ caption: Y,
827
828
  onClose: Pe
828
829
  }
829
830
  )
@@ -894,11 +895,11 @@ function Ea({
894
895
  getPanelUrl: S,
895
896
  openArtifact: L,
896
897
  instance: u
897
- } = xe(), h = W(null), C = W(null), f = W(null), g = W(null), z = W(null), se = W(null), M = W(null), [R, le] = b(!1), [q, ee] = b(!1), [$, D] = b(!0), [de, ce] = b(!1), [ge, fe] = b(!1), [te, ie] = b(!1), [ne, oe] = b(!1), [o, _] = b("options"), [y, w] = b(""), [H, ae] = b(null), [Ce, K] = b(""), [Le, _e] = b(!1), [ye, Ne] = b(!1), [Se, Ae] = b([]), [ue, Pe] = b(!1), [$e, He] = b(""), [Y, qe] = b(65), [be, De] = b(50), pe = W(null), Ee = W(null), Ue = W(null), ve = W(null), Me = W(null), Ie = T(() => r ? ze(r.language) : "", [r]), Be = T(() => r ? et(r.language) : "", [r]), E = T(() => {
898
+ } = xe(), h = W(null), C = W(null), f = W(null), g = W(null), z = W(null), se = W(null), M = W(null), [R, le] = b(!1), [q, ee] = b(!1), [$, D] = b(!0), [de, ce] = b(!1), [ge, fe] = b(!1), [te, ie] = b(!1), [ne, oe] = b(!1), [o, _] = b("options"), [y, w] = b(""), [H, ae] = b(null), [Ce, Y] = b(""), [Le, _e] = b(!1), [ye, Ne] = b(!1), [Se, Ae] = b([]), [ue, Pe] = b(!1), [$e, He] = b(""), [Q, qe] = b(65), [be, De] = b(50), pe = W(null), Ee = W(null), Ue = W(null), ve = W(null), Me = W(null), Ie = T(() => r ? ze(r.language) : "", [r]), Be = T(() => r ? et(r.language) : "", [r]), E = T(() => {
898
899
  if (!r) return null;
899
900
  let n = S(r);
900
901
  return n && r._refreshToken && (n += (n.includes("?") ? "&" : "?") + "_t=" + r._refreshToken), n;
901
- }, [r, S]), Q = T(() => r ? Wt(r.language) : "plaintext", [r]), A = T(() => s.artifacts.filter((n) => !n.isInline), [s.artifacts]), O = T(() => r ? A.findIndex((n) => n.id === r.id) : -1, [r, A]), P = T(() => {
902
+ }, [r, S]), Z = T(() => r ? Wt(r.language) : "plaintext", [r]), A = T(() => s.artifacts.filter((n) => !n.isInline), [s.artifacts]), O = T(() => r ? A.findIndex((n) => n.id === r.id) : -1, [r, A]), P = T(() => {
902
903
  var n;
903
904
  return ((n = u == null ? void 0 : u.config) == null ? void 0 : n.branding) !== !1;
904
905
  }, [u]), rt = T(() => {
@@ -907,7 +908,7 @@ function Ea({
907
908
  }, [u]), m = T(() => {
908
909
  var n;
909
910
  return ((n = u == null ? void 0 : u.share) == null ? void 0 : n.isAuthenticated()) || !1;
910
- }, [u]), F = T(() => r ? Y : Math.min(Y, 30), [r, Y]), U = d((n) => `<svg viewBox="0 0 24 24" fill="currentColor">${et(n)}</svg>`, []), G = d(() => {
911
+ }, [u]), F = T(() => r ? Q : Math.min(Q, 30), [r, Q]), U = d((n) => `<svg viewBox="0 0 24 24" fill="currentColor">${et(n)}</svg>`, []), G = d(() => {
911
912
  fe(!1), u.state.clearActiveArtifact();
912
913
  }, [u]), me = d((n) => {
913
914
  if (n.language !== "smartdiff") return null;
@@ -917,8 +918,8 @@ function Ea({
917
918
  const I = N.language || "plaintext", B = dt() && window.Prism.languages[I], X = Vt(N.oldCode, N.newCode).split(`
918
919
  `);
919
920
  return { html: X.map((re) => {
920
- const Z = re[0], ke = re.slice(1), he = B ? window.Prism.highlight(ke, B, I) : ke;
921
- return Z === "-" ? `<span class="token deleted">${he}</span>` : Z === "+" ? `<span class="token inserted">${he}</span>` : he;
921
+ const K = re[0], ke = re.slice(1), he = B ? window.Prism.highlight(ke, B, I) : ke;
922
+ return K === "-" ? `<span class="token deleted">${he}</span>` : K === "+" ? `<span class="token inserted">${he}</span>` : he;
922
923
  }).join(`
923
924
  `), lineCount: X.length };
924
925
  } catch {
@@ -935,18 +936,18 @@ function Ea({
935
936
  if (n)
936
937
  C.current.innerHTML = n.html;
937
938
  else {
938
- const N = window.Prism.languages[Q];
939
+ const N = window.Prism.languages[Z];
939
940
  N ? C.current.innerHTML = window.Prism.highlight(
940
941
  r.code,
941
942
  N,
942
- Q
943
+ Z
943
944
  ) : C.current.textContent = r.code;
944
945
  }
945
946
  C.current.dataset.highlighted = "true", setTimeout(() => {
946
947
  gt();
947
948
  }, 0);
948
949
  }
949
- }, [r == null ? void 0 : r.code, Q, me]), gt = d(() => {
950
+ }, [r == null ? void 0 : r.code, Z, me]), gt = d(() => {
950
951
  var N;
951
952
  const n = (N = C.current) == null ? void 0 : N.closest("pre");
952
953
  if (n && z.current && g.current) {
@@ -988,19 +989,19 @@ function Ea({
988
989
  }
989
990
  }, [r]), wt = d(() => {
990
991
  if (!r) return;
991
- const { code: n, language: N, title: I } = r, B = tt(N), X = `${I.toLowerCase().replace(/\s+/g, "-")}.${B}`, Te = new Blob([n], { type: "text/plain" }), re = URL.createObjectURL(Te), Z = document.createElement("a");
992
- Z.href = re, Z.download = X, document.body.appendChild(Z), Z.click(), document.body.removeChild(Z), URL.revokeObjectURL(re);
992
+ const { code: n, language: N, title: I } = r, B = tt(N), X = `${I.toLowerCase().replace(/\s+/g, "-")}.${B}`, Te = new Blob([n], { type: "text/plain" }), re = URL.createObjectURL(Te), K = document.createElement("a");
993
+ K.href = re, K.download = X, document.body.appendChild(K), K.click(), document.body.removeChild(K), URL.revokeObjectURL(re);
993
994
  }, [r]), xt = d(async () => {
994
995
  if (!(te || A.length === 0)) {
995
996
  ie(!0);
996
997
  try {
997
998
  const n = new Rt(), N = /* @__PURE__ */ new Map();
998
- for (const Z of A) {
999
- if (!Z.code) continue;
1000
- const ke = tt(Z.language);
1001
- let he = (Z.title || "untitled").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-_]/g, ""), Qe = `${he}.${ke}`;
999
+ for (const K of A) {
1000
+ if (!K.code) continue;
1001
+ const ke = tt(K.language);
1002
+ let he = (K.title || "untitled").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-_]/g, ""), Qe = `${he}.${ke}`;
1002
1003
  const Ge = N.get(Qe) || 0;
1003
- Ge > 0 && (Qe = `${he}-${Ge}.${ke}`), N.set(`${he}.${ke}`, Ge + 1), n.file(Qe, Z.code);
1004
+ Ge > 0 && (Qe = `${he}-${Ge}.${ke}`), N.set(`${he}.${ke}`, Ge + 1), n.file(Qe, K.code);
1004
1005
  }
1005
1006
  const I = await n.generateAsync({ type: "blob" }), X = `artifacts-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`, Te = URL.createObjectURL(I), re = document.createElement("a");
1006
1007
  re.href = Te, re.download = X, document.body.appendChild(re), re.click(), document.body.removeChild(re), URL.revokeObjectURL(Te);
@@ -1015,17 +1016,17 @@ function Ea({
1015
1016
  oe(!1);
1016
1017
  return;
1017
1018
  }
1018
- r && (_("options"), w(""), ae(null), K(""), _e(!1), Ne(!1), Ae([]), Pe(!1), He(""), oe(!0));
1019
+ r && (_("options"), w(""), ae(null), Y(""), _e(!1), Ne(!1), Ae([]), Pe(!1), He(""), oe(!0));
1019
1020
  }, [r, u, ne]), Lt = d(() => {
1020
1021
  oe(!1);
1021
1022
  }, []), Je = d(async () => {
1022
1023
  if (!(!r || !(u != null && u.share))) {
1023
- _("loading"), K("");
1024
+ _("loading"), Y("");
1024
1025
  try {
1025
1026
  const n = await u.share.share(r);
1026
1027
  w(n.url), ae(n.expiresAt), Ne(!1), _("success");
1027
1028
  } catch (n) {
1028
- K(n.message || "Failed to create share link"), _("error");
1029
+ Y(n.message || "Failed to create share link"), _("error");
1029
1030
  }
1030
1031
  }
1031
1032
  }, [r, u]), ot = d(async () => {
@@ -1036,17 +1037,17 @@ function Ea({
1036
1037
  try {
1037
1038
  await u.share.openAuthPopup(), Fe();
1038
1039
  } catch (n) {
1039
- n.message === "Authentication cancelled" ? _("options") : (K(n.message || "Authentication failed"), _("error"));
1040
+ n.message === "Authentication cancelled" ? _("options") : (Y(n.message || "Authentication failed"), _("error"));
1040
1041
  }
1041
1042
  }
1042
1043
  }, [m, u]), Fe = d(async () => {
1043
1044
  if (!(!r || !(u != null && u.share))) {
1044
- _("loading"), K("");
1045
+ _("loading"), Y("");
1045
1046
  try {
1046
1047
  const n = await u.share.save(r);
1047
1048
  w(n.url), ae(null), Ne(!0), _("success");
1048
1049
  } catch (n) {
1049
- K(n.message || "Failed to save artifact"), _("error");
1050
+ Y(n.message || "Failed to save artifact"), _("error");
1050
1051
  }
1051
1052
  }
1052
1053
  }, [r, u]), Pt = d(() => {
@@ -1058,7 +1059,7 @@ function Ea({
1058
1059
  try {
1059
1060
  await u.share.openAuthPopup();
1060
1061
  } catch (n) {
1061
- n.message === "Authentication cancelled" ? _("options") : (K(n.message || "Authentication failed"), _("error"));
1062
+ n.message === "Authentication cancelled" ? _("options") : (Y(n.message || "Authentication failed"), _("error"));
1062
1063
  return;
1063
1064
  }
1064
1065
  }
@@ -1067,7 +1068,7 @@ function Ea({
1067
1068
  const n = (r == null ? void 0 : r.language) || null, N = await u.share.listArtifacts(n);
1068
1069
  Ae(N.projects || []);
1069
1070
  } catch (n) {
1070
- K(n.message || "Failed to load artifacts"), _("error");
1071
+ Y(n.message || "Failed to load artifacts"), _("error");
1071
1072
  } finally {
1072
1073
  Pe(!1);
1073
1074
  }
@@ -1077,12 +1078,12 @@ function Ea({
1077
1078
  if (!r || !(u != null && u.share)) return;
1078
1079
  const N = (I = n.project) == null ? void 0 : I.uuid;
1079
1080
  if (N) {
1080
- _("loading"), K("");
1081
+ _("loading"), Y("");
1081
1082
  try {
1082
1083
  const X = await u.share.updateArtifact(N, r);
1083
1084
  w(X.url || ""), ae(null), Ne(!0), He(((B = n.project) == null ? void 0 : B.name) || "Untitled"), _("success");
1084
1085
  } catch (X) {
1085
- K(X.message || "Failed to update artifact"), _("error");
1086
+ Y(X.message || "Failed to update artifact"), _("error");
1086
1087
  }
1087
1088
  }
1088
1089
  }, [r, u]), St = d(async () => {
@@ -1101,11 +1102,11 @@ function Ea({
1101
1102
  }, [L]), Xe = d((n) => {
1102
1103
  pe.current = {
1103
1104
  startX: n.clientX,
1104
- startWidth: Y
1105
+ startWidth: Q
1105
1106
  }, document.addEventListener("mousemove", Ze), document.addEventListener("mouseup", We), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.querySelectorAll("iframe").forEach((N) => {
1106
1107
  N.style.pointerEvents = "none";
1107
1108
  });
1108
- }, [Y]), Ze = d((n) => {
1109
+ }, [Q]), Ze = d((n) => {
1109
1110
  if (!pe.current) return;
1110
1111
  const N = window.innerWidth, B = (pe.current.startX - n.clientX) / N * 100, X = pe.current.startWidth + B;
1111
1112
  qe(Math.min(Math.max(X, 25), 75));
@@ -1157,7 +1158,7 @@ function Ea({
1157
1158
  "div",
1158
1159
  {
1159
1160
  className: Ye,
1160
- style: s.isFullscreen ? void 0 : { width: `${Y}%` }
1161
+ style: s.isFullscreen ? void 0 : { width: `${Q}%` }
1161
1162
  },
1162
1163
  !s.isFullscreen && /* @__PURE__ */ e.createElement(
1163
1164
  "div",
@@ -1276,11 +1277,11 @@ function Ea({
1276
1277
  },
1277
1278
  /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__split-handle-line" })
1278
1279
  ),
1279
- /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__code-scroll", ref: z }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__line-numbers", ref: g }), /* @__PURE__ */ e.createElement("pre", { className: `artifactuse-panel__code-block language-${Q}` }, /* @__PURE__ */ e.createElement(
1280
+ /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__code-scroll", ref: z }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__line-numbers", ref: g }), /* @__PURE__ */ e.createElement("pre", { className: `artifactuse-panel__code-block language-${Z}` }, /* @__PURE__ */ e.createElement(
1280
1281
  "code",
1281
1282
  {
1282
1283
  ref: C,
1283
- className: `language-${Q}`
1284
+ className: `language-${Z}`
1284
1285
  }
1285
1286
  )))
1286
1287
  ), /* @__PURE__ */ e.createElement(
@@ -16,6 +16,15 @@
16
16
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
17
17
  }
18
18
 
19
+ /* Non-clickable inline previews (short code, no panel value) */
20
+ .artifactuse-inline-preview--static {
21
+ cursor: default;
22
+ }
23
+
24
+ .artifactuse-inline-preview--static:hover {
25
+ box-shadow: none;
26
+ }
27
+
19
28
  .artifactuse-inline-preview pre {
20
29
  margin: 0 !important;
21
30
  }