@aiquants/markdown-explorer 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +795 -0
- package/README.md +119 -55
- package/dist/EditSurface-CLG70Vnn.cjs +6 -0
- package/dist/EditSurface-D2j1kCEE.js +990 -0
- package/dist/ExplorerSplit-CfP1smbT.js +1589 -0
- package/dist/ExplorerSplit-D_0VohOv.cjs +2 -0
- package/dist/{MultiLayout-DYNGlNy0.js → MultiLayout-BeJ5Lubb.js} +291 -290
- package/dist/MultiLayout-CxV5SI7f.cjs +1 -0
- package/dist/NativeScrollBar-BM5NULzg.js +62 -0
- package/dist/NativeScrollBar-RWXpVhbI.cjs +1 -0
- package/dist/TreeLayout-AxLw-36S.js +103 -0
- package/dist/TreeLayout-Bg2YH-EY.cjs +1 -0
- package/dist/client/MarkdownExplorer.d.cts +14 -1
- package/dist/client/MarkdownExplorer.d.ts +14 -1
- package/dist/client/edit/lineEndings.d.cts +4 -0
- package/dist/client/edit/lineEndings.d.ts +4 -0
- package/dist/client/hostContract.d.cts +67 -0
- package/dist/client/hostContract.d.ts +67 -0
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +10 -4
- package/dist/core/contracts.d.ts +10 -4
- package/dist/core/draftAnswer.d.cts +23 -0
- package/dist/core/draftAnswer.d.ts +23 -0
- package/dist/core/geometry.d.cts +1 -0
- package/dist/core/geometry.d.ts +1 -0
- package/dist/core/labels.d.cts +78 -0
- package/dist/core/labels.d.ts +78 -0
- package/dist/core/location.d.cts +3 -2
- package/dist/core/location.d.ts +3 -2
- package/dist/core/ownUrls.d.cts +15 -0
- package/dist/core/ownUrls.d.ts +15 -0
- package/dist/core/treeSettings.d.cts +3 -2
- package/dist/core/treeSettings.d.ts +3 -2
- package/dist/core/viewSettings.d.cts +5 -1
- package/dist/core/viewSettings.d.ts +5 -1
- package/dist/describeValue-CLlVRO8d.js +17 -0
- package/dist/describeValue-Ccvhbt36.cjs +1 -0
- package/dist/explorerCore-DLpDuSev.js +998 -0
- package/dist/explorerCore-DYrxS9ez.cjs +1 -0
- package/dist/index-C1YMH-yI.js +5816 -0
- package/dist/index-LQWQfpAf.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +47 -42
- package/dist/licenses/@heroicons/react/LICENSE +21 -0
- package/dist/licenses/entities/LICENSE +11 -0
- package/dist/licenses/parse5/LICENSE +19 -0
- package/dist/location--KvTA0Ri.js +726 -0
- package/dist/location-D8DyDkuA.cjs +1 -0
- package/dist/lru-DC8GBmkX.js +39 -0
- package/dist/lru-SGmUyBQU.cjs +1 -0
- package/dist/{merge-D7L_pINl.js → merge-Bb_HpPhe.js} +1 -1
- package/dist/{merge-DZI4pkWI.cjs → merge-DQUYEGCx.cjs} +1 -1
- package/dist/nestingGuardWorker.js +5511 -0
- package/dist/ownUrls-B259RGgd.cjs +1 -0
- package/dist/ownUrls-Dh5g6ZJi.js +370 -0
- package/dist/sanitizeJob-BYRk17nr.js +21 -0
- package/dist/sanitizeJob-Cs9o3Vpl.cjs +1 -0
- package/dist/sanitizePolicy-CEMdaLUB.js +139 -0
- package/dist/sanitizePolicy-CiQfnxyd.cjs +2 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +134 -139
- package/dist/sanitizerService-BY4CPCoA.cjs +1 -0
- package/dist/sanitizerService-KWXv7bPm.js +240 -0
- package/dist/server/assetResponse.d.cts +60 -0
- package/dist/server/assetResponse.d.ts +60 -0
- package/dist/server/browser/browserPlatform.d.cts +12 -0
- package/dist/server/browser/browserPlatform.d.ts +12 -0
- package/dist/server/createMarkdownExplorer.d.cts +0 -10
- package/dist/server/createMarkdownExplorer.d.ts +0 -10
- package/dist/server/explorerCore.d.cts +12 -0
- package/dist/server/explorerCore.d.ts +12 -0
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/inProcessFetch.d.cts +5 -0
- package/dist/server/inProcessFetch.d.ts +5 -0
- package/dist/server/platform.d.cts +18 -0
- package/dist/server/platform.d.ts +18 -0
- package/dist/server/ports.d.cts +36 -5
- package/dist/server/ports.d.ts +36 -5
- package/dist/server/sanitizeProtocol.d.cts +3 -0
- package/dist/server/sanitizeProtocol.d.ts +3 -0
- package/dist/server/sanitizer.d.cts +5 -40
- package/dist/server/sanitizer.d.ts +5 -40
- package/dist/server/sanitizerOptions.d.cts +24 -0
- package/dist/server/sanitizerOptions.d.ts +24 -0
- package/dist/server/sanitizerService.d.cts +41 -0
- package/dist/server/sanitizerService.d.ts +41 -0
- package/dist/server/{workerPool.d.cts → workerJobs.d.cts} +0 -16
- package/dist/server/{workerPool.d.ts → workerJobs.d.ts} +0 -16
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +270 -1343
- package/dist/serverBrowser.cjs +1 -0
- package/dist/serverBrowser.d.cts +1 -0
- package/dist/serverBrowser.d.ts +1 -0
- package/dist/serverBrowser.js +120 -0
- package/dist/serverCore.cjs +1 -0
- package/dist/serverCore.d.cts +14 -0
- package/dist/serverCore.d.ts +14 -0
- package/dist/serverCore.js +46 -0
- package/dist/storage-BpYsprog.cjs +1 -0
- package/dist/{storage-CmGHg7OA.js → storage-D1uSw-xj.js} +19 -18
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/tapScrollCircle-BEydRn0y.js +14 -0
- package/dist/tapScrollCircle-DdX0Wri0.cjs +1 -0
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +6 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +4 -0
- package/dist/useSplitPersistence-B2Fj508K.cjs +1 -0
- package/dist/useSplitPersistence-Fkqak8G8.js +44 -0
- package/docs/behavior/dom-hooks.md +14 -3
- package/docs/behavior/hosting.md +123 -0
- package/docs/behavior/layout.md +69 -19
- package/docs/behavior/localization.md +28 -10
- package/docs/behavior/security.md +34 -14
- package/docs/behavior/url-contract.md +13 -6
- package/package.json +54 -16
- package/dist/EditSurface-BPqqykro.cjs +0 -6
- package/dist/EditSurface-CWq35IWQ.js +0 -972
- package/dist/ExplorerSplit-BRY4uy6x.js +0 -1493
- package/dist/ExplorerSplit-CQxr6b0v.cjs +0 -1
- package/dist/MultiLayout-TXbet9k3.cjs +0 -1
- package/dist/NativeScrollBar-BsWdvkHa.js +0 -64
- package/dist/NativeScrollBar-UpjxjLlB.cjs +0 -1
- package/dist/TreeLayout-BQEgZhz9.js +0 -72
- package/dist/TreeLayout-C0O1OGi4.cjs +0 -1
- package/dist/dataRoute-DLhQfdoW.js +0 -298
- package/dist/dataRoute-DwYtgyt6.cjs +0 -1
- package/dist/index-CO-RgTml.js +0 -4912
- package/dist/index-DSkK8iLE.cjs +0 -15
- package/dist/location-BxiJRTyw.cjs +0 -1
- package/dist/location-perTmwct.js +0 -663
- package/dist/sanitizePolicy-By0tKOpZ.js +0 -98
- package/dist/sanitizePolicy-T5T-3vV5.cjs +0 -1
- package/dist/storage-DM0EvkVf.cjs +0 -1
- package/dist/tapScrollCircle-CRKZremf.js +0 -12
- package/dist/tapScrollCircle-Cbf17x8g.cjs +0 -1
- package/dist/useSplitPersistence-Du01PHNg.js +0 -42
- package/dist/useSplitPersistence-pPmE4GTT.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),Y=require("./describeValue-Ccvhbt36.cjs"),j=require("./location-D8DyDkuA.cjs"),P=require("./index-LQWQfpAf.cjs"),re=require("./ExplorerSplit-D_0VohOv.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-BpYsprog.cjs"),Ce=require("./ownUrls-B259RGgd.cjs"),qe=require("react-dom"),Be=require("@aiquants/markdown"),je=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Oe=c.createContext(null),ie=()=>{const e=c.use(Oe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Fe=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ve=0xcbf29ce484222325n,Ue=0x100000001b3n,$e=(1n<<64n)-1n,Ge=(1n<<53n)-1n,Ye=new TextEncoder,We=e=>{let n=Ve;for(const t of Ye.encode(e))n=(n^BigInt(t))*Ue&$e;return Number(n&Ge)},Q=256,Ke=e=>`aqmx-p-${We(e).toString(36)}`,be=(e,n)=>{const t=Ke(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Je=new Map,Xe=(e,n=Je)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??be(r,t);t.add(s),o.set(r,s)}return o},Pe=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Te=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([m,g])=>e.slice(m,g).reduce((i,v)=>i+v.length,0);let s=t;for(const m of o)r(m)<r(s)&&(s=m);let a=s[0];for(let m=s[0];m<s[1];m+=1)(e[m]?.length??0)<(e[a]?.length??0)&&(a=m);return a},ee=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Pe(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Te(t,n)]?.push(r);return t},Ze=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Qe=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(y,d)=>{const x=[0];for(const h of e)x.push((x.at(-1)??0)+(t(h)===o+d?1:0));return x}),g=(y,d,x)=>(m[y]?.[x]??0)-(m[y]?.[d]??0),i=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),v=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),C=i[0];C&&(C[0]=0);for(let y=0;y<s;y+=1)for(let d=0;d<=a;d+=1)for(let x=0;x<=d;x+=1){const h=(i[y]?.[x]??Number.NEGATIVE_INFINITY)+g(y,x,d),O=i[y+1],L=v[y+1];O&&L&&h>(O[d]??Number.NEGATIVE_INFINITY)&&(O[d]=h,L[d]=x)}const T=Array.from({length:s},()=>[]);let A=a;for(let y=s;y>0;y-=1){const d=v[y]?.[A]??0;T[y-1]=e.slice(d,A),A=d}return T},Le=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},en=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=ee(e,t),s=Pe(e,n,t.logical)??Te(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,be(n,new Set(a.values()))),{state:{...e,...Le(e,r),panelIds:a},outcome:"opened"}},Me=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},nn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Me(e,n),outcome:"closed"};const r=en(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},tn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);a.delete(n),a.set(t,m);const g=new Set(e.markup);return g.delete(n),{state:{docs:e.docs.map(i=>i===n?t:i),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:g,panelIds:a},outcome:"navigated"}},ke=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},on=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},rn=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},sn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[i,v]of o.entries())for(const C of v)r.set(C,i);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),g=Array.from({length:t.logical},()=>[]);for(const[i,v]of m.entries()){const C=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of C)a.add(T);for(const[T,A]of Qe(C,v,y=>r.get(y)).entries())g[v[0]+T]?.push(...A)}for(const i of e.docs)a.has(i)||g[r.get(i)??0]?.push(i);return g.every((i,v)=>i.length===o[v]?.length&&i.every((C,T)=>o[v]?.[T]===C))?e:{...e,...Le(e,g)}},te=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Xe(t,e.panelIds)}},pe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of ee(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Q)break;t.delete(o)}return{...e,columnOf:t}},Re=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),ln=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Re)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Q))Array.isArray(a)&&a.length===2&&typeof a[0]=="string"&&a[0]!==""&&Number.isInteger(a[1])&&a[1]>=0&&a[1]<n&&(r.delete(a[0]),r.set(a[0],a[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(a=>typeof a=="string"&&a!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Re,columnOf:[...e.columnOf.entries()].slice(-Q),hidden:e.docs.filter(n=>e.hidden.has(n))}),ae=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},W=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},ge=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${Y.describeValue(e)}`)},cn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=P.createEmitter(),m=new Map,g=new Map;let i={layout:te({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},v=!1;const C=l=>v?pe(l,{logical:s,visible:i.visibleColumns}):l,T=(l,S)=>j.explorerHref(e,{view:"multi",source:l,docs:S.docs,maximized:S.maximized,markup:S.markup}),A=l=>({docs:l.docs,maximized:l.maximized,markup:[...l.markup]});let y=T(n.source,n),d=n.source,x=y;const h=[],O=[];let L=null;const N=()=>{if(!(h.length>0))for(const l of O.splice(0))l()},R=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=an(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==y&&(y=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const E of[...m.keys()])S.has(E)||m.delete(E);for(const E of[...g.keys()])S.has(E)||g.delete(E);const b=new Set(l.docs),I=[...i.titles.keys()].every(E=>b.has(E))?i.titles:new Map([...i.titles].filter(([E])=>b.has(E))),w=[...i.pendingHashes.keys()].every(E=>S.has(E))?i.pendingHashes:new Map([...i.pendingHashes].filter(([E])=>S.has(E)));return{titles:I,pendingHashes:w}},M=l=>l===i.layout?!1:(R({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{ge(l);const{state:S,outcome:b}=nn(i.layout,l,_(),r);return M(S),b},close:l=>M(Me(i.layout,l)),navigate:(l,S)=>{ge(S);const{state:b,outcome:I}=tn(i.layout,l,S);if(I!=="navigated")return I;const w=b.panelIds.get(S);return w!==void 0&&(m.delete(w),g.delete(w)),M(b),I},setHidden:(l,S)=>M(ke(i.layout,l,S)),maximize:l=>M(rn(i.layout,l)),setMarkup:(l,S)=>M(on(i.layout,l,S)),arrange:l=>M(sn(i.layout,l,{logical:s,visible:l.length})),changeSource:l=>{p(l,i.layout,"push")},revealSource:l=>{p(l,i.layout,"replace")},observeLocation:l=>{const S=T(l.source,l);if(S===y)return h.length=0,x=S,l.source!==i.source&&R({source:l.source}),N(),!1;if(S===x)return!1;x=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&R({source:l.source}),N(),!1;h.length=0,y=S,d=l.source;const I=C(te({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return R({layout:I,source:l.source,...f(I)}),u(),N(),!0},whenUrlRendered:l=>{O.push(l),N()},loadStored:l=>{R({layout:C(te({docs:i.layout.docs,maximized:i.layout.maximized,markup:[...i.layout.markup],stored:l,panelIds:i.layout.panelIds},r)),ready:!0}),u()},setVisibleColumns:l=>{if(!Number.isInteger(l)||l<1||l>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${Y.describeValue(l)}`);v=!0;const S=pe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(R({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&R({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||R({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ae(i.titles,l),setPendingHash:(l,S)=>{const b=i.pendingHashes.get(l);if(S===null||S===""){if(b===void 0)return;const I=new Map(i.pendingHashes);I.delete(l),R({pendingHashes:I});return}b!==S&&R({pendingHashes:new Map(i.pendingHashes).set(l,S)})},saveReadingPosition:(l,S,b)=>{i.layout.panelIds.get(S)===l&&m.set(l,{doc:S,position:b})},readingPositionOf:(l,S)=>{const b=m.get(l);return b===void 0||b.doc!==S?null:b.position},saveImageView:(l,S,b)=>{g.set(l,{url:S,state:b})},imageViewOf:(l,S)=>{const b=g.get(l);return b===void 0||b.url!==S?null:b.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return c.useSyncExternalStore(e.subscribe,t,t)},un=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=fe.useNavigate(),r=c.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=c.useState(()=>cn({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ne.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(ln(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},dn=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=ie(),{announcer:i}=P.useExplorer(),v=z(s,u=>Fe(u,n)),C=z(s,u=>u.layout.markup.has(e)),T=c.useCallback((u,p)=>a(n,e,u,p),[a,n,e]),A=c.useCallback(()=>s.setPendingHash(n,null),[s,n]),y=c.useMemo(()=>({read:u=>s.imageViewOf(n,u),save:(u,p)=>s.saveImageView(n,u,p)}),[s,n]),d=c.useCallback((u,p)=>{p.kind!=="failure"&&s.setTitle(u,p.name),r(u)},[s,r]),x=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:dn,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),O=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:x,paneScroll:h}),[t,T,v,A,x,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),N=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),R=c.useMemo(()=>({shown:C,toggle:N}),[C,N]);return k.jsxs(P.ImageViewMemoryContext,{value:y,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:R,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:C,variant:O,onDocumentShown:d})]})},he=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",J="data-panel-id",se="--aqmx-multi-panel-chrome",fn=e=>e==="normal"?0:P.cssPixels(e),pn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),a=t.clientWidth-P.cssPixels(s.paddingLeft)-P.cssPixels(s.paddingRight),m=t.clientHeight-P.cssPixels(s.paddingTop)-P.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:a,gap:fn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},gn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+P.cssPixels(t.paddingBottom)+P.cssPixels(t.borderBottomWidth)},X="data-aqmx-panel-frame",Se="--aqmx-multi-panel-pinned-block-size",hn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},xn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),$=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ne=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ae=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},xe=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},yn=(e,n)=>{const t=Ae(e,n),o=[];let r=e;for(let a=xe([...r.children],t);a>=0;a=xe([...r.children],t)){const m=r.children[a];if(m===void 0)break;o.push(a),r=m}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const g of t.anchor.path)o=o?.children[g];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:a}=t.anchor,m=s<0&&a>0?s/a*r.height:s;n.scrollTop+=r.top-Ae(e,n)-m},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ie=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...vn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},wn=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:Ie(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ie(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=xn(e,r,t);(o||On(r,s))&&(e.preventDefault(),r.scrollTop+=s)},On=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,bn=e=>e.scrollHeight>e.clientHeight,Pn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=gn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(Se,`${String(v)}px`));const C=i+v;C!==o&&(o=C,e.style.setProperty(se,`${String(C)}px`))};a();let m=null;const g=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return g?.observe(e),g?.observe(n),s!==null&&g?.observe(s),()=>{g?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(se),t.style.removeProperty(Se)}},Tn=e=>{const{docPath:n,panelId:t}=hn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ae(d.titles,n)),i=c.useRef(null),v=c.useRef(null),C=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null||m)return;const h=new Map,O=p=>{const f=h.get(p);if(f!==void 0)return f;const M=Sn(p);return h.set(p,M),M},L=p=>Cn(p,d,O);let N=!1;const R=()=>{const p=bn(x);p!==N&&(N=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};R();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return u?.observe(x),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d),h=d===null?null:d.closest(`[${J}]`);if(!(d===null||x===null||!(h instanceof HTMLElement)))return Pn(h,x,d)},[]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null)return;const h=p=>{ye(d,x,p),T.current=x.scrollTop},O=o.readingPositionOf(t,n);v.current=O===null?null:{doc:n,position:O},O!==null&&h(O);let L=null,N=d.getBoundingClientRect().width;const R=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&x.scrollTop===p||d.getBoundingClientRect().width!==N)return;const f=C.current;f!==null&&o.saveReadingPosition(t,f,yn(d,x))}))};x.addEventListener("scroll",R,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===N)return;N=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{x.removeEventListener("scroll",R),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:d.closest(`[${J}]`);if(d===null||x===null)return;const h=a.take(t);return h!==null&&En(x,d,h),()=>{const O=wn(x,x.ownerDocument.activeElement);O!==null&&a.hold(t,O)}},[a,t]);const A=c.useCallback(d=>{const x=i.current,h=x===null?null:$(x);if(x===null||h===null)return;const O=C.current;C.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(x,h,L.position),T.current=h.scrollTop):O!==null&&O!==d&&(h.scrollTop=0)},[]),y=c.useCallback(d=>{P.isInFullscreenBlock(d.target)||s(n)},[s,n]);return k.jsx("div",{ref:i,role:"group","aria-label":g,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",...m?P.CONTENT_PANE:{},onDoubleClick:m?void 0:y,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Ln=c.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);return t},ve=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Mn=(e,n)=>{const t=Ze(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},kn=(e,n)=>{const t=W(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Rn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,morePanelActions:e.panelMoreActions,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),Nn="--aqmx-multi-stage-bar-gutter",An=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),In=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),_n=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Dn=e=>k.jsx("div",{..._n,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),zn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:In},renderScrollBar:Dn,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),Hn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ue="--aqmx-stage-block",qn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,jn=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${qn})))`,Fn=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((a,m)=>r[m]===a)})},G=(e,n,t,o)=>{P.stopKeepingInView(e);const r=e.querySelector(`[${J}="${n}"]`);if(!(r instanceof HTMLElement))return;const s=t!==null&&r.contains(t)?t:null,a=[{element:r,boundary:r.closest(D.SCROLL_ROOT_SELECTOR)}];s!==null&&a.push({element:s,boundary:r}),P.keepInView(e,()=>r.isConnected?(r.scrollIntoView(P.NEAREST),s?.isConnected!==!0?r:(o(s),s)):null,a)},Z=e=>{e.scrollIntoView(P.NEAREST)},_e=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,Z),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},we=(e,n)=>{if(!de(e,n))return null;const t=[...e.querySelectorAll(`[${X}]`)].map(a=>a.getAttribute(X)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Ee=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},De=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Vn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&de(o,n)?r:null,Z),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Un=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,g=z(e,w=>w.layout),i=z(e,w=>w.visibleColumns),v=z(e,w=>w.titles),C=z(e,w=>w.layout.maximized!==null||w.splitDragging),[T,A]=c.useState(!1),[y]=c.useState(()=>ve(i)),d=c.useMemo(()=>Rn(o),[o]),x=c.useCallback(w=>{e.arrange(kn(e.getSnapshot().layout,w))},[e]),h=D.useDragDropColumns({initialColumnPanels:y,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:x}),{columnPanels:O,setColumnPanels:L}=h,N=c.useRef(C),R=c.useRef(O);c.useLayoutEffect(()=>{N.current=C,R.current=O},[C,O]);const u=c.useCallback(w=>{const E=n.current;if(E===null)return;const{plan:B,stageBlockSize:H}=pn(E,m);if(Number.isFinite(H)&&H>0&&E.style.setProperty(ue,`${String(H)}px`),N.current&&!w)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let E=null;const B=new ResizeObserver(()=>{E===null&&(E=requestAnimationFrame(()=>{E=null,u(!1)}))}),H=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=w.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),E!==null&&cancelAnimationFrame(E)}},[n,u]),c.useEffect(()=>{C||u(!1)},[C,u]);const p=c.useMemo(()=>T?Mn(g,{logical:m,visible:i}):ve(i),[T,g,m,i]);c.useLayoutEffect(()=>{Fn(R.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),M=c.useMemo(()=>g.docs.map(w=>{const E=K(g,w);return{id:E,component:Ln,title:ae(v,w),props:{docPath:w,panelId:E},minHeight:Bn,maxHeight:jn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(w=>[K(g,w),!g.hidden.has(w)])),[g]),l=g.maximized===null?null:K(g,g.maximized),S=c.useCallback(w=>{const{layout:E}=e.getSnapshot();for(const[B,H]of W(E)){const q=w[B];if(q===void 0||q!==E.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),De(n,B);continue}const V=n.current,me=V===null?null:we(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),me!==null&&Ee(n,me))}},[e,n,r,o]),b=c.useCallback(w=>{const E=W(e.getSnapshot().layout).get(w);if(E===void 0)return;const B=()=>{const q=e.titleOf(E),F=n.current,V=F===null?null:we(F,w);e.close(E)&&(r.announce(o.panelClosed(q)),V!==null&&Ee(n,V))},H=s.unsavedAmong([E]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),I=c.useCallback(w=>{if(w===null){a(null);return}const E=W(e.getSnapshot().layout).get(w);E!==void 0&&a(E)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:O,onColumnPanelsChange:x,panelVisibility:_,onPanelVisibilityChange:S,dragState:h.dragState,dragOverPosition:h.dragOverPosition,originalPanelPosition:h.originalPanelPosition,dragModes:h.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:h.panelSizes,customDrag:h.customDrag,setPanelRef:h.setPanelRef,onDragStart:h.handleDragStart,onDragEnd:h.handleDragEnd,onPlaceholderDragEnter:h.handlePlaceholderDragEnter,onPlaceholderDragLeave:h.handlePlaceholderDragLeave,onDragOverWithInsert:h.handleDragOverWithInsert,onDropWithInsert:h.handleDropWithInsert,onColumnDragLeave:h.handleColumnDragLeave,onPanelMouseDown:h.handleMouseDown,onPanelSizeInfoClick:h.handlePanelSizeInfoClick,onToggleDragMode:h.toggleDragMode,onPanelClose:b,onPanelMaximizeChange:I,maximizedPanel:l,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:zn,renderStageScrollBar:Hn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},$n=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(a=>{const m=n.ownerDocument.elementsFromPoint(s,a),g=m.findIndex(v=>n.contains(v)),i=m.findIndex(v=>e.contains(v));return g!==-1&&i!==-1&&i<g}))},Gn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(oe.blockStart,`${String(t.top)}px`),e.style.setProperty(oe.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(oe.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Yn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:g}=P.useExplorer(),i=c.useRef(null),v=c.useRef(null),C=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),y=c.use(re.SheetNoticeSlotContext),d=c.useCallback(u=>{const{layout:p}=e.getSnapshot(),f=p.maximized,M=u===null&&f!==null?p.panelIds.get(f):void 0,_=i.current,l=M!==void 0&&_!==null&&de(_,M);e.maximize(u)&&(u!==null?m.announce(a.panelMaximized(e.titleOf(u))):f!==null&&m.announce(a.panelRestored(e.titleOf(f))),M!==void 0&&Vn(i,M,l))},[e,m,a]),x=c.useCallback((u,p,f,M)=>{if(f===p){e.setPendingHash(u,M);return}const _=g.unsavedAmong([p]);if(_.length>0){g.askToDiscard(_).then(I=>{I&&x(u,p,f,M)});return}const l=e.navigate(p,f);if(l==="navigated"){e.setPendingHash(u,M);return}if(l!=="existing")return;const{layout:S}=e.getSnapshot(),b=S.panelIds.get(f);b!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(f))),S.maximized===null?e.setHidden(f,!1):d(f),e.setPendingHash(b,M),De(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||y!==null||!he())return;const u=v.current,p=i.current;if(u===null||p===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Gn(u,p)},[t,y]),c.useEffect(()=>{const u=v.current;if(t===null||u===null)return;const{ownerDocument:p}=u;let f=null;const M=_=>{const l=_.target;l instanceof Element&&(f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,p.activeElement===l&&u.isConnected&&$n(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,y,o]),c.useImperativeHandle(r,()=>({bringIntoView:u=>{requestAnimationFrame(()=>{const p=i.current,f=e.getSnapshot().layout.panelIds.get(u);p!==null&&f!==void 0&&G(p,f,null,Z)})}}),[e]),c.useEffect(()=>{const u=i.current;return()=>{u!==null&&P.stopKeepingInView(u)}},[]);const h=c.useCallback((u,p)=>{const f=i.current;f!==null&&G(f,u,p,Z)},[]),O=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(je),N=c.useMemo(()=>({store:e,Body:n,followLink:x,maximize:d,revealInPanel:h,keepAtStartInPanel:O,focusCarry:L}),[e,n,x,d,h,O,L]),R=c.useMemo(()=>Array.from({length:s.multiView.columns},(u,p)=>D.generateColumnId(p)),[s]);return k.jsxs("section",{ref:i,className:"aqmx-multi-stage",style:An,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!C,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),T?C?k.jsx(Oe,{value:N,children:k.jsx(Un,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:R.map(u=>k.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]},u))}):k.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:k.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:y!==null?qe.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),y):k.jsx("div",{ref:v,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},ze=3e3,He=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},le=(e,n,t)=>{const o=new Set(e),r=n.filter(a=>!o.has(a)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Wn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${Y.describeValue(o)}`)}}},Kn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=un(e),s=z(r,f=>f.layout.docs),a=z(r,f=>f.layout.maximized),m=z(r,f=>f.layout.markup),g=z(r,f=>f.source),[i,v]=c.useState(()=>({docs:s,latest:le([],s,null)}));i.docs!==s&&v({docs:s,latest:le(i.docs,s,i.latest)});const C=a!==null?a:i.latest,[T,A]=c.useState(!1),y=c.useRef(null),[d,x]=c.useState(0),h=c.useRef(null),O=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),O.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const L=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),A(!0),y.current=setTimeout(()=>{y.current=null,A(!1)},ze)},[]),N=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),y.current=null,A(!1)},[]),R=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Wn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},x(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&O.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=He(s,a);return{href:j.explorerHref(n,{view:"tree",source:g,doc:f,markup:f!==null&&m.has(f)}),target:"tree"}},[n,g,s,a,m]);return k.jsx(re.ExplorerSplit,{view:"multi",explorer:k.jsx(re.ExplorerPane,{mode:"multi",sourceId:g,currentPath:C,openPaths:u,onOpenDocument:R,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Yn,{ref:O,store:r,body:mn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:N}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Kn;exports.PANEL_LIMIT_NOTICE_MS=ze;exports.latestOpenedDocument=le;exports.treeSwitchDocument=He;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { ScrollBar as m } from "@aiquants/virtualscroll";
|
|
3
|
+
import { useCallback as S, useMemo as d, useSyncExternalStore as h } from "react";
|
|
4
|
+
import { u as b, c as v, N as f, s as T } from "./index-C1YMH-yI.js";
|
|
5
|
+
import { NO_TAP_SCROLL_CIRCLE as g, tapScrollCircleFor as H } from "./tapScrollCircle-BEydRn0y.js";
|
|
6
|
+
const p = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), C = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, O = (e) => {
|
|
7
|
+
let t = p(e);
|
|
8
|
+
return {
|
|
9
|
+
getSnapshot: () => t,
|
|
10
|
+
subscribe: (s) => {
|
|
11
|
+
const o = () => {
|
|
12
|
+
const a = p(e);
|
|
13
|
+
C(t, a) || (t = a, s());
|
|
14
|
+
};
|
|
15
|
+
let n = 0;
|
|
16
|
+
const c = () => {
|
|
17
|
+
n === 0 && (n = requestAnimationFrame(() => {
|
|
18
|
+
n = 0, o();
|
|
19
|
+
}));
|
|
20
|
+
}, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(c), i = () => {
|
|
21
|
+
if (r !== null) {
|
|
22
|
+
r.disconnect(), r.observe(e);
|
|
23
|
+
for (const a of e.children) r.observe(a);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
i();
|
|
27
|
+
const l = typeof MutationObserver > "u" ? null : new MutationObserver(() => {
|
|
28
|
+
i(), c();
|
|
29
|
+
});
|
|
30
|
+
return l?.observe(e, { childList: !0 }), e.addEventListener("scroll", o, { passive: !0 }), o(), () => {
|
|
31
|
+
e.removeEventListener("scroll", o), l?.disconnect(), r?.disconnect(), cancelAnimationFrame(n);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, L = (e) => {
|
|
36
|
+
const t = d(() => O(e), [e]);
|
|
37
|
+
return h(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
38
|
+
}, A = (e, t) => {
|
|
39
|
+
const s = typeof t == "function" ? t(e.scrollTop) : t;
|
|
40
|
+
return e.scrollTo({ top: s, behavior: "instant" }), e.scrollTop;
|
|
41
|
+
}, _ = ({ scroller: e, kind: t }) => {
|
|
42
|
+
const { locale: s } = b(), o = v(), { scrollTop: n, scrollHeight: c, clientHeight: r } = L(e), i = S((l) => A(e, l), [e]);
|
|
43
|
+
return /* @__PURE__ */ u("div", { className: "aqmx-native-scroll-bar", children: /* @__PURE__ */ u(
|
|
44
|
+
m,
|
|
45
|
+
{
|
|
46
|
+
contentSize: c,
|
|
47
|
+
viewportSize: r,
|
|
48
|
+
scrollPosition: n,
|
|
49
|
+
onScroll: i,
|
|
50
|
+
scrollBarWidth: f,
|
|
51
|
+
...T(o),
|
|
52
|
+
enableArrowButtonTabStops: !1,
|
|
53
|
+
tapScrollCircleOptions: t === "content" ? H(o) : g,
|
|
54
|
+
locale: s
|
|
55
|
+
}
|
|
56
|
+
) });
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
_ as NativeScrollBar,
|
|
60
|
+
A as scrollScrollerTo,
|
|
61
|
+
L as useScrollerMetrics
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),S=require("react"),u=require("./index-LQWQfpAf.cjs"),d=require("./tapScrollCircle-DdX0Wri0.cjs"),v=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),m=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=v(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const a=v(e);m(t,a)||(t=a,s())};let n=0;const c=()=>{n===0&&(n=requestAnimationFrame(()=>{n=0,o()}))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(c),l=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const a of e.children)r.observe(a)}};l();const i=typeof MutationObserver>"u"?null:new MutationObserver(()=>{l(),c()});return i?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),i?.disconnect(),r?.disconnect(),cancelAnimationFrame(n)}}}},b=e=>{const t=S.useMemo(()=>g(e),[e]);return S.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},h=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},f=({scroller:e,kind:t})=>{const{locale:s}=u.useExplorer(),o=u.useCoarsePointer(),{scrollTop:n,scrollHeight:c,clientHeight:r}=b(e),l=S.useCallback(i=>h(e,i),[e]);return p.jsx("div",{className:"aqmx-native-scroll-bar",children:p.jsx(T.ScrollBar,{contentSize:c,viewportSize:r,scrollPosition:n,onScroll:l,scrollBarWidth:u.NATIVE_SCROLL_BAR_WIDTH,...u.scrollBarControlsFor(o),enableArrowButtonTabStops:!1,tapScrollCircleOptions:t==="content"?d.tapScrollCircleFor(o):d.NO_TAP_SCROLL_CIRCLE,locale:s})})};exports.NativeScrollBar=f;exports.scrollScrollerTo=h;exports.useScrollerMetrics=b;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as x, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as m, useMemo as w, useEffect as E, useSyncExternalStore as j, useState as q, useRef as H, useLayoutEffect as U } from "react";
|
|
3
|
+
import { useLocation as $ } from "react-router";
|
|
4
|
+
import { e as p, c as B } from "./location--KvTA0Ri.js";
|
|
5
|
+
import { u as g, f as D, r as Y, F as J, g as K, h as Q, i as V, D as W, P as X, j as Z } from "./index-C1YMH-yI.js";
|
|
6
|
+
import { isMaximizeEscape as I } from "@aiquants/drag-drop-panels";
|
|
7
|
+
import { l as ee } from "./ownUrls-Dh5g6ZJi.js";
|
|
8
|
+
import { E as te, a as ne, b as re } from "./ExplorerSplit-CfP1smbT.js";
|
|
9
|
+
const se = (t) => {
|
|
10
|
+
const { config: e, labels: n, announcer: r } = g(), s = D(), u = m(() => {
|
|
11
|
+
const a = t.doc !== null ? t.doc : t.folder;
|
|
12
|
+
if (a === null) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");
|
|
13
|
+
s(p(e, { ...t, maximized: !t.maximized }), "browse");
|
|
14
|
+
const o = ee(a);
|
|
15
|
+
r.announce(t.maximized ? n.documentRestored(o) : n.documentMaximized(o));
|
|
16
|
+
}, [e, s, t, r, n]);
|
|
17
|
+
return w(() => ({ maximized: t.maximized, toggle: u }), [t.maximized, u]);
|
|
18
|
+
}, oe = (t, e) => {
|
|
19
|
+
E(() => {
|
|
20
|
+
if (!t) return;
|
|
21
|
+
const n = (r) => {
|
|
22
|
+
I(r) && (r.preventDefault(), e());
|
|
23
|
+
};
|
|
24
|
+
return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
|
|
25
|
+
}, [t, e]);
|
|
26
|
+
}, ae = (t, e) => t.claim !== e.claim || t.readme.status !== e.readme.status ? !1 : t.readme.status === "failed" && e.readme.status === "failed" ? t.readme.failure === e.readme.failure : t.readme.status === "ok" && e.readme.status === "ok" ? t.readme.readme === e.readme.readme : !0, ie = (t, e, n) => {
|
|
27
|
+
let r = null;
|
|
28
|
+
return () => {
|
|
29
|
+
const s = t.version(), u = t.read(e), a = u.status !== "pending";
|
|
30
|
+
if (r !== null && r.version === s && r.tree === u && r.settled === a) return r.state;
|
|
31
|
+
const o = Y(t, e, n), i = r !== null && ae(r.state, o) ? r.state : o;
|
|
32
|
+
return r = { version: s, tree: u, settled: a, state: i }, i;
|
|
33
|
+
};
|
|
34
|
+
}, ue = (t, e, n) => {
|
|
35
|
+
let r = !0, s = null;
|
|
36
|
+
const u = () => {
|
|
37
|
+
r && n();
|
|
38
|
+
}, a = () => {
|
|
39
|
+
const i = t.read(e);
|
|
40
|
+
i === s || i.status !== "pending" || (s = i, i.then(u, u));
|
|
41
|
+
};
|
|
42
|
+
a();
|
|
43
|
+
const o = t.subscribe(() => {
|
|
44
|
+
a(), n();
|
|
45
|
+
});
|
|
46
|
+
return () => {
|
|
47
|
+
r = !1, o();
|
|
48
|
+
};
|
|
49
|
+
}, ce = () => J, le = (t, e) => {
|
|
50
|
+
const { trees: n } = g(), r = w(() => e === null ? null : ie(n, t, e), [n, t, e]), s = m((d) => r === null ? () => {
|
|
51
|
+
} : ue(n, t, d), [r, n, t]), u = m(() => r === null ? null : r(), [r]), a = m(() => r === null ? null : ce(), [r]), o = j(s, u, a), i = o?.claim === !0;
|
|
52
|
+
return E(() => e === null ? void 0 : n.open(t), [n, t, e]), E(() => e === null || !i ? void 0 : n.claimChildren(t, /* @__PURE__ */ new Map([[e, "direct"]])), [n, t, e, i]), o === null ? null : o.readme;
|
|
53
|
+
}, me = /* @__PURE__ */ new Set(), de = Object.freeze({ kind: "loading" }), pe = (t, e) => e.status === "loading" ? de : e.status === "failed" ? { kind: "failure", folder: t, failure: e.failure, onRetry: e.retry } : { kind: "no-readme", folder: t }, ke = ({ location: t }) => {
|
|
54
|
+
const { config: e } = g(), n = D(), { hash: r } = $(), { source: s, doc: u, folder: a, overrides: o, markup: i, maximized: d } = t, [S, R] = q(te), M = w(() => ({ gathered: S, onGatheredChange: R }), [S]), f = le(s, a), l = f === null ? u : f.status === "ok" ? f.readme : null, k = w(() => a === null || f === null ? K : pe(a, f), [a, f]), h = d && (l !== null || k.kind === "loading"), N = m((c) => n(p(e, { view: "tree", source: s, doc: c, overrides: o }), "browse"), [n, e, s, o]), P = m((c) => n(p(e, { view: "tree", source: s, folder: c, overrides: o }), "browse"), [n, e, s, o]), F = m(
|
|
55
|
+
(c) => {
|
|
56
|
+
const v = c.kind === "folder" ? { folder: c.path } : c.kind === "document" ? { doc: c.path } : {};
|
|
57
|
+
n(p(e, { view: "tree", source: s, ...v, overrides: o }), "close-folder");
|
|
58
|
+
},
|
|
59
|
+
[n, e, s, o]
|
|
60
|
+
), T = m((c) => n(p(e, { view: "tree", source: c, doc: u, folder: a, overrides: o, markup: i, maximized: d }), "switch-source"), [n, e, u, a, o, i, d]), C = m((c) => n(`${p(e, { view: "tree", source: c, doc: u, folder: a, overrides: o, markup: i, maximized: d })}${r}`, "browse"), [n, e, u, a, o, i, d, r]), L = m(
|
|
61
|
+
(c) => {
|
|
62
|
+
const v = B(e, c);
|
|
63
|
+
n(p(e, { view: "multi", source: s, docs: v, markup: i && l !== null && v.includes(l) ? [l] : [] }), "switch-view");
|
|
64
|
+
},
|
|
65
|
+
[n, e, s, l, i]
|
|
66
|
+
), _ = w(() => ({ href: p(e, l === null ? { view: "multi", source: s } : { view: "multi", source: s, docs: [l], markup: i ? [l] : [] }), target: "multi" }), [e, s, l, i]), b = H(d);
|
|
67
|
+
U(() => {
|
|
68
|
+
b.current = d;
|
|
69
|
+
}, [d]);
|
|
70
|
+
const z = m(() => b.current, []), y = w(() => ({ kind: "page", view: "tree", overrides: o, embed: {}, maximized: z }), [o, z]), A = Q(t), O = se(t);
|
|
71
|
+
return oe(h, O.toggle), /* @__PURE__ */ x(
|
|
72
|
+
ne,
|
|
73
|
+
{
|
|
74
|
+
view: "tree",
|
|
75
|
+
contentCoversPage: h,
|
|
76
|
+
explorer: /* @__PURE__ */ x(
|
|
77
|
+
re,
|
|
78
|
+
{
|
|
79
|
+
mode: "tree",
|
|
80
|
+
sourceId: s,
|
|
81
|
+
currentPath: a === null ? u : a,
|
|
82
|
+
openPaths: me,
|
|
83
|
+
onOpenDocument: N,
|
|
84
|
+
onOpenFolder: P,
|
|
85
|
+
onCloseFolder: F,
|
|
86
|
+
currentFolder: a !== null,
|
|
87
|
+
onSourceChange: T,
|
|
88
|
+
onRevealSource: C,
|
|
89
|
+
viewSwitch: _,
|
|
90
|
+
tray: M,
|
|
91
|
+
onOpenSelection: L
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
content: /* @__PURE__ */ G("div", { className: "aqmx-document-column aqmx-tree-document", "data-aqmx-maximized": h ? "true" : "false", ...V, children: [
|
|
95
|
+
l === null ? null : /* @__PURE__ */ x(W, { path: l, placement: X, markup: A, maximize: O }),
|
|
96
|
+
/* @__PURE__ */ x(Z, { path: l, absence: k, markup: i, variant: y })
|
|
97
|
+
] })
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
ke as TreeLayout
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),a=require("react"),L=require("react-router"),x=require("./location-D8DyDkuA.cjs"),d=require("./index-LQWQfpAf.cjs"),H=require("@aiquants/drag-drop-panels"),_=require("./ownUrls-B259RGgd.cjs"),b=require("./ExplorerSplit-D_0VohOv.cjs"),j=t=>{const{config:e,labels:n,announcer:r}=d.useExplorer(),s=d.useExplorerNavigate(),c=a.useCallback(()=>{const u=t.doc!==null?t.doc:t.folder;if(u===null)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");s(x.explorerHref(e,{...t,maximized:!t.maximized}),"browse");const o=_.lastPathSegment(u);r.announce(t.maximized?n.documentRestored(o):n.documentMaximized(o))},[e,s,t,r,n]);return a.useMemo(()=>({maximized:t.maximized,toggle:c}),[t.maximized,c])},A=(t,e)=>{a.useEffect(()=>{if(!t)return;const n=r=>{H.isMaximizeEscape(r)&&(r.preventDefault(),e())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,e])},G=(t,e)=>t.claim!==e.claim||t.readme.status!==e.readme.status?!1:t.readme.status==="failed"&&e.readme.status==="failed"?t.readme.failure===e.readme.failure:t.readme.status==="ok"&&e.readme.status==="ok"?t.readme.readme===e.readme.readme:!0,U=(t,e,n)=>{let r=null;return()=>{const s=t.version(),c=t.read(e),u=c.status!=="pending";if(r!==null&&r.version===s&&r.tree===c&&r.settled===u)return r.state;const o=d.readFolderReadme(t,e,n),l=r!==null&&G(r.state,o)?r.state:o;return r={version:s,tree:c,settled:u,state:l},l}},B=(t,e,n)=>{let r=!0,s=null;const c=()=>{r&&n()},u=()=>{const l=t.read(e);l===s||l.status!=="pending"||(s=l,l.then(c,c))};u();const o=t.subscribe(()=>{u(),n()});return()=>{r=!1,o()}},Y=()=>d.FOLDER_README_LOADING,J=(t,e)=>{const{trees:n}=d.useExplorer(),r=a.useMemo(()=>e===null?null:U(n,t,e),[n,t,e]),s=a.useCallback(p=>r===null?()=>{}:B(n,t,p),[r,n,t]),c=a.useCallback(()=>r===null?null:r(),[r]),u=a.useCallback(()=>r===null?null:Y(),[r]),o=a.useSyncExternalStore(s,c,u),l=o?.claim===!0;return a.useEffect(()=>e===null?void 0:n.open(t),[n,t,e]),a.useEffect(()=>e===null||!l?void 0:n.claimChildren(t,new Map([[e,"direct"]])),[n,t,e,l]),o===null?null:o.readme},K=new Set,Q=Object.freeze({kind:"loading"}),V=(t,e)=>e.status==="loading"?Q:e.status==="failed"?{kind:"failure",folder:t,failure:e.failure,onRetry:e.retry}:{kind:"no-readme",folder:t},W=({location:t})=>{const{config:e}=d.useExplorer(),n=d.useExplorerNavigate(),{hash:r}=L.useLocation(),{source:s,doc:c,folder:u,overrides:o,markup:l,maximized:p}=t,[g,z]=a.useState(b.EMPTY_SELECTION),M=a.useMemo(()=>({gathered:g,onGatheredChange:z}),[g]),f=J(s,u),m=f===null?c:f.status==="ok"?f.readme:null,k=a.useMemo(()=>u===null||f===null?d.NO_DOCUMENT:V(u,f),[u,f]),E=p&&(m!==null||k.kind==="loading"),O=a.useCallback(i=>n(x.explorerHref(e,{view:"tree",source:s,doc:i,overrides:o}),"browse"),[n,e,s,o]),R=a.useCallback(i=>n(x.explorerHref(e,{view:"tree",source:s,folder:i,overrides:o}),"browse"),[n,e,s,o]),D=a.useCallback(i=>{const v=i.kind==="folder"?{folder:i.path}:i.kind==="document"?{doc:i.path}:{};n(x.explorerHref(e,{view:"tree",source:s,...v,overrides:o}),"close-folder")},[n,e,s,o]),N=a.useCallback(i=>n(x.explorerHref(e,{view:"tree",source:i,doc:c,folder:u,overrides:o,markup:l,maximized:p}),"switch-source"),[n,e,c,u,o,l,p]),P=a.useCallback(i=>n(`${x.explorerHref(e,{view:"tree",source:i,doc:c,folder:u,overrides:o,markup:l,maximized:p})}${r}`,"browse"),[n,e,c,u,o,l,p,r]),T=a.useCallback(i=>{const v=x.canonicalMultiDocuments(e,i);n(x.explorerHref(e,{view:"multi",source:s,docs:v,markup:l&&m!==null&&v.includes(m)?[m]:[]}),"switch-view")},[n,e,s,m,l]),q=a.useMemo(()=>({href:x.explorerHref(e,m===null?{view:"multi",source:s}:{view:"multi",source:s,docs:[m],markup:l?[m]:[]}),target:"multi"}),[e,s,m,l]),h=a.useRef(p);a.useLayoutEffect(()=>{h.current=p},[p]);const S=a.useCallback(()=>h.current,[]),y=a.useMemo(()=>({kind:"page",view:"tree",overrides:o,embed:{},maximized:S}),[o,S]),F=d.usePageMarkupToggle(t),C=j(t);return A(E,C.toggle),w.jsx(b.ExplorerSplit,{view:"tree",contentCoversPage:E,explorer:w.jsx(b.ExplorerPane,{mode:"tree",sourceId:s,currentPath:u===null?c:u,openPaths:K,onOpenDocument:O,onOpenFolder:R,onCloseFolder:D,currentFolder:u!==null,onSourceChange:N,onRevealSource:P,viewSwitch:q,tray:M,onOpenSelection:T}),content:w.jsxs("div",{className:"aqmx-document-column aqmx-tree-document","data-aqmx-maximized":E?"true":"false",...d.CONTENT_PANE,children:[m===null?null:w.jsx(d.DocumentRefreshBar,{path:m,placement:d.PAGE_DOCUMENT_REFRESH,markup:F,maximize:C}),w.jsx(d.DocumentPane,{path:m,absence:k,markup:l,variant:y})]})})};exports.TreeLayout=W;
|
|
@@ -4,6 +4,7 @@ import { ExplorerConfig, ExplorerView } from "../core/config.cjs";
|
|
|
4
4
|
import { ExplorerDraftConverter, ExplorerFailure, ExplorerPageData } from "../core/contracts.cjs";
|
|
5
5
|
import { MarkdownExplorerLabelOverrides, MarkdownExplorerLocale } from "../core/labels.cjs";
|
|
6
6
|
import { ExplorerTheme } from "../core/theme.cjs";
|
|
7
|
+
import { ExplorerAccountState, ExplorerDraftChange, ExplorerHostChange, ExplorerHostChangePolicy, MarkdownExplorerHandle } from "./hostContract.cjs";
|
|
7
8
|
export type ExplorerFrameRenderer = (frame: {
|
|
8
9
|
readonly view: ExplorerView;
|
|
9
10
|
readonly children: ReactNode;
|
|
@@ -21,8 +22,20 @@ export type MarkdownExplorerProps = {
|
|
|
21
22
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
22
23
|
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
23
24
|
readonly draftConverter?: ExplorerDraftConverter;
|
|
25
|
+
readonly fetch?: typeof fetch;
|
|
26
|
+
readonly persistSettings?: (serialized: string) => void;
|
|
27
|
+
readonly subscribeHostChanges?: (listener: (change: ExplorerHostChange) => void) => () => void;
|
|
28
|
+
readonly hostChangePolicy?: ExplorerHostChangePolicy;
|
|
29
|
+
readonly ref?: Ref<MarkdownExplorerHandle>;
|
|
30
|
+
readonly guardUnload?: boolean;
|
|
31
|
+
readonly onReload?: () => void;
|
|
32
|
+
readonly onSessionEnded?: () => Promise<boolean>;
|
|
33
|
+
readonly onDraftChange?: (change: ExplorerDraftChange) => void;
|
|
34
|
+
readonly accountState?: ExplorerAccountState;
|
|
35
|
+
readonly confirmUnversionedSaves?: boolean;
|
|
36
|
+
readonly paletteKey?: string;
|
|
24
37
|
};
|
|
25
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, }: MarkdownExplorerProps) => ReactElement;
|
|
38
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload, onReload: onReloadProp, onSessionEnded: onSessionEndedProp, onDraftChange, accountState, confirmUnversionedSaves, paletteKey, }: MarkdownExplorerProps) => ReactElement;
|
|
26
39
|
export type ExplorerRootProps = {
|
|
27
40
|
readonly ref?: Ref<HTMLDivElement>;
|
|
28
41
|
readonly theme: ExplorerTheme;
|
|
@@ -4,6 +4,7 @@ import { ExplorerConfig, ExplorerView } from "../core/config.js";
|
|
|
4
4
|
import { ExplorerDraftConverter, ExplorerFailure, ExplorerPageData } from "../core/contracts.js";
|
|
5
5
|
import { MarkdownExplorerLabelOverrides, MarkdownExplorerLocale } from "../core/labels.js";
|
|
6
6
|
import { ExplorerTheme } from "../core/theme.js";
|
|
7
|
+
import { ExplorerAccountState, ExplorerDraftChange, ExplorerHostChange, ExplorerHostChangePolicy, MarkdownExplorerHandle } from "./hostContract.js";
|
|
7
8
|
export type ExplorerFrameRenderer = (frame: {
|
|
8
9
|
readonly view: ExplorerView;
|
|
9
10
|
readonly children: ReactNode;
|
|
@@ -21,8 +22,20 @@ export type MarkdownExplorerProps = {
|
|
|
21
22
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
22
23
|
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
23
24
|
readonly draftConverter?: ExplorerDraftConverter;
|
|
25
|
+
readonly fetch?: typeof fetch;
|
|
26
|
+
readonly persistSettings?: (serialized: string) => void;
|
|
27
|
+
readonly subscribeHostChanges?: (listener: (change: ExplorerHostChange) => void) => () => void;
|
|
28
|
+
readonly hostChangePolicy?: ExplorerHostChangePolicy;
|
|
29
|
+
readonly ref?: Ref<MarkdownExplorerHandle>;
|
|
30
|
+
readonly guardUnload?: boolean;
|
|
31
|
+
readonly onReload?: () => void;
|
|
32
|
+
readonly onSessionEnded?: () => Promise<boolean>;
|
|
33
|
+
readonly onDraftChange?: (change: ExplorerDraftChange) => void;
|
|
34
|
+
readonly accountState?: ExplorerAccountState;
|
|
35
|
+
readonly confirmUnversionedSaves?: boolean;
|
|
36
|
+
readonly paletteKey?: string;
|
|
24
37
|
};
|
|
25
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, }: MarkdownExplorerProps) => ReactElement;
|
|
38
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload, onReload: onReloadProp, onSessionEnded: onSessionEndedProp, onDraftChange, accountState, confirmUnversionedSaves, paletteKey, }: MarkdownExplorerProps) => ReactElement;
|
|
26
39
|
export type ExplorerRootProps = {
|
|
27
40
|
readonly ref?: Ref<HTMLDivElement>;
|
|
28
41
|
readonly theme: ExplorerTheme;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ExplorerFailureReason } from "../core/contracts.cjs";
|
|
2
|
+
import { LineEnding } from "./edit/lineEndings.cjs";
|
|
3
|
+
export type MarkdownExplorerHandle = {
|
|
4
|
+
readonly flushUnsaved: () => readonly string[];
|
|
5
|
+
readonly confirmDiscard: (paths: readonly string[]) => Promise<boolean>;
|
|
6
|
+
readonly restoreDrafts: (drafts: readonly ExplorerUnsavedDraft[]) => Promise<ExplorerDraftRestore>;
|
|
7
|
+
readonly announce: (text: string) => void;
|
|
8
|
+
readonly owns: (element: Element) => boolean;
|
|
9
|
+
readonly reportMediaFailure: (failure: ExplorerMediaFailure) => void;
|
|
10
|
+
};
|
|
11
|
+
export type ExplorerHostChange = {
|
|
12
|
+
readonly sourceIds: readonly string[];
|
|
13
|
+
readonly paths: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
export type ExplorerMediaFailure = {
|
|
16
|
+
readonly url: string;
|
|
17
|
+
readonly final: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ExplorerUnsavedDraft = {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly base: {
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly version: string | null;
|
|
24
|
+
};
|
|
25
|
+
readonly draft: string;
|
|
26
|
+
readonly lineEnding: LineEnding;
|
|
27
|
+
};
|
|
28
|
+
export type ExplorerDraftChange = {
|
|
29
|
+
readonly kept: readonly ExplorerUnsavedDraft[];
|
|
30
|
+
readonly ended: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
export type ExplorerDraftRestore = {
|
|
33
|
+
readonly restored: readonly string[];
|
|
34
|
+
readonly failed: readonly {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly reason: ExplorerFailureReason;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export declare const EXPLORER_HOST_CHANGE_POLICIES: readonly [
|
|
40
|
+
"reload",
|
|
41
|
+
"notify"
|
|
42
|
+
];
|
|
43
|
+
export type ExplorerHostChangePolicy = (typeof EXPLORER_HOST_CHANGE_POLICIES)[number];
|
|
44
|
+
export declare const EXPLORER_ACCOUNT_STATES: readonly [
|
|
45
|
+
"signed-in",
|
|
46
|
+
"signed-out"
|
|
47
|
+
];
|
|
48
|
+
export type ExplorerAccountState = (typeof EXPLORER_ACCOUNT_STATES)[number];
|
|
49
|
+
export type ExplorerHostOptions = {
|
|
50
|
+
readonly fetch: unknown;
|
|
51
|
+
readonly persistSettings: unknown;
|
|
52
|
+
readonly subscribeHostChanges: unknown;
|
|
53
|
+
readonly onReload: unknown;
|
|
54
|
+
readonly onSessionEnded: unknown;
|
|
55
|
+
readonly onDraftChange: unknown;
|
|
56
|
+
readonly guardUnload: unknown;
|
|
57
|
+
readonly confirmUnversionedSaves: unknown;
|
|
58
|
+
readonly hostChangePolicy: unknown;
|
|
59
|
+
readonly accountState: unknown;
|
|
60
|
+
readonly paletteKey: unknown;
|
|
61
|
+
};
|
|
62
|
+
export declare const assertExplorerHostOptions: (options: ExplorerHostOptions) => void;
|
|
63
|
+
export declare const assertExplorerPaths: (name: string, paths: unknown) => asserts paths is readonly string[];
|
|
64
|
+
export declare const assertExplorerHostChange: (change: unknown) => asserts change is ExplorerHostChange;
|
|
65
|
+
export declare const assertExplorerUnsavedDrafts: (drafts: unknown) => asserts drafts is readonly ExplorerUnsavedDraft[];
|
|
66
|
+
export declare const assertExplorerAnnouncement: (text: unknown) => asserts text is string;
|
|
67
|
+
export declare const assertExplorerMediaFailure: (failure: unknown) => asserts failure is ExplorerMediaFailure;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ExplorerFailureReason } from "../core/contracts.js";
|
|
2
|
+
import { LineEnding } from "./edit/lineEndings.js";
|
|
3
|
+
export type MarkdownExplorerHandle = {
|
|
4
|
+
readonly flushUnsaved: () => readonly string[];
|
|
5
|
+
readonly confirmDiscard: (paths: readonly string[]) => Promise<boolean>;
|
|
6
|
+
readonly restoreDrafts: (drafts: readonly ExplorerUnsavedDraft[]) => Promise<ExplorerDraftRestore>;
|
|
7
|
+
readonly announce: (text: string) => void;
|
|
8
|
+
readonly owns: (element: Element) => boolean;
|
|
9
|
+
readonly reportMediaFailure: (failure: ExplorerMediaFailure) => void;
|
|
10
|
+
};
|
|
11
|
+
export type ExplorerHostChange = {
|
|
12
|
+
readonly sourceIds: readonly string[];
|
|
13
|
+
readonly paths: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
export type ExplorerMediaFailure = {
|
|
16
|
+
readonly url: string;
|
|
17
|
+
readonly final: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type ExplorerUnsavedDraft = {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly base: {
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly version: string | null;
|
|
24
|
+
};
|
|
25
|
+
readonly draft: string;
|
|
26
|
+
readonly lineEnding: LineEnding;
|
|
27
|
+
};
|
|
28
|
+
export type ExplorerDraftChange = {
|
|
29
|
+
readonly kept: readonly ExplorerUnsavedDraft[];
|
|
30
|
+
readonly ended: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
export type ExplorerDraftRestore = {
|
|
33
|
+
readonly restored: readonly string[];
|
|
34
|
+
readonly failed: readonly {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly reason: ExplorerFailureReason;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
export declare const EXPLORER_HOST_CHANGE_POLICIES: readonly [
|
|
40
|
+
"reload",
|
|
41
|
+
"notify"
|
|
42
|
+
];
|
|
43
|
+
export type ExplorerHostChangePolicy = (typeof EXPLORER_HOST_CHANGE_POLICIES)[number];
|
|
44
|
+
export declare const EXPLORER_ACCOUNT_STATES: readonly [
|
|
45
|
+
"signed-in",
|
|
46
|
+
"signed-out"
|
|
47
|
+
];
|
|
48
|
+
export type ExplorerAccountState = (typeof EXPLORER_ACCOUNT_STATES)[number];
|
|
49
|
+
export type ExplorerHostOptions = {
|
|
50
|
+
readonly fetch: unknown;
|
|
51
|
+
readonly persistSettings: unknown;
|
|
52
|
+
readonly subscribeHostChanges: unknown;
|
|
53
|
+
readonly onReload: unknown;
|
|
54
|
+
readonly onSessionEnded: unknown;
|
|
55
|
+
readonly onDraftChange: unknown;
|
|
56
|
+
readonly guardUnload: unknown;
|
|
57
|
+
readonly confirmUnversionedSaves: unknown;
|
|
58
|
+
readonly hostChangePolicy: unknown;
|
|
59
|
+
readonly accountState: unknown;
|
|
60
|
+
readonly paletteKey: unknown;
|
|
61
|
+
};
|
|
62
|
+
export declare const assertExplorerHostOptions: (options: ExplorerHostOptions) => void;
|
|
63
|
+
export declare const assertExplorerPaths: (name: string, paths: unknown) => asserts paths is readonly string[];
|
|
64
|
+
export declare const assertExplorerHostChange: (change: unknown) => asserts change is ExplorerHostChange;
|
|
65
|
+
export declare const assertExplorerUnsavedDrafts: (drafts: unknown) => asserts drafts is readonly ExplorerUnsavedDraft[];
|
|
66
|
+
export declare const assertExplorerAnnouncement: (text: unknown) => asserts text is string;
|
|
67
|
+
export declare const assertExplorerMediaFailure: (failure: unknown) => asserts failure is ExplorerMediaFailure;
|
package/dist/core/config.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
2
2
|
import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
|
|
3
|
+
import { ExplorerOwnUrls } from "./ownUrls.cjs";
|
|
3
4
|
import { TreeSettings } from "./treeSettings.cjs";
|
|
4
5
|
export type ExplorerViewSlugs = {
|
|
5
6
|
readonly tree: string;
|
|
@@ -27,6 +28,8 @@ export type ExplorerConfigInput = {
|
|
|
27
28
|
readonly documentStyles?: readonly ExplorerDocumentStyle[];
|
|
28
29
|
readonly defaultDocumentStyle?: string;
|
|
29
30
|
readonly iframeHosts?: readonly string[];
|
|
31
|
+
readonly appOrigins?: readonly string[];
|
|
32
|
+
readonly mediaDataPath?: string;
|
|
30
33
|
readonly embeds?: {
|
|
31
34
|
readonly providers?: readonly EmbedProviderId[];
|
|
32
35
|
readonly linkCards?: boolean;
|
|
@@ -58,6 +61,8 @@ export type ExplorerConfig = {
|
|
|
58
61
|
readonly documentStyles: readonly ExplorerDocumentStyle[];
|
|
59
62
|
readonly defaultDocumentStyle: string;
|
|
60
63
|
readonly iframeHosts: readonly string[];
|
|
64
|
+
readonly appOrigins: readonly string[];
|
|
65
|
+
readonly mediaDataPath: string | null;
|
|
61
66
|
readonly embeds: MarkdownEmbeds;
|
|
62
67
|
readonly defaultTreeSettings: TreeSettings;
|
|
63
68
|
readonly legacyTextEncoding: string | null;
|
|
@@ -102,6 +107,7 @@ export declare const WORKBOOK_BYTE_LIMITS: Readonly<{
|
|
|
102
107
|
min: 1;
|
|
103
108
|
max: number;
|
|
104
109
|
}>;
|
|
110
|
+
export declare const assertMountPath: (name: string, value: unknown) => void;
|
|
105
111
|
export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
|
|
106
112
|
export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
|
|
107
113
|
export declare const isExplorerSourceId: (value: unknown) => value is string;
|
|
@@ -110,3 +116,4 @@ export type ExplorerLocationConfig = ExplorerConfig & {
|
|
|
110
116
|
};
|
|
111
117
|
export declare const withExplorerSources: (config: ExplorerConfig, sourceIds: readonly string[]) => ExplorerLocationConfig;
|
|
112
118
|
export declare const documentStyleNames: (config: ExplorerConfig) => readonly string[];
|
|
119
|
+
export declare const ownUrlsOf: (config: ExplorerConfig) => ExplorerOwnUrls;
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
2
2
|
import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
|
|
3
|
+
import { ExplorerOwnUrls } from "./ownUrls.js";
|
|
3
4
|
import { TreeSettings } from "./treeSettings.js";
|
|
4
5
|
export type ExplorerViewSlugs = {
|
|
5
6
|
readonly tree: string;
|
|
@@ -27,6 +28,8 @@ export type ExplorerConfigInput = {
|
|
|
27
28
|
readonly documentStyles?: readonly ExplorerDocumentStyle[];
|
|
28
29
|
readonly defaultDocumentStyle?: string;
|
|
29
30
|
readonly iframeHosts?: readonly string[];
|
|
31
|
+
readonly appOrigins?: readonly string[];
|
|
32
|
+
readonly mediaDataPath?: string;
|
|
30
33
|
readonly embeds?: {
|
|
31
34
|
readonly providers?: readonly EmbedProviderId[];
|
|
32
35
|
readonly linkCards?: boolean;
|
|
@@ -58,6 +61,8 @@ export type ExplorerConfig = {
|
|
|
58
61
|
readonly documentStyles: readonly ExplorerDocumentStyle[];
|
|
59
62
|
readonly defaultDocumentStyle: string;
|
|
60
63
|
readonly iframeHosts: readonly string[];
|
|
64
|
+
readonly appOrigins: readonly string[];
|
|
65
|
+
readonly mediaDataPath: string | null;
|
|
61
66
|
readonly embeds: MarkdownEmbeds;
|
|
62
67
|
readonly defaultTreeSettings: TreeSettings;
|
|
63
68
|
readonly legacyTextEncoding: string | null;
|
|
@@ -102,6 +107,7 @@ export declare const WORKBOOK_BYTE_LIMITS: Readonly<{
|
|
|
102
107
|
min: 1;
|
|
103
108
|
max: number;
|
|
104
109
|
}>;
|
|
110
|
+
export declare const assertMountPath: (name: string, value: unknown) => void;
|
|
105
111
|
export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
|
|
106
112
|
export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
|
|
107
113
|
export declare const isExplorerSourceId: (value: unknown) => value is string;
|
|
@@ -110,3 +116,4 @@ export type ExplorerLocationConfig = ExplorerConfig & {
|
|
|
110
116
|
};
|
|
111
117
|
export declare const withExplorerSources: (config: ExplorerConfig, sourceIds: readonly string[]) => ExplorerLocationConfig;
|
|
112
118
|
export declare const documentStyleNames: (config: ExplorerConfig) => readonly string[];
|
|
119
|
+
export declare const ownUrlsOf: (config: ExplorerConfig) => ExplorerOwnUrls;
|
|
@@ -120,13 +120,16 @@ export type ExplorerFailureDocument = {
|
|
|
120
120
|
readonly kind: "failure";
|
|
121
121
|
readonly failure: ExplorerFailure;
|
|
122
122
|
};
|
|
123
|
-
export type
|
|
123
|
+
export type ExplorerFileText = {
|
|
124
124
|
readonly kind: "text";
|
|
125
125
|
readonly name: string;
|
|
126
126
|
readonly text: string;
|
|
127
127
|
readonly truncated: boolean;
|
|
128
128
|
readonly url: string;
|
|
129
129
|
};
|
|
130
|
+
export type ExplorerTextDocument = ExplorerFileText & {
|
|
131
|
+
readonly lang: string;
|
|
132
|
+
};
|
|
130
133
|
export type ExplorerExternalEdit = {
|
|
131
134
|
readonly kind: "external";
|
|
132
135
|
readonly href: string;
|
|
@@ -149,6 +152,7 @@ export type ExplorerDocument = {
|
|
|
149
152
|
readonly name: string;
|
|
150
153
|
readonly htmlContent: string;
|
|
151
154
|
readonly headings: readonly ExplorerHeading[];
|
|
155
|
+
readonly lang: string;
|
|
152
156
|
readonly edit: ExplorerDocumentEdit | null;
|
|
153
157
|
} | ExplorerTextDocument | {
|
|
154
158
|
readonly kind: "image";
|
|
@@ -165,7 +169,7 @@ export type ExplorerDocument = {
|
|
|
165
169
|
readonly name: string;
|
|
166
170
|
readonly url: string;
|
|
167
171
|
} | ExplorerFailureDocument;
|
|
168
|
-
export type ExplorerTextAnswer =
|
|
172
|
+
export type ExplorerTextAnswer = ExplorerFileText | ExplorerFailureDocument;
|
|
169
173
|
export type ExplorerGrantRequired = {
|
|
170
174
|
readonly kind: "grant";
|
|
171
175
|
readonly href: string;
|
|
@@ -194,7 +198,7 @@ export type ExplorerPreviewAnswer = {
|
|
|
194
198
|
readonly htmlContent: string;
|
|
195
199
|
readonly headings: readonly ExplorerHeading[];
|
|
196
200
|
} | ExplorerFailureDocument;
|
|
197
|
-
export type
|
|
201
|
+
export type ExplorerPreviewDraft = {
|
|
198
202
|
readonly path: string;
|
|
199
203
|
readonly text: string;
|
|
200
204
|
};
|
|
@@ -206,7 +210,7 @@ export type ExplorerDraftAnswer = {
|
|
|
206
210
|
readonly kind: "unavailable";
|
|
207
211
|
};
|
|
208
212
|
export type ExplorerDraftConverter = {
|
|
209
|
-
readonly convert: (draft:
|
|
213
|
+
readonly convert: (draft: ExplorerPreviewDraft, signal: AbortSignal) => Promise<ExplorerDraftAnswer>;
|
|
210
214
|
readonly prepare?: () => void;
|
|
211
215
|
};
|
|
212
216
|
export type ExplorerRevision = {
|
|
@@ -257,6 +261,8 @@ export declare const isExplorerAncestorsResult: (value: unknown) => value is Exp
|
|
|
257
261
|
export declare const isExplorerRevealResult: (value: unknown) => value is ExplorerRevealResult;
|
|
258
262
|
export declare const isExplorerTreeResult: (value: unknown) => value is ExplorerTreeResult;
|
|
259
263
|
export declare const headingViolation: (value: unknown) => string | null;
|
|
264
|
+
export declare const isExplorerDocumentLang: (value: unknown) => value is string;
|
|
265
|
+
export declare const documentLangRefusal: (kind: "markdown" | "text", value: unknown) => string;
|
|
260
266
|
export declare const documentViolation: (value: unknown) => string | null;
|
|
261
267
|
export declare const isExplorerDocument: (value: unknown) => value is ExplorerDocument;
|
|
262
268
|
export declare const isExplorerTextAnswer: (value: unknown) => value is ExplorerTextAnswer;
|