@aiquants/markdown-explorer 0.8.0 → 0.10.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 +17 -0
- package/README.md +6 -3
- package/dist/{EditSurface-CaS1O6Nt.js → EditSurface-1Jf0CG-f.js} +1 -1
- package/dist/{EditSurface-5nbW7NTP.cjs → EditSurface-B-l3Do_C.cjs} +1 -1
- package/dist/{ExplorerSplit-C9Y02nvj.js → ExplorerSplit-D0zf7Cr_.js} +2 -2
- package/dist/{ExplorerSplit-D60N3_X7.cjs → ExplorerSplit-WX8afxrQ.cjs} +1 -1
- package/dist/{MultiLayout-CqTyFZ_i.cjs → MultiLayout-Bq10p3a3.cjs} +1 -1
- package/dist/{MultiLayout-DBpUTcCQ.js → MultiLayout-Jy9BKofx.js} +4 -4
- package/dist/{NativeScrollBar-CiVlg2ob.js → NativeScrollBar-CyiyL47o.js} +1 -1
- package/dist/{NativeScrollBar-QlOtnddZ.cjs → NativeScrollBar-Dt6xH5Mb.cjs} +1 -1
- package/dist/{TreeLayout-bk-Ziybl.js → TreeLayout-8pRo1ANN.js} +3 -3
- package/dist/{TreeLayout-uwvAgr-t.cjs → TreeLayout-kVWFEKJD.cjs} +1 -1
- package/dist/core/labels.d.cts +3 -0
- package/dist/core/labels.d.ts +3 -0
- package/dist/dataRoute-8pyILcjL.cjs +1 -0
- package/dist/dataRoute-Csl1WBDz.js +278 -0
- package/dist/{index-etFEpIE_.js → index-CfcJEnrC.js} +1126 -1027
- package/dist/index-sNJrKoGN.cjs +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +14 -14
- package/dist/{location-DmzVAFvo.cjs → location-CRYkEWiC.cjs} +1 -1
- package/dist/{location-Q4sgRrUm.js → location-Dc1qNEGm.js} +1 -1
- package/dist/{merge-BR4jKpIc.cjs → merge-D0aGvFKC.cjs} +1 -1
- package/dist/{merge-DfI0ro2L.js → merge-SRCxtHk2.js} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +632 -621
- package/docs/behavior/dom-hooks.md +2 -1
- package/docs/behavior/layout.md +3 -2
- package/docs/behavior/localization.md +1 -0
- package/docs/behavior/security.md +2 -1
- package/docs/behavior/url-contract.md +1 -0
- package/package.json +1 -1
- package/dist/dataRoute-CcZ8PK00.cjs +0 -1
- package/dist/dataRoute-D1vE1wFW.js +0 -270
- package/dist/index-Dlkzr6Zn.cjs +0 -13
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as ie, jsx as M } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as We, use as Te, useRef as q, useState as $, useLayoutEffect as F, useMemo as R, useSyncExternalStore as Ke, useCallback as I, memo as Je, useEffect as U, useImperativeHandle as Xe } from "react";
|
|
3
|
-
import { g as ce, e as ke, h as Ze, P as Qe, j as en } from "./location-
|
|
4
|
-
import { m as nn, u as J, n as tn, I as on, D as rn, c as ln, o as sn, L as Le } from "./index-
|
|
5
|
-
import { S as an, a as cn, b as un } from "./ExplorerSplit-
|
|
3
|
+
import { g as ce, e as ke, h as Ze, P as Qe, j as en } from "./location-Dc1qNEGm.js";
|
|
4
|
+
import { m as nn, u as J, n as tn, I as on, D as rn, c as ln, o as sn, L as Le } from "./index-CfcJEnrC.js";
|
|
5
|
+
import { S as an, a as cn, b as un } from "./ExplorerSplit-D0zf7Cr_.js";
|
|
6
6
|
import { SCROLL_AREA_SELECTOR as Ae, SCROLL_ROOT_SELECTOR as te, generateColumnIds as dn, sortColumnIds as Ie, generateColumnId as De, NO_PANEL_DRAG_ATTRIBUTE as mn, useDragDropColumns as fn, DEFAULT_DEBUG_CONFIG as he, DragDropLayout as pn } from "@aiquants/drag-drop-panels";
|
|
7
7
|
import { useNavigate as gn, useLocation as hn } from "react-router";
|
|
8
8
|
import { s as vn, r as wn, w as yn } from "./storage-BSthKLSG.js";
|
|
9
|
-
import {
|
|
9
|
+
import { C as Sn, i as xn } from "./dataRoute-Csl1WBDz.js";
|
|
10
10
|
import { createPortal as En } from "react-dom";
|
|
11
11
|
import { HostedScrollArea as On } from "@aiquants/markdown";
|
|
12
12
|
import { N as bn } from "./scrollBarGeometry-DOBdGNV-.js";
|
|
@@ -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-CfcJEnrC.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) => {
|
|
@@ -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-sNJrKoGN.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,9 +1,9 @@
|
|
|
1
1
|
import { jsx as u, jsxs as D } from "react/jsx-runtime";
|
|
2
2
|
import { useState as T, useMemo as m, useCallback as i } from "react";
|
|
3
3
|
import { useLocation as b } from "react-router";
|
|
4
|
-
import { e as c, c as C } from "./location-
|
|
5
|
-
import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-
|
|
6
|
-
import { E as H, a as L, b as j } from "./ExplorerSplit-
|
|
4
|
+
import { e as c, c as C } from "./location-Dc1qNEGm.js";
|
|
5
|
+
import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-CfcJEnrC.js";
|
|
6
|
+
import { E as H, a as L, b as j } from "./ExplorerSplit-D0zf7Cr_.js";
|
|
7
7
|
const q = /* @__PURE__ */ new Set(), U = ({ location: l }) => {
|
|
8
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
9
|
(a) => {
|
|
@@ -1 +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-
|
|
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-CRYkEWiC.cjs"),l=require("./index-sNJrKoGN.cjs"),p=require("./ExplorerSplit-WX8afxrQ.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;
|
package/dist/core/labels.d.cts
CHANGED
|
@@ -160,6 +160,9 @@ export type MarkdownExplorerLabels = {
|
|
|
160
160
|
readonly imageZoomLevel: (percent: number) => string;
|
|
161
161
|
readonly openInNewTab: string;
|
|
162
162
|
readonly download: string;
|
|
163
|
+
readonly copyText: string;
|
|
164
|
+
readonly copiedText: string;
|
|
165
|
+
readonly copyTextFailed: string;
|
|
163
166
|
readonly mediaUnsupported: string;
|
|
164
167
|
readonly fileNotShown: string;
|
|
165
168
|
readonly viewerLoading: string;
|
package/dist/core/labels.d.ts
CHANGED
|
@@ -160,6 +160,9 @@ export type MarkdownExplorerLabels = {
|
|
|
160
160
|
readonly imageZoomLevel: (percent: number) => string;
|
|
161
161
|
readonly openInNewTab: string;
|
|
162
162
|
readonly download: string;
|
|
163
|
+
readonly copyText: string;
|
|
164
|
+
readonly copiedText: string;
|
|
165
|
+
readonly copyTextFailed: string;
|
|
163
166
|
readonly mediaUnsupported: string;
|
|
164
167
|
readonly fileNotShown: string;
|
|
165
168
|
readonly viewerLoading: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const x=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),X=/[\u0000-\u001f\u007f]/u,C=/\p{Cs}/u,U=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},p=e=>e.length>0&&e.length<=4096&&!C.test(e)&&!X.test(e)&&!e.includes("\\"),b=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),H=/(?:%[0-9A-Fa-f]{2})+/gu,z=new TextDecoder("utf-8"),F=/[/\\]/u,M=e=>e.replace(H,t=>z.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),V=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=M(n);if(o===n)break;t.push(o),n=o}return t.map(b)},G=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=b(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},R=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(G),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&V(o).some(s=>n(s)||s.split(F).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},K=R(x),Y=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),W=e=>e===void 0?K:e===!1?Y:R(e),J=(e,t)=>R(e).deniesPath(t),y=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),Q=Object.freeze(["file","directory"]),q=Object.freeze(["video","audio","pdf"]),B=Object.freeze(["info","warning","danger"]),Z=Object.freeze(["markdown","text","image","media","file","failure"]),O=Object.freeze({min:1,max:6}),ee=1e4,l=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),te=Object.freeze(["http:","https:","mailto:"]),_=1024,ne=/^[a-z0-9-]{1,64}$/u,re="https://relative.invalid/",h=64,d=(e,t)=>typeof t=="string"&&e.includes(t),i=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,T=e=>d(y,e),oe=e=>d(Q,e),P=e=>d(q,e),se=e=>d(B,e),ie=e=>d(Z,e),m=e=>typeof e=="string"&&ne.test(e),ae=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,re).protocol)}catch{return!1}},u=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&&!m(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${i(n)}`:null:`unknown failure reason ${i(t)}`},S=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,children:s,lazy:a}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!p(n)?"an entry needs an acceptable path":oe(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)}`},L=e=>{if(S(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(L)},N=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(L):t==="error"&&u(r)===null},le=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||D(n):t==="error"&&u(r)===null},D=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&p(t))&&new Set(e).size===e.length,ce=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!==""&&D(r):t==="error"&&u(o)===null},ue=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:N(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},v=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!ie(n))return`unknown document kind ${i(n)}`;if(n==="failure")return u(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const a=A(s);if(a!==null)return a}return de(t.edit)}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":l(t.url)?null:"a text document needs a root-relative url";case"image":return l(t.url)?null:"an image document needs a root-relative url";case"media":return l(t.url)?P(t.mediaType)?null:`unknown media type ${i(t.mediaType)}`:"a media document needs a root-relative url";case"file":return l(t.url)?null:"a file document needs a root-relative url"}},w=e=>v(e)===null,fe=e=>w(e)&&(e.kind==="text"||e.kind==="failure"),de=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!=="external"?`unknown edit kind ${i(t)}`:Ee(n)?null:`an external edit needs an absolute https: href; got ${i(n)}`},Ee=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<=_,pe=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:t,modifiedAt:n,size:r,author:o,kept:s,current:a}=e;return c(t)?n!==null&&(typeof n!="string"||Number.isNaN(Date.parse(n)))?`a revision's modifiedAt must be a date-time string or null; got ${i(n)}`: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(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 u(n.failure);if(typeof r!="string"||!t.includes(r))return`unexpected answer kind ${i(r)}`;switch(r){case"grant":return pe(n);case"edit":return typeof n.text!="string"||typeof n.history!="boolean"?"an edit source needs text and history":c(n.version)?null:`an edit source needs a version; got ${i(n.version)}`;case"saved":return c(n.version)?null:`a saved answer needs a version; got ${i(n.version)}`;case"conflict":return typeof n.text!="string"?"a conflict needs the current text":c(n.version)?null:`a conflict needs the current version; got ${i(n.version)}`;case"preview":{const{htmlContent:o,headings:s}=n;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(n.revisions))return"revisions need an array";for(const o of n.revisions){const s=k(o);if(s!==null)return s}return null}case"revision":return typeof n.text!="string"?"a revision answer needs text":c(n.id)?null:`a revision answer needs an id; got ${i(n.id)}`;default:return`unexpected answer kind ${i(r)}`}},Re=Object.freeze(["edit","grant"]),ye=Object.freeze(["saved","conflict","grant"]),_e=Object.freeze(["preview"]),me=Object.freeze(["revisions"]),Ae=Object.freeze(["revision"]),ge=e=>E(e,Re)===null,Oe=e=>E(e,ye)===null,he=e=>E(e,_e)===null,xe=e=>E(e,me)===null,be=e=>E(e,Ae)===null,Te=(e,t)=>({kind:"failure",failure:I(e,t)}),I=(e,t)=>m(t)?{reason:e,code:t}:{reason:e},Pe=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),f=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),Se="asset",Le="link-card",Ne=(e,t,n)=>{const r=`${e}/${Se}?${f.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${f.version}=${encodeURIComponent(n)}`},j="text",De=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${f.display}=${j}`},ve=e=>{const t=e.getAll(f.display);return t.length===0?"file":t.length===1&&t[0]===j?"text":null},we=e=>`${e}/${Le}`,ke="X-Markdown-Explorer-Scope",Ie="X-Markdown-Explorer",je="refresh",$e="edit",Xe="text/markdown",Ce=e=>Pe.includes(e),$=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Ue=e=>{const[t,...n]=y.filter(r=>$[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=x;exports.EXPLORER_DATA_QUERY=f;exports.EXPLORER_DRAFT_MEDIA_TYPE=Xe;exports.EXPLORER_EDIT_PROOF=$e;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=y;exports.EXPLORER_FAILURE_STATUS=$;exports.EXPLORER_LINK_PROTOCOLS=te;exports.EXPLORER_MAX_HEADINGS=ee;exports.EXPLORER_PROOF_HEADER=Ie;exports.EXPLORER_REFRESH_PROOF=je;exports.EXPLORER_SCOPE_HEADER=ke;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=v;exports.entryViolation=S;exports.explorerAssetHref=Ne;exports.explorerLinkCardEndpoint=we;exports.explorerPlainTextHref=De;exports.failureDocument=Te;exports.failureOf=I;exports.failureReasonOfStatus=Ue;exports.failureViolation=u;exports.headingViolation=A;exports.isAcceptableDocumentPath=p;exports.isAcceptableUrl=ae;exports.isDeniedPath=J;exports.isExplorerAncestorsResult=le;exports.isExplorerChildrenResult=N;exports.isExplorerDataOperation=Ce;exports.isExplorerDocument=w;exports.isExplorerEditAnswer=ge;exports.isExplorerEditToken=c;exports.isExplorerFailureCode=m;exports.isExplorerFailureReason=T;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=se;exports.isExplorerPreviewAnswer=he;exports.isExplorerRevealResult=ce;exports.isExplorerRevisionAnswer=be;exports.isExplorerRevisionsAnswer=xe;exports.isExplorerSaveAnswer=Oe;exports.isExplorerTextAnswer=fe;exports.isExplorerTreeResult=ue;exports.isRootRelativeUrl=l;exports.lastPathSegment=U;exports.readExplorerAssetDisplay=ve;exports.resolvePathRules=W;exports.revisionViolation=k;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
const de = 4096;
|
|
2
|
+
const N = 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
|
+
]), v = /[\u0000-\u001f\u007f]/u, w = /\p{Cs}/u, pe = (e) => {
|
|
61
|
+
const t = e.split("/").filter((n) => n !== "").at(-1);
|
|
62
|
+
return t === void 0 ? e : t;
|
|
63
|
+
}, R = (e) => e.length > 0 && e.length <= 4096 && !w.test(e) && !v.test(e) && !e.includes("\\"), h = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), P = /(?:%[0-9A-Fa-f]{2})+/gu, L = new TextDecoder("utf-8"), D = /[/\\]/u, k = (e) => e.replace(
|
|
64
|
+
P,
|
|
65
|
+
(t) => L.decode(
|
|
66
|
+
Uint8Array.from(
|
|
67
|
+
t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
), j = (e) => {
|
|
71
|
+
const t = [e];
|
|
72
|
+
let n = e;
|
|
73
|
+
for (let r = 0; r < 3 && n.includes("%"); r += 1) {
|
|
74
|
+
const s = k(n);
|
|
75
|
+
if (s === n) break;
|
|
76
|
+
t.push(s), n = s;
|
|
77
|
+
}
|
|
78
|
+
return t.map(h);
|
|
79
|
+
}, $ = (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 t = h(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
83
|
+
return new RegExp(`^${t}$`, "su");
|
|
84
|
+
}, E = (e) => {
|
|
85
|
+
if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
|
|
86
|
+
const t = e.map($), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && j(s).some((o) => n(o) || o.split(D).some(n));
|
|
87
|
+
return {
|
|
88
|
+
deniesPath: (s) => s.split("/").some(r),
|
|
89
|
+
deniesName: r
|
|
90
|
+
};
|
|
91
|
+
}, I = E(N), C = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ee = (e) => e === void 0 ? I : e === !1 ? C : E(e), ye = (e, t) => E(e).deniesPath(t), A = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), z = Object.freeze(["file", "directory"]), U = Object.freeze(["video", "audio", "pdf"]), X = Object.freeze(["info", "warning", "danger"]), H = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), me = 1e4, c = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ge = Object.freeze(["http:", "https:", "mailto:"]), _ = 1024, F = /^[a-z0-9-]{1,64}$/u, V = "https://relative.invalid/", g = 64, u = (e, t) => typeof t == "string" && e.includes(t), i = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, M = (e) => u(A, e), K = (e) => u(z, e), G = (e) => u(U, e), Re = (e) => u(X, e), Y = (e) => u(H, e), b = (e) => typeof e == "string" && F.test(e), he = (e, t) => {
|
|
92
|
+
if (typeof e != "string") return !1;
|
|
93
|
+
try {
|
|
94
|
+
return t.includes(new URL(e, V).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: t, code: n } = e;
|
|
101
|
+
return M(t) ? n !== void 0 && !b(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${i(n)}` : null : `unknown failure reason ${i(t)}`;
|
|
102
|
+
}, W = (e) => {
|
|
103
|
+
if (e === null || typeof e != "object") return "an entry must be an object";
|
|
104
|
+
const { name: t, path: n, type: r, mimeType: s, children: o, lazy: a } = 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" : K(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: t } = e;
|
|
109
|
+
return t === void 0 || t.every(O);
|
|
110
|
+
}, J = (e) => {
|
|
111
|
+
if (e === null || typeof e != "object") return !1;
|
|
112
|
+
const { status: t, entries: n, failure: r } = e;
|
|
113
|
+
return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && f(r) === null;
|
|
114
|
+
}, Ae = (e) => {
|
|
115
|
+
if (e === null || typeof e != "object") return !1;
|
|
116
|
+
const { status: t, ancestors: n, failure: r } = e;
|
|
117
|
+
return t === "ok" ? n === null || x(n) : t === "error" && f(r) === null;
|
|
118
|
+
}, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, _e = (e) => {
|
|
119
|
+
if (e === null || typeof e != "object") return !1;
|
|
120
|
+
const { status: t, source: n, ancestors: r, failure: s } = e;
|
|
121
|
+
return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && f(s) === null;
|
|
122
|
+
}, be = (e) => {
|
|
123
|
+
if (e === null || typeof e != "object") return !1;
|
|
124
|
+
const { status: t, loadedAt: n } = e;
|
|
125
|
+
return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : J(e);
|
|
126
|
+
}, T = (e) => {
|
|
127
|
+
if (e === null || typeof e != "object") return "a heading must be an object";
|
|
128
|
+
const { text: t, depth: n, id: r } = e;
|
|
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
|
+
}, q = (e) => {
|
|
131
|
+
if (e === null || typeof e != "object") return "a document must be an object";
|
|
132
|
+
const t = e, { kind: n } = t;
|
|
133
|
+
if (!Y(n)) return `unknown document kind ${i(n)}`;
|
|
134
|
+
if (n === "failure") return f(t.failure);
|
|
135
|
+
if (typeof t.name != "string") return "a document needs a name string";
|
|
136
|
+
switch (n) {
|
|
137
|
+
case "markdown": {
|
|
138
|
+
const { htmlContent: r, headings: s } = t;
|
|
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(t.edit);
|
|
145
|
+
}
|
|
146
|
+
case "text":
|
|
147
|
+
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";
|
|
148
|
+
case "image":
|
|
149
|
+
return c(t.url) ? null : "an image document needs a root-relative url";
|
|
150
|
+
case "media":
|
|
151
|
+
return c(t.url) ? G(t.mediaType) ? null : `unknown media type ${i(t.mediaType)}` : "a media document needs a root-relative url";
|
|
152
|
+
case "file":
|
|
153
|
+
return c(t.url) ? null : "a file document needs a root-relative url";
|
|
154
|
+
}
|
|
155
|
+
}, B = (e) => q(e) === null, Oe = (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: t, href: n } = e;
|
|
159
|
+
return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t !== "external" ? `unknown edit kind ${i(t)}` : Z(n) ? null : `an external edit needs an absolute https: href; got ${i(n)}`;
|
|
160
|
+
}, Z = (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 <= _, ee = (e) => c(e.href) ? null : `a grant needs a root-relative href; got ${i(e.href)}`, te = (e) => {
|
|
168
|
+
if (e === null || typeof e != "object") return "a revision must be an object";
|
|
169
|
+
const { id: t, modifiedAt: n, size: r, author: s, kept: o, current: a } = e;
|
|
170
|
+
return l(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${i(n)}` : 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 ${_} characters; got ${i(t)}`;
|
|
171
|
+
}, d = (e, t) => {
|
|
172
|
+
if (e === null || typeof e != "object") return "an answer must be an object";
|
|
173
|
+
const n = e, { kind: r } = n;
|
|
174
|
+
if (r === "failure") return f(n.failure);
|
|
175
|
+
if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${i(r)}`;
|
|
176
|
+
switch (r) {
|
|
177
|
+
case "grant":
|
|
178
|
+
return ee(n);
|
|
179
|
+
case "edit":
|
|
180
|
+
return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : l(n.version) ? null : `an edit source needs a version; got ${i(n.version)}`;
|
|
181
|
+
case "saved":
|
|
182
|
+
return l(n.version) ? null : `a saved answer needs a version; got ${i(n.version)}`;
|
|
183
|
+
case "conflict":
|
|
184
|
+
return typeof n.text != "string" ? "a conflict needs the current text" : l(n.version) ? null : `a conflict needs the current version; got ${i(n.version)}`;
|
|
185
|
+
case "preview": {
|
|
186
|
+
const { htmlContent: s, headings: o } = n;
|
|
187
|
+
if (typeof s != "string" || !Array.isArray(o)) return "a preview needs htmlContent and headings";
|
|
188
|
+
for (const a of o) {
|
|
189
|
+
const y = T(a);
|
|
190
|
+
if (y !== null) return y;
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
case "revisions": {
|
|
195
|
+
if (!Array.isArray(n.revisions)) return "revisions need an array";
|
|
196
|
+
for (const s of n.revisions) {
|
|
197
|
+
const o = te(s);
|
|
198
|
+
if (o !== null) return o;
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
case "revision":
|
|
203
|
+
return typeof n.text != "string" ? "a revision answer needs text" : l(n.id) ? null : `a revision answer needs an id; got ${i(n.id)}`;
|
|
204
|
+
default:
|
|
205
|
+
return `unexpected answer kind ${i(r)}`;
|
|
206
|
+
}
|
|
207
|
+
}, ne = Object.freeze(["edit", "grant"]), re = Object.freeze(["saved", "conflict", "grant"]), se = Object.freeze(["preview"]), oe = Object.freeze(["revisions"]), ie = Object.freeze(["revision"]), 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) => d(e, ie) === null, we = (e, t) => ({ kind: "failure", failure: ae(e, t) }), ae = (e, t) => b(t) ? { reason: e, code: t } : { reason: e }, ce = 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" }), le = "asset", ue = "link-card", Pe = (e, t, n) => {
|
|
208
|
+
const r = `${e}/${le}?${p.path}=${encodeURIComponent(t)}`;
|
|
209
|
+
return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
|
|
210
|
+
}, S = "text", Le = (e) => {
|
|
211
|
+
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
|
|
212
|
+
return `${e}&${p.display}=${S}`;
|
|
213
|
+
}, De = (e) => {
|
|
214
|
+
const t = e.getAll(p.display);
|
|
215
|
+
return t.length === 0 ? "file" : t.length === 1 && t[0] === S ? "text" : null;
|
|
216
|
+
}, ke = (e) => `${e}/${ue}`, je = "X-Markdown-Explorer-Scope", $e = "X-Markdown-Explorer", Ie = "refresh", Ce = "edit", ze = "text/markdown", Ue = (e) => ce.includes(e), fe = Object.freeze({
|
|
217
|
+
invalid: 400,
|
|
218
|
+
unauthorized: 401,
|
|
219
|
+
forbidden: 403,
|
|
220
|
+
"not-found": 404,
|
|
221
|
+
"too-large": 413,
|
|
222
|
+
"not-configured": 500,
|
|
223
|
+
unsupported: 500,
|
|
224
|
+
failed: 500
|
|
225
|
+
}), Xe = (e) => {
|
|
226
|
+
const [t, ...n] = A.filter((r) => fe[r] === e);
|
|
227
|
+
return t !== void 0 && n.length === 0 ? t : "failed";
|
|
228
|
+
};
|
|
229
|
+
export {
|
|
230
|
+
ze as A,
|
|
231
|
+
ye as B,
|
|
232
|
+
pe as C,
|
|
233
|
+
N as D,
|
|
234
|
+
me as E,
|
|
235
|
+
Le as F,
|
|
236
|
+
Xe as G,
|
|
237
|
+
Oe as H,
|
|
238
|
+
_e as I,
|
|
239
|
+
Ae as J,
|
|
240
|
+
J as K,
|
|
241
|
+
f as L,
|
|
242
|
+
de as M,
|
|
243
|
+
be as N,
|
|
244
|
+
ve as O,
|
|
245
|
+
Ne as P,
|
|
246
|
+
Se as Q,
|
|
247
|
+
Te as R,
|
|
248
|
+
xe as S,
|
|
249
|
+
B as T,
|
|
250
|
+
_ as U,
|
|
251
|
+
A as V,
|
|
252
|
+
ke as a,
|
|
253
|
+
M as b,
|
|
254
|
+
b as c,
|
|
255
|
+
Re as d,
|
|
256
|
+
Pe as e,
|
|
257
|
+
ae as f,
|
|
258
|
+
he as g,
|
|
259
|
+
G as h,
|
|
260
|
+
R as i,
|
|
261
|
+
q as j,
|
|
262
|
+
l as k,
|
|
263
|
+
T as l,
|
|
264
|
+
c as m,
|
|
265
|
+
W as n,
|
|
266
|
+
ge as o,
|
|
267
|
+
Ee as p,
|
|
268
|
+
Ue as q,
|
|
269
|
+
te as r,
|
|
270
|
+
fe as s,
|
|
271
|
+
$e as t,
|
|
272
|
+
Ie as u,
|
|
273
|
+
Ce as v,
|
|
274
|
+
je as w,
|
|
275
|
+
p as x,
|
|
276
|
+
we as y,
|
|
277
|
+
De as z
|
|
278
|
+
};
|