@decentnetwork/beagle 0.1.4 → 0.1.5

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.3";
1
+ window.__DK_UI_VERSION="0.1.4";
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"/>',
@@ -1313,9 +1313,27 @@ function dkSafeHref(s) {
1313
1313
  }
1314
1314
  return "";
1315
1315
  }
1316
+ function dkTrimUrlTail(raw) {
1317
+ let url = raw;
1318
+ const TAIL = `.,;:!?'"\u3002\uFF0C\u3001\uFF1B\uFF1A\uFF01\uFF1F\u2026\u201D\u2019\u300D\u300F`;
1319
+ const PAIRS = [["(", ")"], ["[", "]"], ["{", "}"], ["\uFF08", "\uFF09"], ["\u3010", "\u3011"], ["\u300A", "\u300B"]];
1320
+ const count = (s, ch) => s.split(ch).length - 1;
1321
+ for (; ; ) {
1322
+ const before = url;
1323
+ while (url && TAIL.indexOf(url[url.length - 1]) >= 0)
1324
+ url = url.slice(0, -1);
1325
+ for (let i = 0; i < PAIRS.length; i += 1) {
1326
+ const open = PAIRS[i][0], close = PAIRS[i][1];
1327
+ if (url.slice(-1) === close && count(url, open) < count(url, close))
1328
+ url = url.slice(0, -1);
1329
+ }
1330
+ if (url === before)
1331
+ return url;
1332
+ }
1333
+ }
1316
1334
  function dkInlineMarkdown(s) {
1317
1335
  const text = String(s == null ? "" : s);
1318
- const tokenRe = /(`[^`\n]+`|\[[^\]\n]+\]\([^) \n]+(?: [^)]+)?\)|\*\*[^*\n]+?\*\*|\*[^*\n]+?\*)/g;
1336
+ const tokenRe = /(`[^`\n]+`|\[[^\]\n]+\]\([^) \n]+(?: [^)]+)?\)|https?:\/\/[A-Za-z0-9\-._~:/?#[\]@!$&'()*+,;=%]+|\*\*[^*\n]+?\*\*|\*[^*\n]+?\*)/g;
1319
1337
  let out = "";
1320
1338
  let last = 0;
1321
1339
  let m;
@@ -1328,6 +1346,11 @@ function dkInlineMarkdown(s) {
1328
1346
  const lm = /^\[([^\]\n]+)\]\(([^) \n]+)(?: [^)]+)?\)$/.exec(tok);
1329
1347
  const href = lm && dkSafeHref(lm[2]);
1330
1348
  out += href ? '<a href="' + dkHtmlEscape(href) + '" target="_blank" rel="noopener">' + dkHtmlEscape(lm[1]) + "</a>" : dkHtmlEscape(tok);
1349
+ } else if (/^https?:\/\//.test(tok)) {
1350
+ const url = dkTrimUrlTail(tok);
1351
+ const href = dkSafeHref(url);
1352
+ const tail = tok.slice(url.length);
1353
+ out += href ? '<a href="' + dkHtmlEscape(href) + '" target="_blank" rel="noopener">' + dkHtmlEscape(url) + "</a>" + dkHtmlEscape(tail) : dkHtmlEscape(tok);
1331
1354
  } else if (tok.startsWith("**")) {
1332
1355
  out += "<strong>" + dkHtmlEscape(tok.slice(2, -2)) + "</strong>";
1333
1356
  } else if (tok.startsWith("*")) {
@@ -36,7 +36,12 @@
36
36
  .dk-md code { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-size: 0.92em; background: rgba(0,0,0,0.18); border-radius: 4px; padding: 0.08em 0.3em; }
37
37
  .dk-md pre { margin: 0.45em 0 0; padding: 8px 10px; overflow: auto; border-radius: 8px; background: rgba(0,0,0,0.22); }
38
38
  .dk-md pre code { display: block; background: transparent; padding: 0; white-space: pre; }
39
- .dk-md a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
39
+ /* color:inherit is deliberate the same rule has to read well on the dark
40
+ incoming bubble AND on the accent-coloured outgoing one, where a blue link
41
+ would clash. The affordance comes from the underline and the cursor. */
42
+ .dk-md a { color: inherit; text-decoration: underline; text-underline-offset: 2px;
43
+ cursor: pointer; overflow-wrap: anywhere; }
44
+ .dk-md a:hover { text-decoration-thickness: 2px; opacity: 0.85; }
40
45
  @keyframes dkpulse { 0% { transform: scale(0.9); opacity: 0.7; } 70% { transform: scale(1.5); opacity: 0; } 100% { opacity: 0; } }
41
46
  </style>
42
47
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/beagle",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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",