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