@aiquants/markdown-explorer 0.4.0 → 0.5.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 (36) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +20 -2
  3. package/dist/ExplorerSplit-CWcK1E4I.js +1495 -0
  4. package/dist/ExplorerSplit-ajN3GSdA.cjs +1 -0
  5. package/dist/{MultiLayout-8s7q3-Hm.js → MultiLayout-BtWtCzJV.js} +69 -66
  6. package/dist/MultiLayout-DvkcdO9c.cjs +1 -0
  7. package/dist/{NativeScrollBar-DqkutcGb.cjs → NativeScrollBar-DbzyQ85y.cjs} +1 -1
  8. package/dist/{NativeScrollBar-D3VDRQqf.js → NativeScrollBar-apXjIKRW.js} +1 -1
  9. package/dist/TreeLayout-BcHsv9G8.js +23 -0
  10. package/dist/TreeLayout-rwhJfLmU.cjs +1 -0
  11. package/dist/core/contracts.d.cts +13 -0
  12. package/dist/core/contracts.d.ts +13 -0
  13. package/dist/{dataRoute-Dl6xmEFs.js → dataRoute-Btg4w3vO.js} +70 -65
  14. package/dist/dataRoute-DHpu0fg2.cjs +1 -0
  15. package/dist/{index-Dv9lUZqD.js → index-CIZw73j9.js} +539 -519
  16. package/dist/index-Cie6WPiM.cjs +3 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +5 -5
  19. package/dist/{location-2QZADLiv.cjs → location-CSIhx-L4.cjs} +1 -1
  20. package/dist/{location-CaNtUswk.js → location-c1zdeySY.js} +1 -1
  21. package/dist/sanitizeWorker.cjs +1 -1
  22. package/dist/sanitizeWorker.js +1 -1
  23. package/dist/server/errors.d.cts +1 -1
  24. package/dist/server/errors.d.ts +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +597 -589
  27. package/docs/behavior/security.md +1 -1
  28. package/docs/behavior/url-contract.md +1 -0
  29. package/package.json +1 -1
  30. package/dist/ExplorerSplit-rUVsf5i-.cjs +0 -1
  31. package/dist/ExplorerSplit-uX2ojZe8.js +0 -1479
  32. package/dist/MultiLayout-ZK2V9nms.cjs +0 -1
  33. package/dist/TreeLayout-C7ZNnaOr.js +0 -22
  34. package/dist/TreeLayout-DkTVgxxb.cjs +0 -1
  35. package/dist/dataRoute-DYjYBiXF.cjs +0 -1
  36. 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-c1zdeySY.js";
5
+ import { u as C, a as N, D as O, P as T, b as M } from "./index-CIZw73j9.js";
6
+ import { E as R, a as _, b as G } from "./ExplorerSplit-CWcK1E4I.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
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("react"),f=require("react-router"),a=require("./location-CSIhx-L4.cjs"),l=require("./index-Cie6WPiM.cjs"),i=require("./ExplorerSplit-ajN3GSdA.cjs"),q=new Set,C=({location:x})=>{const{config:e}=l.useExplorer(),r=l.useExplorerNavigate(),{hash:p}=f.useLocation(),{source:c,doc:o,overrides:t}=x,[m,d]=n.useState(i.EMPTY_SELECTION),h=n.useMemo(()=>({gathered:m,onGatheredChange:d}),[m]),v=n.useCallback(s=>r(a.explorerHref(e,{view:"tree",source:c,doc:s,overrides:t}),"browse"),[r,e,c,t]),S=n.useCallback(s=>r(a.explorerHref(e,{view:"tree",source:s,doc:o,overrides:t}),"switch-source"),[r,e,o,t]),w=n.useCallback(s=>r(`${a.explorerHref(e,{view:"tree",source:s,doc:o,overrides:t})}${p}`,"browse"),[r,e,o,t,p]),E=n.useCallback(s=>r(a.explorerHref(e,{view:"multi",source:c,docs:a.canonicalMultiDocuments(e,s)}),"switch-view"),[r,e,c]),g=n.useMemo(()=>({href:a.explorerHref(e,{view:"multi",source:c,docs:o===null?[]:[o]}),target:"multi"}),[e,c,o]),b=n.useMemo(()=>({kind:"page",view:"tree",overrides:t,embed:{}}),[t]);return u.jsx(i.ExplorerSplit,{view:"tree",explorer:u.jsx(i.ExplorerPane,{mode:"tree",sourceId:c,currentPath:o,openPaths:q,onOpenDocument:v,onSourceChange:S,onRevealSource:w,viewSwitch:g,tray:h,onOpenSelection:E}),content:u.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[o===null?null:u.jsx(l.DocumentRefreshBar,{path:o,placement:l.PAGE_DOCUMENT_REFRESH}),u.jsx(l.DocumentPane,{path:o,variant:b})]})})};exports.TreeLayout=C;
@@ -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;
@@ -140,6 +152,7 @@ export declare const failureViolation: (value: unknown) => string | null;
140
152
  export declare const entryViolation: (value: unknown) => string | null;
141
153
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
154
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
155
+ export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
143
156
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
144
157
  export declare const headingViolation: (value: unknown) => string | null;
145
158
  export declare const documentViolation: (value: unknown) => string | null;
@@ -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;
@@ -140,6 +152,7 @@ export declare const failureViolation: (value: unknown) => string | null;
140
152
  export declare const entryViolation: (value: unknown) => string | null;
141
153
  export declare const isExplorerChildrenResult: (value: unknown) => value is ExplorerChildrenResult;
142
154
  export declare const isExplorerAncestorsResult: (value: unknown) => value is ExplorerAncestorsResult;
155
+ export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
143
156
  export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
144
157
  export declare const headingViolation: (value: unknown) => string | null;
145
158
  export declare const documentViolation: (value: unknown) => string | null;
@@ -1,5 +1,5 @@
1
- const q = 4096;
2
- const A = Object.freeze([
1
+ const Q = 4096;
2
+ const O = Object.freeze([
3
3
  ".env*",
4
4
  "*.env",
5
5
  "*.env.*",
@@ -57,84 +57,88 @@ 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, W = (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, L = new TextDecoder("utf-8"), P = /[/\\]/u, S = (e) => e.replace(
64
+ T,
65
+ (t) => L.decode(
66
66
  Uint8Array.from(
67
67
  t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
68
  )
69
69
  )
70
- ), S = (e) => {
70
+ ), x = (e) => {
71
71
  const t = [e];
72
72
  let n = e;
73
73
  for (let r = 0; r < 3 && n.includes("%"); r += 1) {
74
- const s = P(n);
74
+ const s = S(n);
75
75
  if (s === n) break;
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 !== "" && x(s).some((o) => n(o) || o.split(P).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), j = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Z = (e) => e === void 0 ? N : e === !1 ? j : f(e), ee = (e, t) => f(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), k = 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 }), te = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ne = 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(k, e), X = (e) => c(C, e), re = (e) => c(w, e), v = (e) => c(U, e), g = (e) => typeof e == "string" && $.test(e), se = (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
+ }, oe = (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, ie = (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
+ }, ae = (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
+ }, ce = (e) => G(e) === null, le = (e, t) => ({ kind: "failure", failure: Y(e, t) }), Y = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, K = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), B = "asset", J = "link-card", ue = (e, t, n) => {
156
+ const r = `${e}/${B}?${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
+ }, fe = (e) => `${e}/${J}`, de = "X-Markdown-Explorer-Scope", Ee = "X-Markdown-Explorer", pe = "refresh", me = (e) => K.includes(e), q = Object.freeze({
155
159
  invalid: 400,
156
160
  unauthorized: 401,
157
161
  forbidden: 403,
@@ -160,41 +164,42 @@ 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
+ }), ye = (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
+ u as A,
173
+ ae as B,
174
+ ce as C,
175
+ O as D,
176
+ te as E,
177
+ R as F,
178
+ Q as M,
179
+ fe as a,
180
+ I as b,
176
181
  g as c,
177
- ne as d,
178
- ce as e,
179
- G as f,
180
- re as g,
181
- I as h,
182
+ re as d,
183
+ ue as e,
184
+ Y as f,
185
+ se as g,
186
+ X as h,
182
187
  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,
188
+ G as j,
189
+ F as k,
190
+ ne as l,
191
+ me as m,
192
+ q as n,
193
+ Ee as o,
194
+ pe as p,
195
+ de as q,
196
+ Z as r,
192
197
  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
198
+ le as t,
199
+ ee as u,
200
+ W as v,
201
+ ye as w,
202
+ ie as x,
203
+ oe as y,
204
+ M as z
200
205
  };
@@ -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"]),x=/[\u0000-\u001f\u007f]/u,N=/\p{Cs}/u,C=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},f=e=>e.length>0&&e.length<=4096&&!N.test(e)&&!x.test(e)&&!e.includes("\\"),A=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),U=/(?:%[0-9A-Fa-f]{2})+/gu,k=new TextDecoder("utf-8"),H=/[/\\]/u,j=e=>e.replace(U,t=>k.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),X=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=j(n);if(o===n)break;t.push(o),n=o}return t.map(A)},w=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(w),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&X(o).some(s=>n(s)||s.split(H).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},I=d(_),$=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),z=e=>e===void 0?I:e===!1?$:d(e),F=(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"]),M=Object.freeze(["video","audio","pdf"]),V=Object.freeze(["info","warning","danger"]),G=Object.freeze(["markdown","text","image","media","file","failure"]),m=Object.freeze({min:1,max:6}),Y=1e4,u=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),K=Object.freeze(["http:","https:","mailto:"]),J=/^[a-z0-9-]{1,64}$/u,Q="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),B=e=>c(v,e),g=e=>c(M,e),W=e=>c(V,e),q=e=>c(G,e),R=e=>typeof e=="string"&&J.test(e),Z=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,Q).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)}`},h=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":B(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)}`},T=e=>{if(h(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(T)},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(T):t==="error"&&l(r)===null},ee=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,te=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},ne=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)},re=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(!q(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=re(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"}},oe=e=>b(e)===null,se=(e,t)=>({kind:"failure",failure:S(e,t)}),S=(e,t)=>R(t)?{reason:e,code:t}:{reason:e},ie=Object.freeze(["tree","children","ancestors","reveal","document","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v"}),ae="asset",ce="link-card",le=(e,t,n)=>{const r=`${e}/${ae}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},ue=e=>`${e}/${ce}`,Ee="X-Markdown-Explorer-Scope",fe="X-Markdown-Explorer",de="refresh",pe=e=>ie.includes(e),D=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Re=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=K;exports.EXPLORER_MAX_HEADINGS=Y;exports.EXPLORER_REFRESH_HEADER=fe;exports.EXPLORER_REFRESH_HEADER_VALUE=de;exports.EXPLORER_SCOPE_HEADER=Ee;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=b;exports.entryViolation=h;exports.explorerAssetHref=le;exports.explorerLinkCardEndpoint=ue;exports.failureDocument=se;exports.failureOf=S;exports.failureReasonOfStatus=Re;exports.failureViolation=l;exports.isAcceptableDocumentPath=f;exports.isAcceptableUrl=Z;exports.isDeniedPath=F;exports.isExplorerAncestorsResult=ee;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=pe;exports.isExplorerDocument=oe;exports.isExplorerFailureCode=R;exports.isExplorerFailureReason=O;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=W;exports.isExplorerRevealResult=te;exports.isExplorerTreeResult=ne;exports.lastPathSegment=C;exports.resolvePathRules=z;