@aiquants/markdown-explorer 0.3.0 → 0.4.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.
- package/CHANGELOG.md +28 -0
- package/README.md +45 -6
- package/dist/ExplorerSplit-rUVsf5i-.cjs +1 -0
- package/dist/ExplorerSplit-uX2ojZe8.js +1479 -0
- package/dist/MultiLayout-8s7q3-Hm.js +919 -0
- package/dist/MultiLayout-ZK2V9nms.cjs +1 -0
- package/dist/NativeScrollBar-D3VDRQqf.js +59 -0
- package/dist/NativeScrollBar-DqkutcGb.cjs +1 -0
- package/dist/{TreeLayout-D6hCSihW.js → TreeLayout-C7ZNnaOr.js} +3 -3
- package/dist/{TreeLayout-BQUfVNlA.cjs → TreeLayout-DkTVgxxb.cjs} +1 -1
- package/dist/core/config.d.cts +11 -0
- package/dist/core/config.d.ts +11 -0
- package/dist/core/contracts.d.cts +8 -0
- package/dist/core/contracts.d.ts +8 -0
- package/dist/core/labels.d.cts +5 -1
- package/dist/core/labels.d.ts +5 -1
- package/dist/core/treeSettings.d.cts +4 -2
- package/dist/core/treeSettings.d.ts +4 -2
- package/dist/dataRoute-DYjYBiXF.cjs +1 -0
- package/dist/{dataRoute-zUX-oR9j.js → dataRoute-Dl6xmEFs.js} +41 -36
- package/dist/index-CLe6vRXs.cjs +3 -0
- package/dist/{index-BJTmp0lR.js → index-Dv9lUZqD.js} +530 -503
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -22
- package/dist/location-2QZADLiv.cjs +1 -0
- package/dist/{location-V5BKeWNs.js → location-CaNtUswk.js} +202 -187
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/scrollBarGeometry-C46jBtmM.cjs +1 -0
- package/dist/scrollBarGeometry-DOBdGNV-.js +4 -0
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/ports.d.cts +4 -0
- package/dist/server/ports.d.ts +4 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +725 -680
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/tapScrollCircle-C5DGI-0H.cjs +1 -0
- package/dist/tapScrollCircle-u4EXeLhx.js +6 -0
- package/docs/behavior/dom-hooks.md +3 -1
- package/docs/behavior/layout.md +2 -0
- package/docs/behavior/localization.md +1 -0
- package/docs/behavior/security.md +1 -1
- package/package.json +7 -7
- package/dist/ExplorerSplit-B7pmzR8t.js +0 -1362
- package/dist/ExplorerSplit-Bi3yU6NG.cjs +0 -1
- package/dist/MultiLayout-BxeXOLX1.js +0 -909
- package/dist/MultiLayout-DtFrFRmS.cjs +0 -1
- package/dist/dataRoute-B9Wk-G7A.cjs +0 -1
- package/dist/index-DkiGlM7C.cjs +0 -3
- package/dist/location-DfYTzfFS.cjs +0 -1
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { NO_EMBEDS as
|
|
2
|
-
import { CONTENT_ALIGNS as
|
|
3
|
-
import { a as
|
|
1
|
+
import { NO_EMBEDS as Q, isEmbedProviderId as ee, EMBED_PROVIDER_IDS as te, isLinkCardSize as re, LINK_CARD_SIZES as ne } from "@aiquants/markdown/embeds";
|
|
2
|
+
import { CONTENT_ALIGNS as b, DEFAULT_MARKDOWN_STYLES as oe } from "@aiquants/markdown/viewer-settings";
|
|
3
|
+
import { a as se, i as A } from "./dataRoute-Dl6xmEFs.js";
|
|
4
4
|
const $ = (e) => {
|
|
5
5
|
if (e === null || typeof e != "object") return !1;
|
|
6
6
|
const t = Object.getPrototypeOf(e);
|
|
7
7
|
return t === Object.prototype || t === null;
|
|
8
8
|
}, P = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), C = Object.freeze({
|
|
9
9
|
sortMode: "native",
|
|
10
|
-
|
|
10
|
+
folderPlacement: "mixed",
|
|
11
11
|
selectionMode: "single",
|
|
12
12
|
doubleClickAction: "recursive",
|
|
13
13
|
expandIconSize: 8,
|
|
14
14
|
alwaysExpanded: !1,
|
|
15
|
+
revealDocument: !1,
|
|
15
16
|
removeRootIndent: !1,
|
|
16
17
|
lines: !0,
|
|
17
18
|
expandIcons: !0,
|
|
18
19
|
directoryIcons: !0,
|
|
19
20
|
fileIcons: !0
|
|
20
|
-
}),
|
|
21
|
+
}), ie = [!0, !1], ae = (e, t) => t ? e.settingOn : e.settingOff, g = (e, t) => ({ key: e, labelKey: t, values: ie, formatValue: ae, requiresItemSelection: !1 }), h = Object.freeze([
|
|
21
22
|
{
|
|
22
23
|
key: "sortMode",
|
|
23
24
|
labelKey: "settingSortMode",
|
|
@@ -25,7 +26,13 @@ const $ = (e) => {
|
|
|
25
26
|
formatValue: (e, t) => t === "native" ? e.sortNative : t === "asc" ? e.sortAscending : e.sortDescending,
|
|
26
27
|
requiresItemSelection: !1
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
+
{
|
|
30
|
+
key: "folderPlacement",
|
|
31
|
+
labelKey: "settingFolderPlacement",
|
|
32
|
+
values: ["mixed", "first", "last"],
|
|
33
|
+
formatValue: (e, t) => t === "mixed" ? e.folderPlacementMixed : t === "first" ? e.folderPlacementFirst : e.folderPlacementLast,
|
|
34
|
+
requiresItemSelection: !1
|
|
35
|
+
},
|
|
29
36
|
{
|
|
30
37
|
key: "selectionMode",
|
|
31
38
|
labelKey: "settingSelectionMode",
|
|
@@ -48,90 +55,96 @@ const $ = (e) => {
|
|
|
48
55
|
requiresItemSelection: !1
|
|
49
56
|
},
|
|
50
57
|
g("alwaysExpanded", "settingAlwaysExpanded"),
|
|
58
|
+
g("revealDocument", "settingRevealDocument"),
|
|
51
59
|
g("removeRootIndent", "settingRemoveRootIndent"),
|
|
52
60
|
g("lines", "settingTreeLines"),
|
|
53
61
|
g("expandIcons", "settingExpandIcons"),
|
|
54
62
|
g("directoryIcons", "settingDirectoryIcons"),
|
|
55
63
|
g("fileIcons", "settingFileIcons")
|
|
56
|
-
]),
|
|
57
|
-
const t =
|
|
64
|
+
]), Ke = (e) => e ? h : h.filter((t) => !t.requiresItemSelection), U = (e) => {
|
|
65
|
+
const t = h.find((r) => r.key === e);
|
|
58
66
|
if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
|
|
59
67
|
return t;
|
|
60
|
-
},
|
|
61
|
-
const r =
|
|
68
|
+
}, Be = (e, t) => {
|
|
69
|
+
const r = U(t).values, n = r[(r.indexOf(e[t]) + 1) % r.length];
|
|
62
70
|
return { ...e, [t]: n };
|
|
63
|
-
},
|
|
71
|
+
}, Ze = (e, t, r) => U(r).formatValue(e, t[r]), G = 2, z = Object.freeze({}), v = (e, t) => Object.freeze(Object.fromEntries(h.filter((r) => t(r, e[r.key])).map((r) => [r.key, e[r.key]]))), j = "directoriesFirst", le = (e) => {
|
|
72
|
+
if (!Object.hasOwn(e, j)) return e;
|
|
73
|
+
const { [j]: t, ...r } = e;
|
|
74
|
+
return Object.hasOwn(r, "folderPlacement") || typeof t != "boolean" ? r : { ...r, folderPlacement: t ? "first" : "mixed" };
|
|
75
|
+
}, Ye = (e) => {
|
|
64
76
|
if (e === null || typeof e != "object" || Array.isArray(e)) return z;
|
|
65
77
|
const t = e;
|
|
66
|
-
return t.version !==
|
|
67
|
-
},
|
|
78
|
+
return t.version !== G || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? z : v(le(t.settings), (r, n) => r.values.includes(n));
|
|
79
|
+
}, Qe = (e, t) => {
|
|
68
80
|
const r = v(t, (n, o) => o !== void 0 && o !== e[n.key]);
|
|
69
81
|
return Object.keys(r).length === 0 ? e : Object.freeze({ ...e, ...r });
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
}, et = (e, t, r, n) => v({ ...e, [t]: r }, (o, s) => s !== void 0 && !(o.key === t && s === n[t])), tt = (e) => JSON.stringify({ version: G, settings: e }), rt = (e) => {
|
|
83
|
+
const { sortMode: t, folderPlacement: r } = e;
|
|
84
|
+
if (t === "native" && r === "mixed") return;
|
|
85
|
+
const n = t === "desc" ? -1 : 1;
|
|
86
|
+
return (o, s) => {
|
|
87
|
+
if (r !== "mixed" && o.type !== s.type) return o.type === "directory" == (r === "first") ? -1 : 1;
|
|
88
|
+
if (t === "native") return 0;
|
|
89
|
+
const i = P.compare(o.name, s.name);
|
|
90
|
+
return n * (i !== 0 ? i : P.compare(o.path, s.path));
|
|
78
91
|
};
|
|
79
|
-
}, w = (1 + Math.sqrt(5)) / 2,
|
|
92
|
+
}, w = (1 + Math.sqrt(5)) / 2, nt = 100 / w ** 3, ot = 100 / w ** 4, J = 100 / w ** 2, ce = 13, st = 16, it = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), de = Object.freeze([89, 144, 233, 377]), at = 34, lt = 44, ct = 24, dt = 1 / w, mt = 1 / w ** 3, ft = "40ch", me = (e) => {
|
|
80
93
|
if (!Number.isFinite(e) || e <= 0)
|
|
81
94
|
throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`);
|
|
82
|
-
},
|
|
95
|
+
}, fe = (e) => (me(e), ce * e), ut = (e) => fe(e) * w ** 2, gt = 233, wt = de[0], L = (e, t) => {
|
|
83
96
|
if (!Number.isFinite(t) || t < 0)
|
|
84
97
|
throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`);
|
|
85
|
-
},
|
|
98
|
+
}, ue = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
|
|
86
99
|
if (L("trackInlineSize", e), L("gap", t), !Number.isFinite(r) || r <= 0)
|
|
87
100
|
throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);
|
|
88
101
|
if (!Number.isInteger(n) || n < 1)
|
|
89
102
|
throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);
|
|
90
103
|
const o = Math.floor((e + t) / (r + t));
|
|
91
104
|
return Math.min(n, Math.max(1, o));
|
|
92
|
-
},
|
|
105
|
+
}, pt = (e, t) => {
|
|
93
106
|
const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: s } = t;
|
|
94
107
|
if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
|
|
95
|
-
const
|
|
96
|
-
if (e === null ||
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
const k = (
|
|
100
|
-
return r >= k ?
|
|
108
|
+
const c = ue(t);
|
|
109
|
+
if (e === null || c === e) return c;
|
|
110
|
+
const a = Math.min(s, Math.max(1, e));
|
|
111
|
+
if (c > a) {
|
|
112
|
+
const k = (a + 1) * o + a * n + n / w;
|
|
113
|
+
return r >= k ? c : a;
|
|
101
114
|
}
|
|
102
|
-
return r >=
|
|
103
|
-
},
|
|
115
|
+
return r >= a * o + (a - 1) * n ? a : c;
|
|
116
|
+
}, ht = (e, t) => {
|
|
104
117
|
if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
|
|
105
118
|
throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);
|
|
106
119
|
return Array.from({ length: t }, (r, n) => [Math.floor(n * e / t), Math.floor((n + 1) * e / t)]);
|
|
107
|
-
},
|
|
108
|
-
if (typeof e != "string" || !
|
|
120
|
+
}, ge = 31536e3, we = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, pe = (e) => {
|
|
121
|
+
if (typeof e != "string" || !we.test(e))
|
|
109
122
|
throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`);
|
|
110
|
-
},
|
|
123
|
+
}, D = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= J, he = (e, t) => {
|
|
111
124
|
if (e === null || typeof e != "object" || Array.isArray(e)) return {};
|
|
112
|
-
const r = e, { treeExplorer: n, multiExplorer: o, style: s, align:
|
|
125
|
+
const r = e, { treeExplorer: n, multiExplorer: o, style: s, align: i } = r;
|
|
113
126
|
return {
|
|
114
|
-
...
|
|
115
|
-
...
|
|
127
|
+
...D(n) ? { treeExplorer: n } : {},
|
|
128
|
+
...D(o) ? { multiExplorer: o } : {},
|
|
116
129
|
...typeof s == "string" && t.includes(s) ? { style: s } : {},
|
|
117
|
-
...typeof
|
|
130
|
+
...typeof i == "string" && b.includes(i) ? { align: i } : {}
|
|
118
131
|
};
|
|
119
|
-
},
|
|
132
|
+
}, Et = (e, t) => {
|
|
120
133
|
if (e !== null)
|
|
121
134
|
for (const r of e.split(";")) {
|
|
122
135
|
const n = r.indexOf("=");
|
|
123
136
|
if (!(n < 0) && r.slice(0, n).trim() === t)
|
|
124
137
|
return r.slice(n + 1).trim();
|
|
125
138
|
}
|
|
126
|
-
},
|
|
139
|
+
}, St = (e, t) => {
|
|
127
140
|
if (e === void 0 || e === "") return {};
|
|
128
141
|
try {
|
|
129
|
-
return
|
|
142
|
+
return he(JSON.parse(decodeURIComponent(e)), t);
|
|
130
143
|
} catch {
|
|
131
144
|
return {};
|
|
132
145
|
}
|
|
133
|
-
}, O = 100,
|
|
134
|
-
const t = (r) => Math.min(
|
|
146
|
+
}, O = 100, Ee = Math.floor(J * O) / O, Se = (e) => {
|
|
147
|
+
const t = (r) => Math.min(Ee, Math.max(1, Math.round(r * O)) / O);
|
|
135
148
|
return encodeURIComponent(
|
|
136
149
|
JSON.stringify({
|
|
137
150
|
...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
|
|
@@ -140,85 +153,85 @@ const $ = (e) => {
|
|
|
140
153
|
...e.align === void 0 ? {} : { align: e.align }
|
|
141
154
|
})
|
|
142
155
|
);
|
|
143
|
-
},
|
|
156
|
+
}, xt = (e, t, r) => `${e}=${Se(t)}; Path=/; Max-Age=${String(ge)}; SameSite=Lax${r ? "; Secure" : ""}`, M = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), xe = Object.freeze({ default: 12, min: 1, max: 64 }), ye = Object.freeze({ default: 4, min: 1, max: 6 }), be = Object.freeze({ default: 500, min: 1, max: 1e4 }), Oe = Object.freeze({ default: 16, min: 1, max: 64 }), ke = Object.freeze({ default: 16, min: 1, max: 64 }), Re = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, _e = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, Te = /^[a-z0-9][a-z0-9-]*$/u, Ie = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u, V = (e, t) => {
|
|
144
157
|
if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);
|
|
145
|
-
if (!
|
|
158
|
+
if (!Re.test(t) || t.split("/").some((r) => r === "." || r === ".."))
|
|
146
159
|
throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`);
|
|
147
|
-
},
|
|
160
|
+
}, d = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "bigint" ? `${String(e)}n` : Object.is(e, -0) ? "-0" : typeof e == "function" ? "a function" : Array.isArray(e) ? "an array" : e !== null && typeof e == "object" ? $(e) ? "a plain object" : `a non-plain object (${Object.prototype.toString.call(e)})` : String(e), p = (e, t, r) => {
|
|
148
161
|
if (t === void 0) return [];
|
|
149
|
-
if (!$(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${
|
|
162
|
+
if (!$(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);
|
|
150
163
|
const n = Object.entries(t);
|
|
151
164
|
for (const [o] of n)
|
|
152
165
|
if (!r.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);
|
|
153
166
|
return n.filter(([, o]) => o !== void 0);
|
|
154
|
-
},
|
|
167
|
+
}, Ne = (e) => {
|
|
155
168
|
const t = { ...M };
|
|
156
|
-
for (const [r, n] of
|
|
169
|
+
for (const [r, n] of p("views", e, Object.keys(M))) t[r] = n;
|
|
157
170
|
for (const [r, n] of Object.entries(t))
|
|
158
|
-
if (typeof n != "string" || !
|
|
171
|
+
if (typeof n != "string" || !_e.test(n))
|
|
159
172
|
throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);
|
|
160
173
|
return Object.freeze(t);
|
|
161
|
-
},
|
|
174
|
+
}, x = (e, t, r) => {
|
|
162
175
|
if (t === void 0) return r.default;
|
|
163
176
|
if (typeof t != "number" || !Number.isInteger(t) || t < r.min || t > r.max)
|
|
164
|
-
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${
|
|
177
|
+
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);
|
|
165
178
|
return t;
|
|
166
|
-
},
|
|
167
|
-
const r = new Map(
|
|
168
|
-
if (r.size === 0) return
|
|
179
|
+
}, Ae = (e, t) => {
|
|
180
|
+
const r = new Map(p("embeds", e, ["providers", "linkCards", "linkCardSize"]));
|
|
181
|
+
if (r.size === 0) return Q;
|
|
169
182
|
const n = r.has("providers") ? r.get("providers") : [];
|
|
170
|
-
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${
|
|
171
|
-
for (const
|
|
172
|
-
if (!
|
|
183
|
+
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(n)}`);
|
|
184
|
+
for (const c of n)
|
|
185
|
+
if (!ee(c)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${te.join(", ")}; got ${d(c)}`);
|
|
173
186
|
const o = r.has("linkCards") ? r.get("linkCards") : !1;
|
|
174
|
-
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${
|
|
175
|
-
const s = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ?
|
|
187
|
+
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);
|
|
188
|
+
const s = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ? se(t) : null };
|
|
176
189
|
if (!r.has("linkCardSize")) return Object.freeze(s);
|
|
177
|
-
const
|
|
178
|
-
if (!
|
|
179
|
-
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${
|
|
180
|
-
return Object.freeze({ ...s, linkCardSize:
|
|
181
|
-
},
|
|
190
|
+
const i = r.get("linkCardSize");
|
|
191
|
+
if (!re(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${ne.join(", ")}; got ${d(i)}`);
|
|
192
|
+
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(i)} with linkCards ${d(o)}`);
|
|
193
|
+
return Object.freeze({ ...s, linkCardSize: i });
|
|
194
|
+
}, $e = (e) => {
|
|
182
195
|
const t = new Map(
|
|
183
|
-
|
|
196
|
+
p(
|
|
184
197
|
"defaultTreeSettings",
|
|
185
198
|
e,
|
|
186
|
-
|
|
199
|
+
h.map((n) => n.key)
|
|
187
200
|
)
|
|
188
201
|
);
|
|
189
202
|
if (t.size === 0) return C;
|
|
190
203
|
const r = { ...C };
|
|
191
|
-
for (const n of
|
|
204
|
+
for (const n of h) {
|
|
192
205
|
if (!t.has(n.key)) continue;
|
|
193
206
|
const o = t.get(n.key), s = n.values;
|
|
194
|
-
if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(
|
|
207
|
+
if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(d).join(", ")}; got ${d(o)}`);
|
|
195
208
|
r[n.key] = o;
|
|
196
209
|
}
|
|
197
210
|
return Object.freeze(r);
|
|
198
|
-
},
|
|
211
|
+
}, ve = (e) => {
|
|
199
212
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
|
|
200
|
-
|
|
201
|
-
const t =
|
|
213
|
+
V("basePath", e.basePath), V("dataPath", e.dataPath);
|
|
214
|
+
const t = Ne(e.views);
|
|
202
215
|
if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
|
|
203
216
|
throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);
|
|
204
217
|
if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
|
|
205
218
|
if (e.dataPath.startsWith(`${e.basePath}/`)) {
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
219
|
+
const a = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
|
|
220
|
+
if (a === t.tree || a === t.multi || a === t.single)
|
|
208
221
|
throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`);
|
|
209
222
|
}
|
|
210
|
-
|
|
223
|
+
pe(e.settingsCookie);
|
|
211
224
|
const r = e.iframeHosts ?? [];
|
|
212
|
-
if (!Array.isArray(r) || r.some((
|
|
225
|
+
if (!Array.isArray(r) || r.some((a) => typeof a != "string" || !Ie.test(a)))
|
|
213
226
|
throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);
|
|
214
|
-
const n = Object.fromEntries(
|
|
215
|
-
if (!Array.isArray(
|
|
216
|
-
const
|
|
217
|
-
for (const
|
|
218
|
-
if (
|
|
227
|
+
const n = Object.fromEntries(p("multiView", e.multiView, ["maxPanels", "columns"])), o = Object.fromEntries(p("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), s = Object.fromEntries(p("revealDocument", e.revealDocument, ["maxDepth"])), i = e.documentStyles ?? oe;
|
|
228
|
+
if (!Array.isArray(i) || i.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
229
|
+
const c = /* @__PURE__ */ new Set();
|
|
230
|
+
for (const a of i) {
|
|
231
|
+
if (a === null || typeof a != "object" || typeof a.name != "string" || a.name.trim() === "" || typeof a.className != "string")
|
|
219
232
|
throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");
|
|
220
|
-
if (
|
|
221
|
-
|
|
233
|
+
if (c.has(a.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(a.name)} repeats`);
|
|
234
|
+
c.add(a.name);
|
|
222
235
|
}
|
|
223
236
|
return Object.freeze({
|
|
224
237
|
basePath: e.basePath,
|
|
@@ -226,35 +239,36 @@ const $ = (e) => {
|
|
|
226
239
|
settingsCookie: e.settingsCookie,
|
|
227
240
|
views: t,
|
|
228
241
|
multiView: Object.freeze({
|
|
229
|
-
maxPanels:
|
|
230
|
-
columns:
|
|
242
|
+
maxPanels: x("multiView.maxPanels", n.maxPanels, xe),
|
|
243
|
+
columns: x("multiView.columns", n.columns, ye)
|
|
231
244
|
}),
|
|
232
245
|
expandAll: Object.freeze({
|
|
233
|
-
maxFolders:
|
|
234
|
-
maxDepth:
|
|
246
|
+
maxFolders: x("expandAll.maxFolders", o.maxFolders, be),
|
|
247
|
+
maxDepth: x("expandAll.maxDepth", o.maxDepth, Oe)
|
|
235
248
|
}),
|
|
236
|
-
|
|
249
|
+
revealDocument: Object.freeze({ maxDepth: x("revealDocument.maxDepth", s.maxDepth, ke) }),
|
|
250
|
+
documentStyles: Object.freeze(i.map((a) => Object.freeze({ name: a.name, className: a.className }))),
|
|
237
251
|
iframeHosts: Object.freeze([...new Set(r)]),
|
|
238
|
-
embeds:
|
|
239
|
-
defaultTreeSettings:
|
|
252
|
+
embeds: Ae(e.embeds, e.dataPath),
|
|
253
|
+
defaultTreeSettings: $e(e.defaultTreeSettings)
|
|
240
254
|
});
|
|
241
|
-
},
|
|
255
|
+
}, yt = (e) => {
|
|
242
256
|
const t = e.embeds;
|
|
243
|
-
if (!$(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${
|
|
257
|
+
if (!$(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);
|
|
244
258
|
if (Object.hasOwn(t, "linkCards"))
|
|
245
|
-
throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${
|
|
246
|
-
const { linkCardEndpoint: r, ...n } = t, o =
|
|
259
|
+
throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${d(t.linkCards)})`);
|
|
260
|
+
const { linkCardEndpoint: r, ...n } = t, o = ve({ ...e, embeds: { ...n, linkCards: r !== null } });
|
|
247
261
|
if (o.embeds.linkCardEndpoint !== r)
|
|
248
|
-
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${
|
|
262
|
+
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(o.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);
|
|
249
263
|
return o;
|
|
250
|
-
},
|
|
251
|
-
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${
|
|
252
|
-
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${
|
|
264
|
+
}, Pe = (e) => typeof e == "string" && Te.test(e), bt = (e, t) => {
|
|
265
|
+
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);
|
|
266
|
+
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);
|
|
253
267
|
for (const r of t)
|
|
254
|
-
if (!
|
|
268
|
+
if (!Pe(r)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);
|
|
255
269
|
if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);
|
|
256
270
|
return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
|
|
257
|
-
},
|
|
271
|
+
}, Ot = (e) => e.documentStyles.map((t) => t.name), l = Object.freeze({
|
|
258
272
|
source: "source",
|
|
259
273
|
doc: "doc",
|
|
260
274
|
maximized: "maximized",
|
|
@@ -266,144 +280,145 @@ const $ = (e) => {
|
|
|
266
280
|
padding: "padding",
|
|
267
281
|
width: "width",
|
|
268
282
|
maxWidth: "maxWidth"
|
|
269
|
-
}), F = ".data",
|
|
283
|
+
}), F = ".data", X = 256, W = /^\d+(?:\.\d+)?$/u, N = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, H = Object.freeze(["showToc", "showStyle", "showAlign"]), Ce = (e) => {
|
|
270
284
|
const t = encodeURIComponent(e.replaceAll("%", "%25"));
|
|
271
285
|
return t.endsWith(F) ? `${t.slice(0, -F.length)}%2Edata` : t;
|
|
272
|
-
},
|
|
286
|
+
}, ze = (e) => e.replaceAll("%25", "%"), q = (e) => {
|
|
273
287
|
const { sourceIds: t } = e;
|
|
274
288
|
if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
|
|
275
289
|
return t;
|
|
276
|
-
},
|
|
290
|
+
}, je = (e, t, r) => {
|
|
277
291
|
const n = r.getAll(l.source);
|
|
278
292
|
if (n.length === 0) return t;
|
|
279
293
|
const [o] = n;
|
|
280
294
|
return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
|
|
281
|
-
},
|
|
295
|
+
}, Le = (e, t) => {
|
|
282
296
|
const r = t.get(l.style), n = t.get(l.align);
|
|
283
297
|
return {
|
|
284
298
|
...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
|
|
285
|
-
...n !== null &&
|
|
299
|
+
...n !== null && b.includes(n) ? { align: n } : {}
|
|
286
300
|
};
|
|
287
|
-
},
|
|
288
|
-
const t = e.get(l.padding), r = t !== null &&
|
|
301
|
+
}, K = (e) => Number.isFinite(e) && e >= 0 && e <= X && W.test(String(e)), De = (e) => {
|
|
302
|
+
const t = e.get(l.padding), r = t !== null && W.test(t) ? Number(t) : Number.NaN, n = e.get(l.width), o = e.get(l.maxWidth);
|
|
289
303
|
return {
|
|
290
304
|
...e.get(l.showToc) === "false" ? { showToc: !1 } : {},
|
|
291
305
|
...e.get(l.showStyle) === "false" ? { showStyle: !1 } : {},
|
|
292
306
|
...e.get(l.showAlign) === "false" ? { showAlign: !1 } : {},
|
|
293
|
-
...
|
|
294
|
-
...n !== null &&
|
|
295
|
-
...o !== null &&
|
|
307
|
+
...K(r) ? { padding: r } : {},
|
|
308
|
+
...n !== null && N.test(n) ? { width: n } : {},
|
|
309
|
+
...o !== null && N.test(o) ? { maxWidth: o } : {}
|
|
296
310
|
};
|
|
297
|
-
},
|
|
311
|
+
}, Me = (e, t) => [...new Set(t.filter(A))].slice(0, e.multiView.maxPanels), Ve = (e, t, r) => {
|
|
298
312
|
for (const n of t) B(n);
|
|
299
313
|
if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);
|
|
300
314
|
if (t.length > e.multiView.maxPanels) throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);
|
|
301
315
|
if (r !== null && !t.includes(r)) throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0, 80))}`);
|
|
302
316
|
}, B = (e) => {
|
|
303
|
-
if (!
|
|
317
|
+
if (!A(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0, 80))}`);
|
|
304
318
|
return e;
|
|
305
|
-
},
|
|
319
|
+
}, Fe = (e, t) => {
|
|
306
320
|
if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
|
|
307
321
|
throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((r) => JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);
|
|
308
|
-
if (t.align !== void 0 && !
|
|
309
|
-
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${
|
|
310
|
-
},
|
|
311
|
-
for (const t of
|
|
322
|
+
if (t.align !== void 0 && !b.includes(t.align))
|
|
323
|
+
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${b.join(", ")}; got ${JSON.stringify(t.align)}`);
|
|
324
|
+
}, Ue = (e) => {
|
|
325
|
+
for (const t of H)
|
|
312
326
|
if (e[t] !== void 0 && typeof e[t] != "boolean") throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);
|
|
313
|
-
if (e.padding !== void 0 && !
|
|
327
|
+
if (e.padding !== void 0 && !K(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(X)} px in plain decimal digits; got ${String(e.padding)}`);
|
|
314
328
|
for (const t of ["width", "maxWidth"]) {
|
|
315
329
|
const r = e[t];
|
|
316
|
-
if (r !== void 0 && !
|
|
330
|
+
if (r !== void 0 && !N.test(r)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`);
|
|
317
331
|
}
|
|
318
|
-
},
|
|
332
|
+
}, Ge = (e, t) => {
|
|
319
333
|
const r = new URLSearchParams();
|
|
320
334
|
let n = `${e.basePath}/${e.views[t.view]}`;
|
|
321
335
|
if (t.view === "multi") {
|
|
322
|
-
const s = t.docs ?? [],
|
|
323
|
-
|
|
324
|
-
for (const
|
|
325
|
-
|
|
326
|
-
} else t.doc !== void 0 && t.doc !== null && (n += `/${
|
|
336
|
+
const s = t.docs ?? [], i = t.maximized ?? null;
|
|
337
|
+
Ve(e, s, i);
|
|
338
|
+
for (const c of s) r.append(l.doc, c);
|
|
339
|
+
i !== null && r.set(l.maximized, i);
|
|
340
|
+
} else t.doc !== void 0 && t.doc !== null && (n += `/${Ce(B(t.doc))}`);
|
|
327
341
|
if (t.source !== void 0) {
|
|
328
|
-
const s =
|
|
342
|
+
const s = q(e);
|
|
329
343
|
if (!s.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${s.join(", ")}`);
|
|
330
344
|
t.source !== s[0] && r.set(l.source, t.source);
|
|
331
345
|
}
|
|
332
|
-
if (t.view !== "multi" && t.overrides !== void 0 && (
|
|
346
|
+
if (t.view !== "multi" && t.overrides !== void 0 && (Fe(e, t.overrides), t.overrides.style !== void 0 && r.set(l.style, t.overrides.style), t.overrides.align !== void 0 && r.set(l.align, t.overrides.align)), t.view === "single" && t.embed !== void 0) {
|
|
333
347
|
const { embed: s } = t;
|
|
334
|
-
|
|
335
|
-
for (const
|
|
348
|
+
Ue(s);
|
|
349
|
+
for (const i of H) s[i] === !1 && r.set(l[i], "false");
|
|
336
350
|
s.padding !== void 0 && r.set(l.padding, String(s.padding)), s.width !== void 0 && r.set(l.width, s.width), s.maxWidth !== void 0 && r.set(l.maxWidth, s.maxWidth);
|
|
337
351
|
}
|
|
338
352
|
const o = r.toString();
|
|
339
353
|
return o === "" ? n : `${n}?${o}`;
|
|
340
|
-
},
|
|
341
|
-
const n =
|
|
354
|
+
}, Je = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), kt = (e, t, r) => {
|
|
355
|
+
const n = q(e), [o] = n;
|
|
342
356
|
if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
|
|
343
|
-
const s =
|
|
344
|
-
if (t === void 0 || t === "") return
|
|
345
|
-
const
|
|
346
|
-
if (f === void 0) return
|
|
357
|
+
const s = je(n, o, r), i = s === null ? o : s, c = (m) => ({ kind: "redirect", href: Ge(e, m), location: m }), a = () => c({ view: "tree", source: i, doc: null, overrides: {} });
|
|
358
|
+
if (t === void 0 || t === "") return a();
|
|
359
|
+
const E = t.indexOf("/"), k = E < 0 ? t : t.slice(0, E), R = E < 0 ? null : t.slice(E + 1), f = Je(e, k);
|
|
360
|
+
if (f === void 0) return a();
|
|
347
361
|
if (f === "multi") {
|
|
348
|
-
const m = r.getAll(l.doc),
|
|
349
|
-
return R === null && s !== null &&
|
|
362
|
+
const m = r.getAll(l.doc), S = Me(e, m), _ = r.getAll(l.maximized), [T] = _, I = _.length === 1 && T !== void 0 && S.includes(T) ? T : null;
|
|
363
|
+
return R === null && s !== null && S.length === m.length && S.every((Z, Y) => Z === m[Y]) && (_.length === 0 || I !== null) ? { kind: "location", location: { view: "multi", source: i, docs: S, maximized: I } } : c({ view: "multi", source: i, docs: S, maximized: I });
|
|
350
364
|
}
|
|
351
|
-
const u = R === null ? null :
|
|
352
|
-
if (u !== null && !
|
|
353
|
-
const y =
|
|
365
|
+
const u = R === null ? null : ze(R);
|
|
366
|
+
if (u !== null && !A(u)) return a();
|
|
367
|
+
const y = Le(e, r);
|
|
354
368
|
if (f === "single") {
|
|
355
|
-
if (u === null) return
|
|
356
|
-
const m =
|
|
357
|
-
return s === null ?
|
|
369
|
+
if (u === null) return a();
|
|
370
|
+
const m = De(r);
|
|
371
|
+
return s === null ? c({ view: f, source: i, doc: u, overrides: y, embed: m }) : { kind: "location", location: { view: f, source: i, doc: u, overrides: y, embed: m } };
|
|
358
372
|
}
|
|
359
|
-
return s === null ?
|
|
373
|
+
return s === null ? c({ view: f, source: i, doc: u, overrides: y }) : { kind: "location", location: { view: f, source: i, doc: u, overrides: y } };
|
|
360
374
|
};
|
|
361
375
|
export {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
376
|
+
st as A,
|
|
377
|
+
tt as B,
|
|
378
|
+
at as C,
|
|
365
379
|
z as D,
|
|
366
|
-
|
|
367
|
-
|
|
380
|
+
gt as E,
|
|
381
|
+
ct as F,
|
|
368
382
|
w as G,
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
383
|
+
Ye as H,
|
|
384
|
+
xt as I,
|
|
385
|
+
ft as J,
|
|
372
386
|
C as K,
|
|
373
387
|
M as L,
|
|
374
|
-
|
|
388
|
+
Oe as M,
|
|
375
389
|
P as N,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
390
|
+
be as O,
|
|
391
|
+
dt as P,
|
|
392
|
+
ce as Q,
|
|
393
|
+
ye as R,
|
|
394
|
+
it as S,
|
|
395
|
+
xe as T,
|
|
396
|
+
ke as U,
|
|
397
|
+
ve as V,
|
|
398
|
+
kt as a,
|
|
399
|
+
Et as b,
|
|
400
|
+
Me as c,
|
|
401
|
+
Ot as d,
|
|
402
|
+
Ge as e,
|
|
388
403
|
$ as f,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
ht as g,
|
|
405
|
+
pt as h,
|
|
406
|
+
Pe as i,
|
|
407
|
+
mt as j,
|
|
408
|
+
rt as k,
|
|
409
|
+
Ze as l,
|
|
410
|
+
ut as m,
|
|
411
|
+
fe as n,
|
|
412
|
+
J as o,
|
|
413
|
+
St as p,
|
|
414
|
+
nt as q,
|
|
415
|
+
yt as r,
|
|
416
|
+
ot as s,
|
|
417
|
+
lt as t,
|
|
418
|
+
wt as u,
|
|
419
|
+
Ke as v,
|
|
420
|
+
bt as w,
|
|
421
|
+
et as x,
|
|
422
|
+
Be as y,
|
|
423
|
+
Qe as z
|
|
409
424
|
};
|