lupacode 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47494,6 +47494,50 @@ class TextBufferRenderable extends Renderable {
47494
47494
  onBgChanged(newColor) {}
47495
47495
  onAttributesChanged(newAttributes) {}
47496
47496
  }
47497
+ function fallbackHighlight(content, filetype) {
47498
+ const f = filetype?.toLowerCase() || "";
47499
+ const K = {
47500
+ js: "abstract,arguments,async,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,of,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,var,void,while,with,yield".split(","),
47501
+ ts: "abstract,arguments,async,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,of,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,type,var,void,while,with,yield".split(","),
47502
+ python: "False,None,True,and,as,assert,async,await,break,class,continue,def,del,elif,else,except,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,raise,return,try,while,with,yield".split(","),
47503
+ html: "a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,rp,rt,ruby,s,samp,script,section,select,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr,DOCTYPE".split(","),
47504
+ css: "color,background,border,margin,padding,font,display,position,width,height,top,left,right,bottom,flex,grid,align,justify,text,transform,transition,animation,opacity,overflow,z-index,cursor,outline,box-shadow,white-space,content,visibility,filter,backdrop-filter,clip-path,mask,border-radius,box-sizing,user-select,pointer-events,min-width,max-width,min-height,max-height,gap,order,float,clear,list-style,table-layout,border-collapse,vertical-align,line-height,letter-spacing,word-spacing,text-indent,text-align,text-decoration,text-transform,text-shadow,font-family,font-size,font-weight,font-style,background-color,background-image,background-size,background-position,background-repeat,border-width,border-style,border-color,margin-top,margin-right,margin-bottom,margin-left,padding-top,padding-right,padding-bottom,padding-left".split(",")
47505
+ };
47506
+ const kw = K[f] || K.js;
47507
+ const kwPat = new RegExp("\\b(" + kw.join("|") + ")\\b", "g");
47508
+ const patterns = [
47509
+ [/\/\*[\s\S]*?\*\//g, "comment"],
47510
+ [/\/\/[^\n]*/g, "comment"],
47511
+ [/#[^\n]*/g, "comment"],
47512
+ [/<!--[\s\S]*?-->/g, "comment"],
47513
+ [/"([^"\\]*(\\.[^"\\]*)*)"/g, "string"],
47514
+ [/`([^`\\]*(\\.[^`\\]*)*)`/g, "string"],
47515
+ [/'([^'\\]*(\\.[^'\\]*)*)'/g, "string"],
47516
+ [/\b(\d+(?:\.\d+)?)\b/g, "number"],
47517
+ [/<\/?(\w[\w-]*)[^>]*\/?>/g, "markup.raw"],
47518
+ [/&lt;!?--&gt;/g, "comment"],
47519
+ [/\s(\w[\w-]*)=/g, "attribute"],
47520
+ [/(?:\.|#)([\w-]+)/g, "type"],
47521
+ [/@[\w-]+/g, "builtin"]
47522
+ ];
47523
+ if (f === "html") {
47524
+ patterns.push([kwPat, "keyword"]);
47525
+ } else if (f === "css") {
47526
+ patterns.push([kwPat, "property"]);
47527
+ patterns.push([/#([\da-f]{3}){1,2}\b/gi, "number"]);
47528
+ } else {
47529
+ patterns.push([kwPat, "keyword"]);
47530
+ }
47531
+ const H = [];
47532
+ for (const [re, group] of patterns) {
47533
+ re.lastIndex = 0;
47534
+ let m;
47535
+ while ((m = re.exec(content)) !== null) {
47536
+ H.push([m.index, m.index + m[0].length, group, undefined]);
47537
+ }
47538
+ }
47539
+ return H;
47540
+ }
47497
47541
 
47498
47542
  class CodeRenderable extends TextBufferRenderable {
47499
47543
  _content;
@@ -47787,8 +47831,26 @@ class CodeRenderable extends TextBufferRenderable {
47787
47831
  this.textBuffer.setStyledText(styledText);
47788
47832
  this.setRenderedLineSources(renderedLineSources);
47789
47833
  } else {
47790
- this.textBuffer.setText(content);
47791
- this.setRenderedLineSources(undefined);
47834
+ const fallback = fallbackHighlight(content, filetype);
47835
+ if (fallback.length > 0) {
47836
+ let chunks2 = treeSitterToTextChunks(content, fallback, this._syntaxStyle, {
47837
+ enabled: this._conceal,
47838
+ baseHighlight: this._baseHighlight
47839
+ });
47840
+ chunks2 = await this.transformChunks(chunks2, { content, filetype, syntaxStyle: this._syntaxStyle, highlights: fallback });
47841
+ if (snapshotId !== this._highlightSnapshotId) {
47842
+ this.requestRender();
47843
+ return;
47844
+ }
47845
+ if (this.isDestroyed)
47846
+ return;
47847
+ const styledText2 = new StyledText(chunks2);
47848
+ this.textBuffer.setStyledText(styledText2);
47849
+ this.setRenderedLineSources(undefined);
47850
+ } else {
47851
+ this.textBuffer.setText(content);
47852
+ this.setRenderedLineSources(undefined);
47853
+ }
47792
47854
  }
47793
47855
  this._shouldRenderTextBuffer = true;
47794
47856
  this._isHighlighting = false;
@@ -96422,7 +96484,7 @@ var import_react35 = __toESM(require_react(), 1);
96422
96484
  // package.json
96423
96485
  var package_default2 = {
96424
96486
  name: "lupacode",
96425
- version: "1.0.9",
96487
+ version: "1.0.10",
96426
96488
  description: "AI-powered terminal coding assistant",
96427
96489
  type: "module",
96428
96490
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lupacode",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "AI-powered terminal coding assistant",
5
5
  "type": "module",
6
6
  "bin": {