@fileverse-dev/ddoc 2.1.4-patch-20 → 2.1.4-patch-21

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.es.js CHANGED
@@ -140175,71 +140175,86 @@ else {
140175
140175
  }
140176
140176
  const rF = ({
140177
140177
  link: t,
140178
- metadataProxyUrl: e
140178
+ metadataProxyUrl: e,
140179
+ hoverEvent: n
140179
140180
  }) => {
140180
- const [n, r] = Pe(null), [i, a] = Pe(!0), s = Ge(/* @__PURE__ */ new Map());
140181
- return ze(() => {
140182
- if (!t) return;
140183
- if (r(null), a(!0), s.current.has(t)) {
140184
- r(s.current.get(t)), a(!1);
140185
- return;
140186
- }
140187
- (async () => {
140181
+ const [r, i] = Pe(null), [a, s] = Pe(!1), o = Ge(/* @__PURE__ */ new Map()), l = async (c) => {
140182
+ if (c) {
140183
+ if (o.current.has(c)) {
140184
+ i(o.current.get(c)), s(!1);
140185
+ return;
140186
+ }
140187
+ s(!0);
140188
140188
  try {
140189
- a(!0);
140190
- const l = await fetch(
140191
- `${e}/${encodeURIComponent(t)}`
140192
- ), { metadata: c } = await l.json(), u = {
140193
- title: c.title,
140194
- description: c.description,
140195
- image: c.image,
140196
- favicon: c.favicon,
140197
- link: t
140189
+ const u = await fetch(
140190
+ `${e}/${encodeURIComponent(c)}`
140191
+ ), { metadata: f } = await u.json(), d = {
140192
+ title: f.title,
140193
+ description: f.description,
140194
+ image: f.image,
140195
+ favicon: f.favicon,
140196
+ link: c
140198
140197
  };
140199
- s.current.set(t, u), r(u), setTimeout(() => {
140200
- a(!1);
140201
- }, 1e3);
140202
- } catch (l) {
140203
- console.error("Error fetching link preview:", l), r(null), a(!1);
140198
+ o.current.set(c, d), i(d);
140199
+ } catch (u) {
140200
+ console.error("Error fetching link preview:", u), i(null);
140201
+ } finally {
140202
+ s(!1);
140204
140203
  }
140205
- })();
140206
- }, [t]), /* @__PURE__ */ A.jsx("div", { className: "w-[250px] border color-border-default shadow-elevation-3 rounded p-3 flex flex-col gap-2 justify-center hover-link-popup color-bg-default", children: i ? /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary", children: "Loading preview..." }) : n ? /* @__PURE__ */ A.jsxs(A.Fragment, { children: [
140207
- n.image && /* @__PURE__ */ A.jsx(
140204
+ }
140205
+ };
140206
+ return ze(() => {
140207
+ t && l(t);
140208
+ }, [t]), ze(() => {
140209
+ const c = (u) => {
140210
+ u.detail ? o.current.has(t) ? (i(o.current.get(t)), s(!1)) : l(t) : i(null);
140211
+ };
140212
+ return n.addEventListener(
140213
+ "hoverStateChange",
140214
+ c
140215
+ ), () => {
140216
+ n.removeEventListener(
140217
+ "hoverStateChange",
140218
+ c
140219
+ );
140220
+ };
140221
+ }, [n, t]), /* @__PURE__ */ A.jsx("div", { className: "w-[250px] border color-border-default shadow-elevation-3 rounded p-3 flex flex-col gap-2 justify-center hover-link-popup color-bg-default", children: a ? /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary", children: "Loading preview..." }) : r ? /* @__PURE__ */ A.jsxs(A.Fragment, { children: [
140222
+ r.image && /* @__PURE__ */ A.jsx(
140208
140223
  "img",
140209
140224
  {
140210
- src: n.image,
140225
+ src: r.image,
140211
140226
  className: "w-[225px] h-[125px] object-contain rounded",
140212
140227
  alt: "Preview",
140213
- onError: (o) => {
140214
- o.currentTarget.style.display = "none";
140228
+ onError: (c) => {
140229
+ c.currentTarget.style.display = "none";
140215
140230
  }
140216
140231
  }
140217
140232
  ),
140218
140233
  /* @__PURE__ */ A.jsxs("div", { className: "flex flex-col gap-2", children: [
140219
- (n.title || n.description) && /* @__PURE__ */ A.jsxs("div", { className: "flex flex-col gap-[2px]", children: [
140220
- n.title && /* @__PURE__ */ A.jsx("p", { className: "text-heading-xsm w-full truncate color-text-default select-text", children: n.title }),
140221
- n.description && /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary w-full truncate select-text", children: n.description })
140234
+ (r.title || r.description) && /* @__PURE__ */ A.jsxs("div", { className: "flex flex-col gap-[2px]", children: [
140235
+ r.title && /* @__PURE__ */ A.jsx("p", { className: "text-heading-xsm w-full truncate color-text-default select-text", children: r.title }),
140236
+ r.description && /* @__PURE__ */ A.jsx("p", { className: "text-helper-text-sm color-text-secondary w-full truncate select-text", children: r.description })
140222
140237
  ] }),
140223
140238
  /* @__PURE__ */ A.jsxs("div", { className: "flex gap-2", children: [
140224
- n.favicon && /* @__PURE__ */ A.jsx(
140239
+ r.favicon && /* @__PURE__ */ A.jsx(
140225
140240
  "img",
140226
140241
  {
140227
- src: n.favicon,
140242
+ src: r.favicon,
140228
140243
  className: "w-[18px] aspect-square rounded",
140229
140244
  alt: "Favicon",
140230
- onError: (o) => {
140231
- o.currentTarget.style.display = "none";
140245
+ onError: (c) => {
140246
+ c.currentTarget.style.display = "none";
140232
140247
  }
140233
140248
  }
140234
140249
  ),
140235
- n.link && /* @__PURE__ */ A.jsx(
140250
+ r.link && /* @__PURE__ */ A.jsx(
140236
140251
  "a",
140237
140252
  {
140238
- href: n.link,
140253
+ href: r.link,
140239
140254
  target: "_blank",
140240
140255
  rel: "noopener noreferrer",
140241
140256
  className: "text-helper-text-sm color-text-link w-full truncate hover:underline hover:cursor-pointer",
140242
- children: n.link
140257
+ children: r.link
140243
140258
  }
140244
140259
  )
140245
140260
  ] })
@@ -140252,28 +140267,32 @@ const rF = ({
140252
140267
  return [];
140253
140268
  const t = new Cn("link-preview");
140254
140269
  let e = null, n = null, r = null, i = null;
140270
+ const a = new EventTarget();
140255
140271
  return [
140256
140272
  new hn({
140257
140273
  key: t,
140258
140274
  props: {
140259
140275
  handleDOMEvents: {
140260
- mouseover: (a, s) => {
140261
- const l = s.target.closest("a");
140262
- if (l) {
140263
- const c = l.getAttribute("href");
140264
- if (!c) return !1;
140265
- e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r === l && setTimeout(() => {
140276
+ mouseover: (s, o) => {
140277
+ const c = o.target.closest("a");
140278
+ if (c) {
140279
+ const u = c.getAttribute("href");
140280
+ if (!u) return !1;
140281
+ e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r === c && setTimeout(() => {
140266
140282
  if (e)
140267
- return e.style.display = "block", !1;
140268
- }, 600), r = l;
140269
- const u = l.getBoundingClientRect();
140270
- e.style.left = `${u.left}px`, e.style.top = `${u.bottom + 5}px`, setTimeout(() => {
140283
+ return e.style.display = "block", a.dispatchEvent(
140284
+ new CustomEvent("hoverStateChange", { detail: !0 })
140285
+ ), !1;
140286
+ }, 600), r = c;
140287
+ const f = c.getBoundingClientRect();
140288
+ e.style.left = `${f.left}px`, e.style.top = `${f.bottom + 5}px`, setTimeout(() => {
140271
140289
  e && (e.style.display = "block", n || (n = P8(e))), n && n.render(
140272
140290
  /* @__PURE__ */ A.jsx(
140273
140291
  rF,
140274
140292
  {
140275
- link: c,
140276
- metadataProxyUrl: this.options.metadataProxyUrl
140293
+ link: u,
140294
+ metadataProxyUrl: this.options.metadataProxyUrl,
140295
+ hoverEvent: a
140277
140296
  }
140278
140297
  )
140279
140298
  );
@@ -140281,28 +140300,33 @@ const rF = ({
140281
140300
  }
140282
140301
  return !1;
140283
140302
  },
140284
- mouseout: (a, s) => {
140285
- const o = s.relatedTarget;
140303
+ mouseout: (s, o) => {
140304
+ const l = o.relatedTarget;
140286
140305
  return i && clearTimeout(i), i = setTimeout(() => {
140287
- e && !e.contains(o) && !(o != null && o.closest(".hover-link-popup")) && (e.style.display = "none");
140288
- }, 300), !1;
140306
+ e && !e.contains(l) && !(l != null && l.closest(".hover-link-popup")) && (e.style.display = "none", a.dispatchEvent(
140307
+ new CustomEvent("hoverStateChange", { detail: !1 })
140308
+ ));
140309
+ }, 100), !1;
140289
140310
  },
140290
- touchstart: (a, s) => {
140291
- const l = s.target.closest("a");
140292
- if (l) {
140293
- const c = l.getAttribute("href");
140294
- if (!c) return !1;
140295
- e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r = l;
140296
- const u = l.getBoundingClientRect();
140297
- e.style.left = `${u.left}px`, e.style.top = `${u.bottom + 5}px`, setTimeout(() => {
140311
+ touchstart: (s, o) => {
140312
+ const c = o.target.closest("a");
140313
+ if (c) {
140314
+ const u = c.getAttribute("href");
140315
+ if (!u) return !1;
140316
+ e || (e = document.createElement("div"), e.className = "hover-link-popup", e.style.position = "absolute", e.style.zIndex = "999", document.body.appendChild(e)), r = c;
140317
+ const f = c.getBoundingClientRect();
140318
+ e.style.left = `${f.left}px`, e.style.top = `${f.bottom + 5}px`, setTimeout(() => {
140298
140319
  e && (e.style.display = "block", n || (n = P8(e)), n.render(
140299
140320
  /* @__PURE__ */ A.jsx(
140300
140321
  rF,
140301
140322
  {
140302
- link: c,
140303
- metadataProxyUrl: this.options.metadataProxyUrl
140323
+ link: u,
140324
+ metadataProxyUrl: this.options.metadataProxyUrl,
140325
+ hoverEvent: a
140304
140326
  }
140305
140327
  )
140328
+ ), a.dispatchEvent(
140329
+ new CustomEvent("hoverStateChange", { detail: !0 })
140306
140330
  ));
140307
140331
  }, 600);
140308
140332
  }
@@ -5,7 +5,8 @@ export interface LinkPreviewData {
5
5
  favicon: string;
6
6
  link: string;
7
7
  }
8
- export declare const LinkPreviewCard: ({ link, metadataProxyUrl, }: {
8
+ export declare const LinkPreviewCard: ({ link, metadataProxyUrl, hoverEvent, }: {
9
9
  link: string;
10
10
  metadataProxyUrl: string;
11
+ hoverEvent: EventTarget;
11
12
  }) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "2.1.4-patch-20",
5
+ "version": "2.1.4-patch-21",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {