codelight.js 1.3.0 → 1.3.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/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 1.3.1
4
+
5
+ - Benchmark against highlight.js, Prism and Shiki: docs/benchmark.md, and npm run bench to run it yourself.
6
+ - CDN links use @1, so they always load the latest 1.x release.
7
+ - Demo: side by side with highlight.js.
8
+
3
9
  ## 1.3.0
4
10
 
5
11
  - **8 new languages:** Kotlin, Swift, Dockerfile, TOML, Markdown, GraphQL, PowerShell and Terraform/HCL. 27 in all.
package/README.CDN.md CHANGED
@@ -17,24 +17,24 @@ Unminified `.css` versions of each theme are next to them.
17
17
  ## jsDelivr
18
18
 
19
19
  ```html
20
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codelight.js@1.0.0/build/styles/default.min.css">
21
- <script src="https://cdn.jsdelivr.net/npm/codelight.js@1.0.0/build/codelight.min.js"></script>
20
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codelight.js@1/build/styles/default.min.css">
21
+ <script src="https://cdn.jsdelivr.net/npm/codelight.js@1/build/codelight.min.js"></script>
22
22
  ```
23
23
 
24
24
  ## unpkg
25
25
 
26
26
  ```html
27
- <link rel="stylesheet" href="https://unpkg.com/codelight.js@1.0.0/build/styles/default.min.css">
28
- <script src="https://unpkg.com/codelight.js@1.0.0/build/codelight.min.js"></script>
27
+ <link rel="stylesheet" href="https://unpkg.com/codelight.js@1/build/styles/default.min.css">
28
+ <script src="https://unpkg.com/codelight.js@1/build/codelight.min.js"></script>
29
29
  ```
30
30
 
31
- Pin a version (`@1.0.0`) in production so an update never changes your page unexpectedly. `https://cdn.jsdelivr.net/npm/codelight.js` with no path also serves `build/codelight.min.js`.
31
+ `@1` always serves the newest 1.x release, which never has breaking changes. To lock an exact version, use it instead, for example `@1.3.1`. `https://cdn.jsdelivr.net/npm/codelight.js@1` with no path also serves `build/codelight.min.js`.
32
32
 
33
33
  ## ES module
34
34
 
35
35
  ```html
36
36
  <script type="module">
37
- import codelight from "https://cdn.jsdelivr.net/npm/codelight.js@1.0.0/es/codelight.js";
37
+ import codelight from "https://cdn.jsdelivr.net/npm/codelight.js@1/es/codelight.js";
38
38
  codelight.highlightAll();
39
39
  </script>
40
40
  ```
package/README.md CHANGED
@@ -32,6 +32,20 @@ Very fast and lightweight. Only the line being written gets updated, so it stays
32
32
  - **Line numbers, highlighted lines and a copy button,** built in. Copying never includes the line numbers.
33
33
  - **Light and dark themes.** Every colour is a CSS variable, and every colour meets WCAG AA contrast.
34
34
 
35
+ ## How fast?
36
+
37
+ A real 282-line TypeScript file arriving 4 characters at a time (2,538 updates), in Edge on a 2020 laptop. After each update the page is updated and laid out.
38
+
39
+ | | Whole file, as it arrives | Per update, late in the file | Finished file, once | Size, gzipped |
40
+ |---|---|---|---|---|
41
+ | **codelight.js** | **7.6 s** | **6.0 ms** | **21 ms** | 11.8 KB, 27 languages |
42
+ | highlight.js | 33.9 s | 24 ms | 23 ms | 11.1 KB, 1 language |
43
+ | Prism | 35.3 s | 30 ms | 23 ms | 7.7 KB, 1 language |
44
+ | Shiki | 218 s | 190 ms | 175 ms | 71.6 KB, 1 language |
45
+ | Shiki + `@shikijs/stream` | 9.0 s | 7.0 ms | 174 ms | 72.2 KB, 1 language |
46
+
47
+ About 4.5× faster than highlight.js and Prism on code that's arriving, and about as fast on finished code. Shiki's streaming package comes close on live code, at six times the size. Method, raw numbers and how to run it yourself: [docs/benchmark.md](https://github.com/codelightjs/codelight.js/blob/main/docs/benchmark.md).
48
+
35
49
  ## Quick start
36
50
 
37
51
  ### On a web page
@@ -39,8 +53,8 @@ Very fast and lightweight. Only the line being written gets updated, so it stays
39
53
  Add the stylesheet and the script, then highlight the page. Code blocks need a `language-xxx` class (what Markdown renderers already produce) or a `data-lang` attribute.
40
54
 
41
55
  ```html
42
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codelight.js@1.0.0/build/styles/default.min.css">
43
- <script src="https://cdn.jsdelivr.net/npm/codelight.js@1.0.0/build/codelight.min.js"></script>
56
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/codelight.js@1/build/styles/default.min.css">
57
+ <script src="https://cdn.jsdelivr.net/npm/codelight.js@1/build/codelight.min.js"></script>
44
58
 
45
59
  <pre><code class="language-python">print("hello")</code></pre>
46
60
 
@@ -1,4 +1,4 @@
1
- /*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ /*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  "use strict";
3
3
  var codelight = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ /*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  "use strict";var codelight=(()=>{var $=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var st=(t,e,o)=>e in t?$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var it=(t,e)=>{for(var o in e)$(t,o,{get:e[o],enumerable:!0})},lt=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ot(e))!at.call(t,a)&&a!==o&&$(t,a,{get:()=>e[a],enumerable:!(r=rt(e,a))||r.enumerable});return t};var ct=t=>lt($({},"__esModule",{value:!0}),t);var ge=(t,e,o)=>st(t,typeof e!="symbol"?e+"":e,o);var Nt={};it(Nt,{addCopyButton:()=>A,createMarkup:()=>N,createStream:()=>M,default:()=>Ot,defineLanguage:()=>i,escapeHtml:()=>z,getLanguage:()=>R,highlight:()=>j,highlightAll:()=>ie,highlightElement:()=>H,injectTheme:()=>pe,listLanguages:()=>ae,mount:()=>le,registerLanguage:()=>oe,renderLine:()=>C,splitFences:()=>ce,themeCss:()=>B,tokenize:()=>W});async function pt(t,e=document){try{await e.defaultView.navigator.clipboard.writeText(t)}catch{let o=e.createElement("textarea");o.value=t,o.setAttribute("readonly",""),o.style.cssText="position:fixed;top:-1000px;opacity:0",e.body.append(o),o.select(),e.execCommand("copy"),o.remove()}}function A(t,e={}){let o=t.parentElement;if(!o||[...o.children].some(l=>l.classList.contains("cl-copy")))return null;let r=t.ownerDocument,a=e.label??"Copy",n=r.createElement("button");n.type="button",n.className="cl-copy",n.textContent=a,n.setAttribute("aria-label","Copy code");let c;return n.addEventListener("click",async()=>{await pt(t.textContent??"",r),n.textContent=e.copiedLabel??"Copied",clearTimeout(c),c=setTimeout(()=>n.textContent=a,1500)}),o.classList.add("cl-has-copy"),o.append(n),n}var O=class{constructor(){ge(this,"tokens",[])}add(e,o){if(!o)return;let r=this.tokens[this.tokens.length-1];r&&r.type===e?r.text+=o:this.tokens.push(e?{type:e,text:o}:{text:o})}},T=(t,e)=>new Set((t??"").split(/\s+/).filter(Boolean).map(o=>e?o.toLowerCase():o)),he=t=>new RegExp(t.source,t.flags.replace(/[gy]/g,"")+"y"),ye=/(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*(?:\.\d[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?\d+)?)\w*/y,ut=/[A-Za-z_$][\w$]*/,be=/\s+/y,xe=/[+\-*/%=<>!&|^~?:]+/y,we=/\s*\(/y,ke=/<<(-?)\s*(['"]?)([A-Za-z_]\w*)\2/y,mt="()[]{},;.",dt={"}":"{",")":"(","]":"["};function i(t){let e=t.caseInsensitive??!1,o=T(t.keywords,e),r=T(t.constants,e),a=T(t.types,e),n=T(t.variables,e),c=T(t.builtins,e),l=(t.rules??[]).map(s=>({match:he(s.match),type:s.type})),f=[...t.strings??[]].sort((s,S)=>S.open.length-s.open.length).map(s=>({open:s.open,close:s.close??s.open,escape:s.escape??!0,multiline:s.multiline??!1,type:s.type??"string",interpolate:s.interpolate})),L=he(t.identifier??ut),E=t.calls??!0,v=t.numbers??!0,y=t.operators??!0;function w(s,S,d){let m=e?s.toLowerCase():s;if(o.has(m))return"keyword";if(r.has(m))return"constant";if(a.has(m))return"type";if(n.has(m))return"variable";if(c.has(m)||E&&(we.lastIndex=d,we.test(S)))return"function";if(t.classNames&&/^[A-Z]/.test(s)&&/[a-z]/.test(s))return"type"}return{tokenizeLine(s,S){let d=new O,m=S?[...S]:[],ue=()=>m[m.length-1],G,u=0,g,Q=ue();if(Q?.t==="heredoc")return(Q.dash?s.replace(/^\t+/,""):s)===Q.end?(d.add("meta",s),m.pop()):d.add("string",s),{tokens:d.tokens,state:m.length?m:null};e:for(;u<s.length;){let b=ue();if(b?.t==="comment"){let p=s.indexOf(b.close,u);if(p<0){d.add("comment",s.slice(u));break}d.add("comment",s.slice(u,p+b.close.length)),u=p+b.close.length,m.pop();continue}if(b?.t==="string"){let p=b.s;for(let x=u;x<s.length;x++){if(p.interpolate&&s.startsWith(p.interpolate[0],x)){if(p.interpolate[0]==="{"&&s[x+1]==="{"){x++;continue}d.add(p.type,s.slice(u,x)),d.add("punctuation",p.interpolate[0]),u=x+p.interpolate[0].length;let fe=p.interpolate[1];m.push({t:"code",close:fe,open:dt[fe]??"",depth:0});continue e}if(p.escape&&s[x]==="\\"){x++;continue}if(s.startsWith(p.close,x)){d.add(p.type,s.slice(u,x+p.close.length)),u=x+p.close.length,m.pop();continue e}}d.add(p.type,s.slice(u));break}if(b?.t==="code"){if(b.depth===0&&s.startsWith(b.close,u)){d.add("punctuation",b.close),u+=b.close.length,m.pop();continue}let p=s[u];if(p===b.open||b.depth>0&&p===b.close){m[m.length-1]={...b,depth:b.depth+(p===b.open?1:-1)},d.add("punctuation",p),u++;continue}}for(let p of l){p.match.lastIndex=u;let x=p.match.exec(s);if(x&&x[0]){d.add(p.type,x[0]),u+=x[0].length;continue e}}for(let[p,x]of t.blockComment??[])if(s.startsWith(p,u)){d.add("comment",p),u+=p.length,m.push({t:"comment",close:x});continue e}for(let p of t.lineComment??[])if(s.startsWith(p,u)){d.add("comment",s.slice(u));break e}for(let p of f)if(s.startsWith(p.open,u)){d.add(p.type,p.open),u+=p.open.length,m.push({t:"string",s:p});continue e}if(t.heredoc&&(g=(ke.lastIndex=u,ke.exec(s)))){d.add("operator",`<<${g[1]}`),d.add("meta",g[0].slice(2+g[1].length)),G={t:"heredoc",end:g[3],dash:!!g[1]},u+=g[0].length;continue}if(ye.lastIndex=u,v&&(g=ye.exec(s))){d.add("number",g[0]),u+=g[0].length;continue}if(L.lastIndex=u,(g=L.exec(s))&&g[0]){d.add(w(g[0],s,u+g[0].length),g[0]),u+=g[0].length;continue}if(be.lastIndex=u,g=be.exec(s)){d.add(void 0,g[0]),u+=g[0].length;continue}if(xe.lastIndex=u,g=xe.exec(s)){d.add(y?"operator":void 0,g[0]),u+=g[0].length;continue}let de=s[u];d.add(mt.includes(de)?"punctuation":void 0,de),u++}let me=m.findIndex(b=>b.t==="string"&&!b.s.multiline);return me>=0&&(m.length=me),G&&m.push(G),{tokens:d.tokens,state:m.length?m:null}}}}var D={tokenizeLine:t=>({tokens:t?[{text:t}]:[],state:null})};function Z(t){let e=new Set;if(t==null)return e;if(typeof t=="number")return e.add(t);if(Array.isArray(t))return new Set(t);for(let o of t.split(/[\s,]+/)){let r=/^(\d+)(?:-(\d+))?$/.exec(o);if(!r)continue;let a=Number(r[1]),n=Number(r[2]??r[1]);for(let c=Math.min(a,n);c<=Math.max(a,n)&&c-a<1e5;c++)e.add(c)}return e}var Le=t=>!!t&&(!!t.lineNumbers||t.highlightLines!=null);function Y(t,e,o){return"cl-line"+(e?" cl-ln":"")+(o.has(t)?" cl-mark":"")}function ve(t,e,o,r){return`<span class="${Y(e,o,r)}" data-line="${e}">${t}</span>`}var Se=i({strings:[{open:'"',multiline:!0},{open:"'",escape:!1,multiline:!0}],keywords:"if then else elif fi for while until do done case esac in function select return exit break continue local export readonly declare unset source alias time",builtins:"echo cd printf read set shift test eval exec trap pwd ls cat grep sed awk find mkdir rm cp mv chmod chown touch curl wget tar sudo git npm npx pnpm yarn bun node deno python python3 pip pip3 docker kubectl ssh make brew apt apt-get",rules:[{match:/(?<=^|\s)#.*/,type:"comment"},{match:/\$(?:\{[^}]*\}|[A-Za-z_]\w*|[\d@#?$!*-])/,type:"variable"},{match:/(?<=^\s*(?:(?:export|local|declare|readonly)\s+)?)[A-Za-z_]\w*(?==)/,type:"variable"},{match:/(?<=\s)--?[A-Za-z][\w-]*/,type:"attr"}],identifier:/[A-Za-z_][\w-]*/,calls:!1,heredoc:!0});var h={lineComment:["//"],blockComment:[["/*","*/"]]},k=[{open:'"'},{open:"'"}];var K="auto break case const continue default do else enum extern for goto if inline register restrict return sizeof static struct switch typedef union volatile while",V="char double float int long short signed unsigned void bool size_t ssize_t int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t uint64_t FILE",X=[{match:/(?<=^\s*#\s*include\s*)<[^>]*>/,type:"string"},{match:/(?<=^\s*)#\s*[A-Za-z]+/,type:"meta"}],Ee=i({...h,strings:k,keywords:K,types:V,constants:"NULL true false",rules:X});var Ce=i({...h,strings:k,keywords:K+" class namespace template typename public private protected virtual override final new delete this try catch throw using operator friend explicit constexpr consteval noexcept auto decltype static_cast dynamic_cast reinterpret_cast const_cast co_await co_return co_yield concept requires mutable",types:V+" string vector map unordered_map set array unique_ptr shared_ptr optional",constants:"nullptr NULL true false",rules:X,classNames:!0});var J=["{","}"],_e=i({...h,strings:[{open:'$@"',close:'"',escape:!1,multiline:!0,interpolate:J},{open:'@$"',close:'"',escape:!1,multiline:!0,interpolate:J},{open:'@"',close:'"',escape:!1,multiline:!0},{open:'$"',close:'"',interpolate:J},...k],keywords:"abstract as base break case catch checked class const continue default delegate do else enum event explicit extern finally fixed for foreach goto if implicit in interface internal is lock namespace new operator out override params private protected public readonly ref return sealed sizeof stackalloc static struct switch this throw try typeof unchecked unsafe using virtual volatile while async await var record get set init yield where when",types:"bool byte char decimal double float int long object sbyte short string uint ulong ushort void dynamic",constants:"true false null",rules:[{match:/(?<=^\s*)\[[A-Z]\w*(?:\([^)]*\))?\]/,type:"meta"}],classNames:!0});var I=i({blockComment:[["/*","*/"]],strings:k,rules:[{match:/@[\w-]+/,type:"keyword"},{match:/#[\da-fA-F]{3,8}(?![\w-])/,type:"number"},{match:/(?:--|-?[A-Za-z])[\w-]*(?=\s*:(?!:)[^{};]*(?:[;})]|$))/,type:"property"},{match:/[.#][A-Za-z_-][\w-]*/,type:"type"},{match:/::?[A-Za-z-]+/,type:"attr"},{match:/!\s*important/,type:"keyword"}],identifier:/-?[A-Za-z_][\w-]*/});var ft={tokenizeLine(t){if(!t)return{tokens:[],state:null};let e=t.startsWith("+++")||t.startsWith("---")||t.startsWith("@@")||t.startsWith("diff ")||t.startsWith("index ")?"meta":t[0]==="+"?"inserted":t[0]==="-"?"deleted":void 0;return{tokens:[e?{type:e,text:t}:{text:t}],state:null}}},Ae=ft;var gt="FROM|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL|MAINTAINER",Te=i({strings:[{open:'"'},{open:"'",escape:!1}],rules:[{match:/(?<=^\s*)#.*/,type:"comment"},{match:new RegExp(`(?<=^\\s*)(?:${gt})\\b`,"i"),type:"keyword"},{match:/(?<=^\s*FROM\s.*\s)AS(?=\s)/i,type:"keyword"},{match:/\$(?:\{[^}]*\}|[A-Za-z_]\w*)/,type:"variable"},{match:/(?<=\s)--[A-Za-z][\w-]*/,type:"attr"}],identifier:/[A-Za-z_][\w.-]*/,calls:!1});var Oe=i({...h,strings:[{open:'"'},{open:"'"},{open:"`",escape:!1,multiline:!0}],keywords:"break case chan const continue default defer else fallthrough for func go goto if import interface map package range return select struct switch type var",constants:"true false nil iota",types:"string int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 uintptr float32 float64 complex64 complex128 bool byte rune error any",builtins:"append cap close copy delete len make new panic print println recover"});var Ne=i({lineComment:["#"],strings:[{open:'"""',multiline:!0},{open:'"'}],keywords:"query mutation subscription fragment on type interface union enum input scalar schema extend directive implements repeatable",constants:"true false null",types:"Int Float String Boolean ID",rules:[{match:/\$[A-Za-z_]\w*/,type:"variable"},{match:/@[A-Za-z_]\w*/,type:"meta"},{match:/\.\.\./,type:"operator"},{match:/[A-Za-z_]\w*(?=\s*:)/,type:"property"}],classNames:!0});var Re=i({lineComment:["#","//"],blockComment:[["/*","*/"]],strings:[{open:'"',interpolate:["${","}"]}],constants:"true false null",types:"string number bool list map set object tuple any",rules:[{match:/(?<=^\s*)(?:resource|data|variable|output|module|provider|locals|terraform|moved|import|check)\b/,type:"keyword"},{match:/\b(?:for|in|if|for_each|count|depends_on|lifecycle|dynamic|content)\b(?!\s*=)/,type:"keyword"},{match:/(?<=^\s*)[A-Za-z_][\w-]*(?=\s*=(?!=))/,type:"property"}],identifier:/[A-Za-z_][\w-]*/,heredoc:!0});var ze=i({...h,strings:[{open:'"""',multiline:!0},...k],keywords:"abstract assert break case catch class const continue default do else enum extends final finally for goto if implements import instanceof interface native new package private protected public return static strictfp super switch synchronized this throw throws transient try volatile while var record sealed permits yield",types:"boolean byte char double float int long short void",constants:"true false null",rules:[{match:/@[A-Za-z_]\w*/,type:"meta"}],classNames:!0});var ee="break case catch class const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield async await of static get set from as",te="true false null undefined NaN Infinity",ne={open:"`",multiline:!0,interpolate:["${","}"]},re={match:/(?<=(?:^|[(=?:,&|{}[>;]|\breturn)\s*)<\/?[A-Za-z][\w.:-]*(?=[\s/>]|$)/,type:"tag"},q={match:/(?<=(?:^|[(,=:[!&|?{;]|\breturn|\btypeof|\bcase)\s*)\/(?![*/\s>])(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\\/[])+\/[dgimsuvy]*/,type:"regex"},P={match:/@[A-Za-z_$][\w$.]*/,type:"meta"},U=i({...h,strings:[...k,ne],keywords:ee,constants:te,rules:[re,q,P],classNames:!0});var je=i({...h,strings:[{open:'"'}],constants:"true false null",rules:[{match:/"(?:[^"\\]|\\.)*"(?=\s*:)/,type:"property"}],calls:!1});var Me=["${","}"],$e=i({...h,strings:[{open:'"""',multiline:!0,escape:!1,interpolate:Me},{open:'"',interpolate:Me},{open:"'"}],keywords:"package import class interface object fun val var if else when for while do return break continue throw try catch finally is in as typealias this super data sealed enum open abstract override private protected public internal companion lateinit suspend inline reified by init get set where out vararg const operator infix annotation",constants:"true false null",types:"Int Long Short Byte Double Float Boolean Char String Unit Any Nothing List Map Set",rules:[{match:/@[A-Za-z_]\w*(?::\w+)?/,type:"meta"}],classNames:!0});var De=i({blockComment:[["<!--","-->"]],rules:[{match:/^#{1,6}\s.*/,type:"keyword"},{match:/^ {0,3}(?:`{3,}|~{3,}).*/,type:"meta"},{match:/^\s*>.*/,type:"comment"},{match:/^\s*(?:[-*+]|\d+[.)])(?=\s)/,type:"punctuation"},{match:/^\s*(?:-{3,}|\*{3,}|_{3,})\s*$/,type:"punctuation"},{match:/`[^`]+`/,type:"string"},{match:/!?\[[^\]]*\]\([^)\s]*(?:\s+"[^"]*")?\)/,type:"function"},{match:/\*\*[^*]+\*\*|__[^_]+__/,type:"type"},{match:/(?<![\w*])\*[^*\s][^*]*\*(?!\*)|(?<!\w)_[^_\s][^_]*_(?!\w)/,type:"attr"},{match:/<\/?[A-Za-z][^>]*>/,type:"tag"}],identifier:/[A-Za-z_][\w'-]*/,calls:!1,numbers:!1,operators:!1});var Ze=i({lineComment:["//","#"],blockComment:[["/*","*/"]],strings:[{open:'"',multiline:!0},{open:"'",multiline:!0}],keywords:"abstract and array as break callable case catch class clone const continue declare default do echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile enum extends final finally fn for foreach function global goto if implements include include_once instanceof insteadof interface isset list match namespace new or print private protected public readonly require require_once return static switch throw trait try unset use var while xor yield",constants:"true false null TRUE FALSE NULL",types:"int float string bool void mixed never object iterable",rules:[{match:/<\?(?:php|=)?|\?>/,type:"meta"},{match:/\$[A-Za-z_]\w*/,type:"variable"}],classNames:!0});var Ie=i({lineComment:["#"],blockComment:[["<#","#>"]],strings:[{open:'@"',close:'"@',escape:!1,multiline:!0,interpolate:["$(",")"]},{open:"@'",close:"'@",escape:!1,multiline:!0},{open:'"',escape:!1,multiline:!0,interpolate:["$(",")"]},{open:"'",escape:!1,multiline:!0}],keywords:"if else elseif switch foreach for while do until break continue return function filter param begin process end try catch finally throw trap in exit class enum using",caseInsensitive:!0,rules:[{match:/\$(?:true|false|null)\b/i,type:"constant"},{match:/\$(?:\{[^}]+\}|[\w:]+)/,type:"variable"},{match:/-(?:eq|ne|gt|ge|lt|le|like|notlike|match|notmatch|contains|notcontains|in|notin|and|or|not|xor|replace|split|join|is|isnot|as)\b/i,type:"operator"},{match:/\[[A-Za-z][\w.]*(?:\[\])?\]/,type:"type"},{match:/\b[A-Z][a-z]+-[A-Z]\w+/,type:"function"},{match:/(?<=\s)-[A-Za-z]\w*/,type:"attr"}],identifier:/[A-Za-z_][\w-]*/});var ht=["f","F","rf","rF","Rf","RF","fr","fR","Fr","FR"].flatMap(t=>['"""',"'''",'"',"'"].map(e=>({open:t+e,close:e,escape:!/r/i.test(t),multiline:e.length===3,interpolate:["{","}"]}))),qe=i({lineComment:["#"],strings:[...ht,{open:'"""',multiline:!0},{open:"'''",multiline:!0},...k],keywords:"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 match case",constants:"True False None",variables:"self cls",types:"int float str bool list dict set tuple bytes object Exception",rules:[{match:/(?<=^\s*)@[\w.]+/,type:"meta"},{match:/[rRbBuU]{1,2}(?=["'])/,type:"string"}],classNames:!0});var Pe=i({lineComment:["#"],strings:[{open:'"',multiline:!0},{open:"'",multiline:!0}],keywords:"alias and begin break case class def defined? do else elsif end ensure for if in module next not or redo rescue retry return self super then undef unless until when while yield require require_relative include extend attr_accessor attr_reader attr_writer private protected public lambda proc",builtins:"puts print p raise",constants:"true false nil",rules:[{match:/@{1,2}[A-Za-z_]\w*|\$[A-Za-z_]\w*/,type:"variable"},{match:/(?<![:\w]):[A-Za-z_]\w*[?!]?/,type:"constant"}],identifier:/[A-Za-z_]\w*[?!]?/,classNames:!0});var Ue=i({...h,strings:[{open:'"',multiline:!0},{open:"'"}],keywords:"as async await break const continue crate dyn else enum extern fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait type unsafe use where while",constants:"true false None",types:"i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 bool char str",rules:[{match:/#!?\[[^\]]*\]/,type:"meta"},{match:/'[A-Za-z_]\w*(?!')/,type:"keyword"},{match:/[A-Za-z_]\w*!(?=\s*[([{])/,type:"function"}],classNames:!0});var Fe=i({lineComment:["--"],blockComment:[["/*","*/"]],strings:[{open:"'",escape:!1},{open:'"',escape:!1,type:"property"},{open:"`",escape:!1,type:"property"}],keywords:"select from where and or not insert into values update set delete create table alter drop index primary key foreign references join left right inner outer full cross on as group by order having limit offset union all distinct case when then else end is in like ilike between exists default constraint unique check view begin commit rollback transaction returning with recursive if desc asc add column grant revoke cascade truncate database schema explain using natural over partition window",constants:"null true false",types:"int integer bigint smallint serial bigserial varchar char text boolean bool date time timestamp timestamptz interval decimal numeric float real double precision uuid json jsonb blob bytea",caseInsensitive:!0});var We=["\\(",")"],He=i({...h,strings:[{open:'"""',multiline:!0,interpolate:We},{open:'"',interpolate:We}],keywords:"import let var func class struct enum protocol extension if else guard switch case default for in while repeat return break continue fallthrough throw throws rethrows try catch do defer as is init deinit self Self super static private fileprivate internal public open final override mutating nonmutating weak unowned lazy inout where async await some any typealias associatedtype subscript convenience required",constants:"true false nil",types:"Int Double Float String Bool Character Array Dictionary Set Void Optional Result Error",rules:[{match:/@[A-Za-z_]\w*/,type:"meta"},{match:/#(?:available|if|else|elseif|endif|selector|keyPath|warning|error)\b/,type:"meta"}],classNames:!0});var Be=i({lineComment:["#"],strings:[{open:'"""',multiline:!0},{open:"'''",multiline:!0,escape:!1},{open:'"'},{open:"'",escape:!1}],constants:"true false inf nan",rules:[{match:/(?<=^\s*)\[\[?[^\]]*\]\]?/,type:"tag"},{match:/(?<=^\s*)[\w.\-"' ]+?(?=\s*=)/,type:"property"},{match:/\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?/,type:"number"}],identifier:/[A-Za-z_][\w-]*/,calls:!1});var yt=" interface type enum implements namespace declare abstract readonly private protected public keyof infer is satisfies asserts module override unique",Ge=t=>({...h,strings:[...k,ne],keywords:ee+yt,types:"string number boolean any unknown never void object symbol bigint",constants:te,rules:t?[re,q,P]:[q,P],classNames:!0}),Qe=i(Ge(!1)),Ye=i(Ge(!0));var bt=/<(\/?)([A-Za-z][\w:.-]*)/y,xt=/&(?:#\d+|#[xX][\da-fA-F]+|\w+);/y,wt=/[^<&]+/y,kt=/[^\s=/>"']+/y,Lt=/[^\s>"']+/y,vt=/\s+/y,_=(t,e,o)=>(t.lastIndex=o,t.exec(e));function N(t={}){return{tokenizeLine(e,o){let r=new O,a=o,n=0,c;for(;n<e.length;){if(!a){if(e.startsWith("<!--",n)){let l=e.indexOf("-->",n+4);if(l<0){r.add("comment",e.slice(n)),a={m:"comment"};break}r.add("comment",e.slice(n,l+3)),n=l+3}else if(e.startsWith("<!",n)||e.startsWith("<?",n)){let l=e.indexOf(">",n);if(l<0){r.add("meta",e.slice(n)),a={m:"meta"};break}r.add("meta",e.slice(n,l+1)),n=l+1}else(c=_(bt,e,n))?(r.add("punctuation",c[1]?"</":"<"),r.add("tag",c[2]),a={m:"tag",name:c[2].toLowerCase(),closing:!!c[1]},n+=c[0].length):(c=_(xt,e,n))?(r.add("constant",c[0]),n+=c[0].length):(c=_(wt,e,n))?(r.add(void 0,c[0]),n+=c[0].length):(r.add(void 0,e[n]),n++);continue}if(a.m==="comment"||a.m==="meta"){let l=a.m==="comment"?"-->":">",f=a.m==="comment"?"comment":"meta",L=e.indexOf(l,n);if(L<0){r.add(f,e.slice(n));break}r.add(f,e.slice(n,L+l.length)),n=L+l.length,a=null;continue}if(a.m==="embed"){let l=e.toLowerCase().indexOf(a.end,n),f=l<0?e.slice(n):e.slice(n,l),L=a.lang.tokenizeLine(f,a.inner);for(let E of L.tokens)r.add(E.type,E.text);if(l<0){a={...a,inner:L.state};break}a=null,n=l;continue}if(a.quote){let l=e.indexOf(a.quote,n);if(l<0){r.add("string",e.slice(n));break}r.add("string",e.slice(n,l+1)),n=l+1,a={...a,quote:void 0,eq:!1}}else if(c=_(vt,e,n))r.add(void 0,c[0]),n+=c[0].length;else if(e.startsWith("/>",n)||e[n]===">"){let l=e[n]===">"?1:2;r.add("punctuation",e.slice(n,n+l)),n+=l;let f=l===1&&!a.closing?t[a.name]:void 0;a=f?{m:"embed",end:`</${a.name}`,lang:f,inner:null}:null}else if(e[n]==="=")r.add("operator","="),n++,a={...a,eq:!0};else if(e[n]==='"'||e[n]==="'"){let l=e[n],f=e.indexOf(l,n+1);if(f<0){r.add("string",e.slice(n)),a={...a,quote:l};break}r.add("string",e.slice(n,f+1)),n=f+1,a={...a,eq:!1}}else a.eq&&(c=_(Lt,e,n))?(r.add("string",c[0]),n+=c[0].length,a={...a,eq:!1}):(c=_(kt,e,n))?(r.add("attr",c[0]),n+=c[0].length):(r.add(void 0,e[n]),n++)}return{tokens:r.tokens,state:a}}}}var Ke=N({script:U,style:I});var Ve=i({strings:[{open:'"'},{open:"'",escape:!1}],constants:"true false null yes no on off ~",caseInsensitive:!0,rules:[{match:/(?<=^|\s)#.*/,type:"comment"},{match:/^(?:---|\.\.\.)(?=\s*$)/,type:"meta"},{match:/[^\s#:'"[\]{},-][^#:]*?(?=:(?:\s|$))|(?<=^\s*-\s+)[^\s#:'"[\]{},][^#:]*?(?=:(?:\s|$))/,type:"property"},{match:/[&*][\w-]+/,type:"variable"},{match:/!!?[\w-]+/,type:"type"}],identifier:/[A-Za-z_][\w-]*/,calls:!1});var Xe={javascript:U,typescript:Qe,tsx:Ye,json:je,python:qe,bash:Se,ruby:Pe,php:Ze,go:Oe,rust:Ue,java:ze,c:Ee,cpp:Ce,csharp:_e,sql:Fe,css:I,yaml:Ve,xml:Ke,diff:Ae,kotlin:$e,swift:He,dockerfile:Te,toml:Be,markdown:De,graphql:Ne,powershell:Ie,hcl:Re,plaintext:D};var F=new Map(Object.entries(Xe)),Je=new Map(Object.entries({js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",ts:"typescript",mts:"typescript",cts:"typescript",jsonc:"json",json5:"json",py:"python",python3:"python",sh:"bash",shell:"bash",zsh:"bash",shellscript:"bash",console:"bash",terminal:"bash",rb:"ruby",golang:"go",rs:"rust",h:"c","c++":"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",cs:"csharp","c#":"csharp",postgres:"sql",postgresql:"sql",mysql:"sql",sqlite:"sql",plsql:"sql",scss:"css",less:"css",yml:"yaml",html:"xml",xhtml:"xml",svg:"xml",vue:"xml",svelte:"xml",patch:"diff",kt:"kotlin",kts:"kotlin",docker:"dockerfile",containerfile:"dockerfile",md:"markdown",mdx:"markdown",gql:"graphql",ps1:"powershell",pwsh:"powershell",ps:"powershell",terraform:"hcl",tf:"hcl",tfvars:"hcl",opentofu:"hcl",text:"plaintext",txt:"plaintext",plain:"plaintext","":"plaintext"}));function R(t){let e=(t??"").trim().toLowerCase();return F.get(e)??F.get(Je.get(e)??"")}function oe(t,e,o=[]){F.set(t.toLowerCase(),e);for(let r of o)Je.set(r.toLowerCase(),t.toLowerCase())}function ae(){return[...F.keys()]}var et=t=>typeof t=="object"?t:R(t)??D,St={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function z(t){return t.replace(/[&<>"]/g,e=>St[e])}function C(t){let e="";for(let o of t)e+=o.type?`<span class="cl-${o.type}">${z(o.text)}</span>`:z(o.text);return e}function W(t,e){let o=et(e),r=null;return t.split(`
3
3
  `).map(a=>{let n=o.tokenizeLine(a.replace(/\r$/,""),r);return r=n.state,n.tokens})}function j(t,e,o){let r=W(t,e).map(C);if(!Le(o))return r.join(`
4
4
  `);let a=Z(o.highlightLines);return r.map((n,c)=>ve(n,c+1,!!o.lineNumbers,a)).join(`
@@ -1,4 +1,4 @@
1
- /*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ /*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
package/es/codelight.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ /*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  import {
3
3
  addCopyButton,
4
4
  createMarkup,
@@ -12,7 +12,7 @@ import {
12
12
  registerLanguage,
13
13
  renderLine,
14
14
  tokenize
15
- } from "./chunk-F46VGBFI.js";
15
+ } from "./chunk-XG43K62Y.js";
16
16
 
17
17
  // src/lib/auto.ts
18
18
  var MARKDOWN_CLASS = /(?:^|\s)language-(\S+)/;
package/es/react.js CHANGED
@@ -1,9 +1,9 @@
1
- /*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ /*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  import {
3
3
  copyText,
4
4
  highlight,
5
5
  mount
6
- } from "./chunk-F46VGBFI.js";
6
+ } from "./chunk-XG43K62Y.js";
7
7
 
8
8
  // src/react.ts
9
9
  import { createElement, useEffect, useLayoutEffect, useRef, useState } from "react";
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
package/lib/codelight.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
 
3
3
 
4
4
 
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkHSSBKI63cjs = require('./chunk-HSSBKI63.cjs');
15
+ var _chunkKZATGNQAcjs = require('./chunk-KZATGNQA.cjs');
16
16
 
17
17
  // src/lib/auto.ts
18
18
  var MARKDOWN_CLASS = /(?:^|\s)language-(\S+)/;
@@ -23,10 +23,10 @@ function languageOf(code) {
23
23
  function highlightElement(code, lang = languageOf(code), options = {}) {
24
24
  const lineNumbers = _nullishCoalesce(options.lineNumbers, () => ( attr(code, "data-line-numbers") != null));
25
25
  const highlightLines = _nullishCoalesce(_nullishCoalesce(options.highlightLines, () => ( attr(code, "data-highlight-lines"))), () => ( void 0));
26
- code.innerHTML = _chunkHSSBKI63cjs.highlight.call(void 0, _nullishCoalesce(code.textContent, () => ( "")), lang, { lineNumbers, highlightLines });
26
+ code.innerHTML = _chunkKZATGNQAcjs.highlight.call(void 0, _nullishCoalesce(code.textContent, () => ( "")), lang, { lineNumbers, highlightLines });
27
27
  code.classList.add("cl");
28
28
  code.setAttribute("data-cl", lang);
29
- if (options.copyButton) _chunkHSSBKI63cjs.addCopyButton.call(void 0, code);
29
+ if (options.copyButton) _chunkKZATGNQAcjs.addCopyButton.call(void 0, code);
30
30
  }
31
31
  function highlightAll(rootOrOptions, maybeOptions = {}) {
32
32
  const isRoot = !!rootOrOptions && typeof rootOrOptions.querySelectorAll === "function";
@@ -280,23 +280,23 @@ function injectTheme(doc = document) {
280
280
 
281
281
  // src/codelight.ts
282
282
  var codelight = {
283
- addCopyButton: _chunkHSSBKI63cjs.addCopyButton,
284
- createMarkup: _chunkHSSBKI63cjs.createMarkup,
285
- createStream: _chunkHSSBKI63cjs.createStream,
286
- defineLanguage: _chunkHSSBKI63cjs.defineLanguage,
287
- escapeHtml: _chunkHSSBKI63cjs.escapeHtml,
288
- getLanguage: _chunkHSSBKI63cjs.getLanguage,
289
- highlight: _chunkHSSBKI63cjs.highlight,
283
+ addCopyButton: _chunkKZATGNQAcjs.addCopyButton,
284
+ createMarkup: _chunkKZATGNQAcjs.createMarkup,
285
+ createStream: _chunkKZATGNQAcjs.createStream,
286
+ defineLanguage: _chunkKZATGNQAcjs.defineLanguage,
287
+ escapeHtml: _chunkKZATGNQAcjs.escapeHtml,
288
+ getLanguage: _chunkKZATGNQAcjs.getLanguage,
289
+ highlight: _chunkKZATGNQAcjs.highlight,
290
290
  highlightAll,
291
291
  highlightElement,
292
292
  injectTheme,
293
- listLanguages: _chunkHSSBKI63cjs.listLanguages,
294
- mount: _chunkHSSBKI63cjs.mount,
295
- registerLanguage: _chunkHSSBKI63cjs.registerLanguage,
296
- renderLine: _chunkHSSBKI63cjs.renderLine,
293
+ listLanguages: _chunkKZATGNQAcjs.listLanguages,
294
+ mount: _chunkKZATGNQAcjs.mount,
295
+ registerLanguage: _chunkKZATGNQAcjs.registerLanguage,
296
+ renderLine: _chunkKZATGNQAcjs.renderLine,
297
297
  splitFences,
298
298
  themeCss,
299
- tokenize: _chunkHSSBKI63cjs.tokenize
299
+ tokenize: _chunkKZATGNQAcjs.tokenize
300
300
  };
301
301
  var codelight_default = codelight;
302
302
 
@@ -318,7 +318,7 @@ var codelight_default = codelight;
318
318
 
319
319
 
320
320
 
321
- exports.addCopyButton = _chunkHSSBKI63cjs.addCopyButton; exports.createMarkup = _chunkHSSBKI63cjs.createMarkup; exports.createStream = _chunkHSSBKI63cjs.createStream; exports.default = codelight_default; exports.defineLanguage = _chunkHSSBKI63cjs.defineLanguage; exports.escapeHtml = _chunkHSSBKI63cjs.escapeHtml; exports.getLanguage = _chunkHSSBKI63cjs.getLanguage; exports.highlight = _chunkHSSBKI63cjs.highlight; exports.highlightAll = highlightAll; exports.highlightElement = highlightElement; exports.injectTheme = injectTheme; exports.listLanguages = _chunkHSSBKI63cjs.listLanguages; exports.mount = _chunkHSSBKI63cjs.mount; exports.registerLanguage = _chunkHSSBKI63cjs.registerLanguage; exports.renderLine = _chunkHSSBKI63cjs.renderLine; exports.splitFences = splitFences; exports.themeCss = themeCss; exports.tokenize = _chunkHSSBKI63cjs.tokenize;
321
+ exports.addCopyButton = _chunkKZATGNQAcjs.addCopyButton; exports.createMarkup = _chunkKZATGNQAcjs.createMarkup; exports.createStream = _chunkKZATGNQAcjs.createStream; exports.default = codelight_default; exports.defineLanguage = _chunkKZATGNQAcjs.defineLanguage; exports.escapeHtml = _chunkKZATGNQAcjs.escapeHtml; exports.getLanguage = _chunkKZATGNQAcjs.getLanguage; exports.highlight = _chunkKZATGNQAcjs.highlight; exports.highlightAll = highlightAll; exports.highlightElement = highlightElement; exports.injectTheme = injectTheme; exports.listLanguages = _chunkKZATGNQAcjs.listLanguages; exports.mount = _chunkKZATGNQAcjs.mount; exports.registerLanguage = _chunkKZATGNQAcjs.registerLanguage; exports.renderLine = _chunkKZATGNQAcjs.renderLine; exports.splitFences = splitFences; exports.themeCss = themeCss; exports.tokenize = _chunkKZATGNQAcjs.tokenize;
322
322
  /*!
323
323
  codelight.js — syntax highlighting for code that streams in, like AI chat replies.
324
324
  MIT License · https://github.com/codelightjs/codelight.js
package/lib/react.cjs CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.0 | MIT License | https://github.com/codelightjs/codelight.js */
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/*! codelight.js 1.3.1 | MIT License | https://github.com/codelightjs/codelight.js */
2
2
 
3
3
 
4
4
 
5
5
 
6
- var _chunkHSSBKI63cjs = require('./chunk-HSSBKI63.cjs');
6
+ var _chunkKZATGNQAcjs = require('./chunk-KZATGNQA.cjs');
7
7
 
8
8
  // src/react.ts
9
9
  var _react = require('react');
@@ -12,10 +12,10 @@ function CodeLight({ code, lang, lineNumbers, highlightLines, copyButton, classN
12
12
  const ref = _react.useRef.call(void 0, null);
13
13
  const view = _react.useRef.call(void 0, null);
14
14
  const [copied, setCopied] = _react.useState.call(void 0, false);
15
- const [initial] = _react.useState.call(void 0, () => ({ __html: _chunkHSSBKI63cjs.highlight.call(void 0, code, lang, { lineNumbers, highlightLines }) }));
15
+ const [initial] = _react.useState.call(void 0, () => ({ __html: _chunkKZATGNQAcjs.highlight.call(void 0, code, lang, { lineNumbers, highlightLines }) }));
16
16
  const lines = `${!!lineNumbers}|${String(_nullishCoalesce(highlightLines, () => ( "")))}`;
17
17
  useIsomorphicLayoutEffect(() => {
18
- const v = _chunkHSSBKI63cjs.mount.call(void 0, ref.current, { lang, lineNumbers, highlightLines });
18
+ const v = _chunkKZATGNQAcjs.mount.call(void 0, ref.current, { lang, lineNumbers, highlightLines });
19
19
  v.set(code);
20
20
  view.current = v;
21
21
  return () => {
@@ -38,7 +38,7 @@ function CodeLight({ code, lang, lineNumbers, highlightLines, copyButton, classN
38
38
  _react.createElement.call(void 0, "code", { ref, className: "cl", dangerouslySetInnerHTML: initial }),
39
39
  copyButton ? _react.createElement.call(void 0,
40
40
  "button",
41
- { type: "button", className: "cl-copy", "aria-label": "Copy code", onClick: () => void _chunkHSSBKI63cjs.copyText.call(void 0, code).then(() => setCopied(true)) },
41
+ { type: "button", className: "cl-copy", "aria-label": "Copy code", onClick: () => void _chunkKZATGNQAcjs.copyText.call(void 0, code).then(() => setCopied(true)) },
42
42
  copied ? "Copied" : "Copy"
43
43
  ) : null
44
44
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codelight.js",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Very fast, lightweight syntax highlighter. Highlights each line once and redraws only what changed, so live code never flickers. 27 languages, no dependencies, React or a script tag.",
5
5
  "keywords": [
6
6
  "syntax-highlighting",
@@ -90,17 +90,22 @@
90
90
  "release:minor": "npm version minor && git push --follow-tags",
91
91
  "release:major": "npm version major && git push --follow-tags",
92
92
  "screenshot": "npm run demo && node tools/screenshot.mjs",
93
- "demo": "npm run build && node tools/build-demo.mjs"
93
+ "demo": "npm run build && node tools/build-demo.mjs",
94
+ "bench": "npm run build && node tools/bench/run.mjs"
94
95
  },
95
96
  "devDependencies": {
97
+ "@shikijs/stream": "^4.6.0",
96
98
  "@types/node": "^20.19.43",
97
99
  "@types/react": "^19.3.3",
98
100
  "@types/react-dom": "^19.3.0",
99
101
  "esbuild": "^0.27.7",
100
102
  "happy-dom": "^21.0.4",
103
+ "highlight.js": "^11.12.0",
104
+ "prismjs": "^1.30.0",
101
105
  "puppeteer-core": "^25.19.0",
102
106
  "react": "^19.3.1",
103
107
  "react-dom": "^19.3.1",
108
+ "shiki": "^4.6.0",
104
109
  "tsup": "^8.5.1",
105
110
  "typescript": "^5.9.3",
106
111
  "vitest": "^2.1.9"