@decentnetwork/beagle 0.1.36 → 0.1.37

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,4 +1,4 @@
1
- window.__DK_UI_VERSION="0.1.35";
1
+ window.__DK_UI_VERSION="0.1.36";
2
2
  const ICON_PATHS = {
3
3
  // ---- tab bar (the four must feel like one set) ----
4
4
  users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
@@ -1622,7 +1622,7 @@ function DkGroupSender({ grp, T, avatar }) {
1622
1622
  title: grp.sender,
1623
1623
  style: { display: "inline-flex", alignItems: "center", gap: 5, background: "none", border: "none", padding: 0, cursor: "pointer" }
1624
1624
  },
1625
- avatar ? /* @__PURE__ */ React.createElement(DkIdenticon, { seed, size: 24, radius: 6 }) : /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 10.5, color: "var(--faint)" } }, grp.sender)
1625
+ avatar ? /* @__PURE__ */ React.createElement(DkEnsAvatar, { userid: grp.senderId, fallbackSeed: seed, size: 24, radius: 6 }) : /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 10.5, color: "var(--faint)" } }, grp.sender)
1626
1626
  ), open && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { onClick: () => setOpen(false), style: { position: "fixed", inset: 0, zIndex: 40 } }), /* @__PURE__ */ React.createElement("span", { style: {
1627
1627
  position: "absolute",
1628
1628
  left: 0,
@@ -1637,7 +1637,7 @@ function DkGroupSender({ grp, T, avatar }) {
1637
1637
  display: "flex",
1638
1638
  flexDirection: "column",
1639
1639
  gap: 8
1640
- } }, /* @__PURE__ */ React.createElement("span", { style: { display: "flex", alignItems: "center", gap: 8 } }, /* @__PURE__ */ React.createElement(DkIdenticon, { seed, size: 34, radius: 8 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 12.5, fontWeight: 700, color: "var(--text)", wordBreak: "break-all" } }, grp.sender)), grp.senderId ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Mono, { size: 10.5, dim: true, copy: grp.senderId, title: grp.senderId }, shortKey(grp.senderId, 12, 8)), /* @__PURE__ */ React.createElement(
1640
+ } }, /* @__PURE__ */ React.createElement("span", { style: { display: "flex", alignItems: "center", gap: 8 } }, /* @__PURE__ */ React.createElement(DkEnsAvatar, { userid: grp.senderId, fallbackSeed: seed, size: 34, radius: 8 }), /* @__PURE__ */ React.createElement("span", { style: { fontFamily: "var(--mono)", fontSize: 12.5, fontWeight: 700, color: "var(--text)", wordBreak: "break-all" } }, grp.sender)), grp.senderId ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Mono, { size: 10.5, dim: true, copy: grp.senderId, title: grp.senderId }, shortKey(grp.senderId, 12, 8)), /* @__PURE__ */ React.createElement(
1641
1641
  "button",
1642
1642
  {
1643
1643
  onClick: addFriend,
@@ -2874,6 +2874,39 @@ function DkPunkAvatar({ id, size, radius, fallbackSeed }) {
2874
2874
  }
2875
2875
  );
2876
2876
  }
2877
+ const dkEnsAvCache = /* @__PURE__ */ new Map();
2878
+ function DkEnsAvatar({ userid, fallbackSeed, size, radius }) {
2879
+ const [pub, setPub] = React.useState(() => userid && dkEnsAvCache.has(userid) ? dkEnsAvCache.get(userid) : void 0);
2880
+ React.useEffect(() => {
2881
+ let dead = false;
2882
+ if (!userid) {
2883
+ setPub(null);
2884
+ return void 0;
2885
+ }
2886
+ if (dkEnsAvCache.has(userid)) {
2887
+ setPub(dkEnsAvCache.get(userid));
2888
+ return void 0;
2889
+ }
2890
+ fetch(`/api/ens-profile?userid=${encodeURIComponent(userid)}`).then((r) => r.json()).then((d) => {
2891
+ var _a;
2892
+ const v = d.ok && d.profile ? { avatarUrl: d.profile.avatarUrl || null, punkId: (_a = d.profile.punkId) != null ? _a : null } : null;
2893
+ dkEnsAvCache.set(userid, v);
2894
+ if (!dead)
2895
+ setPub(v);
2896
+ }).catch(() => {
2897
+ if (!dead)
2898
+ setPub(null);
2899
+ });
2900
+ return () => {
2901
+ dead = true;
2902
+ };
2903
+ }, [userid]);
2904
+ if (pub && pub.avatarUrl)
2905
+ return /* @__PURE__ */ React.createElement(DkImgAvatar, { url: pub.avatarUrl, seed: fallbackSeed || userid, size, radius });
2906
+ if (pub && pub.punkId != null)
2907
+ return /* @__PURE__ */ React.createElement(DkPunkAvatar, { id: pub.punkId, size, radius, fallbackSeed: fallbackSeed || userid });
2908
+ return /* @__PURE__ */ React.createElement(DkIdenticon, { seed: fallbackSeed || userid || "x", size, radius });
2909
+ }
2877
2910
  function DkPunkPicker({ T, onPick, onClose }) {
2878
2911
  const TYPES = ["any", "female", "male", "zombie", "ape", "alien"];
2879
2912
  const tLabel = (t) => T && T["pt_" + t] || t;
@@ -3211,7 +3244,7 @@ function ProfileTab({ T, me, onEdit }) {
3211
3244
  setEditing(false);
3212
3245
  } }));
3213
3246
  }
3214
- Object.assign(window, { ProfileTab, DkPunkAvatar, DkPublicProfile });
3247
+ Object.assign(window, { ProfileTab, DkPunkAvatar, DkEnsAvatar, DkPublicProfile });
3215
3248
  function DkDirAvatar({ p, size }) {
3216
3249
  const [broken, setBroken] = React.useState(false);
3217
3250
  if (p.punkId != null && !(p.avatar && !broken)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",