@inkeep/open-knowledge 0.16.2-beta.4 → 0.17.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/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-0mGfStNQ.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/init-BGvWkJT5.mjs +1 -0
- package/dist/{init-HzYu5F2S.mjs → init-CnuOnNM4.mjs} +3 -3
- package/dist/{loader-wRC3o7BW.mjs → loader-BC1xQQPM.mjs} +2 -2
- package/dist/loader-zIR0bbiS.mjs +1 -0
- package/dist/preview-BOn8AG6T.mjs +1 -0
- package/dist/{preview-R8PXGmn8.mjs → preview-OyCPPr4x.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-DWY6kzh3.js → ActivityModeContent-Dl8kJCiz.js} +1 -1
- package/dist/public/assets/{DocumentContext-uJ7dvJjx.js → DocumentContext-ahzUXqR1.js} +11 -11
- package/dist/public/assets/{GraphPanel-Vj2cdFDc.js → GraphPanel-BqyJr7H0.js} +2 -2
- package/dist/public/assets/{OpenInAgentMenuRequestContext-axWN-B2j.js → OpenInAgentMenuRequestContext-Clw6Qq_e.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-IoSjH8ke.js → SettingsDialogBody-BhXgXyf7.js} +2 -2
- package/dist/public/assets/{SourceEditor-DUpyKeSh.js → SourceEditor-D2O63e1-.js} +2 -2
- package/dist/public/assets/{TerminalPanel-FU0wWCd1.js → TerminalPanel-CUIIoGHN.js} +23 -23
- package/dist/public/assets/{config-validation-events-COL07V5l.js → config-validation-events-Bekqky0D.js} +4 -4
- package/dist/public/assets/{dist-CYnX9zTz.js → dist-Cxvuqvas.js} +147 -147
- package/dist/public/assets/index-C0_gw-ES.js +2002 -0
- package/dist/public/assets/{keyboard-shortcuts-Chx3IvC6.js → keyboard-shortcuts-DfWwnTs8.js} +1 -1
- package/dist/public/assets/{prop-types-DS25JQVI.js → prop-types-DG4ribF0.js} +2 -2
- package/dist/public/assets/{target-navigation-intent-D14fYAPV.js → target-navigation-intent-CUr8kqsv.js} +1 -1
- package/dist/public/index.html +8 -8
- package/dist/{repair-launch-json-B751tV6R.mjs → repair-launch-json-BYM8CIj6.mjs} +2 -2
- package/dist/{repair-mcp-configs--PCY6--S.mjs → repair-mcp-configs-BamXpBTG.mjs} +2 -2
- package/dist/{src-BM908QJI.mjs → src-pqgJP0A8.mjs} +2 -2
- package/dist/start-BitVoQc9.mjs +1 -0
- package/dist/{start-DoZdHNuZ.mjs → start-D2qkDoxq.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-DIaSebgM.mjs +0 -2
- package/dist/init--AEPL4aP.mjs +0 -1
- package/dist/loader-3i4sJ6ft.mjs +0 -1
- package/dist/preview-CglsqRLU.mjs +0 -1
- package/dist/public/assets/index-DS79AHUv.js +0 -2002
- package/dist/start-CHSLqM56.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,o as n,t as r}from"./compiler-runtime-Cs91PcD2.js";import{D as i,E as a,G as o,I as s,O as c,R as l,U as u,bt as d,cn as f,dn as p,fn as m,gn as h,hn as g,in as _,ln as v,mn as y,on as b,pn as x,sn as S,un as C,xt as ee}from"./DocumentContext-
|
|
2
|
-
`);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)}},K=M.fromClass(G),q=P.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`}}),J=L.define(),Y=class extends E{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return m(`span`,[y(`class`,`cm-ySelectionCaret`),y(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[x(``),m(`div`,[y(`class`,`cm-ySelectionCaretDot`)]),x(``),m(`div`,[y(`class`,`cm-ySelectionInfo`)],[x(this.name)]),x(``)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},fe=class{constructor(e){this.conf=e.state.facet(U),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:[J.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=F.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:v(a.cursor.anchor),s=a.cursor==null?null:v(a.cursor.head);if(i!=null){let e=C(t,i.anchor),n=C(t,i.head);(a.cursor==null||!S(o,e)||!S(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=f(s.anchor,n),l=f(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},p=a.user&&a.user.colorLight||u+`33`,m=h(c.index,l.index),_=g(c.index,l.index),v=e.view.state.doc.lineAt(m),y=e.view.state.doc.lineAt(_);if(v.number===y.number)i.push({from:m,to:_,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})});else{i.push({from:m,to:v.from+v.length,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})}),i.push({from:y.from,to:_,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})});for(let t=v.number+1;t<y.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:k.line({attributes:{style:`background-color: ${p}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:k.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new Y(u,d)})})}),this.decorations=k.set(i,!0)}},pe=M.fromClass(fe,{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}},X=A.define({combine(e){return e[e.length-1]}});L.define();var he=class{constructor(e){this.view=e,this.conf=e.state.facet(X),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(U),this._beforeChangeSelection=null,this._mux=_(),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:[P.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(W)!==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)}},ge=M.fromClass(he),_e=({state:e,dispatch:t})=>e.facet(X).undo()||!0,ve=({state:e,dispatch:t})=>e.facet(X).redo()||!0,ye=(e,t,{undoManager:n=new b(e)}={})=>{let r=new H(e,t),i=[U.of(r),K];return t&&i.push(q,pe),n!==!1&&i.push(X.of(new me(n)),ge,P.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?_e(t):e.inputType===`historyRedo`?ve(t):!1}})),i},be=k.mark({class:`cm-link-ref-broken`}),Z=/^\s{0,3}\[([^\]]+)\]:\s/,Q=/\[([^\]]*)\]\[([^\]]*)\]/g,xe=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function $(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 Se(e){let t=[];return j(e).iterate({enter(e){if(xe.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ce(e){let t=new Set,n=[],r=e.doc,i=Se(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=Z.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!$(t.from,i)&&!Z.test(t.text))for(Q.lastIndex=0;;){let e=Q.exec(t.text);if(!e)break;let r=t.from+e.index;if($(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(be.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),k.set(a)}var we=O.define({create(e){return Ce(e)},update(e,t){return t.docChanged?Ce(t.state):e},provide:e=>P.decorations.from(e)}),Te=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Ee=k.mark({class:`cm-del`}),De=k.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Oe=k.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function ke(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Ae(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!T.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(T.test(r.text))return{from:t.from,to:r.to}}return null}function je(e,t){let n=[],r=j(e),i=Ae(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){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(Ee.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=Te.exec(r.text),a=i?i[1].length:2,o=k.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=ke(r.text),a=k.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(De.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),k.set(n)}var Me=class{decorations;constructor(e){this.decorations=je(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=je(e.view.state,e.view.visibleRanges))}},Ne=M.fromClass(Me,{decorations:e=>e.decorations});function Pe(){return[Ne,we]}var Fe=n(),Ie=56;function Le(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&T.test(n.line(1).text)){for(let e=2;e<=n.lines;e++)if(T.test(n.line(e).text)){r=e+1;break}}let i=w(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:D.cursor(r.from),effects:P.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Re(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:D.cursor(r),effects:P.scrollIntoView(r,{y:`center`})}),e.focus()})}function ze(e){let t=e.state.selection.main;return t.empty?``:e.state.sliceDoc(t.from,t.to)}function Be(e){let t=(0,de.c)(36),{docName:n,ytext:r,provider:s,placeholder:f,isSourceModeActive:p}=e,m=(0,B.useRef)(null),h=(0,B.useRef)(null),[g,_]=(0,B.useState)(null);if(g)throw g;let{resolvedTheme:v}=ne(),{merged:y}=l(),{openSelection:b}=ce(),x=(0,B.useRef)(b),S=(0,B.useRef)(p),C=y?.editor?.wordWrap??!0,w,T;t[0]===b?(w=t[1],T=t[2]):(w=()=>{x.current=b},T=[b],t[0]=b,t[1]=w,t[2]=T),(0,B.useEffect)(w,T);let E,D;t[3]===p?(E=t[4],D=t[5]):(E=()=>{S.current=p},D=[p],t[3]=p,t[4]=E,t[5]=D),(0,B.useEffect)(E,D);let O=(0,B.useRef)(null),k;t[6]!==f||t[7]!==s||t[8]!==v||t[9]!==C||t[10]!==r?(k=()=>{let e=m.current;if(!e)return;let t=s.configuration.name??``,n,i=He;try{n=d({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let n=null,c=o({ydoc:s.document,ytext:r}),l=new N,d=new N,p=new N,m=new P({state:ie.create({doc:r.toString(),extensions:[ue,ae.of([u]),ye(r,s.awareness),...a({themeCompartment:l,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:d,wordWrap:C}),Pe(),c,P.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,oe(t,`source`,R(e.view))},120))}),P.domEventHandlers({keydown:(e,n)=>!S.current||!te()||!re(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),x.current({docName:t,instruction:``,selectionMarkdown:ze(n)}),!0)}),p.of(I(f??``)),P.theme({"&":{height:`100%`}}),P.scrollMargins.of(Ve)]}),parent:e});oe(t,`source`,R(m));let h=m.contentDOM;return h.addEventListener(`keydown`,i),h.addEventListener(`paste`,i),h.addEventListener(`drop`,i),h.addEventListener(`cut`,i),{view:m,ydoc:s.document,ytext:r,provider:s,themeCompartment:l,wordWrapCompartment:d,placeholderCompartment:p}}}),O.current=n,h.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),O.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=O.current;e&&ee(e),O.current=null,h.current=null}},t[6]=f,t[7]=s,t[8]=v,t[9]=C,t[10]=r,t[11]=k):k=t[11];let A;t[12]!==s||t[13]!==r?(A=[r,s],t[12]=s,t[13]=r,t[14]=A):A=t[14],(0,B.useEffect)(k,A);let j,M;t[15]===n?(j=t[16],M=t[17]):(j=()=>{},M=[n],t[15]=n,t[16]=j,t[17]=M),(0,B.useEffect)(j,M);let F,L;t[18]===v?(F=t[19],L=t[20]):(L=()=>{let e=O.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?i:c)})},F=[v],t[18]=v,t[19]=F,t[20]=L),(0,B.useEffect)(L,F);let V,H;t[21]===C?(V=t[22],H=t[23]):(V=()=>{let e=O.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(C?P.lineWrapping:[])})},H=[C],t[21]=C,t[22]=V,t[23]=H),(0,B.useEffect)(V,H);let U,W;t[24]===f?(U=t[25],W=t[26]):(U=()=>{let e=O.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(I(f??``))})},W=[f],t[24]=f,t[25]=U,t[26]=W),(0,B.useEffect)(U,W);let G,K;t[27]!==n||t[28]!==p?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!p)return;let r=h.current;r&&(Le(r,t),le(n))};return window.addEventListener(z,e),()=>window.removeEventListener(z,e)},K=[n,p],t[27]=n,t[28]=p,t[29]=G,t[30]=K):(G=t[29],K=t[30]),(0,B.useEffect)(G,K);let q,J;t[31]!==n||t[32]!==p?(q=()=>{if(!p)return;let e=h.current;if(!e)return;let t=se(n);if(t){if(t.kind===`outline`){Le(e,t.detail);return}Re(e,t.detail)}},J=[n,p],t[31]=n,t[32]=p,t[33]=q,t[34]=J):(q=t[33],J=t[34]),(0,B.useEffect)(q,J);let Y;return t[35]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Fe.jsx)(`div`,{ref:m,className:`source-editor h-full pb-3`}),t[35]=Y):Y=t[35],Y}function Ve(){return{top:Ie}}function He(){return s()}export{Be as SourceEditor};
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,o as n,t as r}from"./compiler-runtime-Cs91PcD2.js";import{D as i,E as a,G as o,I as s,O as c,R as l,U as u,bt as d,cn as f,dn as p,fn as m,gn as h,hn as g,in as _,ln as v,mn as y,on as b,pn as x,sn as S,un as C,xt as ee}from"./DocumentContext-ahzUXqR1.js";import{I as w,Ir as te,fi as ne,tn as T}from"./dist-Cxvuqvas.js";import{l as re}from"./keyboard-shortcuts-DfWwnTs8.js";import{$ as E,Dt as ie,Et as D,Ft as O,J as k,Ot as A,P as j,Q as M,Tt as N,X as P,jt as F,pt as I,ut as ae,xt as L}from"./dist-C0jOOVYt.js";import{a as R,d as z,i as oe,m as se,n as ce,p as le,u as ue}from"./OpenInAgentMenuRequestContext-Clw6Qq_e.js";var B=e(t(),1),de=r(),V=class e{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:p(this.yanchor),yhead:p(this.yhead)}}static fromJSON(t){return new e(v(t.yanchor),v(t.yhead))}},H=class{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new b(e)}toYPos(e,t=0){return C(this.ytext,e,t)}fromYPos(e){let t=f(v(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 V(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?D.cursor(n.pos,n.assoc):D.range(t.pos,n.pos)}},U=A.define({combine(e){return e[e.length-1]}}),W=L.define(),G=class{constructor(e){this.view=e,this.conf=e.state.facet(U),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:[W.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(W)===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,`
|
|
2
|
+
`);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)}},K=M.fromClass(G),q=P.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`}}),J=L.define(),Y=class extends E{constructor(e,t){super(),this.color=e,this.name=t}toDOM(){return m(`span`,[y(`class`,`cm-ySelectionCaret`),y(`style`,`background-color: ${this.color}; border-color: ${this.color}`)],[x(``),m(`div`,[y(`class`,`cm-ySelectionCaretDot`)]),x(``),m(`div`,[y(`class`,`cm-ySelectionInfo`)],[x(this.name)]),x(``)])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},fe=class{constructor(e){this.conf=e.state.facet(U),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:[J.of([])]})},this._awareness=this.conf.awareness,this._awareness.on(`change`,this._listener),this.decorations=F.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:v(a.cursor.anchor),s=a.cursor==null?null:v(a.cursor.head);if(i!=null){let e=C(t,i.anchor),n=C(t,i.head);(a.cursor==null||!S(o,e)||!S(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=f(s.anchor,n),l=f(s.head,n);if(c==null||l==null||c.type!==t||l.type!==t)return;let{color:u=`#30bced`,name:d=`Anonymous`}=a.user||{},p=a.user&&a.user.colorLight||u+`33`,m=h(c.index,l.index),_=g(c.index,l.index),v=e.view.state.doc.lineAt(m),y=e.view.state.doc.lineAt(_);if(v.number===y.number)i.push({from:m,to:_,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})});else{i.push({from:m,to:v.from+v.length,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})}),i.push({from:y.from,to:_,value:k.mark({attributes:{style:`background-color: ${p}`},class:`cm-ySelection`})});for(let t=v.number+1;t<y.number;t++){let n=e.view.state.doc.line(t).from;i.push({from:n,to:n,value:k.line({attributes:{style:`background-color: ${p}`,class:`cm-yLineSelection`}})})}}i.push({from:l.index,to:l.index,value:k.widget({side:l.index-c.index>0?-1:1,block:!1,widget:new Y(u,d)})})}),this.decorations=k.set(i,!0)}},pe=M.fromClass(fe,{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}},X=A.define({combine(e){return e[e.length-1]}});L.define();var he=class{constructor(e){this.view=e,this.conf=e.state.facet(X),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(U),this._beforeChangeSelection=null,this._mux=_(),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:[P.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(W)!==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)}},ge=M.fromClass(he),_e=({state:e,dispatch:t})=>e.facet(X).undo()||!0,ve=({state:e,dispatch:t})=>e.facet(X).redo()||!0,ye=(e,t,{undoManager:n=new b(e)}={})=>{let r=new H(e,t),i=[U.of(r),K];return t&&i.push(q,pe),n!==!1&&i.push(X.of(new me(n)),ge,P.domEventHandlers({beforeinput(e,t){return e.inputType===`historyUndo`?_e(t):e.inputType===`historyRedo`?ve(t):!1}})),i},be=k.mark({class:`cm-link-ref-broken`}),Z=/^\s{0,3}\[([^\]]+)\]:\s/,Q=/\[([^\]]*)\]\[([^\]]*)\]/g,xe=new Set([`FencedCode`,`CodeBlock`,`InlineCode`]);function $(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 Se(e){let t=[];return j(e).iterate({enter(e){if(xe.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ce(e){let t=new Set,n=[],r=e.doc,i=Se(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=Z.exec(n.text);a&&t.add(a[1].toLowerCase())}for(let e=1;e<=r.lines;e++){let t=r.line(e);if(!$(t.from,i)&&!Z.test(t.text))for(Q.lastIndex=0;;){let e=Q.exec(t.text);if(!e)break;let r=t.from+e.index;if($(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(be.range(e.from,e.to));return a.sort((e,t)=>e.from-t.from),k.set(a)}var we=O.define({create(e){return Ce(e)},update(e,t){return t.docChanged?Ce(t.state):e},provide:e=>P.decorations.from(e)}),Te=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Ee=k.mark({class:`cm-del`}),De=k.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Oe=k.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function ke(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Ae(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!w.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(w.test(r.text))return{from:t.from,to:r.to}}return null}function je(e,t){let n=[],r=j(e),i=Ae(e),a=e=>i!==null&&e>=i.from&&e<=i.to;for(let{from:i,to:o}of t)r.iterate({from:i,to:o,enter(t){if(!a(t.from)){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(Ee.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=Te.exec(r.text),a=i?i[1].length:2,o=k.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=ke(r.text),a=k.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(De.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Oe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),k.set(n)}var Me=class{decorations;constructor(e){this.decorations=je(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=je(e.view.state,e.view.visibleRanges))}},Ne=M.fromClass(Me,{decorations:e=>e.decorations});function Pe(){return[Ne,we]}var Fe=n(),Ie=56;function Le(e,t){let n=e.state.doc,r=1;if(n.lines>=1&&w.test(n.line(1).text)){for(let e=2;e<=n.lines;e++)if(w.test(n.line(e).text)){r=e+1;break}}let i=T(),a=0;for(let o=r;o<=n.lines;o++){let r=n.line(o);if(!i(r.text)&&/^#{1,6}\s/.test(r.text)){if(a===t.index){e.dispatch({selection:D.cursor(r.from),effects:P.scrollIntoView(r.from,{y:`start`})}),e.focus();return}a++}}}function Re(e,t){requestAnimationFrame(()=>{let n=e.state.doc,r=Math.min(t.offset,n.length);e.dispatch({selection:D.cursor(r),effects:P.scrollIntoView(r,{y:`center`})}),e.focus()})}function ze(e){let t=e.state.selection.main;return t.empty?``:e.state.sliceDoc(t.from,t.to)}function Be(e){let t=(0,de.c)(36),{docName:n,ytext:r,provider:s,placeholder:f,isSourceModeActive:p}=e,m=(0,B.useRef)(null),h=(0,B.useRef)(null),[g,_]=(0,B.useState)(null);if(g)throw g;let{resolvedTheme:v}=ne(),{merged:y}=l(),{openSelection:b}=ce(),x=(0,B.useRef)(b),S=(0,B.useRef)(p),C=y?.editor?.wordWrap??!0,w,T;t[0]===b?(w=t[1],T=t[2]):(w=()=>{x.current=b},T=[b],t[0]=b,t[1]=w,t[2]=T),(0,B.useEffect)(w,T);let E,D;t[3]===p?(E=t[4],D=t[5]):(E=()=>{S.current=p},D=[p],t[3]=p,t[4]=E,t[5]=D),(0,B.useEffect)(E,D);let O=(0,B.useRef)(null),k;t[6]!==f||t[7]!==s||t[8]!==v||t[9]!==C||t[10]!==r?(k=()=>{let e=m.current;if(!e)return;let t=s.configuration.name??``,n,i=He;try{n=d({docName:t,container:e,sizeStats:{viewCount:0,bytes:r.length},factory:e=>{let n=null,c=o({ydoc:s.document,ytext:r}),l=new N,d=new N,p=new N,m=new P({state:ie.create({doc:r.toString(),extensions:[ue,ae.of([u]),ye(r,s.awareness),...a({themeCompartment:l,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:d,wordWrap:C}),Pe(),c,P.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,oe(t,`source`,R(e.view))},120))}),P.domEventHandlers({keydown:(e,n)=>!S.current||!te()||!re(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),x.current({docName:t,instruction:``,selectionMarkdown:ze(n)}),!0)}),p.of(I(f??``)),P.theme({"&":{height:`100%`}}),P.scrollMargins.of(Ve)]}),parent:e});oe(t,`source`,R(m));let h=m.contentDOM;return h.addEventListener(`keydown`,i),h.addEventListener(`paste`,i),h.addEventListener(`drop`,i),h.addEventListener(`cut`,i),{view:m,ydoc:s.document,ytext:r,provider:s,themeCompartment:l,wordWrapCompartment:d,placeholderCompartment:p}}}),O.current=n,h.current=n.view}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),O.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=O.current;e&&ee(e),O.current=null,h.current=null}},t[6]=f,t[7]=s,t[8]=v,t[9]=C,t[10]=r,t[11]=k):k=t[11];let A;t[12]!==s||t[13]!==r?(A=[r,s],t[12]=s,t[13]=r,t[14]=A):A=t[14],(0,B.useEffect)(k,A);let j,M;t[15]===n?(j=t[16],M=t[17]):(j=()=>{},M=[n],t[15]=n,t[16]=j,t[17]=M),(0,B.useEffect)(j,M);let F,L;t[18]===v?(F=t[19],L=t[20]):(L=()=>{let e=O.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?i:c)})},F=[v],t[18]=v,t[19]=F,t[20]=L),(0,B.useEffect)(L,F);let V,H;t[21]===C?(V=t[22],H=t[23]):(V=()=>{let e=O.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(C?P.lineWrapping:[])})},H=[C],t[21]=C,t[22]=V,t[23]=H),(0,B.useEffect)(V,H);let U,W;t[24]===f?(U=t[25],W=t[26]):(U=()=>{let e=O.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(I(f??``))})},W=[f],t[24]=f,t[25]=U,t[26]=W),(0,B.useEffect)(U,W);let G,K;t[27]!==n||t[28]!==p?(G=()=>{let e=function(e){let t=e.detail;if(!t||t.mode!==`source`||!p)return;let r=h.current;r&&(Le(r,t),le(n))};return window.addEventListener(z,e),()=>window.removeEventListener(z,e)},K=[n,p],t[27]=n,t[28]=p,t[29]=G,t[30]=K):(G=t[29],K=t[30]),(0,B.useEffect)(G,K);let q,J;t[31]!==n||t[32]!==p?(q=()=>{if(!p)return;let e=h.current;if(!e)return;let t=se(n);if(t){if(t.kind===`outline`){Le(e,t.detail);return}Re(e,t.detail)}},J=[n,p],t[31]=n,t[32]=p,t[33]=q,t[34]=J):(q=t[33],J=t[34]),(0,B.useEffect)(q,J);let Y;return t[35]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Fe.jsx)(`div`,{ref:m,className:`source-editor h-full pb-3`}),t[35]=Y):Y=t[35],Y}function Ve(){return{top:Ie}}function He(){return s()}export{Be as SourceEditor};
|