@aiquants/markdown-explorer 0.5.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.
- package/CHANGELOG.md +49 -0
- package/README.md +65 -8
- package/dist/EditSurface-BCB-0vUK.js +371 -0
- package/dist/EditSurface-BZ98L7hy.cjs +2 -0
- package/dist/ExplorerSplit-BTRTah7R.cjs +1 -0
- package/dist/{ExplorerSplit-CWcK1E4I.js → ExplorerSplit-DpoMtzq3.js} +391 -417
- package/dist/MultiLayout-B7OiXgWH.cjs +1 -0
- package/dist/MultiLayout-BD2LiwOe.js +947 -0
- package/dist/{NativeScrollBar-DbzyQ85y.cjs → NativeScrollBar-B4j3Vigb.cjs} +1 -1
- package/dist/{NativeScrollBar-apXjIKRW.js → NativeScrollBar-EXOKhHP4.js} +1 -1
- package/dist/TreeLayout-B9dF2A3h.cjs +1 -0
- package/dist/TreeLayout-hn2bfU22.js +29 -0
- package/dist/client/MarkdownExplorer.d.cts +2 -1
- package/dist/client/MarkdownExplorer.d.ts +2 -1
- package/dist/client/storage.d.cts +1 -0
- package/dist/client/storage.d.ts +1 -0
- package/dist/core/contracts.d.cts +67 -6
- package/dist/core/contracts.d.ts +67 -6
- package/dist/core/labels.d.cts +53 -0
- package/dist/core/labels.d.ts +53 -0
- package/dist/core/location.d.cts +7 -0
- package/dist/core/location.d.ts +7 -0
- package/dist/dataRoute-CcZ8PK00.cjs +1 -0
- package/dist/dataRoute-D1vE1wFW.js +270 -0
- package/dist/index-C0gh_dRY.js +3188 -0
- package/dist/index-CCc6qUbM.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -31
- package/dist/location-DmzVAFvo.cjs +1 -0
- package/dist/{location-c1zdeySY.js → location-Q4sgRrUm.js} +202 -193
- package/dist/merge-0W6xtIxj.cjs +5 -0
- package/dist/merge-Bi41vtSe.js +20 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +173 -172
- package/dist/server/errors.d.cts +1 -1
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/ports.d.cts +34 -1
- package/dist/server/ports.d.ts +34 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +889 -729
- package/dist/{storage-DA4ItHzl.js → storage-BSthKLSG.js} +14 -13
- package/dist/storage-Dgi4JXaB.cjs +1 -0
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/docs/behavior/dom-hooks.md +20 -3
- package/docs/behavior/layout.md +11 -0
- package/docs/behavior/localization.md +4 -1
- package/docs/behavior/security.md +21 -4
- package/docs/behavior/url-contract.md +13 -4
- package/package.json +14 -5
- package/dist/ExplorerSplit-ajN3GSdA.cjs +0 -1
- package/dist/MultiLayout-BtWtCzJV.js +0 -922
- package/dist/MultiLayout-DvkcdO9c.cjs +0 -1
- package/dist/TreeLayout-BcHsv9G8.js +0 -23
- package/dist/TreeLayout-rwhJfLmU.cjs +0 -1
- package/dist/dataRoute-Btg4w3vO.js +0 -205
- package/dist/dataRoute-DHpu0fg2.cjs +0 -1
- package/dist/index-CIZw73j9.js +0 -2154
- package/dist/index-Cie6WPiM.cjs +0 -3
- package/dist/location-CSIhx-L4.cjs +0 -1
- package/dist/storage-Bkb2Axdi.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-CCc6qUbM.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { ScrollBar as u } from "@aiquants/virtualscroll";
|
|
3
3
|
import { useCallback as p, useMemo as b, useSyncExternalStore as S } from "react";
|
|
4
|
-
import { u as h } from "./index-
|
|
4
|
+
import { u as h } from "./index-C0gh_dRY.js";
|
|
5
5
|
import { N as m } from "./scrollBarGeometry-DOBdGNV-.js";
|
|
6
6
|
import { T, N as d } from "./tapScrollCircle-u4EXeLhx.js";
|
|
7
7
|
const l = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), f = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, v = (e) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),T=require("react-router"),a=require("./location-DmzVAFvo.cjs"),l=require("./index-CCc6qUbM.cjs"),p=require("./ExplorerSplit-BTRTah7R.cjs"),q=new Set,C=({location:m})=>{const{config:r}=l.useExplorer(),t=l.useExplorerNavigate(),{hash:d}=T.useLocation(),{source:n,doc:e,overrides:c,markup:o}=m,[x,v]=s.useState(p.EMPTY_SELECTION),g=s.useMemo(()=>({gathered:x,onGatheredChange:v}),[x]),w=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:n,doc:u,overrides:c}),"browse"),[t,r,n,c]),S=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o}),"switch-source"),[t,r,e,c,o]),E=s.useCallback(u=>t(`${a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o})}${d}`,"browse"),[t,r,e,c,o,d]),k=s.useCallback(u=>{const h=a.canonicalMultiDocuments(r,u);t(a.explorerHref(r,{view:"multi",source:n,docs:h,markup:o&&e!==null&&h.includes(e)?[e]:[]}),"switch-view")},[t,r,n,e,o]),b=s.useMemo(()=>({href:a.explorerHref(r,e===null?{view:"multi",source:n}:{view:"multi",source:n,docs:[e],markup:o?[e]:[]}),target:"multi"}),[r,n,e,o]),f=s.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]),P=l.usePageMarkupToggle(m);return i.jsx(p.ExplorerSplit,{view:"tree",explorer:i.jsx(p.ExplorerPane,{mode:"tree",sourceId:n,currentPath:e,openPaths:q,onOpenDocument:w,onSourceChange:S,onRevealSource:E,viewSwitch:b,tray:g,onOpenSelection:k}),content:i.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[e===null?null:i.jsx(l.DocumentRefreshBar,{path:e,placement:l.PAGE_DOCUMENT_REFRESH,markup:P}),i.jsx(l.DocumentPane,{path:e,markup:o,variant:f})]})})};exports.TreeLayout=C;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as u, jsxs as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as T, useMemo as m, useCallback as i } from "react";
|
|
3
|
+
import { useLocation as b } from "react-router";
|
|
4
|
+
import { e as c, c as C } from "./location-Q4sgRrUm.js";
|
|
5
|
+
import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-C0gh_dRY.js";
|
|
6
|
+
import { E as H, a as L, b as j } from "./ExplorerSplit-DpoMtzq3.js";
|
|
7
|
+
const q = /* @__PURE__ */ new Set(), U = ({ location: l }) => {
|
|
8
|
+
const { config: o } = M(), r = N(), { hash: p } = b(), { source: n, doc: e, overrides: s, markup: t } = l, [h, v] = T(H), w = m(() => ({ gathered: h, onGatheredChange: v }), [h]), g = i((a) => r(c(o, { view: "tree", source: n, doc: a, overrides: s }), "browse"), [r, o, n, s]), S = i((a) => r(c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t }), "switch-source"), [r, o, e, s, t]), E = i((a) => r(`${c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t })}${p}`, "browse"), [r, o, e, s, t, p]), x = i(
|
|
9
|
+
(a) => {
|
|
10
|
+
const d = C(o, a);
|
|
11
|
+
r(c(o, { view: "multi", source: n, docs: d, markup: t && e !== null && d.includes(e) ? [e] : [] }), "switch-view");
|
|
12
|
+
},
|
|
13
|
+
[r, o, n, e, t]
|
|
14
|
+
), f = m(() => ({ href: c(o, e === null ? { view: "multi", source: n } : { view: "multi", source: n, docs: [e], markup: t ? [e] : [] }), target: "multi" }), [o, n, e, t]), P = m(() => ({ kind: "page", view: "tree", overrides: s, embed: {} }), [s]), k = O(l);
|
|
15
|
+
return /* @__PURE__ */ u(
|
|
16
|
+
L,
|
|
17
|
+
{
|
|
18
|
+
view: "tree",
|
|
19
|
+
explorer: /* @__PURE__ */ u(j, { mode: "tree", sourceId: n, currentPath: e, openPaths: q, onOpenDocument: g, onSourceChange: S, onRevealSource: E, viewSwitch: f, tray: w, onOpenSelection: x }),
|
|
20
|
+
content: /* @__PURE__ */ D("div", { className: "aqmx-document-column aqmx-tree-document", children: [
|
|
21
|
+
e === null ? null : /* @__PURE__ */ u(R, { path: e, placement: _, markup: k }),
|
|
22
|
+
/* @__PURE__ */ u(G, { path: e, markup: t, variant: P })
|
|
23
|
+
] })
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
U as TreeLayout
|
|
29
|
+
};
|
|
@@ -19,8 +19,9 @@ export type MarkdownExplorerProps = {
|
|
|
19
19
|
readonly renderTreeFailure?: (failure: ExplorerFailure) => ReactNode | undefined;
|
|
20
20
|
readonly lockDocumentScroll?: boolean;
|
|
21
21
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
22
|
+
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
22
23
|
};
|
|
23
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics }: MarkdownExplorerProps) => ReactElement;
|
|
24
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant }: MarkdownExplorerProps) => ReactElement;
|
|
24
25
|
export type ExplorerRootProps = {
|
|
25
26
|
readonly ref?: Ref<HTMLDivElement>;
|
|
26
27
|
readonly theme: ExplorerTheme;
|
|
@@ -19,8 +19,9 @@ export type MarkdownExplorerProps = {
|
|
|
19
19
|
readonly renderTreeFailure?: (failure: ExplorerFailure) => ReactNode | undefined;
|
|
20
20
|
readonly lockDocumentScroll?: boolean;
|
|
21
21
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
22
|
+
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
22
23
|
};
|
|
23
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics }: MarkdownExplorerProps) => ReactElement;
|
|
24
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant }: MarkdownExplorerProps) => ReactElement;
|
|
24
25
|
export type ExplorerRootProps = {
|
|
25
26
|
readonly ref?: Ref<HTMLDivElement>;
|
|
26
27
|
readonly theme: ExplorerTheme;
|
|
@@ -3,6 +3,7 @@ export declare const storageKeys: (namespace: string) => Readonly<{
|
|
|
3
3
|
treeSettings: `${string}:tree-settings`;
|
|
4
4
|
multiLayout: `${string}:multi-layout`;
|
|
5
5
|
scope: `${string}:scope`;
|
|
6
|
+
editPreview: `${string}:edit-preview`;
|
|
6
7
|
treeExpansion: (sourceId: string) => string;
|
|
7
8
|
}>;
|
|
8
9
|
export declare const readStorage: (key: string) => string | null;
|
package/dist/client/storage.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const storageKeys: (namespace: string) => Readonly<{
|
|
|
3
3
|
treeSettings: `${string}:tree-settings`;
|
|
4
4
|
multiLayout: `${string}:multi-layout`;
|
|
5
5
|
scope: `${string}:scope`;
|
|
6
|
+
editPreview: `${string}:edit-preview`;
|
|
6
7
|
treeExpansion: (sourceId: string) => string;
|
|
7
8
|
}>;
|
|
8
9
|
export declare const readStorage: (key: string) => string | null;
|
|
@@ -102,18 +102,26 @@ export type ExplorerFailureDocument = {
|
|
|
102
102
|
readonly kind: "failure";
|
|
103
103
|
readonly failure: ExplorerFailure;
|
|
104
104
|
};
|
|
105
|
-
export type
|
|
106
|
-
readonly kind: "markdown";
|
|
107
|
-
readonly name: string;
|
|
108
|
-
readonly htmlContent: string;
|
|
109
|
-
readonly headings: readonly ExplorerHeading[];
|
|
110
|
-
} | {
|
|
105
|
+
export type ExplorerTextDocument = {
|
|
111
106
|
readonly kind: "text";
|
|
112
107
|
readonly name: string;
|
|
113
108
|
readonly text: string;
|
|
114
109
|
readonly truncated: boolean;
|
|
115
110
|
readonly url: string;
|
|
111
|
+
};
|
|
112
|
+
export type ExplorerDocumentEdit = {
|
|
113
|
+
readonly kind: "inline";
|
|
116
114
|
} | {
|
|
115
|
+
readonly kind: "external";
|
|
116
|
+
readonly href: string;
|
|
117
|
+
};
|
|
118
|
+
export type ExplorerDocument = {
|
|
119
|
+
readonly kind: "markdown";
|
|
120
|
+
readonly name: string;
|
|
121
|
+
readonly htmlContent: string;
|
|
122
|
+
readonly headings: readonly ExplorerHeading[];
|
|
123
|
+
readonly edit: ExplorerDocumentEdit | null;
|
|
124
|
+
} | ExplorerTextDocument | {
|
|
117
125
|
readonly kind: "image";
|
|
118
126
|
readonly name: string;
|
|
119
127
|
readonly url: string;
|
|
@@ -127,6 +135,49 @@ export type ExplorerDocument = {
|
|
|
127
135
|
readonly name: string;
|
|
128
136
|
readonly url: string;
|
|
129
137
|
} | ExplorerFailureDocument;
|
|
138
|
+
export type ExplorerTextAnswer = ExplorerTextDocument | ExplorerFailureDocument;
|
|
139
|
+
export type ExplorerGrantRequired = {
|
|
140
|
+
readonly kind: "grant";
|
|
141
|
+
readonly href: string;
|
|
142
|
+
};
|
|
143
|
+
export type ExplorerEditSource = {
|
|
144
|
+
readonly kind: "edit";
|
|
145
|
+
readonly text: string;
|
|
146
|
+
readonly version: string;
|
|
147
|
+
readonly history: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type ExplorerEditAnswer = ExplorerEditSource | ExplorerGrantRequired | ExplorerFailureDocument;
|
|
150
|
+
export type ExplorerSaveAnswer = {
|
|
151
|
+
readonly kind: "saved";
|
|
152
|
+
readonly version: string;
|
|
153
|
+
} | {
|
|
154
|
+
readonly kind: "conflict";
|
|
155
|
+
readonly version: string;
|
|
156
|
+
readonly text: string;
|
|
157
|
+
} | ExplorerGrantRequired | ExplorerFailureDocument;
|
|
158
|
+
export type ExplorerPreviewAnswer = {
|
|
159
|
+
readonly kind: "preview";
|
|
160
|
+
readonly htmlContent: string;
|
|
161
|
+
readonly headings: readonly ExplorerHeading[];
|
|
162
|
+
} | ExplorerFailureDocument;
|
|
163
|
+
export type ExplorerRevision = {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
readonly modifiedAt: string | null;
|
|
166
|
+
readonly size: number;
|
|
167
|
+
readonly author: string | null;
|
|
168
|
+
readonly kept: boolean;
|
|
169
|
+
readonly current: boolean;
|
|
170
|
+
};
|
|
171
|
+
export type ExplorerRevisionsAnswer = {
|
|
172
|
+
readonly kind: "revisions";
|
|
173
|
+
readonly revisions: readonly ExplorerRevision[];
|
|
174
|
+
} | ExplorerFailureDocument;
|
|
175
|
+
export type ExplorerRevisionAnswer = {
|
|
176
|
+
readonly kind: "revision";
|
|
177
|
+
readonly id: string;
|
|
178
|
+
readonly text: string;
|
|
179
|
+
} | ExplorerFailureDocument;
|
|
180
|
+
export declare const EXPLORER_EDIT_TOKEN_MAX_LENGTH = 1024;
|
|
130
181
|
export type ExplorerNotice = {
|
|
131
182
|
readonly id: string;
|
|
132
183
|
readonly tone: ExplorerNoticeTone;
|
|
@@ -157,6 +208,16 @@ export declare const isExplorerTreeResult: (value: unknown) => value is Explorer
|
|
|
157
208
|
export declare const headingViolation: (value: unknown) => string | null;
|
|
158
209
|
export declare const documentViolation: (value: unknown) => string | null;
|
|
159
210
|
export declare const isExplorerDocument: (value: unknown) => value is ExplorerDocument;
|
|
211
|
+
export declare const isExplorerTextAnswer: (value: unknown) => value is ExplorerTextAnswer;
|
|
212
|
+
export declare const editViolation: (value: unknown) => string | null;
|
|
213
|
+
export declare const isExplorerEditToken: (value: unknown) => value is string;
|
|
214
|
+
export declare const revisionViolation: (value: unknown) => string | null;
|
|
215
|
+
export declare const editAnswerViolation: (value: unknown, kinds: readonly string[]) => string | null;
|
|
216
|
+
export declare const isExplorerEditAnswer: (value: unknown) => value is ExplorerEditAnswer;
|
|
217
|
+
export declare const isExplorerSaveAnswer: (value: unknown) => value is ExplorerSaveAnswer;
|
|
218
|
+
export declare const isExplorerPreviewAnswer: (value: unknown) => value is ExplorerPreviewAnswer;
|
|
219
|
+
export declare const isExplorerRevisionsAnswer: (value: unknown) => value is ExplorerRevisionsAnswer;
|
|
220
|
+
export declare const isExplorerRevisionAnswer: (value: unknown) => value is ExplorerRevisionAnswer;
|
|
160
221
|
export declare const failureDocument: (reason: ExplorerFailureReason, code?: string) => ExplorerFailureDocument;
|
|
161
222
|
export declare const failureOf: (reason: ExplorerFailureReason, code?: string) => ExplorerFailure;
|
|
162
223
|
export type ExplorerSeededDocument = {
|
package/dist/core/contracts.d.ts
CHANGED
|
@@ -102,18 +102,26 @@ export type ExplorerFailureDocument = {
|
|
|
102
102
|
readonly kind: "failure";
|
|
103
103
|
readonly failure: ExplorerFailure;
|
|
104
104
|
};
|
|
105
|
-
export type
|
|
106
|
-
readonly kind: "markdown";
|
|
107
|
-
readonly name: string;
|
|
108
|
-
readonly htmlContent: string;
|
|
109
|
-
readonly headings: readonly ExplorerHeading[];
|
|
110
|
-
} | {
|
|
105
|
+
export type ExplorerTextDocument = {
|
|
111
106
|
readonly kind: "text";
|
|
112
107
|
readonly name: string;
|
|
113
108
|
readonly text: string;
|
|
114
109
|
readonly truncated: boolean;
|
|
115
110
|
readonly url: string;
|
|
111
|
+
};
|
|
112
|
+
export type ExplorerDocumentEdit = {
|
|
113
|
+
readonly kind: "inline";
|
|
116
114
|
} | {
|
|
115
|
+
readonly kind: "external";
|
|
116
|
+
readonly href: string;
|
|
117
|
+
};
|
|
118
|
+
export type ExplorerDocument = {
|
|
119
|
+
readonly kind: "markdown";
|
|
120
|
+
readonly name: string;
|
|
121
|
+
readonly htmlContent: string;
|
|
122
|
+
readonly headings: readonly ExplorerHeading[];
|
|
123
|
+
readonly edit: ExplorerDocumentEdit | null;
|
|
124
|
+
} | ExplorerTextDocument | {
|
|
117
125
|
readonly kind: "image";
|
|
118
126
|
readonly name: string;
|
|
119
127
|
readonly url: string;
|
|
@@ -127,6 +135,49 @@ export type ExplorerDocument = {
|
|
|
127
135
|
readonly name: string;
|
|
128
136
|
readonly url: string;
|
|
129
137
|
} | ExplorerFailureDocument;
|
|
138
|
+
export type ExplorerTextAnswer = ExplorerTextDocument | ExplorerFailureDocument;
|
|
139
|
+
export type ExplorerGrantRequired = {
|
|
140
|
+
readonly kind: "grant";
|
|
141
|
+
readonly href: string;
|
|
142
|
+
};
|
|
143
|
+
export type ExplorerEditSource = {
|
|
144
|
+
readonly kind: "edit";
|
|
145
|
+
readonly text: string;
|
|
146
|
+
readonly version: string;
|
|
147
|
+
readonly history: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type ExplorerEditAnswer = ExplorerEditSource | ExplorerGrantRequired | ExplorerFailureDocument;
|
|
150
|
+
export type ExplorerSaveAnswer = {
|
|
151
|
+
readonly kind: "saved";
|
|
152
|
+
readonly version: string;
|
|
153
|
+
} | {
|
|
154
|
+
readonly kind: "conflict";
|
|
155
|
+
readonly version: string;
|
|
156
|
+
readonly text: string;
|
|
157
|
+
} | ExplorerGrantRequired | ExplorerFailureDocument;
|
|
158
|
+
export type ExplorerPreviewAnswer = {
|
|
159
|
+
readonly kind: "preview";
|
|
160
|
+
readonly htmlContent: string;
|
|
161
|
+
readonly headings: readonly ExplorerHeading[];
|
|
162
|
+
} | ExplorerFailureDocument;
|
|
163
|
+
export type ExplorerRevision = {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
readonly modifiedAt: string | null;
|
|
166
|
+
readonly size: number;
|
|
167
|
+
readonly author: string | null;
|
|
168
|
+
readonly kept: boolean;
|
|
169
|
+
readonly current: boolean;
|
|
170
|
+
};
|
|
171
|
+
export type ExplorerRevisionsAnswer = {
|
|
172
|
+
readonly kind: "revisions";
|
|
173
|
+
readonly revisions: readonly ExplorerRevision[];
|
|
174
|
+
} | ExplorerFailureDocument;
|
|
175
|
+
export type ExplorerRevisionAnswer = {
|
|
176
|
+
readonly kind: "revision";
|
|
177
|
+
readonly id: string;
|
|
178
|
+
readonly text: string;
|
|
179
|
+
} | ExplorerFailureDocument;
|
|
180
|
+
export declare const EXPLORER_EDIT_TOKEN_MAX_LENGTH = 1024;
|
|
130
181
|
export type ExplorerNotice = {
|
|
131
182
|
readonly id: string;
|
|
132
183
|
readonly tone: ExplorerNoticeTone;
|
|
@@ -157,6 +208,16 @@ export declare const isExplorerTreeResult: (value: unknown) => value is Explorer
|
|
|
157
208
|
export declare const headingViolation: (value: unknown) => string | null;
|
|
158
209
|
export declare const documentViolation: (value: unknown) => string | null;
|
|
159
210
|
export declare const isExplorerDocument: (value: unknown) => value is ExplorerDocument;
|
|
211
|
+
export declare const isExplorerTextAnswer: (value: unknown) => value is ExplorerTextAnswer;
|
|
212
|
+
export declare const editViolation: (value: unknown) => string | null;
|
|
213
|
+
export declare const isExplorerEditToken: (value: unknown) => value is string;
|
|
214
|
+
export declare const revisionViolation: (value: unknown) => string | null;
|
|
215
|
+
export declare const editAnswerViolation: (value: unknown, kinds: readonly string[]) => string | null;
|
|
216
|
+
export declare const isExplorerEditAnswer: (value: unknown) => value is ExplorerEditAnswer;
|
|
217
|
+
export declare const isExplorerSaveAnswer: (value: unknown) => value is ExplorerSaveAnswer;
|
|
218
|
+
export declare const isExplorerPreviewAnswer: (value: unknown) => value is ExplorerPreviewAnswer;
|
|
219
|
+
export declare const isExplorerRevisionsAnswer: (value: unknown) => value is ExplorerRevisionsAnswer;
|
|
220
|
+
export declare const isExplorerRevisionAnswer: (value: unknown) => value is ExplorerRevisionAnswer;
|
|
160
221
|
export declare const failureDocument: (reason: ExplorerFailureReason, code?: string) => ExplorerFailureDocument;
|
|
161
222
|
export declare const failureOf: (reason: ExplorerFailureReason, code?: string) => ExplorerFailure;
|
|
162
223
|
export type ExplorerSeededDocument = {
|
package/dist/core/labels.d.cts
CHANGED
|
@@ -16,6 +16,58 @@ 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;
|
|
22
|
+
readonly editDocumentLabel: string;
|
|
23
|
+
readonly editDocument: string;
|
|
24
|
+
readonly editDocumentNamed: (name: string) => string;
|
|
25
|
+
readonly editExternallyLabel: string;
|
|
26
|
+
readonly editExternally: string;
|
|
27
|
+
readonly editExternallyNamed: (name: string) => string;
|
|
28
|
+
readonly editorRegion: (name: string) => string;
|
|
29
|
+
readonly editorLabel: (name: string) => string;
|
|
30
|
+
readonly editLoading: string;
|
|
31
|
+
readonly editToolbar: string;
|
|
32
|
+
readonly saveDraft: string;
|
|
33
|
+
readonly saveDraftTooltip: string;
|
|
34
|
+
readonly closeEditor: string;
|
|
35
|
+
readonly previewToggle: string;
|
|
36
|
+
readonly historyOpen: string;
|
|
37
|
+
readonly draftUnsaved: string;
|
|
38
|
+
readonly draftSaving: string;
|
|
39
|
+
readonly draftSaved: string;
|
|
40
|
+
readonly draftSavedMerged: string;
|
|
41
|
+
readonly draftConflicts: (count: number) => string;
|
|
42
|
+
readonly draftSaveFailed: (reason: string) => string;
|
|
43
|
+
readonly documentSaved: (name: string) => string;
|
|
44
|
+
readonly documentSavedMerged: (name: string) => string;
|
|
45
|
+
readonly conflictOurs: string;
|
|
46
|
+
readonly conflictTheirs: string;
|
|
47
|
+
readonly conflictUseOurs: string;
|
|
48
|
+
readonly conflictUseTheirs: string;
|
|
49
|
+
readonly conflictKeepBoth: string;
|
|
50
|
+
readonly conflictNext: string;
|
|
51
|
+
readonly editGrantTitle: string;
|
|
52
|
+
readonly editGrantBody: string;
|
|
53
|
+
readonly editGrantAction: string;
|
|
54
|
+
readonly editGrantRetry: string;
|
|
55
|
+
readonly unsavedTitle: string;
|
|
56
|
+
readonly unsavedBody: (names: string) => string;
|
|
57
|
+
readonly unsavedDiscard: string;
|
|
58
|
+
readonly unsavedStay: string;
|
|
59
|
+
readonly historyTitle: (name: string) => string;
|
|
60
|
+
readonly historyLoading: string;
|
|
61
|
+
readonly historyEmpty: string;
|
|
62
|
+
readonly historyCurrent: string;
|
|
63
|
+
readonly historyKept: string;
|
|
64
|
+
readonly historyEntry: (time: string, author: string) => string;
|
|
65
|
+
readonly historyRestore: string;
|
|
66
|
+
readonly historyClose: string;
|
|
67
|
+
readonly historyRestored: (name: string) => string;
|
|
68
|
+
readonly previewRegion: string;
|
|
69
|
+
readonly previewUpdating: string;
|
|
70
|
+
readonly previewFailed: (reason: string) => string;
|
|
19
71
|
readonly expandAll: string;
|
|
20
72
|
readonly collapseAll: string;
|
|
21
73
|
readonly treeSettings: string;
|
|
@@ -77,6 +129,7 @@ export type MarkdownExplorerLabels = {
|
|
|
77
129
|
readonly documentRegion: string;
|
|
78
130
|
readonly documentEmpty: string;
|
|
79
131
|
readonly documentLoading: string;
|
|
132
|
+
readonly markupLoading: string;
|
|
80
133
|
readonly documentShown: (name: string) => string;
|
|
81
134
|
readonly documentFailed: (name: string, title: string) => string;
|
|
82
135
|
readonly announcementSequence: (messages: readonly string[]) => string;
|
package/dist/core/labels.d.ts
CHANGED
|
@@ -16,6 +16,58 @@ 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;
|
|
22
|
+
readonly editDocumentLabel: string;
|
|
23
|
+
readonly editDocument: string;
|
|
24
|
+
readonly editDocumentNamed: (name: string) => string;
|
|
25
|
+
readonly editExternallyLabel: string;
|
|
26
|
+
readonly editExternally: string;
|
|
27
|
+
readonly editExternallyNamed: (name: string) => string;
|
|
28
|
+
readonly editorRegion: (name: string) => string;
|
|
29
|
+
readonly editorLabel: (name: string) => string;
|
|
30
|
+
readonly editLoading: string;
|
|
31
|
+
readonly editToolbar: string;
|
|
32
|
+
readonly saveDraft: string;
|
|
33
|
+
readonly saveDraftTooltip: string;
|
|
34
|
+
readonly closeEditor: string;
|
|
35
|
+
readonly previewToggle: string;
|
|
36
|
+
readonly historyOpen: string;
|
|
37
|
+
readonly draftUnsaved: string;
|
|
38
|
+
readonly draftSaving: string;
|
|
39
|
+
readonly draftSaved: string;
|
|
40
|
+
readonly draftSavedMerged: string;
|
|
41
|
+
readonly draftConflicts: (count: number) => string;
|
|
42
|
+
readonly draftSaveFailed: (reason: string) => string;
|
|
43
|
+
readonly documentSaved: (name: string) => string;
|
|
44
|
+
readonly documentSavedMerged: (name: string) => string;
|
|
45
|
+
readonly conflictOurs: string;
|
|
46
|
+
readonly conflictTheirs: string;
|
|
47
|
+
readonly conflictUseOurs: string;
|
|
48
|
+
readonly conflictUseTheirs: string;
|
|
49
|
+
readonly conflictKeepBoth: string;
|
|
50
|
+
readonly conflictNext: string;
|
|
51
|
+
readonly editGrantTitle: string;
|
|
52
|
+
readonly editGrantBody: string;
|
|
53
|
+
readonly editGrantAction: string;
|
|
54
|
+
readonly editGrantRetry: string;
|
|
55
|
+
readonly unsavedTitle: string;
|
|
56
|
+
readonly unsavedBody: (names: string) => string;
|
|
57
|
+
readonly unsavedDiscard: string;
|
|
58
|
+
readonly unsavedStay: string;
|
|
59
|
+
readonly historyTitle: (name: string) => string;
|
|
60
|
+
readonly historyLoading: string;
|
|
61
|
+
readonly historyEmpty: string;
|
|
62
|
+
readonly historyCurrent: string;
|
|
63
|
+
readonly historyKept: string;
|
|
64
|
+
readonly historyEntry: (time: string, author: string) => string;
|
|
65
|
+
readonly historyRestore: string;
|
|
66
|
+
readonly historyClose: string;
|
|
67
|
+
readonly historyRestored: (name: string) => string;
|
|
68
|
+
readonly previewRegion: string;
|
|
69
|
+
readonly previewUpdating: string;
|
|
70
|
+
readonly previewFailed: (reason: string) => string;
|
|
19
71
|
readonly expandAll: string;
|
|
20
72
|
readonly collapseAll: string;
|
|
21
73
|
readonly treeSettings: string;
|
|
@@ -77,6 +129,7 @@ export type MarkdownExplorerLabels = {
|
|
|
77
129
|
readonly documentRegion: string;
|
|
78
130
|
readonly documentEmpty: string;
|
|
79
131
|
readonly documentLoading: string;
|
|
132
|
+
readonly markupLoading: string;
|
|
80
133
|
readonly documentShown: (name: string) => string;
|
|
81
134
|
readonly documentFailed: (name: string, title: string) => string;
|
|
82
135
|
readonly announcementSequence: (messages: readonly string[]) => string;
|
package/dist/core/location.d.cts
CHANGED
|
@@ -17,17 +17,20 @@ export type ExplorerLocation = {
|
|
|
17
17
|
readonly source: string;
|
|
18
18
|
readonly doc: string | null;
|
|
19
19
|
readonly overrides: ExplorerOverrides;
|
|
20
|
+
readonly markup: boolean;
|
|
20
21
|
} | {
|
|
21
22
|
readonly view: "multi";
|
|
22
23
|
readonly source: string;
|
|
23
24
|
readonly docs: readonly string[];
|
|
24
25
|
readonly maximized: string | null;
|
|
26
|
+
readonly markup: readonly string[];
|
|
25
27
|
} | {
|
|
26
28
|
readonly view: "single";
|
|
27
29
|
readonly source: string;
|
|
28
30
|
readonly doc: string;
|
|
29
31
|
readonly overrides: ExplorerOverrides;
|
|
30
32
|
readonly embed: ExplorerEmbedOptions;
|
|
33
|
+
readonly markup: boolean;
|
|
31
34
|
};
|
|
32
35
|
export type ExplorerLocationResult = {
|
|
33
36
|
readonly kind: "location";
|
|
@@ -42,17 +45,20 @@ export type ExplorerHrefTarget = {
|
|
|
42
45
|
readonly source?: string;
|
|
43
46
|
readonly doc?: string | null;
|
|
44
47
|
readonly overrides?: ExplorerOverrides;
|
|
48
|
+
readonly markup?: boolean;
|
|
45
49
|
} | {
|
|
46
50
|
readonly view: "multi";
|
|
47
51
|
readonly source?: string;
|
|
48
52
|
readonly docs?: readonly string[];
|
|
49
53
|
readonly maximized?: string | null;
|
|
54
|
+
readonly markup?: readonly string[];
|
|
50
55
|
} | {
|
|
51
56
|
readonly view: "single";
|
|
52
57
|
readonly source?: string;
|
|
53
58
|
readonly doc: string;
|
|
54
59
|
readonly overrides?: ExplorerOverrides;
|
|
55
60
|
readonly embed?: ExplorerEmbedOptions;
|
|
61
|
+
readonly markup?: boolean;
|
|
56
62
|
};
|
|
57
63
|
export type ExplorerSourcelessHrefTarget = ExplorerHrefTarget & {
|
|
58
64
|
readonly source?: undefined;
|
|
@@ -73,6 +79,7 @@ export declare const EXPLORER_QUERY: Readonly<{
|
|
|
73
79
|
readonly padding: "padding";
|
|
74
80
|
readonly width: "width";
|
|
75
81
|
readonly maxWidth: "maxWidth";
|
|
82
|
+
readonly markup: "markup";
|
|
76
83
|
}>;
|
|
77
84
|
export declare const encodeDocumentSegment: (path: string) => string;
|
|
78
85
|
export declare const decodeDocumentSegment: (segment: string) => string;
|
package/dist/core/location.d.ts
CHANGED
|
@@ -17,17 +17,20 @@ export type ExplorerLocation = {
|
|
|
17
17
|
readonly source: string;
|
|
18
18
|
readonly doc: string | null;
|
|
19
19
|
readonly overrides: ExplorerOverrides;
|
|
20
|
+
readonly markup: boolean;
|
|
20
21
|
} | {
|
|
21
22
|
readonly view: "multi";
|
|
22
23
|
readonly source: string;
|
|
23
24
|
readonly docs: readonly string[];
|
|
24
25
|
readonly maximized: string | null;
|
|
26
|
+
readonly markup: readonly string[];
|
|
25
27
|
} | {
|
|
26
28
|
readonly view: "single";
|
|
27
29
|
readonly source: string;
|
|
28
30
|
readonly doc: string;
|
|
29
31
|
readonly overrides: ExplorerOverrides;
|
|
30
32
|
readonly embed: ExplorerEmbedOptions;
|
|
33
|
+
readonly markup: boolean;
|
|
31
34
|
};
|
|
32
35
|
export type ExplorerLocationResult = {
|
|
33
36
|
readonly kind: "location";
|
|
@@ -42,17 +45,20 @@ export type ExplorerHrefTarget = {
|
|
|
42
45
|
readonly source?: string;
|
|
43
46
|
readonly doc?: string | null;
|
|
44
47
|
readonly overrides?: ExplorerOverrides;
|
|
48
|
+
readonly markup?: boolean;
|
|
45
49
|
} | {
|
|
46
50
|
readonly view: "multi";
|
|
47
51
|
readonly source?: string;
|
|
48
52
|
readonly docs?: readonly string[];
|
|
49
53
|
readonly maximized?: string | null;
|
|
54
|
+
readonly markup?: readonly string[];
|
|
50
55
|
} | {
|
|
51
56
|
readonly view: "single";
|
|
52
57
|
readonly source?: string;
|
|
53
58
|
readonly doc: string;
|
|
54
59
|
readonly overrides?: ExplorerOverrides;
|
|
55
60
|
readonly embed?: ExplorerEmbedOptions;
|
|
61
|
+
readonly markup?: boolean;
|
|
56
62
|
};
|
|
57
63
|
export type ExplorerSourcelessHrefTarget = ExplorerHrefTarget & {
|
|
58
64
|
readonly source?: undefined;
|
|
@@ -73,6 +79,7 @@ export declare const EXPLORER_QUERY: Readonly<{
|
|
|
73
79
|
readonly padding: "padding";
|
|
74
80
|
readonly width: "width";
|
|
75
81
|
readonly maxWidth: "maxWidth";
|
|
82
|
+
readonly markup: "markup";
|
|
76
83
|
}>;
|
|
77
84
|
export declare const encodeDocumentSegment: (path: string) => string;
|
|
78
85
|
export declare const decodeDocumentSegment: (segment: string) => string;
|
|
@@ -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"]),C=/[\u0000-\u001f\u007f]/u,X=/\p{Cs}/u,$=e=>{const n=e.split("/").filter(t=>t!=="").at(-1);return n===void 0?e:n},p=e=>e.length>0&&e.length<=4096&&!X.test(e)&&!C.test(e)&&!e.includes("\\"),T=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),U=/(?:%[0-9A-Fa-f]{2})+/gu,H=new TextDecoder("utf-8"),z=/[/\\]/u,F=e=>e.replace(U,n=>H.decode(Uint8Array.from(n.slice(1).split("%").map(t=>Number.parseInt(t,16))))),M=e=>{const n=[e];let t=e;for(let r=0;r<3&&t.includes("%");r+=1){const o=F(t);if(o===t)break;n.push(o),t=o}return n.map(T)},V=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 n=T(e).split("*").map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${n}$`,"su")},R=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const n=e.map(V),t=o=>o!==""&&n.some(s=>s.test(o)),r=o=>o!==""&&M(o).some(s=>t(s)||s.split(z).some(t));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},G=R(b),K=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),Y=e=>e===void 0?G:e===!1?K:R(e),W=(e,n)=>R(e).deniesPath(n),y=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),J=Object.freeze(["file","directory"]),Q=Object.freeze(["video","audio","pdf"]),B=Object.freeze(["info","warning","danger"]),q=Object.freeze(["markdown","text","image","media","file","failure"]),O=Object.freeze({min:1,max:6}),Z=1e4,l=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ee=Object.freeze(["http:","https:","mailto:"]),_=1024,te=/^[a-z0-9-]{1,64}$/u,ne="https://relative.invalid/",h=64,f=(e,n)=>typeof n=="string"&&e.includes(n),i=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,x=e=>f(y,e),re=e=>f(J,e),P=e=>f(Q,e),oe=e=>f(B,e),se=e=>f(q,e),m=e=>typeof e=="string"&&te.test(e),ie=(e,n)=>{if(typeof e!="string")return!1;try{return n.includes(new URL(e,ne).protocol)}catch{return!1}},u=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:n,code:t}=e;return x(n)?t!==void 0&&!m(t)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${i(t)}`:null:`unknown failure reason ${i(n)}`},S=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:n,path:t,type:r,mimeType:o,children:s,lazy:a}=e;return typeof n!="string"||n===""?"an entry needs a non-empty name":typeof t!="string"||!p(t)?"an entry needs an acceptable path":re(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":a!==void 0&&typeof a!="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||a===!0)?"a file entry cannot have children or be lazy":a===!0&&Array.isArray(s)&&s.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${i(r)}`},N=e=>{if(S(e)!==null)return!1;const{children:n}=e;return n===void 0||n.every(N)},L=e=>{if(e===null||typeof e!="object")return!1;const{status:n,entries:t,failure:r}=e;return n==="ok"?Array.isArray(t)&&t.every(N):n==="error"&&u(r)===null},ae=e=>{if(e===null||typeof e!="object")return!1;const{status:n,ancestors:t,failure:r}=e;return n==="ok"?t===null||D(t):n==="error"&&u(r)===null},D=e=>Array.isArray(e)&&e.every(n=>typeof n=="string"&&p(n))&&new Set(e).size===e.length,le=e=>{if(e===null||typeof e!="object")return!1;const{status:n,source:t,ancestors:r,failure:o}=e;return n==="ok"?t===null&&r===null||typeof t=="string"&&t!==""&&D(r):n==="error"&&u(o)===null},ce=e=>{if(e===null||typeof e!="object")return!1;const{status:n,loadedAt:t}=e;return n==="ok"&&!(Number.isSafeInteger(t)&&t>=0)?!1:L(e)},A=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:n,depth:t,id:r}=e;return typeof n!="string"||typeof r!="string"?"a heading needs text and id strings":typeof t!="number"||!Number.isInteger(t)||t<O.min||t>O.max?`a heading depth must be an integer in 1..6; got ${String(t)}`:null},v=e=>{if(e===null||typeof e!="object")return"a document must be an object";const n=e,{kind:t}=n;if(!se(t))return`unknown document kind ${i(t)}`;if(t==="failure")return u(n.failure);if(typeof n.name!="string")return"a document needs a name string";switch(t){case"markdown":{const{htmlContent:r,headings:o}=n;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const a=A(s);if(a!==null)return a}return fe(n.edit)}case"text":return typeof n.text!="string"||typeof n.truncated!="boolean"?"a text document needs text and truncated":l(n.url)?null:"a text document needs a root-relative url";case"image":return l(n.url)?null:"an image document needs a root-relative url";case"media":return l(n.url)?P(n.mediaType)?null:`unknown media type ${i(n.mediaType)}`:"a media document needs a root-relative url";case"file":return l(n.url)?null:"a file document needs a root-relative url"}},w=e=>v(e)===null,ue=e=>w(e)&&(e.kind==="text"||e.kind==="failure"),fe=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:n,href:t}=e;return n==="inline"?t===void 0?null:"an inline edit carries no href":n!=="external"?`unknown edit kind ${i(n)}`:de(t)?null:`an external edit needs an absolute https: href; got ${i(t)}`},de=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},c=e=>typeof e=="string"&&e.length>0&&e.length<=_,Ee=e=>l(e.href)?null:`a grant needs a root-relative href; got ${i(e.href)}`,k=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:n,modifiedAt:t,size:r,author:o,kept:s,current:a}=e;return c(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)}`:o!==null&&typeof o!="string"?`a revision's author must be a string or null; got ${i(o)}`:typeof s!="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 ${i(n)}`},d=(e,n)=>{if(e===null||typeof e!="object")return"an answer must be an object";const t=e,{kind:r}=t;if(r==="failure")return u(t.failure);if(typeof r!="string"||!n.includes(r))return`unexpected answer kind ${i(r)}`;switch(r){case"grant":return Ee(t);case"edit":return typeof t.text!="string"||typeof t.history!="boolean"?"an edit source needs text and history":c(t.version)?null:`an edit source needs a version; got ${i(t.version)}`;case"saved":return c(t.version)?null:`a saved answer needs a version; got ${i(t.version)}`;case"conflict":return typeof t.text!="string"?"a conflict needs the current text":c(t.version)?null:`a conflict needs the current version; got ${i(t.version)}`;case"preview":{const{htmlContent:o,headings:s}=t;if(typeof o!="string"||!Array.isArray(s))return"a preview needs htmlContent and headings";for(const a of s){const g=A(a);if(g!==null)return g}return null}case"revisions":{if(!Array.isArray(t.revisions))return"revisions need an array";for(const o of t.revisions){const s=k(o);if(s!==null)return s}return null}case"revision":return typeof t.text!="string"?"a revision answer needs text":c(t.id)?null:`a revision answer needs an id; got ${i(t.id)}`;default:return`unexpected answer kind ${i(r)}`}},pe=Object.freeze(["edit","grant"]),Re=Object.freeze(["saved","conflict","grant"]),ye=Object.freeze(["preview"]),_e=Object.freeze(["revisions"]),me=Object.freeze(["revision"]),Ae=e=>d(e,pe)===null,ge=e=>d(e,Re)===null,Oe=e=>d(e,ye)===null,he=e=>d(e,_e)===null,be=e=>d(e,me)===null,Te=(e,n)=>({kind:"failure",failure:I(e,n)}),I=(e,n)=>m(n)?{reason:e,code:n}:{reason:e},xe=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"}),Pe="asset",Se="link-card",Ne=(e,n,t)=>{const r=`${e}/${Pe}?${E.path}=${encodeURIComponent(n)}`;return t===null?r:`${r}&${E.version}=${encodeURIComponent(t)}`},Le=e=>`${e}/${Se}`,De="X-Markdown-Explorer-Scope",ve="X-Markdown-Explorer",we="refresh",ke="edit",Ie="text/markdown",je=e=>xe.includes(e),j=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Ce=e=>{const[n,...t]=y.filter(r=>j[r]===e);return n!==void 0&&t.length===0?n:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_DRAFT_MEDIA_TYPE=Ie;exports.EXPLORER_EDIT_PROOF=ke;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=y;exports.EXPLORER_FAILURE_STATUS=j;exports.EXPLORER_LINK_PROTOCOLS=ee;exports.EXPLORER_MAX_HEADINGS=Z;exports.EXPLORER_PROOF_HEADER=ve;exports.EXPLORER_REFRESH_PROOF=we;exports.EXPLORER_SCOPE_HEADER=De;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=v;exports.entryViolation=S;exports.explorerAssetHref=Ne;exports.explorerLinkCardEndpoint=Le;exports.failureDocument=Te;exports.failureOf=I;exports.failureReasonOfStatus=Ce;exports.failureViolation=u;exports.headingViolation=A;exports.isAcceptableDocumentPath=p;exports.isAcceptableUrl=ie;exports.isDeniedPath=W;exports.isExplorerAncestorsResult=ae;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=je;exports.isExplorerDocument=w;exports.isExplorerEditAnswer=Ae;exports.isExplorerEditToken=c;exports.isExplorerFailureCode=m;exports.isExplorerFailureReason=x;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=oe;exports.isExplorerPreviewAnswer=Oe;exports.isExplorerRevealResult=le;exports.isExplorerRevisionAnswer=be;exports.isExplorerRevisionsAnswer=he;exports.isExplorerSaveAnswer=ge;exports.isExplorerTextAnswer=ue;exports.isExplorerTreeResult=ce;exports.isRootRelativeUrl=l;exports.lastPathSegment=$;exports.resolvePathRules=Y;exports.revisionViolation=k;
|