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