@aiquants/markdown-explorer 0.36.0 → 0.37.1
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 +112 -0
- package/README.md +77 -11
- package/dist/{EditSurface-BCFJRyIM.js → EditSurface-BvwgM4lC.js} +250 -245
- package/dist/EditSurface-Ce4bpuvh.cjs +6 -0
- package/dist/ExplorerSplit-DBUFhlo_.cjs +2 -0
- package/dist/ExplorerSplit-DKpqQBsQ.js +1619 -0
- package/dist/{MultiLayout-Bo9LAXiY.cjs → MultiLayout-BfGxy2pf.cjs} +1 -1
- package/dist/{MultiLayout-Dy5TIC2t.js → MultiLayout-CVj5iam0.js} +22 -22
- package/dist/{NativeScrollBar-Bj-LKej0.cjs → NativeScrollBar-BQpaWt45.cjs} +1 -1
- package/dist/{NativeScrollBar-DpZMYhmf.js → NativeScrollBar-BkZPkphH.js} +2 -2
- package/dist/{TreeLayout-DsSKW_Qj.js → TreeLayout-B83wJ2CL.js} +2 -2
- package/dist/{TreeLayout-T8sc_wg7.cjs → TreeLayout-Df4HLMP-.cjs} +1 -1
- package/dist/client/MarkdownExplorer.d.cts +4 -5
- package/dist/client/MarkdownExplorer.d.ts +4 -5
- package/dist/client/hostContract.d.cts +1 -8
- package/dist/client/hostContract.d.ts +1 -8
- package/dist/core/labels.d.cts +0 -9
- package/dist/core/labels.d.ts +0 -9
- package/dist/explorerCore-DivWkFQF.cjs +1 -0
- package/dist/{explorerCore-B3RGmMG6.js → explorerCore-EkU0mwdW.js} +310 -308
- package/dist/index-Bz-n0dl1.cjs +18 -0
- package/dist/{index-D0l_BJqb.js → index-CVnGqEmh.js} +2447 -2430
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -55
- package/dist/{merge-BwcqBd4c.js → merge-BGr72noP.js} +1 -1
- package/dist/{merge-Dckw7r9T.cjs → merge-hFiGx_ND.cjs} +1 -1
- package/dist/server/anonymous.d.cts +2 -2
- package/dist/server/anonymous.d.ts +2 -2
- package/dist/server/ports.d.cts +5 -2
- package/dist/server/ports.d.ts +5 -2
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +12 -12
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-smKLgRa2.js → tapScrollCircle-BTCGTQ8T.js} +1 -1
- package/dist/{tapScrollCircle-DyLInGck.cjs → tapScrollCircle-DDwYa54Q.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +8 -1
- package/docs/behavior/hosting.md +1 -1
- package/docs/behavior/localization.md +2 -2
- package/docs/behavior/security.md +2 -2
- package/docs/behavior/url-contract.md +2 -2
- package/package.json +6 -4
- package/dist/EditSurface-B70iRFkG.cjs +0 -6
- package/dist/ExplorerSplit-BNrHrIus.cjs +0 -2
- package/dist/ExplorerSplit-Bgccz2nm.js +0 -1589
- package/dist/explorerCore-CUkyKtm8.cjs +0 -1
- package/dist/index-lpL7GltU.cjs +0 -18
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { accessFailureResponse as rt } from "@aiquants/auth-core";
|
|
1
2
|
import { crossOriginRefusal as ke, NO_CROSS_ORIGIN_NAVIGATION as Te } from "@aiquants/request-isolation";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { h as
|
|
5
|
-
import { d as x, i as
|
|
6
|
-
import { c as
|
|
7
|
-
const
|
|
3
|
+
import { redirect as Fe, data as Ue } from "react-router";
|
|
4
|
+
import { t as cr, b as tt, w as nt, o as st, f as ot, g as at, i as it, h as ct, e as dt, j as ut, p as lt, k as dr } from "./location-Dh6K-y7w.js";
|
|
5
|
+
import { h as ur, j as ft, k as se, s as pt, b as ht, m as wt, n as mt, o as yt, p as gt, E as lr, q as ee, t as bt, u as Et, i as F, v as kt, w as Tt, x as Rt, y as Ot, z as vt, f as xt, A as fr, B as At, C as ce, F as St, G as It, H as Pt, I as _t, J as M, K as pr, L as Dt, g as V, e as He, N as $t, O as Nt } from "./ownUrls-DD0cSCsF.js";
|
|
6
|
+
import { d as x, i as Lt } from "./describeValue-CLlVRO8d.js";
|
|
7
|
+
import { c as jt, i as Mt, M as Ct } from "./lru-DC8GBmkX.js";
|
|
8
|
+
const hr = "application/octet-stream", wr = "application/pdf", zt = /* @__PURE__ */ new Set([
|
|
8
9
|
"image/png",
|
|
9
10
|
"image/apng",
|
|
10
11
|
"image/jpeg",
|
|
@@ -30,11 +31,11 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
30
31
|
"video/webm",
|
|
31
32
|
"video/ogg",
|
|
32
33
|
"video/quicktime",
|
|
33
|
-
|
|
34
|
+
wr
|
|
34
35
|
]), Xe = "default-src 'none'; media-src 'self'; style-src 'unsafe-inline'", ye = Object.freeze({
|
|
35
36
|
sandboxed: `${Xe}; sandbox`,
|
|
36
37
|
mediaDocument: `${Xe}; sandbox allow-same-origin`
|
|
37
|
-
}), Be = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, Ft = /^[\t\n\r ]+|[\t\n\r ]+$/gu, ge = /^[\t ]+|[\t ]+$/gu,
|
|
38
|
+
}), Be = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u, Ft = /^[\t\n\r ]+|[\t\n\r ]+$/gu, ge = /^[\t ]+|[\t ]+$/gu, Ut = (e) => {
|
|
38
39
|
const r = [];
|
|
39
40
|
let t = "", o = 0;
|
|
40
41
|
for (; ; ) {
|
|
@@ -49,67 +50,67 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
49
50
|
if (r.push(t.replace(ge, "")), t = "", o >= e.length) return r;
|
|
50
51
|
o += 1;
|
|
51
52
|
}
|
|
52
|
-
},
|
|
53
|
+
}, Ht = (e) => {
|
|
53
54
|
const r = e.replace(Ft, ""), t = r.indexOf("/");
|
|
54
55
|
if (t < 0) return null;
|
|
55
56
|
const o = r.slice(0, t), c = r.indexOf(";", t + 1), u = r.slice(t + 1, c < 0 ? r.length : c).replace(/[\t\n\r ]+$/u, "");
|
|
56
57
|
return Be.test(o) && Be.test(u) ? `${o}/${u}`.toLowerCase() : null;
|
|
57
|
-
},
|
|
58
|
+
}, Xt = (e) => {
|
|
58
59
|
let r = null;
|
|
59
|
-
for (const t of
|
|
60
|
-
const o =
|
|
60
|
+
for (const t of Ut(e)) {
|
|
61
|
+
const o = Ht(t);
|
|
61
62
|
o !== null && o !== "*/*" && (r = o);
|
|
62
63
|
}
|
|
63
64
|
return r;
|
|
64
|
-
},
|
|
65
|
+
}, Bt = /['()*]/gu, mr = (e) => encodeURIComponent(e).replace(Bt, (r) => `%${r.charCodeAt(0).toString(16).toUpperCase()}`), Re = Object.freeze({
|
|
65
66
|
"Cache-Control": "private, max-age=60, stale-while-revalidate=600, no-transform",
|
|
66
67
|
Vary: "Cookie"
|
|
67
|
-
}),
|
|
68
|
-
const t =
|
|
68
|
+
}), yr = (e, r) => {
|
|
69
|
+
const t = Xt(e), o = t !== null && zt.has(t), c = o && (t.startsWith("audio/") || t.startsWith("video/"));
|
|
69
70
|
return {
|
|
70
|
-
contentType: t === null ?
|
|
71
|
+
contentType: t === null ? hr : t,
|
|
71
72
|
inline: o,
|
|
72
73
|
headers: {
|
|
73
74
|
"X-Content-Type-Options": "nosniff",
|
|
74
|
-
"Content-Disposition": `${o ? "inline" : "attachment"}; filename*=UTF-8''${
|
|
75
|
-
...t ===
|
|
75
|
+
"Content-Disposition": `${o ? "inline" : "attachment"}; filename*=UTF-8''${mr(r)}`,
|
|
76
|
+
...t === wr ? {} : { "Content-Security-Policy": c ? ye.mediaDocument : ye.sandboxed },
|
|
76
77
|
"Cross-Origin-Resource-Policy": "same-origin"
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
}, ne = 64 * 1024,
|
|
80
|
+
}, ne = 64 * 1024, gr = (e) => `text/plain; charset=${e}`, Vt = (e) => ({
|
|
80
81
|
"X-Content-Type-Options": "nosniff",
|
|
81
|
-
"Content-Disposition": `inline; filename*=UTF-8''${
|
|
82
|
+
"Content-Disposition": `inline; filename*=UTF-8''${mr(e)}`,
|
|
82
83
|
"Content-Security-Policy": ye.sandboxed,
|
|
83
84
|
"Cross-Origin-Resource-Policy": "same-origin"
|
|
84
|
-
}),
|
|
85
|
+
}), Gt = (e, r) => `${r === null ? "" : r};${e}`, Wt = /^bytes=(?:(\d+)-(\d*)|-(\d+))$/iu, re = Object.freeze({ kind: "whole" }), Ve = Object.freeze({ kind: "unsatisfiable" }), br = (e, r, t, o) => {
|
|
85
86
|
const c = e.get("Range");
|
|
86
87
|
if (c === null) return re;
|
|
87
88
|
const u = e.get("If-Range");
|
|
88
89
|
if (u !== null && u !== t) return re;
|
|
89
|
-
const f =
|
|
90
|
+
const f = Wt.exec(c);
|
|
90
91
|
if (f === null) return re;
|
|
91
92
|
const [, p, h, T] = f;
|
|
92
93
|
if (T !== void 0) {
|
|
93
94
|
const E = Number(T);
|
|
94
95
|
if (E === 0) return Ve;
|
|
95
|
-
const
|
|
96
|
-
return Ge(
|
|
96
|
+
const O = Math.max(0, r - E);
|
|
97
|
+
return Ge(O, r - O, o);
|
|
97
98
|
}
|
|
98
99
|
const m = Number(p), b = h === "" ? Number.POSITIVE_INFINITY : Number(h);
|
|
99
100
|
return b < m ? re : m >= r ? Ve : Ge(m, Math.min(b, r - 1) - m + 1, o);
|
|
100
|
-
}, Ge = (e, r, t) => ({ kind: "partial", range: { offset: e, length: t === null ? r : Math.min(r, t) } }), We = "W/",
|
|
101
|
+
}, Ge = (e, r, t) => ({ kind: "partial", range: { offset: e, length: t === null ? r : Math.min(r, t) } }), We = "W/", Yt = (e) => {
|
|
101
102
|
const r = [];
|
|
102
103
|
let t = 0, o = !1;
|
|
103
104
|
for (let c = 0; c < e.length; c += 1)
|
|
104
105
|
e[c] === '"' ? o = !o : e[c] === "," && !o && (r.push(e.slice(t, c).replace(ge, "")), t = c + 1);
|
|
105
106
|
return r.push(e.slice(t).replace(ge, "")), r;
|
|
106
|
-
}, Ye = (e) => e.startsWith(We) ? e.slice(We.length) : e,
|
|
107
|
+
}, Ye = (e) => e.startsWith(We) ? e.slice(We.length) : e, Oe = (e, r) => {
|
|
107
108
|
if (e === null) return !1;
|
|
108
|
-
const t =
|
|
109
|
+
const t = Yt(e);
|
|
109
110
|
if (t.length === 1 && t[0] === "*") return !0;
|
|
110
111
|
const o = Ye(r);
|
|
111
112
|
return t.some((c) => Ye(c) === o);
|
|
112
|
-
},
|
|
113
|
+
}, Jt = (e, r) => {
|
|
113
114
|
let t = r;
|
|
114
115
|
return e.pipeThrough(
|
|
115
116
|
new TransformStream({
|
|
@@ -125,25 +126,25 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
125
126
|
}, W = (e, r, t, o, c) => (c !== null && t.set("Content-Length", String(c)), { head: e.method.toUpperCase() === "HEAD", status: r, headers: t, range: o, length: c }), q = ({ head: e, status: r, headers: t, range: o, length: c }) => e ? { kind: "respond", response: new Response(null, { status: r, headers: t }) } : { kind: "stream", status: r, headers: t, range: o, length: c }, oe = async (e, r) => {
|
|
126
127
|
if (e.kind === "respond") return e.response;
|
|
127
128
|
const t = await r(e.range);
|
|
128
|
-
return new Response(e.length === null ? t :
|
|
129
|
-
},
|
|
129
|
+
return new Response(e.length === null ? t : Jt(t, e.length), { status: e.status, headers: e.headers });
|
|
130
|
+
}, Er = (e, r) => {
|
|
130
131
|
const t = new Headers(e);
|
|
131
132
|
for (const [o, c] of Object.entries({ "Accept-Ranges": "bytes", "Content-Range": `bytes */${r}`, "Cache-Control": "private, no-store", "X-Content-Type-Options": "nosniff" })) t.set(o, c);
|
|
132
133
|
return new Response(null, { status: 416, headers: t });
|
|
133
|
-
},
|
|
134
|
-
const c = `"${r.version}"`, u =
|
|
135
|
-
for (const [T, m] of Object.entries({ ...u.headers, ...
|
|
136
|
-
if (
|
|
134
|
+
}, kr = (e, r, t, o) => {
|
|
135
|
+
const c = `"${r.version}"`, u = yr(r.contentType, r.name), f = new Headers(t);
|
|
136
|
+
for (const [T, m] of Object.entries({ ...u.headers, ...Re, ETag: c })) f.set(T, m);
|
|
137
|
+
if (Oe(e.headers.get("If-None-Match"), c)) return { kind: "respond", response: new Response(null, { status: 304, headers: f }) };
|
|
137
138
|
if (f.set("Content-Type", u.contentType), r.size === null) return q(W(e, 200, f, null, null));
|
|
138
139
|
if (r.size === 0)
|
|
139
140
|
return f.set("Content-Length", "0"), { kind: "respond", response: new Response(null, { status: 200, headers: f }) };
|
|
140
141
|
f.set("Accept-Ranges", "bytes");
|
|
141
|
-
const p =
|
|
142
|
-
if (p.kind === "unsatisfiable") return { kind: "respond", response:
|
|
142
|
+
const p = br(e.headers, r.size, c, o);
|
|
143
|
+
if (p.kind === "unsatisfiable") return { kind: "respond", response: Er(t, r.size) };
|
|
143
144
|
if (p.kind === "whole") return q(W(e, 200, f, null, r.size));
|
|
144
145
|
const { range: h } = p;
|
|
145
146
|
return f.set("Content-Range", `bytes ${h.offset}-${h.offset + h.length - 1}/${r.size}`), q(W(e, 206, f, h, h.length));
|
|
146
|
-
},
|
|
147
|
+
}, Kt = async (e, r, t, o) => oe(kr(e, r, t, o), (c) => r.open(c)), Qt = (e, r) => {
|
|
147
148
|
const t = new Uint8Array(r);
|
|
148
149
|
let o = 0;
|
|
149
150
|
for (const c of e) {
|
|
@@ -152,7 +153,7 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
152
153
|
t.set(u, o), o += u.byteLength;
|
|
153
154
|
}
|
|
154
155
|
return t;
|
|
155
|
-
},
|
|
156
|
+
}, Zt = (e, r, t) => new ReadableStream(
|
|
156
157
|
{
|
|
157
158
|
start: (o) => {
|
|
158
159
|
for (const c of e) o.enqueue(c);
|
|
@@ -165,7 +166,7 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
165
166
|
cancel: (o) => t.cancel(o)
|
|
166
167
|
},
|
|
167
168
|
{ highWaterMark: 0 }
|
|
168
|
-
),
|
|
169
|
+
), Tr = async (e, r, t) => {
|
|
169
170
|
const o = e.getReader(), c = r === null ? ne : Math.min(r, ne), u = r === null ? c + 1 : c, f = [];
|
|
170
171
|
let p = 0, h = !1;
|
|
171
172
|
try {
|
|
@@ -179,50 +180,50 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
179
180
|
}
|
|
180
181
|
if (h && r !== null && p < c) throw new RangeError("[markdown-explorer] the asset ended before its declared length");
|
|
181
182
|
const T = r === null ? h : r <= ne;
|
|
182
|
-
return { encoding:
|
|
183
|
+
return { encoding: cr(Qt(f, Math.min(p, c)), T, t), body: Zt(f, h, o) };
|
|
183
184
|
} catch (T) {
|
|
184
185
|
throw o.cancel(T).catch(() => {
|
|
185
186
|
}), T;
|
|
186
187
|
}
|
|
187
|
-
},
|
|
188
|
-
const t = await
|
|
188
|
+
}, Rr = async (e, r) => {
|
|
189
|
+
const t = await Tr(await e.open(e.size === null ? null : { offset: 0, length: Math.min(e.size, ne) }), e.size, r);
|
|
189
190
|
return t.body.cancel().catch(() => {
|
|
190
191
|
}), t.encoding;
|
|
191
|
-
},
|
|
192
|
-
const u = `"${
|
|
193
|
-
for (const [T, m] of Object.entries({ ...
|
|
194
|
-
if (
|
|
192
|
+
}, Or = (e, r, t, o, c) => {
|
|
193
|
+
const u = `"${Gt(r.version, o)}"`, f = new Headers(t);
|
|
194
|
+
for (const [T, m] of Object.entries({ ...Vt(r.name), ...Re, ETag: u })) f.set(T, m);
|
|
195
|
+
if (Oe(e.headers.get("If-None-Match"), u)) return { kind: "respond", response: new Response(null, { status: 304, headers: f }) };
|
|
195
196
|
if (r.size === 0)
|
|
196
|
-
return f.set("Content-Type",
|
|
197
|
+
return f.set("Content-Type", gr(cr(new Uint8Array(0), !0, o))), f.set("Content-Length", "0"), { kind: "respond", response: new Response(null, { status: 200, headers: f }) };
|
|
197
198
|
if (r.size === null) return { kind: "needs-encoding", selection: W(e, 200, f, null, null) };
|
|
198
199
|
f.set("Accept-Ranges", "bytes");
|
|
199
|
-
const p =
|
|
200
|
-
if (p.kind === "unsatisfiable") return { kind: "respond", response:
|
|
200
|
+
const p = br(e.headers, r.size, u, c);
|
|
201
|
+
if (p.kind === "unsatisfiable") return { kind: "respond", response: Er(t, r.size) };
|
|
201
202
|
if (p.kind === "whole") return { kind: "needs-encoding", selection: W(e, 200, f, null, r.size) };
|
|
202
203
|
const { range: h } = p;
|
|
203
204
|
return f.set("Content-Range", `bytes ${h.offset}-${h.offset + h.length - 1}/${r.size}`), { kind: "needs-encoding", selection: W(e, 206, f, h, h.length) };
|
|
204
205
|
}, be = (e, r) => {
|
|
205
206
|
const t = new Headers(e.headers);
|
|
206
|
-
return t.set("Content-Type",
|
|
207
|
-
},
|
|
208
|
-
const u =
|
|
207
|
+
return t.set("Content-Type", gr(r)), q({ ...e, headers: t });
|
|
208
|
+
}, qt = async (e, r, t, o, c) => {
|
|
209
|
+
const u = Or(e, r, t, o, c);
|
|
209
210
|
if (u.kind === "respond") return u.response;
|
|
210
211
|
const { selection: f } = u;
|
|
211
|
-
if (f.head || f.range !== null) return oe(be(f, await
|
|
212
|
-
const p = await
|
|
212
|
+
if (f.head || f.range !== null) return oe(be(f, await Rr(r, o)), (h) => r.open(h));
|
|
213
|
+
const p = await Tr(await r.open(null), r.size, o);
|
|
213
214
|
return oe(be(f, p.encoding), async () => p.body);
|
|
214
|
-
},
|
|
215
|
-
const o = `"${
|
|
216
|
-
for (const [f, p] of Object.entries({ ...c.headers, ...
|
|
217
|
-
return
|
|
218
|
-
},
|
|
215
|
+
}, en = (e) => `workbook;${e}`, rn = async (e, r, t) => {
|
|
216
|
+
const o = `"${en(r.version)}"`, c = yr(hr, r.name), u = new Headers(t);
|
|
217
|
+
for (const [f, p] of Object.entries({ ...c.headers, ...Re, ETag: o })) u.set(f, p);
|
|
218
|
+
return Oe(e.headers.get("If-None-Match"), o) ? new Response(null, { status: 304, headers: u }) : (u.set("Content-Type", c.contentType), oe(q(W(e, 200, u, null, r.size)), (f) => r.open(f)));
|
|
219
|
+
}, tn = Object.freeze({
|
|
219
220
|
"Cache-Control": "private, no-store",
|
|
220
221
|
"Referrer-Policy": "no-referrer"
|
|
221
|
-
}),
|
|
222
|
+
}), nn = (e, r) => {
|
|
222
223
|
const t = new Headers(r);
|
|
223
|
-
for (const [o, c] of Object.entries(
|
|
224
|
+
for (const [o, c] of Object.entries(tn)) t.set(o, c);
|
|
224
225
|
return t.set("Location", e), new Response(null, { status: 302, headers: t });
|
|
225
|
-
},
|
|
226
|
+
}, pe = (e, r) => {
|
|
226
227
|
const t = new AbortController(), o = r(AbortSignal.any([e.signal, t.signal]));
|
|
227
228
|
return new Promise((c) => {
|
|
228
229
|
let u;
|
|
@@ -240,29 +241,29 @@ const mr = "application/octet-stream", yr = "application/pdf", Ut = /* @__PURE__
|
|
|
240
241
|
}
|
|
241
242
|
);
|
|
242
243
|
});
|
|
243
|
-
},
|
|
244
|
+
}, sn = Object.freeze({
|
|
244
245
|
error: (e, r) => {
|
|
245
246
|
console.error(e, r);
|
|
246
247
|
}
|
|
247
|
-
}),
|
|
248
|
-
class
|
|
248
|
+
}), vr = /* @__PURE__ */ Symbol.for("@aiquants/markdown-explorer:ExplorerError");
|
|
249
|
+
class us extends Error {
|
|
249
250
|
reason;
|
|
250
251
|
code;
|
|
251
252
|
constructor(r, t = {}) {
|
|
252
|
-
if (!
|
|
253
|
-
if (t.code !== void 0 && !
|
|
254
|
-
super(`[markdown-explorer] ${r}`, t.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "ExplorerError", this.reason = r, this.code = t.code, Object.defineProperty(this,
|
|
253
|
+
if (!ur(r)) throw new RangeError(`[markdown-explorer] ExplorerError needs a failure reason; got ${x(r)}`);
|
|
254
|
+
if (t.code !== void 0 && !ft(t.code)) throw new RangeError(`[markdown-explorer] an ExplorerError code must be 1 to 64 lowercase letters, digits or hyphens; got ${x(t.code)}`);
|
|
255
|
+
super(`[markdown-explorer] ${r}`, t.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "ExplorerError", this.reason = r, this.code = t.code, Object.defineProperty(this, vr, { value: !0 });
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
|
-
const
|
|
258
|
+
const on = (e) => e instanceof Error && Object.hasOwn(e, vr) && ur(e.reason), an = (e) => typeof e == "object" && e !== null && e.name === "AbortError", ve = (e, r, t) => {
|
|
258
259
|
try {
|
|
259
260
|
e.error(r, t);
|
|
260
261
|
} catch (o) {
|
|
261
262
|
console.error("[markdown-explorer] the logger threw while reporting a failure", { operation: t.operation, error: o });
|
|
262
263
|
}
|
|
263
|
-
}, $ = (e, r) => ve(e, `[markdown-explorer] ${r.operation} failed`, r),
|
|
264
|
+
}, $ = (e, r) => ve(e, `[markdown-explorer] ${r.operation} failed`, r), cn = (e, r) => ve(e, `[markdown-explorer] ${r.operation} left out an entry`, r), Z = (e, r) => ve(e, `[markdown-explorer] ${r.operation} refused a path the deny rules match`, { ...r, error: new RangeError("[markdown-explorer] the path matches a deny rule") }), Je = (e, r) => {
|
|
264
265
|
e === null || typeof e != "object" && typeof e != "function" || Promise.resolve(e).then(void 0, r);
|
|
265
|
-
}, v = (e, r, t, o) =>
|
|
266
|
+
}, v = (e, r, t, o) => on(e) ? se(e.reason, e.code) : (an(e) || t.aborted || $(o, { ...r, error: e }), { reason: "failed" }), Ke = 2 * 1024 * 1024, Qe = 256 * 1024 * 1024, dn = async (e, r) => {
|
|
266
267
|
const t = e.getReader(), o = new Uint8Array(r);
|
|
267
268
|
let c = 0;
|
|
268
269
|
for (; c < r; ) {
|
|
@@ -273,24 +274,24 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
273
274
|
}
|
|
274
275
|
return t.cancel().catch(() => {
|
|
275
276
|
}), o;
|
|
276
|
-
},
|
|
277
|
+
}, un = async (e, r, t) => {
|
|
277
278
|
if (e.size === 0) return { text: "", truncated: !1 };
|
|
278
|
-
const o = e.size !== null && e.size > r, c = e.size === null ? r + 1 : Math.min(e.size, r), u = await
|
|
279
|
+
const o = e.size !== null && e.size > r, c = e.size === null ? r + 1 : Math.min(e.size, r), u = await dn(await e.open(o ? { offset: 0, length: r } : null), c);
|
|
279
280
|
if (e.size !== null && u.byteLength < c) throw new RangeError("[markdown-explorer] the file ended before the length its asset port reported");
|
|
280
|
-
const f = o || u.byteLength > r, p = f ? u.subarray(0, r) : u, h =
|
|
281
|
+
const f = o || u.byteLength > r, p = f ? u.subarray(0, r) : u, h = tt(p, !f, t);
|
|
281
282
|
return h.includes("\0") ? null : { text: h, truncated: f };
|
|
282
|
-
}, ae = (e) => ({ result: e, json: JSON.stringify(e) }),
|
|
283
|
-
const c =
|
|
284
|
-
const E = new AbortController(),
|
|
283
|
+
}, ae = (e) => ({ result: e, json: JSON.stringify(e) }), he = Object.freeze(ae(Object.freeze({ status: "error", failure: Object.freeze({ reason: "failed" }) }))), ln = (e) => e.status === "ok" && e.entries.length > 0, fn = ({ ttlMs: e, maxEntries: r, maxBytes: t, now: o }) => {
|
|
284
|
+
const c = jt(r, { max: t, of: (m, b) => 2 * b.tree.json.length }), u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = (m, b) => {
|
|
285
|
+
const E = new AbortController(), O = { waiters: 0, superseded: !1, started: !1, loadTree: b }, P = f.get(m), U = (j, de) => {
|
|
285
286
|
const K = ae(j);
|
|
286
|
-
return !(
|
|
287
|
+
return !(O.superseded || E.signal.aborted) && ln(j) && c.set(m, { tree: K, loadedAt: de }), K;
|
|
287
288
|
}, z = (async () => {
|
|
288
|
-
if (
|
|
289
|
+
if (P !== void 0 && await P, E.signal.aborted) return he;
|
|
289
290
|
const j = o();
|
|
290
|
-
return
|
|
291
|
+
return O.started = !0, U(await O.loadTree(E.signal, j), j);
|
|
291
292
|
})().finally(() => {
|
|
292
293
|
u.get(m) === X && u.delete(m);
|
|
293
|
-
}), X = { promise: z, controller: E, state:
|
|
294
|
+
}), X = { promise: z, controller: E, state: O };
|
|
294
295
|
u.set(m, X);
|
|
295
296
|
const N = z.then(
|
|
296
297
|
() => {
|
|
@@ -303,11 +304,11 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
303
304
|
}), X;
|
|
304
305
|
}, h = (m, b, E) => {
|
|
305
306
|
b.state.waiters += 1;
|
|
306
|
-
const
|
|
307
|
+
const O = () => {
|
|
307
308
|
b.state.waiters -= 1, !(b.state.waiters > 0) && (u.get(m) === b && u.delete(m), b.controller.abort());
|
|
308
309
|
};
|
|
309
|
-
return E.addEventListener("abort",
|
|
310
|
-
E.removeEventListener("abort",
|
|
310
|
+
return E.addEventListener("abort", O, { once: !0 }), b.promise.finally(() => {
|
|
311
|
+
E.removeEventListener("abort", O);
|
|
311
312
|
});
|
|
312
313
|
}, T = (m) => {
|
|
313
314
|
c.delete(m);
|
|
@@ -316,40 +317,40 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
316
317
|
};
|
|
317
318
|
return {
|
|
318
319
|
load: (m, b, E) => {
|
|
319
|
-
if (b.aborted) return Promise.resolve(
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
if (o() -
|
|
320
|
+
if (b.aborted) return Promise.resolve(he);
|
|
321
|
+
const O = c.get(m);
|
|
322
|
+
if (O !== void 0) {
|
|
323
|
+
if (o() - O.loadedAt < e) return Promise.resolve(O.tree);
|
|
323
324
|
c.delete(m);
|
|
324
325
|
}
|
|
325
|
-
const
|
|
326
|
-
return h(m,
|
|
326
|
+
const P = u.get(m);
|
|
327
|
+
return h(m, P === void 0 ? p(m, E) : P, b);
|
|
327
328
|
},
|
|
328
329
|
refresh: (m, b, E) => {
|
|
329
|
-
if (b.aborted) return Promise.resolve(
|
|
330
|
+
if (b.aborted) return Promise.resolve(he);
|
|
330
331
|
T(m);
|
|
331
|
-
const
|
|
332
|
-
return
|
|
332
|
+
const O = u.get(m);
|
|
333
|
+
return O === void 0 ? h(m, p(m, E), b) : (O.state.loadTree = E, h(m, O, b));
|
|
333
334
|
},
|
|
334
335
|
forget: T
|
|
335
336
|
};
|
|
336
|
-
},
|
|
337
|
+
}, pn = (e) => ({
|
|
337
338
|
load: (r, t, o) => o(t, e()).then(ae),
|
|
338
339
|
refresh: (r, t, o) => o(t, e()).then(ae),
|
|
339
340
|
forget: () => {
|
|
340
341
|
}
|
|
341
342
|
}), g = (e) => {
|
|
342
343
|
throw new TypeError(`[markdown-explorer] ${e}`);
|
|
343
|
-
},
|
|
344
|
+
}, hn = (e) => {
|
|
344
345
|
if (e === null || typeof e != "object") return null;
|
|
345
346
|
const { name: r, path: t } = e;
|
|
346
|
-
return typeof r != "string" || typeof t != "string" ? null : r === "" ? { path: t, reason: "an empty name" } :
|
|
347
|
-
},
|
|
347
|
+
return typeof r != "string" || typeof t != "string" ? null : r === "" ? { path: t, reason: "an empty name" } : F(t) ? null : { path: t, reason: "a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash)" };
|
|
348
|
+
}, wn = (e, r, t, o) => {
|
|
348
349
|
if (e === null) return null;
|
|
349
350
|
if (!Array.isArray(e)) throw new TypeError(`[markdown-explorer] a source's ancestors must be null or an array of folder paths; got ${x(e)}`);
|
|
350
351
|
const c = /* @__PURE__ */ new Set();
|
|
351
352
|
for (const u of e) {
|
|
352
|
-
if (typeof u != "string" || !
|
|
353
|
+
if (typeof u != "string" || !F(u)) throw new TypeError("[markdown-explorer] a source's ancestors held a path the explorer does not accept");
|
|
353
354
|
if (t.deniesPath(u)) throw new TypeError("[markdown-explorer] a source's ancestors held a denied path");
|
|
354
355
|
if (!o(u)) throw new TypeError("[markdown-explorer] a source's ancestors held a path outside the source's boundary");
|
|
355
356
|
if (u === r) throw new TypeError("[markdown-explorer] a source's ancestors held the document itself");
|
|
@@ -357,7 +358,7 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
357
358
|
c.add(u);
|
|
358
359
|
}
|
|
359
360
|
return Object.freeze([...c]);
|
|
360
|
-
},
|
|
361
|
+
}, mn = (e, r, t, o, c) => {
|
|
361
362
|
const u = /* @__PURE__ */ new Set(), f = (h) => {
|
|
362
363
|
if (!Array.isArray(h)) return g("a source returned entries that are not an array");
|
|
363
364
|
const T = [];
|
|
@@ -367,60 +368,60 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
367
368
|
}
|
|
368
369
|
return T;
|
|
369
370
|
}, p = (h) => {
|
|
370
|
-
const T =
|
|
371
|
+
const T = hn(h);
|
|
371
372
|
if (T !== null)
|
|
372
373
|
return o(T), null;
|
|
373
|
-
const m =
|
|
374
|
+
const m = Tt(h);
|
|
374
375
|
if (m !== null) return g(m);
|
|
375
376
|
const b = h;
|
|
376
377
|
if (u.has(b)) return g("a source returned entries that contain themselves");
|
|
377
|
-
const { name: E, path:
|
|
378
|
-
if (r.deniesName(E) || r.deniesPath(
|
|
379
|
-
if (!c(
|
|
380
|
-
return o({ path:
|
|
381
|
-
const N = { name: E, path:
|
|
382
|
-
if (
|
|
378
|
+
const { name: E, path: O, type: P, mimeType: U, modifiedAt: H, children: z, lazy: X } = b;
|
|
379
|
+
if (r.deniesName(E) || r.deniesPath(O)) return null;
|
|
380
|
+
if (!c(O))
|
|
381
|
+
return o({ path: O, reason: "a path outside the source's boundary" }), null;
|
|
382
|
+
const N = { name: E, path: O, ...U === void 0 ? {} : { mimeType: U }, ...H === void 0 ? {} : { modifiedAt: H } };
|
|
383
|
+
if (P === "file") return { ...N, type: P };
|
|
383
384
|
if (X === !0)
|
|
384
|
-
return t ? { ...N, type:
|
|
385
|
-
if (z === void 0) return { ...N, type:
|
|
385
|
+
return t ? { ...N, type: P, lazy: !0, children: [] } : g("a lazy directory came from a source without a children function");
|
|
386
|
+
if (z === void 0) return { ...N, type: P };
|
|
386
387
|
u.add(b);
|
|
387
388
|
const j = f(z);
|
|
388
|
-
return u.delete(b), { ...N, type:
|
|
389
|
+
return u.delete(b), { ...N, type: P, children: j };
|
|
389
390
|
};
|
|
390
391
|
return f(e);
|
|
391
|
-
},
|
|
392
|
+
}, yn = /^[\x21\x23-\x7E]{1,256}$/u, xr = (e) => typeof e == "string" && yn.test(e), gn = /* @__PURE__ */ new Set(["text", "image", "media", "spreadsheet", "file"]), bn = (e) => typeof e == "string" && gn.has(e), En = (e, r, t) => {
|
|
392
393
|
if (e !== null && typeof e == "object") {
|
|
393
394
|
const u = e, { kind: f } = u;
|
|
394
|
-
if (
|
|
395
|
+
if (bn(f)) {
|
|
395
396
|
if (Object.hasOwn(u, "url")) return g(`a ${f} document carries its version, not a url`);
|
|
396
397
|
if (typeof u.name != "string") return g("a document needs a name string");
|
|
397
|
-
if (!
|
|
398
|
+
if (!xr(u.version)) return g(`a ${f} document needs a version of 1 to 256 visible ASCII characters other than '"'`);
|
|
398
399
|
const p = r(u.version);
|
|
399
400
|
switch (f) {
|
|
400
401
|
case "image": {
|
|
401
402
|
const { imageType: h } = u;
|
|
402
|
-
return
|
|
403
|
+
return yt(h) ? { kind: f, name: u.name, url: p, imageType: h } : g(`unknown image type ${x(h)}`);
|
|
403
404
|
}
|
|
404
405
|
case "file":
|
|
405
406
|
return { kind: f, name: u.name, url: p };
|
|
406
407
|
case "media": {
|
|
407
408
|
const { mediaType: h } = u;
|
|
408
|
-
return
|
|
409
|
+
return mt(h) ? { kind: f, name: u.name, url: p, mediaType: h } : g(`unknown media type ${x(h)}`);
|
|
409
410
|
}
|
|
410
411
|
case "text": {
|
|
411
412
|
const { text: h, truncated: T, lang: m } = u;
|
|
412
|
-
return typeof h != "string" || typeof T != "boolean" ? g("a text document needs text and truncated") :
|
|
413
|
+
return typeof h != "string" || typeof T != "boolean" ? g("a text document needs text and truncated") : ht(m) ? { kind: f, name: u.name, text: h, truncated: T, lang: m, url: p } : g(wt(f, m));
|
|
413
414
|
}
|
|
414
415
|
case "spreadsheet": {
|
|
415
|
-
const h =
|
|
416
|
+
const h = pt(u);
|
|
416
417
|
if (h !== null) return g(h);
|
|
417
418
|
const { format: T, firstSheetText: m, edit: b } = u;
|
|
418
|
-
return { kind: f, name: u.name, url: p, format: T, firstSheetText: m, edit:
|
|
419
|
+
return { kind: f, name: u.name, url: p, format: T, firstSheetText: m, edit: Tn(b) };
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
|
-
const o =
|
|
424
|
+
const o = gt(e);
|
|
424
425
|
if (o !== null) return g(o);
|
|
425
426
|
const c = e;
|
|
426
427
|
switch (c.kind) {
|
|
@@ -429,9 +430,9 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
429
430
|
return { kind: "failure", failure: se(u, f) };
|
|
430
431
|
}
|
|
431
432
|
case "markdown":
|
|
432
|
-
return c.headings.length >
|
|
433
|
+
return c.headings.length > lr ? { kind: "failure", failure: se("too-large") } : (c.edit?.kind === "inline" || c.edit?.kind === "draft") && !t ? g(`a markdown document offers ${c.edit.kind} editing, but the server has no edit ports`) : { kind: "unsanitized-markdown", name: c.name, html: c.htmlContent, headings: c.headings.map(({ text: u, depth: f, id: p }) => ({ text: u, depth: f, id: p })), lang: c.lang, edit: kn(c.edit) };
|
|
433
434
|
}
|
|
434
|
-
},
|
|
435
|
+
}, kn = (e) => {
|
|
435
436
|
if (e === null) return null;
|
|
436
437
|
switch (e.kind) {
|
|
437
438
|
case "inline":
|
|
@@ -441,16 +442,16 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
441
442
|
case "external":
|
|
442
443
|
return { kind: "external", href: e.href };
|
|
443
444
|
}
|
|
444
|
-
},
|
|
445
|
+
}, Tn = (e) => e === null ? null : { kind: "external", href: e.href }, ie = (e, r, t) => typeof e != "string" ? g(`${t} needs a text string`) : e.includes("\0") ? g(`${t} holds NUL, which no text editor can keep`) : new TextEncoder().encode(e).byteLength > r ? g(`${t} is over editMaxBytes (${r} bytes); refuse a longer source with ExplorerError "too-large"`) : e, Ar = (e) => kt(e.href) ? { kind: "grant", href: e.href } : g("a grant needs a root-relative href"), Rn = (e, r) => {
|
|
445
446
|
if (e === null || typeof e != "object") return g("an edit source must be an object");
|
|
446
447
|
const t = e;
|
|
447
|
-
return t.kind === "grant" ?
|
|
448
|
-
},
|
|
448
|
+
return t.kind === "grant" ? Ar(t) : t.kind === "draft" ? { kind: "draft", text: ie(t.text, r, "a draft source") } : t.kind !== "edit" ? g(`an edit source's kind must be "edit", "draft" or "grant"`) : ee(t.version) ? typeof t.history != "boolean" ? g("an edit source needs history") : { kind: "edit", text: ie(t.text, r, "an edit source"), version: t.version, history: t.history } : g("an edit source needs a version of 1 to 1024 characters");
|
|
449
|
+
}, On = (e, r) => {
|
|
449
450
|
if (e === null || typeof e != "object") return g("a save result must be an object");
|
|
450
451
|
const t = e;
|
|
451
452
|
switch (t.kind) {
|
|
452
453
|
case "grant":
|
|
453
|
-
return
|
|
454
|
+
return Ar(t);
|
|
454
455
|
case "saved":
|
|
455
456
|
return ee(t.version) ? { kind: "saved", version: t.version } : g("a saved result needs a version of 1 to 1024 characters");
|
|
456
457
|
case "conflict":
|
|
@@ -458,37 +459,37 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
458
459
|
default:
|
|
459
460
|
return g(`a save result's kind must be "saved", "conflict" or "grant"`);
|
|
460
461
|
}
|
|
461
|
-
},
|
|
462
|
+
}, vn = (e) => {
|
|
462
463
|
if (e === null || typeof e != "object") return g("a preview must be an object");
|
|
463
464
|
const { htmlContent: r, headings: t } = e;
|
|
464
465
|
if (typeof r != "string" || !Array.isArray(t)) return g("a preview needs htmlContent and headings");
|
|
465
|
-
if (t.length >
|
|
466
|
+
if (t.length > lr) return { kind: "failure", failure: se("too-large") };
|
|
466
467
|
for (const o of t) {
|
|
467
|
-
const c =
|
|
468
|
+
const c = Et(o);
|
|
468
469
|
if (c !== null) return g(c);
|
|
469
470
|
}
|
|
470
471
|
return { html: r, headings: t.map(({ text: o, depth: c, id: u }) => ({ text: o, depth: c, id: u })) };
|
|
471
|
-
},
|
|
472
|
+
}, xn = (e) => {
|
|
472
473
|
if (!Array.isArray(e)) return g("revisions must be an array");
|
|
473
474
|
const r = /* @__PURE__ */ new Set();
|
|
474
475
|
return e.map((t) => {
|
|
475
|
-
const o =
|
|
476
|
+
const o = bt(t);
|
|
476
477
|
if (o !== null) return g(o);
|
|
477
478
|
const { id: c, modifiedAt: u, size: f, author: p, kept: h, current: T } = t;
|
|
478
479
|
return r.has(c) ? g(`two revisions share the id ${x(c)}`) : (r.add(c), { id: c, modifiedAt: u, size: f, author: p, kept: h, current: T });
|
|
479
480
|
});
|
|
480
|
-
},
|
|
481
|
+
}, An = (e, r) => ie(e, r, "a revision"), Ee = (e) => {
|
|
481
482
|
if (e === null || typeof e != "object") return g("an asset file must be an object");
|
|
482
483
|
const { name: r, contentType: t, size: o, version: c, open: u, kind: f, bridge: p } = e;
|
|
483
484
|
if (f !== void 0) return g(f === "redirect" ? "an asset redirect answers only a request for the stored file (options.delivery file), never one that reads the bytes" : 'an asset file has no kind (the only kind is "redirect")');
|
|
484
485
|
if (typeof r != "string" || r === "") return g("an asset file needs a non-empty name");
|
|
485
486
|
if (typeof t != "string") return g("an asset file needs a contentType string ('' when unknown)");
|
|
486
487
|
if (o !== null && !(typeof o == "number" && Number.isSafeInteger(o) && o >= 0)) return g("an asset file's size must be null or a non-negative safe integer");
|
|
487
|
-
if (!
|
|
488
|
+
if (!xr(c)) return g(`an asset file needs a version of 1 to 256 visible ASCII characters other than '"'`);
|
|
488
489
|
if (typeof u != "function") return g("an asset file needs an open function");
|
|
489
490
|
const h = { name: r, contentType: t, size: o, version: c, open: u };
|
|
490
|
-
return Object.freeze(p === void 0 ? h : { ...h, bridge:
|
|
491
|
-
},
|
|
491
|
+
return Object.freeze(p === void 0 ? h : { ...h, bridge: Sn(p) });
|
|
492
|
+
}, Sn = (e) => {
|
|
492
493
|
if (e === null || typeof e != "object") return g("an asset file's bridge must be an object when present");
|
|
493
494
|
const { uri: r, storageVersion: t, readFailure: o } = e;
|
|
494
495
|
return typeof r != "string" || r === "" ? g("an asset file's bridge needs a non-empty uri") : t !== null && (typeof t != "string" || t === "") ? g("an asset file's bridge needs a storageVersion that is a non-empty string, or null when the storage keeps none") : typeof o != "function" ? g("an asset file's bridge needs a readFailure function") : Object.freeze({ uri: r, storageVersion: t, readFailure: o });
|
|
@@ -508,35 +509,35 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
508
509
|
if (f === void 0) return h;
|
|
509
510
|
if (f === null || typeof f != "object") return g("a notice action must be an object");
|
|
510
511
|
const { label: T, href: m } = f;
|
|
511
|
-
return typeof T != "string" || !
|
|
512
|
-
}) : g("notices must be an array"),
|
|
512
|
+
return typeof T != "string" || !Ot(m, vt) ? g("a notice action needs a label and an http(s), mailto or relative href") : { ...h, action: { label: T, href: m } };
|
|
513
|
+
}) : g("notices must be an array"), Pn = 4e3, te = Object.freeze({ ttlMs: 3e5, maxEntries: 64, maxBytes: 64 * 1024 * 1024 }), Sr = "private, no-store", _n = Object.freeze({
|
|
513
514
|
"Content-Type": "application/json; charset=utf-8",
|
|
514
|
-
"Cache-Control":
|
|
515
|
+
"Cache-Control": Sr,
|
|
515
516
|
"X-Content-Type-Options": "nosniff",
|
|
516
517
|
"Content-Security-Policy": "default-src 'none'; frame-ancestors 'none'; sandbox",
|
|
517
518
|
"Cross-Origin-Resource-Policy": "same-origin"
|
|
518
|
-
}),
|
|
519
|
+
}), we = Object.freeze([]), Dn = Object.freeze({ status: "ok", source: null, ancestors: null }), qe = Object.freeze(["contains", "confirm"]), er = Object.freeze({ readOnly: !1 }), $n = Object.freeze({ readOnly: !0 }), Nn = /* @__PURE__ */ new Set(["file", "text", "workbook"]), Ln = /* @__PURE__ */ new Set(["file", "text"]), jn = Object.freeze({ status: "error", failure: Object.freeze({ reason: "invalid" }) }), I = (e, r, t) => {
|
|
519
520
|
if (!(t && r === void 0) && typeof r != "function")
|
|
520
521
|
throw new TypeError(`[markdown-explorer] ${e} must be a function; got ${x(r)}`);
|
|
521
522
|
}, G = (e, r, t) => {
|
|
522
523
|
if (typeof r != "number") throw new TypeError(`[markdown-explorer] ${e} must be a number; got ${x(r)}`);
|
|
523
524
|
if (!Number.isSafeInteger(r) || r <= 0 || r > t) throw new RangeError(`[markdown-explorer] ${e} must be an integer in 1..${String(t)}; got ${x(r)}`);
|
|
524
525
|
return r;
|
|
525
|
-
},
|
|
526
|
+
}, Mn = (e) => {
|
|
526
527
|
if (e === null || typeof e != "object" || !Object.isFrozen(e)) throw new TypeError("[markdown-explorer] config must be the value returned by defineExplorerConfig");
|
|
527
|
-
return
|
|
528
|
-
},
|
|
528
|
+
return at(e);
|
|
529
|
+
}, me = (e) => {
|
|
529
530
|
try {
|
|
530
531
|
return new Headers(e);
|
|
531
532
|
} catch {
|
|
532
533
|
throw new TypeError("[markdown-explorer] authenticate returned headers that are not a valid headers init (their values are not logged)");
|
|
533
534
|
}
|
|
534
|
-
},
|
|
535
|
-
if (!
|
|
535
|
+
}, rr = (e) => e instanceof Response ? new TypeError(`[markdown-explorer] authenticate threw a Response (status ${String(e.status)}), which a data request does not follow`) : e, Cn = (e, r) => {
|
|
536
|
+
if (!Lt(r)) throw new TypeError(`[markdown-explorer] ${e}.boundary must be a plain object { contains, confirm? }`);
|
|
536
537
|
for (const t of Object.keys(r))
|
|
537
538
|
if (!qe.includes(t)) throw new RangeError(`[markdown-explorer] ${e}.boundary.${t} is not an option; expected ${qe.join(", ")}`);
|
|
538
|
-
|
|
539
|
-
},
|
|
539
|
+
I(`${e}.boundary.contains`, r.contains, !1), I(`${e}.boundary.confirm`, r.confirm, !0);
|
|
540
|
+
}, zn = (e) => {
|
|
540
541
|
if (!Array.isArray(e)) throw new TypeError("[markdown-explorer] sources must be an array");
|
|
541
542
|
const r = e;
|
|
542
543
|
if (r.length === 0) throw new RangeError("[markdown-explorer] sources must hold at least one source");
|
|
@@ -544,13 +545,13 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
544
545
|
for (const [o, c] of r.entries()) {
|
|
545
546
|
if (c === null || typeof c != "object") throw new TypeError(`[markdown-explorer] sources[${String(o)}] must be an object`);
|
|
546
547
|
const { id: u, label: f, boundary: p, tree: h, children: T, ancestors: m, cacheScope: b } = c;
|
|
547
|
-
if (!
|
|
548
|
+
if (!it(u))
|
|
548
549
|
throw new RangeError(`[markdown-explorer] sources[${String(o)}].id must use lowercase letters, digits and "-" and start with a letter or digit; got ${x(u)}`);
|
|
549
550
|
const E = `source ${x(u)}`;
|
|
550
551
|
if (t.has(u)) throw new RangeError(`[markdown-explorer] source ids must be unique; ${x(u)} repeats at sources[${String(o)}]`);
|
|
551
552
|
if (t.add(u), typeof f != "string" && typeof f != "function") throw new TypeError(`[markdown-explorer] ${E}.label must be a string or a function`);
|
|
552
553
|
if (typeof f == "string" && f.trim() === "") throw new RangeError(`[markdown-explorer] ${E}.label must not be blank`);
|
|
553
|
-
if (
|
|
554
|
+
if (Cn(E, p), I(`${E}.tree`, h, !1), I(`${E}.children`, T, !0), I(`${E}.ancestors`, m, !0), b !== void 0 && b !== "principal" && b !== "shared") throw new RangeError(`[markdown-explorer] ${E}.cacheScope must be "principal" or "shared"; got ${x(b)}`);
|
|
554
555
|
}
|
|
555
556
|
return r;
|
|
556
557
|
}, Fn = (e) => {
|
|
@@ -563,18 +564,18 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
563
564
|
maxEntries: t === void 0 ? te.maxEntries : G("treeCache.maxEntries", t, Number.MAX_SAFE_INTEGER),
|
|
564
565
|
maxBytes: o === void 0 ? te.maxBytes : G("treeCache.maxBytes", o, Number.MAX_SAFE_INTEGER)
|
|
565
566
|
};
|
|
566
|
-
},
|
|
567
|
+
}, tr = (e) => {
|
|
567
568
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] authenticate must resolve to { status, ... }");
|
|
568
569
|
const { status: r } = e;
|
|
569
570
|
if (r !== "signed-in" && r !== "signed-out" && r !== "forbidden") throw new TypeError(`[markdown-explorer] authenticate resolved to an unknown status ${x(r)}`);
|
|
570
571
|
return e;
|
|
571
|
-
},
|
|
572
|
+
}, Un = (e, r) => {
|
|
572
573
|
if (!(r instanceof Response)) throw new TypeError(`[markdown-explorer] ${e} must return a Response`);
|
|
573
574
|
return r;
|
|
574
|
-
},
|
|
575
|
+
}, nr = (e, r) => {
|
|
575
576
|
if (typeof r != "string" || r === "") throw new TypeError("[markdown-explorer] principalKey must return a non-empty string");
|
|
576
577
|
const t = e(r);
|
|
577
|
-
if (!
|
|
578
|
+
if (!Mt(t)) throw new TypeError("[markdown-explorer] the platform's scope must be 22 base64url characters");
|
|
578
579
|
return t;
|
|
579
580
|
}, Hn = (e, r) => {
|
|
580
581
|
try {
|
|
@@ -589,27 +590,27 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
589
590
|
}, Bn = (e) => e.view === "multi" ? e.docs : e.doc === null ? [] : [e.doc], C = (e, r) => {
|
|
590
591
|
const t = e.getAll(r), [o] = t;
|
|
591
592
|
return t.length === 1 && o !== void 0 && o !== "" ? o : null;
|
|
592
|
-
},
|
|
593
|
+
}, S = (e, r, t, o = {}) => {
|
|
593
594
|
const c = new Headers(t);
|
|
594
|
-
for (const [u, f] of Object.entries({ ...
|
|
595
|
+
for (const [u, f] of Object.entries({ ..._n, ...o })) c.set(u, f);
|
|
595
596
|
return new Response(r, { status: e, headers: c });
|
|
596
|
-
},
|
|
597
|
+
}, R = (e, r, t) => S(fr[e.reason], JSON.stringify({ failure: e }), r, t), Vn = /* @__PURE__ */ new Set(["refresh", "save", "preview", "issue-id"]), Gn = /* @__PURE__ */ new Set(["issue-id", "resolve-id"]), sr = 4, Wn = /* @__PURE__ */ new Set(["edit", "save", "preview", "revisions", "revision"]), or = (e, r) => {
|
|
597
598
|
const t = Vn.has(r) ? ["POST"] : ["GET", "HEAD"];
|
|
598
|
-
return t.includes(e.method.toUpperCase()) ? null :
|
|
599
|
-
},
|
|
599
|
+
return t.includes(e.method.toUpperCase()) ? null : S(405, JSON.stringify({ failure: { reason: "invalid" } }), void 0, { Allow: t.join(", ") });
|
|
600
|
+
}, ar = (e) => e.headers.get(ce) === St && ke(e, Te) === void 0, Yn = (e) => e.headers.get(ce) === It && ke(e, Te) === void 0, Jn = (e) => e.headers.get(ce) === Pt && ke(e, Te) === void 0, Kn = async (e, r) => {
|
|
600
601
|
const [t, ...o] = (e.headers.get("Content-Type") ?? "").split(";").map((E) => E.trim().toLowerCase()), c = o.find((E) => E.startsWith("charset="));
|
|
601
|
-
if (t !==
|
|
602
|
+
if (t !== Nt || c !== void 0 && c !== "charset=utf-8") return { status: "error", failure: { reason: "invalid" } };
|
|
602
603
|
const u = Number(e.headers.get("Content-Length") ?? "0");
|
|
603
604
|
if (Number.isFinite(u) && u > r) return { status: "error", failure: { reason: "too-large" } };
|
|
604
605
|
if (e.body === null) return { status: "ok", text: "" };
|
|
605
606
|
const f = e.body.getReader(), p = [];
|
|
606
607
|
let h = 0;
|
|
607
608
|
for (; ; ) {
|
|
608
|
-
const { done: E, value:
|
|
609
|
+
const { done: E, value: O } = await f.read();
|
|
609
610
|
if (E) break;
|
|
610
|
-
if (h +=
|
|
611
|
+
if (h += O.byteLength, h > r)
|
|
611
612
|
return await f.cancel(), { status: "error", failure: { reason: "too-large" } };
|
|
612
|
-
p.push(
|
|
613
|
+
p.push(O);
|
|
613
614
|
}
|
|
614
615
|
const T = new Uint8Array(h);
|
|
615
616
|
let m = 0;
|
|
@@ -626,42 +627,42 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
626
627
|
if (e === void 0) return;
|
|
627
628
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] edit must be an object of the editor's ports");
|
|
628
629
|
const r = e;
|
|
629
|
-
for (const t of ["source", "save", "preview", "revisions", "revision"])
|
|
630
|
+
for (const t of ["source", "save", "preview", "revisions", "revision"]) I(`edit.${t}`, r[t], !1);
|
|
630
631
|
return e;
|
|
631
632
|
}, Zn = (e, r) => {
|
|
632
633
|
if (e.documentIds === null != (r === void 0)) throw new TypeError("[markdown-explorer] documentIds in defineExplorerConfig and the server's documentIds ports go together; give both or neither");
|
|
633
634
|
if (r === void 0) return;
|
|
634
635
|
if (r === null || typeof r != "object") throw new TypeError("[markdown-explorer] documentIds must be an object of the registry's ports");
|
|
635
636
|
const t = r;
|
|
636
|
-
for (const o of ["issue", "resolve"])
|
|
637
|
+
for (const o of ["issue", "resolve"]) I(`documentIds.${o}`, t[o], !1);
|
|
637
638
|
return r;
|
|
638
639
|
}, qn = (e) => {
|
|
639
640
|
if (e === null || typeof e != "object") return null;
|
|
640
641
|
const { kind: r, id: t } = e;
|
|
641
|
-
return r === "issued" || r === "taken" ? { kind: r } : r === "existing" &&
|
|
642
|
+
return r === "issued" || r === "taken" ? { kind: r } : r === "existing" && pr(t) ? { kind: r, id: t } : null;
|
|
642
643
|
}, es = (e) => {
|
|
643
644
|
if (e === null || typeof e != "object") return;
|
|
644
645
|
const { kind: r, path: t } = e;
|
|
645
|
-
return r === "unbound" ? null : r === "bound" && typeof t == "string" &&
|
|
646
|
-
},
|
|
646
|
+
return r === "unbound" ? null : r === "bound" && typeof t == "string" && dr(t) ? t : void 0;
|
|
647
|
+
}, ir = (e, r) => e.status === "ok" ? S(200, JSON.stringify(e), r) : R(e.failure, r), rs = ({ parentHeaders: e, loaderHeaders: r, errorHeaders: t }) => {
|
|
647
648
|
const o = new Headers(), c = t === void 0 ? [e, r] : [e, r, t];
|
|
648
649
|
for (const u of c)
|
|
649
650
|
for (const [f, p] of u)
|
|
650
651
|
f !== "set-cookie" && o.set(f, p);
|
|
651
652
|
return o;
|
|
652
|
-
},
|
|
653
|
+
}, ls = (e, r) => {
|
|
653
654
|
if (e === null || typeof e != "object") throw new TypeError("[markdown-explorer] the server configuration must be an object");
|
|
654
|
-
const t =
|
|
655
|
-
|
|
656
|
-
const c =
|
|
655
|
+
const t = Mn(e.config), o = r.prepareScope();
|
|
656
|
+
I("authenticate", e.authenticate, !1), I("principalKey", e.principalKey, !1), I("document", e.document, !1), I("asset", e.asset, !1), I("signedOutPage", e.signedOutPage, !1), I("notices", e.notices, !0), I("onTreeRefreshed", e.onTreeRefreshed, !0), I("readSettings", e.readSettings, !1);
|
|
657
|
+
const c = zn(e.sources), u = nt(
|
|
657
658
|
t,
|
|
658
659
|
c.map((n) => n.id)
|
|
659
660
|
), f = e.logger;
|
|
660
661
|
if (f !== void 0 && (f === null || typeof f != "object" || typeof f.error != "function"))
|
|
661
662
|
throw new TypeError("[markdown-explorer] logger must be an object with an error function");
|
|
662
|
-
const p = e.logger === void 0 ?
|
|
663
|
+
const p = e.logger === void 0 ? sn : e.logger, h = xt(e.deny), T = e.deferredTimeoutMs === void 0 ? Pn : G("deferredTimeoutMs", e.deferredTimeoutMs, Ct), m = e.textMaxBytes === void 0 ? Ke : G("textMaxBytes", e.textMaxBytes, Qe), b = Qn(e.edit);
|
|
663
664
|
if (b === void 0 && e.editMaxBytes !== void 0) throw new TypeError("[markdown-explorer] editMaxBytes needs the edit ports");
|
|
664
|
-
const E = e.editMaxBytes === void 0 ? Ke : G("editMaxBytes", e.editMaxBytes, Qe),
|
|
665
|
+
const E = e.editMaxBytes === void 0 ? Ke : G("editMaxBytes", e.editMaxBytes, Qe), O = Zn(t, e.documentIds), P = Fn(e.treeCache), U = () => Date.now(), H = P === !1 ? pn(U) : fn({ ...P, now: U }), z = r.createSanitizer({ options: e.sanitizer, maxPanels: t.multiView.maxPanels, iframeHosts: t.iframeHosts, dataPath: t.dataPath, ownUrls: st(t) }), X = e.readSettings, N = e.assetMaxRangeBytes === null ? null : G("assetMaxRangeBytes", e.assetMaxRangeBytes, Number.MAX_SAFE_INTEGER), j = new Map(c.map((n) => [n.id, n])), de = ot(t), { authenticate: K, principalKey: xe, signedOutPage: Ir, onTreeRefreshed: Ae } = e, Pr = (n, a) => {
|
|
665
666
|
if (typeof n.label == "string") return n.label;
|
|
666
667
|
const s = n.label(a);
|
|
667
668
|
if (typeof s != "string" || s.trim() === "") throw new TypeError(`[markdown-explorer] the label of source ${x(n.id)} must be a non-blank string`);
|
|
@@ -687,7 +688,7 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
687
688
|
const l = (k) => ($(p, { operation: "boundary", sourceId: n.id, path: s, error: new TypeError(`[markdown-explorer] boundary.confirm of source ${x(n.id)} ${k}`) }), { status: "outside" });
|
|
688
689
|
if (d === null || typeof d != "object") return l(`must resolve to { inside, readPath? }; got ${d === null ? "null" : typeof d}`);
|
|
689
690
|
const { inside: w, readPath: y } = d;
|
|
690
|
-
return w === !1 ? { status: "outside" } : w !== !0 || typeof y != "string" ? l("must resolve to { inside: false } or { inside: true, readPath: string }") : !
|
|
691
|
+
return w === !1 ? { status: "outside" } : w !== !0 || typeof y != "string" ? l("must resolve to { inside: false } or { inside: true, readPath: string }") : !F(y) || h.deniesPath(y) ? ($(p, { operation: "boundary", sourceId: n.id, path: s, error: new RangeError(`[markdown-explorer] boundary.confirm of source ${x(n.id)} answered a readPath the explorer does not serve (unacceptable or denied)`) }), { status: "error", failure: { reason: "failed" } }) : { status: "inside", readPath: y };
|
|
691
692
|
}, J = async (n, a) => {
|
|
692
693
|
const s = c.filter((l) => Y(l, a));
|
|
693
694
|
if (s.length === 0) return { status: "error", failure: { reason: "forbidden" } };
|
|
@@ -700,7 +701,7 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
700
701
|
w.status === "error" && d === null && (d = w.failure);
|
|
701
702
|
}
|
|
702
703
|
return { status: "error", failure: d === null ? { reason: "forbidden" } : d };
|
|
703
|
-
},
|
|
704
|
+
}, Se = async (n, a, s) => {
|
|
704
705
|
try {
|
|
705
706
|
return Ze(await e.asset(n, a, s, { delivery: "file" })), null;
|
|
706
707
|
} catch (i) {
|
|
@@ -721,17 +722,17 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
721
722
|
return Z(p, { operation: "resolve-id", path: d }), { status: "error", failure: { reason: "forbidden" } };
|
|
722
723
|
const l = await J(a, d);
|
|
723
724
|
if (l.status === "error") return l;
|
|
724
|
-
const w = await
|
|
725
|
+
const w = await Se(a, d, l.readPath);
|
|
725
726
|
return w !== null ? { status: "error", failure: w } : { status: "resolved", path: d, sourceId: l.sourceId };
|
|
726
|
-
},
|
|
727
|
+
}, _r = async (n, a, s) => {
|
|
727
728
|
if (h.deniesPath(s))
|
|
728
729
|
return Z(p, { operation: "issue-id", path: s }), { status: "error", failure: { reason: "forbidden" } };
|
|
729
730
|
const i = await J(a, s);
|
|
730
731
|
if (i.status === "error") return i;
|
|
731
|
-
const d = await
|
|
732
|
+
const d = await Se(a, s, i.readPath);
|
|
732
733
|
if (d !== null) return { status: "error", failure: d };
|
|
733
|
-
for (let l = 0; l <
|
|
734
|
-
const w =
|
|
734
|
+
for (let l = 0; l < sr; l += 1) {
|
|
735
|
+
const w = $t((_) => crypto.getRandomValues(_));
|
|
735
736
|
let y;
|
|
736
737
|
try {
|
|
737
738
|
y = await n.issue(a, s, w);
|
|
@@ -744,32 +745,32 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
744
745
|
if (k.kind === "issued") return { status: "ok", id: w };
|
|
745
746
|
if (k.kind === "existing") return { status: "ok", id: k.id };
|
|
746
747
|
}
|
|
747
|
-
return $(p, { operation: "issue-id", path: s, error: new Error(`[markdown-explorer] documentIds.issue answered taken for ${String(
|
|
748
|
-
},
|
|
749
|
-
const i = ({ path: d, reason: l }) =>
|
|
748
|
+
return $(p, { operation: "issue-id", path: s, error: new Error(`[markdown-explorer] documentIds.issue answered taken for ${String(sr)} candidates in a row`) }), { status: "error", failure: { reason: "failed" } };
|
|
749
|
+
}, Pe = (n, a, s) => {
|
|
750
|
+
const i = ({ path: d, reason: l }) => cn(p, { operation: s.operation, sourceId: s.sourceId, path: d, error: new TypeError(`[markdown-explorer] an entry with ${l} was left out`) });
|
|
750
751
|
try {
|
|
751
|
-
return { status: "ok", entries:
|
|
752
|
+
return { status: "ok", entries: mn(n, h, a.children !== void 0, i, (d) => Y(a, d)) };
|
|
752
753
|
} catch (d) {
|
|
753
754
|
return $(p, { ...s, error: d }), { status: "error", failure: { reason: "failed" } };
|
|
754
755
|
}
|
|
755
|
-
},
|
|
756
|
+
}, Dr = async (n, a, s) => {
|
|
756
757
|
let i;
|
|
757
758
|
try {
|
|
758
759
|
i = await n.tree(a);
|
|
759
760
|
} catch (l) {
|
|
760
761
|
return { status: "error", failure: v(l, { operation: "tree", sourceId: n.id }, a.signal, p) };
|
|
761
762
|
}
|
|
762
|
-
const d =
|
|
763
|
+
const d = Pe(i, n, { operation: "tree", sourceId: n.id });
|
|
763
764
|
return d.status === "ok" ? { status: "ok", entries: d.entries, loadedAt: s } : d;
|
|
764
|
-
},
|
|
765
|
-
if (
|
|
765
|
+
}, _e = (n, a, s, i) => (d, l) => Dr(n, { principal: a, request: s, signal: d, refresh: i }, l), De = (n, a, s, i, d) => H.load(ue(n, s), d, _e(n, a, i, !1)), $r = (n, a, s, i) => H.refresh(ue(n, s), i.signal, _e(n, a, i, !0)), Nr = (n, a) => {
|
|
766
|
+
if (Ae === void 0) return;
|
|
766
767
|
const s = (i) => $(p, { operation: "refresh", sourceId: n.id, error: i });
|
|
767
768
|
try {
|
|
768
|
-
Je(
|
|
769
|
+
Je(Ae(a), s);
|
|
769
770
|
} catch (i) {
|
|
770
771
|
s(i);
|
|
771
772
|
}
|
|
772
|
-
},
|
|
773
|
+
}, Lr = async (n, a, s, i) => {
|
|
773
774
|
if (h.deniesPath(i) || !Y(n, i)) return { status: "error", failure: { reason: "forbidden" } };
|
|
774
775
|
const d = await le(n, s, i);
|
|
775
776
|
if (d.status === "outside") return { status: "error", failure: { reason: "forbidden" } };
|
|
@@ -780,8 +781,8 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
780
781
|
} catch (w) {
|
|
781
782
|
return { status: "error", failure: v(w, { operation: "children", sourceId: n.id, path: i }, s.signal, p) };
|
|
782
783
|
}
|
|
783
|
-
return
|
|
784
|
-
},
|
|
784
|
+
return Pe(l, n, { operation: "children", sourceId: n.id, path: i });
|
|
785
|
+
}, $e = async (n, a, s, i) => {
|
|
785
786
|
const d = await le(n, s, i);
|
|
786
787
|
if (d.status === "outside") return { status: "ok", ancestors: null };
|
|
787
788
|
if (d.status === "error") return { status: "error", failure: d.failure };
|
|
@@ -793,21 +794,21 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
793
794
|
}
|
|
794
795
|
if (Array.isArray(l) && l.length > t.revealDocument.maxDepth) return { status: "ok", ancestors: null };
|
|
795
796
|
try {
|
|
796
|
-
return { status: "ok", ancestors:
|
|
797
|
+
return { status: "ok", ancestors: wn(l, i, h, (w) => Y(n, w)) };
|
|
797
798
|
} catch (w) {
|
|
798
799
|
return $(p, { operation: "ancestors", sourceId: n.id, path: i, error: w }), { status: "error", failure: { reason: "failed" } };
|
|
799
800
|
}
|
|
800
|
-
},
|
|
801
|
+
}, jr = async (n, a, s, i) => h.deniesPath(i) ? { status: "error", failure: { reason: "forbidden" } } : Y(n, i) ? $e(n, a, s, i) : { status: "ok", ancestors: null }, Mr = async (n, a, s) => {
|
|
801
802
|
if (h.deniesPath(s)) return { status: "error", failure: { reason: "forbidden" } };
|
|
802
803
|
for (const i of [n, ...c.filter((d) => d !== n)]) {
|
|
803
804
|
if (a.signal.aborted) break;
|
|
804
805
|
const d = i.ancestors;
|
|
805
806
|
if (d === void 0 || !Y(i, s)) continue;
|
|
806
|
-
const l = await
|
|
807
|
+
const l = await $e(i, d, a, s);
|
|
807
808
|
if (l.status === "ok" && l.ancestors !== null) return { status: "ok", source: i.id, ancestors: l.ancestors };
|
|
808
809
|
}
|
|
809
|
-
return
|
|
810
|
-
},
|
|
810
|
+
return Dn;
|
|
811
|
+
}, Ne = async (n, a, s) => {
|
|
811
812
|
if (h.deniesPath(s)) return V("forbidden");
|
|
812
813
|
const i = await J(n, s);
|
|
813
814
|
if (i.status === "error") return { kind: "failure", failure: i.failure };
|
|
@@ -819,72 +820,72 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
819
820
|
}
|
|
820
821
|
let l;
|
|
821
822
|
try {
|
|
822
|
-
l =
|
|
823
|
+
l = En(d, (y) => He(t.dataPath, s, y), b !== void 0);
|
|
823
824
|
} catch (y) {
|
|
824
825
|
return $(p, { operation: "document", path: s, error: y }), V("failed");
|
|
825
826
|
}
|
|
826
827
|
if (l.kind !== "unsanitized-markdown") return l;
|
|
827
828
|
const w = await z(l.html, { scope: a, signal: n.signal });
|
|
828
829
|
return w.status === "sanitized" ? { kind: "markdown", name: l.name, htmlContent: w.html, headings: l.headings, lang: l.lang, edit: l.edit } : (w.cause !== null && $(p, { operation: "document", path: s, error: w.cause }), V(w.reason));
|
|
829
|
-
},
|
|
830
|
-
if (e.notices === void 0) return
|
|
830
|
+
}, Cr = async (n) => {
|
|
831
|
+
if (e.notices === void 0) return we;
|
|
831
832
|
try {
|
|
832
833
|
return In(await e.notices(n));
|
|
833
834
|
} catch (a) {
|
|
834
|
-
return v(a, { operation: "notices" }, n.signal, p),
|
|
835
|
+
return v(a, { operation: "notices" }, n.signal, p), we;
|
|
835
836
|
}
|
|
836
|
-
},
|
|
837
|
+
}, Le = async (n, a, s, i) => {
|
|
837
838
|
const d = C(a, M.path);
|
|
838
|
-
if (d === null || !
|
|
839
|
-
const l =
|
|
840
|
-
if (l === null || !i.has(l)) return { status: "answered", response:
|
|
839
|
+
if (d === null || !F(d)) return { status: "answered", response: R({ reason: "invalid" }, s) };
|
|
840
|
+
const l = Dt(a);
|
|
841
|
+
if (l === null || !i.has(l)) return { status: "answered", response: R({ reason: "invalid" }, s) };
|
|
841
842
|
if (h.deniesPath(d))
|
|
842
|
-
return Z(p, { operation: "asset", path: d }), { status: "answered", response:
|
|
843
|
+
return Z(p, { operation: "asset", path: d }), { status: "answered", response: R({ reason: "forbidden" }, s) };
|
|
843
844
|
const w = await J(n, d);
|
|
844
|
-
if (w.status === "error") return { status: "answered", response:
|
|
845
|
+
if (w.status === "error") return { status: "answered", response: R(w.failure, s) };
|
|
845
846
|
try {
|
|
846
847
|
const y = await e.asset(n, d, w.readPath, { delivery: l }), k = l === "file" ? Ze(y) : Ee(y);
|
|
847
|
-
return "kind" in k ? { status: "answered", response:
|
|
848
|
+
return "kind" in k ? { status: "answered", response: nn(k.url, s) } : { status: "admitted", path: d, display: l, file: k };
|
|
848
849
|
} catch (y) {
|
|
849
|
-
return { status: "answered", response:
|
|
850
|
+
return { status: "answered", response: R(v(y, { operation: "asset", path: d }, n.signal, p), s) };
|
|
850
851
|
}
|
|
851
|
-
},
|
|
852
|
-
const i = await
|
|
852
|
+
}, zr = async (n, a, s) => {
|
|
853
|
+
const i = await Le(n, a, s, Nn);
|
|
853
854
|
if (i.status === "answered") return i.response;
|
|
854
855
|
const { path: d, display: l, file: w } = i;
|
|
855
856
|
try {
|
|
856
|
-
return l === "text" ? await
|
|
857
|
+
return l === "text" ? await qt(n.request, w, s, t.legacyTextEncoding, N) : l === "workbook" ? await rn(n.request, w, s) : await Kt(n.request, w, s, N);
|
|
857
858
|
} catch (y) {
|
|
858
|
-
return
|
|
859
|
+
return R(v(y, { operation: "asset", path: d }, n.signal, p), s);
|
|
859
860
|
}
|
|
860
|
-
},
|
|
861
|
-
const i =
|
|
862
|
-
return i.kind === "respond" ? i : be(i.selection, await
|
|
863
|
-
},
|
|
864
|
-
const i = await
|
|
861
|
+
}, Fr = async (n, a, s) => {
|
|
862
|
+
const i = Or(n, a, s, t.legacyTextEncoding, N);
|
|
863
|
+
return i.kind === "respond" ? i : be(i.selection, await Rr(a, t.legacyTextEncoding));
|
|
864
|
+
}, Ur = async (n, a, s) => {
|
|
865
|
+
const i = await Le(n, a, s, Ln);
|
|
865
866
|
if (i.status === "answered") return { kind: "response", response: i.response };
|
|
866
|
-
const { path: d, display: l, file: w } = i, y = (D) =>
|
|
867
|
+
const { path: d, display: l, file: w } = i, y = (D) => R(v(D, { operation: "asset", path: d }, n.signal, p), s);
|
|
867
868
|
let k;
|
|
868
869
|
try {
|
|
869
|
-
k = l === "text" ? await
|
|
870
|
+
k = l === "text" ? await Fr(n.request, w, s) : kr(n.request, w, s, N);
|
|
870
871
|
} catch (D) {
|
|
871
872
|
return { kind: "response", response: y(D) };
|
|
872
873
|
}
|
|
873
874
|
if (k.kind === "respond") return { kind: "response", response: k.response };
|
|
874
875
|
const { bridge: _ } = w;
|
|
875
|
-
return _ === void 0 ? ($(p, { operation: "asset", path: d, error: new TypeError("[markdown-explorer] the asset port must attach a bridge to a file the host streams itself") }), { kind: "response", response:
|
|
876
|
-
},
|
|
876
|
+
return _ === void 0 ? ($(p, { operation: "asset", path: d, error: new TypeError("[markdown-explorer] the asset port must attach a bridge to a file the host streams itself") }), { kind: "response", response: R({ reason: "failed" }, s) }) : { kind: "file", status: k.status, headers: k.headers, bridge: { uri: _.uri, storageVersion: _.storageVersion }, range: k.range, length: k.length, fail: (D) => y(Hn(_.readFailure, D)) };
|
|
877
|
+
}, Hr = async (n, a) => {
|
|
877
878
|
if (h.deniesPath(a))
|
|
878
879
|
return Z(p, { operation: "text", path: a }), V("forbidden");
|
|
879
880
|
const s = await J(n, a);
|
|
880
881
|
if (s.status === "error") return { kind: "failure", failure: s.failure };
|
|
881
882
|
try {
|
|
882
|
-
const i = Ee(await e.asset(n, a, s.readPath, { delivery: "text" })), d = await
|
|
883
|
+
const i = Ee(await e.asset(n, a, s.readPath, { delivery: "text" })), d = await un(i, m, t.legacyTextEncoding);
|
|
883
884
|
return d === null ? V("unsupported") : { kind: "text", name: i.name, text: d.text, truncated: d.truncated, url: He(t.dataPath, a, i.version) };
|
|
884
885
|
} catch (i) {
|
|
885
886
|
return { kind: "failure", failure: v(i, { operation: "text", path: a }, n.signal, p) };
|
|
886
887
|
}
|
|
887
|
-
}, Q = async (n, a, s) => h.deniesPath(s) ? (Z(p, { operation: a, path: s }), { status: "error", failure: { reason: "forbidden" } }) : J(n, s),
|
|
888
|
+
}, Q = async (n, a, s) => h.deniesPath(s) ? (Z(p, { operation: a, path: s }), { status: "error", failure: { reason: "forbidden" } }) : J(n, s), Xr = async (n, a, s) => {
|
|
888
889
|
const i = await Q(a, "edit", s);
|
|
889
890
|
if (i.status === "error") return { kind: "failure", failure: i.failure };
|
|
890
891
|
try {
|
|
@@ -892,184 +893,185 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
892
893
|
} catch (d) {
|
|
893
894
|
return { kind: "failure", failure: v(d, { operation: "edit", path: s }, a.signal, p) };
|
|
894
895
|
}
|
|
895
|
-
},
|
|
896
|
+
}, Br = async (n, a, s, i, d) => {
|
|
896
897
|
const l = await Q(a, "save", s);
|
|
897
898
|
if (l.status === "error") return { kind: "failure", failure: l.failure };
|
|
898
899
|
try {
|
|
899
|
-
return
|
|
900
|
+
return On(await n.save(a, s, l.readPath, { text: d, baseVersion: i }), E);
|
|
900
901
|
} catch (w) {
|
|
901
902
|
return { kind: "failure", failure: v(w, { operation: "save", path: s }, a.signal, p) };
|
|
902
903
|
}
|
|
903
|
-
},
|
|
904
|
+
}, Vr = async (n, a, s, i, d) => {
|
|
904
905
|
const l = await Q(a, "preview", i);
|
|
905
906
|
if (l.status === "error") return { kind: "failure", failure: l.failure };
|
|
906
907
|
let w;
|
|
907
908
|
try {
|
|
908
|
-
w =
|
|
909
|
+
w = vn(await n.preview(a, i, l.readPath, d));
|
|
909
910
|
} catch (k) {
|
|
910
911
|
return { kind: "failure", failure: v(k, { operation: "preview", path: i }, a.signal, p) };
|
|
911
912
|
}
|
|
912
913
|
if ("kind" in w) return w.kind === "failure" ? w : V("failed");
|
|
913
914
|
const y = await z(w.html, { scope: s, signal: a.signal });
|
|
914
915
|
return y.status === "sanitized" ? { kind: "preview", htmlContent: y.html, headings: w.headings } : (y.cause !== null && $(p, { operation: "preview", path: i, error: y.cause }), V(y.reason));
|
|
915
|
-
},
|
|
916
|
+
}, Gr = async (n, a, s) => {
|
|
916
917
|
const i = await Q(a, "revisions", s);
|
|
917
918
|
if (i.status === "error") return { kind: "failure", failure: i.failure };
|
|
918
919
|
try {
|
|
919
|
-
return { kind: "revisions", revisions:
|
|
920
|
+
return { kind: "revisions", revisions: xn(await n.revisions(a, s, i.readPath)) };
|
|
920
921
|
} catch (d) {
|
|
921
922
|
return { kind: "failure", failure: v(d, { operation: "revisions", path: s }, a.signal, p) };
|
|
922
923
|
}
|
|
923
|
-
},
|
|
924
|
+
}, Wr = async (n, a, s, i) => {
|
|
924
925
|
const d = await Q(a, "revision", s);
|
|
925
926
|
if (d.status === "error") return { kind: "failure", failure: d.failure };
|
|
926
927
|
try {
|
|
927
|
-
return { kind: "revision", id: i, text:
|
|
928
|
+
return { kind: "revision", id: i, text: An(await n.revision(a, s, d.readPath, i), E) };
|
|
928
929
|
} catch (l) {
|
|
929
930
|
return { kind: "failure", failure: v(l, { operation: "revision", path: s }, a.signal, p) };
|
|
930
931
|
}
|
|
931
|
-
},
|
|
932
|
+
}, Yr = async (n, a, s, i, d, l) => {
|
|
932
933
|
const w = C(d, M.path);
|
|
933
|
-
if (w === null || !
|
|
934
|
-
if (a === "edit") return
|
|
935
|
-
if (a === "revisions") return
|
|
934
|
+
if (w === null || !F(w)) return R({ reason: "invalid" }, l);
|
|
935
|
+
if (a === "edit") return S(200, JSON.stringify(await Xr(n, s, w)), l);
|
|
936
|
+
if (a === "revisions") return S(200, JSON.stringify(await Gr(n, s, w)), l);
|
|
936
937
|
if (a === "revision") {
|
|
937
938
|
const _ = C(d, M.revision);
|
|
938
|
-
return ee(_) ?
|
|
939
|
+
return ee(_) ? S(200, JSON.stringify(await Wr(n, s, w, _)), l) : R({ reason: "invalid" }, l);
|
|
939
940
|
}
|
|
940
941
|
const y = C(d, M.base);
|
|
941
|
-
if (a === "save" && !ee(y)) return
|
|
942
|
+
if (a === "save" && !ee(y)) return R({ reason: "invalid" }, l);
|
|
942
943
|
const k = await Kn(s.request, E);
|
|
943
|
-
return k.status === "error" ?
|
|
944
|
-
},
|
|
945
|
-
const i =
|
|
946
|
-
if (
|
|
947
|
-
|
|
948
|
-
|
|
944
|
+
return k.status === "error" ? R(k.failure, l) : a === "preview" ? S(200, JSON.stringify(await Vr(n, s, i, w, k.text)), l) : S(200, JSON.stringify(await Br(n, s, w, y, k.text)), l);
|
|
945
|
+
}, Jr = async ({ request: n, url: a, params: s }) => {
|
|
946
|
+
const i = tr(await K(n, er));
|
|
947
|
+
if (i.status === "forbidden") throw rt("forbidden", { headers: me(i.headers) });
|
|
948
|
+
const d = me(i.headers);
|
|
949
|
+
if (d.set("Cache-Control", Sr), i.status === "signed-out") throw Un("signedOutPage", Ir({ request: n, url: a }, d));
|
|
950
|
+
const l = ct(u, s["*"], a.searchParams);
|
|
949
951
|
if (l.kind === "redirect") throw Fe(l.href, { headers: d });
|
|
950
|
-
const { principal: w } = i, y =
|
|
952
|
+
const { principal: w } = i, y = nr(o, xe(w));
|
|
951
953
|
if (l.kind === "document-id") {
|
|
952
|
-
if (
|
|
953
|
-
const k = l.id === null ?
|
|
954
|
-
if (k.status === "resolved") throw Fe(
|
|
955
|
-
return
|
|
954
|
+
if (O === void 0) throw new TypeError("[markdown-explorer] an ID URL was resolved without the documentIds ports");
|
|
955
|
+
const k = l.id === null ? jn : await Ie(O, { principal: w, request: n, signal: n.signal, refresh: !1 }, l.id);
|
|
956
|
+
if (k.status === "resolved") throw Fe(Kr(l.opens, k), { headers: d });
|
|
957
|
+
return Ue(je(w, y, n, l.location, { id: l.id, failure: k.failure }), { status: fr[k.failure.reason], headers: d });
|
|
956
958
|
}
|
|
957
|
-
return
|
|
958
|
-
},
|
|
959
|
+
return Ue(je(w, y, n, l.location, null), { headers: d });
|
|
960
|
+
}, Kr = (n, a) => dt(u, ut(n, a.path, a.sourceId)), je = (n, a, s, i, d) => {
|
|
959
961
|
const l = j.get(i.source);
|
|
960
962
|
if (l === void 0) throw new RangeError(`[markdown-explorer] no source for ${x(i.source)}`);
|
|
961
963
|
const w = { signal: s.signal, timeoutMs: T, late: null, handOverMs: T };
|
|
962
964
|
return {
|
|
963
965
|
scope: a,
|
|
964
|
-
sources: c.map((y) => ({ id: y.id, label:
|
|
965
|
-
settings:
|
|
966
|
+
sources: c.map((y) => ({ id: y.id, label: Pr(y, n) })),
|
|
967
|
+
settings: lt(Xn(X, s), de),
|
|
966
968
|
tree: i.view === "single" ? null : {
|
|
967
969
|
sourceId: i.source,
|
|
968
|
-
result:
|
|
970
|
+
result: pe(w, (y) => De(l, n, a, s, y).then((k) => k.result))
|
|
969
971
|
},
|
|
970
|
-
documents: Bn(i).map((y) => ({ path: y, document:
|
|
971
|
-
notices:
|
|
972
|
+
documents: Bn(i).map((y) => ({ path: y, document: pe(w, (k) => Ne({ principal: n, request: s, signal: k, refresh: !1 }, a, y)) })),
|
|
973
|
+
notices: pe({ signal: s.signal, timeoutMs: T, late: we, handOverMs: 0 }, (y) => Cr({ principal: n, request: s, signal: y, refresh: !1 })),
|
|
972
974
|
documentId: d
|
|
973
975
|
};
|
|
974
|
-
},
|
|
975
|
-
const s =
|
|
976
|
-
return { authentication: s, headers:
|
|
977
|
-
},
|
|
976
|
+
}, Me = async (n, a) => {
|
|
977
|
+
const s = tr(await K(n, a));
|
|
978
|
+
return { authentication: s, headers: me(s.headers) };
|
|
979
|
+
}, Ce = async (n) => {
|
|
978
980
|
let a;
|
|
979
981
|
try {
|
|
980
|
-
a = await
|
|
982
|
+
a = await Me(n, er);
|
|
981
983
|
} catch (d) {
|
|
982
|
-
return { status: "answered", response:
|
|
984
|
+
return { status: "answered", response: R(v(rr(d), { operation: "authenticate" }, n.signal, p)) };
|
|
983
985
|
}
|
|
984
986
|
const { authentication: s, headers: i } = a;
|
|
985
|
-
return s.status === "signed-out" ? { status: "answered", response:
|
|
986
|
-
},
|
|
987
|
-
const i = await
|
|
987
|
+
return s.status === "signed-out" ? { status: "answered", response: R({ reason: "unauthorized" }, i) } : s.status === "forbidden" ? { status: "answered", response: R({ reason: "forbidden" }, i) } : { status: "signed-in", principal: s.principal, headers: i };
|
|
988
|
+
}, Qr = async (n, a, s) => {
|
|
989
|
+
const i = await Ce(a);
|
|
988
990
|
if (i.status === "answered") return i.response;
|
|
989
991
|
const { principal: d, headers: l } = i;
|
|
990
|
-
if (n === "asset") return
|
|
991
|
-
const w =
|
|
992
|
-
l.set(
|
|
993
|
-
const y = { principal: d, request: a, signal: a.signal, refresh: !1 }, k = () =>
|
|
992
|
+
if (n === "asset") return zr({ principal: d, request: a, signal: a.signal, refresh: !1 }, s, l);
|
|
993
|
+
const w = nr(o, xe(d));
|
|
994
|
+
l.set(_t, w);
|
|
995
|
+
const y = { principal: d, request: a, signal: a.signal, refresh: !1 }, k = () => R({ reason: "invalid" }, l);
|
|
994
996
|
if (n === "document") {
|
|
995
997
|
const A = C(s, M.path);
|
|
996
|
-
if (A === null || !
|
|
998
|
+
if (A === null || !F(A)) return k();
|
|
997
999
|
const B = a.headers.has(ce);
|
|
998
|
-
return B && !
|
|
1000
|
+
return B && !ar(a) ? R({ reason: "forbidden" }, l) : S(200, JSON.stringify(await Ne({ ...y, refresh: B }, w, A)), l);
|
|
999
1001
|
}
|
|
1000
1002
|
if (n === "text") {
|
|
1001
1003
|
const A = C(s, M.path);
|
|
1002
|
-
return A === null || !
|
|
1004
|
+
return A === null || !F(A) ? k() : S(200, JSON.stringify(await Hr(y, A)), l);
|
|
1003
1005
|
}
|
|
1004
1006
|
if (n === "edit" || n === "save" || n === "preview" || n === "revisions" || n === "revision")
|
|
1005
|
-
return b === void 0 ?
|
|
1007
|
+
return b === void 0 ? R({ reason: "not-found" }, l) : Yr(b, n, y, w, s, l);
|
|
1006
1008
|
if (n === "issue-id") {
|
|
1007
|
-
if (
|
|
1009
|
+
if (O === void 0) return R({ reason: "not-found" }, l);
|
|
1008
1010
|
const A = C(s, M.path);
|
|
1009
|
-
return A === null || !
|
|
1011
|
+
return A === null || !dr(A) ? k() : ir(await _r(O, y, A), l);
|
|
1010
1012
|
}
|
|
1011
1013
|
if (n === "resolve-id") {
|
|
1012
|
-
if (
|
|
1014
|
+
if (O === void 0) return R({ reason: "not-found" }, l);
|
|
1013
1015
|
const A = C(s, M.id);
|
|
1014
|
-
if (A === null || !
|
|
1015
|
-
const B = await Ie(
|
|
1016
|
-
return
|
|
1016
|
+
if (A === null || !pr(A)) return k();
|
|
1017
|
+
const B = await Ie(O, y, A);
|
|
1018
|
+
return ir(B.status === "resolved" ? { status: "ok", path: B.path, source: B.sourceId } : B, l);
|
|
1017
1019
|
}
|
|
1018
1020
|
const _ = C(s, M.source), D = C(s, M.path);
|
|
1019
|
-
if (_ === null || (n === "children" || n === "ancestors" || n === "reveal") && (D === null || !
|
|
1021
|
+
if (_ === null || (n === "children" || n === "ancestors" || n === "reveal") && (D === null || !F(D))) return k();
|
|
1020
1022
|
const L = j.get(_);
|
|
1021
|
-
if (L === void 0) return
|
|
1022
|
-
if (n === "tree") return
|
|
1023
|
+
if (L === void 0) return R({ reason: "not-found" }, l);
|
|
1024
|
+
if (n === "tree") return S(200, (await De(L, d, w, a, a.signal)).json, l);
|
|
1023
1025
|
if (n === "refresh") {
|
|
1024
|
-
const A = await
|
|
1025
|
-
return a.signal.aborted ||
|
|
1026
|
+
const A = await $r(L, d, w, a);
|
|
1027
|
+
return a.signal.aborted || Nr(L, ue(L, w)), S(200, A.json, l);
|
|
1026
1028
|
}
|
|
1027
|
-
return n === "ancestors" ? L.ancestors === void 0 || D === null ?
|
|
1028
|
-
},
|
|
1029
|
-
const { authentication: a, headers: s } = await
|
|
1029
|
+
return n === "ancestors" ? L.ancestors === void 0 || D === null ? R({ reason: "not-found" }, l) : S(200, JSON.stringify(await jr(L, L.ancestors, y, D)), l) : n === "reveal" ? D === null ? k() : S(200, JSON.stringify(await Mr(L, y, D)), l) : L.children === void 0 || D === null ? R({ reason: "not-found" }, l) : S(200, JSON.stringify(await Lr(L, L.children, y, D)), l);
|
|
1030
|
+
}, Zr = async (n) => {
|
|
1031
|
+
const { authentication: a, headers: s } = await Me(n, $n);
|
|
1030
1032
|
if (!s.keys().next().done) throw new TypeError("[markdown-explorer] authenticate returned headers in read-only mode; a read-only authentication must only read the session (none was forwarded)");
|
|
1031
1033
|
return a.status === "signed-in";
|
|
1032
|
-
},
|
|
1034
|
+
}, ze = t.embeds.linkCardEndpoint === null ? null : r.createLinkCardHandler({ authorize: Zr }), qr = async (n, a) => {
|
|
1033
1035
|
try {
|
|
1034
1036
|
return await n(a);
|
|
1035
1037
|
} catch (s) {
|
|
1036
|
-
return
|
|
1038
|
+
return R(v(rr(s), { operation: "authenticate" }, a.signal, p));
|
|
1037
1039
|
}
|
|
1038
1040
|
}, fe = async (n, a, s) => {
|
|
1039
|
-
if (new URL(n.url).pathname.endsWith(".data")) return
|
|
1040
|
-
if (!
|
|
1041
|
+
if (new URL(n.url).pathname.endsWith(".data")) return R({ reason: "not-found" });
|
|
1042
|
+
if (!At(s)) return R({ reason: "not-found" });
|
|
1041
1043
|
if (s === "link-card") {
|
|
1042
|
-
if (
|
|
1043
|
-
const d =
|
|
1044
|
-
return d !== null ? d :
|
|
1044
|
+
if (ze === null) return R({ reason: "not-found" });
|
|
1045
|
+
const d = or(n, s);
|
|
1046
|
+
return d !== null ? d : qr(ze, n);
|
|
1045
1047
|
}
|
|
1046
|
-
if (Wn.has(s) && b === void 0) return
|
|
1047
|
-
if (Gn.has(s) &&
|
|
1048
|
-
const i =
|
|
1048
|
+
if (Wn.has(s) && b === void 0) return R({ reason: "not-found" });
|
|
1049
|
+
if (Gn.has(s) && O === void 0) return R({ reason: "not-found" });
|
|
1050
|
+
const i = or(n, s);
|
|
1049
1051
|
if (i !== null) return i;
|
|
1050
|
-
if (s === "refresh" && !
|
|
1051
|
-
if ((s === "save" || s === "preview") && !Yn(n)) return
|
|
1052
|
-
if (s === "issue-id" && !Jn(n)) return
|
|
1052
|
+
if (s === "refresh" && !ar(n)) return R({ reason: "forbidden" });
|
|
1053
|
+
if ((s === "save" || s === "preview") && !Yn(n)) return R({ reason: "forbidden" });
|
|
1054
|
+
if (s === "issue-id" && !Jn(n)) return R({ reason: "forbidden" });
|
|
1053
1055
|
try {
|
|
1054
|
-
return await
|
|
1056
|
+
return await Qr(s, n, a.searchParams);
|
|
1055
1057
|
} catch (d) {
|
|
1056
|
-
return
|
|
1058
|
+
return R(v(d, { operation: s }, n.signal, p));
|
|
1057
1059
|
}
|
|
1058
|
-
},
|
|
1060
|
+
}, et = async (n, a, s) => {
|
|
1059
1061
|
if (s !== "asset" || n.method.toUpperCase() !== "GET" || new URL(n.url).pathname.endsWith(".data")) return { kind: "response", response: await fe(n, a, s) };
|
|
1060
1062
|
try {
|
|
1061
|
-
const i = await
|
|
1062
|
-
return i.status === "answered" ? { kind: "response", response: i.response } : await
|
|
1063
|
+
const i = await Ce(n);
|
|
1064
|
+
return i.status === "answered" ? { kind: "response", response: i.response } : await Ur({ principal: i.principal, request: n, signal: n.signal, refresh: !1 }, a.searchParams, i.headers);
|
|
1063
1065
|
} catch (i) {
|
|
1064
|
-
return { kind: "response", response:
|
|
1066
|
+
return { kind: "response", response: R(v(i, { operation: "asset" }, n.signal, p)) };
|
|
1065
1067
|
}
|
|
1066
1068
|
};
|
|
1067
1069
|
return Object.freeze({
|
|
1068
|
-
loader:
|
|
1070
|
+
loader: Jr,
|
|
1069
1071
|
headers: rs,
|
|
1070
1072
|
dataLoader: ({ request: n, url: a, params: s }) => fe(n, a, s["*"]),
|
|
1071
1073
|
dataAction: ({ request: n, url: a, params: s }) => fe(n, a, s["*"]),
|
|
1072
|
-
planData: ({ request: n, url: a, params: s }) =>
|
|
1074
|
+
planData: ({ request: n, url: a, params: s }) => et(n, a, s["*"]),
|
|
1073
1075
|
forgetTree: (n) => {
|
|
1074
1076
|
if (typeof n != "string") throw new TypeError(`[markdown-explorer] forgetTree needs the string key onTreeRefreshed received; got ${x(n)}`);
|
|
1075
1077
|
H.forget(n);
|
|
@@ -1078,6 +1080,6 @@ const an = (e) => e instanceof Error && Object.hasOwn(e, Ar) && fr(e.reason), cn
|
|
|
1078
1080
|
};
|
|
1079
1081
|
export {
|
|
1080
1082
|
ye as A,
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
+
us as E,
|
|
1084
|
+
ls as c
|
|
1083
1085
|
};
|