@aiquants/markdown-explorer 0.39.0 → 0.40.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 +24 -0
- package/README.md +3 -1
- package/dist/{EditSurface-CZnjX0sv.cjs → EditSurface-DFHZLbWC.cjs} +1 -1
- package/dist/{EditSurface-CUPN9dUY.js → EditSurface-DV4FuQVx.js} +3 -3
- package/dist/{ExplorerSplit-DHpgdXhb.js → ExplorerSplit-DTkr0q2C.js} +4 -4
- package/dist/{ExplorerSplit-DWBhCe7m.cjs → ExplorerSplit-DnuuUifU.cjs} +1 -1
- package/dist/{MultiLayout-BkHbfUuh.cjs → MultiLayout-CC0VPiFf.cjs} +1 -1
- package/dist/{MultiLayout-HmvjE8ht.js → MultiLayout-S77I1xQr.js} +3 -3
- package/dist/{NativeScrollBar-CzGhZ-w3.cjs → NativeScrollBar-C2n-DzEJ.cjs} +1 -1
- package/dist/{NativeScrollBar-DAukiH01.js → NativeScrollBar-DMCPxFeR.js} +2 -2
- package/dist/{TreeLayout-dtnugwQ7.js → TreeLayout-BGTzh0L4.js} +3 -3
- package/dist/{TreeLayout-BEvPaxLb.cjs → TreeLayout-DjJMAxWJ.cjs} +1 -1
- package/dist/core/config.d.cts +2 -0
- package/dist/core/config.d.ts +2 -0
- package/dist/{explorerCore-CUtc1Vmx.js → explorerCore-COhVrnGO.js} +1 -1
- package/dist/{explorerCore-Dj7RxZRd.cjs → explorerCore-diILGZTv.cjs} +1 -1
- package/dist/{index-D6at9qMs.cjs → index-AfEbgYQI.cjs} +8 -8
- package/dist/{index-BBJoJu-b.js → index-CWFyLa0N.js} +9 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/location-Csj3eAm_.cjs +1 -0
- package/dist/{location-T9o5XYpX.js → location-DFfbnUZ9.js} +26 -19
- package/dist/{merge-CkMe5hqA.js → merge-D-Oak4Xy.js} +1 -1
- package/dist/{merge-XyuOlVWP.cjs → merge-DvoikrFp.cjs} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +3 -3
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.js +3 -3
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-ExxyHVWY.cjs → tapScrollCircle-CS3hbyGb.cjs} +1 -1
- package/dist/{tapScrollCircle-CvWJKtbF.js → tapScrollCircle-DKoj17z6.js} +1 -1
- package/dist/{useSplitPersistence-BCitqdAe.cjs → useSplitPersistence-C6s7a4Iu.cjs} +1 -1
- package/dist/{useSplitPersistence-C86jW1yY.js → useSplitPersistence-CC9bx9iq.js} +1 -1
- package/package.json +3 -3
- package/dist/location-DFXJSMit.cjs +0 -1
|
@@ -4,7 +4,7 @@ import { jsx as d, jsxs as j, Fragment as Oe } from "react/jsx-runtime";
|
|
|
4
4
|
import * as T from "react";
|
|
5
5
|
import { createContext as ge, use as se, useMemo as Q, useSyncExternalStore as oe, useLayoutEffect as K, useRef as z, useCallback as _, useId as Le, useEffect as ne, Component as Or, Suspense as tt, lazy as hn, useState as V, useEffectEvent as pe, startTransition as ea, useImperativeHandle as ta } from "react";
|
|
6
6
|
import { useParams as na, useSearchParams as ra, matchPath as oa, useBlocker as aa, useNavigate as ia, Link as sa, NavigationType as la, useHref as at, useLocation as pn, useRevalidator as ca } from "react-router";
|
|
7
|
-
import { h as Lr, K as da, E as Ar, m as Dr, L as ua, x as Cn, M as fa, y as ma, O as ha, Q as Ye, e as xe, d as pa, R as wa, k as ga, T as va, U as ya, V as Rn, W as ba, X as Mn, Y as ka, j as Ea, w as Sa, Z as xa, _ as Ta } from "./location-
|
|
7
|
+
import { h as Lr, K as da, E as Ar, m as Dr, L as ua, x as Cn, M as fa, y as ma, O as ha, Q as Ye, e as xe, d as pa, R as wa, k as ga, T as va, U as ya, V as Rn, W as ba, X as Mn, Y as ka, j as Ea, w as Sa, Z as xa, _ as Ta } from "./location-DFfbnUZ9.js";
|
|
8
8
|
import { SPREADSHEET_BLOCK_LABEL_PLACEHOLDERS as On, SPREADSHEET_BLOCK_LABEL_CATALOGS as xt } from "@aiquants/markdown/code-blocks";
|
|
9
9
|
import { J as ae, l as ve, i as Ca, W as Lt, X as Ra, Y as Ma, Z as qt, g as $e, I as Oa, _ as La, k as Aa, $ as Da, a0 as Na, a1 as Ia, a2 as Pa, a3 as Fa, a4 as $a, H as _a, a5 as Ln, F as qa, a6 as Ba, a7 as Ua, a8 as Ha, O as za, G as ja, a9 as Va, aa as Za, ab as Ga, C as Bt } from "./ownUrls-DD0cSCsF.js";
|
|
10
10
|
import { HostedScrollArea as An, SpreadsheetBlock as Wa, useMarkdownToolbarState as Ka, MarkdownViewer as Nr } from "@aiquants/markdown";
|
|
@@ -1259,7 +1259,7 @@ const Hi = (e, t, n, r) => {
|
|
|
1259
1259
|
H(c, l, { kind: "failed", failure: A.failure });
|
|
1260
1260
|
return;
|
|
1261
1261
|
}
|
|
1262
|
-
const { mergeDraft: q } = await import("./merge-
|
|
1262
|
+
const { mergeDraft: q } = await import("./merge-D-Oak4Xy.js");
|
|
1263
1263
|
if (!I(c, l) || O.aborted) return;
|
|
1264
1264
|
const ee = f.get(c);
|
|
1265
1265
|
ee?.flush();
|
|
@@ -1285,7 +1285,7 @@ const Hi = (e, t, n, r) => {
|
|
|
1285
1285
|
else if (c.base.version === l.version)
|
|
1286
1286
|
x = { text: E, version: l.version }, O = c.draft, F = Ge;
|
|
1287
1287
|
else {
|
|
1288
|
-
const { mergeDraft: y } = await import("./merge-
|
|
1288
|
+
const { mergeDraft: y } = await import("./merge-D-Oak4Xy.js"), S = y(c.base.text, c.draft, E, t());
|
|
1289
1289
|
x = { text: E, version: l.version }, O = S.text, F = S.kind === "conflicts" ? { kind: "conflicts", count: S.conflicts } : Ge;
|
|
1290
1290
|
}
|
|
1291
1291
|
if (a.has(c.path)) return { restored: !1, reason: "failed" };
|
|
@@ -1647,7 +1647,7 @@ function Ts({
|
|
|
1647
1647
|
}
|
|
1648
1648
|
const Cs = /* @__PURE__ */ T.forwardRef(Ts);
|
|
1649
1649
|
let zt = null;
|
|
1650
|
-
const Kr = () => (zt ??= import("./EditSurface-
|
|
1650
|
+
const Kr = () => (zt ??= import("./EditSurface-DV4FuQVx.js").catch((e) => {
|
|
1651
1651
|
throw zt = null, e;
|
|
1652
1652
|
}), zt), Rs = () => {
|
|
1653
1653
|
Kr().catch(() => {
|
|
@@ -1829,7 +1829,7 @@ const Xr = "[data-aqmd-fullscreen]", Ls = "[data-aqmd-fullscreen-dialog]:modal",
|
|
|
1829
1829
|
}),
|
|
1830
1830
|
[s, f]
|
|
1831
1831
|
);
|
|
1832
|
-
}, Ks = hn(() => import("./NativeScrollBar-
|
|
1832
|
+
}, Ks = hn(() => import("./NativeScrollBar-DMCPxFeR.js").then((e) => ({ default: e.NativeScrollBar })));
|
|
1833
1833
|
class Xs extends Or {
|
|
1834
1834
|
state = { failed: !1 };
|
|
1835
1835
|
static getDerivedStateFromError() {
|
|
@@ -1847,7 +1847,7 @@ let ro = null, jt = null;
|
|
|
1847
1847
|
const ln = /* @__PURE__ */ new Set(), ol = (e) => (ln.add(e), () => {
|
|
1848
1848
|
ln.delete(e);
|
|
1849
1849
|
}), al = () => {
|
|
1850
|
-
jt === null && (jt = import("./tapScrollCircle-
|
|
1850
|
+
jt === null && (jt = import("./tapScrollCircle-DKoj17z6.js").then((e) => {
|
|
1851
1851
|
const t = e.TAP_SCROLL_CIRCLE.renderVisual;
|
|
1852
1852
|
if (t === void 0) throw new TypeError("[markdown-explorer] the bars' tap-scroll circle has no look to share");
|
|
1853
1853
|
ro = t;
|
|
@@ -4308,6 +4308,7 @@ const ld = /* @__PURE__ */ new Map([
|
|
|
4308
4308
|
iFrameAllowedDomains: x,
|
|
4309
4309
|
embeds: w.embeds,
|
|
4310
4310
|
mermaidModifier: w.mermaidModifier,
|
|
4311
|
+
documentFontFamily: w.documentFontFamily,
|
|
4311
4312
|
fetch: b,
|
|
4312
4313
|
linkComponent: Mc,
|
|
4313
4314
|
toolbar: k,
|
|
@@ -4332,7 +4333,7 @@ const ld = /* @__PURE__ */ new Map([
|
|
|
4332
4333
|
scrollBarGutter: O ? void 0 : no,
|
|
4333
4334
|
imageSource: E
|
|
4334
4335
|
}),
|
|
4335
|
-
[l, p, F, u.documentEmpty, m, w.documentStyles, x, w.embeds, w.mermaidModifier, b, k, r, O, E]
|
|
4336
|
+
[l, p, F, u.documentEmpty, m, w.documentStyles, x, w.embeds, w.mermaidModifier, w.documentFontFamily, b, k, r, O, E]
|
|
4336
4337
|
), S = _((A, q) => O ? q === null || q.kind === "failure" ? ve(A) : q.name : u.documentRegion, [O, u.documentRegion]), L = O ? "content" : "fill";
|
|
4337
4338
|
return e === null ? /* @__PURE__ */ d(Ae, { value: L, children: /* @__PURE__ */ d(gu, { absence: t, announces: s, announceFailure: f }) }) : /* @__PURE__ */ d(Ae, { value: L, children: /* @__PURE__ */ d(tt, { fallback: /* @__PURE__ */ d(xn, { label: S(e, null) }), children: /* @__PURE__ */ d(
|
|
4338
4339
|
Ou,
|
|
@@ -5602,7 +5603,7 @@ const em = () => {
|
|
|
5602
5603
|
});
|
|
5603
5604
|
return s.observe(i, { childList: !0, subtree: !0 }), () => s.disconnect();
|
|
5604
5605
|
}, [t, e]);
|
|
5605
|
-
}, cm = hn(() => import("./TreeLayout-
|
|
5606
|
+
}, cm = hn(() => import("./TreeLayout-BGTzh0L4.js").then((e) => ({ default: e.TreeLayout }))), dm = hn(() => import("./MultiLayout-S77I1xQr.js").then((e) => ({ default: e.MultiLayout }))), um = 64, fm = {
|
|
5606
5607
|
request: (e) => {
|
|
5607
5608
|
requestAnimationFrame(e);
|
|
5608
5609
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-AfEbgYQI.cjs"),e=require("./storage-BpYsprog.cjs"),E=require("./location-Csj3eAm_.cjs"),_=require("./ownUrls-BTPGNhBt.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_HOST_CHANGE_POLICIES=L.EXPLORER_HOST_CHANGE_POLICIES;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.draftAnswerOf=L.draftAnswerOf;exports.draftConversionOf=L.draftConversionOf;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=E.REVEAL_DOCUMENT_DEPTH_LIMITS;exports.SPREADSHEET_BYTE_LIMITS=E.SPREADSHEET_BYTE_LIMITS;exports.WORKBOOK_BYTE_LIMITS=E.WORKBOOK_BYTE_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.DOCUMENT_ID_ALPHABET=_.DOCUMENT_ID_ALPHABET;exports.DOCUMENT_ID_LENGTH=_.DOCUMENT_ID_LENGTH;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_.EXPLORER_EDIT_TOKEN_MAX_LENGTH;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.groupDocumentId=_.groupDocumentId;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isCanonicalDocumentId=_.isCanonicalDocumentId;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerDocumentLang=_.isExplorerDocumentLang;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;exports.parseDocumentId=_.parseDocumentId;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ak as _, al as s, am as L, an as e, ao as r, ap as R, aq as T, ar as o, as as A, at as O, au as I, av as D } from "./index-
|
|
1
|
+
import { ak as _, al as s, am as L, an as e, ao as r, ap as R, aq as T, ar as o, as as A, at as O, au as I, av as D } from "./index-CWFyLa0N.js";
|
|
2
2
|
import { c as N } from "./storage-D1uSw-xj.js";
|
|
3
|
-
import { $ as S, a0 as l, a1 as i, a2 as n, a3 as p, H as t, G as X, a4 as C, I as U, Q as x, a5 as u, a6 as c, a7 as d, a8 as f, a9 as H, aa as m, e as G, i as F, h as K, w as W } from "./location-
|
|
3
|
+
import { $ as S, a0 as l, a1 as i, a2 as n, a3 as p, H as t, G as X, a4 as C, I as U, Q as x, a5 as u, a6 as c, a7 as d, a8 as f, a9 as H, aa as m, e as G, i as F, h as K, w as W } from "./location-DFfbnUZ9.js";
|
|
4
4
|
import { D as B, ac as g, ad as v, ae as w, af as k, E as V, M as Y, g as b, k as j, Y as q, i as Q, K as $, a as y, a2 as z, b as J, j as Z, h as EE, T as aE } from "./ownUrls-DD0cSCsF.js";
|
|
5
5
|
export {
|
|
6
6
|
S as COLUMN_MIN_MEASURE,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const L=require("@aiquants/markdown/embeds"),T=require("@aiquants/markdown/viewer-settings"),h=require("./ownUrls-BTPGNhBt.cjs"),i=require("./describeValue-Ccvhbt36.cjs"),Je=Object.freeze(["UTF-8","IBM866","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-8-I","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","KOI8-R","KOI8-U","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic","GBK","gb18030","Big5","EUC-JP","ISO-2022-JP","Shift_JIS","EUC-KR","replacement","UTF-16BE","UTF-16LE","x-user-defined"]),Ze=new Map(Je.map(e=>[e.toLowerCase(),e])),$="UTF-8",ae=Object.freeze([Object.freeze({bytes:Object.freeze([239,187,191]),encoding:$}),Object.freeze({bytes:Object.freeze([255,254]),encoding:"UTF-16LE"}),Object.freeze({bytes:Object.freeze([254,255]),encoding:"UTF-16BE"})]),Qe=new Map([[$,"is read before any legacy encoding"],["UTF-16LE","is read only by its byte order mark"],["UTF-16BE","is read only by its byte order mark"],["ISO-2022-JP","writes only bytes below 0x80, which UTF-8 always reads first, so it would never be used"],["x-user-defined","is no text encoding (it maps bytes to private-use characters)"]]),Q=e=>{let r;try{r=new TextDecoder(e).encoding}catch(o){throw o instanceof RangeError?new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} is no encoding label TextDecoder knows (for example "Shift_JIS" or "windows-1252")`):o}const t=er(r),n=Qe.get(t);if(n!==void 0)throw new RangeError(`[markdown-explorer] legacyTextEncoding ${i.describeValue(e)} names ${t}, which cannot be the legacy encoding: it ${n}`);return t},er=e=>{const r=Ze.get(e);if(r===void 0)throw new RangeError(`[markdown-explorer] TextDecoder answered ${i.describeValue(e)}, which is no encoding of the WHATWG Encoding Standard`);return r},V=(e,r,t)=>{const n=t===null?null:Q(t),o=ae.find(({bytes:a})=>a.every((d,l)=>e[l]===d));if(o!==void 0)return{body:e.subarray(o.bytes.length),encodings:[o.encoding]};const s=r||e.length===0?void 0:ae.find(({bytes:a})=>e.length<a.length&&e.every((d,l)=>a[l]===d));return s!==void 0?{body:e.subarray(e.length),encodings:[s.encoding]}:{body:e,encodings:n===null?[$]:[$,n]}},rr=(e,r,t)=>V(e,r,t).encodings,tr=(e,r,t)=>{try{return new TextDecoder(e,{fatal:!0,ignoreBOM:!0}).decode(r,{stream:!t})}catch(n){if(n instanceof TypeError)return null;throw n}},nr=(e,r,t)=>{const n=ee(V(e,r,t),r);return n===null?null:n.text},ee=({body:e,encodings:r},t)=>{for(const n of r){const o=tr(n,e,t);if(o!==null)return{encoding:n,text:o}}return null},or=(e,r,t)=>{const n=V(e,r,t),o=ee(n,r);return o===null?n.encodings[0]:o.encoding},ir=(e,r,t)=>{const n=V(e,r,t),o=ee(n,r);return o!==null?o.text:new TextDecoder(n.encodings[0],{ignoreBOM:!0}).decode(n.body,{stream:!r})},N=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),sr=/^readme(?:\.|$)/iu,de=/^readme(?:\.[^.]*)?$/iu,le=Object.freeze(["md","markdown","mdx","txt",""]),ar=e=>sr.test(e),X=e=>e.type==="file"&&ar(e.name),ce=e=>{const r=e.lastIndexOf("."),t=le.indexOf(r<0?"":e.slice(r+1).toLowerCase());return t<0?le.length:t},dr=(e,r)=>{const t=+!de.test(e.name)-+!de.test(r.name);if(t!==0)return t;const n=ce(e.name)-ce(r.name);if(n!==0)return n;const o=N.compare(e.name,r.name);return o!==0?o:N.compare(e.path,r.path)},lr=e=>{let r=null;for(const t of e)X(t)&&(r===null||dr(t,r)<0)&&(r=t);return r===null?null:r.path},W=Object.freeze({sortMode:"native",folderPlacement:"mixed",readmePlacement:"mixed",selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,revealDocument:!1,showFolderReadme:!0,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),he=[!0,!1],pe=(e,r)=>r?e.settingOn:e.settingOff,y=(e,r)=>({key:e,labelKey:r,values:he,formatValue:pe,requiresTreeView:!1}),cr=Object.freeze({native:e=>e.sortNative,asc:e=>e.sortAscending,desc:e=>e.sortDescending,oldest:e=>e.sortOldest,newest:e=>e.sortNewest}),R=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc","oldest","newest"],formatValue:(e,r)=>cr[r](e),requiresTreeView:!1},{key:"folderPlacement",labelKey:"settingFolderPlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.folderPlacementMixed:r==="first"?e.folderPlacementFirst:e.folderPlacementLast,requiresTreeView:!1},{key:"readmePlacement",labelKey:"settingReadmePlacement",values:["mixed","first","last"],formatValue:(e,r)=>r==="mixed"?e.readmePlacementMixed:r==="first"?e.readmePlacementFirst:e.readmePlacementLast,requiresTreeView:!1},{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,r)=>r==="single"?e.selectionSingle:r==="multiple"?e.selectionMultiple:e.selectionNone,requiresTreeView:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,r)=>r==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresTreeView:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,r)=>e.expandIconSizeValue(r),requiresTreeView:!1},y("alwaysExpanded","settingAlwaysExpanded"),y("revealDocument","settingRevealDocument"),{key:"showFolderReadme",labelKey:"settingShowFolderReadme",values:he,formatValue:pe,requiresTreeView:!0},y("removeRootIndent","settingRemoveRootIndent"),y("lines","settingTreeLines"),y("expandIcons","settingExpandIcons"),y("directoryIcons","settingDirectoryIcons"),y("fileIcons","settingFileIcons")]),ur=e=>e==="tree"?R:R.filter(r=>!r.requiresTreeView),be=e=>{const r=R.find(t=>t.key===e);if(r===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return r},mr=(e,r)=>{const t=be(r).values,n=t[(t.indexOf(e[r])+1)%t.length];return{...e,[r]:n}},fr=(e,r,t)=>be(t).formatValue(e,r[t]),xe=2,H=Object.freeze({}),re=(e,r)=>Object.freeze(Object.fromEntries(R.filter(t=>r(t,e[t.key])).map(t=>[t.key,e[t.key]]))),ue="directoriesFirst",wr=e=>{if(!Object.hasOwn(e,ue))return e;const{[ue]:r,...t}=e;return Object.hasOwn(t,"folderPlacement")||typeof r!="boolean"?t:{...t,folderPlacement:r?"first":"mixed"}},gr=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return H;const r=e;return r.version!==xe||r.settings===null||typeof r.settings!="object"||Array.isArray(r.settings)?H:re(wr(r.settings),(t,n)=>t.values.includes(n))},Er=(e,r)=>{const t=re(r,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(t).length===0?e:Object.freeze({...e,...t})},hr=(e,r,t,n)=>re({...e,[r]:t},(o,s)=>s!==void 0&&!(o.key===r&&s===n[r])),pr=e=>JSON.stringify({version:xe,settings:e}),br=(e,r,t)=>e===void 0||r===void 0?e===r?0:e===void 0?1:-1:t*(e-r),xr=e=>{const{sortMode:r,folderPlacement:t,readmePlacement:n}=e;if(r==="native"&&t==="mixed"&&n==="mixed")return;const o=(s,a)=>{const d=N.compare(s.name,a.name);return d!==0?d:N.compare(s.path,a.path)};return(s,a)=>{if(t!=="mixed"&&s.type!==a.type)return s.type==="directory"==(t==="first")?-1:1;if(n!=="mixed"){const l=X(s);if(l!==X(a))return l===(n==="first")?-1:1}if(r==="native")return 0;if(r==="asc")return o(s,a);if(r==="desc")return-o(s,a);const d=br(s.modifiedAt,a.modifiedAt,r==="oldest"?1:-1);return d!==0?d:o(s,a)}},x=(1+Math.sqrt(5))/2,Sr=100/x**3,Or=100/x**4,te=100/x**2,Se=13,Tr=16,yr=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),K=Object.freeze([1,2,3,5,8,13,21,34,55]),_r=Object.freeze([89,144,233,377]),ne=44,Ir=ne;2*K[3]+ne+K[0];const Rr=1/x,kr=1/x**3,Pr="40ch",Ar=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${i.describeValue(e)}`)},Oe=e=>(Ar(e),Se*e),Lr=e=>Oe(e)*x**2,Nr=233,vr=50,Te=100/x**3,Dr=100-Te,$r=_r[0],S=(e,r)=>{if(!Number.isFinite(r)||r<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${i.describeValue(r)}`)},Cr=({trackInlineSize:e,gap:r,minColumnInlineSize:t,logicalColumns:n})=>{if(S("trackInlineSize",e),S("gap",r),!Number.isFinite(t)||t<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${i.describeValue(t)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${i.describeValue(n)}`);const o=Math.floor((e+r)/(t+r));return Math.min(n,Math.max(1,o))},Mr=(e,r)=>{const{trackInlineSize:t,gap:n,minColumnInlineSize:o,logicalColumns:s}=r;if(!([t,n,o].every(Number.isFinite)&&t>0&&n>=0&&o>0))return e;const d=Cr(r);if(e===null||d===e)return d;const l=Math.min(s,Math.max(1,e));if(d>l){const w=(l+1)*o+l*n+n/x;return t>=w?d:l}return t>=l*o+(l-1)*n?l:d},Vr=(e,r)=>{if(!(Number.isInteger(e)&&Number.isInteger(r))||r<1||r>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${i.describeValue(r)}`);return Array.from({length:r},(t,n)=>[Math.floor(n*e/r),Math.floor((n+1)*e/r)])},zr=(e,r,t)=>{if(S("surfaceInlineSize",e),S("handlePixels",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] measure must be a finite number > 0; got ${i.describeValue(r)}`);return e>=2*r+t?"beside":"stacked"},G=(e,r,t)=>Math.max(r,Math.min(e,t)),me=(e,r,t,n)=>{const o=(G(e,0,t)+G(r,0,t))/2;return G(o-n/2,0,t-n)},jr=(e,r,t)=>{for(const[n,o]of Object.entries(e))if(!Number.isFinite(o))throw new RangeError(`[markdown-explorer] anchor.${n} must be a finite number; got ${i.describeValue(o)}`);return S("marginBox.width",r.width),S("marginBox.height",r.height),S("viewport.width",t.width),S("viewport.height",t.height),{left:me(e.left,e.right,t.width,r.width),top:me(e.top,e.bottom,t.height,r.height)}},Fr=31536e3,Ur=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,Br=e=>{if(typeof e!="string"||!Ur.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${i.describeValue(e)}`)},fe=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=te,D=(e,r)=>typeof r=="string"&&e.includes(r),Gr=(e,r)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const t=e,{treeExplorer:n,treeExplorerHidden:o,multiExplorer:s,multiExplorerHidden:a,style:d,align:l,measure:m,documentColors:w}=t;return{...fe(n)?{treeExplorer:n}:{},...o===!0?{treeExplorerHidden:o}:{},...fe(s)?{multiExplorer:s}:{},...a===!0?{multiExplorerHidden:a}:{},...D(r,d)?{style:d}:{},...D(T.CONTENT_ALIGNS,l)?{align:l}:{},...D(T.CONTENT_MEASURES,m)?{measure:m}:{},...D(T.CONTENT_COLORS,w)?{documentColors:w}:{}}},Xr=(e,r)=>{if(e!==null)for(const t of e.split(";")){const n=t.indexOf("=");if(!(n<0)&&t.slice(0,n).trim()===r)return t.slice(n+1).trim()}},Wr=(e,r)=>{if(e===void 0||e==="")return{};try{return Gr(JSON.parse(decodeURIComponent(e)),r)}catch{return{}}},C=100,Hr=Math.floor(te*C)/C,ye=e=>{const r=t=>Math.min(Hr,Math.max(1,Math.round(t*C))/C);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:r(e.treeExplorer)},...e.treeExplorerHidden===!0?{treeExplorerHidden:!0}:{},...e.multiExplorer===void 0?{}:{multiExplorer:r(e.multiExplorer)},...e.multiExplorerHidden===!0?{multiExplorerHidden:!0}:{},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align},...e.measure===void 0?{}:{measure:e.measure},...e.documentColors===void 0?{}:{documentColors:e.documentColors}}))},Kr=(e,r,t)=>`${e}=${ye(r)}; Path=/; Max-Age=${String(Fr)}; SameSite=Lax${t?"; Secure":""}`,_e=["ctrl","shift"],qr=e=>typeof e=="string"&&_e.includes(e),q=Object.freeze({tree:"tree",multi:"multi",single:"single"}),Ie=Object.freeze({default:12,min:1,max:64}),Re=Object.freeze({default:4,min:1,max:6}),ke=Object.freeze({default:500,min:1,max:1e4}),Pe=Object.freeze({default:16,min:1,max:64}),Ae=Object.freeze({default:16,min:1,max:64}),Le=Object.freeze({default:2*1024*1024,min:1,max:256*1024*1024}),Ne=Object.freeze({default:8*1024*1024,min:1,max:256*1024*1024}),ve=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,Yr=/^[a-z0-9][a-z0-9-]*$/u,Jr=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,Y=(e,r)=>{if(typeof r!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${i.describeValue(r)}`);if(!h.isMountPath(r))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", use only letters, digits and "._~-" in each segment, and have no "." or ".." segment; got ${i.describeValue(r)}`)},we=Object.freeze(Object.keys({basePath:!0,dataPath:!0,settingsCookie:!0,views:!0,documentIds:!0,multiView:!0,expandAll:!0,revealDocument:!0,documentStyles:!0,defaultDocumentStyle:!0,mermaidModifier:!0,documentFontFamily:!0,iframeHosts:!0,appOrigins:!0,mediaDataPath:!0,embeds:!0,defaultTreeSettings:!0,legacyTextEncoding:!0,spreadsheets:!0})),O=(e,r,t)=>{if(r===void 0)return[];if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${i.describeValue(r)}`);const n=Object.entries(r);for(const[o]of n)if(!t.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${t.join(", ")}`);return n.filter(([,o])=>o!==void 0)},Zr=e=>{const r={...q};for(const[t,n]of O("views",e,Object.keys(q)))r[t]=n;for(const[t,n]of Object.entries(r))if(typeof n!="string"||!ve.test(n))throw new RangeError(`[markdown-explorer] views.${t} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(n)}`);return Object.freeze(r)},Qr=e=>{if(e===void 0)return null;const r=O("documentIds",e,["slug"]).find(([t])=>t==="slug")?.[1];if(typeof r!="string"||!ve.test(r))throw new RangeError(`[markdown-explorer] documentIds.slug must start with a letter or digit and use only letters, digits, "_" and "-"; got ${i.describeValue(r)}`);return Object.freeze({slug:r})},_=(e,r,t)=>{if(r===void 0)return t.default;if(typeof r!="number"||!Number.isInteger(r)||r<t.min||r>t.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(t.min)}..${String(t.max)}; got ${i.describeValue(r)}`);return r},et=(e,r)=>{const t=new Map(O("embeds",e,["providers","linkCards","linkCardSize"]));if(t.size===0)return L.NO_EMBEDS;const n=t.has("providers")?t.get("providers"):[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${i.describeValue(n)}`);for(const d of n)if(!L.isEmbedProviderId(d))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${L.EMBED_PROVIDER_IDS.join(", ")}; got ${i.describeValue(d)}`);const o=t.has("linkCards")?t.get("linkCards"):!1;if(typeof o!="boolean")throw new RangeError(`[markdown-explorer] embeds.linkCards must be a boolean; got ${i.describeValue(o)}`);const s={providers:Object.freeze([...new Set(n)]),linkCardEndpoint:o?h.explorerLinkCardEndpoint(r):null};if(!t.has("linkCardSize"))return Object.freeze(s);const a=t.get("linkCardSize");if(!L.isLinkCardSize(a))throw new RangeError(`[markdown-explorer] embeds.linkCardSize must be one of ${L.LINK_CARD_SIZES.join(", ")}; got ${i.describeValue(a)}`);if(!o)throw new RangeError(`[markdown-explorer] embeds.linkCardSize needs embeds.linkCards: true; got linkCardSize ${i.describeValue(a)} with linkCards ${i.describeValue(o)}`);return Object.freeze({...s,linkCardSize:a})},rt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] legacyTextEncoding must be a string; got ${i.describeValue(e)}`);return Q(e)},tt=e=>{if(e===void 0)return Object.freeze([]);if(!Array.isArray(e))throw new TypeError(`[markdown-explorer] appOrigins must be an array of origins; got ${i.describeValue(e)}`);for(const[r,t]of e.entries()){if(typeof t!="string")throw new TypeError(`[markdown-explorer] appOrigins[${String(r)}] must be a string; got ${i.describeValue(t)}`);if(!h.isBrowserOrigin(t))throw new RangeError(`[markdown-explorer] appOrigins[${String(r)}] must be an origin as the browser writes it (scheme://host[:port], without a default port, path, query, fragment or user info); got ${i.describeValue(t)}`)}return Object.freeze([...new Set(e)])},nt=e=>{if(e===void 0)return null;if(typeof e!="string")throw new TypeError(`[markdown-explorer] mediaDataPath must be a string; got ${i.describeValue(e)}`);if(!h.isMediaDataUrl(e))throw new RangeError(`[markdown-explorer] mediaDataPath must be an absolute http: or https: URL as the browser writes it, of an origin and a path that starts with "/", has no trailing "/", uses only letters, digits and "._~-" in each segment and has no "." or ".." segment, without a query, fragment or user info; got ${i.describeValue(e)}`);return e},ot=e=>{const r=new Map(O("defaultTreeSettings",e,R.map(n=>n.key)));if(r.size===0)return W;const t={...W};for(const n of R){if(!r.has(n.key))continue;const o=r.get(n.key),s=n.values;if(!s.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${s.map(i.describeValue).join(", ")}; got ${i.describeValue(o)}`);t[n.key]=o}return Object.freeze(t)},De=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");for(const c of Object.keys(e))if(!we.includes(c))throw new RangeError(`[markdown-explorer] ${c} is not an option of the explorer configuration; expected ${we.join(", ")}`);Y("basePath",e.basePath),Y("dataPath",e.dataPath);const r=Zr(e.views);if(new Set([r.tree,r.multi,r.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got tree ${i.describeValue(r.tree)}, multi ${i.describeValue(r.multi)} and single ${i.describeValue(r.single)}`);const t=Qr(e.documentIds);if(t!==null&&[r.tree,r.multi,r.single].includes(t.slug))throw new RangeError(`[markdown-explorer] documentIds.slug must differ from the view slugs; got ${i.describeValue(t.slug)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const c=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(c===r.tree||c===r.multi||c===r.single||c===t?.slug)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug or documentIds.slug under basePath; got ${i.describeValue(e.dataPath)}`)}Br(e.settingsCookie);const n=e.iframeHosts??[];if(!Array.isArray(n))throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${i.describeValue(n)}`);for(const[c,E]of n.entries())if(typeof E!="string"||!Jr.test(E))throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${i.describeValue(E)}`);const o=Object.fromEntries(O("multiView",e.multiView,["maxPanels","columns"])),s=Object.fromEntries(O("expandAll",e.expandAll,["maxFolders","maxDepth"])),a=Object.fromEntries(O("revealDocument",e.revealDocument,["maxDepth"])),d=Object.fromEntries(O("spreadsheets",e.spreadsheets,["maxBytes","maxWorkbookBytes"])),l=e.documentStyles??T.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(l)||l.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const m=new Set;for(const c of l){if(c===null||typeof c!="object"||typeof c.name!="string"||c.name.trim()===""||typeof c.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(m.has(c.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${i.describeValue(c.name)} repeats`);m.add(c.name)}const w=e.defaultDocumentStyle===void 0?T.DEFAULT_MARKDOWN_STYLE:e.defaultDocumentStyle;if(typeof w!="string")throw new TypeError(`[markdown-explorer] defaultDocumentStyle must be a string; got ${i.describeValue(w)}`);if(!m.has(w)){const c=e.defaultDocumentStyle===void 0?" (the default, DEFAULT_MARKDOWN_STYLE; name one of documentStyles)":"";throw new RangeError(`[markdown-explorer] defaultDocumentStyle must name a configured document style (${[...m].map(i.describeValue).join(", ")}); got ${i.describeValue(w)}${c}`)}const f=e.mermaidModifier;if(f!==void 0&&!qr(f))throw new RangeError(`[markdown-explorer] mermaidModifier must be one of ${_e.map(i.describeValue).join(", ")}; got ${i.describeValue(f)}`);const g=e.documentFontFamily;if(g!==void 0){if(typeof g!="string")throw new TypeError(`[markdown-explorer] documentFontFamily must be a string; got ${i.describeValue(g)}`);if(g.trim()==="")throw new RangeError("[markdown-explorer] documentFontFamily must not be blank; omit it for the display style's font")}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:r,documentIds:t,multiView:Object.freeze({maxPanels:_("multiView.maxPanels",o.maxPanels,Ie),columns:_("multiView.columns",o.columns,Re)}),expandAll:Object.freeze({maxFolders:_("expandAll.maxFolders",s.maxFolders,ke),maxDepth:_("expandAll.maxDepth",s.maxDepth,Pe)}),revealDocument:Object.freeze({maxDepth:_("revealDocument.maxDepth",a.maxDepth,Ae)}),documentStyles:Object.freeze(l.map(c=>Object.freeze({name:c.name,className:c.className}))),defaultDocumentStyle:w,mermaidModifier:f,documentFontFamily:g,iframeHosts:Object.freeze([...new Set(n)]),appOrigins:tt(e.appOrigins),mediaDataPath:nt(e.mediaDataPath),embeds:et(e.embeds,e.dataPath),defaultTreeSettings:ot(e.defaultTreeSettings),legacyTextEncoding:rt(e.legacyTextEncoding),spreadsheets:Object.freeze({maxBytes:_("spreadsheets.maxBytes",d.maxBytes,Le),maxWorkbookBytes:_("spreadsheets.maxWorkbookBytes",d.maxWorkbookBytes,Ne)})})},it=e=>{const r=e.embeds;if(!i.isPlainObject(r))throw new TypeError(`[markdown-explorer] config.embeds must be the embeds defineExplorerConfig resolved; got ${i.describeValue(r)}`);if(Object.hasOwn(r,"linkCards"))throw new RangeError(`[markdown-explorer] config.embeds.linkCards is an option of defineExplorerConfig, not a key of the embeds it resolves; pass the option to defineExplorerConfig (got linkCards ${i.describeValue(r.linkCards)})`);const t=e.legacyTextEncoding;if(t!==null&&typeof t!="string")throw new TypeError(`[markdown-explorer] config.legacyTextEncoding must be the encoding defineExplorerConfig resolved, or null; got ${i.describeValue(t)}`);const n=e.mediaDataPath;if(n!==null&&typeof n!="string")throw new TypeError(`[markdown-explorer] config.mediaDataPath must be the URL defineExplorerConfig resolved, or null; got ${i.describeValue(n)}`);const o=e.documentIds;if(o!==null&&!i.isPlainObject(o))throw new TypeError(`[markdown-explorer] config.documentIds must be the segment defineExplorerConfig resolved, or null; got ${i.describeValue(o)}`);const{linkCardEndpoint:s,...a}=r,d=De({...e,embeds:{...a,linkCards:s!==null},legacyTextEncoding:t===null?void 0:t,mediaDataPath:n===null?void 0:n,documentIds:o===null?void 0:o});if(d.embeds.linkCardEndpoint!==s)throw new RangeError(`[markdown-explorer] config.embeds.linkCardEndpoint must be ${i.describeValue(d.embeds.linkCardEndpoint)} (the data route's link-card path) or null; got ${i.describeValue(s)}`);if(d.legacyTextEncoding!==t)throw new RangeError(`[markdown-explorer] config.legacyTextEncoding must be ${i.describeValue(d.legacyTextEncoding)} (the written name of the encoding it names); got ${i.describeValue(t)}`);const l=e;for(const[m,w]of Object.entries(d)){const f=J(l[m],w,m);if(f!==null)throw f.kind==="extra"?new RangeError(`[markdown-explorer] config.${f.path} is not a key of what defineExplorerConfig resolves; got ${i.describeValue(f.given)} there`):new RangeError(`[markdown-explorer] config.${f.path} must be what defineExplorerConfig resolves; got ${i.describeValue(f.given)} where it resolves ${i.describeValue(f.resolved)}`)}return d},J=(e,r,t)=>{if(Object.is(e,r))return null;if(Array.isArray(r)){if(!Array.isArray(e))return{kind:"value",path:t,given:e,resolved:r};if(e.length!==r.length)return{kind:"value",path:`${t}.length`,given:e.length,resolved:r.length};for(const[o,s]of r.entries()){const a=J(e[o],s,`${t}[${String(o)}]`);if(a!==null)return a}return null}if(!(i.isPlainObject(r)&&i.isPlainObject(e)))return{kind:"value",path:t,given:e,resolved:r};for(const o of Object.keys(r)){const s=J(Object.hasOwn(e,o)?e[o]:void 0,r[o],`${t}.${o}`);if(s!==null)return s}const n=Object.keys(e).find(o=>!Object.hasOwn(r,o));return n===void 0?null:{kind:"extra",path:`${t}.${n}`,given:e[n]}},$e=e=>typeof e=="string"&&Yr.test(e),st=(e,r)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${i.describeValue(e)}`);if(!Array.isArray(r)||r.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${i.describeValue(r)}`);const t=new Set;for(const[n,o]of r.entries()){if(!$e(o))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${i.describeValue(o)}`);if(t.has(o))throw new RangeError(`[markdown-explorer] source ids must be unique; ${i.describeValue(o)} repeats at sourceIds[${String(n)}]`);t.add(o)}return Object.freeze({...e,sourceIds:Object.freeze([...r])})},at=e=>e.documentStyles.map(r=>r.name),dt=e=>Object.freeze({origins:e.appOrigins,resources:Object.freeze([e.dataPath]),links:Object.freeze([e.basePath,e.dataPath]),media:Object.freeze(e.mediaDataPath===null?[]:[e.mediaDataPath])}),u=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth",markup:"markup"}),Ce="true",Me="true",M="/",ge=".data",Ve=256,ze=/^\d+(?:\.\d+)?$/u,Z=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,je=Object.freeze(["showToc","showStyle","showAlign"]),Ee=e=>{const r=encodeURIComponent(e.replaceAll("%","%25"));return r.endsWith(ge)?`${r.slice(0,-ge.length)}%2Edata`:r},lt=e=>e.replaceAll("%25","%"),Fe=e=>{const{sourceIds:r}=e;if(r===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return r},ct=(e,r,t)=>{const n=t.getAll(u.source);if(n.length===0)return r;const[o]=n;return n.length>1||o===void 0||o===r||!e.includes(o)?null:o},Ue=(e,r)=>{const t=r.get(u.style),n=r.get(u.align);return{...t!==null&&e.documentStyles.some(o=>o.name===t)?{style:t}:{},...n!==null&&T.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},Be=e=>Number.isFinite(e)&&e>=0&&e<=Ve&&ze.test(String(e)),Ge=e=>{const r=e.get(u.padding),t=r!==null&&ze.test(r)?Number(r):Number.NaN,n=e.get(u.width),o=e.get(u.maxWidth);return{...e.get(u.showToc)==="false"?{showToc:!1}:{},...e.get(u.showStyle)==="false"?{showStyle:!1}:{},...e.get(u.showAlign)==="false"?{showAlign:!1}:{},...Be(t)?{padding:t}:{},...n!==null&&Z.test(n)?{width:n}:{},...o!==null&&Z.test(o)?{maxWidth:o}:{}}},Xe=(e,r)=>[...new Set(r.filter(h.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),ut=(e,r,t,n)=>{for(const s of r)oe(s);if(new Set(r).size!==r.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(r.length)} with repeats`);if(r.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(r.length)}`);if(t!==null&&!r.includes(t))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${i.describeValue(t)}`);if(new Set(n).size!==n.length)throw new RangeError(`[markdown-explorer] the documents shown as written must each appear once; got ${String(n.length)} with repeats`);const o=n.find(s=>!r.includes(s));if(o!==void 0)throw new RangeError(`[markdown-explorer] a document shown as written must be one of the open documents; got ${i.describeValue(o)}`)},oe=e=>{if(!h.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${i.describeValue(e)}`);return e},mt=e=>{if(!We(oe(e)))throw new RangeError(`[markdown-explorer] a document path ending in a slash has no URL (its segment would name a folder): ${i.describeValue(e)}`);return e},We=e=>h.isAcceptableDocumentPath(e)&&!e.endsWith(M),ft=(e,r)=>{if(r.style!==void 0&&!e.documentStyles.some(t=>t.name===r.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(t=>i.describeValue(t.name)).join(", ")}); got ${i.describeValue(r.style)}`);if(r.align!==void 0&&!T.CONTENT_ALIGNS.includes(r.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${T.CONTENT_ALIGNS.join(", ")}; got ${i.describeValue(r.align)}`)},wt=e=>{for(const r of je)if(e[r]!==void 0&&typeof e[r]!="boolean")throw new RangeError(`[markdown-explorer] embed.${r} must be a boolean; got ${i.describeValue(e[r])}`);if(e.padding!==void 0&&!Be(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(Ve)} px in plain decimal digits; got ${i.describeValue(e.padding)}`);for(const r of["width","maxWidth"]){const t=e[r];if(t!==void 0&&!Z.test(t))throw new RangeError(`[markdown-explorer] embed.${r} must be a CSS length in px, rem, em, ch, vw or %; got ${i.describeValue(t)}`)}},ie=(e,r)=>{if(r.view==="document-id")return gt(e,r);const t=new URLSearchParams;let n=`${e.basePath}/${e.views[r.view]}`;if(r.view==="multi"){const s=r.docs??[],a=r.maximized??null,d=r.markup??[];ut(e,s,a,d);for(const l of s)t.append(u.doc,l);a!==null&&t.set(u.maximized,a);for(const l of s)d.includes(l)&&t.append(u.markup,l)}else{const s=r.doc??null,a=r.view==="tree"?r.folder??null:null;if(s!==null&&a!==null)throw new RangeError("[markdown-explorer] a tree view shows a document or a folder, not both");s!==null&&(n+=`/${Ee(mt(s))}`),a!==null&&(n+=`/${Ee(`${oe(a)}${M}`)}`)}if(r.source!==void 0){const s=Fe(e);if(!s.includes(r.source))throw new RangeError(`[markdown-explorer] unknown source ${i.describeValue(r.source)}; expected one of ${s.join(", ")}`);r.source!==s[0]&&t.set(u.source,r.source)}r.view!=="multi"&&r.overrides!==void 0&&He(e,t,r.overrides);const o=r.view!=="multi"&&(r.doc!==void 0&&r.doc!==null||r.view==="tree"&&r.folder!==void 0&&r.folder!==null);if(r.view==="tree"&&r.maximized===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");t.set(u.maximized,Me)}if(r.view!=="multi"&&r.markup===!0){if(!o)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to show as written");t.set(u.markup,Ce)}return r.view==="single"&&r.embed!==void 0&&Ke(t,r.embed),qe(n,t)},gt=(e,r)=>{if(e.documentIds===null)throw new TypeError("[markdown-explorer] an ID link needs documentIds in defineExplorerConfig");if(!h.isCanonicalDocumentId(r.id))throw new RangeError(`[markdown-explorer] not a canonical document ID: ${i.describeValue(r.id)}`);if(r.opens!==void 0&&r.opens!=="single")throw new RangeError(`[markdown-explorer] opens must be "single" or absent; got ${i.describeValue(r.opens)}`);if(r.embed!==void 0&&r.opens!=="single")throw new RangeError('[markdown-explorer] embed needs opens: "single" (only the single view takes embedding options)');const t=new URLSearchParams;r.overrides!==void 0&&He(e,t,r.overrides),r.embed!==void 0&&Ke(t,r.embed);const n=r.opens==="single"?`/${e.views.single}`:"";return qe(`${e.basePath}/${e.documentIds.slug}/${r.id}${n}`,t)},He=(e,r,t)=>{ft(e,t),t.style!==void 0&&r.set(u.style,t.style),t.align!==void 0&&r.set(u.align,t.align)},Ke=(e,r)=>{wt(r);for(const t of je)r[t]===!1&&e.set(u[t],"false");r.padding!==void 0&&e.set(u.padding,String(r.padding)),r.width!==void 0&&e.set(u.width,r.width),r.maxWidth!==void 0&&e.set(u.maxWidth,r.maxWidth)},qe=(e,r)=>{const t=r.toString();return t===""?e:`${e}?${t}`},Et=(e,r)=>Object.keys(e.views).find(t=>e.views[t]===r),ht=(e,r,t)=>{const n=Fe(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const s=ct(n,o,t),a=s===null?o:s,d=b=>({kind:"redirect",href:ie(e,b),location:b}),l=()=>d({view:"tree",source:a,doc:null,folder:null,overrides:{},markup:!1,maximized:!1});if(r===void 0||r==="")return l();const m=r.indexOf("/"),w=m<0?r:r.slice(0,m),f=m<0?null:r.slice(m+1);if(e.documentIds!==null&&w===e.documentIds.slug)return pt(e,f,t,o,l);const g=Et(e,w);if(g===void 0)return l();if(g==="multi"){const b=t.getAll(u.doc),I=Xe(e,b),z=t.getAll(u.maximized),[j]=z,F=z.length===1&&j!==void 0&&I.includes(j)?j:null,U=t.getAll(u.markup),v=I.filter(A=>U.includes(A)),Ye=v.length===U.length&&v.every((A,B)=>A===U[B]);return f===null&&s!==null&&I.length===b.length&&I.every((A,B)=>A===b[B])&&(z.length===0||F!==null)&&Ye?{kind:"location",location:{view:"multi",source:a,docs:I,maximized:F,markup:v}}:d({view:"multi",source:a,docs:I,maximized:F,markup:v})}const c=f===null?null:lt(f),E=c?.endsWith(M)===!0?c.slice(0,-M.length):null,p=c!==null&&E===null?c:null;if(p!==null&&!h.isAcceptableDocumentPath(p)||E!==null&&!h.isAcceptableDocumentPath(E))return l();const k=Ue(e,t),P=(p!==null||E!==null)&&t.get(u.markup)===Ce;if(g==="single"){if(E!==null)return d({view:"tree",source:a,doc:null,folder:E,overrides:k,markup:P,maximized:!1});if(p===null)return l();const b=Ge(t);return s===null?d({view:g,source:a,doc:p,overrides:k,embed:b,markup:P}):{kind:"location",location:{view:g,source:a,doc:p,overrides:k,embed:b,markup:P}}}const se=(p!==null||E!==null)&&t.get(u.maximized)===Me;return s===null?d({view:g,source:a,doc:p,folder:E,overrides:k,markup:P,maximized:se}):{kind:"location",location:{view:g,source:a,doc:p,folder:E,overrides:k,markup:P,maximized:se}}},pt=(e,r,t,n,o)=>{if(r===null||r==="")return o();const s=r.indexOf("/"),a=h.parseDocumentId(s<0?r:r.slice(0,s)),d=s<0?null:r.slice(s+1),l=Ue(e,t),m={view:"tree",source:n,doc:null,folder:null,overrides:{},markup:!1,maximized:!1};return d===e.views.single?{kind:"document-id",id:a,opens:{view:"single",overrides:l,embed:Ge(t)},location:m}:d!==null&&a!==null?{kind:"redirect",href:ie(e,{view:"document-id",id:a,overrides:l}),location:m}:{kind:"document-id",id:a,opens:{view:"tree",overrides:l},location:m}},bt=(e,r,t)=>e.view==="single"?{view:"single",source:t,doc:r,overrides:e.overrides,embed:e.embed}:{view:"tree",source:t,doc:r,overrides:e.overrides};exports.ASSUMED_ROOT_FONT_PIXELS=Tr;exports.COARSE_TARGET_PIXELS=Ir;exports.COLUMN_MIN_MEASURE=Pr;exports.CONTROL_BLOCK_PIXELS=ne;exports.DEFAULT_TREE_SETTINGS=W;exports.DEFAULT_VIEW_SLUGS=q;exports.EDIT_SPLIT_DEFAULT_PERCENT=vr;exports.EDIT_SPLIT_MAX_PERCENT=Dr;exports.EDIT_SPLIT_MIN_PERCENT=Te;exports.EXPAND_ALL_DEPTH_LIMITS=Pe;exports.EXPAND_ALL_FOLDER_LIMITS=ke;exports.EXPLORER_DEFAULT_PERCENT=Sr;exports.EXPLORER_MAX_PERCENT=te;exports.EXPLORER_MIN_REM=Se;exports.EXPLORER_MULTI_DEFAULT_PERCENT=Or;exports.FIBONACCI_SPACING_PIXELS=K;exports.GOLDEN_RATIO=x;exports.MULTI_VIEW_COLUMN_LIMITS=Re;exports.MULTI_VIEW_PANEL_LIMITS=Ie;exports.NAME_COLLATOR=N;exports.NO_TREE_SETTING_CHANGES=H;exports.PANEL_MAX_BLOCK_RATIO=Rr;exports.PANEL_MIN_BLOCK_RATIO=kr;exports.PREFETCH_DWELL_MS=$r;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=Ae;exports.SPLIT_HANDLE_PIXELS=yr;exports.SPLIT_PERSIST_DELAY_MS=Nr;exports.SPREADSHEET_BYTE_LIMITS=Le;exports.WORKBOOK_BYTE_LIMITS=Ne;exports.advanceTreeSetting=mr;exports.applyTreeSettingChanges=Er;exports.assertMountPath=Y;exports.canonicalMultiDocuments=Xe;exports.centeredDialogPosition=jr;exports.columnGroups=Vr;exports.createEntryComparator=xr;exports.decodeText=nr;exports.decodeTextLeniently=ir;exports.defineExplorerConfig=De;exports.documentIdOpeningTarget=bt;exports.documentStyleNames=at;exports.editSplitOrientation=zr;exports.explorerHref=ie;exports.explorerMinPixels=Oe;exports.explorerSheetBelowPixels=Lr;exports.folderReadmeOf=lr;exports.formatTreeSettingValue=fr;exports.hasDocumentUrl=We;exports.isExplorerSourceId=$e;exports.legacyTextEncodingOf=Q;exports.ownUrlsOf=dt;exports.parseViewSettings=Wr;exports.readCookieValue=Xr;exports.readTreeSettingChanges=gr;exports.recordTreeSettingChange=hr;exports.replanVisibleColumns=Mr;exports.resolveExplorerLocation=ht;exports.revalidateExplorerConfig=it;exports.serializeTreeSettingChanges=pr;exports.serializeViewSettings=ye;exports.textEncodingOf=or;exports.textEncodingsOf=rr;exports.viewSettingsCookieString=Kr;exports.visibleTreeSettingDescriptors=ur;exports.withExplorerSources=st;
|
|
@@ -329,6 +329,7 @@ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
|
329
329
|
documentStyles: !0,
|
|
330
330
|
defaultDocumentStyle: !0,
|
|
331
331
|
mermaidModifier: !0,
|
|
332
|
+
documentFontFamily: !0,
|
|
332
333
|
iframeHosts: !0,
|
|
333
334
|
appOrigins: !0,
|
|
334
335
|
mediaDataPath: !0,
|
|
@@ -435,9 +436,9 @@ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
|
435
436
|
ht(e.settingsCookie);
|
|
436
437
|
const n = e.iframeHosts ?? [];
|
|
437
438
|
if (!Array.isArray(n)) throw new RangeError(`[markdown-explorer] iframeHosts must be an array of lowercase host names without scheme, port or path; got ${s(n)}`);
|
|
438
|
-
for (const [c,
|
|
439
|
-
if (typeof
|
|
440
|
-
throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(
|
|
439
|
+
for (const [c, h] of n.entries())
|
|
440
|
+
if (typeof h != "string" || !_t.test(h))
|
|
441
|
+
throw new RangeError(`[markdown-explorer] iframeHosts[${String(c)}] must be a lowercase host name without scheme, port or path; got ${s(h)}`);
|
|
441
442
|
const o = Object.fromEntries(b("multiView", e.multiView, ["maxPanels", "columns"])), i = Object.fromEntries(b("expandAll", e.expandAll, ["maxFolders", "maxDepth"])), a = Object.fromEntries(b("revealDocument", e.revealDocument, ["maxDepth"])), d = Object.fromEntries(b("spreadsheets", e.spreadsheets, ["maxBytes", "maxWorkbookBytes"])), l = e.documentStyles ?? Be;
|
|
442
443
|
if (!Array.isArray(l) || l.length === 0) throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");
|
|
443
444
|
const u = /* @__PURE__ */ new Set();
|
|
@@ -456,6 +457,11 @@ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
|
456
457
|
const f = e.mermaidModifier;
|
|
457
458
|
if (f !== void 0 && !bt(f))
|
|
458
459
|
throw new RangeError(`[markdown-explorer] mermaidModifier must be one of ${be.map(s).join(", ")}; got ${s(f)}`);
|
|
460
|
+
const g = e.documentFontFamily;
|
|
461
|
+
if (g !== void 0) {
|
|
462
|
+
if (typeof g != "string") throw new TypeError(`[markdown-explorer] documentFontFamily must be a string; got ${s(g)}`);
|
|
463
|
+
if (g.trim() === "") throw new RangeError("[markdown-explorer] documentFontFamily must not be blank; omit it for the display style's font");
|
|
464
|
+
}
|
|
459
465
|
return Object.freeze({
|
|
460
466
|
basePath: e.basePath,
|
|
461
467
|
dataPath: e.dataPath,
|
|
@@ -474,6 +480,7 @@ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
|
474
480
|
documentStyles: Object.freeze(l.map((c) => Object.freeze({ name: c.name, className: c.className }))),
|
|
475
481
|
defaultDocumentStyle: w,
|
|
476
482
|
mermaidModifier: f,
|
|
483
|
+
documentFontFamily: g,
|
|
477
484
|
iframeHosts: Object.freeze([...new Set(n)]),
|
|
478
485
|
appOrigins: Nt(e.appOrigins),
|
|
479
486
|
mediaDataPath: Ct(e.mediaDataPath),
|
|
@@ -670,27 +677,27 @@ const xr = 1 / y, br = 1 / y ** 3, yr = "40ch", ct = (e) => {
|
|
|
670
677
|
}, Xt = (e, t) => Object.keys(e.views).find((r) => e.views[r] === t), Lr = (e, t, r) => {
|
|
671
678
|
const n = Ie(e), [o] = n;
|
|
672
679
|
if (o === void 0) throw new RangeError("[markdown-explorer] the configuration has no source");
|
|
673
|
-
const i = Ft(n, o, r), a = i === null ? o : i, d = (
|
|
680
|
+
const i = Ft(n, o, r), a = i === null ? o : i, d = (E) => ({ kind: "redirect", href: Pe(e, E), location: E }), l = () => d({ view: "tree", source: a, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 });
|
|
674
681
|
if (t === void 0 || t === "") return l();
|
|
675
682
|
const u = t.indexOf("/"), w = u < 0 ? t : t.slice(0, u), f = u < 0 ? null : t.slice(u + 1);
|
|
676
683
|
if (e.documentIds !== null && w === e.documentIds.slug) return qt(e, f, r, o, l);
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
679
|
-
if (
|
|
680
|
-
const
|
|
681
|
-
return f === null && i !== null && k.length ===
|
|
684
|
+
const g = Xt(e, w);
|
|
685
|
+
if (g === void 0) return l();
|
|
686
|
+
if (g === "multi") {
|
|
687
|
+
const E = r.getAll(m.doc), k = Ut(e, E), j = r.getAll(m.maximized), [F] = j, U = j.length === 1 && F !== void 0 && k.includes(F) ? F : null, V = r.getAll(m.markup), P = k.filter(($) => V.includes($)), Ce = P.length === V.length && P.every(($, B) => $ === V[B]);
|
|
688
|
+
return f === null && i !== null && k.length === E.length && k.every(($, B) => $ === E[B]) && (j.length === 0 || U !== null) && Ce ? { kind: "location", location: { view: "multi", source: a, docs: k, maximized: U, markup: P } } : d({ view: "multi", source: a, docs: k, maximized: U, markup: P });
|
|
682
689
|
}
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
const R = $e(e, r), I = (
|
|
686
|
-
if (
|
|
687
|
-
if (
|
|
688
|
-
if (
|
|
689
|
-
const
|
|
690
|
-
return i === null ? d({ view:
|
|
690
|
+
const c = f === null ? null : jt(f), h = c?.endsWith(z) === !0 ? c.slice(0, -z.length) : null, p = c !== null && h === null ? c : null;
|
|
691
|
+
if (p !== null && !_(p) || h !== null && !_(h)) return l();
|
|
692
|
+
const R = $e(e, r), I = (p !== null || h !== null) && r.get(m.markup) === Se;
|
|
693
|
+
if (g === "single") {
|
|
694
|
+
if (h !== null) return d({ view: "tree", source: a, doc: null, folder: h, overrides: R, markup: I, maximized: !1 });
|
|
695
|
+
if (p === null) return l();
|
|
696
|
+
const E = ve(r);
|
|
697
|
+
return i === null ? d({ view: g, source: a, doc: p, overrides: R, embed: E, markup: I }) : { kind: "location", location: { view: g, source: a, doc: p, overrides: R, embed: E, markup: I } };
|
|
691
698
|
}
|
|
692
|
-
const J = (
|
|
693
|
-
return i === null ? d({ view:
|
|
699
|
+
const J = (p !== null || h !== null) && r.get(m.maximized) === Oe;
|
|
700
|
+
return i === null ? d({ view: g, source: a, doc: p, folder: h, overrides: R, markup: I, maximized: J }) : { kind: "location", location: { view: g, source: a, doc: p, folder: h, overrides: R, markup: I, maximized: J } };
|
|
694
701
|
}, qt = (e, t, r, n, o) => {
|
|
695
702
|
if (t === null || t === "") return o();
|
|
696
703
|
const i = t.indexOf("/"), a = Ye(i < 0 ? t : t.slice(0, i)), d = i < 0 ? null : t.slice(i + 1), l = $e(e, r), u = { view: "tree", source: n, doc: null, folder: null, overrides: {}, markup: !1, maximized: !1 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diff3Merge as d } from "node-diff3";
|
|
2
|
-
import { C, a as R, b as u } from "./index-
|
|
2
|
+
import { C, a as R, b as u } from "./index-CWFyLa0N.js";
|
|
3
3
|
const g = (n, o, e, l) => {
|
|
4
4
|
if (o === n || o === e) return { kind: "clean", text: e };
|
|
5
5
|
if (e === n) return { kind: "clean", text: o };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-AfEbgYQI.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
|
|
2
2
|
`),n.split(`
|
|
3
3
|
`),i.split(`
|
|
4
4
|
`),{excludeFalseConflicts:!0}),o=[];let c=0;const u=s(l.ours),a=s(l.theirs);for(const e of d)e.ok!==void 0?o.push(...e.ok):e.conflict!==void 0&&(c+=1,o.push(`${r.CONFLICT_OURS_MARKER} ${u}`,...e.conflict.a,r.CONFLICT_SEPARATOR,...e.conflict.b,`${r.CONFLICT_THEIRS_MARKER} ${a}`));const f=o.join(`
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-BTPGNhBt.cjs"),v=require("./location-DFXJSMit.cjs"),P=require("./explorerCore-Dj7RxZRd.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-DomN7lwC.cjs"),X=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,X.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,X.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,X.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Xe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},qe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),q=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>qe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,q),T=A.size>BigInt(q),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>Xe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-BTPGNhBt.cjs"),v=require("./location-Csj3eAm_.cjs"),P=require("./explorerCore-diILGZTv.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-DomN7lwC.cjs"),X=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,X.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,X.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,X.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Xe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},qe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),q=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>qe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,q),T=A.size>BigInt(q),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>Xe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { b as Te, f as _e, i as $, g as I } from "./ownUrls-DD0cSCsF.js";
|
|
2
2
|
import { D as Yt, M as Kt, a as Jt } from "./ownUrls-DD0cSCsF.js";
|
|
3
|
-
import { r as Oe, l as Ne, b as K, N as Me } from "./location-
|
|
4
|
-
import { d as Zt } from "./location-
|
|
5
|
-
import { c as ve, E as C } from "./explorerCore-
|
|
3
|
+
import { r as Oe, l as Ne, b as K, N as Me } from "./location-DFfbnUZ9.js";
|
|
4
|
+
import { d as Zt } from "./location-DFfbnUZ9.js";
|
|
5
|
+
import { c as ve, E as C } from "./explorerCore-COhVrnGO.js";
|
|
6
6
|
import { createHash as Re, createHmac as Ae } from "node:crypto";
|
|
7
7
|
import { createLinkCardHandler as Le } from "@aiquants/markdown/server";
|
|
8
8
|
import { existsSync as Ie, statSync as Pe, realpathSync as je, constants as v } from "node:fs";
|
package/dist/serverCore.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./location-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./location-Csj3eAm_.cjs"),c=require("./ownUrls-BTPGNhBt.cjs"),u=require("./explorerCore-diILGZTv.cjs"),x=require("react-router"),d=require("./describeValue-Ccvhbt36.cjs"),_=(i,e)=>new Promise((o,a)=>{const t=()=>a(e.reason);e.addEventListener("abort",t,{once:!0}),i.then(n=>{e.removeEventListener("abort",t),o(n)},n=>{e.removeEventListener("abort",t),a(n)}),e.aborted&&t()}),L=(i,{dataPath:e,pageAddress:o})=>{if(E.assertMountPath("dataPath",e),typeof o!="string")throw new TypeError(`[markdown-explorer] pageAddress must be a string; got ${d.describeValue(o)}`);if(!URL.canParse(e,o))throw new RangeError(`[markdown-explorer] pageAddress must be an absolute URL the data path resolves against; got ${d.describeValue(o)}`);const a=new URL(o),t=`${e}/`;return async(n,h)=>{const s=new Request(n instanceof Request?n:new URL(String(n),a),h);s.signal.throwIfAborted();const r=new URL(s.url);if(r.protocol!==a.protocol||r.host!==a.host||!r.pathname.startsWith(t))throw new TypeError(`[markdown-explorer] the in-process fetch answers only ${t}*; got ${r.protocol}//${r.host}${r.pathname}`);const T={request:s,url:r,pattern:`${e}/*`,params:{"*":r.pathname.slice(t.length)},context:new x.RouterContextProvider},p=s.method==="GET"||s.method==="HEAD",l=await _(p?i.dataLoader(T):i.dataAction(T),s.signal);return s.method==="HEAD"?new Response(null,{headers:l.headers,status:l.status,statusText:l.statusText}):l}};exports.decodeText=E.decodeText;exports.decodeTextLeniently=E.decodeTextLeniently;exports.isExplorerSourceId=E.isExplorerSourceId;exports.legacyTextEncodingOf=E.legacyTextEncodingOf;exports.DEFAULT_DENIED_PATH_SEGMENTS=c.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_MAX_HEADINGS=c.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=c.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=c.isAcceptableDocumentPath;exports.isDeniedPath=c.isDeniedPath;exports.isExplorerDocumentLang=c.isExplorerDocumentLang;exports.ASSET_CONTENT_SECURITY_POLICIES=u.ASSET_CONTENT_SECURITY_POLICIES;exports.ExplorerError=u.ExplorerError;exports.createExplorerServer=u.createExplorerServer;exports.createInProcessDataFetch=L;
|
package/dist/serverCore.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as l } from "./location-
|
|
2
|
-
import { d as R, b as A, i as D, l as _ } from "./location-
|
|
1
|
+
import { a as l } from "./location-DFfbnUZ9.js";
|
|
2
|
+
import { d as R, b as A, i as D, l as _ } from "./location-DFfbnUZ9.js";
|
|
3
3
|
import { D as g, E as P, M as I, i as U, a as $, b as v } from "./ownUrls-DD0cSCsF.js";
|
|
4
|
-
import { A as N, E as H, c as M } from "./explorerCore-
|
|
4
|
+
import { A as N, E as H, c as M } from "./explorerCore-COhVrnGO.js";
|
|
5
5
|
import { RouterContextProvider as d } from "react-router";
|
|
6
6
|
import { d as p } from "./describeValue-CLlVRO8d.js";
|
|
7
7
|
const u = (c, e) => new Promise((o, n) => {
|