@aiquants/markdown-explorer 0.33.0 → 0.35.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 +795 -0
- package/README.md +119 -55
- package/dist/EditSurface-CLG70Vnn.cjs +6 -0
- package/dist/EditSurface-D2j1kCEE.js +990 -0
- package/dist/ExplorerSplit-CfP1smbT.js +1589 -0
- package/dist/ExplorerSplit-D_0VohOv.cjs +2 -0
- package/dist/{MultiLayout-DYNGlNy0.js → MultiLayout-BeJ5Lubb.js} +291 -290
- package/dist/MultiLayout-CxV5SI7f.cjs +1 -0
- package/dist/NativeScrollBar-BM5NULzg.js +62 -0
- package/dist/NativeScrollBar-RWXpVhbI.cjs +1 -0
- package/dist/TreeLayout-AxLw-36S.js +103 -0
- package/dist/TreeLayout-Bg2YH-EY.cjs +1 -0
- package/dist/client/MarkdownExplorer.d.cts +14 -1
- package/dist/client/MarkdownExplorer.d.ts +14 -1
- package/dist/client/edit/lineEndings.d.cts +4 -0
- package/dist/client/edit/lineEndings.d.ts +4 -0
- package/dist/client/hostContract.d.cts +67 -0
- package/dist/client/hostContract.d.ts +67 -0
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +10 -4
- package/dist/core/contracts.d.ts +10 -4
- package/dist/core/draftAnswer.d.cts +23 -0
- package/dist/core/draftAnswer.d.ts +23 -0
- package/dist/core/geometry.d.cts +1 -0
- package/dist/core/geometry.d.ts +1 -0
- package/dist/core/labels.d.cts +78 -0
- package/dist/core/labels.d.ts +78 -0
- package/dist/core/location.d.cts +3 -2
- package/dist/core/location.d.ts +3 -2
- package/dist/core/ownUrls.d.cts +15 -0
- package/dist/core/ownUrls.d.ts +15 -0
- package/dist/core/treeSettings.d.cts +3 -2
- package/dist/core/treeSettings.d.ts +3 -2
- package/dist/core/viewSettings.d.cts +5 -1
- package/dist/core/viewSettings.d.ts +5 -1
- package/dist/describeValue-CLlVRO8d.js +17 -0
- package/dist/describeValue-Ccvhbt36.cjs +1 -0
- package/dist/explorerCore-DLpDuSev.js +998 -0
- package/dist/explorerCore-DYrxS9ez.cjs +1 -0
- package/dist/index-C1YMH-yI.js +5816 -0
- package/dist/index-LQWQfpAf.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +47 -42
- package/dist/licenses/@heroicons/react/LICENSE +21 -0
- package/dist/licenses/entities/LICENSE +11 -0
- package/dist/licenses/parse5/LICENSE +19 -0
- package/dist/location--KvTA0Ri.js +726 -0
- package/dist/location-D8DyDkuA.cjs +1 -0
- package/dist/lru-DC8GBmkX.js +39 -0
- package/dist/lru-SGmUyBQU.cjs +1 -0
- package/dist/{merge-D7L_pINl.js → merge-Bb_HpPhe.js} +1 -1
- package/dist/{merge-DZI4pkWI.cjs → merge-DQUYEGCx.cjs} +1 -1
- package/dist/nestingGuardWorker.js +5511 -0
- package/dist/ownUrls-B259RGgd.cjs +1 -0
- package/dist/ownUrls-Dh5g6ZJi.js +370 -0
- package/dist/sanitizeJob-BYRk17nr.js +21 -0
- package/dist/sanitizeJob-Cs9o3Vpl.cjs +1 -0
- package/dist/sanitizePolicy-CEMdaLUB.js +139 -0
- package/dist/sanitizePolicy-CiQfnxyd.cjs +2 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +134 -139
- package/dist/sanitizerService-BY4CPCoA.cjs +1 -0
- package/dist/sanitizerService-KWXv7bPm.js +240 -0
- package/dist/server/assetResponse.d.cts +60 -0
- package/dist/server/assetResponse.d.ts +60 -0
- package/dist/server/browser/browserPlatform.d.cts +12 -0
- package/dist/server/browser/browserPlatform.d.ts +12 -0
- package/dist/server/createMarkdownExplorer.d.cts +0 -10
- package/dist/server/createMarkdownExplorer.d.ts +0 -10
- package/dist/server/explorerCore.d.cts +12 -0
- package/dist/server/explorerCore.d.ts +12 -0
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/inProcessFetch.d.cts +5 -0
- package/dist/server/inProcessFetch.d.ts +5 -0
- package/dist/server/platform.d.cts +18 -0
- package/dist/server/platform.d.ts +18 -0
- package/dist/server/ports.d.cts +36 -5
- package/dist/server/ports.d.ts +36 -5
- package/dist/server/sanitizeProtocol.d.cts +3 -0
- package/dist/server/sanitizeProtocol.d.ts +3 -0
- package/dist/server/sanitizer.d.cts +5 -40
- package/dist/server/sanitizer.d.ts +5 -40
- package/dist/server/sanitizerOptions.d.cts +24 -0
- package/dist/server/sanitizerOptions.d.ts +24 -0
- package/dist/server/sanitizerService.d.cts +41 -0
- package/dist/server/sanitizerService.d.ts +41 -0
- package/dist/server/{workerPool.d.cts → workerJobs.d.cts} +0 -16
- package/dist/server/{workerPool.d.ts → workerJobs.d.ts} +0 -16
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +270 -1343
- package/dist/serverBrowser.cjs +1 -0
- package/dist/serverBrowser.d.cts +1 -0
- package/dist/serverBrowser.d.ts +1 -0
- package/dist/serverBrowser.js +120 -0
- package/dist/serverCore.cjs +1 -0
- package/dist/serverCore.d.cts +14 -0
- package/dist/serverCore.d.ts +14 -0
- package/dist/serverCore.js +46 -0
- package/dist/storage-BpYsprog.cjs +1 -0
- package/dist/{storage-CmGHg7OA.js → storage-D1uSw-xj.js} +19 -18
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/tapScrollCircle-BEydRn0y.js +14 -0
- package/dist/tapScrollCircle-DdX0Wri0.cjs +1 -0
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +6 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +4 -0
- package/dist/useSplitPersistence-B2Fj508K.cjs +1 -0
- package/dist/useSplitPersistence-Fkqak8G8.js +44 -0
- package/docs/behavior/dom-hooks.md +14 -3
- package/docs/behavior/hosting.md +123 -0
- package/docs/behavior/layout.md +69 -19
- package/docs/behavior/localization.md +28 -10
- package/docs/behavior/security.md +34 -14
- package/docs/behavior/url-contract.md +13 -6
- package/package.json +54 -16
- package/dist/EditSurface-BPqqykro.cjs +0 -6
- package/dist/EditSurface-CWq35IWQ.js +0 -972
- package/dist/ExplorerSplit-BRY4uy6x.js +0 -1493
- package/dist/ExplorerSplit-CQxr6b0v.cjs +0 -1
- package/dist/MultiLayout-TXbet9k3.cjs +0 -1
- package/dist/NativeScrollBar-BsWdvkHa.js +0 -64
- package/dist/NativeScrollBar-UpjxjLlB.cjs +0 -1
- package/dist/TreeLayout-BQEgZhz9.js +0 -72
- package/dist/TreeLayout-C0O1OGi4.cjs +0 -1
- package/dist/dataRoute-DLhQfdoW.js +0 -298
- package/dist/dataRoute-DwYtgyt6.cjs +0 -1
- package/dist/index-CO-RgTml.js +0 -4912
- package/dist/index-DSkK8iLE.cjs +0 -15
- package/dist/location-BxiJRTyw.cjs +0 -1
- package/dist/location-perTmwct.js +0 -663
- package/dist/sanitizePolicy-By0tKOpZ.js +0 -98
- package/dist/sanitizePolicy-T5T-3vV5.cjs +0 -1
- package/dist/storage-DM0EvkVf.cjs +0 -1
- package/dist/tapScrollCircle-CRKZremf.js +0 -12
- package/dist/tapScrollCircle-Cbf17x8g.cjs +0 -1
- package/dist/useSplitPersistence-Du01PHNg.js +0 -42
- package/dist/useSplitPersistence-pPmE4GTT.cjs +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { i as Y, d as M } from "./describeValue-CLlVRO8d.js";
|
|
2
|
+
import { M as J, c as G } from "./lru-DC8GBmkX.js";
|
|
3
|
+
import { r as U } from "./ownUrls-Dh5g6ZJi.js";
|
|
4
|
+
const Z = (r) => Math.max(1, r - 1), B = 1024 * 1024, X = 3e4, V = 4 * B, W = 64 * B, q = 2 ** 29, K = 3, ee = (r, o) => r + Z(o) + K, te = 4, v = 512, re = 64, oe = 4096, ne = 32, D = 4096, se = (r, o) => Math.floor(((o - re) * B - r * ne) / oe), k = (r, o, d, u) => {
|
|
5
|
+
if (o === void 0) return d;
|
|
6
|
+
if (typeof o != "number") throw new TypeError(`[markdown-explorer] sanitizer.${r} must be a number; got ${M(o)}`);
|
|
7
|
+
if (!Number.isSafeInteger(o) || o <= 0 || o > u) throw new RangeError(`[markdown-explorer] sanitizer.${r} must be an integer in 1..${String(u)}; got ${M(o)}`);
|
|
8
|
+
return o;
|
|
9
|
+
}, ae = (r, o) => {
|
|
10
|
+
if (r.jobsPerScope < o)
|
|
11
|
+
throw new RangeError(`[markdown-explorer] sanitizer.jobsPerScope must be at least multiView.maxPanels (${String(o)}), because a page sends the document of every panel to the sanitizer at once for one reader; got ${M(r.jobsPerScope)}`);
|
|
12
|
+
if (r.maxQueuedJobs < o)
|
|
13
|
+
throw new RangeError(`[markdown-explorer] sanitizer.maxQueuedJobs must be at least multiView.maxPanels (${String(o)}), because a reader whose page finds every worker busy waits with the document of every panel; got ${M(r.maxQueuedJobs)}`);
|
|
14
|
+
}, ie = Object.freeze(["workers", "workerHeapMb"]), he = (r, o) => {
|
|
15
|
+
if (r !== void 0 && !Y(r)) throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }");
|
|
16
|
+
const d = r ?? {};
|
|
17
|
+
for (const T of ie)
|
|
18
|
+
if (d[T] !== void 0) throw new TypeError(`[markdown-explorer] sanitizer.${T} is an option of Node's worker threads; a browser runtime takes only { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }`);
|
|
19
|
+
const { deadlineMs: u, maxHtmlBytes: g, cacheBytes: w, jobsPerScope: f, maxQueuedJobs: S } = d, l = k("jobsPerScope", f, ee(o, 1), Number.MAX_SAFE_INTEGER), p = Object.freeze({
|
|
20
|
+
deadlineMs: k("deadlineMs", u, X, J),
|
|
21
|
+
maxHtmlBytes: k("maxHtmlBytes", g, V, q),
|
|
22
|
+
cacheBytes: k("cacheBytes", w, W, Number.MAX_SAFE_INTEGER),
|
|
23
|
+
jobsPerScope: l,
|
|
24
|
+
maxQueuedJobs: k("maxQueuedJobs", S, te * l, Number.MAX_SAFE_INTEGER)
|
|
25
|
+
});
|
|
26
|
+
if (ae(p, o), se(p.maxHtmlBytes, v) < D)
|
|
27
|
+
throw new RangeError(
|
|
28
|
+
`[markdown-explorer] sanitizer.maxHtmlBytes (${String(p.maxHtmlBytes)} bytes) must leave room for ${String(D)} parsed nodes in the node budget, which a browser runtime counts in a worker heap of ${String(v)} MiB; lower maxHtmlBytes`
|
|
29
|
+
);
|
|
30
|
+
return p;
|
|
31
|
+
}, C = Object.freeze({ status: "aborted" }), A = (r, o, d) => {
|
|
32
|
+
const u = (r.get(o) ?? 0) + d;
|
|
33
|
+
u === 0 ? r.delete(o) : r.set(o, u);
|
|
34
|
+
}, H = (r, o, d) => {
|
|
35
|
+
if (!Number.isSafeInteger(o) || o <= 0 || o > d) throw new RangeError(`[markdown-explorer] a worker pool's ${r} must be an integer in 1..${String(d)}; got ${M(o)}`);
|
|
36
|
+
}, ue = (r) => r !== null && typeof r == "object" && r.ready === !0 && !("id" in r), ce = (r, o) => r !== null && typeof r == "object" && r.id === o && "output" in r, Se = ({ start: r, size: o, deadlineMs: d, jobsPerScope: u, maxQueuedJobs: g }) => {
|
|
37
|
+
H("size", o, Number.MAX_SAFE_INTEGER), H("deadline", d, J), H("jobsPerScope", u, Number.MAX_SAFE_INTEGER), H("maxQueuedJobs", g, Number.MAX_SAFE_INTEGER);
|
|
38
|
+
const w = /* @__PURE__ */ new Set(), f = [], S = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), p = Z(o);
|
|
39
|
+
let T = 0;
|
|
40
|
+
const _ = (e, t) => {
|
|
41
|
+
const { job: n } = e;
|
|
42
|
+
e.timer !== null && clearTimeout(e.timer), e.timer = null, e.job = null, e.sent = !1, n !== null && (A(S, n.scope, -1), A(l, n.scope, -1), n.settle(t));
|
|
43
|
+
}, h = (e) => {
|
|
44
|
+
const [t] = f.splice(e, 1);
|
|
45
|
+
t?.detach();
|
|
46
|
+
}, I = () => {
|
|
47
|
+
let e = -1, t = p, n = Number.POSITIVE_INFINITY;
|
|
48
|
+
for (const [s, a] of f.entries()) {
|
|
49
|
+
const i = S.get(a.scope) ?? 0, c = l.get(a.scope) ?? 0;
|
|
50
|
+
(i < t || i === t && e >= 0 && c < n) && (e = s, t = i, n = c);
|
|
51
|
+
}
|
|
52
|
+
return e;
|
|
53
|
+
}, E = (e, t) => {
|
|
54
|
+
w.has(e) && (w.delete(e), _(e, t), e.worker.terminate().catch(() => {
|
|
55
|
+
}), x());
|
|
56
|
+
}, y = (e) => {
|
|
57
|
+
e.timer = setTimeout(() => {
|
|
58
|
+
E(e, { status: "timeout" });
|
|
59
|
+
}, d);
|
|
60
|
+
}, N = (e, t) => e.sent ? { status: "crashed", error: t } : { status: "unavailable", error: t }, R = (e, t) => {
|
|
61
|
+
e.sent = !0, y(e);
|
|
62
|
+
try {
|
|
63
|
+
e.worker.postMessage({ id: t.id, input: t.input });
|
|
64
|
+
} catch (n) {
|
|
65
|
+
_(e, { status: "crashed", error: n }), e.worker.unref();
|
|
66
|
+
}
|
|
67
|
+
}, L = () => {
|
|
68
|
+
const e = { worker: r(), job: null, sent: !1, timer: null, ready: !1 };
|
|
69
|
+
return e.worker.unref(), e.timer = setTimeout(() => {
|
|
70
|
+
E(e, { status: "unavailable", error: new Error(`[markdown-explorer] a worker did not start within ${String(d)} ms`) });
|
|
71
|
+
}, d), e.worker.listen({
|
|
72
|
+
message: (t) => {
|
|
73
|
+
if (!e.ready && ue(t)) {
|
|
74
|
+
e.ready = !0, e.timer !== null && clearTimeout(e.timer), e.timer = null, e.job === null ? e.worker.unref() : R(e, e.job), e.job === null && x();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const { job: n } = e;
|
|
78
|
+
if (n === null || !ce(t, n.id)) {
|
|
79
|
+
E(e, N(e, new Error("[markdown-explorer] a worker sent a message that answers no job")));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
_(e, { status: "done", output: t.output }), e.worker.unref(), x();
|
|
83
|
+
},
|
|
84
|
+
failure: (t) => {
|
|
85
|
+
E(e, N(e, t));
|
|
86
|
+
}
|
|
87
|
+
}), w.add(e), e;
|
|
88
|
+
}, x = () => {
|
|
89
|
+
for (; ; ) {
|
|
90
|
+
const e = I(), t = f[e];
|
|
91
|
+
if (t === void 0) return;
|
|
92
|
+
let n;
|
|
93
|
+
for (const a of w)
|
|
94
|
+
if (a.job === null) {
|
|
95
|
+
n = a;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (n === void 0 && w.size < o)
|
|
99
|
+
try {
|
|
100
|
+
n = L();
|
|
101
|
+
} catch (a) {
|
|
102
|
+
h(e), A(l, t.scope, -1), t.settle({ status: "unavailable", error: a });
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (n === void 0) return;
|
|
106
|
+
h(e), A(S, t.scope, 1);
|
|
107
|
+
const s = n;
|
|
108
|
+
s.job = t, s.worker.ref(), s.ready && R(s, t);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
run: (e, { scope: t, signal: n }) => new Promise((s) => {
|
|
113
|
+
if (n.aborted) {
|
|
114
|
+
s(C);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if ((l.get(t) ?? 0) >= u) {
|
|
118
|
+
s({ status: "refused", limit: "scope" });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
T += 1;
|
|
122
|
+
const a = { id: T, input: e, scope: t, settle: s, detach: () => {
|
|
123
|
+
} };
|
|
124
|
+
f.push(a), A(l, t, 1), x();
|
|
125
|
+
const i = f.indexOf(a);
|
|
126
|
+
if (i < 0) return;
|
|
127
|
+
if (f.length > g) {
|
|
128
|
+
h(i), A(l, t, -1), s({ status: "refused", limit: "queue" });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const c = () => {
|
|
132
|
+
const m = f.indexOf(a);
|
|
133
|
+
m < 0 || (h(m), A(l, t, -1), s(C));
|
|
134
|
+
};
|
|
135
|
+
n.addEventListener("abort", c, { once: !0 }), a.detach = () => {
|
|
136
|
+
n.removeEventListener("abort", c);
|
|
137
|
+
};
|
|
138
|
+
}),
|
|
139
|
+
workers: () => w.size
|
|
140
|
+
};
|
|
141
|
+
}, de = 4, le = ({ maxHtmlBytes: r }) => r, me = ({ maxHtmlBytes: r }) => de * r, fe = 1024, we = 64, P = Object.freeze({ status: "rejected", reason: "too-large", cause: null }), j = Object.freeze({ status: "rejected", reason: "failed", cause: null }), Ee = (r) => {
|
|
142
|
+
if (r === null || typeof r != "object") return !1;
|
|
143
|
+
const { status: o, html: d, message: u } = r;
|
|
144
|
+
return o === "sanitized" && typeof d == "string" || o === "too-large" || o === "error" && typeof u == "string";
|
|
145
|
+
}, F = (r) => ({ status: "rejected", reason: "failed", cause: new Error("[markdown-explorer] the HTML sanitizer could not measure a document", { cause: r }) }), Te = ({ iframeHosts: r, dataPath: o, ownUrls: d, limits: u, nodeBudget: g, measureHtml: w, classifyCrash: f, pool: S }) => {
|
|
146
|
+
if (!Number.isSafeInteger(g) || g <= 0) throw new RangeError(`[markdown-explorer] the HTML sanitizer's node budget must be a positive integer; got ${M(g)}`);
|
|
147
|
+
const l = Object.freeze([...r]), p = U(d), T = le(u), _ = me(u), h = G(fe, {
|
|
148
|
+
max: u.cacheBytes,
|
|
149
|
+
of: (e, t) => 2 * e.length + (t.status === "sanitized" ? 2 * t.html.length : we)
|
|
150
|
+
}), I = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), y = (e) => {
|
|
151
|
+
I.get(e.key) === e && I.delete(e.key);
|
|
152
|
+
const t = E.get(e.hash);
|
|
153
|
+
t?.delete(e), t?.size === 0 && E.delete(e.hash);
|
|
154
|
+
}, N = async (e, t, n) => {
|
|
155
|
+
const s = await S.run({ html: e, iframeHosts: l, dataPath: o, ownUrls: p, maxNodes: g, maxAttributeChars: T, maxSanitizedChars: _ }, { scope: t, signal: n });
|
|
156
|
+
if (s.status === "refused") {
|
|
157
|
+
const i = s.limit === "scope" ? `its reader already has ${String(u.jobsPerScope)} documents being sanitized or waiting` : `${String(u.maxQueuedJobs)} documents are already waiting`;
|
|
158
|
+
return { outcome: { status: "rejected", reason: "failed", cause: new Error(`[markdown-explorer] the HTML sanitizer refused a document: ${i}`) }, lasting: !1 };
|
|
159
|
+
}
|
|
160
|
+
if (s.status === "aborted") return { outcome: j, lasting: !1 };
|
|
161
|
+
if (s.status === "timeout") return { outcome: { status: "rejected", reason: "too-large", cause: new Error(`[markdown-explorer] the HTML sanitizer did not finish within ${String(u.deadlineMs)} ms`) }, lasting: !0 };
|
|
162
|
+
if (s.status === "unavailable") return { outcome: { status: "rejected", reason: "failed", cause: new Error("[markdown-explorer] the HTML sanitizer worker could not start", { cause: s.error }) }, lasting: !1 };
|
|
163
|
+
if (s.status === "crashed") {
|
|
164
|
+
const i = f(s.error);
|
|
165
|
+
return i !== null ? { outcome: { status: "rejected", reason: i.reason, cause: new Error(i.message, { cause: s.error }) }, lasting: !0 } : { outcome: { status: "rejected", reason: "failed", cause: new Error("[markdown-explorer] the HTML sanitizer worker failed", { cause: s.error }) }, lasting: !0 };
|
|
166
|
+
}
|
|
167
|
+
const { output: a } = s;
|
|
168
|
+
return Ee(a) ? a.status === "too-large" ? { outcome: P, lasting: !0 } : a.status === "error" ? { outcome: { status: "rejected", reason: "failed", cause: new Error(`[markdown-explorer] the HTML sanitizer failed: ${a.message}`) }, lasting: !0 } : a.html.length > _ ? { outcome: { status: "rejected", reason: "too-large", cause: new Error(`[markdown-explorer] the HTML sanitizer's output of ${String(a.html.length)} characters exceeds its limit of ${String(_)}`) }, lasting: !0 } : { outcome: { status: "sanitized", html: a.html }, lasting: !0 } : { outcome: { status: "rejected", reason: "failed", cause: new Error("[markdown-explorer] the HTML sanitizer worker answered something that is not an outcome") }, lasting: !0 };
|
|
169
|
+
}, R = (e, t, n, s) => {
|
|
170
|
+
let a = () => {
|
|
171
|
+
};
|
|
172
|
+
const i = new Promise((b) => {
|
|
173
|
+
a = b;
|
|
174
|
+
}), c = { hash: t, key: n, outcome: i, answer: a, controller: new AbortController(), waiters: 0 };
|
|
175
|
+
I.set(n, c);
|
|
176
|
+
const m = E.get(t);
|
|
177
|
+
return m === void 0 ? E.set(t, /* @__PURE__ */ new Set([c])) : m.add(c), N(e, s, c.controller.signal).catch((b) => ({ outcome: { status: "rejected", reason: "failed", cause: b instanceof Error ? b : new Error(String(b)) }, lasting: !0 })).then(({ outcome: b, lasting: Q }) => {
|
|
178
|
+
if (y(c), c.answer(b), !Q) return;
|
|
179
|
+
const O = h.get(t), $ = O ?? (b.status === "rejected" ? { ...b, cause: null } : b);
|
|
180
|
+
O === void 0 && h.set(t, $);
|
|
181
|
+
for (const z of E.get(t) ?? [])
|
|
182
|
+
y(z), z.answer($), z.controller.abort();
|
|
183
|
+
}), c;
|
|
184
|
+
}, L = (e, t) => new Promise((n) => {
|
|
185
|
+
e.waiters += 1;
|
|
186
|
+
const s = () => {
|
|
187
|
+
e.waiters -= 1, n(j), !(e.waiters > 0) && (y(e), e.controller.abort());
|
|
188
|
+
};
|
|
189
|
+
t.addEventListener("abort", s, { once: !0 }), e.outcome.then((a) => {
|
|
190
|
+
t.removeEventListener("abort", s), n(a);
|
|
191
|
+
});
|
|
192
|
+
}), x = (e, { utf8Bytes: t, hash: n }, s, a) => {
|
|
193
|
+
if (t > u.maxHtmlBytes) return Promise.resolve(P);
|
|
194
|
+
const i = h.get(n);
|
|
195
|
+
if (i !== void 0) return Promise.resolve(i);
|
|
196
|
+
if (a.aborted) return Promise.resolve(j);
|
|
197
|
+
const c = `${n}\0${s}`, m = I.get(c);
|
|
198
|
+
return L(m === void 0 ? R(e, n, c, s) : m, a);
|
|
199
|
+
};
|
|
200
|
+
return (e, { scope: t, signal: n }) => {
|
|
201
|
+
if (e.length > u.maxHtmlBytes) return Promise.resolve(P);
|
|
202
|
+
let s;
|
|
203
|
+
try {
|
|
204
|
+
s = w(e);
|
|
205
|
+
} catch (i) {
|
|
206
|
+
return Promise.resolve(F(i));
|
|
207
|
+
}
|
|
208
|
+
if (!(s instanceof Promise)) return x(e, s, t, n);
|
|
209
|
+
const a = s;
|
|
210
|
+
return new Promise((i) => {
|
|
211
|
+
const c = () => i(j);
|
|
212
|
+
n.addEventListener("abort", c, { once: !0 }), a.then(
|
|
213
|
+
(m) => {
|
|
214
|
+
n.removeEventListener("abort", c), i(x(e, m, t, n));
|
|
215
|
+
},
|
|
216
|
+
(m) => {
|
|
217
|
+
n.removeEventListener("abort", c), i(F(m));
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
export {
|
|
224
|
+
v as D,
|
|
225
|
+
q as M,
|
|
226
|
+
te as S,
|
|
227
|
+
Te as a,
|
|
228
|
+
H as b,
|
|
229
|
+
Se as c,
|
|
230
|
+
k as d,
|
|
231
|
+
ee as e,
|
|
232
|
+
W as f,
|
|
233
|
+
V as g,
|
|
234
|
+
se as h,
|
|
235
|
+
ce as i,
|
|
236
|
+
X as j,
|
|
237
|
+
ae as k,
|
|
238
|
+
D as l,
|
|
239
|
+
he as r
|
|
240
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ExplorerAssetFile, ExplorerByteRange } from "./ports.cjs";
|
|
2
|
+
export declare const ASSET_CONTENT_SECURITY_POLICIES: Readonly<{
|
|
3
|
+
readonly sandboxed: string;
|
|
4
|
+
readonly mediaDocument: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const browserMediaType: (contentType: string) => string | null;
|
|
7
|
+
export declare const EXPLORER_ASSET_CACHE_HEADERS: Readonly<Record<string, string>>;
|
|
8
|
+
export type AssetDelivery = {
|
|
9
|
+
readonly contentType: string;
|
|
10
|
+
readonly inline: boolean;
|
|
11
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
12
|
+
};
|
|
13
|
+
export declare const assetDelivery: (contentType: string, name: string) => AssetDelivery;
|
|
14
|
+
export declare const PLAIN_TEXT_ENCODING_WINDOW: number;
|
|
15
|
+
export declare const plainTextContentTypeOf: (encoding: string) => string;
|
|
16
|
+
export declare const plainTextHeadersOf: (name: string) => Readonly<Record<string, string>>;
|
|
17
|
+
export declare const plainTextValidatorOf: (version: string, legacyEncoding: string | null) => string;
|
|
18
|
+
export type ByteRangeSelection = {
|
|
19
|
+
readonly kind: "whole";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "partial";
|
|
22
|
+
readonly range: ExplorerByteRange;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "unsatisfiable";
|
|
25
|
+
};
|
|
26
|
+
export declare const selectByteRange: (headers: Headers, size: number, etag: string, maxRangeBytes: number | null) => ByteRangeSelection;
|
|
27
|
+
export type AssetPlan = {
|
|
28
|
+
readonly kind: "respond";
|
|
29
|
+
readonly response: Response;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "stream";
|
|
32
|
+
readonly status: 200 | 206;
|
|
33
|
+
readonly headers: Headers;
|
|
34
|
+
readonly range: ExplorerByteRange | null;
|
|
35
|
+
readonly length: number | null;
|
|
36
|
+
};
|
|
37
|
+
type RespondPlan = Extract<AssetPlan, {
|
|
38
|
+
readonly kind: "respond";
|
|
39
|
+
}>;
|
|
40
|
+
export type AssetBodySelection = {
|
|
41
|
+
readonly head: boolean;
|
|
42
|
+
readonly status: 200 | 206;
|
|
43
|
+
readonly headers: Headers;
|
|
44
|
+
readonly range: ExplorerByteRange | null;
|
|
45
|
+
readonly length: number | null;
|
|
46
|
+
};
|
|
47
|
+
export declare const assetPlanOf: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, maxRangeBytes: number | null) => AssetPlan;
|
|
48
|
+
export declare const assetResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, maxRangeBytes: number | null) => Promise<Response>;
|
|
49
|
+
export declare const beginningTextEncodingOf: (file: ExplorerAssetFile, legacyEncoding: string | null) => Promise<string>;
|
|
50
|
+
export declare const plainTextPlanOf: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, legacyEncoding: string | null, maxRangeBytes: number | null) => RespondPlan | {
|
|
51
|
+
readonly kind: "needs-encoding";
|
|
52
|
+
readonly selection: AssetBodySelection;
|
|
53
|
+
};
|
|
54
|
+
export declare const plainTextStreamPlanOf: (selection: AssetBodySelection, encoding: string) => AssetPlan;
|
|
55
|
+
export declare const plainTextResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, legacyEncoding: string | null, maxRangeBytes: number | null) => Promise<Response>;
|
|
56
|
+
export declare const workbookValidatorOf: (version: string) => string;
|
|
57
|
+
export declare const workbookResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers) => Promise<Response>;
|
|
58
|
+
export declare const EXPLORER_ASSET_REDIRECT_HEADERS: Readonly<Record<string, string>>;
|
|
59
|
+
export declare const assetRedirectResponse: (url: string, authHeaders: Headers) => Response;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ExplorerAssetFile, ExplorerByteRange } from "./ports.js";
|
|
2
|
+
export declare const ASSET_CONTENT_SECURITY_POLICIES: Readonly<{
|
|
3
|
+
readonly sandboxed: string;
|
|
4
|
+
readonly mediaDocument: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const browserMediaType: (contentType: string) => string | null;
|
|
7
|
+
export declare const EXPLORER_ASSET_CACHE_HEADERS: Readonly<Record<string, string>>;
|
|
8
|
+
export type AssetDelivery = {
|
|
9
|
+
readonly contentType: string;
|
|
10
|
+
readonly inline: boolean;
|
|
11
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
12
|
+
};
|
|
13
|
+
export declare const assetDelivery: (contentType: string, name: string) => AssetDelivery;
|
|
14
|
+
export declare const PLAIN_TEXT_ENCODING_WINDOW: number;
|
|
15
|
+
export declare const plainTextContentTypeOf: (encoding: string) => string;
|
|
16
|
+
export declare const plainTextHeadersOf: (name: string) => Readonly<Record<string, string>>;
|
|
17
|
+
export declare const plainTextValidatorOf: (version: string, legacyEncoding: string | null) => string;
|
|
18
|
+
export type ByteRangeSelection = {
|
|
19
|
+
readonly kind: "whole";
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "partial";
|
|
22
|
+
readonly range: ExplorerByteRange;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "unsatisfiable";
|
|
25
|
+
};
|
|
26
|
+
export declare const selectByteRange: (headers: Headers, size: number, etag: string, maxRangeBytes: number | null) => ByteRangeSelection;
|
|
27
|
+
export type AssetPlan = {
|
|
28
|
+
readonly kind: "respond";
|
|
29
|
+
readonly response: Response;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "stream";
|
|
32
|
+
readonly status: 200 | 206;
|
|
33
|
+
readonly headers: Headers;
|
|
34
|
+
readonly range: ExplorerByteRange | null;
|
|
35
|
+
readonly length: number | null;
|
|
36
|
+
};
|
|
37
|
+
type RespondPlan = Extract<AssetPlan, {
|
|
38
|
+
readonly kind: "respond";
|
|
39
|
+
}>;
|
|
40
|
+
export type AssetBodySelection = {
|
|
41
|
+
readonly head: boolean;
|
|
42
|
+
readonly status: 200 | 206;
|
|
43
|
+
readonly headers: Headers;
|
|
44
|
+
readonly range: ExplorerByteRange | null;
|
|
45
|
+
readonly length: number | null;
|
|
46
|
+
};
|
|
47
|
+
export declare const assetPlanOf: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, maxRangeBytes: number | null) => AssetPlan;
|
|
48
|
+
export declare const assetResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, maxRangeBytes: number | null) => Promise<Response>;
|
|
49
|
+
export declare const beginningTextEncodingOf: (file: ExplorerAssetFile, legacyEncoding: string | null) => Promise<string>;
|
|
50
|
+
export declare const plainTextPlanOf: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, legacyEncoding: string | null, maxRangeBytes: number | null) => RespondPlan | {
|
|
51
|
+
readonly kind: "needs-encoding";
|
|
52
|
+
readonly selection: AssetBodySelection;
|
|
53
|
+
};
|
|
54
|
+
export declare const plainTextStreamPlanOf: (selection: AssetBodySelection, encoding: string) => AssetPlan;
|
|
55
|
+
export declare const plainTextResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers, legacyEncoding: string | null, maxRangeBytes: number | null) => Promise<Response>;
|
|
56
|
+
export declare const workbookValidatorOf: (version: string) => string;
|
|
57
|
+
export declare const workbookResponse: (request: Request, file: ExplorerAssetFile, authHeaders: Headers) => Promise<Response>;
|
|
58
|
+
export declare const EXPLORER_ASSET_REDIRECT_HEADERS: Readonly<Record<string, string>>;
|
|
59
|
+
export declare const assetRedirectResponse: (url: string, authHeaders: Headers) => Response;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PageFetchPort } from "@aiquants/markdown/link-cards";
|
|
2
|
+
import { ExplorerServerPlatform } from "../platform.cjs";
|
|
3
|
+
import { HtmlMeasure } from "../sanitizerService.cjs";
|
|
4
|
+
export type BrowserExplorerPlatformOptions = {
|
|
5
|
+
readonly principalKey: string;
|
|
6
|
+
readonly scope: string;
|
|
7
|
+
readonly window: Window & typeof globalThis;
|
|
8
|
+
readonly nestingGuardWorkerUrl: URL;
|
|
9
|
+
readonly pageFetch: PageFetchPort | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const browserHtmlMeasureOf: (subtle: SubtleCrypto) => ((html: string) => Promise<HtmlMeasure>);
|
|
12
|
+
export declare const createBrowserExplorerPlatform: (options: BrowserExplorerPlatformOptions) => ExplorerServerPlatform;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PageFetchPort } from "@aiquants/markdown/link-cards";
|
|
2
|
+
import { ExplorerServerPlatform } from "../platform.js";
|
|
3
|
+
import { HtmlMeasure } from "../sanitizerService.js";
|
|
4
|
+
export type BrowserExplorerPlatformOptions = {
|
|
5
|
+
readonly principalKey: string;
|
|
6
|
+
readonly scope: string;
|
|
7
|
+
readonly window: Window & typeof globalThis;
|
|
8
|
+
readonly nestingGuardWorkerUrl: URL;
|
|
9
|
+
readonly pageFetch: PageFetchPort | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const browserHtmlMeasureOf: (subtle: SubtleCrypto) => ((html: string) => Promise<HtmlMeasure>);
|
|
12
|
+
export declare const createBrowserExplorerPlatform: (options: BrowserExplorerPlatformOptions) => ExplorerServerPlatform;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import { HeadersFunction } from "react-router";
|
|
2
1
|
import { MarkdownExplorerServer, MarkdownExplorerServerConfig } from "./ports.cjs";
|
|
3
|
-
export declare const DEFAULT_DEFERRED_TIMEOUT_MS = 4000;
|
|
4
|
-
export declare const DEFAULT_TREE_CACHE: Readonly<{
|
|
5
|
-
ttlMs: 300000;
|
|
6
|
-
maxEntries: 64;
|
|
7
|
-
maxBytes: number;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const MIN_SCOPE_SECRET_LENGTH = 32;
|
|
10
|
-
export declare const EXPLORER_DATA_RESPONSE_HEADERS: Readonly<Record<string, string>>;
|
|
11
|
-
export declare const carryLoaderHeaders: HeadersFunction;
|
|
12
2
|
export declare const createMarkdownExplorer: <P>(serverConfig: MarkdownExplorerServerConfig<P>) => MarkdownExplorerServer;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import { HeadersFunction } from "react-router";
|
|
2
1
|
import { MarkdownExplorerServer, MarkdownExplorerServerConfig } from "./ports.js";
|
|
3
|
-
export declare const DEFAULT_DEFERRED_TIMEOUT_MS = 4000;
|
|
4
|
-
export declare const DEFAULT_TREE_CACHE: Readonly<{
|
|
5
|
-
ttlMs: 300000;
|
|
6
|
-
maxEntries: 64;
|
|
7
|
-
maxBytes: number;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const MIN_SCOPE_SECRET_LENGTH = 32;
|
|
10
|
-
export declare const EXPLORER_DATA_RESPONSE_HEADERS: Readonly<Record<string, string>>;
|
|
11
|
-
export declare const carryLoaderHeaders: HeadersFunction;
|
|
12
2
|
export declare const createMarkdownExplorer: <P>(serverConfig: MarkdownExplorerServerConfig<P>) => MarkdownExplorerServer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HeadersFunction } from "react-router";
|
|
2
|
+
import { ExplorerServerPlatform } from "./platform.cjs";
|
|
3
|
+
import { ExplorerServerCoreConfig, MarkdownExplorerServer } from "./ports.cjs";
|
|
4
|
+
export declare const DEFAULT_DEFERRED_TIMEOUT_MS = 4000;
|
|
5
|
+
export declare const DEFAULT_TREE_CACHE: Readonly<{
|
|
6
|
+
ttlMs: 300000;
|
|
7
|
+
maxEntries: 64;
|
|
8
|
+
maxBytes: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const EXPLORER_DATA_RESPONSE_HEADERS: Readonly<Record<string, string>>;
|
|
11
|
+
export declare const carryLoaderHeaders: HeadersFunction;
|
|
12
|
+
export declare const createExplorerServer: <P>(serverConfig: ExplorerServerCoreConfig<P>, platform: ExplorerServerPlatform) => MarkdownExplorerServer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HeadersFunction } from "react-router";
|
|
2
|
+
import { ExplorerServerPlatform } from "./platform.js";
|
|
3
|
+
import { ExplorerServerCoreConfig, MarkdownExplorerServer } from "./ports.js";
|
|
4
|
+
export declare const DEFAULT_DEFERRED_TIMEOUT_MS = 4000;
|
|
5
|
+
export declare const DEFAULT_TREE_CACHE: Readonly<{
|
|
6
|
+
ttlMs: 300000;
|
|
7
|
+
maxEntries: 64;
|
|
8
|
+
maxBytes: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const EXPLORER_DATA_RESPONSE_HEADERS: Readonly<Record<string, string>>;
|
|
11
|
+
export declare const carryLoaderHeaders: HeadersFunction;
|
|
12
|
+
export declare const createExplorerServer: <P>(serverConfig: ExplorerServerCoreConfig<P>, platform: ExplorerServerPlatform) => MarkdownExplorerServer;
|
|
@@ -12,6 +12,7 @@ export type FileSystemSourceOptions = {
|
|
|
12
12
|
readonly label: string;
|
|
13
13
|
readonly root: string;
|
|
14
14
|
readonly pathPrefix: string;
|
|
15
|
+
readonly lang: string;
|
|
15
16
|
readonly parse: (markdown: string, docPath: string) => Promise<{
|
|
16
17
|
readonly htmlContent: string;
|
|
17
18
|
readonly headings: readonly ExplorerHeading[];
|
|
@@ -12,6 +12,7 @@ export type FileSystemSourceOptions = {
|
|
|
12
12
|
readonly label: string;
|
|
13
13
|
readonly root: string;
|
|
14
14
|
readonly pathPrefix: string;
|
|
15
|
+
readonly lang: string;
|
|
15
16
|
readonly parse: (markdown: string, docPath: string) => Promise<{
|
|
16
17
|
readonly htmlContent: string;
|
|
17
18
|
readonly headings: readonly ExplorerHeading[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MarkdownExplorerServer } from "./ports.cjs";
|
|
2
|
+
export declare const createInProcessDataFetch: (server: Pick<MarkdownExplorerServer, "dataLoader" | "dataAction">, { dataPath, pageAddress }: {
|
|
3
|
+
readonly dataPath: string;
|
|
4
|
+
readonly pageAddress: string;
|
|
5
|
+
}) => typeof fetch;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MarkdownExplorerServer } from "./ports.js";
|
|
2
|
+
export declare const createInProcessDataFetch: (server: Pick<MarkdownExplorerServer, "dataLoader" | "dataAction">, { dataPath, pageAddress }: {
|
|
3
|
+
readonly dataPath: string;
|
|
4
|
+
readonly pageAddress: string;
|
|
5
|
+
}) => typeof fetch;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LinkCardHandler } from "@aiquants/markdown/link-cards";
|
|
2
|
+
import { ExplorerOwnUrls } from "../core/ownUrls.cjs";
|
|
3
|
+
import { SanitizerLimitsInput } from "./sanitizerOptions.cjs";
|
|
4
|
+
import { HtmlSanitizerService } from "./sanitizerService.cjs";
|
|
5
|
+
export type ExplorerServerPlatform = {
|
|
6
|
+
readonly prepareScope: () => (principalKey: string) => string;
|
|
7
|
+
readonly createSanitizer: (setup: SanitizerSetup) => HtmlSanitizerService;
|
|
8
|
+
readonly createLinkCardHandler: (options: {
|
|
9
|
+
readonly authorize: (request: Request) => Promise<boolean>;
|
|
10
|
+
}) => LinkCardHandler;
|
|
11
|
+
};
|
|
12
|
+
export type SanitizerSetup = {
|
|
13
|
+
readonly options: SanitizerLimitsInput | undefined;
|
|
14
|
+
readonly maxPanels: number;
|
|
15
|
+
readonly iframeHosts: readonly string[];
|
|
16
|
+
readonly dataPath: string;
|
|
17
|
+
readonly ownUrls: ExplorerOwnUrls;
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LinkCardHandler } from "@aiquants/markdown/link-cards";
|
|
2
|
+
import { ExplorerOwnUrls } from "../core/ownUrls.js";
|
|
3
|
+
import { SanitizerLimitsInput } from "./sanitizerOptions.js";
|
|
4
|
+
import { HtmlSanitizerService } from "./sanitizerService.js";
|
|
5
|
+
export type ExplorerServerPlatform = {
|
|
6
|
+
readonly prepareScope: () => (principalKey: string) => string;
|
|
7
|
+
readonly createSanitizer: (setup: SanitizerSetup) => HtmlSanitizerService;
|
|
8
|
+
readonly createLinkCardHandler: (options: {
|
|
9
|
+
readonly authorize: (request: Request) => Promise<boolean>;
|
|
10
|
+
}) => LinkCardHandler;
|
|
11
|
+
};
|
|
12
|
+
export type SanitizerSetup = {
|
|
13
|
+
readonly options: SanitizerLimitsInput | undefined;
|
|
14
|
+
readonly maxPanels: number;
|
|
15
|
+
readonly iframeHosts: readonly string[];
|
|
16
|
+
readonly dataPath: string;
|
|
17
|
+
readonly ownUrls: ExplorerOwnUrls;
|
|
18
|
+
};
|
package/dist/server/ports.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ import { ExplorerAssetDisplay } from "../core/dataRoute.cjs";
|
|
|
5
5
|
import { ExplorerPathRules } from "../core/paths.cjs";
|
|
6
6
|
import { ExplorerLogger } from "./errors.cjs";
|
|
7
7
|
import { HtmlSanitizerOptions } from "./sanitizer.cjs";
|
|
8
|
+
import { SanitizerLimitsInput } from "./sanitizerOptions.cjs";
|
|
8
9
|
export type ExplorerAuthentication<P> = {
|
|
9
10
|
readonly status: "signed-in";
|
|
10
11
|
readonly principal: P;
|
|
@@ -57,6 +58,11 @@ export type ExplorerAssetFile = {
|
|
|
57
58
|
readonly size: number | null;
|
|
58
59
|
readonly version: string;
|
|
59
60
|
readonly open: (range: ExplorerByteRange | null) => Promise<ReadableStream<Uint8Array>>;
|
|
61
|
+
readonly bridge?: {
|
|
62
|
+
readonly uri: string;
|
|
63
|
+
readonly storageVersion: string | null;
|
|
64
|
+
readonly readFailure: (error: unknown) => unknown;
|
|
65
|
+
};
|
|
60
66
|
};
|
|
61
67
|
export type ExplorerAssetRedirect = {
|
|
62
68
|
readonly kind: "redirect";
|
|
@@ -70,12 +76,14 @@ export type ExplorerHostDocument = {
|
|
|
70
76
|
readonly name: string;
|
|
71
77
|
readonly htmlContent: string;
|
|
72
78
|
readonly headings: readonly ExplorerHeading[];
|
|
79
|
+
readonly lang: string;
|
|
73
80
|
readonly edit: ExplorerDocumentEdit | null;
|
|
74
81
|
} | {
|
|
75
82
|
readonly kind: "text";
|
|
76
83
|
readonly name: string;
|
|
77
84
|
readonly text: string;
|
|
78
85
|
readonly truncated: boolean;
|
|
86
|
+
readonly lang: string;
|
|
79
87
|
readonly version: string;
|
|
80
88
|
} | {
|
|
81
89
|
readonly kind: "image";
|
|
@@ -108,7 +116,7 @@ export type ExplorerHostEditSource = {
|
|
|
108
116
|
readonly kind: "draft";
|
|
109
117
|
readonly text: string;
|
|
110
118
|
} | ExplorerGrantRequired;
|
|
111
|
-
export type
|
|
119
|
+
export type ExplorerHostSaveDraft = {
|
|
112
120
|
readonly text: string;
|
|
113
121
|
readonly baseVersion: string;
|
|
114
122
|
};
|
|
@@ -126,16 +134,15 @@ export type ExplorerHostPreview = {
|
|
|
126
134
|
};
|
|
127
135
|
export type ExplorerEditPorts<P> = {
|
|
128
136
|
readonly source: (context: ExplorerSourceContext<P>, path: string, readPath: string) => Promise<ExplorerHostEditSource>;
|
|
129
|
-
readonly save: (context: ExplorerSourceContext<P>, path: string, readPath: string, draft:
|
|
137
|
+
readonly save: (context: ExplorerSourceContext<P>, path: string, readPath: string, draft: ExplorerHostSaveDraft) => Promise<ExplorerHostSaveResult>;
|
|
130
138
|
readonly preview: (context: ExplorerSourceContext<P>, path: string, readPath: string, text: string) => Promise<ExplorerHostPreview>;
|
|
131
139
|
readonly revisions: (context: ExplorerSourceContext<P>, path: string, readPath: string) => Promise<readonly ExplorerRevision[]>;
|
|
132
140
|
readonly revision: (context: ExplorerSourceContext<P>, path: string, readPath: string, revisionId: string) => Promise<string>;
|
|
133
141
|
};
|
|
134
|
-
export type
|
|
142
|
+
export type ExplorerServerSharedConfig<P> = {
|
|
135
143
|
readonly config: ExplorerConfig;
|
|
136
144
|
readonly authenticate: (request: Request, mode: ExplorerAuthenticationMode) => Promise<ExplorerAuthentication<P>>;
|
|
137
145
|
readonly principalKey: (principal: P) => string;
|
|
138
|
-
readonly scopeSecret: string;
|
|
139
146
|
readonly sources: readonly ExplorerSource<P>[];
|
|
140
147
|
readonly document: (context: ExplorerSourceContext<P>, path: string, readPath: string) => Promise<ExplorerHostDocument>;
|
|
141
148
|
readonly asset: (context: ExplorerSourceContext<P>, path: string, readPath: string, options: ExplorerAssetOptions) => Promise<ExplorerAssetFile | ExplorerAssetRedirect>;
|
|
@@ -148,7 +155,6 @@ export type MarkdownExplorerServerConfig<P> = {
|
|
|
148
155
|
readonly maxEntries?: number;
|
|
149
156
|
readonly maxBytes?: number;
|
|
150
157
|
} | false;
|
|
151
|
-
readonly sanitizer?: HtmlSanitizerOptions;
|
|
152
158
|
readonly deferredTimeoutMs?: number;
|
|
153
159
|
readonly textMaxBytes?: number;
|
|
154
160
|
readonly edit?: ExplorerEditPorts<P>;
|
|
@@ -156,11 +162,36 @@ export type MarkdownExplorerServerConfig<P> = {
|
|
|
156
162
|
readonly logger?: ExplorerLogger;
|
|
157
163
|
readonly onTreeRefreshed?: (key: string) => void;
|
|
158
164
|
};
|
|
165
|
+
export type MarkdownExplorerServerConfig<P> = ExplorerServerSharedConfig<P> & {
|
|
166
|
+
readonly scopeSecret: string;
|
|
167
|
+
readonly sanitizer?: HtmlSanitizerOptions;
|
|
168
|
+
};
|
|
169
|
+
export type ExplorerServerCoreConfig<P> = ExplorerServerSharedConfig<P> & {
|
|
170
|
+
readonly sanitizer?: SanitizerLimitsInput & Readonly<Record<string, unknown>>;
|
|
171
|
+
readonly readSettings: (request: Request) => string | undefined;
|
|
172
|
+
readonly assetMaxRangeBytes: number | null;
|
|
173
|
+
};
|
|
159
174
|
export type ExplorerPageLoaderResult = ReturnType<typeof data<ExplorerPageData>>;
|
|
175
|
+
export type ExplorerDataPlan = {
|
|
176
|
+
readonly kind: "response";
|
|
177
|
+
readonly response: Response;
|
|
178
|
+
} | {
|
|
179
|
+
readonly kind: "file";
|
|
180
|
+
readonly status: 200 | 206;
|
|
181
|
+
readonly headers: Headers;
|
|
182
|
+
readonly bridge: {
|
|
183
|
+
readonly uri: string;
|
|
184
|
+
readonly storageVersion: string | null;
|
|
185
|
+
};
|
|
186
|
+
readonly range: ExplorerByteRange | null;
|
|
187
|
+
readonly length: number | null;
|
|
188
|
+
readonly fail: (error: unknown) => Response;
|
|
189
|
+
};
|
|
160
190
|
export type MarkdownExplorerServer = {
|
|
161
191
|
readonly loader: (args: LoaderFunctionArgs) => Promise<ExplorerPageLoaderResult>;
|
|
162
192
|
readonly headers: HeadersFunction;
|
|
163
193
|
readonly dataLoader: (args: LoaderFunctionArgs) => Promise<Response>;
|
|
164
194
|
readonly dataAction: (args: ActionFunctionArgs) => Promise<Response>;
|
|
195
|
+
readonly planData: (args: LoaderFunctionArgs) => Promise<ExplorerDataPlan>;
|
|
165
196
|
readonly forgetTree: (key: string) => void;
|
|
166
197
|
};
|