@aiquants/markdown-explorer 0.4.0 → 0.6.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +30 -4
  3. package/dist/ExplorerSplit-CN5TvRj6.js +1495 -0
  4. package/dist/ExplorerSplit-CUIbSLQm.cjs +1 -0
  5. package/dist/MultiLayout-BDcQSpa6.cjs +1 -0
  6. package/dist/{MultiLayout-8s7q3-Hm.js → MultiLayout-hPmV-bae.js} +69 -66
  7. package/dist/{NativeScrollBar-DqkutcGb.cjs → NativeScrollBar-CHEQgaVx.cjs} +1 -1
  8. package/dist/{NativeScrollBar-D3VDRQqf.js → NativeScrollBar-DYEv2GLV.js} +1 -1
  9. package/dist/TreeLayout-BDaIyoGT.cjs +1 -0
  10. package/dist/TreeLayout-CqzxLpoM.js +23 -0
  11. package/dist/core/contracts.d.cts +23 -7
  12. package/dist/core/contracts.d.ts +23 -7
  13. package/dist/core/labels.d.cts +4 -0
  14. package/dist/core/labels.d.ts +4 -0
  15. package/dist/dataRoute-CUXlMhUJ.cjs +1 -0
  16. package/dist/{dataRoute-Dl6xmEFs.js → dataRoute-Ce6EIuu4.js} +69 -63
  17. package/dist/index-B3nShkkt.cjs +3 -0
  18. package/dist/{index-Dv9lUZqD.js → index-gJp1iXTc.js} +1020 -916
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +3 -3
  21. package/dist/{location-CaNtUswk.js → location-CtM94G0O.js} +1 -1
  22. package/dist/{location-2QZADLiv.cjs → location-FavgY_gB.cjs} +1 -1
  23. package/dist/sanitizeWorker.cjs +1 -1
  24. package/dist/sanitizeWorker.js +1 -1
  25. package/dist/server/errors.d.cts +1 -1
  26. package/dist/server/errors.d.ts +1 -1
  27. package/dist/server/ports.d.cts +1 -0
  28. package/dist/server/ports.d.ts +1 -0
  29. package/dist/server.cjs +1 -1
  30. package/dist/server.js +753 -716
  31. package/dist/styles/markdown-explorer.css +1 -1
  32. package/docs/behavior/dom-hooks.md +6 -3
  33. package/docs/behavior/layout.md +6 -0
  34. package/docs/behavior/localization.md +4 -1
  35. package/docs/behavior/security.md +11 -4
  36. package/docs/behavior/url-contract.md +1 -0
  37. package/package.json +4 -3
  38. package/dist/ExplorerSplit-rUVsf5i-.cjs +0 -1
  39. package/dist/ExplorerSplit-uX2ojZe8.js +0 -1479
  40. package/dist/MultiLayout-ZK2V9nms.cjs +0 -1
  41. package/dist/TreeLayout-C7ZNnaOr.js +0 -22
  42. package/dist/TreeLayout-DkTVgxxb.cjs +0 -1
  43. package/dist/dataRoute-DYjYBiXF.cjs +0 -1
  44. package/dist/index-CLe6vRXs.cjs +0 -3
@@ -0,0 +1,23 @@
1
+ import { jsx as a, jsxs as g } from "react/jsx-runtime";
2
+ import { useState as P, useMemo as u, useCallback as i } from "react";
3
+ import { useLocation as D } from "react-router";
4
+ import { e as s, c as b } from "./location-CtM94G0O.js";
5
+ import { u as C, a as N, D as O, P as T, b as M } from "./index-gJp1iXTc.js";
6
+ import { E as R, a as _, b as G } from "./ExplorerSplit-CN5TvRj6.js";
7
+ const H = /* @__PURE__ */ new Set(), I = ({ location: p }) => {
8
+ const { config: e } = C(), t = N(), { hash: m } = D(), { source: n, doc: o, overrides: r } = p, [l, h] = P(R), d = u(() => ({ gathered: l, onGatheredChange: h }), [l]), v = i((c) => t(s(e, { view: "tree", source: n, doc: c, overrides: r }), "browse"), [t, e, n, r]), w = i((c) => t(s(e, { view: "tree", source: c, doc: o, overrides: r }), "switch-source"), [t, e, o, r]), S = i((c) => t(`${s(e, { view: "tree", source: c, doc: o, overrides: r })}${m}`, "browse"), [t, e, o, r, m]), E = i((c) => t(s(e, { view: "multi", source: n, docs: b(e, c) }), "switch-view"), [t, e, n]), x = u(() => ({ href: s(e, { view: "multi", source: n, docs: o === null ? [] : [o] }), target: "multi" }), [e, n, o]), f = u(() => ({ kind: "page", view: "tree", overrides: r, embed: {} }), [r]);
9
+ return /* @__PURE__ */ a(
10
+ _,
11
+ {
12
+ view: "tree",
13
+ explorer: /* @__PURE__ */ a(G, { mode: "tree", sourceId: n, currentPath: o, openPaths: H, onOpenDocument: v, onSourceChange: w, onRevealSource: S, viewSwitch: x, tray: d, onOpenSelection: E }),
14
+ content: /* @__PURE__ */ g("div", { className: "aqmx-document-column aqmx-tree-document", children: [
15
+ o === null ? null : /* @__PURE__ */ a(O, { path: o, placement: T }),
16
+ /* @__PURE__ */ a(M, { path: o, variant: f })
17
+ ] })
18
+ }
19
+ );
20
+ };
21
+ export {
22
+ I as TreeLayout
23
+ };
@@ -81,6 +81,18 @@ export type ExplorerAncestorsResult = {
81
81
  readonly status: "error";
82
82
  readonly failure: ExplorerFailure;
83
83
  };
84
+ export type ExplorerRevealResult = {
85
+ readonly status: "ok";
86
+ readonly source: string;
87
+ readonly ancestors: readonly string[];
88
+ } | {
89
+ readonly status: "ok";
90
+ readonly source: null;
91
+ readonly ancestors: null;
92
+ } | {
93
+ readonly status: "error";
94
+ readonly failure: ExplorerFailure;
95
+ };
84
96
  export type ExplorerHeading = {
85
97
  readonly text: string;
86
98
  readonly depth: number;
@@ -90,18 +102,19 @@ export type ExplorerFailureDocument = {
90
102
  readonly kind: "failure";
91
103
  readonly failure: ExplorerFailure;
92
104
  };
93
- export type ExplorerDocument = {
94
- readonly kind: "markdown";
95
- readonly name: string;
96
- readonly htmlContent: string;
97
- readonly headings: readonly ExplorerHeading[];
98
- } | {
105
+ export type ExplorerTextDocument = {
99
106
  readonly kind: "text";
100
107
  readonly name: string;
101
108
  readonly text: string;
102
109
  readonly truncated: boolean;
103
110
  readonly url: string;
104
- } | {
111
+ };
112
+ export type ExplorerDocument = {
113
+ readonly kind: "markdown";
114
+ readonly name: string;
115
+ readonly htmlContent: string;
116
+ readonly headings: readonly ExplorerHeading[];
117
+ } | ExplorerTextDocument | {
105
118
  readonly kind: "image";
106
119
  readonly name: string;
107
120
  readonly url: string;
@@ -115,6 +128,7 @@ export type ExplorerDocument = {
115
128
  readonly name: string;
116
129
  readonly url: string;
117
130
  } | ExplorerFailureDocument;
131
+ export type ExplorerTextAnswer = ExplorerTextDocument | ExplorerFailureDocument;
118
132
  export type ExplorerNotice = {
119
133
  readonly id: string;
120
134
  readonly tone: ExplorerNoticeTone;
@@ -140,10 +154,12 @@ export declare const failureViolation: (value: unknown) => string | null;
140
154
  export declare const entryViolation: (value: unknown) => string | null;
141
155
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
156
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
157
+ export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
143
158
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
144
159
  export declare const headingViolation: (value: unknown) => string | null;
145
160
  export declare const documentViolation: (value: unknown) => string | null;
146
161
  export declare const isExplorerDocument: (value: unknown) => value is ExplorerDocument;
162
+ export declare const isExplorerTextAnswer: (value: unknown) => value is ExplorerTextAnswer;
147
163
  export declare const failureDocument: (reason: ExplorerFailureReason, code?: string) => ExplorerFailureDocument;
148
164
  export declare const failureOf: (reason: ExplorerFailureReason, code?: string) => ExplorerFailure;
149
165
  export type ExplorerSeededDocument = {
@@ -81,6 +81,18 @@ export type ExplorerAncestorsResult = {
81
81
  readonly status: "error";
82
82
  readonly failure: ExplorerFailure;
83
83
  };
84
+ export type ExplorerRevealResult = {
85
+ readonly status: "ok";
86
+ readonly source: string;
87
+ readonly ancestors: readonly string[];
88
+ } | {
89
+ readonly status: "ok";
90
+ readonly source: null;
91
+ readonly ancestors: null;
92
+ } | {
93
+ readonly status: "error";
94
+ readonly failure: ExplorerFailure;
95
+ };
84
96
  export type ExplorerHeading = {
85
97
  readonly text: string;
86
98
  readonly depth: number;
@@ -90,18 +102,19 @@ export type ExplorerFailureDocument = {
90
102
  readonly kind: "failure";
91
103
  readonly failure: ExplorerFailure;
92
104
  };
93
- export type ExplorerDocument = {
94
- readonly kind: "markdown";
95
- readonly name: string;
96
- readonly htmlContent: string;
97
- readonly headings: readonly ExplorerHeading[];
98
- } | {
105
+ export type ExplorerTextDocument = {
99
106
  readonly kind: "text";
100
107
  readonly name: string;
101
108
  readonly text: string;
102
109
  readonly truncated: boolean;
103
110
  readonly url: string;
104
- } | {
111
+ };
112
+ export type ExplorerDocument = {
113
+ readonly kind: "markdown";
114
+ readonly name: string;
115
+ readonly htmlContent: string;
116
+ readonly headings: readonly ExplorerHeading[];
117
+ } | ExplorerTextDocument | {
105
118
  readonly kind: "image";
106
119
  readonly name: string;
107
120
  readonly url: string;
@@ -115,6 +128,7 @@ export type ExplorerDocument = {
115
128
  readonly name: string;
116
129
  readonly url: string;
117
130
  } | ExplorerFailureDocument;
131
+ export type ExplorerTextAnswer = ExplorerTextDocument | ExplorerFailureDocument;
118
132
  export type ExplorerNotice = {
119
133
  readonly id: string;
120
134
  readonly tone: ExplorerNoticeTone;
@@ -140,10 +154,12 @@ export declare const failureViolation: (value: unknown) => string | null;
140
154
  export declare const entryViolation: (value: unknown) => string | null;
141
155
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
156
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
157
+ export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
143
158
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
144
159
  export declare const headingViolation: (value: unknown) => string | null;
145
160
  export declare const documentViolation: (value: unknown) => string | null;
146
161
  export declare const isExplorerDocument: (value: unknown) => value is ExplorerDocument;
162
+ export declare const isExplorerTextAnswer: (value: unknown) => value is ExplorerTextAnswer;
147
163
  export declare const failureDocument: (reason: ExplorerFailureReason, code?: string) => ExplorerFailureDocument;
148
164
  export declare const failureOf: (reason: ExplorerFailureReason, code?: string) => ExplorerFailure;
149
165
  export type ExplorerSeededDocument = {
@@ -16,6 +16,9 @@ export type MarkdownExplorerLabels = {
16
16
  readonly refreshDocumentNamed: (name: string) => string;
17
17
  readonly documentRefreshed: (name: string) => string;
18
18
  readonly documentRefreshFailed: (reason: string) => string;
19
+ readonly showMarkupLabel: string;
20
+ readonly showMarkup: string;
21
+ readonly showMarkupNamed: (name: string) => string;
19
22
  readonly expandAll: string;
20
23
  readonly collapseAll: string;
21
24
  readonly treeSettings: string;
@@ -77,6 +80,7 @@ export type MarkdownExplorerLabels = {
77
80
  readonly documentRegion: string;
78
81
  readonly documentEmpty: string;
79
82
  readonly documentLoading: string;
83
+ readonly markupLoading: string;
80
84
  readonly documentShown: (name: string) => string;
81
85
  readonly documentFailed: (name: string, title: string) => string;
82
86
  readonly announcementSequence: (messages: readonly string[]) => string;
@@ -16,6 +16,9 @@ export type MarkdownExplorerLabels = {
16
16
  readonly refreshDocumentNamed: (name: string) => string;
17
17
  readonly documentRefreshed: (name: string) => string;
18
18
  readonly documentRefreshFailed: (reason: string) => string;
19
+ readonly showMarkupLabel: string;
20
+ readonly showMarkup: string;
21
+ readonly showMarkupNamed: (name: string) => string;
19
22
  readonly expandAll: string;
20
23
  readonly collapseAll: string;
21
24
  readonly treeSettings: string;
@@ -77,6 +80,7 @@ export type MarkdownExplorerLabels = {
77
80
  readonly documentRegion: string;
78
81
  readonly documentEmpty: string;
79
82
  readonly documentLoading: string;
83
+ readonly markupLoading: string;
80
84
  readonly documentShown: (name: string) => string;
81
85
  readonly documentFailed: (name: string, title: string) => string;
82
86
  readonly announcementSequence: (messages: readonly string[]) => string;
@@ -0,0 +1 @@
1
+ "use strict";const _=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),N=/[\u0000-\u001f\u007f]/u,C=/\p{Cs}/u,k=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},f=e=>e.length>0&&e.length<=4096&&!C.test(e)&&!N.test(e)&&!e.includes("\\"),A=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),U=/(?:%[0-9A-Fa-f]{2})+/gu,H=new TextDecoder("utf-8"),j=/[/\\]/u,X=e=>e.replace(U,t=>H.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),w=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=X(n);if(o===n)break;t.push(o),n=o}return t.map(A)},I=e=>{if(typeof e!="string"||e.trim()===""||e.includes("/")||e.includes("\\"))throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);const t=A(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},d=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(I),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&w(o).some(s=>n(s)||s.split(j).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},$=d(_),z=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),F=e=>e===void 0?$:e===!1?z:d(e),M=(e,t)=>d(e).deniesPath(t),p=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),v=Object.freeze(["file","directory"]),V=Object.freeze(["video","audio","pdf"]),G=Object.freeze(["info","warning","danger"]),Y=Object.freeze(["markdown","text","image","media","file","failure"]),m=Object.freeze({min:1,max:6}),K=1e4,u=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),J=Object.freeze(["http:","https:","mailto:"]),Q=/^[a-z0-9-]{1,64}$/u,B="https://relative.invalid/",y=64,c=(e,t)=>typeof t=="string"&&e.includes(t),a=e=>typeof e=="string"?JSON.stringify(e.length>y?`${e.slice(0,y)}…`:e):typeof e,O=e=>c(p,e),W=e=>c(v,e),g=e=>c(V,e),q=e=>c(G,e),Z=e=>c(Y,e),R=e=>typeof e=="string"&&Q.test(e),ee=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,B).protocol)}catch{return!1}},l=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return O(t)?n!==void 0&&!R(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}`:null:`unknown failure reason ${a(t)}`},T=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,children:s,lazy:i}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!f(n)?"an entry needs an acceptable path":W(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&typeof i!="boolean"?"an entry lazy flag must be a boolean":s!==void 0&&!Array.isArray(s)?"entry children must be an array":r==="file"&&(s!==void 0||i===!0)?"a file entry cannot have children or be lazy":i===!0&&Array.isArray(s)&&s.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${a(r)}`},h=e=>{if(T(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(h)},L=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:n,failure:r}=e;return t==="ok"?Array.isArray(n)&&n.every(h):t==="error"&&l(r)===null},te=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||P(n):t==="error"&&l(r)===null},P=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&f(t))&&new Set(e).size===e.length,ne=e=>{if(e===null||typeof e!="object")return!1;const{status:t,source:n,ancestors:r,failure:o}=e;return t==="ok"?n===null&&r===null||typeof n=="string"&&n!==""&&P(r):t==="error"&&l(o)===null},re=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:L(e)},oe=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:n,id:r}=e;return typeof t!="string"||typeof r!="string"?"a heading needs text and id strings":typeof n!="number"||!Number.isInteger(n)||n<m.min||n>m.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},b=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!Z(n))return`unknown document kind ${a(n)}`;if(n==="failure")return l(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const i=oe(s);if(i!==null)return i}return null}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":u(t.url)?null:"a text document needs a root-relative url";case"image":return u(t.url)?null:"an image document needs a root-relative url";case"media":return u(t.url)?g(t.mediaType)?null:`unknown media type ${a(t.mediaType)}`:"a media document needs a root-relative url";case"file":return u(t.url)?null:"a file document needs a root-relative url"}},x=e=>b(e)===null,se=e=>x(e)&&(e.kind==="text"||e.kind==="failure"),ie=(e,t)=>({kind:"failure",failure:S(e,t)}),S=(e,t)=>R(t)?{reason:e,code:t}:{reason:e},ae=Object.freeze(["tree","children","ancestors","reveal","document","text","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v"}),ce="asset",le="link-card",ue=(e,t,n)=>{const r=`${e}/${ce}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},Ee=e=>`${e}/${le}`,fe="X-Markdown-Explorer-Scope",de="X-Markdown-Explorer",pe="refresh",Re=e=>ae.includes(e),D=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),me=e=>{const[t,...n]=p.filter(r=>D[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=_;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_FAILURE_REASONS=p;exports.EXPLORER_FAILURE_STATUS=D;exports.EXPLORER_LINK_PROTOCOLS=J;exports.EXPLORER_MAX_HEADINGS=K;exports.EXPLORER_REFRESH_HEADER=de;exports.EXPLORER_REFRESH_HEADER_VALUE=pe;exports.EXPLORER_SCOPE_HEADER=fe;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=b;exports.entryViolation=T;exports.explorerAssetHref=ue;exports.explorerLinkCardEndpoint=Ee;exports.failureDocument=ie;exports.failureOf=S;exports.failureReasonOfStatus=me;exports.failureViolation=l;exports.isAcceptableDocumentPath=f;exports.isAcceptableUrl=ee;exports.isDeniedPath=M;exports.isExplorerAncestorsResult=te;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=Re;exports.isExplorerDocument=x;exports.isExplorerFailureCode=R;exports.isExplorerFailureReason=O;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=q;exports.isExplorerRevealResult=ne;exports.isExplorerTextAnswer=se;exports.isExplorerTreeResult=re;exports.lastPathSegment=k;exports.resolvePathRules=F;
@@ -1,5 +1,5 @@
1
- const q = 4096;
2
- const A = Object.freeze([
1
+ const W = 4096;
2
+ const O = Object.freeze([
3
3
  ".env*",
4
4
  "*.env",
5
5
  "*.env.*",
@@ -57,12 +57,12 @@ const A = Object.freeze([
57
57
  "*.tfvars.json",
58
58
  ".*_history",
59
59
  "fish_history"
60
- ]), O = /[\u0000-\u001f\u007f]/u, h = /\p{Cs}/u, Q = (e) => {
60
+ ]), h = /[\u0000-\u001f\u007f]/u, b = /\p{Cs}/u, Z = (e) => {
61
61
  const t = e.split("/").filter((n) => n !== "").at(-1);
62
62
  return t === void 0 ? e : t;
63
- }, m = (e) => e.length > 0 && e.length <= 4096 && !h.test(e) && !O.test(e) && !e.includes("\\"), y = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), b = /(?:%[0-9A-Fa-f]{2})+/gu, T = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
64
- b,
65
- (t) => T.decode(
63
+ }, m = (e) => e.length > 0 && e.length <= 4096 && !b.test(e) && !h.test(e) && !e.includes("\\"), y = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), T = /(?:%[0-9A-Fa-f]{2})+/gu, x = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
64
+ T,
65
+ (t) => x.decode(
66
66
  Uint8Array.from(
67
67
  t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
68
  )
@@ -76,65 +76,69 @@ const A = Object.freeze([
76
76
  t.push(s), n = s;
77
77
  }
78
78
  return t.map(y);
79
- }, x = (e) => {
79
+ }, D = (e) => {
80
80
  if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
81
  throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
82
  const t = y(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
83
  return new RegExp(`^${t}$`, "su");
84
- }, u = (e) => {
84
+ }, f = (e) => {
85
85
  if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
86
- const t = e.map(x), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && S(s).some((o) => n(o) || o.split(L).some(n));
86
+ const t = e.map(D), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && S(s).some((o) => n(o) || o.split(L).some(n));
87
87
  return {
88
88
  deniesPath: (s) => s.split("/").some(r),
89
89
  deniesName: r
90
90
  };
91
- }, D = u(A), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), W = (e) => e === void 0 ? D : e === !1 ? N : u(e), Z = (e, t) => u(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), k = Object.freeze(["video", "audio", "pdf"]), C = Object.freeze(["info", "warning", "danger"]), w = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), f = Object.freeze({ min: 1, max: 6 }), ee = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), te = Object.freeze(["http:", "https:", "mailto:"]), U = /^[a-z0-9-]{1,64}$/u, $ = "https://relative.invalid/", E = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > E ? `${e.slice(0, E)}…` : e) : typeof e, z = (e) => c(R, e), v = (e) => c(j, e), I = (e) => c(k, e), ne = (e) => c(C, e), H = (e) => c(w, e), g = (e) => typeof e == "string" && U.test(e), re = (e, t) => {
91
+ }, N = f(O), k = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), ee = (e) => e === void 0 ? N : e === !1 ? k : f(e), te = (e, t) => f(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), C = Object.freeze(["video", "audio", "pdf"]), w = Object.freeze(["info", "warning", "danger"]), U = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), d = Object.freeze({ min: 1, max: 6 }), ne = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), re = Object.freeze(["http:", "https:", "mailto:"]), $ = /^[a-z0-9-]{1,64}$/u, z = "https://relative.invalid/", E = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > E ? `${e.slice(0, E)}…` : e) : typeof e, I = (e) => c(R, e), H = (e) => c(j, e), X = (e) => c(C, e), se = (e) => c(w, e), v = (e) => c(U, e), g = (e) => typeof e == "string" && $.test(e), oe = (e, t) => {
92
92
  if (typeof e != "string") return !1;
93
93
  try {
94
- return t.includes(new URL(e, $).protocol);
94
+ return t.includes(new URL(e, z).protocol);
95
95
  } catch {
96
96
  return !1;
97
97
  }
98
- }, d = (e) => {
98
+ }, u = (e) => {
99
99
  if (e === null || typeof e != "object") return "a failure must be an object";
100
100
  const { reason: t, code: n } = e;
101
- return z(t) ? n !== void 0 && !g(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
- }, X = (e) => {
101
+ return I(t) ? n !== void 0 && !g(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
+ }, F = (e) => {
103
103
  if (e === null || typeof e != "object") return "an entry must be an object";
104
104
  const { name: t, path: n, type: r, mimeType: s, children: o, lazy: i } = e;
105
- return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !m(n) ? "an entry needs an acceptable path" : v(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
105
+ return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !m(n) ? "an entry needs an acceptable path" : H(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
106
106
  }, _ = (e) => {
107
- if (X(e) !== null) return !1;
107
+ if (F(e) !== null) return !1;
108
108
  const { children: t } = e;
109
109
  return t === void 0 || t.every(_);
110
- }, F = (e) => {
110
+ }, M = (e) => {
111
111
  if (e === null || typeof e != "object") return !1;
112
112
  const { status: t, entries: n, failure: r } = e;
113
- return t === "ok" ? Array.isArray(n) && n.every(_) : t === "error" && d(r) === null;
114
- }, se = (e) => {
113
+ return t === "ok" ? Array.isArray(n) && n.every(_) : t === "error" && u(r) === null;
114
+ }, ie = (e) => {
115
115
  if (e === null || typeof e != "object") return !1;
116
116
  const { status: t, ancestors: n, failure: r } = e;
117
- return t === "ok" ? n === null || Array.isArray(n) && n.every((s) => typeof s == "string" && m(s)) && new Set(n).size === n.length : t === "error" && d(r) === null;
118
- }, oe = (e) => {
117
+ return t === "ok" ? n === null || A(n) : t === "error" && u(r) === null;
118
+ }, A = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && m(t)) && new Set(e).size === e.length, ae = (e) => {
119
+ if (e === null || typeof e != "object") return !1;
120
+ const { status: t, source: n, ancestors: r, failure: s } = e;
121
+ return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && A(r) : t === "error" && u(s) === null;
122
+ }, ce = (e) => {
119
123
  if (e === null || typeof e != "object") return !1;
120
124
  const { status: t, loadedAt: n } = e;
121
- return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : F(e);
122
- }, M = (e) => {
125
+ return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : M(e);
126
+ }, V = (e) => {
123
127
  if (e === null || typeof e != "object") return "a heading must be an object";
124
128
  const { text: t, depth: n, id: r } = e;
125
- return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < f.min || n > f.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
126
- }, V = (e) => {
129
+ return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < d.min || n > d.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
130
+ }, G = (e) => {
127
131
  if (e === null || typeof e != "object") return "a document must be an object";
128
132
  const t = e, { kind: n } = t;
129
- if (!H(n)) return `unknown document kind ${a(n)}`;
130
- if (n === "failure") return d(t.failure);
133
+ if (!v(n)) return `unknown document kind ${a(n)}`;
134
+ if (n === "failure") return u(t.failure);
131
135
  if (typeof t.name != "string") return "a document needs a name string";
132
136
  switch (n) {
133
137
  case "markdown": {
134
138
  const { htmlContent: r, headings: s } = t;
135
139
  if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
136
140
  for (const o of s) {
137
- const i = M(o);
141
+ const i = V(o);
138
142
  if (i !== null) return i;
139
143
  }
140
144
  return null;
@@ -144,14 +148,14 @@ const A = Object.freeze([
144
148
  case "image":
145
149
  return l(t.url) ? null : "an image document needs a root-relative url";
146
150
  case "media":
147
- return l(t.url) ? I(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
151
+ return l(t.url) ? X(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
148
152
  case "file":
149
153
  return l(t.url) ? null : "a file document needs a root-relative url";
150
154
  }
151
- }, ie = (e) => V(e) === null, ae = (e, t) => ({ kind: "failure", failure: G(e, t) }), G = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, Y = Object.freeze(["tree", "children", "ancestors", "document", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), K = "asset", B = "link-card", ce = (e, t, n) => {
152
- const r = `${e}/${K}?${p.path}=${encodeURIComponent(t)}`;
155
+ }, Y = (e) => G(e) === null, le = (e) => Y(e) && (e.kind === "text" || e.kind === "failure"), ue = (e, t) => ({ kind: "failure", failure: K(e, t) }), K = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, B = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), J = "asset", q = "link-card", fe = (e, t, n) => {
156
+ const r = `${e}/${J}?${p.path}=${encodeURIComponent(t)}`;
153
157
  return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
154
- }, le = (e) => `${e}/${B}`, ue = "X-Markdown-Explorer-Scope", de = "X-Markdown-Explorer", fe = "refresh", Ee = (e) => Y.includes(e), J = Object.freeze({
158
+ }, de = (e) => `${e}/${q}`, Ee = "X-Markdown-Explorer-Scope", pe = "X-Markdown-Explorer", me = "refresh", ye = (e) => B.includes(e), Q = Object.freeze({
155
159
  invalid: 400,
156
160
  unauthorized: 401,
157
161
  forbidden: 403,
@@ -160,41 +164,43 @@ const A = Object.freeze([
160
164
  "not-configured": 500,
161
165
  unsupported: 500,
162
166
  failed: 500
163
- }), pe = (e) => {
164
- const [t, ...n] = R.filter((r) => J[r] === e);
167
+ }), Re = (e) => {
168
+ const [t, ...n] = R.filter((r) => Q[r] === e);
165
169
  return t !== void 0 && n.length === 0 ? t : "failed";
166
170
  };
167
171
  export {
168
- oe as A,
169
- ie as B,
170
- R as C,
171
- A as D,
172
- ee as E,
173
- q as M,
174
- le as a,
175
- z as b,
172
+ M as A,
173
+ u as B,
174
+ ce as C,
175
+ O as D,
176
+ ne as E,
177
+ Y as F,
178
+ R as G,
179
+ W as M,
180
+ de as a,
181
+ I as b,
176
182
  g as c,
177
- ne as d,
178
- ce as e,
179
- G as f,
180
- re as g,
181
- I as h,
183
+ se as d,
184
+ fe as e,
185
+ K as f,
186
+ oe as g,
187
+ X as h,
182
188
  m as i,
183
- V as j,
184
- X as k,
185
- te as l,
186
- Ee as m,
187
- J as n,
188
- de as o,
189
- fe as p,
190
- ue as q,
191
- W as r,
189
+ G as j,
190
+ F as k,
191
+ re as l,
192
+ ye as m,
193
+ Q as n,
194
+ pe as o,
195
+ me as p,
196
+ Ee as q,
197
+ ee as r,
192
198
  p as s,
193
- ae as t,
194
- Z as u,
195
- Q as v,
196
- pe as w,
197
- se as x,
198
- F as y,
199
- d as z
199
+ ue as t,
200
+ te as u,
201
+ Z as v,
202
+ Re as w,
203
+ le as x,
204
+ ae as y,
205
+ ie as z
200
206
  };