@aiquants/markdown-explorer 0.37.1 → 0.39.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 +63 -1
- package/README.md +3 -2
- package/dist/{EditSurface-BvwgM4lC.js → EditSurface-CUPN9dUY.js} +211 -211
- package/dist/{EditSurface-Ce4bpuvh.cjs → EditSurface-CZnjX0sv.cjs} +2 -2
- package/dist/{ExplorerSplit-DKpqQBsQ.js → ExplorerSplit-DHpgdXhb.js} +407 -407
- package/dist/{ExplorerSplit-DBUFhlo_.cjs → ExplorerSplit-DWBhCe7m.cjs} +1 -1
- package/dist/{MultiLayout-BfGxy2pf.cjs → MultiLayout-BkHbfUuh.cjs} +1 -1
- package/dist/{MultiLayout-CVj5iam0.js → MultiLayout-HmvjE8ht.js} +3 -3
- package/dist/{NativeScrollBar-BQpaWt45.cjs → NativeScrollBar-CzGhZ-w3.cjs} +1 -1
- package/dist/{NativeScrollBar-BkZPkphH.js → NativeScrollBar-DAukiH01.js} +2 -2
- package/dist/{TreeLayout-Df4HLMP-.cjs → TreeLayout-BEvPaxLb.cjs} +1 -1
- package/dist/{TreeLayout-B83wJ2CL.js → TreeLayout-dtnugwQ7.js} +3 -3
- package/dist/core/config.d.cts +3 -0
- package/dist/core/config.d.ts +3 -0
- package/dist/core/geometry.d.cts +0 -1
- package/dist/core/geometry.d.ts +0 -1
- package/dist/{explorerCore-EkU0mwdW.js → explorerCore-CUtc1Vmx.js} +1 -1
- package/dist/{explorerCore-DivWkFQF.cjs → explorerCore-Dj7RxZRd.cjs} +1 -1
- package/dist/{index-CVnGqEmh.js → index-BBJoJu-b.js} +13 -12
- package/dist/{index-Bz-n0dl1.cjs → index-D6at9qMs.cjs} +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/location-DFXJSMit.cjs +1 -0
- package/dist/{location-Dh6K-y7w.js → location-T9o5XYpX.js} +245 -241
- package/dist/{merge-BGr72noP.js → merge-CkMe5hqA.js} +1 -1
- package/dist/{merge-hFiGx_ND.cjs → merge-XyuOlVWP.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.js +3 -3
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-BTCGTQ8T.js → tapScrollCircle-CvWJKtbF.js} +1 -1
- package/dist/{tapScrollCircle-DDwYa54Q.cjs → tapScrollCircle-ExxyHVWY.cjs} +1 -1
- package/dist/{useSplitPersistence-BUa_KMsV.cjs → useSplitPersistence-BCitqdAe.cjs} +1 -1
- package/dist/{useSplitPersistence-pnb21dsr.js → useSplitPersistence-C86jW1yY.js} +1 -1
- package/package.json +6 -6
- package/dist/location-DrOP6t1F.cjs +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NO_EMBEDS as
|
|
2
|
-
import { CONTENT_COLORS as
|
|
3
|
-
import { P as
|
|
4
|
-
import { d as s, i as
|
|
5
|
-
const
|
|
1
|
+
import { NO_EMBEDS as Me, isEmbedProviderId as ze, EMBED_PROVIDER_IDS as Le, isLinkCardSize as je, LINK_CARD_SIZES as Fe } from "@aiquants/markdown/embeds";
|
|
2
|
+
import { CONTENT_COLORS as Ue, CONTENT_MEASURES as Ve, CONTENT_ALIGNS as D, DEFAULT_MARKDOWN_STYLES as Be, DEFAULT_MARKDOWN_STYLE as We } from "@aiquants/markdown/viewer-settings";
|
|
3
|
+
import { P as Ge, Q as He, R as Ke, S as Xe, i as _, K as qe, T as Ye } from "./ownUrls-DD0cSCsF.js";
|
|
4
|
+
import { d as s, i as v } from "./describeValue-CLlVRO8d.js";
|
|
5
|
+
const Je = Object.freeze([
|
|
6
6
|
"UTF-8",
|
|
7
7
|
"IBM866",
|
|
8
8
|
"ISO-8859-2",
|
|
@@ -43,11 +43,11 @@ const Ye = Object.freeze([
|
|
|
43
43
|
"UTF-16BE",
|
|
44
44
|
"UTF-16LE",
|
|
45
45
|
"x-user-defined"
|
|
46
|
-
]),
|
|
46
|
+
]), Ze = new Map(Je.map((e) => [e.toLowerCase(), e])), N = "UTF-8", Z = Object.freeze([
|
|
47
47
|
Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: N }),
|
|
48
48
|
Object.freeze({ bytes: Object.freeze([255, 254]), encoding: "UTF-16LE" }),
|
|
49
49
|
Object.freeze({ bytes: Object.freeze([254, 255]), encoding: "UTF-16BE" })
|
|
50
|
-
]),
|
|
50
|
+
]), Qe = /* @__PURE__ */ new Map([
|
|
51
51
|
[N, "is read before any legacy encoding"],
|
|
52
52
|
["UTF-16LE", "is read only by its byte order mark"],
|
|
53
53
|
["UTF-16BE", "is read only by its byte order mark"],
|
|
@@ -60,54 +60,54 @@ const Ye = Object.freeze([
|
|
|
60
60
|
} catch (o) {
|
|
61
61
|
throw o instanceof RangeError ? new RangeError(`[markdown-explorer] legacyTextEncoding ${s(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`) : o;
|
|
62
62
|
}
|
|
63
|
-
const r =
|
|
63
|
+
const r = et(t), n = Qe.get(r);
|
|
64
64
|
if (n !== void 0) throw new RangeError(`[markdown-explorer] legacyTextEncoding ${s(e)} names ${r}, which cannot be the legacy encoding: it ${n}`);
|
|
65
65
|
return r;
|
|
66
|
-
},
|
|
67
|
-
const t =
|
|
66
|
+
}, et = (e) => {
|
|
67
|
+
const t = Ze.get(e);
|
|
68
68
|
if (t === void 0) throw new RangeError(`[markdown-explorer] TextDecoder answered ${s(e)}, which is no encoding of the WHATWG Encoding Standard`);
|
|
69
69
|
return t;
|
|
70
|
-
},
|
|
70
|
+
}, L = (e, t, r) => {
|
|
71
71
|
const n = r === null ? null : fe(r), o = Z.find(({ bytes: a }) => a.every((d, l) => e[l] === d));
|
|
72
72
|
if (o !== void 0) return { body: e.subarray(o.bytes.length), encodings: [o.encoding] };
|
|
73
73
|
const i = t || e.length === 0 ? void 0 : Z.find(({ bytes: a }) => e.length < a.length && e.every((d, l) => a[l] === d));
|
|
74
74
|
return i !== void 0 ? { body: e.subarray(e.length), encodings: [i.encoding] } : { body: e, encodings: n === null ? [N] : [N, n] };
|
|
75
|
-
},
|
|
75
|
+
}, tr = (e, t, r) => L(e, t, r).encodings, tt = (e, t, r) => {
|
|
76
76
|
try {
|
|
77
77
|
return new TextDecoder(e, { fatal: !0, ignoreBOM: !0 }).decode(t, { stream: !r });
|
|
78
78
|
} catch (n) {
|
|
79
79
|
if (n instanceof TypeError) return null;
|
|
80
80
|
throw n;
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
const n = X(
|
|
82
|
+
}, rr = (e, t, r) => {
|
|
83
|
+
const n = X(L(e, t, r), t);
|
|
84
84
|
return n === null ? null : n.text;
|
|
85
85
|
}, X = ({ body: e, encodings: t }, r) => {
|
|
86
86
|
for (const n of t) {
|
|
87
|
-
const o =
|
|
87
|
+
const o = tt(n, e, r);
|
|
88
88
|
if (o !== null) return { encoding: n, text: o };
|
|
89
89
|
}
|
|
90
90
|
return null;
|
|
91
|
-
},
|
|
92
|
-
const n =
|
|
91
|
+
}, nr = (e, t, r) => {
|
|
92
|
+
const n = L(e, t, r), o = X(n, t);
|
|
93
93
|
return o === null ? n.encodings[0] : o.encoding;
|
|
94
|
-
},
|
|
95
|
-
const n =
|
|
94
|
+
}, or = (e, t, r) => {
|
|
95
|
+
const n = L(e, t, r), o = X(n, t);
|
|
96
96
|
return o !== null ? o.text : new TextDecoder(n.encodings[0], { ignoreBOM: !0 }).decode(n.body, { stream: !t });
|
|
97
|
-
}, C = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }),
|
|
97
|
+
}, C = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), rt = /^readme(?:\.|$)/iu, Q = /^readme(?:\.[^.]*)?$/iu, ee = Object.freeze(["md", "markdown", "mdx", "txt", ""]), nt = (e) => rt.test(e), G = (e) => e.type === "file" && nt(e.name), te = (e) => {
|
|
98
98
|
const t = e.lastIndexOf("."), r = ee.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
|
|
99
99
|
return r < 0 ? ee.length : r;
|
|
100
|
-
},
|
|
100
|
+
}, ot = (e, t) => {
|
|
101
101
|
const r = +!Q.test(e.name) - +!Q.test(t.name);
|
|
102
102
|
if (r !== 0) return r;
|
|
103
103
|
const n = te(e.name) - te(t.name);
|
|
104
104
|
if (n !== 0) return n;
|
|
105
105
|
const o = C.compare(e.name, t.name);
|
|
106
106
|
return o !== 0 ? o : C.compare(e.path, t.path);
|
|
107
|
-
},
|
|
107
|
+
}, sr = (e) => {
|
|
108
108
|
let t = null;
|
|
109
109
|
for (const r of e)
|
|
110
|
-
G(r) && (t === null ||
|
|
110
|
+
G(r) && (t === null || ot(r, t) < 0) && (t = r);
|
|
111
111
|
return t === null ? null : t.path;
|
|
112
112
|
}, re = Object.freeze({
|
|
113
113
|
sortMode: "native",
|
|
@@ -124,18 +124,18 @@ const Ye = Object.freeze([
|
|
|
124
124
|
expandIcons: !0,
|
|
125
125
|
directoryIcons: !0,
|
|
126
126
|
fileIcons: !0
|
|
127
|
-
}), we = [!0, !1], ge = (e, t) => t ? e.settingOn : e.settingOff,
|
|
127
|
+
}), we = [!0, !1], ge = (e, t) => t ? e.settingOn : e.settingOff, S = (e, t) => ({ key: e, labelKey: t, values: we, formatValue: ge, requiresTreeView: !1 }), st = Object.freeze({
|
|
128
128
|
native: (e) => e.sortNative,
|
|
129
129
|
asc: (e) => e.sortAscending,
|
|
130
130
|
desc: (e) => e.sortDescending,
|
|
131
131
|
oldest: (e) => e.sortOldest,
|
|
132
132
|
newest: (e) => e.sortNewest
|
|
133
|
-
}),
|
|
133
|
+
}), T = Object.freeze([
|
|
134
134
|
{
|
|
135
135
|
key: "sortMode",
|
|
136
136
|
labelKey: "settingSortMode",
|
|
137
137
|
values: ["native", "asc", "desc", "oldest", "newest"],
|
|
138
|
-
formatValue: (e, t) =>
|
|
138
|
+
formatValue: (e, t) => st[t](e),
|
|
139
139
|
requiresTreeView: !1
|
|
140
140
|
},
|
|
141
141
|
{
|
|
@@ -173,8 +173,8 @@ const Ye = Object.freeze([
|
|
|
173
173
|
formatValue: (e, t) => e.expandIconSizeValue(t),
|
|
174
174
|
requiresTreeView: !1
|
|
175
175
|
},
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
S("alwaysExpanded", "settingAlwaysExpanded"),
|
|
177
|
+
S("revealDocument", "settingRevealDocument"),
|
|
178
178
|
{
|
|
179
179
|
key: "showFolderReadme",
|
|
180
180
|
labelKey: "settingShowFolderReadme",
|
|
@@ -182,30 +182,30 @@ const Ye = Object.freeze([
|
|
|
182
182
|
formatValue: ge,
|
|
183
183
|
requiresTreeView: !0
|
|
184
184
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
]),
|
|
191
|
-
const t =
|
|
185
|
+
S("removeRootIndent", "settingRemoveRootIndent"),
|
|
186
|
+
S("lines", "settingTreeLines"),
|
|
187
|
+
S("expandIcons", "settingExpandIcons"),
|
|
188
|
+
S("directoryIcons", "settingDirectoryIcons"),
|
|
189
|
+
S("fileIcons", "settingFileIcons")
|
|
190
|
+
]), ir = (e) => e === "tree" ? T : T.filter((t) => !t.requiresTreeView), he = (e) => {
|
|
191
|
+
const t = T.find((r) => r.key === e);
|
|
192
192
|
if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
|
|
193
193
|
return t;
|
|
194
|
-
},
|
|
194
|
+
}, ar = (e, t) => {
|
|
195
195
|
const r = he(t).values, n = r[(r.indexOf(e[t]) + 1) % r.length];
|
|
196
196
|
return { ...e, [t]: n };
|
|
197
|
-
},
|
|
197
|
+
}, dr = (e, t, r) => he(r).formatValue(e, t[r]), pe = 2, ne = Object.freeze({}), q = (e, t) => Object.freeze(Object.fromEntries(T.filter((r) => t(r, e[r.key])).map((r) => [r.key, e[r.key]]))), oe = "directoriesFirst", it = (e) => {
|
|
198
198
|
if (!Object.hasOwn(e, oe)) return e;
|
|
199
199
|
const { [oe]: t, ...r } = e;
|
|
200
200
|
return Object.hasOwn(r, "folderPlacement") || typeof t != "boolean" ? r : { ...r, folderPlacement: t ? "first" : "mixed" };
|
|
201
|
-
},
|
|
201
|
+
}, lr = (e) => {
|
|
202
202
|
if (e === null || typeof e != "object" || Array.isArray(e)) return ne;
|
|
203
203
|
const t = e;
|
|
204
|
-
return t.version !== pe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? ne : q(
|
|
205
|
-
},
|
|
204
|
+
return t.version !== pe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? ne : q(it(t.settings), (r, n) => r.values.includes(n));
|
|
205
|
+
}, cr = (e, t) => {
|
|
206
206
|
const r = q(t, (n, o) => o !== void 0 && o !== e[n.key]);
|
|
207
207
|
return Object.keys(r).length === 0 ? e : Object.freeze({ ...e, ...r });
|
|
208
|
-
},
|
|
208
|
+
}, mr = (e, t, r, n) => q({ ...e, [t]: r }, (o, i) => i !== void 0 && !(o.key === t && i === n[t])), ur = (e) => JSON.stringify({ version: pe, settings: e }), at = (e, t, r) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : r * (e - t), fr = (e) => {
|
|
209
209
|
const { sortMode: t, folderPlacement: r, readmePlacement: n } = e;
|
|
210
210
|
if (t === "native" && r === "mixed" && n === "mixed") return;
|
|
211
211
|
const o = (i, a) => {
|
|
@@ -221,59 +221,59 @@ const Ye = Object.freeze([
|
|
|
221
221
|
if (t === "native") return 0;
|
|
222
222
|
if (t === "asc") return o(i, a);
|
|
223
223
|
if (t === "desc") return -o(i, a);
|
|
224
|
-
const d =
|
|
224
|
+
const d = at(i.modifiedAt, a.modifiedAt, t === "oldest" ? 1 : -1);
|
|
225
225
|
return d !== 0 ? d : o(i, a);
|
|
226
226
|
};
|
|
227
|
-
},
|
|
227
|
+
}, y = (1 + Math.sqrt(5)) / 2, wr = 100 / y ** 3, gr = 100 / y ** 4, Ee = 100 / y ** 2, dt = 13, hr = 16, pr = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), se = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), lt = Object.freeze([89, 144, 233, 377]), xe = 44, Er = xe;
|
|
228
228
|
2 * se[3] + xe + se[0];
|
|
229
|
-
const
|
|
229
|
+
const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
230
230
|
if (!Number.isFinite(e) || e <= 0)
|
|
231
231
|
throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${s(e)}`);
|
|
232
|
-
},
|
|
232
|
+
}, mt = (e) => (ct(e), dt * e), Sr = (e) => mt(e) * y ** 2, Or = 233, kr = 50, ut = 100 / y ** 3, Tr = 100 - ut, Rr = lt[0], x = (e, t) => {
|
|
233
233
|
if (!Number.isFinite(t) || t < 0)
|
|
234
234
|
throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${s(t)}`);
|
|
235
|
-
},
|
|
236
|
-
if (
|
|
235
|
+
}, ft = ({ trackInlineSize: e, gap: t, minColumnInlineSize: r, logicalColumns: n }) => {
|
|
236
|
+
if (x("trackInlineSize", e), x("gap", t), !Number.isFinite(r) || r <= 0)
|
|
237
237
|
throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${s(r)}`);
|
|
238
238
|
if (!Number.isInteger(n) || n < 1)
|
|
239
239
|
throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${s(n)}`);
|
|
240
240
|
const o = Math.floor((e + t) / (r + t));
|
|
241
241
|
return Math.min(n, Math.max(1, o));
|
|
242
|
-
},
|
|
242
|
+
}, Ir = (e, t) => {
|
|
243
243
|
const { trackInlineSize: r, gap: n, minColumnInlineSize: o, logicalColumns: i } = t;
|
|
244
244
|
if (!([r, n, o].every(Number.isFinite) && r > 0 && n >= 0 && o > 0)) return e;
|
|
245
|
-
const d =
|
|
245
|
+
const d = ft(t);
|
|
246
246
|
if (e === null || d === e) return d;
|
|
247
247
|
const l = Math.min(i, Math.max(1, e));
|
|
248
248
|
if (d > l) {
|
|
249
|
-
const
|
|
250
|
-
return r >=
|
|
249
|
+
const w = (l + 1) * o + l * n + n / y;
|
|
250
|
+
return r >= w ? d : l;
|
|
251
251
|
}
|
|
252
252
|
return r >= l * o + (l - 1) * n ? l : d;
|
|
253
|
-
},
|
|
253
|
+
}, $r = (e, t) => {
|
|
254
254
|
if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
|
|
255
255
|
throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${s(t)}`);
|
|
256
256
|
return Array.from({ length: t }, (r, n) => [Math.floor(n * e / t), Math.floor((n + 1) * e / t)]);
|
|
257
257
|
}, _r = (e, t, r) => {
|
|
258
|
-
if (
|
|
258
|
+
if (x("surfaceInlineSize", e), x("handlePixels", r), !Number.isFinite(t) || t <= 0)
|
|
259
259
|
throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${s(t)}`);
|
|
260
260
|
return e >= 2 * t + r ? "beside" : "stacked";
|
|
261
261
|
}, W = (e, t, r) => Math.max(t, Math.min(e, r)), ie = (e, t, r, n) => {
|
|
262
262
|
const o = (W(e, 0, r) + W(t, 0, r)) / 2;
|
|
263
263
|
return W(o - n / 2, 0, r - n);
|
|
264
|
-
},
|
|
264
|
+
}, vr = (e, t, r) => {
|
|
265
265
|
for (const [n, o] of Object.entries(e))
|
|
266
266
|
if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${s(o)}`);
|
|
267
|
-
return
|
|
267
|
+
return x("marginBox.width", t.width), x("marginBox.height", t.height), x("viewport.width", r.width), x("viewport.height", r.height), {
|
|
268
268
|
left: ie(e.left, e.right, r.width, t.width),
|
|
269
269
|
top: ie(e.top, e.bottom, r.height, t.height)
|
|
270
270
|
};
|
|
271
|
-
},
|
|
272
|
-
if (typeof e != "string" || !
|
|
271
|
+
}, wt = 31536e3, gt = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, ht = (e) => {
|
|
272
|
+
if (typeof e != "string" || !gt.test(e))
|
|
273
273
|
throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${s(e)}`);
|
|
274
|
-
}, ae = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= Ee, A = (e, t) => typeof t == "string" && e.includes(t),
|
|
274
|
+
}, ae = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= Ee, A = (e, t) => typeof t == "string" && e.includes(t), pt = (e, t) => {
|
|
275
275
|
if (e === null || typeof e != "object" || Array.isArray(e)) return {};
|
|
276
|
-
const r = e, { treeExplorer: n, treeExplorerHidden: o, multiExplorer: i, multiExplorerHidden: a, style: d, align: l, measure: u, documentColors:
|
|
276
|
+
const r = e, { treeExplorer: n, treeExplorerHidden: o, multiExplorer: i, multiExplorerHidden: a, style: d, align: l, measure: u, documentColors: w } = r;
|
|
277
277
|
return {
|
|
278
278
|
...ae(n) ? { treeExplorer: n } : {},
|
|
279
279
|
...o === !0 ? { treeExplorerHidden: o } : {},
|
|
@@ -281,25 +281,25 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
281
281
|
...a === !0 ? { multiExplorerHidden: a } : {},
|
|
282
282
|
...A(t, d) ? { style: d } : {},
|
|
283
283
|
...A(D, l) ? { align: l } : {},
|
|
284
|
-
...A(
|
|
285
|
-
...A(
|
|
284
|
+
...A(Ve, u) ? { measure: u } : {},
|
|
285
|
+
...A(Ue, w) ? { documentColors: w } : {}
|
|
286
286
|
};
|
|
287
|
-
},
|
|
287
|
+
}, Pr = (e, t) => {
|
|
288
288
|
if (e !== null)
|
|
289
289
|
for (const r of e.split(";")) {
|
|
290
290
|
const n = r.indexOf("=");
|
|
291
291
|
if (!(n < 0) && r.slice(0, n).trim() === t)
|
|
292
292
|
return r.slice(n + 1).trim();
|
|
293
293
|
}
|
|
294
|
-
},
|
|
294
|
+
}, Ar = (e, t) => {
|
|
295
295
|
if (e === void 0 || e === "") return {};
|
|
296
296
|
try {
|
|
297
|
-
return
|
|
297
|
+
return pt(JSON.parse(decodeURIComponent(e)), t);
|
|
298
298
|
} catch {
|
|
299
299
|
return {};
|
|
300
300
|
}
|
|
301
|
-
},
|
|
302
|
-
const t = (r) => Math.min(
|
|
301
|
+
}, M = 100, Et = Math.floor(Ee * M) / M, xt = (e) => {
|
|
302
|
+
const t = (r) => Math.min(Et, Math.max(1, Math.round(r * M)) / M);
|
|
303
303
|
return encodeURIComponent(
|
|
304
304
|
JSON.stringify({
|
|
305
305
|
...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
|
|
@@ -312,9 +312,9 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
312
312
|
...e.documentColors === void 0 ? {} : { documentColors: e.documentColors }
|
|
313
313
|
})
|
|
314
314
|
);
|
|
315
|
-
},
|
|
315
|
+
}, Dr = (e, t, r) => `${e}=${xt(t)}; Path=/; Max-Age=${String(wt)}; SameSite=Lax${r ? "; Secure" : ""}`, be = ["ctrl", "shift"], bt = (e) => typeof e == "string" && be.includes(e), de = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), yt = Object.freeze({ default: 12, min: 1, max: 64 }), St = Object.freeze({ default: 4, min: 1, max: 6 }), Ot = Object.freeze({ default: 500, min: 1, max: 1e4 }), kt = Object.freeze({ default: 16, min: 1, max: 64 }), Tt = Object.freeze({ default: 16, min: 1, max: 64 }), Rt = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), It = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ye = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, $t = /^[a-z0-9][a-z0-9-]*$/u, _t = /^(?=.{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, le = (e, t) => {
|
|
316
316
|
if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${s(t)}`);
|
|
317
|
-
if (!
|
|
317
|
+
if (!Ge(t))
|
|
318
318
|
throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${s(t)}`);
|
|
319
319
|
}, ce = Object.freeze(
|
|
320
320
|
Object.keys({
|
|
@@ -328,6 +328,7 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
328
328
|
revealDocument: !0,
|
|
329
329
|
documentStyles: !0,
|
|
330
330
|
defaultDocumentStyle: !0,
|
|
331
|
+
mermaidModifier: !0,
|
|
331
332
|
iframeHosts: !0,
|
|
332
333
|
appOrigins: !0,
|
|
333
334
|
mediaDataPath: !0,
|
|
@@ -336,93 +337,93 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
336
337
|
legacyTextEncoding: !0,
|
|
337
338
|
spreadsheets: !0
|
|
338
339
|
})
|
|
339
|
-
),
|
|
340
|
+
), b = (e, t, r) => {
|
|
340
341
|
if (t === void 0) return [];
|
|
341
|
-
if (
|
|
342
|
+
if (!v(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${s(t)}`);
|
|
342
343
|
const n = Object.entries(t);
|
|
343
344
|
for (const [o] of n)
|
|
344
345
|
if (!r.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);
|
|
345
346
|
return n.filter(([, o]) => o !== void 0);
|
|
346
|
-
},
|
|
347
|
+
}, vt = (e) => {
|
|
347
348
|
const t = { ...de };
|
|
348
|
-
for (const [r, n] of
|
|
349
|
+
for (const [r, n] of b("views", e, Object.keys(de))) t[r] = n;
|
|
349
350
|
for (const [r, n] of Object.entries(t))
|
|
350
|
-
if (typeof n != "string" || !
|
|
351
|
+
if (typeof n != "string" || !ye.test(n))
|
|
351
352
|
throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(n)}`);
|
|
352
353
|
return Object.freeze(t);
|
|
353
|
-
},
|
|
354
|
+
}, Pt = (e) => {
|
|
354
355
|
if (e === void 0) return null;
|
|
355
|
-
const t =
|
|
356
|
-
if (typeof t != "string" || !
|
|
356
|
+
const t = b("documentIds", e, ["slug"]).find(([r]) => r === "slug")?.[1];
|
|
357
|
+
if (typeof t != "string" || !ye.test(t))
|
|
357
358
|
throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${s(t)}`);
|
|
358
359
|
return Object.freeze({ slug: t });
|
|
359
|
-
},
|
|
360
|
+
}, O = (e, t, r) => {
|
|
360
361
|
if (t === void 0) return r.default;
|
|
361
362
|
if (typeof t != "number" || !Number.isInteger(t) || t < r.min || t > r.max)
|
|
362
363
|
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${s(t)}`);
|
|
363
364
|
return t;
|
|
364
|
-
},
|
|
365
|
-
const r = new Map(
|
|
366
|
-
if (r.size === 0) return
|
|
365
|
+
}, At = (e, t) => {
|
|
366
|
+
const r = new Map(b("embeds", e, ["providers", "linkCards", "linkCardSize"]));
|
|
367
|
+
if (r.size === 0) return Me;
|
|
367
368
|
const n = r.has("providers") ? r.get("providers") : [];
|
|
368
369
|
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${s(n)}`);
|
|
369
370
|
for (const d of n)
|
|
370
371
|
if (!ze(d)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Le.join(", ")}; got ${s(d)}`);
|
|
371
372
|
const o = r.has("linkCards") ? r.get("linkCards") : !1;
|
|
372
373
|
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${s(o)}`);
|
|
373
|
-
const i = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ?
|
|
374
|
+
const i = { providers: Object.freeze([...new Set(n)]), linkCardEndpoint: o ? Xe(t) : null };
|
|
374
375
|
if (!r.has("linkCardSize")) return Object.freeze(i);
|
|
375
376
|
const a = r.get("linkCardSize");
|
|
376
|
-
if (!
|
|
377
|
+
if (!je(a)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Fe.join(", ")}; got ${s(a)}`);
|
|
377
378
|
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${s(a)} with linkCards ${s(o)}`);
|
|
378
379
|
return Object.freeze({ ...i, linkCardSize: a });
|
|
379
|
-
},
|
|
380
|
+
}, Dt = (e) => {
|
|
380
381
|
if (e === void 0) return null;
|
|
381
382
|
if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${s(e)}`);
|
|
382
383
|
return fe(e);
|
|
383
|
-
},
|
|
384
|
+
}, Nt = (e) => {
|
|
384
385
|
if (e === void 0) return Object.freeze([]);
|
|
385
386
|
if (!Array.isArray(e)) throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${s(e)}`);
|
|
386
387
|
for (const [t, r] of e.entries()) {
|
|
387
388
|
if (typeof r != "string") throw new TypeError(`[markdown-explorer] appOrigins[${String(t)}] must be a string; got ${s(r)}`);
|
|
388
|
-
if (!
|
|
389
|
+
if (!Ke(r))
|
|
389
390
|
throw new RangeError(`[markdown-explorer] appOrigins[${String(t)}] must be an origin as the browser writes it (scheme://host[:port], without a default port, path, query, fragment or user info); got ${s(r)}`);
|
|
390
391
|
}
|
|
391
392
|
return Object.freeze([...new Set(e)]);
|
|
392
|
-
},
|
|
393
|
+
}, Ct = (e) => {
|
|
393
394
|
if (e === void 0) return null;
|
|
394
395
|
if (typeof e != "string") throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${s(e)}`);
|
|
395
|
-
if (!
|
|
396
|
+
if (!He(e))
|
|
396
397
|
throw new RangeError(
|
|
397
398
|
`[markdown-explorer] mediaDataPath must be an absolute http: or https: URL as the browser writes it, of an origin and a path that starts with "/", has no trailing "/", uses only letters, digits and "._~-" in each segment and has no "." or ".." segment, without a query, fragment or user info; got ${s(e)}`
|
|
398
399
|
);
|
|
399
400
|
return e;
|
|
400
|
-
},
|
|
401
|
+
}, Mt = (e) => {
|
|
401
402
|
const t = new Map(
|
|
402
|
-
|
|
403
|
+
b(
|
|
403
404
|
"defaultTreeSettings",
|
|
404
405
|
e,
|
|
405
|
-
|
|
406
|
+
T.map((n) => n.key)
|
|
406
407
|
)
|
|
407
408
|
);
|
|
408
409
|
if (t.size === 0) return re;
|
|
409
410
|
const r = { ...re };
|
|
410
|
-
for (const n of
|
|
411
|
+
for (const n of T) {
|
|
411
412
|
if (!t.has(n.key)) continue;
|
|
412
413
|
const o = t.get(n.key), i = n.values;
|
|
413
414
|
if (!i.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(s).join(", ")}; got ${s(o)}`);
|
|
414
415
|
r[n.key] = o;
|
|
415
416
|
}
|
|
416
417
|
return Object.freeze(r);
|
|
417
|
-
},
|
|
418
|
+
}, zt = (e) => {
|
|
418
419
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
|
|
419
420
|
for (const c of Object.keys(e))
|
|
420
421
|
if (!ce.includes(c)) throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${ce.join(", ")}`);
|
|
421
422
|
le("basePath", e.basePath), le("dataPath", e.dataPath);
|
|
422
|
-
const t =
|
|
423
|
+
const t = vt(e.views);
|
|
423
424
|
if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
|
|
424
425
|
throw new RangeError(`[markdown-explorer] the view slugs must differ; got tree ${s(t.tree)}, multi ${s(t.multi)} and single ${s(t.single)}`);
|
|
425
|
-
const r =
|
|
426
|
+
const r = Pt(e.documentIds);
|
|
426
427
|
if (r !== null && [t.tree, t.multi, t.single].includes(r.slug))
|
|
427
428
|
throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${s(r.slug)}`);
|
|
428
429
|
if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
|
|
@@ -431,13 +432,13 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
431
432
|
if (c === t.tree || c === t.multi || c === t.single || c === r?.slug)
|
|
432
433
|
throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${s(e.dataPath)}`);
|
|
433
434
|
}
|
|
434
|
-
|
|
435
|
+
ht(e.settingsCookie);
|
|
435
436
|
const n = e.iframeHosts ?? [];
|
|
436
437
|
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${s(n)}`);
|
|
437
|
-
for (const [c,
|
|
438
|
-
if (typeof
|
|
439
|
-
throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(
|
|
440
|
-
const o = Object.fromEntries(
|
|
438
|
+
for (const [c, E] of n.entries())
|
|
439
|
+
if (typeof E != "string" || !_t.test(E))
|
|
440
|
+
throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(E)}`);
|
|
441
|
+
const o = Object.fromEntries(b("multiView", e.multiView, ["maxPanels", "columns"])), i = Object.fromEntries(b("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), a = Object.fromEntries(b("revealDocument", e.revealDocument, ["maxDepth"])), d = Object.fromEntries(b("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), l = e.documentStyles ?? Be;
|
|
441
442
|
if (!Array.isArray(l) || l.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
442
443
|
const u = /* @__PURE__ */ new Set();
|
|
443
444
|
for (const c of l) {
|
|
@@ -446,12 +447,15 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
446
447
|
if (u.has(c.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${s(c.name)} repeats`);
|
|
447
448
|
u.add(c.name);
|
|
448
449
|
}
|
|
449
|
-
const
|
|
450
|
-
if (typeof
|
|
451
|
-
if (!u.has(
|
|
450
|
+
const w = e.defaultDocumentStyle === void 0 ? We : e.defaultDocumentStyle;
|
|
451
|
+
if (typeof w != "string") throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${s(w)}`);
|
|
452
|
+
if (!u.has(w)) {
|
|
452
453
|
const c = e.defaultDocumentStyle === void 0 ? " (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)" : "";
|
|
453
|
-
throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...u].map(s).join(", ")}); got ${s(
|
|
454
|
+
throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...u].map(s).join(", ")}); got ${s(w)}${c}`);
|
|
454
455
|
}
|
|
456
|
+
const f = e.mermaidModifier;
|
|
457
|
+
if (f !== void 0 && !bt(f))
|
|
458
|
+
throw new RangeError(`[markdown-explorer] mermaidModifier must be one of ${be.map(s).join(", ")}; got ${s(f)}`);
|
|
455
459
|
return Object.freeze({
|
|
456
460
|
basePath: e.basePath,
|
|
457
461
|
dataPath: e.dataPath,
|
|
@@ -459,30 +463,31 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
459
463
|
views: t,
|
|
460
464
|
documentIds: r,
|
|
461
465
|
multiView: Object.freeze({
|
|
462
|
-
maxPanels:
|
|
463
|
-
columns:
|
|
466
|
+
maxPanels: O("multiView.maxPanels", o.maxPanels, yt),
|
|
467
|
+
columns: O("multiView.columns", o.columns, St)
|
|
464
468
|
}),
|
|
465
469
|
expandAll: Object.freeze({
|
|
466
|
-
maxFolders:
|
|
467
|
-
maxDepth:
|
|
470
|
+
maxFolders: O("expandAll.maxFolders", i.maxFolders, Ot),
|
|
471
|
+
maxDepth: O("expandAll.maxDepth", i.maxDepth, kt)
|
|
468
472
|
}),
|
|
469
|
-
revealDocument: Object.freeze({ maxDepth:
|
|
473
|
+
revealDocument: Object.freeze({ maxDepth: O("revealDocument.maxDepth", a.maxDepth, Tt) }),
|
|
470
474
|
documentStyles: Object.freeze(l.map((c) => Object.freeze({ name: c.name, className: c.className }))),
|
|
471
|
-
defaultDocumentStyle:
|
|
475
|
+
defaultDocumentStyle: w,
|
|
476
|
+
mermaidModifier: f,
|
|
472
477
|
iframeHosts: Object.freeze([...new Set(n)]),
|
|
473
|
-
appOrigins:
|
|
474
|
-
mediaDataPath:
|
|
475
|
-
embeds:
|
|
476
|
-
defaultTreeSettings:
|
|
477
|
-
legacyTextEncoding:
|
|
478
|
+
appOrigins: Nt(e.appOrigins),
|
|
479
|
+
mediaDataPath: Ct(e.mediaDataPath),
|
|
480
|
+
embeds: At(e.embeds, e.dataPath),
|
|
481
|
+
defaultTreeSettings: Mt(e.defaultTreeSettings),
|
|
482
|
+
legacyTextEncoding: Dt(e.legacyTextEncoding),
|
|
478
483
|
spreadsheets: Object.freeze({
|
|
479
|
-
maxBytes:
|
|
480
|
-
maxWorkbookBytes:
|
|
484
|
+
maxBytes: O("spreadsheets.maxBytes", d.maxBytes, Rt),
|
|
485
|
+
maxWorkbookBytes: O("spreadsheets.maxWorkbookBytes", d.maxWorkbookBytes, It)
|
|
481
486
|
})
|
|
482
487
|
});
|
|
483
|
-
},
|
|
488
|
+
}, Nr = (e) => {
|
|
484
489
|
const t = e.embeds;
|
|
485
|
-
if (
|
|
490
|
+
if (!v(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${s(t)}`);
|
|
486
491
|
if (Object.hasOwn(t, "linkCards"))
|
|
487
492
|
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 ${s(t.linkCards)})`);
|
|
488
493
|
const r = e.legacyTextEncoding;
|
|
@@ -492,9 +497,9 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
492
497
|
if (n !== null && typeof n != "string")
|
|
493
498
|
throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${s(n)}`);
|
|
494
499
|
const o = e.documentIds;
|
|
495
|
-
if (o !== null &&
|
|
500
|
+
if (o !== null && !v(o))
|
|
496
501
|
throw new TypeError(`[markdown-explorer] config.documentIds must be the segment defineExplorerConfig resolved, or null; got ${s(o)}`);
|
|
497
|
-
const { linkCardEndpoint: i, ...a } = t, d =
|
|
502
|
+
const { linkCardEndpoint: i, ...a } = t, d = zt({
|
|
498
503
|
...e,
|
|
499
504
|
embeds: { ...a, linkCards: i !== null },
|
|
500
505
|
legacyTextEncoding: r === null ? void 0 : r,
|
|
@@ -506,10 +511,10 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
506
511
|
if (d.legacyTextEncoding !== r)
|
|
507
512
|
throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${s(d.legacyTextEncoding)} (the written name of the encoding it names); got ${s(r)}`);
|
|
508
513
|
const l = e;
|
|
509
|
-
for (const [u,
|
|
510
|
-
const
|
|
511
|
-
if (
|
|
512
|
-
throw
|
|
514
|
+
for (const [u, w] of Object.entries(d)) {
|
|
515
|
+
const f = H(l[u], w, u);
|
|
516
|
+
if (f !== null)
|
|
517
|
+
throw f.kind === "extra" ? new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${s(f.given)} there`) : new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${s(f.given)} where it resolves ${s(f.resolved)}`);
|
|
513
518
|
}
|
|
514
519
|
return d;
|
|
515
520
|
}, H = (e, t, r) => {
|
|
@@ -523,24 +528,24 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
523
528
|
}
|
|
524
529
|
return null;
|
|
525
530
|
}
|
|
526
|
-
if (!(
|
|
531
|
+
if (!(v(t) && v(e))) return { kind: "value", path: r, given: e, resolved: t };
|
|
527
532
|
for (const o of Object.keys(t)) {
|
|
528
533
|
const i = H(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${r}.${o}`);
|
|
529
534
|
if (i !== null) return i;
|
|
530
535
|
}
|
|
531
536
|
const n = Object.keys(e).find((o) => !Object.hasOwn(t, o));
|
|
532
537
|
return n === void 0 ? null : { kind: "extra", path: `${r}.${n}`, given: e[n] };
|
|
533
|
-
},
|
|
538
|
+
}, Lt = (e) => typeof e == "string" && $t.test(e), Cr = (e, t) => {
|
|
534
539
|
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${s(e)}`);
|
|
535
540
|
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${s(t)}`);
|
|
536
541
|
const r = /* @__PURE__ */ new Set();
|
|
537
542
|
for (const [n, o] of t.entries()) {
|
|
538
|
-
if (!
|
|
543
|
+
if (!Lt(o)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${s(o)}`);
|
|
539
544
|
if (r.has(o)) throw new RangeError(`[markdown-explorer] source ids must be unique; ${s(o)} repeats at sourceIds[${String(n)}]`);
|
|
540
545
|
r.add(o);
|
|
541
546
|
}
|
|
542
547
|
return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
|
|
543
|
-
},
|
|
548
|
+
}, Mr = (e) => e.documentStyles.map((t) => t.name), zr = (e) => Object.freeze({
|
|
544
549
|
origins: e.appOrigins,
|
|
545
550
|
resources: Object.freeze([e.dataPath]),
|
|
546
551
|
links: Object.freeze([e.basePath, e.dataPath]),
|
|
@@ -558,26 +563,26 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
558
563
|
width: "width",
|
|
559
564
|
maxWidth: "maxWidth",
|
|
560
565
|
markup: "markup"
|
|
561
|
-
}),
|
|
566
|
+
}), Se = "true", Oe = "true", z = "/", me = ".data", ke = 256, Te = /^\d+(?:\.\d+)?$/u, K = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Re = Object.freeze(["showToc", "showStyle", "showAlign"]), ue = (e) => {
|
|
562
567
|
const t = encodeURIComponent(e.replaceAll("%", "%25"));
|
|
563
568
|
return t.endsWith(me) ? `${t.slice(0, -me.length)}%2Edata` : t;
|
|
564
|
-
},
|
|
569
|
+
}, jt = (e) => e.replaceAll("%25", "%"), Ie = (e) => {
|
|
565
570
|
const { sourceIds: t } = e;
|
|
566
571
|
if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
|
|
567
572
|
return t;
|
|
568
|
-
},
|
|
573
|
+
}, Ft = (e, t, r) => {
|
|
569
574
|
const n = r.getAll(m.source);
|
|
570
575
|
if (n.length === 0) return t;
|
|
571
576
|
const [o] = n;
|
|
572
577
|
return n.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
|
|
573
|
-
},
|
|
578
|
+
}, $e = (e, t) => {
|
|
574
579
|
const r = t.get(m.style), n = t.get(m.align);
|
|
575
580
|
return {
|
|
576
581
|
...r !== null && e.documentStyles.some((o) => o.name === r) ? { style: r } : {},
|
|
577
582
|
...n !== null && D.includes(n) ? { align: n } : {}
|
|
578
583
|
};
|
|
579
|
-
}, _e = (e) => Number.isFinite(e) && e >= 0 && e <=
|
|
580
|
-
const t = e.get(m.padding), r = t !== null &&
|
|
584
|
+
}, _e = (e) => Number.isFinite(e) && e >= 0 && e <= ke && Te.test(String(e)), ve = (e) => {
|
|
585
|
+
const t = e.get(m.padding), r = t !== null && Te.test(t) ? Number(t) : Number.NaN, n = e.get(m.width), o = e.get(m.maxWidth);
|
|
581
586
|
return {
|
|
582
587
|
...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
|
|
583
588
|
...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
|
|
@@ -586,7 +591,7 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
586
591
|
...n !== null && K.test(n) ? { width: n } : {},
|
|
587
592
|
...o !== null && K.test(o) ? { maxWidth: o } : {}
|
|
588
593
|
};
|
|
589
|
-
},
|
|
594
|
+
}, Ut = (e, t) => [...new Set(t.filter(_))].slice(0, e.multiView.maxPanels), Vt = (e, t, r, n) => {
|
|
590
595
|
for (const i of t) Y(i);
|
|
591
596
|
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`);
|
|
592
597
|
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)}`);
|
|
@@ -597,165 +602,164 @@ const Er = 1 / b, xr = 1 / b ** 3, br = "40ch", lt = (e) => {
|
|
|
597
602
|
}, Y = (e) => {
|
|
598
603
|
if (!_(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${s(e)}`);
|
|
599
604
|
return e;
|
|
600
|
-
},
|
|
601
|
-
if (!
|
|
605
|
+
}, Bt = (e) => {
|
|
606
|
+
if (!Wt(Y(e))) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${s(e)}`);
|
|
602
607
|
return e;
|
|
603
|
-
},
|
|
608
|
+
}, Wt = (e) => _(e) && !e.endsWith(z), Gt = (e, t) => {
|
|
604
609
|
if (t.style !== void 0 && !e.documentStyles.some((r) => r.name === t.style))
|
|
605
610
|
throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((r) => s(r.name)).join(", ")}); got ${s(t.style)}`);
|
|
606
611
|
if (t.align !== void 0 && !D.includes(t.align))
|
|
607
612
|
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${D.join(", ")}; got ${s(t.align)}`);
|
|
608
|
-
},
|
|
609
|
-
for (const t of
|
|
613
|
+
}, Ht = (e) => {
|
|
614
|
+
for (const t of Re)
|
|
610
615
|
if (e[t] !== void 0 && typeof e[t] != "boolean") throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${s(e[t])}`);
|
|
611
|
-
if (e.padding !== void 0 && !_e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(
|
|
616
|
+
if (e.padding !== void 0 && !_e(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(ke)} px in plain decimal digits; got ${s(e.padding)}`);
|
|
612
617
|
for (const t of ["width", "maxWidth"]) {
|
|
613
618
|
const r = e[t];
|
|
614
619
|
if (r !== void 0 && !K.test(r)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${s(r)}`);
|
|
615
620
|
}
|
|
616
|
-
},
|
|
617
|
-
if (t.view === "document-id") return
|
|
621
|
+
}, Pe = (e, t) => {
|
|
622
|
+
if (t.view === "document-id") return Kt(e, t);
|
|
618
623
|
const r = new URLSearchParams();
|
|
619
624
|
let n = `${e.basePath}/${e.views[t.view]}`;
|
|
620
625
|
if (t.view === "multi") {
|
|
621
626
|
const i = t.docs ?? [], a = t.maximized ?? null, d = t.markup ?? [];
|
|
622
|
-
|
|
627
|
+
Vt(e, i, a, d);
|
|
623
628
|
for (const l of i) r.append(m.doc, l);
|
|
624
629
|
a !== null && r.set(m.maximized, a);
|
|
625
630
|
for (const l of i) d.includes(l) && r.append(m.markup, l);
|
|
626
631
|
} else {
|
|
627
632
|
const i = t.doc ?? null, a = t.view === "tree" ? t.folder ?? null : null;
|
|
628
633
|
if (i !== null && a !== null) throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");
|
|
629
|
-
i !== null && (n += `/${ue(
|
|
634
|
+
i !== null && (n += `/${ue(Bt(i))}`), a !== null && (n += `/${ue(`${Y(a)}${z}`)}`);
|
|
630
635
|
}
|
|
631
636
|
if (t.source !== void 0) {
|
|
632
|
-
const i =
|
|
637
|
+
const i = Ie(e);
|
|
633
638
|
if (!i.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${s(t.source)}; expected one of ${i.join(", ")}`);
|
|
634
639
|
t.source !== i[0] && r.set(m.source, t.source);
|
|
635
640
|
}
|
|
636
|
-
t.view !== "multi" && t.overrides !== void 0 &&
|
|
641
|
+
t.view !== "multi" && t.overrides !== void 0 && Ae(e, r, t.overrides);
|
|
637
642
|
const o = t.view !== "multi" && (t.doc !== void 0 && t.doc !== null || t.view === "tree" && t.folder !== void 0 && t.folder !== null);
|
|
638
643
|
if (t.view === "tree" && t.maximized === !0) {
|
|
639
644
|
if (!o) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");
|
|
640
|
-
r.set(m.maximized,
|
|
645
|
+
r.set(m.maximized, Oe);
|
|
641
646
|
}
|
|
642
647
|
if (t.view !== "multi" && t.markup === !0) {
|
|
643
648
|
if (!o) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");
|
|
644
|
-
r.set(m.markup,
|
|
649
|
+
r.set(m.markup, Se);
|
|
645
650
|
}
|
|
646
|
-
return t.view === "single" && t.embed !== void 0 &&
|
|
647
|
-
},
|
|
651
|
+
return t.view === "single" && t.embed !== void 0 && De(r, t.embed), Ne(n, r);
|
|
652
|
+
}, Kt = (e, t) => {
|
|
648
653
|
if (e.documentIds === null) throw new TypeError("[markdown-explorer] an ID link needs documentIds in defineExplorerConfig");
|
|
649
|
-
if (!
|
|
654
|
+
if (!qe(t.id)) throw new RangeError(`[markdown-explorer] not a canonical document ID: ${s(t.id)}`);
|
|
650
655
|
if (t.opens !== void 0 && t.opens !== "single") throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${s(t.opens)}`);
|
|
651
656
|
if (t.embed !== void 0 && t.opens !== "single") throw new RangeError('[markdown-explorer] embed needs opens: "single" (only the single view takes embedding options)');
|
|
652
657
|
const r = new URLSearchParams();
|
|
653
|
-
t.overrides !== void 0 &&
|
|
658
|
+
t.overrides !== void 0 && Ae(e, r, t.overrides), t.embed !== void 0 && De(r, t.embed);
|
|
654
659
|
const n = t.opens === "single" ? `/${e.views.single}` : "";
|
|
655
|
-
return
|
|
656
|
-
},
|
|
657
|
-
|
|
658
|
-
}, Ae = (e, t) => {
|
|
659
|
-
Wt(t);
|
|
660
|
-
for (const r of Te) t[r] === !1 && e.set(m[r], "false");
|
|
661
|
-
t.padding !== void 0 && e.set(m.padding, String(t.padding)), t.width !== void 0 && e.set(m.width, t.width), t.maxWidth !== void 0 && e.set(m.maxWidth, t.maxWidth);
|
|
660
|
+
return Ne(`${e.basePath}/${e.documentIds.slug}/${t.id}${n}`, r);
|
|
661
|
+
}, Ae = (e, t, r) => {
|
|
662
|
+
Gt(e, r), r.style !== void 0 && t.set(m.style, r.style), r.align !== void 0 && t.set(m.align, r.align);
|
|
662
663
|
}, De = (e, t) => {
|
|
664
|
+
Ht(t);
|
|
665
|
+
for (const r of Re) t[r] === !1 && e.set(m[r], "false");
|
|
666
|
+
t.padding !== void 0 && e.set(m.padding, String(t.padding)), t.width !== void 0 && e.set(m.width, t.width), t.maxWidth !== void 0 && e.set(m.maxWidth, t.maxWidth);
|
|
667
|
+
}, Ne = (e, t) => {
|
|
663
668
|
const r = t.toString();
|
|
664
669
|
return r === "" ? e : `${e}?${r}`;
|
|
665
|
-
},
|
|
666
|
-
const n =
|
|
670
|
+
}, Xt = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), Lr = (e, t, r) => {
|
|
671
|
+
const n = Ie(e), [o] = n;
|
|
667
672
|
if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
|
|
668
|
-
const i =
|
|
673
|
+
const i = Ft(n, o, r), a = i === null ? o : i, d = (p) => ({ kind: "redirect", href: Pe(e, p), location: p }), l = () => d({ view: "tree", source: a, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 });
|
|
669
674
|
if (t === void 0 || t === "") return l();
|
|
670
|
-
const u = t.indexOf("/"),
|
|
671
|
-
if (e.documentIds !== null &&
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
if (
|
|
675
|
-
const p = r.getAll(m.doc),
|
|
676
|
-
return
|
|
675
|
+
const u = t.indexOf("/"), w = u < 0 ? t : t.slice(0, u), f = u < 0 ? null : t.slice(u + 1);
|
|
676
|
+
if (e.documentIds !== null && w === e.documentIds.slug) return qt(e, f, r, o, l);
|
|
677
|
+
const c = Xt(e, w);
|
|
678
|
+
if (c === void 0) return l();
|
|
679
|
+
if (c === "multi") {
|
|
680
|
+
const p = r.getAll(m.doc), k = Ut(e, p), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && k.includes(F) ? F : null, V = r.getAll(m.markup), P = k.filter(($) => V.includes($)), Ce = P.length === V.length && P.every(($, B) => $ === V[B]);
|
|
681
|
+
return f === null && i !== null && k.length === p.length && k.every(($, B) => $ === p[B]) && (j.length === 0 || U !== null) && Ce ? { kind: "location", location: { view: "multi", source: a, docs: k, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: k, maximized: U, markup: P });
|
|
677
682
|
}
|
|
678
|
-
const
|
|
683
|
+
const E = f === null ? null : jt(f), g = E?.endsWith(z) === !0 ? E.slice(0, -z.length) : null, h = E !== null && g === null ? E : null;
|
|
679
684
|
if (h !== null && !_(h) || g !== null && !_(g)) return l();
|
|
680
|
-
const
|
|
681
|
-
if (
|
|
682
|
-
if (g !== null) return d({ view: "tree", source: a, doc: null, folder: g, overrides:
|
|
685
|
+
const R = $e(e, r), I = (h !== null || g !== null) && r.get(m.markup) === Se;
|
|
686
|
+
if (c === "single") {
|
|
687
|
+
if (g !== null) return d({ view: "tree", source: a, doc: null, folder: g, overrides: R, markup: I, maximized: !1 });
|
|
683
688
|
if (h === null) return l();
|
|
684
|
-
const p =
|
|
685
|
-
return i === null ? d({ view:
|
|
689
|
+
const p = ve(r);
|
|
690
|
+
return i === null ? d({ view: c, source: a, doc: h, overrides: R, embed: p, markup: I }) : { kind: "location", location: { view: c, source: a, doc: h, overrides: R, embed: p, markup: I } };
|
|
686
691
|
}
|
|
687
|
-
const J = (h !== null || g !== null) && r.get(m.maximized) ===
|
|
688
|
-
return i === null ? d({ view:
|
|
689
|
-
},
|
|
692
|
+
const J = (h !== null || g !== null) && r.get(m.maximized) === Oe;
|
|
693
|
+
return i === null ? d({ view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J }) : { kind: "location", location: { view: c, source: a, doc: h, folder: g, overrides: R, markup: I, maximized: J } };
|
|
694
|
+
}, qt = (e, t, r, n, o) => {
|
|
690
695
|
if (t === null || t === "") return o();
|
|
691
|
-
const i = t.indexOf("/"), a =
|
|
692
|
-
return d === e.views.single ? { kind: "document-id", id: a, opens: { view: "single", overrides: l, embed:
|
|
693
|
-
},
|
|
696
|
+
const i = t.indexOf("/"), a = Ye(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = $e(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
|
|
697
|
+
return d === e.views.single ? { kind: "document-id", id: a, opens: { view: "single", overrides: l, embed: ve(r) }, location: u } : d !== null && a !== null ? { kind: "redirect", href: Pe(e, { view: "document-id", id: a, overrides: l }), location: u } : { kind: "document-id", id: a, opens: { view: "tree", overrides: l }, location: u };
|
|
698
|
+
}, jr = (e, t, r) => e.view === "single" ? { view: "single", source: r, doc: t, overrides: e.overrides, embed: e.embed } : { view: "tree", source: r, doc: t, overrides: e.overrides };
|
|
694
699
|
export {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
700
|
+
yr as $,
|
|
701
|
+
dr as A,
|
|
702
|
+
ir as B,
|
|
703
|
+
Er as C,
|
|
704
|
+
Sr as D,
|
|
705
|
+
Tr as E,
|
|
706
|
+
mt as F,
|
|
707
|
+
Ee as G,
|
|
708
|
+
wr as H,
|
|
709
|
+
gr as I,
|
|
710
|
+
hr as J,
|
|
711
|
+
kr as K,
|
|
712
|
+
vr as L,
|
|
713
|
+
Rr as M,
|
|
709
714
|
C as N,
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
715
|
+
se as O,
|
|
716
|
+
xr as P,
|
|
717
|
+
y as Q,
|
|
718
|
+
tr as R,
|
|
719
|
+
Or as S,
|
|
720
|
+
mr as T,
|
|
721
|
+
ar as U,
|
|
722
|
+
cr as V,
|
|
723
|
+
ur as W,
|
|
724
|
+
ne as X,
|
|
725
|
+
lr as Y,
|
|
726
|
+
xt as Z,
|
|
727
|
+
Dr as _,
|
|
723
728
|
le as a,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
Dr as g,
|
|
729
|
+
re as a0,
|
|
730
|
+
de as a1,
|
|
731
|
+
kt as a2,
|
|
732
|
+
Ot as a3,
|
|
733
|
+
dt as a4,
|
|
734
|
+
St as a5,
|
|
735
|
+
yt as a6,
|
|
736
|
+
Tt as a7,
|
|
737
|
+
Rt as a8,
|
|
738
|
+
It as a9,
|
|
739
|
+
zt as aa,
|
|
740
|
+
or as b,
|
|
741
|
+
Ut as c,
|
|
742
|
+
rr as d,
|
|
743
|
+
Pe as e,
|
|
744
|
+
Mr as f,
|
|
745
|
+
Nr as g,
|
|
742
746
|
Lr as h,
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
747
|
+
Lt as i,
|
|
748
|
+
jr as j,
|
|
749
|
+
Wt as k,
|
|
746
750
|
fe as l,
|
|
747
|
-
|
|
748
|
-
|
|
751
|
+
ut as m,
|
|
752
|
+
pr as n,
|
|
749
753
|
zr as o,
|
|
750
|
-
|
|
754
|
+
Ar as p,
|
|
751
755
|
_r as q,
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
756
|
+
Pr as r,
|
|
757
|
+
$r as s,
|
|
758
|
+
nr as t,
|
|
759
|
+
Ir as u,
|
|
760
|
+
br as v,
|
|
761
|
+
Cr as w,
|
|
762
|
+
sr as x,
|
|
759
763
|
xe as y,
|
|
760
|
-
|
|
764
|
+
fr as z
|
|
761
765
|
};
|