@aiquants/markdown-explorer 0.35.0 → 0.36.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 (81) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +31 -2
  3. package/dist/{EditSurface-CLG70Vnn.cjs → EditSurface-B70iRFkG.cjs} +1 -1
  4. package/dist/{EditSurface-D2j1kCEE.js → EditSurface-BCFJRyIM.js} +5 -5
  5. package/dist/{ExplorerSplit-D_0VohOv.cjs → ExplorerSplit-BNrHrIus.cjs} +1 -1
  6. package/dist/{ExplorerSplit-CfP1smbT.js → ExplorerSplit-Bgccz2nm.js} +77 -77
  7. package/dist/{MultiLayout-CxV5SI7f.cjs → MultiLayout-Bo9LAXiY.cjs} +1 -1
  8. package/dist/{MultiLayout-BeJ5Lubb.js → MultiLayout-Dy5TIC2t.js} +4 -4
  9. package/dist/{NativeScrollBar-RWXpVhbI.cjs → NativeScrollBar-Bj-LKej0.cjs} +1 -1
  10. package/dist/{NativeScrollBar-BM5NULzg.js → NativeScrollBar-DpZMYhmf.js} +2 -2
  11. package/dist/TreeLayout-DsSKW_Qj.js +103 -0
  12. package/dist/TreeLayout-T8sc_wg7.cjs +1 -0
  13. package/dist/core/config.d.cts +6 -0
  14. package/dist/core/config.d.ts +6 -0
  15. package/dist/core/contracts.d.cts +21 -0
  16. package/dist/core/contracts.d.ts +21 -0
  17. package/dist/core/dataRoute.d.cts +5 -1
  18. package/dist/core/dataRoute.d.ts +5 -1
  19. package/dist/core/documentId.d.cts +6 -0
  20. package/dist/core/documentId.d.ts +6 -0
  21. package/dist/core/labels.d.cts +10 -0
  22. package/dist/core/labels.d.ts +10 -0
  23. package/dist/core/location.d.cts +21 -0
  24. package/dist/core/location.d.ts +21 -0
  25. package/dist/explorerCore-B3RGmMG6.js +1083 -0
  26. package/dist/explorerCore-CUkyKtm8.cjs +1 -0
  27. package/dist/{index-C1YMH-yI.js → index-D0l_BJqb.js} +2536 -2372
  28. package/dist/index-lpL7GltU.cjs +18 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +2 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +38 -33
  33. package/dist/location-Dh6K-y7w.js +761 -0
  34. package/dist/location-DrOP6t1F.cjs +1 -0
  35. package/dist/{merge-Bb_HpPhe.js → merge-BwcqBd4c.js} +1 -1
  36. package/dist/{merge-DQUYEGCx.cjs → merge-Dckw7r9T.cjs} +1 -1
  37. package/dist/ownUrls-BTPGNhBt.cjs +1 -0
  38. package/dist/ownUrls-DD0cSCsF.js +409 -0
  39. package/dist/{sanitizeJob-BYRk17nr.js → sanitizeJob-BYqzjFJC.js} +1 -1
  40. package/dist/{sanitizeJob-Cs9o3Vpl.cjs → sanitizeJob-CudE1RUP.cjs} +1 -1
  41. package/dist/{sanitizePolicy-CiQfnxyd.cjs → sanitizePolicy-C-ehd0J_.cjs} +1 -1
  42. package/dist/{sanitizePolicy-CEMdaLUB.js → sanitizePolicy-DAPnUUVm.js} +1 -1
  43. package/dist/sanitizeWorker.cjs +1 -1
  44. package/dist/sanitizeWorker.js +3 -3
  45. package/dist/{sanitizerService-KWXv7bPm.js → sanitizerService-B8v4ap9t.js} +1 -1
  46. package/dist/{sanitizerService-BY4CPCoA.cjs → sanitizerService-DomN7lwC.cjs} +1 -1
  47. package/dist/server/errors.d.cts +1 -1
  48. package/dist/server/errors.d.ts +1 -1
  49. package/dist/server/ports.d.cts +19 -0
  50. package/dist/server/ports.d.ts +19 -0
  51. package/dist/server.cjs +1 -1
  52. package/dist/server.d.cts +1 -1
  53. package/dist/server.d.ts +1 -1
  54. package/dist/server.js +6 -6
  55. package/dist/serverBrowser.cjs +1 -1
  56. package/dist/serverBrowser.js +3 -3
  57. package/dist/serverCore.cjs +1 -1
  58. package/dist/serverCore.d.cts +1 -1
  59. package/dist/serverCore.d.ts +1 -1
  60. package/dist/serverCore.js +4 -4
  61. package/dist/{tapScrollCircle-DdX0Wri0.cjs → tapScrollCircle-DyLInGck.cjs} +1 -1
  62. package/dist/{tapScrollCircle-BEydRn0y.js → tapScrollCircle-smKLgRa2.js} +1 -1
  63. package/dist/testing.cjs +1 -1
  64. package/dist/testing.d.cts +5 -0
  65. package/dist/testing.d.ts +5 -0
  66. package/dist/testing.js +80 -2
  67. package/dist/{useSplitPersistence-B2Fj508K.cjs → useSplitPersistence-BUa_KMsV.cjs} +1 -1
  68. package/dist/{useSplitPersistence-Fkqak8G8.js → useSplitPersistence-pnb21dsr.js} +1 -1
  69. package/docs/behavior/dom-hooks.md +3 -1
  70. package/docs/behavior/security.md +23 -2
  71. package/docs/behavior/url-contract.md +26 -0
  72. package/package.json +2 -2
  73. package/dist/TreeLayout-AxLw-36S.js +0 -103
  74. package/dist/TreeLayout-Bg2YH-EY.cjs +0 -1
  75. package/dist/explorerCore-DLpDuSev.js +0 -998
  76. package/dist/explorerCore-DYrxS9ez.cjs +0 -1
  77. package/dist/index-LQWQfpAf.cjs +0 -18
  78. package/dist/location--KvTA0Ri.js +0 -726
  79. package/dist/location-D8DyDkuA.cjs +0 -1
  80. package/dist/ownUrls-B259RGgd.cjs +0 -1
  81. package/dist/ownUrls-Dh5g6ZJi.js +0 -370
@@ -1 +1 @@
1
- "use strict";const W=require("node:worker_threads"),K=require("isomorphic-dompurify"),Y=require("./ownUrls-B259RGgd.cjs"),Z=require("./sanitizePolicy-CiQfnxyd.cjs"),T=require("parse5"),I=require("./describeValue-Ccvhbt36.cjs"),H=require("./sanitizeJob-Cs9o3Vpl.cjs"),ee=4096,B=1024,V=Symbol("placement"),F=2,te=3,re=new Set(["html","head","body"]),w=0,L=1,y=2,G=3,x=4,b=5,C=6,S=7,z=8,U=9,Q=10,A=-1,ne=0,oe=1,se=2,ae=3,ie=4,ce=5,J=6,le=7,ue=r=>{switch(r){case 9:case 10:case 12:case 13:case 32:return ne;case 47:return oe;case 62:return se;case 61:return ae;case 34:return ie;case 39:return ce;default:return J}},fe=Uint8Array.from({length:128},(r,c)=>ue(c)),M=60,q=47,de=/[\t\n\f\r />="'<]/g,Ee=/["<]/g,he=/['<]/g,u=-1-y,pe=Int8Array.from([[L,U,A,w,w,w,w],[L,U,A,u,u,u,u],[G,U,A,x,y,y,y],[G,U,A,x,u,u,u],[x,S,A,S,b,C,S],[b,b,b,b,z,b,b],[C,C,C,C,C,z,C],[L,S,A,S,S,S,S],[L,U,A,u,u,u,u],[L,U,A,u,u,u,u]].flat()),$=r=>r>=65&&r<=90||r>=97&&r<=122,Te=(r,c)=>{let i=new Int32Array(Q),f=new Int32Array(Q),a=0,E=0,o=0;for(;o<r.length;){if(a===0){const l=r.indexOf("<",o);if(l<0)return!1;o=l+1,r.charCodeAt(o)===q&&(o+=1),$(r.charCodeAt(o))&&(i[w]=0,a=1<<w,o+=1);continue}if((a&-230)===0&&o>=E){const l=a===1<<b?Ee:a===1<<C?he:de;l.lastIndex=o;const _=l.exec(r);if(_===null)return!1;o=_.index,r.charCodeAt(o)===M&&(E=o+3)}const g=r.charCodeAt(o),O=g<128?fe[g]:J;let p=0;for(let l=a;l!==0;l&=l-1){const _=31-Math.clz32(l&-l);let h=pe[_*le+O],d=i[_];if(h<A&&(h=-1-h,d+=1,d>c))return!0;if(h===A)continue;const v=1<<h;((p&v)===0||d>f[h])&&(f[h]=d),p|=v}$(g)&&(r.charCodeAt(o-1)===M||r.charCodeAt(o-1)===q&&r.charCodeAt(o-2)===M)&&(p&1<<w)===0&&(f[w]=0,p|=1<<w);const m=i;i=f,f=m,a=p,o+=1}return!1};class N extends Error{status;constructor(c){super(`[markdown-explorer] the nesting guard stopped the parse: ${c}`),this.name="ParseStop",this.status=c}}const Ae=(r,c,i,f)=>{if(!Number.isSafeInteger(c)||c<=0)throw new RangeError(`[markdown-explorer] the nesting guard's depth limit must be a positive safe integer; got ${I.describeValue(c)}`);if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`[markdown-explorer] the nesting guard's node budget must be a positive safe integer; got ${I.describeValue(i)}`);if(!Number.isSafeInteger(f)||f<=0)throw new RangeError(`[markdown-explorer] the nesting guard's attribute character budget must be a positive safe integer; got ${I.describeValue(f)}`);if(Te(r,B))return{status:"too-many-attributes"};const a=c+F,E=r.length+te;let o=null,g=0,O=0,p=0,m=0;const l=e=>{if(O+=e,O>i)throw new N("too-many-nodes")},_=e=>{for(const t of e)m+=t.name.length+t.value.length;if(m>f)throw new N("too-many-attribute-characters")},h=(e,t,n,s)=>{const P={node:e,above:null,levels:t,height:0,keepsChildren:n,attributes:s,first:null,next:null,previous:null},X=e;return X[V]=P,P},d=e=>{const n=e[V];if(n===void 0)throw new Error("[markdown-explorer] the nesting guard was handed a node it did not create");return n},v=(e,t)=>{let n=t;for(let s=e;s!==null&&n>s.height;s=s.above)s.height=n,n+=s.levels;if(o!==null&&o.height>a)throw new N("too-deep")},R=e=>{const t=e.above;t?.keepsChildren&&(e.previous===null?t.first=e.next:e.previous.next=e.next,e.next!==null&&(e.next.previous=e.previous)),e.above=null,e.next=null,e.previous=null},k=(e,t)=>{if(!T.defaultTreeAdapter.isElementNode(t))return;const n=d(t),s=d(e);R(n),n.above=s,s.keepsChildren&&(n.next=s.first,s.first!==null&&(s.first.previous=n),s.first=n),t.parentNode=e,v(s,n.height+n.levels)},j={...T.defaultTreeAdapter,createDocument:()=>{const e=T.defaultTreeAdapter.createDocument();return o=h(e,0,!1,0),e},createDocumentFragment:()=>{const e=T.defaultTreeAdapter.createDocumentFragment();return h(e,0,!1,0),e},createElement:(e,t,n)=>{if(g+=1,g>E)throw new N("too-many-elements");l(1+n.length),_(n);const s=T.defaultTreeAdapter.createElement(e,t,n);return h(s,1,!(t===T.html.NS.HTML&&re.has(e)),n.length),s},createCommentNode:e=>{if(p+=1,p>ee)throw new N("too-many-comments");return l(1),T.defaultTreeAdapter.createCommentNode(e)},setTemplateContent:(e,t)=>{T.defaultTreeAdapter.setTemplateContent(e,t);const n=d(t);n.above=d(e),v(n.above,n.height)},appendChild:k,insertBefore:(e,t)=>k(e,t),detachNode:e=>{T.defaultTreeAdapter.isElementNode(e)&&(R(d(e)),e.parentNode=null)},getFirstChild:e=>{const t=d(e);if(!t.keepsChildren)throw new Error("[markdown-explorer] the nesting guard was asked for the children of a node whose children it does not keep");return t.first===null?null:t.first.node},getChildNodes:()=>{throw new Error("[markdown-explorer] the nesting guard keeps no child lists for source locations")},onItemPop:e=>{const t=d(e);t.keepsChildren=!1,t.first=null},insertText:()=>{},insertTextBefore:()=>{},adoptAttributes:(e,t)=>{l(t.length),_(t);const n=d(e);if(n.attributes+=t.length,n.attributes>B)throw new N("too-many-attributes")}};let D;try{D=T.parse(r,{scriptingEnabled:!1,treeAdapter:j})}catch(e){if(e instanceof N)return{status:e.status};throw e}return{status:"within",depth:d(D).height-F,elements:g,nodes:O}},ge=r=>{if(r===null||typeof r!="object")return!1;const{id:c,input:i}=r;if(typeof c!="number"||i===null||typeof i!="object")return!1;const{html:f,iframeHosts:a,dataPath:E,ownUrls:o,maxNodes:g,maxAttributeChars:O,maxSanitizedChars:p}=i;return typeof f=="string"&&Array.isArray(a)&&a.every(m=>typeof m=="string")&&typeof E=="string"&&E!==""&&Y.isExplorerOwnUrls(o)&&[g,O,p].every(m=>Number.isSafeInteger(m)&&m>0)},me=()=>{const r=W.parentPort;if(r===null)throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");const c=H.createJobSanitizer(K);r.on("message",i=>{if(!ge(i))throw new TypeError("[markdown-explorer] the sanitizer worker received a message that is not a job");const{id:f,input:a}=i;let E;try{E=Ae(a.html,Z.MAX_HTML_NESTING_DEPTH,a.maxNodes,a.maxAttributeChars).status==="within"?c(a):{status:"too-large"}}catch(o){E=H.sanitizeJobFailureOf(o)}r.postMessage({id:f,output:E})}),r.postMessage({ready:!0})};me();
1
+ "use strict";const W=require("node:worker_threads"),K=require("isomorphic-dompurify"),Y=require("./ownUrls-BTPGNhBt.cjs"),Z=require("./sanitizePolicy-C-ehd0J_.cjs"),T=require("parse5"),I=require("./describeValue-Ccvhbt36.cjs"),H=require("./sanitizeJob-CudE1RUP.cjs"),ee=4096,B=1024,V=Symbol("placement"),F=2,te=3,re=new Set(["html","head","body"]),w=0,L=1,y=2,G=3,x=4,b=5,C=6,S=7,z=8,U=9,Q=10,A=-1,ne=0,oe=1,se=2,ae=3,ie=4,ce=5,J=6,le=7,ue=r=>{switch(r){case 9:case 10:case 12:case 13:case 32:return ne;case 47:return oe;case 62:return se;case 61:return ae;case 34:return ie;case 39:return ce;default:return J}},fe=Uint8Array.from({length:128},(r,c)=>ue(c)),M=60,q=47,de=/[\t\n\f\r />="'<]/g,Ee=/["<]/g,he=/['<]/g,u=-1-y,pe=Int8Array.from([[L,U,A,w,w,w,w],[L,U,A,u,u,u,u],[G,U,A,x,y,y,y],[G,U,A,x,u,u,u],[x,S,A,S,b,C,S],[b,b,b,b,z,b,b],[C,C,C,C,C,z,C],[L,S,A,S,S,S,S],[L,U,A,u,u,u,u],[L,U,A,u,u,u,u]].flat()),$=r=>r>=65&&r<=90||r>=97&&r<=122,Te=(r,c)=>{let i=new Int32Array(Q),f=new Int32Array(Q),a=0,E=0,o=0;for(;o<r.length;){if(a===0){const l=r.indexOf("<",o);if(l<0)return!1;o=l+1,r.charCodeAt(o)===q&&(o+=1),$(r.charCodeAt(o))&&(i[w]=0,a=1<<w,o+=1);continue}if((a&-230)===0&&o>=E){const l=a===1<<b?Ee:a===1<<C?he:de;l.lastIndex=o;const _=l.exec(r);if(_===null)return!1;o=_.index,r.charCodeAt(o)===M&&(E=o+3)}const g=r.charCodeAt(o),O=g<128?fe[g]:J;let p=0;for(let l=a;l!==0;l&=l-1){const _=31-Math.clz32(l&-l);let h=pe[_*le+O],d=i[_];if(h<A&&(h=-1-h,d+=1,d>c))return!0;if(h===A)continue;const v=1<<h;((p&v)===0||d>f[h])&&(f[h]=d),p|=v}$(g)&&(r.charCodeAt(o-1)===M||r.charCodeAt(o-1)===q&&r.charCodeAt(o-2)===M)&&(p&1<<w)===0&&(f[w]=0,p|=1<<w);const m=i;i=f,f=m,a=p,o+=1}return!1};class N extends Error{status;constructor(c){super(`[markdown-explorer] the nesting guard stopped the parse: ${c}`),this.name="ParseStop",this.status=c}}const Ae=(r,c,i,f)=>{if(!Number.isSafeInteger(c)||c<=0)throw new RangeError(`[markdown-explorer] the nesting guard's depth limit must be a positive safe integer; got ${I.describeValue(c)}`);if(!Number.isSafeInteger(i)||i<=0)throw new RangeError(`[markdown-explorer] the nesting guard's node budget must be a positive safe integer; got ${I.describeValue(i)}`);if(!Number.isSafeInteger(f)||f<=0)throw new RangeError(`[markdown-explorer] the nesting guard's attribute character budget must be a positive safe integer; got ${I.describeValue(f)}`);if(Te(r,B))return{status:"too-many-attributes"};const a=c+F,E=r.length+te;let o=null,g=0,O=0,p=0,m=0;const l=e=>{if(O+=e,O>i)throw new N("too-many-nodes")},_=e=>{for(const t of e)m+=t.name.length+t.value.length;if(m>f)throw new N("too-many-attribute-characters")},h=(e,t,n,s)=>{const P={node:e,above:null,levels:t,height:0,keepsChildren:n,attributes:s,first:null,next:null,previous:null},X=e;return X[V]=P,P},d=e=>{const n=e[V];if(n===void 0)throw new Error("[markdown-explorer] the nesting guard was handed a node it did not create");return n},v=(e,t)=>{let n=t;for(let s=e;s!==null&&n>s.height;s=s.above)s.height=n,n+=s.levels;if(o!==null&&o.height>a)throw new N("too-deep")},R=e=>{const t=e.above;t?.keepsChildren&&(e.previous===null?t.first=e.next:e.previous.next=e.next,e.next!==null&&(e.next.previous=e.previous)),e.above=null,e.next=null,e.previous=null},k=(e,t)=>{if(!T.defaultTreeAdapter.isElementNode(t))return;const n=d(t),s=d(e);R(n),n.above=s,s.keepsChildren&&(n.next=s.first,s.first!==null&&(s.first.previous=n),s.first=n),t.parentNode=e,v(s,n.height+n.levels)},j={...T.defaultTreeAdapter,createDocument:()=>{const e=T.defaultTreeAdapter.createDocument();return o=h(e,0,!1,0),e},createDocumentFragment:()=>{const e=T.defaultTreeAdapter.createDocumentFragment();return h(e,0,!1,0),e},createElement:(e,t,n)=>{if(g+=1,g>E)throw new N("too-many-elements");l(1+n.length),_(n);const s=T.defaultTreeAdapter.createElement(e,t,n);return h(s,1,!(t===T.html.NS.HTML&&re.has(e)),n.length),s},createCommentNode:e=>{if(p+=1,p>ee)throw new N("too-many-comments");return l(1),T.defaultTreeAdapter.createCommentNode(e)},setTemplateContent:(e,t)=>{T.defaultTreeAdapter.setTemplateContent(e,t);const n=d(t);n.above=d(e),v(n.above,n.height)},appendChild:k,insertBefore:(e,t)=>k(e,t),detachNode:e=>{T.defaultTreeAdapter.isElementNode(e)&&(R(d(e)),e.parentNode=null)},getFirstChild:e=>{const t=d(e);if(!t.keepsChildren)throw new Error("[markdown-explorer] the nesting guard was asked for the children of a node whose children it does not keep");return t.first===null?null:t.first.node},getChildNodes:()=>{throw new Error("[markdown-explorer] the nesting guard keeps no child lists for source locations")},onItemPop:e=>{const t=d(e);t.keepsChildren=!1,t.first=null},insertText:()=>{},insertTextBefore:()=>{},adoptAttributes:(e,t)=>{l(t.length),_(t);const n=d(e);if(n.attributes+=t.length,n.attributes>B)throw new N("too-many-attributes")}};let D;try{D=T.parse(r,{scriptingEnabled:!1,treeAdapter:j})}catch(e){if(e instanceof N)return{status:e.status};throw e}return{status:"within",depth:d(D).height-F,elements:g,nodes:O}},ge=r=>{if(r===null||typeof r!="object")return!1;const{id:c,input:i}=r;if(typeof c!="number"||i===null||typeof i!="object")return!1;const{html:f,iframeHosts:a,dataPath:E,ownUrls:o,maxNodes:g,maxAttributeChars:O,maxSanitizedChars:p}=i;return typeof f=="string"&&Array.isArray(a)&&a.every(m=>typeof m=="string")&&typeof E=="string"&&E!==""&&Y.isExplorerOwnUrls(o)&&[g,O,p].every(m=>Number.isSafeInteger(m)&&m>0)},me=()=>{const r=W.parentPort;if(r===null)throw new Error("[markdown-explorer] the sanitizer worker must run in a worker thread");const c=H.createJobSanitizer(K);r.on("message",i=>{if(!ge(i))throw new TypeError("[markdown-explorer] the sanitizer worker received a message that is not a job");const{id:f,input:a}=i;let E;try{E=Ae(a.html,Z.MAX_HTML_NESTING_DEPTH,a.maxNodes,a.maxAttributeChars).status==="within"?c(a):{status:"too-large"}}catch(o){E=H.sanitizeJobFailureOf(o)}r.postMessage({id:f,output:E})}),r.postMessage({ready:!0})};me();
@@ -1,10 +1,10 @@
1
1
  import { parentPort as $ } from "node:worker_threads";
2
2
  import q from "isomorphic-dompurify";
3
- import { d as K } from "./ownUrls-Dh5g6ZJi.js";
4
- import { M as Y } from "./sanitizePolicy-CEMdaLUB.js";
3
+ import { d as K } from "./ownUrls-DD0cSCsF.js";
4
+ import { M as Y } from "./sanitizePolicy-DAPnUUVm.js";
5
5
  import { defaultTreeAdapter as S, parse as Z, html as ee } from "parse5";
6
6
  import { d as I } from "./describeValue-CLlVRO8d.js";
7
- import { s as te, c as re } from "./sanitizeJob-BYRk17nr.js";
7
+ import { s as te, c as re } from "./sanitizeJob-BYqzjFJC.js";
8
8
  const ne = 4096, H = 1024, B = /* @__PURE__ */ Symbol("placement"), F = 2, oe = 3, se = /* @__PURE__ */ new Set(["html", "head", "body"]), A = 0, U = 1, y = 2, G = 3, M = 4, C = 5, b = 6, _ = 7, Q = 8, v = 9, V = 10, T = -1, ae = 0, ie = 1, ce = 2, le = 3, ue = 4, fe = 5, j = 6, Ee = 7, he = (r) => {
9
9
  switch (r) {
10
10
  case 9:
@@ -1,6 +1,6 @@
1
1
  import { i as Y, d as M } from "./describeValue-CLlVRO8d.js";
2
2
  import { M as J, c as G } from "./lru-DC8GBmkX.js";
3
- import { r as U } from "./ownUrls-Dh5g6ZJi.js";
3
+ import { r as U } from "./ownUrls-DD0cSCsF.js";
4
4
  const Z = (r) => Math.max(1, r - 1), B = 1024 * 1024, X = 3e4, V = 4 * B, W = 64 * B, q = 2 ** 29, K = 3, ee = (r, o) => r + Z(o) + K, te = 4, v = 512, re = 64, oe = 4096, ne = 32, D = 4096, se = (r, o) => Math.floor(((o - re) * B - r * ne) / oe), k = (r, o, d, u) => {
5
5
  if (o === void 0) return d;
6
6
  if (typeof o != "number") throw new TypeError(`[markdown-explorer] sanitizer.${r} must be a number; got ${M(o)}`);
@@ -1 +1 @@
1
- "use strict";const M=require("./describeValue-Ccvhbt36.cjs"),D=require("./lru-SGmUyBQU.cjs"),te=require("./ownUrls-B259RGgd.cjs"),Z=r=>Math.max(1,r-1),v=1024*1024,J=3e4,Y=4*v,X=64*v,Q=2**29,re=3,G=(r,o)=>r+Z(o)+re,V=4,z=512,oe=64,ne=4096,se=32,O=4096,q=(r,o)=>Math.floor(((o-oe)*v-r*se)/ne),R=(r,o,d,u)=>{if(o===void 0)return d;if(typeof o!="number")throw new TypeError(`[markdown-explorer] sanitizer.${r} must be a number; got ${M.describeValue(o)}`);if(!Number.isSafeInteger(o)||o<=0||o>u)throw new RangeError(`[markdown-explorer] sanitizer.${r} must be an integer in 1..${String(u)}; got ${M.describeValue(o)}`);return o},W=(r,o)=>{if(r.jobsPerScope<o)throw new RangeError(`[markdown-explorer] sanitizer.jobsPerScope must be at least multiView.maxPanels (${String(o)}), because a page sends the document of every panel to the sanitizer at once for one reader; got ${M.describeValue(r.jobsPerScope)}`);if(r.maxQueuedJobs<o)throw new RangeError(`[markdown-explorer] sanitizer.maxQueuedJobs must be at least multiView.maxPanels (${String(o)}), because a reader whose page finds every worker busy waits with the document of every panel; got ${M.describeValue(r.maxQueuedJobs)}`)},ae=Object.freeze(["workers","workerHeapMb"]),ie=(r,o)=>{if(r!==void 0&&!M.isPlainObject(r))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }");const d=r??{};for(const p of ae)if(d[p]!==void 0)throw new TypeError(`[markdown-explorer] sanitizer.${p} is an option of Node's worker threads; a browser runtime takes only { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }`);const{deadlineMs:u,maxHtmlBytes:S,cacheBytes:f,jobsPerScope:E,maxQueuedJobs:g}=d,l=R("jobsPerScope",E,G(o,1),Number.MAX_SAFE_INTEGER),_=Object.freeze({deadlineMs:R("deadlineMs",u,J,D.MAX_TIMER_MILLISECONDS),maxHtmlBytes:R("maxHtmlBytes",S,Y,Q),cacheBytes:R("cacheBytes",f,X,Number.MAX_SAFE_INTEGER),jobsPerScope:l,maxQueuedJobs:R("maxQueuedJobs",g,V*l,Number.MAX_SAFE_INTEGER)});if(W(_,o),q(_.maxHtmlBytes,z)<O)throw new RangeError(`[markdown-explorer] sanitizer.maxHtmlBytes (${String(_.maxHtmlBytes)} bytes) must leave room for ${String(O)} parsed nodes in the node budget, which a browser runtime counts in a worker heap of ${String(z)} MiB; lower maxHtmlBytes`);return _},U=Object.freeze({status:"aborted"}),I=(r,o,d)=>{const u=(r.get(o)??0)+d;u===0?r.delete(o):r.set(o,u)},L=(r,o,d)=>{if(!Number.isSafeInteger(o)||o<=0||o>d)throw new RangeError(`[markdown-explorer] a worker pool's ${r} must be an integer in 1..${String(d)}; got ${M.describeValue(o)}`)},ue=r=>r!==null&&typeof r=="object"&&r.ready===!0&&!("id"in r),K=(r,o)=>r!==null&&typeof r=="object"&&r.id===o&&"output"in r,ce=({start:r,size:o,deadlineMs:d,jobsPerScope:u,maxQueuedJobs:S})=>{L("size",o,Number.MAX_SAFE_INTEGER),L("deadline",d,D.MAX_TIMER_MILLISECONDS),L("jobsPerScope",u,Number.MAX_SAFE_INTEGER),L("maxQueuedJobs",S,Number.MAX_SAFE_INTEGER);const f=new Set,E=[],g=new Map,l=new Map,_=Z(o);let p=0;const h=(e,t)=>{const{job:n}=e;e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.job=null,e.sent=!1,n!==null&&(I(g,n.scope,-1),I(l,n.scope,-1),n.settle(t))},T=e=>{const[t]=E.splice(e,1);t?.detach()},N=()=>{let e=-1,t=_,n=Number.POSITIVE_INFINITY;for(const[s,a]of E.entries()){const i=g.get(a.scope)??0,c=l.get(a.scope)??0;(i<t||i===t&&e>=0&&c<n)&&(e=s,t=i,n=c)}return e},w=(e,t)=>{f.has(e)&&(f.delete(e),h(e,t),e.worker.terminate().catch(()=>{}),A())},x=e=>{e.timer=setTimeout(()=>{w(e,{status:"timeout"})},d)},y=(e,t)=>e.sent?{status:"crashed",error:t}:{status:"unavailable",error:t},H=(e,t)=>{e.sent=!0,x(e);try{e.worker.postMessage({id:t.id,input:t.input})}catch(n){h(e,{status:"crashed",error:n}),e.worker.unref()}},B=()=>{const e={worker:r(),job:null,sent:!1,timer:null,ready:!1};return e.worker.unref(),e.timer=setTimeout(()=>{w(e,{status:"unavailable",error:new Error(`[markdown-explorer] a worker did not start within ${String(d)} ms`)})},d),e.worker.listen({message:t=>{if(!e.ready&&ue(t)){e.ready=!0,e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.job===null?e.worker.unref():H(e,e.job),e.job===null&&A();return}const{job:n}=e;if(n===null||!K(t,n.id)){w(e,y(e,new Error("[markdown-explorer] a worker sent a message that answers no job")));return}h(e,{status:"done",output:t.output}),e.worker.unref(),A()},failure:t=>{w(e,y(e,t))}}),f.add(e),e},A=()=>{for(;;){const e=N(),t=E[e];if(t===void 0)return;let n;for(const a of f)if(a.job===null){n=a;break}if(n===void 0&&f.size<o)try{n=B()}catch(a){T(e),I(l,t.scope,-1),t.settle({status:"unavailable",error:a});continue}if(n===void 0)return;T(e),I(g,t.scope,1);const s=n;s.job=t,s.worker.ref(),s.ready&&H(s,t)}};return{run:(e,{scope:t,signal:n})=>new Promise(s=>{if(n.aborted){s(U);return}if((l.get(t)??0)>=u){s({status:"refused",limit:"scope"});return}p+=1;const a={id:p,input:e,scope:t,settle:s,detach:()=>{}};E.push(a),I(l,t,1),A();const i=E.indexOf(a);if(i<0)return;if(E.length>S){T(i),I(l,t,-1),s({status:"refused",limit:"queue"});return}const c=()=>{const m=E.indexOf(a);m<0||(T(m),I(l,t,-1),s(U))};n.addEventListener("abort",c,{once:!0}),a.detach=()=>{n.removeEventListener("abort",c)}}),workers:()=>f.size}},de=4,le=({maxHtmlBytes:r})=>r,me=({maxHtmlBytes:r})=>de*r,Ee=1024,fe=64,j=Object.freeze({status:"rejected",reason:"too-large",cause:null}),k=Object.freeze({status:"rejected",reason:"failed",cause:null}),we=r=>{if(r===null||typeof r!="object")return!1;const{status:o,html:d,message:u}=r;return o==="sanitized"&&typeof d=="string"||o==="too-large"||o==="error"&&typeof u=="string"},F=r=>({status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer could not measure a document",{cause:r})}),be=({iframeHosts:r,dataPath:o,ownUrls:d,limits:u,nodeBudget:S,measureHtml:f,classifyCrash:E,pool:g})=>{if(!Number.isSafeInteger(S)||S<=0)throw new RangeError(`[markdown-explorer] the HTML sanitizer's node budget must be a positive integer; got ${M.describeValue(S)}`);const l=Object.freeze([...r]),_=te.readOwnUrls(d),p=le(u),h=me(u),T=D.createLruCache(Ee,{max:u.cacheBytes,of:(e,t)=>2*e.length+(t.status==="sanitized"?2*t.html.length:fe)}),N=new Map,w=new Map,x=e=>{N.get(e.key)===e&&N.delete(e.key);const t=w.get(e.hash);t?.delete(e),t?.size===0&&w.delete(e.hash)},y=async(e,t,n)=>{const s=await g.run({html:e,iframeHosts:l,dataPath:o,ownUrls:_,maxNodes:S,maxAttributeChars:p,maxSanitizedChars:h},{scope:t,signal:n});if(s.status==="refused"){const i=s.limit==="scope"?`its reader already has ${String(u.jobsPerScope)} documents being sanitized or waiting`:`${String(u.maxQueuedJobs)} documents are already waiting`;return{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer refused a document: ${i}`)},lasting:!1}}if(s.status==="aborted")return{outcome:k,lasting:!1};if(s.status==="timeout")return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer did not finish within ${String(u.deadlineMs)} ms`)},lasting:!0};if(s.status==="unavailable")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker could not start",{cause:s.error})},lasting:!1};if(s.status==="crashed"){const i=E(s.error);return i!==null?{outcome:{status:"rejected",reason:i.reason,cause:new Error(i.message,{cause:s.error})},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker failed",{cause:s.error})},lasting:!0}}const{output:a}=s;return we(a)?a.status==="too-large"?{outcome:j,lasting:!0}:a.status==="error"?{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer failed: ${a.message}`)},lasting:!0}:a.html.length>h?{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer's output of ${String(a.html.length)} characters exceeds its limit of ${String(h)}`)},lasting:!0}:{outcome:{status:"sanitized",html:a.html},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker answered something that is not an outcome")},lasting:!0}},H=(e,t,n,s)=>{let a=()=>{};const i=new Promise(b=>{a=b}),c={hash:t,key:n,outcome:i,answer:a,controller:new AbortController,waiters:0};N.set(n,c);const m=w.get(t);return m===void 0?w.set(t,new Set([c])):m.add(c),y(e,s,c.controller.signal).catch(b=>({outcome:{status:"rejected",reason:"failed",cause:b instanceof Error?b:new Error(String(b))},lasting:!0})).then(({outcome:b,lasting:ee})=>{if(x(c),c.answer(b),!ee)return;const $=T.get(t),C=$??(b.status==="rejected"?{...b,cause:null}:b);$===void 0&&T.set(t,C);for(const P of w.get(t)??[])x(P),P.answer(C),P.controller.abort()}),c},B=(e,t)=>new Promise(n=>{e.waiters+=1;const s=()=>{e.waiters-=1,n(k),!(e.waiters>0)&&(x(e),e.controller.abort())};t.addEventListener("abort",s,{once:!0}),e.outcome.then(a=>{t.removeEventListener("abort",s),n(a)})}),A=(e,{utf8Bytes:t,hash:n},s,a)=>{if(t>u.maxHtmlBytes)return Promise.resolve(j);const i=T.get(n);if(i!==void 0)return Promise.resolve(i);if(a.aborted)return Promise.resolve(k);const c=`${n}\0${s}`,m=N.get(c);return B(m===void 0?H(e,n,c,s):m,a)};return(e,{scope:t,signal:n})=>{if(e.length>u.maxHtmlBytes)return Promise.resolve(j);let s;try{s=f(e)}catch(i){return Promise.resolve(F(i))}if(!(s instanceof Promise))return A(e,s,t,n);const a=s;return new Promise(i=>{const c=()=>i(k);n.addEventListener("abort",c,{once:!0}),a.then(m=>{n.removeEventListener("abort",c),i(A(e,m,t,n))},m=>{n.removeEventListener("abort",c),i(F(m))})})}};exports.DEFAULT_SANITIZER_CACHE_BYTES=X;exports.DEFAULT_SANITIZER_DEADLINE_MS=J;exports.DEFAULT_SANITIZER_MAX_HTML_BYTES=Y;exports.DEFAULT_SANITIZER_WORKER_HEAP_MB=z;exports.MAX_HTML_BYTES=Q;exports.MIN_HTML_NODE_BUDGET=O;exports.SANITIZER_QUEUED_READERS=V;exports.assertAdmissionCoversPanels=W;exports.assertPoolLimit=L;exports.createHtmlSanitizerService=be;exports.createWorkerPoolCore=ce;exports.defaultSanitizerJobsPerScope=G;exports.htmlNodeBudgetOf=q;exports.isReplyTo=K;exports.readLimit=R;exports.resolveBrowserSanitizerLimits=ie;
1
+ "use strict";const M=require("./describeValue-Ccvhbt36.cjs"),D=require("./lru-SGmUyBQU.cjs"),te=require("./ownUrls-BTPGNhBt.cjs"),Z=r=>Math.max(1,r-1),v=1024*1024,J=3e4,Y=4*v,X=64*v,Q=2**29,re=3,G=(r,o)=>r+Z(o)+re,V=4,z=512,oe=64,ne=4096,se=32,O=4096,q=(r,o)=>Math.floor(((o-oe)*v-r*se)/ne),R=(r,o,d,u)=>{if(o===void 0)return d;if(typeof o!="number")throw new TypeError(`[markdown-explorer] sanitizer.${r} must be a number; got ${M.describeValue(o)}`);if(!Number.isSafeInteger(o)||o<=0||o>u)throw new RangeError(`[markdown-explorer] sanitizer.${r} must be an integer in 1..${String(u)}; got ${M.describeValue(o)}`);return o},W=(r,o)=>{if(r.jobsPerScope<o)throw new RangeError(`[markdown-explorer] sanitizer.jobsPerScope must be at least multiView.maxPanels (${String(o)}), because a page sends the document of every panel to the sanitizer at once for one reader; got ${M.describeValue(r.jobsPerScope)}`);if(r.maxQueuedJobs<o)throw new RangeError(`[markdown-explorer] sanitizer.maxQueuedJobs must be at least multiView.maxPanels (${String(o)}), because a reader whose page finds every worker busy waits with the document of every panel; got ${M.describeValue(r.maxQueuedJobs)}`)},ae=Object.freeze(["workers","workerHeapMb"]),ie=(r,o)=>{if(r!==void 0&&!M.isPlainObject(r))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }");const d=r??{};for(const p of ae)if(d[p]!==void 0)throw new TypeError(`[markdown-explorer] sanitizer.${p} is an option of Node's worker threads; a browser runtime takes only { deadlineMs, maxHtmlBytes, cacheBytes, jobsPerScope, maxQueuedJobs }`);const{deadlineMs:u,maxHtmlBytes:S,cacheBytes:f,jobsPerScope:E,maxQueuedJobs:g}=d,l=R("jobsPerScope",E,G(o,1),Number.MAX_SAFE_INTEGER),_=Object.freeze({deadlineMs:R("deadlineMs",u,J,D.MAX_TIMER_MILLISECONDS),maxHtmlBytes:R("maxHtmlBytes",S,Y,Q),cacheBytes:R("cacheBytes",f,X,Number.MAX_SAFE_INTEGER),jobsPerScope:l,maxQueuedJobs:R("maxQueuedJobs",g,V*l,Number.MAX_SAFE_INTEGER)});if(W(_,o),q(_.maxHtmlBytes,z)<O)throw new RangeError(`[markdown-explorer] sanitizer.maxHtmlBytes (${String(_.maxHtmlBytes)} bytes) must leave room for ${String(O)} parsed nodes in the node budget, which a browser runtime counts in a worker heap of ${String(z)} MiB; lower maxHtmlBytes`);return _},U=Object.freeze({status:"aborted"}),I=(r,o,d)=>{const u=(r.get(o)??0)+d;u===0?r.delete(o):r.set(o,u)},L=(r,o,d)=>{if(!Number.isSafeInteger(o)||o<=0||o>d)throw new RangeError(`[markdown-explorer] a worker pool's ${r} must be an integer in 1..${String(d)}; got ${M.describeValue(o)}`)},ue=r=>r!==null&&typeof r=="object"&&r.ready===!0&&!("id"in r),K=(r,o)=>r!==null&&typeof r=="object"&&r.id===o&&"output"in r,ce=({start:r,size:o,deadlineMs:d,jobsPerScope:u,maxQueuedJobs:S})=>{L("size",o,Number.MAX_SAFE_INTEGER),L("deadline",d,D.MAX_TIMER_MILLISECONDS),L("jobsPerScope",u,Number.MAX_SAFE_INTEGER),L("maxQueuedJobs",S,Number.MAX_SAFE_INTEGER);const f=new Set,E=[],g=new Map,l=new Map,_=Z(o);let p=0;const h=(e,t)=>{const{job:n}=e;e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.job=null,e.sent=!1,n!==null&&(I(g,n.scope,-1),I(l,n.scope,-1),n.settle(t))},T=e=>{const[t]=E.splice(e,1);t?.detach()},N=()=>{let e=-1,t=_,n=Number.POSITIVE_INFINITY;for(const[s,a]of E.entries()){const i=g.get(a.scope)??0,c=l.get(a.scope)??0;(i<t||i===t&&e>=0&&c<n)&&(e=s,t=i,n=c)}return e},w=(e,t)=>{f.has(e)&&(f.delete(e),h(e,t),e.worker.terminate().catch(()=>{}),A())},x=e=>{e.timer=setTimeout(()=>{w(e,{status:"timeout"})},d)},y=(e,t)=>e.sent?{status:"crashed",error:t}:{status:"unavailable",error:t},H=(e,t)=>{e.sent=!0,x(e);try{e.worker.postMessage({id:t.id,input:t.input})}catch(n){h(e,{status:"crashed",error:n}),e.worker.unref()}},B=()=>{const e={worker:r(),job:null,sent:!1,timer:null,ready:!1};return e.worker.unref(),e.timer=setTimeout(()=>{w(e,{status:"unavailable",error:new Error(`[markdown-explorer] a worker did not start within ${String(d)} ms`)})},d),e.worker.listen({message:t=>{if(!e.ready&&ue(t)){e.ready=!0,e.timer!==null&&clearTimeout(e.timer),e.timer=null,e.job===null?e.worker.unref():H(e,e.job),e.job===null&&A();return}const{job:n}=e;if(n===null||!K(t,n.id)){w(e,y(e,new Error("[markdown-explorer] a worker sent a message that answers no job")));return}h(e,{status:"done",output:t.output}),e.worker.unref(),A()},failure:t=>{w(e,y(e,t))}}),f.add(e),e},A=()=>{for(;;){const e=N(),t=E[e];if(t===void 0)return;let n;for(const a of f)if(a.job===null){n=a;break}if(n===void 0&&f.size<o)try{n=B()}catch(a){T(e),I(l,t.scope,-1),t.settle({status:"unavailable",error:a});continue}if(n===void 0)return;T(e),I(g,t.scope,1);const s=n;s.job=t,s.worker.ref(),s.ready&&H(s,t)}};return{run:(e,{scope:t,signal:n})=>new Promise(s=>{if(n.aborted){s(U);return}if((l.get(t)??0)>=u){s({status:"refused",limit:"scope"});return}p+=1;const a={id:p,input:e,scope:t,settle:s,detach:()=>{}};E.push(a),I(l,t,1),A();const i=E.indexOf(a);if(i<0)return;if(E.length>S){T(i),I(l,t,-1),s({status:"refused",limit:"queue"});return}const c=()=>{const m=E.indexOf(a);m<0||(T(m),I(l,t,-1),s(U))};n.addEventListener("abort",c,{once:!0}),a.detach=()=>{n.removeEventListener("abort",c)}}),workers:()=>f.size}},de=4,le=({maxHtmlBytes:r})=>r,me=({maxHtmlBytes:r})=>de*r,Ee=1024,fe=64,j=Object.freeze({status:"rejected",reason:"too-large",cause:null}),k=Object.freeze({status:"rejected",reason:"failed",cause:null}),we=r=>{if(r===null||typeof r!="object")return!1;const{status:o,html:d,message:u}=r;return o==="sanitized"&&typeof d=="string"||o==="too-large"||o==="error"&&typeof u=="string"},F=r=>({status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer could not measure a document",{cause:r})}),be=({iframeHosts:r,dataPath:o,ownUrls:d,limits:u,nodeBudget:S,measureHtml:f,classifyCrash:E,pool:g})=>{if(!Number.isSafeInteger(S)||S<=0)throw new RangeError(`[markdown-explorer] the HTML sanitizer's node budget must be a positive integer; got ${M.describeValue(S)}`);const l=Object.freeze([...r]),_=te.readOwnUrls(d),p=le(u),h=me(u),T=D.createLruCache(Ee,{max:u.cacheBytes,of:(e,t)=>2*e.length+(t.status==="sanitized"?2*t.html.length:fe)}),N=new Map,w=new Map,x=e=>{N.get(e.key)===e&&N.delete(e.key);const t=w.get(e.hash);t?.delete(e),t?.size===0&&w.delete(e.hash)},y=async(e,t,n)=>{const s=await g.run({html:e,iframeHosts:l,dataPath:o,ownUrls:_,maxNodes:S,maxAttributeChars:p,maxSanitizedChars:h},{scope:t,signal:n});if(s.status==="refused"){const i=s.limit==="scope"?`its reader already has ${String(u.jobsPerScope)} documents being sanitized or waiting`:`${String(u.maxQueuedJobs)} documents are already waiting`;return{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer refused a document: ${i}`)},lasting:!1}}if(s.status==="aborted")return{outcome:k,lasting:!1};if(s.status==="timeout")return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer did not finish within ${String(u.deadlineMs)} ms`)},lasting:!0};if(s.status==="unavailable")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker could not start",{cause:s.error})},lasting:!1};if(s.status==="crashed"){const i=E(s.error);return i!==null?{outcome:{status:"rejected",reason:i.reason,cause:new Error(i.message,{cause:s.error})},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker failed",{cause:s.error})},lasting:!0}}const{output:a}=s;return we(a)?a.status==="too-large"?{outcome:j,lasting:!0}:a.status==="error"?{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer failed: ${a.message}`)},lasting:!0}:a.html.length>h?{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer's output of ${String(a.html.length)} characters exceeds its limit of ${String(h)}`)},lasting:!0}:{outcome:{status:"sanitized",html:a.html},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker answered something that is not an outcome")},lasting:!0}},H=(e,t,n,s)=>{let a=()=>{};const i=new Promise(b=>{a=b}),c={hash:t,key:n,outcome:i,answer:a,controller:new AbortController,waiters:0};N.set(n,c);const m=w.get(t);return m===void 0?w.set(t,new Set([c])):m.add(c),y(e,s,c.controller.signal).catch(b=>({outcome:{status:"rejected",reason:"failed",cause:b instanceof Error?b:new Error(String(b))},lasting:!0})).then(({outcome:b,lasting:ee})=>{if(x(c),c.answer(b),!ee)return;const $=T.get(t),C=$??(b.status==="rejected"?{...b,cause:null}:b);$===void 0&&T.set(t,C);for(const P of w.get(t)??[])x(P),P.answer(C),P.controller.abort()}),c},B=(e,t)=>new Promise(n=>{e.waiters+=1;const s=()=>{e.waiters-=1,n(k),!(e.waiters>0)&&(x(e),e.controller.abort())};t.addEventListener("abort",s,{once:!0}),e.outcome.then(a=>{t.removeEventListener("abort",s),n(a)})}),A=(e,{utf8Bytes:t,hash:n},s,a)=>{if(t>u.maxHtmlBytes)return Promise.resolve(j);const i=T.get(n);if(i!==void 0)return Promise.resolve(i);if(a.aborted)return Promise.resolve(k);const c=`${n}\0${s}`,m=N.get(c);return B(m===void 0?H(e,n,c,s):m,a)};return(e,{scope:t,signal:n})=>{if(e.length>u.maxHtmlBytes)return Promise.resolve(j);let s;try{s=f(e)}catch(i){return Promise.resolve(F(i))}if(!(s instanceof Promise))return A(e,s,t,n);const a=s;return new Promise(i=>{const c=()=>i(k);n.addEventListener("abort",c,{once:!0}),a.then(m=>{n.removeEventListener("abort",c),i(A(e,m,t,n))},m=>{n.removeEventListener("abort",c),i(F(m))})})}};exports.DEFAULT_SANITIZER_CACHE_BYTES=X;exports.DEFAULT_SANITIZER_DEADLINE_MS=J;exports.DEFAULT_SANITIZER_MAX_HTML_BYTES=Y;exports.DEFAULT_SANITIZER_WORKER_HEAP_MB=z;exports.MAX_HTML_BYTES=Q;exports.MIN_HTML_NODE_BUDGET=O;exports.SANITIZER_QUEUED_READERS=V;exports.assertAdmissionCoversPanels=W;exports.assertPoolLimit=L;exports.createHtmlSanitizerService=be;exports.createWorkerPoolCore=ce;exports.defaultSanitizerJobsPerScope=G;exports.htmlNodeBudgetOf=q;exports.isReplyTo=K;exports.readLimit=R;exports.resolveBrowserSanitizerLimits=ie;
@@ -1,5 +1,5 @@
1
1
  import { ExplorerFailure, ExplorerFailureReason } from "../core/contracts.cjs";
2
- export type ExplorerOperation = "authenticate" | "tree" | "children" | "ancestors" | "reveal" | "document" | "text" | "edit" | "save" | "preview" | "revisions" | "revision" | "notices" | "refresh" | "boundary" | "asset";
2
+ export type ExplorerOperation = "authenticate" | "tree" | "children" | "ancestors" | "reveal" | "document" | "text" | "edit" | "save" | "preview" | "revisions" | "revision" | "notices" | "refresh" | "boundary" | "asset" | "issue-id" | "resolve-id";
3
3
  export type ExplorerLogDetail = {
4
4
  readonly operation: ExplorerOperation;
5
5
  readonly sourceId?: string;
@@ -1,5 +1,5 @@
1
1
  import { ExplorerFailure, ExplorerFailureReason } from "../core/contracts.js";
2
- export type ExplorerOperation = "authenticate" | "tree" | "children" | "ancestors" | "reveal" | "document" | "text" | "edit" | "save" | "preview" | "revisions" | "revision" | "notices" | "refresh" | "boundary" | "asset";
2
+ export type ExplorerOperation = "authenticate" | "tree" | "children" | "ancestors" | "reveal" | "document" | "text" | "edit" | "save" | "preview" | "revisions" | "revision" | "notices" | "refresh" | "boundary" | "asset" | "issue-id" | "resolve-id";
3
3
  export type ExplorerLogDetail = {
4
4
  readonly operation: ExplorerOperation;
5
5
  readonly sourceId?: string;
@@ -139,6 +139,24 @@ export type ExplorerEditPorts<P> = {
139
139
  readonly revisions: (context: ExplorerSourceContext<P>, path: string, readPath: string) => Promise<readonly ExplorerRevision[]>;
140
140
  readonly revision: (context: ExplorerSourceContext<P>, path: string, readPath: string, revisionId: string) => Promise<string>;
141
141
  };
142
+ export type ExplorerDocumentIdIssue = {
143
+ readonly kind: "issued";
144
+ } | {
145
+ readonly kind: "existing";
146
+ readonly id: string;
147
+ } | {
148
+ readonly kind: "taken";
149
+ };
150
+ export type ExplorerDocumentIdBinding = {
151
+ readonly kind: "bound";
152
+ readonly path: string;
153
+ } | {
154
+ readonly kind: "unbound";
155
+ };
156
+ export type ExplorerDocumentIdPorts<P> = {
157
+ readonly issue: (context: ExplorerSourceContext<P>, path: string, candidate: string) => Promise<ExplorerDocumentIdIssue>;
158
+ readonly resolve: (context: ExplorerSourceContext<P>, id: string) => Promise<ExplorerDocumentIdBinding>;
159
+ };
142
160
  export type ExplorerServerSharedConfig<P> = {
143
161
  readonly config: ExplorerConfig;
144
162
  readonly authenticate: (request: Request, mode: ExplorerAuthenticationMode) => Promise<ExplorerAuthentication<P>>;
@@ -159,6 +177,7 @@ export type ExplorerServerSharedConfig<P> = {
159
177
  readonly textMaxBytes?: number;
160
178
  readonly edit?: ExplorerEditPorts<P>;
161
179
  readonly editMaxBytes?: number;
180
+ readonly documentIds?: ExplorerDocumentIdPorts<P>;
162
181
  readonly logger?: ExplorerLogger;
163
182
  readonly onTreeRefreshed?: (key: string) => void;
164
183
  };
@@ -139,6 +139,24 @@ export type ExplorerEditPorts<P> = {
139
139
  readonly revisions: (context: ExplorerSourceContext<P>, path: string, readPath: string) => Promise<readonly ExplorerRevision[]>;
140
140
  readonly revision: (context: ExplorerSourceContext<P>, path: string, readPath: string, revisionId: string) => Promise<string>;
141
141
  };
142
+ export type ExplorerDocumentIdIssue = {
143
+ readonly kind: "issued";
144
+ } | {
145
+ readonly kind: "existing";
146
+ readonly id: string;
147
+ } | {
148
+ readonly kind: "taken";
149
+ };
150
+ export type ExplorerDocumentIdBinding = {
151
+ readonly kind: "bound";
152
+ readonly path: string;
153
+ } | {
154
+ readonly kind: "unbound";
155
+ };
156
+ export type ExplorerDocumentIdPorts<P> = {
157
+ readonly issue: (context: ExplorerSourceContext<P>, path: string, candidate: string) => Promise<ExplorerDocumentIdIssue>;
158
+ readonly resolve: (context: ExplorerSourceContext<P>, id: string) => Promise<ExplorerDocumentIdBinding>;
159
+ };
142
160
  export type ExplorerServerSharedConfig<P> = {
143
161
  readonly config: ExplorerConfig;
144
162
  readonly authenticate: (request: Request, mode: ExplorerAuthenticationMode) => Promise<ExplorerAuthentication<P>>;
@@ -159,6 +177,7 @@ export type ExplorerServerSharedConfig<P> = {
159
177
  readonly textMaxBytes?: number;
160
178
  readonly edit?: ExplorerEditPorts<P>;
161
179
  readonly editMaxBytes?: number;
180
+ readonly documentIds?: ExplorerDocumentIdPorts<P>;
162
181
  readonly logger?: ExplorerLogger;
163
182
  readonly onTreeRefreshed?: (key: string) => void;
164
183
  };
package/dist/server.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-B259RGgd.cjs"),v=require("./location-D8DyDkuA.cjs"),P=require("./explorerCore-DYrxS9ez.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-BY4CPCoA.cjs"),q=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,q.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,q.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,q.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},qe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},Xe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),X=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>Xe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,X),T=A.size>BigInt(X),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>qe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./ownUrls-BTPGNhBt.cjs"),v=require("./location-DrOP6t1F.cjs"),P=require("./explorerCore-CUkyKtm8.cjs"),ne=require("node:crypto"),ye=require("@aiquants/markdown/server"),N=require("node:fs"),S=require("node:path"),U=require("node:url"),O=require("./describeValue-Ccvhbt36.cjs"),i=require("./sanitizerService-DomN7lwC.cjs"),q=require("./lru-SGmUyBQU.cjs"),be=require("node:worker_threads"),R=require("node:fs/promises"),xe=require("node:stream");var G=typeof document<"u"?document.currentScript:null;const J=Object.freeze({kind:"anonymous"}),Se=Object.freeze({authenticate:async()=>({status:"signed-in",principal:J}),principalKey:()=>J.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),ke=(e,t)=>{const r=new be.Worker(e,{resourceLimits:t});return{postMessage:o=>{r.postMessage(o)},terminate:()=>r.terminate(),ref:()=>{r.ref()},unref:()=>{r.unref()},listen:({message:o,failure:a})=>{r.on("message",o),r.on("error",a),r.on("messageerror",a),r.on("exit",p=>{a(new Error(`[markdown-explorer] a worker exited with code ${String(p)}`))})}}},Te=({url:e,size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a,heapLimits:p})=>{i.assertPoolLimit("size",t,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("deadline",r,q.MAX_TIMER_MILLISECONDS),i.assertPoolLimit("jobsPerScope",o,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxQueuedJobs",a,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxOldGenerationSizeMb",p.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),i.assertPoolLimit("maxYoungGenerationSizeMb",p.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const x=Object.freeze({maxOldGenerationSizeMb:p.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:p.maxYoungGenerationSizeMb});return i.createWorkerPoolCore({start:()=>ke(e,x),size:t,deadlineMs:r,jobsPerScope:o,maxQueuedJobs:a})},_e=2,Oe=32,se=({workerHeapMb:e,maxHtmlBytes:t})=>i.htmlNodeBudgetOf(t,e),Ne=64,Me=1024*1024,ve=(e,t)=>{if(e!==void 0&&!O.isPlainObject(e))throw new TypeError("[markdown-explorer] sanitizer must be a plain object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:o,maxHtmlBytes:a,cacheBytes:p,workerHeapMb:x,jobsPerScope:l,maxQueuedJobs:w}=e??{},L=i.readLimit("workers",r,_e,Ne),I=i.readLimit("jobsPerScope",l,i.defaultSanitizerJobsPerScope(t,L),Number.MAX_SAFE_INTEGER),k=Object.freeze({workers:L,deadlineMs:i.readLimit("deadlineMs",o,i.DEFAULT_SANITIZER_DEADLINE_MS,q.MAX_TIMER_MILLISECONDS),maxHtmlBytes:i.readLimit("maxHtmlBytes",a,i.DEFAULT_SANITIZER_MAX_HTML_BYTES,i.MAX_HTML_BYTES),cacheBytes:i.readLimit("cacheBytes",p,i.DEFAULT_SANITIZER_CACHE_BYTES,Number.MAX_SAFE_INTEGER),workerHeapMb:i.readLimit("workerHeapMb",x,i.DEFAULT_SANITIZER_WORKER_HEAP_MB,Me),jobsPerScope:I,maxQueuedJobs:i.readLimit("maxQueuedJobs",w,i.SANITIZER_QUEUED_READERS*I,Number.MAX_SAFE_INTEGER)});if(i.assertAdmissionCoversPanels(k,t),se(k)<i.MIN_HTML_NODE_BUDGET)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(k.workerHeapMb)} MiB) must leave room for ${String(i.MIN_HTML_NODE_BUDGET)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(k.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return k},Le=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${S.extname(U.fileURLToPath(e))}`,e);if(!N.existsSync(U.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${U.fileURLToPath(t)}`);return t},Q=new Map,Ae=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let o=Q.get(r);return o===void 0&&(o=Te({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Oe}}),Q.set(r,o)),o},Re=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",Pe=e=>({utf8Bytes:Buffer.byteLength(e,"utf8"),hash:ne.createHash("sha256").update(e,"utf8").digest("base64")}),Ie=e=>t=>Re(t)?{reason:"too-large",message:`[markdown-explorer] the HTML sanitizer ran out of its ${String(e)} MiB worker heap`}:null,Z=32,De=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Z)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Z)} characters; got ${String(e.length)}`);return e},je=({scopeSecret:e})=>Object.freeze({prepareScope:()=>{const r=De(e);return o=>ne.createHmac("sha256",r).update(o,"utf8").digest("base64url").slice(0,q.EXPLORER_SCOPE_LENGTH)},createSanitizer:({options:r,maxPanels:o,iframeHosts:a,dataPath:p,ownUrls:x})=>{const l=ve(r,o);return i.createHtmlSanitizerService({iframeHosts:a,dataPath:p,ownUrls:x,limits:l,nodeBudget:se(l),measureHtml:Pe,classifyCrash:Ie(l.workerHeapMb),pool:Ae(Le(),l)})},createLinkCardHandler:r=>ye.createLinkCardHandler(r)}),Be=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const{scopeSecret:t,...r}=e;return P.createExplorerServer({...r,readSettings:o=>v.readCookieValue(o.headers.get("Cookie"),e.config.settingsCookie),assetMaxRangeBytes:null},je({scopeSecret:t}))},z=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Ce=new Set(["md","markdown","mdx"]),ee="image/svg+xml",ae=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg",ee],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",imageType:t===ee?"svg":"raster",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),ze=new Map([["csv","csv"],["tsv","tsv"],["tab","tsv"],["xlsx","workbook"],["xlsm","workbook"],["ods","workbook"]]),He=new Set(["txt","text","log","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fe=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ie=typeof N.constants.O_NOFOLLOW=="number"?N.constants.O_NOFOLLOW:0,ce=typeof N.constants.O_NONBLOCK=="number"?N.constants.O_NONBLOCK:0,te=e=>`${e.size}-${e.mtimeNs}`,$e=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),re=e=>g.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every($e),le=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Ue=e=>{const t=le(e);if(Ce.has(t))return{kind:"markdown"};const r=ae.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image",imageType:r.imageType}:{kind:"media",mediaType:r.mediaType};const o=ze.get(t);if(o!==void 0)return{kind:"spreadsheet",format:o};const a=e.toLowerCase();return He.has(t)||!a.includes(".")&&Fe.has(a)?{kind:"text"}:{kind:"file"}},W=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},de=e=>{const t=W(e);return t===null?e:new P.ExplorerError(t)},ue=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Ge=async e=>{try{return Math.trunc((await R.lstat(e)).mtimeMs)}catch(t){if(ue(t))return;throw t}},oe=async(e,t)=>{const r=[];for await(const o of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(o);return Buffer.concat(r)},We=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},qe=async(e,t,r,o)=>{let a;try{a=await R.open(e,N.constants.O_RDONLY|ie|ce);const w=await a.stat({bigint:!0});if(!w.isFile()||w.ino!==t.ino||w.dev!==t.dev||w.size!==t.size||w.mtimeNs!==t.mtimeNs)throw new P.ExplorerError("not-found")}catch(w){throw await a?.close(),de(w)}const p=a.createReadStream(We(r,t.size)),x=xe.Readable.toWeb(p),l=()=>{p.destroy(o.reason)};return o.aborted?l():o.addEventListener("abort",l,{once:!0}),x},Xe=(e,t)=>{const r=v.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Ye=e=>{let t=0;const r=[];return async o=>{t<e?t+=1:await new Promise(a=>r.push(a));try{return await o()}finally{const a=r.shift();a===void 0?t-=1:a()}}},Ve=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":g.isAcceptableDocumentPath(r)?g.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Ke=new Set(["id","label","root","pathPrefix","lang","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","legacyTextEncoding","walkConcurrency","cacheScope","reportSkipped"]),H=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${O.describeValue(t)}`);return t},Je=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const n of Object.keys(e))if(!Ke.has(n))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${O.describeValue(n)}`);const{id:t,label:r,root:o,parse:a}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof a!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof o!="string"||!S.isAbsolute(o))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${O.describeValue(o)}`);let p;try{p=N.statSync(o).isDirectory()}catch(n){throw new RangeError(`[markdown-explorer] root does not exist: ${o}`,{cause:n})}if(!p)throw new RangeError(`[markdown-explorer] root is not a directory: ${o}`);const x=N.realpathSync(o),l=e.pathPrefix;if(typeof l!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(l!==""&&!(l.endsWith("/")&&re(l.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${O.describeValue(l)}`);const w=e.lang;if(typeof w!="string")throw new TypeError('[markdown-explorer] lang is required: the language of the documents, a canonical BCP 47 language tag such as "ja" or "en-US"');if(!g.isExplorerDocumentLang(w))throw new RangeError(`[markdown-explorer] lang must be a canonical BCP 47 language tag (such as "ja" or "en-US"); got ${O.describeValue(w)}`);const L=g.resolvePathRules(e.deny),I=H("maxEntries",e.maxEntries,z.maxEntries),k=H("maxDocumentBytes",e.maxDocumentBytes,z.maxDocumentBytes),X=H("textPreviewBytes",e.textPreviewBytes,z.textPreviewBytes),D=e.legacyTextEncoding;if(D!=null&&typeof D!="string")throw new TypeError("[markdown-explorer] legacyTextEncoding must be a string or null");const Y=typeof D=="string"?v.legacyTextEncodingOf(D):null,me=H("walkConcurrency",e.walkConcurrency,z.walkConcurrency),B=e.cacheScope===void 0?"principal":e.cacheScope;if(B!=="principal"&&B!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${O.describeValue(B)}`);const C=e.reportSkipped;if(C!==void 0&&typeof C!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const fe=C===void 0?n=>{console.warn(`[markdown-explorer] the file-system source ${O.describeValue(n.sourceId)} does not list ${O.describeValue(n.path)}: ${n.reason}`)}:C,F=new Set,pe=n=>{const d=S.resolve(x,...n.split("/")),c=S.relative(x,d);return c===""||c===".."||c.startsWith(`..${S.sep}`)||S.isAbsolute(c)?null:d},V=(n,d)=>{const c=`${d}\0${n}`;F.has(c)||F.size>=I||(F.add(c),fe({sourceId:t,path:n,reason:d}))},we=async({signal:n})=>{n.throwIfAborted();const d=new AbortController,c=()=>{d.abort(n.reason)};n.addEventListener("abort",c,{once:!0});const m=Ye(me);let f=0;const h=async(s,y)=>{const b=await m(async()=>{d.signal.throwIfAborted();try{return await R.readdir(s,{withFileTypes:!0})}catch(u){if(y===""||!ue(u))throw u;return null}});if(d.signal.throwIfAborted(),b===null)return V(`${l}${y}`,"unreadable-directory"),null;const E=[];for(const u of b){if(L.deniesName(u.name))continue;const T=y===""?u.name:`${y}/${u.name}`,_=`${l}${T}`,M=Ve(u,_);if(M!==null){V(_,M);continue}E.push({dirent:u,relativePath:T,path:_})}if(f+=E.length,f>I)throw new P.ExplorerError("too-large");return E.sort((u,T)=>Xe(u.dirent.name,T.dirent.name)),(await Promise.all(E.map(async({dirent:u,relativePath:T,path:_})=>{const M=await Ge(S.join(s,u.name)),j=M===void 0?{}:{modifiedAt:M};if(!u.isDirectory())return{name:u.name,path:_,type:"file",...j};const K=await h(S.join(s,u.name),T);return K===null?null:{name:u.name,path:_,type:"directory",...j,children:K}}))).filter(u=>u!==null)};try{const s=await h(x,"");if(s===null)throw new Error("[markdown-explorer] the source's root could not be listed");return s}catch(s){throw d.abort(),s}finally{n.removeEventListener("abort",c)}},$=async n=>{if(!n.startsWith(l))return{status:"refused",reason:"not-found"};const d=n.slice(l.length);if(!re(d))return{status:"refused",reason:"invalid"};if(L.deniesPath(d))return{status:"refused",reason:"forbidden"};const c=pe(d);if(c===null)return{status:"refused",reason:"forbidden"};const m=await R.lstat(c,{bigint:!0});if(m.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!m.isFile())return{status:"refused",reason:"unsupported"};const f=await R.realpath(c);return f!==c||L.deniesPath(S.relative(x,f).split(S.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:c,name:d.slice(d.lastIndexOf("/")+1),stats:m}},Ee=async(n,d,c)=>{let m;try{const f=await $(c);if(f.status==="refused")return g.failureDocument(f.reason);const{target:h,name:s,stats:y}=f,b=Ue(s),E=te(y);if(b.kind==="image")return{kind:"image",name:s,imageType:b.imageType,version:E};if(b.kind==="media")return{kind:"media",name:s,mediaType:b.mediaType,version:E};if(b.kind==="spreadsheet")return{kind:"spreadsheet",name:s,format:b.format,firstSheetText:null,edit:null,version:E};if(b.kind==="file")return{kind:"file",name:s,version:E};m=await R.open(h,N.constants.O_RDONLY|ie|ce);const A=await m.stat({bigint:!0});if(!A.isFile()||A.ino!==y.ino||A.dev!==y.dev)return g.failureDocument("forbidden");if(b.kind==="markdown"){if(A.size>BigInt(k))return g.failureDocument("too-large");const M=await oe(m,k+1);if(M.length>k)return g.failureDocument("too-large");const j=await a(v.decodeTextLeniently(M,!0,Y),d);return{kind:"markdown",name:s,htmlContent:j.htmlContent,headings:j.headings,lang:w,edit:null}}const u=await oe(m,X),T=A.size>BigInt(X),_=v.decodeTextLeniently(u,!T,Y);return _.includes("\0")?{kind:"file",name:s,version:E}:{kind:"text",name:s,text:_,truncated:T,lang:w,version:E}}catch(f){const h=W(f);if(h===null)throw f;return g.failureDocument(h)}finally{await m?.close()}},ge=async(n,d,c)=>{let m;try{m=await $(c)}catch(E){throw de(E)}if(m.status==="refused")throw new P.ExplorerError(m.reason);const{target:f,name:h,stats:s}=m,y=ae.get(le(h)),b=y===void 0?"":y.contentType;return{name:h,contentType:b,size:Number(s.size),version:te(s),open:E=>qe(f,s,E,n.signal)}},he=async(n,d,c)=>{let m;try{m=await $(c)}catch(s){if(W(s)!==null)return null;throw s}if(m.status==="refused")return null;const f=c.slice(l.length).split("/");if(f.some(s=>L.deniesName(s)))return null;const h=f.slice(0,-1);return h.map((s,y)=>`${l}${h.slice(0,y+1).join("/")}`)};return Object.freeze({id:t,label:r,cacheScope:B,boundary:Object.freeze({contains:n=>n.startsWith(l)}),tree:we,ancestors:he,document:Ee,asset:ge})};exports.DEFAULT_DENIED_PATH_SEGMENTS=g.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=g.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=g.isAcceptableDocumentPath;exports.isDeniedPath=g.isDeniedPath;exports.decodeText=v.decodeText;exports.decodeTextLeniently=v.decodeTextLeniently;exports.legacyTextEncodingOf=v.legacyTextEncodingOf;exports.ExplorerError=P.ExplorerError;exports.anonymousAccess=Se;exports.createFileSystemSource=Je;exports.createMarkdownExplorer=Be;
package/dist/server.d.cts CHANGED
@@ -5,6 +5,6 @@ export { type AnonymousAccess, type AnonymousPrincipal, anonymousAccess } from "
5
5
  export { createMarkdownExplorer } from "./server/createMarkdownExplorer.cjs";
6
6
  export { ExplorerError, type ExplorerLogDetail, type ExplorerLogger, type ExplorerOperation } from "./server/errors.cjs";
7
7
  export { createFileSystemSource, type FileSystemSkippedEntry, type FileSystemSkipReason, type FileSystemSource, type FileSystemSourceOptions } from "./server/fileSystemSource.cjs";
8
- export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, MarkdownExplorerServerConfig, } from "./server/ports.cjs";
8
+ export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerDocumentIdBinding, ExplorerDocumentIdIssue, ExplorerDocumentIdPorts, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, MarkdownExplorerServerConfig, } from "./server/ports.cjs";
9
9
  export type { HtmlSanitizerOptions } from "./server/sanitizer.cjs";
10
10
  export type { SanitizerLimitsInput } from "./server/sanitizerOptions.cjs";
package/dist/server.d.ts CHANGED
@@ -5,6 +5,6 @@ export { type AnonymousAccess, type AnonymousPrincipal, anonymousAccess } from "
5
5
  export { createMarkdownExplorer } from "./server/createMarkdownExplorer.js";
6
6
  export { ExplorerError, type ExplorerLogDetail, type ExplorerLogger, type ExplorerOperation } from "./server/errors.js";
7
7
  export { createFileSystemSource, type FileSystemSkippedEntry, type FileSystemSkipReason, type FileSystemSource, type FileSystemSourceOptions } from "./server/fileSystemSource.js";
8
- export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, MarkdownExplorerServerConfig, } from "./server/ports.js";
8
+ export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerDocumentIdBinding, ExplorerDocumentIdIssue, ExplorerDocumentIdPorts, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, MarkdownExplorerServerConfig, } from "./server/ports.js";
9
9
  export type { HtmlSanitizerOptions } from "./server/sanitizer.js";
10
10
  export type { SanitizerLimitsInput } from "./server/sanitizerOptions.js";
package/dist/server.js CHANGED
@@ -1,15 +1,15 @@
1
- import { b as Te, f as _e, i as $, g as I } from "./ownUrls-Dh5g6ZJi.js";
2
- import { D as Yt, M as Kt, a as Jt } from "./ownUrls-Dh5g6ZJi.js";
3
- import { r as Oe, l as Ne, b as K, N as Me } from "./location--KvTA0Ri.js";
4
- import { d as qt } from "./location--KvTA0Ri.js";
5
- import { c as ve, E as C } from "./explorerCore-DLpDuSev.js";
1
+ import { b as Te, f as _e, i as $, g as I } from "./ownUrls-DD0cSCsF.js";
2
+ import { D as Yt, M as Kt, a as Jt } from "./ownUrls-DD0cSCsF.js";
3
+ import { r as Oe, l as Ne, b as K, N as Me } from "./location-Dh6K-y7w.js";
4
+ import { d as qt } from "./location-Dh6K-y7w.js";
5
+ import { c as ve, E as C } from "./explorerCore-B3RGmMG6.js";
6
6
  import { createHash as Re, createHmac as Ae } from "node:crypto";
7
7
  import { createLinkCardHandler as Le } from "@aiquants/markdown/server";
8
8
  import { existsSync as Ie, statSync as Pe, realpathSync as je, constants as v } from "node:fs";
9
9
  import { extname as Be, isAbsolute as J, relative as Q, sep as q, join as Z, resolve as ze } from "node:path";
10
10
  import { fileURLToPath as F } from "node:url";
11
11
  import { i as Ce, d as T } from "./describeValue-CLlVRO8d.js";
12
- import { b as M, c as He, d as O, e as De, S as Fe, D as $e, f as Ge, M as We, g as Ue, j as Xe, k as Ye, l as V, h as Ke, a as Je } from "./sanitizerService-KWXv7bPm.js";
12
+ import { b as M, c as He, d as O, e as De, S as Fe, D as $e, f as Ge, M as We, g as Ue, j as Xe, k as Ye, l as V, h as Ke, a as Je } from "./sanitizerService-B8v4ap9t.js";
13
13
  import { M as ie, E as Qe } from "./lru-DC8GBmkX.js";
14
14
  import { Worker as qe } from "node:worker_threads";
15
15
  import { open as ce, lstat as le, realpath as Ze, readdir as Ve } from "node:fs/promises";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@aiquants/markdown/link-cards"),g=require("isomorphic-dompurify"),d=require("./sanitizerService-BY4CPCoA.cjs"),y=require("./lru-SGmUyBQU.cjs"),b=require("./sanitizePolicy-CiQfnxyd.cjs"),E=require("./sanitizeJob-Cs9o3Vpl.cjs"),k=e=>e!==null&&typeof e=="object"&&e.status==="within",x=e=>new Error(e instanceof ErrorEvent?`[markdown-explorer] the nesting-guard worker failed: ${e.message}`:`[markdown-explorer] the nesting-guard worker failed (${e.type})`),T=({nestingGuardWorkerUrl:e,sanitizeJob:r,yieldToMain:n,deadlineMs:a})=>{const t=new Worker(e,{type:"module"});let o=null,c=!1;return{postMessage:({id:u,input:i})=>{const p={id:u,input:{html:i.html,maxDepth:b.MAX_HTML_NESTING_DEPTH,maxNodes:i.maxNodes,maxAttributeChars:i.maxAttributeChars}};t.postMessage(p),o={id:u,input:i,sentAt:performance.now()}},terminate:()=>(c=!0,o=null,t.terminate(),Promise.resolve()),ref:()=>{},unref:()=>{},listen:({message:u,failure:i})=>{const p=s=>{c||i(s)},m=async s=>{if(await n(),o!==s)return;const l=r(s.input);performance.now()-s.sentAt>=a||(o=null,u({id:s.id,output:l}))};t.addEventListener("message",s=>{if(c)return;const l=s.data,w=o;if(w!==null&&d.isReplyTo(l,w.id)){if(k(l.output)){m(w).catch(p);return}o=null}u(l)});const f=s=>{s.preventDefault(),p(x(s))};t.addEventListener("error",f),t.addEventListener("messageerror",f)}}},S=({purify:e,nestingGuardWorkerUrl:r,yieldToMain:n,deadlineMs:a,jobsPerScope:t,maxQueuedJobs:o})=>{const c=E.createJobSanitizer(e);return d.createWorkerPoolCore({start:()=>T({nestingGuardWorkerUrl:r,sanitizeJob:c,yieldToMain:n,deadlineMs:a}),size:1,deadlineMs:a,jobsPerScope:t,maxQueuedJobs:o})},P=e=>{if(e===null||typeof e!="object")return null;const{yield:r}=e;return typeof r=="function"?()=>Reflect.apply(r,e,[]):null},C=e=>{const r=P(e.scheduler);if(r!==null)return async()=>{await r()};const n=e.MessageChannel;return()=>new Promise(a=>{const t=new n;t.port1.onmessage=()=>{t.port1.close(),a()},t.port2.postMessage(null)})},L=e=>{if(e===null||typeof e!="object")return!1;const{open:r,classify:n}=e;return typeof r=="function"&&typeof n=="function"},z=e=>async r=>{const n=new TextEncoder().encode(r),a=new Uint8Array(await e.digest("SHA-256",n));return{utf8Bytes:n.byteLength,hash:btoa(String.fromCharCode(...a))}},H=e=>{const{principalKey:r,scope:n,window:a,nestingGuardWorkerUrl:t,pageFetch:o}=e;if(typeof r!="string"||r==="")throw new TypeError("[markdown-explorer] principalKey must be a non-empty string");if(!y.isExplorerScope(n))throw new TypeError(`[markdown-explorer] scope must be ${String(y.EXPLORER_SCOPE_LENGTH)} base64url characters`);const c=a.crypto.subtle;if(c===void 0)throw new TypeError("[markdown-explorer] window must be a secure context: it has no crypto.subtle to measure HTML with");if(!(t instanceof URL))throw new TypeError("[markdown-explorer] nestingGuardWorkerUrl must be a URL");if(o!==null&&!L(o))throw new TypeError("[markdown-explorer] pageFetch must be a page-fetch port ({ open, classify }) or null");return Object.freeze({prepareScope:()=>i=>{if(i!==r)throw new TypeError("[markdown-explorer] the browser runtime serves one principal; a request named another principal key");return n},createSanitizer:({options:i,maxPanels:p,iframeHosts:m,dataPath:f,ownUrls:s})=>{const l=d.resolveBrowserSanitizerLimits(i,p);return d.createHtmlSanitizerService({iframeHosts:m,dataPath:f,ownUrls:s,limits:l,nodeBudget:d.htmlNodeBudgetOf(l.maxHtmlBytes,d.DEFAULT_SANITIZER_WORKER_HEAP_MB),measureHtml:z(c),classifyCrash:()=>null,pool:S({purify:g(a),nestingGuardWorkerUrl:t,yieldToMain:C(globalThis),deadlineMs:l.deadlineMs,jobsPerScope:l.jobsPerScope,maxQueuedJobs:l.maxQueuedJobs})})},createLinkCardHandler:({authorize:i})=>{if(o===null)throw new TypeError("[markdown-explorer] config.embeds.linkCardEndpoint is set, but the browser runtime was created with pageFetch: null");return h.createLinkCardHandlerCore({authorize:i,pageFetch:o})}})};exports.createBrowserExplorerPlatform=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@aiquants/markdown/link-cards"),g=require("isomorphic-dompurify"),d=require("./sanitizerService-DomN7lwC.cjs"),y=require("./lru-SGmUyBQU.cjs"),b=require("./sanitizePolicy-C-ehd0J_.cjs"),E=require("./sanitizeJob-CudE1RUP.cjs"),k=e=>e!==null&&typeof e=="object"&&e.status==="within",x=e=>new Error(e instanceof ErrorEvent?`[markdown-explorer] the nesting-guard worker failed: ${e.message}`:`[markdown-explorer] the nesting-guard worker failed (${e.type})`),T=({nestingGuardWorkerUrl:e,sanitizeJob:r,yieldToMain:n,deadlineMs:a})=>{const t=new Worker(e,{type:"module"});let o=null,c=!1;return{postMessage:({id:u,input:i})=>{const p={id:u,input:{html:i.html,maxDepth:b.MAX_HTML_NESTING_DEPTH,maxNodes:i.maxNodes,maxAttributeChars:i.maxAttributeChars}};t.postMessage(p),o={id:u,input:i,sentAt:performance.now()}},terminate:()=>(c=!0,o=null,t.terminate(),Promise.resolve()),ref:()=>{},unref:()=>{},listen:({message:u,failure:i})=>{const p=s=>{c||i(s)},m=async s=>{if(await n(),o!==s)return;const l=r(s.input);performance.now()-s.sentAt>=a||(o=null,u({id:s.id,output:l}))};t.addEventListener("message",s=>{if(c)return;const l=s.data,w=o;if(w!==null&&d.isReplyTo(l,w.id)){if(k(l.output)){m(w).catch(p);return}o=null}u(l)});const f=s=>{s.preventDefault(),p(x(s))};t.addEventListener("error",f),t.addEventListener("messageerror",f)}}},S=({purify:e,nestingGuardWorkerUrl:r,yieldToMain:n,deadlineMs:a,jobsPerScope:t,maxQueuedJobs:o})=>{const c=E.createJobSanitizer(e);return d.createWorkerPoolCore({start:()=>T({nestingGuardWorkerUrl:r,sanitizeJob:c,yieldToMain:n,deadlineMs:a}),size:1,deadlineMs:a,jobsPerScope:t,maxQueuedJobs:o})},P=e=>{if(e===null||typeof e!="object")return null;const{yield:r}=e;return typeof r=="function"?()=>Reflect.apply(r,e,[]):null},C=e=>{const r=P(e.scheduler);if(r!==null)return async()=>{await r()};const n=e.MessageChannel;return()=>new Promise(a=>{const t=new n;t.port1.onmessage=()=>{t.port1.close(),a()},t.port2.postMessage(null)})},L=e=>{if(e===null||typeof e!="object")return!1;const{open:r,classify:n}=e;return typeof r=="function"&&typeof n=="function"},z=e=>async r=>{const n=new TextEncoder().encode(r),a=new Uint8Array(await e.digest("SHA-256",n));return{utf8Bytes:n.byteLength,hash:btoa(String.fromCharCode(...a))}},H=e=>{const{principalKey:r,scope:n,window:a,nestingGuardWorkerUrl:t,pageFetch:o}=e;if(typeof r!="string"||r==="")throw new TypeError("[markdown-explorer] principalKey must be a non-empty string");if(!y.isExplorerScope(n))throw new TypeError(`[markdown-explorer] scope must be ${String(y.EXPLORER_SCOPE_LENGTH)} base64url characters`);const c=a.crypto.subtle;if(c===void 0)throw new TypeError("[markdown-explorer] window must be a secure context: it has no crypto.subtle to measure HTML with");if(!(t instanceof URL))throw new TypeError("[markdown-explorer] nestingGuardWorkerUrl must be a URL");if(o!==null&&!L(o))throw new TypeError("[markdown-explorer] pageFetch must be a page-fetch port ({ open, classify }) or null");return Object.freeze({prepareScope:()=>i=>{if(i!==r)throw new TypeError("[markdown-explorer] the browser runtime serves one principal; a request named another principal key");return n},createSanitizer:({options:i,maxPanels:p,iframeHosts:m,dataPath:f,ownUrls:s})=>{const l=d.resolveBrowserSanitizerLimits(i,p);return d.createHtmlSanitizerService({iframeHosts:m,dataPath:f,ownUrls:s,limits:l,nodeBudget:d.htmlNodeBudgetOf(l.maxHtmlBytes,d.DEFAULT_SANITIZER_WORKER_HEAP_MB),measureHtml:z(c),classifyCrash:()=>null,pool:S({purify:g(a),nestingGuardWorkerUrl:t,yieldToMain:C(globalThis),deadlineMs:l.deadlineMs,jobsPerScope:l.jobsPerScope,maxQueuedJobs:l.maxQueuedJobs})})},createLinkCardHandler:({authorize:i})=>{if(o===null)throw new TypeError("[markdown-explorer] config.embeds.linkCardEndpoint is set, but the browser runtime was created with pageFetch: null");return h.createLinkCardHandlerCore({authorize:i,pageFetch:o})}})};exports.createBrowserExplorerPlatform=H;
@@ -1,9 +1,9 @@
1
1
  import { createLinkCardHandlerCore as w } from "@aiquants/markdown/link-cards";
2
2
  import h from "isomorphic-dompurify";
3
- import { c as y, i as g, r as b, a as E, h as x, D as k } from "./sanitizerService-KWXv7bPm.js";
3
+ import { c as y, i as g, r as b, a as E, h as x, D as k } from "./sanitizerService-B8v4ap9t.js";
4
4
  import { i as T, E as S } from "./lru-DC8GBmkX.js";
5
- import { M as L } from "./sanitizePolicy-CEMdaLUB.js";
6
- import { c as P } from "./sanitizeJob-BYRk17nr.js";
5
+ import { M as L } from "./sanitizePolicy-DAPnUUVm.js";
6
+ import { c as P } from "./sanitizeJob-BYqzjFJC.js";
7
7
  const C = (e) => e !== null && typeof e == "object" && e.status === "within", H = (e) => new Error(e instanceof ErrorEvent ? `[markdown-explorer] the nesting-guard worker failed: ${e.message}` : `[markdown-explorer] the nesting-guard worker failed (${e.type})`), M = ({ nestingGuardWorkerUrl: e, sanitizeJob: r, yieldToMain: o, deadlineMs: i }) => {
8
8
  const t = new Worker(e, { type: "module" });
9
9
  let n = null, c = !1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./location-D8DyDkuA.cjs"),c=require("./ownUrls-B259RGgd.cjs"),u=require("./explorerCore-DYrxS9ez.cjs"),x=require("react-router"),d=require("./describeValue-Ccvhbt36.cjs"),_=(i,e)=>new Promise((o,a)=>{const t=()=>a(e.reason);e.addEventListener("abort",t,{once:!0}),i.then(n=>{e.removeEventListener("abort",t),o(n)},n=>{e.removeEventListener("abort",t),a(n)}),e.aborted&&t()}),L=(i,{dataPath:e,pageAddress:o})=>{if(E.assertMountPath("dataPath",e),typeof o!="string")throw new TypeError(`[markdown-explorer] pageAddress must be a string; got ${d.describeValue(o)}`);if(!URL.canParse(e,o))throw new RangeError(`[markdown-explorer] pageAddress must be an absolute URL the data path resolves against; got ${d.describeValue(o)}`);const a=new URL(o),t=`${e}/`;return async(n,h)=>{const s=new Request(n instanceof Request?n:new URL(String(n),a),h);s.signal.throwIfAborted();const r=new URL(s.url);if(r.protocol!==a.protocol||r.host!==a.host||!r.pathname.startsWith(t))throw new TypeError(`[markdown-explorer] the in-process fetch answers only ${t}*; got ${r.protocol}//${r.host}${r.pathname}`);const T={request:s,url:r,pattern:`${e}/*`,params:{"*":r.pathname.slice(t.length)},context:new x.RouterContextProvider},p=s.method==="GET"||s.method==="HEAD",l=await _(p?i.dataLoader(T):i.dataAction(T),s.signal);return s.method==="HEAD"?new Response(null,{headers:l.headers,status:l.status,statusText:l.statusText}):l}};exports.decodeText=E.decodeText;exports.decodeTextLeniently=E.decodeTextLeniently;exports.isExplorerSourceId=E.isExplorerSourceId;exports.legacyTextEncodingOf=E.legacyTextEncodingOf;exports.DEFAULT_DENIED_PATH_SEGMENTS=c.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_MAX_HEADINGS=c.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=c.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=c.isAcceptableDocumentPath;exports.isDeniedPath=c.isDeniedPath;exports.isExplorerDocumentLang=c.isExplorerDocumentLang;exports.ASSET_CONTENT_SECURITY_POLICIES=u.ASSET_CONTENT_SECURITY_POLICIES;exports.ExplorerError=u.ExplorerError;exports.createExplorerServer=u.createExplorerServer;exports.createInProcessDataFetch=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./location-DrOP6t1F.cjs"),c=require("./ownUrls-BTPGNhBt.cjs"),u=require("./explorerCore-CUkyKtm8.cjs"),x=require("react-router"),d=require("./describeValue-Ccvhbt36.cjs"),_=(i,e)=>new Promise((o,a)=>{const t=()=>a(e.reason);e.addEventListener("abort",t,{once:!0}),i.then(n=>{e.removeEventListener("abort",t),o(n)},n=>{e.removeEventListener("abort",t),a(n)}),e.aborted&&t()}),L=(i,{dataPath:e,pageAddress:o})=>{if(E.assertMountPath("dataPath",e),typeof o!="string")throw new TypeError(`[markdown-explorer] pageAddress must be a string; got ${d.describeValue(o)}`);if(!URL.canParse(e,o))throw new RangeError(`[markdown-explorer] pageAddress must be an absolute URL the data path resolves against; got ${d.describeValue(o)}`);const a=new URL(o),t=`${e}/`;return async(n,h)=>{const s=new Request(n instanceof Request?n:new URL(String(n),a),h);s.signal.throwIfAborted();const r=new URL(s.url);if(r.protocol!==a.protocol||r.host!==a.host||!r.pathname.startsWith(t))throw new TypeError(`[markdown-explorer] the in-process fetch answers only ${t}*; got ${r.protocol}//${r.host}${r.pathname}`);const T={request:s,url:r,pattern:`${e}/*`,params:{"*":r.pathname.slice(t.length)},context:new x.RouterContextProvider},p=s.method==="GET"||s.method==="HEAD",l=await _(p?i.dataLoader(T):i.dataAction(T),s.signal);return s.method==="HEAD"?new Response(null,{headers:l.headers,status:l.status,statusText:l.statusText}):l}};exports.decodeText=E.decodeText;exports.decodeTextLeniently=E.decodeTextLeniently;exports.isExplorerSourceId=E.isExplorerSourceId;exports.legacyTextEncodingOf=E.legacyTextEncodingOf;exports.DEFAULT_DENIED_PATH_SEGMENTS=c.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_MAX_HEADINGS=c.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=c.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=c.isAcceptableDocumentPath;exports.isDeniedPath=c.isDeniedPath;exports.isExplorerDocumentLang=c.isExplorerDocumentLang;exports.ASSET_CONTENT_SECURITY_POLICIES=u.ASSET_CONTENT_SECURITY_POLICIES;exports.ExplorerError=u.ExplorerError;exports.createExplorerServer=u.createExplorerServer;exports.createInProcessDataFetch=L;
@@ -9,6 +9,6 @@ export { ExplorerError, type ExplorerLogDetail, type ExplorerLogger, type Explor
9
9
  export { createExplorerServer } from "./server/explorerCore.cjs";
10
10
  export { createInProcessDataFetch } from "./server/inProcessFetch.cjs";
11
11
  export type { ExplorerServerPlatform, SanitizerSetup } from "./server/platform.cjs";
12
- export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerCoreConfig, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, } from "./server/ports.cjs";
12
+ export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerDocumentIdBinding, ExplorerDocumentIdIssue, ExplorerDocumentIdPorts, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerCoreConfig, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, } from "./server/ports.cjs";
13
13
  export type { SanitizerLimitsInput } from "./server/sanitizerOptions.cjs";
14
14
  export type { HtmlSanitizerService, SanitizedHtml, SanitizeRequest } from "./server/sanitizerService.cjs";
@@ -9,6 +9,6 @@ export { ExplorerError, type ExplorerLogDetail, type ExplorerLogger, type Explor
9
9
  export { createExplorerServer } from "./server/explorerCore.js";
10
10
  export { createInProcessDataFetch } from "./server/inProcessFetch.js";
11
11
  export type { ExplorerServerPlatform, SanitizerSetup } from "./server/platform.js";
12
- export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerCoreConfig, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, } from "./server/ports.js";
12
+ export type { ExplorerAncestorsOptions, ExplorerAssetFile, ExplorerAssetOptions, ExplorerAssetRedirect, ExplorerAuthentication, ExplorerAuthenticationMode, ExplorerBoundaryAnswer, ExplorerByteRange, ExplorerDataPlan, ExplorerDocumentIdBinding, ExplorerDocumentIdIssue, ExplorerDocumentIdPorts, ExplorerEditPorts, ExplorerHostDocument, ExplorerHostEditSource, ExplorerHostPreview, ExplorerHostSaveDraft, ExplorerHostSaveResult, ExplorerPageLoaderResult, ExplorerServerCoreConfig, ExplorerServerSharedConfig, ExplorerSource, ExplorerSourceBoundary, ExplorerSourceContext, MarkdownExplorerServer, } from "./server/ports.js";
13
13
  export type { SanitizerLimitsInput } from "./server/sanitizerOptions.js";
14
14
  export type { HtmlSanitizerService, SanitizedHtml, SanitizeRequest } from "./server/sanitizerService.js";
@@ -1,7 +1,7 @@
1
- import { a as l } from "./location--KvTA0Ri.js";
2
- import { d as R, b as A, i as D, l as _ } from "./location--KvTA0Ri.js";
3
- import { D as g, E as P, M as I, i as U, a as $, b as v } from "./ownUrls-Dh5g6ZJi.js";
4
- import { A as N, E as H, c as M } from "./explorerCore-DLpDuSev.js";
1
+ import { a as l } from "./location-Dh6K-y7w.js";
2
+ import { d as R, b as A, i as D, l as _ } from "./location-Dh6K-y7w.js";
3
+ import { D as g, E as P, M as I, i as U, a as $, b as v } from "./ownUrls-DD0cSCsF.js";
4
+ import { A as N, E as H, c as M } from "./explorerCore-B3RGmMG6.js";
5
5
  import { RouterContextProvider as d } from "react-router";
6
6
  import { d as p } from "./describeValue-CLlVRO8d.js";
7
7
  const u = (c, e) => new Promise((o, n) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@aiquants/virtualscroll"),e=require("./index-LQWQfpAf.cjs"),C=Object.freeze({renderVisual:r.tapScrollCircleSampleVisual,...e.TAP_SCROLL_CIRCLE_SPEED_RANGE,size:e.TAP_SCROLL_CIRCLE_SIZE,offsetX:e.TAP_SCROLL_CIRCLE_OFFSET_X}),L=Object.freeze({...C,visibility:"scrolling"}),l=_=>_?L:C,t=Object.freeze({enabled:!1});exports.NO_TAP_SCROLL_CIRCLE=t;exports.TAP_SCROLL_CIRCLE=C;exports.TOUCH_TAP_SCROLL_CIRCLE=L;exports.tapScrollCircleFor=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@aiquants/virtualscroll"),e=require("./index-lpL7GltU.cjs"),C=Object.freeze({renderVisual:r.tapScrollCircleSampleVisual,...e.TAP_SCROLL_CIRCLE_SPEED_RANGE,size:e.TAP_SCROLL_CIRCLE_SIZE,offsetX:e.TAP_SCROLL_CIRCLE_OFFSET_X}),L=Object.freeze({...C,visibility:"scrolling"}),l=_=>_?L:C,t=Object.freeze({enabled:!1});exports.NO_TAP_SCROLL_CIRCLE=t;exports.TAP_SCROLL_CIRCLE=C;exports.TOUCH_TAP_SCROLL_CIRCLE=L;exports.tapScrollCircleFor=l;
@@ -1,5 +1,5 @@
1
1
  import { tapScrollCircleSampleVisual as _ } from "@aiquants/virtualscroll";
2
- import { T as L, d as r, e as l } from "./index-C1YMH-yI.js";
2
+ import { T as L, d as r, e as l } from "./index-D0l_BJqb.js";
3
3
  const e = Object.freeze({
4
4
  renderVisual: _,
5
5
  ...l,
package/dist/testing.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=JSON.parse('[{"pattern":".env*","path":".env","expect":true},{"pattern":".env*","path":"apps/web/.env.production","expect":true},{"pattern":".env*","path":".envrc","expect":true},{"pattern":".env*","path":".env~","expect":true},{"pattern":".env*","path":".env-old","expect":true},{"pattern":".env*","path":".env_backup","expect":true},{"pattern":".env*","path":"docs/environment.md","expect":false},{"pattern":".env*","path":"docs/prod.env","expect":false},{"pattern":"*.env","path":"prod.env","expect":true},{"pattern":"*.env","path":"config/staging.env","expect":true},{"pattern":"*.env","path":"prod.env.bak","expect":false},{"pattern":"*.env","path":"environment.md","expect":false},{"pattern":"*.env.*","path":"prod.env.bak","expect":true},{"pattern":"*.env.*","path":"config/deploy.env.production","expect":true},{"pattern":"*.env.*","path":"prod.env","expect":false},{"pattern":"*.env.*","path":"prod.environment.md","expect":false},{"pattern":"*.env~*","path":"prod.env~","expect":true},{"pattern":"*.env~*","path":"config/prod.env~1","expect":true},{"pattern":"*.env~*","path":"prod.env","expect":false},{"pattern":"*.env-*","path":"prod.env-old","expect":true},{"pattern":"*.env-*","path":"config/app.env-2026","expect":true},{"pattern":"*.env-*","path":"my-env-file.md","expect":false},{"pattern":"*.env_*","path":"prod.env_backup","expect":true},{"pattern":"*.env_*","path":"config/app.env_local","expect":true},{"pattern":"*.env_*","path":"my_env_file.md","expect":false},{"pattern":"*.env#*","path":"#prod.env#","expect":true},{"pattern":"*.env#*","path":"config/prod.env#1","expect":true},{"pattern":"*.env#*","path":"prod.env","expect":false},{"pattern":".git","path":".git/config","expect":true},{"pattern":".git","path":"sub/.git/HEAD","expect":true},{"pattern":".git","path":".github/workflows/ci.yml","expect":false},{"pattern":".git","path":".gitignore","expect":false},{"pattern":".git-credentials","path":".git-credentials","expect":true},{"pattern":".git-credentials","path":"home/.git-credentials","expect":true},{"pattern":".git-credentials","path":"git-credentials","expect":false},{"pattern":".svn","path":".svn/entries","expect":true},{"pattern":".svn","path":"svn/entries","expect":false},{"pattern":".hg","path":".hg/hgrc","expect":true},{"pattern":".hg","path":".hgignore","expect":false},{"pattern":"node_modules","path":"node_modules/pkg/index.js","expect":true},{"pattern":"node_modules","path":"packages/a/node_modules/b/README.md","expect":true},{"pattern":"node_modules","path":"docs/node_modules_guide.md","expect":false},{"pattern":"secrets","path":"secrets/api.md","expect":true},{"pattern":"secrets","path":"config/secrets/prod.json","expect":true},{"pattern":"secrets","path":"docs/secrets-overview.md","expect":false},{"pattern":".secrets","path":".secrets/key","expect":true},{"pattern":".secrets","path":"app/.secrets","expect":true},{"pattern":".secrets","path":".secrets.md","expect":false},{"pattern":"secrets.json","path":"secrets.json","expect":true},{"pattern":"secrets.json","path":"config/secrets.json","expect":true},{"pattern":"secrets.json","path":"my-secrets.json","expect":false},{"pattern":"secrets.yml","path":"config/secrets.yml","expect":true},{"pattern":"secrets.yml","path":"secrets.yaml","expect":false},{"pattern":"secrets.yaml","path":"config/secrets.yaml","expect":true},{"pattern":"secrets.yaml","path":"secrets.yml","expect":false},{"pattern":"secrets.toml","path":"config/secrets.toml","expect":true},{"pattern":"secrets.toml","path":"secrets.toml.example","expect":false},{"pattern":"secrets.ini","path":"config/secrets.ini","expect":true},{"pattern":"secrets.ini","path":"app.ini","expect":false},{"pattern":"secrets.txt","path":"notes/secrets.txt","expect":true},{"pattern":"secrets.txt","path":"secrets.txt.bak","expect":false},{"pattern":".ssh","path":".ssh/id_rsa","expect":true},{"pattern":".ssh","path":"home/user/.ssh/config","expect":true},{"pattern":".ssh","path":".ssh_config","expect":false},{"pattern":".aws","path":".aws/credentials","expect":true},{"pattern":".aws","path":"home/user/.aws/config","expect":true},{"pattern":".aws","path":".aws-sam/build.toml","expect":false},{"pattern":".gnupg","path":".gnupg/secring.gpg","expect":true},{"pattern":".gnupg","path":".gnupg2/pubring.kbx","expect":false},{"pattern":".docker","path":".docker/config.json","expect":true},{"pattern":".docker","path":"docker/Dockerfile","expect":false},{"pattern":".kube","path":".kube/config","expect":true},{"pattern":".kube","path":"kube/deployment.yaml","expect":false},{"pattern":".terraform","path":".terraform/terraform.tfstate","expect":true},{"pattern":".terraform","path":"terraform/main.tf","expect":false},{"pattern":".npmrc","path":".npmrc","expect":true},{"pattern":".npmrc","path":"packages/web/.npmrc","expect":true},{"pattern":".npmrc","path":"npmrc","expect":false},{"pattern":".yarnrc","path":".yarnrc","expect":true},{"pattern":".yarnrc","path":".yarnrc.yml","expect":false},{"pattern":".yarnrc.yml","path":".yarnrc.yml","expect":true},{"pattern":".yarnrc.yml","path":".yarnrc","expect":false},{"pattern":".netrc","path":".netrc","expect":true},{"pattern":".netrc","path":"_netrc","expect":false},{"pattern":"_netrc","path":"_netrc","expect":true},{"pattern":"_netrc","path":".netrc","expect":false},{"pattern":".pypirc","path":"home/.pypirc","expect":true},{"pattern":".pypirc","path":"pypirc","expect":false},{"pattern":".pgpass","path":"home/.pgpass","expect":true},{"pattern":".pgpass","path":"pgpass.conf","expect":false},{"pattern":".my.cnf","path":"home/.my.cnf","expect":true},{"pattern":".my.cnf","path":"my.cnf","expect":false},{"pattern":".htpasswd","path":"etc/nginx/.htpasswd","expect":true},{"pattern":".htpasswd","path":"htpasswd","expect":false},{"pattern":".vault-token","path":"home/.vault-token","expect":true},{"pattern":".vault-token","path":"vault-token","expect":false},{"pattern":"id_rsa*","path":"id_rsa","expect":true},{"pattern":"id_rsa*","path":"keys/id_rsa.pub","expect":true},{"pattern":"id_rsa*","path":"my_id_rsa","expect":false},{"pattern":"id_dsa*","path":"legacy/id_dsa","expect":true},{"pattern":"id_dsa*","path":"my_id_dsa","expect":false},{"pattern":"id_ecdsa*","path":"keys/id_ecdsa-cert.pub","expect":true},{"pattern":"id_ecdsa*","path":"my_id_ecdsa","expect":false},{"pattern":"id_ed25519*","path":"keys/id_ed25519.pub","expect":true},{"pattern":"id_ed25519*","path":"my_id_ed25519","expect":false},{"pattern":"*.pem","path":"tls/fullchain.pem","expect":true},{"pattern":"*.pem","path":"tls/fullchain.pem.bak","expect":false},{"pattern":"*.key","path":"certs/server.key","expect":true},{"pattern":"*.key","path":"certs/server.key.pub","expect":false},{"pattern":"*.p8","path":"apple/AuthKey_123.p8","expect":true},{"pattern":"*.p8","path":"apple/AuthKey_123.p8.txt","expect":false},{"pattern":"*.p12","path":"certs/client.p12","expect":true},{"pattern":"*.p12","path":"certs/client.p12.enc","expect":false},{"pattern":"*.pfx","path":"win/signing.pfx","expect":true},{"pattern":"*.pfx","path":"win/signing.pfx.bak","expect":false},{"pattern":"*.ppk","path":"putty/server.ppk","expect":true},{"pattern":"*.ppk","path":"putty/server.ppk.old","expect":false},{"pattern":"*.jks","path":"java/keystore.jks","expect":true},{"pattern":"*.jks","path":"java/keystore.jks.bak","expect":false},{"pattern":"*.keystore","path":"android/release.keystore","expect":true},{"pattern":"*.keystore","path":"android/keystore.properties","expect":false},{"pattern":"*.kdbx","path":"vault/passwords.kdbx","expect":true},{"pattern":"*.kdbx","path":"vault/passwords.kdbx.html","expect":false},{"pattern":"*credentials*.json","path":"gcp/client_credentials_prod.json","expect":true},{"pattern":"*credentials*.json","path":"credentials.json","expect":true},{"pattern":"*credentials*.json","path":"gcp/credentials.yaml","expect":false},{"pattern":"service-account*.json","path":"gcp/service-account-prod.json","expect":true},{"pattern":"service-account*.json","path":"gcp/my-service-account.json","expect":false},{"pattern":"*.tfstate","path":"infra/terraform.tfstate","expect":true},{"pattern":"*.tfstate","path":"infra/terraform.tfstate.backup","expect":false},{"pattern":"*.tfstate.*","path":"infra/terraform.tfstate.backup","expect":true},{"pattern":"*.tfstate.*","path":"infra/terraform.tfstate","expect":false},{"pattern":"*.tfvars","path":"infra/prod.tfvars","expect":true},{"pattern":"*.tfvars","path":"infra/prod.tfvars.json","expect":false},{"pattern":"*.tfvars.json","path":"infra/prod.tfvars.json","expect":true},{"pattern":"*.tfvars.json","path":"infra/prod.tfvars","expect":false},{"pattern":".*_history","path":"home/.bash_history","expect":true},{"pattern":".*_history","path":"home/.zsh_history","expect":true},{"pattern":".*_history","path":"home/bash_history","expect":false},{"pattern":"fish_history","path":"local/share/fish/fish_history","expect":true},{"pattern":"fish_history","path":"docs/fish_history.md","expect":false},{"pattern":".env*","path":".ENV","expect":true},{"pattern":".env*","path":"docs/.Env.Local","expect":true},{"pattern":"*.pem","path":"TLS/Server.PEM","expect":true},{"pattern":"id_ed25519*","path":"keys/ID_ED25519.PUB","expect":true},{"pattern":".AWS","path":"docs/.aws/credentials","expect":true},{"pattern":"*.KEY","path":"certs/tls.key","expect":true},{"pattern":"secrets","path":"docs/ſecrets/note.md","expect":true},{"pattern":".ssh","path":".ſsh/config","expect":true},{"pattern":"id_rsa*","path":"keys/ıd_rsa","expect":true},{"pattern":".env*","path":"docs/.env","expect":true},{"pattern":".ssh","path":".ssh/config","expect":true},{"pattern":"*.key","path":"tls/server.Key","expect":true},{"pattern":".ENV*","path":"apps/.env.local","expect":true},{"pattern":".env*","path":"docs\.env","expect":true},{"pattern":".env*","path":"docs/.env","expect":true},{"pattern":".env*","path":"%2eenv","expect":true},{"pattern":".env*","path":"%2E%45%4E%56","expect":true},{"pattern":".ssh","path":"docs/%2essh/config","expect":true},{"pattern":".env*","path":"%252eenv","expect":true},{"pattern":".aws","path":"docs/%252Eaws/credentials","expect":true},{"pattern":"*.pem","path":"certs/root%252Epem","expect":true},{"pattern":".env*","path":"%25252eenv","expect":true},{"pattern":".gnupg","path":"home/%25252Egnupg/key","expect":true},{"pattern":"id_rsa*","path":"keys/%252569d_rsa","expect":true},{"pattern":".env*","path":"docs%2f.env","expect":true},{"pattern":".ssh","path":"docs%252f.ssh%252fconfig","expect":true},{"pattern":".aws","path":"docs%25255c.aws%25255ccredentials","expect":true},{"pattern":".env*","path":"docs/%EF%BC%8Eenv","expect":true},{"pattern":".env*","path":"docs/%25EF%25BC%258Eenv","expect":true},{"pattern":".env*","path":".env.%ZZlocal","expect":true},{"pattern":".env*","path":"%2eenv.%ZZ","expect":true},{"pattern":".env*","path":"%2eenv.trail%","expect":true},{"pattern":".env*","path":"%2eenv.short%2","expect":true},{"pattern":"secrets","path":"secrets%2F%ZZ","expect":true},{"pattern":".env*","path":"%FF/.env","expect":true},{"pattern":".env*","path":"%ZZenv","expect":false},{"pattern":".env*","path":"%2Genv","expect":false},{"pattern":"*credentials*.json","path":"my-credentials\\\\backup.json","expect":true},{"pattern":"*credentials*.json","path":"my-credentials%5Cbackup.json","expect":true},{"pattern":".env*","path":"apps\\\\backend\\\\.env","expect":true},{"pattern":".ssh","path":"C:\\\\Users\\\\example\\\\.ssh\\\\id","expect":true},{"pattern":"*.key","path":"certs\\\\prod/tls.key","expect":true},{"pattern":".env*","path":"///docs///.env///","expect":true},{"pattern":".env*","path":"\\\\\\\\\\\\docs\\\\\\\\\\\\.env\\\\\\\\","expect":true},{"pattern":".env*","path":"","expect":false},{"pattern":".env*","path":"/","expect":false},{"pattern":".env*","path":"\\\\","expect":false},{"pattern":".env.?","path":".env.?","expect":true},{"pattern":".env.?","path":".env.a","expect":false},{"pattern":"file+[1](test)$^|{2}.txt","path":"dir/file+[1](test)$^|{2}.txt","expect":true},{"pattern":"file+[1](test)$^|{2}.txt","path":"dir/file+1(test)$^|{2}.txt","expect":false},{"pattern":"a|b.md","path":"docs/a|b.md","expect":true},{"pattern":"a|b.md","path":"docs/a.md","expect":false},{"pattern":"foo+bar.md","path":"docs/foo+bar.md","expect":true},{"pattern":"foo+bar.md","path":"docs/fooooobar.md","expect":false},{"pattern":"unrelated","path":"docs/safe-%252561-name/readme.md","expect":false},{"pattern":".env","path":"%2525252Eenv","expect":true},{"pattern":".env*","path":"%2525252Eenv","expect":true},{"pattern":".aws","path":"docs/%2525252Eaws/credentials","expect":true},{"pattern":"unrelated","path":"%2525252Eenv","expect":true},{"pattern":"unrelated","path":"docs/%2525252Eaws/credentials","expect":true},{"pattern":"unrelated","path":"docs/safe-%25252561-name/readme.md","expect":true},{"pattern":".env*","path":"%252525252Eenv","expect":true},{"pattern":"unrelated","path":"a/b/%2525252F/c.md","expect":true},{"pattern":"unrelated","path":"a/b/%2525255C..%2525255C/c.md","expect":true},{"pattern":"unrelated","path":"docs/%2525252Eenv%ZZ","expect":true}]'),r=Object.freeze(a.map(({pattern:e,path:t,expect:p})=>Object.freeze({pattern:e,path:t,expect:p}))),n=()=>r;exports.denyVectors=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=JSON.parse('[{"pattern":".env*","path":".env","expect":true},{"pattern":".env*","path":"apps/web/.env.production","expect":true},{"pattern":".env*","path":".envrc","expect":true},{"pattern":".env*","path":".env~","expect":true},{"pattern":".env*","path":".env-old","expect":true},{"pattern":".env*","path":".env_backup","expect":true},{"pattern":".env*","path":"docs/environment.md","expect":false},{"pattern":".env*","path":"docs/prod.env","expect":false},{"pattern":"*.env","path":"prod.env","expect":true},{"pattern":"*.env","path":"config/staging.env","expect":true},{"pattern":"*.env","path":"prod.env.bak","expect":false},{"pattern":"*.env","path":"environment.md","expect":false},{"pattern":"*.env.*","path":"prod.env.bak","expect":true},{"pattern":"*.env.*","path":"config/deploy.env.production","expect":true},{"pattern":"*.env.*","path":"prod.env","expect":false},{"pattern":"*.env.*","path":"prod.environment.md","expect":false},{"pattern":"*.env~*","path":"prod.env~","expect":true},{"pattern":"*.env~*","path":"config/prod.env~1","expect":true},{"pattern":"*.env~*","path":"prod.env","expect":false},{"pattern":"*.env-*","path":"prod.env-old","expect":true},{"pattern":"*.env-*","path":"config/app.env-2026","expect":true},{"pattern":"*.env-*","path":"my-env-file.md","expect":false},{"pattern":"*.env_*","path":"prod.env_backup","expect":true},{"pattern":"*.env_*","path":"config/app.env_local","expect":true},{"pattern":"*.env_*","path":"my_env_file.md","expect":false},{"pattern":"*.env#*","path":"#prod.env#","expect":true},{"pattern":"*.env#*","path":"config/prod.env#1","expect":true},{"pattern":"*.env#*","path":"prod.env","expect":false},{"pattern":".git","path":".git/config","expect":true},{"pattern":".git","path":"sub/.git/HEAD","expect":true},{"pattern":".git","path":".github/workflows/ci.yml","expect":false},{"pattern":".git","path":".gitignore","expect":false},{"pattern":".git-credentials","path":".git-credentials","expect":true},{"pattern":".git-credentials","path":"home/.git-credentials","expect":true},{"pattern":".git-credentials","path":"git-credentials","expect":false},{"pattern":".svn","path":".svn/entries","expect":true},{"pattern":".svn","path":"svn/entries","expect":false},{"pattern":".hg","path":".hg/hgrc","expect":true},{"pattern":".hg","path":".hgignore","expect":false},{"pattern":"node_modules","path":"node_modules/pkg/index.js","expect":true},{"pattern":"node_modules","path":"packages/a/node_modules/b/README.md","expect":true},{"pattern":"node_modules","path":"docs/node_modules_guide.md","expect":false},{"pattern":"secrets","path":"secrets/api.md","expect":true},{"pattern":"secrets","path":"config/secrets/prod.json","expect":true},{"pattern":"secrets","path":"docs/secrets-overview.md","expect":false},{"pattern":".secrets","path":".secrets/key","expect":true},{"pattern":".secrets","path":"app/.secrets","expect":true},{"pattern":".secrets","path":".secrets.md","expect":false},{"pattern":"secrets.json","path":"secrets.json","expect":true},{"pattern":"secrets.json","path":"config/secrets.json","expect":true},{"pattern":"secrets.json","path":"my-secrets.json","expect":false},{"pattern":"secrets.yml","path":"config/secrets.yml","expect":true},{"pattern":"secrets.yml","path":"secrets.yaml","expect":false},{"pattern":"secrets.yaml","path":"config/secrets.yaml","expect":true},{"pattern":"secrets.yaml","path":"secrets.yml","expect":false},{"pattern":"secrets.toml","path":"config/secrets.toml","expect":true},{"pattern":"secrets.toml","path":"secrets.toml.example","expect":false},{"pattern":"secrets.ini","path":"config/secrets.ini","expect":true},{"pattern":"secrets.ini","path":"app.ini","expect":false},{"pattern":"secrets.txt","path":"notes/secrets.txt","expect":true},{"pattern":"secrets.txt","path":"secrets.txt.bak","expect":false},{"pattern":".ssh","path":".ssh/id_rsa","expect":true},{"pattern":".ssh","path":"home/user/.ssh/config","expect":true},{"pattern":".ssh","path":".ssh_config","expect":false},{"pattern":".aws","path":".aws/credentials","expect":true},{"pattern":".aws","path":"home/user/.aws/config","expect":true},{"pattern":".aws","path":".aws-sam/build.toml","expect":false},{"pattern":".gnupg","path":".gnupg/secring.gpg","expect":true},{"pattern":".gnupg","path":".gnupg2/pubring.kbx","expect":false},{"pattern":".docker","path":".docker/config.json","expect":true},{"pattern":".docker","path":"docker/Dockerfile","expect":false},{"pattern":".kube","path":".kube/config","expect":true},{"pattern":".kube","path":"kube/deployment.yaml","expect":false},{"pattern":".terraform","path":".terraform/terraform.tfstate","expect":true},{"pattern":".terraform","path":"terraform/main.tf","expect":false},{"pattern":".npmrc","path":".npmrc","expect":true},{"pattern":".npmrc","path":"packages/web/.npmrc","expect":true},{"pattern":".npmrc","path":"npmrc","expect":false},{"pattern":".yarnrc","path":".yarnrc","expect":true},{"pattern":".yarnrc","path":".yarnrc.yml","expect":false},{"pattern":".yarnrc.yml","path":".yarnrc.yml","expect":true},{"pattern":".yarnrc.yml","path":".yarnrc","expect":false},{"pattern":".netrc","path":".netrc","expect":true},{"pattern":".netrc","path":"_netrc","expect":false},{"pattern":"_netrc","path":"_netrc","expect":true},{"pattern":"_netrc","path":".netrc","expect":false},{"pattern":".pypirc","path":"home/.pypirc","expect":true},{"pattern":".pypirc","path":"pypirc","expect":false},{"pattern":".pgpass","path":"home/.pgpass","expect":true},{"pattern":".pgpass","path":"pgpass.conf","expect":false},{"pattern":".my.cnf","path":"home/.my.cnf","expect":true},{"pattern":".my.cnf","path":"my.cnf","expect":false},{"pattern":".htpasswd","path":"etc/nginx/.htpasswd","expect":true},{"pattern":".htpasswd","path":"htpasswd","expect":false},{"pattern":".vault-token","path":"home/.vault-token","expect":true},{"pattern":".vault-token","path":"vault-token","expect":false},{"pattern":"id_rsa*","path":"id_rsa","expect":true},{"pattern":"id_rsa*","path":"keys/id_rsa.pub","expect":true},{"pattern":"id_rsa*","path":"my_id_rsa","expect":false},{"pattern":"id_dsa*","path":"legacy/id_dsa","expect":true},{"pattern":"id_dsa*","path":"my_id_dsa","expect":false},{"pattern":"id_ecdsa*","path":"keys/id_ecdsa-cert.pub","expect":true},{"pattern":"id_ecdsa*","path":"my_id_ecdsa","expect":false},{"pattern":"id_ed25519*","path":"keys/id_ed25519.pub","expect":true},{"pattern":"id_ed25519*","path":"my_id_ed25519","expect":false},{"pattern":"*.pem","path":"tls/fullchain.pem","expect":true},{"pattern":"*.pem","path":"tls/fullchain.pem.bak","expect":false},{"pattern":"*.key","path":"certs/server.key","expect":true},{"pattern":"*.key","path":"certs/server.key.pub","expect":false},{"pattern":"*.p8","path":"apple/AuthKey_123.p8","expect":true},{"pattern":"*.p8","path":"apple/AuthKey_123.p8.txt","expect":false},{"pattern":"*.p12","path":"certs/client.p12","expect":true},{"pattern":"*.p12","path":"certs/client.p12.enc","expect":false},{"pattern":"*.pfx","path":"win/signing.pfx","expect":true},{"pattern":"*.pfx","path":"win/signing.pfx.bak","expect":false},{"pattern":"*.ppk","path":"putty/server.ppk","expect":true},{"pattern":"*.ppk","path":"putty/server.ppk.old","expect":false},{"pattern":"*.jks","path":"java/keystore.jks","expect":true},{"pattern":"*.jks","path":"java/keystore.jks.bak","expect":false},{"pattern":"*.keystore","path":"android/release.keystore","expect":true},{"pattern":"*.keystore","path":"android/keystore.properties","expect":false},{"pattern":"*.kdbx","path":"vault/passwords.kdbx","expect":true},{"pattern":"*.kdbx","path":"vault/passwords.kdbx.html","expect":false},{"pattern":"*credentials*.json","path":"gcp/client_credentials_prod.json","expect":true},{"pattern":"*credentials*.json","path":"credentials.json","expect":true},{"pattern":"*credentials*.json","path":"gcp/credentials.yaml","expect":false},{"pattern":"service-account*.json","path":"gcp/service-account-prod.json","expect":true},{"pattern":"service-account*.json","path":"gcp/my-service-account.json","expect":false},{"pattern":"*.tfstate","path":"infra/terraform.tfstate","expect":true},{"pattern":"*.tfstate","path":"infra/terraform.tfstate.backup","expect":false},{"pattern":"*.tfstate.*","path":"infra/terraform.tfstate.backup","expect":true},{"pattern":"*.tfstate.*","path":"infra/terraform.tfstate","expect":false},{"pattern":"*.tfvars","path":"infra/prod.tfvars","expect":true},{"pattern":"*.tfvars","path":"infra/prod.tfvars.json","expect":false},{"pattern":"*.tfvars.json","path":"infra/prod.tfvars.json","expect":true},{"pattern":"*.tfvars.json","path":"infra/prod.tfvars","expect":false},{"pattern":".*_history","path":"home/.bash_history","expect":true},{"pattern":".*_history","path":"home/.zsh_history","expect":true},{"pattern":".*_history","path":"home/bash_history","expect":false},{"pattern":"fish_history","path":"local/share/fish/fish_history","expect":true},{"pattern":"fish_history","path":"docs/fish_history.md","expect":false},{"pattern":".env*","path":".ENV","expect":true},{"pattern":".env*","path":"docs/.Env.Local","expect":true},{"pattern":"*.pem","path":"TLS/Server.PEM","expect":true},{"pattern":"id_ed25519*","path":"keys/ID_ED25519.PUB","expect":true},{"pattern":".AWS","path":"docs/.aws/credentials","expect":true},{"pattern":"*.KEY","path":"certs/tls.key","expect":true},{"pattern":"secrets","path":"docs/ſecrets/note.md","expect":true},{"pattern":".ssh","path":".ſsh/config","expect":true},{"pattern":"id_rsa*","path":"keys/ıd_rsa","expect":true},{"pattern":".env*","path":"docs/.env","expect":true},{"pattern":".ssh","path":".ssh/config","expect":true},{"pattern":"*.key","path":"tls/server.Key","expect":true},{"pattern":".ENV*","path":"apps/.env.local","expect":true},{"pattern":".env*","path":"docs\.env","expect":true},{"pattern":".env*","path":"docs/.env","expect":true},{"pattern":".env*","path":"%2eenv","expect":true},{"pattern":".env*","path":"%2E%45%4E%56","expect":true},{"pattern":".ssh","path":"docs/%2essh/config","expect":true},{"pattern":".env*","path":"%252eenv","expect":true},{"pattern":".aws","path":"docs/%252Eaws/credentials","expect":true},{"pattern":"*.pem","path":"certs/root%252Epem","expect":true},{"pattern":".env*","path":"%25252eenv","expect":true},{"pattern":".gnupg","path":"home/%25252Egnupg/key","expect":true},{"pattern":"id_rsa*","path":"keys/%252569d_rsa","expect":true},{"pattern":".env*","path":"docs%2f.env","expect":true},{"pattern":".ssh","path":"docs%252f.ssh%252fconfig","expect":true},{"pattern":".aws","path":"docs%25255c.aws%25255ccredentials","expect":true},{"pattern":".env*","path":"docs/%EF%BC%8Eenv","expect":true},{"pattern":".env*","path":"docs/%25EF%25BC%258Eenv","expect":true},{"pattern":".env*","path":".env.%ZZlocal","expect":true},{"pattern":".env*","path":"%2eenv.%ZZ","expect":true},{"pattern":".env*","path":"%2eenv.trail%","expect":true},{"pattern":".env*","path":"%2eenv.short%2","expect":true},{"pattern":"secrets","path":"secrets%2F%ZZ","expect":true},{"pattern":".env*","path":"%FF/.env","expect":true},{"pattern":".env*","path":"%ZZenv","expect":false},{"pattern":".env*","path":"%2Genv","expect":false},{"pattern":"*credentials*.json","path":"my-credentials\\\\backup.json","expect":true},{"pattern":"*credentials*.json","path":"my-credentials%5Cbackup.json","expect":true},{"pattern":".env*","path":"apps\\\\backend\\\\.env","expect":true},{"pattern":".ssh","path":"C:\\\\Users\\\\example\\\\.ssh\\\\id","expect":true},{"pattern":"*.key","path":"certs\\\\prod/tls.key","expect":true},{"pattern":".env*","path":"///docs///.env///","expect":true},{"pattern":".env*","path":"\\\\\\\\\\\\docs\\\\\\\\\\\\.env\\\\\\\\","expect":true},{"pattern":".env*","path":"","expect":false},{"pattern":".env*","path":"/","expect":false},{"pattern":".env*","path":"\\\\","expect":false},{"pattern":".env.?","path":".env.?","expect":true},{"pattern":".env.?","path":".env.a","expect":false},{"pattern":"file+[1](test)$^|{2}.txt","path":"dir/file+[1](test)$^|{2}.txt","expect":true},{"pattern":"file+[1](test)$^|{2}.txt","path":"dir/file+1(test)$^|{2}.txt","expect":false},{"pattern":"a|b.md","path":"docs/a|b.md","expect":true},{"pattern":"a|b.md","path":"docs/a.md","expect":false},{"pattern":"foo+bar.md","path":"docs/foo+bar.md","expect":true},{"pattern":"foo+bar.md","path":"docs/fooooobar.md","expect":false},{"pattern":"unrelated","path":"docs/safe-%252561-name/readme.md","expect":false},{"pattern":".env","path":"%2525252Eenv","expect":true},{"pattern":".env*","path":"%2525252Eenv","expect":true},{"pattern":".aws","path":"docs/%2525252Eaws/credentials","expect":true},{"pattern":"unrelated","path":"%2525252Eenv","expect":true},{"pattern":"unrelated","path":"docs/%2525252Eaws/credentials","expect":true},{"pattern":"unrelated","path":"docs/safe-%25252561-name/readme.md","expect":true},{"pattern":".env*","path":"%252525252Eenv","expect":true},{"pattern":"unrelated","path":"a/b/%2525252F/c.md","expect":true},{"pattern":"unrelated","path":"a/b/%2525255C..%2525255C/c.md","expect":true},{"pattern":"unrelated","path":"docs/%2525252Eenv%ZZ","expect":true}]'),r=[{written:"7K3M9QX2AB4W",canonical:"7K3M9QX2AB4W"},{written:"1A0B1C0D1E0J",canonical:"1A0B1C0D1E0J"},{written:"000000000000",canonical:"000000000000"},{written:"0000000000ZZ",canonical:"0000000000ZZ"},{written:"7K3M-9QX2-AB4W",canonical:"7K3M9QX2AB4W"},{written:"7k3m-9qx2-ab4w",canonical:"7K3M9QX2AB4W"},{written:"-7K3M--9QX2-AB4W-",canonical:"7K3M9QX2AB4W"},{written:"lAoB-iCoD-lEoj",canonical:"1A0B1C0D1E0J"},{written:"7K3M9RX2AB4W",canonical:null},{written:"7KM39QX2AB4W",canonical:null},{written:"ZZZZZZZZZZZ$",canonical:null},{written:"00000000014U",canonical:null},{written:"7K3M9QX2AB4",canonical:null},{written:"7K3M9QX2AB4WX",canonical:null},{written:"",canonical:null},{written:"----",canonical:null},{written:"7K3M 9QX2 AB4W",canonical:null},{written:"7K3M9QX2AB4W",canonical:null},{written:"ıA0B1C0D1E0J",canonical:null}],n=Object.freeze(a.map(({pattern:e,path:t,expect:p})=>Object.freeze({pattern:e,path:t,expect:p}))),c=Object.freeze(r.map(({written:e,canonical:t})=>Object.freeze({written:e,canonical:t}))),s=()=>n,h=()=>c;exports.denyVectors=s;exports.documentIdVectors=h;
@@ -3,4 +3,9 @@ export type DenyVector = {
3
3
  readonly path: string;
4
4
  readonly expect: boolean;
5
5
  };
6
+ export type DocumentIdVector = {
7
+ readonly written: string;
8
+ readonly canonical: string | null;
9
+ };
6
10
  export declare const denyVectors: () => readonly DenyVector[];
11
+ export declare const documentIdVectors: () => readonly DocumentIdVector[];