This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
wcui/js/lib/codemirror/js.js

1 line
14 KiB
JavaScript

define(["./codemirror"],function(e){"use strict";function t(e,t,r){return/^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(r||0)))}e.defineMode("javascript",function(r,n){function a(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}}function i(e,t,r){return Vt=e,Et=r,t}function o(e,r){var n=e.next();if('"'==n||"'"==n)return r.tokenize=c(n),r.tokenize(e,r);if("."==n&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return i("number","number");if("."==n&&e.match(".."))return i("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return i(n);if("="==n&&e.eat(">"))return i("=>","operator");if("0"==n&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),i("number","number");if("0"==n&&e.eat(/o/i))return e.eatWhile(/[0-7]/i),i("number","number");if("0"==n&&e.eat(/b/i))return e.eatWhile(/[01]/i),i("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),i("number","number");if("/"==n)return e.eat("*")?(r.tokenize=u,u(e,r)):e.eat("/")?(e.skipToEnd(),i("comment","comment")):t(e,r,1)?(a(e),e.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),i("regexp","string-2")):(e.eatWhile(qt),i("operator","operator",e.current()));if("`"==n)return r.tokenize=s,s(e,r);if("#"==n)return e.skipToEnd(),i("error","error");if(qt.test(n))return">"==n&&r.lexical&&">"==r.lexical.type||e.eatWhile(qt),i("operator","operator",e.current());if(Ot.test(n)){e.eatWhile(Ot);var o=e.current(),l=Wt.propertyIsEnumerable(o)&&Wt[o];return l&&"."!=r.lastType?i(l.type,l.style,o):i("variable","variable",o)}}function c(e){return function(t,r){var n,a=!1;if(At&&"@"==t.peek()&&t.match(Ct))return r.tokenize=o,i("jsonld-keyword","meta");for(;null!=(n=t.next())&&(n!=e||a);)a=!a&&"\\"==n;return a||(r.tokenize=o),i("string","string")}}function u(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=o;break}n="*"==r}return i("comment","comment")}function s(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=o;break}n=!n&&"\\"==r}return i("quasi","string-2",e.current())}function l(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r=e.string.indexOf("=>",e.start);if(!(0>r)){if($t){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,r));n&&(r=n.index)}for(var a=0,i=!1,o=r-1;o>=0;--o){var c=e.string.charAt(o),u=Pt.indexOf(c);if(u>=0&&3>u){if(!a){++o;break}if(0==--a){"("==c&&(i=!0);break}}else if(u>=3&&6>u)++a;else if(Ot.test(c))i=!0;else{if(/["'\/]/.test(c))return;if(i&&!a){++o;break}}}i&&!a&&(t.fatArrowAt=o)}}function f(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 d(e,t){for(var r=e.localVars;r;r=r.next)if(r.name==t)return!0;for(var n=e.context;n;n=n.prev)for(var r=n.vars;r;r=r.next)if(r.name==t)return!0}function p(e,t,r,n,a){var i=e.cc;for(Nt.state=e,Nt.stream=a,Nt.marked=null,Nt.cc=i,Nt.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;){var o=i.length?i.pop():Tt?j:w;if(o(r,n)){for(;i.length&&i[i.length-1].lex;)i.pop()();return Nt.marked?Nt.marked:"variable"==r&&d(e,n)?"variable-2":t}}}function m(){for(var e=arguments.length-1;e>=0;e--)Nt.cc.push(arguments[e])}function v(){return m.apply(null,arguments),!0}function y(e){function t(t){for(var r=t;r;r=r.next)if(r.name==e)return!0;return!1}var r=Nt.state;if(Nt.marked="def",r.context){if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function k(){Nt.state.context={prev:Nt.state.context,vars:Nt.state.localVars},Nt.state.localVars=Bt}function b(){Nt.state.localVars=Nt.state.context.vars,Nt.state.context=Nt.state.context.prev}function x(e,t){var r=function(){var r=Nt.state,n=r.indented;if("stat"==r.lexical.type)n=r.lexical.indented;else for(var a=r.lexical;a&&")"==a.type&&a.align;a=a.prev)n=a.indented;r.lexical=new f(n,Nt.stream.column(),e,null,r.lexical,t)};return r.lex=!0,r}function h(){var e=Nt.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function g(e){function t(r){return r==e?v():";"==e?m():v(t)}return t}function w(e,t){return"var"==e?v(x("vardef",t.length),Z,g(";"),h):"keyword a"==e?v(x("form"),V,w,h):"keyword b"==e?v(x("form"),w,h):"{"==e?v(x("}"),J,h):";"==e?v():"if"==e?("else"==Nt.state.lexical.info&&Nt.state.cc[Nt.state.cc.length-1]==h&&Nt.state.cc.pop()(),v(x("form"),V,w,h,nt)):"function"==e?v(st):"for"==e?v(x("form"),at,w,h):"variable"==e?v(x("stat"),N):"switch"==e?v(x("form"),V,x("}","switch"),g("{"),J,h,h):"case"==e?v(j,g(":")):"default"==e?v(g(":")):"catch"==e?v(x("form"),k,g("("),lt,g(")"),w,h,b):"class"==e?v(x("form"),dt,h):"export"==e?v(x("stat"),yt,h):"import"==e?v(x("stat"),bt,h):"module"==e?v(x("form"),_,x("}"),g("{"),J,h,h):"type"==e?v(L,g("operator"),L,g(";")):"async"==e?v(w):m(x("stat"),j,g(";"),h)}function j(e){return E(e,!1)}function M(e){return E(e,!0)}function V(e){return"("!=e?m():v(x(")"),j,g(")"),h)}function E(e,t){if(Nt.state.fatArrowAt==Nt.stream.start){var r=t?q:W;if("("==e)return v(k,x(")"),F(_,")"),h,g("=>"),r,b);if("variable"==e)return m(k,_,g("=>"),r,b)}var n=t?T:A;return St.hasOwnProperty(e)?v(n):"function"==e?v(st,n):"class"==e?v(x("form"),ft,h):"keyword c"==e||"async"==e?v(t?z:I):"("==e?v(x(")"),I,g(")"),h,n):"operator"==e||"spread"==e?v(t?M:j):"["==e?v(x("]"),jt,h,n):"{"==e?G(H,"}",null,n):"quasi"==e?m($,n):"new"==e?v(C(t)):v()}function I(e){return e.match(/[;\}\)\],]/)?m():m(j)}function z(e){return e.match(/[;\}\)\],]/)?m():m(M)}function A(e,t){return","==e?v(j):T(e,t,!1)}function T(e,t,r){var n=0==r?A:T,a=0==r?j:M;return"=>"==e?v(k,r?q:W,b):"operator"==e?/\+\+|--/.test(t)?v(n):"?"==t?v(j,g(":"),a):v(a):"quasi"==e?m($,n):";"!=e?"("==e?G(M,")","call",n):"."==e?v(B,n):"["==e?v(x("]"),I,g("]"),h,n):void 0:void 0}function $(e,t){return"quasi"!=e?m():"${"!=t.slice(t.length-2)?v($):v(j,O)}function O(e){return"}"==e?(Nt.marked="string-2",Nt.state.tokenize=s,v($)):void 0}function W(e){return l(Nt.stream,Nt.state),m("{"==e?w:j)}function q(e){return l(Nt.stream,Nt.state),m("{"==e?w:M)}function C(e){return function(t){return"."==t?v(e?S:P):m(e?M:j)}}function P(e,t){return"target"==t?(Nt.marked="keyword",v(A)):void 0}function S(e,t){return"target"==t?(Nt.marked="keyword",v(T)):void 0}function N(e){return":"==e?v(h,w):m(A,g(";"),h)}function B(e){return"variable"==e?(Nt.marked="property",v()):void 0}function H(e,t){return"async"==e?(Nt.marked="property",v(H)):"variable"==e||"keyword"==Nt.style?(Nt.marked="property",v("get"==t||"set"==t?U:D)):"number"==e||"string"==e?(Nt.marked=At?"property":Nt.style+" property",v(D)):"jsonld-keyword"==e?v(D):"modifier"==e?v(H):"["==e?v(j,g("]"),D):"spread"==e?v(j):":"==e?m(D):void 0}function U(e){return"variable"!=e?m(D):(Nt.marked="property",v(st))}function D(e){return":"==e?v(M):"("==e?m(st):void 0}function F(e,t,r){function n(a,i){if(r?r.indexOf(a)>-1:","==a){var o=Nt.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),v(function(r,n){return r==t||n==t?m():m(e)},n)}return a==t||i==t?v():v(g(t))}return function(r,a){return r==t||a==t?v():m(e,n)}}function G(e,t,r){for(var n=3;n<arguments.length;n++)Nt.cc.push(arguments[n]);return v(x(t,r),F(e,t),h)}function J(e){return"}"==e?v():m(w,J)}function K(e,t){if($t){if(":"==e)return v(L);if("?"==t)return v(K)}}function L(e){return"variable"==e?(Nt.marked="variable-3",v(Y)):"string"==e||"number"==e||"atom"==e?v(Y):"{"==e?v(x("}"),F(R,"}",",;"),h):"("==e?v(F(X,")"),Q):void 0}function Q(e){return"=>"==e?v(L):void 0}function R(e,t){return"variable"==e||"keyword"==Nt.style?(Nt.marked="property",v(R)):"?"==t?v(R):":"==e?v(L):void 0}function X(e){return"variable"==e?v(X):":"==e?v(L):void 0}function Y(e,t){return"<"==t?v(x(">"),F(L,">"),h,Y):"|"==t||"."==e?v(L):"["==e?v(g("]"),Y):void 0}function Z(){return m(_,K,tt,rt)}function _(e,t){return"modifier"==e?v(_):"variable"==e?(y(t),v()):"spread"==e?v(_):"["==e?G(_,"]"):"{"==e?G(et,"}"):void 0}function et(e,t){return"variable"!=e||Nt.stream.match(/^\s*:/,!1)?("variable"==e&&(Nt.marked="property"),"spread"==e?v(_):"}"==e?m():v(g(":"),_,tt)):(y(t),v(tt))}function tt(e,t){return"="==t?v(M):void 0}function rt(e){return","==e?v(Z):void 0}function nt(e,t){return"keyword b"==e&&"else"==t?v(x("form","else"),w,h):void 0}function at(e){return"("==e?v(x(")"),it,g(")"),h):void 0}function it(e){return"var"==e?v(Z,g(";"),ct):";"==e?v(ct):"variable"==e?v(ot):m(j,g(";"),ct)}function ot(e,t){return"in"==t||"of"==t?(Nt.marked="keyword",v(j)):v(A,ct)}function ct(e,t){return";"==e?v(ut):"in"==t||"of"==t?(Nt.marked="keyword",v(j)):m(j,g(";"),ut)}function ut(e){")"!=e&&v(j)}function st(e,t){return"*"==t?(Nt.marked="keyword",v(st)):"variable"==e?(y(t),v(st)):"("==e?v(k,x(")"),F(lt,")"),h,K,w,b):void 0}function lt(e){return"spread"==e?v(lt):m(_,K,tt)}function ft(e,t){return"variable"==e?dt(e,t):pt(e,t)}function dt(e,t){return"variable"==e?(y(t),v(pt)):void 0}function pt(e,t){return"<"==t?v(x(">"),F(L,">"),h,pt):"extends"==t||"implements"==t||$t&&","==e?v($t?L:j,pt):"{"==e?v(x("}"),mt,h):void 0}function mt(e,t){return"variable"==e||"keyword"==Nt.style?("async"==t||"static"==t||"get"==t||"set"==t||$t&&("public"==t||"private"==t||"protected"==t||"readonly"==t||"abstract"==t))&&Nt.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(Nt.marked="keyword",v(mt)):(Nt.marked="property",v($t?vt:st,mt)):"["==e?v(j,g("]"),$t?vt:st,mt):"*"==t?(Nt.marked="keyword",v(mt)):";"==e?v(mt):"}"==e?v():void 0}function vt(e,t){return"?"==t?v(vt):":"==e?v(L,tt):"="==t?v(M):m(st)}function yt(e,t){return"*"==t?(Nt.marked="keyword",v(wt,g(";"))):"default"==t?(Nt.marked="keyword",v(j,g(";"))):"{"==e?v(F(kt,"}"),wt,g(";")):m(w)}function kt(e,t){return"as"==t?(Nt.marked="keyword",v(g("variable"))):"variable"==e?m(M,kt):void 0}function bt(e){return"string"==e?v():m(xt,ht,wt)}function xt(e,t){return"{"==e?G(xt,"}"):("variable"==e&&y(t),"*"==t&&(Nt.marked="keyword"),v(gt))}function ht(e){return","==e?v(xt,ht):void 0}function gt(e,t){return"as"==t?(Nt.marked="keyword",v(xt)):void 0}function wt(e,t){return"from"==t?(Nt.marked="keyword",v(j)):void 0}function jt(e){return"]"==e?v():m(F(M,"]"))}function Mt(e,t){return"operator"==e.lastType||","==e.lastType||qt.test(t.charAt(0))||/[,.]/.test(t.charAt(0))}var Vt,Et,It=r.indentUnit,zt=n.statementIndent,At=n.jsonld,Tt=n.json||At,$t=n.typescript,Ot=n.wordCharacters||/[\w$\xa1-\uffff]/,Wt=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),r=e("keyword b"),n=e("keyword c"),a=e("operator"),i={type:"atom",style:"atom"},o={"if":e("if"),"while":t,"with":t,"else":r,"do":r,"try":r,"finally":r,"return":n,"break":n,"continue":n,"new":e("new"),"delete":n,"throw":n,"debugger":n,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":a,"typeof":a,"instanceof":a,"true":i,"false":i,"null":i,undefined:i,NaN:i,Infinity:i,"this":e("this"),"class":e("class"),"super":e("atom"),"yield":n,"export":e("export"),"import":e("import"),"extends":n,await:n,async:e("async")};if($t){var c={type:"variable",style:"variable-3"},u={"interface":e("class"),"implements":n,namespace:n,module:e("module"),"enum":e("module"),type:e("type"),"public":e("modifier"),"private":e("modifier"),"protected":e("modifier"),"abstract":e("modifier"),as:a,string:c,number:c,"boolean":c,any:c};for(var s in u)o[s]=u[s]}return o}(),qt=/[+\-*&%=<>!?|~^]/,Ct=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Pt="([{}])",St={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Nt={state:null,column:null,marked:null,cc:null},Bt={name:"this",next:{name:"arguments"}};return h.lex=!0,{startState:function(e){var t={tokenize:o,lastType:"sof",cc:[],lexical:new f((e||0)-It,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:e||0};return n.globalVars&&"object"==typeof n.globalVars&&(t.globalVars=n.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),l(e,t)),t.tokenize!=u&&e.eatSpace())return null;var r=t.tokenize(e,t);return"comment"==Vt?r:(t.lastType="operator"!=Vt||"++"!=Et&&"--"!=Et?Vt:"incdec",p(t,r,Vt,Et,e))},indent:function(t,r){if(t.tokenize==u)return e.Pass;if(t.tokenize!=o)return 0;var a,i=r&&r.charAt(0),c=t.lexical;if(!/^\s*else\b/.test(r))for(var s=t.cc.length-1;s>=0;--s){var l=t.cc[s];if(l==h)c=c.prev;else if(l!=nt)break}for(;!("stat"!=c.type&&"form"!=c.type||"}"!=i&&(!(a=t.cc[t.cc.length-1])||a!=A&&a!=T||/^[,\.=+\-*:?[\(]/.test(r)));)c=c.prev;zt&&")"==c.type&&"stat"==c.prev.type&&(c=c.prev);var f=c.type,d=i==f;return"vardef"==f?c.indented+("operator"==t.lastType||","==t.lastType?c.info+1:0):"form"==f&&"{"==i?c.indented:"form"==f?c.indented+It:"stat"==f?c.indented+(Mt(t,r)?zt||It:0):"switch"!=c.info||d||0==n.doubleIndentSwitch?c.align?c.column+(d?0:1):c.indented+(d?0:It):c.indented+(/^(?:case|default)\b/.test(r)?It:2*It)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Tt?null:"/*",blockCommentEnd:Tt?null:"*/",lineComment:Tt?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Tt?"json":"javascript",jsonldMode:At,jsonMode:Tt,expressionAllowed:t,skipExpression:function(e){var t=e.cc[e.cc.length-1];(t==j||t==M)&&e.cc.pop()}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})});
wcui是一套基于`Web Components`的UI组件库, 宗旨是追求简单、实用、不花哨。
JavaScript 95.2%
CSS 4.8%