@inkeep/open-knowledge 0.0.0-dev-20260422183611 → 0.0.0-dev-20260422210111
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/dist/cli.mjs +13 -13
- package/dist/constants-CiZgq6zT.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-BVkwhSV7.mjs → init-B8Xnbhhn.mjs} +2 -2
- package/dist/init-C1HljSB5.mjs +1 -0
- package/dist/{init-CbtQtRR6.mjs → init-CnpwEFdK.mjs} +3 -3
- package/dist/{init-CjD3Y8vy.mjs → init-DhXIUBvg.mjs} +1 -1
- package/dist/keepalive-BtwYrChs.mjs +2 -0
- package/dist/{loader-EY80f87l.mjs → loader-CrnVpSji.mjs} +2 -2
- package/dist/loader-OQS9ACNm.mjs +1 -0
- package/dist/{paths-ClIaGARi.mjs → paths-B5Xymv2W.mjs} +2 -2
- package/dist/paths-CUf-odRI.mjs +1 -0
- package/dist/preview-B22xjLsP.mjs +1 -0
- package/dist/{preview-CYIJfQoO.mjs → preview-uvtKxu1o.mjs} +2 -2
- package/dist/public/assets/{GraphPanel-DqKpB1Tz.js → GraphPanel-CtPBcypT.js} +1 -1
- package/dist/public/assets/SourceEditor-3D1gs8jR.js +3 -0
- package/dist/public/assets/clipboard-DLkbuX0Y.js +80 -0
- package/dist/public/assets/{dist-BZpbe8U5.js → dist-BL9mEocg.js} +1 -1
- package/dist/public/assets/{dist-C5cYj6hk.js → dist-BRU9Z8nb.js} +1 -1
- package/dist/public/assets/{dist-CtX4SukE.js → dist-BixLmXN7.js} +1 -1
- package/dist/public/assets/{dist-C0ssNH5f.js → dist-BoNTyP8X.js} +1 -1
- package/dist/public/assets/{dist-BXy0xauE.js → dist-C2luWP3Z.js} +1 -1
- package/dist/public/assets/{dist-CYCPSCCQ.js → dist-DKlym6RD.js} +1 -1
- package/dist/public/assets/{dist-ztaVC3x4.js → dist-DZ-UOMpP.js} +1 -1
- package/dist/public/assets/index-CpGPsUWx.css +1 -0
- package/dist/public/assets/index-QecScGij.js +21 -0
- package/dist/public/assets/{panel-DFRQJTBG.js → panel-C8Asv8L6.js} +31 -31
- package/dist/public/assets/toggle-group-DWj1iQFr.js +1 -0
- package/dist/public/index.html +8 -8
- package/dist/src-DAd92e3U.mjs +1 -0
- package/dist/src-DSnJWc-y.mjs +1 -0
- package/dist/src-DkmdJZsK.mjs +91 -0
- package/dist/start-B9GVxmFS.mjs +1 -0
- package/dist/{start-CmfUuJ8y.mjs → start-DeV2jvfm.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-Cqh2k1vs.mjs +0 -2
- package/dist/init-DCdj_qYX.mjs +0 -1
- package/dist/keepalive-BI3oBFIq.mjs +0 -2
- package/dist/loader-D4WqC1BR.mjs +0 -1
- package/dist/paths-De38nMxk.mjs +0 -1
- package/dist/preview-DCtsNigW.mjs +0 -1
- package/dist/public/assets/SourceEditor-CV7AqTwb.js +0 -3
- package/dist/public/assets/clipboard-D_fdmuyh.js +0 -80
- package/dist/public/assets/index-DGQHaqKr.css +0 -1
- package/dist/public/assets/index-l0fisju1.js +0 -21
- package/dist/public/assets/toggle-group-D4a_dmpa.js +0 -1
- package/dist/src-B-CjXHOr.mjs +0 -1
- package/dist/src-B2ovo79d.mjs +0 -1
- package/dist/src-CHPbwD29.mjs +0 -90
- package/dist/start-CwtyENWS.mjs +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./constants-
|
|
1
|
+
import"./constants-CiZgq6zT.mjs";import{D as e}from"./src-CdcLi3q2.mjs";import{p as t}from"./src-DkmdJZsK.mjs";import{existsSync as n,lstatSync as r,readdirSync as i,realpathSync as a,statSync as o}from"node:fs";import{join as s,relative as c}from"node:path";function l(e){let{projectDir:n,contentDir:l,include:u,exclude:d,sampleCap:f=5}=e,p=[],m=[];try{r(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let h;try{h=t({projectDir:n,contentDir:l,includePatterns:u,excludePatterns:d})}catch(e){return{totalCount:0,sample:[],contentDir:l,include:u,exclude:d,warnings:[e instanceof Error?e.message:String(e)]}}function g(e){let t;try{t=i(e,{withFileTypes:!0})}catch(t){let n=t instanceof Error?t.message:String(t);p.push(`could not read directory ${c(l,e)||`.`}: ${n}`);return}for(let n of t){let t=s(e,n.name);if(n.isSymbolicLink()){let e;try{e=a(t)}catch(e){let n=e.code;n===`ENOENT`||n===`ELOOP`?p.push(`broken or cyclic symlink: ${c(l,t)}`):p.push(`cannot resolve symlink ${c(l,t)}: ${n??`unknown error`}`);continue}let n;try{n=o(e)}catch{continue}if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}else if(n.isDirectory()){let e=c(l,t);if(h.isDirExcluded(e))continue;g(t)}else if(n.isFile()){let e=c(l,t);if(h.isExcluded(e))continue;m.push(e)}}}return g(l),{totalCount:m.length,sample:m.slice(0,f),contentDir:l,include:u,exclude:d,warnings:p}}function u(t,r){let i=[],a=c(r,t.contentDir),o=a===``?`./`:`./${a}`;i.push(`Content:`),i.push(` Found ${t.totalCount} markdown files in ${o}`);let l=t.include.join(`, `),u=t.exclude.length>0?t.exclude.join(`, `):`(none)`;if(i.push(` Scope: include=${l} exclude=${u}`),t.sample.length>0){let e=t.sample.join(`, `),n=t.totalCount>t.sample.length?`, …`:``;i.push(` Sample: ${e}${n}`)}if(t.warnings.length>0)for(let e of t.warnings)i.push(` Warning: ${e}`);return i.push(``),n(s(r,`.open-knowledge`,`config.yml`))?(i.push(` To adjust, edit ${e}/config.yml:`),i.push(` content:`),i.push(` include: ${JSON.stringify(t.include)}`),i.push(` exclude: ${JSON.stringify(t.exclude)}`)):(i.push(" Run `open-knowledge init` to scaffold config, then adjust:"),i.push(` ${e}/config.yml → content.include / content.exclude`)),i.push(``),i.push(` Re-check anytime: open-knowledge preview`),i.join(`
|
|
2
2
|
`)}export{l as n,u as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-uvtKxu1o.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as e,Hn as n,
|
|
1
|
+
import{G as e,Hn as n,It as r,W as i,Wn as a,_n as o,a as s,bn as c,d as l,fn as u,gn as d,h as f,i as p,l as m,n as h,o as g,ot as _,pn as v,r as y,s as b,t as x,xn as S}from"./panel-C8Asv8L6.js";import{a as C,b as w,i as T,n as E,r as ee,s as te,t as ne,x as re,y as ie}from"./toggle-group-DWj1iQFr.js";var ae=u(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),oe=u(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),D=a(S(),1),se=v(),ce=[`#60a5fa`,`#a78bfa`,`#34d399`,`#f472b6`,`#fb923c`,`#22d3ee`,`#c084fc`,`#4ade80`,`#f87171`,`#eab308`,`#ec4899`,`#06b67f`,`#8b5cf6`,`#f43f5e`,`#0ea5e9`,`#a855f7`],le=[`#1e40af`,`#6b21a8`,`#166534`,`#9f1239`,`#9a3412`,`#164e63`,`#581c87`,`#166534`,`#991b1b`,`#854d0e`,`#831843`,`#0f766e`,`#312e81`,`#9f1239`,`#0c4a6e`,`#6b21a8`];function ue(e){let n=2;for(let r=0;r<e.length;r++)n=Math.imul(n^e.charCodeAt(r),1540483477),n^=n>>>13,n=Math.imul(n,1540483477),n^=n>>>15;return n>>>0}function de(e,n){let r=n?ce:le;return r[ue(e)%r.length]}var O=c(),fe=10;function pe(e){let n=(0,se.c)(17),{clusters:r}=e,{resolvedTheme:i}=d(),a=i===`dark`;if(r.length===0)return null;let o,s,c,l;if(n[0]!==r||n[1]!==a){let e=r.slice(0,fe);o=r.length-e.length,s=`absolute bottom-3 left-3 z-10 flex flex-col gap-1 rounded-lg px-3 py-2 text-xs backdrop-blur-sm ${a?`bg-black/70 text-gray-200`:`bg-white/80 text-gray-800 ring-1 ring-black/5`}`;let i=`font-medium mb-1.5 ${a?`text-slate-300`:`text-slate-700`}`;n[6]===i?c=n[7]:(c=(0,O.jsx)(`div`,{className:i,children:`Clusters`}),n[6]=i,n[7]=c);let u;n[8]===a?u=n[9]:(u=e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`inline-block size-2.5 shrink-0 rounded-full`,style:{backgroundColor:de(e,a)}}),(0,O.jsx)(`span`,{className:`truncate max-w-[140px]`,children:e})]},e),n[8]=a,n[9]=u),l=e.map(u),n[0]=r,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l}else o=n[2],s=n[3],c=n[4],l=n[5];let u;n[10]===o?u=n[11]:(u=o>0&&(0,O.jsxs)(`div`,{className:`text-muted-foreground pl-[18px]`,children:[`+ `,o,` more`]}),n[10]=o,n[11]=u);let f;return n[12]!==s||n[13]!==c||n[14]!==l||n[15]!==u?(f=(0,O.jsxs)(`div`,{className:s,children:[c,l,u]}),n[12]=s,n[13]=c,n[14]=l,n[15]=u,n[16]=f):f=n[16],f}function me(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function he(e,n,r){return n=Ce(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function ge(e,n){return ye(e)||me(e,n)||k(e,n)||Se()}function _e(e){return ve(e)||be(e)||k(e)||xe()}function ve(e){if(Array.isArray(e))return A(e)}function ye(e){if(Array.isArray(e))return e}function be(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function k(e,n){if(e){if(typeof e==`string`)return A(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,n)}}function A(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function xe(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Se(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function j(e,n){if(typeof e!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(typeof i!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function Ce(e){var n=j(e,`string`);return typeof n==`symbol`?n:String(n)}var we=function(e,n){var r=new Set(n);return Object.assign.apply(Object,[{}].concat(_e(Object.entries(e).filter(function(e){var n=ge(e,1)[0];return!r.has(n)}).map(function(e){var n=ge(e,2),r=n[0],i=n[1];return he({},r,i)}))))};function M(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Te(e){if(Array.isArray(e))return e}function Ee(e){if(Array.isArray(e))return M(e)}function De(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Oe(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n!==0)for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function ke(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
4
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ae(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-BL9mEocg.js","assets/dist-BixLmXN7.js","assets/panel-C8Asv8L6.js","assets/w3c-keyname-DLDSJn4E.js","assets/dist-DZ-UOMpP.js","assets/dist-C2luWP3Z.js","assets/dist-BoNTyP8X.js","assets/dist-BRU9Z8nb.js","assets/dist-DKlym6RD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{C as e,J as t,Wn as n,Y as r,bn as i,gn as a,pn as o,q as s,v as c,xn as l}from"./panel-C8Asv8L6.js";import{A as u,Ct as d,F as f,G as p,I as m,J as h,K as g,L as _,P as v,Q as ee,St as y,Tt as b,_ as te,_t as x,a as S,bt as C,c as ne,d as re,et as ie,f as ae,g as oe,gt as w,h as T,ht as E,kt as D,l as se,m as ce,p as le,pt as ue,q as de,s as fe,t as pe,u as me,v as he,vt as O,wt as ge,xt as k,yt as A}from"./clipboard-DLkbuX0Y.js";import{At as _e,Dt as j,Et as ve,N as M,Nt as N,Pt as P,Q as ye,Tt as F,Y as I,Z as L,a as R,bt as z,ft as B,jt as V,lt as be,q as H,wt as xe}from"./dist-BixLmXN7.js";var U=n(l(),1),Se=o(),Ce=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:C(this.yanchor),yhead:C(this.yhead)}}static fromJSON(t){return new e(O(t.yanchor),O(t.yhead))}},we=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new E(e)}toYPos(e,t=0){return A(this.ytext,e,t)}fromYPos(e){let t=x(O(e),this.ytext.doc);if(t==null||t.type!==this.ytext)throw Error(`[y-codemirror] The position you want to retrieve was created by a different document`);return{pos:t.index,assoc:t.assoc}}toYRange(e){let t=e.assoc;return new Ce(this.toYPos(e.anchor,t),this.toYPos(e.head,t))}fromYRange(e){let t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?F.cursor(n.pos,n.assoc):F.range(t.pos,n.pos)}},W=j.define({combine(e){return e[e.length-1]}}),G=z.define(),Te=class{constructor(e){this.view=e,this.conf=e.state.facet(W),this._observer=(t,n)=>{if(n.origin!==this.conf){let n=t.delta,r=[],i=0;for(let e=0;e<n.length;e++){let t=n[e];t.insert==null?t.delete==null?i+=t.retain:(r.push({from:i,to:i+t.delete,insert:``}),i+=t.delete):r.push({from:i,to:i,insert:t.insert})}e.dispatch({changes:r,annotations:[G.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(G)===this.conf)return;let t=this.conf.ytext;t.doc.transact(()=>{let n=0;e.changes.iterChanges((e,r,i,a,o)=>{let s=o.sliceString(0,o.length,`
|
|
3
|
+
`);e!==r&&t.delete(e+n,r-e),s.length>0&&t.insert(e+n,s),n+=s.length-(r-e)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},Ee=L.fromClass(Te),De=I.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:`0px 2px 0px 4px`},".cm-ySelectionCaret":{position:`relative`,borderLeft:`1px solid black`,borderRight:`1px solid black`,marginLeft:`-1px`,marginRight:`-1px`,boxSizing:`border-box`,display:`inline`},".cm-ySelectionCaretDot":{borderRadius:`50%`,position:`absolute`,width:`.4em`,height:`.4em`,top:`-.2em`,left:`-.2em`,backgroundColor:`inherit`,transition:`transform .3s ease-in-out`,boxSizing:`border-box`},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:`bottom center`,transform:`scale(0)`},".cm-ySelectionInfo":{position:`absolute`,top:`-1.05em`,left:`-1px`,fontSize:`.75em`,fontFamily:`serif`,fontStyle:`normal`,fontWeight:`normal`,lineHeight:`normal`,userSelect:`none`,color:`white`,paddingLeft:`2px`,paddingRight:`2px`,zIndex:101,transition:`opacity .3s ease-in-out`,backgroundColor:`inherit`,opacity:0,transitionDelay:`0s`,whiteSpace:`nowrap`},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:`0s`}}),Oe=z.define(),ke=class extends ye{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return k(`span`,[d(`class`,`cm-ySelectionCaret`),d(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[y(``),k(`div`,[d(`class`,`cm-ySelectionCaretDot`)]),y(``),k(`div`,[d(`class`,`cm-ySelectionInfo`)],[y(this.name)]),y(``)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},Ae=class{constructor(e){this.conf=e.state.facet(W),this._listener=({added:t,updated:n,removed:r},i,a)=>{t.concat(n).concat(r).findIndex(e=>e!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[Oe.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=_e.of([])}destroy(){this._awareness.off(`change`,this._listener)}update(e){let t=this.conf.ytext,n=t.doc,r=this.conf.awareness,i=[],a=this.conf.awareness.getLocalState();if(a!=null){let n=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),i=n?e.state.selection.main:null,o=a.cursor==null?null:O(a.cursor.anchor),s=a.cursor==null?null:O(a.cursor.head);if(i!=null){let e=A(t,i.anchor),n=A(t,i.head);(a.cursor==null||!w(o,e)||!w(s,n))&&r.setLocalStateField(`cursor`,{anchor:e,head:n})}else a.cursor!=null&&n&&r.setLocalStateField(`cursor`,null)}r.getStates().forEach((a,o)=>{if(o===r.doc.clientID)return;let s=a.cursor;if(s==null||s.anchor==null||s.head==null)return;let c=x(s.anchor,n),l=x(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},f=a.user&&a.user.colorLight||u+`33`,p=b(c.index,l.index),m=ge(c.index,l.index),h=e.view.state.doc.lineAt(p),g=e.view.state.doc.lineAt(m);if(h.number===g.number)i.push({from:p,to:m,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});else{i.push({from:p,to:h.from+h.length,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})}),i.push({from:g.from,to:m,value:H.mark({attributes:{style:`background-color: ${f}`},class:`cm-ySelection`})});for(let t=h.number+1;t<g.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:H.line({attributes:{style:`background-color: ${f}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:H.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new ke(u,d)})})}),this.decorations=H.set(i,!0)}},je=L.fromClass(Ae,{decorations:e=>e.decorations}),Me=class{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},K=j.define({combine(e){return e[e.length-1]}});z.define();var Ne=class{constructor(e){this.view=e,this.conf=e.state.facet(K),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(W),this._beforeChangeSelection=null,this._mux=ue(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{let n=t.meta.get(this);if(n){let t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[I.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on(`stack-item-added`,this._onStackItemAdded),this._undoManager.on(`stack-item-popped`,this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(G)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off(`stack-item-added`,this._onStackItemAdded),this._undoManager.off(`stack-item-popped`,this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Pe=L.fromClass(Ne),Fe=({state:e,dispatch:t})=>e.facet(K).undo()||!0,Ie=({state:e,dispatch:t})=>e.facet(K).redo()||!0,Le=(e,t,{undoManager:n=new E(e)}={})=>{let r=new we(e,t),i=[W.of(r),Ee];return t&&i.push(De,je),n!==!1&&i.push(K.of(new Me(n)),Pe,I.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?Fe(t):e.inputType===`historyRedo`?Ie(t):!1}})),i},Re=[R.of({name:`javascript`,alias:[`js`,`jsx`],extensions:[`js`,`mjs`,`cjs`,`jsx`],load:async()=>ce({jsx:!0})}),R.of({name:`typescript`,alias:[`ts`,`tsx`],extensions:[`ts`,`mts`,`cts`,`tsx`],load:async()=>ce({typescript:!0,jsx:!0})}),R.of({name:`json`,alias:[`jsonc`],extensions:[`json`,`jsonc`],load:()=>D(()=>import(`./dist-BL9mEocg.js`).then(e=>e.json()),__vite__mapDeps([0,1,2,3,4]))}),R.of({name:`yaml`,alias:[`yml`],extensions:[`yaml`,`yml`],load:()=>D(()=>import(`./dist-C2luWP3Z.js`).then(e=>e.yaml()),__vite__mapDeps([5,1,2,3,4]))}),R.of({name:`css`,alias:[`scss`,`less`],extensions:[`css`,`scss`,`less`],load:async()=>T()}),R.of({name:`html`,alias:[`htm`],extensions:[`html`,`htm`],load:async()=>le()}),R.of({name:`python`,alias:[`py`],extensions:[`py`,`pyw`],load:()=>D(()=>import(`./dist-BoNTyP8X.js`).then(e=>e.python()),__vite__mapDeps([6,7,1,2,3,4]))}),R.of({name:`rust`,alias:[`rs`],extensions:[`rs`],load:()=>D(()=>import(`./dist-DKlym6RD.js`).then(e=>e.rust()),__vite__mapDeps([8,1,2,3,4]))}),R.of({name:`markdown`,alias:[`md`,`mdx`],extensions:[`md`,`mdx`,`markdown`],load:async()=>re()}),R.of({name:`bash`,alias:[`sh`,`shell`,`zsh`],extensions:[`sh`,`bash`,`zsh`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{shell:n}]=await Promise.all([D(()=>import(`./dist-BixLmXN7.js`).then(e=>e.m),__vite__mapDeps([1,2,3])),D(()=>import(`./shell-COsTRxlr.js`),[])]);return new t(e.define(n))}}),R.of({name:`go`,alias:[`golang`],extensions:[`go`],load:async()=>{let[{StreamLanguage:e,LanguageSupport:t},{go:n}]=await Promise.all([D(()=>import(`./dist-BixLmXN7.js`).then(e=>e.m),__vite__mapDeps([1,2,3])),D(()=>import(`./go-IODVg4Ok.js`),[])]);return new t(e.define(n))}})],ze=N.define(),Be=N.define(),Ve=H.line({class:`agent-flash`}),He=P.define({create(){return H.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(ze)){let{from:r,to:i}=n.value,a=[];for(let e=r;e<=i;){let n=t.state.doc.lineAt(e);a.push(Ve.range(n.from)),e=n.to+1}e=e.update({add:a,sort:!0})}else n.is(Be)&&(e=H.none);return e},provide:e=>I.decorations.from(e)});function Ue(e){let n=e.getMap(`agent-flash`);return[He,L.define(e=>{let i=0,a=Date.now(),o=null,c=null,l=!1;function u(){let t=e.state.doc.length;t!==0&&(l||(e.dispatch({effects:ze.of({from:0,to:t})}),c&&clearTimeout(c),c=setTimeout(()=>{c=null,!l&&e.dispatch({effects:Be.of(null)})},s)))}let d=e=>{if(t(n),!r(n,a))return;a=Date.now();let s=Date.now();if(s-i<500){if(!o){let e=500-(s-i);o=setTimeout(()=>{o=null,i=Date.now(),u()},e)}return}i=s,u()};n.observe(d);let f=()=>{document.visibilityState===`visible`?r(n,a)&&(a=Date.now(),i=Date.now(),u()):a=Date.now()};return document.addEventListener(`visibilitychange`,f),{update(e){},destroy(){l=!0,n.unobserve(d),document.removeEventListener(`visibilitychange`,f),o&&=(clearTimeout(o),null),c&&=(clearTimeout(c),null)}}})]}var q=/\[([^\]\n]*)\]\((<[^>\n]+>|[^)\s\n]+)(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^)\n]*\)))?\)/g,We=H.mark({class:`cm-md-internal-link`});function Ge(e,t){return t>0&&e[t-1]===`!`}function Ke(e){let t=e[2]??``;return t.startsWith(`<`)&&t.endsWith(`>`)?t.slice(1,-1):t}function qe(e){let t=new V;for(let{from:n,to:r}of e.visibleRanges){let i=e.state.doc.sliceString(n,r);q.lastIndex=0;let a=q.exec(i);for(;a!==null;){let e=Ge(i,a.index)?null:p(Ke(a));e&&e.kind!==`external`&&t.add(n+a.index,n+a.index+a[0].length,We),a=q.exec(i)}}return t.finish()}var Je=L.fromClass(class{decorations;constructor(e){this.decorations=qe(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=qe(e.view))}},{decorations:e=>e.decorations}),Ye=I.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);q.lastIndex=0;let i=q.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=Ge(r.text,i.index)?null:p(Ke(i));if(t&&t.kind!==`external`)return e.preventDefault(),t.kind===`doc`&&h(e)?(de(t),!0):(g(t),!0)}i=q.exec(r.text)}return!1}}),Xe=I.theme({".cm-md-internal-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-md-internal-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function Ze(){return[Je,Ye,Xe]}var Qe=5e3,J=null,$e=0,et=null,Y=new Map;async function tt(){let e=Date.now();return J&&e-$e<Qe?J:(J=await f(),$e=e,et=ot(J),J)}async function nt(e){let t=Date.now(),n=Y.get(e);if(n!==void 0&&t-n.time<Qe)return n.headings;try{let n=await v(e);return Y.set(e,{headings:n,time:t}),n}catch(n){return console.warn(`[wiki-link-source] /api/page-headings fetch failed:`,n),Y.set(e,{headings:[],time:t}),[]}}var X=/\[\[[^\]]*?\]\]/g,rt=H.mark({class:`cm-wiki-link`}),it=H.mark({class:`cm-wiki-link cm-wiki-link-broken`});function at(e){let t=new Set;for(let n of e)t.add(n.docName.toLowerCase()),n.title&&t.add(n.title.toLowerCase());return t}function ot(e){let t=at(e);for(let n of e){let e=n.docName.split(`/`);e.pop();let r=``;for(let n of e)r=r?`${r}/${n}`:n,t.add(r.toLowerCase())}return t}function st(e){return e.split(/[#|]/)[0].trim().toLowerCase()}function ct(e){let t=new V,n=J?et:null;for(let{from:r,to:i}of e.visibleRanges){let a=e.state.doc.sliceString(r,i);X.lastIndex=0;let o=X.exec(a);for(;o!==null;){let e=rt;if(n){let t=st(o[0].slice(2,-2));t&&!n.has(t)&&(e=it)}t.add(r+o.index,r+o.index+o[0].length,e),o=X.exec(a)}}return t.finish()}var lt=L.fromClass(class{decorations;cacheWarmAtBuild;constructor(e){this.cacheWarmAtBuild=J!==null,this.decorations=ct(e),this.cacheWarmAtBuild||this.warmCache(e)}update(e){let t=J!==null;(e.docChanged||e.viewportChanged||!this.cacheWarmAtBuild&&t)&&(this.cacheWarmAtBuild=t,this.decorations=ct(e.view))}warmCache(e){tt().then(()=>{try{e.dispatch({})}catch{}}).catch(e=>{console.warn(`[wiki-link-source] warmCache fetch failed:`,e)})}},{decorations:e=>e.decorations}),Z=/\[\[([^[\]|#]+?)(?:#([^\]|]+?))?(?:\|([^\]]+?))?\]\]/g,ut=I.domEventHandlers({mousedown(e,t){if(!e.ctrlKey&&!e.metaKey)return!1;let n=t.posAtCoords({x:e.clientX,y:e.clientY});if(n===null)return!1;let r=t.state.doc.lineAt(n);Z.lastIndex=0;let i=Z.exec(r.text);for(;i!==null;){let t=r.from+i.index,a=t+i[0].length;if(n>=t&&n<=a){let t=i[1]?.trim(),n=i[2]?.trim()||null;if(t){let r=c(t,n);if(!r)return!1;e.preventDefault(),r.kind===`external`?window.open(r.url,`_blank`,`noopener,noreferrer`):h(e)?de(r):window.location.hash=r.anchor?`#/${r.docName}?anchor=${encodeURIComponent(r.anchor)}`:`#/${r.docName}`}return!0}i=Z.exec(r.text)}return!1}});async function dt(e){let t=e.state.doc.sliceString(0,e.pos).match(/\[\[([^\]]*)$/);if(!t)return null;let n=t[1],r=e.pos-n.length,i=n.indexOf(`#`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1),a=r+i+1,o=await nt(e);if(!o.length)return null;let s=m(o,t);return s.length?{from:a,filter:!1,options:s.map(e=>({label:e.text,detail:`H${e.level}`,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.slug+a},selection:{anchor:r+e.slug.length+a.length}})}}))}:null}return{from:r,filter:!1,options:_(await tt().catch(e=>(console.warn(`[wiki-link-source] Failed to fetch pages:`,e),[])),n).map(e=>({label:e.title,detail:e.title===e.docName?void 0:e.docName,apply(t,n,r,i){let a=t.state.doc.sliceString(i,i+2)===`]]`?``:`]]`;t.dispatch({changes:{from:r,to:i,insert:e.docName+a},selection:{anchor:r+e.docName.length+a.length}})}}))}}var ft=I.theme({".cm-wiki-link":{color:`oklch(52.7% 0.154 228.4)`,fontWeight:`500`},".cm-wiki-link:hover":{textDecoration:`underline`,cursor:`pointer`}});function pt(){return[lt,ut,ft,ae.data.of({autocomplete:dt})]}var mt=H.mark({class:`cm-link-ref-broken`}),ht=/^\s{0,3}\[([^\]]+)\]:\s/,gt=/\[([^\]]*)\]\[([^\]]*)\]/g,_t=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function Q(e,t){let n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i];if(e<a.from)r=i-1;else if(e>=a.to)n=i+1;else return!0}return!1}function vt(e){let t=[];return M(e).iterate({enter(e){if(_t.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function $(e){let t=new Set,n=[],r=e.doc,i=vt(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if(Q(n.from,i))continue;let a=ht.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!Q(t.from,i)&&!ht.test(t.text))for(gt.lastIndex=0;;){let e=gt.exec(t.text);if(!e)break;let r=t.from+e.index;if(Q(r,i))continue;let a=e[2]||e[1];n.push({from:r,to:r+e[0].length,label:a.toLowerCase()})}}let a=[];for(let e of n)t.has(e.label)||a.push(mt.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),H.set(a)}var yt=P.define({create(e){return $(e)},update(e,t){return t.docChanged?$(t.state):e},provide:e=>I.decorations.from(e)}),bt=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,xt=H.mark({class:`cm-del`}),St=H.line({class:`cm-table-header`}),Ct=H.line({class:`cm-table-row`});function wt(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Tt(e,t){let n=[],r=M(e);for(let{from:i,to:a}of t)r.iterate({from:i,to:a,enter(t){if(t.name===`Strikethrough`){let e=t.from,r=t.to,i=t.node.cursor();if(i.firstChild())do i.name===`StrikethroughMark`&&(i.from===t.from?e=i.to:r=i.from);while(i.nextSibling());return e<r&&n.push(xt.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=bt.exec(r.text),a=i?i[1].length:2,o=H.line({class:`cm-list-item`,attributes:{style:`--list-hang: ${a}ch`}});n.push(o.range(r.from));return}if(t.name===`FencedCode`){let r=e.doc.lineAt(t.from),i=e.doc.lineAt(t.to);for(let t=r.number+1;t<i.number;t++){let r=e.doc.line(t),i=wt(r.text),a=H.line({class:`cm-fenced-code-line`,attributes:{style:`--line-indent: ${i}`}});n.push(a.range(r.from))}return!1}if(t.name===`TableHeader`){let r=e.doc.lineAt(t.from);return n.push(St.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Ct.range(r.from)),!1}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),H.set(n)}var Et=class{decorations;constructor(e){this.decorations=Tt(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||M(e.startState)!==M(e.state))&&(this.decorations=Tt(e.view.state,e.view.visibleRanges))}},Dt=L.fromClass(Et,{decorations:e=>e.decorations});function Ot(){return[Dt,yt]}var kt=i(),At=me({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),jt=se({settings:{background:`var(--background)`,gutterBackground:`var(--background)`}}),Mt=new xe,Nt=new xe;function Pt(t,n){let r=t.state.doc,i=1;if(r.lines>=1&&r.line(1).text===`---`){for(let e=2;e<=r.lines;e++)if(r.line(e).text===`---`){i=e+1;break}}let a=e(),o=0;for(let e=i;e<=r.lines;e++){let i=r.line(e);if(!a(i.text)&&/^#{1,6}\s/.test(i.text)){if(o===n.index){t.dispatch({selection:F.cursor(i.from),effects:I.scrollIntoView(i.from,{y:`start`})}),t.focus();return}o++}}}function Ft(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:F.cursor(r),effects:I.scrollIntoView(r,{y:`center`})}),e.focus()})}function It(e){let t=(0,Se.c)(29),{docName:n,ytext:r,provider:i,placeholder:o,isSourceModeActive:s}=e,c=(0,U.useRef)(null),l=(0,U.useRef)(null),[u,d]=(0,U.useState)(null);if(u)throw u;let{resolvedTheme:f}=a(),p;t[0]!==s||t[1]!==i.awareness?(p=()=>{let e=i.awareness;if(e)return e.setLocalStateField(`mode`,s?`source`:`wysiwyg`),()=>{e.setLocalStateField(`mode`,`wysiwyg`)}},t[0]=s,t[1]=i.awareness,t[2]=p):p=t[2];let m;t[3]!==s||t[4]!==i?(m=[i,s],t[3]=s,t[4]=i,t[5]=m):m=t[5],(0,U.useEffect)(p,m);let h=(0,U.useRef)(null),g;t[6]!==o||t[7]!==i||t[8]!==f||t[9]!==r?(g=()=>{let e=c.current;if(!e)return;let t=i.configuration.name??``,n,a=Lt;try{n=ee({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let t=pe({ydoc:i.document,ytext:r}),n=new I({state:ve.create({doc:r.toString(),extensions:[fe,be.of([ne]),re({base:ae,extensions:[oe],codeLanguages:Re}),Le(r,i.awareness),Ue(i.document),pt(),Ze(),Ot(),t,Mt.of(f===`dark`?At:jt),Nt.of(B(o??``)),I.lineWrapping,I.theme({"&":{height:`100%`}})]}),parent:e}),s=n.contentDOM;return s.addEventListener(`keydown`,a),s.addEventListener(`paste`,a),s.addEventListener(`drop`,a),s.addEventListener(`cut`,a),{view:n,ydoc:i.document,ytext:r,provider:i}}}),h.current=n,l.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),h.current=null,l.current=null,d(t instanceof Error?t:Error(String(t)))}return()=>{let e=h.current;e&&ie(e),h.current=null,l.current=null}},t[6]=o,t[7]=i,t[8]=f,t[9]=r,t[10]=g):g=t[10];let _;t[11]!==i||t[12]!==r?(_=[r,i],t[11]=i,t[12]=r,t[13]=_):_=t[13],(0,U.useEffect)(g,_);let v,y;t[14]===f?(v=t[15],y=t[16]):(v=()=>{l.current&&l.current.dispatch({effects:Mt.reconfigure(f===`dark`?At:jt)})},y=[f],t[14]=f,t[15]=v,t[16]=y),(0,U.useEffect)(v,y);let b,x;t[17]===o?(b=t[18],x=t[19]):(b=()=>{l.current&&l.current.dispatch({effects:Nt.reconfigure(B(o??``))})},x=[o],t[17]=o,t[18]=b,t[19]=x),(0,U.useEffect)(b,x);let C,w;t[20]!==n||t[21]!==s?(w=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!s)return;let r=l.current;r&&(Pt(r,t),te(n))};return window.addEventListener(S,e),()=>window.removeEventListener(S,e)},C=[n,s],t[20]=n,t[21]=s,t[22]=C,t[23]=w):(C=t[22],w=t[23]),(0,U.useEffect)(w,C);let T,E;t[24]!==n||t[25]!==s?(T=()=>{if(!s)return;let e=l.current;if(!e)return;let t=he(n);if(t){if(t.kind===`outline`){Pt(e,t.detail);return}Ft(e,t.detail)}},E=[n,s],t[24]=n,t[25]=s,t[26]=T,t[27]=E):(T=t[26],E=t[27]),(0,U.useEffect)(T,E);let D;return t[28]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,kt.jsx)(`div`,{ref:c,className:`source-editor h-full py-3`}),t[28]=D):D=t[28],D}function Lt(){return u()}export{It as SourceEditor};
|