1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(tt){"use strict";tt.defineMode("javascript",function(e,l){var t,r,n,a,i,o,d=e.indentUnit,p=l.statementIndent,c=l.jsonld,s=l.json||c,u=l.typescript,f=l.wordCharacters||/[\w$\xa1-\uffff]/,m=(t=v("keyword a"),r=v("keyword b"),n=v("keyword c"),a=v("keyword d"),i=v("operator"),{if:v("if"),while:t,with:t,else:r,do:r,try:r,finally:r,return:a,break:a,continue:a,new:v("new"),delete:n,void:n,throw:n,debugger:v("debugger"),var:v("var"),const:v("var"),let:v("var"),function:v("function"),catch:v("catch"),for:v("for"),switch:v("switch"),case:v("case"),default:v("default"),in:i,typeof:i,instanceof:i,true:o={type:"atom",style:"atom"},false:o,null:o,undefined:o,NaN:o,Infinity:o,this:v("this"),class:v("class"),super:v("atom"),yield:n,export:v("export"),import:v("import"),extends:n,await:n});function v(e){return{type:e,style:"keyword"}}var k,y,w=/[+\-*&%=<>!?|~^@]/,b=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function x(e,t,r){return k=e,y=r,t}function h(e,t){var a,r=e.next();if('"'==r||"'"==r)return t.tokenize=(a=r,function(e,t){var r,n=!1;if(c&&"@"==e.peek()&&e.match(b))return t.tokenize=h,x("jsonld-keyword","meta");for(;null!=(r=e.next())&&(r!=a||n);)n=!n&&"\\"==r;return n||(t.tokenize=h),x("string","string")}),t.tokenize(e,t);if("."==r&&e.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return x("number","number");if("."==r&&e.match(".."))return x("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(r))return x(r);if("="==r&&e.eat(">"))return x("=>","operator");if("0"==r&&e.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return x("number","number");if(/\d/.test(r))return e.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),x("number","number");if("/"==r)return e.eat("*")?(t.tokenize=g)(e,t):e.eat("/")?(e.skipToEnd(),x("comment","comment")):et(e,t,1)?(function(e){for(var t,r=!1,n=!1;null!=(t=e.next());){if(!r){if("/"==t&&!n)return;"["==t?n=!0:n&&"]"==t&&(n=!1)}r=!r&&"\\"==t}}(e),e.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),x("regexp","string-2")):(e.eat("="),x("operator","operator",e.current()));if("`"==r)return(t.tokenize=j)(e,t);if("#"==r&&"!"==e.peek())return e.skipToEnd(),x("meta","meta");if("#"==r&&e.eatWhile(f))return x("variable","property");if("<"==r&&e.match("!--")||"-"==r&&e.match("->")&&!/\S/.test(e.string.slice(0,e.start)))return e.skipToEnd(),x("comment","comment");if(w.test(r))return">"==r&&t.lexical&&">"==t.lexical.type||(e.eat("=")?"!"!=r&&"="!=r||e.eat("="):/[<>*+\-]/.test(r)&&(e.eat(r),">"==r&&e.eat(r))),"?"==r&&e.eat(".")?x("."):x("operator","operator",e.current());if(f.test(r)){e.eatWhile(f);var n=e.current();if("."!=t.lastType){if(m.propertyIsEnumerable(n)){var i=m[n];return x(i.type,i.style,n)}if("async"==n&&e.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/,!1))return x("async","keyword",n)}return x("variable","variable",n)}}function g(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=h;break}n="*"==r}return x("comment","comment")}function j(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=h;break}n=!n&&"\\"==r}return x("quasi","string-2",e.current())}var M="([{}])";function A(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r,n=e.string.indexOf("=>",e.start);if(!(n<0)){!u||(r=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,n)))&&(n=r.index);for(var a=0,i=!1,o=n-1;0<=o;--o){var c=e.string.charAt(o),s=M.indexOf(c);if(0<=s&&s<3){if(!a){++o;break}if(0==--a){"("==c&&(i=!0);break}}else if(3<=s&&s<6)++a;else if(f.test(c))i=!0;else if(/["'\/`]/.test(c))for(;;--o){if(0==o)return;if(e.string.charAt(o-1)==c&&"\\"!=e.string.charAt(o-2)){o--;break}}else if(i&&!a){++o;break}}i&&!a&&(t.fatArrowAt=o)}}var V={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0};function E(e,t,r,n,a,i){this.indented=e,this.column=t,this.type=r,this.prev=a,this.info=i,null!=n&&(this.align=n)}function z(e,t){for(var r=e.localVars;r;r=r.next)if(r
|