@inkeep/open-knowledge 0.48.0-beta.3 → 0.48.1
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/{acp-harness-probe-DIIQjTRp.mjs → acp-harness-probe-B4V6KJkv.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/constants-BtTFdIEz.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-DKL1cDrG.mjs → init-BTuBIiJr.mjs} +3 -3
- package/dist/init-PWlU6Inh.mjs +1 -0
- package/dist/{launch-json-removal-DB_ok2PB.mjs → launch-json-removal-BuFfgFK6.mjs} +2 -2
- package/dist/{loader-uj7aNLsh.mjs → loader-Faz8vqCB.mjs} +2 -2
- package/dist/loader-LMzEjgFg.mjs +1 -0
- package/dist/{preview-Dk_BQ90q.mjs → preview-BIeu4g0O.mjs} +2 -2
- package/dist/preview-CepegBxs.mjs +1 -0
- package/dist/public/assets/FeedbackForm-BXkT1oYo.js +1 -0
- package/dist/public/assets/{SourceEditor-CeQc0tTS.js → SourceEditor-BgyZO1t7.js} +1 -1
- package/dist/public/assets/{globals-i3eL0jPG.js → globals-CiUwipyS.js} +1 -1
- package/dist/public/assets/{index-CUE-YCY2.js → index-C8WPpAGW.js} +3 -3
- package/dist/public/assets/typing-burst-detector-BHTVn_xV.js +8 -0
- package/dist/public/assets/{uninstall-Baseq7_l.js → uninstall-D82wPzEe.js} +1 -1
- package/dist/public/index.html +3 -3
- package/dist/public/uninstall.html +2 -2
- package/dist/{repair-launch-json-DzxXAo0b.mjs → repair-launch-json-t6-ItmBL.mjs} +2 -2
- package/dist/{repair-mcp-configs-BlpR9vnM.mjs → repair-mcp-configs-rKNBA3_W.mjs} +2 -2
- package/dist/{src-VEqyb6ZN.mjs → src-DBW4c9sO.mjs} +2 -2
- package/dist/{start-4OXjSb10.mjs → start-BqVtFjo1.mjs} +2 -2
- package/dist/start-RqncH3ch.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-Dp5jNJXR.mjs +0 -2
- package/dist/init-Bp5YIi45.mjs +0 -1
- package/dist/loader-C1z01owc.mjs +0 -1
- package/dist/preview-CVaFt88u.mjs +0 -1
- package/dist/public/assets/FeedbackForm-DVcz7TWB.js +0 -1
- package/dist/public/assets/typing-burst-detector-CG82yzgN.js +0 -8
- package/dist/start-DHXgmi4I.mjs +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Ar as e}from"./src-BTCvmkZK.mjs";import"./constants-
|
|
1
|
+
import{Ar as e}from"./src-BTCvmkZK.mjs";import"./constants-BtTFdIEz.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-BIeu4g0O.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-BIeu4g0O.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./index-C8WPpAGW.js";export{e as FeedbackForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-CP7yqH5z.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-BQoCzCdy.js";import{Fa as _,Ii as re,T as ie,Ta as v,ei as ae,wr as y,ya as b}from"./dist-D0lKV18u2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-CG82yzgN.js";import{f as S,g as C}from"./doc-paths-BuYvs-Sl.js";import{v as ge}from"./use-settings-route-B1Atzr9C.js";import{J as w}from"./navigation-targets-kcw1-114.js";import"./config-provider-GgI7K6tF.js";import{n as _e}from"./config-context-JFJadbOg.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as ye,ft as I,ht as L,l as R,lt as z,mt as be,nt as B,rt as V,st as H,tt as U,y as W}from"./dist-zYQJXuRH.js";import{a as xe,n as G}from"./cm-theme-CUwlOcHl.js";import{i as K,n as q,o as J,r as Y}from"./dist-DgD72kci.js";import{o as Se,r as Ce}from"./selection-context-BN5sWQOX.js";import{l as we}from"./lint-config-client-CKLyoxWn.js";import{a as Te,i as X,n as Ee,o as De,r as Oe,t as ke}from"./dist-BX-8uxZE.js";import{n as Ae,t as je}from"./src-BFaead-K.js";var Z=e(p(),1),Me=h();function Ne(){let e=d();return e===null?null:new Set(e.keys())}function Pe(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);v.lastIndex=0;for(let e=v.exec(t);e!==null;e=v.exec(t)){let t=e[2];if(!_(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&_(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Fe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Pe(e.state,e.visibleRanges,Ne())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Pe(e.view.state,e.view.visibleRanges,Ne()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Ie(e,t){return e.enabled?[ke(),Oe(async n=>Le(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function Q(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Le(e,t){let n=[];for(let r of t){let t=Q(e,r.range.start),i=Q(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Re(r);o&&(a.actions=[o]),n.push(a)}return n}function Re(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:Q(n,e.range.start),to:Q(n,e.range.end),insert:e.newText}))})}}}var ze=[I(),F(),z(),P(),B(),V(),ve.allowMultipleSelections.of(!0),E(),R(),Y(),q(),L(),U(),H(),X(),ye.of([...K,...G,...De,...W,...J,...Ee])],Be=A.mark({class:`cm-link-ref-broken`}),Ve=/^\s{0,3}\[([^\]]+)\]:\s/,He=/\[([^\]]*)\]\[([^\]]*)\]/g,Ue=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 We(e){let t=[];return j(e).iterate({enter(e){if(Ue.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=Ve.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)&&!Ve.test(t.text))for(He.lastIndex=0;;){let e=He.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),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(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(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.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=Ze(r.text),a=A.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(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,Me.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Z.useRef)(null),h=(0,Z.useRef)(null),[g,_]=(0,Z.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Z.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=we(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):ie),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Z.useEffect)(O,k);let A=(0,Z.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[ze,Te({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),ye.of([xe]),je(o,s.awareness),ye.of(Ae),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Fe(t),ce(),p.of(Ie(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Ce(t,`source`,Se(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!re()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(be(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Ce(t,`source`,Se(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Z.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Z.useEffect)(P,F);let I,L;t[22]===v?(I=t[23],L=t[24]):(L=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},I=[v],t[22]=v,t[23]=I,t[24]=L),(0,Z.useEffect)(L,I);let R,z;t[25]===x?(R=t[26],z=t[27]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},z=[x],t[25]=x,t[26]=R,t[27]=z),(0,Z.useEffect)(R,z);let B,V;t[28]===d?(B=t[29],V=t[30]):(B=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(be(d??``))})},V=[d],t[28]=d,t[29]=B,t[30]=V),(0,Z.useEffect)(B,V);let H;t[31]!==a||t[32]!==w?(H=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Ie(w,a))})},t[31]=a,t[32]=w,t[33]=H):H=t[33];let U;t[34]===E?U=t[35]:(U=[E],t[34]=E,t[35]=U),(0,Z.useEffect)(H,U);let W,G;t[36]!==a||t[37]!==f?(W=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},G=[a,f],t[36]=a,t[37]=f,t[38]=W,t[39]=G):(W=t[38],G=t[39]),(0,Z.useEffect)(W,G);let K,q;t[40]!==a||t[41]!==f?(K=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},q=[a,f],t[40]=a,t[41]=f,t[42]=K,t[43]=q):(K=t[42],q=t[43]),(0,Z.useEffect)(K,q);let J,Y;t[44]!==a||t[45]!==f||t[46]!==s?(J=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},Y=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=J,t[48]=Y):(J=t[47],Y=t[48]),(0,Z.useEffect)(J,Y);let X;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=X):X=t[49],X}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};
|
|
1
|
+
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{Gt as n,Lt as r,Rt as i,Xt as a,_t as o,bt as s,gn as c,k as l,mn as u,xt as d,yt as f}from"./DocumentContext-CP7yqH5z.js";import{t as p}from"./react-f2sANaYj.js";import{n as m}from"./dist-PQ5KMVDh.js";import{t as h}from"./compiler-runtime-BfE3aGVn.js";import{E as g,a as ee,i as te,o as ne}from"./CodeMirrorPropInput-BQoCzCdy.js";import{Fa as _,Ii as re,T as ie,Ta as v,ei as ae,wr as y,ya as b}from"./dist-D0lKV18u2.js";import{A as oe,C as x,D as se,I as ce,N as le,a as ue,i as de,j as fe,t as pe,u as me,x as he}from"./typing-burst-detector-BHTVn_xV.js";import{f as S,g as C}from"./doc-paths-BuYvs-Sl.js";import{v as ge}from"./use-settings-route-B1Atzr9C.js";import{J as w}from"./navigation-targets-kcw1-114.js";import"./config-provider-GgI7K6tF.js";import{n as _e}from"./config-context-JFJadbOg.js";import{Dt as T,E,Et as D,Ft as O,It as k,J as A,Ot as ve,P as j,Q as M,X as N,_ as P,ct as F,dt as ye,ft as I,ht as L,l as R,lt as z,mt as be,nt as B,rt as V,st as H,tt as U,y as W}from"./dist-zYQJXuRH.js";import{a as xe,n as G}from"./cm-theme-CUwlOcHl.js";import{i as K,n as q,o as J,r as Y}from"./dist-DgD72kci.js";import{o as Se,r as Ce}from"./selection-context-BN5sWQOX.js";import{l as we}from"./lint-config-client-CKLyoxWn.js";import{a as Te,i as X,n as Ee,o as De,r as Oe,t as ke}from"./dist-BX-8uxZE.js";import{n as Ae,t as je}from"./src-BFaead-K.js";var Z=e(p(),1),Me=h();function Ne(){let e=d();return e===null?null:new Set(e.keys())}function Pe(e,t,n){let r=[],i=j(e);if(n!=null){let a=[];for(let{from:e,to:n}of t)i.iterate({from:e,to:n,enter(e){if(e.name===`InlineCode`||e.name===`FencedCode`)return a.push({from:e.from,to:e.to}),!1}});let o=(e,t)=>a.some(n=>e>=n.from&&t<=n.to);for(let{from:i,to:a}of t){let t=e.doc.sliceString(i,a);v.lastIndex=0;for(let e=v.exec(t);e!==null;e=v.exec(t)){let t=e[2];if(!_(t))continue;let a=i+(e.index??0)+e[1].length,s=a+t.length+1;o(a,s)||r.push(A.mark({class:n.has(t)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":t}}).range(a,s))}}}for(let{from:a,to:s}of t)i.iterate({from:a,to:s,enter(t){if(t.name!==`InlineCode`)return;let i=e.doc.sliceString(t.from,t.to),a=i.length-i.replace(/^`+/,``).length,s=i.length-i.replace(/`+$/,``).length,c=i.slice(a,i.length-s),l=/^\/([a-z0-9][a-z0-9-]{1,63})$/.exec(c)?.[1];if(l!==void 0&&_(l)&&n!=null)return r.push(A.mark({class:n.has(l)?`cm-skill-ref`:`cm-skill-ref cm-skill-ref-missing`,attributes:{"data-skill-ref":l}}).range(t.from+a,t.to-s)),!1;let u=o.exec(c);if(u)return r.push(A.mark({class:`cm-skill-path-link`,attributes:{"data-skill-path":u[1]}}).range(t.from+a,t.to-s)),!1}});return r.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(r)}function Fe(e){let t=s(e);return t===null?[]:[M.fromClass(class{decorations;constructor(e){this.decorations=Pe(e.state,e.visibleRanges,Ne())}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=Pe(e.view.state,e.view.visibleRanges,Ne()))}},{decorations:e=>e.decorations}),N.domEventHandlers({mousedown(n){let r=n.target?.closest?.(`[data-skill-ref]`),i=r instanceof HTMLElement?r.dataset.skillRef:void 0;if(i!==void 0){n.preventDefault();let e=d()?.get(i);return window.location.hash=e===void 0?C():S(w({scope:e.scope,name:i,path:e.path})),!0}let a=n.target?.closest?.(`.cm-skill-path-link`),o=a instanceof HTMLElement?a.dataset.skillPath:void 0;return o===void 0?!1:(n.preventDefault(),window.location.hash=f(t,e,o),!0)}})]}function Ie(e,t){return e.enabled?[ke(),Oe(async n=>Le(n.state.doc,await y(n.state.doc.toString(),e,t)),{delay:600})]:[]}function Q(e,t){let n=Math.min(Math.max(t.line+1,1),e.lines),r=e.line(n);return Math.min(r.from+Math.max(0,t.character),r.to)}function Le(e,t){let n=[];for(let r of t){let t=Q(e,r.range.start),i=Q(e,r.range.end),a={from:t,to:Math.max(i,t),severity:r.severity,message:r.message,source:`${r.source}/${r.code}`},o=Re(r);o&&(a.actions=[o]),n.push(a)}return n}function Re(e){let t=e.fixes;return!t||t.length===0?null:{name:`Fix`,apply(e){let n=e.state.doc;e.dispatch({changes:t.map(e=>({from:Q(n,e.range.start),to:Q(n,e.range.end),insert:e.newText}))})}}}var ze=[I(),F(),z(),P(),B(),V(),ve.allowMultipleSelections.of(!0),E(),R(),Y(),q(),L(),U(),H(),X(),ye.of([...K,...G,...De,...W,...J,...Ee])],Be=A.mark({class:`cm-link-ref-broken`}),Ve=/^\s{0,3}\[([^\]]+)\]:\s/,He=/\[([^\]]*)\]\[([^\]]*)\]/g,Ue=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 We(e){let t=[];return j(e).iterate({enter(e){if(Ue.has(e.name))return t.push({from:e.from,to:e.to}),!1}}),t.sort((e,t)=>e.from-t.from),t}function Ge(e){let t=new Set,n=[],r=e.doc,i=We(e);for(let e=1;e<=r.lines;e++){let n=r.line(e);if($(n.from,i))continue;let a=Ve.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)&&!Ve.test(t.text))for(He.lastIndex=0;;){let e=He.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),A.set(a)}var Ke=k.define({create(e){return Ge(e)},update(e,t){return t.docChanged?Ge(t.state):e},provide:e=>N.decorations.from(e)}),qe=/^(\s*(?:[-*+]|\d+[.)]) (?:\[[ x]\] )?)/,Je=A.mark({class:`cm-del`}),Ye=A.line({class:`cm-table-header`,attributes:{style:`--list-hang: 2ch`}}),Xe=A.line({class:`cm-table-row`,attributes:{style:`--list-hang: 2ch`}});function Ze(e){let t=0;for(let n of e)if(n===` `)t++;else if(n===` `)t+=4;else break;return t}function Qe(e){if(e.doc.lines<2)return null;let t=e.doc.line(1);if(!b.test(t.text))return null;for(let n=2;n<=e.doc.lines;n++){let r=e.doc.line(n);if(b.test(r.text))return{from:t.from,to:r.to}}return null}function $e(e,t){let n=[],r=j(e),i=Qe(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(Je.range(e,r)),!1}if(t.name===`ListItem`){let r=e.doc.lineAt(t.from),i=qe.exec(r.text),a=i?i[1].length:2,o=A.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=Ze(r.text),a=A.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(Ye.range(r.from)),!1}if(t.name===`TableRow`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}if(t.name===`TableDelimiter`&&t.node.parent?.name===`Table`){let r=e.doc.lineAt(t.from);return n.push(Xe.range(r.from)),!1}}}});return n.sort((e,t)=>e.from-t.from||e.value.startSide-t.value.startSide),A.set(n)}var et=class{decorations;constructor(e){this.decorations=$e(e.state,e.visibleRanges)}update(e){(e.docChanged||e.viewportChanged||j(e.startState)!==j(e.state))&&(this.decorations=$e(e.view.state,e.view.visibleRanges))}},tt=M.fromClass(et,{decorations:e=>e.decorations});function nt(){return[tt,Ke]}var rt=t(),it=56,at=O.define();function ot(e,t,n){let r=x(e.state.doc)[t.index];r&&a(n,()=>{e.dispatch({selection:T.cursor(r.from),effects:N.scrollIntoView(r.from,{y:`start`})}),e.focus()})}function st(e,t,n,r){requestAnimationFrame(()=>{if(!n())return;let i=e.state.doc,o=Math.min(t.offset,i.length);a(r,()=>{e.dispatch({selection:T.cursor(o),effects:N.scrollIntoView(o,{y:`center`})}),e.focus()})})}function ct(e,t,n){let r=e.state.doc,i=Math.min(Math.max(t.line,1),r.lines),o=r.line(i),s=Math.min(o.from+Math.max(0,t.column-1),o.to);a(n,()=>{e.dispatch({selection:T.cursor(s),effects:N.scrollIntoView(s,{y:`start`})}),e.focus()})}function lt(e){let t=(0,Me.c)(50),{docName:a,ytext:o,provider:s,placeholder:d,isSourceModeActive:f}=e,p=(0,Z.useRef)(null),h=(0,Z.useRef)(null),[g,_]=(0,Z.useState)(null);if(g)throw g;let{resolvedTheme:v}=m(),{merged:y}=_e(),b=(0,Z.useRef)(f),x=y?.editor?.wordWrap??!0,{data:S}=we(a),C;t[0]!==S?.effective||t[1]!==y?(C=S?.effective??(y?.contentRules?ae(y.contentRules):ie),t[0]=S?.effective,t[1]=y,t[2]=C):C=t[2];let w=C,T;t[3]===w?T=t[4]:(T=JSON.stringify(w),t[3]=w,t[4]=T);let E=T,O,k;t[5]===f?(O=t[6],k=t[7]):(O=()=>{b.current=f},k=[f],t[5]=f,t[6]=O,t[7]=k),(0,Z.useEffect)(O,k);let A=(0,Z.useRef)(null),j;t[8]!==a||t[9]!==w||t[10]!==d||t[11]!==s||t[12]!==v||t[13]!==x||t[14]!==o?(j=()=>{let e=p.current;if(!e)return;let t=s.configuration.name??``,f,m=dt;try{f=r({docName:t,container:e,sizeStats:{viewCount:0,bytes:o.length},factory:e=>{let r=null,i=l({ydoc:s.document,ytext:o}),c=new D,u=new D,f=new D,p=new D,h=new N({state:ve.create({doc:o.toString(),extensions:[ze,Te({scrollToMatch:e=>n(t)?N.scrollIntoView(e,{y:`start`}):at.of(null)}),ye.of([xe]),je(o,s.awareness),ye.of(Ae),...te({themeCompartment:c,resolvedTheme:v,ydoc:s.document,wordWrapCompartment:u,wordWrap:x,currentDocName:t}),nt(),Fe(t),ce(),p.of(Ie(w,a)),i,N.updateListener.of(e=>{!e.selectionSet&&!e.docChanged||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,de(t,`source`,ue(e.view)),Ce(t,`source`,Se(e.view,t))},120))}),N.domEventHandlers({keydown:(e,t)=>!b.current||!re()||!ge(e,`edit-with-ai`)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pe(),!0)}),f.of(be(d??``)),N.theme({"&":{height:`100%`}}),N.scrollMargins.of(ut)]}),parent:e});de(t,`source`,ue(h)),Ce(t,`source`,Se(h,t));let g=h.contentDOM;return g.addEventListener(`keydown`,m),g.addEventListener(`paste`,m),g.addEventListener(`drop`,m),g.addEventListener(`cut`,m),{view:h,ydoc:s.document,ytext:o,provider:s,themeCompartment:c,wordWrapCompartment:u,placeholderCompartment:f,lintCompartment:p}}}),A.current=f,h.current=f.view,u(a,f.view)}catch(e){let t=e;console.error(`[SourceEditor] mountCmEditor failed`,t),A.current=null,h.current=null,_(t instanceof Error?t:Error(String(t)))}return()=>{let e=A.current;e&&(i(e),c(a,e.view)),A.current=null,h.current=null}},t[8]=a,t[9]=w,t[10]=d,t[11]=s,t[12]=v,t[13]=x,t[14]=o,t[15]=j):j=t[15];let M;t[16]!==s||t[17]!==o?(M=[o,s],t[16]=s,t[17]=o,t[18]=M):M=t[18],(0,Z.useEffect)(j,M);let P,F;t[19]===a?(P=t[20],F=t[21]):(P=()=>{},F=[a],t[19]=a,t[20]=P,t[21]=F),(0,Z.useEffect)(P,F);let I,L;t[22]===v?(I=t[23],L=t[24]):(L=()=>{let e=A.current;e&&e.view.dispatch({effects:e.themeCompartment.reconfigure(v===`dark`?ee:ne)})},I=[v],t[22]=v,t[23]=I,t[24]=L),(0,Z.useEffect)(L,I);let R,z;t[25]===x?(R=t[26],z=t[27]):(R=()=>{let e=A.current;e&&e.view.dispatch({effects:e.wordWrapCompartment.reconfigure(x?N.lineWrapping:[])})},z=[x],t[25]=x,t[26]=R,t[27]=z),(0,Z.useEffect)(R,z);let B,V;t[28]===d?(B=t[29],V=t[30]):(B=()=>{let e=A.current;e&&e.view.dispatch({effects:e.placeholderCompartment.reconfigure(be(d??``))})},V=[d],t[28]=d,t[29]=B,t[30]=V),(0,Z.useEffect)(B,V);let H;t[31]!==a||t[32]!==w?(H=()=>{let e=A.current;e&&e.view.dispatch({effects:e.lintCompartment.reconfigure(Ie(w,a))})},t[31]=a,t[32]=w,t[33]=H):H=t[33];let U;t[34]===E?U=t[35]:(U=[E],t[34]=E,t[35]=U),(0,Z.useEffect)(H,U);let W,G;t[36]!==a||t[37]!==f?(W=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||t.mode!==`source`||!f)return;let n=h.current;n&&(ot(n,t,a),oe(a))};return window.addEventListener(he,e),()=>window.removeEventListener(he,e)},G=[a,f],t[36]=a,t[37]=f,t[38]=W,t[39]=G):(W=t[38],G=t[39]),(0,Z.useEffect)(W,G);let K,q;t[40]!==a||t[41]!==f?(K=()=>{let e=function(e){let t=e.detail;if(!t||t.docName!==a||!f)return;let n=h.current;n&&(ct(n,t,a),oe(a))};return window.addEventListener(me,e),()=>window.removeEventListener(me,e)},q=[a,f],t[40]=a,t[41]=f,t[42]=K,t[43]=q):(K=t[42],q=t[43]),(0,Z.useEffect)(K,q);let J,Y;t[44]!==a||t[45]!==f||t[46]!==s?(J=()=>{if(!f)return;let e=h.current;if(!e)return;let t=le(a);if(!t)return;if(t.kind!==`selection-offset`){fe(a),t.kind===`outline`?ot(e,t.detail,a):t.kind===`lint`?ct(e,t.detail,a):t.kind===`raw-mdx`&&st(e,t.detail,()=>b.current,a);return}let n=!1,r=null;return queueMicrotask(()=>{if(n)return;let t=le(a);t?.kind===`selection-offset`&&(r=se({view:e,docName:a,navigation:t,ydoc:s.document,transition:{from:`wysiwyg`,to:`source`}}),r&&fe(a))}),()=>{n=!0,r?.cancel(`mode-flip`)}},Y=[a,f,s],t[44]=a,t[45]=f,t[46]=s,t[47]=J,t[48]=Y):(J=t[47],Y=t[48]),(0,Z.useEffect)(J,Y);let X;return t[49]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,rt.jsx)(`div`,{ref:p,className:`source-editor h-full pb-3`}),t[49]=X):X=t[49],X}function ut(){return{top:it}}function dt(){return g()}export{lt as SourceEditor,st as applyRawMdxNavigation};
|