838eec30a8
- Implemented a new composable `useTheme` for managing theme state. - Added functions to read and write theme preference to local storage. - Applied theme styles to the DOM based on user preference. - Introduced a toggle function to switch between light and dark themes. refactor: enhance copilot plugin functionality - Improved request handling with sequence and document versioning. - Refactored ghost text handling to improve clarity and efficiency. - Updated markdown insertion logic to handle parsed content more robustly. - Enhanced error handling and logging for better debugging. style: update global styles for light and dark themes - Defined CSS variables for light and dark themes to streamline styling. - Improved overall styling consistency and responsiveness. - Added transitions for smoother theme changes and interactions.
2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
import{N as F}from"./vendor-lezer-common-tVQBIsvN.js";let z=0;class g{constructor(t,a,n,i){this.name=t,this.set=a,this.base=n,this.modified=i,this.id=z++}toString(){let{name:t}=this;for(let a of this.modified)a.name&&(t=`${a.name}(${t})`);return t}static define(t,a){let n=typeof t=="string"?t:"?";if(t instanceof g&&(a=t),a?.base)throw new Error("Can not derive from a modified tag");let i=new g(n,[],null,[]);if(i.set.push(i),a)for(let s of a.set)i.set.push(s);return i}static defineModifier(t){let a=new q(t);return n=>n.modified.indexOf(a)>-1?n:q.get(n.base||n,n.modified.concat(a).sort((i,s)=>i.id-s.id))}}let G=0;class q{constructor(t){this.name=t,this.instances=[],this.id=G++}static get(t,a){if(!a.length)return t;let n=a[0].instances.find(r=>r.base==t&&L(a,r.modified));if(n)return n;let i=[],s=new g(t.name,i,t,a);for(let r of a)r.instances.push(s);let c=P(a);for(let r of t.set)if(!r.modified.length)for(let m of c)i.push(q.get(r,m));return s}}function L(o,t){return o.length==t.length&&o.every((a,n)=>a==t[n])}function P(o){let t=[[]];for(let a=0;a<o.length;a++)for(let n=0,i=t.length;n<i;n++)t.push(t[n].concat(o[a]));return t.sort((a,n)=>n.length-a.length)}function Z(o){let t=Object.create(null);for(let a in o){let n=o[a];Array.isArray(n)||(n=[n]);for(let i of a.split(" "))if(i){let s=[],c=2,r=i;for(let d=0;;){if(r=="..."&&d>0&&d+3==i.length){c=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!f)throw new RangeError("Invalid path: "+i);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==i.length)break;let b=i[d++];if(d==i.length&&b=="!"){c=0;break}if(b!="/")throw new RangeError("Invalid path: "+i);r=i.slice(d)}let m=s.length-1,h=s[m];if(!h)throw new RangeError("Invalid path: "+i);let v=new R(n,c,m>0?s.slice(0,m):null);t[h]=v.sort(t[h])}}return J.add(t)}const J=new F({combine(o,t){let a,n,i;for(;o||t;){if(!o||t&&o.depth>=t.depth?(i=t,t=t.next):(i=o,o=o.next),a&&a.mode==i.mode&&!i.context&&!a.context)continue;let s=new R(i.tags,i.mode,i.context);a?a.next=s:n=s,a=s}return n}});class R{constructor(t,a,n,i){this.tags=t,this.mode=a,this.context=n,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}R.empty=new R([],2,null);function Q(o,t){let a=Object.create(null);for(let s of o)if(!Array.isArray(s.tag))a[s.tag.id]=s.class;else for(let c of s.tag)a[c.id]=s.class;let{scope:n,all:i=null}=t||{};return{style:s=>{let c=i;for(let r of s)for(let m of r.set){let h=a[m.id];if(h){c=c?c+" "+h:h;break}}return c},scope:n}}function U(o,t){let a=null;for(let n of o){let i=n.style(t);i&&(a=a?a+" "+i:i)}return a}function _(o,t,a,n=0,i=o.length){let s=new W(n,Array.isArray(t)?t:[t],a);s.highlightRange(o.cursor(),n,i,"",s.highlighters),s.flush(i)}class W{constructor(t,a,n){this.at=t,this.highlighters=a,this.span=n,this.class=""}startSpan(t,a){a!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=a)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,a,n,i,s){let{type:c,from:r,to:m}=t;if(r>=n||m<=a)return;c.isTop&&(s=this.highlighters.filter(b=>!b.scope||b.scope(c)));let h=i,v=X(t)||R.empty,d=U(s,v.tags);if(d&&(h&&(h+=" "),h+=d,v.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(a,r),h),v.opaque)return;let f=t.tree&&t.tree.prop(F.mounted);if(f&&f.overlay){let b=t.node.enter(f.overlay[0].from+r,1),V=this.highlighters.filter(w=>!w.scope||w.scope(f.tree.type)),B=t.firstChild();for(let w=0,M=r;;w++){let S=w<f.overlay.length?f.overlay[w]:null,E=S?S.from+r:m,H=Math.max(a,M),A=Math.min(n,E);if(H<A&&B)for(;t.from<A&&(this.highlightRange(t,H,A,i,s),this.startSpan(Math.min(A,t.to),h),!(t.to>=E||!t.nextSibling())););if(!S||E>n)break;M=S.to+r,M>a&&(this.highlightRange(b.cursor(),Math.max(a,S.from+r),Math.min(n,M),"",V),this.startSpan(Math.min(n,M),h))}B&&t.parent()}else if(t.firstChild()){f&&(i="");do if(!(t.to<=a)){if(t.from>=n)break;this.highlightRange(t,a,n,i,s),this.startSpan(Math.min(n,t.to),h)}while(t.nextSibling());t.parent()}}}function X(o){let t=o.type.prop(J);for(;t&&t.context&&!o.matchContext(t.context);)t=t.next;return t||null}const e=g.define,T=e(),y=e(),D=e(y),$=e(y),N=e(),I=e(N),K=e(N),k=e(),x=e(k),p=e(),u=e(),j=e(),O=e(j),C=e(),l={comment:T,lineComment:e(T),blockComment:e(T),docComment:e(T),name:y,variableName:e(y),typeName:D,tagName:e(D),propertyName:$,attributeName:e($),className:e(y),labelName:e(y),namespace:e(y),macroName:e(y),literal:N,string:I,docString:e(I),character:e(I),attributeValue:e(I),number:K,integer:e(K),float:e(K),bool:e(N),regexp:e(N),escape:e(N),color:e(N),url:e(N),keyword:p,self:e(p),null:e(p),atom:e(p),unit:e(p),modifier:e(p),operatorKeyword:e(p),controlKeyword:e(p),definitionKeyword:e(p),moduleKeyword:e(p),operator:u,derefOperator:e(u),arithmeticOperator:e(u),logicOperator:e(u),bitwiseOperator:e(u),compareOperator:e(u),updateOperator:e(u),definitionOperator:e(u),typeOperator:e(u),controlOperator:e(u),punctuation:j,separator:e(j),bracket:O,angleBracket:e(O),squareBracket:e(O),paren:e(O),brace:e(O),content:k,heading:x,heading1:e(x),heading2:e(x),heading3:e(x),heading4:e(x),heading5:e(x),heading6:e(x),contentSeparator:e(k),list:e(k),quote:e(k),emphasis:e(k),strong:e(k),link:e(k),monospace:e(k),strikethrough:e(k),inserted:e(),deleted:e(),changed:e(),invalid:e(),meta:C,documentMeta:e(C),annotation:e(C),processingInstruction:e(C),definition:g.defineModifier("definition"),constant:g.defineModifier("constant"),function:g.defineModifier("function"),standard:g.defineModifier("standard"),local:g.defineModifier("local"),special:g.defineModifier("special")};for(let o in l){let t=l[o];t instanceof g&&(t.name=o)}Q([{tag:l.link,class:"tok-link"},{tag:l.heading,class:"tok-heading"},{tag:l.emphasis,class:"tok-emphasis"},{tag:l.strong,class:"tok-strong"},{tag:l.keyword,class:"tok-keyword"},{tag:l.atom,class:"tok-atom"},{tag:l.bool,class:"tok-bool"},{tag:l.url,class:"tok-url"},{tag:l.labelName,class:"tok-labelName"},{tag:l.inserted,class:"tok-inserted"},{tag:l.deleted,class:"tok-deleted"},{tag:l.literal,class:"tok-literal"},{tag:l.string,class:"tok-string"},{tag:l.number,class:"tok-number"},{tag:[l.regexp,l.escape,l.special(l.string)],class:"tok-string2"},{tag:l.variableName,class:"tok-variableName"},{tag:l.local(l.variableName),class:"tok-variableName tok-local"},{tag:l.definition(l.variableName),class:"tok-variableName tok-definition"},{tag:l.special(l.variableName),class:"tok-variableName2"},{tag:l.definition(l.propertyName),class:"tok-propertyName tok-definition"},{tag:l.typeName,class:"tok-typeName"},{tag:l.namespace,class:"tok-namespace"},{tag:l.className,class:"tok-className"},{tag:l.macroName,class:"tok-macroName"},{tag:l.propertyName,class:"tok-propertyName"},{tag:l.operator,class:"tok-operator"},{tag:l.comment,class:"tok-comment"},{tag:l.meta,class:"tok-meta"},{tag:l.invalid,class:"tok-invalid"},{tag:l.punctuation,class:"tok-punctuation"}]);export{g as T,Q as a,_ as h,Z as s,l as t};
|