@aiquants/markdown-explorer 0.35.0 → 0.36.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +31 -2
  3. package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
  4. package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
  5. package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
  6. package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
  7. package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
  8. package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
  9. package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
  10. package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
  11. package/dist/TreeLayout-DsSKW_Qj.js +103 -0
  12. package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
  13. package/dist/core/config.d.cts +6 -0
  14. package/dist/core/config.d.ts +6 -0
  15. package/dist/core/contracts.d.cts +21 -0
  16. package/dist/core/contracts.d.ts +21 -0
  17. package/dist/core/dataRoute.d.cts +5 -1
  18. package/dist/core/dataRoute.d.ts +5 -1
  19. package/dist/core/documentId.d.cts +6 -0
  20. package/dist/core/documentId.d.ts +6 -0
  21. package/dist/core/labels.d.cts +10 -0
  22. package/dist/core/labels.d.ts +10 -0
  23. package/dist/core/location.d.cts +21 -0
  24. package/dist/core/location.d.ts +21 -0
  25. package/dist/explorerCore-B3RGmMG6.js +1083 -0
  26. package/dist/explorerCore-CUkyKtm8.cjs +1 -0
  27. package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
  28. package/dist/index-lpL7GltU.cjs +18 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +2 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +38 -33
  33. package/dist/location-Dh6K-y7w.js +761 -0
  34. package/dist/location-DrOP6t1F.cjs +1 -0
  35. package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
  36. package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
  37. package/dist/ownUrls-BTPGNhBt.cjs +1 -0
  38. package/dist/ownUrls-DD0cSCsF.js +409 -0
  39. package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
  40. package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
  41. package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
  42. package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
  43. package/dist/sanitizeWorker.cjs +1 -1
  44. package/dist/sanitizeWorker.js +3 -3
  45. package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
  46. package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
  47. package/dist/server/errors.d.cts +1 -1
  48. package/dist/server/errors.d.ts +1 -1
  49. package/dist/server/ports.d.cts +19 -0
  50. package/dist/server/ports.d.ts +19 -0
  51. package/dist/server.cjs +1 -1
  52. package/dist/server.d.cts +1 -1
  53. package/dist/server.d.ts +1 -1
  54. package/dist/server.js +6 -6
  55. package/dist/serverBrowser.cjs +1 -1
  56. package/dist/serverBrowser.js +3 -3
  57. package/dist/serverCore.cjs +1 -1
  58. package/dist/serverCore.d.cts +1 -1
  59. package/dist/serverCore.d.ts +1 -1
  60. package/dist/serverCore.js +4 -4
  61. package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
  62. package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
  63. package/dist/testing.cjs +1 -1
  64. package/dist/testing.d.cts +5 -0
  65. package/dist/testing.d.ts +5 -0
  66. package/dist/testing.js +80 -2
  67. package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
  68. package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
  69. package/docs/behavior/dom-hooks.md +3 -1
  70. package/docs/behavior/security.md +23 -2
  71. package/docs/behavior/url-contract.md +26 -0
  72. package/package.json +2 -2
  73. package/dist/TreeLayout-AxLw-36S.js +0 -103
  74. package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
  75. package/dist/explorerCore-DLpDuSev.js +0 -998
  76. package/dist/explorerCore-DYrxS9ez.cjs +0 -1
  77. package/dist/index-LQWQfpAf.cjs +0 -18
  78. package/dist/location--KvTA0Ri.js +0 -726
  79. package/dist/location-D8DyDkuA.cjs +0 -1
  80. package/dist/ownUrls-B259RGgd.cjs +0 -1
  81. package/dist/ownUrls-Dh5g6ZJi.js +0 -370
@@ -1,13 +1,13 @@
1
1
  import { jsxs as ae, jsx as A } from "react/jsx-runtime";
2
2
  import { createContext as Xe, use as Ae, useRef as q, useState as $, useLayoutEffect as F, useMemo as D, useSyncExternalStore as Ze, useCallback as R, memo as Qe, useEffect as U, useImperativeHandle as en } from "react";
3
3
  import { d as J } from "./describeValue-CLlVRO8d.js";
4
- import { n as ue, e as Me, q as nn, P as tn, s as on } from "./location--KvTA0Ri.js";
5
- import { R as rn, u as X, S as ln, U as sn, D as an, j as cn, g as un, V, J as dn, i as ke, W as mn, N as fn, X as Ie, Y as pn, Z as gn, _ as Le, $ as hn, a0 as Re, a1 as vn } from "./index-C1YMH-yI.js";
6
- import { S as wn, a as yn, b as Sn } from "./ExplorerSplit-CfP1smbT.js";
4
+ import { s as ue, e as Me, u as nn, P as tn, v as on } from "./location-Dh6K-y7w.js";
5
+ import { R as rn, u as X, S as ln, U as sn, D as an, j as cn, g as un, V, J as dn, i as ke, W as mn, N as fn, X as Ie, Y as pn, Z as gn, _ as Le, $ as hn, a0 as Re, a1 as vn } from "./index-D0l_BJqb.js";
6
+ import { S as wn, a as yn, b as Sn } from "./ExplorerSplit-Bgccz2nm.js";
7
7
  import { SCROLL_AREA_SELECTOR as De, SCROLL_ROOT_SELECTOR as oe, PANEL_ACTION_ATTRIBUTE as ve, generateColumnIds as xn, sortColumnIds as _e, generateColumnId as ze, NO_PANEL_DRAG_ATTRIBUTE as En, useDragDropColumns as On, DEFAULT_DEBUG_CONFIG as we, DragDropLayout as Pn } from "@aiquants/drag-drop-panels";
8
8
  import { useNavigate as bn, useLocation as Cn } from "react-router";
9
9
  import { s as Tn, r as Nn, w as An } from "./storage-D1uSw-xj.js";
10
- import { l as Mn, i as kn } from "./ownUrls-Dh5g6ZJi.js";
10
+ import { l as Mn, i as kn } from "./ownUrls-DD0cSCsF.js";
11
11
  import { createPortal as In } from "react-dom";
12
12
  import { HostedScrollArea as Ln } from "@aiquants/markdown";
13
13
  const Rn = () => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),S=require("react"),u=require("./index-LQWQfpAf.cjs"),d=require("./tapScrollCircle-DdX0Wri0.cjs"),v=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),m=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=v(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const a=v(e);m(t,a)||(t=a,s())};let n=0;const c=()=>{n===0&&(n=requestAnimationFrame(()=>{n=0,o()}))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(c),l=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const a of e.children)r.observe(a)}};l();const i=typeof MutationObserver>"u"?null:new MutationObserver(()=>{l(),c()});return i?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),i?.disconnect(),r?.disconnect(),cancelAnimationFrame(n)}}}},b=e=>{const t=S.useMemo(()=>g(e),[e]);return S.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},h=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},f=({scroller:e,kind:t})=>{const{locale:s}=u.useExplorer(),o=u.useCoarsePointer(),{scrollTop:n,scrollHeight:c,clientHeight:r}=b(e),l=S.useCallback(i=>h(e,i),[e]);return p.jsx("div",{className:"aqmx-native-scroll-bar",children:p.jsx(T.ScrollBar,{contentSize:c,viewportSize:r,scrollPosition:n,onScroll:l,scrollBarWidth:u.NATIVE_SCROLL_BAR_WIDTH,...u.scrollBarControlsFor(o),enableArrowButtonTabStops:!1,tapScrollCircleOptions:t==="content"?d.tapScrollCircleFor(o):d.NO_TAP_SCROLL_CIRCLE,locale:s})})};exports.NativeScrollBar=f;exports.scrollScrollerTo=h;exports.useScrollerMetrics=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),S=require("react"),u=require("./index-lpL7GltU.cjs"),d=require("./tapScrollCircle-DyLInGck.cjs"),v=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),m=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=v(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const a=v(e);m(t,a)||(t=a,s())};let n=0;const c=()=>{n===0&&(n=requestAnimationFrame(()=>{n=0,o()}))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(c),l=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const a of e.children)r.observe(a)}};l();const i=typeof MutationObserver>"u"?null:new MutationObserver(()=>{l(),c()});return i?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),i?.disconnect(),r?.disconnect(),cancelAnimationFrame(n)}}}},b=e=>{const t=S.useMemo(()=>g(e),[e]);return S.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},h=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},f=({scroller:e,kind:t})=>{const{locale:s}=u.useExplorer(),o=u.useCoarsePointer(),{scrollTop:n,scrollHeight:c,clientHeight:r}=b(e),l=S.useCallback(i=>h(e,i),[e]);return p.jsx("div",{className:"aqmx-native-scroll-bar",children:p.jsx(T.ScrollBar,{contentSize:c,viewportSize:r,scrollPosition:n,onScroll:l,scrollBarWidth:u.NATIVE_SCROLL_BAR_WIDTH,...u.scrollBarControlsFor(o),enableArrowButtonTabStops:!1,tapScrollCircleOptions:t==="content"?d.tapScrollCircleFor(o):d.NO_TAP_SCROLL_CIRCLE,locale:s})})};exports.NativeScrollBar=f;exports.scrollScrollerTo=h;exports.useScrollerMetrics=b;
@@ -1,8 +1,8 @@
1
1
  import { jsx as u } from "react/jsx-runtime";
2
2
  import { ScrollBar as m } from "@aiquants/virtualscroll";
3
3
  import { useCallback as S, useMemo as d, useSyncExternalStore as h } from "react";
4
- import { u as b, c as v, N as f, s as T } from "./index-C1YMH-yI.js";
5
- import { NO_TAP_SCROLL_CIRCLE as g, tapScrollCircleFor as H } from "./tapScrollCircle-BEydRn0y.js";
4
+ import { u as b, c as v, N as f, s as T } from "./index-D0l_BJqb.js";
5
+ import { NO_TAP_SCROLL_CIRCLE as g, tapScrollCircleFor as H } from "./tapScrollCircle-smKLgRa2.js";
6
6
  const p = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), C = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, O = (e) => {
7
7
  let t = p(e);
8
8
  return {
@@ -0,0 +1,103 @@
1
+ import { jsx as h, jsxs as j } from "react/jsx-runtime";
2
+ import { useCallback as d, useMemo as v, useEffect as g, useSyncExternalStore as q, useState as H, useRef as U, useLayoutEffect as $ } from "react";
3
+ import { useLocation as B } from "react-router";
4
+ import { e as f, c as Y } from "./location-Dh6K-y7w.js";
5
+ import { u as S, f as R, r as J, F as K, g as Q, h as V, i as W, D as X, P as Z, j as I } from "./index-D0l_BJqb.js";
6
+ import { isMaximizeEscape as ee } from "@aiquants/drag-drop-panels";
7
+ import { l as te } from "./ownUrls-DD0cSCsF.js";
8
+ import { E as ne, a as re, b as se } from "./ExplorerSplit-Bgccz2nm.js";
9
+ const ae = (e) => {
10
+ const { config: r, labels: n, announcer: t } = S(), c = R(), s = d(() => {
11
+ const u = e.doc !== null ? e.doc : e.folder;
12
+ if (u === null) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");
13
+ c(f(r, { ...e, maximized: !e.maximized }), "browse");
14
+ const a = te(u);
15
+ t.announce(e.maximized ? n.documentRestored(a) : n.documentMaximized(a));
16
+ }, [r, c, e, t, n]);
17
+ return v(() => ({ maximized: e.maximized, toggle: s }), [e.maximized, s]);
18
+ }, oe = (e, r) => {
19
+ g(() => {
20
+ if (!e) return;
21
+ const n = (t) => {
22
+ ee(t) && (t.preventDefault(), r());
23
+ };
24
+ return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
25
+ }, [e, r]);
26
+ }, ue = (e, r) => e.claim !== r.claim || e.readme.status !== r.readme.status ? !1 : e.readme.status === "failed" && r.readme.status === "failed" ? e.readme.failure === r.readme.failure : e.readme.status === "ok" && r.readme.status === "ok" ? e.readme.readme === r.readme.readme : !0, ie = (e, r, n) => {
27
+ let t = null;
28
+ return () => {
29
+ const c = e.version(), s = e.read(r), u = s.status !== "pending";
30
+ if (t !== null && t.version === c && t.tree === s && t.settled === u) return t.state;
31
+ const a = J(e, r, n), o = t !== null && ue(t.state, a) ? t.state : a;
32
+ return t = { version: c, tree: s, settled: u, state: o }, o;
33
+ };
34
+ }, ce = (e, r, n) => {
35
+ let t = !0, c = null;
36
+ const s = () => {
37
+ t && n();
38
+ }, u = () => {
39
+ const o = e.read(r);
40
+ o === c || o.status !== "pending" || (c = o, o.then(s, s));
41
+ };
42
+ u();
43
+ const a = e.subscribe(() => {
44
+ u(), n();
45
+ });
46
+ return () => {
47
+ t = !1, a();
48
+ };
49
+ }, le = () => K, me = (e, r) => {
50
+ const { trees: n } = S(), t = v(() => r === null ? null : ie(n, e, r), [n, e, r]), c = d((m) => t === null ? () => {
51
+ } : ce(n, e, m), [t, n, e]), s = d(() => t === null ? null : t(), [t]), u = d(() => t === null ? null : le(), [t]), a = q(c, s, u), o = a?.claim === !0;
52
+ return g(() => r === null ? void 0 : n.open(e), [n, e, r]), g(() => r === null || !o ? void 0 : n.claimChildren(e, /* @__PURE__ */ new Map([[r, "direct"]])), [n, e, r, o]), a === null ? null : a.readme;
53
+ }, de = /* @__PURE__ */ new Set(), pe = Object.freeze({ kind: "loading" }), fe = (e, r) => r.status === "loading" ? pe : r.status === "failed" ? { kind: "failure", folder: e, failure: r.failure, onRetry: r.retry } : { kind: "no-readme", folder: e }, be = ({ location: e, opening: r }) => {
54
+ const { config: n } = S(), t = R(), { hash: c } = B(), { source: s, doc: u, folder: a, overrides: o, markup: m, maximized: p } = e, [k, M] = H(ne), N = v(() => ({ gathered: k, onGatheredChange: M }), [k]), w = me(s, a), l = w === null ? u : w.status === "ok" ? w.readme : null, b = v(() => r !== null ? r : a === null || w === null ? Q : fe(a, w), [r, a, w]), E = p && (l !== null || b.kind === "loading"), P = d((i) => t(f(n, { view: "tree", source: s, doc: i, overrides: o }), "browse"), [t, n, s, o]), F = d((i) => t(f(n, { view: "tree", source: s, folder: i, overrides: o }), "browse"), [t, n, s, o]), T = d(
55
+ (i) => {
56
+ const x = i.kind === "folder" ? { folder: i.path } : i.kind === "document" ? { doc: i.path } : {};
57
+ t(f(n, { view: "tree", source: s, ...x, overrides: o }), "close-folder");
58
+ },
59
+ [t, n, s, o]
60
+ ), C = d((i) => t(f(n, { view: "tree", source: i, doc: u, folder: a, overrides: o, markup: m, maximized: p }), "switch-source"), [t, n, u, a, o, m, p]), L = d((i) => t(`${f(n, { view: "tree", source: i, doc: u, folder: a, overrides: o, markup: m, maximized: p })}${c}`, "browse"), [t, n, u, a, o, m, p, c]), _ = d(
61
+ (i) => {
62
+ const x = Y(n, i);
63
+ t(f(n, { view: "multi", source: s, docs: x, markup: m && l !== null && x.includes(l) ? [l] : [] }), "switch-view");
64
+ },
65
+ [t, n, s, l, m]
66
+ ), y = v(() => ({ href: f(n, l === null ? { view: "multi", source: s } : { view: "multi", source: s, docs: [l], markup: m ? [l] : [] }), target: "multi" }), [n, s, l, m]), z = U(p);
67
+ $(() => {
68
+ z.current = p;
69
+ }, [p]);
70
+ const O = d(() => z.current, []), A = v(() => ({ kind: "page", view: "tree", overrides: o, embed: {}, maximized: O }), [o, O]), G = V(e), D = ae(e);
71
+ return oe(E, D.toggle), /* @__PURE__ */ h(
72
+ re,
73
+ {
74
+ view: "tree",
75
+ contentCoversPage: E,
76
+ explorer: /* @__PURE__ */ h(
77
+ se,
78
+ {
79
+ mode: "tree",
80
+ sourceId: s,
81
+ currentPath: a === null ? u : a,
82
+ openPaths: de,
83
+ onOpenDocument: P,
84
+ onOpenFolder: F,
85
+ onCloseFolder: T,
86
+ currentFolder: a !== null,
87
+ onSourceChange: C,
88
+ onRevealSource: L,
89
+ viewSwitch: y,
90
+ tray: N,
91
+ onOpenSelection: _
92
+ }
93
+ ),
94
+ content: /* @__PURE__ */ j("div", { className: "aqmx-document-column aqmx-tree-document", "data-aqmx-maximized": E ? "true" : "false", ...W, children: [
95
+ l === null ? null : /* @__PURE__ */ h(X, { path: l, placement: Z, markup: G, maximize: D }),
96
+ /* @__PURE__ */ h(I, { path: l, absence: b, markup: m, variant: A })
97
+ ] })
98
+ }
99
+ );
100
+ };
101
+ export {
102
+ be as TreeLayout
103
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),o=require("react"),H=require("react-router"),x=require("./location-DrOP6t1F.cjs"),d=require("./index-lpL7GltU.cjs"),_=require("@aiquants/drag-drop-panels"),j=require("./ownUrls-BTPGNhBt.cjs"),k=require("./ExplorerSplit-BNrHrIus.cjs"),A=e=>{const{config:r,labels:n,announcer:t}=d.useExplorer(),i=d.useExplorerNavigate(),s=o.useCallback(()=>{const u=e.doc!==null?e.doc:e.folder;if(u===null)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");i(x.explorerHref(r,{...e,maximized:!e.maximized}),"browse");const a=j.lastPathSegment(u);t.announce(e.maximized?n.documentRestored(a):n.documentMaximized(a))},[r,i,e,t,n]);return o.useMemo(()=>({maximized:e.maximized,toggle:s}),[e.maximized,s])},G=(e,r)=>{o.useEffect(()=>{if(!e)return;const n=t=>{_.isMaximizeEscape(t)&&(t.preventDefault(),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r])},U=(e,r)=>e.claim!==r.claim||e.readme.status!==r.readme.status?!1:e.readme.status==="failed"&&r.readme.status==="failed"?e.readme.failure===r.readme.failure:e.readme.status==="ok"&&r.readme.status==="ok"?e.readme.readme===r.readme.readme:!0,B=(e,r,n)=>{let t=null;return()=>{const i=e.version(),s=e.read(r),u=s.status!=="pending";if(t!==null&&t.version===i&&t.tree===s&&t.settled===u)return t.state;const a=d.readFolderReadme(e,r,n),l=t!==null&&U(t.state,a)?t.state:a;return t={version:i,tree:s,settled:u,state:l},l}},Y=(e,r,n)=>{let t=!0,i=null;const s=()=>{t&&n()},u=()=>{const l=e.read(r);l===i||l.status!=="pending"||(i=l,l.then(s,s))};u();const a=e.subscribe(()=>{u(),n()});return()=>{t=!1,a()}},J=()=>d.FOLDER_README_LOADING,K=(e,r)=>{const{trees:n}=d.useExplorer(),t=o.useMemo(()=>r===null?null:B(n,e,r),[n,e,r]),i=o.useCallback(p=>t===null?()=>{}:Y(n,e,p),[t,n,e]),s=o.useCallback(()=>t===null?null:t(),[t]),u=o.useCallback(()=>t===null?null:J(),[t]),a=o.useSyncExternalStore(i,s,u),l=a?.claim===!0;return o.useEffect(()=>r===null?void 0:n.open(e),[n,e,r]),o.useEffect(()=>r===null||!l?void 0:n.claimChildren(e,new Map([[r,"direct"]])),[n,e,r,l]),a===null?null:a.readme},Q=new Set,V=Object.freeze({kind:"loading"}),W=(e,r)=>r.status==="loading"?V:r.status==="failed"?{kind:"failure",folder:e,failure:r.failure,onRetry:r.retry}:{kind:"no-readme",folder:e},X=({location:e,opening:r})=>{const{config:n}=d.useExplorer(),t=d.useExplorerNavigate(),{hash:i}=H.useLocation(),{source:s,doc:u,folder:a,overrides:l,markup:p,maximized:f}=e,[g,M]=o.useState(k.EMPTY_SELECTION),O=o.useMemo(()=>({gathered:g,onGatheredChange:M}),[g]),w=K(s,a),m=w===null?u:w.status==="ok"?w.readme:null,h=o.useMemo(()=>r!==null?r:a===null||w===null?d.NO_DOCUMENT:W(a,w),[r,a,w]),b=f&&(m!==null||h.kind==="loading"),R=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:s,doc:c,overrides:l}),"browse"),[t,n,s,l]),D=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:s,folder:c,overrides:l}),"browse"),[t,n,s,l]),N=o.useCallback(c=>{const E=c.kind==="folder"?{folder:c.path}:c.kind==="document"?{doc:c.path}:{};t(x.explorerHref(n,{view:"tree",source:s,...E,overrides:l}),"close-folder")},[t,n,s,l]),P=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:c,doc:u,folder:a,overrides:l,markup:p,maximized:f}),"switch-source"),[t,n,u,a,l,p,f]),T=o.useCallback(c=>t(`${x.explorerHref(n,{view:"tree",source:c,doc:u,folder:a,overrides:l,markup:p,maximized:f})}${i}`,"browse"),[t,n,u,a,l,p,f,i]),q=o.useCallback(c=>{const E=x.canonicalMultiDocuments(n,c);t(x.explorerHref(n,{view:"multi",source:s,docs:E,markup:p&&m!==null&&E.includes(m)?[m]:[]}),"switch-view")},[t,n,s,m,p]),y=o.useMemo(()=>({href:x.explorerHref(n,m===null?{view:"multi",source:s}:{view:"multi",source:s,docs:[m],markup:p?[m]:[]}),target:"multi"}),[n,s,m,p]),S=o.useRef(f);o.useLayoutEffect(()=>{S.current=f},[f]);const C=o.useCallback(()=>S.current,[]),F=o.useMemo(()=>({kind:"page",view:"tree",overrides:l,embed:{},maximized:C}),[l,C]),L=d.usePageMarkupToggle(e),z=A(e);return G(b,z.toggle),v.jsx(k.ExplorerSplit,{view:"tree",contentCoversPage:b,explorer:v.jsx(k.ExplorerPane,{mode:"tree",sourceId:s,currentPath:a===null?u:a,openPaths:Q,onOpenDocument:R,onOpenFolder:D,onCloseFolder:N,currentFolder:a!==null,onSourceChange:P,onRevealSource:T,viewSwitch:y,tray:O,onOpenSelection:q}),content:v.jsxs("div",{className:"aqmx-document-column aqmx-tree-document","data-aqmx-maximized":b?"true":"false",...d.CONTENT_PANE,children:[m===null?null:v.jsx(d.DocumentRefreshBar,{path:m,placement:d.PAGE_DOCUMENT_REFRESH,markup:L,maximize:z}),v.jsx(d.DocumentPane,{path:m,absence:h,markup:p,variant:F})]})})};exports.TreeLayout=X;
@@ -14,6 +14,9 @@ export type ExplorerConfigInput = {
14
14
  readonly dataPath: string;
15
15
  readonly settingsCookie: string;
16
16
  readonly views?: Partial<ExplorerViewSlugs>;
17
+ readonly documentIds?: {
18
+ readonly slug: string;
19
+ };
17
20
  readonly multiView?: {
18
21
  readonly maxPanels?: number;
19
22
  readonly columns?: number;
@@ -47,6 +50,9 @@ export type ExplorerConfig = {
47
50
  readonly dataPath: string;
48
51
  readonly settingsCookie: string;
49
52
  readonly views: ExplorerViewSlugs;
53
+ readonly documentIds: {
54
+ readonly slug: string;
55
+ } | null;
50
56
  readonly multiView: {
51
57
  readonly maxPanels: number;
52
58
  readonly columns: number;
@@ -14,6 +14,9 @@ export type ExplorerConfigInput = {
14
14
  readonly dataPath: string;
15
15
  readonly settingsCookie: string;
16
16
  readonly views?: Partial<ExplorerViewSlugs>;
17
+ readonly documentIds?: {
18
+ readonly slug: string;
19
+ };
17
20
  readonly multiView?: {
18
21
  readonly maxPanels?: number;
19
22
  readonly columns?: number;
@@ -47,6 +50,9 @@ export type ExplorerConfig = {
47
50
  readonly dataPath: string;
48
51
  readonly settingsCookie: string;
49
52
  readonly views: ExplorerViewSlugs;
53
+ readonly documentIds: {
54
+ readonly slug: string;
55
+ } | null;
50
56
  readonly multiView: {
51
57
  readonly maxPanels: number;
52
58
  readonly columns: number;
@@ -111,6 +111,21 @@ export type ExplorerRevealResult = {
111
111
  readonly status: "error";
112
112
  readonly failure: ExplorerFailure;
113
113
  };
114
+ export type ExplorerIssuedDocumentId = {
115
+ readonly status: "ok";
116
+ readonly id: string;
117
+ } | {
118
+ readonly status: "error";
119
+ readonly failure: ExplorerFailure;
120
+ };
121
+ export type ExplorerResolvedDocumentId = {
122
+ readonly status: "ok";
123
+ readonly path: string;
124
+ readonly source: string;
125
+ } | {
126
+ readonly status: "error";
127
+ readonly failure: ExplorerFailure;
128
+ };
114
129
  export type ExplorerHeading = {
115
130
  readonly text: string;
116
131
  readonly depth: number;
@@ -259,6 +274,8 @@ export declare const entryViolation: (value: unknown) => string | null;
259
274
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
260
275
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
261
276
  export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
277
+ export declare const isExplorerIssuedDocumentId: (value: unknown) => value is ExplorerIssuedDocumentId;
278
+ export declare const isExplorerResolvedDocumentId: (value: unknown) => value is ExplorerResolvedDocumentId;
262
279
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
263
280
  export declare const headingViolation: (value: unknown) => string | null;
264
281
  export declare const isExplorerDocumentLang: (value: unknown) => value is string;
@@ -294,4 +311,8 @@ export type ExplorerPageData = {
294
311
  } | null;
295
312
  readonly documents: readonly ExplorerSeededDocument[];
296
313
  readonly notices: Promise<readonly ExplorerNotice[]>;
314
+ readonly documentId: {
315
+ readonly id: string | null;
316
+ readonly failure: ExplorerFailure;
317
+ } | null;
297
318
  };
@@ -111,6 +111,21 @@ export type ExplorerRevealResult = {
111
111
  readonly status: "error";
112
112
  readonly failure: ExplorerFailure;
113
113
  };
114
+ export type ExplorerIssuedDocumentId = {
115
+ readonly status: "ok";
116
+ readonly id: string;
117
+ } | {
118
+ readonly status: "error";
119
+ readonly failure: ExplorerFailure;
120
+ };
121
+ export type ExplorerResolvedDocumentId = {
122
+ readonly status: "ok";
123
+ readonly path: string;
124
+ readonly source: string;
125
+ } | {
126
+ readonly status: "error";
127
+ readonly failure: ExplorerFailure;
128
+ };
114
129
  export type ExplorerHeading = {
115
130
  readonly text: string;
116
131
  readonly depth: number;
@@ -259,6 +274,8 @@ export declare const entryViolation: (value: unknown) => string | null;
259
274
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
260
275
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
261
276
  export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
277
+ export declare const isExplorerIssuedDocumentId: (value: unknown) => value is ExplorerIssuedDocumentId;
278
+ export declare const isExplorerResolvedDocumentId: (value: unknown) => value is ExplorerResolvedDocumentId;
262
279
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
263
280
  export declare const headingViolation: (value: unknown) => string | null;
264
281
  export declare const isExplorerDocumentLang: (value: unknown) => value is string;
@@ -294,4 +311,8 @@ export type ExplorerPageData = {
294
311
  } | null;
295
312
  readonly documents: readonly ExplorerSeededDocument[];
296
313
  readonly notices: Promise<readonly ExplorerNotice[]>;
314
+ readonly documentId: {
315
+ readonly id: string | null;
316
+ readonly failure: ExplorerFailure;
317
+ } | null;
297
318
  };
@@ -13,7 +13,9 @@ export declare const EXPLORER_DATA_OPERATIONS: readonly [
13
13
  "revision",
14
14
  "refresh",
15
15
  "asset",
16
- "link-card"
16
+ "link-card",
17
+ "issue-id",
18
+ "resolve-id"
17
19
  ];
18
20
  export type ExplorerDataOperation = (typeof EXPLORER_DATA_OPERATIONS)[number];
19
21
  export declare const EXPLORER_DATA_QUERY: Readonly<{
@@ -23,6 +25,7 @@ export declare const EXPLORER_DATA_QUERY: Readonly<{
23
25
  readonly base: "base";
24
26
  readonly revision: "revision";
25
27
  readonly display: "as";
28
+ readonly id: "id";
26
29
  }>;
27
30
  export declare const explorerAssetHref: (dataPath: string, path: string, version: string | null) => string;
28
31
  export type ExplorerAssetDisplay = "file" | "text" | "workbook";
@@ -34,6 +37,7 @@ export declare const EXPLORER_SCOPE_HEADER = "X-Markdown-Explorer-Scope";
34
37
  export declare const EXPLORER_PROOF_HEADER = "X-Markdown-Explorer";
35
38
  export declare const EXPLORER_REFRESH_PROOF = "refresh";
36
39
  export declare const EXPLORER_EDIT_PROOF = "edit";
40
+ export declare const EXPLORER_DOCUMENT_ID_PROOF = "document-id";
37
41
  export declare const EXPLORER_DRAFT_MEDIA_TYPE = "text/markdown";
38
42
  export declare const isExplorerDataOperation: (segment: string | undefined) => segment is ExplorerDataOperation;
39
43
  export declare const EXPLORER_FAILURE_STATUS: Readonly<Record<ExplorerFailureReason, number>>;
@@ -13,7 +13,9 @@ export declare const EXPLORER_DATA_OPERATIONS: readonly [
13
13
  "revision",
14
14
  "refresh",
15
15
  "asset",
16
- "link-card"
16
+ "link-card",
17
+ "issue-id",
18
+ "resolve-id"
17
19
  ];
18
20
  export type ExplorerDataOperation = (typeof EXPLORER_DATA_OPERATIONS)[number];
19
21
  export declare const EXPLORER_DATA_QUERY: Readonly<{
@@ -23,6 +25,7 @@ export declare const EXPLORER_DATA_QUERY: Readonly<{
23
25
  readonly base: "base";
24
26
  readonly revision: "revision";
25
27
  readonly display: "as";
28
+ readonly id: "id";
26
29
  }>;
27
30
  export declare const explorerAssetHref: (dataPath: string, path: string, version: string | null) => string;
28
31
  export type ExplorerAssetDisplay = "file" | "text" | "workbook";
@@ -34,6 +37,7 @@ export declare const EXPLORER_SCOPE_HEADER = "X-Markdown-Explorer-Scope";
34
37
  export declare const EXPLORER_PROOF_HEADER = "X-Markdown-Explorer";
35
38
  export declare const EXPLORER_REFRESH_PROOF = "refresh";
36
39
  export declare const EXPLORER_EDIT_PROOF = "edit";
40
+ export declare const EXPLORER_DOCUMENT_ID_PROOF = "document-id";
37
41
  export declare const EXPLORER_DRAFT_MEDIA_TYPE = "text/markdown";
38
42
  export declare const isExplorerDataOperation: (segment: string | undefined) => segment is ExplorerDataOperation;
39
43
  export declare const EXPLORER_FAILURE_STATUS: Readonly<Record<ExplorerFailureReason, number>>;
@@ -0,0 +1,6 @@
1
+ export declare const DOCUMENT_ID_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
+ export declare const DOCUMENT_ID_LENGTH = 12;
3
+ export declare const isCanonicalDocumentId: (value: unknown) => value is string;
4
+ export declare const parseDocumentId: (written: string) => string | null;
5
+ export declare const createDocumentId: (fillRandom: (bytes: Uint8Array<ArrayBuffer>) => void) => string;
6
+ export declare const groupDocumentId: (id: string) => string;
@@ -0,0 +1,6 @@
1
+ export declare const DOCUMENT_ID_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
2
+ export declare const DOCUMENT_ID_LENGTH = 12;
3
+ export declare const isCanonicalDocumentId: (value: unknown) => value is string;
4
+ export declare const parseDocumentId: (written: string) => string | null;
5
+ export declare const createDocumentId: (fillRandom: (bytes: Uint8Array<ArrayBuffer>) => void) => string;
6
+ export declare const groupDocumentId: (id: string) => string;
@@ -213,6 +213,16 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
213
213
  readonly copyText: string;
214
214
  readonly copiedText: string;
215
215
  readonly copyTextFailed: string;
216
+ readonly copyPermalinkLabel: string;
217
+ readonly copyPermalink: string;
218
+ readonly copyPermalinkNamed: (name: string) => string;
219
+ readonly permalinkCopied: (groupedId: string) => string;
220
+ readonly permalinkCopyFailed: (reason: string) => string;
221
+ readonly permalinkClipboardRefused: string;
222
+ readonly documentIdFailedTitle: string;
223
+ readonly documentIdInvalid: string;
224
+ readonly documentIdNotFound: string;
225
+ readonly documentIdForbidden: string;
216
226
  readonly mediaUnsupported: string;
217
227
  readonly fileNotShown: string;
218
228
  readonly pdfNotShown: string;
@@ -213,6 +213,16 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
213
213
  readonly copyText: string;
214
214
  readonly copiedText: string;
215
215
  readonly copyTextFailed: string;
216
+ readonly copyPermalinkLabel: string;
217
+ readonly copyPermalink: string;
218
+ readonly copyPermalinkNamed: (name: string) => string;
219
+ readonly permalinkCopied: (groupedId: string) => string;
220
+ readonly permalinkCopyFailed: (reason: string) => string;
221
+ readonly permalinkClipboardRefused: string;
222
+ readonly documentIdFailedTitle: string;
223
+ readonly documentIdInvalid: string;
224
+ readonly documentIdNotFound: string;
225
+ readonly documentIdForbidden: string;
216
226
  readonly mediaUnsupported: string;
217
227
  readonly fileNotShown: string;
218
228
  readonly pdfNotShown: string;
@@ -34,6 +34,14 @@ export type ExplorerLocation = {
34
34
  readonly embed: ExplorerEmbedOptions;
35
35
  readonly markup: boolean;
36
36
  };
37
+ export type ExplorerDocumentIdOpening = {
38
+ readonly view: "tree";
39
+ readonly overrides: ExplorerOverrides;
40
+ } | {
41
+ readonly view: "single";
42
+ readonly overrides: ExplorerOverrides;
43
+ readonly embed: ExplorerEmbedOptions;
44
+ };
37
45
  export type ExplorerLocationResult = {
38
46
  readonly kind: "location";
39
47
  readonly location: ExplorerLocation;
@@ -41,6 +49,11 @@ export type ExplorerLocationResult = {
41
49
  readonly kind: "redirect";
42
50
  readonly href: string;
43
51
  readonly location: ExplorerLocation;
52
+ } | {
53
+ readonly kind: "document-id";
54
+ readonly id: string | null;
55
+ readonly opens: ExplorerDocumentIdOpening;
56
+ readonly location: ExplorerLocation;
44
57
  };
45
58
  export type ExplorerHrefTarget = {
46
59
  readonly view: "tree";
@@ -63,6 +76,12 @@ export type ExplorerHrefTarget = {
63
76
  readonly overrides?: ExplorerOverrides;
64
77
  readonly embed?: ExplorerEmbedOptions;
65
78
  readonly markup?: boolean;
79
+ } | {
80
+ readonly view: "document-id";
81
+ readonly id: string;
82
+ readonly opens?: "single";
83
+ readonly overrides?: ExplorerOverrides;
84
+ readonly embed?: ExplorerEmbedOptions;
66
85
  };
67
86
  export type ExplorerSourcelessHrefTarget = ExplorerHrefTarget & {
68
87
  readonly source?: undefined;
@@ -89,5 +108,7 @@ export declare const FOLDER_SEGMENT_MARK = "/";
89
108
  export declare const encodeDocumentSegment: (path: string) => string;
90
109
  export declare const decodeDocumentSegment: (segment: string) => string;
91
110
  export declare const canonicalMultiDocuments: (config: ExplorerConfig, docs: readonly string[]) => readonly string[];
111
+ export declare const hasDocumentUrl: (path: string) => boolean;
92
112
  export declare const explorerHref: ExplorerHrefWriter;
93
113
  export declare const resolveExplorerLocation: (config: ExplorerLocationConfig, splat: string | undefined, search: URLSearchParams) => ExplorerLocationResult;
114
+ export declare const documentIdOpeningTarget: (opens: ExplorerDocumentIdOpening, path: string, source: string) => ExplorerHrefTarget;
@@ -34,6 +34,14 @@ export type ExplorerLocation = {
34
34
  readonly embed: ExplorerEmbedOptions;
35
35
  readonly markup: boolean;
36
36
  };
37
+ export type ExplorerDocumentIdOpening = {
38
+ readonly view: "tree";
39
+ readonly overrides: ExplorerOverrides;
40
+ } | {
41
+ readonly view: "single";
42
+ readonly overrides: ExplorerOverrides;
43
+ readonly embed: ExplorerEmbedOptions;
44
+ };
37
45
  export type ExplorerLocationResult = {
38
46
  readonly kind: "location";
39
47
  readonly location: ExplorerLocation;
@@ -41,6 +49,11 @@ export type ExplorerLocationResult = {
41
49
  readonly kind: "redirect";
42
50
  readonly href: string;
43
51
  readonly location: ExplorerLocation;
52
+ } | {
53
+ readonly kind: "document-id";
54
+ readonly id: string | null;
55
+ readonly opens: ExplorerDocumentIdOpening;
56
+ readonly location: ExplorerLocation;
44
57
  };
45
58
  export type ExplorerHrefTarget = {
46
59
  readonly view: "tree";
@@ -63,6 +76,12 @@ export type ExplorerHrefTarget = {
63
76
  readonly overrides?: ExplorerOverrides;
64
77
  readonly embed?: ExplorerEmbedOptions;
65
78
  readonly markup?: boolean;
79
+ } | {
80
+ readonly view: "document-id";
81
+ readonly id: string;
82
+ readonly opens?: "single";
83
+ readonly overrides?: ExplorerOverrides;
84
+ readonly embed?: ExplorerEmbedOptions;
66
85
  };
67
86
  export type ExplorerSourcelessHrefTarget = ExplorerHrefTarget & {
68
87
  readonly source?: undefined;
@@ -89,5 +108,7 @@ export declare const FOLDER_SEGMENT_MARK = "/";
89
108
  export declare const encodeDocumentSegment: (path: string) => string;
90
109
  export declare const decodeDocumentSegment: (segment: string) => string;
91
110
  export declare const canonicalMultiDocuments: (config: ExplorerConfig, docs: readonly string[]) => readonly string[];
111
+ export declare const hasDocumentUrl: (path: string) => boolean;
92
112
  export declare const explorerHref: ExplorerHrefWriter;
93
113
  export declare const resolveExplorerLocation: (config: ExplorerLocationConfig, splat: string | undefined, search: URLSearchParams) => ExplorerLocationResult;
114
+ export declare const documentIdOpeningTarget: (opens: ExplorerDocumentIdOpening, path: string, source: string) => ExplorerHrefTarget;