@aiquants/markdown-explorer 0.6.0 → 0.7.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 (65) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +57 -8
  3. package/dist/EditSurface-BCB-0vUK.js +371 -0
  4. package/dist/EditSurface-BZ98L7hy.cjs +2 -0
  5. package/dist/ExplorerSplit-BTRTah7R.cjs +1 -0
  6. package/dist/{ExplorerSplit-CN5TvRj6.js → ExplorerSplit-DpoMtzq3.js} +391 -417
  7. package/dist/MultiLayout-B7OiXgWH.cjs +1 -0
  8. package/dist/MultiLayout-BD2LiwOe.js +947 -0
  9. package/dist/{NativeScrollBar-CHEQgaVx.cjs → NativeScrollBar-B4j3Vigb.cjs} +1 -1
  10. package/dist/{NativeScrollBar-DYEv2GLV.js → NativeScrollBar-EXOKhHP4.js} +1 -1
  11. package/dist/TreeLayout-B9dF2A3h.cjs +1 -0
  12. package/dist/TreeLayout-hn2bfU22.js +29 -0
  13. package/dist/client/MarkdownExplorer.d.cts +2 -1
  14. package/dist/client/MarkdownExplorer.d.ts +2 -1
  15. package/dist/client/storage.d.cts +1 -0
  16. package/dist/client/storage.d.ts +1 -0
  17. package/dist/core/contracts.d.cts +58 -0
  18. package/dist/core/contracts.d.ts +58 -0
  19. package/dist/core/labels.d.cts +49 -0
  20. package/dist/core/labels.d.ts +49 -0
  21. package/dist/core/location.d.cts +7 -0
  22. package/dist/core/location.d.ts +7 -0
  23. package/dist/dataRoute-CcZ8PK00.cjs +1 -0
  24. package/dist/dataRoute-D1vE1wFW.js +270 -0
  25. package/dist/index-C0gh_dRY.js +3188 -0
  26. package/dist/index-CCc6qUbM.cjs +5 -0
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +31 -30
  31. package/dist/location-DmzVAFvo.cjs +1 -0
  32. package/dist/{location-CtM94G0O.js → location-Q4sgRrUm.js} +202 -193
  33. package/dist/merge-0W6xtIxj.cjs +5 -0
  34. package/dist/merge-Bi41vtSe.js +20 -0
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +173 -172
  37. package/dist/server/errors.d.cts +1 -1
  38. package/dist/server/errors.d.ts +1 -1
  39. package/dist/server/ports.d.cts +33 -1
  40. package/dist/server/ports.d.ts +33 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -1
  43. package/dist/server.d.ts +1 -1
  44. package/dist/server.js +882 -751
  45. package/dist/{storage-DA4ItHzl.js → storage-BSthKLSG.js} +14 -13
  46. package/dist/storage-Dgi4JXaB.cjs +1 -0
  47. package/dist/storage.cjs +1 -1
  48. package/dist/storage.js +1 -1
  49. package/dist/styles/markdown-explorer.css +1 -1
  50. package/docs/behavior/dom-hooks.md +17 -3
  51. package/docs/behavior/layout.md +6 -1
  52. package/docs/behavior/security.md +11 -1
  53. package/docs/behavior/url-contract.md +13 -4
  54. package/package.json +11 -3
  55. package/dist/ExplorerSplit-CUIbSLQm.cjs +0 -1
  56. package/dist/MultiLayout-BDcQSpa6.cjs +0 -1
  57. package/dist/MultiLayout-hPmV-bae.js +0 -922
  58. package/dist/TreeLayout-BDaIyoGT.cjs +0 -1
  59. package/dist/TreeLayout-CqzxLpoM.js +0 -23
  60. package/dist/dataRoute-CUXlMhUJ.cjs +0 -1
  61. package/dist/dataRoute-Ce6EIuu4.js +0 -206
  62. package/dist/index-B3nShkkt.cjs +0 -3
  63. package/dist/index-gJp1iXTc.js +0 -2238
  64. package/dist/location-FavgY_gB.cjs +0 -1
  65. package/dist/storage-Bkb2Axdi.cjs +0 -1
@@ -0,0 +1,270 @@
1
+ const fe = 4096;
2
+ const S = Object.freeze([
3
+ ".env*",
4
+ "*.env",
5
+ "*.env.*",
6
+ "*.env~*",
7
+ "*.env-*",
8
+ "*.env_*",
9
+ "*.env#*",
10
+ ".git",
11
+ ".git-credentials",
12
+ ".svn",
13
+ ".hg",
14
+ "node_modules",
15
+ "secrets",
16
+ ".secrets",
17
+ "secrets.json",
18
+ "secrets.yml",
19
+ "secrets.yaml",
20
+ "secrets.toml",
21
+ "secrets.ini",
22
+ "secrets.txt",
23
+ ".ssh",
24
+ ".aws",
25
+ ".gnupg",
26
+ ".docker",
27
+ ".kube",
28
+ ".terraform",
29
+ ".npmrc",
30
+ ".yarnrc",
31
+ ".yarnrc.yml",
32
+ ".netrc",
33
+ "_netrc",
34
+ ".pypirc",
35
+ ".pgpass",
36
+ ".my.cnf",
37
+ ".htpasswd",
38
+ ".vault-token",
39
+ "id_rsa*",
40
+ "id_dsa*",
41
+ "id_ecdsa*",
42
+ "id_ed25519*",
43
+ "*.pem",
44
+ "*.key",
45
+ "*.p8",
46
+ "*.p12",
47
+ "*.pfx",
48
+ "*.ppk",
49
+ "*.jks",
50
+ "*.keystore",
51
+ "*.kdbx",
52
+ "*credentials*.json",
53
+ "service-account*.json",
54
+ "*.tfstate",
55
+ "*.tfstate.*",
56
+ "*.tfvars",
57
+ "*.tfvars.json",
58
+ ".*_history",
59
+ "fish_history"
60
+ ]), N = /[\u0000-\u001f\u007f]/u, v = /\p{Cs}/u, de = (e) => {
61
+ const n = e.split("/").filter((t) => t !== "").at(-1);
62
+ return n === void 0 ? e : n;
63
+ }, R = (e) => e.length > 0 && e.length <= 4096 && !v.test(e) && !N.test(e) && !e.includes("\\"), _ = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), P = /(?:%[0-9A-Fa-f]{2})+/gu, w = new TextDecoder("utf-8"), D = /[/\\]/u, L = (e) => e.replace(
64
+ P,
65
+ (n) => w.decode(
66
+ Uint8Array.from(
67
+ n.slice(1).split("%").map((t) => Number.parseInt(t, 16))
68
+ )
69
+ )
70
+ ), k = (e) => {
71
+ const n = [e];
72
+ let t = e;
73
+ for (let r = 0; r < 3 && t.includes("%"); r += 1) {
74
+ const s = L(t);
75
+ if (s === t) break;
76
+ n.push(s), t = s;
77
+ }
78
+ return n.map(_);
79
+ }, j = (e) => {
80
+ if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
+ throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
+ const n = _(e).split("*").map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
+ return new RegExp(`^${n}$`, "su");
84
+ }, p = (e) => {
85
+ if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
86
+ const n = e.map(j), t = (s) => s !== "" && n.some((o) => o.test(s)), r = (s) => s !== "" && k(s).some((o) => t(o) || o.split(D).some(t));
87
+ return {
88
+ deniesPath: (s) => s.split("/").some(r),
89
+ deniesName: r
90
+ };
91
+ }, $ = p(S), I = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), pe = (e) => e === void 0 ? $ : e === !1 ? I : p(e), Ee = (e, n) => p(e).deniesPath(n), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), C = Object.freeze(["file", "directory"]), z = Object.freeze(["video", "audio", "pdf"]), U = Object.freeze(["info", "warning", "danger"]), X = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), y = Object.freeze({ min: 1, max: 6 }), ye = 1e4, c = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), me = Object.freeze(["http:", "https:", "mailto:"]), h = 1024, H = /^[a-z0-9-]{1,64}$/u, F = "https://relative.invalid/", m = 64, u = (e, n) => typeof n == "string" && e.includes(n), i = (e) => typeof e == "string" ? JSON.stringify(e.length > m ? `${e.slice(0, m)}…` : e) : typeof e, V = (e) => u(b, e), M = (e) => u(C, e), K = (e) => u(z, e), ge = (e) => u(U, e), G = (e) => u(X, e), A = (e) => typeof e == "string" && H.test(e), Re = (e, n) => {
92
+ if (typeof e != "string") return !1;
93
+ try {
94
+ return n.includes(new URL(e, F).protocol);
95
+ } catch {
96
+ return !1;
97
+ }
98
+ }, f = (e) => {
99
+ if (e === null || typeof e != "object") return "a failure must be an object";
100
+ const { reason: n, code: t } = e;
101
+ return V(n) ? t !== void 0 && !A(t) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${i(t)}` : null : `unknown failure reason ${i(n)}`;
102
+ }, W = (e) => {
103
+ if (e === null || typeof e != "object") return "an entry must be an object";
104
+ const { name: n, path: t, type: r, mimeType: s, children: o, lazy: a } = e;
105
+ return typeof n != "string" || n === "" ? "an entry needs a non-empty name" : typeof t != "string" || !R(t) ? "an entry needs an acceptable path" : M(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : a !== void 0 && typeof a != "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 || a === !0) ? "a file entry cannot have children or be lazy" : a === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${i(r)}`;
106
+ }, O = (e) => {
107
+ if (W(e) !== null) return !1;
108
+ const { children: n } = e;
109
+ return n === void 0 || n.every(O);
110
+ }, Y = (e) => {
111
+ if (e === null || typeof e != "object") return !1;
112
+ const { status: n, entries: t, failure: r } = e;
113
+ return n === "ok" ? Array.isArray(t) && t.every(O) : n === "error" && f(r) === null;
114
+ }, _e = (e) => {
115
+ if (e === null || typeof e != "object") return !1;
116
+ const { status: n, ancestors: t, failure: r } = e;
117
+ return n === "ok" ? t === null || x(t) : n === "error" && f(r) === null;
118
+ }, x = (e) => Array.isArray(e) && e.every((n) => typeof n == "string" && R(n)) && new Set(e).size === e.length, be = (e) => {
119
+ if (e === null || typeof e != "object") return !1;
120
+ const { status: n, source: t, ancestors: r, failure: s } = e;
121
+ return n === "ok" ? t === null && r === null || typeof t == "string" && t !== "" && x(r) : n === "error" && f(s) === null;
122
+ }, he = (e) => {
123
+ if (e === null || typeof e != "object") return !1;
124
+ const { status: n, loadedAt: t } = e;
125
+ return n === "ok" && !(Number.isSafeInteger(t) && t >= 0) ? !1 : Y(e);
126
+ }, T = (e) => {
127
+ if (e === null || typeof e != "object") return "a heading must be an object";
128
+ const { text: n, depth: t, id: r } = e;
129
+ return typeof n != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof t != "number" || !Number.isInteger(t) || t < y.min || t > y.max ? `a heading depth must be an integer in 1..6; got ${String(t)}` : null;
130
+ }, J = (e) => {
131
+ if (e === null || typeof e != "object") return "a document must be an object";
132
+ const n = e, { kind: t } = n;
133
+ if (!G(t)) return `unknown document kind ${i(t)}`;
134
+ if (t === "failure") return f(n.failure);
135
+ if (typeof n.name != "string") return "a document needs a name string";
136
+ switch (t) {
137
+ case "markdown": {
138
+ const { htmlContent: r, headings: s } = n;
139
+ if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
140
+ for (const o of s) {
141
+ const a = T(o);
142
+ if (a !== null) return a;
143
+ }
144
+ return Q(n.edit);
145
+ }
146
+ case "text":
147
+ return typeof n.text != "string" || typeof n.truncated != "boolean" ? "a text document needs text and truncated" : c(n.url) ? null : "a text document needs a root-relative url";
148
+ case "image":
149
+ return c(n.url) ? null : "an image document needs a root-relative url";
150
+ case "media":
151
+ return c(n.url) ? K(n.mediaType) ? null : `unknown media type ${i(n.mediaType)}` : "a media document needs a root-relative url";
152
+ case "file":
153
+ return c(n.url) ? null : "a file document needs a root-relative url";
154
+ }
155
+ }, B = (e) => J(e) === null, Ae = (e) => B(e) && (e.kind === "text" || e.kind === "failure"), Q = (e) => {
156
+ if (e === null) return null;
157
+ if (typeof e != "object") return "a markdown document's edit must be null or an object";
158
+ const { kind: n, href: t } = e;
159
+ return n === "inline" ? t === void 0 ? null : "an inline edit carries no href" : n !== "external" ? `unknown edit kind ${i(n)}` : q(t) ? null : `an external edit needs an absolute https: href; got ${i(t)}`;
160
+ }, q = (e) => {
161
+ if (typeof e != "string") return !1;
162
+ try {
163
+ return new URL(e).protocol === "https:";
164
+ } catch {
165
+ return !1;
166
+ }
167
+ }, l = (e) => typeof e == "string" && e.length > 0 && e.length <= h, Z = (e) => c(e.href) ? null : `a grant needs a root-relative href; got ${i(e.href)}`, ee = (e) => {
168
+ if (e === null || typeof e != "object") return "a revision must be an object";
169
+ const { id: n, modifiedAt: t, size: r, author: s, kept: o, current: a } = e;
170
+ return l(n) ? t !== null && (typeof t != "string" || Number.isNaN(Date.parse(t))) ? `a revision's modifiedAt must be a date-time string or null; got ${i(t)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${i(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${i(s)}` : typeof o != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${h} characters; got ${i(n)}`;
171
+ }, d = (e, n) => {
172
+ if (e === null || typeof e != "object") return "an answer must be an object";
173
+ const t = e, { kind: r } = t;
174
+ if (r === "failure") return f(t.failure);
175
+ if (typeof r != "string" || !n.includes(r)) return `unexpected answer kind ${i(r)}`;
176
+ switch (r) {
177
+ case "grant":
178
+ return Z(t);
179
+ case "edit":
180
+ return typeof t.text != "string" || typeof t.history != "boolean" ? "an edit source needs text and history" : l(t.version) ? null : `an edit source needs a version; got ${i(t.version)}`;
181
+ case "saved":
182
+ return l(t.version) ? null : `a saved answer needs a version; got ${i(t.version)}`;
183
+ case "conflict":
184
+ return typeof t.text != "string" ? "a conflict needs the current text" : l(t.version) ? null : `a conflict needs the current version; got ${i(t.version)}`;
185
+ case "preview": {
186
+ const { htmlContent: s, headings: o } = t;
187
+ if (typeof s != "string" || !Array.isArray(o)) return "a preview needs htmlContent and headings";
188
+ for (const a of o) {
189
+ const E = T(a);
190
+ if (E !== null) return E;
191
+ }
192
+ return null;
193
+ }
194
+ case "revisions": {
195
+ if (!Array.isArray(t.revisions)) return "revisions need an array";
196
+ for (const s of t.revisions) {
197
+ const o = ee(s);
198
+ if (o !== null) return o;
199
+ }
200
+ return null;
201
+ }
202
+ case "revision":
203
+ return typeof t.text != "string" ? "a revision answer needs text" : l(t.id) ? null : `a revision answer needs an id; got ${i(t.id)}`;
204
+ default:
205
+ return `unexpected answer kind ${i(r)}`;
206
+ }
207
+ }, te = Object.freeze(["edit", "grant"]), ne = Object.freeze(["saved", "conflict", "grant"]), re = Object.freeze(["preview"]), se = Object.freeze(["revisions"]), oe = Object.freeze(["revision"]), Oe = (e) => d(e, te) === null, xe = (e) => d(e, ne) === null, Te = (e) => d(e, re) === null, Se = (e) => d(e, se) === null, Ne = (e) => d(e, oe) === null, ve = (e, n) => ({ kind: "failure", failure: ie(e, n) }), ie = (e, n) => A(n) ? { reason: e, code: n } : { reason: e }, ae = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), g = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision" }), ce = "asset", le = "link-card", Pe = (e, n, t) => {
208
+ const r = `${e}/${ce}?${g.path}=${encodeURIComponent(n)}`;
209
+ return t === null ? r : `${r}&${g.version}=${encodeURIComponent(t)}`;
210
+ }, we = (e) => `${e}/${le}`, De = "X-Markdown-Explorer-Scope", Le = "X-Markdown-Explorer", ke = "refresh", je = "edit", $e = "text/markdown", Ie = (e) => ae.includes(e), ue = Object.freeze({
211
+ invalid: 400,
212
+ unauthorized: 401,
213
+ forbidden: 403,
214
+ "not-found": 404,
215
+ "too-large": 413,
216
+ "not-configured": 500,
217
+ unsupported: 500,
218
+ failed: 500
219
+ }), Ce = (e) => {
220
+ const [n, ...t] = b.filter((r) => ue[r] === e);
221
+ return n !== void 0 && t.length === 0 ? n : "failed";
222
+ };
223
+ export {
224
+ Ee as A,
225
+ de as B,
226
+ Ce as C,
227
+ S as D,
228
+ ye as E,
229
+ Ae as F,
230
+ be as G,
231
+ _e as H,
232
+ Y as I,
233
+ f as J,
234
+ he as K,
235
+ Ne as L,
236
+ fe as M,
237
+ Se as N,
238
+ Te as O,
239
+ xe as P,
240
+ Oe as Q,
241
+ B as R,
242
+ h as S,
243
+ b as T,
244
+ we as a,
245
+ V as b,
246
+ A as c,
247
+ ge as d,
248
+ Pe as e,
249
+ ie as f,
250
+ Re as g,
251
+ K as h,
252
+ R as i,
253
+ J as j,
254
+ l as k,
255
+ T as l,
256
+ c as m,
257
+ W as n,
258
+ me as o,
259
+ pe as p,
260
+ Ie as q,
261
+ ee as r,
262
+ ue as s,
263
+ Le as t,
264
+ ke as u,
265
+ je as v,
266
+ De as w,
267
+ g as x,
268
+ ve as y,
269
+ $e as z
270
+ };