@vizejs/fresco 0.805.0 → 0.807.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,5 +1,5 @@
1
- import { A as useFocusManager, O as provideFocusScope, k as useFocus, m as getLastRenderLayout } from "./app-CjfLCWic.mjs";
2
- import { a as useInput, c as useIsScreenReaderEnabled, i as useMouse, n as createVirtualViewport, t as useBoxMetrics } from "./useBoxMetrics-BMD1acRU.mjs";
1
+ import { A as useFocusManager, O as provideFocusScope, k as useFocus, m as getLastRenderLayout } from "./app-CDSThgku.mjs";
2
+ import { a as useInput, c as useIsScreenReaderEnabled, i as useMouse, n as createVirtualViewport, t as useBoxMetrics } from "./useBoxMetrics-9FFVE-tA.mjs";
3
3
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, mergeProps, nextTick, normalizeStyle, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRaw, unref, useSlots, useTemplateRef, watch, withCtx } from "vue";
4
4
  //#region src/components/Box.ts
5
5
  /**
@@ -1689,8 +1689,56 @@ function mergeAdjacentSpans(spans) {
1689
1689
  }
1690
1690
  return merged;
1691
1691
  }
1692
+ /** A search that only moves forward, so text behind the last result is never scanned again. */
1693
+ function forwardSearch(search) {
1694
+ let found = Number.NEGATIVE_INFINITY;
1695
+ return (from) => {
1696
+ if (found !== -1 && found < from) found = search(from);
1697
+ return found;
1698
+ };
1699
+ }
1700
+ /**
1701
+ * Match `[label](url)` or `[label](url "title")` at an index of `content`.
1702
+ *
1703
+ * Each part ends at the first character that can end it, so it is located with a
1704
+ * forward search instead of a pattern retried at every index: a long run of
1705
+ * unmatched `[` is scanned once, not once per bracket.
1706
+ */
1707
+ function createLinkMatcher(content) {
1708
+ const urlBoundary = /[\s)]/gu;
1709
+ const labelEnd = forwardSearch((from) => content.indexOf("]", from));
1710
+ const urlEnd = forwardSearch((from) => {
1711
+ urlBoundary.lastIndex = from;
1712
+ return urlBoundary.exec(content)?.index ?? -1;
1713
+ });
1714
+ let titleFrom = -1;
1715
+ let titleLength = 0;
1716
+ return (index) => {
1717
+ if (content[index] !== "[") return void 0;
1718
+ const close = labelEnd(index + 1);
1719
+ if (close <= index + 1 || content[close + 1] !== "(") return void 0;
1720
+ const urlStart = close + 2;
1721
+ const boundary = urlEnd(urlStart);
1722
+ if (boundary <= urlStart) return void 0;
1723
+ let end = boundary;
1724
+ if (content[boundary] !== ")") {
1725
+ if (titleFrom !== boundary) {
1726
+ titleFrom = boundary;
1727
+ titleLength = /^\s+"[^"]*"/u.exec(content.slice(boundary))?.[0].length ?? 0;
1728
+ }
1729
+ end = boundary + titleLength;
1730
+ if (titleLength === 0 || content[end] !== ")") return void 0;
1731
+ }
1732
+ return {
1733
+ label: content.slice(index + 1, close),
1734
+ url: content.slice(urlStart, boundary),
1735
+ end: end + 1
1736
+ };
1737
+ };
1738
+ }
1692
1739
  function parseInline(content, options) {
1693
1740
  const spans = [];
1741
+ const matchLink = createLinkMatcher(content);
1694
1742
  let plain = "";
1695
1743
  const flush = () => {
1696
1744
  if (plain) spans.push({ text: plain });
@@ -1714,19 +1762,19 @@ function parseInline(content, options) {
1714
1762
  index += code[0].length;
1715
1763
  continue;
1716
1764
  }
1717
- const link = /^\[([^\]]+)\]\(([^\s)]+)(?:\s+"[^"]*")?\)/u.exec(rest);
1765
+ const link = matchLink(index);
1718
1766
  if (link) {
1719
1767
  flush();
1720
1768
  spans.push({
1721
- text: link[1] ?? "",
1769
+ text: link.label,
1722
1770
  fg: options.linkFg,
1723
1771
  underline: true
1724
1772
  });
1725
1773
  spans.push({
1726
- text: ` (${link[2] ?? ""})`,
1774
+ text: ` (${link.url})`,
1727
1775
  dim: true
1728
1776
  });
1729
- index += link[0].length;
1777
+ index = link.end;
1730
1778
  continue;
1731
1779
  }
1732
1780
  const strong = /^(\*\*|__)(.+?)\1/u.exec(rest);
@@ -7055,4 +7103,4 @@ var FrescoAvatar_default = /* @__PURE__ */ defineComponent({
7055
7103
  //#endregion
7056
7104
  export { FrescoFrameBuffer_default as A, FrescoNewline_default as B, RadioGroup as C, TextInput as D, TextArea as E, Code as F, Grid as G, ScrollBar_default as H, createCodeBuffer as I, FrescoStack_default as J, FrescoVStack_default as K, LineNumber as L, defaultMarkdownRenderer as M, parseMarkdown as N, FrescoLink_default as O, renderMarkdown as P, FrescoTransform_default as R, Confirm as S, FrescoSelect_default as T, Text as U, ScrollBox_default as V, FrescoCard_default as W, FrescoSpacer_default as X, FrescoDivider_default as Y, Box as Z, FrescoAlert_default as _, FrescoPopover_default as a, Form as b, FrescoBreadcrumb_default as c, FrescoTree_default as d, Table as f, FrescoBadge_default as g, Timer as h, StatusBar as i, FrescoMarkdown_default as j, Diff as k, FrescoTabs_default as l, FrescoTooltip_default as m, KeyHint as n, FrescoModal_default as o, FrescoList_default as p, FrescoHStack_default as q, FrescoHeader_default as r, Stepper as s, FrescoAvatar_default as t, FrescoMenu_default as u, ProgressBar as v, Checkbox as w, FrescoSlider_default as x, FrescoSpinner_default as y, FrescoStatic_default as z };
7057
7105
 
7058
- //# sourceMappingURL=components-B-HgL5id.mjs.map
7106
+ //# sourceMappingURL=components-BzxfzImn.mjs.map