UNPKG

@ryusei/light

Version:

<div align="center"> <a href="https://light.ryuseijs.com"> <img alt="RyuseiLight" src="https://light.ryuseijs.com/images/svg/logo.svg" width="70"> </a>

2 lines (1 loc) 3.57 kB
!function(e,n){if("function"==typeof define&&define.amd)define([],n);else if("undefined"!=typeof exports)n();else{n(),e.unknown={}}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(){function e(e){return null!==e&&"object"==typeof e}function n(e){return void 0===e}function a(e,n){if(e)for(var a=Object.keys(e),t=0;t<a.length;t++)n(e[a[t]],a[t])}function t(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return r.forEach((function(i){e(i)&&a(i,(function(e,a){n(i[a])||(t[a]=i[a])}))})),t}function i(e,n,a){var t=function(e,n){for(var a=0;a<e.length;a++)if(e[a][0]===n)return a;return-1}(e,n);t>-1?e.splice.apply(e,[t,0].concat(a)):e.push.apply(e,a)}var r="keyword",s="comment",o="string",u="function",f="class",c="operator",d="bracket",l="delimiter",p="space",b=/[+-]?(\d+\.?\d*|\d*\.?\d+)([eE][+-]?\d+)?/,g=/\b(?:true|false)\b/,m=/[[\]{}()]/,y=/[ \t]+/,F=/'(?:\\'|.)*?'/,k=/"(?:\\"|.)*?"/,w=/\/\*[\s\S]*?(\*\/|$)/,h=/\/\/.*/,T=/\b(?:break|catch|class|continue|do|else|extends|finally|for|function|if|implements|in|instanceof|interface|new|null|return|throw|try|while)\b/;function v(){return{id:"javascript",name:"JavaScript",alias:["js"],source:{func:/[_$a-z\xA0-\uFFFF][_$a-z0-9\xA0-\uFFFF]*/},grammar:{main:[[o,F],[o,k],["#backtick",/`/,"@rest"],[s,w],[s,h],["regexp",/\/(\[.*?]|\\\/|.)+?\/[gimsuy]*/],[r,T],[r,/\b(?:as|async|await|case|catch|const|debugger|default|delete|enum|export|from|import|let|package|private|protected|public|super|switch|static|this|typeof|undefined|var|void|with|yield)\b/],[r,/\b((get|set)(?=\s+%func))/i],[f,/\b[A-Z][\w$]*\b/],[u,/%func(?=\s*\()/i],["boolean",g],["decorator",/@[^\s(@]+/],["identifier",/\b[a-z_$][\w$]*\b/],["number",b],[c,/=>/],[c,/\+[+=]?|-[-=]?|\*\*?=?|[/%^]=?|&&?=?|\|\|?=?|\?\??=?|<<?=?|>>>=?|>>?=?|[!=]=?=?|[~:^]/],[d,m],[l,/[;.,]+/],[p,y]],backtick:[[o,/^`/],[o,/(\$[^{]|\\[$`]|[^`$])+/],["#expression",/\${/,"@rest"],[o,/`/,"@break"]],expression:[[l,/^\${/],[l,/}/,"@break"],["#main"]]}}}function $(){var e=t(v(),{id:"typescript",name:"TypeScript",alias:["ts"]}),n=e.grammar,a=n.main;return i(a,r,[[r,/\b(?:declare|keyof|namespace|readonly|type|string|number|boolean|bigint|symbol|object|any|never|unknown|infer|is)\b/]]),i(a,u,[["#functions",/([_$a-z\xA0-\uFFFF][_$a-z0-9\xA0-\uFFFF]*)?(?:<[^>]+?>)?\s*?\(/]]),t(n,{functions:[[u,/^[\w$]+/]].concat(a.filter((function(e){return"#functions"!==e[0]})))}),e}"undefined"!=typeof window&&window.RyuseiLight&&window.RyuseiLight.register(t(function(e){void 0===e&&(e={});var n=t((e.base||v)(),{id:"jsx",name:"JSX",alias:["react"]}),a=n.grammar;return i(a.main,f,[["#findPairedTag"],["#findSelfClosedTag"]]),t(a,{findPairedTag:[["#pairedTag",/(?:<[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*?([0-9A-Z_a-z]+)[\s\S]*?>[\s\S]*?<\/\1>)|<[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*?>[\s\S]*?<\/>/,"@rest"]],findSelfClosedTag:[["#selfClosedTag",/<(?:\{[\s\S]*?\}|(["'])[\s\S]*?\1|(?:(?!>)[\s\S]))+?\/>/]],findBracket:[["#code",/{/,"@rest"]],pairedTag:[["#openTag",/^</,"@rest"],["#findBracket"],["#findPairedTag"],["#findSelfClosedTag"],["#tagName",/<\/([\w][^\s]*?)?>/,"@break"],[p,y]],code:[[d,/^{/],[d,/}/,"@break"],["#findBracket"],["#main"]],selfClosedTag:[["#openTag",/^</,"@rest"]],openTag:[["#tagName",/<\s*[^\s/>"'=]*/],["#findBracket"],["attr",/[^\s/>"'=]+/],["value",/(['"])(\\\1|.)*?\1/],[p,y],[l,/[/=]/],[d,/>/,"@break"]],tagName:[[d,/[<>]/],[p,y],[l,/\//],[f,/[A-Z][\w$-]*/],["tag",/[^\s/>"'=]+/]]}),n}({base:$}),{id:"tsx",name:"TSX"}))}));