@aiquants/markdown-explorer 0.30.0 → 0.31.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 +43 -0
- package/README.md +12 -8
- package/dist/{EditSurface-Cw0kbedj.cjs → EditSurface-BBHPQhf3.cjs} +3 -3
- package/dist/{EditSurface-DY1VNM9L.js → EditSurface-N7HkpyJA.js} +187 -187
- package/dist/{ExplorerSplit-x9Qkldh6.cjs → ExplorerSplit-C7GvlQ-G.cjs} +1 -1
- package/dist/{ExplorerSplit-D3f1FiZ7.js → ExplorerSplit-DMqbSL3i.js} +4 -4
- package/dist/{MultiLayout-B0dfZlpx.js → MultiLayout-9g9_IBi5.js} +237 -232
- package/dist/MultiLayout-mDzolCaK.cjs +1 -0
- package/dist/{NativeScrollBar-C2UoYO3i.cjs → NativeScrollBar-B0QLIVf3.cjs} +1 -1
- package/dist/{NativeScrollBar-C4vkvdGz.js → NativeScrollBar-BiLLVz18.js} +2 -2
- package/dist/{TreeLayout-DsFH17x_.cjs → TreeLayout-DKq_aXBx.cjs} +1 -1
- package/dist/{TreeLayout-Bak1y1m4.js → TreeLayout-OjVoHBDI.js} +3 -3
- package/dist/core/config.d.cts +2 -0
- package/dist/core/config.d.ts +2 -0
- package/dist/core/labels.d.cts +6 -0
- package/dist/core/labels.d.ts +6 -0
- package/dist/{index-auQVKY4M.js → index-C8yNTkdV.js} +917 -903
- package/dist/{index-DgaTEKsI.cjs → index-CT-daekP.cjs} +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/location-BxiJRTyw.cjs +1 -0
- package/dist/{location-CKuabtKl.js → location-perTmwct.js} +253 -245
- package/dist/{merge-D1jbIOPw.js → merge-Be3mcQZD.js} +1 -1
- package/dist/{merge-BEa-lale.cjs → merge-Cv6zPoVK.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +2 -2
- package/dist/{tapScrollCircle-BSb6lisN.cjs → tapScrollCircle-37FU6daT.cjs} +1 -1
- package/dist/{tapScrollCircle-DYQ8P2ag.js → tapScrollCircle-Cy1KyTg2.js} +1 -1
- package/dist/{useSplitPersistence-Bf4M35Il.js → useSplitPersistence-Du01PHNg.js} +1 -1
- package/dist/{useSplitPersistence-9Nu6J1WF.cjs → useSplitPersistence-pPmE4GTT.cjs} +1 -1
- package/docs/behavior/layout.md +8 -4
- package/docs/behavior/localization.md +3 -3
- package/docs/behavior/url-contract.md +1 -1
- package/package.json +6 -6
- package/dist/MultiLayout-BXr2UAvl.cjs +0 -1
- package/dist/location-l_HysaZR.cjs +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { NO_EMBEDS as
|
|
2
|
-
import { CONTENT_ALIGNS as
|
|
3
|
-
import { a as Ie, i as
|
|
4
|
-
const
|
|
1
|
+
import { NO_EMBEDS as xe, isEmbedProviderId as be, EMBED_PROVIDER_IDS as Oe, isLinkCardSize as ke, LINK_CARD_SIZES as Te } from "@aiquants/markdown/embeds";
|
|
2
|
+
import { CONTENT_ALIGNS as $, DEFAULT_MARKDOWN_STYLES as Re, DEFAULT_MARKDOWN_STYLE as _e } from "@aiquants/markdown/viewer-settings";
|
|
3
|
+
import { a as Ie, i as P } from "./dataRoute-DLhQfdoW.js";
|
|
4
|
+
const I = (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
|
+
}, Ne = Object.freeze([
|
|
9
9
|
"UTF-8",
|
|
10
10
|
"IBM866",
|
|
11
11
|
"ISO-8859-2",
|
|
@@ -46,12 +46,12 @@ const R = (e) => {
|
|
|
46
46
|
"UTF-16BE",
|
|
47
47
|
"UTF-16LE",
|
|
48
48
|
"x-user-defined"
|
|
49
|
-
]),
|
|
50
|
-
Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding:
|
|
49
|
+
]), Ae = new Map(Ne.map((e) => [e.toLowerCase(), e])), v = "UTF-8", q = Object.freeze([
|
|
50
|
+
Object.freeze({ bytes: Object.freeze([239, 187, 191]), encoding: v }),
|
|
51
51
|
Object.freeze({ bytes: Object.freeze([255, 254]), encoding: "UTF-16LE" }),
|
|
52
52
|
Object.freeze({ bytes: Object.freeze([254, 255]), encoding: "UTF-16BE" })
|
|
53
|
-
]),
|
|
54
|
-
[
|
|
53
|
+
]), $e = /* @__PURE__ */ new Map([
|
|
54
|
+
[v, "is read before any legacy encoding"],
|
|
55
55
|
["UTF-16LE", "is read only by its byte order mark"],
|
|
56
56
|
["UTF-16BE", "is read only by its byte order mark"],
|
|
57
57
|
["ISO-2022-JP", "writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],
|
|
@@ -63,41 +63,41 @@ const R = (e) => {
|
|
|
63
63
|
} catch (o) {
|
|
64
64
|
throw o instanceof RangeError ? new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`) : o;
|
|
65
65
|
}
|
|
66
|
-
const n =
|
|
66
|
+
const n = Pe(t), r = $e.get(n);
|
|
67
67
|
if (r !== void 0) throw new RangeError(`[markdown-explorer] legacyTextEncoding ${JSON.stringify(e)} names ${n}, which cannot be the legacy encoding: it ${r}`);
|
|
68
68
|
return n;
|
|
69
|
-
},
|
|
70
|
-
const t =
|
|
69
|
+
}, Pe = (e) => {
|
|
70
|
+
const t = Ae.get(e);
|
|
71
71
|
if (t === void 0) throw new RangeError(`[markdown-explorer] TextDecoder answered ${JSON.stringify(e)}, which is no encoding of the WHATWG Encoding Standard`);
|
|
72
72
|
return t;
|
|
73
|
-
},
|
|
74
|
-
const r = n === null ? null : de(n), o = q.find(({ bytes: i }) => i.every((a,
|
|
73
|
+
}, L = (e, t, n) => {
|
|
74
|
+
const r = n === null ? null : de(n), o = q.find(({ bytes: i }) => i.every((a, c) => e[c] === a));
|
|
75
75
|
if (o !== void 0) return { body: e.subarray(o.bytes.length), encodings: [o.encoding] };
|
|
76
|
-
const s = t || e.length === 0 ? void 0 : q.find(({ bytes: i }) => e.length < i.length && e.every((a,
|
|
77
|
-
return s !== void 0 ? { body: e.subarray(e.length), encodings: [s.encoding] } : { body: e, encodings: r === null ? [
|
|
78
|
-
},
|
|
76
|
+
const s = t || e.length === 0 ? void 0 : q.find(({ bytes: i }) => e.length < i.length && e.every((a, c) => i[c] === a));
|
|
77
|
+
return s !== void 0 ? { body: e.subarray(e.length), encodings: [s.encoding] } : { body: e, encodings: r === null ? [v] : [v, r] };
|
|
78
|
+
}, vt = (e, t, n) => L(e, t, n).encodings, ve = (e, t, n) => {
|
|
79
79
|
try {
|
|
80
80
|
return new TextDecoder(e, { fatal: !0, ignoreBOM: !0 }).decode(t, { stream: !n });
|
|
81
81
|
} catch (r) {
|
|
82
82
|
if (r instanceof TypeError) return null;
|
|
83
83
|
throw r;
|
|
84
84
|
}
|
|
85
|
-
},
|
|
86
|
-
const r = X(
|
|
85
|
+
}, Dt = (e, t, n) => {
|
|
86
|
+
const r = X(L(e, t, n), t);
|
|
87
87
|
return r === null ? null : r.text;
|
|
88
88
|
}, X = ({ body: e, encodings: t }, n) => {
|
|
89
89
|
for (const r of t) {
|
|
90
|
-
const o =
|
|
90
|
+
const o = ve(r, e, n);
|
|
91
91
|
if (o !== null) return { encoding: r, text: o };
|
|
92
92
|
}
|
|
93
93
|
return null;
|
|
94
94
|
}, jt = (e, t, n) => {
|
|
95
|
-
const r =
|
|
95
|
+
const r = L(e, t, n), o = X(r, t);
|
|
96
96
|
return o === null ? r.encodings[0] : o.encoding;
|
|
97
97
|
}, Ct = (e, t, n) => {
|
|
98
|
-
const r =
|
|
98
|
+
const r = L(e, t, n), o = X(r, t);
|
|
99
99
|
return o !== null ? o.text : new TextDecoder(r.encodings[0], { ignoreBOM: !0 }).decode(r.body, { stream: !t });
|
|
100
|
-
},
|
|
100
|
+
}, D = new Intl.Collator("en", { numeric: !0, sensitivity: "variant" }), De = /^readme(?:\.|$)/iu, Y = /^readme(?:\.[^.]*)?$/iu, Z = Object.freeze(["md", "markdown", "mdx", "txt", ""]), je = (e) => De.test(e), B = (e) => e.type === "file" && je(e.name), Q = (e) => {
|
|
101
101
|
const t = e.lastIndexOf("."), n = Z.indexOf(t < 0 ? "" : e.slice(t + 1).toLowerCase());
|
|
102
102
|
return n < 0 ? Z.length : n;
|
|
103
103
|
}, Ce = (e, t) => {
|
|
@@ -105,12 +105,12 @@ const R = (e) => {
|
|
|
105
105
|
if (n !== 0) return n;
|
|
106
106
|
const r = Q(e.name) - Q(t.name);
|
|
107
107
|
if (r !== 0) return r;
|
|
108
|
-
const o =
|
|
109
|
-
return o !== 0 ? o :
|
|
110
|
-
},
|
|
108
|
+
const o = D.compare(e.name, t.name);
|
|
109
|
+
return o !== 0 ? o : D.compare(e.path, t.path);
|
|
110
|
+
}, Lt = (e) => {
|
|
111
111
|
let t = null;
|
|
112
112
|
for (const n of e)
|
|
113
|
-
|
|
113
|
+
B(n) && (t === null || Ce(n, t) < 0) && (t = n);
|
|
114
114
|
return t === null ? null : t.path;
|
|
115
115
|
}, ee = Object.freeze({
|
|
116
116
|
sortMode: "native",
|
|
@@ -126,18 +126,18 @@ const R = (e) => {
|
|
|
126
126
|
expandIcons: !0,
|
|
127
127
|
directoryIcons: !0,
|
|
128
128
|
fileIcons: !0
|
|
129
|
-
}),
|
|
129
|
+
}), Le = [!0, !1], Me = (e, t) => t ? e.settingOn : e.settingOff, S = (e, t) => ({ key: e, labelKey: t, values: Le, formatValue: Me, requiresItemSelection: !1 }), ze = Object.freeze({
|
|
130
130
|
native: (e) => e.sortNative,
|
|
131
131
|
asc: (e) => e.sortAscending,
|
|
132
132
|
desc: (e) => e.sortDescending,
|
|
133
133
|
oldest: (e) => e.sortOldest,
|
|
134
134
|
newest: (e) => e.sortNewest
|
|
135
|
-
}),
|
|
135
|
+
}), O = Object.freeze([
|
|
136
136
|
{
|
|
137
137
|
key: "sortMode",
|
|
138
138
|
labelKey: "settingSortMode",
|
|
139
139
|
values: ["native", "asc", "desc", "oldest", "newest"],
|
|
140
|
-
formatValue: (e, t) =>
|
|
140
|
+
formatValue: (e, t) => ze[t](e),
|
|
141
141
|
requiresItemSelection: !1
|
|
142
142
|
},
|
|
143
143
|
{
|
|
@@ -175,120 +175,120 @@ const R = (e) => {
|
|
|
175
175
|
formatValue: (e, t) => e.expandIconSizeValue(t),
|
|
176
176
|
requiresItemSelection: !1
|
|
177
177
|
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
]),
|
|
186
|
-
const t =
|
|
178
|
+
S("alwaysExpanded", "settingAlwaysExpanded"),
|
|
179
|
+
S("revealDocument", "settingRevealDocument"),
|
|
180
|
+
S("removeRootIndent", "settingRemoveRootIndent"),
|
|
181
|
+
S("lines", "settingTreeLines"),
|
|
182
|
+
S("expandIcons", "settingExpandIcons"),
|
|
183
|
+
S("directoryIcons", "settingDirectoryIcons"),
|
|
184
|
+
S("fileIcons", "settingFileIcons")
|
|
185
|
+
]), Mt = (e) => e ? O : O.filter((t) => !t.requiresItemSelection), me = (e) => {
|
|
186
|
+
const t = O.find((n) => n.key === e);
|
|
187
187
|
if (t === void 0) throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);
|
|
188
188
|
return t;
|
|
189
|
-
},
|
|
189
|
+
}, zt = (e, t) => {
|
|
190
190
|
const n = me(t).values, r = n[(n.indexOf(e[t]) + 1) % n.length];
|
|
191
191
|
return { ...e, [t]: r };
|
|
192
|
-
},
|
|
192
|
+
}, Ft = (e, t, n) => me(n).formatValue(e, t[n]), fe = 2, te = Object.freeze({}), K = (e, t) => Object.freeze(Object.fromEntries(O.filter((n) => t(n, e[n.key])).map((n) => [n.key, e[n.key]]))), ne = "directoriesFirst", Fe = (e) => {
|
|
193
193
|
if (!Object.hasOwn(e, ne)) return e;
|
|
194
194
|
const { [ne]: t, ...n } = e;
|
|
195
195
|
return Object.hasOwn(n, "folderPlacement") || typeof t != "boolean" ? n : { ...n, folderPlacement: t ? "first" : "mixed" };
|
|
196
|
-
},
|
|
196
|
+
}, Ut = (e) => {
|
|
197
197
|
if (e === null || typeof e != "object" || Array.isArray(e)) return te;
|
|
198
198
|
const t = e;
|
|
199
|
-
return t.version !== fe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? te : K(
|
|
200
|
-
},
|
|
199
|
+
return t.version !== fe || t.settings === null || typeof t.settings != "object" || Array.isArray(t.settings) ? te : K(Fe(t.settings), (n, r) => n.values.includes(r));
|
|
200
|
+
}, Vt = (e, t) => {
|
|
201
201
|
const n = K(t, (r, o) => o !== void 0 && o !== e[r.key]);
|
|
202
202
|
return Object.keys(n).length === 0 ? e : Object.freeze({ ...e, ...n });
|
|
203
|
-
},
|
|
203
|
+
}, Jt = (e, t, n, r) => K({ ...e, [t]: n }, (o, s) => s !== void 0 && !(o.key === t && s === r[t])), Bt = (e) => JSON.stringify({ version: fe, settings: e }), Ue = (e, t, n) => e === void 0 || t === void 0 ? e === t ? 0 : e === void 0 ? 1 : -1 : n * (e - t), Wt = (e) => {
|
|
204
204
|
const { sortMode: t, folderPlacement: n, readmePlacement: r } = e;
|
|
205
205
|
if (t === "native" && n === "mixed" && r === "mixed") return;
|
|
206
206
|
const o = (s, i) => {
|
|
207
|
-
const a =
|
|
208
|
-
return a !== 0 ? a :
|
|
207
|
+
const a = D.compare(s.name, i.name);
|
|
208
|
+
return a !== 0 ? a : D.compare(s.path, i.path);
|
|
209
209
|
};
|
|
210
210
|
return (s, i) => {
|
|
211
211
|
if (n !== "mixed" && s.type !== i.type) return s.type === "directory" == (n === "first") ? -1 : 1;
|
|
212
212
|
if (r !== "mixed") {
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
213
|
+
const c = B(s);
|
|
214
|
+
if (c !== B(i)) return c === (r === "first") ? -1 : 1;
|
|
215
215
|
}
|
|
216
216
|
if (t === "native") return 0;
|
|
217
217
|
if (t === "asc") return o(s, i);
|
|
218
218
|
if (t === "desc") return -o(s, i);
|
|
219
|
-
const a =
|
|
219
|
+
const a = Ue(s.modifiedAt, i.modifiedAt, t === "oldest" ? 1 : -1);
|
|
220
220
|
return a !== 0 ? a : o(s, i);
|
|
221
221
|
};
|
|
222
|
-
},
|
|
222
|
+
}, E = (1 + Math.sqrt(5)) / 2, Gt = 100 / E ** 3, Xt = 100 / E ** 4, ue = 100 / E ** 2, Ve = 13, Kt = 16, Ht = Object.freeze({ gripThickness: 5, gripLength: 34, barThickness: 2, barLength: 21 }), qt = Object.freeze([1, 2, 3, 5, 8, 13, 21, 34, 55]), Je = Object.freeze([89, 144, 233, 377]), Be = 44, Yt = Be, Zt = 24, Qt = 1 / E, en = 1 / E ** 3, tn = "40ch", We = (e) => {
|
|
223
223
|
if (!Number.isFinite(e) || e <= 0)
|
|
224
224
|
throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`);
|
|
225
|
-
}, Ge = (e) => (
|
|
225
|
+
}, Ge = (e) => (We(e), Ve * e), nn = (e) => Ge(e) * E ** 2, rn = 233, on = 50, Xe = 100 / E ** 3, sn = 100 - Xe, an = Je[0], h = (e, t) => {
|
|
226
226
|
if (!Number.isFinite(t) || t < 0)
|
|
227
227
|
throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`);
|
|
228
|
-
},
|
|
229
|
-
if (
|
|
228
|
+
}, Ke = ({ trackInlineSize: e, gap: t, minColumnInlineSize: n, logicalColumns: r }) => {
|
|
229
|
+
if (h("trackInlineSize", e), h("gap", t), !Number.isFinite(n) || n <= 0)
|
|
230
230
|
throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(n)}`);
|
|
231
231
|
if (!Number.isInteger(r) || r < 1)
|
|
232
232
|
throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(r)}`);
|
|
233
233
|
const o = Math.floor((e + t) / (n + t));
|
|
234
234
|
return Math.min(r, Math.max(1, o));
|
|
235
|
-
},
|
|
235
|
+
}, cn = (e, t) => {
|
|
236
236
|
const { trackInlineSize: n, gap: r, minColumnInlineSize: o, logicalColumns: s } = t;
|
|
237
237
|
if (!([n, r, o].every(Number.isFinite) && n > 0 && r >= 0 && o > 0)) return e;
|
|
238
|
-
const a =
|
|
238
|
+
const a = Ke(t);
|
|
239
239
|
if (e === null || a === e) return a;
|
|
240
|
-
const
|
|
241
|
-
if (a >
|
|
242
|
-
const
|
|
243
|
-
return n >=
|
|
240
|
+
const c = Math.min(s, Math.max(1, e));
|
|
241
|
+
if (a > c) {
|
|
242
|
+
const l = (c + 1) * o + c * r + r / E;
|
|
243
|
+
return n >= l ? a : c;
|
|
244
244
|
}
|
|
245
|
-
return n >=
|
|
246
|
-
},
|
|
245
|
+
return n >= c * o + (c - 1) * r ? c : a;
|
|
246
|
+
}, ln = (e, t) => {
|
|
247
247
|
if (!(Number.isInteger(e) && Number.isInteger(t)) || t < 1 || t > e)
|
|
248
248
|
throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);
|
|
249
249
|
return Array.from({ length: t }, (n, r) => [Math.floor(r * e / t), Math.floor((r + 1) * e / t)]);
|
|
250
|
-
},
|
|
251
|
-
if (
|
|
250
|
+
}, dn = (e, t, n) => {
|
|
251
|
+
if (h("surfaceInlineSize", e), h("handlePixels", n), !Number.isFinite(t) || t <= 0)
|
|
252
252
|
throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${String(t)}`);
|
|
253
253
|
return e >= 2 * t + n ? "beside" : "stacked";
|
|
254
|
-
},
|
|
255
|
-
const o = (
|
|
256
|
-
return
|
|
257
|
-
},
|
|
254
|
+
}, J = (e, t, n) => Math.max(t, Math.min(e, n)), re = (e, t, n, r) => {
|
|
255
|
+
const o = (J(e, 0, n) + J(t, 0, n)) / 2;
|
|
256
|
+
return J(o - r / 2, 0, n - r);
|
|
257
|
+
}, mn = (e, t, n) => {
|
|
258
258
|
for (const [r, o] of Object.entries(e))
|
|
259
259
|
if (!Number.isFinite(o)) throw new RangeError(`[markdown-explorer] anchor.${r} must be a finite number; got ${String(o)}`);
|
|
260
|
-
return
|
|
260
|
+
return h("marginBox.width", t.width), h("marginBox.height", t.height), h("viewport.width", n.width), h("viewport.height", n.height), {
|
|
261
261
|
left: re(e.left, e.right, n.width, t.width),
|
|
262
262
|
top: re(e.top, e.bottom, n.height, t.height)
|
|
263
263
|
};
|
|
264
|
-
},
|
|
265
|
-
if (typeof e != "string" || !
|
|
264
|
+
}, He = 31536e3, qe = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, Ye = (e) => {
|
|
265
|
+
if (typeof e != "string" || !qe.test(e))
|
|
266
266
|
throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`);
|
|
267
|
-
}, oe = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= ue,
|
|
267
|
+
}, oe = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 && e <= ue, Ze = (e, t) => {
|
|
268
268
|
if (e === null || typeof e != "object" || Array.isArray(e)) return {};
|
|
269
269
|
const n = e, { treeExplorer: r, multiExplorer: o, style: s, align: i } = n;
|
|
270
270
|
return {
|
|
271
271
|
...oe(r) ? { treeExplorer: r } : {},
|
|
272
272
|
...oe(o) ? { multiExplorer: o } : {},
|
|
273
273
|
...typeof s == "string" && t.includes(s) ? { style: s } : {},
|
|
274
|
-
...typeof i == "string" &&
|
|
274
|
+
...typeof i == "string" && $.includes(i) ? { align: i } : {}
|
|
275
275
|
};
|
|
276
|
-
},
|
|
276
|
+
}, fn = (e, t) => {
|
|
277
277
|
if (e !== null)
|
|
278
278
|
for (const n of e.split(";")) {
|
|
279
279
|
const r = n.indexOf("=");
|
|
280
280
|
if (!(r < 0) && n.slice(0, r).trim() === t)
|
|
281
281
|
return n.slice(r + 1).trim();
|
|
282
282
|
}
|
|
283
|
-
},
|
|
283
|
+
}, un = (e, t) => {
|
|
284
284
|
if (e === void 0 || e === "") return {};
|
|
285
285
|
try {
|
|
286
|
-
return
|
|
286
|
+
return Ze(JSON.parse(decodeURIComponent(e)), t);
|
|
287
287
|
} catch {
|
|
288
288
|
return {};
|
|
289
289
|
}
|
|
290
|
-
},
|
|
291
|
-
const t = (n) => Math.min(
|
|
290
|
+
}, j = 100, Qe = Math.floor(ue * j) / j, et = (e) => {
|
|
291
|
+
const t = (n) => Math.min(Qe, Math.max(1, Math.round(n * j)) / j);
|
|
292
292
|
return encodeURIComponent(
|
|
293
293
|
JSON.stringify({
|
|
294
294
|
...e.treeExplorer === void 0 ? {} : { treeExplorer: t(e.treeExplorer) },
|
|
@@ -297,11 +297,11 @@ const R = (e) => {
|
|
|
297
297
|
...e.align === void 0 ? {} : { align: e.align }
|
|
298
298
|
})
|
|
299
299
|
);
|
|
300
|
-
},
|
|
300
|
+
}, gn = (e, t, n) => `${e}=${et(t)}; Path=/; Max-Age=${String(He)}; SameSite=Lax${n ? "; Secure" : ""}`, se = Object.freeze({ tree: "tree", multi: "multi", single: "single" }), tt = Object.freeze({ default: 12, min: 1, max: 64 }), nt = Object.freeze({ default: 4, min: 1, max: 6 }), rt = Object.freeze({ default: 500, min: 1, max: 1e4 }), ot = Object.freeze({ default: 16, min: 1, max: 64 }), st = Object.freeze({ default: 16, min: 1, max: 64 }), it = Object.freeze({ default: 2 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), at = Object.freeze({ default: 8 * 1024 * 1024, min: 1, max: 256 * 1024 * 1024 }), ct = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u, lt = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u, dt = /^[a-z0-9][a-z0-9-]*$/u, mt = /^(?=.{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, ie = (e, t) => {
|
|
301
301
|
if (typeof t != "string") throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);
|
|
302
|
-
if (!
|
|
302
|
+
if (!ct.test(t) || t.split("/").some((n) => n === "." || n === ".."))
|
|
303
303
|
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)}`);
|
|
304
|
-
},
|
|
304
|
+
}, 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" ? I(e) ? "a plain object" : `a non-plain object (${Object.prototype.toString.call(e)})` : String(e), ae = Object.freeze(
|
|
305
305
|
Object.keys({
|
|
306
306
|
basePath: !0,
|
|
307
307
|
dataPath: !0,
|
|
@@ -311,6 +311,7 @@ const R = (e) => {
|
|
|
311
311
|
expandAll: !0,
|
|
312
312
|
revealDocument: !0,
|
|
313
313
|
documentStyles: !0,
|
|
314
|
+
defaultDocumentStyle: !0,
|
|
314
315
|
iframeHosts: !0,
|
|
315
316
|
embeds: !0,
|
|
316
317
|
defaultTreeSettings: !0,
|
|
@@ -319,85 +320,91 @@ const R = (e) => {
|
|
|
319
320
|
})
|
|
320
321
|
), x = (e, t, n) => {
|
|
321
322
|
if (t === void 0) return [];
|
|
322
|
-
if (!
|
|
323
|
+
if (!I(t)) throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);
|
|
323
324
|
const r = Object.entries(t);
|
|
324
325
|
for (const [o] of r)
|
|
325
326
|
if (!n.includes(o)) throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${n.join(", ")}`);
|
|
326
327
|
return r.filter(([, o]) => o !== void 0);
|
|
327
|
-
},
|
|
328
|
+
}, ft = (e) => {
|
|
328
329
|
const t = { ...se };
|
|
329
330
|
for (const [n, r] of x("views", e, Object.keys(se))) t[n] = r;
|
|
330
331
|
for (const [n, r] of Object.entries(t))
|
|
331
|
-
if (typeof r != "string" || !
|
|
332
|
+
if (typeof r != "string" || !lt.test(r))
|
|
332
333
|
throw new RangeError(`[markdown-explorer] views.${n} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(r)}`);
|
|
333
334
|
return Object.freeze(t);
|
|
334
|
-
},
|
|
335
|
+
}, y = (e, t, n) => {
|
|
335
336
|
if (t === void 0) return n.default;
|
|
336
337
|
if (typeof t != "number" || !Number.isInteger(t) || t < n.min || t > n.max)
|
|
337
|
-
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${
|
|
338
|
+
throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(n.min)}..${String(n.max)}; got ${d(t)}`);
|
|
338
339
|
return t;
|
|
339
|
-
},
|
|
340
|
+
}, ut = (e, t) => {
|
|
340
341
|
const n = new Map(x("embeds", e, ["providers", "linkCards", "linkCardSize"]));
|
|
341
|
-
if (n.size === 0) return
|
|
342
|
+
if (n.size === 0) return xe;
|
|
342
343
|
const r = n.has("providers") ? n.get("providers") : [];
|
|
343
|
-
if (!Array.isArray(r)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${
|
|
344
|
+
if (!Array.isArray(r)) throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(r)}`);
|
|
344
345
|
for (const a of r)
|
|
345
|
-
if (!be(a)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Oe.join(", ")}; got ${
|
|
346
|
+
if (!be(a)) throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${Oe.join(", ")}; got ${d(a)}`);
|
|
346
347
|
const o = n.has("linkCards") ? n.get("linkCards") : !1;
|
|
347
|
-
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${
|
|
348
|
+
if (typeof o != "boolean") throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${d(o)}`);
|
|
348
349
|
const s = { providers: Object.freeze([...new Set(r)]), linkCardEndpoint: o ? Ie(t) : null };
|
|
349
350
|
if (!n.has("linkCardSize")) return Object.freeze(s);
|
|
350
351
|
const i = n.get("linkCardSize");
|
|
351
|
-
if (!ke(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Te.join(", ")}; got ${
|
|
352
|
-
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${
|
|
352
|
+
if (!ke(i)) throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${Te.join(", ")}; got ${d(i)}`);
|
|
353
|
+
if (!o) throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${d(i)} with linkCards ${d(o)}`);
|
|
353
354
|
return Object.freeze({ ...s, linkCardSize: i });
|
|
354
|
-
},
|
|
355
|
+
}, gt = (e) => {
|
|
355
356
|
if (e === void 0) return null;
|
|
356
|
-
if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${
|
|
357
|
+
if (typeof e != "string") throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${d(e)}`);
|
|
357
358
|
return de(e);
|
|
358
|
-
},
|
|
359
|
+
}, wt = (e) => {
|
|
359
360
|
const t = new Map(
|
|
360
361
|
x(
|
|
361
362
|
"defaultTreeSettings",
|
|
362
363
|
e,
|
|
363
|
-
|
|
364
|
+
O.map((r) => r.key)
|
|
364
365
|
)
|
|
365
366
|
);
|
|
366
367
|
if (t.size === 0) return ee;
|
|
367
368
|
const n = { ...ee };
|
|
368
|
-
for (const r of
|
|
369
|
+
for (const r of O) {
|
|
369
370
|
if (!t.has(r.key)) continue;
|
|
370
371
|
const o = t.get(r.key), s = r.values;
|
|
371
|
-
if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${s.map(
|
|
372
|
+
if (!s.includes(o)) throw new RangeError(`[markdown-explorer] defaultTreeSettings.${r.key} must be one of ${s.map(d).join(", ")}; got ${d(o)}`);
|
|
372
373
|
n[r.key] = o;
|
|
373
374
|
}
|
|
374
375
|
return Object.freeze(n);
|
|
375
|
-
},
|
|
376
|
+
}, ht = (e) => {
|
|
376
377
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the explorer configuration must be an object");
|
|
377
|
-
for (const
|
|
378
|
-
if (!ae.includes(
|
|
378
|
+
for (const l of Object.keys(e))
|
|
379
|
+
if (!ae.includes(l)) throw new RangeError(`[markdown-explorer] ${l} is not an option of the explorer configuration; expected ${ae.join(", ")}`);
|
|
379
380
|
ie("basePath", e.basePath), ie("dataPath", e.dataPath);
|
|
380
|
-
const t =
|
|
381
|
+
const t = ft(e.views);
|
|
381
382
|
if ((/* @__PURE__ */ new Set([t.tree, t.multi, t.single])).size !== 3)
|
|
382
383
|
throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);
|
|
383
384
|
if (e.dataPath === e.basePath) throw new RangeError("[markdown-explorer] dataPath must differ from basePath");
|
|
384
385
|
if (e.dataPath.startsWith(`${e.basePath}/`)) {
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
386
|
+
const l = e.dataPath.slice(e.basePath.length + 1).split("/")[0];
|
|
387
|
+
if (l === t.tree || l === t.multi || l === t.single)
|
|
387
388
|
throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`);
|
|
388
389
|
}
|
|
389
|
-
|
|
390
|
+
Ye(e.settingsCookie);
|
|
390
391
|
const n = e.iframeHosts ?? [];
|
|
391
|
-
if (!Array.isArray(n) || n.some((
|
|
392
|
+
if (!Array.isArray(n) || n.some((l) => typeof l != "string" || !mt.test(l)))
|
|
392
393
|
throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(n)}`);
|
|
393
394
|
const r = Object.fromEntries(x("multiView", e.multiView, ["maxPanels", "columns"])), o = Object.fromEntries(x("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), s = Object.fromEntries(x("revealDocument", e.revealDocument, ["maxDepth"])), i = Object.fromEntries(x("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), a = e.documentStyles ?? Re;
|
|
394
395
|
if (!Array.isArray(a) || a.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
395
|
-
const
|
|
396
|
-
for (const
|
|
397
|
-
if (
|
|
396
|
+
const c = /* @__PURE__ */ new Set();
|
|
397
|
+
for (const l of a) {
|
|
398
|
+
if (l === null || typeof l != "object" || typeof l.name != "string" || l.name.trim() === "" || typeof l.className != "string")
|
|
398
399
|
throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");
|
|
399
|
-
if (
|
|
400
|
-
|
|
400
|
+
if (c.has(l.name)) throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(l.name)} repeats`);
|
|
401
|
+
c.add(l.name);
|
|
402
|
+
}
|
|
403
|
+
const f = e.defaultDocumentStyle === void 0 ? _e : e.defaultDocumentStyle;
|
|
404
|
+
if (typeof f != "string") throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${d(f)}`);
|
|
405
|
+
if (!c.has(f)) {
|
|
406
|
+
const l = e.defaultDocumentStyle === void 0 ? " (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)" : "";
|
|
407
|
+
throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...c].map((k) => JSON.stringify(k)).join(", ")}); got ${JSON.stringify(f)}${l}`);
|
|
401
408
|
}
|
|
402
409
|
return Object.freeze({
|
|
403
410
|
basePath: e.basePath,
|
|
@@ -405,70 +412,71 @@ const R = (e) => {
|
|
|
405
412
|
settingsCookie: e.settingsCookie,
|
|
406
413
|
views: t,
|
|
407
414
|
multiView: Object.freeze({
|
|
408
|
-
maxPanels:
|
|
409
|
-
columns:
|
|
415
|
+
maxPanels: y("multiView.maxPanels", r.maxPanels, tt),
|
|
416
|
+
columns: y("multiView.columns", r.columns, nt)
|
|
410
417
|
}),
|
|
411
418
|
expandAll: Object.freeze({
|
|
412
|
-
maxFolders:
|
|
413
|
-
maxDepth:
|
|
419
|
+
maxFolders: y("expandAll.maxFolders", o.maxFolders, rt),
|
|
420
|
+
maxDepth: y("expandAll.maxDepth", o.maxDepth, ot)
|
|
414
421
|
}),
|
|
415
|
-
revealDocument: Object.freeze({ maxDepth:
|
|
416
|
-
documentStyles: Object.freeze(a.map((
|
|
422
|
+
revealDocument: Object.freeze({ maxDepth: y("revealDocument.maxDepth", s.maxDepth, st) }),
|
|
423
|
+
documentStyles: Object.freeze(a.map((l) => Object.freeze({ name: l.name, className: l.className }))),
|
|
424
|
+
defaultDocumentStyle: f,
|
|
417
425
|
iframeHosts: Object.freeze([...new Set(n)]),
|
|
418
|
-
embeds:
|
|
419
|
-
defaultTreeSettings:
|
|
420
|
-
legacyTextEncoding:
|
|
426
|
+
embeds: ut(e.embeds, e.dataPath),
|
|
427
|
+
defaultTreeSettings: wt(e.defaultTreeSettings),
|
|
428
|
+
legacyTextEncoding: gt(e.legacyTextEncoding),
|
|
421
429
|
spreadsheets: Object.freeze({
|
|
422
|
-
maxBytes:
|
|
423
|
-
maxWorkbookBytes:
|
|
430
|
+
maxBytes: y("spreadsheets.maxBytes", i.maxBytes, it),
|
|
431
|
+
maxWorkbookBytes: y("spreadsheets.maxWorkbookBytes", i.maxWorkbookBytes, at)
|
|
424
432
|
})
|
|
425
433
|
});
|
|
426
|
-
},
|
|
434
|
+
}, wn = (e) => {
|
|
427
435
|
const t = e.embeds;
|
|
428
|
-
if (!
|
|
436
|
+
if (!I(t)) throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${d(t)}`);
|
|
429
437
|
if (Object.hasOwn(t, "linkCards"))
|
|
430
|
-
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 ${
|
|
438
|
+
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)})`);
|
|
431
439
|
const n = e.legacyTextEncoding;
|
|
432
440
|
if (n !== null && typeof n != "string")
|
|
433
|
-
throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${
|
|
434
|
-
const { linkCardEndpoint: r, ...o } = t, s =
|
|
441
|
+
throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${d(n)}`);
|
|
442
|
+
const { linkCardEndpoint: r, ...o } = t, s = ht({ ...e, embeds: { ...o, linkCards: r !== null }, legacyTextEncoding: n === null ? void 0 : n });
|
|
435
443
|
if (s.embeds.linkCardEndpoint !== r)
|
|
436
|
-
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${
|
|
444
|
+
throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${d(s.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${d(r)}`);
|
|
437
445
|
if (s.legacyTextEncoding !== n)
|
|
438
|
-
throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${
|
|
446
|
+
throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${d(s.legacyTextEncoding)} (the written name of the encoding it names); got ${d(n)}`);
|
|
439
447
|
const i = e;
|
|
440
|
-
for (const [a,
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
throw
|
|
448
|
+
for (const [a, c] of Object.entries(s)) {
|
|
449
|
+
const f = W(i[a], c, a);
|
|
450
|
+
if (f !== null)
|
|
451
|
+
throw f.kind === "extra" ? new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${d(f.given)} there`) : new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${d(f.given)} where it resolves ${d(f.resolved)}`);
|
|
444
452
|
}
|
|
445
453
|
return s;
|
|
446
|
-
},
|
|
454
|
+
}, W = (e, t, n) => {
|
|
447
455
|
if (Object.is(e, t)) return null;
|
|
448
456
|
if (Array.isArray(t)) {
|
|
449
457
|
if (!Array.isArray(e)) return { kind: "value", path: n, given: e, resolved: t };
|
|
450
458
|
if (e.length !== t.length) return { kind: "value", path: `${n}.length`, given: e.length, resolved: t.length };
|
|
451
459
|
for (const [o, s] of t.entries()) {
|
|
452
|
-
const i =
|
|
460
|
+
const i = W(e[o], s, `${n}[${String(o)}]`);
|
|
453
461
|
if (i !== null) return i;
|
|
454
462
|
}
|
|
455
463
|
return null;
|
|
456
464
|
}
|
|
457
|
-
if (!(
|
|
465
|
+
if (!(I(t) && I(e))) return { kind: "value", path: n, given: e, resolved: t };
|
|
458
466
|
for (const o of Object.keys(t)) {
|
|
459
|
-
const s =
|
|
467
|
+
const s = W(Object.hasOwn(e, o) ? e[o] : void 0, t[o], `${n}.${o}`);
|
|
460
468
|
if (s !== null) return s;
|
|
461
469
|
}
|
|
462
470
|
const r = Object.keys(e).find((o) => !Object.hasOwn(t, o));
|
|
463
471
|
return r === void 0 ? null : { kind: "extra", path: `${n}.${r}`, given: e[r] };
|
|
464
|
-
},
|
|
465
|
-
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${
|
|
466
|
-
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${
|
|
472
|
+
}, Et = (e) => typeof e == "string" && dt.test(e), hn = (e, t) => {
|
|
473
|
+
if (e === null || typeof e != "object") throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);
|
|
474
|
+
if (!Array.isArray(t) || t.length === 0) throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);
|
|
467
475
|
for (const n of t)
|
|
468
|
-
if (!
|
|
476
|
+
if (!Et(n)) throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(n)}`);
|
|
469
477
|
if (new Set(t).size !== t.length) throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);
|
|
470
478
|
return Object.freeze({ ...e, sourceIds: Object.freeze([...t]) });
|
|
471
|
-
},
|
|
479
|
+
}, En = (e) => e.documentStyles.map((t) => t.name), m = Object.freeze({
|
|
472
480
|
source: "source",
|
|
473
481
|
doc: "doc",
|
|
474
482
|
maximized: "maximized",
|
|
@@ -481,35 +489,35 @@ const R = (e) => {
|
|
|
481
489
|
width: "width",
|
|
482
490
|
maxWidth: "maxWidth",
|
|
483
491
|
markup: "markup"
|
|
484
|
-
}), ge = "true",
|
|
492
|
+
}), ge = "true", C = "/", ce = ".data", we = 256, he = /^\d+(?:\.\d+)?$/u, G = /^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u, Ee = Object.freeze(["showToc", "showStyle", "showAlign"]), le = (e) => {
|
|
485
493
|
const t = encodeURIComponent(e.replaceAll("%", "%25"));
|
|
486
494
|
return t.endsWith(ce) ? `${t.slice(0, -ce.length)}%2Edata` : t;
|
|
487
|
-
},
|
|
495
|
+
}, pt = (e) => e.replaceAll("%25", "%"), pe = (e) => {
|
|
488
496
|
const { sourceIds: t } = e;
|
|
489
497
|
if (t === void 0) throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");
|
|
490
498
|
return t;
|
|
491
|
-
},
|
|
492
|
-
const r = n.getAll(
|
|
499
|
+
}, St = (e, t, n) => {
|
|
500
|
+
const r = n.getAll(m.source);
|
|
493
501
|
if (r.length === 0) return t;
|
|
494
502
|
const [o] = r;
|
|
495
503
|
return r.length > 1 || o === void 0 || o === t || !e.includes(o) ? null : o;
|
|
496
|
-
},
|
|
497
|
-
const n = t.get(
|
|
504
|
+
}, yt = (e, t) => {
|
|
505
|
+
const n = t.get(m.style), r = t.get(m.align);
|
|
498
506
|
return {
|
|
499
507
|
...n !== null && e.documentStyles.some((o) => o.name === n) ? { style: n } : {},
|
|
500
|
-
...r !== null &&
|
|
508
|
+
...r !== null && $.includes(r) ? { align: r } : {}
|
|
501
509
|
};
|
|
502
510
|
}, Se = (e) => Number.isFinite(e) && e >= 0 && e <= we && he.test(String(e)), xt = (e) => {
|
|
503
|
-
const t = e.get(
|
|
511
|
+
const t = e.get(m.padding), n = t !== null && he.test(t) ? Number(t) : Number.NaN, r = e.get(m.width), o = e.get(m.maxWidth);
|
|
504
512
|
return {
|
|
505
|
-
...e.get(
|
|
506
|
-
...e.get(
|
|
507
|
-
...e.get(
|
|
513
|
+
...e.get(m.showToc) === "false" ? { showToc: !1 } : {},
|
|
514
|
+
...e.get(m.showStyle) === "false" ? { showStyle: !1 } : {},
|
|
515
|
+
...e.get(m.showAlign) === "false" ? { showAlign: !1 } : {},
|
|
508
516
|
...Se(n) ? { padding: n } : {},
|
|
509
|
-
...r !== null &&
|
|
510
|
-
...o !== null &&
|
|
517
|
+
...r !== null && G.test(r) ? { width: r } : {},
|
|
518
|
+
...o !== null && G.test(o) ? { maxWidth: o } : {}
|
|
511
519
|
};
|
|
512
|
-
},
|
|
520
|
+
}, bt = (e, t) => [...new Set(t.filter(P))].slice(0, e.multiView.maxPanels), Ot = (e, t, n, r) => {
|
|
513
521
|
for (const s of t) H(s);
|
|
514
522
|
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`);
|
|
515
523
|
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)}`);
|
|
@@ -518,138 +526,138 @@ const R = (e) => {
|
|
|
518
526
|
const o = r.find((s) => !t.includes(s));
|
|
519
527
|
if (o !== void 0) throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${JSON.stringify(o.slice(0, 80))}`);
|
|
520
528
|
}, H = (e) => {
|
|
521
|
-
if (!
|
|
529
|
+
if (!P(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0, 80))}`);
|
|
522
530
|
return e;
|
|
523
|
-
},
|
|
524
|
-
if (H(e).endsWith(
|
|
531
|
+
}, kt = (e) => {
|
|
532
|
+
if (H(e).endsWith(C)) throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${JSON.stringify(e.slice(0, 80))}`);
|
|
525
533
|
return e;
|
|
526
|
-
},
|
|
534
|
+
}, Tt = (e, t) => {
|
|
527
535
|
if (t.style !== void 0 && !e.documentStyles.some((n) => n.name === t.style))
|
|
528
536
|
throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map((n) => JSON.stringify(n.name)).join(", ")}); got ${JSON.stringify(t.style)}`);
|
|
529
|
-
if (t.align !== void 0 &&
|
|
530
|
-
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${
|
|
531
|
-
},
|
|
537
|
+
if (t.align !== void 0 && !$.includes(t.align))
|
|
538
|
+
throw new RangeError(`[markdown-explorer] overrides.align must be one of ${$.join(", ")}; got ${JSON.stringify(t.align)}`);
|
|
539
|
+
}, Rt = (e) => {
|
|
532
540
|
for (const t of Ee)
|
|
533
541
|
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])}`);
|
|
534
542
|
if (e.padding !== void 0 && !Se(e.padding)) throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(we)} px in plain decimal digits; got ${String(e.padding)}`);
|
|
535
543
|
for (const t of ["width", "maxWidth"]) {
|
|
536
544
|
const n = e[t];
|
|
537
|
-
if (n !== void 0 && !
|
|
545
|
+
if (n !== void 0 && !G.test(n)) throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(n)}`);
|
|
538
546
|
}
|
|
539
|
-
},
|
|
547
|
+
}, _t = (e, t) => {
|
|
540
548
|
const n = new URLSearchParams();
|
|
541
549
|
let r = `${e.basePath}/${e.views[t.view]}`;
|
|
542
550
|
if (t.view === "multi") {
|
|
543
551
|
const s = t.docs ?? [], i = t.maximized ?? null, a = t.markup ?? [];
|
|
544
|
-
|
|
545
|
-
for (const
|
|
546
|
-
i !== null && n.set(
|
|
547
|
-
for (const
|
|
552
|
+
Ot(e, s, i, a);
|
|
553
|
+
for (const c of s) n.append(m.doc, c);
|
|
554
|
+
i !== null && n.set(m.maximized, i);
|
|
555
|
+
for (const c of s) a.includes(c) && n.append(m.markup, c);
|
|
548
556
|
} else {
|
|
549
557
|
const s = t.doc ?? null, i = t.view === "tree" ? t.folder ?? null : null;
|
|
550
558
|
if (s !== null && i !== null) throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");
|
|
551
|
-
s !== null && (r += `/${le(
|
|
559
|
+
s !== null && (r += `/${le(kt(s))}`), i !== null && (r += `/${le(`${H(i)}${C}`)}`);
|
|
552
560
|
}
|
|
553
561
|
if (t.source !== void 0) {
|
|
554
562
|
const s = pe(e);
|
|
555
563
|
if (!s.includes(t.source)) throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${s.join(", ")}`);
|
|
556
|
-
t.source !== s[0] && n.set(
|
|
564
|
+
t.source !== s[0] && n.set(m.source, t.source);
|
|
557
565
|
}
|
|
558
|
-
if (t.view !== "multi" && t.overrides !== void 0 && (
|
|
566
|
+
if (t.view !== "multi" && t.overrides !== void 0 && (Tt(e, t.overrides), t.overrides.style !== void 0 && n.set(m.style, t.overrides.style), t.overrides.align !== void 0 && n.set(m.align, t.overrides.align)), t.view !== "multi" && t.markup === !0) {
|
|
559
567
|
if (!(t.doc !== void 0 && t.doc !== null || t.view === "tree" && t.folder !== void 0 && t.folder !== null)) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");
|
|
560
|
-
n.set(
|
|
568
|
+
n.set(m.markup, ge);
|
|
561
569
|
}
|
|
562
570
|
if (t.view === "single" && t.embed !== void 0) {
|
|
563
571
|
const { embed: s } = t;
|
|
564
|
-
|
|
565
|
-
for (const i of Ee) s[i] === !1 && n.set(
|
|
566
|
-
s.padding !== void 0 && n.set(
|
|
572
|
+
Rt(s);
|
|
573
|
+
for (const i of Ee) s[i] === !1 && n.set(m[i], "false");
|
|
574
|
+
s.padding !== void 0 && n.set(m.padding, String(s.padding)), s.width !== void 0 && n.set(m.width, s.width), s.maxWidth !== void 0 && n.set(m.maxWidth, s.maxWidth);
|
|
567
575
|
}
|
|
568
576
|
const o = n.toString();
|
|
569
577
|
return o === "" ? r : `${r}?${o}`;
|
|
570
|
-
}, It = (e, t) => Object.keys(e.views).find((n) => e.views[n] === t),
|
|
578
|
+
}, It = (e, t) => Object.keys(e.views).find((n) => e.views[n] === t), pn = (e, t, n) => {
|
|
571
579
|
const r = pe(e), [o] = r;
|
|
572
580
|
if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
|
|
573
|
-
const s =
|
|
574
|
-
if (t === void 0 || t === "") return
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
return
|
|
581
|
+
const s = St(r, o, n), i = s === null ? o : s, a = (u) => ({ kind: "redirect", href: _t(e, u), location: u }), c = () => a({ view: "tree", source: i, doc: null, folder: null, overrides: {}, markup: !1 });
|
|
582
|
+
if (t === void 0 || t === "") return c();
|
|
583
|
+
const f = t.indexOf("/"), l = f < 0 ? t : t.slice(0, f), k = f < 0 ? null : t.slice(f + 1), p = It(e, l);
|
|
584
|
+
if (p === void 0) return c();
|
|
585
|
+
if (p === "multi") {
|
|
586
|
+
const u = n.getAll(m.doc), b = bt(e, u), M = n.getAll(m.maximized), [z] = M, F = M.length === 1 && z !== void 0 && b.includes(z) ? z : null, U = n.getAll(m.markup), A = b.filter((_) => U.includes(_)), ye = A.length === U.length && A.every((_, V) => _ === U[V]);
|
|
587
|
+
return k === null && s !== null && b.length === u.length && b.every((_, V) => _ === u[V]) && (M.length === 0 || F !== null) && ye ? { kind: "location", location: { view: "multi", source: i, docs: b, maximized: F, markup: A } } : a({ view: "multi", source: i, docs: b, maximized: F, markup: A });
|
|
580
588
|
}
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
if (
|
|
586
|
-
if (
|
|
587
|
-
const
|
|
588
|
-
return s === null ? a({ view:
|
|
589
|
+
const N = k === null ? null : pt(k), g = N?.endsWith(C) === !0 ? N.slice(0, -C.length) : null, w = N !== null && g === null ? N : null;
|
|
590
|
+
if (w !== null && !P(w) || g !== null && !P(g)) return c();
|
|
591
|
+
const T = yt(e, n), R = (w !== null || g !== null) && n.get(m.markup) === ge;
|
|
592
|
+
if (p === "single") {
|
|
593
|
+
if (g !== null) return a({ view: "tree", source: i, doc: null, folder: g, overrides: T, markup: R });
|
|
594
|
+
if (w === null) return c();
|
|
595
|
+
const u = xt(n);
|
|
596
|
+
return s === null ? a({ view: p, source: i, doc: w, overrides: T, embed: u, markup: R }) : { kind: "location", location: { view: p, source: i, doc: w, overrides: T, embed: u, markup: R } };
|
|
589
597
|
}
|
|
590
|
-
return s === null ? a({ view:
|
|
598
|
+
return s === null ? a({ view: p, source: i, doc: w, folder: g, overrides: T, markup: R }) : { kind: "location", location: { view: p, source: i, doc: w, folder: g, overrides: T, markup: R } };
|
|
591
599
|
};
|
|
592
600
|
export {
|
|
593
|
-
|
|
601
|
+
ot as $,
|
|
594
602
|
ue as A,
|
|
595
603
|
Gt as B,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
604
|
+
Yt as C,
|
|
605
|
+
Xt as D,
|
|
606
|
+
sn as E,
|
|
607
|
+
Zt as F,
|
|
608
|
+
Kt as G,
|
|
609
|
+
on as H,
|
|
610
|
+
mn as I,
|
|
611
|
+
Lt as J,
|
|
612
|
+
an as K,
|
|
613
|
+
qt as L,
|
|
614
|
+
E as M,
|
|
615
|
+
D as N,
|
|
616
|
+
vt as O,
|
|
617
|
+
Qt as P,
|
|
618
|
+
Jt as Q,
|
|
619
|
+
zt as R,
|
|
620
|
+
rn as S,
|
|
621
|
+
Vt as T,
|
|
614
622
|
Bt as U,
|
|
615
623
|
te as V,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
624
|
+
Ut as W,
|
|
625
|
+
gn as X,
|
|
626
|
+
tn as Y,
|
|
619
627
|
ee as Z,
|
|
620
628
|
se as _,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
629
|
+
Xe as a,
|
|
630
|
+
rt as a0,
|
|
631
|
+
Ve as a1,
|
|
632
|
+
nt as a2,
|
|
633
|
+
tt as a3,
|
|
634
|
+
st as a4,
|
|
635
|
+
it as a5,
|
|
636
|
+
at as a6,
|
|
637
|
+
ht as a7,
|
|
638
|
+
Ht as b,
|
|
639
|
+
bt as c,
|
|
640
|
+
dn as d,
|
|
641
|
+
_t as e,
|
|
634
642
|
Ct as f,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
643
|
+
En as g,
|
|
644
|
+
pn as h,
|
|
645
|
+
Et as i,
|
|
646
|
+
fn as j,
|
|
647
|
+
I as k,
|
|
640
648
|
de as l,
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
649
|
+
Dt as m,
|
|
650
|
+
ln as n,
|
|
651
|
+
cn as o,
|
|
652
|
+
un as p,
|
|
653
|
+
en as q,
|
|
654
|
+
wn as r,
|
|
647
655
|
Be as s,
|
|
648
656
|
jt as t,
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
657
|
+
Wt as u,
|
|
658
|
+
Ft as v,
|
|
659
|
+
hn as w,
|
|
660
|
+
Mt as x,
|
|
661
|
+
nn as y,
|
|
654
662
|
Ge as z
|
|
655
663
|
};
|