@aiquants/markdown-explorer 0.23.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +127 -0
- package/README.md +66 -21
- package/dist/{EditSurface-Dhvw9IDD.js → EditSurface-CFXG8Qok.js} +333 -336
- package/dist/{EditSurface-Bk4tdJ99.cjs → EditSurface-CiKQiYSD.cjs} +5 -5
- package/dist/{ExplorerSplit-BAFiXU-V.cjs → ExplorerSplit-BWMVatnB.cjs} +1 -1
- package/dist/{ExplorerSplit-Q5VqUBDE.js → ExplorerSplit-DIkC3R7O.js} +81 -81
- package/dist/{MultiLayout-DlATT7km.js → MultiLayout-DXnuRzb4.js} +22 -22
- package/dist/{MultiLayout-Bq_TS3ez.cjs → MultiLayout-q_Pvwykp.cjs} +1 -1
- package/dist/{NativeScrollBar-A6-qEpz7.cjs → NativeScrollBar-UYBG64v1.cjs} +1 -1
- package/dist/{NativeScrollBar-TsIcS3JZ.js → NativeScrollBar-s_uSPPEd.js} +1 -1
- package/dist/{TreeLayout-zrSo4MNZ.js → TreeLayout-BQ1lWVf3.js} +3 -3
- package/dist/{TreeLayout-l-r2pPao.cjs → TreeLayout-Di0yv1E-.cjs} +1 -1
- package/dist/core/config.d.cts +13 -0
- package/dist/core/config.d.ts +13 -0
- package/dist/core/contracts.d.cts +22 -4
- package/dist/core/contracts.d.ts +22 -4
- package/dist/core/labels.d.cts +12 -0
- package/dist/core/labels.d.ts +12 -0
- package/dist/core/textEncoding.d.cts +4 -0
- package/dist/core/textEncoding.d.ts +4 -0
- package/dist/{dataRoute-Diu_7gle.js → dataRoute-BEvesOvN.js} +105 -97
- package/dist/dataRoute-Cv7fgCW7.cjs +1 -0
- package/dist/index-BhxsL0Sm.js +4097 -0
- package/dist/index-ZdsIXJap.cjs +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -23
- package/dist/location-CasigkBk.cjs +1 -0
- package/dist/location-gXXmC7CQ.js +643 -0
- package/dist/{merge-BzMpSaxx.js → merge-CQAXBfvi.js} +1 -1
- package/dist/{merge-DlPkU2Jc.cjs → merge-DkmrVEIc.cjs} +1 -1
- package/dist/{sanitizePolicy-Du3lFZd-.cjs → sanitizePolicy-CZwOaJ92.cjs} +1 -1
- package/dist/{sanitizePolicy-BvhYIqVO.js → sanitizePolicy-gVKBhabq.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/ports.d.cts +8 -1
- package/dist/server/ports.d.ts +8 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +783 -768
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{useSplitPersistence-HfAb8Kzh.js → useSplitPersistence-BPNjvuJi.js} +1 -1
- package/dist/{useSplitPersistence-CR4Oxtaa.cjs → useSplitPersistence-Bmpb2prR.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +13 -6
- package/docs/behavior/layout.md +22 -10
- package/docs/behavior/localization.md +10 -4
- package/docs/behavior/security.md +7 -4
- package/docs/behavior/url-contract.md +2 -2
- package/package.json +5 -5
- package/dist/dataRoute-vXGZMVB-.cjs +0 -1
- package/dist/index-BNFl3BsO.cjs +0 -13
- package/dist/index-Jz6zeO4O.js +0 -3703
- package/dist/location-8Ho8ZNv_.js +0 -499
- package/dist/location-DN0AI4ir.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const he = 4096;
|
|
2
|
+
const P = Object.freeze([
|
|
3
3
|
".env*",
|
|
4
4
|
"*.env",
|
|
5
5
|
"*.env.*",
|
|
@@ -57,80 +57,80 @@ const v = Object.freeze([
|
|
|
57
57
|
"*.tfvars.json",
|
|
58
58
|
".*_history",
|
|
59
59
|
"fish_history"
|
|
60
|
-
]), w = /[\u0000-\u001f\u007f]/u,
|
|
60
|
+
]), w = /[\u0000-\u001f\u007f]/u, L = /\p{Cs}/u, be = (e) => {
|
|
61
61
|
const t = e.split("/").filter((n) => n !== "").at(-1);
|
|
62
62
|
return t === void 0 ? e : t;
|
|
63
|
-
}, R = (e) => e.length > 0 && e.length <= 4096 && !
|
|
64
|
-
|
|
63
|
+
}, R = (e) => e.length > 0 && e.length <= 4096 && !L.test(e) && !w.test(e) && !e.includes("\\"), h = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), k = /(?:%[0-9A-Fa-f]{2})+/gu, D = new TextDecoder("utf-8"), j = /[/\\]/u, $ = (e) => e.replace(
|
|
64
|
+
k,
|
|
65
65
|
(t) => D.decode(
|
|
66
66
|
Uint8Array.from(
|
|
67
67
|
t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
|
|
68
68
|
)
|
|
69
69
|
)
|
|
70
|
-
),
|
|
70
|
+
), I = (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 =
|
|
74
|
+
const s = $(n);
|
|
75
75
|
if (s === n) break;
|
|
76
76
|
t.push(s), n = s;
|
|
77
77
|
}
|
|
78
|
-
return t.map(
|
|
79
|
-
},
|
|
78
|
+
return t.map(h);
|
|
79
|
+
}, C = (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
|
-
const t =
|
|
82
|
+
const t = h(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
83
83
|
return new RegExp(`^${t}$`, "su");
|
|
84
84
|
}, y = (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(
|
|
86
|
+
const t = e.map(C), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => s !== "" && I(s).some((i) => n(i) || i.split(j).some(n));
|
|
87
87
|
return {
|
|
88
88
|
deniesPath: (s) => s.split("/").some(r),
|
|
89
89
|
deniesName: r
|
|
90
90
|
};
|
|
91
|
-
},
|
|
91
|
+
}, z = y(P), X = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ae = (e) => e === void 0 ? z : e === !1 ? X : y(e), _e = (e, t) => y(e).deniesPath(t), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), H = Object.freeze(["video", "audio", "pdf"]), V = Object.freeze(["raster", "svg"]), F = Object.freeze(["csv", "tsv"]), M = Object.freeze(["info", "warning", "danger"]), K = Object.freeze(["markdown", "text", "image", "media", "spreadsheet", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), Oe = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), xe = Object.freeze(["http:", "https:", "mailto:"]), A = 1024, G = /^[a-z0-9-]{1,64}$/u, Y = "https://relative.invalid/", g = 64, c = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, W = (e) => c(b, e), J = (e) => c(U, e), q = (e) => c(H, e), B = (e) => c(V, e), Q = (e) => c(F, e), Se = (e) => c(M, e), Z = (e) => c(K, e), _ = (e) => typeof e == "string" && G.test(e), Te = (e, t) => {
|
|
92
92
|
if (typeof e != "string") return !1;
|
|
93
93
|
try {
|
|
94
|
-
return t.includes(new URL(e,
|
|
94
|
+
return t.includes(new URL(e, Y).protocol);
|
|
95
95
|
} catch {
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
}, p = (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
|
|
102
|
-
},
|
|
101
|
+
return W(t) ? n !== void 0 && !_(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
|
|
102
|
+
}, ee = (e) => {
|
|
103
103
|
if (e === null || typeof e != "object") return "an entry must be an object";
|
|
104
|
-
const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy:
|
|
105
|
-
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" :
|
|
104
|
+
const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy: l } = e;
|
|
105
|
+
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" : J(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : l !== void 0 && typeof l != "boolean" ? "an entry lazy flag must be a boolean" : a !== void 0 && !Array.isArray(a) ? "entry children must be an array" : r === "file" && (a !== void 0 || l === !0) ? "a file entry cannot have children or be lazy" : l === !0 && Array.isArray(a) && a.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
|
|
106
106
|
}, O = (e) => {
|
|
107
|
-
if (
|
|
107
|
+
if (ee(e) !== null) return !1;
|
|
108
108
|
const { children: t } = e;
|
|
109
109
|
return t === void 0 || t.every(O);
|
|
110
|
-
},
|
|
110
|
+
}, te = (e) => {
|
|
111
111
|
if (e === null || typeof e != "object") return !1;
|
|
112
112
|
const { status: t, entries: n, failure: r } = e;
|
|
113
113
|
return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && p(r) === null;
|
|
114
|
-
},
|
|
114
|
+
}, Ne = (e) => {
|
|
115
115
|
if (e === null || typeof e != "object") return !1;
|
|
116
116
|
const { status: t, ancestors: n, failure: r } = e;
|
|
117
117
|
return t === "ok" ? n === null || x(n) : t === "error" && p(r) === null;
|
|
118
|
-
}, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length,
|
|
118
|
+
}, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, ve = (e) => {
|
|
119
119
|
if (e === null || typeof e != "object") return !1;
|
|
120
120
|
const { status: t, source: n, ancestors: r, failure: s } = e;
|
|
121
121
|
return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && p(s) === null;
|
|
122
|
-
},
|
|
122
|
+
}, Pe = (e) => {
|
|
123
123
|
if (e === null || typeof e != "object") return !1;
|
|
124
124
|
const { status: t, loadedAt: n } = e;
|
|
125
|
-
return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 :
|
|
126
|
-
},
|
|
125
|
+
return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : te(e);
|
|
126
|
+
}, S = (e) => {
|
|
127
127
|
if (e === null || typeof e != "object") return "a heading must be an object";
|
|
128
128
|
const { text: t, depth: n, id: r } = e;
|
|
129
129
|
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;
|
|
130
|
-
},
|
|
130
|
+
}, ne = (e) => {
|
|
131
131
|
if (e === null || typeof e != "object") return "a document must be an object";
|
|
132
132
|
const t = e, { kind: n } = t;
|
|
133
|
-
if (!
|
|
133
|
+
if (!Z(n)) return `unknown document kind ${o(n)}`;
|
|
134
134
|
if (n === "failure") return p(t.failure);
|
|
135
135
|
if (typeof t.name != "string") return "a document needs a name string";
|
|
136
136
|
switch (n) {
|
|
@@ -138,44 +138,51 @@ const v = Object.freeze([
|
|
|
138
138
|
const { htmlContent: r, headings: s } = t;
|
|
139
139
|
if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
|
|
140
140
|
for (const i of s) {
|
|
141
|
-
const a =
|
|
141
|
+
const a = S(i);
|
|
142
142
|
if (a !== null) return a;
|
|
143
143
|
}
|
|
144
|
-
return
|
|
144
|
+
return se(t.edit);
|
|
145
145
|
}
|
|
146
146
|
case "text":
|
|
147
|
-
return typeof t.text != "string" || typeof t.truncated != "boolean" ? "a text document needs text and truncated" :
|
|
147
|
+
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";
|
|
148
148
|
case "image":
|
|
149
|
-
return
|
|
149
|
+
return u(t.url) ? B(t.imageType) ? null : `unknown image type ${o(t.imageType)}` : "an image document needs a root-relative url";
|
|
150
150
|
case "media":
|
|
151
|
-
return
|
|
151
|
+
return u(t.url) ? q(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
|
|
152
|
+
case "spreadsheet":
|
|
153
|
+
return u(t.url) ? ie(t) : "a spreadsheet document needs a root-relative url";
|
|
152
154
|
case "file":
|
|
153
|
-
return
|
|
155
|
+
return u(t.url) ? null : "a file document needs a root-relative url";
|
|
154
156
|
}
|
|
155
|
-
},
|
|
157
|
+
}, re = (e) => ne(e) === null, we = (e) => re(e) && (e.kind === "text" || e.kind === "failure"), se = (e) => {
|
|
156
158
|
if (e === null) return null;
|
|
157
159
|
if (typeof e != "object") return "a markdown document's edit must be null or an object";
|
|
158
160
|
const { kind: t, href: n } = e;
|
|
159
|
-
return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` :
|
|
160
|
-
},
|
|
161
|
+
return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : T(n);
|
|
162
|
+
}, oe = (e) => {
|
|
163
|
+
if (e === null) return null;
|
|
164
|
+
if (typeof e != "object") return "a spreadsheet document's edit must be null or an object";
|
|
165
|
+
const { kind: t, href: n } = e;
|
|
166
|
+
return t !== "external" ? `a spreadsheet document's edit must be external; got ${o(t)}` : T(n);
|
|
167
|
+
}, ie = (e) => Q(e.format) ? typeof e.firstSheetOnly != "boolean" ? "a spreadsheet document needs a boolean firstSheetOnly" : oe(e.edit) : `unknown spreadsheet format ${o(e.format)}`, T = (e) => ae(e) ? null : `an external edit needs an absolute https: href; got ${o(e)}`, ae = (e) => {
|
|
161
168
|
if (typeof e != "string") return !1;
|
|
162
169
|
try {
|
|
163
170
|
return new URL(e).protocol === "https:";
|
|
164
171
|
} catch {
|
|
165
172
|
return !1;
|
|
166
173
|
}
|
|
167
|
-
}, d = (e) => typeof e == "string" && e.length > 0 && e.length <=
|
|
174
|
+
}, d = (e) => typeof e == "string" && e.length > 0 && e.length <= A, le = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ce = (e) => {
|
|
168
175
|
if (e === null || typeof e != "object") return "a revision must be an object";
|
|
169
176
|
const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: a } = e;
|
|
170
|
-
return d(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${
|
|
171
|
-
},
|
|
177
|
+
return d(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${A} characters; got ${o(t)}`;
|
|
178
|
+
}, f = (e, t) => {
|
|
172
179
|
if (e === null || typeof e != "object") return "an answer must be an object";
|
|
173
180
|
const n = e, { kind: r } = n;
|
|
174
181
|
if (r === "failure") return p(n.failure);
|
|
175
182
|
if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${o(r)}`;
|
|
176
183
|
switch (r) {
|
|
177
184
|
case "grant":
|
|
178
|
-
return
|
|
185
|
+
return le(n);
|
|
179
186
|
case "edit":
|
|
180
187
|
return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : d(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
|
|
181
188
|
case "draft":
|
|
@@ -188,15 +195,15 @@ const v = Object.freeze([
|
|
|
188
195
|
const { htmlContent: s, headings: i } = n;
|
|
189
196
|
if (typeof s != "string" || !Array.isArray(i)) return "a preview needs htmlContent and headings";
|
|
190
197
|
for (const a of i) {
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
198
|
+
const l = S(a);
|
|
199
|
+
if (l !== null) return l;
|
|
193
200
|
}
|
|
194
201
|
return null;
|
|
195
202
|
}
|
|
196
203
|
case "revisions": {
|
|
197
204
|
if (!Array.isArray(n.revisions)) return "revisions need an array";
|
|
198
205
|
for (const s of n.revisions) {
|
|
199
|
-
const i =
|
|
206
|
+
const i = ce(s);
|
|
200
207
|
if (i !== null) return i;
|
|
201
208
|
}
|
|
202
209
|
return null;
|
|
@@ -206,16 +213,16 @@ const v = Object.freeze([
|
|
|
206
213
|
default:
|
|
207
214
|
return `unexpected answer kind ${o(r)}`;
|
|
208
215
|
}
|
|
209
|
-
},
|
|
210
|
-
const r = `${e}/${
|
|
216
|
+
}, ue = Object.freeze(["edit", "draft", "grant"]), fe = Object.freeze(["saved", "conflict", "grant"]), N = Object.freeze(["preview"]), de = Object.freeze(["revisions"]), pe = Object.freeze(["revision"]), Le = (e) => f(e, ue) === null, ke = (e) => f(e, fe) === null, De = (e) => f(e, N) === null, je = (e) => f(e, de) === null, $e = (e) => f(e, pe) === null, Ie = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : f(e, N), Ce = (e, t) => ({ kind: "failure", failure: Ee(e, t) }), Ee = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ye = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), me = "asset", ge = "link-card", ze = (e, t, n) => {
|
|
217
|
+
const r = `${e}/${me}?${E.path}=${encodeURIComponent(t)}`;
|
|
211
218
|
return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
|
|
212
|
-
},
|
|
219
|
+
}, v = "text", Xe = (e) => {
|
|
213
220
|
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
|
|
214
|
-
return `${e}&${E.display}=${
|
|
215
|
-
},
|
|
221
|
+
return `${e}&${E.display}=${v}`;
|
|
222
|
+
}, Ue = (e) => {
|
|
216
223
|
const t = e.getAll(E.display);
|
|
217
|
-
return t.length === 0 ? "file" : t.length === 1 && t[0] ===
|
|
218
|
-
},
|
|
224
|
+
return t.length === 0 ? "file" : t.length === 1 && t[0] === v ? "text" : null;
|
|
225
|
+
}, He = (e) => `${e}/${ge}`, Ve = "X-Markdown-Explorer-Scope", Fe = "X-Markdown-Explorer", Me = "refresh", Ke = "edit", Ge = "text/markdown", Ye = (e) => ye.includes(e), Re = Object.freeze({
|
|
219
226
|
invalid: 400,
|
|
220
227
|
unauthorized: 401,
|
|
221
228
|
forbidden: 403,
|
|
@@ -224,59 +231,60 @@ const v = Object.freeze([
|
|
|
224
231
|
"not-configured": 500,
|
|
225
232
|
unsupported: 500,
|
|
226
233
|
failed: 500
|
|
227
|
-
}),
|
|
228
|
-
const [t, ...n] = b.filter((r) =>
|
|
234
|
+
}), We = (e) => {
|
|
235
|
+
const [t, ...n] = b.filter((r) => Re[r] === e);
|
|
229
236
|
return t !== void 0 && n.length === 0 ? t : "failed";
|
|
230
237
|
};
|
|
231
238
|
export {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
239
|
+
E as A,
|
|
240
|
+
Ce as B,
|
|
241
|
+
Ue as C,
|
|
242
|
+
Ge as D,
|
|
243
|
+
Oe as E,
|
|
244
|
+
P as F,
|
|
245
|
+
_e as G,
|
|
246
|
+
be as H,
|
|
247
|
+
Xe as I,
|
|
248
|
+
We as J,
|
|
249
|
+
p as K,
|
|
250
|
+
we as L,
|
|
251
|
+
he as M,
|
|
252
|
+
ve as N,
|
|
253
|
+
Ne as O,
|
|
254
|
+
te as P,
|
|
248
255
|
Pe as Q,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
$e as R,
|
|
257
|
+
je as S,
|
|
258
|
+
De as T,
|
|
259
|
+
ke as U,
|
|
260
|
+
Le as V,
|
|
261
|
+
re as W,
|
|
262
|
+
A as X,
|
|
263
|
+
b as Y,
|
|
264
|
+
He as a,
|
|
265
|
+
W as b,
|
|
258
266
|
_ as c,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
Ie as d,
|
|
268
|
+
ze as e,
|
|
269
|
+
Ee as f,
|
|
270
|
+
Se as g,
|
|
271
|
+
Te as h,
|
|
264
272
|
R as i,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
273
|
+
q as j,
|
|
274
|
+
B as k,
|
|
275
|
+
ne as l,
|
|
268
276
|
d as m,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
S as n,
|
|
278
|
+
u as o,
|
|
279
|
+
ee as p,
|
|
280
|
+
xe as q,
|
|
281
|
+
ce as r,
|
|
282
|
+
ie as s,
|
|
283
|
+
Ae as t,
|
|
284
|
+
Ye as u,
|
|
285
|
+
Re as v,
|
|
286
|
+
Fe as w,
|
|
287
|
+
Me as x,
|
|
288
|
+
Ke as y,
|
|
289
|
+
Ve as z
|
|
282
290
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b=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"]),z=/[\u0000-\u001f\u007f]/u,F=/\p{Cs}/u,V=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},R=e=>e.length>0&&e.length<=4096&&!F.test(e)&&!z.test(e)&&!e.includes("\\"),x=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),M=/(?:%[0-9A-Fa-f]{2})+/gu,G=new TextDecoder("utf-8"),K=/[/\\]/u,Y=e=>e.replace(M,t=>G.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=Y(n);if(o===n)break;t.push(o),n=o}return t.map(x)},J=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=x(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},m=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(J),n=o=>o!==""&&t.some(i=>i.test(o)),r=o=>o!==""&&W(o).some(i=>n(i)||i.split(K).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},Q=m(b),q=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),B=e=>e===void 0?Q:e===!1?q:m(e),Z=(e,t)=>m(e).deniesPath(t),y=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),ee=Object.freeze(["file","directory"]),te=Object.freeze(["video","audio","pdf"]),ne=Object.freeze(["raster","svg"]),re=Object.freeze(["csv","tsv"]),oe=Object.freeze(["info","warning","danger"]),se=Object.freeze(["markdown","text","image","media","spreadsheet","file","failure"]),O=Object.freeze({min:1,max:6}),ie=1e4,c=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ae=Object.freeze(["http:","https:","mailto:"]),_=1024,le=/^[a-z0-9-]{1,64}$/u,ce="https://relative.invalid/",h=64,u=(e,t)=>typeof t=="string"&&e.includes(t),s=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,T=e=>u(y,e),ue=e=>u(ee,e),P=e=>u(te,e),S=e=>u(ne,e),fe=e=>u(re,e),de=e=>u(oe,e),Ee=e=>u(se,e),g=e=>typeof e=="string"&&le.test(e),pe=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,ce).protocol)}catch{return!1}},d=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return T(t)?n!==void 0&&!g(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${s(n)}`:null:`unknown failure reason ${s(t)}`},L=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,modifiedAt:i,children:a,lazy:l}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!R(n)?"an entry needs an acceptable path":ue(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&!Number.isSafeInteger(i)?`an entry modifiedAt must be a safe integer of epoch milliseconds; got ${s(i)}`:l!==void 0&&typeof l!="boolean"?"an entry lazy flag must be a boolean":a!==void 0&&!Array.isArray(a)?"entry children must be an array":r==="file"&&(a!==void 0||l===!0)?"a file entry cannot have children or be lazy":l===!0&&Array.isArray(a)&&a.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${s(r)}`},N=e=>{if(L(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(N)},D=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(N):t==="error"&&d(r)===null},Re=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||v(n):t==="error"&&d(r)===null},v=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&R(t))&&new Set(e).size===e.length,me=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!==""&&v(r):t==="error"&&d(o)===null},ye=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:D(e)},A=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<O.min||n>O.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},w=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!Ee(n))return`unknown document kind ${s(n)}`;if(n==="failure")return d(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 i of o){const a=A(i);if(a!==null)return a}return ge(t.edit)}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":c(t.url)?null:"a text document needs a root-relative url";case"image":return c(t.url)?S(t.imageType)?null:`unknown image type ${s(t.imageType)}`:"an image document needs a root-relative url";case"media":return c(t.url)?P(t.mediaType)?null:`unknown media type ${s(t.mediaType)}`:"a media document needs a root-relative url";case"spreadsheet":return c(t.url)?I(t):"a spreadsheet document needs a root-relative url";case"file":return c(t.url)?null:"a file document needs a root-relative url"}},k=e=>w(e)===null,_e=e=>k(e)&&(e.kind==="text"||e.kind==="failure"),ge=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:t,href:n}=e;return t==="inline"?n===void 0?null:"an inline edit carries no href":t==="draft"?n===void 0?null:"a draft edit carries no href":t!=="external"?`unknown edit kind ${s(t)}`:j(n)},Ae=e=>{if(e===null)return null;if(typeof e!="object")return"a spreadsheet document's edit must be null or an object";const{kind:t,href:n}=e;return t!=="external"?`a spreadsheet document's edit must be external; got ${s(t)}`:j(n)},I=e=>fe(e.format)?typeof e.firstSheetOnly!="boolean"?"a spreadsheet document needs a boolean firstSheetOnly":Ae(e.edit):`unknown spreadsheet format ${s(e.format)}`,j=e=>Oe(e)?null:`an external edit needs an absolute https: href; got ${s(e)}`,Oe=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},f=e=>typeof e=="string"&&e.length>0&&e.length<=_,he=e=>c(e.href)?null:`a grant needs a root-relative href; got ${s(e.href)}`,$=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:n,size:r,author:o,kept:i,current:a}=e;return f(t)?n!==null&&(typeof n!="string"||Number.isNaN(Date.parse(n)))?`a revision's modifiedAt must be a date-time string or null; got ${s(n)}`:typeof r!="number"||!Number.isSafeInteger(r)||r<0?`a revision's size must be a non-negative integer; got ${s(r)}`:o!==null&&typeof o!="string"?`a revision's author must be a string or null; got ${s(o)}`:typeof i!="boolean"||typeof a!="boolean"?"a revision needs kept and current booleans":null:`a revision id must be a non-empty string of at most ${_} characters; got ${s(t)}`},E=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const n=e,{kind:r}=n;if(r==="failure")return d(n.failure);if(typeof r!="string"||!t.includes(r))return`unexpected answer kind ${s(r)}`;switch(r){case"grant":return he(n);case"edit":return typeof n.text!="string"||typeof n.history!="boolean"?"an edit source needs text and history":f(n.version)?null:`an edit source needs a version; got ${s(n.version)}`;case"draft":return typeof n.text=="string"?null:"a draft source needs text";case"saved":return f(n.version)?null:`a saved answer needs a version; got ${s(n.version)}`;case"conflict":return typeof n.text!="string"?"a conflict needs the current text":f(n.version)?null:`a conflict needs the current version; got ${s(n.version)}`;case"preview":{const{htmlContent:o,headings:i}=n;if(typeof o!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const a of i){const l=A(a);if(l!==null)return l}return null}case"revisions":{if(!Array.isArray(n.revisions))return"revisions need an array";for(const o of n.revisions){const i=$(o);if(i!==null)return i}return null}case"revision":return typeof n.text!="string"?"a revision answer needs text":f(n.id)?null:`a revision answer needs an id; got ${s(n.id)}`;default:return`unexpected answer kind ${s(r)}`}},be=Object.freeze(["edit","draft","grant"]),xe=Object.freeze(["saved","conflict","grant"]),X=Object.freeze(["preview"]),Te=Object.freeze(["revisions"]),Pe=Object.freeze(["revision"]),Se=e=>E(e,be)===null,Le=e=>E(e,xe)===null,Ne=e=>E(e,X)===null,De=e=>E(e,Te)===null,ve=e=>E(e,Pe)===null,we=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:E(e,X),ke=(e,t)=>({kind:"failure",failure:C(e,t)}),C=(e,t)=>g(t)?{reason:e,code:t}:{reason:e},Ie=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),p=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),je="asset",$e="link-card",Xe=(e,t,n)=>{const r=`${e}/${je}?${p.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${p.version}=${encodeURIComponent(n)}`},U="text",Ce=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${p.display}=${U}`},Ue=e=>{const t=e.getAll(p.display);return t.length===0?"file":t.length===1&&t[0]===U?"text":null},He=e=>`${e}/${$e}`,ze="X-Markdown-Explorer-Scope",Fe="X-Markdown-Explorer",Ve="refresh",Me="edit",Ge="text/markdown",Ke=e=>Ie.includes(e),H=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Ye=e=>{const[t,...n]=y.filter(r=>H[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=p;exports.EXPLORER_DRAFT_MEDIA_TYPE=Ge;exports.EXPLORER_EDIT_PROOF=Me;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=y;exports.EXPLORER_FAILURE_STATUS=H;exports.EXPLORER_LINK_PROTOCOLS=ae;exports.EXPLORER_MAX_HEADINGS=ie;exports.EXPLORER_PROOF_HEADER=Fe;exports.EXPLORER_REFRESH_PROOF=Ve;exports.EXPLORER_SCOPE_HEADER=ze;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=w;exports.draftAnswerViolation=we;exports.entryViolation=L;exports.explorerAssetHref=Xe;exports.explorerLinkCardEndpoint=He;exports.explorerPlainTextHref=Ce;exports.failureDocument=ke;exports.failureOf=C;exports.failureReasonOfStatus=Ye;exports.failureViolation=d;exports.headingViolation=A;exports.isAcceptableDocumentPath=R;exports.isAcceptableUrl=pe;exports.isDeniedPath=Z;exports.isExplorerAncestorsResult=Re;exports.isExplorerChildrenResult=D;exports.isExplorerDataOperation=Ke;exports.isExplorerDocument=k;exports.isExplorerEditAnswer=Se;exports.isExplorerEditToken=f;exports.isExplorerFailureCode=g;exports.isExplorerFailureReason=T;exports.isExplorerImageType=S;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=de;exports.isExplorerPreviewAnswer=Ne;exports.isExplorerRevealResult=me;exports.isExplorerRevisionAnswer=ve;exports.isExplorerRevisionsAnswer=De;exports.isExplorerSaveAnswer=Le;exports.isExplorerTextAnswer=_e;exports.isExplorerTreeResult=ye;exports.isRootRelativeUrl=c;exports.lastPathSegment=V;exports.readExplorerAssetDisplay=Ue;exports.resolvePathRules=B;exports.revisionViolation=$;exports.spreadsheetFieldsViolation=I;
|