diff --git a/_docs/personalization.md b/_docs/personalization.md index c33ae315..e29776e1 100644 --- a/_docs/personalization.md +++ b/_docs/personalization.md @@ -423,7 +423,6 @@ if (core.flags.statusBarItems.indexOf('enableSkill')>=0) { - **`flag:input`**: 接受用户输入的事件后,存放用户输入的结果。 - **`flag:type`**, **`flag:keycode`**, **`flag:x`**, **`flag:y`**, **`flag:px`**, **`flag:py`**: 等待用户操作后,用户的操作类型,按键keycode或点击/像素坐标。 - **`flag:skill`**, **`flag:skillName`**: 开启的技能编号和技能名。 -- **`flag:heroIcon`**: 当前的勇士行走图名称。 - **`flag:saveEquips`**: 快速换装时保存的套装。 - **`flag:__visited__`**: 当前访问过的楼层。 - **`flag:__atk_buff__`**, **`flag:__def_buff__`**, **`flag:__mdef_buff__`**: 当前攻防护盾的实际计算比例加成。 diff --git a/_server/CodeMirror/acorn.min.js b/_server/CodeMirror/acorn.min.js new file mode 100644 index 00000000..32d04821 --- /dev/null +++ b/_server/CodeMirror/acorn.min.js @@ -0,0 +1,6 @@ +/*acorn.min.js*/ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).acorn={})}(this,function(t){"use strict";var n={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},e="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",o={5:e,"5module":e+" export import",6:e+" const class extends export import super"},h=/^in(stanceof)?$/,i="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿯ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞿꟂ-Ᶎꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭧꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",s="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࣓-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",a=new RegExp("["+i+"]"),r=new RegExp("["+i+s+"]");i=s=null;var p=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,155,22,13,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],c=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,232,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239];function u(t,e){for(var i=65536,s=0;s",g),template:new f("template"),invalidTemplate:new f("invalidTemplate"),ellipsis:new f("...",g),backQuote:new f("`",x),dollarBraceL:new f("${",{beforeExpr:!0,startsExpr:!0}),eq:new f("=",{beforeExpr:!0,isAssign:!0}),assign:new f("_=",{beforeExpr:!0,isAssign:!0}),incDec:new f("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new f("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:m("||",1),logicalAND:m("&&",2),bitwiseOR:m("|",3),bitwiseXOR:m("^",4),bitwiseAND:m("&",5),equality:m("==/!=/===/!==",6),relational:m("/<=/>=",7),bitShift:m("<>/>>>",8),plusMin:new f("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:m("%",10),star:m("*",10),slash:m("/",10),starstar:new f("**",{beforeExpr:!0}),_break:v("break"),_case:v("case",g),_catch:v("catch"),_continue:v("continue"),_debugger:v("debugger"),_default:v("default",g),_do:v("do",{isLoop:!0,beforeExpr:!0}),_else:v("else",g),_finally:v("finally"),_for:v("for",{isLoop:!0}),_function:v("function",x),_if:v("if"),_return:v("return",g),_switch:v("switch"),_throw:v("throw",g),_try:v("try"),_var:v("var"),_const:v("const"),_while:v("while",{isLoop:!0}),_with:v("with"),_new:v("new",{beforeExpr:!0,startsExpr:!0}),_this:v("this",x),_super:v("super",x),_class:v("class",x),_extends:v("extends",g),_export:v("export"),_import:v("import",x),_null:v("null",x),_true:v("true",x),_false:v("false",x),_in:v("in",{beforeExpr:!0,binop:7}),_instanceof:v("instanceof",{beforeExpr:!0,binop:7}),_typeof:v("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:v("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:v("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},b=/\r\n?|\n|\u2028|\u2029/,k=new RegExp(b.source,"g");function S(t,e){return 10===t||13===t||!e&&(8232===t||8233===t)}var C=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,w=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,E=Object.prototype,A=E.hasOwnProperty,I=E.toString;function P(t,e){return A.call(t,e)}var T=Array.isArray||function(t){return"[object Array]"===I.call(t)};function L(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function N(t,e){this.line=t,this.column=e}var V=function(t,e,i){this.start=e,this.end=i,null!==t.sourceFile&&(this.source=t.sourceFile)};function R(t,e){for(var i=1,s=0;;){k.lastIndex=s;var a=k.exec(t);if(!(a&&a.index>10),56320+(1023&t)))}function vt(t){return 36===t||40<=t&&t<=43||46===t||63===t||91<=t&&t<=94||123<=t&&t<=125}function _t(t){return 65<=t&&t<=90||97<=t&&t<=122}function bt(t){return _t(t)||95===t}function kt(t){return 48<=t&&t<=57}function St(t){return 48<=t&&t<=57||65<=t&&t<=70||97<=t&&t<=102}function Ct(t){return 65<=t&&t<=70?t-65+10:97<=t&&t<=102?t-97+10:t-48}function wt(t){return 48<=t&&t<=55}gt.prototype.reset=function(t,e,i){var s=-1!==i.indexOf("u");this.start=0|t,this.source=e+"",this.flags=i,this.switchU=s&&6<=this.parser.options.ecmaVersion,this.switchN=s&&9<=this.parser.options.ecmaVersion},gt.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},gt.prototype.at=function(t){var e=this.source,i=e.length;if(i<=t)return-1;var s=e.charCodeAt(t);return!this.switchU||s<=55295||57344<=s||i<=t+1?s:(s<<10)+e.charCodeAt(t+1)-56613888},gt.prototype.nextIndex=function(t){var e=this.source,i=e.length;if(i<=t)return i;var s=e.charCodeAt(t);return!this.switchU||s<=55295||57344<=s||i<=t+1?t+1:t+2},gt.prototype.current=function(){return this.at(this.pos)},gt.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},gt.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},gt.prototype.eat=function(t){return this.current()===t&&(this.advance(),!0)},xt.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,s=0;st.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;et.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1},xt.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1},xt.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},xt.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1},xt.regexp_eatZero=function(t){return 48===t.current()&&!kt(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},xt.regexp_eatControlEscape=function(t){var e=t.current();return 116===e?(t.lastIntValue=9,t.advance(),!0):110===e?(t.lastIntValue=10,t.advance(),!0):118===e?(t.lastIntValue=11,t.advance(),!0):102===e?(t.lastIntValue=12,t.advance(),!0):114===e&&(t.lastIntValue=13,t.advance(),!0)},xt.regexp_eatControlLetter=function(t){var e=t.current();return!!_t(e)&&(t.lastIntValue=e%32,t.advance(),!0)},xt.regexp_eatRegExpUnicodeEscapeSequence=function(t){var e=t.pos;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var i=t.lastIntValue;if(t.switchU&&55296<=i&&i<=56319){var s=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var a=t.lastIntValue;if(56320<=a&&a<=57343)return t.lastIntValue=1024*(i-55296)+(a-56320)+65536,!0}t.pos=s,t.lastIntValue=i}return!0}if(t.switchU&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&function(t){return 0<=t&&t<=1114111}(t.lastIntValue))return!0;t.switchU&&t.raise("Invalid unicode escape"),t.pos=e}return!1},xt.regexp_eatIdentityEscape=function(t){if(t.switchU)return!!this.regexp_eatSyntaxCharacter(t)||!!t.eat(47)&&(t.lastIntValue=47,!0);var e=t.current();return!(99===e||t.switchN&&107===e)&&(t.lastIntValue=e,t.advance(),!0)},xt.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(49<=e&&e<=57){for(;t.lastIntValue=10*t.lastIntValue+(e-48),t.advance(),48<=(e=t.current())&&e<=57;);return!0}return!1},xt.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(function(t){return 100===t||68===t||115===t||83===t||119===t||87===t}(e))return t.lastIntValue=-1,t.advance(),!0;if(t.switchU&&9<=this.options.ecmaVersion&&(80===e||112===e)){if(t.lastIntValue=-1,t.advance(),t.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(t)&&t.eat(125))return!0;t.raise("Invalid property name")}return!1},xt.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var s=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,s),!0}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var a=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,a),!0}return!1},xt.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){P(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")},xt.regexp_validateUnicodePropertyNameOrValue=function(t,e){t.unicodeProperties.binary.test(e)||t.raise("Invalid property name")},xt.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";bt(e=t.current());)t.lastStringValue+=yt(e),t.advance();return""!==t.lastStringValue},xt.regexp_eatUnicodePropertyValue=function(t){var e,i=0;for(t.lastStringValue="";bt(e=i=t.current())||kt(e);)t.lastStringValue+=yt(i),t.advance();return""!==t.lastStringValue},xt.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},xt.regexp_eatCharacterClass=function(t){if(t.eat(91)){if(t.eat(94),this.regexp_classRanges(t),t.eat(93))return!0;t.raise("Unterminated character class")}return!1},xt.regexp_classRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;!t.switchU||-1!==e&&-1!==i||t.raise("Invalid character class"),-1!==e&&-1!==i&&i>10),56320+(1023&t)))}At.next=function(){this.options.onToken&&this.options.onToken(new Et(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},At.getToken=function(){return this.next(),new Et(this)},"undefined"!=typeof Symbol&&(At[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===_.eof,value:t}}}}),At.curContext=function(){return this.context[this.context.length-1]},At.nextToken=function(){var t=this.curContext();return t&&t.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(_.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},At.readToken=function(t){return l(t,6<=this.options.ecmaVersion)||92===t?this.readWord():this.getTokenFromCode(t)},At.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);return t<=55295||57344<=t?t:(t<<10)+this.input.charCodeAt(this.pos+1)-56613888},At.skipBlockComment=function(){var t,e=this.options.onComment&&this.curPosition(),i=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(-1===s&&this.raise(this.pos-2,"Unterminated comment"),this.pos=s+2,this.options.locations)for(k.lastIndex=i;(t=k.exec(this.input))&&t.index=this.input.length&&this.raise(i,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(b.test(s)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if("["===s)e=!0;else if("]"===s&&e)e=!1;else if("/"===s&&!e)break;t="\\"===s}++this.pos}var a=this.input.slice(i,this.pos);++this.pos;var r=this.pos,n=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new gt(this));o.reset(i,a,n),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var h=null;try{h=new RegExp(a,n)}catch(t){}return this.finishToken(_.regexp,{pattern:a,flags:n,value:h})},At.readInt=function(t,e){for(var i=this.pos,s=0,a=0,r=null==e?1/0:e;a=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===t)break;92===s?(e+=this.input.slice(i,this.pos),e+=this.readEscapedChar(!1),i=this.pos):(S(s,10<=this.options.ecmaVersion)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(_.string,e)};var Pt={};At.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==Pt)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},At.invalidStringToken=function(t,e){if(this.inTemplateElement&&9<=this.options.ecmaVersion)throw Pt;this.raise(t,e)},At.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(96===i||36===i&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==_.template&&this.type!==_.invalidTemplate?(t+=this.input.slice(e,this.pos),this.finishToken(_.template,t)):36===i?(this.pos+=2,this.finishToken(_.dollarBraceL)):(++this.pos,this.finishToken(_.backQuote));if(92===i)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(S(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:t+="\n";break;default:t+=String.fromCharCode(i)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}},At.readInvalidTemplateToken=function(){for(;this.pos=this.input.length||this.indentationAfter(this.nextLineStart)=this.curLineStart;--t){var e=this.input.charCodeAt(t);if(9!==e&&32!==e)return!1}return!0},s.prototype.extend=function(t,e){this[t]=e(this[t])},s.prototype.parse=function(){return this.next(),this.parseTopLevel()},s.extend=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];for(var s=this,i=0;i=this.nextLineStart){for(;this.tok.start>=this.nextLineStart;)this.curLineStart=this.nextLineStart,this.nextLineStart=this.lineEnd(this.curLineStart)+1;this.curIndent=this.indentationAfter(this.curLineStart)}},e.readToken=function(){for(;;)try{return this.toks.next(),this.toks.type===l.tokTypes.dot&&"."===this.input.substr(this.toks.end,1)&&6<=this.options.ecmaVersion&&(this.toks.end++,this.toks.type=l.tokTypes.ellipsis),new l.Token(this.toks)}catch(t){if(!(t instanceof SyntaxError))throw t;var e=t.message,s=t.raisedAt,i=!0;if(/unterminated/i.test(e))if(s=this.lineEnd(t.pos+1),/string/.test(e))i={start:t.pos,end:s,type:l.tokTypes.string,value:this.input.slice(t.pos+1,s)};else if(/regular expr/i.test(e)){var r=this.input.slice(t.pos,s);try{r=new RegExp(r)}catch(t){}i={start:t.pos,end:s,type:l.tokTypes.regexp,value:r}}else i=!!/template/.test(e)&&{start:t.pos,end:s,type:l.tokTypes.template,value:this.input.slice(t.pos,s)};else if(/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number|expected number in radix/i.test(e))for(;s]/.test(s)||/[enwfd]/.test(s)&&/\b(case|else|return|throw|new|in|(instance|type)?of|delete|void)$/.test(this.input.slice(t-10,t)),this.options.locations)for(this.toks.curLine=1,this.toks.lineStart=l.lineBreakG.lastIndex=0;(e=l.lineBreakG.exec(this.input))&&e.indexthis.ahead.length;)this.ahead.push(this.readToken());return this.ahead[t-1]};var r=s.prototype;r.parseTopLevel=function(){var t=this.startNodeAt(this.options.locations?[0,l.getLineInfo(this.input,0)]:0);for(t.body=[];this.tok.type!==l.tokTypes.eof;)t.body.push(this.parseStatement());return this.toks.adaptDirectivePrologue(t.body),this.last=this.tok,t.sourceType=this.options.sourceType,this.finishNode(t,"Program")},r.parseStatement=function(){var t,e,s=this.tok.type,i=this.startNode();switch(this.toks.isLet()&&(s=l.tokTypes._var,t="let"),s){case l.tokTypes._break:case l.tokTypes._continue:this.next();var r=s===l.tokTypes._break;return this.semicolon()||this.canInsertSemicolon()?i.label=null:(i.label=this.tok.type===l.tokTypes.name?this.parseIdent():null,this.semicolon()),this.finishNode(i,r?"BreakStatement":"ContinueStatement");case l.tokTypes._debugger:return this.next(),this.semicolon(),this.finishNode(i,"DebuggerStatement");case l.tokTypes._do:return this.next(),i.body=this.parseStatement(),i.test=this.eat(l.tokTypes._while)?this.parseParenExpression():this.dummyIdent(),this.semicolon(),this.finishNode(i,"DoWhileStatement");case l.tokTypes._for:this.next();var o=9<=this.options.ecmaVersion&&this.inAsync&&this.eatContextual("await");if(this.pushCx(),this.expect(l.tokTypes.parenL),this.tok.type===l.tokTypes.semi)return this.parseFor(i,null);var n=this.toks.isLet();if(n||this.tok.type===l.tokTypes._var||this.tok.type===l.tokTypes._const){var a=this.parseVar(this.startNode(),!0,n?"let":this.tok.value);return 1!==a.declarations.length||this.tok.type!==l.tokTypes._in&&!this.isContextual("of")?this.parseFor(i,a):(9<=this.options.ecmaVersion&&this.tok.type!==l.tokTypes._in&&(i.await=o),this.parseForIn(i,a))}var h=this.parseExpression(!0);return this.tok.type===l.tokTypes._in||this.isContextual("of")?(9<=this.options.ecmaVersion&&this.tok.type!==l.tokTypes._in&&(i.await=o),this.parseForIn(i,this.toAssignable(h))):this.parseFor(i,h);case l.tokTypes._function:return this.next(),this.parseFunction(i,!0);case l.tokTypes._if:return this.next(),i.test=this.parseParenExpression(),i.consequent=this.parseStatement(),i.alternate=this.eat(l.tokTypes._else)?this.parseStatement():null,this.finishNode(i,"IfStatement");case l.tokTypes._return:return this.next(),this.eat(l.tokTypes.semi)||this.canInsertSemicolon()?i.argument=null:(i.argument=this.parseExpression(),this.semicolon()),this.finishNode(i,"ReturnStatement");case l.tokTypes._switch:var p,c,u=this.curIndent,y=this.curLineStart;for(this.next(),i.discriminant=this.parseParenExpression(),i.cases=[],this.pushCx(),this.expect(l.tokTypes.braceL);!this.closes(l.tokTypes.braceR,u,y,!0);){this.tok.type===l.tokTypes._case||this.tok.type===l.tokTypes._default?(c=this.tok.type===l.tokTypes._case,p&&this.finishNode(p,"SwitchCase"),i.cases.push(p=this.startNode()),p.consequent=[],this.next(),p.test=c?this.parseExpression():null,this.expect(l.tokTypes.colon)):(p||(i.cases.push(p=this.startNode()),p.consequent=[],p.test=null),p.consequent.push(this.parseStatement()))}return p&&this.finishNode(p,"SwitchCase"),this.popCx(),this.eat(l.tokTypes.braceR),this.finishNode(i,"SwitchStatement");case l.tokTypes._throw:return this.next(),i.argument=this.parseExpression(),this.semicolon(),this.finishNode(i,"ThrowStatement");case l.tokTypes._try:return this.next(),i.block=this.parseBlock(),i.handler=null,this.tok.type===l.tokTypes._catch&&(e=this.startNode(),this.next(),this.eat(l.tokTypes.parenL)?(e.param=this.toAssignable(this.parseExprAtom(),!0),this.expect(l.tokTypes.parenR)):e.param=null,e.body=this.parseBlock(),i.handler=this.finishNode(e,"CatchClause")),i.finalizer=this.eat(l.tokTypes._finally)?this.parseBlock():null,i.handler||i.finalizer?this.finishNode(i,"TryStatement"):i.block;case l.tokTypes._var:case l.tokTypes._const:return this.parseVar(i,!1,t||this.tok.value);case l.tokTypes._while:return this.next(),i.test=this.parseParenExpression(),i.body=this.parseStatement(),this.finishNode(i,"WhileStatement");case l.tokTypes._with:return this.next(),i.object=this.parseParenExpression(),i.body=this.parseStatement(),this.finishNode(i,"WithStatement");case l.tokTypes.braceL:return this.parseBlock();case l.tokTypes.semi:return this.next(),this.finishNode(i,"EmptyStatement");case l.tokTypes._class:return this.parseClass(!0);case l.tokTypes._import:return 10r&&(r=this.curLineStart);!this.closes(l.tokTypes.braceR,s+(this.curLineStart<=r?1:0),i);){var o=this.startNode();if(this.eat(l.tokTypes.star))o.local=this.eatContextual("as")?this.parseIdent():this.dummyIdent(),this.finishNode(o,"ImportNamespaceSpecifier");else{if(this.isContextual("from"))break;if(o.imported=this.parseIdent(),k(o.imported))break;o.local=this.eatContextual("as")?this.parseIdent():o.imported,this.finishNode(o,"ImportSpecifier")}t.push(o),this.eat(l.tokTypes.comma)}this.eat(l.tokTypes.braceR),this.popCx()}return t},r.parseExportSpecifierList=function(){var t=[],e=this.curIndent,s=this.curLineStart,i=this.nextLineStart;for(this.pushCx(),this.eat(l.tokTypes.braceL),this.curLineStart>i&&(i=this.curLineStart);!this.closes(l.tokTypes.braceR,e+(this.curLineStart<=i?1:0),s)&&!this.isContextual("from");){var r=this.startNode();if(r.local=this.parseIdent(),k(r.local))break;r.exported=this.eatContextual("as")?this.parseIdent():r.local,this.finishNode(r,"ExportSpecifier"),t.push(r),this.eat(l.tokTypes.comma)}return this.eat(l.tokTypes.braceR),this.popCx(),t};var o=s.prototype;o.checkLVal=function(t){if(!t)return t;switch(t.type){case"Identifier":case"MemberExpression":return t;case"ParenthesizedExpression":return t.expression=this.checkLVal(t.expression),t;default:return this.dummyIdent()}},o.parseExpression=function(t){var e=this.storeCurrentPos(),s=this.parseMaybeAssign(t);if(this.tok.type!==l.tokTypes.comma)return s;var i=this.startNodeAt(e);for(i.expressions=[s];this.eat(l.tokTypes.comma);)i.expressions.push(this.parseMaybeAssign(t));return this.finishNode(i,"SequenceExpression")},o.parseParenExpression=function(){this.pushCx(),this.expect(l.tokTypes.parenL);var t=this.parseExpression();return this.popCx(),this.expect(l.tokTypes.parenR),t},o.parseMaybeAssign=function(t){if(this.toks.isContextual("yield")){var e=this.startNode();return this.next(),this.semicolon()||this.canInsertSemicolon()||this.tok.type!==l.tokTypes.star&&!this.tok.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(l.tokTypes.star),e.argument=this.parseMaybeAssign()),this.finishNode(e,"YieldExpression")}var s=this.storeCurrentPos(),i=this.parseMaybeConditional(t);if(this.tok.type.isAssign){var r=this.startNodeAt(s);return r.operator=this.tok.value,r.left=this.tok.type===l.tokTypes.eq?this.toAssignable(i):this.checkLVal(i),this.next(),r.right=this.parseMaybeAssign(t),this.finishNode(r,"AssignmentExpression")}return i},o.parseMaybeConditional=function(t){var e=this.storeCurrentPos(),s=this.parseExprOps(t);if(this.eat(l.tokTypes.question)){var i=this.startNodeAt(e);return i.test=s,i.consequent=this.parseMaybeAssign(),i.alternate=this.expect(l.tokTypes.colon)?this.parseMaybeAssign(t):this.dummyIdent(),this.finishNode(i,"ConditionalExpression")}return s},o.parseExprOps=function(t){var e=this.storeCurrentPos(),s=this.curIndent,i=this.curLineStart;return this.parseExprOp(this.parseMaybeUnary(!1),e,-1,t,s,i)},o.parseExprOp=function(t,e,s,i,r,o){if(this.curLineStart!==o&&this.curIndent=i&&s(o,e))throw new u(e,n);a[o](e,n,t)}}(t,e)}catch(t){if(t instanceof u)return t;throw t}},t.findNodeAround=function(t,i,s,a,e){s=n(s),a=a||p;try{!function t(e,n,r){var o=r||e.type;if(!(e.start>i||e.end=s)&&c[o](e,n,t),(null==i||e.start===i)&&(null==s||e.end===s)&&a(o,e))throw new u(e,n)}(t,e)}catch(t){if(t instanceof u)return t;throw t}},t.findNodeBefore=function(t,i,s,a,e){var c;return s=n(s),a=a||p,function t(e,n,r){var o;e.start>i||(o=r||e.type,e.end<=i&&(!c||c.node.end 1) return; + // By default, don't allow completion when something is selected. + // A hint function can have a `supportsSelection` property to + // indicate that it can handle selections. + if (this.somethingSelected()) { + if (!options.hint.supportsSelection) return; + // Don't try with cross-line selections + for (var i = 0; i < selections.length; i++) + if (selections[i].head.line != selections[i].anchor.line) return; + } + + if (this.state.completionActive) this.state.completionActive.close(); + var completion = this.state.completionActive = new Completion(this, options); + if (!completion.options.hint) return; + + CodeMirror.signal(this, "startCompletion", this); + completion.update(true); + }); + + CodeMirror.defineExtension("closeHint", function() { + if (this.state.completionActive) this.state.completionActive.close() + }) + + function Completion(cm, options) { + this.cm = cm; + this.options = options; + this.widget = null; + this.debounce = 0; + this.tick = 0; + this.startPos = this.cm.getCursor("start"); + this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length; + + var self = this; + cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); }); + } + + var requestAnimationFrame = window.requestAnimationFrame || function(fn) { + return setTimeout(fn, 1000/60); + }; + var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout; + + Completion.prototype = { + close: function() { + if (!this.active()) return; + this.cm.state.completionActive = null; + this.tick = null; + this.cm.off("cursorActivity", this.activityFunc); + + if (this.widget && this.data) CodeMirror.signal(this.data, "close"); + if (this.widget) this.widget.close(); + CodeMirror.signal(this.cm, "endCompletion", this.cm); + }, + + active: function() { + return this.cm.state.completionActive == this; + }, + + pick: function(data, i) { + var completion = data.list[i]; + if (completion.hint) completion.hint(this.cm, data, completion); + else this.cm.replaceRange(getText(completion), completion.from || data.from, + completion.to || data.to, "complete"); + CodeMirror.signal(data, "pick", completion); + this.close(); + }, + + cursorActivity: function() { + if (this.debounce) { + cancelAnimationFrame(this.debounce); + this.debounce = 0; + } + + var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line); + if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || + pos.ch < this.startPos.ch || this.cm.somethingSelected() || + (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) { + this.close(); + } else { + var self = this; + this.debounce = requestAnimationFrame(function() {self.update();}); + if (this.widget) this.widget.disable(); + } + }, + + update: function(first) { + if (this.tick == null) return + var self = this, myTick = ++this.tick + fetchHints(this.options.hint, this.cm, this.options, function(data) { + if (self.tick == myTick) self.finishUpdate(data, first) + }) + }, + + finishUpdate: function(data, first) { + if (this.data) CodeMirror.signal(this.data, "update"); + + var picked = (this.widget && this.widget.picked); + if (this.widget) this.widget.close(); + + this.data = data; + + if (data && data.list.length) { + if (picked && data.list.length == 1) { + this.pick(data, 0); + } else { + this.widget = new Widget(this, data); + CodeMirror.signal(data, "shown"); + } + } + } + }; + + function parseOptions(cm, pos, options) { + var editor = cm.options.hintOptions; + var out = {}; + for (var prop in defaultOptions) out[prop] = defaultOptions[prop]; + if (editor) for (var prop in editor) + if (editor[prop] !== undefined) out[prop] = editor[prop]; + if (options) for (var prop in options) + if (options[prop] !== undefined) out[prop] = options[prop]; + if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos) + return out; + } + + function getText(completion) { + if (typeof completion == "string") return completion; + else return completion.text; + } + + function buildKeyMap(completion, handle) { + var baseMap = { + Up: function() {handle.moveFocus(-1);}, + Down: function() {handle.moveFocus(1);}, + PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);}, + PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);}, + Home: function() {handle.setFocus(0);}, + End: function() {handle.setFocus(handle.length - 1);}, + Enter: handle.pick, + Tab: handle.pick, + Esc: handle.close + }; + + var mac = /Mac/.test(navigator.platform); + + if (mac) { + baseMap["Ctrl-P"] = function() {handle.moveFocus(-1);}; + baseMap["Ctrl-N"] = function() {handle.moveFocus(1);}; + } + + var custom = completion.options.customKeys; + var ourMap = custom ? {} : baseMap; + function addBinding(key, val) { + var bound; + if (typeof val != "string") + bound = function(cm) { return val(cm, handle); }; + // This mechanism is deprecated + else if (baseMap.hasOwnProperty(val)) + bound = baseMap[val]; + else + bound = val; + ourMap[key] = bound; + } + if (custom) + for (var key in custom) if (custom.hasOwnProperty(key)) + addBinding(key, custom[key]); + var extra = completion.options.extraKeys; + if (extra) + for (var key in extra) if (extra.hasOwnProperty(key)) + addBinding(key, extra[key]); + return ourMap; + } + + function getHintElement(hintsElement, el) { + while (el && el != hintsElement) { + if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el; + el = el.parentNode; + } + } + + function Widget(completion, data) { + this.completion = completion; + this.data = data; + this.picked = false; + var widget = this, cm = completion.cm; + var ownerDocument = cm.getInputField().ownerDocument; + var parentWindow = ownerDocument.defaultView || ownerDocument.parentWindow; + + var hints = this.hints = ownerDocument.createElement("ul"); + var theme = completion.cm.options.theme; + hints.className = "CodeMirror-hints " + theme; + this.selectedHint = data.selectedHint || 0; + + var completions = data.list; + for (var i = 0; i < completions.length; ++i) { + var elt = hints.appendChild(ownerDocument.createElement("li")), cur = completions[i]; + var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS); + if (cur.className != null) className = cur.className + " " + className; + elt.className = className; + if (cur.render) cur.render(elt, data, cur); + else elt.appendChild(ownerDocument.createTextNode(cur.displayText || getText(cur))); + elt.hintId = i; + } + + var container = completion.options.container || ownerDocument.body; + var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null); + var left = pos.left, top = pos.bottom, below = true; + var offsetLeft = 0, offsetTop = 0; + if (container !== ownerDocument.body) { + // We offset the cursor position because left and top are relative to the offsetParent's top left corner. + var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1; + var offsetParent = isContainerPositioned ? container : container.offsetParent; + var offsetParentPosition = offsetParent.getBoundingClientRect(); + var bodyPosition = ownerDocument.body.getBoundingClientRect(); + offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft); + offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop); + } + hints.style.left = (left - offsetLeft) + "px"; + hints.style.top = (top - offsetTop) + "px"; + + // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor. + var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth); + var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight); + container.appendChild(hints); + var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; + var scrolls = hints.scrollHeight > hints.clientHeight + 1 + var startScroll = cm.getScrollInfo(); + + if (overlapY > 0) { + var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); + if (curTop - height > 0) { // Fits above cursor + hints.style.top = (top = pos.top - height - offsetTop) + "px"; + below = false; + } else if (height > winH) { + hints.style.height = (winH - 5) + "px"; + hints.style.top = (top = pos.bottom - box.top - offsetTop) + "px"; + var cursor = cm.getCursor(); + if (data.from.ch != cursor.ch) { + pos = cm.cursorCoords(cursor); + hints.style.left = (left = pos.left - offsetLeft) + "px"; + box = hints.getBoundingClientRect(); + } + } + } + var overlapX = box.right - winW; + if (overlapX > 0) { + if (box.right - box.left > winW) { + hints.style.width = (winW - 5) + "px"; + overlapX -= (box.right - box.left) - winW; + } + hints.style.left = (left = pos.left - overlapX - offsetLeft) + "px"; + } + if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling) + node.style.paddingRight = cm.display.nativeBarWidth + "px" + + cm.addKeyMap(this.keyMap = buildKeyMap(completion, { + moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); }, + setFocus: function(n) { widget.changeActive(n); }, + menuSize: function() { return widget.screenAmount(); }, + length: completions.length, + close: function() { completion.close(); }, + pick: function() { widget.pick(); }, + data: data + })); + + if (completion.options.closeOnUnfocus) { + var closingOnBlur; + cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); }); + cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); + } + + cm.on("scroll", this.onScroll = function() { + var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); + var newTop = top + startScroll.top - curScroll.top; + var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop); + if (!below) point += hints.offsetHeight; + if (point <= editor.top || point >= editor.bottom) return completion.close(); + hints.style.top = newTop + "px"; + hints.style.left = (left + startScroll.left - curScroll.left) + "px"; + }); + + CodeMirror.on(hints, "dblclick", function(e) { + var t = getHintElement(hints, e.target || e.srcElement); + if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();} + }); + + CodeMirror.on(hints, "click", function(e) { + var t = getHintElement(hints, e.target || e.srcElement); + if (t && t.hintId != null) { + widget.changeActive(t.hintId); + if (completion.options.completeOnSingleClick) widget.pick(); + } + }); + + CodeMirror.on(hints, "mousedown", function() { + setTimeout(function(){cm.focus();}, 20); + }); + + CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); + return true; + } + + Widget.prototype = { + close: function() { + if (this.completion.widget != this) return; + this.completion.widget = null; + this.hints.parentNode.removeChild(this.hints); + this.completion.cm.removeKeyMap(this.keyMap); + + var cm = this.completion.cm; + if (this.completion.options.closeOnUnfocus) { + cm.off("blur", this.onBlur); + cm.off("focus", this.onFocus); + } + cm.off("scroll", this.onScroll); + }, + + disable: function() { + this.completion.cm.removeKeyMap(this.keyMap); + var widget = this; + this.keyMap = {Enter: function() { widget.picked = true; }}; + this.completion.cm.addKeyMap(this.keyMap); + }, + + pick: function() { + this.completion.pick(this.data, this.selectedHint); + }, + + changeActive: function(i, avoidWrap) { + if (i >= this.data.list.length) + i = avoidWrap ? this.data.list.length - 1 : 0; + else if (i < 0) + i = avoidWrap ? 0 : this.data.list.length - 1; + if (this.selectedHint == i) return; + var node = this.hints.childNodes[this.selectedHint]; + if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, ""); + node = this.hints.childNodes[this.selectedHint = i]; + node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; + if (node.offsetTop < this.hints.scrollTop) + this.hints.scrollTop = node.offsetTop - 3; + else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) + this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3; + CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); + }, + + screenAmount: function() { + return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1; + } + }; + + function applicableHelpers(cm, helpers) { + if (!cm.somethingSelected()) return helpers + var result = [] + for (var i = 0; i < helpers.length; i++) + if (helpers[i].supportsSelection) result.push(helpers[i]) + return result + } + + function fetchHints(hint, cm, options, callback) { + if (hint.async) { + hint(cm, callback, options) + } else { + var result = hint(cm, options) + if (result && result.then) result.then(callback) + else callback(result) + } + } + + function resolveAutoHints(cm, pos) { + var helpers = cm.getHelpers(pos, "hint"), words + if (helpers.length) { + var resolved = function(cm, callback, options) { + var app = applicableHelpers(cm, helpers); + function run(i) { + if (i == app.length) return callback(null) + fetchHints(app[i], cm, options, function(result) { + if (result && result.list.length > 0) callback(result) + else run(i + 1) + }) + } + run(0) + } + resolved.async = true + resolved.supportsSelection = true + return resolved + } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) { + return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) } + } else if (CodeMirror.hint.anyword) { + return function(cm, options) { return CodeMirror.hint.anyword(cm, options) } + } else { + return function() {} + } + } + + CodeMirror.registerHelper("hint", "auto", { + resolve: resolveAutoHints + }); + + CodeMirror.registerHelper("hint", "fromList", function(cm, options) { + var cur = cm.getCursor(), token = cm.getTokenAt(cur) + var term, from = CodeMirror.Pos(cur.line, token.start), to = cur + if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) { + term = token.string.substr(0, cur.ch - token.start) + } else { + term = "" + from = cur + } + var found = []; + for (var i = 0; i < options.words.length; i++) { + var word = options.words[i]; + if (word.slice(0, term.length) == term) + found.push(word); + } + + if (found.length) return {list: found, from: from, to: to}; + }); + + CodeMirror.commands.autocomplete = CodeMirror.showHint; + + var defaultOptions = { + hint: CodeMirror.hint.auto, + completeSingle: true, + alignWithWord: true, + closeCharacters: /[\s()\[\]{};:>,]/, + closeOnUnfocus: true, + completeOnSingleClick: true, + container: null, + customKeys: null, + extraKeys: null + }; + + CodeMirror.defineOption("hintOptions", null); +}); + +// ========= dialog.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Open simple dialogs on top of an editor. Relies on dialog.css. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + function dialogDiv(cm, template, bottom) { + var wrap = cm.getWrapperElement(); + var dialog; + dialog = wrap.appendChild(document.createElement("div")); + if (bottom) + dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; + else + dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; + + if (typeof template == "string") { + dialog.innerHTML = template; + } else { // Assuming it's a detached DOM element. + dialog.appendChild(template); + } + CodeMirror.addClass(wrap, 'dialog-opened'); + return dialog; + } + + function closeNotification(cm, newVal) { + if (cm.state.currentNotificationClose) + cm.state.currentNotificationClose(); + cm.state.currentNotificationClose = newVal; + } + + CodeMirror.defineExtension("openDialog", function(template, callback, options) { + if (!options) options = {}; + + closeNotification(this, null); + + var dialog = dialogDiv(this, template, options.bottom); + var closed = false, me = this; + function close(newVal) { + if (typeof newVal == 'string') { + inp.value = newVal; + } else { + if (closed) return; + closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + me.focus(); + + if (options.onClose) options.onClose(dialog); + } + } + + var inp = dialog.getElementsByTagName("input")[0], button; + if (inp) { + inp.focus(); + + if (options.value) { + inp.value = options.value; + if (options.selectValueOnOpen !== false) { + inp.select(); + } + } + + if (options.onInput) + CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); + if (options.onKeyUp) + CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); + + CodeMirror.on(inp, "keydown", function(e) { + if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } + if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { + inp.blur(); + CodeMirror.e_stop(e); + close(); + } + if (e.keyCode == 13) callback(inp.value, e); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close); + } else if (button = dialog.getElementsByTagName("button")[0]) { + CodeMirror.on(button, "click", function() { + close(); + me.focus(); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); + + button.focus(); + } + return close; + }); + + CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) { + closeNotification(this, null); + var dialog = dialogDiv(this, template, options && options.bottom); + var buttons = dialog.getElementsByTagName("button"); + var closed = false, me = this, blurring = 1; + function close() { + if (closed) return; + closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + me.focus(); + } + buttons[0].focus(); + for (var i = 0; i < buttons.length; ++i) { + var b = buttons[i]; + (function(callback) { + CodeMirror.on(b, "click", function(e) { + CodeMirror.e_preventDefault(e); + close(); + if (callback) callback(me); + }); + })(callbacks[i]); + CodeMirror.on(b, "blur", function() { + --blurring; + setTimeout(function() { if (blurring <= 0) close(); }, 200); + }); + CodeMirror.on(b, "focus", function() { ++blurring; }); + } + }); + + /* + * openNotification + * Opens a notification, that can be closed with an optional timer + * (default 5000ms timer) and always closes on click. + * + * If a notification is opened while another is opened, it will close the + * currently opened one and open the new one immediately. + */ + CodeMirror.defineExtension("openNotification", function(template, options) { + closeNotification(this, close); + var dialog = dialogDiv(this, template, options && options.bottom); + var closed = false, doneTimer; + var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; + + function close() { + if (closed) return; + closed = true; + clearTimeout(doneTimer); + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); + dialog.parentNode.removeChild(dialog); + } + + CodeMirror.on(dialog, 'click', function(e) { + CodeMirror.e_preventDefault(e); + close(); + }); + + if (duration) + doneTimer = setTimeout(close, duration); + + return close; + }); +}); + +// ========= searchcursor.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")) + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod) + else // Plain browser env + mod(CodeMirror) +})(function(CodeMirror) { + "use strict" + var Pos = CodeMirror.Pos + + function regexpFlags(regexp) { + var flags = regexp.flags + return flags != null ? flags : (regexp.ignoreCase ? "i" : "") + + (regexp.global ? "g" : "") + + (regexp.multiline ? "m" : "") + } + + function ensureFlags(regexp, flags) { + var current = regexpFlags(regexp), target = current + for (var i = 0; i < flags.length; i++) if (target.indexOf(flags.charAt(i)) == -1) + target += flags.charAt(i) + return current == target ? regexp : new RegExp(regexp.source, target) + } + + function maybeMultiline(regexp) { + return /\\s|\\n|\n|\\W|\\D|\[\^/.test(regexp.source) + } + + function searchRegexpForward(doc, regexp, start) { + regexp = ensureFlags(regexp, "g") + for (var line = start.line, ch = start.ch, last = doc.lastLine(); line <= last; line++, ch = 0) { + regexp.lastIndex = ch + var string = doc.getLine(line), match = regexp.exec(string) + if (match) + return {from: Pos(line, match.index), + to: Pos(line, match.index + match[0].length), + match: match} + } + } + + function searchRegexpForwardMultiline(doc, regexp, start) { + if (!maybeMultiline(regexp)) return searchRegexpForward(doc, regexp, start) + + regexp = ensureFlags(regexp, "gm") + var string, chunk = 1 + for (var line = start.line, last = doc.lastLine(); line <= last;) { + // This grows the search buffer in exponentially-sized chunks + // between matches, so that nearby matches are fast and don't + // require concatenating the whole document (in case we're + // searching for something that has tons of matches), but at the + // same time, the amount of retries is limited. + for (var i = 0; i < chunk; i++) { + if (line > last) break + var curLine = doc.getLine(line++) + string = string == null ? curLine : string + "\n" + curLine + } + chunk = chunk * 2 + regexp.lastIndex = start.ch + var match = regexp.exec(string) + if (match) { + var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") + var startLine = start.line + before.length - 1, startCh = before[before.length - 1].length + return {from: Pos(startLine, startCh), + to: Pos(startLine + inside.length - 1, + inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), + match: match} + } + } + } + + function lastMatchIn(string, regexp) { + var cutOff = 0, match + for (;;) { + regexp.lastIndex = cutOff + var newMatch = regexp.exec(string) + if (!newMatch) return match + match = newMatch + cutOff = match.index + (match[0].length || 1) + if (cutOff == string.length) return match + } + } + + function searchRegexpBackward(doc, regexp, start) { + regexp = ensureFlags(regexp, "g") + for (var line = start.line, ch = start.ch, first = doc.firstLine(); line >= first; line--, ch = -1) { + var string = doc.getLine(line) + if (ch > -1) string = string.slice(0, ch) + var match = lastMatchIn(string, regexp) + if (match) + return {from: Pos(line, match.index), + to: Pos(line, match.index + match[0].length), + match: match} + } + } + + function searchRegexpBackwardMultiline(doc, regexp, start) { + regexp = ensureFlags(regexp, "gm") + var string, chunk = 1 + for (var line = start.line, first = doc.firstLine(); line >= first;) { + for (var i = 0; i < chunk; i++) { + var curLine = doc.getLine(line--) + string = string == null ? curLine.slice(0, start.ch) : curLine + "\n" + string + } + chunk *= 2 + + var match = lastMatchIn(string, regexp) + if (match) { + var before = string.slice(0, match.index).split("\n"), inside = match[0].split("\n") + var startLine = line + before.length, startCh = before[before.length - 1].length + return {from: Pos(startLine, startCh), + to: Pos(startLine + inside.length - 1, + inside.length == 1 ? startCh + inside[0].length : inside[inside.length - 1].length), + match: match} + } + } + } + + var doFold, noFold + if (String.prototype.normalize) { + doFold = function(str) { return str.normalize("NFD").toLowerCase() } + noFold = function(str) { return str.normalize("NFD") } + } else { + doFold = function(str) { return str.toLowerCase() } + noFold = function(str) { return str } + } + + // Maps a position in a case-folded line back to a position in the original line + // (compensating for codepoints increasing in number during folding) + function adjustPos(orig, folded, pos, foldFunc) { + if (orig.length == folded.length) return pos + for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) { + if (min == max) return min + var mid = (min + max) >> 1 + var len = foldFunc(orig.slice(0, mid)).length + if (len == pos) return mid + else if (len > pos) max = mid + else min = mid + 1 + } + } + + function searchStringForward(doc, query, start, caseFold) { + // Empty string would match anything and never progress, so we + // define it to match nothing instead. + if (!query.length) return null + var fold = caseFold ? doFold : noFold + var lines = fold(query).split(/\r|\n\r?/) + + search: for (var line = start.line, ch = start.ch, last = doc.lastLine() + 1 - lines.length; line <= last; line++, ch = 0) { + var orig = doc.getLine(line).slice(ch), string = fold(orig) + if (lines.length == 1) { + var found = string.indexOf(lines[0]) + if (found == -1) continue search + var start = adjustPos(orig, string, found, fold) + ch + return {from: Pos(line, adjustPos(orig, string, found, fold) + ch), + to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold) + ch)} + } else { + var cutFrom = string.length - lines[0].length + if (string.slice(cutFrom) != lines[0]) continue search + for (var i = 1; i < lines.length - 1; i++) + if (fold(doc.getLine(line + i)) != lines[i]) continue search + var end = doc.getLine(line + lines.length - 1), endString = fold(end), lastLine = lines[lines.length - 1] + if (endString.slice(0, lastLine.length) != lastLine) continue search + return {from: Pos(line, adjustPos(orig, string, cutFrom, fold) + ch), + to: Pos(line + lines.length - 1, adjustPos(end, endString, lastLine.length, fold))} + } + } + } + + function searchStringBackward(doc, query, start, caseFold) { + if (!query.length) return null + var fold = caseFold ? doFold : noFold + var lines = fold(query).split(/\r|\n\r?/) + + search: for (var line = start.line, ch = start.ch, first = doc.firstLine() - 1 + lines.length; line >= first; line--, ch = -1) { + var orig = doc.getLine(line) + if (ch > -1) orig = orig.slice(0, ch) + var string = fold(orig) + if (lines.length == 1) { + var found = string.lastIndexOf(lines[0]) + if (found == -1) continue search + return {from: Pos(line, adjustPos(orig, string, found, fold)), + to: Pos(line, adjustPos(orig, string, found + lines[0].length, fold))} + } else { + var lastLine = lines[lines.length - 1] + if (string.slice(0, lastLine.length) != lastLine) continue search + for (var i = 1, start = line - lines.length + 1; i < lines.length - 1; i++) + if (fold(doc.getLine(start + i)) != lines[i]) continue search + var top = doc.getLine(line + 1 - lines.length), topString = fold(top) + if (topString.slice(topString.length - lines[0].length) != lines[0]) continue search + return {from: Pos(line + 1 - lines.length, adjustPos(top, topString, top.length - lines[0].length, fold)), + to: Pos(line, adjustPos(orig, string, lastLine.length, fold))} + } + } + } + + function SearchCursor(doc, query, pos, options) { + this.atOccurrence = false + this.doc = doc + pos = pos ? doc.clipPos(pos) : Pos(0, 0) + this.pos = {from: pos, to: pos} + + var caseFold + if (typeof options == "object") { + caseFold = options.caseFold + } else { // Backwards compat for when caseFold was the 4th argument + caseFold = options + options = null + } + + if (typeof query == "string") { + if (caseFold == null) caseFold = false + this.matches = function(reverse, pos) { + return (reverse ? searchStringBackward : searchStringForward)(doc, query, pos, caseFold) + } + } else { + query = ensureFlags(query, "gm") + if (!options || options.multiline !== false) + this.matches = function(reverse, pos) { + return (reverse ? searchRegexpBackwardMultiline : searchRegexpForwardMultiline)(doc, query, pos) + } + else + this.matches = function(reverse, pos) { + return (reverse ? searchRegexpBackward : searchRegexpForward)(doc, query, pos) + } + } + } + + SearchCursor.prototype = { + findNext: function() {return this.find(false)}, + findPrevious: function() {return this.find(true)}, + + find: function(reverse) { + var result = this.matches(reverse, this.doc.clipPos(reverse ? this.pos.from : this.pos.to)) + + // Implements weird auto-growing behavior on null-matches for + // backwards-compatiblity with the vim code (unfortunately) + while (result && CodeMirror.cmpPos(result.from, result.to) == 0) { + if (reverse) { + if (result.from.ch) result.from = Pos(result.from.line, result.from.ch - 1) + else if (result.from.line == this.doc.firstLine()) result = null + else result = this.matches(reverse, this.doc.clipPos(Pos(result.from.line - 1))) + } else { + if (result.to.ch < this.doc.getLine(result.to.line).length) result.to = Pos(result.to.line, result.to.ch + 1) + else if (result.to.line == this.doc.lastLine()) result = null + else result = this.matches(reverse, Pos(result.to.line + 1, 0)) + } + } + + if (result) { + this.pos = result + this.atOccurrence = true + return this.pos.match || true + } else { + var end = Pos(reverse ? this.doc.firstLine() : this.doc.lastLine() + 1, 0) + this.pos = {from: end, to: end} + return this.atOccurrence = false + } + }, + + from: function() {if (this.atOccurrence) return this.pos.from}, + to: function() {if (this.atOccurrence) return this.pos.to}, + + replace: function(newText, origin) { + if (!this.atOccurrence) return + var lines = CodeMirror.splitLines(newText) + this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin) + this.pos.to = Pos(this.pos.from.line + lines.length - 1, + lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0)) + } + } + + CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) { + return new SearchCursor(this.doc, query, pos, caseFold) + }) + CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) { + return new SearchCursor(this, query, pos, caseFold) + }) + + CodeMirror.defineExtension("selectMatches", function(query, caseFold) { + var ranges = [] + var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold) + while (cur.findNext()) { + if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break + ranges.push({anchor: cur.from(), head: cur.to()}) + } + if (ranges.length) + this.setSelections(ranges, 0) + }) +}); + +// ========= search.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Define search commands. Depends on dialog.js or another +// implementation of the openDialog method. + +// Replace works a little oddly -- it will do the replace on the next +// Ctrl-G (or whatever is bound to findNext) press. You prevent a +// replace by making sure the match is no longer selected when hitting +// Ctrl-G. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + function searchOverlay(query, caseInsensitive) { + if (typeof query == "string") + query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g"); + else if (!query.global) + query = new RegExp(query.source, query.ignoreCase ? "gi" : "g"); + + return {token: function(stream) { + query.lastIndex = stream.pos; + var match = query.exec(stream.string); + if (match && match.index == stream.pos) { + stream.pos += match[0].length || 1; + return "searching"; + } else if (match) { + stream.pos = match.index; + } else { + stream.skipToEnd(); + } + }}; + } + + function SearchState() { + this.posFrom = this.posTo = this.lastQuery = this.query = null; + this.overlay = null; + } + + function getSearchState(cm) { + return cm.state.search || (cm.state.search = new SearchState()); + } + + function queryCaseInsensitive(query) { + return typeof query == "string" && query == query.toLowerCase(); + } + + function getSearchCursor(cm, query, pos) { + // Heuristic: if the query string is all lowercase, do a case insensitive search. + return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true}); + } + + function persistentDialog(cm, text, deflt, onEnter, onKeyDown) { + cm.openDialog(text, onEnter, { + value: deflt, + selectValueOnOpen: true, + closeOnEnter: false, + onClose: function() { clearSearch(cm); }, + onKeyDown: onKeyDown + }); + } + + function dialog(cm, text, shortText, deflt, f) { + if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true}); + else f(prompt(shortText, deflt)); + } + + function confirmDialog(cm, text, shortText, fs) { + if (cm.openConfirm) cm.openConfirm(text, fs); + else if (confirm(shortText)) fs[0](); + } + + function parseString(string) { + return string.replace(/\\(.)/g, function(_, ch) { + if (ch == "n") return "\n" + if (ch == "r") return "\r" + return ch + }) + } + + function parseQuery(query) { + var isRE = query.match(/^\/(.*)\/([a-z]*)$/); + if (isRE) { + try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); } + catch(e) {} // Not a regular expression after all, do a string search + } else { + query = parseString(query) + } + if (typeof query == "string" ? query == "" : query.test("")) + query = /x^/; + return query; + } + + function startSearch(cm, state, query) { + state.queryText = query; + state.query = parseQuery(query); + cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query)); + state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); + cm.addOverlay(state.overlay); + if (cm.showMatchesOnScrollbar) { + if (state.annotate) { state.annotate.clear(); state.annotate = null; } + state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query)); + } + } + + function doSearch(cm, rev, persistent, immediate) { + var state = getSearchState(cm); + if (state.query) return findNext(cm, rev); + var q = cm.getSelection() || state.lastQuery; + if (q instanceof RegExp && q.source == "x^") q = null + if (persistent && cm.openDialog) { + var hiding = null + var searchNext = function(query, event) { + CodeMirror.e_stop(event); + if (!query) return; + if (query != state.queryText) { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + } + if (hiding) hiding.style.opacity = 1 + findNext(cm, event.shiftKey, function(_, to) { + var dialog + if (to.line < 3 && document.querySelector && + (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) && + dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) + (hiding = dialog).style.opacity = .4 + }) + }; + persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) { + var keyName = CodeMirror.keyName(event) + var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName] + if (cmd == "findNext" || cmd == "findPrev" || + cmd == "findPersistentNext" || cmd == "findPersistentPrev") { + CodeMirror.e_stop(event); + startSearch(cm, getSearchState(cm), query); + cm.execCommand(cmd); + } else if (cmd == "find" || cmd == "findPersistent") { + CodeMirror.e_stop(event); + searchNext(query, event); + } + }); + if (immediate && q) { + startSearch(cm, state, q); + findNext(cm, rev); + } + } else { + dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) { + if (query && !state.query) cm.operation(function() { + startSearch(cm, state, query); + state.posFrom = state.posTo = cm.getCursor(); + findNext(cm, rev); + }); + }); + } + } + + function findNext(cm, rev, callback) {cm.operation(function() { + var state = getSearchState(cm); + var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo); + if (!cursor.find(rev)) { + cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0)); + if (!cursor.find(rev)) return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20); + state.posFrom = cursor.from(); state.posTo = cursor.to(); + if (callback) callback(cursor.from(), cursor.to()) + });} + + function clearSearch(cm) {cm.operation(function() { + var state = getSearchState(cm); + state.lastQuery = state.query; + if (!state.query) return; + state.query = state.queryText = null; + cm.removeOverlay(state.overlay); + if (state.annotate) { state.annotate.clear(); state.annotate = null; } + });} + + + function getQueryDialog(cm) { + return '' + cm.phrase("Search:") + ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; + } + function getReplaceQueryDialog(cm) { + return ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + ''; + } + function getReplacementQueryDialog(cm) { + return '' + cm.phrase("With:") + ' '; + } + function getDoReplaceConfirm(cm) { + return '' + cm.phrase("Replace?") + ' '; + } + + function replaceAll(cm, query, text) { + cm.operation(function() { + for (var cursor = getSearchCursor(cm, query); cursor.findNext();) { + if (typeof query != "string") { + var match = cm.getRange(cursor.from(), cursor.to()).match(query); + cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];})); + } else cursor.replace(text); + } + }); + } + + function replace(cm, all) { + if (cm.getOption("readOnly")) return; + var query = cm.getSelection() || getSearchState(cm).lastQuery; + var dialogText = '' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + ''; + dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) { + if (!query) return; + query = parseQuery(query); + dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) { + text = parseString(text) + if (all) { + replaceAll(cm, query, text) + } else { + clearSearch(cm); + var cursor = getSearchCursor(cm, query, cm.getCursor("from")); + var advance = function() { + var start = cursor.from(), match; + if (!(match = cursor.findNext())) { + cursor = getSearchCursor(cm, query); + if (!(match = cursor.findNext()) || + (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return; + } + cm.setSelection(cursor.from(), cursor.to()); + cm.scrollIntoView({from: cursor.from(), to: cursor.to()}); + confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"), + [function() {doReplace(match);}, advance, + function() {replaceAll(cm, query, text)}]); + }; + var doReplace = function(match) { + cursor.replace(typeof query == "string" ? text : + text.replace(/\$(\d)/g, function(_, i) {return match[i];})); + advance(); + }; + advance(); + } + }); + }); + } + + CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; + CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; + CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);}; + CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);}; + CodeMirror.commands.findNext = doSearch; + CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; + CodeMirror.commands.clearSearch = clearSearch; + CodeMirror.commands.replace = replace; + CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);}; +}); + +// ========= matchbrackets.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && + (document.documentMode == null || document.documentMode < 8); + + var Pos = CodeMirror.Pos; + + var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<", "<": ">>", ">": "<<"}; + + function bracketRegex(config) { + return config && config.bracketRegex || /[(){}[\]]/ + } + + function findMatchingBracket(cm, where, config) { + var line = cm.getLineHandle(where.line), pos = where.ch - 1; + var afterCursor = config && config.afterCursor + if (afterCursor == null) + afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className) + var re = bracketRegex(config) + + // A cursor is defined as between two characters, but in in vim command mode + // (i.e. not insert mode), the cursor is visually represented as a + // highlighted box on top of the 2nd character. Otherwise, we allow matches + // from before or after the cursor. + var match = (!afterCursor && pos >= 0 && re.test(line.text.charAt(pos)) && matching[line.text.charAt(pos)]) || + re.test(line.text.charAt(pos + 1)) && matching[line.text.charAt(++pos)]; + if (!match) return null; + var dir = match.charAt(1) == ">" ? 1 : -1; + if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; + var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); + + var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); + if (found == null) return null; + return {from: Pos(where.line, pos), to: found && found.pos, + match: found && found.ch == match.charAt(0), forward: dir > 0}; + } + + // bracketRegex is used to specify which type of bracket to scan + // should be a regexp, e.g. /[[\]]/ + // + // Note: If "where" is on an open bracket, then this bracket is ignored. + // + // Returns false when no bracket was found, null when it reached + // maxScanLines and gave up + function scanForBracket(cm, where, dir, style, config) { + var maxScanLen = (config && config.maxScanLineLength) || 10000; + var maxScanLines = (config && config.maxScanLines) || 1000; + + var stack = []; + var re = bracketRegex(config) + var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) + : Math.max(cm.firstLine() - 1, where.line - maxScanLines); + for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { + var line = cm.getLine(lineNo); + if (!line) continue; + var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; + if (line.length > maxScanLen) continue; + if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); + for (; pos != end; pos += dir) { + var ch = line.charAt(pos); + if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { + var match = matching[ch]; + if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); + else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; + else stack.pop(); + } + } + } + return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; + } + + function matchBrackets(cm, autoclear, config) { + // Disable brace matching in long lines, since it'll cause hugely slow updates + var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; + var marks = [], ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); + if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { + var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; + marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); + if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) + marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); + } + } + + if (marks.length) { + // Kludge to work around the IE bug from issue #1193, where text + // input stops going to the textare whever this fires. + if (ie_lt8 && cm.state.focused) cm.focus(); + + var clear = function() { + cm.operation(function() { + for (var i = 0; i < marks.length; i++) marks[i].clear(); + }); + }; + if (autoclear) setTimeout(clear, 800); + else return clear; + } + } + + function doMatchBrackets(cm) { + cm.operation(function() { + if (cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; + } + cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); + }); + } + + CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.off("cursorActivity", doMatchBrackets); + if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { + cm.state.matchBrackets.currentlyHighlighted(); + cm.state.matchBrackets.currentlyHighlighted = null; + } + } + if (val) { + cm.state.matchBrackets = typeof val == "object" ? val : {}; + cm.on("cursorActivity", doMatchBrackets); + } + }); + + CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); + CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){ + // Backwards-compatibility kludge + if (oldConfig || typeof config == "boolean") { + if (!oldConfig) { + config = config ? {strict: true} : null + } else { + oldConfig.strict = config + config = oldConfig + } + } + return findMatchingBracket(this, pos, config) + }); + CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ + return scanForBracket(this, pos, dir, style, config); + }); +}); + +// ========= close-bracket.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + var defaults = { + pairs: "()[]{}''\"\"", + closeBefore: ")]}'\":;>", + triples: "", + explode: "[]{}" + }; + + var Pos = CodeMirror.Pos; + + CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.removeKeyMap(keyMap); + cm.state.closeBrackets = null; + } + if (val) { + ensureBound(getOption(val, "pairs")) + cm.state.closeBrackets = val; + cm.addKeyMap(keyMap); + } + }); + + function getOption(conf, name) { + if (name == "pairs" && typeof conf == "string") return conf; + if (typeof conf == "object" && conf[name] != null) return conf[name]; + return defaults[name]; + } + + var keyMap = {Backspace: handleBackspace, Enter: handleEnter}; + function ensureBound(chars) { + for (var i = 0; i < chars.length; i++) { + var ch = chars.charAt(i), key = "'" + ch + "'" + if (!keyMap[key]) keyMap[key] = handler(ch) + } + } + ensureBound(defaults.pairs + "`") + + function handler(ch) { + return function(cm) { return handleChar(cm, ch); }; + } + + function getConfig(cm) { + var deflt = cm.state.closeBrackets; + if (!deflt || deflt.override) return deflt; + var mode = cm.getModeAt(cm.getCursor()); + return mode.closeBrackets || deflt; + } + + function handleBackspace(cm) { + var conf = getConfig(cm); + if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; + + var pairs = getOption(conf, "pairs"); + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) return CodeMirror.Pass; + var around = charsAround(cm, ranges[i].head); + if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass; + } + for (var i = ranges.length - 1; i >= 0; i--) { + var cur = ranges[i].head; + cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete"); + } + } + + function handleEnter(cm) { + var conf = getConfig(cm); + var explode = conf && getOption(conf, "explode"); + if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass; + + var ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + if (!ranges[i].empty()) return CodeMirror.Pass; + var around = charsAround(cm, ranges[i].head); + if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass; + } + cm.operation(function() { + var linesep = cm.lineSeparator() || "\n"; + cm.replaceSelection(linesep + linesep, null); + cm.execCommand("goCharLeft"); + ranges = cm.listSelections(); + for (var i = 0; i < ranges.length; i++) { + var line = ranges[i].head.line; + cm.indentLine(line, null, true); + cm.indentLine(line + 1, null, true); + } + }); + } + + function contractSelection(sel) { + var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0; + return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)), + head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))}; + } + + function handleChar(cm, ch) { + var conf = getConfig(cm); + if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass; + + var pairs = getOption(conf, "pairs"); + var pos = pairs.indexOf(ch); + if (pos == -1) return CodeMirror.Pass; + + var closeBefore = getOption(conf,"closeBefore"); + + var triples = getOption(conf, "triples"); + + var identical = pairs.charAt(pos + 1) == ch; + var ranges = cm.listSelections(); + var opening = pos % 2 == 0; + + var type; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i], cur = range.head, curType; + var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1)); + if (opening && !range.empty()) { + curType = "surround"; + } else if ((identical || !opening) && next == ch) { + if (identical && stringStartsAfter(cm, cur)) + curType = "both"; + else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch) + curType = "skipThree"; + else + curType = "skip"; + } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 && + cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) { + if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass; + curType = "addFour"; + } else if (identical) { + var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur) + if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both"; + else return CodeMirror.Pass; + } else if (opening && (next.length === 0 || /\s/.test(next) || closeBefore.indexOf(next) > -1)) { + curType = "both"; + } else { + return CodeMirror.Pass; + } + if (!type) type = curType; + else if (type != curType) return CodeMirror.Pass; + } + + var left = pos % 2 ? pairs.charAt(pos - 1) : ch; + var right = pos % 2 ? ch : pairs.charAt(pos + 1); + cm.operation(function() { + if (type == "skip") { + cm.execCommand("goCharRight"); + } else if (type == "skipThree") { + for (var i = 0; i < 3; i++) + cm.execCommand("goCharRight"); + } else if (type == "surround") { + var sels = cm.getSelections(); + for (var i = 0; i < sels.length; i++) + sels[i] = left + sels[i] + right; + cm.replaceSelections(sels, "around"); + sels = cm.listSelections().slice(); + for (var i = 0; i < sels.length; i++) + sels[i] = contractSelection(sels[i]); + cm.setSelections(sels); + } else if (type == "both") { + cm.replaceSelection(left + right, null); + cm.triggerElectric(left + right); + cm.execCommand("goCharLeft"); + } else if (type == "addFour") { + cm.replaceSelection(left + left + left + left, "before"); + cm.execCommand("goCharRight"); + } + }); + } + + function charsAround(cm, pos) { + var str = cm.getRange(Pos(pos.line, pos.ch - 1), + Pos(pos.line, pos.ch + 1)); + return str.length == 2 ? str : null; + } + + function stringStartsAfter(cm, pos) { + var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1)) + return /\bstring/.test(token.type) && token.start == pos.ch && + (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos))) + } +}); + +// ========= active-line.js ========= // +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + var WRAP_CLASS = "CodeMirror-activeline"; + var BACK_CLASS = "CodeMirror-activeline-background"; + var GUTT_CLASS = "CodeMirror-activeline-gutter"; + + CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) { + var prev = old == CodeMirror.Init ? false : old; + if (val == prev) return + if (prev) { + cm.off("beforeSelectionChange", selectionChange); + clearActiveLines(cm); + delete cm.state.activeLines; + } + if (val) { + cm.state.activeLines = []; + updateActiveLines(cm, cm.listSelections()); + cm.on("beforeSelectionChange", selectionChange); + } + }); + + function clearActiveLines(cm) { + for (var i = 0; i < cm.state.activeLines.length; i++) { + cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS); + cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS); + cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS); + } + } + + function sameArray(a, b) { + if (a.length != b.length) return false; + for (var i = 0; i < a.length; i++) + if (a[i] != b[i]) return false; + return true; + } + + function updateActiveLines(cm, ranges) { + var active = []; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + var option = cm.getOption("styleActiveLine"); + if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty()) + continue + var line = cm.getLineHandleVisualStart(range.head.line); + if (active[active.length - 1] != line) active.push(line); + } + if (sameArray(cm.state.activeLines, active)) return; + cm.operation(function() { + clearActiveLines(cm); + for (var i = 0; i < active.length; i++) { + cm.addLineClass(active[i], "wrap", WRAP_CLASS); + cm.addLineClass(active[i], "background", BACK_CLASS); + cm.addLineClass(active[i], "gutter", GUTT_CLASS); + } + cm.state.activeLines = active; + }); + } + + function selectionChange(cm, sel) { + updateActiveLines(cm, sel.ranges); + } +}); + +// ========= tern.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +// Glue code between CodeMirror and Tern. +// +// Create a CodeMirror.TernServer to wrap an actual Tern server, +// register open documents (CodeMirror.Doc instances) with it, and +// call its methods to activate the assisting functions that Tern +// provides. +// +// Options supported (all optional): +// * defs: An array of JSON definition data structures. +// * plugins: An object mapping plugin names to configuration +// options. +// * getFile: A function(name, c) that can be used to access files in +// the project that haven't been loaded yet. Simply do c(null) to +// indicate that a file is not available. +// * fileFilter: A function(value, docName, doc) that will be applied +// to documents before passing them on to Tern. +// * switchToDoc: A function(name, doc) that should, when providing a +// multi-file view, switch the view or focus to the named file. +// * showError: A function(editor, message) that can be used to +// override the way errors are displayed. +// * completionTip: Customize the content in tooltips for completions. +// Is passed a single argument—the completion's data as returned by +// Tern—and may return a string, DOM node, or null to indicate that +// no tip should be shown. By default the docstring is shown. +// * typeTip: Like completionTip, but for the tooltips shown for type +// queries. +// * responseFilter: A function(doc, query, request, error, data) that +// will be applied to the Tern responses before treating them +// +// +// It is possible to run the Tern server in a web worker by specifying +// these additional options: +// * useWorker: Set to true to enable web worker mode. You'll probably +// want to feature detect the actual value you use here, for example +// !!window.Worker. +// * workerScript: The main script of the worker. Point this to +// wherever you are hosting worker.js from this directory. +// * workerDeps: An array of paths pointing (relative to workerScript) +// to the Acorn and Tern libraries and any Tern plugins you want to +// load. Or, if you minified those into a single script and included +// them in the workerScript, simply leave this undefined. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + // declare global: tern + + CodeMirror.TernServer = function(options) { + var self = this; + this.options = options || {}; + var plugins = this.options.plugins || (this.options.plugins = {}); + if (!plugins.doc_comment) plugins.doc_comment = true; + this.docs = Object.create(null); + if (this.options.useWorker) { + this.server = new WorkerServer(this); + } else { + this.server = new tern.Server({ + getFile: function(name, c) { return getFile(self, name, c); }, + async: true, + defs: this.options.defs || [], + plugins: plugins + }); + } + this.trackChange = function(doc, change) { trackChange(self, doc, change); }; + + this.cachedArgHints = null; + this.activeArgHints = null; + this.jumpStack = []; + + this.getHint = function(cm, c) { return hint(self, cm, c); }; + this.getHint.async = true; + }; + + CodeMirror.TernServer.prototype = { + addDoc: function(name, doc) { + var data = {doc: doc, name: name, changed: null}; + this.server.addFile(name, docValue(this, data)); + CodeMirror.on(doc, "change", this.trackChange); + return this.docs[name] = data; + }, + + delDoc: function(id) { + var found = resolveDoc(this, id); + if (!found) return; + CodeMirror.off(found.doc, "change", this.trackChange); + delete this.docs[found.name]; + this.server.delFile(found.name); + }, + + hideDoc: function(id) { + closeArgHints(this); + var found = resolveDoc(this, id); + if (found && found.changed) sendDoc(this, found); + }, + + complete: function(cm) { + cm.showHint({hint: this.getHint}); + }, + + showType: function(cm, pos, c) { showContextInfo(this, cm, pos, "type", c); }, + + showDocs: function(cm, pos, c) { showContextInfo(this, cm, pos, "documentation", c); }, + + updateArgHints: function(cm) { updateArgHints(this, cm); }, + + jumpToDef: function(cm) { jumpToDef(this, cm); }, + + jumpBack: function(cm) { jumpBack(this, cm); }, + + rename: function(cm) { rename(this, cm); }, + + selectName: function(cm) { selectName(this, cm); }, + + request: function (cm, query, c, pos) { + var self = this; + var doc = findDoc(this, cm.getDoc()); + var request = buildRequest(this, doc, query, pos); + var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type] + if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop]; + + this.server.request(request, function (error, data) { + if (!error && self.options.responseFilter) + data = self.options.responseFilter(doc, query, request, error, data); + c(error, data); + }); + }, + + destroy: function () { + closeArgHints(this) + if (this.worker) { + this.worker.terminate(); + this.worker = null; + } + } + }; + + var Pos = CodeMirror.Pos; + var cls = "CodeMirror-Tern-"; + var bigDoc = 250; + + function getFile(ts, name, c) { + var buf = ts.docs[name]; + if (buf) + c(docValue(ts, buf)); + else if (ts.options.getFile) + ts.options.getFile(name, c); + else + c(null); + } + + function findDoc(ts, doc, name) { + for (var n in ts.docs) { + var cur = ts.docs[n]; + if (cur.doc == doc) return cur; + } + if (!name) for (var i = 0;; ++i) { + n = "[doc" + (i || "") + "]"; + if (!ts.docs[n]) { name = n; break; } + } + return ts.addDoc(name, doc); + } + + function resolveDoc(ts, id) { + if (typeof id == "string") return ts.docs[id]; + if (id instanceof CodeMirror) id = id.getDoc(); + if (id instanceof CodeMirror.Doc) return findDoc(ts, id); + } + + function trackChange(ts, doc, change) { + var data = findDoc(ts, doc); + + var argHints = ts.cachedArgHints; + if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0) + ts.cachedArgHints = null; + + var changed = data.changed; + if (changed == null) + data.changed = changed = {from: change.from.line, to: change.from.line}; + var end = change.from.line + (change.text.length - 1); + if (change.from.line < changed.to) changed.to = changed.to - (change.to.line - end); + if (end >= changed.to) changed.to = end + 1; + if (changed.from > change.from.line) changed.from = change.from.line; + + if (doc.lineCount() > bigDoc && change.to - changed.from > 100) setTimeout(function() { + if (data.changed && data.changed.to - data.changed.from > 100) sendDoc(ts, data); + }, 200); + } + + function sendDoc(ts, doc) { + ts.server.request({files: [{type: "full", name: doc.name, text: docValue(ts, doc)}]}, function(error) { + if (error) window.console.error(error); + else doc.changed = null; + }); + } + + // Completion + + function hint(ts, cm, c) { + ts.request(cm, {type: "completions", types: true, docs: true, urls: true}, function(error, data) { + if (error) return showError(ts, cm, error); + var completions = [], after = ""; + var from = data.start, to = data.end; + if (cm.getRange(Pos(from.line, from.ch - 2), from) == "[\"" && + cm.getRange(to, Pos(to.line, to.ch + 2)) != "\"]") + after = "\"]"; + + for (var i = 0; i < data.completions.length; ++i) { + var completion = data.completions[i], className = typeToIcon(completion.type); + if (data.guess) className += " " + cls + "guess"; + completions.push({text: completion.name + after, + displayText: completion.displayName || completion.name, + className: className, + data: completion}); + } + + var obj = {from: from, to: to, list: completions}; + var tooltip = null; + CodeMirror.on(obj, "close", function() { remove(tooltip); }); + CodeMirror.on(obj, "update", function() { remove(tooltip); }); + CodeMirror.on(obj, "select", function(cur, node) { + remove(tooltip); + var content = ts.options.completionTip ? ts.options.completionTip(cur.data) : cur.data.doc; + if (content) { + tooltip = makeTooltip(node.parentNode.getBoundingClientRect().right + window.pageXOffset, + node.getBoundingClientRect().top + window.pageYOffset, content); + tooltip.className += " " + cls + "hint-doc"; + } + }); + c(obj); + }); + } + + function typeToIcon(type) { + var suffix; + if (type == "?") suffix = "unknown"; + else if (type == "number" || type == "string" || type == "bool") suffix = type; + else if (/^fn\(/.test(type)) suffix = "fn"; + else if (/^\[/.test(type)) suffix = "array"; + else suffix = "object"; + return cls + "completion " + cls + "completion-" + suffix; + } + + // Type queries + + function showContextInfo(ts, cm, pos, queryName, c) { + ts.request(cm, queryName, function(error, data) { + data = data || {}; + data.type = data.type || ''; + data.doc = data.doc || ''; + if (!error && (data.type.startsWith('fn(') || data.doc)) { + var tip = elt("span", null, elt("strong", null, data.type || "not found")); + if (data.doc) + tip.appendChild(document.createTextNode("\n" + data.doc.replace(//g,"\n"))); + if (data.url) { + tip.appendChild(document.createTextNode("\n")); + var child = tip.appendChild(elt("a", null, "[文档]")); + child.href = data.url; + child.target = "_blank"; + } + tempTooltip(cm, tip, ts); + } + if (c) c(); + }, pos); + } + + // Maintaining argument hints + + function updateArgHints(ts, cm) { + closeArgHints(ts); + + if (cm.somethingSelected()) return; + var state = cm.getTokenAt(cm.getCursor()).state; + var inner = CodeMirror.innerMode(cm.getMode(), state); + if (inner.mode.name != "javascript") return; + var lex = inner.state.lexical; + if (lex.info != "call") return; + + var ch, argPos = lex.pos || 0, tabSize = cm.getOption("tabSize"); + for (var line = cm.getCursor().line, e = Math.max(0, line - 9), found = false; line >= e; --line) { + var str = cm.getLine(line), extra = 0; + for (var pos = 0;;) { + var tab = str.indexOf("\t", pos); + if (tab == -1) break; + extra += tabSize - (tab + extra) % tabSize - 1; + pos = tab + 1; + } + ch = lex.column - extra; + if (str.charAt(ch) == "(") {found = true; break;} + } + if (!found) return; + + var start = Pos(line, ch); + var cache = ts.cachedArgHints; + if (cache && cache.doc == cm.getDoc() && cmpPos(start, cache.start) == 0) + return showArgHints(ts, cm, argPos); + + ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) { + if (error || !data.type || !(/^fn\(/).test(data.type)) return; + ts.cachedArgHints = { + start: start, + type: parseFnType(data.type), + name: data.exprName || data.name || "fn", + guess: data.guess, + doc: cm.getDoc() + }; + showArgHints(ts, cm, argPos); + }); + } + + function showArgHints(ts, cm, pos) { + closeArgHints(ts); + + var cache = ts.cachedArgHints, tp = cache.type; + var tip = elt("span", cache.guess ? cls + "fhint-guess" : null, + elt("span", cls + "fname", cache.name), "("); + for (var i = 0; i < tp.args.length; ++i) { + if (i) tip.appendChild(document.createTextNode(", ")); + var arg = tp.args[i]; + tip.appendChild(elt("span", cls + "farg" + (i == pos ? " " + cls + "farg-current" : ""), arg.name || "?")); + if (arg.type != "?") { + tip.appendChild(document.createTextNode(":\u00a0")); + tip.appendChild(elt("span", cls + "type", arg.type)); + } + } + tip.appendChild(document.createTextNode(tp.rettype ? ") ->\u00a0" : ")")); + if (tp.rettype) tip.appendChild(elt("span", cls + "type", tp.rettype)); + var place = cm.cursorCoords(null, "page"); + var tooltip = ts.activeArgHints = makeTooltip(place.right + 1, place.bottom, tip) + setTimeout(function() { + tooltip.clear = onEditorActivity(cm, function() { + if (ts.activeArgHints == tooltip) closeArgHints(ts) }) + }, 20) + } + + function parseFnType(text) { + var args = [], pos = 3; + + function skipMatching(upto) { + var depth = 0, start = pos; + for (;;) { + var next = text.charAt(pos); + if (upto.test(next) && !depth) return text.slice(start, pos); + if (/[{\[\(]/.test(next)) ++depth; + else if (/[}\]\)]/.test(next)) --depth; + ++pos; + } + } + + // Parse arguments + if (text.charAt(pos) != ")") for (;;) { + var name = text.slice(pos).match(/^([^, \(\[\{]+): /); + if (name) { + pos += name[0].length; + name = name[1]; + } + args.push({name: name, type: skipMatching(/[\),]/)}); + if (text.charAt(pos) == ")") break; + pos += 2; + } + + var rettype = text.slice(pos).match(/^\) -> (.*)$/); + + return {args: args, rettype: rettype && rettype[1]}; + } + + // Moving to the definition of something + + function jumpToDef(ts, cm) { + function inner(varName) { + var req = {type: "definition", variable: varName || null}; + var doc = findDoc(ts, cm.getDoc()); + ts.server.request(buildRequest(ts, doc, req), function(error, data) { + if (error) return showError(ts, cm, error); + if (!data.file && data.url) { window.open(data.url); return; } + + if (data.file) { + var localDoc = ts.docs[data.file], found; + if (localDoc && (found = findContext(localDoc.doc, data))) { + ts.jumpStack.push({file: doc.name, + start: cm.getCursor("from"), + end: cm.getCursor("to")}); + moveTo(ts, doc, localDoc, found.start, found.end); + return; + } + } + showError(ts, cm, "Could not find a definition."); + }); + } + + if (!atInterestingExpression(cm)) + dialog(cm, "Jump to variable", function(name) { if (name) inner(name); }); + else + inner(); + } + + function jumpBack(ts, cm) { + var pos = ts.jumpStack.pop(), doc = pos && ts.docs[pos.file]; + if (!doc) return; + moveTo(ts, findDoc(ts, cm.getDoc()), doc, pos.start, pos.end); + } + + function moveTo(ts, curDoc, doc, start, end) { + doc.doc.setSelection(start, end); + if (curDoc != doc && ts.options.switchToDoc) { + closeArgHints(ts); + ts.options.switchToDoc(doc.name, doc.doc); + } + } + + // The {line,ch} representation of positions makes this rather awkward. + function findContext(doc, data) { + var before = data.context.slice(0, data.contextOffset).split("\n"); + var startLine = data.start.line - (before.length - 1); + var start = Pos(startLine, (before.length == 1 ? data.start.ch : doc.getLine(startLine).length) - before[0].length); + + var text = doc.getLine(startLine).slice(start.ch); + for (var cur = startLine + 1; cur < doc.lineCount() && text.length < data.context.length; ++cur) + text += "\n" + doc.getLine(cur); + if (text.slice(0, data.context.length) == data.context) return data; + + var cursor = doc.getSearchCursor(data.context, 0, false); + var nearest, nearestDist = Infinity; + while (cursor.findNext()) { + var from = cursor.from(), dist = Math.abs(from.line - start.line) * 10000; + if (!dist) dist = Math.abs(from.ch - start.ch); + if (dist < nearestDist) { nearest = from; nearestDist = dist; } + } + if (!nearest) return null; + + if (before.length == 1) + nearest.ch += before[0].length; + else + nearest = Pos(nearest.line + (before.length - 1), before[before.length - 1].length); + if (data.start.line == data.end.line) + var end = Pos(nearest.line, nearest.ch + (data.end.ch - data.start.ch)); + else + var end = Pos(nearest.line + (data.end.line - data.start.line), data.end.ch); + return {start: nearest, end: end}; + } + + function atInterestingExpression(cm) { + var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos); + if (tok.start < pos.ch && tok.type == "comment") return false; + return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1)); + } + + // Variable renaming + + function rename(ts, cm) { + var token = cm.getTokenAt(cm.getCursor()); + if (!/\w/.test(token.string)) return showError(ts, cm, "Not at a variable"); + dialog(cm, "New name for " + token.string, function(newName) { + ts.request(cm, {type: "rename", newName: newName, fullDocs: true}, function(error, data) { + if (error) return showError(ts, cm, error); + applyChanges(ts, data.changes); + }); + }); + } + + function selectName(ts, cm) { + var name = findDoc(ts, cm.doc).name; + ts.request(cm, {type: "refs"}, function(error, data) { + if (error) return showError(ts, cm, error); + var ranges = [], cur = 0; + var curPos = cm.getCursor(); + for (var i = 0; i < data.refs.length; i++) { + var ref = data.refs[i]; + if (ref.file == name) { + ranges.push({anchor: ref.start, head: ref.end}); + if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0) + cur = ranges.length - 1; + } + } + cm.setSelections(ranges, cur); + }); + } + + var nextChangeOrig = 0; + function applyChanges(ts, changes) { + var perFile = Object.create(null); + for (var i = 0; i < changes.length; ++i) { + var ch = changes[i]; + (perFile[ch.file] || (perFile[ch.file] = [])).push(ch); + } + for (var file in perFile) { + var known = ts.docs[file], chs = perFile[file];; + if (!known) continue; + chs.sort(function(a, b) { return cmpPos(b.start, a.start); }); + var origin = "*rename" + (++nextChangeOrig); + for (var i = 0; i < chs.length; ++i) { + var ch = chs[i]; + known.doc.replaceRange(ch.text, ch.start, ch.end, origin); + } + } + } + + // Generic request-building helper + + function buildRequest(ts, doc, query, pos) { + var files = [], offsetLines = 0, allowFragments = !query.fullDocs; + if (!allowFragments) delete query.fullDocs; + if (typeof query == "string") query = {type: query}; + query.lineCharPositions = true; + if (query.end == null) { + query.end = pos || doc.doc.getCursor("end"); + if (doc.doc.somethingSelected()) + query.start = doc.doc.getCursor("start"); + } + var startPos = query.start || query.end; + + if (doc.changed) { + if (doc.doc.lineCount() > bigDoc && allowFragments !== false && + doc.changed.to - doc.changed.from < 100 && + doc.changed.from <= startPos.line && doc.changed.to > query.end.line) { + files.push(getFragmentAround(doc, startPos, query.end)); + query.file = "#0"; + var offsetLines = files[0].offsetLines; + if (query.start != null) query.start = Pos(query.start.line - -offsetLines, query.start.ch); + query.end = Pos(query.end.line - offsetLines, query.end.ch); + } else { + files.push({type: "full", + name: doc.name, + text: docValue(ts, doc)}); + query.file = doc.name; + doc.changed = null; + } + } else { + query.file = doc.name; + } + for (var name in ts.docs) { + var cur = ts.docs[name]; + if (cur.changed && cur != doc) { + files.push({type: "full", name: cur.name, text: docValue(ts, cur)}); + cur.changed = null; + } + } + + return {query: query, files: files}; + } + + function getFragmentAround(data, start, end) { + var doc = data.doc; + var minIndent = null, minLine = null, endLine, tabSize = 4; + for (var p = start.line - 1, min = Math.max(0, p - 50); p >= min; --p) { + var line = doc.getLine(p), fn = line.search(/\bfunction\b/); + if (fn < 0) continue; + var indent = CodeMirror.countColumn(line, null, tabSize); + if (minIndent != null && minIndent <= indent) continue; + minIndent = indent; + minLine = p; + } + if (minLine == null) minLine = min; + var max = Math.min(doc.lastLine(), end.line + 20); + if (minIndent == null || minIndent == CodeMirror.countColumn(doc.getLine(start.line), null, tabSize)) + endLine = max; + else for (endLine = end.line + 1; endLine < max; ++endLine) { + var indent = CodeMirror.countColumn(doc.getLine(endLine), null, tabSize); + if (indent <= minIndent) break; + } + var from = Pos(minLine, 0); + + return {type: "part", + name: data.name, + offsetLines: from.line, + text: doc.getRange(from, Pos(endLine, end.line == endLine ? null : 0))}; + } + + // Generic utilities + + var cmpPos = CodeMirror.cmpPos; + + function elt(tagname, cls /*, ... elts*/) { + var e = document.createElement(tagname); + if (cls) e.className = cls; + for (var i = 2; i < arguments.length; ++i) { + var elt = arguments[i]; + if (typeof elt == "string") elt = document.createTextNode(elt); + e.appendChild(elt); + } + return e; + } + + function dialog(cm, text, f) { + if (cm.openDialog) + cm.openDialog(text + ": ", f); + else + f(prompt(text, "")); + } + + // Tooltips + function tempTooltip(cm, content, ts) { + if (cm.state.ternTooltip) remove(cm.state.ternTooltip); + var where = cm.cursorCoords(); + var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content); + function clear() { + if (mouseOnTip) { + mouseOnTip = false; + setTimeout(clear, 50); + return; + } + cm.state.ternTooltip = null; + if (tip.parentNode) remove(tip) + clearActivity() + } + var mouseOnTip = false; + CodeMirror.on(tip, "mousemove", function() { mouseOnTip = true; }); + CodeMirror.on(tip, "mouseout", function(e) { mouseOnTip = false; }); + var clearActivity = onEditorActivity(cm, clear) + } + + function onEditorActivity(cm, f) { + cm.on("cursorActivity", f) + cm.on("blur", f) + cm.on("scroll", f) + cm.on("setDoc", f) + return function() { + cm.off("cursorActivity", f) + cm.off("blur", f) + cm.off("scroll", f) + cm.off("setDoc", f) + } + } + + function makeTooltip(x, y, content) { + if (typeof content === 'string') { + content = content.replace(//g, '\n') + } + var node = elt("div", cls + "tooltip", content); + node.style.left = x + "px"; + node.style.top = y + "px"; + document.body.appendChild(node); + return node; + } + + function remove(node) { + var p = node && node.parentNode; + if (p) p.removeChild(node); + } + + function fadeOut(tooltip) { + tooltip.style.opacity = "0"; + setTimeout(function() { remove(tooltip); }, 1100); + } + + function showError(ts, cm, msg) { + if (ts.options.showError) + ts.options.showError(cm, msg); + else + tempTooltip(cm, String(msg), ts); + } + + function closeArgHints(ts) { + if (ts.activeArgHints) { + if (ts.activeArgHints.clear) ts.activeArgHints.clear() + remove(ts.activeArgHints) + ts.activeArgHints = null + } + } + + function docValue(ts, doc) { + var val = doc.doc.getValue(); + if (ts.options.fileFilter) val = ts.options.fileFilter(val, doc.name, doc.doc); + return val; + } + + // Worker wrapper + + function WorkerServer(ts) { + var worker = ts.worker = new Worker(ts.options.workerScript); + worker.postMessage({type: "init", + defs: ts.options.defs, + plugins: ts.options.plugins, + scripts: ts.options.workerDeps}); + var msgId = 0, pending = {}; + + function send(data, c) { + if (c) { + data.id = ++msgId; + pending[msgId] = c; + } + worker.postMessage(data); + } + worker.onmessage = function(e) { + var data = e.data; + if (data.type == "getFile") { + getFile(ts, data.name, function(err, text) { + send({type: "getFile", err: String(err), text: text, id: data.id}); + }); + } else if (data.type == "debug") { + window.console.log(data.message); + } else if (data.id && pending[data.id]) { + pending[data.id](data.err, data.body); + delete pending[data.id]; + } + }; + worker.onerror = function(e) { + for (var id in pending) pending[id](e); + pending = {}; + }; + + this.addFile = function(name, text) { send({type: "add", name: name, text: text}); }; + this.delFile = function(name) { send({type: "del", name: name}); }; + this.request = function(body, c) { send({type: "req", body: body}, c); }; + } +}); + +// ========= lint.js ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + var GUTTER_ID = "CodeMirror-lint-markers"; + + function showTooltip(cm, e, content) { + var tt = document.createElement("div"); + tt.className = "CodeMirror-lint-tooltip cm-s-" + cm.options.theme; + tt.appendChild(content.cloneNode(true)); + if (cm.state.lint.options.selfContain) + cm.getWrapperElement().appendChild(tt); + else + document.body.appendChild(tt); + + function position(e) { + if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position); + tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px"; + tt.style.left = (e.clientX + 5) + "px"; + } + CodeMirror.on(document, "mousemove", position); + position(e); + if (tt.style.opacity != null) tt.style.opacity = 1; + return tt; + } + function rm(elt) { + if (elt.parentNode) elt.parentNode.removeChild(elt); + } + function hideTooltip(tt) { + if (!tt.parentNode) return; + if (tt.style.opacity == null) rm(tt); + tt.style.opacity = 0; + setTimeout(function() { rm(tt); }, 600); + } + + function showTooltipFor(cm, e, content, node) { + var tooltip = showTooltip(cm, e, content); + function hide() { + CodeMirror.off(node, "mouseout", hide); + if (tooltip) { hideTooltip(tooltip); tooltip = null; } + } + var poll = setInterval(function() { + if (tooltip) for (var n = node;; n = n.parentNode) { + if (n && n.nodeType == 11) n = n.host; + if (n == document.body) return; + if (!n) { hide(); break; } + } + if (!tooltip) return clearInterval(poll); + }, 400); + CodeMirror.on(node, "mouseout", hide); + } + + function LintState(cm, options, hasGutter) { + this.marked = []; + this.options = options; + this.timeout = null; + this.hasGutter = hasGutter; + this.onMouseOver = function(e) { onMouseOver(cm, e); }; + this.waitingFor = 0 + } + + function parseOptions(_cm, options) { + if (options instanceof Function) return {getAnnotations: options}; + if (!options || options === true) options = {}; + return options; + } + + function clearMarks(cm) { + var state = cm.state.lint; + if (state.hasGutter) cm.clearGutter(GUTTER_ID); + for (var i = 0; i < state.marked.length; ++i) + state.marked[i].clear(); + state.marked.length = 0; + } + + function makeMarker(cm, labels, severity, multiple, tooltips) { + var marker = document.createElement("div"), inner = marker; + marker.className = "CodeMirror-lint-marker-" + severity; + if (multiple) { + inner = marker.appendChild(document.createElement("div")); + inner.className = "CodeMirror-lint-marker-multiple"; + } + + if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) { + showTooltipFor(cm, e, labels, inner); + }); + + return marker; + } + + function getMaxSeverity(a, b) { + if (a == "error") return a; + else return b; + } + + function groupByLine(annotations) { + var lines = []; + for (var i = 0; i < annotations.length; ++i) { + var ann = annotations[i], line = ann.from.line; + (lines[line] || (lines[line] = [])).push(ann); + } + return lines; + } + + function annotationTooltip(ann) { + var severity = ann.severity; + if (!severity) severity = "error"; + var tip = document.createElement("div"); + tip.className = "CodeMirror-lint-message-" + severity; + if (typeof ann.messageHTML != 'undefined') { + tip.innerHTML = ann.messageHTML; + } else { + tip.appendChild(document.createTextNode(ann.message)); + } + return tip; + } + + function lintAsync(cm, getAnnotations, passOptions) { + var state = cm.state.lint + var id = ++state.waitingFor + function abort() { + id = -1 + cm.off("change", abort) + } + cm.on("change", abort) + getAnnotations(cm.getValue(), function(annotations, arg2) { + cm.off("change", abort) + if (state.waitingFor != id) return + if (arg2 && annotations instanceof CodeMirror) annotations = arg2 + cm.operation(function() {updateLinting(cm, annotations)}) + }, passOptions, cm); + } + + function startLinting(cm) { + var state = cm.state.lint, options = state.options; + /* + * Passing rules in `options` property prevents JSHint (and other linters) from complaining + * about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc. + */ + var passOptions = options.options || options; + var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); + if (!getAnnotations) return; + if (options.async || getAnnotations.async) { + lintAsync(cm, getAnnotations, passOptions) + } else { + var annotations = getAnnotations(cm.getValue(), passOptions, cm); + if (!annotations) return; + if (annotations.then) annotations.then(function(issues) { + cm.operation(function() {updateLinting(cm, issues)}) + }); + else cm.operation(function() {updateLinting(cm, annotations)}) + } + } + + function updateLinting(cm, annotationsNotSorted) { + clearMarks(cm); + var state = cm.state.lint, options = state.options; + + var annotations = groupByLine(annotationsNotSorted); + + for (var line = 0; line < annotations.length; ++line) { + var anns = annotations[line]; + if (!anns) continue; + + var maxSeverity = null; + var tipLabel = state.hasGutter && document.createDocumentFragment(); + + for (var i = 0; i < anns.length; ++i) { + var ann = anns[i]; + var severity = ann.severity; + if (!severity) severity = "error"; + maxSeverity = getMaxSeverity(maxSeverity, severity); + + if (options.formatAnnotation) ann = options.formatAnnotation(ann); + if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann)); + + if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, { + className: "CodeMirror-lint-mark-" + severity, + __annotation: ann + })); + } + + if (state.hasGutter) + cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, + state.options.tooltips)); + } + if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); + } + + function onChange(cm) { + var state = cm.state.lint; + if (!state) return; + clearTimeout(state.timeout); + state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500); + } + + function popupTooltips(cm, annotations, e) { + var target = e.target || e.srcElement; + var tooltip = document.createDocumentFragment(); + for (var i = 0; i < annotations.length; i++) { + var ann = annotations[i]; + tooltip.appendChild(annotationTooltip(ann)); + } + showTooltipFor(cm, e, tooltip, target); + } + + function onMouseOver(cm, e) { + var target = e.target || e.srcElement; + if (!/\bCodeMirror-lint-mark-/.test(target.className)) return; + var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2; + var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client")); + + var annotations = []; + for (var i = 0; i < spans.length; ++i) { + var ann = spans[i].__annotation; + if (ann) annotations.push(ann); + } + if (annotations.length) popupTooltips(cm, annotations, e); + } + + CodeMirror.defineOption("lint", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + clearMarks(cm); + if (cm.state.lint.options.lintOnChange !== false) + cm.off("change", onChange); + CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); + clearTimeout(cm.state.lint.timeout); + delete cm.state.lint; + } + + if (val) { + var gutters = cm.getOption("gutters"), hasLintGutter = false; + for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; + var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); + if (state.options.lintOnChange !== false) + cm.on("change", onChange); + if (state.options.tooltips != false && state.options.tooltips != "gutter") + CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); + + startLinting(cm); + } + }); + + CodeMirror.defineExtension("performLint", function() { + if (this.state.lint) startLinting(this); + }); +}); + +// ========= lint ========= // + +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: https://codemirror.net/LICENSE + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + // declare global: JSHINT + + function validator(text, options) { + if (!window.JSHINT) { + if (window.console) { + window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run."); + } + return []; + } + if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation + options.indent = 1; // JSHint default value is 4 + JSHINT(text, options, options.globals); + var errors = JSHINT.data().errors, result = []; + if (errors) parseErrors(errors, result); + return result; + } + + CodeMirror.registerHelper("lint", "javascript", validator); + + function parseErrors(errors, output) { + for ( var i = 0; i < errors.length; i++) { + var error = errors[i]; + if (error) { + if (error.line <= 0) { + if (window.console) { + window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error); + } + continue; + } + + var start = error.character - 1, end = start + 1; + if (error.evidence) { + var index = error.evidence.substring(start).search(/.\b/); + if (index > -1) { + end += index; + } + } + + // Convert to format expected by validation service + var hint = { + message: error.reason, + severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error", + from: CodeMirror.Pos(error.line - 1, start), + to: CodeMirror.Pos(error.line - 1, end) + }; + + output.push(hint); + } + } + } +}); + diff --git a/_server/CodeMirror/codeMirror.plugin.min.js b/_server/CodeMirror/codeMirror.plugin.min.js deleted file mode 100644 index 76b0471c..00000000 --- a/_server/CodeMirror/codeMirror.plugin.min.js +++ /dev/null @@ -1,19 +0,0 @@ -(function(mod){if(typeof exports=="object"&&typeof module=="object"){mod(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],mod)}else{mod(CodeMirror)}}})(function(CodeMirror){var HINT_ELEMENT_CLASS="CodeMirror-hint";var ACTIVE_HINT_ELEMENT_CLASS="CodeMirror-hint-active";CodeMirror.showHint=function(cm,getHints,options){if(!getHints){return cm.showHint(options)}if(options&&options.async){getHints.async=true}var newOpts={hint:getHints};if(options){for(var prop in options){newOpts[prop]=options[prop]}}return cm.showHint(newOpts)};CodeMirror.defineExtension("showHint",function(options){options=parseOptions(this,this.getCursor("start"),options);var selections=this.listSelections();if(selections.length>1){return}if(this.somethingSelected()){if(!options.hint.supportsSelection){return}for(var i=0;ihints.clientHeight+1;var startScroll=cm.getScrollInfo();if(overlapY>0){var height=box.bottom-box.top,curTop=pos.top-(pos.bottom-box.top);if(curTop-height>0){hints.style.top=(top=pos.top-height)+"px";below=false}else{if(height>winH){hints.style.height=(winH-5)+"px";hints.style.top=(top=pos.bottom-box.top)+"px";var cursor=cm.getCursor();if(data.from.ch!=cursor.ch){pos=cm.cursorCoords(cursor);hints.style.left=(left=pos.left)+"px";box=hints.getBoundingClientRect()}}}}var overlapX=box.right-winW;if(overlapX>0){if(box.right-box.left>winW){hints.style.width=(winW-5)+"px";overlapX-=(box.right-box.left)-winW}hints.style.left=(left=pos.left-overlapX)+"px"}if(scrolls){for(var node=hints.firstChild;node;node=node.nextSibling){node.style.paddingRight=cm.display.nativeBarWidth+"px"}}cm.addKeyMap(this.keyMap=buildKeyMap(completion,{moveFocus:function(n,avoidWrap){widget.changeActive(widget.selectedHint+n,avoidWrap)},setFocus:function(n){widget.changeActive(n)},menuSize:function(){return widget.screenAmount()},length:completions.length,close:function(){completion.close()},pick:function(){widget.pick()},data:data}));if(completion.options.closeOnUnfocus){var closingOnBlur;cm.on("blur",this.onBlur=function(){closingOnBlur=setTimeout(function(){completion.close()},100)});cm.on("focus",this.onFocus=function(){clearTimeout(closingOnBlur)})}cm.on("scroll",this.onScroll=function(){var curScroll=cm.getScrollInfo(),editor=cm.getWrapperElement().getBoundingClientRect();var newTop=top+startScroll.top-curScroll.top;var point=newTop-(window.pageYOffset||(document.documentElement||document.body).scrollTop);if(!below){point+=hints.offsetHeight}if(point<=editor.top||point>=editor.bottom){return completion.close()}hints.style.top=newTop+"px";hints.style.left=(left+startScroll.left-curScroll.left)+"px"});CodeMirror.on(hints,"dblclick",function(e){var t=getHintElement(hints,e.target||e.srcElement); -if(t&&t.hintId!=null){widget.changeActive(t.hintId);widget.pick()}});CodeMirror.on(hints,"click",function(e){var t=getHintElement(hints,e.target||e.srcElement);if(t&&t.hintId!=null){widget.changeActive(t.hintId);if(completion.options.completeOnSingleClick){widget.pick()}}});CodeMirror.on(hints,"mousedown",function(){setTimeout(function(){cm.focus()},20)});CodeMirror.signal(data,"select",completions[this.selectedHint],hints.childNodes[this.selectedHint]);return true}Widget.prototype={close:function(){if(this.completion.widget!=this){return}this.completion.widget=null;this.hints.parentNode.removeChild(this.hints);this.completion.cm.removeKeyMap(this.keyMap);var cm=this.completion.cm;if(this.completion.options.closeOnUnfocus){cm.off("blur",this.onBlur);cm.off("focus",this.onFocus)}cm.off("scroll",this.onScroll)},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var widget=this;this.keyMap={Enter:function(){widget.picked=true}};this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(i,avoidWrap){if(i>=this.data.list.length){i=avoidWrap?this.data.list.length-1:0}else{if(i<0){i=avoidWrap?0:this.data.list.length-1}}if(this.selectedHint==i){return}var node=this.hints.childNodes[this.selectedHint];node.className=node.className.replace(" "+ACTIVE_HINT_ELEMENT_CLASS,"");node=this.hints.childNodes[this.selectedHint=i];node.className+=" "+ACTIVE_HINT_ELEMENT_CLASS;if(node.offsetTopthis.hints.scrollTop+this.hints.clientHeight){this.hints.scrollTop=node.offsetTop+node.offsetHeight-this.hints.clientHeight+3}}CodeMirror.signal(this.data,"select",this.data.list[this.selectedHint],node)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}};function applicableHelpers(cm,helpers){if(!cm.somethingSelected()){return helpers}var result=[];for(var i=0; -i0){callback(result)}else{run(i+1)}})}run(0)};resolved.async=true;resolved.supportsSelection=true;return resolved}else{if(words=cm.getHelper(cm.getCursor(),"hintWords")){return function(cm){return CodeMirror.hint.fromList(cm,{words:words})}}else{if(CodeMirror.hint.anyword){return function(cm,options){return CodeMirror.hint.anyword(cm,options)}}else{return function(){}}}}}CodeMirror.registerHelper("hint","auto",{resolve:resolveAutoHints});CodeMirror.registerHelper("hint","fromList",function(cm,options){var cur=cm.getCursor(),token=cm.getTokenAt(cur);var to=CodeMirror.Pos(cur.line,token.end);if(token.string&&/\w/.test(token.string[token.string.length-1])){var term=token.string,from=CodeMirror.Pos(cur.line,token.start)}else{var term="",from=to}var found=[];for(var i=0;i,]/,closeOnUnfocus:true,completeOnSingleClick:true,container:null,customKeys:null,extraKeys:null};CodeMirror.defineOption("hintOptions",null)}); -(function(mod){if(typeof exports=="object"&&typeof module=="object"){mod(require("../../lib/codemirror"),require("./matchesonscrollbar"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","./matchesonscrollbar"],mod)}else{mod(CodeMirror)}}})(function(CodeMirror){var defaults={style:"matchhighlight",minChars:2,delay:100,wordsOnly:false,annotateScrollbar:false,showToken:false,trim:true};function State(options){this.options={};for(var name in defaults){this.options[name]=(options&&options.hasOwnProperty(name)?options:defaults)[name]}this.overlay=this.timeout=null;this.matchesonscroll=null;this.active=false}CodeMirror.defineOption("highlightSelectionMatches",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){removeOverlay(cm);clearTimeout(cm.state.matchHighlighter.timeout);cm.state.matchHighlighter=null;cm.off("cursorActivity",cursorActivity);cm.off("focus",onFocus)}if(val){var state=cm.state.matchHighlighter=new State(val);if(cm.hasFocus()){state.active=true;highlightMatches(cm)}else{cm.on("focus",onFocus)}cm.on("cursorActivity",cursorActivity)}});function cursorActivity(cm){var state=cm.state.matchHighlighter;if(state.active||cm.hasFocus()){scheduleHighlight(cm,state)}}function onFocus(cm){var state=cm.state.matchHighlighter;if(!state.active){state.active=true;scheduleHighlight(cm,state)}}function scheduleHighlight(cm,state){clearTimeout(state.timeout);state.timeout=setTimeout(function(){highlightMatches(cm)},state.options.delay)}function addOverlay(cm,query,hasBoundary,style){var state=cm.state.matchHighlighter;cm.addOverlay(state.overlay=makeOverlay(query,hasBoundary,style));if(state.options.annotateScrollbar&&cm.showMatchesOnScrollbar){var searchFor=hasBoundary?new RegExp("\\b"+query.replace(/[\\\[.+*?(){|^$]/g,"\\$&")+"\\b"):query;state.matchesonscroll=cm.showMatchesOnScrollbar(searchFor,false,{className:"CodeMirror-selection-highlight-scrollbar"})}}function removeOverlay(cm){var state=cm.state.matchHighlighter;if(state.overlay){cm.removeOverlay(state.overlay); -state.overlay=null;if(state.matchesonscroll){state.matchesonscroll.clear();state.matchesonscroll=null}}}function highlightMatches(cm){cm.operation(function(){var state=cm.state.matchHighlighter;removeOverlay(cm);if(!cm.somethingSelected()&&state.options.showToken){var re=state.options.showToken===true?/[\w$]/:state.options.showToken;var cur=cm.getCursor(),line=cm.getLine(cur.line),start=cur.ch,end=start;while(start&&re.test(line.charAt(start-1))){--start}while(end=state.options.minChars){addOverlay(cm,selection,false,state.options.style)}})}function isWord(cm,from,to){var str=cm.getRange(from,to);if(str.match(/^\w+$/)!==null){if(from.ch>0){var pos={line:from.line,ch:from.ch-1};var chr=cm.getRange(pos,from);if(chr.match(/\W/)===null){return false}}if(to.ch1,state.options.tooltips))}}if(options.onUpdateLinting){options.onUpdateLinting(annotationsNotSorted,annotations,cm)}}function onChange(cm){var state=cm.state.lint;if(!state){return}clearTimeout(state.timeout);state.timeout=setTimeout(function(){startLinting(cm)},state.options.delay||500)}function popupTooltips(annotations,e){var target=e.target||e.srcElement;var tooltip=document.createDocumentFragment();for(var i=0;i-1){end+=index}}var hint={message:error.reason,severity:error.code?(error.code.startsWith("W")?"warning":"error"):"error",from:CodeMirror.Pos(error.line-1,start),to:CodeMirror.Pos(error.line-1,end)};output.push(hint)}}}}); -(function(mod){if(typeof exports=="object"&&typeof module=="object"){mod(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],mod)}else{mod(CodeMirror)}}})(function(CodeMirror){var defaults={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"};var Pos=CodeMirror.Pos;CodeMirror.defineOption("autoCloseBrackets",false,function(cm,val,old){if(old&&old!=CodeMirror.Init){cm.removeKeyMap(keyMap);cm.state.closeBrackets=null}if(val){ensureBound(getOption(val,"pairs"));cm.state.closeBrackets=val;cm.addKeyMap(keyMap)}});function getOption(conf,name){if(name=="pairs"&&typeof conf=="string"){return conf}if(typeof conf=="object"&&conf[name]!=null){return conf[name]}return defaults[name]}var keyMap={Backspace:handleBackspace,Enter:handleEnter};function ensureBound(chars){for(var i=0;i=0;i--){var cur=ranges[i].head;cm.replaceRange("",Pos(cur.line,cur.ch-1),Pos(cur.line,cur.ch+1),"+delete")}}function handleEnter(cm){var conf=getConfig(cm);var explode=conf&&getOption(conf,"explode");if(!explode||cm.getOption("disableInput")){return CodeMirror.Pass}var ranges=cm.listSelections();for(var i=0;i0;return{anchor:new Pos(sel.anchor.line,sel.anchor.ch+(inverted?-1:1)),head:new Pos(sel.head.line,sel.head.ch+(inverted?1:-1))}}function handleChar(cm,ch){var conf=getConfig(cm);if(!conf||cm.getOption("disableInput")){return CodeMirror.Pass}var pairs=getOption(conf,"pairs");var pos=pairs.indexOf(ch);if(pos==-1){return CodeMirror.Pass}var triples=getOption(conf,"triples");var identical=pairs.charAt(pos+1)==ch;var ranges=cm.listSelections();var opening=pos%2==0;var type;for(var i=0;i=0&&cm.getRange(cur,Pos(cur.line,cur.ch+3))==ch+ch+ch){curType="skipThree"}else{curType="skip"}}}else{if(identical&&cur.ch>1&&triples.indexOf(ch)>=0&&cm.getRange(Pos(cur.line,cur.ch-2),cur)==ch+ch){if(cur.ch>2&&/\bstring/.test(cm.getTokenTypeAt(Pos(cur.line,cur.ch-2)))){return CodeMirror.Pass}curType="addFour"}else{if(identical){var prev=cur.ch==0?" ":cm.getRange(Pos(cur.line,cur.ch-1),cur);if(!CodeMirror.isWordChar(next)&&prev!=ch&&!CodeMirror.isWordChar(prev)){curType="both"}else{return CodeMirror.Pass}}else{if(opening&&(cm.getLine(cur.line).length==cur.ch||isClosingBracket(next,pairs)||/\s/.test(next))){curType="both"}else{return CodeMirror.Pass}}}}}if(!type){type=curType}else{if(type!=curType){return CodeMirror.Pass}}}var left=pos%2?pairs.charAt(pos-1):ch;var right=pos%2?ch:pairs.charAt(pos+1); -cm.operation(function(){if(type=="skip"){cm.execCommand("goCharRight")}else{if(type=="skipThree"){for(var i=0;i<3;i++){cm.execCommand("goCharRight")}}else{if(type=="surround"){var sels=cm.getSelections();for(var i=0;i-1&&pos%2==1}function charsAround(cm,pos){var str=cm.getRange(Pos(pos.line,pos.ch-1),Pos(pos.line,pos.ch+1));return str.length==2?str:null}function stringStartsAfter(cm,pos){var token=cm.getTokenAt(Pos(pos.line,pos.ch+1));return/\bstring/.test(token.type)&&token.start==pos.ch&&(pos.ch==0||!/\bstring/.test(cm.getTokenTypeAt(pos)))}}); -(function(mod){if(typeof exports=="object"&&typeof module=="object"){mod(require("../../lib/codemirror"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror"],mod)}else{mod(CodeMirror)}}})(function(CodeMirror){var Pos=CodeMirror.Pos;function forEach(arr,f){for(var i=0,e=arr.length;icur.ch){token.end=cur.ch;token.string=token.string.slice(0,cur.ch-token.start)}}var tprop=token;while(tprop.type=="property"){tprop=getToken(editor,Pos(cur.line,tprop.start));if(tprop.string!="."){return}tprop=getToken(editor,Pos(cur.line,tprop.start));if(!context){var context=[]}context.push(tprop)}return{list:getCompletions(token,context,keywords,options),from:Pos(cur.line,token.start),to:Pos(cur.line,token.end)}}function javascriptHint(editor,options){return scriptHint(editor,javascriptKeywords,function(e,cur){return e.getTokenAt(cur)},options)}CodeMirror.registerHelper("hint","javascript",javascriptHint);function getCoffeeScriptToken(editor,cur){var token=editor.getTokenAt(cur);if(cur.ch==token.start+1&&token.string.charAt(0)=="."){token.end=token.start;token.string=".";token.type="property"}else{if(/^\.[\w$_]*$/.test(token.string)){token.type="property";token.start++;token.string=token.string.replace(/\./,"")}}return token}function coffeescriptHint(editor,options){return scriptHint(editor,coffeescriptKeywords,getCoffeeScriptToken,options)}CodeMirror.registerHelper("hint","coffeescript",coffeescriptHint);var stringProps=("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight "+"toUpperCase toLowerCase split concat match replace search").split(" "); -var arrayProps=("length concat join splice push pop shift unshift slice reverse sort indexOf "+"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");var funcProps="prototype apply call bind".split(" ");var javascriptKeywords=("break case catch class const continue debugger default delete do else export extends false finally for function "+"if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");var coffeescriptKeywords=("and break catch class continue delete do else extends false finally for "+"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");function forAllProps(obj,callback){if(!Object.getOwnPropertyNames||!Object.getPrototypeOf){for(var name in obj){callback(name)}}else{for(var o=obj;o;o=Object.getPrototypeOf(o)){Object.getOwnPropertyNames(o).forEach(callback)}}}function getCompletions(token,context,keywords,options){var found=[],start=token.string,global=options&&options.globalScope||window;function maybeAdd(str){if(str==null||str==undefined){return}if(str.lastIndexOf(start,0)==0&&!arrayContains(found,str)){found.push(str)}}function gatherCompletions(obj){if(typeof obj=="string"){forEach(stringProps,maybeAdd)}else{if(obj instanceof Array){forEach(arrayProps,maybeAdd)}else{if(obj instanceof Function){forEach(funcProps,maybeAdd)}}}forAllProps(obj,maybeAdd)}if(context&&context.length){var obj=context.pop(),base;if(obj.type&&obj.type.indexOf("variable")===0){if(options&&options.additionalContext){base=options.additionalContext[obj.string]}if(!options||options.useGlobalScope!==false){base=base||global[obj.string]}}else{if(obj.type=="string"){base=""}else{if(obj.type=="atom"){base=1}else{if(obj.type=="function"){if(global.jQuery!=null&&(obj.string=="$"||obj.string=="jQuery")&&(typeof global.jQuery=="function")){base=global.jQuery()}else{if(global._!=null&&(obj.string=="_")&&(typeof global._=="function")){base=global._() -}}}}}}while(base!=null&&context.length){base=base[context.pop().string]}if(base!=null){gatherCompletions(base)}}else{for(var v=token.state.localVars;v;v=v.next){maybeAdd(v.name)}for(var v=token.state.globalVars;v;v=v.next){maybeAdd(v.name)}if(!options||options.useGlobalScope!==false){gatherCompletions(global)}forEach(keywords,maybeAdd)}return found}}); diff --git a/_server/CodeMirror/codemirror.css b/_server/CodeMirror/codemirror.css index e290de7f..05e1ce9d 100644 --- a/_server/CodeMirror/codemirror.css +++ b/_server/CodeMirror/codemirror.css @@ -1,121 +1,121 @@ -/* BASICS */ +/* ========== CodeMirror.css ========= */ .CodeMirror { - /* Set height, width, borders, and global font properties here */ - font-family: monospace; - height: 300px; - color: black; - direction: ltr; + /* Set height, width, borders, and global font properties here */ + font-family: monospace; + height: 300px; + color: black; + direction: ltr; } /* PADDING */ .CodeMirror-lines { - padding: 4px 0; /* Vertical padding around content */ + padding: 4px 0; /* Vertical padding around content */ } .CodeMirror pre { - padding: 0 4px; /* Horizontal padding of content */ + padding: 0 4px; /* Horizontal padding of content */ } .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - background-color: white; /* The little square between H and V scrollbars */ + background-color: white; /* The little square between H and V scrollbars */ } /* GUTTER */ .CodeMirror-gutters { - border-right: 1px solid #ddd; - background-color: #f7f7f7; - white-space: nowrap; + border-right: 1px solid #ddd; + background-color: #f7f7f7; + white-space: nowrap; } .CodeMirror-linenumbers { } .CodeMirror-linenumber { - padding: 0 3px 0 5px; - min-width: 20px; - text-align: right; - color: #999; - white-space: nowrap; + padding: 0 3px 0 5px; + min-width: 20px; + text-align: right; + color: #999; + white-space: nowrap; } .CodeMirror-guttermarker { - color: black; + color: black; } .CodeMirror-guttermarker-subtle { - color: #999; + color: #999; } /* CURSOR */ .CodeMirror-cursor { - border-left: 1px solid black; - border-right: none; - width: 0; + border-left: 1px solid black; + border-right: none; + width: 0; } /* Shown when moving in bi-directional text */ .CodeMirror div.CodeMirror-secondarycursor { - border-left: 1px solid silver; + border-left: 1px solid silver; } .cm-fat-cursor .CodeMirror-cursor { - width: auto; - border: 0 !important; - background: #7e7; + width: auto; + border: 0 !important; + background: #7e7; } .cm-fat-cursor div.CodeMirror-cursors { - z-index: 1; + z-index: 1; } .cm-fat-cursor-mark { - background-color: rgba(20, 255, 20, 0.5); - -webkit-animation: blink 1.06s steps(1) infinite; - -moz-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; + background-color: rgba(20, 255, 20, 0.5); + -webkit-animation: blink 1.06s steps(1) infinite; + -moz-animation: blink 1.06s steps(1) infinite; + animation: blink 1.06s steps(1) infinite; } .cm-animate-fat-cursor { - width: auto; - border: 0; - -webkit-animation: blink 1.06s steps(1) infinite; - -moz-animation: blink 1.06s steps(1) infinite; - animation: blink 1.06s steps(1) infinite; - background-color: #7e7; + width: auto; + border: 0; + -webkit-animation: blink 1.06s steps(1) infinite; + -moz-animation: blink 1.06s steps(1) infinite; + animation: blink 1.06s steps(1) infinite; + background-color: #7e7; } @-moz-keyframes blink { - 0% { - } - 50% { - background-color: transparent; - } - 100% { - } + 0% { + } + 50% { + background-color: transparent; + } + 100% { + } } @-webkit-keyframes blink { - 0% { - } - 50% { - background-color: transparent; - } - 100% { - } + 0% { + } + 50% { + background-color: transparent; + } + 100% { + } } @keyframes blink { - 0% { - } - 50% { - background-color: transparent; - } - 100% { - } + 0% { + } + 50% { + background-color: transparent; + } + 100% { + } } /* Can style cursor different in overwrite (non-insert) mode */ @@ -123,74 +123,74 @@ } .cm-tab { - display: inline-block; - text-decoration: inherit; + display: inline-block; + text-decoration: inherit; } .CodeMirror-rulers { - position: absolute; - left: 0; - right: 0; - top: -50px; - bottom: -20px; - overflow: hidden; + position: absolute; + left: 0; + right: 0; + top: -50px; + bottom: -20px; + overflow: hidden; } .CodeMirror-ruler { - border-left: 1px solid #ccc; - top: 0; - bottom: 0; - position: absolute; + border-left: 1px solid #ccc; + top: 0; + bottom: 0; + position: absolute; } /* DEFAULT THEME */ .cm-s-default .cm-header { - color: blue; + color: blue; } .cm-s-default .cm-quote { - color: #090; + color: #090; } .cm-negative { - color: #d44; + color: #d44; } .cm-positive { - color: #292; + color: #292; } .cm-header, .cm-strong { - font-weight: bold; + font-weight: bold; } .cm-em { - font-style: italic; + font-style: italic; } .cm-link { - text-decoration: underline; + text-decoration: underline; } .cm-strikethrough { - text-decoration: line-through; + text-decoration: line-through; } .cm-s-default .cm-keyword { - color: #708; + color: #708; } .cm-s-default .cm-atom { - color: #219; + color: #219; } .cm-s-default .cm-number { - color: #164; + color: #164; } .cm-s-default .cm-def { - color: #00f; + color: #00f; } .cm-s-default .cm-variable, @@ -200,249 +200,249 @@ } .cm-s-default .cm-variable-2 { - color: #05a; + color: #05a; } .cm-s-default .cm-variable-3, .cm-s-default .cm-type { - color: #085; + color: #085; } .cm-s-default .cm-comment { - color: #a50; + color: #a50; } .cm-s-default .cm-string { - color: #a11; + color: #a11; } .cm-s-default .cm-string-2 { - color: #f50; + color: #f50; } .cm-s-default .cm-meta { - color: #555; + color: #555; } .cm-s-default .cm-qualifier { - color: #555; + color: #555; } .cm-s-default .cm-builtin { - color: #30a; + color: #30a; } .cm-s-default .cm-bracket { - color: #997; + color: #997; } .cm-s-default .cm-tag { - color: #170; + color: #170; } .cm-s-default .cm-attribute { - color: #00c; + color: #00c; } .cm-s-default .cm-hr { - color: #999; + color: #999; } .cm-s-default .cm-link { - color: #00c; + color: #00c; } .cm-s-default .cm-error { - color: #f00; + color: #f00; } .cm-invalidchar { - color: #f00; + color: #f00; } .CodeMirror-composing { - border-bottom: 2px solid; + border-bottom: 2px solid; } /* Default styles for common addons */ div.CodeMirror span.CodeMirror-matchingbracket { - color: #0b0; + color: #0b0; } div.CodeMirror span.CodeMirror-nonmatchingbracket { - color: #a22; + color: #a22; } .CodeMirror-matchingtag { - background: rgba(255, 150, 0, .3); + background: rgba(255, 150, 0, .3); } .CodeMirror-activeline-background { - background: #e8f2ff; + background: #e8f2ff; } /* STOP */ /* The rest of this file contains styles related to the mechanics of - the editor. You probably shouldn't touch them. */ + the editor. You probably shouldn't touch them. */ .CodeMirror { - position: relative; - overflow: hidden; - background: white; + position: relative; + overflow: hidden; + background: white; } .CodeMirror-scroll { - overflow: scroll !important; /* Things will break if this is overridden */ - /* 30px is the magic margin used to hide the element's real scrollbars */ - /* See overflow: hidden in .CodeMirror */ - margin-bottom: -30px; - margin-right: -30px; - padding-bottom: 30px; - height: 100%; - outline: none; /* Prevent dragging from highlighting the element */ - position: relative; + overflow: scroll !important; /* Things will break if this is overridden */ + /* 30px is the magic margin used to hide the element's real scrollbars */ + /* See overflow: hidden in .CodeMirror */ + margin-bottom: -30px; + margin-right: -30px; + padding-bottom: 30px; + height: 100%; + outline: none; /* Prevent dragging from highlighting the element */ + position: relative; } .CodeMirror-sizer { - position: relative; - border-right: 30px solid transparent; + position: relative; + border-right: 30px solid transparent; } /* The fake, visible scrollbars. Used to force redraw during scrolling - before actual scrolling happens, thus preventing shaking and - flickering artifacts. */ + before actual scrolling happens, thus preventing shaking and + flickering artifacts. */ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { - position: absolute; - z-index: 6; - display: none; + position: absolute; + z-index: 6; + display: none; } .CodeMirror-vscrollbar { - right: 0; - top: 0; - overflow-x: hidden; - overflow-y: scroll; + right: 0; + top: 0; + overflow-x: hidden; + overflow-y: scroll; } .CodeMirror-hscrollbar { - bottom: 0; - left: 0; - overflow-y: hidden; - overflow-x: scroll; + bottom: 0; + left: 0; + overflow-y: hidden; + overflow-x: scroll; } .CodeMirror-scrollbar-filler { - right: 0; - bottom: 0; + right: 0; + bottom: 0; } .CodeMirror-gutter-filler { - left: 0; - bottom: 0; + left: 0; + bottom: 0; } .CodeMirror-gutters { - position: absolute; - left: 0; - top: 0; - min-height: 100%; - z-index: 3; + position: absolute; + left: 0; + top: 0; + min-height: 100%; + z-index: 3; } .CodeMirror-gutter { - white-space: normal; - height: 100%; - display: inline-block; - vertical-align: top; - margin-bottom: -30px; + white-space: normal; + height: 100%; + display: inline-block; + vertical-align: top; + margin-bottom: -30px; } .CodeMirror-gutter-wrapper { - position: absolute; - z-index: 4; - background: none !important; - border: none !important; + position: absolute; + z-index: 4; + background: none !important; + border: none !important; } .CodeMirror-gutter-background { - position: absolute; - top: 0; - bottom: 0; - z-index: 4; + position: absolute; + top: 0; + bottom: 0; + z-index: 4; } .CodeMirror-gutter-elt { - position: absolute; - cursor: default; - z-index: 4; + position: absolute; + cursor: default; + z-index: 4; } .CodeMirror-gutter-wrapper ::selection { - background-color: transparent + background-color: transparent } .CodeMirror-gutter-wrapper ::-moz-selection { - background-color: transparent + background-color: transparent } .CodeMirror-lines { - cursor: text; - min-height: 1px; /* prevents collapsing before first draw */ + cursor: text; + min-height: 1px; /* prevents collapsing before first draw */ } .CodeMirror pre { - /* Reset some styles that the rest of the page might have set */ - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; - border-width: 0; - background: transparent; - font-family: inherit; - font-size: inherit; - margin: 0; - white-space: pre; - word-wrap: normal; - line-height: inherit; - color: inherit; - z-index: 2; - position: relative; - overflow: visible; - -webkit-tap-highlight-color: transparent; - -webkit-font-variant-ligatures: contextual; - font-variant-ligatures: contextual; + /* Reset some styles that the rest of the page might have set */ + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; + border-width: 0; + background: transparent; + font-family: inherit; + font-size: inherit; + margin: 0; + white-space: pre; + word-wrap: normal; + line-height: inherit; + color: inherit; + z-index: 2; + position: relative; + overflow: visible; + -webkit-tap-highlight-color: transparent; + -webkit-font-variant-ligatures: contextual; + font-variant-ligatures: contextual; } .CodeMirror-wrap pre { - word-wrap: break-word; - white-space: pre-wrap; - word-break: normal; + word-wrap: break-word; + white-space: pre-wrap; + word-break: normal; } .CodeMirror-linebackground { - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; - z-index: 0; + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + z-index: 0; } .CodeMirror-linewidget { - position: relative; - z-index: 2; - padding: 0.1px; /* Force widget margins to stay inside of the container */ + position: relative; + z-index: 2; + padding: 0.1px; /* Force widget margins to stay inside of the container */ } .CodeMirror-widget { } .CodeMirror-rtl pre { - direction: rtl; + direction: rtl; } .CodeMirror-code { - outline: none; + outline: none; } /* Force content-box sizing for the elements where we expect it */ @@ -451,196 +451,361 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket { .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber { - -moz-box-sizing: content-box; - box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; } .CodeMirror-measure { - position: absolute; - width: 100%; - height: 0; - overflow: hidden; - visibility: hidden; + position: absolute; + width: 100%; + height: 0; + overflow: hidden; + visibility: hidden; } .CodeMirror-cursor { - position: absolute; - pointer-events: none; + position: absolute; + pointer-events: none; } .CodeMirror-measure pre { - position: static; + position: static; } div.CodeMirror-cursors { - visibility: hidden; - position: relative; - z-index: 3; + visibility: hidden; + position: relative; + z-index: 3; } div.CodeMirror-dragcursors { - visibility: visible; + visibility: visible; } .CodeMirror-focused div.CodeMirror-cursors { - visibility: visible; + visibility: visible; } .CodeMirror-selected { - background: #d9d9d9; + background: #d9d9d9; } .CodeMirror-focused .CodeMirror-selected { - background: #d7d4f0; + background: #d7d4f0; } .CodeMirror-crosshair { - cursor: crosshair; + cursor: crosshair; } .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { - background: #d7d4f0; + background: #d7d4f0; } .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { - background: #d7d4f0; + background: #d7d4f0; } .cm-searching { - background-color: #ffa; - background-color: rgba(255, 255, 0, .4); + background-color: #ffa; + background-color: rgba(255, 255, 0, .4); } /* Used to force a border model for a node */ .cm-force-border { - padding-right: .1px; + padding-right: .1px; } @media print { - /* Hide the cursor when printing */ - .CodeMirror div.CodeMirror-cursors { - visibility: hidden; - } + /* Hide the cursor when printing */ + .CodeMirror div.CodeMirror-cursors { + visibility: hidden; + } } /* See issue #2901 */ .cm-tab-wrap-hack:after { - content: ''; + content: ''; } /* Help users use markselection to safely style text background */ span.CodeMirror-selectedtext { - background: none; + background: none; } +/* ========= show-hint.css ========= */ + .cm-matchhighlight {background-color: #dedede} .CodeMirror-hints { - position: absolute; - z-index: 301; - overflow: hidden; - list-style: none; + position: absolute; + z-index: 340; + overflow: hidden; + list-style: none; - margin: 0; - padding: 2px; + margin: 0; + padding: 2px; - -webkit-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); - -moz-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); - box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); - border-radius: 3px; - border: 1px solid silver; + -webkit-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); + -moz-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); + box-shadow: 2px 3px 5px rgba(0, 0, 0, .2); + border-radius: 3px; + border: 1px solid silver; - background: white; - font-size: 90%; - font-family: monospace; + background: white; + font-size: 90%; + font-family: monospace; - max-height: 20em; - overflow-y: auto; + max-height: 20em; + overflow-y: auto; } .CodeMirror-hint { - margin: 0; - padding: 0 4px; - border-radius: 2px; - white-space: pre; - color: black; - cursor: pointer; + margin: 0; + padding: 0 4px; + border-radius: 2px; + white-space: pre; + color: black; + cursor: pointer; } li.CodeMirror-hint-active { - background: #08f; - color: white; + background: #08f; + color: white; } +/* ========= lint.css ========= */ + /* The lint marker gutter */ .CodeMirror-lint-markers { - width: 16px; + width: 16px; } .CodeMirror-lint-tooltip { - background-color: #ffd; - border: 1px solid black; - border-radius: 4px 4px 4px 4px; - color: black; - font-family: monospace; - font-size: 10pt; - overflow: hidden; - padding: 2px 5px; - position: fixed; - white-space: pre; - white-space: pre-wrap; - z-index: 330; - max-width: 600px; - opacity: 0; - transition: opacity .4s; - -moz-transition: opacity .4s; - -webkit-transition: opacity .4s; - -o-transition: opacity .4s; - -ms-transition: opacity .4s; + background-color: #ffd; + border: 1px solid black; + border-radius: 4px 4px 4px 4px; + color: black; + font-family: monospace; + font-size: 10pt; + overflow: hidden; + padding: 2px 5px; + position: fixed; + white-space: pre; + white-space: pre-wrap; + z-index: 330; + max-width: 600px; + opacity: 0; + transition: opacity .4s; + -moz-transition: opacity .4s; + -webkit-transition: opacity .4s; + -o-transition: opacity .4s; + -ms-transition: opacity .4s; } .CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { - background-position: left bottom; - background-repeat: repeat-x; + background-position: left bottom; + background-repeat: repeat-x; } .CodeMirror-lint-mark-error { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); } .CodeMirror-lint-mark-warning { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { - background-position: center center; - background-repeat: no-repeat; - cursor: pointer; - display: inline-block; - height: 16px; - width: 16px; - vertical-align: middle; - position: relative; + background-position: center center; + background-repeat: no-repeat; + cursor: pointer; + display: inline-block; + height: 16px; + width: 16px; + vertical-align: middle; + position: relative; } .CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { - padding-left: 18px; - background-position: top left; - background-repeat: no-repeat; + padding-left: 18px; + background-position: top left; + background-repeat: no-repeat; } .CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII="); } .CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII="); } .CodeMirror-lint-marker-multiple { - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); - background-repeat: no-repeat; - background-position: right bottom; - width: 100%; - height: 100%; -} \ No newline at end of file + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + background-position: right bottom; + width: 100%; + height: 100%; +} + +/* ========= dialog.css ========= */ + +.CodeMirror-dialog { + position: absolute; + left: 0; right: 0; + background: inherit; + z-index: 15; + padding: .1em .8em; + overflow: hidden; + color: inherit; +} + +.CodeMirror-dialog-top { + border-bottom: 1px solid #eee; + top: 0; +} + +.CodeMirror-dialog-bottom { + border-top: 1px solid #eee; + bottom: 0; +} + +.CodeMirror-dialog input { + border: none; + outline: none; + background: transparent; + width: 20em; + color: inherit; + font-family: monospace; +} + +.CodeMirror-dialog button { + font-size: 70%; +} + +/* ========= dialog.css ========= */ + +.CodeMirror-dialog { + position: absolute; + left: 0; right: 0; + background: inherit; + z-index: 15; + padding: .1em .8em; + overflow: hidden; + color: inherit; +} + +.CodeMirror-dialog-top { + border-bottom: 1px solid #eee; + top: 0; +} + +.CodeMirror-dialog-bottom { + border-top: 1px solid #eee; + bottom: 0; +} + +.CodeMirror-dialog input { + border: none; + outline: none; + background: transparent; + width: 20em; + color: inherit; + font-family: monospace; +} + +.CodeMirror-dialog button { + font-size: 70%; +} + + +/* ========= tern.css ========= */ + +.CodeMirror-Tern-completion { + padding-left: 22px; + position: relative; + line-height: 1.5; +} +.CodeMirror-Tern-completion:before { + position: absolute; + left: 2px; + bottom: 2px; + border-radius: 50%; + font-size: 12px; + font-weight: bold; + height: 15px; + width: 15px; + line-height: 16px; + text-align: center; + color: white; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.CodeMirror-Tern-completion-unknown:before { + content: "?"; + background: #4bb; +} +.CodeMirror-Tern-completion-object:before { + content: "O"; + background: #77c; +} +.CodeMirror-Tern-completion-fn:before { + content: "F"; + background: #7c7; +} +.CodeMirror-Tern-completion-array:before { + content: "A"; + background: #c66; +} +.CodeMirror-Tern-completion-number:before { + content: "1"; + background: #999; +} +.CodeMirror-Tern-completion-string:before { + content: "S"; + background: #999; +} +.CodeMirror-Tern-completion-bool:before { + content: "B"; + background: #999; +} + +.CodeMirror-Tern-completion-guess { + color: #999; +} + +.CodeMirror-Tern-tooltip { + border: 1px solid silver; + border-radius: 3px; + color: #444; + padding: 2px 5px; + font-size: 90%; + font-family: monospace; + background-color: white; + white-space: pre-wrap; + + max-width: 40em; + position: absolute; + z-index: 320; + -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + + transition: opacity 1s; + -moz-transition: opacity 1s; + -webkit-transition: opacity 1s; + -o-transition: opacity 1s; + -ms-transition: opacity 1s; +} + +.CodeMirror-Tern-hint-doc { + max-width: 25em; + margin-top: -3px; +} + +.CodeMirror-Tern-fname { color: black; } +.CodeMirror-Tern-farg { color: #70a; } +.CodeMirror-Tern-farg-current { text-decoration: underline; } +.CodeMirror-Tern-type { color: #07c; } +.CodeMirror-Tern-fhint-guess { opacity: .7; } diff --git a/_server/CodeMirror/defs.js b/_server/CodeMirror/defs.js new file mode 100644 index 00000000..0ff5a0ca --- /dev/null +++ b/_server/CodeMirror/defs.js @@ -0,0 +1,3861 @@ +var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ + { + "!name": "browser", + "Node": { + "!type": "fn()", + "prototype": { + "nextSibling": { + "!type": "+Element", + "!doc": "返回紧接其父节点的childNodes列表中指定节点之后的节点;如果指定节点是该列表中的最后一个节点,则返回null.", + }, + "previousSibling": { + "!type": "+Element", + "!doc": "返回紧接其父节点的childNodes列表中指定节点之前的节点,如果指定节点是该列表中的第一个节点,则返回null.", + }, + "lastChild": { + "!type": "+Element", + "!doc": "返回节点的最后一个孩子." + }, + "firstChild": { + "!type": "+Element", + "!doc": "返回树中该节点的第一个子节点;如果该节点为无子节点,则返回null.如果该节点是Document,则返回其直接子节点列表中的第一个节点.", + }, + "childNodes": { + "!type": "+NodeList", + "!doc": "返回给定元素的子节点的集合." + }, + "parentNode": { + "!type": "+Element", + "!doc": "返回DOM树中指定节点的父级." + }, + "tagName": { + "!type": "string", + "!doc": "将当前节点的名称作为字符串返回." + }, + "insertBefore": { + "!type": "fn(newElt: +Element, before: +Element) -> +Element", + "!doc": "将指定的节点插入到参考元素之前,作为当前节点的子级.", + }, + "removeChild": { + "!type": "fn(oldNode: +Element) -> +Element", + "!doc": "从DOM中删除一个子节点.返回已删除的节点.", + }, + "appendChild": { + "!type": "fn(newNode: +Element) -> +Element", + "!doc": "将一个节点添加到指定父节点的子节点列表的末尾.如果该节点已经存在,则将其从当前父节点中删除,然后添加到新的父节点中.", + }, + "cloneNode": { + "!type": "fn(deep: bool) -> +Element", + "!doc": "返回在其上调用此方法的节点的副本." + }, + "addEventListener": { + "!type": "fn(type: string, listener: fn(e: +Event), capture: bool)", + "!doc": "在单个目标上注册单个事件侦听器.事件目标可以是文档中的单个元素,文档本身,窗口或XMLHttpRequest.", + }, + "removeEventListener": { + "!type": "fn(type: string, listener: fn(), capture: bool)", + "!doc": "允许从事件目标中删除事件侦听器.", + }, + "innerText": { + "!type": "string", + "!doc": "获取或设置节点及其后代的文本内容." + } + }, + "!doc": "节点是一个接口,许多DOM类型都从该接口继承,并允许类似地对待(或测试)这些各种类型.", + }, + "Element": { + "!type": "fn()", + "prototype": { + "!proto": "Node.prototype", + "getAttribute": { + "!type": "fn(name: string) -> string", + "!doc": "返回指定元素上的命名属性的值.如果命名属性不存在,则返回的值将为null或\" \"(空字符串).", + }, + "setAttribute": { + "!type": "fn(name: string, value: string)", + "!doc": "在指定元素上添加新属性或更改现有属性的值.", + }, + "removeAttribute": { + "!type": "fn(name: string)", + "!doc": "从指定元素中删除属性.", + }, + "getElementsByTagName": { + "!type": "fn(tagName: string) -> +NodeList", + "!doc": "返回具有给定标签名的元素列表.搜索指定元素下面的子树,不包括元素本身.返回的列表是活动的,这意味着它将自动使用DOM树进行更新.因此,无需使用相同的元素和参数多次调用element.getElementsByTagName." + }, + "getElementsByClassName": { + "!type": "fn(name: string) -> +NodeList", + "!doc": "返回具有所有给定类名称的一组元素.在文档对象上调用时,将搜索整个文档,包括根节点.您还可以在任何元素上调用getElementsByClassName;它将仅返回元素,它们是具有给定类名的指定根元素的后代." + }, + "children": { + "!type": "+HTMLCollection", + "!doc": "返回给定元素的子元素的集合." + }, + "className": { + "!type": "string", + "!doc": "获取并设置指定元素的class属性的值.", + }, + "style": { + "cssText": "string", + "alignmentBaseline": "string", + "background": "string", + "backgroundAttachment": "string", + "backgroundClip": "string", + "backgroundColor": "string", + "backgroundImage": "string", + "backgroundOrigin": "string", + "backgroundPosition": "string", + "backgroundPositionX": "string", + "backgroundPositionY": "string", + "backgroundRepeat": "string", + "backgroundRepeatX": "string", + "backgroundRepeatY": "string", + "backgroundSize": "string", + "baselineShift": "string", + "border": "string", + "borderBottom": "string", + "borderBottomColor": "string", + "borderBottomLeftRadius": "string", + "borderBottomRightRadius": "string", + "borderBottomStyle": "string", + "borderBottomWidth": "string", + "borderCollapse": "string", + "borderColor": "string", + "borderImage": "string", + "borderImageOutset": "string", + "borderImageRepeat": "string", + "borderImageSlice": "string", + "borderImageSource": "string", + "borderImageWidth": "string", + "borderLeft": "string", + "borderLeftColor": "string", + "borderLeftStyle": "string", + "borderLeftWidth": "string", + "borderRadius": "string", + "borderRight": "string", + "borderRightColor": "string", + "borderRightStyle": "string", + "borderRightWidth": "string", + "borderSpacing": "string", + "borderStyle": "string", + "borderTop": "string", + "borderTopColor": "string", + "borderTopLeftRadius": "string", + "borderTopRightRadius": "string", + "borderTopStyle": "string", + "borderTopWidth": "string", + "borderWidth": "string", + "bottom": "string", + "boxShadow": "string", + "boxSizing": "string", + "captionSide": "string", + "clear": "string", + "clip": "string", + "clipPath": "string", + "clipRule": "string", + "color": "string", + "colorInterpolation": "string", + "colorInterpolationFilters": "string", + "colorProfile": "string", + "colorRendering": "string", + "content": "string", + "counterIncrement": "string", + "counterReset": "string", + "cursor": "string", + "direction": "string", + "display": "string", + "dominantBaseline": "string", + "emptyCells": "string", + "enableBackground": "string", + "fill": "string", + "fillOpacity": "string", + "fillRule": "string", + "filter": "string", + "float": "string", + "floodColor": "string", + "floodOpacity": "string", + "font": "string", + "fontFamily": "string", + "fontSize": "string", + "fontStretch": "string", + "fontStyle": "string", + "fontVariant": "string", + "fontWeight": "string", + "glyphOrientationHorizontal": "string", + "glyphOrientationVertical": "string", + "height": "string", + "imageRendering": "string", + "kerning": "string", + "left": "string", + "letterSpacing": "string", + "lightingColor": "string", + "lineHeight": "string", + "listStyle": "string", + "listStyleImage": "string", + "listStylePosition": "string", + "listStyleType": "string", + "margin": "string", + "marginBottom": "string", + "marginLeft": "string", + "marginRight": "string", + "marginTop": "string", + "marker": "string", + "markerEnd": "string", + "markerMid": "string", + "markerStart": "string", + "mask": "string", + "maxHeight": "string", + "maxWidth": "string", + "minHeight": "string", + "minWidth": "string", + "opacity": "string", + "orphans": "string", + "outline": "string", + "outlineColor": "string", + "outlineOffset": "string", + "outlineStyle": "string", + "outlineWidth": "string", + "overflow": "string", + "overflowWrap": "string", + "overflowX": "string", + "overflowY": "string", + "padding": "string", + "paddingBottom": "string", + "paddingLeft": "string", + "paddingRight": "string", + "paddingTop": "string", + "page": "string", + "pageBreakAfter": "string", + "pageBreakBefore": "string", + "pageBreakInside": "string", + "pointerEvents": "string", + "position": "string", + "quotes": "string", + "resize": "string", + "right": "string", + "shapeRendering": "string", + "size": "string", + "speak": "string", + "src": "string", + "stopColor": "string", + "stopOpacity": "string", + "stroke": "string", + "strokeDasharray": "string", + "strokeDashoffset": "string", + "strokeLinecap": "string", + "strokeLinejoin": "string", + "strokeMiterlimit": "string", + "strokeOpacity": "string", + "strokeWidth": "string", + "tabSize": "string", + "tableLayout": "string", + "textAlign": "string", + "textAnchor": "string", + "textDecoration": "string", + "textIndent": "string", + "textLineThrough": "string", + "textLineThroughColor": "string", + "textLineThroughMode": "string", + "textLineThroughStyle": "string", + "textLineThroughWidth": "string", + "textOverflow": "string", + "textOverline": "string", + "textOverlineColor": "string", + "textOverlineMode": "string", + "textOverlineStyle": "string", + "textOverlineWidth": "string", + "textRendering": "string", + "textShadow": "string", + "textTransform": "string", + "textUnderline": "string", + "textUnderlineColor": "string", + "textUnderlineMode": "string", + "textUnderlineStyle": "string", + "textUnderlineWidth": "string", + "top": "string", + "unicodeBidi": "string", + "unicodeRange": "string", + "vectorEffect": "string", + "verticalAlign": "string", + "visibility": "string", + "whiteSpace": "string", + "width": "string", + "wordBreak": "string", + "wordSpacing": "string", + "wordWrap": "string", + "writingMode": "string", + "zIndex": "string", + "zoom": "string", + "!doc": "返回一个表示元素的style属性的对象." + }, + "classList": { + "!type": "+DOMTokenList", + "!doc": "返回元素的class属性的标记列表." + }, + "title": { + "!type": "string", + "!doc":" \"\u5efa\u7acb\u5f53\u9f20\u6807\u60ac\u505c\u5728\u663e\u793a\u7684\u8282\u70b9\u4e0a\u65f6\u5728\"\u5de5\u5177\u63d0\u793a\"\u5f39\u51fa\u7a97\u53e3\u4e2d\u663e\u793a\u7684\u6587\u672c.\"," + }, + "width": { + "!type": "number", + "!doc": "返回元素的布局宽度." + }, + "height": { + "!type": "number", + "!doc": "元素相对于元素的offsetParent的高度." + }, + "getContext": { + "!type": "fn(id: string) -> CanvasRenderingContext2D", + "!doc": " DOM画布元素公开了HTMLCanvasElement接口,该接口提供了用于操纵画布元素的布局和表示的属性和方法.HTMLCanvasElement接口继承了元素对象接口的属性和方法.", + }, + "innerHTML": { + "!type": "string", + "!doc": "设置或获取描述元素后代的HTML语法.", + } + }, + "!doc": "表示HTML或XML文档中的元素.", + }, + "Document": { + "!type": "fn()", + "prototype": { + "!proto": "Node.prototype", + "height": { + "!type": "number", + "!doc": "返回当前文档的元素的高度.", + }, + "width": { + "!type": "number", + "!doc": "以像素为单位返回当前文档的元素的宽度.", + }, + "body": { + "!type": "+Element", + "!doc": "返回当前文档的或节点.", + }, + "cookie": { + "!type": "string", + "!doc": "获取并设置与当前文档关联的cookie.", + }, + "URL": "string", + "title": { + "!type": "string", + "!doc": "获取或设置文档的标题." + }, + "getElementById": { + "!type": "fn(id: string) -> +Element", + "!doc": "通过元素ID返回对该元素的引用." + }, + "getElementsByTagName": { + "!type": "fn(tagName: string) -> +NodeList", + "!doc": "返回具有给定标签名称的元素的NodeList.将搜索整个文档,包括根节点.返回的NodeList处于活动状态,这意味着它会自动更新自身以与DOM树保持同步,而无需再次调用document.getElementsByTagName." + }, + "getElementsByName": { + "!type": "fn(name: string) -> +HTMLCollection", + "!doc": "返回HTML文档中具有给定名称的元素列表.", + }, + "getElementsByClassName": "Element.prototype.getElementsByClassName" + }, + "!doc": "浏览器中加载的每个网页都有其自己的文档对象.此对象用作网页内容(DOM树,包括诸如和之类的元素)的入口点,并提供文档的全局功能(例如获取页面的URL和在文档中创建新元素)." + }, + "document": { + "!type": "+Document", + "!doc": "浏览器中加载的每个网页都有其自己的文档对象.此对象用作网页内容(DOM树,包括诸如和
之类的元素)的入口点,并提供文档的全局功能(例如获取页面的URL和在文档中创建新元素)." + }, + "Event": { + "!type": "fn()", + "prototype": { + "stopPropagation": { + "!type": "fn()", + "!doc": "防止当前事件进一步传播." + }, + "preventDefault": { + "!type": "fn()", + "!doc": "如果可以取消事件,则取消该事件,而不停止事件的进一步传播." + }, + "stopImmediatePropagation": { + "!type": "fn()", + "!doc": "防止同一事件的其他侦听器被调用." + }, + "type": { + "!type": "string", + "!doc": "返回包含事件类型的字符串." + }, + "target": { + "!type": "+Element", + "!doc": " EventTarget是由对象实现的DOM接口,这些对象可以接收DOM事件并具有侦听器.最常见的EventTarget是DOM元素,尽管其他对象也可以是EventTarget,例如文档,窗口,XMLHttpRequest,和别的." + }, + "clientX": { + "!type": "number", + "!doc": "返回事件发生的应用程序客户区域内的水平坐标(与页面内的坐标相反).例如,单击客户区域左上角将始终显示clientX值为0的鼠标事件,无论页面是否水平滚动." + }, + "clientY": { + "!type": "number", + "!doc": "返回事件发生在应用程序客户区中的垂直坐标(与页面中的坐标相反).例如,单击客户区左上角将始终显示不管页面是否垂直滚动,clientY值为0的鼠标事件." + }, + "keyCode": { + "!type": "number", + "!doc": "返回按键事件中的非字符键或任何其他类型的键盘事件中的任何键的Unicode值.", + }, + "charCode": { + "!type": "number", + "!doc": "返回在按键事件期间按下的字符键的Unicode值." + }, + "which": { + "!type": "number", + "!doc": "返回所按下键的数字keyCode或所按下字母数字键的字符代码(charCode)." + }, + "button": { + "!type": "number", + "!doc": "指示导致事件的鼠标按钮." + }, + "shiftKey": { + "!type": "bool", + "!doc": "指示事件触发时是否按下SHIFT键.", + }, + "ctrlKey": { + "!type": "bool", + "!doc": "指示事件触发时是否按下了CTRL键.", + }, + "altKey": { + "!type": "bool", + "!doc": "指示事件触发时是否按下ALT键.", + } + } + }, + "Storage": { + "length": { + "!type": "number", + "!doc": "存储接口的length只读属性返回一个整数,该整数表示存储在存储对象中的数据项的数量.", + }, + "setItem": { + "!type": "fn(name: string, value: string)", + "!doc": "存储接口的setItem()方法在传递键名称和值时,会将该键添加到存储中,或者更新该键的值(如果已存在).", + }, + "getItem": { + "!type": "fn(name: string) -> string", + "!doc": "存储接口的getItem()方法在传递键名时将返回该键的值.", + }, + "key": { + "!type": "fn(index: number) -> string", + "!doc": "存储接口的key()方法传递数字n时,返回存储中第n个键的名称.键的顺序是用户代理定义的,因此您不应依赖它." + }, + "removeItem": { + "!type": "fn(key: string)", + "!doc": "存储接口的removeItem()方法在传递了键名后,将从存储中删除该键.", + }, + "clear": { + "!type": "fn()", + "!doc": "存储接口的clear()方法在被调用时将从存储中清空所有键." + } + }, + "localStorage": { + "!type": "Storage", + "!doc": " localStorage属性允许您访问本地存储对象.localStorage与sessionStorage类似.唯一的区别是,虽然存储在localStorage中的数据没有到期时间,但是浏览会话时存储在sessionStorage中的数据将被清除.结束-也就是说,当浏览器关闭时.\ n \ n请注意,存储在localStorage或sessionStorage中的数据特定于页面协议." + }, + "console": { + "assert": { + "!type": "fn(assertion: bool, text: string)", + "!doc": "如果断言为false,则将错误消息写入控制台.", + }, + "error": { + "!type": "fn(...msg: ?)", + "!doc": "将错误消息输出到Web控制台.", + }, + "info": { + "!type": "fn(...msg: ?)", + "!doc": "将参考消息输出到Web控制台.", + }, + "log": { + "!type": "fn(...msg: ?)", + "!doc": "将消息输出到Web控制台.", + }, + "time": { + "!type": "fn(label: string)", + "!doc": "启动计时器,您可以使用该计时器来跟踪操作需要多长时间.", + }, + "timeEnd": { + "!type": "fn(label: string)", + "!doc": "停止以前通过调用console.time()启动的计时器.", + }, + "trace": { + "!type": "fn()", + "!doc": "将堆栈跟踪输出到Web控制台.", + }, + "warn": { + "!type": "fn(...msg: ?)", + "!doc": "将警告消息输出到Web控制台.", + }, + "!doc": "控制台对象提供对浏览器调试控制台的访问.其工作方式的细节因浏览器而异,但实际上提供了一组事实上的功能.", + }, + "window": { + "!type": "", + "!doc": "窗口对象代表一个包含DOM文档的窗口.", + }, + "self": { + "!type": "", + "!doc": "将对象引用返回到窗口对象.", + }, + "devicePixelRatio": "number", + "requestAnimationFrame": { + "!type": "fn(callback: fn(timestamp: number)) -> number", + "!doc": " Window.requestAnimationFrame()方法告诉浏览器您希望执行动画,并请求浏览器在下一次重绘之前调用指定的函数来更新动画.该方法将回调作为参数在重新粉刷之前被调用." + }, + "cancelAnimationFrame": { + "!type": "fn(number)n", + "!doc": "取消先前安排的动画帧请求.", + }, + "alert": { + "!type": "fn(message: string)", + "!doc": "显示具有指定内容和确定按钮的警报对话框." + }, + "confirm": { + "!type": "fn(message: string) -> bool", + "!doc": "显示带有消息和两个按钮(确定和取消)的模式对话框.", + }, + "prompt": { + "!type": "fn(message: string, value: string) -> string", + "!doc": "显示一个对话框,提示用户输入一些文本.", + }, + "setTimeout": { + "!type": "fn(f: fn(), ms: number) -> number", + "!doc": "在指定的延迟后调用函数或执行代码段." + }, + "clearTimeout": { + "!type": "fn(timeout: number)", + "!doc": "清除window.setTimeout()设置的延迟.", + }, + "setInterval": { + "!type": "fn(f: fn(), ms: number) -> number", + "!doc": "反复调用一个函数或执行代码段,每次调用该函数之间有固定的时间延迟.", + }, + "clearInterval": { + "!type": "fn(interval: number)", + "!doc": "取消使用setInterval设置的重复操作.", + }, + "atob": { + "!type": "fn(encoded: string) -> string", + "!doc": "解码使用base-64编码编码的数据字符串." + }, + "btoa": { + "!type": "fn(data: string) -> string", + "!doc": "从一串二进制数据创建一个base-64编码的ASCII字符串.", + }, + "getComputedStyle": { + "!type": "fn(node: +Element, pseudo?: string) -> Element.prototype.style", + "!doc": "给出元素的所有CSS属性的最终使用值.", + }, + "CanvasRenderingContext2D": { + "canvas": "+Element", + "width": "number", + "height": "number", + "commit": "fn()", + "save": "fn()", + "restore": "fn()", + "currentTransform": "?", + "scale": "fn(x: number, y: number)", + "rotate": "fn(angle: number)", + "translate": "fn(x: number, y: number)", + "transform": "fn(a: number, b: number, c: number, d: number, e: number, f: number)", + "setTransform": "fn(a: number, b: number, c: number, d: number, e: number, f: number)", + "resetTransform": "fn()", + "globalAlpha": "number", + "globalCompositeOperation": "string", + "imageSmoothingEnabled": "bool", + "strokeStyle": "string", + "fillStyle": "string", + "createLinearGradient": "fn(x0: number, y0: number, x1: number, y1: number) -> ?", + "createPattern": "fn(image: ?, repetition: string) -> ?", + "shadowOffsetX": "number", + "shadowOffsetY": "number", + "shadowBlur": "number", + "shadowColor": "string", + "clearRect": "fn(x: number, y: number, w: number, h: number)", + "fillRect": "fn(x: number, y: number, w: number, h: number)", + "strokeRect": "fn(x: number, y: number, w: number, h: number)", + "fillRule": "string", + "fill": "fn()", + "beginPath": "fn()", + "stroke": "fn()", + "clip": "fn()", + "resetClip": "fn()", + "fillText": "fn(text: string, x: number, y: number, maxWidth: number)", + "strokeText": "fn(text: string, x: number, y: number, maxWidth: number)", + "measureText": "fn(text: string) -> ?", + "drawImage": "fn(image: ?, dx: number, dy: number)", + "createImageData": "fn(sw: number, sh: number) -> ?", + "getImageData": "fn(sx: number, sy: number, sw: number, sh: number) -> ?", + "putImageData": "fn(imagedata: ?, dx: number, dy: number)", + "lineWidth": "number", + "lineCap": "string", + "lineJoin": "string", + "miterLimit": "number", + "setLineDash": "fn(segments: [number])", + "getLineDash": "fn() -> [number]", + "lineDashOffset": "number", + "font": "string", + "textAlign": "string", + "textBaseline": "string", + "direction": "string", + "closePath": "fn()", + "moveTo": "fn(x: number, y: number)", + "lineTo": "fn(x: number, y: number)", + "quadraticCurveTo": "fn(cpx: number, cpy: number, x: number, y: number)", + "bezierCurveTo": "fn(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number)", + "arcTo": "fn(x1: number, y1: number, x2: number, y2: number, radius: number)", + "rect": "fn(x: number, y: number, w: number, h: number)", + "arc": "fn(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: bool)", + "ellipse": "fn(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: bool)" + } + }, + { + "!name": "ecmascript", + "Infinity": { + "!type": "number", + "!doc": "代表无穷大的数值." + }, + "undefined": { + "!type": "?", + "!doc": "该值未定义.", + }, + "NaN": { + "!type": "number", + "!doc": "代表非数字的值." + }, + "Object": { + "!type": "fn()", + "create": { + "!type": "fn(proto: ?) -> !custom:Object_create", + "!doc": "使用指定的原型对象和属性创建一个新对象.", + }, + "defineProperty": { + "!type": "fn(obj: ?, prop: string, desc: propertyDescriptor) -> !custom:Object_defineProperty", + "!doc": "直接在对象上定义新属性,或修改对象上的现有属性,然后返回对象.如果想了解如何将Object.defineProperty方法与类似二进制标志的语法一起使用,请参阅本文." + }, + "keys": { + "!type": "fn(obj: ?) -> [string]", + "!doc": "返回一个给定对象自己的可枚举属性的数组,其顺序与for-in循环所提供的顺序相同(不同之处在于for-in循环也枚举了原型链中的属性). " + }, + "assign": { + "!type": "fn(target: ?, source: ?, source?: ?) -> !0", + "!effects": ["copy !1 !0", "copy !2 !0", "copy !3 !0"], + "!doc": " Object.assign()方法用于将所有可枚举的自身属性的值从一个或多个源对象复制到目标对象.它将返回目标对象.,", + }, + "prototype": { + "!stdProto": "Object", + "toString": { + "!type": "fn() -> string", + "!doc": "返回表示对象的字符串." + }, + "hasOwnProperty": { + "!type": "fn(prop: string) -> bool", + "!doc": "返回一个布尔值,指示对象是否具有指定的属性.", + } + }, + "!doc": "创建对象包装器.", + }, + "Function": { + "!type": "fn(body: string) -> fn()", + "prototype": { + "!stdProto": "Function", + "apply": { + "!type": "fn(this: ?, args: [?])", + "!effects": [ + "call and return !this this=!0 !1. !1. !1." + ], + "!doc": "调用具有给定值的函数,并以数组(或类似对象的数组)形式提供参数.", + }, + "call": { + "!type": "fn(this: ?, args?: ?) -> !this.!ret", + "!effects": [ + "call and return !this this=!0 !1 !2 !3 !4" + ], + "!doc": "调用具有给定值和单独提供的参数的函数.", + }, + "bind": { + "!type": "fn(this: ?, args?: ?) -> !custom:Function_bind", + "!doc": "创建一个新函数,该函数在被调用时将其this关键字设置为提供的值,并在调用新函数时提供给定的参数序列.", + }, + "prototype": "?" + }, + "!doc": " JavaScript中的每个函数实际上都是一个Function对象." + }, + "Array": { + "!type": "fn(size: number) -> !custom:Array_ctor", + "isArray": { + "!type": "fn(value: ?) -> bool", + "!doc": "如果对象是数组,则返回true,否则返回false.", + }, + "from": { + "!type": "fn(arrayLike: ?, mapFn?: fn(elt: ?, i: number) -> ?, thisArg?: ?) -> [!0.]", + "!effects": [ + "call !1 this=!2 !0. number" + ], + "!doc": " Array.from()方法从类似数组或可迭代的对象创建一个新的Array实例.,", + }, + "of": { + "!type": "fn(elementN: ?) -> [!0]", + "!doc": " Array.of()方法创建一个新的Array实例,该实例具有可变数量的参数,而不考虑参数的数量或类型.,", + }, + "prototype": { + "!stdProto": "Array", + "length": { + "!type": "number", + "!doc": "一个无符号的32位整数,指定数组中的元素数.", + }, + "concat": { + "!type": "fn(other: [?]) -> !this", + "!doc": "返回一个新数组,该数组由该数组与其他数组和/或值组成.", + }, + "join": { + "!type": "fn(separator?: string) -> string", + "!doc": "将数组的所有元素连接到字符串中." + }, + "splice": { + "!type": "fn(pos: number, amount: number, newelt?: ?) -> [?]", + "!doc": "更改数组的内容,在删除旧元素的同时添加新元素.", + }, + "pop": { + "!type": "fn() -> !this.", + "!doc": "从数组中删除最后一个元素并返回该元素.", + }, + "push": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this." + ], + "!doc": "通过添加给定元素并返回数组的新长度来更改数组.", + }, + "shift": { + "!type": "fn() -> !this.", + "!doc": "从数组中删除第一个元素并返回该元素.此方法更改数组的长度.", + }, + "unshift": { + "!type": "fn(newelt: ?) -> number", + "!effects": [ + "propagate !0 !this." + ], + "!doc": "将一个或多个元素添加到数组的开头,并返回数组的新长度.", + }, + "slice": { + "!type": "fn(from?: number, to?: number) -> !this", + "!doc": "返回数组一部分的浅表副本." + }, + "reverse": { + "!type": "fn()", + "!doc": "就地反转数组.第一个数组元素变为最后一个,而最后一个数组变为第一个.", + }, + "sort": { + "!type": "fn(compare?: fn(a: ?, b: ?) -> number)", + "!effects": [ + "call !0 !this. !this." + ], + "!doc": "将数组中的元素排序并返回数组." + }, + "indexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!doc": "返回在数组中可以找到给定元素的第一个索引;如果不存在,则返回-1.", + }, + "lastIndexOf": { + "!type": "fn(elt: ?, from?: number) -> number", + "!doc": "返回在数组中找到给定元素的最后一个索引,如果不存在则返回-1.从fromIndex开始向后搜索数组.", + }, + "filter": { + "!type": "fn(test: fn(elt: ?, i: number, array: +Array) -> bool, context?: ?) -> !this", + "!effects": [ + "call !0 this=!1 !this. number !this" + ], + "!doc": "创建一个新数组,其中包含所有通过提供的功能实现的测试的元素.", + }, + "forEach": { + "!type": "fn(f: fn(elt: ?, i: number, array: +Array), context?: ?)", + "!effects": [ + "call !0 this=!1 !this. number !this" + ], + "!doc": "每个数组元素执行一次提供的功能." + }, + "map": { + "!type": "fn(f: fn(elt: ?, i: number, array: +Array) -> ?, context?: ?) -> [!0.!ret]", + "!effects": [ + "call !0 this=!1 !this. number !this" + ], + "!doc": "创建一个新数组,其结果是对该数组中的每个元素调用提供的函数.", + }, + "reduce": { + "!type": "fn(combine: fn(sum: ?, elt: ?, i: number, array: +Array) -> ?, init?: ?) -> !0.!ret", + "!effects": [ + "call !0 !1 !this. number !this" + ], + "!doc": "对一个累加器和数组的每个值(从左到右)应用一个函数,以将其减小为单个值.", + }, + "fill": { + "!type": "fn(value: ?, start?: number, end?: number) -> !this", + "!doc": " fill()方法使用静态值填充数组的所有元素,从开始索引到结束索引.,", + }, + "find": { + "!type": "fn(callback: fn(element: ?, index: number, array: [?]) -> bool, thisArg?: ?) -> !this.", + "!effects": ["call !0 this=!2 !this. number"], + "!doc": "如果数组中的元素满足提供的测试功能,则find()方法将在数组中返回一个值.否则,返回undefined.,", + }, + "findIndex": { + "!type": "fn(callback: fn(element: ?, index: number, array: [?]), thisArg?: ?) -> number", + "!effects": ["call !0 this=!2 !this. number"], + "!doc": "如果数组中的元素满足提供的测试功能,则findIndex()方法将返回数组中的索引.否则返回-1.,", + }, + "keys": { + "!type": "fn() -> +iter[:t=number]", + "!doc": " keys()方法返回一个新的数组迭代器,其中包含数组中每个索引的键.,", + }, + "values": { + "!type": "fn() -> +iter[:t=!this.]", + "!doc": " values()方法返回一个新的Array Iterator对象,该对象包含数组中每个索引的值.,", + }, + "includes": { + "!type": "fn(value: ?, fromIndex?: number) -> bool", + "!doc": "确定数组是否包含某个元素,并根据需要返回true或false.,", + } + }, + "!doc": " JavaScript Array全局对象是数组的构造函数,这些数组是高级的,类似于列表的对象.", + }, + "String": { + "!type": "fn(value: ?) -> string", + "prototype": { + "!stdProto": "String", + "length": { + "!type": "number", + "!doc": "表示字符串的长度." + }, + "": "string", + "charAt": { + "!type": "fn(i: number) -> string", + "!doc": "从字符串中返回指定的字符.", + }, + "charCodeAt": { + "!type": "fn(i: number) -> number", + "!doc": "返回给定索引处字符的数字Unicode值(Unicode代码点> 0x10000除外).", + }, + "indexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!doc": "返回指定值首次出现的调用String对象中的索引,从fromIndex开始搜索,\ n如果未找到该值,则返回-1.", + }, + "lastIndexOf": { + "!type": "fn(char: string, from?: number) -> number", + "!doc": "返回指定值最后一次出现的调用String对象内的索引,如果未找到则返回-1.从fromIndex开始向后搜索调用字符串.", + }, + "substring": { + "!type": "fn(from: number, to?: number) -> string", + "!doc": "返回一个索引与另一个索引之间或字符串末尾的字符串子集.", + }, + "substr": { + "!type": "fn(from: number, length?: number) -> string", + "!doc": "以指定的字符数返回从指定位置开始的字符串中的字符.", + }, + "slice": { + "!type": "fn(from: number, to?: number) -> string", + "!doc": "提取字符串的一部分并返回新的字符串.", + }, + "padStart": { + "!type": "fn(targetLength: number, padString?: string) -> string", + "!doc": "用另一个字符串(如果需要,重复)填充当前字符串,以使结果字符串达到给定的长度.", + }, + "padEnd": { + "!type": "fn(targetLength: number, padString?: string) -> string", + "!doc": "用给定的字符串(如果需要,重复)填充当前字符串,以使结果字符串达到给定的长度.", + }, + "trim": { + "!type": "fn() -> string", + "!doc": "从字符串的两端删除空格.", + }, + "trimStart": { + "!type": "fn() -> string", + "!doc": "从字符串的开头删除空格.", + }, + "trimEnd": { + "!type": "fn() -> string", + "!doc": "从字符串末尾删除空格.", + }, + "toUpperCase": { + "!type": "fn() -> string", + "!doc": "返回转换为大写的调用字符串值." + }, + "toLowerCase": { + "!type": "fn() -> string", + "!doc": "返回转换为小写的调用字符串值." + }, + "split": { + "!type": "fn(pattern?: string|+RegExp, limit?: number) -> [string]", + "!doc": "通过将字符串分成子字符串,将String对象拆分为字符串数组.", + }, + "concat": { + "!type": "fn(other: string) -> string", + "!doc": "将两个或多个字符串的文本合并,并返回一个新字符串." + }, + "match": { + "!type": "fn(pattern: +RegExp) -> [string]", + "!doc": "用于将字符串与正则表达式匹配时用于检索匹配.", + }, + "replace": { + "!type": "fn(pattern: string|+RegExp, replacement: string) -> string", + "!doc": "返回一个新字符串,该字符串的某个或所有匹配项都由替换项替换.该模式可以是字符串或RegExp,并且替换项可以是字符串或每个匹配项将调用的函数. " + }, + "endsWith": { + "!type": "fn(searchString: string, position?: number) -> bool", + "!doc": " endsWith()方法确定一个字符串是否以另一个字符串的字符结尾,并根据需要返回true或false.,", + }, + "startsWith": { + "!type": "fn(searchString: string, position?: number) -> bool", + "!doc": " startsWith()方法确定一个字符串是否以另一个字符串的字符开头,并根据需要返回true或false.,", + } + }, + "!doc": " String全局对象是字符串或字符序列的构造函数.", + }, + "Number": { + "!type": "fn(value: ?) -> number", + "MAX_VALUE": { + "!type": "number", + "!doc": " JavaScript中可表示的最大数值." + }, + "MIN_VALUE": { + "!type": "number", + "!doc": " JavaScript中可表示的最小正数值." + }, + "POSITIVE_INFINITY": { + "!type": "number", + "!doc": "代表正无穷大值的值." + }, + "NEGATIVE_INFINITY": { + "!type": "number", + "!doc": "代表负无穷大值的值." + }, + "prototype": { + "!stdProto": "Number", + "toString": { + "!type": "fn(radix?: number) -> string", + "!doc": "返回代表指定Number对象的字符串" + }, + "toFixed": { + "!type": "fn(digits: number) -> string", + "!doc": "使用定点符号格式化数字" + }, + "toExponential": { + "!type": "fn(digits: number) -> string", + "!doc": "返回以指数表示形式表示Number对象的字符串" + }, + "toPrecision": { + "!type": "fn(digits: number) -> string", + "!doc": " toPrecision()方法返回一个字符串,该数字表示指定精度的数字.", + } + }, + "EPSILON": { + "!type": "number", + "!doc": " Number.EPSILON属性表示一个数值与可以表示为Number的最小值之间的差异.,", + }, + "MAX_SAFE_INTEGER": { + "!type": "number", + "!doc": " Number.MAX_SAFE_INTEGER常量表示JavaScript中的最大安全整数(2 ^ 53-1).,", + }, + "MIN_SAFE_INTEGER": { + "!type": "number", + "!doc": " Number.MIN_SAFE_INTEGER常量表示JavaScript(-(2 ^ 53-1))中的最小安全整数.,", + }, + "isFinite": { + "!type": "fn(testValue: ?) -> bool", + "!doc": " Number.isFinite()方法确定传递的值是否为有限值.,", + }, + "isInteger": { + "!type": "fn(testValue: ?) -> bool", + "!doc": " Number.isInteger()方法确定传递的值是否为整数.,", + }, + "isNaN": { + "!type": "fn(testValue: ?) -> bool", + "!doc": " Number.isNaN()方法确定传递的值是否为NaN.原始全局isNaN()的更可靠的版本.,", + }, + "isSafeInteger": { + "!type": "fn(testValue: ?) -> bool", + "!doc": " Number.isSafeInteger()方法确定所提供的值是否是一个安全整数的数字.安全整数是该数字的整数." , + }, + "parseFloat": { + "!type": "fn(string: string) -> number", + "!doc": " Number.parseFloat()方法解析字符串参数并返回浮点数.,", + }, + "parseInt": { + "!type": "fn(string: string, radix?: number) -> number", + "!doc": " Number.parseInt()方法解析字符串参数并返回指定基数或基数的整数.,", + }, + "!doc": " Number JavaScript对象是一个包装器对象,允许您使用数值.使用Number()构造函数创建Number对象.", + }, + "Boolean": { + "!type": "fn(value: ?) -> bool", + "prototype": { + "!stdProto": "Boolean" + }, + "!doc": "布尔对象是布尔值的对象包装.", + }, + "RegExp": { + "!type": "fn(source: string, flags?: string)", + "prototype": { + "!stdProto": "RegExp", + "exec": { + "!type": "fn(input: string) -> [string]", + "!doc": "搜索指定字符串中的匹配项.返回结果数组,或者为null.", + }, + "test": { + "!type": "fn(input: string) -> bool", + "!doc": "执行正则表达式和指定字符串之间的匹配搜索.返回true或false.", + } + }, + "!doc": "创建正则表达式对象以将文本与模式匹配.", + }, + "parseInt": { + "!type": "fn(string: string, radix?: number) -> number", + "!doc": "解析字符串参数并返回指定基数或基数的整数." + }, + "parseFloat": { + "!type": "fn(string: string) -> number", + "!doc": "解析字符串参数并返回浮点数." + }, + "isNaN": { + "!type": "fn(value: number) -> bool", + "!doc": "确定值是否为NaN.请注意,此函数已损坏.您可能对ECMAScript 6 Number.isNaN感兴趣.", + }, + "isFinite": { + "!type": "fn(value: number) -> bool", + "!doc": "确定传递的值是否为有限数字." + }, + "eval": { + "!type": "fn(code: string) -> ?", + "!doc": "评估以字符串形式表示的JavaScript代码." + }, + "encodeURI": { + "!type": "fn(uri: string) -> string", + "!doc": "通过用表示字符的UTF-8编码的一个,两个,三个或四个转义序列替换某些字符的每个实例来编码统一资源标识符(URI)(对于字符而言将仅是四个转义序列由两个\"代理\"字符组成).", + }, + "encodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!doc": "通过用表示字符的UTF-8编码的一个,两个,三个或四个转义序列替换某些字符的每个实例来编码统一资源标识符(URI)组件(对于由两个\"代理\"字符组成的字符).", + }, + "decodeURI": { + "!type": "fn(uri: string) -> string", + "!doc": "解码以前由encodeURI或类似例程创建的统一资源标识符(URI).", + }, + "decodeURIComponent": { + "!type": "fn(uri: string) -> string", + "!doc": "解码以前由encodeURIComponent或类似例程创建的统一资源标识符(URI)组件.", + }, + "Math": { + "E": { + "!type": "number", + "!doc": "自然对数的底数,e约为2.718." + }, + "LN2": { + "!type": "number", + "!doc": " 2的自然对数,大约为0.693." + }, + "LN10": { + "!type": "number", + "!doc": " 10的自然对数,大约为2.302." + }, + "LOG2E": { + "!type": "number", + "!doc": " E的以2为底的对数(大约1.442).", + }, + "LOG10E": { + "!type": "number", + "!doc": " E的以10为底的对数(约0.434)." + }, + "SQRT1_2": { + "!type": "number", + "!doc": " 1/2的平方根;等效于2的平方根上的1,大约为0.707." + }, + "SQRT2": { + "!type": "number", + "!doc": " 2的平方根,大约为1.414." + }, + "PI": { + "!type": "number", + "!doc": "圆的周长与其直径之比,大约为3.14159." + }, + "abs": { + "!type": "fn(number) -> number", + "!doc": "返回数字的绝对值." + }, + "cos": { + "!type": "fn(number) -> number", + "!doc": "返回数字的余弦." + }, + "sin": { + "!type": "fn(number) -> number", + "!doc": "返回数字的正弦." + }, + "tan": { + "!type": "fn(number) -> number", + "!doc": "返回数字的正切值." + }, + "acos": { + "!type": "fn(number) -> number", + "!doc": "返回数字的反余弦(以弧度为单位)." + }, + "asin": { + "!type": "fn(number) -> number", + "!doc": "返回数字的反正弦(以弧度为单位)." + }, + "atan": { + "!type": "fn(number) -> number", + "!doc": "返回数字的反正切(以弧度为单位)." + }, + "atan2": { + "!type": "fn(y: number, x: number) -> number", + "!doc": "返回其参数商的反正切值." + }, + "ceil": { + "!type": "fn(number) -> number", + "!doc": "返回大于或等于数字的最小整数." + }, + "floor": { + "!type": "fn(number) -> number", + "!doc": "返回小于或等于数字的最大整数." + }, + "round": { + "!type": "fn(number) -> number", + "!doc": "返回四舍五入到最接近整数的数字的值." + }, + "exp": { + "!type": "fn(number) -> number", + "!doc": "返回E ^ x,其中x是自变量,E是欧拉常数,自然对数的底." + }, + "log": { + "!type": "fn(number) -> number", + "!doc": "返回数字的自然对数(以E为底).", + }, + "sqrt": { + "!type": "fn(number) -> number", + "!doc": "返回数字的平方根." + }, + "pow": { + "!type": "fn(number, number) -> number", + "!doc": "将基数返回指数幂,即baseexponent." + }, + "max": { + "!type": "fn(number, number) -> number", + "!doc": "返回零个或多个数字中的最大值." + }, + "min": { + "!type": "fn(number, number) -> number", + "!doc": "返回零个或多个数字中的最小值." + }, + "random": { + "!type": "fn() -> number", + "!doc": "返回一个浮点伪随机数,范围为[0,1),即从0(包括)到不包括1(排除),然后您可以缩放到所需的值范围." + }, + "log10": { + "!type": "fn(x: number) -> number", + "!doc": " Math.log10()函数返回数字的以10为底的对数." , + }, + "log2": { + "!type": "fn(x: number) -> number", + "!doc": " Math.log2()函数返回数字的以2为底的对数." , + }, + "sign": { + "!type": "fn(x: number) -> number", + "!doc": " Math.sign()函数返回数字的符号,指示数字是正数,负数还是零.,", + }, + "trunc": { + "!type": "fn(x: number) -> number", + "!doc": " Math.trunc()函数通过删除任何小数位来返回数字的整数部分.它不舍入任何数字.该函数可以用floor()和ceil()函数表示: ,", + }, + "!doc": "一个内置对象,具有用于数学常数和函数的属性和方法.", + }, + "JSON": { + "parse": { + "!type": "fn(json: string, reviver?: fn(key: string, value: ?) -> ?) -> ?", + "!doc": "将字符串解析为JSON,可以选择转换解析产生的值.", + }, + "stringify": { + "!type": "fn(value: ?, replacer?: fn(key: string, value: ?) -> ?, space?: string|number) -> string", + "!doc": "将值转换为JSON,如果指定了replacer函数,则可以选择替换值,如果指定了replacer数组,则可以选择仅包括指定的属性.", + }, + "!doc": " JSON(JavaScript对象表示法)是一种数据交换格式.尽管它不是严格的子集,但它非常类似于JavaScript语法的子集.(有关详细信息,请参见JavaScript参考中的JSON.)在编写任何类型的基于JavaScript的应用程序(包括网站和浏览器扩展程序)时非常有用.例如,您可以将JSON格式的用户信息存储在cookie中,或者可以将扩展名首选项以JSON形式存储在字符串值的浏览器首选项中." + } + }, + { + "!name": "core", + "!define": { + "image": { + "!doc": "图片信息", + "width": "number", + "height": "number", + "src": "string" + }, + "audio": { + "!doc": "音乐音效信息", + "currentTime": "number", + "play": "fn()", + "pause": "fn()", + "paused": "bool", + "duration": "number", + "volume": "number", + }, + "flag": { + "!doc": "当前变量", + "hard": { + "!type": "number", + "!doc": "当前难度编号" + }, + "hatred":{ + "!type": "number", + "!doc": "当前仇恨值" + }, + "poison":{ + "!type": "bool", + "!doc": "是否处于中毒状态" + }, + "weak":{ + "!type": "number", + "!doc": "是否处于衰弱状态" + }, + "curse":{ + "!type": "number", + "!doc": "是否处于诅咒状态" + }, + "no_zone": { + "!type": "bool", + "!doc": "无视领域伤害" + }, + "no_repulse": { + "!type": "bool", + "!doc": "无视阻击伤害" + }, + "no_lasel": { + "!type": "bool", + "!doc": "无视激光伤害" + }, + "no_ambush": { + "!type": "bool", + "!doc": "无视捕捉" + }, + "__bgm__": { + "!type": "string", + "!doc": "背景音乐" + }, + "__weather__": { + "!doc": "天气" + }, + "__color__": { + "!doc": "色调" + }, + "__volume__": { + "!type": "number", + "!doc": "音量" + }, + "skill": { + "!type": "number", + "!doc": "当前开启的技能编号" + }, + "skillName": { + "!type": "string", + "!doc": "当前开启的技能名" + }, + "input": { + "!type": "string|number", + "!doc": "等待用户输入后的存放值" + }, + "type": { + "!type": "number", + "!doc": "等待用户操作后获得的操作类型" + }, + "keycode": { + "!type": "number", + "!doc": "等待用户操作后用户按键的键值" + }, + "x": { + "!type": "number", + "!doc": "等待用户操作后用户点击的网格横坐标" + }, + "y": { + "!type": "number", + "!doc": "等待用户操作后用户点击的网格纵坐标" + }, + "px": { + "!type": "number", + "!doc": "等待用户操作后用户点击的像素横坐标" + }, + "py": { + "!type": "number", + "!doc": "等待用户操作后用户点击的像素纵坐标" + }, + "__visited__": { + "!doc": "当前访问过的楼层" + }, + "cannotMoveDirectly": { + "!type": "bool", + "!doc": "当前是否全局不可瞬移" + }, + }, + "loc": { + "!doc": "勇士坐标", + "x": "number", + "y": "number", + "direction": "string" + }, + "hero": { + "!doc": "勇士当前属性", + "image": { + "!type": "string", + "!doc": "行走图" + }, + "animate": { + "!type": "bool", + "!doc": "是否开启帧动画" + }, + "name": { + "!type": "string", + "!doc": "勇士名" + }, + "lv": { + "!type": "number", + "!doc": "勇士等级" + }, + "hpmax": { + "!type": "number", + "!doc": "勇士生命上限" + }, + "hp": { + "!type": "number", + "!doc": "勇士当前生命值" + }, + "atk": { + "!type": "number", + "!doc": "勇士当前攻击力" + }, + "def": { + "!type": "number", + "!doc": "勇士当前防御力" + }, + "manamax": { + "!type": "number", + "!doc": "勇士当前魔力上限,负数无效" + }, + "mana": { + "!type": "number", + "!doc": "勇士当前魔力值" + }, + "mdef": { + "!type": "number", + "!doc": "勇士当前护盾值" + }, + "money": { + "!type": "number", + "!doc": "勇士当前金币" + }, + "exp": { + "!type": "number", + "!doc": "勇士当前经验" + }, + "equipment": { + "!type": "[string]", + "!doc": "勇士当前装备" + }, + "items": { + "!doc": "勇士当前道具", + "constants": { + "!doc": "永久道具" + }, + "tools": { + "!doc": "消耗道具", + "yellowKey": { + "!type": "number", + "!doc": "黄钥匙个数" + }, + "blueKey": { + "!type": "number", + "!doc": "蓝钥匙个数" + }, + "redKey": { + "!type": "number", + "!doc": "红钥匙个数" + }, + "greenKey": { + "!type": "number", + "!doc": "绿钥匙个数" + }, + "steelKey": { + "!type": "number", + "!doc": "铁门钥匙个数" + }, + }, + "equips": { + "!doc": "未装备上的装备" + }, + }, + "loc": { + "!doc": "勇士当前坐标和朝向", + "!type": "loc", + }, + "flags": { + "!type": "flag", + "!doc": "当前游戏中用到的变量" + }, + "followers": { + "!type": "[?]", + "!doc": "跟随者信息" + }, + "steps": { + "!type": "number", + "!doc": "当前步数" + } + }, + "block": { + "!doc": "地图图块信息", + "x": { + "!type": "number", + "!doc": "图块的x坐标" + }, + "y": { + "!type": "number", + "!doc": "图块的y坐标" + }, + "id": { + "!type": "number", + "!doc": "图块的数字" + }, + "event": { + "!doc": "图块上的事件信息", + "id": { + "!type": "string", + "!doc": "图块的ID" + }, + "cls": { + "!type": "string", + "!doc": "图块的类别,一般为所在图片名去掉后缀" + }, + "disabled": { + "!type": "bool", + "!doc": "启用状态" + } + } + }, + "blockInfo": { + "!doc": "图块的更多信息", + "animate": { + "!type": "number", + "!doc": "动画帧数" + }, + "cls": { + "!type": "string", + "!doc": "图块类别" + }, + "faceIds": { + "!doc": "行走图朝向", + "up": "string", + "down": "string", + "left": "string", + "right": "string" + }, + "height": { + "!type": "number", + "!doc": "图块高度" + }, + "id": { + "!type": "string", + "!doc": "图块ID" + }, + "image": { + "!type": "image", + "!doc": "图块所在的图片" + }, + "name": { + "!type": "string", + "!doc": "图块名称" + }, + "number": { + "!type": "number", + "!doc": "图块使用的数字" + }, + "posX": { + "!type": "number", + "!doc": "图块在图片上的横坐标" + }, + "posY": { + "!type": "number", + "!doc": "图块在图片上的纵坐标" + }, + }, + "enemy": { + "!doc": "怪物信息", + "id": { + "!type": "string", + "!doc": "怪物ID" + }, + "name": { + "!type": "string", + "!doc": "怪物名称" + }, + "displayIdInBook": { + "!type": "string", + "!doc": "在怪物手册映射ID" + }, + "hp": { + "!type": "number", + "!doc": "怪物生命值" + }, + "atk": { + "!type": "number", + "!doc": "怪物攻击" + }, + "def": { + "!type": "number", + "!doc": "怪物防御" + }, + "money": { + "!type": "number", + "!doc": "怪物金币" + }, + "exp": { + "!type": "number", + "!doc": "怪物经验" + }, + "special": { + "!type": "[number]", + "!doc": "怪物特殊属性" + }, + "point": { + "!type": "number", + "!doc": "怪物加点" + }, + "value": { + "!type": "number", + "!doc": "怪物特殊属性值:阻激夹域伤害值;吸血比例;光环增加生命比例" + }, + "zoneSquare": { + "!type": "bool", + "!doc": "领域怪是否九宫格伤害;区域光环是否九宫格范围" + }, + "range": { + "!type": "number", + "!doc": "领域伤害的范围;区域光环范围" + }, + "notBomb": { + "!type": "bool", + "!doc": "怪物不可炸" + }, + "n": { + "!type": "number", + "!doc": "多连击的连击数;净化比例" + }, + "add": { + "!type": "bool", + "!doc": "吸血是否加到自身;光环是否叠加" + }, + "atkValue": { + "!type": "number", + "!doc": "反击比例;退化扣除攻击;光环增加攻击;" + }, + "defValue": { + "!type": "number", + "!doc": "破甲比例;退化扣除防御;光环增加防御" + }, + "damage": { + "!type": "number", + "!doc": "固伤值" + }, + }, + "item":{ + "!doc": "道具信息", + "id": { + "!type": "string", + "!doc": "道具ID" + }, + "cls": { + "!type": "string", + "!doc": "道具类型" + }, + "name": { + "!type": "string", + "!doc": "道具名称" + }, + "text": { + "!type": "string", + "!doc": "道具描述" + }, + "hideInToolbox": { + "!type": "bool", + "!doc": "不显示在道具栏" + }, + "equip": { + "!doc": "装备属性", + "type": { + "!type": "number|string", + "!doc": "装备类型" + }, + "animate": { + "!type": "string", + "!doc": "装备动画" + }, + "value": { + "!doc": "数值加成" + }, + "percentage": { + "!doc": "比例加成" + } + }, + "hideInReplay": { + "!type": "bool", + "!doc": "回放不绘制道具栏" + }, + }, + "floor": { + "!doc": "楼层信息", + "floorId": { + "!type": "string", + "!doc": "楼层ID" + }, + "title": { + "!type": "string", + "!doc": "楼层中文名" + }, + "name": { + "!type": "string", + "!doc": "状态栏显示值" + }, + "width": { + "!type": "number", + "!doc": "地图宽" + }, + "height": { + "!type": "number", + "!doc": "地图高" + }, + "canFlyTo": { + "!type": "bool", + "!doc": "该楼是否可以楼传,包括飞来和飞走" + }, + "canUseQuickShop": { + "!type": "bool", + "!doc": "该楼是否可快捷商店" + }, + "cannotViewMap": { + "!type": "bool", + "!doc": "该层是否不允许被浏览地图看到,也不统计" + }, + "cannotMoveDirectly": { + "!type": "bool", + "!doc": "该层是否不允许瞬间移动" + }, + "upFloor": { + "!type": "[number]", + "!doc": "上楼点" + }, + "downFloor": { + "!type": "[number]", + "!doc": "下楼点" + }, + "flyPoint": { + "!type": "[number]", + "!doc": "楼传落点" + }, + "color": { + "!doc": "楼层色调" + }, + "weather": { + "!doc": "楼层天气" + }, + "bgm": { + "!type": "string", + "!doc": "楼层背景音乐" + }, + "ratio": { + "!type": "number", + "!doc": "宝石/血瓶效果" + }, + "map": { + "!type": "[[number]]", + "!doc": "地图数据" + }, + "blocks": { + "!type": "[block]", + "!doc": "本层图块信息" + } + }, + "animate": { + "!doc": "动画信息", + "se": { + "!type": "string", + "!doc": "动画音效" + } + } + }, + "core": { + "!doc": "核心游戏控制", + "__SIZE__": { + "!type": "number", + "!doc": "窗口宽度,为13或15" + }, + "__PIXELS__": { + "!type": "number", + "!doc": "窗口像素宽度,为416或480" + }, + "__HALF_SIZE__": { + "!type": "number", + "!doc": "窗口宽度的一半,为6或7" + }, + "material": { + "!doc": "游戏所用到的资源", + "animates": { + "!doc": "注册的动画" + }, + "images": { + "!doc": "注册的图片" + }, + "bgms": { + "!doc": "注册的背景音乐" + }, + "sounds": { + "!doc": "注册的音效" + }, + "enemys": { + "!doc": "怪物定义", + }, + "items": { + "!doc": "道具定义" + } + }, + "timeout": { + "!doc": "当前异步事件句柄" + }, + "interval": { + "!doc": "当前异步事件延时" + }, + "animateFrame": { + "!doc": "当前各个帧动画" + }, + "musicStatus": { + "!doc": "音乐音效状态", + "bgmStatus": { + "!type": "bool", + "!doc": "是否播放BGM" + }, + "soundStatus": { + "!type": "bool", + "!doc": "是否播放SE" + }, + "playingBgm": { + "!type": "string", + "!doc": "正在播放的bgm" + }, + "lastBgm": { + "!type": "string", + "!doc": "上次播放的bgm" + }, + "playingSounds": { + "!doc": "正在播放的SE" + }, + "volume": { + "!type": "number", + "!doc": "当前bgm音量" + } + }, + "platform": { + "!doc": "平台信息", + "isPC": "bool", + "isAndroid": "bool", + "isIOS": "bool", + "useLocalForage": "bool" + }, + "domStyle": { + "!doc": "界面样式", + "scale": { + "!type": "number", + "!doc": "当前界面放缩比例", + }, + "availableScale": { + "!type": "[number]", + "!doc": "当前界面支持的放缩比例" + }, + "isVertical": { + "!type": "bool", + "!doc": "当前是否是竖屏" + }, + "showStatusBar": { + "!type": "bool", + "!doc": "当前是否显示状态栏" + }, + "toolbarBtn": { + "!type": "bool", + "!doc": "当前工具栏是否是1-8的按钮" + }, + }, + "bigmap": { + "!doc": "大地图信息", + "canvas": { + "!type": "[string]", + "!doc": "大地图的画布" + }, + "width": { + "!type": "number", + "!doc": "大地图高度" + }, + "height": { + "!type": "number", + "!doc": "大地图宽度" + }, + "offsetX": { + "!type": "number", + "!doc": "大地图视角横向偏移量" + }, + "offsetY": { + "!type": "number", + "!doc": "大地图视角纵向偏移量" + }, + "tempCanvas": { + "!type": "CanvasRenderingContext2D", + "!doc": "临时画布" + } + }, + "saves": { + "!doc": "当前存档信息" + }, + "dymCanvas": { + "!doc": "各个自定义画布" + }, + "statusBar": { + "!doc": "状态栏信息" + }, + "canvas": { + "!doc": "系统画布" + }, + "flags": { + "!doc": "系统开关" + }, + "values": { + "!doc": "全局数值,如毒衰效果" + }, + "firstData": { + "!doc": "初始属性,如出生点" + }, + "status": { + "!doc": "状态信息", + "hero": { + "!type": "hero", + "!doc": "勇士信息" + }, + "automaticRoute": { + "!doc": "自动寻路信息" + }, + "bgmaps": { + "!doc": "各地图背景层" + }, + "fgmaps": { + "!doc": "各地图前景层" + }, + "boxAnimateObjs": { + "!doc": "(手册和剧情文本的)帧动画对象" + }, + "checkBlock": { + "!doc": "阻激夹域捕捉信息", + "damage": { + "!doc": "每个点的伤害信息" + }, + "type": { + "!doc": "每个点的伤害类型" + }, + "repluse": { + "!doc": "每个点的阻击信息" + }, + "ambush": { + "!doc": "每个点的捕捉信息" + }, + "needCache": { + "!type": "bool", + "!doc": "该楼层是否需要计算缓存" + }, + "cache": { + "!doc": "每个点的光环缓存" + }, + }, + "ctrlDown": { + "!type": "bool", + "!doc": "Ctrl键是否被按下" + }, + "curtainColor": { + "!doc": "当前画面色调" + }, + "event": { + "!doc": "当前事件", + "data": { + "!doc": "事件信息,如坐标等" + }, + "id": { + "!type": "string", + "!doc": "事件类型,如选择项/确认框" + }, + "interval": { + "!type": "number", + "!doc": "打字机效果的定时器" + }, + "selection": { + "!type": "number", + "!doc": "选择项和确认框的当前选中项" + }, + "ui": { + "!doc": "当前事件的界面信息,如楼传/手册/SL" + } + }, + "floorAnimateObjs": { + "!doc": "楼层贴图的帧动画" + }, + "floorId": { + "!type": "string", + "!doc": "当前楼层ID" + }, + "gameOver": { + "!type": "bool", + "!doc": "游戏是否已结束" + }, + "globalAnimateObjs": { + "!doc": "各全局动画" + }, + "globalAnimateStatus": { + "!type": "number", + "!doc": "全局动画的帧状态" + }, + "globalAttribute": { + "!doc": "全局css属性" + }, + "hard": { + "!type": "string", + "!doc": "状态栏一角的难度名" + }, + "downTime": { + "!type": "number", + "!doc": "方向键已按下的时间" + }, + "heroCenter": { + "!doc": "勇士中心像素坐标", + "px": { + "!type": "number", + "!doc": "勇士中心的横坐标" + }, + "py": { + "!type": "number", + "!doc": "勇士中心的纵坐标" + }, + }, + "heroMoving": { + "!type": "number", + "!doc": "勇士行走的状态值" + }, + "heroStop": { + "!type": "bool", + "!doc": "勇士是否已停下" + }, + "holdingKeys": { + "!type": "[number]", + "!doc": "当前按下的键" + }, + "id2number": { + "!doc": "图块ID到数字的对应关系" + }, + "lockControl": { + "!type": "bool", + "!doc": "当前是否是锁定操作状态" + }, + "maps": { + "!doc": "当前各地图信息" + }, + "number2Block": { + "!doc": "数字到图块对象的对应关系" + }, + "openingDoor": { + "!doc": "正在开关的门" + }, + "played": { + "!type": "bool", + "!doc": "当前是否游戏中(不包括标题画面和录像回放)" + }, + "replay": { + "!doc": "当前录像回放信息", + "animate": { + "!type": "bool", + "!doc": "回放是否正处于动画中" + }, + "pausing": { + "!type": "bool", + "!doc": "回放是否暂停中" + }, + "replaying": { + "!type": "bool", + "!doc": "当前是否回放中" + }, + "save": { + "!type": "[]", + "!doc": "录像中的存档" + }, + "speed": { + "!type": "number", + "!doc": "回放速度" + }, + "steps": { + "!type": "number", + "!doc": "回放步数" + }, + "toReplay": { + "!type": "[string]", + "!doc": "待回放的列表" + }, + "totalList": { + "!type": "[string]", + "!doc": "回放总列表" + } + }, + "route": { + "!type": "[string]", + "!doc": "当前录像内容" + }, + "shops": { + "!doc": "全局商店列表" + }, + "textAttribute": { + "!doc": "当前剧情文本属性" + }, + "thisMap": { + "!type": "floor", + "!doc": "当前地图信息" + } + }, + "control": { + "!doc": "游戏控制", + "showStatusBar": { + "!doc": "显示状态栏", + "!type": "fn()" + }, + "startReplay": { + "!doc": "开始播放", + "!type": "fn(list: [string])" + }, + "triggerReplay": { + "!doc": "更改播放状态", + "!type": "fn()" + }, + "screenFlash": { + "!doc": "画面闪烁
例如:core.screenFlash([255, 0, 0, 1], 3); // 红屏一闪而过
color: 一行三列(第四列视为1)或一行四列(第四列若大于1则会被视为1,第四列若填负数则会被视为0)的颜色数组,必填
time: 单次闪烁时长,实际闪烁效果为先花其三分之一的时间渐变到目标色调,再花剩余三分之二的时间渐变回去
times: 闪烁的总次数,不填或填0都视为1
callback: 闪烁全部完毕后的回调函数,可选", + "!type": "fn(color: [number], time: number, times?: number, callback?: fn())" + }, + "setCurtain": { + "!doc": "更改画面色调,不计入存档。如需长期生效请使用core.events._action_setCurtain()函数
例如:core.setCurtain(); // 恢复画面色调,用时四分之三秒
color: 一行三列(第四列视为1)或一行四列(第四列若大于1则会被视为1,第四列若为负数则会被视为0)的颜色数组,不填视为[0, 0, 0, 0]
time: 渐变时间,单位为毫秒。不填视为750ms,负数视为0(无渐变,立即更改)
callback: 更改完毕后的回调函数,可选。事件流中常取core.doAction", + "!type": "fn(color?: [number], time?: number, callback?: fn())" + }, + "updateDamage": { + "!doc": "更新地图显伤
例如:core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)
floorId: 地图id,不填视为当前地图。预览地图时填写
ctx: 绘制到的画布,如果填写了就会画在该画布而不是显伤层", + "!type": "fn(floorId?: string, ctx?: string|CanvasRenderingContext2D)" + }, + "nextX": { + "!doc": "获取主角面前第n格的横坐标
例如:core.closeDoor(core.nextX(), core.nextY(), 'yellowDoor', core.turnHero); // 在主角面前关上一扇黄门,然后主角顺时针旋转90°
n: 目标格与主角的距离,面前为正数,背后为负数,脚下为0,不填视为1", + "!type": "fn(n?: number) -> number" + }, + "nextY": { + "!doc": "获取主角面前第n格的纵坐标
例如:core.jumpHero(core.nextX(2), core.nextY(2)); // 主角向前跃过一格,即跳跃靴道具的使用效果
n: 目标格与主角的距离,面前为正数,背后为负数,脚下为0,不填视为1", + "!type": "fn(n?: number) -> number" + }, + "clearContinueAutomaticRoute": { + "!doc": "清空剩下的自动寻路列表", + "!type": "fn(callback?: fn())" + }, + "updateViewport": { + "!doc": "更新大地图的可见区域", + "!type": "fn()" + }, + "getMappedName": { + "!doc": "获得映射文件名", + "!type": "fn(name: string) -> string" + }, + "addFlag": { + "!doc": "增减一个flag变量,等价于 core.setFlag(name, core.getFlag(name, 0) + value)
例如:core.addFlag('hatred', 1); // 增加1点仇恨值
name: 变量名,支持中文
value: 变量的增量", + "!type": "fn(name: string, value: number)" + }, + "setFlag": { + "!doc": "设置一个flag变量
例如:core.setFlag('poison', true); // 令主角中毒
name: 变量名,支持中文
value: 变量的新值,不填或填null视为删除", + "!type": "fn(name: string, value: ?)" + }, + "viewMapReplay": { + "!doc": "回放录像时浏览地图", + "!type": "fn()" + }, + "stopSound": { + "!doc": "停止所有音频", + "!type": "fn()" + }, + "addGameCanvasTranslate": { + "!doc": "加减画布偏移", + "!type": "fn(x?: number, y?: number)" + }, + "addBuff": { + "!doc": "增减主角某个属性的百分比修正倍率,加减法叠加和抵消。等价于 core.setBuff(name, core.getBuff(name) + value)
例如:core.addBuff('atk', -0.1); // 主角获得一层“攻击力减一成”的负面效果
name: 属性的英文名,请注意只能用于数值类属性哦,否则随后的乘法会得到NaN
value: 倍率的增量", + "!type": "fn(name: string, value: number)" + }, + "drawHero": { + "!doc": "绘制主角和跟随者并重置视野到以主角为中心
例如:core.drawHero(); // 原地绘制主角的静止帧(第一帧)并重置视野,这样调用一般就是用来重置视野
status: 绘制第几帧(默认支持1、2、4,推荐在project\\icons.js中把第三帧也注册了,这里预留了一个'midFoot'作为其枚举值),不填视为静止帧(第一帧)。
offset: 相对主角逻辑位置的偏移量,不填视为无偏移。用于绘制行走中的主角(正数表示前进,负数表示后退,但跟随者的后退很难看)或表现一些特殊的演出效果", + "!type": "fn(status?: string, offset?: number, frame?: number)" + }, + "pauseBgm": { + "!doc": "暂停背景音乐的播放", + "!type": "fn()" + }, + "setReplaySpeed": { + "!doc": "设置播放速度", + "!type": "fn(speed: number)" + }, + "pauseReplay": { + "!doc": "暂停播放", + "!type": "fn()" + }, + "doSL": { + "!doc": "实际进行存读档事件", + "!type": "fn(id?: string, type?: string)" + }, + "setStatus": { + "!doc": "设置主角的某个属性
例如:core.setStatus('atk', 100); // 设置攻击力为100
name: 属性的英文名,其中'x'、'y'和'direction'会被特殊处理为 core.setHeroLoc(name, value),其他的会直接对 core.status.hero[name] 赋值
value: 属性的新值", + "!type": "fn(name: string, value: number)" + }, + "setAutomaticRoute": { + "!doc": "半自动寻路,用于鼠标或手指拖动
例如:core.setAutomaticRoute(0, 0, [{direction: \"right\", x: 4, y: 9}, {direction: \"right\", x: 5, y: 9}, {direction: \"right\", x: 6, y: 9}, {direction: \"up\", x: 6, y: 8}]);
destX: 鼠标或手指的起拖点横坐标
destY: 鼠标或手指的起拖点横坐标
stepPostfix: 拖动轨迹的数组表示,每项为一步的方向和目标点。", + "!type": "fn(destX: number, destY: number, stepPostfix: [loc])" + }, + "triggerHero": { + "!doc": "改变勇士的显隐状态", + "!type": "fn(type?: string, time?: number, callback?: fn())" + }, + "gatherFollowers": { + "!doc": "立刻聚集所有的跟随者", + "!type": "fn()" + }, + "getStatus": { + "!doc": "读取主角的某个属性,不包括百分比修正
例如:core.getStatus('atk'); // 读取主角的攻击力
name: 属性的英文名,其中'x'、'y'和'direction'会被特殊处理为 core.getHeroLoc(name),其他的会直接读取 core.status.hero[name]", + "!type": "fn(name: string) -> number" + }, + "setHeroLoc": { + "!doc": "设置勇士位置
值得注意的是,这句话虽然会使勇士改变位置,但并不会使界面重新绘制;
如需立刻重新绘制地图还需调用:core.clearMap('hero'); core.drawHero(); 来对界面进行更新。
例如:core.setHeroLoc('x', 5) // 将勇士当前位置的横坐标设置为5。
name: 要设置的坐标属性
value: 新值
noGather: 是否聚集跟随者", + "!type": "fn(name: string, value: string|number, noGather?: bool)" + }, + "getLvName": { + "!doc": "根据级别的数字获取对应的名称,后者定义在全塔属性
例如:core.getLvName(); // 获取主角当前级别的名称,如“下级佣兵”
lv: 级别的数字,不填则视为主角当前的级别
返回值:级别的名称,如果不存在就还是返回数字", + "!type": "fn(lv?: number) -> string|number" + }, + "addStatus": { + "!doc": "增减主角的某个属性,等价于core.setStatus(name, core.getStatus(name) + value)
例如:core.addStatus('atk', 100'); // 给主角攻击力加100
name: 属性的英文名
value: 属性的增量", + "!type": "fn(name: string, value: number)" + }, + "speedUpReplay": { + "!doc": "加速播放", + "!type": "fn()" + }, + "loadData": { + "!doc": "从本地读档", + "!type": "fn(data?: ?, callback?: fn())" + }, + "debug": { + "!doc": "开启调试模式, 此模式下可以按Ctrl键进行穿墙, 并忽略一切事件。
此模式下不可回放录像和上传成绩。", + "!type": "fn()" + }, + "moveOneStep": { + "!doc": "每移动一格后执行的事件", + "!type": "fn(callback?: fn())" + }, + "clearStatus": { + "!doc": "清除游戏状态和数据", + "!type": "fn()" + }, + "updateFollowers": { + "!doc": "更新跟随者坐标", + "!type": "fn()" + }, + "waitHeroToStop": { + "!doc": "等待主角停下
例如:core.waitHeroToStop(core.vibrate); // 等待主角停下,然后视野左右抖动1秒
callback: 主角停止后的回调函数", + "!type": "fn(callback?: fn())" + }, + "hideStatusBar": { + "!doc": "隐藏状态栏", + "!type": "fn(showToolbox?: bool)" + }, + "getBuff": { + "!doc": "读取主角某个属性的百分比修正倍率,初始值为1
例如:core.getBuff('atk'); // 主角当前能发挥出多大比例的攻击力
name: 属性的英文名", + "!type": "fn(name: string) -> number" + }, + "setToolbarButton": { + "!doc": "改变工具栏为按钮1-8", + "!type": "fn(useButton?: bool)" + }, + "getSaves": { + "!doc": "获得某些存档内容", + "!type": "fn(ids?: ?, callback?: fn())" + }, + "replay": { + "!doc": "回放下一个操作", + "!type": "fn()" + }, + "getStatusOrDefault": { + "!doc": "从status中获得属性,如果不存在则从勇士属性中获取", + "!type": "fn(status?: ?, name?: string)" + }, + "unregisterReplayAction": { + "!doc": "注销一个录像行为", + "!type": "fn(name: string)" + }, + "setBuff": { + "!doc": "设置主角某个属性的百分比修正倍率,初始值为1,
倍率存放在flag: '__'+name+'_buff__' 中
例如:core.setBuff('atk', 0.5); // 主角能发挥出的攻击力减半
name: 属性的英文名,请注意只能用于数值类属性哦,否则随后的乘法会得到NaN
value: 新的百分比修正倍率,不填(效果上)视为1", + "!type": "fn(name: string, value: number)" + }, + "continueAutomaticRoute": { + "!doc": "继续剩下的自动寻路操作", + "!type": "fn()" + }, + "saveReplay": { + "!doc": "回放时存档", + "!type": "fn()" + }, + "setAutoHeroMove": { + "!doc": "连续行走
例如:core.setAutoHeroMove([{direction: \"up\", step: 1}, {direction: \"left\", step: 3}, {direction: \"right\", step: 3}, {direction: \"up\", step: 9}]); // 上左左左右右右上9
steps: 压缩的步伐数组,每项表示朝某方向走多少步", + "!type": "fn(steps: [?])" + }, + "fillPosWithPoint": { + "!doc": "显示离散的寻路点", + "!type": "fn(pos?: ?)" + }, + "unregisterResize": { + "!doc": "注销一个resize函数", + "!type": "fn(name: string)" + }, + "saveAndStopAutomaticRoute": { + "!doc": "保存剩下的寻路,并停止", + "!type": "fn()" + }, + "hideStartAnimate": { + "!doc": "淡出标题画面
例如:core.hideStartAnimate(core.startGame); // 淡出标题画面并开始新游戏,跳过难度选择
callback: 标题画面完全淡出后的回调函数", + "!type": "fn(callback?: fn())" + }, + "getAllSaves": { + "!doc": "获得所有存档内容", + "!type": "fn(callback?: fn())" + }, + "updateHeroIcon": { + "!doc": "更新状态栏的勇士图标", + "!type": "fn(name: string)" + }, + "setMusicBtn": { + "!doc": "设置音乐图标的显隐状态", + "!type": "fn()" + }, + "isPlaying": { + "!doc": "游戏是否已经开始", + "!type": "fn() -> bool" + }, + "triggerBgm": { + "!doc": "更改背景音乐的播放", + "!type": "fn()" + }, + "moveHero": { + "!doc": "连续前进,不撞南墙不回头
例如:core.moveHero(); // 连续前进
direction: 可选,如果设置了就会先转身到该方向
callback: 可选,如果设置了就只走一步", + "!type": "fn(direction?: string, callback?: fn())" + }, + "getRealStatusOrDefault": { + "!doc": "从status中获得实际属性(增幅后的),如果不存在则从勇士属性中获取", + "!type": "fn(status?: ?, name?: string)" + }, + "removeSave": { + "!doc": "删除某个存档", + "!type": "fn(index?: number, callback?: fn())" + }, + "registerAnimationFrame": { + "!doc": "注册一个 animationFrame
name: 名称,可用来作为注销使用
needPlaying: 是否只在游戏运行时才执行(在标题界面不执行)
func: 要执行的函数,或插件中的函数名;可接受timestamp(从页面加载完毕到当前所经过的时间)作为参数", + "!type": "fn(name: string, needPlaying: bool, func?: fn(timestamp: number))" + }, + "getHeroLoc": { + "!doc": "读取主角的位置和/或朝向
例如:core.getHeroLoc(); // 读取主角的位置和朝向
name: 要读取横坐标还是纵坐标还是朝向还是都读取
返回值:name ? core.status.hero.loc[name] : core.status.hero.loc", + "!type": "fn(name: string) -> string|number" + }, + "stopAutomaticRoute": { + "!doc": "停止自动寻路操作", + "!type": "fn()" + }, + "setWeather": { + "!doc": "设置天气,不计入存档。如需长期生效请使用core.events._action_setWeather()函数
例如:core.setWeather('fog', 10); // 设置十级大雾天
type: 新天气的类型,不填视为晴天
level: 新天气(晴天除外)的级别,必须为不大于10的正整数,不填视为5", + "!type": "fn(type?: string, level?: number)" + }, + "updateStatusBar": { + "!doc": "立刻刷新状态栏和地图显伤", + "!type": "fn()" + }, + "autosave": { + "!doc": "自动存档", + "!type": "fn(removeLast?: bool)" + }, + "clearStatusBar": { + "!doc": "清空状态栏", + "!type": "fn()" + }, + "moveAction": { + "!doc": "尝试前进一步,如果面前不可被踏入就会直接触发该点事件
例如:core.moveAction(core.doAction); // 尝试前进一步,然后继续事件处理。常用于在事件流中让主角像自由行动时一样前进一步,可以照常触发moveOneStep(跑毒和计步)和面前的事件(包括但不限于阻激夹域捕)
callback: 走一步后的回调函数,可选", + "!type": "fn(callback?: fn())" + }, + "hasFlag": { + "!doc": "判定一个flag变量是否存在且不为false、0、''、null、undefined和NaN
例如:core.hasFlag('poison'); // 判断主角当前是否中毒
name: 变量名,支持中文
此函数等价于 !!core.getFlag(name)", + "!type": "fn(name: string) -> bool" + }, + "rewindReplay": { + "!doc": "回退", + "!type": "fn()" + }, + "toolboxReplay": { + "!doc": "回放录像时打开道具栏", + "!type": "fn()" + }, + "playBgm": { + "!doc": "播放背景音乐,中途开播但不计入存档且只会持续到下次场景切换。如需长期生效请将背景音乐的文件名赋值给flags.__bgm__
例如:core.playBgm('bgm.mp3', 30); // 播放bgm.mp3,并跳过前半分钟
bgm: 背景音乐的文件名,支持全塔属性中映射前的中文名
startTime: 跳过前多少秒,不填则不跳过", + "!type": "fn(bgm: string, startTime?: number)" + }, + "isReplaying": { + "!doc": "是否正在播放录像", + "!type": "fn() -> bool" + }, + "isMoving": { + "!doc": "当前是否正在移动", + "!type": "fn() -> bool" + }, + "getSaveIndexes": { + "!doc": "获得所有存在存档的存档位", + "!type": "fn(callback?: fn())" + }, + "unLockControl": { + "!doc": "解锁状态栏", + "!type": "fn()" + }, + "syncSave": { + "!doc": "同步存档到服务器", + "!type": "fn(type?: string)" + }, + "removeFlag": { + "!doc": "删除某个flag/变量", + "!type": "fn(name: string)" + }, + "registerResize": { + "!doc": "注册一个resize函数
name: 名称,可供注销使用
func: 可以是一个函数,或者是插件中的函数名;可以接受obj参数,详见resize函数。", + "!type": "fn(name: string, func: fn(obj: ?))" + }, + "stopReplay": { + "!doc": "停止播放", + "!type": "fn(force?: bool)" + }, + "bookReplay": { + "!doc": "回放时查看怪物手册", + "!type": "fn()" + }, + "turnHero": { + "!doc": "主角转向并计入录像,不会导致跟随者聚集,会导致视野重置到以主角为中心
例如:core.turnHero(); // 主角顺时针旋转90°,即单击主角或按下Z键的效果
direction: 主角的新朝向,可选", + "!type": "fn(direction?: string)" + }, + "resumeReplay": { + "!doc": "恢复播放", + "!type": "fn()" + }, + "resize": { + "!doc": "屏幕分辨率改变后重新自适应", + "!type": "fn()" + }, + "equipboxReplay": { + "!doc": "回放录像时打开装备栏", + "!type": "fn()" + }, + "getSave": { + "!doc": "获得某个存档内容", + "!type": "fn(index?: number, callback?: fn(data: ?))" + }, + "setViewport": { + "!doc": "设置视野范围", + "!type": "fn(x?: number, y?: number)" + }, + "chooseReplayFile": { + "!doc": "选择录像文件", + "!type": "fn()" + }, + "lockControl": { + "!doc": "锁定状态栏,常常用于事件处理", + "!type": "fn()" + }, + "updateCheckBlock": { + "!doc": "更新领域、夹击、阻击的伤害地图", + "!type": "fn(floorId?: string)" + }, + "checkBlock": { + "!doc": "检查并执行领域、夹击、阻击事件", + "!type": "fn()" + }, + "clearAutomaticRouteNode": { + "!doc": "清除自动寻路路线", + "!type": "fn(x?: number, y?: number)" + }, + "getFlag": { + "!doc": "读取一个flag变量
name: 变量名,支持中文
defaultValue: 当变量不存在时的返回值,可选(事件流中默认填0)。", + "!type": "fn(name: string, defaultValue?: ?)" + }, + "getNakedStatus": { + "!doc": "获得勇士原始属性(无装备和衰弱影响)", + "!type": "fn(name: string)" + }, + "nearHero": { + "!doc": "判定主角是否身处某个点的锯齿领域(即曼哈顿距离)
例如:core.nearHero(6, 6, 6); // 判定主角是否身处点(6,6)的半径为6的锯齿领域
x: 领域的中心横坐标
y: 领域的中心纵坐标
n: 领域的半径,不填视为1", + "!type": "fn(x: number, y: number, n?: number) -> bool" + }, + "stepReplay": { + "!doc": "单步播放", + "!type": "fn()" + }, + "hasSave": { + "!doc": "判断某个存档位是否存在存档", + "!type": "fn(index?: number) -> bool" + }, + "showStartAnimate": { + "!doc": "进入标题画面
例如:core.showStartAnimate(); // 重启游戏但不重置bgm
noAnimate: 可选,true表示不由黑屏淡入而是立即亮屏
callback: 可选,完全亮屏后的回调函数", + "!type": "fn(noAnimate?: bool, callback?: fn())" + }, + "moveViewport": { + "!doc": "移动视野范围", + "!type": "fn(steps?: ?, time?: number, callback?: fn())" + }, + "syncLoad": { + "!doc": "从服务器加载存档", + "!type": "fn()" + }, + "setHeroMoveInterval": { + "!doc": "设置行走的效果动画", + "!type": "fn(callback?: fn())" + }, + "registerReplayAction": { + "!doc": "注册一个录像行为
name: 自定义名称,可用于注销使用
func: 具体执行录像的函数,可为一个函数或插件中的函数名;
需要接受一个action参数,代表录像回放时的下一个操作
func返回true代表成功处理了此录像行为,false代表没有处理此录像行为。", + "!type": "fn(name: string, func: fn(action?: string) -> bool)" + }, + "checkAutosave": { + "!doc": "实际将自动存档写入存储", + "!type": "fn()" + }, + "resumeBgm": { + "!doc": "恢复背景音乐的播放", + "!type": "fn(resumeTime?: number)" + }, + "setGameCanvasTranslate": { + "!doc": "设置大地图的偏移量", + "!type": "fn(ctx: string|CanvasRenderingContext2D, x: number, y: number)" + }, + "checkBgm": { + "!doc": "检查bgm状态", + "!type": "fn()" + }, + "speedDownReplay": { + "!doc": "减速播放", + "!type": "fn()" + }, + "getRealStatus": { + "!doc": "计算主角的某个属性,包括百分比修正
例如:core.getRealStatus('atk'); // 计算主角的攻击力,包括百分比修正。战斗使用的就是这个值
name: 属性的英文名,请注意只能用于数值类属性哦,否则乘法会得到NaN", + "!type": "fn(name: string)" + }, + "saveData": { + "!doc": "存档到本地", + "!type": "fn()" + }, + "unregisterAnimationFrame": { + "!doc": "注销一个animationFrame", + "!type": "fn(name: string)" + }, + "tryMoveDirectly": { + "!doc": "尝试瞬移,如果该点有图块/事件/阻激夹域捕则会瞬移到它旁边再走一步(不可踏入的话当然还是触发该点事件),这一步的方向优先和瞬移前主角的朝向一致
例如:core.tryMoveDirectly(6, 0); // 尝试瞬移到地图顶部的正中央,以样板0层为例,实际效果是瞬移到了上楼梯下面一格然后向上走一步并触发上楼事件
destX: 目标点的横坐标
destY: 目标点的纵坐标", + "!type": "fn(destX: number, destY: number)" + }, + "moveDirectly": { + "!doc": "瞬间移动", + "!type": "fn(destX?: number, destY?: number, ignoreSteps?: number)" + } + }, + "icons": { + "!doc": "图标信息", + "getTilesetOffset": { + "!doc": "根据图块数字或ID获得所在的tileset和坐标信息", + "!type": "fn(id?: string) -> {image: ?, x: number, y: number}" + }, + "getClsFromId": { + "!doc": "根据ID获得其图标类型", + "!type": "fn(id?: string) -> string" + }, + "getAllIconIds": { + "!doc": "获得所有图标的ID", + "!type": "fn() -> [string]" + }, + "getIcons": { + "!doc": "获得所有图标类型", + "!type": "fn()" + } + }, + "items": { + "!doc": "道具相关的函数", + "getEquip": { + "!doc": "检查主角某种类型的装备目前是什么
例如:core.getEquip(1) // 主角目前装备了什么盾牌
equipType: 装备类型,自然数
返回值:装备id,null表示未穿戴", + "!type": "fn(equipType: number) -> string" + }, + "loadEquip": { + "!doc": "尝试穿上某件装备并提示
例如:core.loadEquip('sword5') // 尝试装备上神圣剑,无回调
equipId: 装备id
callback: 穿戴成功或失败后的回调函数", + "!type": "fn(equipId: string, callback?: fn())" + }, + "itemCount": { + "!doc": "统计某种道具的持有量
例如:core.itemCount('yellowKey') // 持有多少把黄钥匙
itemId: 道具id
返回值:该种道具的持有量,不包括已穿戴的装备", + "!type": "fn(itemId: string) -> number" + }, + "getItems": { + "!doc": "获得所有道具", + "!type": "fn()" + }, + "canUseItem": { + "!doc": "检查能否使用某种道具
例如:core.canUseItem('pickaxe') // 能否使用破墙镐
itemId: 道具id
返回值:true表示可以使用", + "!type": "fn(itemId: string) -> bool" + }, + "hasItem": { + "!doc": "检查主角是否持有某种道具(不包括已穿戴的装备)
例如:core.hasItem('yellowKey') // 主角是否持有黄钥匙
itemId: 道具id
返回值:true表示持有", + "!type": "fn(itemId: string) -> bool" + }, + "addItem": { + "!doc": "静默增减某种道具的持有量 不会更新游戏画面或是显示提示
例如:core.addItem('yellowKey', -2) // 没收两把黄钥匙
itemId: 道具id
itemNum: 增加量,负数表示没收", + "!type": "fn(itemId: string, itemNum?: number)" + }, + "unloadEquip": { + "!doc": "脱下某个类型的装备
例如:core.unloadEquip(1) // 卸下盾牌,无回调
equipType: 装备类型编号,自然数
callback: 卸下装备后的回调函数", + "!type": "fn(equipType: number, callback?: fn())" + }, + "quickLoadEquip": { + "!doc": "快速换装
例如:core.quickLoadEquip(1) // 快速换上1号套装
index: 套装编号,自然数", + "!type": "fn(index: number)" + }, + "getItemEffect": { + "!doc": "即捡即用类的道具获得时的效果
例如:core.getItemEffect('redPotion', 10) // 执行获得10瓶红血的效果
itemId: 道具id
itemNum: 道具数量,可选,默认为1", + "!type": "fn(itemId: string, itemNum?: number)" + }, + "quickSaveEquip": { + "!doc": "保存当前套装
例如:core.quickSaveEquip(1) // 将当前套装保存为1号套装
index: 套装编号,自然数", + "!type": "fn(index: number)" + }, + "setItem": { + "!doc": "设置某种道具的持有量
例如:core.setItem('shoes') // 没收绿鞋,重新启用passNet触发器
itemId: 道具id
itemNum: 新的持有量,可选,自然数,默认为0", + "!type": "fn(itemId: string, itemNum?: number)" + }, + "compareEquipment": { + "!doc": "比较两件(类型可不同)装备的优劣
例如:core.compareEquipment('sword5', 'shield5') // 比较神圣剑和神圣盾的优劣
compareEquipId: 装备甲的id
beComparedEquipId: 装备乙的id
返回值:两装备的各属性差,甲减乙,0省略", + "!type": "fn(compareEquipId: string, beComparedEquipId: string) -> {value: ?, percentage: ?}" + }, + "removeItem": { + "!doc": "删除某个物品", + "!type": "fn(itemId?: string, itemNum?: number)" + }, + "getEquipTypeById": { + "!doc": "判定某件装备的类型
例如:core.getEquipTypeById('shield5') // 1(盾牌)
equipId: 装备id
返回值:类型编号,自然数", + "!type": "fn(equipId: string) -> number" + }, + "getEquipTypeByName": { + "!doc": "根据类型获得一个可用的装备孔", + "!type": "fn(name?: string)" + }, + "useItem": { + "!doc": "使用一个道具
例如:core.useItem('pickaxe', true) // 使用破墙镐,不计入录像,无回调
itemId: 道具id
noRoute: 是否不计入录像,快捷键使用的请填true,否则可省略
callback: 道具使用完毕或使用失败后的回调函数", + "!type": "fn(itemId: string, noRoute?: bool, callback?: fn())" + }, + "hasEquip": { + "!doc": "检查主角是否穿戴着某件装备
例如:core.hasEquip('sword5') // 主角是否装备了神圣剑
itemId: 装备id
返回值:true表示已装备", + "!type": "fn(itemId: string) -> bool" + }, + "getItemEffectTip": { + "!doc": "即捡即用类的道具获得时的额外提示
例如:core.getItemEffectTip(redPotion) // (获得 红血瓶)',生命+100'
itemId: 道具id
返回值:图块属性itemEffectTip的内容", + "!type": "fn(itemId: string) -> string" + }, + "canEquip": { + "!doc": "检查能否穿上某件装备
例如:core.canEquip('sword5', true) // 主角可以装备神圣剑吗,如果不能会有提示
equipId: 装备id
hint: 无法穿上时是否提示(比如是因为未持有还是别的什么原因)
返回值:true表示可以穿上,false表示无法穿上", + "!type": "fn(equipId: string, hint?: bool) -> bool" + } + }, + "utils": { + "!doc": "工具类函数", + "scan": { + "!doc": "朝向到x,y映射", + "up": { + "x": "number", + "y": "number" + }, + "down": { + "x": "number", + "y": "number" + }, + "left": { + "x": "number", + "y": "number" + }, + "right": { + "x": "number", + "y": "number" + }, + }, + "clamp": { + "!doc": "将x限定在[a,b]区间内,注意a和b可交换
例如:core.clamp(1200, 1, 1000); // 1000
x: 原始值,!x为true时x一律视为0
a: 下限值,大于b将导致与b交换
b: 上限值,小于a将导致与a交换", + "!type": "fn(x: number, a: number, b: number) -> number" + }, + "rand": { + "!doc": "不支持SL的随机数
例如:1 + core.rand(6); // 随机生成一个小于7的正整数,模拟骰子的效果
num: 填正数表示生成小于num的随机自然数,否则生成小于1的随机正数
返回值:随机数,即使读档也不会改变结果", + "!type": "fn(num?: number) -> number" + }, + "clone": { + "!doc": "深拷贝一个对象(函数将原样返回)
例如:core.clone(core.status.hero, (name, value) => (name == 'items' || typeof value == 'number'), false); // 深拷贝主角的属性和道具
data: 待拷贝对象
filter: 过滤器,可选,表示data为数组或对象时拷贝哪些项或属性,true表示拷贝
recursion: 过滤器是否递归,可选。true表示过滤器也被递归
返回值:拷贝的结果,注意函数将原样返回", + "!type": "fn(data?: ?, filter?: fn(name: string, value: ?) -> bool, recursion?: bool)" + }, + "setLocalForage": { + "!doc": "往数据库写入一段数据", + "!type": "fn(key: string, value?: ?, successCallback?: fn(), errorCallback?: fn())" + }, + "getGlobal": { + "!doc": "读取一个全局存储,适用于global:xxx,支持录像。
例如:if (core.getGlobal('一周目已通关', false) === true) core.getItem('dagger'); // 二周目游戏进行到此处时会获得一把屠龙匕首
key: 全局变量名称,支持中文
defaultValue: 可选,当此全局变量不存在或值为null、undefined时,用此值代替
返回值:全局变量的值", + "!type": "fn(key: string, defaultValue?: ?)" + }, + "replaceText": { + "!doc": "将一段文字中的${}(表达式)进行替换。
例如:core.replaceText('衬衫的价格是${status:hp}镑${item:yellowKey}便士。'); // 把主角的生命值和持有的黄钥匙数量代入这句话
text: 模板字符串,可以使用${}计算js表达式,支持“状态、物品、变量、独立开关、全局存储、图块id、图块类型、敌人数据、装备id”等量参与运算
返回值:替换完毕后的字符串", + "!type": "fn(text: string, prefix?: string) -> string" + }, + "removeLocalStorage": { + "!doc": "移除本地存储", + "!type": "fn(key: string)" + }, + "unzip": { + "!doc": "解压一段内容", + "!type": "fn(blobOrUrl?: ?, success?: fn(data: ?), error?: fn(error: string), convertToText?: bool, onprogress?: fn(loaded: number, total: number))" + }, + "formatTime": { + "!doc": "格式化时间", + "!type": "fn(time: number) -> string" + }, + "readFile": { + "!doc": "尝试请求读取一个本地文件内容 [异步]
success: 成功后的回调
error: 失败后的回调
readType: 不设置则以文本读取,否则以DataUrl形式读取", + "!type": "fn(success?: fn(data: string), error?: fn(message: string), readType?: bool)" + }, + "readFileContent": { + "!doc": "文件读取完毕后的内容处理 [异步]", + "!type": "fn(content: string)" + }, + "formatDate": { + "!doc": "格式化日期为字符串", + "!type": "fn(date: ?) -> string" + }, + "download": { + "!doc": "弹窗请求下载一个文本文件
例如:core.download('route.txt', JSON.stringify(core.status.route)); // 弹窗请求下载录像
filename: 文件名
content: 文件内容", + "!type": "fn(filename: string, content: string)" + }, + "encodeBase64": { + "!doc": "base64加密
例如:core.encodeBase64('abcd'); // 'YWJjZA=='
str: 明文
返回值:密文", + "!type": "fn(str: string) -> string" + }, + "strlen": { + "!doc": "求字符串的国标码字节数,也可用于等宽字体下文本的宽度测算。请注意样板的默认字体Verdana不是等宽字体
例如:core.strlen('无敌ad'); // 6
str: 待测字符串
返回值:字符串的国标码字节数,每个汉字为2,每个ASCII字符为1", + "!type": "fn(str: string) -> number" + }, + "myprompt": { + "!doc": "让用户输入一段文字", + "!type": "fn(hint: string, value: string, callback?: fn(data?: string))" + }, + "getCookie": { + "!doc": "访问浏览器cookie", + "!type": "fn(name: string) -> string" + }, + "decodeRoute": { + "!doc": "录像解压的最后一步,即一压的逆过程
例如:core.decodeRoute(core.encodeRoute(core.status.route)); // 一压当前录像再解压-_-|
route: 录像解压倒数第二步的结果,即一压的结果
返回值:原始录像", + "!type": "fn(route: string) -> [string]" + }, + "formatDate2": { + "!doc": "格式化日期为最简字符串", + "!type": "fn(date: ?) -> string" + }, + "unshift": { + "!doc": "将b(可以是另一个数组)插入数组a的开头,此函数用于弥补a.unshift(b)中b只能是单项的不足。
例如:core.unshift(todo, {type: 'unfollow'}); // 在事件指令数组todo的开头插入“取消所有跟随者”指令
a: 原数组
b: 待插入的新首项或前缀数组
返回值:插入完毕后的新数组,它是改变原数组a本身得到的", + "!type": "fn(a: [?], b: ?) -> [?]" + }, + "same": { + "!doc": "判定深层相等, 会逐层比较每个元素
例如:core.same(['1', 2], ['1', 2]); // true", + "!type": "fn(a?: ?, b?: ?) -> bool" + }, + "setTwoDigits": { + "!doc": "两位数显示", + "!type": "fn(x: number) -> string" + }, + "splitImage": { + "!doc": "等比例切分一张图片
例如:core.splitImage(core.material.images.images['npc48.png'], 32, 48); // 把npc48.png切分成若干32×48px的小人
image: 图片名(支持映射前的中文名)或图片对象(参见上面的例子),获取不到时返回[]
width: 子图的宽度,单位为像素。原图总宽度必须是其倍数,不填视为32
height: 子图的高度,单位为像素。原图总高度必须是其倍数,不填视为正方形
返回值:子图组成的数组,在原图中呈先行后列,从左到右、从上到下排列。", + "!type": "fn(image?: string|image, width?: number, height?: number) -> [image]" + }, + "decompress": { + "!doc": "解压缩一个数据", + "!type": "fn(value: ?)" + }, + "showWithAnimate": { + "!doc": "动画显示某对象", + "!type": "fn(obj?: ?, speed?: number, callback?: fn())" + }, + "subarray": { + "!doc": "判定一个数组是否为另一个数组的前缀,用于录像接续播放。请注意函数名没有大写字母
例如:core.subarray(['ad', '米库', '小精灵', '小破草', '小艾'], ['ad', '米库', '小精灵']); // ['小破草', '小艾']
a: 可能的母数组,不填或比b短将返回null
b: 可能的前缀,不填或比a长将返回null
返回值:如果b不是a的前缀将返回null,否则将返回a去掉此前缀后的剩余数组", + "!type": "fn(a?: [?], b?: [?]) -> [?]|null" + }, + "turnDirection": { + "!doc": "转向某方向
turn: 转向的方向,可为 up,down,left,right,:left,:right,:back 七种
direction: 当前方向", + "!type": "fn(turn: string, direction?: string) -> string" + }, + "myconfirm": { + "!doc": "显示确认框,类似core.drawConfirmBox()
例如:core.myconfirm('重启游戏?', core.restart); // 弹窗询问玩家是否重启游戏
hint: 弹窗的内容
yesCallback: 确定后的回调函数
noCallback: 取消后的回调函数,可选", + "!type": "fn(hint: string, yesCallback?: fn(), noCallback?: fn())" + }, + "calValue": { + "!doc": "计算一个表达式的值,支持status:xxx等的计算。
例如:core.calValue('status:hp + status:def'); // 计算主角的生命值加防御力
value: 待求值的表达式
prefix: 独立开关前缀,一般可省略
返回值:求出的值", + "!type": "fn(value: string, prefix?: string)" + }, + "encodeRoute": { + "!doc": "录像压缩缩
例如:core.encodeRoute(core.status.route); // 压缩当前录像
route: 原始录像,自定义内容(不予压缩,原样写入)必须由0-9A-Za-z和下划线、冒号组成,所以中文和数组需要用JSON.stringify预处理再base64压缩才能交由一压
返回值:一压的结果", + "!type": "fn(route: [string]) -> string" + }, + "decodeBase64": { + "!doc": "base64解密
例如:core.decodeBase64('YWJjZA=='); // \"abcd\"
str: 密文
返回值:明文", + "!type": "fn(str: string) -> string" + }, + "http": { + "!doc": "发送一个HTTP请求 [异步]
type: 请求类型,只能为GET或POST
url: 目标地址
formData: 如果是POST请求则为表单数据
success: 成功后的回调
error: 失败后的回调", + "!type": "fn(type: string, url: string, formData: ?, success?: fn(data: string), error?: fn(message: string), mimeType?: string, responseType?: string, onprogress?: fn(loaded: number, total: number))" + }, + "getLocalStorage": { + "!doc": "获得本地存储", + "!type": "fn(key: string, defaultValue?: ?)" + }, + "arrayToRGB": { + "!doc": "颜色数组转字符串
例如:core.arrayToRGBA([102, 204, 255]); // \"rgba(102,204,255,1)\"
color: 一行三列或一行四列的数组,前三个元素必须为不大于255的自然数。第四个元素(如果有)必须为0或不大于1的数字,第四个元素不填视为1
返回值:该颜色的字符串表示", + "!type": "fn(color: [number]) -> string" + }, + "formatBigNumber": { + "!doc": "大数字格式化,单位为10000的倍数(w,e,z,j,g),末尾四舍五入
例如:core.formatBigNumber(123456789, false); // \"12346w\"
x: 原数字
onMap: 可选,true表示用于地图显伤,结果总字符数最多为5,否则最多为6
返回值:格式化结果", + "!type": "fn(x: number, onMap?: bool) -> string" + }, + "removeLocalForage": { + "!doc": "移除本地数据库的数据", + "!type": "fn(key: string, successCallback?: fn(), errorCallback?: fn())" + }, + "matchWildcard": { + "!doc": "通配符匹配,用于搜索图块等批量处理。
例如:core.playSound(core.matchWildcard('*Key', itemId) ? 'item.mp3' : 'door.mp3'); // 判断捡到的是钥匙还是别的道具,从而播放不同的音效
pattern: 模式串,每个星号表示任意多个(0个起)字符
string: 待测串
返回值:true表示匹配成功,false表示匹配失败", + "!type": "fn(pattern: string, string: string) -> bool" + }, + "setLocalStorage": { + "!doc": "设置本地存储", + "!type": "fn(key: string, value?: ?)" + }, + "hideWithAnimate": { + "!doc": "动画使某对象消失", + "!type": "fn(obj?: ?, speed?: number, callback?: fn())" + }, + "copy": { + "!doc": "尝试复制一段文本到剪切板。", + "!type": "fn(data: string) -> bool" + }, + "isset": { + "!doc": "判断一个值是否不为null,undefined和NaN
例如:core.isset(0/0); // false,因为0/0等于NaN
v: 待测值,可选
返回值:false表示待测值为null、undefined、NaN或未填写,true表示为其他值。", + "!type": "fn(v?: ?) -> bool" + }, + "replaceValue": { + "!doc": "对一个表达式中的特殊规则进行替换,如status:xxx等。
例如:core.replaceValue('status:atk+item:yellowKey'); // 把这两个冒号表达式替换为core.getStatus('hp')和core.itemCount('yellowKey')这样的函数调用
value: 模板字符串,注意独立开关不会被替换
返回值:替换完毕后的字符串", + "!type": "fn(value: string) -> string" + }, + "getLocalForage": { + "!doc": "从本地数据库读出一段数据", + "!type": "fn(key: string, defaultValue?: ?, successCallback?: fn(data: ?), errorCallback?: fn())" + }, + "inArray": { + "!doc": "判定array是不是一个数组,以及element是否在该数组中。
例如:core.inArray(core.material.enemys.greenSlime.special, 1); // 判定绿头怪除先攻外还有无其他特殊属性
array: 可能的数组,不为数组或不填将导致返回值为false
element: 待查找的元素
返回值:如果array为数组且具有element这项,就返回true,否则返回false", + "!type": "fn(array?: ?, element?: ?) -> bool" + }, + "setGlobal": { + "!doc": "设置一个全局存储,适用于global:xxx,录像播放时将忽略此函数。
例如:core.setBlobal('一周目已通关', true); // 设置全局存储“一周目已通关”为true,方便二周目游戏中的新要素。
key: 全局变量名称,支持中文
value: 全局变量的新值,不填或null表示清除此全局存储", + "!type": "fn(key: string, value?: ?)" + }, + "rand2": { + "!doc": "支持SL的随机数,并计入录像
例如:1 + core.rand2(6); // 随机生成一个小于7的正整数,模拟骰子的效果
num: 正整数,0或不填会被视为2147483648
返回值:属于 [0, num) 的随机数", + "!type": "fn(num?: number) -> number" + }, + "setStatusBarInnerHTML": { + "!doc": "填写非自绘状态栏
例如:core.setStatusBarInnerHTML('hp', core.status.hero.hp, 'color: #66CCFF'); // 更新状态栏中的主角生命,使用加载画面的宣传色
name: 状态栏项的名称,如'hp', 'atk', 'def'等。必须是core.statusBar中的一个合法项
value: 要填写的内容,大数字会被格式化为至多6个字符,无中文的内容会被自动设为斜体
css: 额外的css样式,可选。如更改颜色等", + "!type": "fn(name: string, value: ?, css?: string)" + }, + "matchRegex": { + "!doc": "是否满足正则表达式", + "!type": "fn(pattern: string, string: string) -> string" + }, + "push": { + "!doc": "将b(可以是另一个数组)插入数组a的末尾,此函数用于弥补a.push(b)中b只能是单项的不足。
例如:core.push(todo, {type: 'unfollow'}); // 在事件指令数组todo的末尾插入“取消所有跟随者”指令
a: 原数组
b: 待插入的新末项或后缀数组
返回值:插入完毕后的新数组,它是改变原数组a本身得到的", + "!type": "fn(a: [?], b: ?) -> [?]" + }, + "formatSize": { + "!doc": "格式化文件大小", + "!type": "fn(size: number) -> string" + } + }, + "actions": { + "!doc": "用户操作相关的函数", + "onup": { + "!doc": "当点击(触摸)事件放开时", + "!type": "fn(loc: {x: number, y: number, size: number})" + }, + "pressKey": { + "!doc": "按住某个键时", + "!type": "fn(keyCode: number)" + }, + "keyUp": { + "!doc": "根据放开键的code来执行一系列操作", + "!type": "fn(keyCode: number, altKey?: bool, fromReplay?: bool)" + }, + "ondown": { + "!doc": "点击(触摸)事件按下时", + "!type": "fn(loc: {x: number, y: number, size: number})" + }, + "registerAction": { + "!doc": "此函数将注册一个用户交互行为。
action: 要注册的交互类型,如 ondown, onclick, keyDown 等等。
name: 你的自定义名称,可被注销使用;同名重复注册将后者覆盖前者。
func: 执行函数。
如果func返回true,则不会再继续执行其他的交互函数;否则会继续执行其他的交互函数。
priority: 优先级;优先级高的将会被执行。此项可不填,默认为0", + "!type": "fn(action: string, name: string, func: string|fn(params: ?), priority?: number)" + }, + "onkeyDown": { + "!doc": "按下某个键时", + "!type": "fn(e: Event)" + }, + "keyDown": { + "!doc": "根据按下键的code来执行一系列操作", + "!type": "fn(keyCode: number)" + }, + "onStatusBarClick": { + "!doc": "点击自绘状态栏时", + "!type": "fn(e?: Event)" + }, + "longClick": { + "!doc": "长按", + "!type": "fn(x: number, y: number, fromEvent?: bool)" + }, + "unregisterAction": { + "!doc": "注销一个用户交互行为", + "!type": "fn(action: string, name: string)" + }, + "keyDownCtrl": { + "!doc": "长按Ctrl键时", + "!type": "fn() -> bool" + }, + "onclick": { + "!doc": "具体点击屏幕上(x,y)点时,执行的操作", + "!type": "fn(x: number, y: number, stepPostfix?: ?)" + }, + "doRegisteredAction": { + "!doc": "执行一个用户交互行为", + "!type": "fn(action: string, params: ?)" + }, + "onkeyUp": { + "!doc": "放开某个键时", + "!type": "fn(e: Event)" + }, + "onmousewheel": { + "!doc": "滑动鼠标滚轮时的操作", + "!type": "fn(direct: number)" + }, + "onmove": { + "!doc": "当在触摸屏上滑动时", + "!type": "fn(loc: {x: number, y: number, size: number})" + } + }, + "loader": { + "!doc": "资源加载相关的函数", + "loadImages": { + "!doc": "加载一系列图片", + "!type": "fn(dir: string, names: [string], toSave: ?, callback?: fn()) " + }, + "loadImagesFromZip": { + "!doc": "从zip中加载一系列图片", + "!type": "fn(url: string, names: [string], toSave?: ?, onprogress?: ?, onfinished?: ?)" + }, + "loadBgm": { + "!doc": "加载一个bgm", + "!type": "fn(name: string)" + }, + "loadOneMusic": { + "!doc": "加载一个音乐或音效", + "!type": "fn(name: string)" + }, + "freeBgm": { + "!doc": "释放一个bgm的缓存", + "!type": "fn(name: string)" + }, + "loadOneSound": { + "!doc": "加载一个音效", + "!type": "fn(name: string)" + }, + "loadImage": { + "!doc": "加载某一张图片", + "!type": "fn(dir: name, imgName: name, callback?: fn())" + } + }, + "maps": { + "!doc": "地图处理相关的函数", + "noPass": { + "!doc": "判定某个点是否不可被踏入(不基于主角生命值和图块cannotIn属性)
例如:core.noPass(0, 0); // 判断地图左上角能否被踏入
x: 目标点的横坐标
y: 目标点的纵坐标
floorId: 目标点所在的地图id,不填视为当前地图
返回值:true表示可踏入", + "!type": "fn(x: number, y: number, floorId?: string) -> bool" + }, + "drawAnimate": { + "!doc": "播放动画,注意即使指定了主角的坐标也不会跟随主角移动,如有需要请使用core.drawHeroAnimate(name, callback)函数
例如:core.drawAnimate('attack', core.nextX(), core.nextY(), core.vibrate); // 在主角面前一格播放普攻动画,动画停止后视野左右抖动1秒
name: 动画文件名,不含后缀
x: 绝对横坐标
y: 绝对纵坐标
callback: 动画停止后的回调函数,可选
返回值:一个数字,可作为core.stopAnimate()的参数来立即停止播放(届时还可选择是否执行此次播放的回调函数)", + "!type": "fn(name: string, x: number, y: number, alignWindow: bool, callback?: fn()) -> number" + }, + "getBlockCls": { + "!doc": "判定某个点的图块类型
例如:if(core.getBlockCls(x1, y1) != 'enemys' && core.getBlockCls(x2, y2) != 'enemy48') core.openDoor(x3, y3); // 另一个简单的机关门事件,打败或炸掉这一对不同身高的敌人就开门
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图
showDisable: 隐藏点是否不返回null,true表示不返回null
返回值:图块类型,即“地形、四帧动画、矮敌人、高敌人、道具、矮npc、高npc、自动元件、额外地形”之一", + "!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string" + }, + "drawMap": { + "!doc": "地图重绘
例如:core.drawMap(); // 重绘当前地图,常用于更改贴图后的刷新
floorId: 地图id,建议省略
callback: 重绘完毕后的回调函数,可选", + "!type": "fn(floorId?: string)" + }, + "nearStair": { + "!doc": "当前位置是否在楼梯边", + "!type": "fn() -> bool" + }, + "turnBlock": { + "!doc": "事件转向", + "!type": "fn(direction?: string, x?: number, y?: number, floorId?: string)" + }, + "getMapArray": { + "!doc": "生成事件层矩阵
例如:core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵,隐藏的图块视为0
floorId: 地图id,不填视为当前地图
showDisable: 可选,true表示隐藏的图块也会被表示出来
返回值:事件层矩阵,注意对其阵元的访问是[y][x]", + "!type": "fn(floorId?: string) -> [[number]]" + }, + "jumpBlock": { + "!doc": "跳跃图块
例如:core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出
sx: 起点的横坐标
sy: 起点的纵坐标
ex: 终点的横坐标
ey: 终点的纵坐标
time: 单步和淡出用时,单位为毫秒。不填视为半秒
keep: 是否不淡出,true表示不淡出
callback: 落地或淡出后的回调函数,可选", + "!type": "fn(sx: number, sy: number, ex: number, ey: number, time?: number, keep?: bool, callback?: fn())" + }, + "replaceBlock": { + "!doc": "批量替换图块
例如:core.replaceBlock(21, 22, core.floorIds); // 把游戏中地上当前所有的黄钥匙都变成蓝钥匙
fromNumber: 旧图块的数字
toNumber: 新图块的数字
floorId: 地图id或其数组,不填视为当前地图", + "!type": "fn(fromNumber: number, toNumber: number, floorId?: string|[string])" + }, + "drawBlock": { + "!doc": "绘制一个图块", + "!type": "fn(block?: block, animate?: number)" + }, + "resetMap": { + "!doc": "重置地图", + "!type": "fn(floorId?: string|[string])" + }, + "animateSetBlock": { + "!doc": "动画形式转变某点图块", + "!type": "fn(number: number|string, x: number, y: number, floorId?: string, time?: number, callback?: fn())" + }, + "animateSetBlocks": { + "!doc": "动画形式同时转变若干点图块", + "!type": "fn(number: number|string, locs: [?], floorId?: string, time?: number, callback?: fn())" + }, + "compressMap": { + "!doc": "压缩地图", + "!type": "fn(mapArr: [[number]], floorId?: string) -> [[number]]" + }, + "enemyExists": { + "!doc": "某个点是否存在(指定的)怪物", + "!type": "fn(x: number, y: number, id?: string, floorId?: string) -> bool" + }, + "npcExists": { + "!doc": "某个点是否存在NPC", + "!type": "fn(x: number, y: number, floorId?: string) -> bool" + }, + "getBlockByNumber": { + "!doc": "根据数字获得图块", + "!type": "fn(number: number) -> block" + }, + "removeBlock": { + "!doc": "尝试删除一个图块,此函数会被打怪开门捡道具、“隐藏事件”指令和“移动/跳跃事件”指令的起点直接调用。
例如:core.removeBlock(0, 0); // 尝试删除地图左上角的图块
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图", + "!type": "fn(x: number, y: number, floorId?: string)" + }, + "hideBlock": { + "!doc": "隐藏(显示或隐藏的)图块,此函数不会被任何事件指令【直接】调用
例如:core.hideBlock(0, 0); // 隐藏地图左上角的图块
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图", + "!type": "fn(x: number, y: number, floorId?: string)" + }, + "removeBlockByIndex": { + "!doc": "根据block的索引删除该块", + "!type": "fn(index: number, floorId?: string)" + }, + "stairExists": { + "!doc": "某个点是否存在楼梯", + "!type": "fn(x: number, y: number, floorId?: string) -> bool" + }, + "decompressMap": { + "!doc": "解压缩地图", + "!type": "fn(mapArr: [[number]], floorId?: string) -> [[number]]" + }, + "automaticRoute": { + "!doc": "自动寻路
例如:core.automaticRoute(0, 0); // 自动寻路到地图左上角
destX: 目标点的横坐标
destY: 目标点的纵坐标
返回值:每步走完后主角的loc属性组成的一维数组", + "!type": "fn(destX: number, destY: number) -> [loc]" + }, + "resizeMap": { + "!doc": "更改地图画布的尺寸", + "!type": "fn(floorId?: string)" + }, + "getFgNumber": { + "!doc": "判定前景层的一个位置是什么
例如:core.getFgNumber(core.status.hero.loc.x, core.status.hero.loc.y); // 判断主角脚下的前景层图块的数字
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图
noCache: 可选,true表示不使用缓存", + "!type": "fn(x: number, y: number, floorId?: string, noCache?: bool) -> number" + }, + "moveBlock": { + "!doc": "移动图块
例如:core.moveBlock(0, 0, ['down']); // 令地图左上角的图块下移一格,用时半秒,再花半秒淡出
x: 起点的横坐标
y: 起点的纵坐标
steps: 步伐数组,前进和后退用于带朝向的npc
time: 单步和淡出用时,单位为毫秒。不填视为半秒
keep: 是否不淡出,true表示不淡出
callback: 移动或淡出后的回调函数,可选", + "!type": "fn(x: number, y: number, steps: [string], time?: number, keep?: bool, callback?: fn())" + }, + "getBgNumber": { + "!doc": "判定背景层的一个位置是什么,主要用于滑冰(167)
例如:core.getBgNumber(core.status.hero.loc.x, core.status.hero.loc.y); // 判断主角脚下的背景层图块的数字
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图
@param 可选,true表示不使用缓存", + "!type": "fn(x: number, y: number, floorId?: string, noCache?: bool) -> number" + }, + "getIdOfThis": { + "!doc": "获得当前事件点的ID", + "!type": "fn(id?: string) -> string" + }, + "searchBlock": { + "!doc": "搜索图块, 支持通配符和正则表达式
例如:core.searchBlock('*Door'); // 搜索当前地图的所有门
id: 图块id,支持星号表示任意多个(0个起)字符
floorId: 地图id,不填视为当前地图
showDisable: 隐藏点是否计入,true表示计入
返回值:一个详尽的数组,一般只用到其长度", + "!type": "fn(id: string, floorId?: string, showDisable?: bool) -> Array<{ floorId -> string, index -> number, x -> number, y -> number, block -> Block }>" + }, + "hideBgFgMap": { + "!doc": "隐藏前景/背景地图", + "!type": "fn(name?: string, loc?: [number]|[[number]], floorId?: string, callback?: fn())" + }, + "getBlockInfo": { + "!doc": "获得某个图块或素材的信息,包括ID,cls,图片,坐标,faceIds等等", + "!type": "fn(block?: number|string|block) -> blockInfo" + }, + "canMoveDirectlyArray": { + "!doc": "获得某些点可否通行的信息", + "!type": "fn(locs?: [[number]])" + }, + "hideFloorImage": { + "!doc": "隐藏一个楼层贴图", + "!type": "fn(loc?: [number]|[[number]], floorId?: string, callback?: fn())" + }, + "extractBlocks": { + "!doc": "根据需求解析出blocks", + "!type": "fn(map?: [[number]], flags?: flags)" + }, + "getBlockId": { + "!doc": "判定某个点的图块id
例如:if(core.getBlockId(x1, y1) != 'greenSlime' && core.getBlockId(x2, y2) != 'redSlime') core.openDoor(x3, y3); // 一个简单的机关门事件,打败或炸掉这一对绿头怪和红头怪就开门
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图
showDisable: 隐藏点是否不返回null,true表示不返回null
返回值:图块id,该点无图块则返回null", + "!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> string" + }, + "loadFloor": { + "!doc": "从文件或存档中加载某个楼层", + "!type": "fn(floorId?: string, map?: ?)" + }, + "generateMovableArray": { + "!doc": "可通行性判定
例如:core.generateMovableArray(); // 判断当前地图主角从各点能向何方向移动
floorId: 地图id,不填视为当前地图
x: 起点横坐标,不填视为挨个判定
y: 起点纵坐标,不填视为挨个判定
direction: 可选,必须和坐标一起使用。填写后将只检查是否可向该方向移动并返回布尔值
返回值:不设置坐标时为从各点可移动方向的三维数组,设置坐标但不设置方向时为该点可移动方向的一维数组,都设置时为布尔值", + "!type": "fn(floorId?: string, x?: number, y?: number, direction?: string)" + }, + "terrainExists": { + "!doc": "某个点是否存在(指定的)地形", + "!type": "fn(x: number, y: number, id?: string, floorId?: string) -> bool" + }, + "getBlockById": { + "!doc": "根据ID获得图块", + "!type": "fn(id: string) -> block" + }, + "drawBg": { + "!doc": "绘制背景层(含贴图,其与背景层矩阵的绘制顺序可通过复写此函数来改变)
例如:core.drawBg(); // 绘制当前地图的背景层
floorId: 地图id,不填视为当前地图
ctx: 某画布的ctx,用于绘制缩略图,一般不需要", + "!type": "fn(floorId?: string, ctx?: CanvasRenderingContext2D)" + }, + "showBlock": { + "!doc": "显示(隐藏或显示的)图块,此函数将被“显示事件”指令和勾选了“不消失”的“移动/跳跃事件”指令(如阻击怪)的终点调用
例如:core.showBlock(0, 0); // 显示地图左上角的图块
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图", + "!type": "fn(x: number, y: number, floorId?: string)" + }, + "getMapBlocksObj": { + "!doc": "以x,y的形式返回每个点的事件", + "!type": "fn(floorId?: string, showDisable?: bool)" + }, + "removeGlobalAnimate": { + "!doc": "删除一个或所有全局动画", + "!type": "fn(x?: number, y?: number, name?: string)" + }, + "drawEvents": { + "!doc": "绘制事件层
例如:core.drawEvents(); // 绘制当前地图的事件层
floorId: 地图id,不填视为当前地图
blocks: 一般不需要
ctx: 某画布的ctx,用于绘制缩略图,一般不需要", + "!type": "fn(floorId?: string, blocks?: [block], ctx?: CanvasRenderingContext2D)" + }, + "canMoveDirectly": { + "!doc": "能否瞬移到某点,并求出节约的步数。此函数会无视可通行图块的script属性,如需使用该属性请手动禁止瞬移
例如:core.canMoveDirectly(0, 0); // 能否瞬移到地图左上角
destX: 目标点的横坐标
destY: 目标点的纵坐标
返回值:正数表示节约的步数,-1表示不可瞬移", + "!type": "fn(destX: number, destY: number) -> number" + }, + "saveMap": { + "!doc": "将当前地图重新变成数字,以便于存档", + "!type": "fn(floorId?: string)" + }, + "drawBoxAnimate": { + "!doc": "绘制UI层的box动画", + "!type": "fn()" + }, + "setBgFgBlock": { + "!doc": "转变图层块
例如:core.setBgFgBlock('bg', 167, 6, 6); // 把当前地图背景层的中心块改为滑冰
name: 背景还是前景
number: 新图层块的数字(也支持纯数字字符串如'1')或id
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图", + "!type": "fn(name: string, number: number|string, x: number, y: number, floorId?: string)" + }, + "drawFg": { + "!doc": "绘制前景层(含贴图,其与前景层矩阵的绘制顺序可通过复写此函数来改变)
例如:core.drawFg(); // 绘制当前地图的前景层
floorId: 地图id,不填视为当前地图
ctx: 某画布的ctx,用于绘制缩略图,一般不需要", + "!type": "fn(floorId?: string, ctx?: CanvasRenderingContext2D)" + }, + "getBlock": { + "!doc": "获得某个点的block", + "!type": "fn(x: number, y: number, floorId?: string, showDisable?: bool) -> block" + }, + "initBlock": { + "!doc": "初始化一个图块", + "!type": "fn(x: number, y: number, id: string|number, addInfo?: bool, eventFloor?: ?, flags?: ?) -> block" + }, + "addGlobalAnimate": { + "!doc": "添加一个全局动画", + "!type": "fn(block?: block)" + }, + "animateBlock": { + "!doc": "显示/隐藏某个块时的动画效果", + "!type": "fn(loc?: [number]|[[number]], type?: string, time?: number, callback?: fn())" + }, + "loadMap": { + "!doc": "将存档中的地图信息重新读取出来", + "!type": "fn(data?: ?, floorId?: string)" + }, + "setBlock": { + "!doc": "转变图块
例如:core.setBlock(1, 0, 0); // 把地图左上角变成黄墙
number: 新图块的数字(也支持纯数字字符串如'1')或id
x: 横坐标
y: 纵坐标
floorId: 地图id,不填视为当前地图", + "!type": "fn(number: number|string, x: number, y: number, floorId?: string)" + }, + "getFgMapArray": { + "!doc": "生成前景层矩阵
例如:core.getFgMapArray('MT0'); // 生成主塔0层的前景层矩阵,使用缓存
floorId: 地图id,不填视为当前地图
noCache: 可选,true表示不使用缓存
返回值:前景层矩阵,注意对其阵元的访问是[y][x]", + "!type": "fn(floorId?: string, noCache?: bool) -> [[number]]" + }, + "getBgMapArray": { + "!doc": "生成背景层矩阵
例如:core.getBgMapArray('MT0'); // 生成主塔0层的背景层矩阵,使用缓存
floorId: 地图id,不填视为当前地图
noCache: 可选,true表示不使用缓存
返回值:背景层矩阵,注意对其阵元的访问是[y][x]", + "!type": "fn(floorId?: string, noCache?: bool) -> [[number]]" + }, + "canMoveHero": { + "!doc": "单点单朝向的可通行性判定
@exmaple core.canMoveHero(); // 判断主角是否可以前进一步
x: 起点横坐标,不填视为主角当前的
y: 起点纵坐标,不填视为主角当前的
direction: 移动的方向,不填视为主角面对的方向
floorId: 地图id,不填视为当前地图
返回值:true表示可移动,false表示不可移动", + "!type": "fn(x?: number, y?: number, direction?: string, floorId?: string) -> bool" + }, + "drawThumbnail": { + "!doc": "绘制缩略图
例如:core.drawThumbnail(); // 绘制当前地图的缩略图
floorId: 地图id,不填视为当前地图
blocks: 一般不需要
options: 额外的绘制项,可选。可以增绘主角位置和朝向、采用不同于游戏中的主角行走图、增绘显伤、提供flags用于存读档
toDraw: 要绘制到的画布名或画布的ctx或还有其他信息,如起绘坐标、绘制大小、是否绘制全图、截取中心", + "!type": "fn(floorId?: string, blocks?: [block], options?: ?, toDraw?: string|CanvasRenderingContext2D|?)" + }, + "hideBlockByIndex": { + "!doc": "根据图块的索引来隐藏图块", + "!type": "fn(index?: number, floorId?: string)" + }, + "getNumberById": { + "!doc": "根据图块id得到数字(地图矩阵中的值)
例如:core.getNumberById('yellowWall'); // 1
id: 图块id
返回值:图块的数字,定义在project\\maps.js(请注意和project\\icons.js中的“图块索引”相区分!)", + "!type": "fn(id: string) -> number" + }, + "removeBlockByIndexes": { + "!doc": "一次性删除多个block", + "!type": "fn(indexes?: [number], floorId?: string)" + }, + "hideBlockByIndexes": { + "!doc": "一次性隐藏多个block", + "!type": "fn(indexes?: [number], floorId?: string)" + }, + "generateGroundPattern": { + "!doc": "生成groundPattern", + "!type": "fn(floorId?: string)" + }, + "showBgFgMap": { + "!doc": "显示前景/背景地图", + "!type": "fn(name?: string, loc?: [number]|[[number]], floorId?: string, callback?: fn())" + }, + "showFloorImage": { + "!doc": "显示一个楼层贴图", + "!type": "fn(loc?: [number]|[[number]], floorId?: string, callback?: fn())" + } + }, + "ui": { + "!doc": "UI绘制相关的函数", + "resizeCanvas": { + "!doc": "重新设置一个自定义画布的大小", + "!type": "fn(name: string, x: number, y: number)" + }, + "deleteCanvas": { + "!doc": "删除一个自定义画布", + "!type": "fn(name: string)" + }, + "drawSLPanel": { + "!doc": "绘制存档/读档界面", + "!type": "fn(index?: ?, refresh?: bool)" + }, + "drawKeyBoard": { + "!doc": "绘制虚拟键盘", + "!type": "fn()" + }, + "drawStorageRemove": { + "!doc": "绘制存档删除页面", + "!type": "fn()" + }, + "deleteAllCanvas": { + "!doc": "清空所有的自定义画布", + "!type": "fn()" + }, + "drawIcon": { + "!doc": "在某个canvas上绘制一个图标", + "!type": "fn(name: string|CanvasRenderingContext2D, id: string, x: number, y: number, w?: number, h?: number, frame?: number)" + }, + "drawFly": { + "!doc": "绘制楼层传送器", + "!type": "fn(page?: ?)" + }, + "setOpacity": { + "!doc": "设置某个canvas的透明度;尽量不要使用本函数,而是全部换成setAlpha实现", + "!type": "fn(name: string|CanvasRenderingContext2D, opacity: number)" + }, + "drawAbout": { + "!doc": "绘制“关于”界面", + "!type": "fn()" + }, + "getTextContentHeight": { + "!doc": "获得某段文字的预计绘制高度;参数说明详见 drawTextContent", + "!type": "fn(content: string, config?: ?)" + }, + "drawSwitchs": { + "!doc": "绘制系统设置界面", + "!type": "fn()" + }, + "drawSyncSelect": { + "!doc": "绘制存档同步选择页面", + "!type": "fn()" + }, + "drawArrow": { + "!doc": "在某个canvas上绘制一个箭头", + "!type": "fn(name: string|CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, style?: string, lineWidth?: number)" + }, + "drawReplay": { + "!doc": "绘制回放界面", + "!type": "fn()" + }, + "strokeEllipse": { + "!doc": "在某个canvas上绘制一个椭圆的边框", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, a: number, b: number, angle?: number, style?: string, lineWidth?: number)" + }, + "fillCircle": { + "!doc": "在某个canvas上绘制一个圆", + "!url": "https://www.w3school.com.cn/tags/canvas_arc.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, r: number, style?: string)" + }, + "clearTip": { + "!doc": "清除左上角提示内容", + "!type": "fn()" + }, + "strokeRoundRect": { + "!doc": "在某个canvas上绘制一个圆角矩形的边框", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, style?: string, lineWidth?: number, angle?: number)" + }, + "getContextByName": { + "!doc": "根据画布名找到一个画布的context;支持系统画布和自定义画布。如果不存在画布返回null。
也可以传画布的context自身,则返回自己。", + "!type": "fn(canvas: string|CanvasRenderingContext2D) -> CanvasRenderingContext2D" + }, + "drawImage": { + "!doc": "在一个画布上绘制图片
后面的8个坐标参数与canvas的drawImage的八个参数完全相同。
name: 可以是系统画布之一,也可以是任意自定义动态创建的画布名 画布名称或者画布的context
image: 要绘制的图片,可以是一个全塔属性中定义的图片名(会从images中去获取;支持加':x',':y',':o'翻转),图片本身,或者一个画布。
angle:旋转角度", + "!url": "http://www.w3school.com.cn/html5/canvas_drawimage.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, image: string|image, x: number, y: number, w?: number, h?: number, x1?: number, y1?: number, w1?: number, h1?: number, angle?: number)" + }, + "drawTip": { + "!doc": "左上角绘制一段提示", + "!type": "fn(text: string, id?: string, frame?: number)" + }, + "drawBackground": { + "!doc": "绘制一个背景图,可绘制winskin或纯色背景;支持小箭头绘制", + "!type": "fn(left: string, top: string, right: string, bottom: string, posInfo?: {px: number, py: number, direction: string})" + }, + "fillEllipse": { + "!doc": "在某个canvas上绘制一个椭圆", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, a: number, b: number, angle?: number, style?: string)" + }, + "setFillStyle": { + "!doc": "设置某个canvas的绘制属性(如颜色等)", + "!url": "https://www.w3school.com.cn/tags/canvas_fillstyle.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, style: string)" + }, + "drawText": { + "!doc": "地图中间绘制一段文字", + "!type": "fn(contents: string, callback?: fn())" + }, + "fillPolygon": { + "!doc": "在某个canvas上绘制一个多边形", + "!type": "fn(name: string|CanvasRenderingContext2D, nodes?: [[number]], style?: string)" + }, + "drawStatistics": { + "!doc": "绘制“数据统计”界面", + "!type": "fn(floorIds?: string)" + }, + "fillText": { + "!doc": "在某个画布上绘制一段文字
text: 要绘制的文本
style: 绘制的样式
font: 绘制的字体
最大宽度,超过此宽度会自动放缩", + "!url": "https://www.w3school.com.cn/tags/canvas_filltext.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, text: string, x: number, y: number, style?: string, font?: string, maxWidth?: number)" + }, + "setTextBaseline": { + "!doc": "设置某个canvas的baseline", + "!url": "https://www.w3school.com.cn/tags/canvas_textbaseline.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, baseline: string)" + }, + "drawSettings": { + "!doc": "绘制系统菜单栏", + "!type": "fn()" + }, + "loadCanvas": { + "!doc": "加载某个canvas状态", + "!type": "fn(name: string|CanvasRenderingContext2D)" + }, + "splitLines": { + "!doc": "字符串自动换行的分割", + "!type": "fn(name: string|CanvasRenderingContext2D, text: string, maxWidth?: number, font?: string)" + }, + "setAlpha": { + "!doc": "设置某个canvas的alpha值", + "!url": "https://www.w3school.com.cn/tags/canvas_globalalpha.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, alpha: number)" + }, + "setLineWidth": { + "!doc": "设置某个canvas的线宽度", + "!url": "https://www.w3school.com.cn/tags/canvas_linewidth.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, lineWidth: number)" + }, + "drawEquipbox": { + "!doc": "绘制装备界面", + "!type": "fn(index?: ?)" + }, + "drawTextBox": { + "!doc": "绘制一个对话框", + "!type": "fn(content: string, showAll?: bool)" + }, + "relocateCanvas": { + "!doc": "重新定位一个自定义画布", + "!type": "fn(name: string, x: number, y: number)" + }, + "closePanel": { + "!doc": "结束一切事件和绘制,关闭UI窗口,返回游戏进程", + "!type": "fn()" + }, + "textImage": { + "!doc": "文本图片化", + "!type": "fn(content: string, lineHeight?: number) -> image" + }, + "drawStatusBar": { + "!doc": "绘制状态栏", + "!type": "fn()" + }, + "setStrokeStyle": { + "!doc": "设置某个canvas边框属性", + "!url": "https://www.w3school.com.cn/tags/canvas_strokestyle.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, style: string)" + }, + "clearUI": { + "!doc": "清空UI层内容", + "!type": "fn()" + }, + "drawWindowSkin": { + "!doc": "绘制WindowSkin", + "!type": "fn(background: string, ctx: string|CanvasRenderingContext2D, x: number, y: number, w: string, h: string, direction?: string, px?: number, py?: number)" + }, + "drawGameInfo": { + "!doc": "绘制游戏信息界面", + "!type": "fn()" + }, + "fillRect": { + "!doc": "绘制一个矩形。style可选为绘制样式
text: 要绘制的文本
style: 绘制的样式
font: 绘制的字体", + "!url": "https://www.w3school.com.cn/tags/canvas_fillrect.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, text: string, x: number, y: number, style?: string, font?: string)" + }, + "drawScrollText": { + "!doc": "绘制滚动字幕", + "!type": "fn(content: string, time: number, lineHeight?: number, callback?: fn())" + }, + "strokePolygon": { + "!doc": "在某个canvas上绘制一个多边形的边框", + "!type": "fn(name: string|CanvasRenderingContext2D, nodes?: [[number]], style?: string, lineWidth?: number)" + }, + "strokeCircle": { + "!doc": "在某个canvas上绘制一个圆的边框", + "!url": "https://www.w3school.com.cn/tags/canvas_arc.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, r: ?, style?: string, lineWidth?: number)" + }, + "drawLocalSaveSelect": { + "!doc": "绘制单存档界面", + "!type": "fn()" + }, + "drawWaiting": { + "!doc": "绘制等待界面", + "!type": "fn(text: string)" + }, + "setFont": { + "!doc": "设置某个canvas的文字字体", + "!url": "https://www.w3school.com.cn/tags/canvas_font.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, font: string)" + }, + "drawChoices": { + "!doc": "绘制一个选项界面", + "!type": "fn(content?: string, choices?: [?])" + }, + "setFontForMaxWidth": { + "!doc": "根据最大宽度自动缩小字体", + "!type": "fn(name: string|CanvasRenderingContext2D, text: string, maxWidth: number, font?: ?) -> string" + }, + "clearMap": { + "!doc": "清空某个画布图层
name为画布名,可以是系统画布之一,也可以是任意自定义动态创建的画布名;还可以直接传画布的context本身。(下同)
如果name也可以是'all',若为all则为清空所有系统画布。", + "!url": "https://www.w3school.com.cn/tags/canvas_clearrect.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x?: number, y?: number, width?: number, height?: number)" + }, + "drawTextContent": { + "!doc": "绘制一段文字到某个画布上面
ctx: 要绘制到的画布
content: 要绘制的内容;转义字符不允许保留 \\t, \\b 和 \\f
config: 绘制配置项,目前暂时包含如下内容(均为可选)
left, top:起始点位置;maxWidth:单行最大宽度;color:默认颜色;align:左中右
fontSize:字体大小;lineHeight:行高;time:打字机间隔
返回值:绘制信息", + "!type": "fn(ctx: string|CanvasRenderingContext2D, content: string, config: ?)" + }, + "calWidth": { + "!doc": "计算某段文字的宽度", + "!url": "https://www.w3school.com.cn/tags/canvas_measuretext.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, text: string, font?: string) -> number" + }, + "fillArc": { + "!doc": "在某个canvas上绘制一个扇形", + "!url": "https://www.w3school.com.cn/tags/canvas_arc.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, r: number, start: number, end: number, style?: string)" + }, + "drawWindowSelector": { + "!doc": "绘制选择光标", + "!type": "fn(background: ?, x: number, y: number, w: number, h: number)" + }, + "strokeArc": { + "!doc": "在某个canvas上绘制一段弧", + "!url": "https://www.w3school.com.cn/tags/canvas_arc.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, r: number, start: number, end: number, style?: string, lineWidth?: number)" + }, + "drawLine": { + "!doc": "在某个canvas上绘制一条线", + "!url": "https://www.w3school.com.cn/tags/canvas_lineto.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, style?: string, lineWidth?: number)" + }, + "drawPagination": { + "!doc": "绘制分页", + "!type": "fn(page?: ?, totalPage?: ?, y?: number)" + }, + "drawBookDetail": { + "!doc": "绘制怪物属性的详细信息", + "!type": "fn(index?: ?)" + }, + "drawToolbox": { + "!doc": "绘制道具栏", + "!type": "fn(index?: ?)" + }, + "drawHelp": { + "!doc": "绘制帮助页面", + "!type": "fn()" + }, + "drawQuickShop": { + "!doc": "绘制快捷商店选择栏", + "!type": "fn()" + }, + "drawCenterFly": { + "!doc": "绘制中心对称飞行器", + "!type": "fn()" + }, + "strokeRect": { + "!doc": "绘制一个矩形的边框
style: 绘制的样式", + "!url": "https://www.w3school.com.cn/tags/canvas_strokerect.asp", + "!type": "fn(name: CtxRefer, x: number, y: number, width: number, height: number, style: string)" + }, + "drawBook": { + "!doc": "绘制怪物手册", + "!type": "fn(index?: ?)" + }, + "fillRoundRect": { + "!doc": "在某个canvas上绘制一个圆角矩形", + "!type": "fn(name: string|CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, style?: string, angle?: number)" + }, + "fillBoldText": { + "!doc": "在某个画布上绘制一个描黑边的文字
text: 要绘制的文本
style: 绘制的样式
font: 绘制的字体", + "!type": "fn(name: CtxRefer, text: string, x: number, y: number, style: string, font: string)" + }, + "drawSyncSave": { + "!doc": "绘制存档同步界面", + "!type": "fn()" + }, + "saveCanvas": { + "!doc": "保存某个canvas状态", + "!type": "fn(name: string|CanvasRenderingContext2D)" + }, + "drawCursor": { + "!doc": "绘制键盘光标", + "!type": "fn()" + }, + "createCanvas": { + "!doc": "动态创建一个画布。name为要创建的画布名,如果已存在则会直接取用当前存在的。
x,y为创建的画布相对窗口左上角的像素坐标,width,height为创建的长宽。
zIndex为创建的纵向高度(关系到画布之间的覆盖),z值高的将覆盖z值低的;系统画布的z值可在个性化中查看。
返回创建的画布的context,也可以通过core.dymCanvas[name]调用。
name:
x:
y:
width:
height:
zIndex:", + "!type": "fn(name: string, x: number, y: number, width: number, height: number, zIndex: number) -> CanvasRenderingContext2D" + }, + "setTextAlign": { + "!doc": "设置某个canvas的对齐", + "!url": "https://www.w3school.com.cn/tags/canvas_textalign.asp", + "!type": "fn(name: string|CanvasRenderingContext2D, align: string)" + }, + "drawMaps": { + "!doc": "绘制浏览地图界面", + "!type": "fn(index?: ?, x?: number, y?: number)" + } + }, + "enemys": { + "!doc": "怪物处理的相关函数", + "getSpecialHint": { + "!doc": "获得某种敌人的某种特殊属性的介绍
例如:core.getSpecialHint('bat', 1) // '先攻:怪物首先攻击'
enemy: 敌人id或敌人对象,用于确定属性的具体数值,否则可选
special: 属性编号,可以是该敌人没有的属性
返回值:属性的介绍,以属性名加中文冒号开头", + "!type": "fn(enemy: string|enemy, special: number) -> string" + }, + "getSpecialText": { + "!doc": "获得某种敌人的全部特殊属性名称
例如:core.getSpecialText('greenSlime') // ['先攻', '3连击', '破甲', '反击']
enemy: 敌人id或敌人对象,如core.material.enemys.greenSlime
返回值:字符串数组", + "!type": "fn(enemy: string|enemy) -> [string]" + }, + "hasSpecial": { + "!doc": "判定某种特殊属性的有无
例如:core.hasSpecial('greenSlime', 1) // 判定绿头怪有无先攻属性
special: 敌人id或敌人对象或正整数数组或自然数
test: 待检查的属性编号
", + "!type": "fn(special: number|[number]|string|number, test: number) -> bool" + }, + "canBattle": { + "!doc": "判定主角当前能否打败某只敌人
例如:core.canBattle('greenSlime',0,0,'MT0') // 能否打败主塔0层左上角的绿头怪(假设有)
enemy: 敌人id或敌人对象
x: 敌人的横坐标,可选
y: 敌人的纵坐标,可选
floorId: 敌人所在的地图,可选
返回值:true表示可以打败,false表示无法打败", + "!type": "fn(enemy: string|enemy, x?: number, y?: number, floorId?: string) -> bool" + }, + "getDamage": { + "!doc": "获得某只敌人对主角的总伤害
例如:core.getDamage('greenSlime',0,0,'MT0') // 绿头怪的总伤害
enemy: 敌人id或敌人对象
x: 敌人的横坐标,可选
y: 敌人的纵坐标,可选
floorId: 敌人所在的地图,可选
返回值:总伤害,如果因为没有破防或无敌怪等其他原因无法战斗,则返回null", + "!type": "fn(enemy: string|enemy, x?: number, y?: number, floorId?: string) -> number" + }, + "getDamageString": { + "!doc": "获得某只敌人的地图显伤,包括颜色
例如:core.getDamageString('greenSlime', 0, 0, 'MT0') // 绿头怪的地图显伤
enemy: 敌人id或敌人对象
x: 敌人的横坐标,可选
y: 敌人的纵坐标,可选
floorId: 敌人所在的地图,可选
返回值:damage: 表示伤害值或为'???',color: 形如'#RrGgBb'", + "!type": "fn(enemy: string|enemy, x?: number, y?: number, floorId?: string) -> {color: string, damage: string}" + } + }, + "events": { + "!doc": "事件处理相关的函数", + "afterChangeFloor": { + "!doc": "转换楼层结束的事件", + "!type": "fn(floorId?: string)" + }, + "popEventLoc": { + "!doc": "将当前点坐标入栈", + "!type": "fn()" + }, + "afterOpenDoor": { + "!doc": "开一个门后触发的事件", + "!type": "fn(doorId?: string, x?: number, y?: number)" + }, + "checkLvUp": { + "!doc": "检查升级事件", + "!type": "fn()" + }, + "insertAction": { + "!doc": "插入事件
例如:core.insertAction('一段文字'); // 插入一个显示文章
action: 单个事件指令,或事件指令数组
x: 新的当前点横坐标,可选
y: 新的当前点纵坐标,可选
callback: 新的回调函数,可选
addToLast: 插入的位置,true表示插入到末尾,否则插入到开头", + "!type": "fn(action: string|?|[?], x?: number, y?: number, callback?: fn(), addToLast?: bool)" + }, + "unfollow": { + "!doc": "取消跟随", + "!type": "fn(name?: string)" + }, + "hasVisitedFloor": { + "!doc": "是否到达过某个楼层", + "!type": "fn(floorId?: string) -> bool" + }, + "startEvents": { + "!doc": "开始执行一系列自定义事件", + "!type": "fn(list?: [?], x?: number, y?: number, callback?: fn())" + }, + "setHeroIcon": { + "!doc": "更改主角行走图
例如:core.setHeroIcon('npc48.png', true); // 把主角从阳光变成样板0层左下角的小姐姐,但不立即刷新
name: 新的行走图文件名,可以是全塔属性中映射前的中文名。映射后会被存入core.status.hero.image
noDraw: true表示不立即刷新(刷新会导致大地图下视野重置到以主角为中心)", + "!type": "fn(name: string, noDraw?: bool)" + }, + "changingFloor": { + "!doc": "楼层转换中", + "!type": "fn(floorId?: string, heroLoc?: {x: number, y: number, direction: string})" + }, + "setEvents": { + "!doc": "直接设置事件列表", + "!type": "fn(list?: [?], x?: number, y?: number, callback?: fn())" + }, + "setValue": { + "!doc": "数值操作", + "!type": "fn(name: string, operator: string, value: ?, prefix?: string)" + }, + "precompile": { + "!doc": "预编辑事件", + "!type": "fn(data?: ?)" + }, + "vibrate": { + "!doc": "视野左右抖动
例如:core.vibrate(); // 视野左右抖动1秒
time: 抖动时长,单位为毫秒。必须为半秒的倍数,不填或小于1秒都视为1秒
callback: 抖动平息后的回调函数,可选", + "!type": "fn(time?: number, callback?: fn())" + }, + "confirmRestart": { + "!doc": "询问是否需要重新开始", + "!type": "fn()" + }, + "battle": { + "!doc": "战斗,如果填写了坐标就会删除该点的敌人并触发战后事件
例如:core.battle('greenSlime'); // 和从天而降的绿头怪战斗(如果打得过)
id: 敌人id,必填
x: 敌人的横坐标,可选
y: 敌人的纵坐标,可选
force: true表示强制战斗,可选
callback: 回调函数,可选", + "!type": "fn(id: string, x?: number, y?: number, force?: bool, callback?: fn())" + }, + "follow": { + "!doc": "跟随", + "!type": "fn(name: string)" + }, + "beforeBattle": { + "!doc": "战斗前触发的事件;返回false代表不进行战斗", + "!type": "fn(enemyId?: string, x?: number, y?: number) -> bool" + }, + "registerEvent": { + "!doc": "注册一个自定义事件
type: 事件类型
func: 事件的处理函数,可接受(data, x, y, prefix)参数
data为事件内容,x和y为当前点坐标(可为null),prefix为当前点前缀", + "!type": "fn(type: string, func: fn(data: ?, x?: number, y?: number, prefix?: string))" + }, + "flyTo": { + "!doc": "飞往某一层", + "!type": "fn(toId?: string, callback?: fn()) -> bool" + }, + "afterGetItem": { + "!doc": "获得一个道具后的事件", + "!type": "fn(id?: string, x?: number, y?: number, isGentleClick?: bool)" + }, + "doAction": { + "!doc": "执行下一个事件指令,常作为回调
例如:core.setCurtain([0,0,0,1], undefined, core.doAction); // 事件中的原生脚本,配合勾选“不自动执行下一个事件”来达到此改变色调只持续到下次场景切换的效果
keepUI: true表示不清除UI画布和选择光标", + "!type": "fn(keepUI?: true)" + }, + "openBook": { + "!doc": "点击怪物手册时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "getNextItem": { + "!doc": "获得面前的物品(轻按)", + "!type": "fn(noRoute?: bool)" + }, + "hasAsync": { + "!doc": "当前是否有未处理完毕的异步事件", + "!type": "fn() -> bool" + }, + "openEquipbox": { + "!doc": "点击装备栏时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "recoverEvents": { + "!doc": "恢复一个事件", + "!type": "fn(data?: ?)" + }, + "setGlobalFlag": { + "!doc": "设置一个系统开关
例如:core.setGlobalFlag('steelDoorWithoutKey', true); // 使全塔的所有铁门都不再需要钥匙就能打开
name: 系统开关的英文名
value: 开关的新值,您可以用!core.flags[name]简单地表示将此开关反转", + "!type": "fn(name: string, value: bool)" + }, + "moveImage": { + "!doc": "移动一张图片并/或改变其透明度
例如:core.moveImage(1, null, 0.5); // 1秒内把1号图片变为50%透明
code: 图片编号
to: 新的左上角坐标,省略表示原地改变透明度
opacityVal: 新的透明度,省略表示不变
time: 移动用时,单位为毫秒。不填视为1秒
callback: 图片移动完毕后的回调函数,可选", + "!type": "fn(code: number, to?: [number], opacityVal?: number, time?: number, callback?: fn())" + }, + "openSettings": { + "!doc": "点击设置按钮时的操作", + "!type": "fn(fromUserAction?: bool)" + }, + "afterPushBox": { + "!doc": "推箱子后的事件", + "!type": "fn()" + }, + "unregisterSystemEvent": { + "!doc": "注销一个系统事件", + "!type": "fn(type: string)" + }, + "trigger": { + "!doc": "触发(x,y)点的事件", + "!type": "fn(x?: number, y?: number, callback?: fn())" + }, + "restart": { + "!doc": "重新开始游戏;此函数将回到标题页面", + "!type": "fn()" + }, + "doEvent": { + "!doc": "执行一个自定义事件", + "!type": "fn(data?: ?, x?: number, y?: number, prefix?: string)" + }, + "win": { + "!doc": "游戏获胜事件", + "!type": "fn(reason?: string, norank?: bool, noexit?: bool)" + }, + "setGlobalAttribute": { + "!doc": "设置全塔属性", + "!type": "fn(name: string, value: string)" + }, + "openToolbox": { + "!doc": "点击工具栏时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "setVolume": { + "!doc": "调节bgm的音量
例如:core.setVolume(0, 100, core.jumpHero); // 0.1秒内淡出bgm,然后主角原地跳跃半秒
value: 新的音量,为0或不大于1的正数。注意系统设置中是这个值的平方根的十倍
time: 渐变用时,单位为毫秒。不填或小于100毫秒都视为0
callback: 渐变完成后的回调函数,可选", + "!type": "fn(value: number, time?: number, callback?: fn())" + }, + "pushEventLoc": { + "!doc": "将当前点坐标入栈", + "!type": "fn(x?: number, y?: number, floorId?: string) -> bool" + }, + "openKeyBoard": { + "!doc": "点击虚拟键盘时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "insertCommonEvent": { + "!doc": "往当前事件列表之前或之后添加一个公共事件", + "!type": "fn(name?: string, args?: [?], x?: number, y?: number, callback?: fn(), addToLast?: bool)" + }, + "hideImage": { + "!doc": "隐藏一张图片
例如:core.hideImage(1, 1000, core.jumpHero); // 1秒内淡出1号图片,然后主角原地跳跃半秒
code: 图片编号
time: 淡出时间,单位为毫秒
callback: 图片完全消失后的回调函数,可选", + "!type": "fn(code: number, time?: number, callback?: fn())" + }, + "visitFloor": { + "!doc": "到达某楼层", + "!type": "fn(floorId?: string)" + }, + "openQuickShop": { + "!doc": "点击快捷商店按钮时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "afterBattle": { + "!doc": "战斗结束后触发的事件", + "!type": "fn(enemyId?: string, x?: number, y?: number)" + }, + "pushBox": { + "!doc": "推箱子", + "!type": "fn(data?: ?)" + }, + "autoEventExecuted": { + "!doc": "当前是否执行过某个自动事件", + "!type": "fn(symbol?: string, value?: ?) -> bool" + }, + "addValue": { + "!doc": "数值增减", + "!type": "fn(name: string, value: ?, prefix?: string)" + }, + "onSki": { + "!doc": "当前是否在冰上", + "!type": "fn(number?: number) -> bool" + }, + "showImage": { + "!doc": "显示一张图片
例如:core.showImage(1, core.material.images.images['winskin.png'], [0,0,128,128], [0,0,416,416], 0.5, 1000); // 裁剪winskin.png的最左边128×128px,放大到铺满整个视野,1秒内淡入到50%透明,编号为1
code: 图片编号,为不大于50的正整数,加上100后就是对应画布层的z值,较大的会遮罩较小的,注意色调层的z值为125,UI层为140
image: 图片文件名(可以是全塔属性中映射前的中文名)或图片对象(见上面的例子)
sloc: 一行且至多四列的数组,表示从原图裁剪的左上角坐标和宽高,可选
loc: 一行且至多四列的数组,表示图片在视野中的左上角坐标和宽高,可选
opacityVal: 不透明度,为小于1的正数。不填视为1
time: 淡入时间,单位为毫秒。不填视为0
callback: 图片完全显示出来后的回调函数,可选", + "!type": "fn(code: number, image: string|image, sloc?: [number], loc?: [number], opacityVal?: number, time?: number, callback?: fn())" + }, + "getItem": { + "!doc": "获得道具并提示,如果填写了坐标就会删除该点的该道具
例如:core.getItem('book'); // 获得敌人手册并提示
id: 道具id,必填
num: 获得的数量,不填视为1,填了就别填坐标了
x: 道具的横坐标,可选
y: 道具的纵坐标,可选
callback: 回调函数,可选", + "!type": "fn(id: string, num?: number, x?: number, y?: number, callback?: fn())" + }, + "registerSystemEvent": { + "!doc": "注册一个系统事件
type: 事件名
func: 为事件的处理函数,可接受(data,callback)参数", + "!type": "fn(type: string, func: fn(data?: ?, callback?: fn()))" + }, + "startGame": { + "!doc": "开始新游戏
例如:core.startGame('咸鱼乱撞', 0, ''); // 开始一局咸鱼乱撞难度的新游戏,随机种子为0
hard: 难度名,会显示在左下角(横屏)或右下角(竖屏)
seed: 随机种子,相同的种子保证了录像的可重复性
route: 经由base64压缩后的录像,用于从头开始的录像回放
callback: 回调函数,可选", + "!type": "fn(hard: string, seed: number, route: string, callback?: fn())" + }, + "doSystemEvent": { + "!doc": "执行一个系统事件", + "!type": "fn(type: string, data?: ?, callback?: fn())" + }, + "resetGame": { + "!doc": "初始化游戏", + "!type": "fn(hero?: ?, hard?: ?, floorId?: string, maps?: ?, values?: ?)" + }, + "setFloorInfo": { + "!doc": "设置一项楼层属性并刷新状态栏
例如:core.setFloorInfo('ratio', 2, 'MT0'); // 把主塔0层的血瓶和宝石变为双倍效果
name: 'title','name','canFlyTo','canUseQuickShop','cannotViewMap','cannotMoveDirectly','upFloor','downFloor','defaultGround','images','color','weather','bgm','ratio','underGround'之一
values: 属性的新值,可选。对'title'、'name'、'defaultGround'和'bgm'需要是字符串,对'underGround'和四个'canXxx'需要是布尔值,对两个'xxxFloor'需要是一行两列的自然数数组,对'ratio'需要是数字
floorId: 楼层id,不填视为当前层
prefix: 独立开关前缀,一般不需要,下同", + "!type": "fn(name: string, values: ?, floorId?: string, prefix?: string)" + }, + "openDoor": { + "!doc": "开门(包括三种基础墙)
例如:core.openDoor(0, 0, true, core.jumpHero); // 打开左上角的门,需要钥匙,然后主角原地跳跃半秒
x: 门的横坐标
y: 门的纵坐标
needKey: true表示需要钥匙,会导致机关门打不开
callback: 门完全打开后或打不开时的回调函数,可选", + "!type": "fn(x: number, y: number, needKey?: bool, callback?: fn())" + }, + "setEnemy": { + "!doc": "设置一项敌人属性并计入存档
例如:core.setEnemy('greenSlime', 'def', 0); // 把绿头怪的防御设为0
id: 敌人id
name: 属性的英文缩写
value: 属性的新值,可选
prefix: 独立开关前缀,一般不需要,下同", + "!type": "fn(id: string, name: string, value: ?, prefix?: string)" + }, + "autoEventExecuting": { + "!doc": "当前是否在执行某个自动事件", + "!type": "fn(symbol?: string, value?: ?) -> bool" + }, + "checkAutoEvents": { + "!doc": "检测自动事件", + "!type": "fn()" + }, + "showGif": { + "!doc": "绘制一张动图或擦除所有动图
例如:core.showGif(); // 擦除所有动图
name: 动图文件名,可以是全塔属性中映射前的中文名
x: 动图在视野中的左上角横坐标
y: 动图在视野中的左上角纵坐标", + "!type": "fn(name?: string, x?: number, y?: number)" + }, + "unregisterEvent": { + "!doc": "注销一个自定义事件", + "!type": "fn(type: string)" + }, + "jumpHero": { + "!doc": "主角跳跃,跳跃勇士。ex和ey为目标点的坐标,可以为null表示原地跳跃。time为总跳跃时间。
例如:core.jumpHero(); // 主角原地跳跃半秒
ex: 跳跃后的横坐标
ey: 跳跃后的纵坐标
time: 跳跃时长,单位为毫秒。不填视为半秒
callback: 跳跃完毕后的回调函数,可选", + "!type": "fn(ex?: number, ey?: number, time?: number, callback?: fn())" + }, + "closeDoor": { + "!doc": "关门,目标点必须为空地
例如:core.closeDoor(0, 0, 'yellowWall', core.jumpHero); // 在左上角关掉一堵黄墙,然后主角原地跳跃半秒
x: 横坐标
y: 纵坐标
id: 门的id,也可以用三种基础墙
callback: 门完全关上后的回调函数,可选", + "!type": "fn(x: number, y: number, id: string, callback?: fn())" + }, + "eventMoveHero": { + "!doc": "强制移动主角(包括后退),这个函数的作者已经看不懂这个函数了
例如:core.eventMoveHero(['forward'], 125, core.jumpHero); // 主角强制前进一步,用时1/8秒,然后主角原地跳跃半秒
steps: 步伐数组,注意后退时跟随者的行为会很难看
time: 每步的用时,单位为毫秒。0或不填则取主角的移速,如果后者也不存在就取0.1秒
callback: 移动完毕后的回调函数,可选", + "!type": "fn(steps: [step], time?: number, callback?: fn())" + }, + "changeFloor": { + "!doc": "场景切换
例如:core.changeFloor('MT0'); // 传送到主塔0层,主角坐标和朝向不变,黑屏时间取全塔属性中的值
floorId: 传送的目标地图id,可以填':before'和':after'分别表示楼下或楼上
stair: 传送的位置,可以填':now'(保持不变,可省略),':symmetry'(中心对称),':symmetry_x'(左右对称),':symmetry_y'(上下对称)或图块id(该图块最好在目标层唯一,一般为'downFloor'或'upFloor')
heroLoc: 传送的坐标(如果填写了,就会覆盖上述的粗略目标位置)和传送后主角的朝向(不填表示保持不变)
time: 传送的黑屏时间,单位为毫秒。可以填0(无黑屏)或不小于100的正整数,也可以省略(取全塔属性中的值)
callback: 黑屏结束后的回调函数,可选(这居然不是最后一个参数)
fromLoad: 本次场景切换是否为读档,读档会提示且没有黑屏,不会触发“每次到达事件”,也不会导致重生怪复活", + "!type": "fn(floorId: string, stair?: string, heroLoc?: {x?: number, y?: number, direction?: string}, time?: number, callback?: fn(), fromLoad?: bool)" + }, + "getCommonEvent": { + "!doc": "获得一个公共事件", + "!type": "fn(name: string) -> [?]" + }, + "lose": { + "!doc": "游戏失败事件", + "!type": "fn(reason?: string)" + }, + "gameOver": { + "!doc": "游戏结束
例如:core.gameOver(); // 游戏失败
ending: 结局名,省略表示失败
fromReplay: true表示在播放录像,可选
norank: true表示不计入榜单,可选", + "!type": "fn(ending?: string, fromReplay?: bool, norank?: bool)" + }, + "useFly": { + "!doc": "点击楼层传送器时的打开操作", + "!type": "fn(fromUserAction?: bool)" + }, + "tryUseItem": { + "!doc": "尝试使用一个道具
例如:core.tryUseItem('pickaxe'); // 尝试使用破墙镐
itemId: 道具id,其中敌人手册、传送器和飞行器会被特殊处理", + "!type": "fn(itemId: string)" + } + } + }, + "hero": { + "!type": "heroStatus", + "!doc": "勇士信息,为 core.status.hero 的简写", + }, + "flags": { + "!doc": "游戏中用到的变量,为 core.status.hero.flags 的简写", + "hatred":{ + "!type": "number", + "!doc": "当前仇恨值" + }, + "poison":{ + "!type": "bool", + "!doc": "是否处于中毒状态" + }, + "weak":{ + "!type": "number", + "!doc": "是否处于衰弱状态" + }, + "curse":{ + "!type": "number", + "!doc": "是否处于诅咒状态" + }, + "no_zone": { + "!type": "bool", + "!doc": "无视领域伤害" + }, + "no_repulse": { + "!type": "bool", + "!doc": "无视阻击伤害" + }, + "no_lasel": { + "!type": "bool", + "!doc": "无视激光伤害" + }, + "no_ambush": { + "!type": "bool", + "!doc": "无视捕捉" + }, + "__bgm__": { + "!type": "string", + "!doc": "背景音乐" + }, + "__weather__": { + "!doc": "天气" + }, + "__color__": { + "!doc": "色调" + }, + } + } +]; \ No newline at end of file diff --git a/_server/CodeMirror/jshint.min.js b/_server/CodeMirror/jshint.min.js index edd851ba..0acbc1d0 100644 --- a/_server/CodeMirror/jshint.min.js +++ b/_server/CodeMirror/jshint.min.js @@ -1 +1 @@ -var JSHINT;"undefined"==typeof window&&(window={}),function(){var e;e=function t(n,r,i){function o(a,u){if(!r[a]){if(!n[a]){var c="function"==typeof e&&e;if(!u&&c)return c(a,!0);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[a]={exports:{}};n[a][0].call(f.exports,function(e){var t=n[a][1][e];return o(t||e)},f,f.exports,t,n,r,i)}return r[a].exports}for(var s="function"==typeof e&&e,a=0;a=65&&i<=90||95===i||i>=97&&i<=122;for(var o=[],i=0;i<128;i++)o[i]=r[i]||i>=48&&i<=57;t.exports={asciiIdentifierStartTable:r,asciiIdentifierPartTable:o}},{}],2:[function(e,t,n){var r=[];[[768,112],[1155,5],[1425,45],1472,[1473,2],[1476,2],1480,[1552,11],[1611,31],1649,[1750,7],[1759,6],[1767,2],[1770,4],[1776,10],1810,[1840,27],[1958,11],[1984,10],[2027,9],[2070,4],[2075,9],[2085,3],[2089,5],[2137,3],[2276,27],[2304,4],[2362,3],[2366,18],[2385,7],[2402,2],[2406,10],[2433,3],2493,[2494,7],[2503,2],[2507,3],2520,[2530,2],[2534,10],[2561,3],2621,[2622,5],[2631,2],[2635,3],2642,[2662,12],2678,[2689,3],2749,[2750,8],[2759,3],[2763,3],[2786,2],[2790,10],[2817,3],2877,[2878,7],[2887,2],[2891,3],[2902,2],[2914,2],[2918,10],2947,[3006,5],[3014,3],[3018,4],3032,[3046,10],[3073,3],[3134,7],[3142,3],[3146,4],[3157,2],[3170,2],[3174,10],[3202,2],3261,[3262,7],[3270,3],[3274,4],[3285,2],[3298,2],[3302,10],[3330,2],[3390,7],[3398,3],[3402,4],3416,[3426,2],[3430,10],[3458,2],3531,[3535,6],3543,[3544,8],[3570,2],3634,[3636,7],[3655,8],[3664,10],3762,[3764,6],[3771,2],[3784,6],[3792,10],[3864,2],[3872,10],3894,3896,3898,[3902,2],[3953,20],[3974,2],[3981,11],[3993,36],4039,[4139,20],[4160,10],[4182,4],[4190,3],[4194,3],[4199,7],[4209,4],[4226,12],[4239,15],[4957,3],[5906,3],[5938,3],[5970,2],[6002,2],[6068,32],6110,[6112,10],[6155,3],[6160,10],6314,[6432,12],[6448,12],[6470,10],[6576,17],[6600,2],[6608,10],[6679,5],[6741,10],[6752,29],[6783,11],[6800,10],[6912,5],[6964,17],[6992,10],[7019,9],[7040,3],[7073,13],[7088,10],[7142,14],[7204,20],[7232,10],[7248,10],[7376,3],[7380,21],7406,[7410,3],[7616,39],[7676,4],[8204,2],[8255,2],8277,[8400,13],8418,[8421,12],[11503,3],11648,[11744,32],[12330,6],[12441,2],[42528,10],42608,[42612,10],42656,[42736,2],43011,43015,43020,[43043,5],[43136,2],[43188,17],[43216,10],[43232,18],[43264,10],[43302,8],[43335,13],[43392,4],[43443,14],[43472,10],[43561,14],43588,[43596,2],[43600,10],43644,43697,[43698,3],[43703,2],[43710,2],43714,[43755,5],[43765,2],[44003,8],[44012,2],[44016,10],64287,[65024,16],[65056,7],[65075,2],[65101,3],[65296,10],65344].forEach(function(o){for(var x=0;x<(o[1]||1);x++)r.push((o[0]||o)+x)});t.exports=r},{}],3:[function(e,t,n){var r=[];[171,182,187,[192,23],[216,31],[248,458],[710,12],[736,5],749,751,[880,5],[886,2],[890,4],903,[904,3],909,[910,20],[931,83],[1015,139],[1162,158],[1329,38],1370,[1377,39],[1488,27],[1520,3],[1568,43],[1646,2],[1649,99],1750,[1765,2],[1774,2],[1786,3],1792,1809,[1810,30],[1869,89],1970,[1994,33],[2036,2],2043,[2048,22],2075,2085,2089,[2112,25],2209,[2210,11],[2308,54],2366,2385,[2392,10],[2417,7],[2425,7],[2437,8],[2447,2],[2451,22],[2474,7],2483,[2486,4],2494,2511,[2524,2],[2527,3],[2544,2],[2565,6],[2575,2],[2579,22],[2602,7],[2610,2],[2613,2],[2616,2],[2649,4],2655,[2674,3],[2693,9],[2703,3],[2707,22],[2730,7],[2738,2],[2741,5],2750,2769,[2784,2],[2821,8],[2831,2],[2835,22],[2858,7],[2866,2],[2869,5],2878,[2908,2],[2911,3],2930,2948,[2949,6],[2958,3],[2962,4],[2969,2],2973,[2974,2],[2979,2],[2984,3],[2990,12],3025,[3077,8],[3086,3],[3090,23],[3114,10],[3125,5],3134,[3160,2],[3168,2],[3205,8],[3214,3],[3218,23],[3242,10],[3253,5],3262,3295,[3296,2],[3313,2],[3333,8],[3342,3],[3346,41],3390,3407,[3424,2],[3450,6],[3461,18],[3482,24],[3507,9],3518,[3520,7],[3585,48],[3634,2],[3648,7],[3713,2],3717,[3719,2],3723,3726,[3732,4],[3737,7],[3745,3],3750,3752,[3754,2],[3757,4],[3762,2],3774,[3776,5],3783,[3804,4],3841,[3904,8],[3913,36],[3976,5],[4096,43],4160,[4176,6],[4186,4],4194,[4197,2],[4206,3],[4213,13],4239,[4256,38],4296,4302,[4304,43],[4348,333],[4682,4],[4688,7],4697,[4698,4],[4704,41],[4746,4],[4752,33],[4786,4],[4792,7],4801,[4802,4],[4808,15],[4824,57],[4882,4],[4888,67],[4992,16],[5024,85],[5121,620],[5743,17],[5761,26],[5792,75],[5870,3],[5888,13],[5902,4],[5920,18],[5952,18],[5984,13],[5998,3],[6016,52],6104,6109,[6176,88],[6272,41],6315,[6320,70],[6400,29],[6480,30],[6512,5],[6528,44],[6593,7],[6656,23],[6688,53],6824,[6917,47],[6981,7],[7043,30],[7086,2],[7098,44],[7168,36],[7245,3],[7258,36],[7401,4],[7406,4],[7413,2],[7424,192],[7680,278],[7960,6],[7968,38],[8008,6],[8016,8],8026,8028,8030,[8031,31],[8064,53],[8118,7],8127,[8130,3],[8134,7],[8144,4],[8150,6],[8160,13],[8178,3],[8182,7],8306,8320,[8336,13],8451,8456,[8458,10],8470,[8473,5],8485,8487,8489,[8490,4],[8495,11],[8508,4],[8517,5],8527,[8544,41],[11264,47],[11312,47],[11360,133],[11499,4],[11506,2],[11520,38],11560,11566,[11568,56],11632,[11648,23],[11680,7],[11688,7],[11696,7],[11704,7],[11712,7],[11720,7],[11728,7],[11736,7],11824,[12293,3],[12321,9],[12337,5],[12344,5],[12353,86],[12445,3],[12449,90],[12540,4],[12549,41],[12593,94],[12704,27],[12784,16],[13312,6582],[19968,20941],[40960,1165],[42192,46],[42240,269],[42512,16],[42538,2],[42560,47],[42623,25],[42656,80],[42775,9],[42786,103],[42891,4],[42896,4],[42912,11],[43000,10],[43011,3],[43015,4],[43020,23],[43072,52],[43138,50],[43250,6],43260,[43274,28],[43312,23],[43360,29],[43396,47],43472,[43520,41],[43584,3],[43588,8],[43616,23],43643,[43648,48],43698,[43701,2],[43705,5],43713,43715,[43739,3],[43744,11],[43762,3],[43777,6],[43785,6],[43793,6],[43808,7],[43816,7],[43968,35],[44032,11172],[55216,23],[55243,49],[63744,366],[64112,106],[64256,7],[64275,5],64286,[64287,10],[64298,13],[64312,5],64319,[64320,2],[64323,2],[64326,108],[64467,363],[64848,64],[64914,54],[65008,12],[65136,5],[65142,135],[65313,26],[65345,26],[65382,89],[65474,6],[65482,6],[65490,6],[65498,3]].forEach(function(o){for(var x=0;x<(o[1]||1);x++)r.push((o[0]||o)+x)});t.exports=r},{}],4:[function(e,t,n){function r(e,t){return h.isUndefined(t)?""+t:h.isNumber(t)&&!isFinite(t)?t.toString():h.isFunction(t)||h.isRegExp(t)?t.toString():t}function i(e,t){return h.isString(e)?e.length=0;o--)if(s[o]!=a[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!u(e[i],t[i]))return!1;return!0}function f(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function p(e,t,n,r){var i;h.isString(n)&&(r=n,n=null);try{t()}catch(e){i=e}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&s(i,n,"Missing expected exception"+r),!e&&f(i,n)&&s(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var h=e("util/"),d=Array.prototype.slice,v=Object.prototype.hasOwnProperty,g=t.exports=a;g.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var t=e.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=t.name,a=r.indexOf("\n"+i);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},h.inherits(g.AssertionError,Error),g.fail=s,g.ok=a,g.equal=function(e,t,n){e!=t&&s(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&s(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){u(e,t)||s(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){u(e,t)&&s(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&s(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&s(e,t,n,"!==",g.notStrictEqual)},g.throws=function(e,t,n){p.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(e,t){p.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var m=Object.keys||function(e){var t=[];for(var n in e)v.call(e,n)&&t.push(n);return t}},{"util/":9}],5:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(r=arguments.length,o=new Array(r-1),u=1;u0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){return e._events&&e._events[t]?i(e._events[t])?1:e._events[t].length:0}},{}],6:[function(e,t,n){function r(){if(!a){a=!0;for(var e,t=s.length;t;){e=s,s=[];for(var n=-1;++n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(t)?r.showHidden=t:t&&n._extend(r,t),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return k(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),v=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),_(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(t);if(0===s.length){if(w(t)){var g=t.name?": "+t.name:"";return e.stylize("[Function"+g+"]","special")}if(x(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(_(t))return l(t)}var m="",y=!1,b=["{","}"];if(d(t)&&(y=!0,b=["[","]"]),w(t)&&(m=" [Function"+(t.name?": "+t.name:"")+"]"),x(t)&&(m=" "+RegExp.prototype.toString.call(t)),E(t)&&(m=" "+Date.prototype.toUTCString.call(t)),_(t)&&(m=" "+l(t)),0===s.length&&(!y||0==t.length))return b[0]+m+b[1];if(r<0)return x(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=y?f(e,t,r,v,s):s.map(function(n){return p(e,t,r,v,n,y)}),e.seen.pop(),h(S,m,b)}function c(e,t){if(y(t))return e.stylize("undefined","undefined");if(k(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,i){for(var o=[],s=0,a=t.length;s-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e,t,n){var r=0;return e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function k(e){return"string"==typeof e}function y(e){return void 0===e}function x(e){return b(e)&&"[object RegExp]"===S(e)}function b(e){return"object"==typeof e&&null!==e}function E(e){return b(e)&&"[object Date]"===S(e)}function _(e){return b(e)&&("[object Error]"===S(e)||e instanceof Error)}function w(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function W(e){return e<10?"0"+e.toString(10):e.toString(10)}function A(){var e=new Date,t=[W(e.getHours()),W(e.getMinutes()),W(e.getSeconds())].join(":");return[e.getDate(),G[e.getMonth()],t].join(" ")}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var j=/%[sdj%]/g;n.format=function(e){if(!k(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),a=r[n];nt||!n||e===S&&r)return 1;if(e-1;);return n}function l(e,t){for(var n=e.length;n--&&t.indexOf(e.charAt(n))>-1;);return n}function f(e,t){return r(e.criteria,t.criteria)||e.index-t.index}function p(e,t,n){for(var i=-1,o=e.criteria,s=t.criteria,a=o.length,u=n.length;++i=u?c:c*(n[i]?1:-1)}return e.index-t.index}function h(e){return Ne[e]}function d(e){return De[e]}function v(e){return"\\"+He[e]}function g(e,t,n){for(var r=e.length,i=t+(n?0:-1);n?i--:++i=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function y(e,t){for(var n=-1,r=e.length,i=-1,o=[];++nr&&(r=i)}return r}function Ye(e,t){for(var n=-1,r=e.length;++n=200?Xi(t):null,c=t.length;u&&(s=ze,a=!1,t=u);e:for(;++ii?0:i+n),(r=r===S||r>i?i:+r||0)<0&&(r+=i),i=n>r?0:r>>>0,n>>>=0;ni?0:i+t),(n=n===S||n>i?i:+n||0)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Ur(i);++r=200,u=a?Xi():null,c=[];u?(r=ze,s=!1):(a=!1,u=t?[]:c);e:for(;++n>>1,s=e[o];(n?s<=t:s2&&n[i-2],s=i>2&&n[2],a=i>1&&n[i-1];for("function"==typeof o?(o=zt(o,a,5),i-=2):i-=(o="function"==typeof a?a:null)?1:0,s&&Gn(n[0],n[1],s)&&(o=i<3?null:o,i=1);++r-1?n[s]:S}return dt(n,r,e)}}function sn(e){return function(t,n,r){return t&&t.length?(n=wn(n,r,3),i(t,n,e)):-1}}function an(e){return function(t,n,r){return n=wn(n,r,3),dt(t,n,e,!0)}}function un(e){return function(){var t=arguments.length;if(!t)return function(){return arguments[0]};for(var n,r=e?t:-1,i=0,o=Ur(t);e?r--:++r=t||!Si(t))return"";var i=t-r;return n=null==n?" ":n+"",Or(n,ui(i/n.length)).slice(0,i)}function mn(e,t,n,r){function i(){for(var t=-1,a=arguments.length,u=-1,c=r.length,l=Ur(a+c);++uu))return!1;for(;l&&++ai)||u===r&&u===o)&&(i=u,o=e)}),o}function wn(e,n,r){var i=t.callback||Mr;return i=i===Mr?at:i,r?i(e,n,r):i}function Sn(e,n,r){var i=t.indexOf||Xn;return i=i===Xn?o:i,e?i(e,n,r):i}function Wn(e,t,n){for(var r=-1,i=n?n.length:0;++r-1&&e%1==0&&e-1&&e%1==0&&e<=Ri}function In(e){return e===e&&(0===e?1/e>0:!kr(e))}function Fn(e,t){var n=e[1],r=t[1],i=n|r,o=i>>0,r=Ur(n);++t-1:Sn(e,t,n)>-1)}function ar(e,t,n){var r=Po(e)?Xe:wt;return t=wn(t,n,3),r(e,t)}function ur(e,t,n){if(n?Gn(e,t,n):null==t){var r=(e=Dn(e)).length;return r>0?e[Gt(0,r-1)]:S}var i=cr(e);return i.length=Li(t<0?0:+t||0,i.length),i}function cr(e){for(var t=-1,n=(e=Dn(e)).length,r=Ur(n);++t0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}function pr(e,t,n){function r(){var n=t-(So()-c);if(n<=0||n>t){a&&ci(a);var i=p;a=f=p=S,i&&(h=So(),u=e.apply(l,s),f||a||(s=l=null))}else f=mi(r,n)}function i(){f&&ci(f),a=f=p=S,(v||d!==t)&&(h=So(),u=e.apply(l,s),f||a||(s=l=null))}function o(){if(s=arguments,c=So(),l=this,p=v&&(f||!g),!1===d)var n=g&&!f;else{a||g||(h=c);var o=d-(c-h),m=o<=0||o>d;m?(a&&(a=ci(a)),h=c,u=e.apply(l,s)):a||(a=mi(i,o))}return m&&f?f=ci(f):f||t===d||(f=mi(r,t)),n&&(m=!0,u=e.apply(l,s)),!m||f||a||(s=l=null),u}var s,a,u,c,l,f,p,h=0,d=!1,v=!0;if("function"!=typeof e)throw new Zr(D);if(t=t<0?0:+t||0,!0===n){var g=!0;v=!1}else kr(n)&&(g=n.leading,d="maxWait"in n&&Ai(+n.maxWait||0,t),v="trailing"in n?n.trailing:v);return o.cancel=function(){f&&ci(f),a&&ci(a),a=f=p=S},o}function hr(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new Zr(D);var n=function(){var r=arguments,i=n.cache,o=t?t.apply(this,r):r[0];if(i.has(o))return i.get(o);var s=e.apply(this,r);return i.set(o,s),s};return n.cache=new hr.Cache,n}function dr(e,t){if("function"!=typeof e)throw new Zr(D);return t=Ai(t===S?e.length-1:+t||0,0),function(){for(var n=arguments,r=-1,i=Ai(n.length-t,0),o=Ur(i);++r-1}function mr(e){return m(e)&&"string"==typeof e.message&&ri.call(e)==Z}function kr(e){var t=typeof e;return"function"==t||!!e&&"object"==t}function yr(e){return null!=e&&(ri.call(e)==X?oi.test(ei.call(e)):m(e)&&Oe.test(e))}function xr(e){return"number"==typeof e||m(e)&&ri.call(e)==K}function br(e){return m(e)&&ri.call(e)==Q||!1}function Er(e){return"string"==typeof e||m(e)&&ri.call(e)==ee}function _r(e){return m(e)&&Vn(e.length)&&!!Re[ri.call(e)]}function wr(e){return st(e,Wr(e))}function Sr(e){return yt(e,Wr(e))}function Wr(e){if(null==e)return[];kr(e)||(e=Hr(e));var t=e.length;t=t&&Vn(t)&&(Po(e)||Ni.nonEnumArgs&&vr(e))&&t||0;for(var n=e.constructor,r=-1,i="function"==typeof n&&n.prototype===e,o=Ur(t),s=t>0;++r>>1,Pi=bi?bi.BYTES_PER_ELEMENT:0,Ri=qr.pow(2,53)-1,Ui=xi&&new xi,Bi={},Ni=t.support={};!function(e){var t=function(){this.x=e},n=[];t.prototype={valueOf:e,y:e};for(var r in new t)n.push(r);Ni.funcDecomp=/\bthis\b/.test(function(){return this}),Ni.funcNames="string"==typeof Dr.name;try{Ni.dom=11===Qr.createDocumentFragment().nodeType}catch(e){Ni.dom=!1}try{Ni.nonEnumArgs=!vi.call(arguments,1)}catch(e){Ni.nonEnumArgs=!0}}(1,0),t.templateSettings={escape:ke,evaluate:ye,interpolate:xe,variable:"",imports:{_:t}};var Di=Ei||function(e,t){return null==t?e:st(t,eo(t),st(t,Xo(t),e))},qi=function(){function t(){}return function(n){if(kr(n)){t.prototype=n;var r=new t;t.prototype=null}return r||e.Object()}}(),zi=Kt(mt),Hi=Kt(kt,!0),$i=Yt(),Ji=Yt(!0),Zi=Ui?function(e,t){return Ui.set(e,t),e}:Ir;ai||(Ht=si&&yi?function(e){var t=e.byteLength,n=bi?li(t/Pi):0,r=n*Pi,i=new si(t);if(n){var o=new bi(i,0,n);o.set(new bi(e,0,n))}return t!=r&&(o=new yi(i,r)).set(new yi(e,r)),i}:Vr(null));var Xi=wi&&gi?function(e){return new qe(e)}:Vr(null),Ki=Ui?function(e){return Ui.get(e)}:Pr,Yi=Ni.funcNames?"constant"==Vr.name?jt("name"):function(e){for(var t=e.name,n=Bi[t],r=n?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==e)return i.name}return t}:Vr(""),Qi=jt("length"),eo=fi?function(e){return fi(qn(e))}:Vr([]),to=function(){var e=0,t=0;return function(n,r){var i=So(),o=R-(i-t);if(t=i,o>0){if(++e>=P)return n}else e=0;return Zi(n,r)}}(),no=dr(function(e,t){return Po(e)||vr(e)?lt(e,vt(t,!1,!0)):[]}),ro=sn(),io=sn(!0),oo=dr(function(e,t){e||(e=[]);var n=ot(e,t=vt(t));return Ot(e,t.sort(r)),n}),so=kn(),ao=kn(!0),uo=dr(function(e){return Rt(vt(e,!1,!0))}),co=dr(function(e,t){return Po(e)||vr(e)?lt(e,t):[]}),lo=dr(er),fo=dr(function(e,t){return Vn(e?Qi(e):0)&&(e=Dn(e)),ot(e,vt(t))}),po=Zt(function(e,t,n){ti.call(e,n)?++e[n]:e[n]=1}),ho=on(zi),vo=on(Hi,!0),go=cn($e,zi),mo=cn(function(e,t){for(var n=e.length;n--&&!1!==t(e[n],n,e););return e},Hi),ko=Zt(function(e,t,n){ti.call(e,n)?e[n].push(t):e[n]=[t]}),yo=Zt(function(e,t,n){e[n]=t}),xo=dr(function(e,t,n){var r=-1,i="function"==typeof t,o=Cn(t),s=Qi(e),a=Vn(s)?Ur(s):[];return zi(e,function(e){var s=i?t:o&&null!=e&&e[t];a[++r]=s?s.apply(e,n):Tn(e,t,n)}),a}),bo=Zt(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),Eo=dn(function(e,t,n,r){var i=-1,o=e.length;for(r&&o&&(n=e[++i]);++i=120?Xi(t&&u):null))}if((n=e.length)<2)return a;var c=e[0],l=-1,f=c?c.length:0,p=r[0];e:for(;++l-1;)ki.call(t,o,1);return t},t.pullAt=oo,t.range=function(e,t,n){n&&Gn(e,t,n)&&(t=n=null),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var r=-1,i=Ai(ui((t-e)/(n||1)),0),o=Ur(i);++r=0&&e.indexOf(t,n)==n},t.escape=function(e){return e=a(e),e&&me.test(e)?e.replace(ve,d):e},t.escapeRegExp=jr,t.every=ir,t.find=ho,t.findIndex=ro,t.findKey=qo,t.findLast=vo,t.findLastIndex=io,t.findLastKey=zo,t.findWhere=function(e,t){return ho(e,St(t))},t.first=Zn,t.get=function(e,t,n){var r=null==e?S:xt(e,zn(t),t+"");return r===S?n:r},t.has=function(e,t){if(null==e)return!1;var n=ti.call(e,t);return n||Cn(t)||(e=1==(t=zn(t)).length?e:xt(e,Mt(t,0,-1)),t=Kn(t),n=null!=e&&ti.call(e,t)),n},t.identity=Ir,t.includes=sr,t.indexOf=Xn,t.inRange=function(e,t,n){return t=+t||0,void 0===n?(n=t,t=0):n=+n||0,e>=Li(t,n)&&e=t||!Si(t))return e;var i=(t-r)/2,o=li(i);return(n=gn("",ui(i),n)).slice(0,o)+e+n},t.padLeft=ns,t.padRight=rs,t.parseInt=Tr,t.random=function(e,t,n){n&&Gn(e,t,n)&&(t=n=null);var r=null==e,i=null==t;if(null==n&&(i&&"boolean"==typeof e?(n=e,e=1):"boolean"==typeof t&&(n=t,i=!0)),r&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,n||e%1||t%1){var o=Gi();return Li(e+o*(t-e+parseFloat("1e-"+((o+"").length-1))),t)}return Gt(e,t)},t.reduce=Eo,t.reduceRight=_o,t.repeat=Or,t.result=function(e,t,n){var r=null==e?S:e[t];return r===S&&(null==e||Cn(t,e)||(r=null==(e=1==(t=zn(t)).length?e:xt(e,Mt(t,0,-1)))?S:e[Kn(t)]),r=r===S?n:r),Uo(r)?r.call(e):r},t.runInContext=w,t.size=function(e){var t=e?Qi(e):0;return Vn(t)?t:Xo(e).length},t.snakeCase=is,t.some=lr,t.sortedIndex=so,t.sortedLastIndex=ao,t.startCase=os,t.startsWith=function(e,t,n){return e=a(e),n=null==n?0:Li(n<0?0:+n||0,e.length),e.lastIndexOf(t,n)==n},t.sum=function(e,t,n){n&&Gn(e,t,n)&&(t=null);var r=wn(),i=null==t;return r===at&&i||(i=!1,t=r(t,n,3)),i?tt(Po(e)?e:Dn(e)):Pt(e,t)},t.template=function(e,n,r){var i=t.templateSettings;r&&Gn(e,n,r)&&(n=r=null),e=a(e),n=it(Di({},r||n),i,rt);var o,s,u=it(Di({},n.imports),i.imports,rt),c=Xo(u),l=Ut(u,c),f=0,p=n.interpolate||Ce,h="__p += '",d=$r((n.escape||Ce).source+"|"+p.source+"|"+(p===xe?Le:Ce).source+"|"+(n.evaluate||Ce).source+"|$","g"),g="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++Pe+"]")+"\n";e.replace(d,function(t,n,r,i,a,u){return r||(r=i),h+=e.slice(f,u).replace(Me,v),n&&(o=!0,h+="' +\n__e("+n+") +\n'"),a&&(s=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=u+t.length,t}),h+="';\n";var m=n.variable;m||(h="with (obj) {\n"+h+"\n}\n"),h=(s?h.replace(fe,""):h).replace(pe,"$1").replace(he,"$1;"),h="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var k=ss(function(){return Dr(c,g+"return "+h).apply(S,l)});if(k.source=h,mr(k))throw k;return k},t.trim=Gr,t.trimLeft=function(e,t,n){var r=e;return e=a(e),e?(n?Gn(r,t,n):null==t)?e.slice(b(e)):e.slice(c(e,t+"")):e},t.trimRight=function(e,t,n){var r=e;return e=a(e),e?(n?Gn(r,t,n):null==t)?e.slice(0,E(e)+1):e.slice(0,l(e,t+"")+1):e},t.trunc=function(e,t,n){n&&Gn(e,t,n)&&(t=null);var r=I,i=F;if(null!=t)if(kr(t)){var o="separator"in t?t.separator:o;r="length"in t?+t.length||0:r,i="omission"in t?a(t.omission):i}else r=+t||0;if(e=a(e),r>=e.length)return e;var s=r-i.length;if(s<1)return i;var u=e.slice(0,s);if(null==o)return u+i;if(br(o)){if(e.slice(s).search(o)){var c,l,f=e.slice(0,s);for(o.global||(o=$r(o.source,(je.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(f);)l=c.index;u=u.slice(0,null==l?s:l)}}else if(e.indexOf(o,s)!=s){var p=u.lastIndexOf(o);p>-1&&(u=u.slice(0,p))}return u+i},t.unescape=function(e){return e=a(e),e&&ge.test(e)?e.replace(de,_):e},t.uniqueId=function(e){var t=++ni;return a(e)+t},t.words=Cr,t.all=ir,t.any=lr,t.contains=sr,t.detect=ho,t.foldl=Eo,t.foldr=_o,t.head=Zn,t.include=sr,t.inject=Eo,Fr(t,function(){var e={};return mt(t,function(n,r){t.prototype[r]||(e[r]=n)}),e}(),!1),t.sample=ur,t.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return ur(t,e)}):ur(this.value())},t.VERSION=W,$e(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){t[e].placeholder=t}),$e(["dropWhile","filter","map","takeWhile"],function(e,t){var n=t!=N,r=t==U;Ne.prototype[e]=function(e,i){var o=this.__filtered__,s=o&&r?new Ne(this):this.clone();return(s.__iteratees__||(s.__iteratees__=[])).push({done:!1,count:0,index:0,iteratee:wn(e,i,1),limit:-1,type:t}),s.__filtered__=o||n,s}}),$e(["drop","take"],function(e,t){var n=e+"While";Ne.prototype[e]=function(n){var r=this.__filtered__,i=r&&!t?this.dropWhile():this.clone();return n=null==n?1:Ai(li(n)||0,0),r?t?i.__takeCount__=Li(i.__takeCount__,n):Kn(i.__iteratees__).limit=n:(i.__views__||(i.__views__=[])).push({size:n,type:e+(i.__dir__<0?"Right":"")}),i},Ne.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()},Ne.prototype[e+"RightWhile"]=function(e,t){return this.reverse()[n](e,t).reverse()}}),$e(["first","last"],function(e,t){var n="take"+(t?"Right":"");Ne.prototype[e]=function(){return this[n](1).value()[0]}}),$e(["initial","rest"],function(e,t){var n="drop"+(t?"":"Right");Ne.prototype[e]=function(){return this[n](1)}}),$e(["pluck","where"],function(e,t){var n=t?"filter":"map",r=t?St:Rr;Ne.prototype[e]=function(e){return this[n](r(e))}}),Ne.prototype.compact=function(){return this.filter(Ir)},Ne.prototype.reject=function(e,t){return e=wn(e,t,1),this.filter(function(t){return!e(t)})},Ne.prototype.slice=function(e,t){var n=(e=null==e?0:+e||0)<0?this.takeRight(-e):this.drop(e);return t!==S&&(n=(t=+t||0)<0?n.dropRight(-t):n.take(t-e)),n},Ne.prototype.toArray=function(){return this.drop(0)},mt(Ne.prototype,function(e,n){var r=t[n];if(r){var i=/^(?:filter|map|reject)|While$/.test(n),o=/^(?:first|last)$/.test(n);t.prototype[n]=function(){var n=arguments,s=(n.length,this.__chain__),a=this.__wrapped__,u=!!this.__actions__.length,c=a instanceof Ne,l=n[0],f=c||Po(a);f&&i&&"function"==typeof l&&1!=l.length&&(c=f=!1);var p=c&&!u;if(o&&!s)return p?e.call(a):r.call(t,this.value());var h=function(e){var i=[e];return hi.apply(i,n),r.apply(t,i)};if(f){var d=p?a:new Ne(this),v=e.apply(d,n);return o||!u&&!v.__actions__||(v.__actions__||(v.__actions__=[])).push({func:rr,args:[h],thisArg:t}),new k(v,s)}return this.thru(h)}}}),$e(["concat","join","pop","push","replace","shift","sort","splice","split","unshift"],function(e){var n=(/^(?:replace|split)$/.test(e)?Yr:Xr)[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(e);t.prototype[e]=function(){var e=arguments;return i&&!this.__chain__?n.apply(this.value(),e):this[r](function(t){return n.apply(t,e)})}}),mt(Ne.prototype,function(e,n){var r=t[n];if(r){var i=r.name;(Bi[i]||(Bi[i]=[])).push({name:n,func:r})}}),Bi[vn(null,L).name]=[{name:"wrapper",func:null}],Ne.prototype.clone=function(){var e=this.__actions__,t=this.__iteratees__,n=this.__views__,r=new Ne(this.__wrapped__);return r.__actions__=e?He(e):null,r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=t?He(t):null,r.__takeCount__=this.__takeCount__,r.__views__=n?He(n):null,r},Ne.prototype.reverse=function(){if(this.__filtered__){var e=new Ne(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Ne.prototype.value=function(){var e=this.__wrapped__.value();if(!Po(e))return Nt(e,this.__actions__);var t=this.__dir__,n=t<0,r=Wn(0,e.length,this.__views__),i=r.start,o=r.end,s=o-i,a=n?o:i-1,u=Li(s,this.__takeCount__),c=this.__iteratees__,l=c?c.length:0,f=0,p=[];e:for(;s--&&fv.index:a-1?v.count++>=k:!g(d)))continue e}}else{var y=g(d);if(m==N)d=y;else if(!y){if(m==B)continue e;break e}}}p[f++]=d}return p},t.prototype.chain=function(){return nr(this)},t.prototype.commit=function(){return new k(this.value(),this.__chain__)},t.prototype.plant=function(e){for(var t,r=this;r instanceof n;){var i=Hn(r);t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},t.prototype.reverse=function(){var e=this.__wrapped__;return e instanceof Ne?(this.__actions__.length&&(e=new Ne(this)),new k(e.reverse(),this.__chain__)):this.thru(function(e){return e.reverse()})},t.prototype.toString=function(){return this.value()+""},t.prototype.run=t.prototype.toJSON=t.prototype.valueOf=t.prototype.value=function(){return Nt(this.__wrapped__,this.__actions__)},t.prototype.collect=t.prototype.map,t.prototype.head=t.prototype.first,t.prototype.select=t.prototype.filter,t.prototype.tail=t.prototype.rest,t}var S,W="3.7.0",A=1,L=2,j=4,T=8,O=16,G=32,C=64,M=128,V=256,I=30,F="...",P=150,R=16,U=0,B=1,N=2,D="Expected a function",q="__lodash_placeholder__",z="[object Arguments]",H="[object Array]",$="[object Boolean]",J="[object Date]",Z="[object Error]",X="[object Function]",K="[object Number]",Y="[object Object]",Q="[object RegExp]",ee="[object String]",te="[object ArrayBuffer]",ne="[object Float32Array]",re="[object Float64Array]",ie="[object Int8Array]",oe="[object Int16Array]",se="[object Int32Array]",ae="[object Uint8Array]",ue="[object Uint8ClampedArray]",ce="[object Uint16Array]",le="[object Uint32Array]",fe=/\b__p \+= '';/g,pe=/\b(__p \+=) '' \+/g,he=/(__e\(.*?\)|\b__t\)) \+\n'';/g,de=/&(?:amp|lt|gt|quot|#39|#96);/g,ve=/[&<>"'`]/g,ge=RegExp(de.source),me=RegExp(ve.source),ke=/<%-([\s\S]+?)%>/g,ye=/<%([\s\S]+?)%>/g,xe=/<%=([\s\S]+?)%>/g,be=/\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,Ee=/^\w*$/,_e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,we=/[.*+?^${}()|[\]\/\\]/g,Se=RegExp(we.source),We=/[\u0300-\u036f\ufe20-\ufe23]/g,Ae=/\\(\\)?/g,Le=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,je=/\w*$/,Te=/^0[xX]/,Oe=/^\[object .+?Constructor\]$/,Ge=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Ce=/($^)/,Me=/['\n\r\u2028\u2029\\]/g,Ve=function(){var e="[A-Z\\xc0-\\xd6\\xd8-\\xde]",t="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(e+"+(?="+e+t+")|"+e+"?"+t+"|"+e+"+|[0-9]+","g")}(),Ie=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",Fe=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window"],Pe=-1,Re={};Re[ne]=Re[re]=Re[ie]=Re[oe]=Re[se]=Re[ae]=Re[ue]=Re[ce]=Re[le]=!0,Re[z]=Re[H]=Re[te]=Re[$]=Re[J]=Re[Z]=Re[X]=Re["[object Map]"]=Re[K]=Re[Y]=Re[Q]=Re["[object Set]"]=Re[ee]=Re["[object WeakMap]"]=!1;var Ue={};Ue[z]=Ue[H]=Ue[te]=Ue[$]=Ue[J]=Ue[ne]=Ue[re]=Ue[ie]=Ue[oe]=Ue[se]=Ue[K]=Ue[Y]=Ue[Q]=Ue[ee]=Ue[ae]=Ue[ue]=Ue[ce]=Ue[le]=!0,Ue[Z]=Ue[X]=Ue["[object Map]"]=Ue["[object Set]"]=Ue["[object WeakMap]"]=!1;var Be={leading:!1,maxWait:0,trailing:!1},Ne={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},De={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qe={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},ze={function:!0,object:!0},He={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$e=ze[typeof n]&&n&&!n.nodeType&&n,Je=ze[typeof t]&&t&&!t.nodeType&&t,Ze=$e&&Je&&"object"==typeof e&&e&&e.Object&&e,Xe=ze[typeof self]&&self&&self.Object&&self,Ke=ze[typeof window]&&window&&window.Object&&window,Ye=Je&&Je.exports===$e&&$e,Qe=Ze||Ke!==(this&&this.window)&&Ke||Xe||this,et=w();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Qe._=et,define(function(){return et})):$e&&Je?Ye?(Je.exports=et)._=et:$e._=et:Qe._=et}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(e,t,n){"use strict";function r(e){return/^[0-9a-fA-F]+$/.test(e)}function i(e){return 1===e.length&&r(e)}function o(){var e=[];return{push:function(t){e.push(t)},check:function(){for(var t=0;t0&&this.context[this.context.length-1].type===e},pushContext:function(e){this.context.push({type:e})},popContext:function(){return this.context.pop()},isContext:function(e){return this.context.length>0&&this.context[this.context.length-1]===e},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=l.lines,this._lines},setLines:function(e){this._lines=e,l.lines=this._lines},peek:function(e){return this.input.charAt(e||0)},skip:function(e){e=e||1,this.char+=e,this.input=this.input.slice(e)},on:function(e,t){e.split(" ").forEach(function(e){this.emitter.on(e,t)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(e,t,n,r){n.push(function(){r()&&this.trigger(e,t)}.bind(this))},scanPunctuator:function(){var e,t,n,r=this.peek();switch(r){case".":if(/^[0-9]$/.test(this.peek(1)))return null;if("."===this.peek(1)&&"."===this.peek(2))return{type:g.Punctuator,value:"..."};case"(":case")":case";":case",":case"[":case"]":case":":case"~":case"?":return{type:g.Punctuator,value:r};case"{":return this.pushContext(m.Block),{type:g.Punctuator,value:r};case"}":return this.inContext(m.Block)&&this.popContext(),{type:g.Punctuator,value:r};case"#":return{type:g.Punctuator,value:r};case"":return null}return e=this.peek(1),t=this.peek(2),n=this.peek(3),">"===r&&">"===e&&">"===t&&"="===n?{type:g.Punctuator,value:">>>="}:"="===r&&"="===e&&"="===t?{type:g.Punctuator,value:"==="}:"!"===r&&"="===e&&"="===t?{type:g.Punctuator,value:"!=="}:">"===r&&">"===e&&">"===t?{type:g.Punctuator,value:">>>"}:"<"===r&&"<"===e&&"="===t?{type:g.Punctuator,value:"<<="}:">"===r&&">"===e&&"="===t?{type:g.Punctuator,value:">>="}:"="===r&&">"===e?{type:g.Punctuator,value:r+e}:r===e&&"+-<>&|".indexOf(r)>=0?{type:g.Punctuator,value:r+e}:"<>=!+-*%&|^/".indexOf(r)>=0?"="===e?{type:g.Punctuator,value:r+e}:{type:g.Punctuator,value:r}:null},scanComments:function(e){function t(e,t,n){var r=["jshint","jslint","members","member","globals","global","exported"],i=!1,o=e+t,s="plain";return(n=n||{}).isMultiline&&(o+="*/"),t=t.replace(/\n/g," "),"/*"===e&&c.fallsThrough.test(t)&&(i=!0,s="falls through"),r.forEach(function(n){if(!i&&("//"!==e||"jshint"===n)&&(" "===t.charAt(n.length)&&t.substr(0,n.length)===n&&(i=!0,e+=n,t=t.substr(n.length)),i||" "!==t.charAt(0)||" "!==t.charAt(n.length+1)||t.substr(1,n.length)!==n||(i=!0,e=e+" "+n,t=t.substr(n.length+1)),i))switch(n){case"member":s="members";break;case"global":s="globals";break;default:var r=t.split(":").map(function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")});if(2===r.length)switch(r[0]){case"ignore":switch(r[1]){case"start":a.ignoringLinterErrors=!0,i=!1;break;case"end":a.ignoringLinterErrors=!1,i=!1}}s=n}}),{type:g.Comment,commentType:s,value:o,body:t,isSpecial:i,isMultiline:n.isMultiline||!1,isMalformed:n.isMalformed||!1}}var n=this.peek(),r=this.peek(1),i=this.input.substr(2),o=this.line,s=this.char,a=this;if("*"===n&&"/"===r)return this.trigger("error",{code:"E018",line:o,character:s}),this.skip(2),null;if("/"!==n||"*"!==r&&"/"!==r)return null;if("/"===r)return this.skip(this.input.length),t("//",i);var u="";if("*"===r){for(this.inComment=!0,this.skip(2);"*"!==this.peek()||"/"!==this.peek(1);)if(""===this.peek()){if(u+="\n",!this.nextLine(e))return this.trigger("error",{code:"E017",line:o,character:s}),this.inComment=!1,t("/*",u,{isMultiline:!0,isMalformed:!0})}else u+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,t("/*",u,{isMultiline:!0})}},scanKeyword:function(){var e=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),t=["if","in","do","var","for","new","try","let","this","else","case","void","with","enum","while","break","catch","throw","const","yield","class","super","return","typeof","delete","switch","export","import","default","finally","extends","function","continue","debugger","instanceof"];return e&&t.indexOf(e[0])>=0?{type:g.Keyword,value:e[0]}:null},scanIdentifier:function(){function e(e){return d.indexOf(e)>-1}function t(t){return e(t)||v.indexOf(t)>-1}var n,i,o="",s=0,a=function(){if(s+=1,"u"!==this.peek(s))return null;var e,n=this.peek(s+1)+this.peek(s+2)+this.peek(s+3)+this.peek(s+4);return r(n)?(e=parseInt(n,16),h[e]||t(e)?(s+=5,"\\u"+n):null):null}.bind(this),u=function(){var t=this.peek(s),n=t.charCodeAt(0);return 92===n?a():n<128?p[n]?(s+=1,t):null:e(n)?(s+=1,t):null}.bind(this),c=function(){var e=this.peek(s),n=e.charCodeAt(0);return 92===n?a():n<128?h[n]?(s+=1,e):null:t(n)?(s+=1,e):null}.bind(this);if(null===(i=u()))return null;for(o=i;null!==(i=c());)o+=i;switch(o){case"true":case"false":n=g.BooleanLiteral;break;case"null":n=g.NullLiteral;break;default:n=g.Identifier}return{type:n,value:function(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}(o),text:o,tokenLength:o.length}},scanNumericLiteral:function(e){function t(e){return/^[0-9]$/.test(e)}function n(e){return/^[0-7]$/.test(e)}function r(e){return"$"===e||"_"===e||"\\"===e||e>="a"&&e<="z"||e>="A"&&e<="Z"}var o=0,s="",a=this.input.length,u=this.peek(o),c=t,f=10,p=!1;if("."!==u&&!t(u))return null;if("."!==u){for(s=this.peek(o),o+=1,u=this.peek(o),"0"===s&&("x"!==u&&"X"!==u||(c=i,f=16,o+=1,s+=u),"o"!==u&&"O"!==u||(c=n,f=8,l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Octal integer literal","6"]},e,function(){return!0}),o+=1,s+=u),"b"!==u&&"B"!==u||(c=function(e){return/^[01]$/.test(e)},f=2,l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Binary integer literal","6"]},e,function(){return!0}),o+=1,s+=u),n(u)&&(c=n,f=8,p=!0,!1,o+=1,s+=u),!n(u)&&t(u)&&(o+=1,s+=u));o=0&&o<=7&&l.isStrict()});break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":i="\\"+i,this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return l.isStrict()});break;case"u":var s=this.input.substr(1,4),a=parseInt(s,16);r(s)||this.trigger("warning",{code:"W052",line:this.line,character:this.char,data:["u"+s]}),i=String.fromCharCode(a),n=5;break;case"v":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\v"]},e,function(){return l.jsonMode}),i="\v";break;case"x":var u=parseInt(this.input.substr(1,2),16);this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\x-"]},e,function(){return l.jsonMode}),i=String.fromCharCode(u),n=3;break;case"\\":i="\\\\";break;case'"':i='\\"';break;case"/":break;case"":t=!0,i=""}return{char:i,jump:n,allowNewLine:t}},scanTemplateLiteral:function(e){var t,n,r="",i=this.line,o=this.char,s=this.templateStarts.length;if("`"===this.peek())l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["template literal syntax","6"]},e,function(){return!0}),t=g.TemplateHead,this.templateStarts.push({line:this.line,char:this.char}),s=this.templateStarts.length,this.skip(1),this.pushContext(m.Template);else{if(!this.inContext(m.Template)||"}"!==this.peek())return null;t=g.TemplateMiddle}for(;"`"!==this.peek();){for(;""===(n=this.peek());)if(r+="\n",!this.nextLine(e)){var a=this.templateStarts.pop();return this.trigger("error",{code:"E052",line:a.line,character:a.char}),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!0,depth:s,context:this.popContext()}}if("$"===n&&"{"===this.peek(1))return r+="${",this.skip(2),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!1,depth:s,context:this.currentContext()};if("\\"===n){var u=this.scanEscapeSequence(e);r+=u.char,this.skip(u.jump)}else"`"!==n&&(r+=n,this.skip(1))}return t=t===g.TemplateHead?g.NoSubstTemplate:g.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!1,depth:s,context:this.popContext()}},scanStringLiteral:function(e){var t=this.peek();if('"'!==t&&"'"!==t)return null;this.triggerAsync("warning",{code:"W108",line:this.line,character:this.char},e,function(){return l.jsonMode&&'"'!==t});var n="",r=this.line,i=this.char,o=!1;for(this.skip();this.peek()!==t;)if(""===this.peek()){if(o?(o=!1,this.triggerAsync("warning",{code:"W043",line:this.line,character:this.char},e,function(){return!l.option.multistr}),this.triggerAsync("warning",{code:"W042",line:this.line,character:this.char},e,function(){return l.jsonMode&&l.option.multistr})):this.trigger("warning",{code:"W112",line:this.line,character:this.char}),!this.nextLine(e))return this.trigger("error",{code:"E029",line:r,character:i}),{type:g.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!0,quote:t}}else{o=!1;var s=this.peek(),a=1;if(s<" "&&this.triggerAsync("warning",{code:"W113",line:this.line,character:this.char,data:[""]},e,function(){return!0}),"\\"===s){var u=this.scanEscapeSequence(e);s=u.char,a=u.jump,o=u.allowNewLine}n+=s,this.skip(a)}return this.skip(),{type:g.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!1,quote:t}},scanRegExp:function(e){var t,n,r=0,i=this.input.length,o=this.peek(),s=o,a="",u=[],c=!1,f=!1,p=function(){o<" "&&(c=!0,this.triggerAsync("warning",{code:"W048",line:this.line,character:this.char},e,function(){return!0})),"<"===o&&(c=!0,this.triggerAsync("warning",{code:"W049",line:this.line,character:this.char,data:[o]},e,function(){return!0}))}.bind(this);if(!this.prereg||"/"!==o)return null;for(r+=1,t=!1;r-1&&(n="Duplicate RegExp flag")):u.push(o),s+=o,r+=1;try{new RegExp(a,u.join(""))}catch(e){n=e.message}return n&&(c=!0,this.trigger("error",{code:"E016",line:this.line,character:this.char,data:[n]})),{type:g.RegExp,value:s,flags:u,isMalformed:c}},scanNonBreakingSpaces:function(){return l.option.nonbsp?this.input.search(/(\u00A0)/):-1},scanUnsafeChars:function(){return this.input.search(c.unsafeChars)},next:function(e){for(this.from=this.char;/\s/.test(this.peek());)this.from+=1,this.skip();var t=this.scanComments(e)||this.scanStringLiteral(e)||this.scanTemplateLiteral(e);return t||(t=this.scanRegExp(e)||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier()||this.scanNumericLiteral(e),t?(this.skip(t.tokenLength||t.value.length),t):null)},nextLine:function(e){var t;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var n=this.input.trim(),r=function(){return a.some(arguments,function(e){return 0===n.indexOf(e)})};return!0===this.ignoringLinterErrors&&(r("/*","//")||this.inComment&&function(){return a.some(arguments,function(e){return-1!==n.indexOf(e,n.length-e.length)})}("*/")||(this.input="")),(t=this.scanNonBreakingSpaces())>=0&&this.triggerAsync("warning",{code:"W125",line:this.line,character:t+1},e,function(){return!0}),this.input=this.input.replace(/\t/g,l.tab),(t=this.scanUnsafeChars())>=0&&this.triggerAsync("warning",{code:"W100",line:this.line,character:t},e,function(){return!0}),!this.ignoringLinterErrors&&l.option.maxlen&&l.option.maxlen=0;--t){var n=k[t]["(labels)"];if(n[e])return n}}function d(e){for(var t=k.length-1;t>=0;t--){var n=k[t];if(n["(usages)"][e])return n["(usages)"][e];if(n===y)break}return!1}function v(t,n){if("outer"===e.option.shadow)for(var r="global"===y["(type)"],i="functionparams"===m["(type)"],o=!r,s=0;s1?k[k.length-2]:null,a=m===y,l="functionparams"===m["(type)"],p="functionouter"===m["(type)"],h=m["(usages)"],d=m["(labels)"],v=Object.keys(h);for(h.__proto__&&-1===v.indexOf("__proto__")&&v.push("__proto__"),t=0;t=0;i--){var o=k[i];if(o["(labels)"][e]&&(!n||o["(labels)"][e]["(blockscoped)"]))return o["(labels)"][e]["(type)"];var s=r?k[i-1]:o;if(s&&"functionparams"===s["(type)"])return null}return null},hasBreakLabel:function(e){for(var t=k.length-1;t>=0;t--){var n=k[t];if(n["(breakLabels)"][e])return!0;if("functionparams"===n["(type)"])return!1}return!1},has:function(e,t){return Boolean(this.labeltype(e,t))},add:function(e,t,n,r){m["(labels)"][e]={"(type)":t,"(token)":n,"(blockscoped)":!1,"(function)":y,"(unused)":r}}},block:{isGlobal:function(){return"global"===m["(type)"]},use:function(t,n){var r=y["(parent)"];r&&r["(labels)"][t]&&"param"===r["(labels)"][t]["(type)"]&&(W.funct.has(t,{excludeParams:!0,onlyBlockscoped:!0})||(r["(labels)"][t]["(unused)"]=!1)),n&&(e.ignored.W117||!1===e.option.undef)&&(n.ignoreUndef=!0),l(t),m["(usages)"][t]["(onlyUsedSubFunction)"]=!1,n&&(n["(function)"]=y,m["(usages)"][t]["(tokens)"].push(n));var i=m["(labels)"][t];i&&i["(blockscoped)"]&&!i["(initialized)"]&&c("E056",n,t,i["(type)"])},reassign:function(t,n){n.ignoreW020=e.ignored.W020,n.ignoreW021=e.ignored.W021,this.modify(t,n),m["(usages)"][t]["(reassigned)"].push(n)},modify:function(e,t){l(e),m["(usages)"][e]["(onlyUsedSubFunction)"]=!1,m["(usages)"][e]["(modified)"].push(t)},add:function(e,t,n,r,i){m["(labels)"][e]={"(type)":t,"(token)":n,"(initialized)":!!i,"(blockscoped)":!0,"(unused)":r}},addBreakLabel:function(t,n){var r=n.token;W.funct.hasBreakLabel(t)?u("E011",r,t):"outer"===e.option.shadow&&(W.funct.has(t)?u("W004",r,t):v(t,r)),m["(breakLabels)"][t]=r}}};return W}},{events:5,lodash:12}],19:[function(e,t,n){"use strict";var r=e("./name-stack.js"),i={syntax:{},isStrict:function(){return this.directive["use strict"]||this.inClassBody||this.option.module||"implied"===this.option.strict},stmtMissingStrict:function(){return"global"===this.option.strict||!1!==this.option.strict&&!!this.option.globalstrict},allowsGlobalUsd:function(){return"global"===this.option.strict||this.option.globalstrict||this.option.module||this.impliedClosure()},impliedClosure:function(){return this.option.node||this.option.phantom||this.option.browserify},inMoz:function(){return this.option.moz},inES6:function(e){return e?6===this.esVersion:this.option.moz||this.esVersion>=6},inES5:function(e){return e?!(this.esVersion&&5!==this.esVersion||this.option.moz):!this.esVersion||this.esVersion>=5||this.option.moz},inferEsVersion:function(){var e=null;if(this.option.esversion){if(this.option.es3?e="es3":this.option.es5?e="es5":this.option.esnext&&(e="esnext"),e)return e;2015===this.option.esversion?this.esVersion=6:this.esVersion=this.option.esversion}else this.option.es3?this.esVersion=3:this.option.esnext&&(this.esVersion=6);return null},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={},this.esVersion=5,this.funct=null,this.ignored={},this.directive={},this.jsonMode=!1,this.jsonWarnings=[],this.lines=[],this.tab="",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new r,this.inClassBody=!1}};n.state=i},{"./name-stack.js":15}],20:[function(e,t,n){"use strict";n.register=function(e){e.on("Identifier",function(t){e.getOption("proto")||"__proto__"===t.name&&e.warn("W103",{line:t.line,char:t.char,data:[t.name,"6"]})}),e.on("Identifier",function(t){e.getOption("iterator")||"__iterator__"===t.name&&e.warn("W103",{line:t.line,char:t.char,data:[t.name]})}),e.on("Identifier",function(t){e.getOption("camelcase")&&t.name.replace(/^_+|_+$/g,"").indexOf("_")>-1&&!t.name.match(/^[A-Z0-9_]*$/)&&e.warn("W106",{line:t.line,char:t.char,data:[t.name]})}),e.on("String",function(t){var n,r=e.getOption("quotmark");r&&("single"===r&&"'"!==t.quote&&(n="W109"),"double"===r&&'"'!==t.quote&&(n="W108"),!0===r&&(e.getCache("quotmark")||e.setCache("quotmark",t.quote),e.getCache("quotmark")!==t.quote&&(n="W110")),n&&e.warn(n,{line:t.line,char:t.char}))}),e.on("Number",function(t){"."===t.value.charAt(0)&&e.warn("W008",{line:t.line,char:t.char,data:[t.value]}),"."===t.value.substr(t.value.length-1)&&e.warn("W047",{line:t.line,char:t.char,data:[t.value]}),/^00+/.test(t.value)&&e.warn("W046",{line:t.line,char:t.char,data:[t.value]})}),e.on("String",function(t){var n=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;e.getOption("scripturl")||n.test(t.value)&&e.warn("W107",{line:t.line,char:t.char})})}},{}],21:[function(e,t,n){"use strict";n.reservedVars={arguments:!1,NaN:!1},n.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{ArrayBuffer:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int8Array:!1,Int16Array:!1,Int32Array:!1,Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,Uint8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8ClampledArray:!1,WeakMap:!1,WeakSet:!1}},n.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CompositionEvent:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,File:!1,FileList:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MediaRecorder:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,performance:!1,print:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,Storage:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},n.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},n.worker={importScripts:!0,onmessage:!0,postMessage:!0,self:!0,FileReaderSync:!0},n.nonstandard={escape:!1,unescape:!1},n.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},n.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,require:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},n.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,require:!1,Buffer:!0,exports:!0,process:!0},n.phantom={phantom:!0,require:!0,WebPage:!0,console:!0,exports:!0},n.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notOk:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,throws:!1},n.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},n.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},n.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},n.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},n.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},n.jquery={$:!1,jQuery:!1},n.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},n.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},n.yui={YUI:!1,Y:!1,YUI_config:!1},n.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},n.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1}},{}],jshint:[function(e,t,n){var r=e("lodash"),i=e("events"),o=e("./vars.js"),s=e("./messages.js"),a=e("./lex.js").Lexer,u=e("./reg.js"),c=e("./state.js").state,l=e("./style.js"),f=e("./options.js"),p=e("./scope-manager.js"),h=(e("console-browserify"),function(){"use strict";function e(e,t){return e=e.trim(),!!/^[+-]W\d{3}$/g.test(e)||(!(-1===f.validNames.indexOf(e)&&"jslint"!==t.type&&!r.has(f.removed,e))||(_("E001",t,e),!1))}function t(e){return"[object String]"===Object.prototype.toString.call(e)}function n(e,t){return!!e&&!(!e.identifier||e.value!==t)}function d(e){if(!e.reserved)return!1;var t=e.meta;if(t&&t.isFutureReservedWord){if(t.moduleOnly&&!c.option.module)return!1;if(c.inES5()){if(!t.es5)return!1;if(t.strictOnly&&!c.option.strict&&!c.isStrict())return!1;if(e.isProperty)return!1}}return!0}function v(e,t){return e.replace(/\{([^{}]*)\}/g,function(e,n){var r=t[n];return"string"==typeof r||"number"==typeof r?r:e})}function g(e,t){Object.keys(t).forEach(function(n){r.has(h.blacklist,n)||(e[n]=t[n])})}function m(){if(c.option.enforceall){for(var e in f.bool.enforcing)void 0!==c.option[e]||f.noenforceall[e]||(c.option[e]=!0);for(var t in f.bool.relaxing)void 0===c.option[t]&&(c.option[t]=!1)}}function k(){var e=null;m(),(e=c.inferEsVersion())&&y("E059",c.tokens.next,"esversion",e),c.inES5()&&g(Ye,o.ecmaIdentifiers[5]),c.inES6()&&g(Ye,o.ecmaIdentifiers[6]),"global"===c.option.strict&&"globalstrict"in c.option&&y("E059",c.tokens.next,"strict","globalstrict"),c.option.module&&(c.inES6()||b("W134",c.tokens.next,"module",6)),c.option.couch&&g(Ye,o.couch),c.option.qunit&&g(Ye,o.qunit),c.option.rhino&&g(Ye,o.rhino),c.option.shelljs&&(g(Ye,o.shelljs),g(Ye,o.node)),c.option.typed&&g(Ye,o.typed),c.option.phantom&&g(Ye,o.phantom),c.option.prototypejs&&g(Ye,o.prototypejs),c.option.node&&(g(Ye,o.node),g(Ye,o.typed)),c.option.devel&&g(Ye,o.devel),c.option.dojo&&g(Ye,o.dojo),c.option.browser&&(g(Ye,o.browser),g(Ye,o.typed)),c.option.browserify&&(g(Ye,o.browser),g(Ye,o.typed),g(Ye,o.browserify)),c.option.nonstandard&&g(Ye,o.nonstandard),c.option.jasmine&&g(Ye,o.jasmine),c.option.jquery&&g(Ye,o.jquery),c.option.mootools&&g(Ye,o.mootools),c.option.worker&&g(Ye,o.worker),c.option.wsh&&g(Ye,o.wsh),c.option.yui&&g(Ye,o.yui),c.option.mocha&&g(Ye,o.mocha)}function y(e,t,n,r){var i=Math.floor(t.line/c.lines.length*100),o=s.errors[e].desc,a={name:"JSHintError",line:t.line,character:t.from,message:o+" ("+i+"% scanned).",raw:o,code:e,a:n,b:r};throw a.reason=v(o,a)+" ("+i+"% scanned).",a}function x(){var e=c.ignoredLines;r.isEmpty(e)||(h.errors=r.reject(h.errors,function(t){return e[t.line]}))}function b(e,t,n,r,i,o){var a,u,l,f;if(/^W\d{3}$/.test(e)){if(c.ignored[e])return;f=s.warnings[e]}else/E\d{3}/.test(e)?f=s.errors[e]:/I\d{3}/.test(e)&&(f=s.info[e]);return"(end)"===(t=t||c.tokens.next||{}).id&&(t=c.tokens.curr),u=t.line,a=t.from,l={id:"(error)",raw:f.desc,code:f.code,evidence:c.lines[u-1]||"",line:u,character:a,scope:h.scope,a:n,b:r,c:i,d:o},l.reason=v(f.desc,l),h.errors.push(l),x(),h.errors.length>=c.option.maxerr&&y("E043",t),l}function E(e,t,n,r,i,o,s){return b(e,{line:t,from:n},r,i,o,s)}function _(e,t,n,r,i,o){b(e,t,n,r,i,o)}function w(e,t,n,r,i,o,s){return _(e,{line:t,from:n},r,i,o,s)}function S(e,t){h.internals.push({id:"(internal)",elem:e,token:t,code:t.value.replace(/([^\\])(\\*)\2\\n/g,"$1\n")})}function W(t,n){var i=t.body.split(",").map(function(e){return e.trim()}),o={};if("falls through"!==t.type){if("globals"===t.type){i.forEach(function(e,n){var r=((e=e.split(":"))[0]||"").trim(),s=(e[1]||"").trim();if("-"!==r&&r.length)"-"===r.charAt(0)?(r=r.slice(1),s=!1,h.blacklist[r]=r,delete Ye[r]):o[r]="true"===s;else{if(n>0&&n===i.length-1)return;_("E002",t)}}),g(Ye,o);for(var s in o)r.has(o,s)&&(qe[s]=t)}"exported"===t.type&&i.forEach(function(e,n){if(e.length)c.funct["(scope)"].addExported(e);else{if(n>0&&n===i.length-1)return;_("E002",t)}}),"members"===t.type&&(Ke=Ke||{},i.forEach(function(e){var t=e.charAt(0);t!==e.charAt(e.length-1)||'"'!==t&&"'"!==t||(e=e.substr(1,e.length-2).replace('\\"','"')),Ke[e]=!1}));var a=["maxstatements","maxparams","maxdepth","maxcomplexity","maxerr","maxlen","indent"];"jshint"!==t.type&&"jslint"!==t.type||(i.forEach(function(n){var r=((n=n.split(":"))[0]||"").trim(),i=(n[1]||"").trim();if(e(r,t))if(a.indexOf(r)>=0)if("false"!==i){if("number"!=typeof(i=+i)||!isFinite(i)||i<=0||Math.floor(i)!==i)return void _("E032",t,n[1].trim());c.option[r]=i}else c.option[r]="indent"===r&&4;else{if("validthis"===r)return c.funct["(global)"]?void _("E009"):"true"!==i&&"false"!==i?void _("E002",t):void(c.option.validthis="true"===i);if("quotmark"!==r)if("shadow"!==r)if("unused"!==r)if("latedef"!==r)if("ignore"!==r)if("strict"!==r)if("module"===r&&(xe(c.funct)||_("E055",t,"module")),"esversion"!==r){var o=/^([+-])(W\d{3})$/g.exec(r);if(o)c.ignored[o[2]]="-"===o[1];else{var s;"true"!==i&&"false"!==i?_("E002",t):"jslint"===t.type?(s=f.renamed[r]||r,c.option[s]="true"===i,void 0!==f.inverted[s]&&(c.option[s]=!c.option[s])):c.option[r]="true"===i}}else{switch(i){case"3":case"5":case"6":case"2015":c.option.moz=!1,c.option.esversion=+i;break;default:_("E002",t)}xe(c.funct)||_("E055",t,"esversion")}else switch(i){case"true":c.option.strict=!0;break;case"false":c.option.strict=!1;break;case"global":case"implied":c.option.strict=i;break;default:_("E002",t)}else switch(i){case"line":c.ignoredLines[t.line]=!0,x();break;default:_("E002",t)}else switch(i){case"true":c.option.latedef=!0;break;case"false":c.option.latedef=!1;break;case"nofunc":c.option.latedef="nofunc";break;default:_("E002",t)}else switch(i){case"true":c.option.unused=!0;break;case"false":c.option.unused=!1;break;case"vars":case"strict":c.option.unused=i;break;default:_("E002",t)}else switch(i){case"true":c.option.shadow=!0;break;case"outer":c.option.shadow="outer";break;case"false":case"inner":c.option.shadow="inner";break;default:_("E002",t)}else switch(i){case"true":case"false":c.option.quotmark="true"===i;break;case"double":case"single":c.option.quotmark=i;break;default:_("E002",t)}}}),k())}else n.caseFallsThrough=!0}function A(e){var t,n=e||0,r=Je.length;if(n="a"&&t<="z"||t>="A"&&t<="Z")&&(e.identifier=e.reserved=!0),e}function D(e,t){var n=P(e,150);return N(n),n.nud="function"==typeof t?t:function(){return this.arity="unary",this.right=G(150),"++"!==this.id&&"--"!==this.id||(c.option.plusplus?b("W016",this,this.id):!this.right||this.right.identifier&&!d(this.right)||"."===this.right.id||"["===this.right.id||b("W017",this),this.right&&this.right.isMetaProperty?_("E031",this):this.right&&this.right.identifier&&c.funct["(scope)"].block.modify(this.right.value,this)),this},n}function q(e,t){var n=R(e);return n.type=e,n.nud=t,n}function z(e,t){var n=q(e,t);return n.identifier=!0,n.reserved=!0,n}function H(e,t){var n=q(e,t&&t.nud||function(){return this});return t=t||{},t.isFutureReservedWord=!0,n.value=e,n.identifier=!0,n.reserved=!0,n.meta=t,n}function $(e,t){return z(e,function(){return"function"==typeof t&&t(this),this})}function J(e,t,n,r){var i=P(e,n);return N(i),i.infix=!0,i.led=function(i){return r||M(c.tokens.prev,c.tokens.curr),"in"!==e&&"instanceof"!==e||"!"!==i.id||b("W018",i,"!"),"function"==typeof t?t(i,this):(this.left=i,this.right=G(n),this)},i}function Z(e,t){var r=P(e,100);return r.infix=!0,r.led=function(e){M(c.tokens.prev,c.tokens.curr),this.left=e;var r=this.right=G(100);return n(e,"NaN")||n(r,"NaN")?b("W019",this):t&&t.apply(this,[e,r]),e&&r||y("E041",c.tokens.curr),"!"===e.id&&b("W018",e,"!"),"!"===r.id&&b("W018",r,"!"),this},r}function X(e,t,n){var i;return!n.option.notypeof&&(!(!e||!t)&&(i=n.inES6()?ot.es6:ot.es3,"(identifier)"===t.type&&"typeof"===t.value&&"(string)"===e.type&&!r.contains(i,e.value)))}function K(e,t){var n=!1;return"this"===e.type&&null===t.funct["(context)"]?n=!0:"(identifier)"===e.type&&(t.option.node&&"global"===e.value?n=!0:!t.option.browser||"window"!==e.value&&"document"!==e.value||(n=!0)),n}function Y(e){function t(e){if("object"==typeof e)return"prototype"===e.right?e:t(e.left)}var n=["Array","ArrayBuffer","Boolean","Collator","DataView","Date","DateTimeFormat","Error","EvalError","Float32Array","Float64Array","Function","Infinity","Intl","Int16Array","Int32Array","Int8Array","Iterator","Number","NumberFormat","Object","RangeError","ReferenceError","RegExp","StopIteration","String","SyntaxError","TypeError","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","URIError"],r=t(e);if(r)return function(e){for(;!e.identifier&&"object"==typeof e.left;)e=e.left;if(e.identifier&&n.indexOf(e.value)>=0&&c.funct["(scope)"].isPredefined(e.value))return e.value}(r)}function Q(e,t,n){var r=n&&n.allowDestructuring;if(t=t||e,c.option.freeze){var i=Y(e);i&&b("W121",e,i)}return Re(e,"...")&&(e=e.right),e.identifier&&!e.isMetaProperty&&c.funct["(scope)"].block.reassign(e.value,e),"."===e.id?(e.left&&("arguments"!==e.left.value||c.isStrict())||b("E031",t),c.nameStack.set(c.tokens.prev),!0):"{"===e.id||"["===e.id?(r&&e.destructAssign||("{"!==e.id&&e.left?"arguments"!==e.left.value||c.isStrict()||b("E031",t):b("E031",t)),"["===e.id&&c.nameStack.set(e.right),!0):!e.identifier||d(e)||e.isMetaProperty?(e===c.syntax.function?b("W023",c.tokens.curr):_("E031",t),!1):("exception"===c.funct["(scope)"].labeltype(e.value)&&b("W022",e),c.nameStack.set(e),!0)}function ee(e,t,n){var r=J(e,"function"==typeof t?t:function(e,t){return t.left=e,Q(e,t,{allowDestructuring:!0}),t.right=G(10),t},n);return r.exps=!0,r.assign=!0,r}function te(e,t,n){var r=P(e,n);return N(r),r.infix=!0,r.led="function"==typeof t?t:function(e){return c.option.bitwise&&b("W016",this,this.id),this.left=e,this.right=G(n),this},r}function ne(e){return ee(e,function(e,t){return c.option.bitwise&&b("W016",t,t.id),Q(e,t),t.right=G(10),t},20)}function re(e){var t=P(e,150);return t.led=function(e){return c.option.plusplus?b("W016",this,this.id):e.identifier&&!d(e)||"."===e.id||"["===e.id||b("W017",this),e.isMetaProperty?_("E031",this):e&&e.identifier&&c.funct["(scope)"].block.modify(e.value,e),this.left=e,this},t}function ie(e,t,n){if(c.tokens.next.identifier){n||j();var r=c.tokens.curr,i=c.tokens.curr.value;return d(r)?t&&c.inES5()?i:e&&"undefined"===i?i:(b("W024",c.tokens.curr,c.tokens.curr.id),i):i}}function oe(e,t){var n=ie(e,t,!1);if(n)return n;if("..."===c.tokens.next.value){if(c.inES6(!0)||b("W119",c.tokens.next,"spread/rest operator","6"),j(),Re(c.tokens.next,"..."))for(b("E024",c.tokens.next,"...");Re(c.tokens.next,"...");)j();return c.tokens.next.identifier?oe(e,t):void b("E024",c.tokens.curr,c.tokens.next.id)}_("E030",c.tokens.next,c.tokens.next.value),";"!==c.tokens.next.id&&j()}function se(e){var t,n=0;if(";"===c.tokens.next.id&&!e.inBracelessBlock)for(;;){do{t=A(n),n+=1}while("(end)"!==t.id&&"(comment)"===t.id);if(t.reach)return;if("(endline)"!==t.id){if("function"===t.id){!0===c.option.latedef&&b("W026",t);break}b("W027",t,t.value,e.value);break}}}function ae(e){if(";"!==c.tokens.next.id){if(c.tokens.next.isUnclosed)return j();var t=C(c.tokens.next)===c.tokens.curr.line&&"(end)"!==c.tokens.next.id,n=Re(c.tokens.next,"}");!t||n||"do"===e.id&&c.inES6(!0)?c.option.asi||n&&t&&c.option.lastsemic||E("W033",c.tokens.curr.line,c.tokens.curr.character):w("E058",c.tokens.curr.line,c.tokens.curr.character)}else j(";")}function ue(){var e,t=$e,n=c.tokens.next,r=!1;{if(";"!==n.id){var i=d(n);return i&&n.meta&&n.meta.isFutureReservedWord&&":"===A().id&&(b("W024",n,n.id),i=!1),n.identifier&&!i&&":"===A().id&&(j(),j(":"),r=!0,c.funct["(scope)"].stack(),c.funct["(scope)"].block.addBreakLabel(n.value,{token:c.tokens.curr}),c.tokens.next.labelled||"{"===c.tokens.next.value||b("W028",c.tokens.next,n.value,c.tokens.next.value),c.tokens.next.label=n.value,n=c.tokens.next),"{"===n.id?(fe(!0,!0,!1,!1,"case"===c.funct["(verb)"]&&":"===c.tokens.curr.value),void(r&&c.funct["(scope)"].unstack())):(!(e=G(0,!0))||e.identifier&&"function"===e.value||"(punctuator)"===e.type&&e.left&&e.left.identifier&&"function"===e.left.value||!c.isStrict()&&c.stmtMissingStrict()&&b("E007"),n.block||(c.option.expr||e&&e.exps?c.option.nonew&&e&&e.left&&"("===e.id&&"new"===e.left.id&&b("W031",n):b("W030",c.tokens.curr),ae(n)),$e=t,r&&c.funct["(scope)"].unstack(),e)}j(";")}}function ce(){for(var e,t=[];!c.tokens.next.reach&&"(end)"!==c.tokens.next.id;)";"===c.tokens.next.id?((!(e=A())||"("!==e.id&&"["!==e.id)&&b("W032"),j(";")):t.push(ue());return t}function le(){for(var e=c.tokens.next;"(string)"===c.tokens.next.id;){var t=L();if(!O(e,t))break;e=t,j();var n=c.tokens.curr.value;(c.directive[n]||"use strict"===n&&"implied"===c.option.strict)&&b("W034",c.tokens.curr,n),c.directive[n]=!0,ae(e)}c.isStrict()&&(c.option.undef=!0)}function fe(e,t,n,i,o){var s,a,u,l,f=He,p=$e;He=e,u=c.tokens.next;var h=c.funct["(metrics)"];if(h.nestedBlockDepth+=1,h.verifyMaxNestedBlockDepthPerFunction(),"{"===c.tokens.next.id){if(j("{"),c.funct["(scope)"].stack(),c.funct["(noblockscopedvar)"]=!1,c.tokens.curr.line,"}"!==c.tokens.next.id){for($e+=c.option.indent;!e&&c.tokens.next.from>$e;)$e+=c.option.indent;if(n){a={};for(l in c.directive)r.has(c.directive,l)&&(a[l]=c.directive[l]);le(),c.option.strict&&c.funct["(context)"]["(global)"]&&(a["use strict"]||c.isStrict()||b("E007"))}s=ce(),h.statementCount+=s.length,$e-=c.option.indent}j("}",u),n&&(c.funct["(scope)"].validateParams(),a&&(c.directive=a)),c.funct["(scope)"].unstack(),$e=p}else if(e)c.funct["(noblockscopedvar)"]="for"!==c.tokens.next.id,c.funct["(scope)"].stack(),t&&!c.option.curly||b("W116",c.tokens.next,"{",c.tokens.next.value),c.tokens.next.inBracelessBlock=!0,$e+=c.option.indent,s=[ue()],$e-=c.option.indent,c.funct["(scope)"].unstack(),delete c.funct["(noblockscopedvar)"];else if(n){if(c.funct["(scope)"].stack(),a={},!t||i||c.inMoz()||_("W118",c.tokens.curr,"function closure expressions"),!t)for(l in c.directive)r.has(c.directive,l)&&(a[l]=c.directive[l]);G(10),c.option.strict&&c.funct["(context)"]["(global)"]&&(a["use strict"]||c.isStrict()||b("E007")),c.funct["(scope)"].unstack()}else _("E021",c.tokens.next,"{",c.tokens.next.value);switch(c.funct["(verb)"]){case"break":case"continue":case"return":case"throw":if(o)break;default:c.funct["(verb)"]=null}return He=f,!e||!c.option.noempty||s&&0!==s.length||b("W035",c.tokens.prev),h.nestedBlockDepth-=1,s}function pe(e){Ke&&"boolean"!=typeof Ke[e]&&b("W036",c.tokens.curr,e),"number"==typeof Xe[e]?Xe[e]+=1:Xe[e]=1}function he(){var e={};e.exps=!0,c.funct["(comparray)"].stack();var t=!1;return"for"!==c.tokens.next.value&&(t=!0,c.inMoz()||b("W116",c.tokens.next,"for",c.tokens.next.value),c.funct["(comparray)"].setState("use"),e.right=G(10)),j("for"),"each"===c.tokens.next.value&&(j("each"),c.inMoz()||b("W118",c.tokens.curr,"for each")),j("("),c.funct["(comparray)"].setState("define"),e.left=G(130),r.contains(["in","of"],c.tokens.next.value)?j():_("E045",c.tokens.curr),c.funct["(comparray)"].setState("generate"),G(10),j(")"),"if"===c.tokens.next.value&&(j("if"),j("("),c.funct["(comparray)"].setState("filter"),e.filter=G(10),j(")")),t||(c.funct["(comparray)"].setState("use"),e.right=G(10)),j("]"),c.funct["(comparray)"].unstack(),e}function de(){return c.funct["(statement)"]&&"class"===c.funct["(statement)"].type||c.funct["(context)"]&&"class"===c.funct["(context)"]["(verb)"]}function ve(e){return e.identifier||"(string)"===e.id||"(number)"===e.id}function ge(e){var t,n=!0;return t="object"==typeof e?e:ie(!1,!0,n=e),t?"object"==typeof t&&("(string)"===t.id||"(identifier)"===t.id?t=t.value:"(number)"===t.id&&(t=t.value.toString())):"(string)"===c.tokens.next.id?(t=c.tokens.next.value,n||j()):"(number)"===c.tokens.next.id&&(t=c.tokens.next.value.toString(),n||j()),"hasOwnProperty"===t&&b("W001"),t}function me(e){var t,n,i,o=[],s=[],a=!1,u=!1,l=0,f=e&&e.loneArg;if(f&&!0===f.identifier)return c.funct["(scope)"].addParam(f.value,f),{arity:1,params:[f.value]};if(t=c.tokens.next,e&&e.parsedOpening||j("("),")"!==c.tokens.next.id)for(;;){l++;var p=[];if(r.contains(["{","["],c.tokens.next.id)){s=Le();for(i in s)(i=s[i]).id&&(o.push(i.id),p.push([i.id,i.token]))}else if(Re(c.tokens.next,"...")&&(u=!0),n=oe(!0))o.push(n),p.push([n,c.tokens.curr]);else for(;!Pe(c.tokens.next,[",",")"]);)j();if(a&&"="!==c.tokens.next.id&&_("W138",c.tokens.current),"="===c.tokens.next.id&&(c.inES6()||b("W119",c.tokens.next,"default parameters","6"),j("="),a=!0,G(10)),p.forEach(function(e){c.funct["(scope)"].addParam.apply(c.funct["(scope)"],e)}),","!==c.tokens.next.id)return j(")",t),{arity:l,params:o};u&&b("W131",c.tokens.next),F()}else j(")")}function ke(e,t,n){var i={"(name)":e,"(breakage)":0,"(loopage)":0,"(tokens)":{},"(properties)":{},"(catch)":!1,"(global)":!1,"(line)":null,"(character)":null,"(metrics)":null,"(statement)":null,"(context)":null,"(scope)":null,"(comparray)":null,"(generator)":null,"(arrow)":null,"(params)":null};return t&&r.extend(i,{"(line)":t.line,"(character)":t.character,"(metrics)":_e(t)}),r.extend(i,n),i["(context)"]&&(i["(scope)"]=i["(context)"]["(scope)"],i["(comparray)"]=i["(context)"]["(comparray)"]),i}function ye(e){return"(scope)"in e}function xe(e){return e["(global)"]&&!e["(verb)"]}function be(e){var t=this.context,n=this.noSubst,r=this.depth,i="number"==typeof e?null:e;if(!n)for(;!function(){if(c.tokens.curr.template&&c.tokens.curr.tail&&c.tokens.curr.context===t)return!0;var e=c.tokens.next.template&&c.tokens.next.tail&&c.tokens.next.context===t;return e&&j(),e||c.tokens.next.isUnclosed}();)!c.tokens.next.template||c.tokens.next.depth>r?G(0):j();return{id:"(template)",type:"(template)",tag:i}}function Ee(e){var t,n,r,i,o,s,a,u,l=c.option,f=c.ignored;e&&(r=e.name,i=e.statement,o=e.classExprBinding,s="generator"===e.type,a="arrow"===e.type,u=e.ignoreLoopFunc),c.option=Object.create(c.option),c.ignored=Object.create(c.ignored),c.funct=ke(r||c.nameStack.infer(),c.tokens.next,{"(statement)":i,"(context)":c.funct,"(arrow)":a,"(generator)":s}),t=c.funct,(n=c.tokens.curr).funct=c.funct,ze.push(c.funct),c.funct["(scope)"].stack("functionouter");var p=r||o;p&&c.funct["(scope)"].block.add(p,o?"class":"function",c.tokens.curr,!1),c.funct["(scope)"].stack("functionparams");var h=me(e);return h?(c.funct["(params)"]=h.params,c.funct["(metrics)"].arity=h.arity,c.funct["(metrics)"].verifyMaxParametersPerFunction()):c.funct["(metrics)"].arity=0,a&&(c.inES6(!0)||b("W119",c.tokens.curr,"arrow function syntax (=>)","6"),e.loneArg||j("=>")),fe(!1,!0,!0,a),!c.option.noyield&&s&&"yielded"!==c.funct["(generator)"]&&b("W124",c.tokens.curr),c.funct["(metrics)"].verifyMaxStatementsPerFunction(),c.funct["(metrics)"].verifyMaxComplexityPerFunction(),c.funct["(unusedOption)"]=c.option.unused,c.option=l,c.ignored=f,c.funct["(last)"]=c.tokens.curr.line,c.funct["(lastcharacter)"]=c.tokens.curr.character,c.funct["(scope)"].unstack(),c.funct["(scope)"].unstack(),c.funct=c.funct["(context)"],u||c.option.loopfunc||!c.funct["(loopage)"]||t["(isCapturing)"]&&b("W083",n),t}function _e(e){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){c.option.maxstatements&&this.statementCount>c.option.maxstatements&&b("W071",e,this.statementCount)},verifyMaxParametersPerFunction:function(){r.isNumber(c.option.maxparams)&&this.arity>c.option.maxparams&&b("W072",e,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){c.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===c.option.maxdepth+1&&b("W073",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var t=c.option.maxcomplexity,n=this.ComplexityCount;t&&n>t&&b("W074",e,n)}}}function we(){c.funct["(metrics)"].ComplexityCount+=1}function Se(e){var t,n;switch(e&&(t=e.id,n=e.paren,","===t&&(e=e.exprs[e.exprs.length-1])&&(t=e.id,n=n||e.paren)),t){case"=":case"+=":case"-=":case"*=":case"%=":case"&=":case"|=":case"^=":case"/=":n||c.option.boss||b("W084")}}function We(e){if(c.inES5())for(var t in e)e[t]&&e[t].setterToken&&!e[t].getterToken&&b("W078",e[t].setterToken)}function Ae(e,t){if(Re(c.tokens.next,".")){var n=c.tokens.curr.id;j(".");var r=oe();return c.tokens.curr.isMetaProperty=!0,e!==r?_("E057",c.tokens.prev,n,r):t(),c.tokens.curr}}function Le(e){var t=e&&e.assignment;return c.inES6()||b("W104",c.tokens.curr,t?"destructuring assignment":"destructuring binding","6"),je(e)}function je(e){var t,n,r,i=[],o=e&&e.openingParsed,s=e&&e.assignment,a=s?{assignment:s}:null,u=o?c.tokens.curr:c.tokens.next,l=function(){var e;if(Pe(c.tokens.next,["[","{"])){t=je(a);for(var n in t)n=t[n],i.push({id:n.id,token:n.token})}else if(Re(c.tokens.next,","))i.push({id:null,token:c.tokens.curr});else{if(!Re(c.tokens.next,"(")){var r=Re(c.tokens.next,"...");if(s){var o=G(20);o&&(Q(o),o.identifier&&(e=o.value))}else e=oe();return e&&i.push({id:e,token:c.tokens.curr}),r}j("("),l(),j(")")}return!1};if(Re(u,"[")){o||j("["),Re(c.tokens.next,"]")&&b("W137",c.tokens.curr);for(var f=!1;!Re(c.tokens.next,"]");)l()&&!f&&Re(c.tokens.next,",")&&(b("W130",c.tokens.next),f=!0),Re(c.tokens.next,"=")&&(j(Re(c.tokens.prev,"...")?"]":"="),n=c.tokens.prev,(r=G(10))&&"undefined"===r.type&&b("W080",n,n.value)),Re(c.tokens.next,"]")||j(",");j("]")}else if(Re(u,"{")){for(o||j("{"),Re(c.tokens.next,"}")&&b("W137",c.tokens.curr);!Re(c.tokens.next,"}")&&(function(){var e;Re(c.tokens.next,"[")?(j("["),G(10),j("]"),j(":"),l()):"(string)"===c.tokens.next.id||"(number)"===c.tokens.next.id?(j(),j(":"),l()):(e=oe(),Re(c.tokens.next,":")?(j(":"),l()):e&&(s&&Q(c.tokens.curr),i.push({id:e,token:c.tokens.curr})))}(),Re(c.tokens.next,"=")&&(j("="),n=c.tokens.prev,(r=G(10))&&"undefined"===r.type&&b("W080",n,n.value)),Re(c.tokens.next,"}")||(j(","),!Re(c.tokens.next,"}"))););j("}")}return i}function Te(e,t){var n=t.first;n&&r.zip(e,Array.isArray(n)?n:[n]).forEach(function(e){var t=e[0],n=e[1];t&&n?t.first=n:t&&t.first&&!n&&b("W080",t.first,t.first.value)})}function Oe(e,t,n){var i,o,s,a,u=n&&n.prefix,l=n&&n.inexport,f="let"===e,p="const"===e;for(c.inES6()||b("W104",c.tokens.curr,e,"6"),f&&"("===c.tokens.next.value?(c.inMoz()||b("W118",c.tokens.next,"let block"),j("("),c.funct["(scope)"].stack(),a=!0):c.funct["(noblockscopedvar)"]&&_("E048",c.tokens.curr,p?"Const":"Let"),t.first=[];;){var h=[];r.contains(["{","["],c.tokens.next.value)?(i=Le(),o=!1):(i=[{id:oe(),token:c.tokens.curr}],o=!0),!u&&p&&"="!==c.tokens.next.id&&b("E012",c.tokens.curr,c.tokens.curr.value);for(var d in i)i.hasOwnProperty(d)&&(d=i[d],c.funct["(scope)"].block.isGlobal()&&!1===Ye[d.id]&&b("W079",d.token,d.id),d.id&&!c.funct["(noblockscopedvar)"]&&(c.funct["(scope)"].addlabel(d.id,{type:e,token:d.token}),h.push(d.token)));if("="===c.tokens.next.id){j("="),!u&&"="===A(0).id&&c.tokens.next.identifier&&b("W120",c.tokens.next,c.tokens.next.value);var v=c.tokens.prev;s=G(u?120:10),!u&&s&&"undefined"===s.type&&b("W080",v,v.value),o?i[0].first=s:Te(h,s)}if(!u)for(d in i)i.hasOwnProperty(d)&&(d=i[d],c.funct["(scope)"].initialize(d.id),o&&l&&c.funct["(scope)"].setExported(d.token.value,d.token));if(t.first=t.first.concat(h),","!==c.tokens.next.id)break;F()}return a&&(j(")"),fe(!0,!0),t.block=!0,c.funct["(scope)"].unstack()),t}function Ge(e,t){return c.inES6()||b("W104",c.tokens.curr,"class","6"),t?(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"class",token:c.tokens.curr})):c.tokens.next.identifier&&"extends"!==c.tokens.next.value?(this.name=oe(),this.namedExpr=!0):this.name=c.nameStack.infer(),Ce(this),t&&c.funct["(scope)"].initialize(this.name),this}function Ce(e){var t=c.inClassBody;"extends"===c.tokens.next.value&&(j("extends"),e.heritage=G(10)),c.inClassBody=!0,j("{"),e.body=Me(e),j("}"),c.inClassBody=t}function Me(e){for(var t,n,r,i,o,s=Object.create(null),a=Object.create(null),u=0;"}"!==c.tokens.next.id;++u)if(t=c.tokens.next,n=!1,r=!1,i=null,";"!==t.id){if("*"===t.id&&(r=!0,j("*"),t=c.tokens.next),"["===t.id)t=Fe(),o=!0;else{if(!ve(t)){b("W052",c.tokens.next,c.tokens.next.value||c.tokens.next.type),j();continue}j(),o=!1,t.identifier&&"static"===t.value&&(Re(c.tokens.next,"*")&&(r=!0,j("*")),(ve(c.tokens.next)||"["===c.tokens.next.id)&&(o="["===c.tokens.next.id,n=!0,t=c.tokens.next,"["===c.tokens.next.id?t=Fe():j())),!t.identifier||"get"!==t.value&&"set"!==t.value||(ve(c.tokens.next)||"["===c.tokens.next.id)&&(o="["===c.tokens.next.id,i=t,t=c.tokens.next,"["===c.tokens.next.id?t=Fe():j())}if(!Re(c.tokens.next,"(")){for(_("E054",c.tokens.next,c.tokens.next.value);"}"!==c.tokens.next.id&&!Re(c.tokens.next,"(");)j();"("!==c.tokens.next.value&&Ee({statement:e})}o||(i?Ie(i.value,n?a:s,t.value,t,!0,n):("constructor"===t.value?c.nameStack.set(e):c.nameStack.set(t),Ve(n?a:s,t.value,t,!0,n))),i&&"constructor"===t.value?_("E049",t,"get"===i.value?"class getter method":"class setter method","constructor"):"prototype"===t.value&&_("E049",t,"class method","prototype"),ge(t),Ee({statement:e,type:r?"generator":null,classExprBinding:e.namedExpr?e.name:null})}else b("W032"),j(";");We(s)}function Ve(e,t,n,r,i){var o=["key","class method","static class method"];o=o[(r||!1)+(i||!1)],n.identifier&&(t=n.value),e[t]&&"__proto__"!==t?b("W075",c.tokens.next,o,t):e[t]=Object.create(null),e[t].basic=!0,e[t].basictkn=n}function Ie(e,t,n,r,i,o){var s="get"===e?"getterToken":"setterToken",a="";i?(o&&(a+="static "),a+=e+"ter method"):a="key",c.tokens.curr.accessorType=e,c.nameStack.set(r),t[n]?(t[n].basic||t[n][s])&&"__proto__"!==n&&b("W075",c.tokens.next,a,n):t[n]=Object.create(null),t[n][s]=r}function Fe(){j("["),c.inES6()||b("W119",c.tokens.curr,"computed property names","6");var e=G(10);return j("]"),e}function Pe(e,t){return"(punctuator)"===e.type&&r.contains(t,e.value)}function Re(e,t){return"(punctuator)"===e.type&&e.value===t}function Ue(){var e=ut();e.notJson?(!c.inES6()&&e.isDestAssign&&b("W104",c.tokens.curr,"destructuring assignment","6"),ce()):(c.option.laxbreak=!0,c.jsonMode=!0,Be())}function Be(){switch(c.tokens.next.id){case"{":!function(){var e={},t=c.tokens.next;if(j("{"),"}"!==c.tokens.next.id)for(;;){if("(end)"===c.tokens.next.id)_("E026",c.tokens.next,t.line);else{if("}"===c.tokens.next.id){b("W094",c.tokens.curr);break}","===c.tokens.next.id?_("E028",c.tokens.next):"(string)"!==c.tokens.next.id&&b("W095",c.tokens.next,c.tokens.next.value)}if(!0===e[c.tokens.next.value]?b("W075",c.tokens.next,"key",c.tokens.next.value):"__proto__"===c.tokens.next.value&&!c.option.proto||"__iterator__"===c.tokens.next.value&&!c.option.iterator?b("W096",c.tokens.next,c.tokens.next.value):e[c.tokens.next.value]=!0,j(),j(":"),Be(),","!==c.tokens.next.id)break;j(",")}j("}")}();break;case"[":!function(){var e=c.tokens.next;if(j("["),"]"!==c.tokens.next.id)for(;;){if("(end)"===c.tokens.next.id)_("E027",c.tokens.next,e.line);else{if("]"===c.tokens.next.id){b("W094",c.tokens.curr);break}","===c.tokens.next.id&&_("E028",c.tokens.next)}if(Be(),","!==c.tokens.next.id)break;j(",")}j("]")}();break;case"true":case"false":case"null":case"(number)":case"(string)":j();break;case"-":j("-"),j("(number)");break;default:_("E003",c.tokens.next)}}function Ne(e,t,n){var r,i,o,s;for(i=0;i":!0,">=":!0,"+":!0,"-":!0,"*":!0,"/":!0,"%":!0},nt=["closure","exception","global","label","outer","unused","var"],rt=[],it=new i.EventEmitter,ot={};ot.legacy=["xml","unknown"],ot.es3=["undefined","boolean","number","string","function","object"],ot.es3=ot.es3.concat(ot.legacy),ot.es6=ot.es3.concat("symbol"),q("(number)",function(){return this}),q("(string)",function(){return this}),c.syntax["(identifier)"]={type:"(identifier)",lbp:0,identifier:!0,nud:function(){var e=this.value;return"=>"===c.tokens.next.id?this:(c.funct["(comparray)"].check(e)||c.funct["(scope)"].block.use(e,c.tokens.curr),this)},led:function(){_("E033",c.tokens.next,c.tokens.next.value)}};var st={identifier:!1,template:!0};c.syntax["(template)"]=r.extend({lbp:155,type:"(template)",nud:be,led:be,noSubst:!1},st),c.syntax["(template middle)"]=r.extend({lbp:0,type:"(template middle)",middle:!0,noSubst:!1},st),c.syntax["(template tail)"]=r.extend({lbp:0,type:"(template tail)",tail:!0,noSubst:!1},st),c.syntax["(no subst template)"]=r.extend({lbp:155,type:"(template)",nud:be,led:be,noSubst:!0,tail:!0},st),q("(regexp)",function(){return this}),R("(endline)"),function(e){e.line=e.from=0}(R("(begin)")),R("(end)").reach=!0,R("(error)").reach=!0,R("}").reach=!0,R(")"),R("]"),R('"').reach=!0,R("'").reach=!0,R(";"),R(":").reach=!0,R("#"),z("else"),z("case").reach=!0,z("catch"),z("default").reach=!0,z("finally"),$("arguments",function(e){c.isStrict()&&c.funct["(global)"]&&b("E008",e)}),$("eval"),$("false"),$("Infinity"),$("null"),$("this",function(e){c.isStrict()&&!de()&&!c.option.validthis&&(c.funct["(statement)"]&&c.funct["(name)"].charAt(0)>"Z"||c.funct["(global)"])&&b("W040",e)}),$("true"),$("undefined"),ee("=","assign",20),ee("+=","assignadd",20),ee("-=","assignsub",20),ee("*=","assignmult",20),ee("/=","assigndiv",20).nud=function(){_("E014")},ee("%=","assignmod",20),ne("&="),ne("|="),ne("^="),ne("<<="),ne(">>="),ne(">>>="),J(",",function(e,t){var n;if(t.exprs=[e],c.option.nocomma&&b("W127"),!F({peek:!0}))return t;for(;;){if(!(n=G(10)))break;if(t.exprs.push(n),","!==c.tokens.next.value||!F())break}return t},10,!0),J("?",function(e,t){return we(),t.left=e,t.right=G(10),j(":"),t.else=G(10),t},30);J("||",function(e,t){return we(),t.left=e,t.right=G(40),t},40),J("&&","and",50),te("|","bitor",70),te("^","bitxor",80),te("&","bitand",90),Z("==",function(e,t){switch(!0){case!(c.option.eqnull&&("null"===(e&&e.value)||"null"===(t&&t.value)))&&c.option.eqeqeq:this.from=this.character,b("W116",this,"===","==");break;case X(t,e,c):b("W122",this,t.value);break;case X(e,t,c):b("W122",this,e.value)}return this}),Z("===",function(e,t){return X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("!=",function(e,t){return!(c.option.eqnull&&("null"===(e&&e.value)||"null"===(t&&t.value)))&&c.option.eqeqeq?(this.from=this.character,b("W116",this,"!==","!=")):X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("!==",function(e,t){return X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("<"),Z(">"),Z("<="),Z(">="),te("<<","shiftleft",120),te(">>","shiftright",120),te(">>>","shiftrightunsigned",120),J("in","in",120),J("instanceof",function(e,t){var n,r=c.funct["(scope)"];return t.left=e,t.right=n=G(120),n?(("(number)"===n.id||"(string)"===n.id||"null"===n.value||"undefined"===n.value&&!r.has("undefined")||"unary"===n.arity||"{"===n.id||"["===n.id&&!n.right||"(regexp)"===n.id||"(template)"===n.id&&!n.tag)&&_("E060"),"function"===n.id&&b("W139"),t):t},120),J("+",function(e,t){var n;return t.left=e,t.right=n=G(130),e&&n&&"(string)"===e.id&&"(string)"===n.id?(e.value+=n.value,e.character=n.character,!c.option.scripturl&&u.javascriptURL.test(e.value)&&b("W050",e),e):t},130),D("+","num"),D("+++",function(){return b("W007"),this.arity="unary",this.right=G(150),this}),J("+++",function(e){return b("W007"),this.left=e,this.right=G(130),this},130),J("-","sub",130),D("-","neg"),D("---",function(){return b("W006"),this.arity="unary",this.right=G(150),this}),J("---",function(e){return b("W006"),this.left=e,this.right=G(130),this},130),J("*","mult",140),J("/","div",140),J("%","mod",140),re("++"),D("++","preinc"),c.syntax["++"].exps=!0,c.syntax["++"].ltBoundary="before",re("--"),D("--","predec"),c.syntax["--"].exps=!0,c.syntax["--"].ltBoundary="before",D("delete",function(){var e=G(10);return e?("."!==e.id&&"["!==e.id&&b("W051"),this.first=e,e.identifier&&!c.isStrict()&&(e.forgiveUndef=!0),this):this}).exps=!0,D("~",function(){return c.option.bitwise&&b("W016",this,"~"),this.arity="unary",this.right=G(150),this}),D("...",function(){return c.inES6(!0)||b("W119",this,"spread/rest operator","6"),c.tokens.next.identifier||"(string)"===c.tokens.next.type||Pe(c.tokens.next,["[","("])||_("E030",c.tokens.next,c.tokens.next.value),this.right=G(150),this}),D("!",function(){return this.arity="unary",this.right=G(150),this.right||y("E041",this),!0===tt[this.right.id]&&b("W018",this,"!"),this}),D("typeof",function(){var e=G(150);return this.first=this.right=e,e||y("E041",this),e.identifier&&(e.forgiveUndef=!0),this}),D("new",function(){var e=Ae("target",function(){c.inES6(!0)||b("W119",c.tokens.prev,"new.target","6");for(var e,t=c.funct;t&&(e=!t["(global)"],t["(arrow)"]);)t=t["(context)"];e||b("W136",c.tokens.prev,"new.target")});if(e)return e;var t,n=G(155);if(n&&"function"!==n.id)if(n.identifier)switch(n.new=!0,n.value){case"Number":case"String":case"Boolean":case"Math":case"JSON":b("W053",c.tokens.prev,n.value);break;case"Symbol":c.inES6()&&b("W053",c.tokens.prev,n.value);break;case"Function":c.option.evil||b("W054");break;case"Date":case"RegExp":case"this":break;default:"function"!==n.id&&(t=n.value.substr(0,1),c.option.newcap&&(t<"A"||t>"Z")&&!c.funct["(scope)"].isPredefined(n.value)&&b("W055",c.tokens.curr))}else"."!==n.id&&"["!==n.id&&"("!==n.id&&b("W056",c.tokens.curr);else c.option.supernew||b("W057",this);return"("===c.tokens.next.id||c.option.supernew||b("W058",c.tokens.curr,c.tokens.curr.value),this.first=this.right=n,this}),c.syntax.new.exps=!0,D("void").exps=!0,J(".",function(e,t){var n=oe(!1,!0);return"string"==typeof n&&pe(n),t.left=e,t.right=n,n&&"hasOwnProperty"===n&&"="===c.tokens.next.value&&b("W001"),!e||"arguments"!==e.value||"callee"!==n&&"caller"!==n?c.option.evil||!e||"document"!==e.value||"write"!==n&&"writeln"!==n||b("W060",e):c.option.noarg?b("W059",e,n):c.isStrict()&&_("E008"),c.option.evil||"eval"!==n&&"execScript"!==n||K(e,c)&&b("W061"),t},160,!0),J("(",function(e,t){c.option.immed&&e&&!e.immed&&"function"===e.id&&b("W062");var n=0,r=[];if(e&&"(identifier)"===e.type&&e.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1==="Array Number String Boolean Date Object Error Symbol".indexOf(e.value)&&("Math"===e.value?b("W063",e):c.option.newcap&&b("W064",e)),")"!==c.tokens.next.id)for(;r[r.length]=G(10),n+=1,","===c.tokens.next.id;)F();return j(")"),"object"==typeof e&&(c.inES5()||"parseInt"!==e.value||1!==n||b("W065",c.tokens.curr),c.option.evil||("eval"===e.value||"Function"===e.value||"execScript"===e.value?b("W061",e):!r[0]||"(string)"!==r[0].id||"setTimeout"!==e.value&&"setInterval"!==e.value?!r[0]||"(string)"!==r[0].id||"."!==e.value||"window"!==e.left.value||"setTimeout"!==e.right&&"setInterval"!==e.right||(b("W066",e),S(e,r[0])):(b("W066",e),S(e,r[0]))),e.identifier||"."===e.id||"["===e.id||"=>"===e.id||"("===e.id||"&&"===e.id||"||"===e.id||"?"===e.id||c.inES6()&&e["(name)"]||b("W067",t)),t.left=e,t},155,!0).exps=!0,D("(",function(e){var t,n,r,i,o,s=c.tokens.next,a=-1,u=1,l=c.tokens.curr,f=c.tokens.prev,p=!c.option.singleGroups;do{"("===s.value?u+=1:")"===s.value&&(u-=1),t=s,s=A(a+=1)}while((0!==u||")"!==t.value)&&"(end)"!==s.type);if("function"===c.tokens.next.id&&(r=c.tokens.next.immed=!0),"=>"===s.value)return Ee({type:"arrow",parsedOpening:!0});var h=[];if(")"!==c.tokens.next.id)for(;h.push(G(10)),","===c.tokens.next.id;)c.option.nocomma&&b("W127"),F();return j(")",this),c.option.immed&&h[0]&&"function"===h[0].id&&"("!==c.tokens.next.id&&"."!==c.tokens.next.id&&"["!==c.tokens.next.id&&b("W068",this),h.length?(h.length>1?((n=Object.create(c.syntax[","])).exprs=h,i=h[0],o=h[h.length-1]):(n=i=o=h[0],p||(p=l.beginsStmt&&("{"===n.id||r||ye(n))||r&&(!O()||"}"!==c.tokens.prev.id)||ye(n)&&!O()||"{"===n.id&&"=>"===f.id||"(number)"===n.type&&Re(s,".")&&/^\d+$/.test(n.value)||l.beginsStmt&&"="===n.id&&"{"===n.left.id)),n&&(p||!T(i)&&!n.exprs||(p=e>i.lbp||e>0&&e===i.lbp||!O()&&o.lbp"),J("[",function(e,t){var n,r=G(10);return r&&"(string)"===r.type&&(c.option.evil||"eval"!==r.value&&"execScript"!==r.value||K(e,c)&&b("W061"),pe(r.value),!c.option.sub&&u.identifier.test(r.value)&&((n=c.syntax[r.value])&&d(n)||b("W069",c.tokens.prev,r.value))),j("]",t),r&&"hasOwnProperty"===r.value&&"="===c.tokens.next.value&&b("W001"),t.left=e,t.right=r,t},160,!0),D("[",function(){var e=ut();if(e.isCompArray)return c.option.esnext||c.inMoz()||b("W118",c.tokens.curr,"array comprehension"),he();if(e.isDestAssign)return this.destructAssign=Le({openingParsed:!0,assignment:!0}),this;var t=c.tokens.curr.line!==C(c.tokens.next);for(this.first=[],t&&($e+=c.option.indent,c.tokens.next.from===$e+c.option.indent&&($e+=c.option.indent));"(end)"!==c.tokens.next.id;){for(;","===c.tokens.next.id;){if(!c.option.elision){if(c.inES5()){b("W128");do{j(",")}while(","===c.tokens.next.id);continue}b("W070")}j(",")}if("]"===c.tokens.next.id)break;if(this.first.push(G(10)),","!==c.tokens.next.id){c.option.trailingcomma&&c.inES5()&&E("W140",c.tokens.curr.line,c.tokens.curr.character);break}if(F({allowTrailing:!0}),"]"===c.tokens.next.id&&!c.inES5()){b("W070",c.tokens.curr);break}}return t&&($e-=c.option.indent),j("]",this),this}),function(e){e.nud=function(){var e,t,n,r,i,o,s=!1,a=Object.create(null);if((e=c.tokens.curr.line!==C(c.tokens.next))&&($e+=c.option.indent,c.tokens.next.from===$e+c.option.indent&&($e+=c.option.indent)),ut().isDestAssign)return this.destructAssign=Le({openingParsed:!0,assignment:!0}),this;for(;"}"!==c.tokens.next.id;){if(o=c.tokens.next.value,!c.tokens.next.identifier||","!==L().id&&"}"!==L().id)if(":"===A().id||"get"!==o&&"set"!==o){if("*"===c.tokens.next.value&&"(punctuator)"===c.tokens.next.type?(c.inES6()||b("W104",c.tokens.next,"generator functions","6"),j("*"),s=!0):s=!1,"["===c.tokens.next.id)n=Fe(),c.nameStack.set(n);else if(c.nameStack.set(c.tokens.next),n=ge(),Ve(a,n,c.tokens.next),"string"!=typeof n)break;"("===c.tokens.next.value?(c.inES6()||b("W104",c.tokens.curr,"concise methods","6"),Ee({type:s?"generator":null})):(j(":"),G(10))}else j(o),c.inES5()||_("E034"),(n=ge())||c.inES6()||_("E035"),n&&Ie(o,a,n,c.tokens.curr),i=c.tokens.next,r=(t=Ee())["(params)"],"get"===o&&n&&r?b("W076",i,r[0],n):"set"===o&&n&&1!==t["(metrics)"].arity&&b("W077",i,n);else c.inES6()||b("W104",c.tokens.next,"object short notation","6"),Ve(a,n=ge(!0),c.tokens.next),G(10);if(pe(n),","!==c.tokens.next.id){c.option.trailingcomma&&c.inES5()&&E("W140",c.tokens.curr.line,c.tokens.curr.character);break}F({allowTrailing:!0,property:!0}),","===c.tokens.next.id?b("W070",c.tokens.curr):"}"!==c.tokens.next.id||c.inES5()||b("W070",c.tokens.curr)}return e&&($e-=c.option.indent),j("}",this),We(a),this},e.fud=function(){_("E036",c.tokens.curr)}}(R("{")),U("const",function(e){return Oe("const",this,e)}).exps=!0,U("let",function(e){return Oe("let",this,e)}).exps=!0,U("var",function(e){var t,n,i,s=e&&e.prefix,a=e&&e.inexport;for(this.first=[];;){var u=[];r.contains(["{","["],c.tokens.next.value)?(t=Le(),n=!1):(t=[{id:oe(),token:c.tokens.curr}],n=!0),c.option.varstmt&&b("W132",this),this.first=this.first.concat(u);for(var l in t)t.hasOwnProperty(l)&&(l=t[l],c.funct["(global)"]&&!c.impliedClosure()&&(!1===Ye[l.id]?b("W079",l.token,l.id):!1===c.option.futurehostile&&(!c.inES5()&&!1===o.ecmaIdentifiers[5][l.id]||!c.inES6()&&!1===o.ecmaIdentifiers[6][l.id])&&b("W129",l.token,l.id)),l.id&&(c.funct["(scope)"].addlabel(l.id,{type:"var",token:l.token}),n&&a&&c.funct["(scope)"].setExported(l.id,l.token),u.push(l.token)));if("="===c.tokens.next.id){c.nameStack.set(c.tokens.curr),j("="),"="===A(0).id&&c.tokens.next.identifier&&((s||c.funct["(params)"])&&-1!==c.funct["(params)"].indexOf(c.tokens.next.value)||b("W120",c.tokens.next,c.tokens.next.value));var f=c.tokens.prev;!(i=G(s?120:10))||s||c.funct["(loopage)"]||"undefined"!==i.type||b("W080",f,f.value),n?t[0].first=i:Te(u,i)}if(","!==c.tokens.next.id)break;F()}return this}).exps=!0,B("class",function(e){return Ge.call(this,e,!0)}),B("function",function(e){var t=e&&e.inexport,n=!1;"*"===c.tokens.next.value&&(j("*"),c.inES6(!0)?n=!0:b("W119",c.tokens.curr,"function*","6")),He&&b("W082",c.tokens.curr);var r=ie();return c.funct["(scope)"].addlabel(r,{type:"function",token:c.tokens.curr}),void 0===r?b("W025"):t&&c.funct["(scope)"].setExported(r,c.tokens.prev),Ee({name:r,statement:this,type:n?"generator":null,ignoreLoopFunc:He}),"("===c.tokens.next.id&&c.tokens.next.line===c.tokens.curr.line&&_("E039"),this}),D("function",function(){var e=!1;return"*"===c.tokens.next.value&&(c.inES6()||b("W119",c.tokens.curr,"function*","6"),j("*"),e=!0),Ee({name:ie(),type:e?"generator":null}),this}),B("if",function(){var e=c.tokens.next;we(),c.condition=!0,j("(");var t=G(0);t||y("E041",this),Se(t);var n=null;c.option.forin&&c.forinifcheckneeded&&(c.forinifcheckneeded=!1,n=c.forinifchecks[c.forinifchecks.length-1],"(punctuator)"===t.type&&"!"===t.value?n.type="(negative)":n.type="(positive)"),j(")",e),c.condition=!1;var r=fe(!0,!0);return n&&"(negative)"===n.type&&r&&r[0]&&"(identifier)"===r[0].type&&"continue"===r[0].value&&(n.type="(negative-with-continue)"),"else"===c.tokens.next.id&&(j("else"),"if"===c.tokens.next.id||"switch"===c.tokens.next.id?ue():fe(!0,!0)),this}),B("try",function(){var e;for(fe(!0);"catch"===c.tokens.next.id;)we(),e&&!c.inMoz()&&b("W118",c.tokens.next,"multiple catch blocks"),function(){if(j("catch"),j("("),c.funct["(scope)"].stack("catchparams"),Pe(c.tokens.next,["[","{"])){var e=Le();r.each(e,function(e){e.id&&c.funct["(scope)"].addParam(e.id,e,"exception")})}else"(identifier)"!==c.tokens.next.type?b("E030",c.tokens.next,c.tokens.next.value):c.funct["(scope)"].addParam(oe(),c.tokens.curr,"exception");"if"===c.tokens.next.value&&(c.inMoz()||b("W118",c.tokens.curr,"catch filter"),j("if"),G(0)),j(")"),fe(!1),c.funct["(scope)"].unstack()}(),e=!0;return"finally"===c.tokens.next.id?(j("finally"),void fe(!0)):(e||_("E021",c.tokens.next,"catch",c.tokens.next.value),this)}),B("while",function(){var e=c.tokens.next;return c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,we(),j("("),Se(G(0)),j(")",e),fe(!0,!0),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1,this}).labelled=!0,B("with",function(){var e=c.tokens.next;return c.isStrict()?_("E010",c.tokens.curr):c.option.withstmt||b("W085",c.tokens.curr),j("("),G(0),j(")",e),fe(!0,!0),this}),B("switch",function(){var e=c.tokens.next,t=!1,n=!1;for(c.funct["(breakage)"]+=1,j("("),Se(G(0)),j(")",e),e=c.tokens.next,j("{"),c.tokens.next.from===$e&&(n=!0),n||($e+=c.option.indent),this.cases=[];;)switch(c.tokens.next.id){case"case":switch(c.funct["(verb)"]){case"yield":case"break":case"case":case"continue":case"return":case"switch":case"throw":break;default:c.tokens.curr.caseFallsThrough||b("W086",c.tokens.curr,"case")}j("case"),this.cases.push(G(0)),we(),t=!0,j(":"),c.funct["(verb)"]="case";break;case"default":switch(c.funct["(verb)"]){case"yield":case"break":case"continue":case"return":case"throw":break;default:this.cases.length&&(c.tokens.curr.caseFallsThrough||b("W086",c.tokens.curr,"default"))}j("default"),t=!0,j(":");break;case"}":return n||($e-=c.option.indent),j("}",e),c.funct["(breakage)"]-=1,void(c.funct["(verb)"]=void 0);case"(end)":return void _("E023",c.tokens.next,"}");default:if($e+=c.option.indent,t)switch(c.tokens.curr.id){case",":return void _("E040");case":":t=!1,ce();break;default:return void _("E025",c.tokens.curr)}else{if(":"!==c.tokens.curr.id)return void _("E021",c.tokens.next,"case",c.tokens.next.value);j(":"),_("E024",c.tokens.curr,":"),ce()}$e-=c.option.indent}return this}).labelled=!0,U("debugger",function(){return c.option.debug||b("W087",this),this}).exps=!0,function(){var e=U("do",function(){c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,we(),this.first=fe(!0,!0),j("while");var e=c.tokens.next;return j("("),Se(G(0)),j(")",e),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1,this});e.labelled=!0,e.exps=!0}(),B("for",function(){var e,t=c.tokens.next,n=!1,i=null;"each"===t.value&&(i=t,j("each"),c.inMoz()||b("W118",c.tokens.curr,"for each")),we(),j("(");var o,s,a,u,l,f,p=0,h=["in","of"],d=0;Pe(c.tokens.next,["{","["])&&++d;do{if(o=A(p),++p,Pe(o,["{","["])?++d:Pe(o,["}","]"])&&--d,d<0)break;0===d&&(!s&&Re(o,",")?s=o:!a&&Re(o,"=")&&(a=o))}while(d>0||!r.contains(h,o.value)&&";"!==o.value&&"(end)"!==o.type);if(r.contains(h,o.value)){if("of"===o.value?(u=20,c.inES6()||b("W104",o,"for of","6")):u=0,a&&_("W133",s,o.value,"initializer is forbidden"),s&&_("W133",s,o.value,"more than one ForBinding"),"var"===c.tokens.next.id)j("var"),c.tokens.curr.fud({prefix:!0});else if("let"===c.tokens.next.id||"const"===c.tokens.next.id)j(c.tokens.next.id),n=!0,c.funct["(scope)"].stack(),c.tokens.curr.fud({prefix:!0});else{l=[];do{Pe(c.tokens.next,["{","["])?Le({assignment:!0}).forEach(function(e){this.push(e.token)},l):("(identifier)"===(f=G(120)).type&&l.push(f),Q(f,o)),Re(c.tokens.next,"=")&&(j("="),G(120)),Re(c.tokens.next,",")&&j(",")}while(c.tokens.next!==o);a||s||l.forEach(function(e){c.funct["(scope)"].has(e.value)||b("W088",e,e.value)})}if(j(o.value),G(u),j(")",t),"in"===o.value&&c.option.forin&&(c.forinifcheckneeded=!0,void 0===c.forinifchecks&&(c.forinifchecks=[]),c.forinifchecks.push({type:"(none)"})),c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,e=fe(!0,!0),"in"===o.value&&c.option.forin){if(c.forinifchecks&&c.forinifchecks.length>0){var v=c.forinifchecks.pop();(e&&e.length>0&&("object"!=typeof e[0]||"if"!==e[0].value)||"(positive)"===v.type&&e.length>1||"(negative)"===v.type)&&b("W089",this)}c.forinifcheckneeded=!1}c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1}else{if(i&&_("E045",i),";"!==c.tokens.next.id)if("var"===c.tokens.next.id)j("var"),c.tokens.curr.fud();else if("let"===c.tokens.next.id)j("let"),n=!0,c.funct["(scope)"].stack(),c.tokens.curr.fud();else for(;G(0,"for"),","===c.tokens.next.id;)F();if(V(c.tokens.curr),j(";"),c.funct["(loopage)"]+=1,";"!==c.tokens.next.id&&Se(G(0)),V(c.tokens.curr),j(";"),";"===c.tokens.next.id&&_("E021",c.tokens.next,")",";"),")"!==c.tokens.next.id)for(;G(0,"for"),","===c.tokens.next.id;)F();j(")",t),c.funct["(breakage)"]+=1,fe(!0,!0),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1}return n&&c.funct["(scope)"].unstack(),this}).labelled=!0,U("break",function(){var e=c.tokens.next.value;return c.option.asi||V(this),";"===c.tokens.next.id||c.tokens.next.reach||c.tokens.curr.line!==C(c.tokens.next)?0===c.funct["(breakage)"]&&b("W052",c.tokens.next,this.value):(c.funct["(scope)"].funct.hasBreakLabel(e)||b("W090",c.tokens.next,e),this.first=c.tokens.next,j()),se(this),this}).exps=!0,U("continue",function(){var e=c.tokens.next.value;return 0!==c.funct["(breakage)"]&&c.funct["(loopage)"]||b("W052",c.tokens.next,this.value),c.option.asi||V(this),";"===c.tokens.next.id||c.tokens.next.reach||c.tokens.curr.line===C(c.tokens.next)&&(c.funct["(scope)"].funct.hasBreakLabel(e)||b("W090",c.tokens.next,e),this.first=c.tokens.next,j()),se(this),this}).exps=!0,U("return",function(){return this.line===C(c.tokens.next)?";"===c.tokens.next.id||c.tokens.next.reach||(this.first=G(0),!this.first||"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)):"(punctuator)"===c.tokens.next.type&&["[","{","+","-"].indexOf(c.tokens.next.value)>-1&&V(this),se(this),this}).exps=!0,function(e){e.exps=!0,e.lbp=25,e.ltBoundary="after"}(D("yield",function(){if(c.inMoz())return at.call(this);var e=c.tokens.prev;!this.beginsStmt&&e.lbp>30&&!Pe(e,["("])&&_("E061",this),c.inES6(!0)&&!c.funct["(generator)"]?"(catch)"===c.funct["(name)"]&&c.funct["(context)"]["(generator)"]||_("E046",c.tokens.curr,"yield"):c.inES6()||b("W104",c.tokens.curr,"yield","6"),c.funct["(generator)"]="yielded";return"*"===c.tokens.next.value&&(!0,j("*")),O()||","===c.tokens.next.id||(c.tokens.next.nud?(M(c.tokens.curr,c.tokens.next),this.first=G(10),"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)):c.tokens.next.led&&","!==c.tokens.next.id&&_("W017",c.tokens.next)),this}));var at=function(){var e=c.tokens.prev;c.inES6(!0)&&!c.funct["(generator)"]&&("(catch)"===c.funct["(name)"]&&c.funct["(context)"]["(generator)"]||_("E046",c.tokens.curr,"yield")),c.funct["(generator)"]="yielded";var t=!1;return"*"===c.tokens.next.value&&(t=!0,j("*")),this.line===C(c.tokens.next)?((t||";"!==c.tokens.next.id&&!c.option.asi&&!c.tokens.next.reach&&c.tokens.next.nud)&&(M(c.tokens.curr,c.tokens.next),this.first=G(10),"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)),")"!==c.tokens.next.id&&(e.lbp>30||!e.assign&&!O()||"yield"===e.id)&&_("E050",this)):c.option.asi||V(this),this};U("throw",function(){return V(this),this.first=G(20),se(this),this}).exps=!0,U("import",function(){if(c.funct["(scope)"].block.isGlobal()||_("E053",c.tokens.curr,"Import"),c.inES6()||b("W119",c.tokens.curr,"import","6"),"(string)"===c.tokens.next.type)return j("(string)"),this;if(c.tokens.next.identifier){if(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"import",initialized:!0,token:c.tokens.curr}),","!==c.tokens.next.value)return j("from"),j("(string)"),this;j(",")}if("*"===c.tokens.next.id)j("*"),j("as"),c.tokens.next.identifier&&(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"import",initialized:!0,token:c.tokens.curr}));else for(j("{");;){if("}"===c.tokens.next.value){j("}");break}var e;if("default"===c.tokens.next.type?(e="default",j("default")):e=oe(),"as"===c.tokens.next.value&&(j("as"),e=oe()),c.funct["(scope)"].addlabel(e,{type:"import",initialized:!0,token:c.tokens.curr}),","!==c.tokens.next.value){if("}"===c.tokens.next.value){j("}");break}_("E024",c.tokens.next,c.tokens.next.value);break}j(",")}return j("from"),j("(string)"),this}).exps=!0,U("export",function(){var e,t,n=!0;if(c.inES6()||(b("W119",c.tokens.curr,"export","6"),n=!1),c.funct["(scope)"].block.isGlobal()||(_("E053",c.tokens.curr,"Export"),n=!1),"*"===c.tokens.next.value)return j("*"),j("from"),j("(string)"),this;if("default"===c.tokens.next.type){c.nameStack.set(c.tokens.next),j("default");var r=c.tokens.next.id;return"function"!==r&&"class"!==r||(this.block=!0),e=A(),G(10),t=e.value,this.block&&(c.funct["(scope)"].addlabel(t,{type:r,initialized:!0,token:e}),c.funct["(scope)"].setExported(t,e)),this}if("{"===c.tokens.next.value){j("{");for(var i=[];;){if(c.tokens.next.identifier||_("E030",c.tokens.next,c.tokens.next.value),j(),i.push(c.tokens.curr),"as"===c.tokens.next.value&&(j("as"),c.tokens.next.identifier||_("E030",c.tokens.next,c.tokens.next.value),j()),","!==c.tokens.next.value){if("}"===c.tokens.next.value){j("}");break}_("E024",c.tokens.next,c.tokens.next.value);break}j(",")}return"from"===c.tokens.next.value?(j("from"),j("(string)")):n&&i.forEach(function(e){c.funct["(scope)"].setExported(e.value,e)}),this}if("var"===c.tokens.next.id)j("var"),c.tokens.curr.fud({inexport:!0});else if("let"===c.tokens.next.id)j("let"),c.tokens.curr.fud({inexport:!0});else if("const"===c.tokens.next.id)j("const"),c.tokens.curr.fud({inexport:!0});else if("function"===c.tokens.next.id)this.block=!0,j("function"),c.syntax.function.fud({inexport:!0});else if("class"===c.tokens.next.id){this.block=!0,j("class");var o=c.tokens.next;c.syntax.class.fud(),c.funct["(scope)"].setExported(o.value,o)}else _("E024",c.tokens.next,c.tokens.next.value);return this}).exps=!0,H("abstract"),H("await",{es5:!0,moduleOnly:!0}),H("boolean"),H("byte"),H("char"),H("class",{es5:!0,nud:Ge}),H("double"),H("enum",{es5:!0}),H("export",{es5:!0}),H("extends",{es5:!0}),H("final"),H("float"),H("goto"),H("implements",{es5:!0,strictOnly:!0}),H("import",{es5:!0}),H("int"),H("interface",{es5:!0,strictOnly:!0}),H("long"),H("native"),H("package",{es5:!0,strictOnly:!0}),H("private",{es5:!0,strictOnly:!0}),H("protected",{es5:!0,strictOnly:!0}),H("public",{es5:!0,strictOnly:!0}),H("short"),H("static",{es5:!0,strictOnly:!0}),H("super",{es5:!0}),H("synchronized"),H("transient"),H("volatile");var ut=function(){var e,t,n,r=-1,i=0,o={};Pe(c.tokens.curr,["[","{"])&&(i+=1);do{if(n=-1===r?c.tokens.curr:e,e=-1===r?c.tokens.next:A(r),t=A(r+1),r+=1,Pe(e,["[","{"])?i+=1:Pe(e,["]","}"])&&(i-=1),1===i&&e.identifier&&"for"===e.value&&!Re(n,".")){o.isCompArray=!0,o.notJson=!0;break}if(0===i&&Pe(e,["}","]"])){if("="===t.value){o.isDestAssign=!0,o.notJson=!0;break}if("."===t.value){o.notJson=!0;break}}Re(e,";")&&(o.isBlock=!0,o.notJson=!0)}while(i>0&&"(end)"!==e.id);return o},ct=function(){function e(e){return 0!==n.variables.filter(function(t){if(t.value===e)return t.undef=!1,e}).length}function t(e){return 0===n.variables.filter(function(t){if(t.value===e&&!t.undef)return!0===t.unused&&(t.unused=!1),e}).length}var n,i=function(){this.mode="use",this.variables=[]},o=[];return{stack:function(){n=new i,o.push(n)},unstack:function(){n.variables.filter(function(e){e.unused&&b("W098",e.token,e.raw_text||e.value),e.undef&&c.funct["(scope)"].block.use(e.value,e.token)}),o.splice(-1,1),n=o[o.length-1]},setState:function(e){r.contains(["use","define","generate","filter"],e)&&(n.mode=e)},check:function(r){if(n)return n&&"use"===n.mode?(t(r)&&n.variables.push({funct:c.funct,token:c.tokens.curr,value:r,undef:!0,unused:!1}),!0):n&&"define"===n.mode?(e(r)||n.variables.push({funct:c.funct,token:c.tokens.curr,value:r,undef:!1,unused:!0}),!0):n&&"generate"===n.mode?(c.funct["(scope)"].block.use(r,c.tokens.curr),!0):!(!n||"filter"!==n.mode)&&(t(r)&&c.funct["(scope)"].block.use(r,c.tokens.curr),!0)}}},lt=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},ft=function(n,i,s){function u(e,t){e&&(Array.isArray(e)||"object"!=typeof e||(e=Object.keys(e)),e.forEach(t))}var l,f,d,v,m={},x={};i=r.clone(i),c.reset(),i&&i.scope?h.scope=i.scope:(h.errors=[],h.undefs=[],h.internals=[],h.blacklist={},h.scope="(main)"),g(Ye=Object.create(null),o.ecmaIdentifiers[3]),g(Ye,o.reservedVars),g(Ye,s||{}),qe=Object.create(null);var S=Object.create(null);if(i)for(u(i.predef||null,function(e){var t,n;"-"===e[0]?(t=e.slice(1),h.blacklist[t]=t,delete Ye[t]):(n=Object.getOwnPropertyDescriptor(i.predef,e),Ye[e]=!!n&&n.value)}),u(i.exported||null,function(e){S[e]=!0}),delete i.predef,delete i.exported,v=Object.keys(i),l=0;l0&&(s.implieds=a),et.length>0&&(s.urls=et),(o=c.funct["(scope)"].getUsedOrDefinedGlobals()).length>0&&(s.globals=o),n=1;n0&&(s.unused=u);for(i in Xe)if("number"==typeof Xe[i]){s.member=Xe;break}return s},ft.jshint=ft,ft}());"object"==typeof n&&n&&(n.JSHINT=h)},{"./lex.js":13,"./messages.js":14,"./options.js":16,"./reg.js":17,"./scope-manager.js":18,"./state.js":19,"./style.js":20,"./vars.js":21,"console-browserify":10,events:5,lodash:12}]},{},[]),JSHINT=e("jshint").JSHINT,"object"==typeof exports&&exports&&(exports.JSHINT=JSHINT)}(); +var JSHINT;"undefined"==typeof window&&(window={}),function(){var e;e=function t(n,r,i){function o(a,u){if(!r[a]){if(!n[a]){var c="function"==typeof e&&e;if(!u&&c)return c(a,!0);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[a]={exports:{}};n[a][0].call(f.exports,function(e){var t=n[a][1][e];return o(t||e)},f,f.exports,t,n,r,i)}return r[a].exports}for(var s="function"==typeof e&&e,a=0;a=65&&i<=90||95===i||i>=97&&i<=122;for(var o=[],i=0;i<128;i++)o[i]=r[i]||i>=48&&i<=57;t.exports={asciiIdentifierStartTable:r,asciiIdentifierPartTable:o}},{}],2:[function(e,t,n){var r=[];[[768,112],[1155,5],[1425,45],1472,[1473,2],[1476,2],1480,[1552,11],[1611,31],1649,[1750,7],[1759,6],[1767,2],[1770,4],[1776,10],1810,[1840,27],[1958,11],[1984,10],[2027,9],[2070,4],[2075,9],[2085,3],[2089,5],[2137,3],[2276,27],[2304,4],[2362,3],[2366,18],[2385,7],[2402,2],[2406,10],[2433,3],2493,[2494,7],[2503,2],[2507,3],2520,[2530,2],[2534,10],[2561,3],2621,[2622,5],[2631,2],[2635,3],2642,[2662,12],2678,[2689,3],2749,[2750,8],[2759,3],[2763,3],[2786,2],[2790,10],[2817,3],2877,[2878,7],[2887,2],[2891,3],[2902,2],[2914,2],[2918,10],2947,[3006,5],[3014,3],[3018,4],3032,[3046,10],[3073,3],[3134,7],[3142,3],[3146,4],[3157,2],[3170,2],[3174,10],[3202,2],3261,[3262,7],[3270,3],[3274,4],[3285,2],[3298,2],[3302,10],[3330,2],[3390,7],[3398,3],[3402,4],3416,[3426,2],[3430,10],[3458,2],3531,[3535,6],3543,[3544,8],[3570,2],3634,[3636,7],[3655,8],[3664,10],3762,[3764,6],[3771,2],[3784,6],[3792,10],[3864,2],[3872,10],3894,3896,3898,[3902,2],[3953,20],[3974,2],[3981,11],[3993,36],4039,[4139,20],[4160,10],[4182,4],[4190,3],[4194,3],[4199,7],[4209,4],[4226,12],[4239,15],[4957,3],[5906,3],[5938,3],[5970,2],[6002,2],[6068,32],6110,[6112,10],[6155,3],[6160,10],6314,[6432,12],[6448,12],[6470,10],[6576,17],[6600,2],[6608,10],[6679,5],[6741,10],[6752,29],[6783,11],[6800,10],[6912,5],[6964,17],[6992,10],[7019,9],[7040,3],[7073,13],[7088,10],[7142,14],[7204,20],[7232,10],[7248,10],[7376,3],[7380,21],7406,[7410,3],[7616,39],[7676,4],[8204,2],[8255,2],8277,[8400,13],8418,[8421,12],[11503,3],11648,[11744,32],[12330,6],[12441,2],[42528,10],42608,[42612,10],42656,[42736,2],43011,43015,43020,[43043,5],[43136,2],[43188,17],[43216,10],[43232,18],[43264,10],[43302,8],[43335,13],[43392,4],[43443,14],[43472,10],[43561,14],43588,[43596,2],[43600,10],43644,43697,[43698,3],[43703,2],[43710,2],43714,[43755,5],[43765,2],[44003,8],[44012,2],[44016,10],64287,[65024,16],[65056,7],[65075,2],[65101,3],[65296,10],65344].forEach(function(o){for(var x=0;x<(o[1]||1);x++)r.push((o[0]||o)+x)});t.exports=r},{}],3:[function(e,t,n){var r=[];[171,182,187,[192,23],[216,31],[248,458],[710,12],[736,5],749,751,[880,5],[886,2],[890,4],903,[904,3],909,[910,20],[931,83],[1015,139],[1162,158],[1329,38],1370,[1377,39],[1488,27],[1520,3],[1568,43],[1646,2],[1649,99],1750,[1765,2],[1774,2],[1786,3],1792,1809,[1810,30],[1869,89],1970,[1994,33],[2036,2],2043,[2048,22],2075,2085,2089,[2112,25],2209,[2210,11],[2308,54],2366,2385,[2392,10],[2417,7],[2425,7],[2437,8],[2447,2],[2451,22],[2474,7],2483,[2486,4],2494,2511,[2524,2],[2527,3],[2544,2],[2565,6],[2575,2],[2579,22],[2602,7],[2610,2],[2613,2],[2616,2],[2649,4],2655,[2674,3],[2693,9],[2703,3],[2707,22],[2730,7],[2738,2],[2741,5],2750,2769,[2784,2],[2821,8],[2831,2],[2835,22],[2858,7],[2866,2],[2869,5],2878,[2908,2],[2911,3],2930,2948,[2949,6],[2958,3],[2962,4],[2969,2],2973,[2974,2],[2979,2],[2984,3],[2990,12],3025,[3077,8],[3086,3],[3090,23],[3114,10],[3125,5],3134,[3160,2],[3168,2],[3205,8],[3214,3],[3218,23],[3242,10],[3253,5],3262,3295,[3296,2],[3313,2],[3333,8],[3342,3],[3346,41],3390,3407,[3424,2],[3450,6],[3461,18],[3482,24],[3507,9],3518,[3520,7],[3585,48],[3634,2],[3648,7],[3713,2],3717,[3719,2],3723,3726,[3732,4],[3737,7],[3745,3],3750,3752,[3754,2],[3757,4],[3762,2],3774,[3776,5],3783,[3804,4],3841,[3904,8],[3913,36],[3976,5],[4096,43],4160,[4176,6],[4186,4],4194,[4197,2],[4206,3],[4213,13],4239,[4256,38],4296,4302,[4304,43],[4348,333],[4682,4],[4688,7],4697,[4698,4],[4704,41],[4746,4],[4752,33],[4786,4],[4792,7],4801,[4802,4],[4808,15],[4824,57],[4882,4],[4888,67],[4992,16],[5024,85],[5121,620],[5743,17],[5761,26],[5792,75],[5870,3],[5888,13],[5902,4],[5920,18],[5952,18],[5984,13],[5998,3],[6016,52],6104,6109,[6176,88],[6272,41],6315,[6320,70],[6400,29],[6480,30],[6512,5],[6528,44],[6593,7],[6656,23],[6688,53],6824,[6917,47],[6981,7],[7043,30],[7086,2],[7098,44],[7168,36],[7245,3],[7258,36],[7401,4],[7406,4],[7413,2],[7424,192],[7680,278],[7960,6],[7968,38],[8008,6],[8016,8],8026,8028,8030,[8031,31],[8064,53],[8118,7],8127,[8130,3],[8134,7],[8144,4],[8150,6],[8160,13],[8178,3],[8182,7],8306,8320,[8336,13],8451,8456,[8458,10],8470,[8473,5],8485,8487,8489,[8490,4],[8495,11],[8508,4],[8517,5],8527,[8544,41],[11264,47],[11312,47],[11360,133],[11499,4],[11506,2],[11520,38],11560,11566,[11568,56],11632,[11648,23],[11680,7],[11688,7],[11696,7],[11704,7],[11712,7],[11720,7],[11728,7],[11736,7],11824,[12293,3],[12321,9],[12337,5],[12344,5],[12353,86],[12445,3],[12449,90],[12540,4],[12549,41],[12593,94],[12704,27],[12784,16],[13312,6582],[19968,20941],[40960,1165],[42192,46],[42240,269],[42512,16],[42538,2],[42560,47],[42623,25],[42656,80],[42775,9],[42786,103],[42891,4],[42896,4],[42912,11],[43000,10],[43011,3],[43015,4],[43020,23],[43072,52],[43138,50],[43250,6],43260,[43274,28],[43312,23],[43360,29],[43396,47],43472,[43520,41],[43584,3],[43588,8],[43616,23],43643,[43648,48],43698,[43701,2],[43705,5],43713,43715,[43739,3],[43744,11],[43762,3],[43777,6],[43785,6],[43793,6],[43808,7],[43816,7],[43968,35],[44032,11172],[55216,23],[55243,49],[63744,366],[64112,106],[64256,7],[64275,5],64286,[64287,10],[64298,13],[64312,5],64319,[64320,2],[64323,2],[64326,108],[64467,363],[64848,64],[64914,54],[65008,12],[65136,5],[65142,135],[65313,26],[65345,26],[65382,89],[65474,6],[65482,6],[65490,6],[65498,3]].forEach(function(o){for(var x=0;x<(o[1]||1);x++)r.push((o[0]||o)+x)});t.exports=r},{}],4:[function(e,t,n){function r(e,t){return h.isUndefined(t)?""+t:h.isNumber(t)&&!isFinite(t)?t.toString():h.isFunction(t)||h.isRegExp(t)?t.toString():t}function i(e,t){return h.isString(e)?e.length=0;o--)if(s[o]!=a[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!u(e[i],t[i]))return!1;return!0}function f(e,t){return!(!e||!t)&&("[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t||!0===t.call({},e))}function p(e,t,n,r){var i;h.isString(n)&&(r=n,n=null);try{t()}catch(e){i=e}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&s(i,n,"Missing expected exception"+r),!e&&f(i,n)&&s(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var h=e("util/"),d=Array.prototype.slice,v=Object.prototype.hasOwnProperty,g=t.exports=a;g.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var t=e.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,i=t.name,a=r.indexOf("\n"+i);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},h.inherits(g.AssertionError,Error),g.fail=s,g.ok=a,g.equal=function(e,t,n){e!=t&&s(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&s(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){u(e,t)||s(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){u(e,t)&&s(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&s(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&s(e,t,n,"!==",g.notStrictEqual)},g.throws=function(e,t,n){p.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(e,t){p.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var m=Object.keys||function(e){var t=[];for(var n in e)v.call(e,n)&&t.push(n);return t}},{"util/":9}],5:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],a(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(r=arguments.length,o=new Array(r-1),u=1;u0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){return e._events&&e._events[t]?i(e._events[t])?1:e._events[t].length:0}},{}],6:[function(e,t,n){function r(){if(!a){a=!0;for(var e,t=s.length;t;){e=s,s=[];for(var n=-1;++n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(t)?r.showHidden=t:t&&n._extend(r,t),y(r.showHidden)&&(r.showHidden=!1),y(r.depth)&&(r.depth=2),y(r.colors)&&(r.colors=!1),y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function a(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&w(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return k(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),v=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),_(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(t);if(0===s.length){if(w(t)){var g=t.name?": "+t.name:"";return e.stylize("[Function"+g+"]","special")}if(x(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(_(t))return l(t)}var m="",y=!1,b=["{","}"];if(d(t)&&(y=!0,b=["[","]"]),w(t)&&(m=" [Function"+(t.name?": "+t.name:"")+"]"),x(t)&&(m=" "+RegExp.prototype.toString.call(t)),E(t)&&(m=" "+Date.prototype.toUTCString.call(t)),_(t)&&(m=" "+l(t)),0===s.length&&(!y||0==t.length))return b[0]+m+b[1];if(r<0)return x(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=y?f(e,t,r,v,s):s.map(function(n){return p(e,t,r,v,n,y)}),e.seen.pop(),h(S,m,b)}function c(e,t){if(y(t))return e.stylize("undefined","undefined");if(k(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,n,r,i){for(var o=[],s=0,a=t.length;s-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),y(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function h(e,t,n){var r=0;return e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function k(e){return"string"==typeof e}function y(e){return void 0===e}function x(e){return b(e)&&"[object RegExp]"===S(e)}function b(e){return"object"==typeof e&&null!==e}function E(e){return b(e)&&"[object Date]"===S(e)}function _(e){return b(e)&&("[object Error]"===S(e)||e instanceof Error)}function w(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function W(e){return e<10?"0"+e.toString(10):e.toString(10)}function A(){var e=new Date,t=[W(e.getHours()),W(e.getMinutes()),W(e.getSeconds())].join(":");return[e.getDate(),G[e.getMonth()],t].join(" ")}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var j=/%[sdj%]/g;n.format=function(e){if(!k(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}}),a=r[n];nt||!n||e===S&&r)return 1;if(e-1;);return n}function l(e,t){for(var n=e.length;n--&&t.indexOf(e.charAt(n))>-1;);return n}function f(e,t){return r(e.criteria,t.criteria)||e.index-t.index}function p(e,t,n){for(var i=-1,o=e.criteria,s=t.criteria,a=o.length,u=n.length;++i=u?c:c*(n[i]?1:-1)}return e.index-t.index}function h(e){return Ne[e]}function d(e){return De[e]}function v(e){return"\\"+He[e]}function g(e,t,n){for(var r=e.length,i=t+(n?0:-1);n?i--:++i=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function y(e,t){for(var n=-1,r=e.length,i=-1,o=[];++nr&&(r=i)}return r}function Ye(e,t){for(var n=-1,r=e.length;++n=200?Xi(t):null,c=t.length;u&&(s=ze,a=!1,t=u);e:for(;++ii?0:i+n),(r=r===S||r>i?i:+r||0)<0&&(r+=i),i=n>r?0:r>>>0,n>>>=0;ni?0:i+t),(n=n===S||n>i?i:+n||0)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Ur(i);++r=200,u=a?Xi():null,c=[];u?(r=ze,s=!1):(a=!1,u=t?[]:c);e:for(;++n>>1,s=e[o];(n?s<=t:s2&&n[i-2],s=i>2&&n[2],a=i>1&&n[i-1];for("function"==typeof o?(o=zt(o,a,5),i-=2):i-=(o="function"==typeof a?a:null)?1:0,s&&Gn(n[0],n[1],s)&&(o=i<3?null:o,i=1);++r-1?n[s]:S}return dt(n,r,e)}}function sn(e){return function(t,n,r){return t&&t.length?(n=wn(n,r,3),i(t,n,e)):-1}}function an(e){return function(t,n,r){return n=wn(n,r,3),dt(t,n,e,!0)}}function un(e){return function(){var t=arguments.length;if(!t)return function(){return arguments[0]};for(var n,r=e?t:-1,i=0,o=Ur(t);e?r--:++r=t||!Si(t))return"";var i=t-r;return n=null==n?" ":n+"",Or(n,ui(i/n.length)).slice(0,i)}function mn(e,t,n,r){function i(){for(var t=-1,a=arguments.length,u=-1,c=r.length,l=Ur(a+c);++uu))return!1;for(;l&&++ai)||u===r&&u===o)&&(i=u,o=e)}),o}function wn(e,n,r){var i=t.callback||Mr;return i=i===Mr?at:i,r?i(e,n,r):i}function Sn(e,n,r){var i=t.indexOf||Xn;return i=i===Xn?o:i,e?i(e,n,r):i}function Wn(e,t,n){for(var r=-1,i=n?n.length:0;++r-1&&e%1==0&&e-1&&e%1==0&&e<=Ri}function In(e){return e===e&&(0===e?1/e>0:!kr(e))}function Fn(e,t){var n=e[1],r=t[1],i=n|r,o=i>>0,r=Ur(n);++t-1:Sn(e,t,n)>-1)}function ar(e,t,n){var r=Po(e)?Xe:wt;return t=wn(t,n,3),r(e,t)}function ur(e,t,n){if(n?Gn(e,t,n):null==t){var r=(e=Dn(e)).length;return r>0?e[Gt(0,r-1)]:S}var i=cr(e);return i.length=Li(t<0?0:+t||0,i.length),i}function cr(e){for(var t=-1,n=(e=Dn(e)).length,r=Ur(n);++t0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}function pr(e,t,n){function r(){var n=t-(So()-c);if(n<=0||n>t){a&&ci(a);var i=p;a=f=p=S,i&&(h=So(),u=e.apply(l,s),f||a||(s=l=null))}else f=mi(r,n)}function i(){f&&ci(f),a=f=p=S,(v||d!==t)&&(h=So(),u=e.apply(l,s),f||a||(s=l=null))}function o(){if(s=arguments,c=So(),l=this,p=v&&(f||!g),!1===d)var n=g&&!f;else{a||g||(h=c);var o=d-(c-h),m=o<=0||o>d;m?(a&&(a=ci(a)),h=c,u=e.apply(l,s)):a||(a=mi(i,o))}return m&&f?f=ci(f):f||t===d||(f=mi(r,t)),n&&(m=!0,u=e.apply(l,s)),!m||f||a||(s=l=null),u}var s,a,u,c,l,f,p,h=0,d=!1,v=!0;if("function"!=typeof e)throw new Zr(D);if(t=t<0?0:+t||0,!0===n){var g=!0;v=!1}else kr(n)&&(g=n.leading,d="maxWait"in n&&Ai(+n.maxWait||0,t),v="trailing"in n?n.trailing:v);return o.cancel=function(){f&&ci(f),a&&ci(a),a=f=p=S},o}function hr(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new Zr(D);var n=function(){var r=arguments,i=n.cache,o=t?t.apply(this,r):r[0];if(i.has(o))return i.get(o);var s=e.apply(this,r);return i.set(o,s),s};return n.cache=new hr.Cache,n}function dr(e,t){if("function"!=typeof e)throw new Zr(D);return t=Ai(t===S?e.length-1:+t||0,0),function(){for(var n=arguments,r=-1,i=Ai(n.length-t,0),o=Ur(i);++r-1}function mr(e){return m(e)&&"string"==typeof e.message&&ri.call(e)==Z}function kr(e){var t=typeof e;return"function"==t||!!e&&"object"==t}function yr(e){return null!=e&&(ri.call(e)==X?oi.test(ei.call(e)):m(e)&&Oe.test(e))}function xr(e){return"number"==typeof e||m(e)&&ri.call(e)==K}function br(e){return m(e)&&ri.call(e)==Q||!1}function Er(e){return"string"==typeof e||m(e)&&ri.call(e)==ee}function _r(e){return m(e)&&Vn(e.length)&&!!Re[ri.call(e)]}function wr(e){return st(e,Wr(e))}function Sr(e){return yt(e,Wr(e))}function Wr(e){if(null==e)return[];kr(e)||(e=Hr(e));var t=e.length;t=t&&Vn(t)&&(Po(e)||Ni.nonEnumArgs&&vr(e))&&t||0;for(var n=e.constructor,r=-1,i="function"==typeof n&&n.prototype===e,o=Ur(t),s=t>0;++r>>1,Pi=bi?bi.BYTES_PER_ELEMENT:0,Ri=qr.pow(2,53)-1,Ui=xi&&new xi,Bi={},Ni=t.support={};!function(e){var t=function(){this.x=e},n=[];t.prototype={valueOf:e,y:e};for(var r in new t)n.push(r);Ni.funcDecomp=/\bthis\b/.test(function(){return this}),Ni.funcNames="string"==typeof Dr.name;try{Ni.dom=11===Qr.createDocumentFragment().nodeType}catch(e){Ni.dom=!1}try{Ni.nonEnumArgs=!vi.call(arguments,1)}catch(e){Ni.nonEnumArgs=!0}}(1,0),t.templateSettings={escape:ke,evaluate:ye,interpolate:xe,variable:"",imports:{_:t}};var Di=Ei||function(e,t){return null==t?e:st(t,eo(t),st(t,Xo(t),e))},qi=function(){function t(){}return function(n){if(kr(n)){t.prototype=n;var r=new t;t.prototype=null}return r||e.Object()}}(),zi=Kt(mt),Hi=Kt(kt,!0),$i=Yt(),Ji=Yt(!0),Zi=Ui?function(e,t){return Ui.set(e,t),e}:Ir;ai||(Ht=si&&yi?function(e){var t=e.byteLength,n=bi?li(t/Pi):0,r=n*Pi,i=new si(t);if(n){var o=new bi(i,0,n);o.set(new bi(e,0,n))}return t!=r&&(o=new yi(i,r)).set(new yi(e,r)),i}:Vr(null));var Xi=wi&&gi?function(e){return new qe(e)}:Vr(null),Ki=Ui?function(e){return Ui.get(e)}:Pr,Yi=Ni.funcNames?"constant"==Vr.name?jt("name"):function(e){for(var t=e.name,n=Bi[t],r=n?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==e)return i.name}return t}:Vr(""),Qi=jt("length"),eo=fi?function(e){return fi(qn(e))}:Vr([]),to=function(){var e=0,t=0;return function(n,r){var i=So(),o=R-(i-t);if(t=i,o>0){if(++e>=P)return n}else e=0;return Zi(n,r)}}(),no=dr(function(e,t){return Po(e)||vr(e)?lt(e,vt(t,!1,!0)):[]}),ro=sn(),io=sn(!0),oo=dr(function(e,t){e||(e=[]);var n=ot(e,t=vt(t));return Ot(e,t.sort(r)),n}),so=kn(),ao=kn(!0),uo=dr(function(e){return Rt(vt(e,!1,!0))}),co=dr(function(e,t){return Po(e)||vr(e)?lt(e,t):[]}),lo=dr(er),fo=dr(function(e,t){return Vn(e?Qi(e):0)&&(e=Dn(e)),ot(e,vt(t))}),po=Zt(function(e,t,n){ti.call(e,n)?++e[n]:e[n]=1}),ho=on(zi),vo=on(Hi,!0),go=cn($e,zi),mo=cn(function(e,t){for(var n=e.length;n--&&!1!==t(e[n],n,e););return e},Hi),ko=Zt(function(e,t,n){ti.call(e,n)?e[n].push(t):e[n]=[t]}),yo=Zt(function(e,t,n){e[n]=t}),xo=dr(function(e,t,n){var r=-1,i="function"==typeof t,o=Cn(t),s=Qi(e),a=Vn(s)?Ur(s):[];return zi(e,function(e){var s=i?t:o&&null!=e&&e[t];a[++r]=s?s.apply(e,n):Tn(e,t,n)}),a}),bo=Zt(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),Eo=dn(function(e,t,n,r){var i=-1,o=e.length;for(r&&o&&(n=e[++i]);++i=120?Xi(t&&u):null))}if((n=e.length)<2)return a;var c=e[0],l=-1,f=c?c.length:0,p=r[0];e:for(;++l-1;)ki.call(t,o,1);return t},t.pullAt=oo,t.range=function(e,t,n){n&&Gn(e,t,n)&&(t=n=null),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var r=-1,i=Ai(ui((t-e)/(n||1)),0),o=Ur(i);++r=0&&e.indexOf(t,n)==n},t.escape=function(e){return e=a(e),e&&me.test(e)?e.replace(ve,d):e},t.escapeRegExp=jr,t.every=ir,t.find=ho,t.findIndex=ro,t.findKey=qo,t.findLast=vo,t.findLastIndex=io,t.findLastKey=zo,t.findWhere=function(e,t){return ho(e,St(t))},t.first=Zn,t.get=function(e,t,n){var r=null==e?S:xt(e,zn(t),t+"");return r===S?n:r},t.has=function(e,t){if(null==e)return!1;var n=ti.call(e,t);return n||Cn(t)||(e=1==(t=zn(t)).length?e:xt(e,Mt(t,0,-1)),t=Kn(t),n=null!=e&&ti.call(e,t)),n},t.identity=Ir,t.includes=sr,t.indexOf=Xn,t.inRange=function(e,t,n){return t=+t||0,void 0===n?(n=t,t=0):n=+n||0,e>=Li(t,n)&&e=t||!Si(t))return e;var i=(t-r)/2,o=li(i);return(n=gn("",ui(i),n)).slice(0,o)+e+n},t.padLeft=ns,t.padRight=rs,t.parseInt=Tr,t.random=function(e,t,n){n&&Gn(e,t,n)&&(t=n=null);var r=null==e,i=null==t;if(null==n&&(i&&"boolean"==typeof e?(n=e,e=1):"boolean"==typeof t&&(n=t,i=!0)),r&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,n||e%1||t%1){var o=Gi();return Li(e+o*(t-e+parseFloat("1e-"+((o+"").length-1))),t)}return Gt(e,t)},t.reduce=Eo,t.reduceRight=_o,t.repeat=Or,t.result=function(e,t,n){var r=null==e?S:e[t];return r===S&&(null==e||Cn(t,e)||(r=null==(e=1==(t=zn(t)).length?e:xt(e,Mt(t,0,-1)))?S:e[Kn(t)]),r=r===S?n:r),Uo(r)?r.call(e):r},t.runInContext=w,t.size=function(e){var t=e?Qi(e):0;return Vn(t)?t:Xo(e).length},t.snakeCase=is,t.some=lr,t.sortedIndex=so,t.sortedLastIndex=ao,t.startCase=os,t.startsWith=function(e,t,n){return e=a(e),n=null==n?0:Li(n<0?0:+n||0,e.length),e.lastIndexOf(t,n)==n},t.sum=function(e,t,n){n&&Gn(e,t,n)&&(t=null);var r=wn(),i=null==t;return r===at&&i||(i=!1,t=r(t,n,3)),i?tt(Po(e)?e:Dn(e)):Pt(e,t)},t.template=function(e,n,r){var i=t.templateSettings;r&&Gn(e,n,r)&&(n=r=null),e=a(e),n=it(Di({},r||n),i,rt);var o,s,u=it(Di({},n.imports),i.imports,rt),c=Xo(u),l=Ut(u,c),f=0,p=n.interpolate||Ce,h="__p += '",d=$r((n.escape||Ce).source+"|"+p.source+"|"+(p===xe?Le:Ce).source+"|"+(n.evaluate||Ce).source+"|$","g"),g="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++Pe+"]")+"\n";e.replace(d,function(t,n,r,i,a,u){return r||(r=i),h+=e.slice(f,u).replace(Me,v),n&&(o=!0,h+="' +\n__e("+n+") +\n'"),a&&(s=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=u+t.length,t}),h+="';\n";var m=n.variable;m||(h="with (obj) {\n"+h+"\n}\n"),h=(s?h.replace(fe,""):h).replace(pe,"$1").replace(he,"$1;"),h="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var k=ss(function(){return Dr(c,g+"return "+h).apply(S,l)});if(k.source=h,mr(k))throw k;return k},t.trim=Gr,t.trimLeft=function(e,t,n){var r=e;return e=a(e),e?(n?Gn(r,t,n):null==t)?e.slice(b(e)):e.slice(c(e,t+"")):e},t.trimRight=function(e,t,n){var r=e;return e=a(e),e?(n?Gn(r,t,n):null==t)?e.slice(0,E(e)+1):e.slice(0,l(e,t+"")+1):e},t.trunc=function(e,t,n){n&&Gn(e,t,n)&&(t=null);var r=I,i=F;if(null!=t)if(kr(t)){var o="separator"in t?t.separator:o;r="length"in t?+t.length||0:r,i="omission"in t?a(t.omission):i}else r=+t||0;if(e=a(e),r>=e.length)return e;var s=r-i.length;if(s<1)return i;var u=e.slice(0,s);if(null==o)return u+i;if(br(o)){if(e.slice(s).search(o)){var c,l,f=e.slice(0,s);for(o.global||(o=$r(o.source,(je.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(f);)l=c.index;u=u.slice(0,null==l?s:l)}}else if(e.indexOf(o,s)!=s){var p=u.lastIndexOf(o);p>-1&&(u=u.slice(0,p))}return u+i},t.unescape=function(e){return e=a(e),e&&ge.test(e)?e.replace(de,_):e},t.uniqueId=function(e){var t=++ni;return a(e)+t},t.words=Cr,t.all=ir,t.any=lr,t.contains=sr,t.detect=ho,t.foldl=Eo,t.foldr=_o,t.head=Zn,t.include=sr,t.inject=Eo,Fr(t,function(){var e={};return mt(t,function(n,r){t.prototype[r]||(e[r]=n)}),e}(),!1),t.sample=ur,t.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return ur(t,e)}):ur(this.value())},t.VERSION=W,$e(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){t[e].placeholder=t}),$e(["dropWhile","filter","map","takeWhile"],function(e,t){var n=t!=N,r=t==U;Ne.prototype[e]=function(e,i){var o=this.__filtered__,s=o&&r?new Ne(this):this.clone();return(s.__iteratees__||(s.__iteratees__=[])).push({done:!1,count:0,index:0,iteratee:wn(e,i,1),limit:-1,type:t}),s.__filtered__=o||n,s}}),$e(["drop","take"],function(e,t){var n=e+"While";Ne.prototype[e]=function(n){var r=this.__filtered__,i=r&&!t?this.dropWhile():this.clone();return n=null==n?1:Ai(li(n)||0,0),r?t?i.__takeCount__=Li(i.__takeCount__,n):Kn(i.__iteratees__).limit=n:(i.__views__||(i.__views__=[])).push({size:n,type:e+(i.__dir__<0?"Right":"")}),i},Ne.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()},Ne.prototype[e+"RightWhile"]=function(e,t){return this.reverse()[n](e,t).reverse()}}),$e(["first","last"],function(e,t){var n="take"+(t?"Right":"");Ne.prototype[e]=function(){return this[n](1).value()[0]}}),$e(["initial","rest"],function(e,t){var n="drop"+(t?"":"Right");Ne.prototype[e]=function(){return this[n](1)}}),$e(["pluck","where"],function(e,t){var n=t?"filter":"map",r=t?St:Rr;Ne.prototype[e]=function(e){return this[n](r(e))}}),Ne.prototype.compact=function(){return this.filter(Ir)},Ne.prototype.reject=function(e,t){return e=wn(e,t,1),this.filter(function(t){return!e(t)})},Ne.prototype.slice=function(e,t){var n=(e=null==e?0:+e||0)<0?this.takeRight(-e):this.drop(e);return t!==S&&(n=(t=+t||0)<0?n.dropRight(-t):n.take(t-e)),n},Ne.prototype.toArray=function(){return this.drop(0)},mt(Ne.prototype,function(e,n){var r=t[n];if(r){var i=/^(?:filter|map|reject)|While$/.test(n),o=/^(?:first|last)$/.test(n);t.prototype[n]=function(){var n=arguments,s=(n.length,this.__chain__),a=this.__wrapped__,u=!!this.__actions__.length,c=a instanceof Ne,l=n[0],f=c||Po(a);f&&i&&"function"==typeof l&&1!=l.length&&(c=f=!1);var p=c&&!u;if(o&&!s)return p?e.call(a):r.call(t,this.value());var h=function(e){var i=[e];return hi.apply(i,n),r.apply(t,i)};if(f){var d=p?a:new Ne(this),v=e.apply(d,n);return o||!u&&!v.__actions__||(v.__actions__||(v.__actions__=[])).push({func:rr,args:[h],thisArg:t}),new k(v,s)}return this.thru(h)}}}),$e(["concat","join","pop","push","replace","shift","sort","splice","split","unshift"],function(e){var n=(/^(?:replace|split)$/.test(e)?Yr:Xr)[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:join|pop|replace|shift)$/.test(e);t.prototype[e]=function(){var e=arguments;return i&&!this.__chain__?n.apply(this.value(),e):this[r](function(t){return n.apply(t,e)})}}),mt(Ne.prototype,function(e,n){var r=t[n];if(r){var i=r.name;(Bi[i]||(Bi[i]=[])).push({name:n,func:r})}}),Bi[vn(null,L).name]=[{name:"wrapper",func:null}],Ne.prototype.clone=function(){var e=this.__actions__,t=this.__iteratees__,n=this.__views__,r=new Ne(this.__wrapped__);return r.__actions__=e?He(e):null,r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=t?He(t):null,r.__takeCount__=this.__takeCount__,r.__views__=n?He(n):null,r},Ne.prototype.reverse=function(){if(this.__filtered__){var e=new Ne(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Ne.prototype.value=function(){var e=this.__wrapped__.value();if(!Po(e))return Nt(e,this.__actions__);var t=this.__dir__,n=t<0,r=Wn(0,e.length,this.__views__),i=r.start,o=r.end,s=o-i,a=n?o:i-1,u=Li(s,this.__takeCount__),c=this.__iteratees__,l=c?c.length:0,f=0,p=[];e:for(;s--&&fv.index:a-1?v.count++>=k:!g(d)))continue e}}else{var y=g(d);if(m==N)d=y;else if(!y){if(m==B)continue e;break e}}}p[f++]=d}return p},t.prototype.chain=function(){return nr(this)},t.prototype.commit=function(){return new k(this.value(),this.__chain__)},t.prototype.plant=function(e){for(var t,r=this;r instanceof n;){var i=Hn(r);t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},t.prototype.reverse=function(){var e=this.__wrapped__;return e instanceof Ne?(this.__actions__.length&&(e=new Ne(this)),new k(e.reverse(),this.__chain__)):this.thru(function(e){return e.reverse()})},t.prototype.toString=function(){return this.value()+""},t.prototype.run=t.prototype.toJSON=t.prototype.valueOf=t.prototype.value=function(){return Nt(this.__wrapped__,this.__actions__)},t.prototype.collect=t.prototype.map,t.prototype.head=t.prototype.first,t.prototype.select=t.prototype.filter,t.prototype.tail=t.prototype.rest,t}var S,W="3.7.0",A=1,L=2,j=4,T=8,O=16,G=32,C=64,M=128,V=256,I=30,F="...",P=150,R=16,U=0,B=1,N=2,D="Expected a function",q="__lodash_placeholder__",z="[object Arguments]",H="[object Array]",$="[object Boolean]",J="[object Date]",Z="[object Error]",X="[object Function]",K="[object Number]",Y="[object Object]",Q="[object RegExp]",ee="[object String]",te="[object ArrayBuffer]",ne="[object Float32Array]",re="[object Float64Array]",ie="[object Int8Array]",oe="[object Int16Array]",se="[object Int32Array]",ae="[object Uint8Array]",ue="[object Uint8ClampedArray]",ce="[object Uint16Array]",le="[object Uint32Array]",fe=/\b__p \+= '';/g,pe=/\b(__p \+=) '' \+/g,he=/(__e\(.*?\)|\b__t\)) \+\n'';/g,de=/&(?:amp|lt|gt|quot|#39|#96);/g,ve=/[&<>"'`]/g,ge=RegExp(de.source),me=RegExp(ve.source),ke=/<%-([\s\S]+?)%>/g,ye=/<%([\s\S]+?)%>/g,xe=/<%=([\s\S]+?)%>/g,be=/\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,Ee=/^\w*$/,_e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,we=/[.*+?^${}()|[\]\/\\]/g,Se=RegExp(we.source),We=/[\u0300-\u036f\ufe20-\ufe23]/g,Ae=/\\(\\)?/g,Le=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,je=/\w*$/,Te=/^0[xX]/,Oe=/^\[object .+?Constructor\]$/,Ge=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Ce=/($^)/,Me=/['\n\r\u2028\u2029\\]/g,Ve=function(){var e="[A-Z\\xc0-\\xd6\\xd8-\\xde]",t="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(e+"+(?="+e+t+")|"+e+"?"+t+"|"+e+"+|[0-9]+","g")}(),Ie=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",Fe=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window"],Pe=-1,Re={};Re[ne]=Re[re]=Re[ie]=Re[oe]=Re[se]=Re[ae]=Re[ue]=Re[ce]=Re[le]=!0,Re[z]=Re[H]=Re[te]=Re[$]=Re[J]=Re[Z]=Re[X]=Re["[object Map]"]=Re[K]=Re[Y]=Re[Q]=Re["[object Set]"]=Re[ee]=Re["[object WeakMap]"]=!1;var Ue={};Ue[z]=Ue[H]=Ue[te]=Ue[$]=Ue[J]=Ue[ne]=Ue[re]=Ue[ie]=Ue[oe]=Ue[se]=Ue[K]=Ue[Y]=Ue[Q]=Ue[ee]=Ue[ae]=Ue[ue]=Ue[ce]=Ue[le]=!0,Ue[Z]=Ue[X]=Ue["[object Map]"]=Ue["[object Set]"]=Ue["[object WeakMap]"]=!1;var Be={leading:!1,maxWait:0,trailing:!1},Ne={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},De={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qe={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},ze={function:!0,object:!0},He={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$e=ze[typeof n]&&n&&!n.nodeType&&n,Je=ze[typeof t]&&t&&!t.nodeType&&t,Ze=$e&&Je&&"object"==typeof e&&e&&e.Object&&e,Xe=ze[typeof self]&&self&&self.Object&&self,Ke=ze[typeof window]&&window&&window.Object&&window,Ye=Je&&Je.exports===$e&&$e,Qe=Ze||Ke!==(this&&this.window)&&Ke||Xe||this,et=w();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Qe._=et,define(function(){return et})):$e&&Je?Ye?(Je.exports=et)._=et:$e._=et:Qe._=et}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],13:[function(e,t,n){"use strict";function r(e){return/^[0-9a-fA-F]+$/.test(e)}function i(e){return 1===e.length&&r(e)}function o(){var e=[];return{push:function(t){e.push(t)},check:function(){for(var t=0;t0&&this.context[this.context.length-1].type===e},pushContext:function(e){this.context.push({type:e})},popContext:function(){return this.context.pop()},isContext:function(e){return this.context.length>0&&this.context[this.context.length-1]===e},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=l.lines,this._lines},setLines:function(e){this._lines=e,l.lines=this._lines},peek:function(e){return this.input.charAt(e||0)},skip:function(e){e=e||1,this.char+=e,this.input=this.input.slice(e)},on:function(e,t){e.split(" ").forEach(function(e){this.emitter.on(e,t)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(e,t,n,r){n.push(function(){r()&&this.trigger(e,t)}.bind(this))},scanPunctuator:function(){var e,t,n,r=this.peek();switch(r){case".":if(/^[0-9]$/.test(this.peek(1)))return null;if("."===this.peek(1)&&"."===this.peek(2))return{type:g.Punctuator,value:"..."};case"(":case")":case";":case",":case"[":case"]":case":":case"~":case"?":return{type:g.Punctuator,value:r};case"{":return this.pushContext(m.Block),{type:g.Punctuator,value:r};case"}":return this.inContext(m.Block)&&this.popContext(),{type:g.Punctuator,value:r};case"#":return{type:g.Punctuator,value:r};case"":return null}return e=this.peek(1),t=this.peek(2),n=this.peek(3),">"===r&&">"===e&&">"===t&&"="===n?{type:g.Punctuator,value:">>>="}:"="===r&&"="===e&&"="===t?{type:g.Punctuator,value:"==="}:"!"===r&&"="===e&&"="===t?{type:g.Punctuator,value:"!=="}:">"===r&&">"===e&&">"===t?{type:g.Punctuator,value:">>>"}:"<"===r&&"<"===e&&"="===t?{type:g.Punctuator,value:"<<="}:">"===r&&">"===e&&"="===t?{type:g.Punctuator,value:">>="}:"="===r&&">"===e?{type:g.Punctuator,value:r+e}:r===e&&"+-<>&|".indexOf(r)>=0?{type:g.Punctuator,value:r+e}:"<>=!+-*%&|^/".indexOf(r)>=0?"="===e?{type:g.Punctuator,value:r+e}:{type:g.Punctuator,value:r}:null},scanComments:function(e){function t(e,t,n){var r=["jshint","jslint","members","member","globals","global","exported"],i=!1,o=e+t,s="plain";return(n=n||{}).isMultiline&&(o+="*/"),t=t.replace(/\n/g," "),"/*"===e&&c.fallsThrough.test(t)&&(i=!0,s="falls through"),r.forEach(function(n){if(!i&&("//"!==e||"jshint"===n)&&(" "===t.charAt(n.length)&&t.substr(0,n.length)===n&&(i=!0,e+=n,t=t.substr(n.length)),i||" "!==t.charAt(0)||" "!==t.charAt(n.length+1)||t.substr(1,n.length)!==n||(i=!0,e=e+" "+n,t=t.substr(n.length+1)),i))switch(n){case"member":s="members";break;case"global":s="globals";break;default:var r=t.split(":").map(function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")});if(2===r.length)switch(r[0]){case"ignore":switch(r[1]){case"start":a.ignoringLinterErrors=!0,i=!1;break;case"end":a.ignoringLinterErrors=!1,i=!1}}s=n}}),{type:g.Comment,commentType:s,value:o,body:t,isSpecial:i,isMultiline:n.isMultiline||!1,isMalformed:n.isMalformed||!1}}var n=this.peek(),r=this.peek(1),i=this.input.substr(2),o=this.line,s=this.char,a=this;if("*"===n&&"/"===r)return this.trigger("error",{code:"E018",line:o,character:s}),this.skip(2),null;if("/"!==n||"*"!==r&&"/"!==r)return null;if("/"===r)return this.skip(this.input.length),t("//",i);var u="";if("*"===r){for(this.inComment=!0,this.skip(2);"*"!==this.peek()||"/"!==this.peek(1);)if(""===this.peek()){if(u+="\n",!this.nextLine(e))return this.trigger("error",{code:"E017",line:o,character:s}),this.inComment=!1,t("/*",u,{isMultiline:!0,isMalformed:!0})}else u+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,t("/*",u,{isMultiline:!0})}},scanKeyword:function(){var e=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),t=["if","in","do","var","for","new","try","let","this","else","case","void","with","enum","while","break","catch","throw","const","yield","class","super","return","typeof","delete","switch","export","import","default","finally","extends","function","continue","debugger","instanceof"];return e&&t.indexOf(e[0])>=0?{type:g.Keyword,value:e[0]}:null},scanIdentifier:function(){function e(e){return d.indexOf(e)>-1}function t(t){return e(t)||v.indexOf(t)>-1}var n,i,o="",s=0,a=function(){if(s+=1,"u"!==this.peek(s))return null;var e,n=this.peek(s+1)+this.peek(s+2)+this.peek(s+3)+this.peek(s+4);return r(n)?(e=parseInt(n,16),h[e]||t(e)?(s+=5,"\\u"+n):null):null}.bind(this),u=function(){var t=this.peek(s),n=t.charCodeAt(0);return 92===n?a():n<128?p[n]?(s+=1,t):null:e(n)?(s+=1,t):null}.bind(this),c=function(){var e=this.peek(s),n=e.charCodeAt(0);return 92===n?a():n<128?h[n]?(s+=1,e):null:t(n)?(s+=1,e):null}.bind(this);if(null===(i=u()))return null;for(o=i;null!==(i=c());)o+=i;switch(o){case"true":case"false":n=g.BooleanLiteral;break;case"null":n=g.NullLiteral;break;default:n=g.Identifier}return{type:n,value:function(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}(o),text:o,tokenLength:o.length}},scanNumericLiteral:function(e){function t(e){return/^[0-9]$/.test(e)}function n(e){return/^[0-7]$/.test(e)}function r(e){return"$"===e||"_"===e||"\\"===e||e>="a"&&e<="z"||e>="A"&&e<="Z"}var o=0,s="",a=this.input.length,u=this.peek(o),c=t,f=10,p=!1;if("."!==u&&!t(u))return null;if("."!==u){for(s=this.peek(o),o+=1,u=this.peek(o),"0"===s&&("x"!==u&&"X"!==u||(c=i,f=16,o+=1,s+=u),"o"!==u&&"O"!==u||(c=n,f=8,l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Octal integer literal","6"]},e,function(){return!0}),o+=1,s+=u),"b"!==u&&"B"!==u||(c=function(e){return/^[01]$/.test(e)},f=2,l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Binary integer literal","6"]},e,function(){return!0}),o+=1,s+=u),n(u)&&(c=n,f=8,p=!0,!1,o+=1,s+=u),!n(u)&&t(u)&&(o+=1,s+=u));o=0&&o<=7&&l.isStrict()});break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":i="\\"+i,this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return l.isStrict()});break;case"u":var s=this.input.substr(1,4),a=parseInt(s,16);r(s)||this.trigger("warning",{code:"W052",line:this.line,character:this.char,data:["u"+s]}),i=String.fromCharCode(a),n=5;break;case"v":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\v"]},e,function(){return l.jsonMode}),i="\v";break;case"x":var u=parseInt(this.input.substr(1,2),16);this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\x-"]},e,function(){return l.jsonMode}),i=String.fromCharCode(u),n=3;break;case"\\":i="\\\\";break;case'"':i='\\"';break;case"/":break;case"":t=!0,i=""}return{char:i,jump:n,allowNewLine:t}},scanTemplateLiteral:function(e){var t,n,r="",i=this.line,o=this.char,s=this.templateStarts.length;if("`"===this.peek())l.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["template literal syntax","6"]},e,function(){return!0}),t=g.TemplateHead,this.templateStarts.push({line:this.line,char:this.char}),s=this.templateStarts.length,this.skip(1),this.pushContext(m.Template);else{if(!this.inContext(m.Template)||"}"!==this.peek())return null;t=g.TemplateMiddle}for(;"`"!==this.peek();){for(;""===(n=this.peek());)if(r+="\n",!this.nextLine(e)){var a=this.templateStarts.pop();return this.trigger("error",{code:"E052",line:a.line,character:a.char}),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!0,depth:s,context:this.popContext()}}if("$"===n&&"{"===this.peek(1))return r+="${",this.skip(2),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!1,depth:s,context:this.currentContext()};if("\\"===n){var u=this.scanEscapeSequence(e);r+=u.char,this.skip(u.jump)}else"`"!==n&&(r+=n,this.skip(1))}return t=t===g.TemplateHead?g.NoSubstTemplate:g.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:t,value:r,startLine:i,startChar:o,isUnclosed:!1,depth:s,context:this.popContext()}},scanStringLiteral:function(e){var t=this.peek();if('"'!==t&&"'"!==t)return null;this.triggerAsync("warning",{code:"W108",line:this.line,character:this.char},e,function(){return l.jsonMode&&'"'!==t});var n="",r=this.line,i=this.char,o=!1;for(this.skip();this.peek()!==t;)if(""===this.peek()){if(o?(o=!1,this.triggerAsync("warning",{code:"W043",line:this.line,character:this.char},e,function(){return!l.option.multistr}),this.triggerAsync("warning",{code:"W042",line:this.line,character:this.char},e,function(){return l.jsonMode&&l.option.multistr})):this.trigger("warning",{code:"W112",line:this.line,character:this.char}),!this.nextLine(e))return this.trigger("error",{code:"E029",line:r,character:i}),{type:g.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!0,quote:t}}else{o=!1;var s=this.peek(),a=1;if(s<" "&&this.triggerAsync("warning",{code:"W113",line:this.line,character:this.char,data:[""]},e,function(){return!0}),"\\"===s){var u=this.scanEscapeSequence(e);s=u.char,a=u.jump,o=u.allowNewLine}n+=s,this.skip(a)}return this.skip(),{type:g.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!1,quote:t}},scanRegExp:function(e){var t,n,r=0,i=this.input.length,o=this.peek(),s=o,a="",u=[],c=!1,f=!1,p=function(){o<" "&&(c=!0,this.triggerAsync("warning",{code:"W048",line:this.line,character:this.char},e,function(){return!0})),"<"===o&&(c=!0,this.triggerAsync("warning",{code:"W049",line:this.line,character:this.char,data:[o]},e,function(){return!0}))}.bind(this);if(!this.prereg||"/"!==o)return null;for(r+=1,t=!1;r-1&&(n="Duplicate RegExp flag")):u.push(o),s+=o,r+=1;try{new RegExp(a,u.join(""))}catch(e){n=e.message}return n&&(c=!0,this.trigger("error",{code:"E016",line:this.line,character:this.char,data:[n]})),{type:g.RegExp,value:s,flags:u,isMalformed:c}},scanNonBreakingSpaces:function(){return l.option.nonbsp?this.input.search(/(\u00A0)/):-1},scanUnsafeChars:function(){return this.input.search(c.unsafeChars)},next:function(e){for(this.from=this.char;/\s/.test(this.peek());)this.from+=1,this.skip();var t=this.scanComments(e)||this.scanStringLiteral(e)||this.scanTemplateLiteral(e);return t||(t=this.scanRegExp(e)||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier()||this.scanNumericLiteral(e),t?(this.skip(t.tokenLength||t.value.length),t):null)},nextLine:function(e){var t;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var n=this.input.trim(),r=function(){return a.some(arguments,function(e){return 0===n.indexOf(e)})};return!0===this.ignoringLinterErrors&&(r("/*","//")||this.inComment&&function(){return a.some(arguments,function(e){return-1!==n.indexOf(e,n.length-e.length)})}("*/")||(this.input="")),(t=this.scanNonBreakingSpaces())>=0&&this.triggerAsync("warning",{code:"W125",line:this.line,character:t+1},e,function(){return!0}),this.input=this.input.replace(/\t/g,l.tab),(t=this.scanUnsafeChars())>=0&&this.triggerAsync("warning",{code:"W100",line:this.line,character:t},e,function(){return!0}),!this.ignoringLinterErrors&&l.option.maxlen&&l.option.maxlen=0;--t){var n=k[t]["(labels)"];if(n[e])return n}}function d(e){for(var t=k.length-1;t>=0;t--){var n=k[t];if(n["(usages)"][e])return n["(usages)"][e];if(n===y)break}return!1}function v(t,n){if("outer"===e.option.shadow)for(var r="global"===y["(type)"],i="functionparams"===m["(type)"],o=!r,s=0;s1?k[k.length-2]:null,a=m===y,l="functionparams"===m["(type)"],p="functionouter"===m["(type)"],h=m["(usages)"],d=m["(labels)"],v=Object.keys(h);for(h.__proto__&&-1===v.indexOf("__proto__")&&v.push("__proto__"),t=0;t=0;i--){var o=k[i];if(o["(labels)"][e]&&(!n||o["(labels)"][e]["(blockscoped)"]))return o["(labels)"][e]["(type)"];var s=r?k[i-1]:o;if(s&&"functionparams"===s["(type)"])return null}return null},hasBreakLabel:function(e){for(var t=k.length-1;t>=0;t--){var n=k[t];if(n["(breakLabels)"][e])return!0;if("functionparams"===n["(type)"])return!1}return!1},has:function(e,t){return Boolean(this.labeltype(e,t))},add:function(e,t,n,r){m["(labels)"][e]={"(type)":t,"(token)":n,"(blockscoped)":!1,"(function)":y,"(unused)":r}}},block:{isGlobal:function(){return"global"===m["(type)"]},use:function(t,n){var r=y["(parent)"];r&&r["(labels)"][t]&&"param"===r["(labels)"][t]["(type)"]&&(W.funct.has(t,{excludeParams:!0,onlyBlockscoped:!0})||(r["(labels)"][t]["(unused)"]=!1)),n&&(e.ignored.W117||!1===e.option.undef)&&(n.ignoreUndef=!0),l(t),m["(usages)"][t]["(onlyUsedSubFunction)"]=!1,n&&(n["(function)"]=y,m["(usages)"][t]["(tokens)"].push(n));var i=m["(labels)"][t];i&&i["(blockscoped)"]&&!i["(initialized)"]&&c("E056",n,t,i["(type)"])},reassign:function(t,n){n.ignoreW020=e.ignored.W020,n.ignoreW021=e.ignored.W021,this.modify(t,n),m["(usages)"][t]["(reassigned)"].push(n)},modify:function(e,t){l(e),m["(usages)"][e]["(onlyUsedSubFunction)"]=!1,m["(usages)"][e]["(modified)"].push(t)},add:function(e,t,n,r,i){m["(labels)"][e]={"(type)":t,"(token)":n,"(initialized)":!!i,"(blockscoped)":!0,"(unused)":r}},addBreakLabel:function(t,n){var r=n.token;W.funct.hasBreakLabel(t)?u("E011",r,t):"outer"===e.option.shadow&&(W.funct.has(t)?u("W004",r,t):v(t,r)),m["(breakLabels)"][t]=r}}};return W}},{events:5,lodash:12}],19:[function(e,t,n){"use strict";var r=e("./name-stack.js"),i={syntax:{},isStrict:function(){return this.directive["use strict"]||this.inClassBody||this.option.module||"implied"===this.option.strict},stmtMissingStrict:function(){return"global"===this.option.strict||!1!==this.option.strict&&!!this.option.globalstrict},allowsGlobalUsd:function(){return"global"===this.option.strict||this.option.globalstrict||this.option.module||this.impliedClosure()},impliedClosure:function(){return this.option.node||this.option.phantom||this.option.browserify},inMoz:function(){return this.option.moz},inES6:function(e){return e?6===this.esVersion:this.option.moz||this.esVersion>=6},inES5:function(e){return e?!(this.esVersion&&5!==this.esVersion||this.option.moz):!this.esVersion||this.esVersion>=5||this.option.moz},inferEsVersion:function(){var e=null;if(this.option.esversion){if(this.option.es3?e="es3":this.option.es5?e="es5":this.option.esnext&&(e="esnext"),e)return e;2015===this.option.esversion?this.esVersion=6:this.esVersion=this.option.esversion}else this.option.es3?this.esVersion=3:this.option.esnext&&(this.esVersion=6);return null},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={},this.esVersion=5,this.funct=null,this.ignored={},this.directive={},this.jsonMode=!1,this.jsonWarnings=[],this.lines=[],this.tab="",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new r,this.inClassBody=!1}};n.state=i},{"./name-stack.js":15}],20:[function(e,t,n){"use strict";n.register=function(e){e.on("Identifier",function(t){e.getOption("proto")||"__proto__"===t.name&&e.warn("W103",{line:t.line,char:t.char,data:[t.name,"6"]})}),e.on("Identifier",function(t){e.getOption("iterator")||"__iterator__"===t.name&&e.warn("W103",{line:t.line,char:t.char,data:[t.name]})}),e.on("Identifier",function(t){e.getOption("camelcase")&&t.name.replace(/^_+|_+$/g,"").indexOf("_")>-1&&!t.name.match(/^[A-Z0-9_]*$/)&&e.warn("W106",{line:t.line,char:t.char,data:[t.name]})}),e.on("String",function(t){var n,r=e.getOption("quotmark");r&&("single"===r&&"'"!==t.quote&&(n="W109"),"double"===r&&'"'!==t.quote&&(n="W108"),!0===r&&(e.getCache("quotmark")||e.setCache("quotmark",t.quote),e.getCache("quotmark")!==t.quote&&(n="W110")),n&&e.warn(n,{line:t.line,char:t.char}))}),e.on("Number",function(t){"."===t.value.charAt(0)&&e.warn("W008",{line:t.line,char:t.char,data:[t.value]}),"."===t.value.substr(t.value.length-1)&&e.warn("W047",{line:t.line,char:t.char,data:[t.value]}),/^00+/.test(t.value)&&e.warn("W046",{line:t.line,char:t.char,data:[t.value]})}),e.on("String",function(t){var n=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;e.getOption("scripturl")||n.test(t.value)&&e.warn("W107",{line:t.line,char:t.char})})}},{}],21:[function(e,t,n){"use strict";n.reservedVars={arguments:!1,NaN:!1},n.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{ArrayBuffer:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int8Array:!1,Int16Array:!1,Int32Array:!1,Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,Uint8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8ClampledArray:!1,WeakMap:!1,WeakSet:!1}},n.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CompositionEvent:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,File:!1,FileList:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MediaRecorder:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,performance:!1,print:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,Storage:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},n.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},n.worker={importScripts:!0,onmessage:!0,postMessage:!0,self:!0,FileReaderSync:!0},n.nonstandard={escape:!1,unescape:!1},n.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},n.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,require:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},n.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,require:!1,Buffer:!0,exports:!0,process:!0},n.phantom={phantom:!0,require:!0,WebPage:!0,console:!0,exports:!0},n.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notOk:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,throws:!1},n.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},n.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},n.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},n.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},n.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},n.jquery={$:!1,jQuery:!1},n.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},n.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},n.yui={YUI:!1,Y:!1,YUI_config:!1},n.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},n.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1}},{}],jshint:[function(e,t,n){var r=e("lodash"),i=e("events"),o=e("./vars.js"),s=e("./messages.js"),a=e("./lex.js").Lexer,u=e("./reg.js"),c=e("./state.js").state,l=e("./style.js"),f=e("./options.js"),p=e("./scope-manager.js"),h=(e("console-browserify"),function(){"use strict";function e(e,t){return e=e.trim(),!!/^[+-]W\d{3}$/g.test(e)||(!(-1===f.validNames.indexOf(e)&&"jslint"!==t.type&&!r.has(f.removed,e))||(_("E001",t,e),!1))}function t(e){return"[object String]"===Object.prototype.toString.call(e)}function n(e,t){return!!e&&!(!e.identifier||e.value!==t)}function d(e){if(!e.reserved)return!1;var t=e.meta;if(t&&t.isFutureReservedWord){if(t.moduleOnly&&!c.option.module)return!1;if(c.inES5()){if(!t.es5)return!1;if(t.strictOnly&&!c.option.strict&&!c.isStrict())return!1;if(e.isProperty)return!1}}return!0}function v(e,t){return e.replace(/\{([^{}]*)\}/g,function(e,n){var r=t[n];return"string"==typeof r||"number"==typeof r?r:e})}function g(e,t){Object.keys(t).forEach(function(n){r.has(h.blacklist,n)||(e[n]=t[n])})}function m(){if(c.option.enforceall){for(var e in f.bool.enforcing)void 0!==c.option[e]||f.noenforceall[e]||(c.option[e]=!0);for(var t in f.bool.relaxing)void 0===c.option[t]&&(c.option[t]=!1)}}function k(){var e=null;m(),(e=c.inferEsVersion())&&y("E059",c.tokens.next,"esversion",e),c.inES5()&&g(Ye,o.ecmaIdentifiers[5]),c.inES6()&&g(Ye,o.ecmaIdentifiers[6]),"global"===c.option.strict&&"globalstrict"in c.option&&y("E059",c.tokens.next,"strict","globalstrict"),c.option.module&&(c.inES6()||b("W134",c.tokens.next,"module",6)),c.option.couch&&g(Ye,o.couch),c.option.qunit&&g(Ye,o.qunit),c.option.rhino&&g(Ye,o.rhino),c.option.shelljs&&(g(Ye,o.shelljs),g(Ye,o.node)),c.option.typed&&g(Ye,o.typed),c.option.phantom&&g(Ye,o.phantom),c.option.prototypejs&&g(Ye,o.prototypejs),c.option.node&&(g(Ye,o.node),g(Ye,o.typed)),c.option.devel&&g(Ye,o.devel),c.option.dojo&&g(Ye,o.dojo),c.option.browser&&(g(Ye,o.browser),g(Ye,o.typed)),c.option.browserify&&(g(Ye,o.browser),g(Ye,o.typed),g(Ye,o.browserify)),c.option.nonstandard&&g(Ye,o.nonstandard),c.option.jasmine&&g(Ye,o.jasmine),c.option.jquery&&g(Ye,o.jquery),c.option.mootools&&g(Ye,o.mootools),c.option.worker&&g(Ye,o.worker),c.option.wsh&&g(Ye,o.wsh),c.option.yui&&g(Ye,o.yui),c.option.mocha&&g(Ye,o.mocha)}function y(e,t,n,r){var i=Math.floor(t.line/c.lines.length*100),o=s.errors[e].desc,a={name:"JSHintError",line:t.line,character:t.from,message:o+" ("+i+"% scanned).",raw:o,code:e,a:n,b:r};throw a.reason=v(o,a)+" ("+i+"% scanned).",a}function x(){var e=c.ignoredLines;r.isEmpty(e)||(h.errors=r.reject(h.errors,function(t){return e[t.line]}))}function b(e,t,n,r,i,o){var a,u,l,f;if(/^W\d{3}$/.test(e)){if(c.ignored[e])return;f=s.warnings[e]}else/E\d{3}/.test(e)?f=s.errors[e]:/I\d{3}/.test(e)&&(f=s.info[e]);return"(end)"===(t=t||c.tokens.next||{}).id&&(t=c.tokens.curr),u=t.line,a=t.from,l={id:"(error)",raw:f.desc,code:f.code,evidence:c.lines[u-1]||"",line:u,character:a,scope:h.scope,a:n,b:r,c:i,d:o},l.reason=v(f.desc,l),h.errors.push(l),x(),h.errors.length>=c.option.maxerr&&y("E043",t),l}function E(e,t,n,r,i,o,s){return b(e,{line:t,from:n},r,i,o,s)}function _(e,t,n,r,i,o){b(e,t,n,r,i,o)}function w(e,t,n,r,i,o,s){return _(e,{line:t,from:n},r,i,o,s)}function S(e,t){h.internals.push({id:"(internal)",elem:e,token:t,code:t.value.replace(/([^\\])(\\*)\2\\n/g,"$1\n")})}function W(t,n){var i=t.body.split(",").map(function(e){return e.trim()}),o={};if("falls through"!==t.type){if("globals"===t.type){i.forEach(function(e,n){var r=((e=e.split(":"))[0]||"").trim(),s=(e[1]||"").trim();if("-"!==r&&r.length)"-"===r.charAt(0)?(r=r.slice(1),s=!1,h.blacklist[r]=r,delete Ye[r]):o[r]="true"===s;else{if(n>0&&n===i.length-1)return;_("E002",t)}}),g(Ye,o);for(var s in o)r.has(o,s)&&(qe[s]=t)}"exported"===t.type&&i.forEach(function(e,n){if(e.length)c.funct["(scope)"].addExported(e);else{if(n>0&&n===i.length-1)return;_("E002",t)}}),"members"===t.type&&(Ke=Ke||{},i.forEach(function(e){var t=e.charAt(0);t!==e.charAt(e.length-1)||'"'!==t&&"'"!==t||(e=e.substr(1,e.length-2).replace('\\"','"')),Ke[e]=!1}));var a=["maxstatements","maxparams","maxdepth","maxcomplexity","maxerr","maxlen","indent"];"jshint"!==t.type&&"jslint"!==t.type||(i.forEach(function(n){var r=((n=n.split(":"))[0]||"").trim(),i=(n[1]||"").trim();if(e(r,t))if(a.indexOf(r)>=0)if("false"!==i){if("number"!=typeof(i=+i)||!isFinite(i)||i<=0||Math.floor(i)!==i)return void _("E032",t,n[1].trim());c.option[r]=i}else c.option[r]="indent"===r&&4;else{if("validthis"===r)return c.funct["(global)"]?void _("E009"):"true"!==i&&"false"!==i?void _("E002",t):void(c.option.validthis="true"===i);if("quotmark"!==r)if("shadow"!==r)if("unused"!==r)if("latedef"!==r)if("ignore"!==r)if("strict"!==r)if("module"===r&&(xe(c.funct)||_("E055",t,"module")),"esversion"!==r){var o=/^([+-])(W\d{3})$/g.exec(r);if(o)c.ignored[o[2]]="-"===o[1];else{var s;"true"!==i&&"false"!==i?_("E002",t):"jslint"===t.type?(s=f.renamed[r]||r,c.option[s]="true"===i,void 0!==f.inverted[s]&&(c.option[s]=!c.option[s])):c.option[r]="true"===i}}else{switch(i){case"3":case"5":case"6":case"2015":c.option.moz=!1,c.option.esversion=+i;break;default:_("E002",t)}xe(c.funct)||_("E055",t,"esversion")}else switch(i){case"true":c.option.strict=!0;break;case"false":c.option.strict=!1;break;case"global":case"implied":c.option.strict=i;break;default:_("E002",t)}else switch(i){case"line":c.ignoredLines[t.line]=!0,x();break;default:_("E002",t)}else switch(i){case"true":c.option.latedef=!0;break;case"false":c.option.latedef=!1;break;case"nofunc":c.option.latedef="nofunc";break;default:_("E002",t)}else switch(i){case"true":c.option.unused=!0;break;case"false":c.option.unused=!1;break;case"vars":case"strict":c.option.unused=i;break;default:_("E002",t)}else switch(i){case"true":c.option.shadow=!0;break;case"outer":c.option.shadow="outer";break;case"false":case"inner":c.option.shadow="inner";break;default:_("E002",t)}else switch(i){case"true":case"false":c.option.quotmark="true"===i;break;case"double":case"single":c.option.quotmark=i;break;default:_("E002",t)}}}),k())}else n.caseFallsThrough=!0}function A(e){var t,n=e||0,r=Je.length;if(n="a"&&t<="z"||t>="A"&&t<="Z")&&(e.identifier=e.reserved=!0),e}function D(e,t){var n=P(e,150);return N(n),n.nud="function"==typeof t?t:function(){return this.arity="unary",this.right=G(150),"++"!==this.id&&"--"!==this.id||(c.option.plusplus?b("W016",this,this.id):!this.right||this.right.identifier&&!d(this.right)||"."===this.right.id||"["===this.right.id||b("W017",this),this.right&&this.right.isMetaProperty?_("E031",this):this.right&&this.right.identifier&&c.funct["(scope)"].block.modify(this.right.value,this)),this},n}function q(e,t){var n=R(e);return n.type=e,n.nud=t,n}function z(e,t){var n=q(e,t);return n.identifier=!0,n.reserved=!0,n}function H(e,t){var n=q(e,t&&t.nud||function(){return this});return t=t||{},t.isFutureReservedWord=!0,n.value=e,n.identifier=!0,n.reserved=!0,n.meta=t,n}function $(e,t){return z(e,function(){return"function"==typeof t&&t(this),this})}function J(e,t,n,r){var i=P(e,n);return N(i),i.infix=!0,i.led=function(i){return r||M(c.tokens.prev,c.tokens.curr),"in"!==e&&"instanceof"!==e||"!"!==i.id||b("W018",i,"!"),"function"==typeof t?t(i,this):(this.left=i,this.right=G(n),this)},i}function Z(e,t){var r=P(e,100);return r.infix=!0,r.led=function(e){M(c.tokens.prev,c.tokens.curr),this.left=e;var r=this.right=G(100);return n(e,"NaN")||n(r,"NaN")?b("W019",this):t&&t.apply(this,[e,r]),e&&r||y("E041",c.tokens.curr),"!"===e.id&&b("W018",e,"!"),"!"===r.id&&b("W018",r,"!"),this},r}function X(e,t,n){var i;return!n.option.notypeof&&(!(!e||!t)&&(i=n.inES6()?ot.es6:ot.es3,"(identifier)"===t.type&&"typeof"===t.value&&"(string)"===e.type&&!r.contains(i,e.value)))}function K(e,t){var n=!1;return"this"===e.type&&null===t.funct["(context)"]?n=!0:"(identifier)"===e.type&&(t.option.node&&"global"===e.value?n=!0:!t.option.browser||"window"!==e.value&&"document"!==e.value||(n=!0)),n}function Y(e){function t(e){if("object"==typeof e)return"prototype"===e.right?e:t(e.left)}var n=["Array","ArrayBuffer","Boolean","Collator","DataView","Date","DateTimeFormat","Error","EvalError","Float32Array","Float64Array","Function","Infinity","Intl","Int16Array","Int32Array","Int8Array","Iterator","Number","NumberFormat","Object","RangeError","ReferenceError","RegExp","StopIteration","String","SyntaxError","TypeError","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","URIError"],r=t(e);if(r)return function(e){for(;!e.identifier&&"object"==typeof e.left;)e=e.left;if(e.identifier&&n.indexOf(e.value)>=0&&c.funct["(scope)"].isPredefined(e.value))return e.value}(r)}function Q(e,t,n){var r=n&&n.allowDestructuring;if(t=t||e,c.option.freeze){var i=Y(e);i&&b("W121",e,i)}return Re(e,"...")&&(e=e.right),e.identifier&&!e.isMetaProperty&&c.funct["(scope)"].block.reassign(e.value,e),"."===e.id?(e.left&&("arguments"!==e.left.value||c.isStrict())||b("E031",t),c.nameStack.set(c.tokens.prev),!0):"{"===e.id||"["===e.id?(r&&e.destructAssign||("{"!==e.id&&e.left?"arguments"!==e.left.value||c.isStrict()||b("E031",t):b("E031",t)),"["===e.id&&c.nameStack.set(e.right),!0):!e.identifier||d(e)||e.isMetaProperty?(e===c.syntax.function?b("W023",c.tokens.curr):_("E031",t),!1):("exception"===c.funct["(scope)"].labeltype(e.value)&&b("W022",e),c.nameStack.set(e),!0)}function ee(e,t,n){var r=J(e,"function"==typeof t?t:function(e,t){return t.left=e,Q(e,t,{allowDestructuring:!0}),t.right=G(10),t},n);return r.exps=!0,r.assign=!0,r}function te(e,t,n){var r=P(e,n);return N(r),r.infix=!0,r.led="function"==typeof t?t:function(e){return c.option.bitwise&&b("W016",this,this.id),this.left=e,this.right=G(n),this},r}function ne(e){return ee(e,function(e,t){return c.option.bitwise&&b("W016",t,t.id),Q(e,t),t.right=G(10),t},20)}function re(e){var t=P(e,150);return t.led=function(e){return c.option.plusplus?b("W016",this,this.id):e.identifier&&!d(e)||"."===e.id||"["===e.id||b("W017",this),e.isMetaProperty?_("E031",this):e&&e.identifier&&c.funct["(scope)"].block.modify(e.value,e),this.left=e,this},t}function ie(e,t,n){if(c.tokens.next.identifier){n||j();var r=c.tokens.curr,i=c.tokens.curr.value;return d(r)?t&&c.inES5()?i:e&&"undefined"===i?i:(b("W024",c.tokens.curr,c.tokens.curr.id),i):i}}function oe(e,t){var n=ie(e,t,!1);if(n)return n;if("..."===c.tokens.next.value){if(c.inES6(!0)||b("W119",c.tokens.next,"spread/rest operator","6"),j(),Re(c.tokens.next,"..."))for(b("E024",c.tokens.next,"...");Re(c.tokens.next,"...");)j();return c.tokens.next.identifier?oe(e,t):void b("E024",c.tokens.curr,c.tokens.next.id)}_("E030",c.tokens.next,c.tokens.next.value),";"!==c.tokens.next.id&&j()}function se(e){var t,n=0;if(";"===c.tokens.next.id&&!e.inBracelessBlock)for(;;){do{t=A(n),n+=1}while("(end)"!==t.id&&"(comment)"===t.id);if(t.reach)return;if("(endline)"!==t.id){if("function"===t.id){!0===c.option.latedef&&b("W026",t);break}b("W027",t,t.value,e.value);break}}}function ae(e){if(";"!==c.tokens.next.id){if(c.tokens.next.isUnclosed)return j();var t=C(c.tokens.next)===c.tokens.curr.line&&"(end)"!==c.tokens.next.id,n=Re(c.tokens.next,"}");!t||n||"do"===e.id&&c.inES6(!0)?c.option.asi||n&&t&&c.option.lastsemic||E("W033",c.tokens.curr.line,c.tokens.curr.character):w("E058",c.tokens.curr.line,c.tokens.curr.character)}else j(";")}function ue(){var e,t=$e,n=c.tokens.next,r=!1;{if(";"!==n.id){var i=d(n);return i&&n.meta&&n.meta.isFutureReservedWord&&":"===A().id&&(b("W024",n,n.id),i=!1),n.identifier&&!i&&":"===A().id&&(j(),j(":"),r=!0,c.funct["(scope)"].stack(),c.funct["(scope)"].block.addBreakLabel(n.value,{token:c.tokens.curr}),c.tokens.next.labelled||"{"===c.tokens.next.value||b("W028",c.tokens.next,n.value,c.tokens.next.value),c.tokens.next.label=n.value,n=c.tokens.next),"{"===n.id?(fe(!0,!0,!1,!1,"case"===c.funct["(verb)"]&&":"===c.tokens.curr.value),void(r&&c.funct["(scope)"].unstack())):(!(e=G(0,!0))||e.identifier&&"function"===e.value||"(punctuator)"===e.type&&e.left&&e.left.identifier&&"function"===e.left.value||!c.isStrict()&&c.stmtMissingStrict()&&b("E007"),n.block||(c.option.expr||e&&e.exps?c.option.nonew&&e&&e.left&&"("===e.id&&"new"===e.left.id&&b("W031",n):b("W030",c.tokens.curr),ae(n)),$e=t,r&&c.funct["(scope)"].unstack(),e)}j(";")}}function ce(){for(var e,t=[];!c.tokens.next.reach&&"(end)"!==c.tokens.next.id;)";"===c.tokens.next.id?((!(e=A())||"("!==e.id&&"["!==e.id)&&b("W032"),j(";")):t.push(ue());return t}function le(){for(var e=c.tokens.next;"(string)"===c.tokens.next.id;){var t=L();if(!O(e,t))break;e=t,j();var n=c.tokens.curr.value;(c.directive[n]||"use strict"===n&&"implied"===c.option.strict)&&b("W034",c.tokens.curr,n),c.directive[n]=!0,ae(e)}c.isStrict()&&(c.option.undef=!0)}function fe(e,t,n,i,o){var s,a,u,l,f=He,p=$e;He=e,u=c.tokens.next;var h=c.funct["(metrics)"];if(h.nestedBlockDepth+=1,h.verifyMaxNestedBlockDepthPerFunction(),"{"===c.tokens.next.id){if(j("{"),c.funct["(scope)"].stack(),c.funct["(noblockscopedvar)"]=!1,c.tokens.curr.line,"}"!==c.tokens.next.id){for($e+=c.option.indent;!e&&c.tokens.next.from>$e;)$e+=c.option.indent;if(n){a={};for(l in c.directive)r.has(c.directive,l)&&(a[l]=c.directive[l]);le(),c.option.strict&&c.funct["(context)"]["(global)"]&&(a["use strict"]||c.isStrict()||b("E007"))}s=ce(),h.statementCount+=s.length,$e-=c.option.indent}j("}",u),n&&(c.funct["(scope)"].validateParams(),a&&(c.directive=a)),c.funct["(scope)"].unstack(),$e=p}else if(e)c.funct["(noblockscopedvar)"]="for"!==c.tokens.next.id,c.funct["(scope)"].stack(),t&&!c.option.curly||b("W116",c.tokens.next,"{",c.tokens.next.value),c.tokens.next.inBracelessBlock=!0,$e+=c.option.indent,s=[ue()],$e-=c.option.indent,c.funct["(scope)"].unstack(),delete c.funct["(noblockscopedvar)"];else if(n){if(c.funct["(scope)"].stack(),a={},!t||i||c.inMoz()||_("W118",c.tokens.curr,"function closure expressions"),!t)for(l in c.directive)r.has(c.directive,l)&&(a[l]=c.directive[l]);G(10),c.option.strict&&c.funct["(context)"]["(global)"]&&(a["use strict"]||c.isStrict()||b("E007")),c.funct["(scope)"].unstack()}else _("E021",c.tokens.next,"{",c.tokens.next.value);switch(c.funct["(verb)"]){case"break":case"continue":case"return":case"throw":if(o)break;default:c.funct["(verb)"]=null}return He=f,!e||!c.option.noempty||s&&0!==s.length||b("W035",c.tokens.prev),h.nestedBlockDepth-=1,s}function pe(e){Ke&&"boolean"!=typeof Ke[e]&&b("W036",c.tokens.curr,e),"number"==typeof Xe[e]?Xe[e]+=1:Xe[e]=1}function he(){var e={};e.exps=!0,c.funct["(comparray)"].stack();var t=!1;return"for"!==c.tokens.next.value&&(t=!0,c.inMoz()||b("W116",c.tokens.next,"for",c.tokens.next.value),c.funct["(comparray)"].setState("use"),e.right=G(10)),j("for"),"each"===c.tokens.next.value&&(j("each"),c.inMoz()||b("W118",c.tokens.curr,"for each")),j("("),c.funct["(comparray)"].setState("define"),e.left=G(130),r.contains(["in","of"],c.tokens.next.value)?j():_("E045",c.tokens.curr),c.funct["(comparray)"].setState("generate"),G(10),j(")"),"if"===c.tokens.next.value&&(j("if"),j("("),c.funct["(comparray)"].setState("filter"),e.filter=G(10),j(")")),t||(c.funct["(comparray)"].setState("use"),e.right=G(10)),j("]"),c.funct["(comparray)"].unstack(),e}function de(){return c.funct["(statement)"]&&"class"===c.funct["(statement)"].type||c.funct["(context)"]&&"class"===c.funct["(context)"]["(verb)"]}function ve(e){return e.identifier||"(string)"===e.id||"(number)"===e.id}function ge(e){var t,n=!0;return t="object"==typeof e?e:ie(!1,!0,n=e),t?"object"==typeof t&&("(string)"===t.id||"(identifier)"===t.id?t=t.value:"(number)"===t.id&&(t=t.value.toString())):"(string)"===c.tokens.next.id?(t=c.tokens.next.value,n||j()):"(number)"===c.tokens.next.id&&(t=c.tokens.next.value.toString(),n||j()),"hasOwnProperty"===t&&b("W001"),t}function me(e){var t,n,i,o=[],s=[],a=!1,u=!1,l=0,f=e&&e.loneArg;if(f&&!0===f.identifier)return c.funct["(scope)"].addParam(f.value,f),{arity:1,params:[f.value]};if(t=c.tokens.next,e&&e.parsedOpening||j("("),")"!==c.tokens.next.id)for(;;){l++;var p=[];if(r.contains(["{","["],c.tokens.next.id)){s=Le();for(i in s)(i=s[i]).id&&(o.push(i.id),p.push([i.id,i.token]))}else if(Re(c.tokens.next,"...")&&(u=!0),n=oe(!0))o.push(n),p.push([n,c.tokens.curr]);else for(;!Pe(c.tokens.next,[",",")"]);)j();if(a&&"="!==c.tokens.next.id&&_("W138",c.tokens.current),"="===c.tokens.next.id&&(c.inES6()||b("W119",c.tokens.next,"default parameters","6"),j("="),a=!0,G(10)),p.forEach(function(e){c.funct["(scope)"].addParam.apply(c.funct["(scope)"],e)}),","!==c.tokens.next.id)return j(")",t),{arity:l,params:o};u&&b("W131",c.tokens.next),F()}else j(")")}function ke(e,t,n){var i={"(name)":e,"(breakage)":0,"(loopage)":0,"(tokens)":{},"(properties)":{},"(catch)":!1,"(global)":!1,"(line)":null,"(character)":null,"(metrics)":null,"(statement)":null,"(context)":null,"(scope)":null,"(comparray)":null,"(generator)":null,"(arrow)":null,"(params)":null};return t&&r.extend(i,{"(line)":t.line,"(character)":t.character,"(metrics)":_e(t)}),r.extend(i,n),i["(context)"]&&(i["(scope)"]=i["(context)"]["(scope)"],i["(comparray)"]=i["(context)"]["(comparray)"]),i}function ye(e){return"(scope)"in e}function xe(e){return e["(global)"]&&!e["(verb)"]}function be(e){var t=this.context,n=this.noSubst,r=this.depth,i="number"==typeof e?null:e;if(!n)for(;!function(){if(c.tokens.curr.template&&c.tokens.curr.tail&&c.tokens.curr.context===t)return!0;var e=c.tokens.next.template&&c.tokens.next.tail&&c.tokens.next.context===t;return e&&j(),e||c.tokens.next.isUnclosed}();)!c.tokens.next.template||c.tokens.next.depth>r?G(0):j();return{id:"(template)",type:"(template)",tag:i}}function Ee(e){var t,n,r,i,o,s,a,u,l=c.option,f=c.ignored;e&&(r=e.name,i=e.statement,o=e.classExprBinding,s="generator"===e.type,a="arrow"===e.type,u=e.ignoreLoopFunc),c.option=Object.create(c.option),c.ignored=Object.create(c.ignored),c.funct=ke(r||c.nameStack.infer(),c.tokens.next,{"(statement)":i,"(context)":c.funct,"(arrow)":a,"(generator)":s}),t=c.funct,(n=c.tokens.curr).funct=c.funct,ze.push(c.funct),c.funct["(scope)"].stack("functionouter");var p=r||o;p&&c.funct["(scope)"].block.add(p,o?"class":"function",c.tokens.curr,!1),c.funct["(scope)"].stack("functionparams");var h=me(e);return h?(c.funct["(params)"]=h.params,c.funct["(metrics)"].arity=h.arity,c.funct["(metrics)"].verifyMaxParametersPerFunction()):c.funct["(metrics)"].arity=0,a&&(c.inES6(!0)||b("W119",c.tokens.curr,"arrow function syntax (=>)","6"),e.loneArg||j("=>")),fe(!1,!0,!0,a),!c.option.noyield&&s&&"yielded"!==c.funct["(generator)"]&&b("W124",c.tokens.curr),c.funct["(metrics)"].verifyMaxStatementsPerFunction(),c.funct["(metrics)"].verifyMaxComplexityPerFunction(),c.funct["(unusedOption)"]=c.option.unused,c.option=l,c.ignored=f,c.funct["(last)"]=c.tokens.curr.line,c.funct["(lastcharacter)"]=c.tokens.curr.character,c.funct["(scope)"].unstack(),c.funct["(scope)"].unstack(),c.funct=c.funct["(context)"],u||c.option.loopfunc||!c.funct["(loopage)"]||t["(isCapturing)"]&&b("W083",n),t}function _e(e){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){c.option.maxstatements&&this.statementCount>c.option.maxstatements&&b("W071",e,this.statementCount)},verifyMaxParametersPerFunction:function(){r.isNumber(c.option.maxparams)&&this.arity>c.option.maxparams&&b("W072",e,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){c.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===c.option.maxdepth+1&&b("W073",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var t=c.option.maxcomplexity,n=this.ComplexityCount;t&&n>t&&b("W074",e,n)}}}function we(){c.funct["(metrics)"].ComplexityCount+=1}function Se(e){var t,n;switch(e&&(t=e.id,n=e.paren,","===t&&(e=e.exprs[e.exprs.length-1])&&(t=e.id,n=n||e.paren)),t){case"=":case"+=":case"-=":case"*=":case"%=":case"&=":case"|=":case"^=":case"/=":n||c.option.boss||b("W084")}}function We(e){if(c.inES5())for(var t in e)e[t]&&e[t].setterToken&&!e[t].getterToken&&b("W078",e[t].setterToken)}function Ae(e,t){if(Re(c.tokens.next,".")){var n=c.tokens.curr.id;j(".");var r=oe();return c.tokens.curr.isMetaProperty=!0,e!==r?_("E057",c.tokens.prev,n,r):t(),c.tokens.curr}}function Le(e){var t=e&&e.assignment;return c.inES6()||b("W104",c.tokens.curr,t?"destructuring assignment":"destructuring binding","6"),je(e)}function je(e){var t,n,r,i=[],o=e&&e.openingParsed,s=e&&e.assignment,a=s?{assignment:s}:null,u=o?c.tokens.curr:c.tokens.next,l=function(){var e;if(Pe(c.tokens.next,["[","{"])){t=je(a);for(var n in t)n=t[n],i.push({id:n.id,token:n.token})}else if(Re(c.tokens.next,","))i.push({id:null,token:c.tokens.curr});else{if(!Re(c.tokens.next,"(")){var r=Re(c.tokens.next,"...");if(s){var o=G(20);o&&(Q(o),o.identifier&&(e=o.value))}else e=oe();return e&&i.push({id:e,token:c.tokens.curr}),r}j("("),l(),j(")")}return!1};if(Re(u,"[")){o||j("["),Re(c.tokens.next,"]")&&b("W137",c.tokens.curr);for(var f=!1;!Re(c.tokens.next,"]");)l()&&!f&&Re(c.tokens.next,",")&&(b("W130",c.tokens.next),f=!0),Re(c.tokens.next,"=")&&(j(Re(c.tokens.prev,"...")?"]":"="),n=c.tokens.prev,(r=G(10))&&"undefined"===r.type&&b("W080",n,n.value)),Re(c.tokens.next,"]")||j(",");j("]")}else if(Re(u,"{")){for(o||j("{"),Re(c.tokens.next,"}")&&b("W137",c.tokens.curr);!Re(c.tokens.next,"}")&&(function(){var e;Re(c.tokens.next,"[")?(j("["),G(10),j("]"),j(":"),l()):"(string)"===c.tokens.next.id||"(number)"===c.tokens.next.id?(j(),j(":"),l()):(e=oe(),Re(c.tokens.next,":")?(j(":"),l()):e&&(s&&Q(c.tokens.curr),i.push({id:e,token:c.tokens.curr})))}(),Re(c.tokens.next,"=")&&(j("="),n=c.tokens.prev,(r=G(10))&&"undefined"===r.type&&b("W080",n,n.value)),Re(c.tokens.next,"}")||(j(","),!Re(c.tokens.next,"}"))););j("}")}return i}function Te(e,t){var n=t.first;n&&r.zip(e,Array.isArray(n)?n:[n]).forEach(function(e){var t=e[0],n=e[1];t&&n?t.first=n:t&&t.first&&!n&&b("W080",t.first,t.first.value)})}function Oe(e,t,n){var i,o,s,a,u=n&&n.prefix,l=n&&n.inexport,f="let"===e,p="const"===e;for(c.inES6()||b("W104",c.tokens.curr,e,"6"),f&&"("===c.tokens.next.value?(c.inMoz()||b("W118",c.tokens.next,"let block"),j("("),c.funct["(scope)"].stack(),a=!0):c.funct["(noblockscopedvar)"]&&_("E048",c.tokens.curr,p?"Const":"Let"),t.first=[];;){var h=[];r.contains(["{","["],c.tokens.next.value)?(i=Le(),o=!1):(i=[{id:oe(),token:c.tokens.curr}],o=!0),!u&&p&&"="!==c.tokens.next.id&&b("E012",c.tokens.curr,c.tokens.curr.value);for(var d in i)i.hasOwnProperty(d)&&(d=i[d],c.funct["(scope)"].block.isGlobal()&&!1===Ye[d.id]&&b("W079",d.token,d.id),d.id&&!c.funct["(noblockscopedvar)"]&&(c.funct["(scope)"].addlabel(d.id,{type:e,token:d.token}),h.push(d.token)));if("="===c.tokens.next.id){j("="),!u&&"="===A(0).id&&c.tokens.next.identifier&&b("W120",c.tokens.next,c.tokens.next.value);var v=c.tokens.prev;s=G(u?120:10),!u&&s&&"undefined"===s.type&&b("W080",v,v.value),o?i[0].first=s:Te(h,s)}if(!u)for(d in i)i.hasOwnProperty(d)&&(d=i[d],c.funct["(scope)"].initialize(d.id),o&&l&&c.funct["(scope)"].setExported(d.token.value,d.token));if(t.first=t.first.concat(h),","!==c.tokens.next.id)break;F()}return a&&(j(")"),fe(!0,!0),t.block=!0,c.funct["(scope)"].unstack()),t}function Ge(e,t){return c.inES6()||b("W104",c.tokens.curr,"class","6"),t?(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"class",token:c.tokens.curr})):c.tokens.next.identifier&&"extends"!==c.tokens.next.value?(this.name=oe(),this.namedExpr=!0):this.name=c.nameStack.infer(),Ce(this),t&&c.funct["(scope)"].initialize(this.name),this}function Ce(e){var t=c.inClassBody;"extends"===c.tokens.next.value&&(j("extends"),e.heritage=G(10)),c.inClassBody=!0,j("{"),e.body=Me(e),j("}"),c.inClassBody=t}function Me(e){for(var t,n,r,i,o,s=Object.create(null),a=Object.create(null),u=0;"}"!==c.tokens.next.id;++u)if(t=c.tokens.next,n=!1,r=!1,i=null,";"!==t.id){if("*"===t.id&&(r=!0,j("*"),t=c.tokens.next),"["===t.id)t=Fe(),o=!0;else{if(!ve(t)){b("W052",c.tokens.next,c.tokens.next.value||c.tokens.next.type),j();continue}j(),o=!1,t.identifier&&"static"===t.value&&(Re(c.tokens.next,"*")&&(r=!0,j("*")),(ve(c.tokens.next)||"["===c.tokens.next.id)&&(o="["===c.tokens.next.id,n=!0,t=c.tokens.next,"["===c.tokens.next.id?t=Fe():j())),!t.identifier||"get"!==t.value&&"set"!==t.value||(ve(c.tokens.next)||"["===c.tokens.next.id)&&(o="["===c.tokens.next.id,i=t,t=c.tokens.next,"["===c.tokens.next.id?t=Fe():j())}if(!Re(c.tokens.next,"(")){for(_("E054",c.tokens.next,c.tokens.next.value);"}"!==c.tokens.next.id&&!Re(c.tokens.next,"(");)j();"("!==c.tokens.next.value&&Ee({statement:e})}o||(i?Ie(i.value,n?a:s,t.value,t,!0,n):("constructor"===t.value?c.nameStack.set(e):c.nameStack.set(t),Ve(n?a:s,t.value,t,!0,n))),i&&"constructor"===t.value?_("E049",t,"get"===i.value?"class getter method":"class setter method","constructor"):"prototype"===t.value&&_("E049",t,"class method","prototype"),ge(t),Ee({statement:e,type:r?"generator":null,classExprBinding:e.namedExpr?e.name:null})}else b("W032"),j(";");We(s)}function Ve(e,t,n,r,i){var o=["key","class method","static class method"];o=o[(r||!1)+(i||!1)],n.identifier&&(t=n.value),e[t]&&"__proto__"!==t?b("W075",c.tokens.next,o,t):e[t]=Object.create(null),e[t].basic=!0,e[t].basictkn=n}function Ie(e,t,n,r,i,o){var s="get"===e?"getterToken":"setterToken",a="";i?(o&&(a+="static "),a+=e+"ter method"):a="key",c.tokens.curr.accessorType=e,c.nameStack.set(r),t[n]?(t[n].basic||t[n][s])&&"__proto__"!==n&&b("W075",c.tokens.next,a,n):t[n]=Object.create(null),t[n][s]=r}function Fe(){j("["),c.inES6()||b("W119",c.tokens.curr,"computed property names","6");var e=G(10);return j("]"),e}function Pe(e,t){return"(punctuator)"===e.type&&r.contains(t,e.value)}function Re(e,t){return"(punctuator)"===e.type&&e.value===t}function Ue(){var e=ut();e.notJson?(!c.inES6()&&e.isDestAssign&&b("W104",c.tokens.curr,"destructuring assignment","6"),ce()):(c.option.laxbreak=!0,c.jsonMode=!0,Be())}function Be(){switch(c.tokens.next.id){case"{":!function(){var e={},t=c.tokens.next;if(j("{"),"}"!==c.tokens.next.id)for(;;){if("(end)"===c.tokens.next.id)_("E026",c.tokens.next,t.line);else{if("}"===c.tokens.next.id){b("W094",c.tokens.curr);break}","===c.tokens.next.id?_("E028",c.tokens.next):"(string)"!==c.tokens.next.id&&b("W095",c.tokens.next,c.tokens.next.value)}if(!0===e[c.tokens.next.value]?b("W075",c.tokens.next,"key",c.tokens.next.value):"__proto__"===c.tokens.next.value&&!c.option.proto||"__iterator__"===c.tokens.next.value&&!c.option.iterator?b("W096",c.tokens.next,c.tokens.next.value):e[c.tokens.next.value]=!0,j(),j(":"),Be(),","!==c.tokens.next.id)break;j(",")}j("}")}();break;case"[":!function(){var e=c.tokens.next;if(j("["),"]"!==c.tokens.next.id)for(;;){if("(end)"===c.tokens.next.id)_("E027",c.tokens.next,e.line);else{if("]"===c.tokens.next.id){b("W094",c.tokens.curr);break}","===c.tokens.next.id&&_("E028",c.tokens.next)}if(Be(),","!==c.tokens.next.id)break;j(",")}j("]")}();break;case"true":case"false":case"null":case"(number)":case"(string)":j();break;case"-":j("-"),j("(number)");break;default:_("E003",c.tokens.next)}}function Ne(e,t,n){var r,i,o,s;for(i=0;i":!0,">=":!0,"+":!0,"-":!0,"*":!0,"/":!0,"%":!0},nt=["closure","exception","global","label","outer","unused","var"],rt=[],it=new i.EventEmitter,ot={};ot.legacy=["xml","unknown"],ot.es3=["undefined","boolean","number","string","function","object"],ot.es3=ot.es3.concat(ot.legacy),ot.es6=ot.es3.concat("symbol"),q("(number)",function(){return this}),q("(string)",function(){return this}),c.syntax["(identifier)"]={type:"(identifier)",lbp:0,identifier:!0,nud:function(){var e=this.value;return"=>"===c.tokens.next.id?this:(c.funct["(comparray)"].check(e)||c.funct["(scope)"].block.use(e,c.tokens.curr),this)},led:function(){_("E033",c.tokens.next,c.tokens.next.value)}};var st={identifier:!1,template:!0};c.syntax["(template)"]=r.extend({lbp:155,type:"(template)",nud:be,led:be,noSubst:!1},st),c.syntax["(template middle)"]=r.extend({lbp:0,type:"(template middle)",middle:!0,noSubst:!1},st),c.syntax["(template tail)"]=r.extend({lbp:0,type:"(template tail)",tail:!0,noSubst:!1},st),c.syntax["(no subst template)"]=r.extend({lbp:155,type:"(template)",nud:be,led:be,noSubst:!0,tail:!0},st),q("(regexp)",function(){return this}),R("(endline)"),function(e){e.line=e.from=0}(R("(begin)")),R("(end)").reach=!0,R("(error)").reach=!0,R("}").reach=!0,R(")"),R("]"),R('"').reach=!0,R("'").reach=!0,R(";"),R(":").reach=!0,R("#"),z("else"),z("case").reach=!0,z("catch"),z("default").reach=!0,z("finally"),$("arguments",function(e){c.isStrict()&&c.funct["(global)"]&&b("E008",e)}),$("eval"),$("false"),$("Infinity"),$("null"),$("this",function(e){c.isStrict()&&!de()&&!c.option.validthis&&(c.funct["(statement)"]&&c.funct["(name)"].charAt(0)>"Z"||c.funct["(global)"])&&b("W040",e)}),$("true"),$("undefined"),ee("=","assign",20),ee("+=","assignadd",20),ee("-=","assignsub",20),ee("*=","assignmult",20),ee("/=","assigndiv",20).nud=function(){_("E014")},ee("%=","assignmod",20),ne("&="),ne("|="),ne("^="),ne("<<="),ne(">>="),ne(">>>="),J(",",function(e,t){var n;if(t.exprs=[e],c.option.nocomma&&b("W127"),!F({peek:!0}))return t;for(;;){if(!(n=G(10)))break;if(t.exprs.push(n),","!==c.tokens.next.value||!F())break}return t},10,!0),J("?",function(e,t){return we(),t.left=e,t.right=G(10),j(":"),t.else=G(10),t},30);J("||",function(e,t){return we(),t.left=e,t.right=G(40),t},40),J("&&","and",50),te("|","bitor",70),te("^","bitxor",80),te("&","bitand",90),Z("==",function(e,t){switch(!0){case!(c.option.eqnull&&("null"===(e&&e.value)||"null"===(t&&t.value)))&&c.option.eqeqeq:this.from=this.character,b("W116",this,"===","==");break;case X(t,e,c):b("W122",this,t.value);break;case X(e,t,c):b("W122",this,e.value)}return this}),Z("===",function(e,t){return X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("!=",function(e,t){return!(c.option.eqnull&&("null"===(e&&e.value)||"null"===(t&&t.value)))&&c.option.eqeqeq?(this.from=this.character,b("W116",this,"!==","!=")):X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("!==",function(e,t){return X(t,e,c)?b("W122",this,t.value):X(e,t,c)&&b("W122",this,e.value),this}),Z("<"),Z(">"),Z("<="),Z(">="),te("<<","shiftleft",120),te(">>","shiftright",120),te(">>>","shiftrightunsigned",120),J("in","in",120),J("instanceof",function(e,t){var n,r=c.funct["(scope)"];return t.left=e,t.right=n=G(120),n?(("(number)"===n.id||"(string)"===n.id||"null"===n.value||"undefined"===n.value&&!r.has("undefined")||"unary"===n.arity||"{"===n.id||"["===n.id&&!n.right||"(regexp)"===n.id||"(template)"===n.id&&!n.tag)&&_("E060"),"function"===n.id&&b("W139"),t):t},120),J("+",function(e,t){var n;return t.left=e,t.right=n=G(130),e&&n&&"(string)"===e.id&&"(string)"===n.id?(e.value+=n.value,e.character=n.character,!c.option.scripturl&&u.javascriptURL.test(e.value)&&b("W050",e),e):t},130),D("+","num"),D("+++",function(){return b("W007"),this.arity="unary",this.right=G(150),this}),J("+++",function(e){return b("W007"),this.left=e,this.right=G(130),this},130),J("-","sub",130),D("-","neg"),D("---",function(){return b("W006"),this.arity="unary",this.right=G(150),this}),J("---",function(e){return b("W006"),this.left=e,this.right=G(130),this},130),J("*","mult",140),J("/","div",140),J("%","mod",140),re("++"),D("++","preinc"),c.syntax["++"].exps=!0,c.syntax["++"].ltBoundary="before",re("--"),D("--","predec"),c.syntax["--"].exps=!0,c.syntax["--"].ltBoundary="before",D("delete",function(){var e=G(10);return e?("."!==e.id&&"["!==e.id&&b("W051"),this.first=e,e.identifier&&!c.isStrict()&&(e.forgiveUndef=!0),this):this}).exps=!0,D("~",function(){return c.option.bitwise&&b("W016",this,"~"),this.arity="unary",this.right=G(150),this}),D("...",function(){return c.inES6(!0)||b("W119",this,"spread/rest operator","6"),c.tokens.next.identifier||"(string)"===c.tokens.next.type||Pe(c.tokens.next,["[","("])||_("E030",c.tokens.next,c.tokens.next.value),this.right=G(150),this}),D("!",function(){return this.arity="unary",this.right=G(150),this.right||y("E041",this),!0===tt[this.right.id]&&b("W018",this,"!"),this}),D("typeof",function(){var e=G(150);return this.first=this.right=e,e||y("E041",this),e.identifier&&(e.forgiveUndef=!0),this}),D("new",function(){var e=Ae("target",function(){c.inES6(!0)||b("W119",c.tokens.prev,"new.target","6");for(var e,t=c.funct;t&&(e=!t["(global)"],t["(arrow)"]);)t=t["(context)"];e||b("W136",c.tokens.prev,"new.target")});if(e)return e;var t,n=G(155);if(n&&"function"!==n.id)if(n.identifier)switch(n.new=!0,n.value){case"Number":case"String":case"Boolean":case"Math":case"JSON":b("W053",c.tokens.prev,n.value);break;case"Symbol":c.inES6()&&b("W053",c.tokens.prev,n.value);break;case"Function":c.option.evil||b("W054");break;case"Date":case"RegExp":case"this":break;default:"function"!==n.id&&(t=n.value.substr(0,1),c.option.newcap&&(t<"A"||t>"Z")&&!c.funct["(scope)"].isPredefined(n.value)&&b("W055",c.tokens.curr))}else"."!==n.id&&"["!==n.id&&"("!==n.id&&b("W056",c.tokens.curr);else c.option.supernew||b("W057",this);return"("===c.tokens.next.id||c.option.supernew||b("W058",c.tokens.curr,c.tokens.curr.value),this.first=this.right=n,this}),c.syntax.new.exps=!0,D("void").exps=!0,J(".",function(e,t){var n=oe(!1,!0);return"string"==typeof n&&pe(n),t.left=e,t.right=n,n&&"hasOwnProperty"===n&&"="===c.tokens.next.value&&b("W001"),!e||"arguments"!==e.value||"callee"!==n&&"caller"!==n?c.option.evil||!e||"document"!==e.value||"write"!==n&&"writeln"!==n||b("W060",e):c.option.noarg?b("W059",e,n):c.isStrict()&&_("E008"),c.option.evil||"eval"!==n&&"execScript"!==n||K(e,c)&&b("W061"),t},160,!0),J("(",function(e,t){c.option.immed&&e&&!e.immed&&"function"===e.id&&b("W062");var n=0,r=[];if(e&&"(identifier)"===e.type&&e.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1==="Array Number String Boolean Date Object Error Symbol".indexOf(e.value)&&("Math"===e.value?b("W063",e):c.option.newcap&&b("W064",e)),")"!==c.tokens.next.id)for(;r[r.length]=G(10),n+=1,","===c.tokens.next.id;)F();return j(")"),"object"==typeof e&&(c.inES5()||"parseInt"!==e.value||1!==n||b("W065",c.tokens.curr),c.option.evil||("eval"===e.value||"Function"===e.value||"execScript"===e.value?b("W061",e):!r[0]||"(string)"!==r[0].id||"setTimeout"!==e.value&&"setInterval"!==e.value?!r[0]||"(string)"!==r[0].id||"."!==e.value||"window"!==e.left.value||"setTimeout"!==e.right&&"setInterval"!==e.right||(b("W066",e),S(e,r[0])):(b("W066",e),S(e,r[0]))),e.identifier||"."===e.id||"["===e.id||"=>"===e.id||"("===e.id||"&&"===e.id||"||"===e.id||"?"===e.id||c.inES6()&&e["(name)"]||b("W067",t)),t.left=e,t},155,!0).exps=!0,D("(",function(e){var t,n,r,i,o,s=c.tokens.next,a=-1,u=1,l=c.tokens.curr,f=c.tokens.prev,p=!c.option.singleGroups;do{"("===s.value?u+=1:")"===s.value&&(u-=1),t=s,s=A(a+=1)}while((0!==u||")"!==t.value)&&"(end)"!==s.type);if("function"===c.tokens.next.id&&(r=c.tokens.next.immed=!0),"=>"===s.value)return Ee({type:"arrow",parsedOpening:!0});var h=[];if(")"!==c.tokens.next.id)for(;h.push(G(10)),","===c.tokens.next.id;)c.option.nocomma&&b("W127"),F();return j(")",this),c.option.immed&&h[0]&&"function"===h[0].id&&"("!==c.tokens.next.id&&"."!==c.tokens.next.id&&"["!==c.tokens.next.id&&b("W068",this),h.length?(h.length>1?((n=Object.create(c.syntax[","])).exprs=h,i=h[0],o=h[h.length-1]):(n=i=o=h[0],p||(p=l.beginsStmt&&("{"===n.id||r||ye(n))||r&&(!O()||"}"!==c.tokens.prev.id)||ye(n)&&!O()||"{"===n.id&&"=>"===f.id||"(number)"===n.type&&Re(s,".")&&/^\d+$/.test(n.value)||l.beginsStmt&&"="===n.id&&"{"===n.left.id)),n&&(p||!T(i)&&!n.exprs||(p=e>i.lbp||e>0&&e===i.lbp||!O()&&o.lbp"),J("[",function(e,t){var n,r=G(10);return r&&"(string)"===r.type&&(c.option.evil||"eval"!==r.value&&"execScript"!==r.value||K(e,c)&&b("W061"),pe(r.value),!c.option.sub&&u.identifier.test(r.value)&&((n=c.syntax[r.value])&&d(n)||b("W069",c.tokens.prev,r.value))),j("]",t),r&&"hasOwnProperty"===r.value&&"="===c.tokens.next.value&&b("W001"),t.left=e,t.right=r,t},160,!0),D("[",function(){var e=ut();if(e.isCompArray)return c.option.esnext||c.inMoz()||b("W118",c.tokens.curr,"array comprehension"),he();if(e.isDestAssign)return this.destructAssign=Le({openingParsed:!0,assignment:!0}),this;var t=c.tokens.curr.line!==C(c.tokens.next);for(this.first=[],t&&($e+=c.option.indent,c.tokens.next.from===$e+c.option.indent&&($e+=c.option.indent));"(end)"!==c.tokens.next.id;){for(;","===c.tokens.next.id;){if(!c.option.elision){if(c.inES5()){b("W128");do{j(",")}while(","===c.tokens.next.id);continue}b("W070")}j(",")}if("]"===c.tokens.next.id)break;if(this.first.push(G(10)),","!==c.tokens.next.id){c.option.trailingcomma&&c.inES5()&&E("W140",c.tokens.curr.line,c.tokens.curr.character);break}if(F({allowTrailing:!0}),"]"===c.tokens.next.id&&!c.inES5()){b("W070",c.tokens.curr);break}}return t&&($e-=c.option.indent),j("]",this),this}),function(e){e.nud=function(){var e,t,n,r,i,o,s=!1,a=Object.create(null);if((e=c.tokens.curr.line!==C(c.tokens.next))&&($e+=c.option.indent,c.tokens.next.from===$e+c.option.indent&&($e+=c.option.indent)),ut().isDestAssign)return this.destructAssign=Le({openingParsed:!0,assignment:!0}),this;for(;"}"!==c.tokens.next.id;){if(o=c.tokens.next.value,!c.tokens.next.identifier||","!==L().id&&"}"!==L().id)if(":"===A().id||"get"!==o&&"set"!==o){if("*"===c.tokens.next.value&&"(punctuator)"===c.tokens.next.type?(c.inES6()||b("W104",c.tokens.next,"generator functions","6"),j("*"),s=!0):s=!1,"["===c.tokens.next.id)n=Fe(),c.nameStack.set(n);else if(c.nameStack.set(c.tokens.next),n=ge(),Ve(a,n,c.tokens.next),"string"!=typeof n)break;"("===c.tokens.next.value?(c.inES6()||b("W104",c.tokens.curr,"concise methods","6"),Ee({type:s?"generator":null})):(j(":"),G(10))}else j(o),c.inES5()||_("E034"),(n=ge())||c.inES6()||_("E035"),n&&Ie(o,a,n,c.tokens.curr),i=c.tokens.next,r=(t=Ee())["(params)"],"get"===o&&n&&r?b("W076",i,r[0],n):"set"===o&&n&&1!==t["(metrics)"].arity&&b("W077",i,n);else c.inES6()||b("W104",c.tokens.next,"object short notation","6"),Ve(a,n=ge(!0),c.tokens.next),G(10);if(pe(n),","!==c.tokens.next.id){c.option.trailingcomma&&c.inES5()&&E("W140",c.tokens.curr.line,c.tokens.curr.character);break}F({allowTrailing:!0,property:!0}),","===c.tokens.next.id?b("W070",c.tokens.curr):"}"!==c.tokens.next.id||c.inES5()||b("W070",c.tokens.curr)}return e&&($e-=c.option.indent),j("}",this),We(a),this},e.fud=function(){_("E036",c.tokens.curr)}}(R("{")),U("const",function(e){return Oe("const",this,e)}).exps=!0,U("let",function(e){return Oe("let",this,e)}).exps=!0,U("var",function(e){var t,n,i,s=e&&e.prefix,a=e&&e.inexport;for(this.first=[];;){var u=[];r.contains(["{","["],c.tokens.next.value)?(t=Le(),n=!1):(t=[{id:oe(),token:c.tokens.curr}],n=!0),c.option.varstmt&&b("W132",this),this.first=this.first.concat(u);for(var l in t)t.hasOwnProperty(l)&&(l=t[l],c.funct["(global)"]&&!c.impliedClosure()&&(!1===Ye[l.id]?b("W079",l.token,l.id):!1===c.option.futurehostile&&(!c.inES5()&&!1===o.ecmaIdentifiers[5][l.id]||!c.inES6()&&!1===o.ecmaIdentifiers[6][l.id])&&b("W129",l.token,l.id)),l.id&&(c.funct["(scope)"].addlabel(l.id,{type:"var",token:l.token}),n&&a&&c.funct["(scope)"].setExported(l.id,l.token),u.push(l.token)));if("="===c.tokens.next.id){c.nameStack.set(c.tokens.curr),j("="),"="===A(0).id&&c.tokens.next.identifier&&((s||c.funct["(params)"])&&-1!==c.funct["(params)"].indexOf(c.tokens.next.value)||b("W120",c.tokens.next,c.tokens.next.value));var f=c.tokens.prev;!(i=G(s?120:10))||s||c.funct["(loopage)"]||"undefined"!==i.type||b("W080",f,f.value),n?t[0].first=i:Te(u,i)}if(","!==c.tokens.next.id)break;F()}return this}).exps=!0,B("class",function(e){return Ge.call(this,e,!0)}),B("function",function(e){var t=e&&e.inexport,n=!1;"*"===c.tokens.next.value&&(j("*"),c.inES6(!0)?n=!0:b("W119",c.tokens.curr,"function*","6")),He&&b("W082",c.tokens.curr);var r=ie();return c.funct["(scope)"].addlabel(r,{type:"function",token:c.tokens.curr}),void 0===r?b("W025"):t&&c.funct["(scope)"].setExported(r,c.tokens.prev),Ee({name:r,statement:this,type:n?"generator":null,ignoreLoopFunc:He}),"("===c.tokens.next.id&&c.tokens.next.line===c.tokens.curr.line&&_("E039"),this}),D("function",function(){var e=!1;return"*"===c.tokens.next.value&&(c.inES6()||b("W119",c.tokens.curr,"function*","6"),j("*"),e=!0),Ee({name:ie(),type:e?"generator":null}),this}),B("if",function(){var e=c.tokens.next;we(),c.condition=!0,j("(");var t=G(0);t||y("E041",this),Se(t);var n=null;c.option.forin&&c.forinifcheckneeded&&(c.forinifcheckneeded=!1,n=c.forinifchecks[c.forinifchecks.length-1],"(punctuator)"===t.type&&"!"===t.value?n.type="(negative)":n.type="(positive)"),j(")",e),c.condition=!1;var r=fe(!0,!0);return n&&"(negative)"===n.type&&r&&r[0]&&"(identifier)"===r[0].type&&"continue"===r[0].value&&(n.type="(negative-with-continue)"),"else"===c.tokens.next.id&&(j("else"),"if"===c.tokens.next.id||"switch"===c.tokens.next.id?ue():fe(!0,!0)),this}),B("try",function(){var e;for(fe(!0);"catch"===c.tokens.next.id;)we(),e&&!c.inMoz()&&b("W118",c.tokens.next,"multiple catch blocks"),function(){if(j("catch"),j("("),c.funct["(scope)"].stack("catchparams"),Pe(c.tokens.next,["[","{"])){var e=Le();r.each(e,function(e){e.id&&c.funct["(scope)"].addParam(e.id,e,"exception")})}else"(identifier)"!==c.tokens.next.type?b("E030",c.tokens.next,c.tokens.next.value):c.funct["(scope)"].addParam(oe(),c.tokens.curr,"exception");"if"===c.tokens.next.value&&(c.inMoz()||b("W118",c.tokens.curr,"catch filter"),j("if"),G(0)),j(")"),fe(!1),c.funct["(scope)"].unstack()}(),e=!0;return"finally"===c.tokens.next.id?(j("finally"),void fe(!0)):(e||_("E021",c.tokens.next,"catch",c.tokens.next.value),this)}),B("while",function(){var e=c.tokens.next;return c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,we(),j("("),Se(G(0)),j(")",e),fe(!0,!0),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1,this}).labelled=!0,B("with",function(){var e=c.tokens.next;return c.isStrict()?_("E010",c.tokens.curr):c.option.withstmt||b("W085",c.tokens.curr),j("("),G(0),j(")",e),fe(!0,!0),this}),B("switch",function(){var e=c.tokens.next,t=!1,n=!1;for(c.funct["(breakage)"]+=1,j("("),Se(G(0)),j(")",e),e=c.tokens.next,j("{"),c.tokens.next.from===$e&&(n=!0),n||($e+=c.option.indent),this.cases=[];;)switch(c.tokens.next.id){case"case":switch(c.funct["(verb)"]){case"yield":case"break":case"case":case"continue":case"return":case"switch":case"throw":break;default:c.tokens.curr.caseFallsThrough||b("W086",c.tokens.curr,"case")}j("case"),this.cases.push(G(0)),we(),t=!0,j(":"),c.funct["(verb)"]="case";break;case"default":switch(c.funct["(verb)"]){case"yield":case"break":case"continue":case"return":case"throw":break;default:this.cases.length&&(c.tokens.curr.caseFallsThrough||b("W086",c.tokens.curr,"default"))}j("default"),t=!0,j(":");break;case"}":return n||($e-=c.option.indent),j("}",e),c.funct["(breakage)"]-=1,void(c.funct["(verb)"]=void 0);case"(end)":return void _("E023",c.tokens.next,"}");default:if($e+=c.option.indent,t)switch(c.tokens.curr.id){case",":return void _("E040");case":":t=!1,ce();break;default:return void _("E025",c.tokens.curr)}else{if(":"!==c.tokens.curr.id)return void _("E021",c.tokens.next,"case",c.tokens.next.value);j(":"),_("E024",c.tokens.curr,":"),ce()}$e-=c.option.indent}return this}).labelled=!0,U("debugger",function(){return c.option.debug||b("W087",this),this}).exps=!0,function(){var e=U("do",function(){c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,we(),this.first=fe(!0,!0),j("while");var e=c.tokens.next;return j("("),Se(G(0)),j(")",e),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1,this});e.labelled=!0,e.exps=!0}(),B("for",function(){var e,t=c.tokens.next,n=!1,i=null;"each"===t.value&&(i=t,j("each"),c.inMoz()||b("W118",c.tokens.curr,"for each")),we(),j("(");var o,s,a,u,l,f,p=0,h=["in","of"],d=0;Pe(c.tokens.next,["{","["])&&++d;do{if(o=A(p),++p,Pe(o,["{","["])?++d:Pe(o,["}","]"])&&--d,d<0)break;0===d&&(!s&&Re(o,",")?s=o:!a&&Re(o,"=")&&(a=o))}while(d>0||!r.contains(h,o.value)&&";"!==o.value&&"(end)"!==o.type);if(r.contains(h,o.value)){if("of"===o.value?(u=20,c.inES6()||b("W104",o,"for of","6")):u=0,a&&_("W133",s,o.value,"initializer is forbidden"),s&&_("W133",s,o.value,"more than one ForBinding"),"var"===c.tokens.next.id)j("var"),c.tokens.curr.fud({prefix:!0});else if("let"===c.tokens.next.id||"const"===c.tokens.next.id)j(c.tokens.next.id),n=!0,c.funct["(scope)"].stack(),c.tokens.curr.fud({prefix:!0});else{l=[];do{Pe(c.tokens.next,["{","["])?Le({assignment:!0}).forEach(function(e){this.push(e.token)},l):("(identifier)"===(f=G(120)).type&&l.push(f),Q(f,o)),Re(c.tokens.next,"=")&&(j("="),G(120)),Re(c.tokens.next,",")&&j(",")}while(c.tokens.next!==o);a||s||l.forEach(function(e){c.funct["(scope)"].has(e.value)||b("W088",e,e.value)})}if(j(o.value),G(u),j(")",t),"in"===o.value&&c.option.forin&&(c.forinifcheckneeded=!0,void 0===c.forinifchecks&&(c.forinifchecks=[]),c.forinifchecks.push({type:"(none)"})),c.funct["(breakage)"]+=1,c.funct["(loopage)"]+=1,e=fe(!0,!0),"in"===o.value&&c.option.forin){if(c.forinifchecks&&c.forinifchecks.length>0){var v=c.forinifchecks.pop();(e&&e.length>0&&("object"!=typeof e[0]||"if"!==e[0].value)||"(positive)"===v.type&&e.length>1||"(negative)"===v.type)&&b("W089",this)}c.forinifcheckneeded=!1}c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1}else{if(i&&_("E045",i),";"!==c.tokens.next.id)if("var"===c.tokens.next.id)j("var"),c.tokens.curr.fud();else if("let"===c.tokens.next.id)j("let"),n=!0,c.funct["(scope)"].stack(),c.tokens.curr.fud();else for(;G(0,"for"),","===c.tokens.next.id;)F();if(V(c.tokens.curr),j(";"),c.funct["(loopage)"]+=1,";"!==c.tokens.next.id&&Se(G(0)),V(c.tokens.curr),j(";"),";"===c.tokens.next.id&&_("E021",c.tokens.next,")",";"),")"!==c.tokens.next.id)for(;G(0,"for"),","===c.tokens.next.id;)F();j(")",t),c.funct["(breakage)"]+=1,fe(!0,!0),c.funct["(breakage)"]-=1,c.funct["(loopage)"]-=1}return n&&c.funct["(scope)"].unstack(),this}).labelled=!0,U("break",function(){var e=c.tokens.next.value;return c.option.asi||V(this),";"===c.tokens.next.id||c.tokens.next.reach||c.tokens.curr.line!==C(c.tokens.next)?0===c.funct["(breakage)"]&&b("W052",c.tokens.next,this.value):(c.funct["(scope)"].funct.hasBreakLabel(e)||b("W090",c.tokens.next,e),this.first=c.tokens.next,j()),se(this),this}).exps=!0,U("continue",function(){var e=c.tokens.next.value;return 0!==c.funct["(breakage)"]&&c.funct["(loopage)"]||b("W052",c.tokens.next,this.value),c.option.asi||V(this),";"===c.tokens.next.id||c.tokens.next.reach||c.tokens.curr.line===C(c.tokens.next)&&(c.funct["(scope)"].funct.hasBreakLabel(e)||b("W090",c.tokens.next,e),this.first=c.tokens.next,j()),se(this),this}).exps=!0,U("return",function(){return this.line===C(c.tokens.next)?";"===c.tokens.next.id||c.tokens.next.reach||(this.first=G(0),!this.first||"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)):"(punctuator)"===c.tokens.next.type&&["[","{","+","-"].indexOf(c.tokens.next.value)>-1&&V(this),se(this),this}).exps=!0,function(e){e.exps=!0,e.lbp=25,e.ltBoundary="after"}(D("yield",function(){if(c.inMoz())return at.call(this);var e=c.tokens.prev;!this.beginsStmt&&e.lbp>30&&!Pe(e,["("])&&_("E061",this),c.inES6(!0)&&!c.funct["(generator)"]?"(catch)"===c.funct["(name)"]&&c.funct["(context)"]["(generator)"]||_("E046",c.tokens.curr,"yield"):c.inES6()||b("W104",c.tokens.curr,"yield","6"),c.funct["(generator)"]="yielded";return"*"===c.tokens.next.value&&(!0,j("*")),O()||","===c.tokens.next.id||(c.tokens.next.nud?(M(c.tokens.curr,c.tokens.next),this.first=G(10),"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)):c.tokens.next.led&&","!==c.tokens.next.id&&_("W017",c.tokens.next)),this}));var at=function(){var e=c.tokens.prev;c.inES6(!0)&&!c.funct["(generator)"]&&("(catch)"===c.funct["(name)"]&&c.funct["(context)"]["(generator)"]||_("E046",c.tokens.curr,"yield")),c.funct["(generator)"]="yielded";var t=!1;return"*"===c.tokens.next.value&&(t=!0,j("*")),this.line===C(c.tokens.next)?((t||";"!==c.tokens.next.id&&!c.option.asi&&!c.tokens.next.reach&&c.tokens.next.nud)&&(M(c.tokens.curr,c.tokens.next),this.first=G(10),"(punctuator)"!==this.first.type||"="!==this.first.value||this.first.paren||c.option.boss||E("W093",this.first.line,this.first.character)),")"!==c.tokens.next.id&&(e.lbp>30||!e.assign&&!O()||"yield"===e.id)&&_("E050",this)):c.option.asi||V(this),this};U("throw",function(){return V(this),this.first=G(20),se(this),this}).exps=!0,U("import",function(){if(c.funct["(scope)"].block.isGlobal()||_("E053",c.tokens.curr,"Import"),c.inES6()||b("W119",c.tokens.curr,"import","6"),"(string)"===c.tokens.next.type)return j("(string)"),this;if(c.tokens.next.identifier){if(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"import",initialized:!0,token:c.tokens.curr}),","!==c.tokens.next.value)return j("from"),j("(string)"),this;j(",")}if("*"===c.tokens.next.id)j("*"),j("as"),c.tokens.next.identifier&&(this.name=oe(),c.funct["(scope)"].addlabel(this.name,{type:"import",initialized:!0,token:c.tokens.curr}));else for(j("{");;){if("}"===c.tokens.next.value){j("}");break}var e;if("default"===c.tokens.next.type?(e="default",j("default")):e=oe(),"as"===c.tokens.next.value&&(j("as"),e=oe()),c.funct["(scope)"].addlabel(e,{type:"import",initialized:!0,token:c.tokens.curr}),","!==c.tokens.next.value){if("}"===c.tokens.next.value){j("}");break}_("E024",c.tokens.next,c.tokens.next.value);break}j(",")}return j("from"),j("(string)"),this}).exps=!0,U("export",function(){var e,t,n=!0;if(c.inES6()||(b("W119",c.tokens.curr,"export","6"),n=!1),c.funct["(scope)"].block.isGlobal()||(_("E053",c.tokens.curr,"Export"),n=!1),"*"===c.tokens.next.value)return j("*"),j("from"),j("(string)"),this;if("default"===c.tokens.next.type){c.nameStack.set(c.tokens.next),j("default");var r=c.tokens.next.id;return"function"!==r&&"class"!==r||(this.block=!0),e=A(),G(10),t=e.value,this.block&&(c.funct["(scope)"].addlabel(t,{type:r,initialized:!0,token:e}),c.funct["(scope)"].setExported(t,e)),this}if("{"===c.tokens.next.value){j("{");for(var i=[];;){if(c.tokens.next.identifier||_("E030",c.tokens.next,c.tokens.next.value),j(),i.push(c.tokens.curr),"as"===c.tokens.next.value&&(j("as"),c.tokens.next.identifier||_("E030",c.tokens.next,c.tokens.next.value),j()),","!==c.tokens.next.value){if("}"===c.tokens.next.value){j("}");break}_("E024",c.tokens.next,c.tokens.next.value);break}j(",")}return"from"===c.tokens.next.value?(j("from"),j("(string)")):n&&i.forEach(function(e){c.funct["(scope)"].setExported(e.value,e)}),this}if("var"===c.tokens.next.id)j("var"),c.tokens.curr.fud({inexport:!0});else if("let"===c.tokens.next.id)j("let"),c.tokens.curr.fud({inexport:!0});else if("const"===c.tokens.next.id)j("const"),c.tokens.curr.fud({inexport:!0});else if("function"===c.tokens.next.id)this.block=!0,j("function"),c.syntax.function.fud({inexport:!0});else if("class"===c.tokens.next.id){this.block=!0,j("class");var o=c.tokens.next;c.syntax.class.fud(),c.funct["(scope)"].setExported(o.value,o)}else _("E024",c.tokens.next,c.tokens.next.value);return this}).exps=!0,H("abstract"),H("await",{es5:!0,moduleOnly:!0}),H("boolean"),H("byte"),H("char"),H("class",{es5:!0,nud:Ge}),H("double"),H("enum",{es5:!0}),H("export",{es5:!0}),H("extends",{es5:!0}),H("final"),H("float"),H("goto"),H("implements",{es5:!0,strictOnly:!0}),H("import",{es5:!0}),H("int"),H("interface",{es5:!0,strictOnly:!0}),H("long"),H("native"),H("package",{es5:!0,strictOnly:!0}),H("private",{es5:!0,strictOnly:!0}),H("protected",{es5:!0,strictOnly:!0}),H("public",{es5:!0,strictOnly:!0}),H("short"),H("static",{es5:!0,strictOnly:!0}),H("super",{es5:!0}),H("synchronized"),H("transient"),H("volatile");var ut=function(){var e,t,n,r=-1,i=0,o={};Pe(c.tokens.curr,["[","{"])&&(i+=1);do{if(n=-1===r?c.tokens.curr:e,e=-1===r?c.tokens.next:A(r),t=A(r+1),r+=1,Pe(e,["[","{"])?i+=1:Pe(e,["]","}"])&&(i-=1),1===i&&e.identifier&&"for"===e.value&&!Re(n,".")){o.isCompArray=!0,o.notJson=!0;break}if(0===i&&Pe(e,["}","]"])){if("="===t.value){o.isDestAssign=!0,o.notJson=!0;break}if("."===t.value){o.notJson=!0;break}}Re(e,";")&&(o.isBlock=!0,o.notJson=!0)}while(i>0&&"(end)"!==e.id);return o},ct=function(){function e(e){return 0!==n.variables.filter(function(t){if(t.value===e)return t.undef=!1,e}).length}function t(e){return 0===n.variables.filter(function(t){if(t.value===e&&!t.undef)return!0===t.unused&&(t.unused=!1),e}).length}var n,i=function(){this.mode="use",this.variables=[]},o=[];return{stack:function(){n=new i,o.push(n)},unstack:function(){n.variables.filter(function(e){e.unused&&b("W098",e.token,e.raw_text||e.value),e.undef&&c.funct["(scope)"].block.use(e.value,e.token)}),o.splice(-1,1),n=o[o.length-1]},setState:function(e){r.contains(["use","define","generate","filter"],e)&&(n.mode=e)},check:function(r){if(n)return n&&"use"===n.mode?(t(r)&&n.variables.push({funct:c.funct,token:c.tokens.curr,value:r,undef:!0,unused:!1}),!0):n&&"define"===n.mode?(e(r)||n.variables.push({funct:c.funct,token:c.tokens.curr,value:r,undef:!1,unused:!0}),!0):n&&"generate"===n.mode?(c.funct["(scope)"].block.use(r,c.tokens.curr),!0):!(!n||"filter"!==n.mode)&&(t(r)&&c.funct["(scope)"].block.use(r,c.tokens.curr),!0)}}},lt=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},ft=function(n,i,s){function u(e,t){e&&(Array.isArray(e)||"object"!=typeof e||(e=Object.keys(e)),e.forEach(t))}var l,f,d,v,m={},x={};i=r.clone(i),c.reset(),i&&i.scope?h.scope=i.scope:(h.errors=[],h.undefs=[],h.internals=[],h.blacklist={},h.scope="(main)"),g(Ye=Object.create(null),o.ecmaIdentifiers[3]),g(Ye,o.reservedVars),g(Ye,s||{}),qe=Object.create(null);var S=Object.create(null);if(i)for(u(i.predef||null,function(e){var t,n;"-"===e[0]?(t=e.slice(1),h.blacklist[t]=t,delete Ye[t]):(n=Object.getOwnPropertyDescriptor(i.predef,e),Ye[e]=!!n&&n.value)}),u(i.exported||null,function(e){S[e]=!0}),delete i.predef,delete i.exported,v=Object.keys(i),l=0;l0&&(s.implieds=a),et.length>0&&(s.urls=et),(o=c.funct["(scope)"].getUsedOrDefinedGlobals()).length>0&&(s.globals=o),n=1;n0&&(s.unused=u);for(i in Xe)if("number"==typeof Xe[i]){s.member=Xe;break}return s},ft.jshint=ft,ft}());"object"==typeof n&&n&&(n.JSHINT=h)},{"./lex.js":13,"./messages.js":14,"./options.js":16,"./reg.js":17,"./scope-manager.js":18,"./state.js":19,"./style.js":20,"./vars.js":21,"console-browserify":10,events:5,lodash:12}]},{},[]),JSHINT=e("jshint").JSHINT,"object"==typeof exports&&exports&&(exports.JSHINT=JSHINT)}(); \ No newline at end of file diff --git a/_server/CodeMirror/tern.js b/_server/CodeMirror/tern.js new file mode 100644 index 00000000..7e823c4b --- /dev/null +++ b/_server/CodeMirror/tern.js @@ -0,0 +1,4367 @@ +(function(root, mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(exports); + if (typeof define == "function" && define.amd) // AMD + return define(["exports"], mod); + mod((root.tern || (root.tern = {})).signal = {}); // Plain browser env +})(this, function(exports) { + + function on(type, f) { + var handlers = this._handlers || (this._handlers = Object.create(null)); + (handlers[type] || (handlers[type] = [])).push(f); + } + + function off(type, f) { + var arr = this._handlers && this._handlers[type]; + if (arr) for (var i = 0; i < arr.length; ++i) + if (arr[i] == f) { arr.splice(i, 1); break; } + } + + var noHandlers = []; + function getHandlers(emitter, type) { + var arr = emitter._handlers && emitter._handlers[type]; + return arr && arr.length ? arr.slice() : noHandlers; + } + + function signal(type, a1, a2, a3, a4) { + var arr = getHandlers(this, type); + for (var i = 0; i < arr.length; ++i) arr[i].call(this, a1, a2, a3, a4); + } + + function signalReturnFirst(type, a1, a2, a3, a4) { + var arr = getHandlers(this, type); + for (var i = 0; i < arr.length; ++i) { + var result = arr[i].call(this, a1, a2, a3, a4); + if (result) return result; + } + } + + function hasHandler(type) { + var arr = this._handlers && this._handlers[type]; + return arr && arr.length > 0 && arr; + } + + exports.mixin = function(obj) { + obj.on = on; obj.off = off; + obj.signal = signal; + obj.signalReturnFirst = signalReturnFirst; + obj.hasHandler = hasHandler; + return obj; + }; +}); +// The Tern server object + +// A server is a stateful object that manages the analysis for a +// project, and defines an interface for querying the code in the +// project. + +(function(root, mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(exports, require("./infer"), require("./signal"), + require("acorn"), require("acorn-walk")); + if (typeof define == "function" && define.amd) // AMD + return define(["exports", "./infer", "./signal", "acorn/dist/acorn", "acorn-walk/dist/walk"], mod); + mod(root.tern || (root.tern = {}), tern, tern.signal, acorn, acorn.walk); // Plain browser env +})(this, function(exports, infer, signal, acorn, walk) { + "use strict"; + + var plugins = Object.create(null); + exports.registerPlugin = function(name, init) { plugins[name] = init; }; + + var defaultOptions = exports.defaultOptions = { + debug: false, + async: false, + getFile: function(_f, c) { if (this.async) c(null, null); }, + normalizeFilename: function(name) { return name }, + defs: [], + plugins: {}, + fetchTimeout: 1000, + dependencyBudget: 20000, + reuseInstances: true, + stripCRs: false, + ecmaVersion: 9, + projectDir: "/", + parent: null + }; + + var queryTypes = { + completions: { + takesFile: true, + run: findCompletions + }, + properties: { + run: findProperties + }, + type: { + takesFile: true, + run: findTypeAt + }, + documentation: { + takesFile: true, + run: findDocs + }, + definition: { + takesFile: true, + run: findDef + }, + refs: { + takesFile: true, + fullFile: true, + run: findRefs + }, + rename: { + takesFile: true, + fullFile: true, + run: buildRename + }, + files: { + run: listFiles + } + }; + + exports.defineQueryType = function(name, desc) { queryTypes[name] = desc; }; + + function File(name, parent) { + this.name = name; + this.parent = parent; + this.scope = this.text = this.ast = this.lineOffsets = null; + } + File.prototype.asLineChar = function(pos) { return asLineChar(this, pos); }; + + function parseFile(srv, file) { + var options = { + directSourceFile: file, + allowReturnOutsideFunction: true, + allowImportExportEverywhere: true, + ecmaVersion: srv.options.ecmaVersion, + allowHashBang: true + }; + var text = srv.signalReturnFirst("preParse", file.text, options) || file.text; + var ast = infer.parse(text, options); + srv.signal("postParse", ast, text); + return ast; + } + + var astral = /[\uD800-\uDBFF]/g; + + function updateText(file, text, srv) { + file.text = srv.options.stripCRs ? text.replace(/\r\n/g, "\n") : text; + file.hasAstral = astral.test(file.text); + infer.withContext(srv.cx, function() { + file.ast = parseFile(srv, file); + }); + file.lineOffsets = null; + } + + var Server = exports.Server = function(options) { + this.cx = null; + this.options = options || {}; + for (var o in defaultOptions) if (!options.hasOwnProperty(o)) + options[o] = defaultOptions[o]; + + this.projectDir = options.projectDir.replace(/\\/g, "/"); + if (!/\/$/.test(this.projectDir)) this.projectDir += "/"; + + this.parent = options.parent; + this.handlers = Object.create(null); + this.files = []; + this.fileMap = Object.create(null); + this.needsPurge = []; + this.budgets = Object.create(null); + this.uses = 0; + this.pending = 0; + this.asyncError = null; + this.mod = {}; + + this.defs = options.defs.slice(0); + this.plugins = Object.create(null); + for (var plugin in options.plugins) if (options.plugins.hasOwnProperty(plugin)) + this.loadPlugin(plugin, options.plugins[plugin]); + + this.reset(); + }; + Server.prototype = signal.mixin({ + addFile: function(name, /*optional*/ text, parent) { + // Don't crash when sloppy plugins pass non-existent parent ids + if (parent && !(parent in this.fileMap)) parent = null; + if (!(name in this.fileMap)) + name = this.normalizeFilename(name); + ensureFile(this, name, parent, text); + }, + delFile: function(name) { + var file = this.findFile(name); + if (file) { + this.needsPurge.push(file.name); + for (var i = 0; i < this.files.length; i++) { + if (this.files[i] == file) this.files.splice(i--, 1); + else if (this.files[i].parent == name) this.files[i].parent = null; + } + delete this.fileMap[file.name]; + } + }, + reset: function() { + this.signal("reset"); + this.cx = new infer.Context(this.defs, this); + this.uses = 0; + this.budgets = Object.create(null); + for (var i = 0; i < this.files.length; ++i) { + var file = this.files[i]; + if (file.scope) { + infer.clearScopes(file.ast); + file.scope = null; + } + } + this.signal("postReset"); + }, + + request: function(doc, c) { + var inv = invalidDoc(doc); + if (inv) return c(inv); + + var self = this; + doRequest(this, doc, function(err, data) { + c(err, data); + if (self.uses > 40) { + self.reset(); + analyzeAll(self, null, function(){}); + } + }); + }, + + findFile: function(name) { + return this.fileMap[this.normalizeFilename(name)]; + }, + + flush: function(c) { + var cx = this.cx; + analyzeAll(this, null, function(err) { + if (err) return c(err); + infer.withContext(cx, c); + }); + }, + + startAsyncAction: function() { + ++this.pending; + }, + finishAsyncAction: function(err) { + if (err) this.asyncError = err; + if (--this.pending === 0) this.signal("everythingFetched"); + }, + + addDefs: function(defs, toFront) { + if (toFront) this.defs.unshift(defs); + else this.defs.push(defs); + + if (this.cx) this.reset(); + }, + + deleteDefs: function(name) { + for (var i = 0; i < this.defs.length; i++) if (this.defs[i]["!name"] == name) { + this.defs.splice(i, 1); + if (this.cx) this.reset(); + return; + } + }, + + loadPlugin: function(name, options) { + if (arguments.length == 1) options = this.options.plugins[name] || true; + if (name in this.plugins || !(name in plugins) || !options) return; + this.plugins[name] = true; + var init = plugins[name](this, options); + + // This is for backwards-compatibilty. Don't rely on it -- use addDef and on directly + if (!init) return; + if (init.defs) this.addDefs(init.defs, init.loadFirst); + if (init.passes) for (var type in init.passes) if (init.passes.hasOwnProperty(type)) + this.on(type, init.passes[type]); + }, + + normalizeFilename: function(name) { + var norm = this.options.normalizeFilename(name).replace(/\\/g, "/"); + if (norm.indexOf(this.projectDir) == 0) norm = norm.slice(this.projectDir.length); + return norm; + } + }); + + function doRequest(srv, doc, c) { + if (doc.query && !queryTypes.hasOwnProperty(doc.query.type)) + return c("No query type '" + doc.query.type + "' defined"); + + var query = doc.query; + // Respond as soon as possible when this just uploads files + if (!query) c(null, {}); + + var files = doc.files || []; + if (files.length) ++srv.uses; + for (var i = 0; i < files.length; ++i) { + var file = files[i]; + file.name = srv.normalizeFilename(file.name); + if (file.type == "delete") + srv.delFile(file.name); + else + ensureFile(srv, file.name, null, file.type == "full" ? file.text : null); + } + + var timeBudget = typeof doc.timeout == "number" ? [doc.timeout] : null; + if (!query) { + analyzeAll(srv, timeBudget, function(){}); + return; + } + + var queryType = queryTypes[query.type]; + if (queryType.takesFile) { + if (typeof query.file != "string") return c(".query.file must be a string"); + if (!/^#/.test(query.file)) ensureFile(srv, query.file, null); + } + + analyzeAll(srv, timeBudget, function(err) { + if (err) return c(err); + var file = queryType.takesFile && resolveFile(srv, files, query.file); + if (queryType.fullFile && file.type == "part") + return c("Can't run a " + query.type + " query on a file fragment"); + + infer.resetGuessing(); + infer.withContext(srv.cx, function() { + var result, run = function() { result = queryType.run(srv, query, file); }; + try { + if (timeBudget) infer.withTimeout(timeBudget[0], run); + else run(); + } catch (e) { + if (srv.options.debug && e.name != "TernError") console.error(e.stack); + return c(e); + } + c(null, result); + }); + }); + } + + function analyzeFile(srv, file) { + infer.withContext(srv.cx, function() { + file.scope = srv.cx.topScope; + srv.signal("beforeLoad", file); + infer.analyze(file.ast, file.name, file.scope); + srv.signal("afterLoad", file); + }); + return file; + } + + function ensureFile(srv, name, parent, text) { + var known = srv.findFile(name); + if (known) { + if (text != null) { + if (known.scope) { + srv.needsPurge.push(name); + infer.clearScopes(known.ast); + known.scope = null; + } + updateText(known, text, srv); + } + if (parentDepth(srv, known.parent) > parentDepth(srv, parent)) { + known.parent = parent; + if (known.excluded) known.excluded = null; + } + return; + } + + var file = new File(name, parent); + srv.files.push(file); + srv.fileMap[name] = file; + if (text != null) { + updateText(file, text, srv); + } else if (srv.options.async) { + srv.startAsyncAction(); + srv.options.getFile(name, function(err, text) { + updateText(file, text || "", srv); + srv.finishAsyncAction(err); + }); + } else { + updateText(file, srv.options.getFile(name) || "", srv); + } + } + + function fetchAll(srv, c) { + var done = true, returned = false; + srv.files.forEach(function(file) { + if (file.text != null) return; + if (srv.options.async) { + done = false; + srv.options.getFile(file.name, function(err, text) { + if (err && !returned) { returned = true; return c(err); } + updateText(file, text || "", srv); + fetchAll(srv, c); + }); + } else { + try { + updateText(file, srv.options.getFile(file.name) || "", srv); + } catch (e) { return c(e); } + } + }); + if (done) c(); + } + + function waitOnFetch(srv, timeBudget, c) { + var done = function() { + srv.off("everythingFetched", done); + clearTimeout(timeout); + analyzeAll(srv, timeBudget, c); + }; + srv.on("everythingFetched", done); + var timeout = setTimeout(done, srv.options.fetchTimeout); + } + + function analyzeAll(srv, timeBudget, c) { + if (srv.pending) return waitOnFetch(srv, timeBudget, c); + + var e = srv.fetchError; + if (e) { srv.fetchError = null; return c(e); } + + if (srv.needsPurge.length > 0) infer.withContext(srv.cx, function() { + infer.purge(srv.needsPurge); + srv.needsPurge.length = 0; + }); + + var done = true; + // The second inner loop might add new files. The outer loop keeps + // repeating both inner loops until all files have been looked at. + for (var i = 0; i < srv.files.length;) { + var toAnalyze = []; + for (; i < srv.files.length; ++i) { + var file = srv.files[i]; + if (file.text == null) done = false; + else if (file.scope == null && !file.excluded) toAnalyze.push(file); + } + toAnalyze.sort(function(a, b) { + return parentDepth(srv, a.parent) - parentDepth(srv, b.parent); + }); + for (var j = 0; j < toAnalyze.length; j++) { + var file = toAnalyze[j]; + if (file.parent && !chargeOnBudget(srv, file)) { + file.excluded = true; + } else if (timeBudget) { + var startTime = +new Date; + try { + infer.withTimeout(timeBudget[0], function() { analyzeFile(srv, file); }); + } catch(e) { + if (e instanceof infer.TimedOut) return c(e); + else throw e; + } + timeBudget[0] -= +new Date - startTime; + } else { + analyzeFile(srv, file); + } + } + } + if (done) c(); + else waitOnFetch(srv, timeBudget, c); + } + + function firstLine(str) { + var end = str.indexOf("\n"); + if (end < 0) return str; + return str.slice(0, end); + } + + function findMatchingPosition(line, file, near) { + var pos = Math.max(0, near - 500), closest = null; + if (!/^\s*$/.test(line)) for (;;) { + var found = file.indexOf(line, pos); + if (found < 0 || found > near + 500) break; + if (closest == null || Math.abs(closest - near) > Math.abs(found - near)) + closest = found; + pos = found + line.length; + } + return closest; + } + + function scopeDepth(s) { + for (var i = 0; s; ++i, s = s.prev) {} + return i; + } + + function ternError(msg) { + var err = new Error(msg); + err.name = "TernError"; + return err; + } + + function resolveFile(srv, localFiles, name) { + var isRef = name.match(/^#(\d+)$/); + if (!isRef) return srv.findFile(name); + + var file = localFiles[isRef[1]]; + if (!file || file.type == "delete") throw ternError("Reference to unknown file " + name); + if (file.type == "full") return srv.fileMap[file.name]; + + // This is a partial file + + var realFile = file.backing = srv.fileMap[file.name]; + var offset = resolvePos(realFile, file.offsetLines == null ? file.offset : {line: file.offsetLines, ch: 0}, true); + var line = firstLine(file.text); + var foundPos = findMatchingPosition(line, realFile.text, offset); + var pos = foundPos == null ? Math.max(0, realFile.text.lastIndexOf("\n", offset)) : foundPos; + var inObject, atFunction; + + infer.withContext(srv.cx, function() { + infer.purge(file.name, pos, pos + file.text.length); + + var text = file.text, m; + if (m = text.match(/(?:"([^"]*)"|([\w$]+))\s*:\s*function\b/)) { + var objNode = walk.findNodeAround(file.backing.ast, pos, "ObjectExpression"); + if (objNode && objNode.node.objType) + inObject = {type: objNode.node.objType, prop: m[2] || m[1]}; + } + if (foundPos && (m = line.match(/^(.*?)\bfunction\b/))) { + var cut = m[1].length, white = ""; + for (var i = 0; i < cut; ++i) white += " "; + file.text = white + text.slice(cut); + atFunction = true; + } + + var scopeStart = infer.scopeAt(realFile.ast, pos, realFile.scope); + var scopeEnd = infer.scopeAt(realFile.ast, pos + text.length, realFile.scope); + var scope = file.scope = scopeDepth(scopeStart) < scopeDepth(scopeEnd) ? scopeEnd : scopeStart; + file.ast = parseFile(srv, file); + infer.analyze(file.ast, file.name, scope); + + // This is a kludge to tie together the function types (if any) + // outside and inside of the fragment, so that arguments and + // return values have some information known about them. + tieTogether: { + if (inObject || atFunction) { + var newInner = infer.scopeAt(file.ast, line.length, scopeStart); + if (!newInner.fnType) break tieTogether; + if (inObject) { + var prop = inObject.type.getProp(inObject.prop); + prop.addType(newInner.fnType); + } else if (atFunction) { + var inner = infer.scopeAt(realFile.ast, pos + line.length, realFile.scope); + if (inner == scopeStart || !inner.fnType) break tieTogether; + var fOld = inner.fnType, fNew = newInner.fnType; + if (!fNew || (fNew.name != fOld.name && fOld.name)) break tieTogether; + for (var i = 0, e = Math.min(fOld.args.length, fNew.args.length); i < e; ++i) + fOld.args[i].propagate(fNew.args[i]); + fOld.self.propagate(fNew.self); + fNew.retval.propagate(fOld.retval); + } + } + } + }); + return file; + } + + // Budget management + + function astSize(node) { + var size = 0; + walk.simple(node, {Expression: function() { ++size; }}); + return size; + } + + function parentDepth(srv, parent) { + var depth = 0; + while (parent) { + parent = srv.fileMap[parent].parent; + ++depth; + } + return depth; + } + + function budgetName(srv, file) { + for (;;) { + var parent = srv.fileMap[file.parent]; + if (!parent.parent) break; + file = parent; + } + return file.name; + } + + function chargeOnBudget(srv, file) { + var bName = budgetName(srv, file); + var size = astSize(file.ast); + var known = srv.budgets[bName]; + if (known == null) + known = srv.budgets[bName] = srv.options.dependencyBudget; + if (known < size) return false; + srv.budgets[bName] = known - size; + return true; + } + + // Query helpers + + function isPosition(val) { + return typeof val == "number" || typeof val == "object" && + typeof val.line == "number" && typeof val.ch == "number"; + } + + // Baseline query document validation + function invalidDoc(doc) { + if (doc.query) { + if (typeof doc.query.type != "string") return ".query.type must be a string"; + if (doc.query.start && !isPosition(doc.query.start)) return ".query.start must be a position"; + if (doc.query.end && !isPosition(doc.query.end)) return ".query.end must be a position"; + } + if (doc.files) { + if (!Array.isArray(doc.files)) return "Files property must be an array"; + for (var i = 0; i < doc.files.length; ++i) { + var file = doc.files[i]; + if (typeof file != "object") return ".files[n] must be objects"; + else if (typeof file.name != "string") return ".files[n].name must be a string"; + else if (file.type == "delete") continue; + else if (typeof file.text != "string") return ".files[n].text must be a string"; + else if (file.type == "part") { + if (!isPosition(file.offset) && typeof file.offsetLines != "number") + return ".files[n].offset must be a position"; + } else if (file.type != "full") return ".files[n].type must be \"full\" or \"part\""; + } + } + } + + var offsetSkipLines = 25; + + function forwardCharacters(file, start, chars) { + var pos = start + chars, m; + if (file.hasAstral) { + astral.lastIndex = start; + while ((m = astral.exec(file.text)) && m.index < pos) pos++; + } + return pos; + } + + function findLineStart(file, line) { + var text = file.text, offsets = file.lineOffsets || (file.lineOffsets = [0]); + var pos = 0, curLine = 0; + var storePos = Math.min(Math.floor(line / offsetSkipLines), offsets.length - 1); + var pos = offsets[storePos], curLine = storePos * offsetSkipLines; + + while (curLine < line) { + ++curLine; + pos = text.indexOf("\n", pos) + 1; + if (pos === 0) return null; + if (curLine % offsetSkipLines === 0) offsets.push(pos); + } + return pos; + } + + var resolvePos = exports.resolvePos = function(file, pos, tolerant) { + if (typeof pos != "number") { + var lineStart = findLineStart(file, pos.line); + if (lineStart == null) { + if (tolerant) pos = file.text.length; + else throw ternError("File doesn't contain a line " + pos.line); + } else { + pos = forwardCharacters(file, lineStart, pos.ch); + } + } else { + pos = forwardCharacters(file, 0, pos); + } + if (pos > file.text.length) { + if (tolerant) pos = file.text.length; + else throw ternError("Position " + pos + " is outside of file."); + } + return pos; + }; + + function charDistanceBetween(file, start, end) { + var diff = end - start, m; + if (file.hasAstral) { + astral.lastIndex = start; + while ((m = astral.exec(file.text)) && m.index < end) diff--; + } + return diff; + } + + function asLineChar(file, pos) { + if (!file) return {line: 0, ch: 0}; + var offsets = file.lineOffsets || (file.lineOffsets = [0]); + var text = file.text, line, lineStart; + for (var i = offsets.length - 1; i >= 0; --i) if (offsets[i] <= pos) { + line = i * offsetSkipLines; + lineStart = offsets[i]; + } + for (;;) { + var eol = text.indexOf("\n", lineStart); + if (eol >= pos || eol < 0) break; + lineStart = eol + 1; + ++line; + } + return {line: line, ch: charDistanceBetween(file, lineStart, pos)}; + } + + var outputPos = exports.outputPos = function(query, file, pos) { + if (query.lineCharPositions) { + var out = asLineChar(file, pos); + if (file.type == "part") + out.line += file.offsetLines != null ? file.offsetLines : asLineChar(file.backing, file.offset).line; + return out; + } else { + return charDistanceBetween(file, 0, pos) + (file.type == "part" ? file.offset : 0); + } + }; + + // Delete empty fields from result objects + function clean(obj) { + for (var prop in obj) if (obj[prop] == null) delete obj[prop]; + return obj; + } + function maybeSet(obj, prop, val) { + if (val != null) obj[prop] = val; + } + + // Built-in query types + + function compareCompletions(a, b) { + if (typeof a != "string") { a = a.name; b = b.name; } + var aUp = /^[A-Z]/.test(a), bUp = /^[A-Z]/.test(b); + if (aUp == bUp) return a < b ? -1 : a == b ? 0 : 1; + else return aUp ? 1 : -1; + } + + function isStringAround(node, start, end) { + return node.type == "Literal" && typeof node.value == "string" && + node.start == start - 1 && node.end <= end + 1; + } + + function pointInProp(objNode, point) { + for (var i = 0; i < objNode.properties.length; i++) { + var curProp = objNode.properties[i]; + if (curProp.key.start <= point && curProp.key.end >= point) + return curProp; + } + } + + var jsKeywords = ("break do instanceof typeof case else new var " + + "catch finally return void continue for switch while debugger " + + "function this with default if throw delete in try").split(" "); + var jsKeywordsES6 = jsKeywords.concat("export class extends const super yield import let static".split(" ")); + + var addCompletion = exports.addCompletion = function(query, completions, name, aval, depth) { + var typeInfo = query.types || query.docs || query.urls || query.origins; + var wrapAsObjs = typeInfo || query.depths; + + for (var i = 0; i < completions.length; ++i) { + var c = completions[i]; + if ((wrapAsObjs ? c.name : c) == name) return; + } + var rec = wrapAsObjs ? {name: name} : name; + completions.push(rec); + + if (aval && typeInfo) { + infer.resetGuessing(); + var type = aval.getType(); + rec.guess = infer.didGuess(); + if (query.types) + rec.type = infer.toString(aval); + if (query.docs) + maybeSet(rec, "doc", parseDoc(query, aval.doc || type && type.doc)); + if (query.urls) + maybeSet(rec, "url", aval.url || type && type.url); + if (query.origins) + maybeSet(rec, "origin", aval.origin || type && type.origin); + } + if (query.depths) rec.depth = depth || 0; + return rec; + }; + + function findCompletions(srv, query, file) { + if (query.end == null) throw ternError("missing .query.end field"); + var fromPlugin = srv.signalReturnFirst("completion", file, query); + if (fromPlugin) return fromPlugin; + + var wordStart = resolvePos(file, query.end), wordEnd = wordStart, text = file.text; + while (wordStart && acorn.isIdentifierChar(text.charCodeAt(wordStart - 1))) --wordStart; + if (query.expandWordForward !== false) + while (wordEnd < text.length && acorn.isIdentifierChar(text.charCodeAt(wordEnd))) ++wordEnd; + var word = text.slice(wordStart, wordEnd), completions = [], ignoreObj; + if (query.caseInsensitive) word = word.toLowerCase(); + + function gather(prop, obj, depth, addInfo) { + // 'hasOwnProperty' and such are usually just noise, leave them + // out when no prefix is provided. + if ((objLit || query.omitObjectPrototype !== false) && obj == srv.cx.protos.Object && !word) return; + if (query.filter !== false && word && + (query.caseInsensitive ? prop.toLowerCase() : prop).indexOf(word) !== 0) return; + if (ignoreObj && ignoreObj.props[prop]) return; + var result = addCompletion(query, completions, prop, obj && obj.props[prop], depth); + if (addInfo && result && typeof result != "string") addInfo(result); + } + + var hookname, prop, objType, isKey; + + var exprAt = infer.findExpressionAround(file.ast, null, wordStart, file.scope); + var memberExpr, objLit; + // Decide whether this is an object property, either in a member + // expression or an object literal. + if (exprAt) { + var exprNode = exprAt.node; + + if (query.inLiteral === false && exprNode.type === "Literal" && + (typeof exprNode.value === 'string' || exprNode.regex)) + return { + start: outputPos(query, file, wordStart), + end: outputPos(query, file, wordEnd), + completions: [] + }; + + if (exprNode.type == "MemberExpression" && exprNode.object.end < wordStart) { + memberExpr = exprAt; + } else if (isStringAround(exprNode, wordStart, wordEnd)) { + var parent = infer.parentNode(exprNode, file.ast); + if (parent.type == "MemberExpression" && parent.property == exprNode) + memberExpr = {node: parent, state: exprAt.state}; + } else if (exprNode.type == "ObjectExpression") { + var objProp = pointInProp(exprNode, wordEnd); + if (objProp) { + objLit = exprAt; + prop = isKey = objProp.key.name || objProp.key.value; + } else if (!word && !/:\s*$/.test(file.text.slice(0, wordStart))) { + objLit = exprAt; + prop = isKey = true; + } + } + } + + if (objLit) { + // Since we can't use the type of the literal itself to complete + // its properties (it doesn't contain the information we need), + // we have to try asking the surrounding expression for type info. + objType = infer.typeFromContext(file.ast, objLit); + ignoreObj = objLit.node.objType; + } else if (memberExpr) { + prop = memberExpr.node.property; + prop = prop.type == "Literal" ? prop.value.slice(1) : prop.name; + memberExpr.node = memberExpr.node.object; + objType = infer.expressionType(memberExpr); + } else if (text.charAt(wordStart - 1) == ".") { + var pathStart = wordStart - 1; + while (pathStart && (text.charAt(pathStart - 1) == "." || acorn.isIdentifierChar(text.charCodeAt(pathStart - 1)))) pathStart--; + var path = text.slice(pathStart, wordStart - 1); + if (path) { + objType = infer.def.parsePath(path, file.scope).getObjType(); + prop = word; + } + } + + if (prop != null) { + srv.cx.completingProperty = prop; + + if (objType) infer.forAllPropertiesOf(objType, gather); + + if (!completions.length && query.guess !== false && objType && objType.guessProperties) + objType.guessProperties(function(p, o, d) {if (p != prop && p != "✖" && p != "") gather(p, o, d);}); + if (!completions.length && word.length >= 2 && query.guess !== false) + for (var prop in srv.cx.props) gather(prop, srv.cx.props[prop][0], 0); + hookname = "memberCompletion"; + } else { + infer.forAllLocalsAt(file.ast, wordStart, file.scope, gather); + if (query.includeKeywords) { + (srv.options.ecmaVersion >= 6 ? jsKeywordsES6 : jsKeywords).forEach(function(kw) { + gather(kw, null, 0, function(rec) { rec.isKeyword = true; }); + }); + } + hookname = "variableCompletion"; + } + srv.signal(hookname, file, wordStart, wordEnd, gather); + + if (query.sort !== false) completions.sort(compareCompletions); + srv.cx.completingProperty = null; + + return {start: outputPos(query, file, wordStart), + end: outputPos(query, file, wordEnd), + isProperty: !!prop, + isObjectKey: !!isKey, + completions: completions}; + } + + function findProperties(srv, query) { + var prefix = query.prefix, found = []; + for (var prop in srv.cx.props) + if (prop != "" && (!prefix || prop.indexOf(prefix) === 0)) found.push(prop); + if (query.sort !== false) found.sort(compareCompletions); + return {completions: found}; + } + + function inBody(node, pos) { + var body = node.body, start, end; + if (!body) return false; + if (Array.isArray(body)) { + start = body[0].start; + end = body[body.length - 1].end; + } else { + start = body.start; + end = body.end; + } + return start <= pos && end >= pos; + } + + var findExpr = exports.findQueryExpr = function(file, query, wide) { + if (query.end == null) throw ternError("missing .query.end field"); + + if (query.variable) { + var scope = infer.scopeAt(file.ast, resolvePos(file, query.end), file.scope); + return {node: {type: "Identifier", name: query.variable, start: query.end, end: query.end + 1}, + state: scope}; + } else { + var start = query.start && resolvePos(file, query.start), end = resolvePos(file, query.end); + var expr = infer.findExpressionAt(file.ast, start, end, file.scope); + if (!expr) { + var span = infer.findClosestExpression(file.ast, start, end, file.scope); + if (span && !inBody(span.node, end) && + (wide || (start == null ? end : start) - span.node.start < 20 || span.node.end - end < 20)) + expr = span; + } + if (!expr) { + var around = infer.findExpressionAround(file.ast, start, end, file.scope); + if (around && !inBody(around.node, end) && + (around.node.type == "ObjectExpression" || wide || + (start == null ? end : start) - around.node.start < 20 || around.node.end - end < 20)) + expr = around; + } + return expr; + } + }; + + function findExprAround(file, query, wide) { + var start = query.start && resolvePos(file, query.start), end = resolvePos(file, query.end); + var expr = null; + var around = infer.findExpressionAround(file.ast, start, end, file.scope); + if (around && !inBody(around.node, end) && + (around.node.type == "ObjectExpression" || wide || + (start == null ? end : start) - around.node.start < 20 || around.node.end - end < 20)) + expr = around; + return expr; + } + + function findExprOrThrow(file, query, wide) { + var expr = findExpr(file, query, wide); + if (expr) return expr; + throw ternError("No expression at the given position."); + } + + function ensureObj(tp) { + if (!tp || !(tp = tp.getType()) || !(tp instanceof infer.Obj)) return null; + return tp; + } + + function findExprType(srv, query, file, expr) { + var type; + if (expr) { + infer.resetGuessing(); + type = infer.expressionType(expr); + } + var typeHandlers = srv.hasHandler("typeAt"); + if (typeHandlers) { + var pos = resolvePos(file, query.end); + for (var i = 0; i < typeHandlers.length; i++) + type = typeHandlers[i](file, pos, expr, type); + } + if (!type) throw ternError("No type found at the given position."); + + var objProp; + if (expr.node.type == "ObjectExpression" && query.end != null && + (objProp = pointInProp(expr.node, resolvePos(file, query.end)))) { + var name = objProp.key.name; + var fromCx = ensureObj(infer.typeFromContext(file.ast, expr)); + if (fromCx && fromCx.hasProp(name)) { + type = fromCx.hasProp(name); + } else { + var fromLocal = ensureObj(type); + if (fromLocal && fromLocal.hasProp(name)) + type = fromLocal.hasProp(name); + } + } + return type; + } + + function findTypeAtExpr(srv, query, file, expr) { + var exprName, exprType; + var type = findExprType(srv, query, file, expr), exprType = type; + if (query.preferFunction) + type = type.getFunctionType() || type.getType(); + else + type = type.getType(); + + if (expr) { + if (expr.node.type == "Identifier") + exprName = expr.node.name; + else if (expr.node.type == "MemberExpression" && !expr.node.computed) + exprName = expr.node.property.name; + else if (expr.node.type == "MethodDefinition" && !expr.node.computed) + exprName = expr.node.key.name; + } + + if (query.depth != null && typeof query.depth != "number") + throw ternError(".query.depth must be a number"); + + return [type, exprName, exprType]; + } + + function findTypeAt(srv, query, file) { + var type, exprName, exprType; + var expr = findExpr(file, query); + var typeResult = findTypeAtExpr(srv, query, file, expr); + type = typeResult[0]; + if (!type) { + expr = findExprAround(file, query); + typeResult = findTypeAtExpr(srv, query, file, expr); + type = typeResult[0]; + } + exprName = typeResult[1]; + exprType = typeResult[2]; + + var result = {guess: infer.didGuess(), + type: infer.toString(exprType, query.depth), + name: type && type.name, + exprName: exprName, + doc: exprType.doc, + url: exprType.url}; + if (type) storeTypeDocs(query, type, result); + + return clean(result); + } + + function parseDoc(query, doc) { + if (!doc) return null; + if (query.docFormat == "full") return doc; + var parabreak = /.\n[\s@\n]/.exec(doc); + if (parabreak) doc = doc.slice(0, parabreak.index + 1); + doc = doc.replace(/\n\s*/g, " "); + if (doc.length < 100) return doc; + var sentenceEnd = /[\.!?] [A-Z]/g; + sentenceEnd.lastIndex = 80; + var found = sentenceEnd.exec(doc); + if (found) doc = doc.slice(0, found.index + 1); + return doc; + } + + function findDocs(srv, query, file) { + var expr = findExpr(file, query); + var type = findExprType(srv, query, file, expr); + var inner = type.getType(); + if (!inner) { + expr = findExprAround(file, query); + type = findExprType(srv, query, file, expr); + inner = type.getType(); + } + var result = {url: type.url, doc: parseDoc(query, type.doc), type: infer.toString(type)}; + if (inner) storeTypeDocs(query, inner, result); + return clean(result); + } + + function storeTypeDocs(query, type, out) { + if (!out.url) out.url = type.url; + if (!out.doc) out.doc = parseDoc(query, type.doc); + if (!out.origin) out.origin = type.origin; + var ctor, boring = infer.cx().protos; + if (!out.url && !out.doc && type.proto && (ctor = type.proto.hasCtor) && + type.proto != boring.Object && type.proto != boring.Function && type.proto != boring.Array) { + out.url = ctor.url; + out.doc = parseDoc(query, ctor.doc); + } + } + + var getSpan = exports.getSpan = function(obj) { + if (!obj.origin) return; + if (obj.originNode) { + var node = obj.originNode; + if (/^Function/.test(node.type) && node.id) node = node.id; + return {origin: obj.origin, node: node}; + } + if (obj.span) return {origin: obj.origin, span: obj.span}; + }; + + var storeSpan = exports.storeSpan = function(srv, query, span, target) { + target.origin = span.origin; + if (span.span) { + var m = /^(\d+)\[(\d+):(\d+)\]-(\d+)\[(\d+):(\d+)\]$/.exec(span.span); + target.start = query.lineCharPositions ? {line: Number(m[2]), ch: Number(m[3])} : Number(m[1]); + target.end = query.lineCharPositions ? {line: Number(m[5]), ch: Number(m[6])} : Number(m[4]); + } else { + var file = srv.fileMap[span.origin]; + target.start = outputPos(query, file, span.node.start); + target.end = outputPos(query, file, span.node.end); + } + }; + + function findDef(srv, query, file) { + var expr = findExpr(file, query); + var type = findExprType(srv, query, file, expr); + if (infer.didGuess()) return {}; + + var span = getSpan(type); + var result = {url: type.url, doc: parseDoc(query, type.doc), origin: type.origin}; + + if (type.types) for (var i = type.types.length - 1; i >= 0; --i) { + var tp = type.types[i]; + storeTypeDocs(query, tp, result); + if (!span) span = getSpan(tp); + } + + if (span && span.node) { // refers to a loaded file + var spanFile = span.node.sourceFile || srv.fileMap[span.origin]; + var start = outputPos(query, spanFile, span.node.start), end = outputPos(query, spanFile, span.node.end); + result.start = start; result.end = end; + result.file = span.origin; + var cxStart = Math.max(0, span.node.start - 50); + result.contextOffset = span.node.start - cxStart; + result.context = spanFile.text.slice(cxStart, cxStart + 50); + } else if (span) { // external + result.file = span.origin; + storeSpan(srv, query, span, result); + } + return clean(result); + } + + function findRefsToVariable(srv, query, file, expr, isRename) { + var name = expr.node.name; + + for (var scope = expr.state; scope && !(name in scope.props); scope = scope.prev) {} + if (!scope) throw ternError("Could not find a definition for " + name); + + var type, refs = []; + function storeRef(file) { + return function(node, scopeHere, ancestors) { + var value = {file: file.name, + start: outputPos(query, file, node.start), + end: outputPos(query, file, node.end)}; + if (isRename) { + for (var s = scopeHere; s != scope; s = s.prev) { + var exists = s.hasProp(isRename); + if (exists) + throw ternError("Renaming `" + name + "` to `" + isRename + "` would make a variable at line " + + (asLineChar(file, node.start).line + 1) + " point to the definition at line " + + (asLineChar(file, exists.name.start).line + 1)); + } + var parent = ancestors[ancestors.length - 2]; + if (parent && parent.type == "Property" && parent.key == parent.value) + value.isShorthand = true; + } + refs.push(value); + }; + } + + if (scope.originNode) { + type = "local"; + if (isRename) { + for (var prev = scope.prev; prev; prev = prev.prev) + if (isRename in prev.props) break; + if (prev) infer.findRefs(scope.originNode, scope, isRename, prev, function(node) { + throw ternError("Renaming `" + name + "` to `" + isRename + "` would shadow the definition used at line " + + (asLineChar(file, node.start).line + 1)); + }); + } + infer.findRefs(scope.originNode, scope, name, scope, storeRef(file)); + } else { + type = "global"; + if (query.onlySourceFile) { + infer.findRefs(file.ast, file.scope, name, scope, storeRef(file)); + } else { + for (var i = 0; i < srv.files.length; ++i) { + var cur = srv.files[i]; + infer.findRefs(cur.ast, cur.scope, name, scope, storeRef(cur)); + } + } + } + + return {refs: refs, type: type, name: name}; + } + + function findRefsToProperty(srv, query, sourceFile, expr, prop) { + var exprType = infer.expressionType(expr); + if (expr.node.type == "MethodDefinition") { + exprType = exprType.propertyOf; + } + var objType = exprType.getObjType(); + if (!objType) throw ternError("Couldn't determine type of base object."); + + var refs = []; + function storeRef(file) { + return function(node) { + refs.push({file: file.name, + start: outputPos(query, file, node.start), + end: outputPos(query, file, node.end)}); + }; + } + + if (query.onlySourceFile) { + infer.findPropRefs(sourceFile.ast, sourceFile.scope, objType, prop.name, storeRef(sourceFile)); + } else { + for (var i = 0; i < srv.files.length; ++i) { + var cur = srv.files[i]; + infer.findPropRefs(cur.ast, cur.scope, objType, prop.name, storeRef(cur)); + } + } + + return {refs: refs, name: prop.name}; + } + + function findRefs(srv, query, file) { + var expr = findExprOrThrow(file, query, true); + if (expr && expr.node.type == "Identifier") { + return findRefsToVariable(srv, query, file, expr); + } else if (expr && expr.node.type == "MemberExpression" && !expr.node.computed) { + var p = expr.node.property; + expr.node = expr.node.object; + return findRefsToProperty(srv, query, file, expr, p); + } else if (expr && expr.node.type == "ObjectExpression") { + var pos = resolvePos(file, query.end); + for (var i = 0; i < expr.node.properties.length; ++i) { + var k = expr.node.properties[i].key; + if (k.start <= pos && k.end >= pos) + return findRefsToProperty(srv, query, file, expr, k); + } + } else if (expr && expr.node.type == "MethodDefinition") { + var p = expr.node.key; + return findRefsToProperty(srv, query, file, expr, p); + } + throw ternError("Not at a variable or property name."); + } + + function buildRename(srv, query, file) { + if (typeof query.newName != "string") throw ternError(".query.newName should be a string"); + var expr = findExprOrThrow(file, query); + if (!expr || expr.node.type != "Identifier") throw ternError("Not at a variable."); + + var data = findRefsToVariable(srv, query, file, expr, query.newName), refs = data.refs; + delete data.refs; + data.files = srv.files.map(function(f){return f.name;}); + + var changes = data.changes = []; + for (var i = 0; i < refs.length; ++i) { + var use = refs[i]; + if (use.isShorthand) use.text = expr.node.name + ": " + query.newName; + else use.text = query.newName; + changes.push(use); + } + + return data; + } + + function listFiles(srv) { + return {files: srv.files.map(function(f){return f.name;})}; + } + + exports.version = "0.24.1"; +}); +// Type description parser +// +// Type description JSON files (such as ecmascript.json and browser.json) +// are used to +// +// A) describe types that come from native code +// +// B) to cheaply load the types for big libraries, or libraries that +// can't be inferred well + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return exports.init = mod; + if (typeof define == "function" && define.amd) // AMD + return define({init: mod}); + tern.def = {init: mod}; +})(function(exports, infer) { + "use strict"; + + function hop(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + var TypeParser = exports.TypeParser = function(spec, start, base, forceNew) { + this.pos = start || 0; + this.spec = spec; + this.base = base; + this.forceNew = forceNew; + }; + + function unwrapType(type, self, args) { + return type.call ? type(self, args) : type; + } + + function extractProp(type, prop) { + if (prop == "!ret") { + if (type.retval) return type.retval; + var rv = new infer.AVal; + type.propagate(new infer.IsCallee(infer.ANull, [], null, rv)); + return rv; + } else { + return type.getProp(prop); + } + } + + function computedFunc(name, args, retType, generator) { + return function(self, cArgs) { + var realArgs = []; + for (var i = 0; i < args.length; i++) realArgs.push(unwrapType(args[i], self, cArgs)); + return new infer.Fn(name, infer.ANull, realArgs, unwrapType(retType, self, cArgs), generator); + }; + } + function computedUnion(types) { + return function(self, args) { + var union = new infer.AVal; + for (var i = 0; i < types.length; i++) unwrapType(types[i], self, args).propagate(union); + union.maxWeight = 1e5; + return union; + }; + } + function computedArray(inner) { + return function(self, args) { + return new infer.Arr(inner(self, args)); + }; + } + function computedTuple(types) { + return function(self, args) { + return new infer.Arr(types.map(function(tp) { return unwrapType(tp, self, args) })); + }; + } + function computedObject(names, types) { + return function(self, args) { + var obj = new infer.Obj; + names.forEach(function (prop, i) { + obj.defProp(prop).addType(unwrapType(types[i], self, args)); + }); + return obj; + }; + } + + TypeParser.prototype = { + eat: function(str) { + if (str.length == 1 ? this.spec.charAt(this.pos) == str : this.spec.indexOf(str, this.pos) == this.pos) { + this.pos += str.length; + return true; + } + }, + word: function(re) { + var word = "", ch, re = re || /[\w$]/; + while ((ch = this.spec.charAt(this.pos)) && re.test(ch)) { word += ch; ++this.pos; } + return word; + }, + error: function() { + throw new Error("Unrecognized type spec: " + this.spec + " (at " + this.pos + ")"); + }, + parseFnType: function(comp, name, top, generator) { + var args = [], names = [], computed = false; + if (!this.eat(")")) for (var i = 0; ; ++i) { + var colon = this.spec.indexOf(": ", this.pos), argname; + if (colon != -1) { + argname = this.spec.slice(this.pos, colon); + if (/^(\.\.\.)?[$\w?]+$/.test(argname)) + this.pos = colon + 2; + else + argname = null; + } + names.push(argname); + var argType = this.parseType(comp); + if (argType.call) computed = true; + args.push(argType); + if (!this.eat(", ")) { + this.eat(")") || this.error(); + break; + } + } + var retType, computeRet, computeRetStart, fn; + if (this.eat(" -> ")) { + var retStart = this.pos; + retType = this.parseType(true); + if (retType.call && !computed) { + computeRet = retType; + retType = infer.ANull; + computeRetStart = retStart; + } + } else { + retType = infer.ANull; + } + if (computed) return computedFunc(name, args, retType, generator); + + if (top && (fn = this.base)) + infer.Fn.call(this.base, name, infer.ANull, args, names, retType, generator); + else + fn = new infer.Fn(name, infer.ANull, args, names, retType, generator); + if (computeRet) fn.computeRet = computeRet; + if (computeRetStart != null) fn.computeRetSource = this.spec.slice(computeRetStart, this.pos); + return fn; + }, + parseType: function(comp, name, top) { + var main = this.parseTypeMaybeProp(comp, name, top); + if (!this.eat("|")) return main; + var types = [main], computed = main.call; + for (;;) { + var next = this.parseTypeMaybeProp(comp, name, top); + types.push(next); + if (next.call) computed = true; + if (!this.eat("|")) break; + } + if (computed) return computedUnion(types); + var union = new infer.AVal; + for (var i = 0; i < types.length; i++) types[i].propagate(union); + union.maxWeight = 1e5; + return union; + }, + parseTypeMaybeProp: function(comp, name, top) { + var result = this.parseTypeInner(comp, name, top); + while (comp && this.eat(".")) result = this.extendWithProp(result); + return result; + }, + extendWithProp: function(base) { + var propName = this.word(/[\w<>$!:]/) || this.error(); + if (base.apply) return function(self, args) { + return extractProp(base(self, args), propName); + }; + return extractProp(base, propName); + }, + parseTypeInner: function(comp, name, top) { + var gen; + if (this.eat("fn(") || (gen = this.eat("fn*("))) { + return this.parseFnType(comp, name, top, gen); + } else if (this.eat("[")) { + var inner = this.parseType(comp), types, computed = inner.call; + while (this.eat(", ")) { + if (!types) types = [inner]; + var next = this.parseType(comp); + types.push(next); + computed = computed || next.call; + } + this.eat("]") || this.error(); + if (computed) return types ? computedTuple(types) : computedArray(inner); + if (top && this.base) { + infer.Arr.call(this.base, types || inner); + return this.base; + } + return new infer.Arr(types || inner); + } else if (this.eat("{")) { + var types = [], names = [], computed = false; + if (!this.eat("}")) { + for (var i = 0; ; ++i) { + var colon = this.spec.indexOf(": ", this.pos), propName; + if (colon != -1) { + propName = this.spec.slice(this.pos, colon); + if (/^[$\w?]+$/.test(propName)) + this.pos = colon + 2; + else + propName = null; + } + var propType = this.parseType(comp); + if (propType.call) computed = true; + names.push(propName); + types.push(propType); + if (!this.eat(", ")) { + this.eat("}") || this.error(); + break; + } + } + } + if (computed) return computedObject(names, types); + var obj = new infer.Obj; + names.forEach(function (prop, i) { + obj.defProp(prop).addType(types[i]); + }); + return obj; + } else if (this.eat("+")) { + var path = this.word(/[\w$<>\.:!]/); + var base = infer.cx().localDefs[path + ".prototype"]; + if (!base) { + var base = parsePath(path); + if (!(base instanceof infer.Obj)) return base; + var proto = descendProps(base, ["prototype"]); + if (proto && (proto = proto.getObjType())) + base = proto; + } + if (comp && this.eat("[")) return this.parsePoly(base); + if (top && this.base) { + this.base.proto = base; + var name = base.hasCtor && base.hasCtor.name || base.name; + if (name) this.base.name = name; + return this.base; + } + if (top && this.forceNew) return new infer.Obj(base); + return infer.getInstance(base); + } else if (this.eat(":")) { + var name = this.word(/[\w$\.]/); + return infer.getSymbol(name); + } else if (comp && this.eat("!")) { + var arg = this.word(/\d/); + if (arg) { + arg = Number(arg); + return function(_self, args) {return args[arg] || infer.ANull;}; + } else if (this.eat("this")) { + return function(self) {return self;}; + } else if (this.eat("custom:")) { + var fname = this.word(/[\w$]/); + return customFunctions[fname] || function() { return infer.ANull; }; + } else { + return this.fromWord("!" + this.word(/[\w$<>\.!:]/)); + } + } else if (this.eat("?")) { + return infer.ANull; + } else { + return this.fromWord(this.word(/[\w$<>\.!:`]/)); + } + }, + fromWord: function(spec) { + var cx = infer.cx(); + switch (spec) { + case "number": return cx.num; + case "string": return cx.str; + case "bool": return cx.bool; + case "": return cx.topScope; + } + if (cx.localDefs && spec in cx.localDefs) return cx.localDefs[spec]; + return parsePath(spec); + }, + parsePoly: function(base) { + var propName = "", match; + if (match = this.spec.slice(this.pos).match(/^\s*([\w$:]+)\s*=\s*/)) { + propName = match[1]; + this.pos += match[0].length; + } + var value = this.parseType(true); + if (!this.eat("]")) this.error(); + if (value.call) return function(self, args) { + var instance = new infer.Obj(base); + value(self, args).propagate(instance.defProp(propName)); + return instance; + }; + var instance = new infer.Obj(base); + value.propagate(instance.defProp(propName)); + return instance; + } + }; + + function addArgCallEffects(type) { + if (type instanceof infer.Fn && type.args) for (var i = 0; i < type.args.length; ++i) { + var arg = type.args[i]; + if (arg instanceof infer.Fn && arg.args && arg.args.length) addArgCallEffect(type, i); + } + } + + function addArgCallEffect(type, argNum) { + addEffect(type, function(_self, args) { + if (args[argNum]) args[argNum].propagate( + new infer.IsCallee(infer.cx().topScope, type.args[argNum].args, null, infer.ANull)); + }); + } + + function parseType(spec, name, base, forceNew) { + var type = new TypeParser(spec, null, base, forceNew).parseType(false, name, true); + if (type instanceof infer.AVal) type.types.forEach(addArgCallEffects); + else addArgCallEffects(type); + return type; + } + + function addEffect(fn, handler, replaceRet) { + var oldCmp = fn.computeRet, rv = fn.retval; + fn.computeRet = function(self, args, argNodes) { + var handled = handler(self, args, argNodes); + var old = oldCmp ? oldCmp(self, args, argNodes) : rv; + return replaceRet ? handled : old; + }; + } + + var parseEffect = exports.parseEffect = function(effect, fn) { + var m; + if (effect.indexOf("propagate ") == 0) { + var p = new TypeParser(effect, 10); + var origin = p.parseType(true); + if (!p.eat(" ")) p.error(); + var target = p.parseType(true); + addEffect(fn, function(self, args) { + unwrapType(origin, self, args).propagate(unwrapType(target, self, args)); + }); + } else if (effect.indexOf("call ") == 0) { + var andRet = effect.indexOf("and return ", 5) == 5; + var p = new TypeParser(effect, andRet ? 16 : 5); + var getCallee = p.parseType(true), getSelf = null, getArgs = []; + if (p.eat(" this=")) getSelf = p.parseType(true); + while (p.eat(" ")) getArgs.push(p.parseType(true)); + addEffect(fn, function(self, args) { + var callee = unwrapType(getCallee, self, args); + var slf = getSelf ? unwrapType(getSelf, self, args) : infer.ANull, as = []; + for (var i = 0; i < getArgs.length; ++i) as.push(unwrapType(getArgs[i], self, args)); + var result = andRet ? new infer.AVal : infer.ANull; + callee.propagate(new infer.IsCallee(slf, as, null, result)); + return result; + }, andRet); + } else if (m = effect.match(/^custom (\S+)\s*(.*)/)) { + var customFunc = customFunctions[m[1]]; + if (customFunc) addEffect(fn, m[2] ? customFunc(m[2]) : customFunc); + } else if (effect.indexOf("copy ") == 0) { + var p = new TypeParser(effect, 5); + var getFrom = p.parseType(true); + p.eat(" "); + var getTo = p.parseType(true); + addEffect(fn, function(self, args) { + var from = unwrapType(getFrom, self, args), to = unwrapType(getTo, self, args); + from.forAllProps(function(prop, val, local) { + if (local && prop != "") + to.propagate(new infer.DefProp(prop, val)); + }); + }); + } else { + throw new Error("Unknown effect type: " + effect); + } + }; + + var currentTopScope; + + var parsePath = exports.parsePath = function(path, scope) { + var cx = infer.cx(), cached = cx.paths[path], origPath = path; + if (cached != null) return cached; + cx.paths[path] = infer.ANull; + + var base = scope || currentTopScope || cx.topScope; + + if (cx.localDefs) for (var name in cx.localDefs) { + if (path.indexOf(name) == 0) { + if (path == name) return cx.paths[path] = cx.localDefs[path]; + if (path.charAt(name.length) == ".") { + base = cx.localDefs[name]; + path = path.slice(name.length + 1); + break; + } + } + } + + var result = descendProps(base, path.split(".")); + // Uncomment this to get feedback on your poorly written .json files + // if (result == infer.ANull) console.error("bad path: " + origPath + " (" + cx.curOrigin + ")") + cx.paths[origPath] = result == infer.ANull ? null : result; + return result; + }; + + function descendProps(base, parts) { + for (var i = 0; i < parts.length && base != infer.ANull; ++i) { + var prop = parts[i]; + if (prop.charAt(0) == "!") { + if (prop == "!proto") { + base = (base instanceof infer.Obj && base.proto) || infer.ANull; + } else { + var fn = base.getFunctionType(); + if (!fn) { + base = infer.ANull; + } else if (prop == "!ret") { + base = fn.retval && fn.retval.getType(false) || infer.ANull; + } else { + var arg = fn.args && fn.args[Number(prop.slice(1))]; + base = (arg && arg.getType(false)) || infer.ANull; + } + } + } else if (base instanceof infer.Obj && + (prop == "prototype" && base instanceof infer.Fn || base.hasProp(prop))) { + var propVal = base.getProp(prop); + if (!propVal || propVal.isEmpty()) + base = infer.ANull; + else + base = propVal.types[0]; + } else { + base = infer.ANull; + } + } + return base; + } + + function emptyObj(ctor) { + var empty = Object.create(ctor.prototype); + empty.props = Object.create(null); + empty.isShell = true; + return empty; + } + + function isSimpleAnnotation(spec) { + if (!spec["!type"] || /^(fn\(|\[|\+)/.test(spec["!type"])) return false; + for (var prop in spec) + if (prop != "!type" && prop != "!doc" && prop != "!url" && prop != "!span" && prop != "!data") + return false; + return true; + } + + function passOne(base, spec, path) { + if (!base) { + var tp = spec["!type"]; + if (tp) { + if (/^fn\(/.test(tp)) base = emptyObj(infer.Fn); + else if (tp.charAt(0) == "[") base = emptyObj(infer.Arr); + else if (tp.charAt(0) == "+") base = emptyObj(infer.Obj); + else throw new Error("Invalid !type spec: " + tp); + } else if (spec["!stdProto"]) { + base = infer.cx().protos[spec["!stdProto"]]; + } else { + base = emptyObj(infer.Obj); + } + base.name = path; + } + + for (var name in spec) if (hop(spec, name) && name.charCodeAt(0) != 33) { + var inner = spec[name]; + if (typeof inner == "string" || isSimpleAnnotation(inner)) continue; + var prop = base.defProp(name); + passOne(prop.getObjType(), inner, path ? path + "." + name : name).propagate(prop); + } + return base; + } + + function passTwo(base, spec, path) { + if (base.isShell) { + delete base.isShell; + var tp = spec["!type"]; + if (tp) { + parseType(tp, path, base); + } else { + var proto = spec["!proto"] && parseType(spec["!proto"]); + infer.Obj.call(base, proto instanceof infer.Obj ? proto : true, path); + } + } + + var effects = spec["!effects"]; + if (effects && base instanceof infer.Fn) for (var i = 0; i < effects.length; ++i) + parseEffect(effects[i], base); + copyInfo(spec, base); + + for (var name in spec) if (hop(spec, name) && name.charCodeAt(0) != 33) { + var inner = spec[name], known = base.defProp(name), innerPath = path ? path + "." + name : name; + if (typeof inner == "string") { + if (known.isEmpty()) parseType(inner, innerPath).propagate(known); + } else { + if (!isSimpleAnnotation(inner)) + passTwo(known.getObjType(), inner, innerPath); + else if (known.isEmpty()) + parseType(inner["!type"], innerPath, null, true).propagate(known); + else + continue; + if (inner["!doc"]) known.doc = inner["!doc"]; + if (inner["!url"]) known.url = inner["!url"]; + if (inner["!span"]) known.span = inner["!span"]; + } + } + return base; + } + + function copyInfo(spec, type) { + if (spec["!doc"]) type.doc = spec["!doc"]; + if (spec["!url"]) type.url = spec["!url"]; + if (spec["!span"]) type.span = spec["!span"]; + if (spec["!data"]) type.metaData = spec["!data"]; + } + + function doLoadEnvironment(data, scope) { + var cx = infer.cx(), server = cx.parent; + + infer.addOrigin(cx.curOrigin = data["!name"] || "env#" + cx.origins.length); + cx.localDefs = cx.definitions[cx.curOrigin] = Object.create(null); + + if (server) server.signal("preLoadDef", data); + + passOne(scope, data); + + var def = data["!define"]; + if (def) { + for (var name in def) { + var spec = def[name]; + cx.localDefs[name] = typeof spec == "string" ? parsePath(spec) : passOne(null, spec, name); + } + for (var name in def) { + var spec = def[name]; + if (typeof spec != "string") passTwo(cx.localDefs[name], def[name], name); + } + } + + passTwo(scope, data); + + if (server) server.signal("postLoadDef", data); + + cx.curOrigin = cx.localDefs = null; + } + + exports.load = function(data, scope) { + if (!scope) scope = infer.cx().topScope; + var oldScope = currentTopScope; + currentTopScope = scope; + try { + doLoadEnvironment(data, scope); + } finally { + currentTopScope = oldScope; + } + }; + + exports.parse = function(data, origin, path) { + var cx = infer.cx(); + if (origin) { + cx.origin = origin; + cx.localDefs = cx.definitions[origin]; + } + + try { + if (typeof data == "string") + return parseType(data, path); + else + return passTwo(passOne(null, data, path), data, path); + } finally { + if (origin) cx.origin = cx.localDefs = null; + } + }; + + // Used to register custom logic for more involved effect or type + // computation. + var customFunctions = Object.create(null); + infer.registerFunction = function(name, f) { customFunctions[name] = f; }; + + var IsCreated = infer.constraint({ + construct: function(created, target, spec) { + this.created = created; + this.target = target; + this.spec = spec; + }, + addType: function(tp) { + if (tp instanceof infer.Obj && this.created++ < 5) { + var derived = new infer.Obj(tp), spec = this.spec; + if (spec instanceof infer.AVal) spec = spec.getObjType(false); + if (spec instanceof infer.Obj) for (var prop in spec.props) { + var cur = spec.props[prop].types[0]; + var p = derived.defProp(prop); + if (cur && cur instanceof infer.Obj && cur.props.value) { + var vtp = cur.props.value.getType(false); + if (vtp) p.addType(vtp); + } + } + this.target.addType(derived); + } + } + }); + + infer.registerFunction("Object_create", function(_self, args, argNodes) { + if (argNodes && argNodes.length && argNodes[0].type == "Literal" && argNodes[0].value == null) + return new infer.Obj(); + + var result = new infer.AVal; + if (args[0]) args[0].propagate(new IsCreated(0, result, args[1])); + return result; + }); + + var PropSpec = infer.constraint({ + construct: function(target) { this.target = target; }, + addType: function(tp) { + if (!(tp instanceof infer.Obj)) return; + if (tp.hasProp("value")) + tp.getProp("value").propagate(this.target); + else if (tp.hasProp("get")) + tp.getProp("get").propagate(new infer.IsCallee(infer.ANull, [], null, this.target)); + } + }); + + infer.registerFunction("Object_defineProperty", function(_self, args, argNodes) { + if (argNodes && argNodes.length >= 3 && argNodes[1].type == "Literal" && + typeof argNodes[1].value == "string") { + var obj = args[0], connect = new infer.AVal; + obj.propagate(new infer.DefProp(argNodes[1].value, connect, argNodes[1])); + args[2].propagate(new PropSpec(connect)); + } + return infer.ANull; + }); + + infer.registerFunction("Object_defineProperties", function(_self, args, argNodes) { + if (args.length >= 2) { + var obj = args[0]; + args[1].forAllProps(function(prop, val, local) { + if (!local) return; + var connect = new infer.AVal; + obj.propagate(new infer.DefProp(prop, connect, argNodes && argNodes[1])); + val.propagate(new PropSpec(connect)); + }); + } + return infer.ANull; + }); + + var IsBound = infer.constraint({ + construct: function(self, args, target) { + this.self = self; this.args = args; this.target = target; + }, + addType: function(tp) { + if (!(tp instanceof infer.Fn)) return; + this.target.addType(new infer.Fn(tp.name, infer.ANull, tp.args.slice(this.args.length), + tp.argNames.slice(this.args.length), tp.retval, tp.generator)); + this.self.propagate(tp.self); + for (var i = 0; i < Math.min(tp.args.length, this.args.length); ++i) + this.args[i].propagate(tp.args[i]); + } + }); + + infer.registerFunction("Function_bind", function(self, args) { + if (!args.length) return infer.ANull; + var result = new infer.AVal; + self.propagate(new IsBound(args[0], args.slice(1), result)); + return result; + }); + + infer.registerFunction("Array_ctor", function(_self, args) { + var arr = new infer.Arr; + if (args.length != 1 || !args[0].hasType(infer.cx().num)) { + var content = arr.getProp(""); + for (var i = 0; i < args.length; ++i) args[i].propagate(content); + } + return arr; + }); + + function makePromise() { + var defs = infer.cx().definitions.ecmascript; + return defs && new infer.Obj(defs["Promise.prototype"]); + } + + infer.registerFunction("Promise_ctor", function(_self, args, argNodes) { + var self = makePromise(); + if (!self || args.length < 1) return infer.ANull; + var valProp = self.defProp(":t", argNodes && argNodes[0]); + var valArg = new infer.AVal; + valArg.propagate(valProp); + var exec = new infer.Fn("execute", infer.ANull, [valArg], ["value"], infer.ANull); + var reject = infer.cx().definitions.ecmascript.Promise_reject; + args[0].propagate(new infer.IsCallee(infer.ANull, [exec, reject], null, infer.ANull)); + return self; + }); + + // Definition for Promise.resolve() + // The behavior is different for Promise and non-Promise arguments, so we + // need a custom definition to handle the different cases properly. + infer.registerFunction("Promise_resolve", function(_self, args, argNodes) { + var self = makePromise(); + if (!self) return infer.ANull; + if (args.length) { + var valProp = self.defProp(":t", argNodes && argNodes[0]); + var valArg = new infer.AVal; + valArg.propagate(valProp); + args[0].propagate(new PromiseResolvesTo(valArg)); + } + return self; + }); + + var PromiseResolvesTo = infer.constraint({ + construct: function(output) { this.output = output; }, + addType: function(tp) { + if (tp.constructor == infer.Obj && tp.name == "Promise" && tp.hasProp(":t")) + tp.getProp(":t").propagate(this.output); + else + tp.propagate(this.output); + } + }); + + var WG_PROMISE_KEEP_VALUE = 50; + + infer.registerFunction("Promise_then", function(self, args, argNodes) { + var fn = args.length && args[0].getFunctionType(); + var defs = infer.cx().definitions.ecmascript; + if (!fn || !defs) return self; + + var result = new infer.Obj(defs["Promise.prototype"]); + var value = result.defProp(":t", argNodes && argNodes[0]), ty; + if (fn.retval.isEmpty() && (ty = self.getType()) instanceof infer.Obj && ty.hasProp(":t")) + ty.getProp(":t").propagate(value, WG_PROMISE_KEEP_VALUE); + fn.retval.propagate(new PromiseResolvesTo(value)); + return result; + }); + + infer.registerFunction("getOwnPropertySymbols", function(_self, args) { + if (!args.length) return infer.ANull; + var result = new infer.AVal; + args[0].forAllProps(function(prop, _val, local) { + if (local && prop.charAt(0) == ":") result.addType(infer.getSymbol(prop.slice(1))); + }); + return result; + }); + + infer.registerFunction("getSymbol", function(_self, _args, argNodes) { + if (argNodes && argNodes.length && argNodes[0].type == "Literal" && typeof argNodes[0].value == "string") + return infer.getSymbol(argNodes[0].value); + else + return infer.ANull; + }); + + return exports; +}); +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(exports); + if (typeof define == "function" && define.amd) // AMD + return define(["exports"], mod); + mod(tern.comment || (tern.comment = {})); +})(function(exports) { + function isSpace(ch) { + return (ch < 14 && ch > 8) || ch === 32 || ch === 160; + } + + function onOwnLine(text, pos) { + for (; pos > 0; --pos) { + var ch = text.charCodeAt(pos - 1); + if (ch == 10) break; + if (!isSpace(ch)) return false; + } + return true; + } + + // Gather comments directly before a function + exports.commentsBefore = function(text, pos) { + var found = null, emptyLines = 0, topIsLineComment; + out: while (pos > 0) { + var prev = text.charCodeAt(pos - 1); + if (prev == 10) { + for (var scan = --pos, sawNonWS = false; scan > 0; --scan) { + prev = text.charCodeAt(scan - 1); + if (prev == 47 && text.charCodeAt(scan - 2) == 47) { + if (!onOwnLine(text, scan - 2)) break out; + var content = text.slice(scan, pos); + if (!emptyLines && topIsLineComment) found[0] = content + "\n" + found[0]; + else (found || (found = [])).unshift(content); + topIsLineComment = true; + emptyLines = 0; + pos = scan - 2; + break; + } else if (prev == 10) { + if (!sawNonWS && ++emptyLines > 1) break out; + break; + } else if (!sawNonWS && !isSpace(prev)) { + sawNonWS = true; + } + } + } else if (prev == 47 && text.charCodeAt(pos - 2) == 42) { + for (var scan = pos - 2; scan > 1; --scan) { + if (text.charCodeAt(scan - 1) == 42 && text.charCodeAt(scan - 2) == 47) { + if (!onOwnLine(text, scan - 2)) break out; + (found || (found = [])).unshift(text.slice(scan, pos - 2)); + topIsLineComment = false; + emptyLines = 0; + break; + } + } + pos = scan - 2; + } else if (isSpace(prev)) { + --pos; + } else { + break; + } + } + return found; + }; + + exports.commentAfter = function(text, pos) { + while (pos < text.length) { + var next = text.charCodeAt(pos); + if (next == 47) { + var after = text.charCodeAt(pos + 1), end; + if (after == 47) // line comment + end = text.indexOf("\n", pos + 2); + else if (after == 42) // block comment + end = text.indexOf("*/", pos + 2); + else + return; + return text.slice(pos + 2, end < 0 ? text.length : end); + } else if (isSpace(next)) { + ++pos; + } + } + }; + + exports.ensureCommentsBefore = function(text, node) { + if (node.hasOwnProperty("commentsBefore")) return node.commentsBefore; + return node.commentsBefore = exports.commentsBefore(text, node.start); + }; +}); +// Main type inference engine + +// Walks an AST, building up a graph of abstract values and constraints +// that cause types to flow from one node to another. Also defines a +// number of utilities for accessing ASTs and scopes. + +// Analysis is done in a context, which is tracked by the dynamically +// bound cx variable. Use withContext to set the current context. + +// For memory-saving reasons, individual types export an interface +// similar to abstract values (which can hold multiple types), and can +// thus be used in place abstract values that only ever contain a +// single type. + +(function(root, mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(exports, require("acorn"), require("acorn-loose"), require("acorn-walk"), + require("./def"), require("./signal")); + if (typeof define == "function" && define.amd) // AMD + return define(["exports", "acorn/dist/acorn", "acorn-loose/dist/acorn-loose", "acorn-walk/dist/walk", "./def", "./signal"], mod); + mod(root.tern || (root.tern = {}), acorn, acorn.loose, acorn.walk, tern.def, tern.signal); // Plain browser env +})(this, function(exports, acorn, acorn_loose, walk, def, signal) { + "use strict"; + + var toString = exports.toString = function(type, maxDepth, parent) { + if (!type || type == parent || maxDepth && maxDepth < -3) return "?"; + return type.toString(maxDepth, parent); + }; + + // A variant of AVal used for unknown, dead-end values. Also serves + // as prototype for AVals, Types, and Constraints because it + // implements 'empty' versions of all the methods that the code + // expects. + var ANull = exports.ANull = signal.mixin({ + addType: function() {}, + propagate: function() {}, + getProp: function() { return ANull; }, + forAllProps: function() {}, + hasType: function() { return false; }, + isEmpty: function() { return true; }, + getFunctionType: function() {}, + getObjType: function() {}, + getSymbolType: function() {}, + getType: function() {}, + gatherProperties: function() {}, + propagatesTo: function() {}, + typeHint: function() {}, + propHint: function() {}, + toString: function() { return "?"; } + }); + + function extend(proto, props) { + var obj = Object.create(proto); + if (props) for (var prop in props) obj[prop] = props[prop]; + return obj; + } + + // ABSTRACT VALUES + + var WG_DEFAULT = 100, WG_NEW_INSTANCE = 90, WG_MADEUP_PROTO = 10, + WG_MULTI_MEMBER = 6, WG_CATCH_ERROR = 6, + WG_PHANTOM_OBJ = 1, + WG_GLOBAL_THIS = 90, WG_SPECULATIVE_THIS = 2, WG_SPECULATIVE_PROTO_THIS = 4; + + var AVal = exports.AVal = function() { + this.types = []; + this.forward = null; + this.maxWeight = 0; + }; + AVal.prototype = extend(ANull, { + addType: function(type, weight) { + weight = weight || WG_DEFAULT; + if (this.maxWeight < weight) { + this.maxWeight = weight; + if (this.types.length == 1 && this.types[0] == type) return; + this.types.length = 0; + } else if (this.maxWeight > weight || this.types.indexOf(type) > -1) { + return; + } + + this.signal("addType", type); + this.types.push(type); + var forward = this.forward; + if (forward) withWorklist(function(add) { + for (var i = 0; i < forward.length; ++i) add(type, forward[i], weight); + }); + }, + + propagate: function(target, weight) { + if (target == ANull || (target instanceof Type && this.forward && this.forward.length > 2)) return; + if (weight && weight != WG_DEFAULT) target = new Muffle(target, weight); + (this.forward || (this.forward = [])).push(target); + var types = this.types; + if (types.length) withWorklist(function(add) { + for (var i = 0; i < types.length; ++i) add(types[i], target, weight); + }); + }, + + getProp: function(prop) { + if (ignoredProp(prop)) return ANull; + var found = (this.props || (this.props = Object.create(null)))[prop]; + if (!found) { + found = this.props[prop] = new AVal; + this.propagate(new GetProp(prop, found)); + } + return found; + }, + + forAllProps: function(c) { + this.propagate(new ForAllProps(c)); + }, + + hasType: function(type) { + return this.types.indexOf(type) > -1; + }, + isEmpty: function() { return this.types.length === 0; }, + getFunctionType: function() { + for (var i = this.types.length - 1; i >= 0; --i) + if (this.types[i] instanceof Fn) return this.types[i]; + }, + getObjType: function() { + var seen = null; + for (var i = this.types.length - 1; i >= 0; --i) { + var type = this.types[i]; + if (!(type instanceof Obj)) continue; + if (type.name) return type; + if (!seen) seen = type; + } + return seen; + }, + + getSymbolType: function() { + for (var i = this.types.length - 1; i >= 0; --i) + if (this.types[i] instanceof Sym) return this.types[i]; + }, + + getType: function(guess) { + if (this.types.length === 0 && guess !== false) return this.makeupType(); + if (this.types.length === 1) return this.types[0]; + return canonicalType(this.types); + }, + + toString: function(maxDepth, parent) { + if (this.types.length == 0) return toString(this.makeupType(), maxDepth, parent); + if (this.types.length == 1) return toString(this.types[0], maxDepth, parent); + var simplified = simplifyTypes(this.types); + if (simplified.length > 2) return "?"; + return simplified.map(function(tp) { return toString(tp, maxDepth, parent); }).join("|"); + }, + + makeupPropType: function(obj) { + var propName = this.propertyName; + + var protoProp = obj.proto && obj.proto.hasProp(propName); + if (protoProp) { + var fromProto = protoProp.getType(); + if (fromProto) return fromProto; + } + + if (propName != "") { + var computedProp = obj.hasProp(""); + if (computedProp) return computedProp.getType(); + } else if (obj.props[""] != this) { + for (var prop in obj.props) { + var val = obj.props[prop]; + if (!val.isEmpty()) return val.getType(); + } + } + }, + + makeupType: function() { + var computed = this.propertyOf && this.makeupPropType(this.propertyOf); + if (computed) return computed; + + if (!this.forward) return null; + for (var i = this.forward.length - 1; i >= 0; --i) { + var hint = this.forward[i].typeHint(); + if (hint && !hint.isEmpty()) {guessing = true; return hint;} + } + + var props = Object.create(null), foundProp = null; + for (var i = 0; i < this.forward.length; ++i) { + var prop = this.forward[i].propHint(); + if (prop && prop != "length" && prop != "" && prop != "✖" && prop != cx.completingProperty) { + props[prop] = true; + foundProp = prop; + } + } + if (!foundProp) return null; + + var objs = objsWithProp(foundProp); + if (objs) { + var matches = []; + search: for (var i = 0; i < objs.length; ++i) { + var obj = objs[i]; + for (var prop in props) if (!obj.hasProp(prop)) continue search; + if (obj.hasCtor) obj = getInstance(obj); + matches.push(obj); + } + var canon = canonicalType(matches); + if (canon) {guessing = true; return canon;} + } + }, + + typeHint: function() { return this.types.length ? this.getType() : null; }, + propagatesTo: function() { return this; }, + + gatherProperties: function(f, depth) { + for (var i = 0; i < this.types.length; ++i) + this.types[i].gatherProperties(f, depth); + }, + + guessProperties: function(f) { + if (this.forward) for (var i = 0; i < this.forward.length; ++i) { + var prop = this.forward[i].propHint(); + if (prop) f(prop, null, 0); + } + var guessed = this.makeupType(); + if (guessed) guessed.gatherProperties(f); + } + }); + + function similarAVal(a, b, depth) { + var typeA = a.getType(false), typeB = b.getType(false); + if (!typeA || !typeB) return true; + return similarType(typeA, typeB, depth); + } + + function similarType(a, b, depth) { + if (!a || depth >= 5) return b; + if (!a || a == b) return a; + if (!b) return a; + if (a.constructor != b.constructor) return false; + if (a.constructor == Arr) { + var innerA = a.getProp("").getType(false); + if (!innerA) return b; + var innerB = b.getProp("").getType(false); + if (!innerB || similarType(innerA, innerB, depth + 1)) return b; + } else if (a.constructor == Obj) { + var propsA = 0, propsB = 0, same = 0; + for (var prop in a.props) { + propsA++; + if (prop in b.props && similarAVal(a.props[prop], b.props[prop], depth + 1)) + same++; + } + for (var prop in b.props) propsB++; + if (propsA && propsB && same < Math.max(propsA, propsB) / 2) return false; + return propsA > propsB ? a : b; + } else if (a.constructor == Fn) { + if (a.args.length != b.args.length || + !a.args.every(function(tp, i) { return similarAVal(tp, b.args[i], depth + 1); }) || + !similarAVal(a.retval, b.retval, depth + 1) || !similarAVal(a.self, b.self, depth + 1)) + return false; + return a; + } else { + return false; + } + } + + var simplifyTypes = exports.simplifyTypes = function(types) { + var found = []; + outer: for (var i = 0; i < types.length; ++i) { + var tp = types[i]; + for (var j = 0; j < found.length; j++) { + var similar = similarType(tp, found[j], 0); + if (similar) { + found[j] = similar; + continue outer; + } + } + found.push(tp); + } + return found; + }; + + function canonicalType(types) { + var arrays = 0, fns = 0, objs = 0, prim = null; + for (var i = 0; i < types.length; ++i) { + var tp = types[i]; + if (tp instanceof Arr) ++arrays; + else if (tp instanceof Fn) ++fns; + else if (tp instanceof Obj) ++objs; + else if (tp instanceof Prim) { + if (prim && tp.name != prim.name) return null; + prim = tp; + } + } + var kinds = (arrays && 1) + (fns && 1) + (objs && 1) + (prim && 1); + if (kinds > 1) return null; + if (prim) return prim; + + var maxScore = 0, maxTp = null; + for (var i = 0; i < types.length; ++i) { + var tp = types[i], score = 0; + if (arrays) { + score = tp.getProp("").isEmpty() ? 1 : 2; + } else if (fns) { + score = 1; + for (var j = 0; j < tp.args.length; ++j) if (!tp.args[j].isEmpty()) ++score; + if (!tp.retval.isEmpty()) ++score; + } else if (objs) { + score = tp.name ? 100 : 2; + } + if (score >= maxScore) { maxScore = score; maxTp = tp; } + } + return maxTp; + } + + // PROPAGATION STRATEGIES + + var constraint = exports.constraint = function(methods) { + var ctor = function() { + this.origin = cx.curOrigin; + this.construct.apply(this, arguments); + }; + ctor.prototype = Object.create(ANull); + for (var m in methods) if (methods.hasOwnProperty(m)) ctor.prototype[m] = methods[m]; + return ctor; + }; + + var GetProp = constraint({ + construct: function(prop, target) { + this.prop = prop; this.target = target; + }, + addType: function(type, weight) { + if (type.getProp) + type.getProp(this.prop).propagate(this.target, weight); + }, + propHint: function() { return this.prop; }, + propagatesTo: function() { + if (this.prop == "" || !/[^\w_]/.test(this.prop)) + return {target: this.target, pathExt: "." + this.prop}; + } + }); + + var DefProp = exports.PropHasSubset = exports.DefProp = constraint({ + construct: function(prop, type, originNode) { + this.prop = prop; this.type = type; this.originNode = originNode; + }, + addType: function(type, weight) { + if (!(type instanceof Obj)) return; + var prop = type.defProp(this.prop, this.originNode); + if (!prop.origin) prop.origin = this.origin; + this.type.propagate(prop, weight); + }, + propHint: function() { return this.prop; } + }); + + var ForAllProps = constraint({ + construct: function(c) { this.c = c; }, + addType: function(type) { + if (!(type instanceof Obj)) return; + type.forAllProps(this.c); + } + }); + + function withDisabledComputing(fn, body) { + cx.disabledComputing = {fn: fn, prev: cx.disabledComputing}; + var result = body(); + cx.disabledComputing = cx.disabledComputing.prev; + return result; + } + var IsCallee = exports.IsCallee = constraint({ + construct: function(self, args, argNodes, retval) { + this.self = self; this.args = args; this.argNodes = argNodes; this.retval = retval; + this.disabled = cx.disabledComputing; + }, + addType: function(fn, weight) { + if (!(fn instanceof Fn)) return; + for (var i = 0; i < this.args.length; ++i) { + if (i < fn.args.length) this.args[i].propagate(fn.args[i], weight); + if (fn.arguments) this.args[i].propagate(fn.arguments, weight); + } + if (!fn.isArrowFn()) + this.self.propagate(fn.self, this.self == cx.topScope ? WG_GLOBAL_THIS : weight); + var compute = fn.computeRet, result = fn.retval; + if (compute) for (var d = this.disabled; d; d = d.prev) + if (d.fn == fn || fn.originNode && d.fn.originNode == fn.originNode) compute = null; + if (compute) { + var old = cx.disabledComputing; + cx.disabledComputing = this.disabled; + result = compute(this.self, this.args, this.argNodes); + cx.disabledComputing = old; + } + if (fn.async && !fn.generator) { + var tp = result.getType(); + if (!(tp && tp.constructor == Obj && tp.name == "Promise")) { + var defs = cx.definitions.ecmascript; + var rtnval = defs && new Obj(defs["Promise.prototype"]); + if (rtnval) { + rtnval.getType().propagate(new DefProp(':t', result)); + result = rtnval; + } + } + } + maybeIterator(fn, result).propagate(this.retval, weight); + }, + typeHint: function() { + var names = []; + for (var i = 0; i < this.args.length; ++i) names.push("?"); + return new Fn(null, this.self, this.args, names, ANull); + }, + propagatesTo: function() { + return {target: this.retval, pathExt: ".!ret"}; + } + }); + + var HasMethodCall = constraint({ + construct: function(propName, args, argNodes, retval) { + this.propName = propName; this.args = args; this.argNodes = argNodes; this.retval = retval; + this.disabled = cx.disabledComputing; + }, + addType: function(obj, weight) { + var callee = new IsCallee(obj, this.args, this.argNodes, this.retval); + callee.disabled = this.disabled; + obj.getProp(this.propName).propagate(callee, weight); + }, + propHint: function() { return this.propName; } + }); + + var IsCtor = exports.IsCtor = constraint({ + construct: function(target, noReuse) { + this.target = target; this.noReuse = noReuse; + }, + addType: function(f, weight) { + if (!(f instanceof Fn)) return; + if (cx.parent && !cx.parent.options.reuseInstances) this.noReuse = true; + f.getProp("prototype").propagate(new IsProto(this.noReuse ? false : f, this.target), weight); + } + }); + + var getInstance = exports.getInstance = function(obj, ctor) { + if (ctor === false || obj == null) return new Obj(obj); + + if (!ctor) ctor = obj.hasCtor; + if (!obj.instances) obj.instances = []; + for (var i = 0; i < obj.instances.length; ++i) { + var cur = obj.instances[i]; + if (cur.ctor == ctor) return cur.instance; + } + var instance = new Obj(obj, ctor && ctor.name); + instance.origin = obj.origin; + obj.instances.push({ctor: ctor, instance: instance}); + return instance; + }; + + var IsProto = exports.IsProto = constraint({ + construct: function(ctor, target) { + this.ctor = ctor; this.target = target; + }, + addType: function(o, _weight) { + if (!(o instanceof Obj)) return; + if ((this.count = (this.count || 0) + 1) > 8) return; + if (o == cx.protos.Array) + this.target.addType(new Arr); + else + this.target.addType(getInstance(o, this.ctor)); + } + }); + + var FnPrototype = constraint({ + construct: function(fn) { this.fn = fn; }, + addType: function(o, _weight) { + if (o instanceof Obj && !o.hasCtor) { + o.hasCtor = this.fn; + var adder = new SpeculativeThis(o, this.fn); + adder.addType(this.fn); + o.forAllProps(function(_prop, val, local) { + if (local) val.propagate(adder); + }); + } + } + }); + + var IsAdded = constraint({ + construct: function(other, target) { + this.other = other; this.target = target; + }, + addType: function(type, weight) { + if (type == cx.str) + this.target.addType(cx.str, weight); + else if (type == cx.num && this.other.hasType(cx.num)) + this.target.addType(cx.num, weight); + }, + typeHint: function() { return this.other; } + }); + + var IfObj = exports.IfObj = constraint({ + construct: function(target) { this.target = target; }, + addType: function(t, weight) { + if (t instanceof Obj) this.target.addType(t, weight); + }, + propagatesTo: function() { return this.target; } + }); + + var SpeculativeThis = constraint({ + construct: function(obj, ctor) { this.obj = obj; this.ctor = ctor; }, + addType: function(tp) { + if (tp instanceof Fn && tp.self) + tp.self.addType(getInstance(this.obj, this.ctor), WG_SPECULATIVE_PROTO_THIS); + } + }); + + var HasProto = constraint({ + construct: function(obj) { this.obj = obj }, + addType: function(tp) { + if (tp instanceof Obj && this.obj.proto == cx.protos.Object) + this.obj.replaceProto(tp); + } + }); + + var Muffle = constraint({ + construct: function(inner, weight) { + this.inner = inner; this.weight = weight; + }, + addType: function(tp, weight) { + this.inner.addType(tp, Math.min(weight, this.weight)); + }, + propagatesTo: function() { return this.inner.propagatesTo(); }, + typeHint: function() { return this.inner.typeHint(); }, + propHint: function() { return this.inner.propHint(); } + }); + + // TYPE OBJECTS + + var Type = exports.Type = function() {}; + Type.prototype = extend(ANull, { + constructor: Type, + propagate: function(c, w) { c.addType(this, w); }, + hasType: function(other) { return other == this; }, + isEmpty: function() { return false; }, + typeHint: function() { return this; }, + getType: function() { return this; } + }); + + var Prim = exports.Prim = function(proto, name) { this.name = name; this.proto = proto; }; + Prim.prototype = extend(Type.prototype, { + constructor: Prim, + toString: function() { return this.name; }, + getProp: function(prop) {return this.proto.hasProp(prop) || ANull;}, + gatherProperties: function(f, depth) { + if (this.proto) this.proto.gatherProperties(f, depth); + } + }); + + function isInteger(str) { + var c0 = str.charCodeAt(0); + if (c0 >= 48 && c0 <= 57) return !/\D/.test(str); + else return false; + } + + var Obj = exports.Obj = function(proto, name) { + if (!this.props) this.props = Object.create(null); + this.proto = proto === true ? cx.protos.Object : proto; + if (proto && proto != cx.protos.Object && !name && proto.name && !(this instanceof Fn)) { + var match = /^(.*)\.prototype$/.exec(this.proto.name); + if (match) name = match[1]; + } + this.name = name; + this.maybeProps = null; + this.origin = cx.curOrigin; + }; + Obj.prototype = extend(Type.prototype, { + constructor: Obj, + toString: function(maxDepth) { + if (maxDepth == null) maxDepth = 0; + if (maxDepth <= 0 && this.name) return this.name; + var props = [], etc = false; + for (var prop in this.props) if (prop != "") { + if (props.length > 5) { etc = true; break; } + if (maxDepth) + props.push(prop + ": " + toString(this.props[prop], maxDepth - 1, this)); + else + props.push(prop); + } + props.sort(); + if (etc) props.push("..."); + return "{" + props.join(", ") + "}"; + }, + hasProp: function(prop, searchProto) { + if (isInteger(prop)) prop = this.normalizeIntegerProp(prop); + var found = this.props[prop]; + if (searchProto !== false) + for (var p = this.proto; p && !found; p = p.proto) found = p.props[prop]; + return found; + }, + defProp: function(prop, originNode) { + var found = this.hasProp(prop, false); + if (found) { + if (originNode && !found.originNode) found.originNode = originNode; + return found; + } + if (ignoredProp(prop)) return ANull; + if (isInteger(prop)) prop = this.normalizeIntegerProp(prop); + + var av = this.maybeProps && this.maybeProps[prop]; + if (av) { + delete this.maybeProps[prop]; + this.maybeUnregProtoPropHandler(); + } else { + av = new AVal; + av.propertyOf = this; + av.propertyName = prop; + } + + this.props[prop] = av; + av.originNode = originNode; + av.origin = cx.curOrigin; + this.broadcastProp(prop, av, true); + return av; + }, + getProp: function(prop) { + var found = this.hasProp(prop, true) || (this.maybeProps && this.maybeProps[prop]); + if (found) return found; + if (ignoredProp(prop)) return ANull; + if (isInteger(prop)) prop = this.normalizeIntegerProp(prop); + var av = this.ensureMaybeProps()[prop] = new AVal; + av.propertyOf = this; + av.propertyName = prop; + return av; + }, + normalizeIntegerProp: function(_) { return "" }, + broadcastProp: function(prop, val, local) { + if (local) { + this.signal("addProp", prop, val); + // If this is a scope, it shouldn't be registered + if (!(this instanceof Scope)) registerProp(prop, this); + } + + if (this.onNewProp) for (var i = 0; i < this.onNewProp.length; ++i) { + var h = this.onNewProp[i]; + h.onProtoProp ? h.onProtoProp(prop, val, local) : h(prop, val, local); + } + }, + onProtoProp: function(prop, val, _local) { + var maybe = this.maybeProps && this.maybeProps[prop]; + if (maybe) { + delete this.maybeProps[prop]; + this.maybeUnregProtoPropHandler(); + this.proto.getProp(prop).propagate(maybe); + } + this.broadcastProp(prop, val, false); + }, + replaceProto: function(proto) { + for (var o = proto; o; o = o.proto) + if (o == this) return; + if (this.proto && this.maybeProps) + this.proto.unregPropHandler(this); + this.proto = proto; + if (this.maybeProps) + this.proto.forAllProps(this); + }, + ensureMaybeProps: function() { + if (!this.maybeProps) { + if (this.proto) this.proto.forAllProps(this); + this.maybeProps = Object.create(null); + } + return this.maybeProps; + }, + removeProp: function(prop) { + var av = this.props[prop]; + delete this.props[prop]; + this.ensureMaybeProps()[prop] = av; + av.types.length = 0; + }, + forAllProps: function(c) { + if (!this.onNewProp) { + this.onNewProp = []; + if (this.proto) this.proto.forAllProps(this); + } + this.onNewProp.push(c); + for (var o = this; o; o = o.proto) for (var prop in o.props) { + if (c.onProtoProp) + c.onProtoProp(prop, o.props[prop], o == this); + else + c(prop, o.props[prop], o == this); + } + }, + maybeUnregProtoPropHandler: function() { + if (this.maybeProps) { + for (var _n in this.maybeProps) return; + this.maybeProps = null; + } + if (!this.proto || this.onNewProp && this.onNewProp.length) return; + this.proto.unregPropHandler(this); + }, + unregPropHandler: function(handler) { + for (var i = 0; i < this.onNewProp.length; ++i) + if (this.onNewProp[i] == handler) { this.onNewProp.splice(i, 1); break; } + this.maybeUnregProtoPropHandler(); + }, + gatherProperties: function(f, depth) { + for (var prop in this.props) if (prop != "" && prop.charAt(0) != ":") + f(prop, this, depth); + if (this.proto) this.proto.gatherProperties(f, depth + 1); + }, + getObjType: function() { return this; } + }); + + var geckoIterators = typeof StopIteration != "undefined"; + function ignoredProp(name) { + return name == "__proto__" || name == "✖" || geckoIterators && name == "__iterator__"; + } + + var Fn = exports.Fn = function(name, self, args, argNames, retval, generator, async) { + Obj.call(this, cx.protos.Function, name); + this.self = self; + this.args = args; + this.argNames = argNames; + this.retval = retval; + this.generator = generator; + this.async = async; + }; + Fn.prototype = extend(Obj.prototype, { + constructor: Fn, + toString: function(maxDepth) { + if (maxDepth == null) maxDepth = 0; + var str = this.generator ? "fn*(" : "fn("; + for (var i = 0; i < this.args.length; ++i) { + if (i) str += ", "; + var name = this.argNames[i]; + if (name && name != "?") str += name + ": "; + str += maxDepth > -3 ? toString(this.args[i], maxDepth - 1, this) : "?"; + } + str += ")"; + if (!this.retval.isEmpty()) + str += " -> " + (maxDepth > -3 ? toString(this.retval, maxDepth - 1, this) : "?"); + return str; + }, + getProp: function(prop) { + if (prop == "prototype") { + var known = this.hasProp(prop, false); + if (!known) { + known = this.defProp(prop); + var proto = new Obj(true, this.name && this.name + ".prototype"); + proto.origin = this.origin; + known.addType(proto, WG_MADEUP_PROTO); + } + return known; + } + return Obj.prototype.getProp.call(this, prop); + }, + defProp: function(prop, originNode) { + if (prop == "prototype") { + var found = this.hasProp(prop, false); + if (found) return found; + found = Obj.prototype.defProp.call(this, prop, originNode); + found.origin = this.origin; + found.propagate(new FnPrototype(this)); + return found; + } + return Obj.prototype.defProp.call(this, prop, originNode); + }, + getFunctionType: function() { return this; }, + isArrowFn: function() { return this.originNode && this.originNode.type == "ArrowFunctionExpression" } + }); + + var Arr = exports.Arr = function(contentType) { + Obj.call(this, cx.protos.Array); + var content = this.defProp(""); + if (Array.isArray(contentType)) { + this.tuple = contentType.length; + for (var i = 0; i < contentType.length; i++) { + var prop = this.defProp(String(i)); + contentType[i].propagate(prop); + prop.propagate(content); + } + } else if (contentType) { + this.tuple = 0; + contentType.propagate(content); + } + }; + Arr.prototype = extend(Obj.prototype, { + constructor: Arr, + toString: function(maxDepth) { + if (maxDepth == null) maxDepth = 0; + if (maxDepth <= -3) return "[?]"; + var content = ""; + if (this.tuple) { + var similar; + for (var i = 0; i in this.props; i++) { + var type = toString(this.getProp(String(i)), maxDepth - 1, this); + if (similar == null) + similar = type; + else if (similar != type) + similar = false; + else + similar = type; + content += (content ? ", " : "") + type; + } + if (similar) content = similar; + } else { + content = toString(this.getProp(""), maxDepth - 1, this); + } + return "[" + content + "]"; + }, + normalizeIntegerProp: function(prop) { + if (+prop < this.tuple) return prop; + else return ""; + } + }); + + var Sym = exports.Sym = function(name, originNode) { + Prim.call(this, cx.protos.Symbol, "Symbol"); + this.symName = name; + this.originNode = originNode; + }; + Sym.prototype = extend(Prim.prototype, { + constructor: Sym, + asPropName: function() { return ":" + this.symName }, + getSymbolType: function() { return this } + }); + + exports.getSymbol = function(name, originNode) { + var cleanName = name.replace(/[^\w$\.]/g, "_"); + var known = cx.symbols[cleanName]; + if (known) { + if (originNode && !known.originNode) known.originNode = originNode; + return known; + } + return cx.symbols[cleanName] = new Sym(cleanName, originNode); + }; + + // THE PROPERTY REGISTRY + + function registerProp(prop, obj) { + var data = cx.props[prop] || (cx.props[prop] = []); + data.push(obj); + } + + function objsWithProp(prop) { + return cx.props[prop]; + } + + // INFERENCE CONTEXT + + exports.Context = function(defs, parent) { + this.parent = parent; + this.props = Object.create(null); + this.protos = Object.create(null); + this.origins = []; + this.curOrigin = "ecmascript"; + this.paths = Object.create(null); + this.definitions = Object.create(null); + this.purgeGen = 0; + this.workList = null; + this.disabledComputing = null; + this.curSuperCtor = this.curSuper = null; + this.symbols = Object.create(null); + + exports.withContext(this, function() { + cx.protos.Object = new Obj(null, "Object.prototype"); + cx.topScope = new Scope(); + cx.topScope.name = ""; + cx.protos.Array = new Obj(true, "Array.prototype"); + cx.protos.Function = new Fn("Function.prototype", ANull, [], [], ANull); + cx.protos.Function.proto = cx.protos.Object; + cx.protos.RegExp = new Obj(true, "RegExp.prototype"); + cx.protos.String = new Obj(true, "String.prototype"); + cx.protos.Number = new Obj(true, "Number.prototype"); + cx.protos.Boolean = new Obj(true, "Boolean.prototype"); + cx.protos.Symbol = new Obj(true, "Symbol.prototype"); + cx.str = new Prim(cx.protos.String, "string"); + cx.bool = new Prim(cx.protos.Boolean, "bool"); + cx.num = new Prim(cx.protos.Number, "number"); + cx.curOrigin = null; + + if (defs) for (var i = 0; i < defs.length; ++i) + def.load(defs[i]); + }); + }; + + exports.Context.prototype.startAnalysis = function() { + this.disabledComputing = this.workList = this.curSuperCtor = this.curSuper = null; + }; + + var cx = null; + exports.cx = function() { return cx; }; + + exports.withContext = function(context, f) { + var old = cx; + cx = context; + try { return f(); } + finally { cx = old; } + }; + + exports.TimedOut = function() { + this.message = "Timed out"; + this.stack = (new Error()).stack; + }; + exports.TimedOut.prototype = Object.create(Error.prototype); + exports.TimedOut.prototype.name = "infer.TimedOut"; + + var timeout; + exports.withTimeout = function(ms, f) { + var end = +new Date + ms; + var oldEnd = timeout; + if (oldEnd && oldEnd < end) return f(); + timeout = end; + try { return f(); } + finally { timeout = oldEnd; } + }; + + exports.addOrigin = function(origin) { + if (cx.origins.indexOf(origin) < 0) cx.origins.push(origin); + }; + + var baseMaxWorkDepth = 20, reduceMaxWorkDepth = 0.0001; + function withWorklist(f) { + if (cx.workList) return f(cx.workList); + + var list = [], depth = 0; + var add = cx.workList = function(type, target, weight) { + if (depth < baseMaxWorkDepth - reduceMaxWorkDepth * list.length) + list.push(type, target, weight, depth); + }; + var ret = f(add); + for (var i = 0; i < list.length; i += 4) { + if (timeout && +new Date >= timeout) + throw new exports.TimedOut(); + depth = list[i + 3] + 1; + list[i + 1].addType(list[i], list[i + 2]); + } + cx.workList = null; + return ret; + } + + function withSuper(ctor, obj, f) { + var oldCtor = cx.curSuperCtor, oldObj = cx.curSuper; + cx.curSuperCtor = ctor; cx.curSuper = obj; + var result = f(); + cx.curSuperCtor = oldCtor; cx.curSuper = oldObj; + return result; + } + + // SCOPES + + var Scope = exports.Scope = function(prev, originNode, isBlock, isCatch) { + Obj.call(this, prev || true); + this.prev = prev; + this.originNode = originNode; + this.isBlock = !!isBlock; + this.isCatch = !!isCatch; + }; + Scope.prototype = extend(Obj.prototype, { + constructor: Scope, + defVar: function(name, originNode) { + for (var s = this; ; s = s.proto) { + var found = s.props[name]; + if (found) return found; + if (!s.prev) return s.defProp(name, originNode); + } + } + }); + + function functionScope(scope, arrow) { + while (scope.isBlock || scope.isCatch || (arrow === false && scope.fnType && scope.fnType.isArrowFn())) + scope = scope.prev; + return scope; + } + + + // RETVAL COMPUTATION HEURISTICS + + function maybeInstantiate(scope, score) { + var fn = functionScope(scope).fnType; + if (fn) fn.instantiateScore = (fn.instantiateScore || 0) + score; + } + + var NotSmaller = {}; + function nodeSmallerThan(node, n) { + try { + walk.simple(node, {Expression: function() { if (--n <= 0) throw NotSmaller; }}); + return true; + } catch(e) { + if (e == NotSmaller) return false; + throw e; + } + } + + function maybeTagAsInstantiated(node, fn) { + var score = fn.instantiateScore; + if (!cx.disabledComputing && score && fn.args.length && nodeSmallerThan(node, score * 5)) { + maybeInstantiate(functionScope(fn.originNode.scope.prev), score / 2); + setFunctionInstantiated(node, fn); + return true; + } else { + fn.instantiateScore = null; + } + } + + function setFunctionInstantiated(node, fn) { + // Disconnect the arg avals, so that we can add info to them without side effects + var refScope = node.scope; + for (var i = 0; i < fn.args.length; ++i) fn.args[i] = new AVal; + fn.self = new AVal; + fn.computeRet = function(self, args) { + // Prevent recursion + return withDisabledComputing(fn, function() { + var oldOrigin = cx.curOrigin; + cx.curOrigin = fn.origin; + var scope = node.scope ? node.scope : refScope; + var scopeCopy = new Scope(scope.prev, scope.originNode); + for (var v in scope.props) { + var local = scopeCopy.defProp(v, scope.props[v].originNode); + for (var i = 0; i < args.length; ++i) if (fn.argNames[i] == v && i < args.length) + args[i].propagate(local); + } + var argNames = fn.argNames.length != args.length ? fn.argNames.slice(0, args.length) : fn.argNames; + while (argNames.length < args.length) argNames.push("?"); + scopeCopy.fnType = new Fn(fn.name, self, args, argNames, ANull, fn.generator, fn.async); + scopeCopy.fnType.originNode = fn.originNode; + if (fn.arguments) { + var argset = scopeCopy.fnType.arguments = new AVal; + scopeCopy.defProp("arguments").addType(new Arr(argset)); + for (var i = 0; i < args.length; ++i) args[i].propagate(argset); + } + node.scope = scopeCopy; + walk.recursive(node.body, scopeCopy, null, scopeGatherer); + walk.recursive(node.body, scopeCopy, null, inferWrapper); + cx.curOrigin = oldOrigin; + return scopeCopy.fnType.retval; + }); + }; + } + + function maybeTagAsGeneric(fn) { + var target = fn.retval; + if (target == ANull || fn.isArrowFn()) return; + var targetInner, asArray; + if (!target.isEmpty() && (targetInner = target.getType()) instanceof Arr) + target = asArray = targetInner.getProp(""); + + function explore(aval, path, depth) { + if (depth > 3 || !aval.forward) return; + for (var i = 0; i < aval.forward.length; ++i) { + var prop = aval.forward[i].propagatesTo(); + if (!prop) continue; + var newPath = path, dest; + if (prop instanceof AVal) { + dest = prop; + } else if (prop.target instanceof AVal) { + newPath += prop.pathExt; + dest = prop.target; + } else continue; + if (dest == target) return newPath; + var found = explore(dest, newPath, depth + 1); + if (found) return found; + } + } + + var foundPath = explore(fn.self, "!this", 0); + for (var i = 0; !foundPath && i < fn.args.length; ++i) + foundPath = explore(fn.args[i], "!" + i, 0); + + if (foundPath) { + if (asArray) foundPath = "[" + foundPath + "]"; + var p = new def.TypeParser(foundPath); + var parsed = p.parseType(true); + fn.computeRet = parsed.apply ? parsed : function() { return parsed; }; + fn.computeRetSource = foundPath; + return true; + } + } + + // SCOPE GATHERING PASS + + function addVar(scope, nameNode) { + return scope.defProp(nameNode.name, nameNode); + } + function patternName(node) { + if (node.type == "Identifier") return node.name; + if (node.type == "AssignmentPattern") return patternName(node.left); + if (node.type == "ObjectPattern") return "{" + node.properties.map(function(e) { return patternName(e.type === 'RestElement' ? e : e.value) }).join(", ") + "}"; + if (node.type == "ArrayPattern") return "[" + node.elements.map(function(e) { return e ? patternName(e) : "" }).join(", ") + "]"; + if (node.type == "RestElement") return "..." + patternName(node.argument); + return "_"; + } + + function isBlockScopedDecl(node) { + return node.type == "VariableDeclaration" && node.kind != "var" || + node.type == "FunctionDeclaration" || + node.type == "ClassDeclaration"; + } + + function patternScopes(inner, outer) { + return {inner: inner, outer: outer || inner}; + } + + var scopeGatherer = exports.scopeGatherer = walk.make({ + VariablePattern: function(node, scopes) { + if (scopes.inner) addVar(scopes.inner, node); + }, + AssignmentPattern: function(node, scopes, c) { + c(node.left, scopes, "Pattern"); + c(node.right, scopes.outer, "Expression"); + }, + AssignmentExpression: function(node, scope, c) { + if (node.left.type == "MemberExpression") + c(node.left, scope, "Expression"); + else + c(node.left, patternScopes(false, scope), "Pattern"); + c(node.right, scope, "Expression"); + }, + MemberPattern: function(node, scope, c) { + c(node, scope.outer); + }, + Function: function(node, scope, c) { + var inner = node.scope = new Scope(scope, node); + var argVals = [], argNames = []; + for (var i = 0; i < node.params.length; ++i) { + var param = node.params[i]; + argNames.push(patternName(param)); + if (param.type == "Identifier") { + argVals.push(addVar(inner, param)); + } else { + var arg = new AVal; + argVals.push(arg); + arg.originNode = param; + c(param, patternScopes(inner), "Pattern"); + } + } + inner.fnType = new Fn(node.id && node.id.name, new AVal, argVals, argNames, ANull, node.generator, node.async); + inner.fnType.originNode = node; + if (node.id) { + var decl = node.type == "FunctionDeclaration"; + addVar(decl ? scope : inner, node.id); + } + c(node.body, inner, node.expression ? "Expression" : "Statement"); + }, + BlockStatement: function(node, scope, c) { + if (!node.scope && node.body.some(isBlockScopedDecl)) + scope = node.scope = new Scope(scope, node, true); + walk.base.BlockStatement(node, scope, c); + }, + CatchClause: function(node, scope, c) { + scope = node.scope = new Scope(scope, node, false, true); + if (node.param.type == "Identifier") { + var v = addVar(scope, node.param); + c(node.body, scope, "Statement"); + var ecma = cx.definitions.ecmascript; + if (ecma && v.isEmpty()) getInstance(ecma["Error.prototype"]).propagate(v, WG_CATCH_ERROR); + } else { + c(node.param, patternScopes(scope), "Pattern"); + } + }, + VariableDeclaration: function(node, scope, c) { + var targetScope = node.kind == "var" ? functionScope(scope) : scope; + for (var i = 0; i < node.declarations.length; ++i) { + var decl = node.declarations[i]; + c(decl.id, patternScopes(targetScope, scope), "Pattern"); + if (decl.init) c(decl.init, scope, "Expression"); + } + }, + ClassDeclaration: function(node, scope, c) { + if (node.id) addVar(scope, node.id); + if (node.superClass) c(node.superClass, scope, "Expression"); + for (var i = 0; i < node.body.body.length; i++) + c(node.body.body[i], scope); + }, + ForInStatement: function(node, scope, c) { + if (!node.scope && isBlockScopedDecl(node.left)) + scope = node.scope = new Scope(scope, node, true); + walk.base.ForInStatement(node, scope, c); + }, + ForStatement: function(node, scope, c) { + if (!node.scope && node.init && isBlockScopedDecl(node.init)) + scope = node.scope = new Scope(scope, node, true); + walk.base.ForStatement(node, scope, c); + }, + ImportDeclaration: function(node, scope) { + for (var i = 0; i < node.specifiers.length; i++) + addVar(scope, node.specifiers[i].local); + } + }); + scopeGatherer.ForOfStatement = scopeGatherer.ForInStatement; + + function rmScope(node) { if (node.scope) node.scope = null } + var scopeClearer = {BlockStatement: rmScope, Function: rmScope, CatchClause: rmScope, + ForInStateMent: rmScope, ForStatement: rmScope}; + exports.clearScopes = function(ast) { + walk.simple(ast, scopeClearer); + }; + + // CONSTRAINT GATHERING PASS + + var propName = exports.propName = function(node, inferInScope) { + var key = node.property || node.key; + if (!node.computed && key.type == "Identifier") return key.name; + if (key.type == "Literal") { + if (typeof key.value == "string") return key.value; + if (typeof key.value == "number") return String(key.value); + } + if (inferInScope) { + var symName = symbolName(infer(key, inferInScope)); + if (symName) return node.propName = symName; + } else if (node.propName) { + return node.propName; + } + return ""; + }; + function symbolName(val) { + var sym = val.getSymbolType(); + if (sym) return sym.asPropName(); + } + + function unopResultType(op) { + switch (op) { + case "+": case "-": case "~": return cx.num; + case "!": return cx.bool; + case "typeof": return cx.str; + case "void": case "delete": return ANull; + } + } + function binopIsBoolean(op) { + switch (op) { + case "==": case "!=": case "===": case "!==": case "<": case ">": case ">=": case "<=": + case "in": case "instanceof": return true; + } + } + function literalType(node) { + if (node.regex) return getInstance(cx.protos.RegExp); + switch (typeof node.value) { + case "boolean": return cx.bool; + case "number": return cx.num; + case "string": return cx.str; + case "object": + case "function": + if (!node.value) return ANull; + return getInstance(cx.protos.RegExp); + } + } + + function join(a, b) { + if (a == b || b == ANull) return a; + if (a == ANull) return b; + var joined = new AVal; + a.propagate(joined); + b.propagate(joined); + return joined; + } + + function connectParams(node, scope) { + for (var i = 0; i < node.params.length; i++) { + var param = node.params[i]; + if (param.type == "Identifier") continue; + connectPattern(param, scope, node.scope.fnType.args[i]); + } + } + + function ensureVar(node, scope) { + return scope.hasProp(node.name) || cx.topScope.defProp(node.name, node); + } + + var inferPatternVisitor = exports.inferPatternVisitor = { + Identifier: function(node, scope, source) { + source.propagate(ensureVar(node, scope)); + }, + MemberExpression: function(node, scope, source) { + var obj = infer(node.object, scope); + var pName = propName(node, scope); + obj.propagate(new DefProp(pName, source, node.property)); + }, + RestElement: function(node, scope, source) { + connectPattern(node.argument, scope, new Arr(source)); + }, + ObjectPattern: function(node, scope, source) { + for (var i = 0; i < node.properties.length; ++i) { + var prop = node.properties[i]; + if (prop.type == 'RestElement') { continue; } + connectPattern(prop.value, scope, source.getProp(propName(prop))); + } + }, + ArrayPattern: function(node, scope, source) { + for (var i = 0; i < node.elements.length; i++) + if (node.elements[i]) + connectPattern(node.elements[i], scope, source.getProp(String(i))); + }, + AssignmentPattern: function(node, scope, source) { + connectPattern(node.left, scope, join(source, infer(node.right, scope))); + } + }; + + function connectPattern(node, scope, source) { + var connecter = inferPatternVisitor[node.type]; + if (connecter) connecter(node, scope, source); + } + + function getThis(scope) { + var fnScope = functionScope(scope); + return fnScope.fnType ? fnScope.fnType.self : fnScope; + } + + function maybeAddPhantomObj(obj) { + if (!obj.isEmpty() || !obj.propertyOf) return; + obj.propertyOf.getProp(obj.propertyName).addType(new Obj, WG_PHANTOM_OBJ); + maybeAddPhantomObj(obj.propertyOf); + } + + function inferClass(node, scope, name) { + if (!name && node.id) name = node.id.name; + + var sup = cx.protos.Object, supCtor, delayed; + if (node.superClass) { + if (node.superClass.type == "Literal" && node.superClass.value == null) { + sup = null; + } else { + var supVal = infer(node.superClass, scope), supProto; + supCtor = supVal.getFunctionType(); + if (supCtor && (supProto = supCtor.getProp("prototype").getObjType())) { + sup = supProto; + } else { + supCtor = supVal; + delayed = supVal.getProp("prototype"); + } + } + } + var proto = new Obj(sup, name && name + ".prototype"); + if (delayed) delayed.propagate(new HasProto(proto)); + + return withSuper(supCtor, delayed || sup, function() { + var ctor, body = node.body.body; + for (var i = 0; i < body.length; i++) + if (body[i].kind == "constructor") ctor = body[i].value; + var fn = node.objType = ctor ? infer(ctor, scope) : new Fn(name, ANull, [], null, ANull); + fn.originNode = node.id || ctor || node; + + var inst = getInstance(proto, fn); + fn.self.addType(inst); + fn.defProp("prototype", node).addType(proto); + for (var i = 0; i < body.length; i++) { + var method = body[i], target; + if (method.kind == "constructor") continue; + var pName = propName(method, scope); + if (pName == "" || method.kind == "set") { + target = ANull; + } else { + target = (method.static ? fn : proto).defProp(pName, method.key); + target.initializer = true; + if (method.kind == "get") target = new IsCallee(inst, [], null, target); + } + infer(method.value, scope, target); + var methodFn = target.getFunctionType(); + if (methodFn) methodFn.self.addType(inst); + } + return fn; + }); + } + + function arrayLiteralType(elements, scope, inner) { + var tuple = elements.length > 1 && elements.length < 6; + if (tuple) { + var homogenous = true, litType; + for (var i = 0; i < elements.length; i++) { + var elt = elements[i]; + if (!elt) + tuple = false; + else if (elt.type != "Literal" || (litType && litType != typeof elt.value)) + homogenous = false; + else + litType = typeof elt.value; + } + if (homogenous) tuple = false; + } + + if (tuple) { + var types = []; + for (var i = 0; i < elements.length; ++i) + types.push(inner(elements[i], scope)); + return new Arr(types); + } else if (elements.length < 2) { + return new Arr(elements[0] && inner(elements[0], scope)); + } else { + var eltVal = new AVal; + for (var i = 0; i < elements.length; i++) + if (elements[i]) inner(elements[i], scope).propagate(eltVal); + return new Arr(eltVal); + } + } + + function ret(f) { + return function(node, scope, out, name) { + var r = f(node, scope, name); + if (out) r.propagate(out); + return r; + }; + } + function fill(f) { + return function(node, scope, out, name) { + if (!out) out = new AVal; + f(node, scope, out, name); + return out; + }; + } + + var inferExprVisitor = exports.inferExprVisitor = { + ArrayExpression: ret(function(node, scope) { + return arrayLiteralType(node.elements, scope, infer); + }), + ObjectExpression: ret(function(node, scope, name) { + var proto = cx.protos.Object, waitForProto; + for (var i = 0; i < node.properties.length; ++i) { + var prop = node.properties[i]; + if (prop.type == 'SpreadElement') { continue; } + if (prop.key.name == "__proto__") { + if (prop.value.type == "Literal" && prop.value.value == null) { + proto = null; + } else { + var protoVal = infer(prop.value, scope), known = protoVal.getObjType(); + if (known) proto = known; + else waitForProto = protoVal; + } + } + } + + var obj = node.objType = new Obj(proto, name); + if (waitForProto) waitForProto.propagate(new HasProto(obj)); + obj.originNode = node; + + withSuper(null, waitForProto || proto, function() { + for (var i = 0; i < node.properties.length; ++i) { + var prop = node.properties[i], key = prop.key; + if (prop.type == 'SpreadElement' || ignoredProp(prop.key.name)) continue; + + var name = propName(prop, scope), target; + if (name == "" || prop.kind == "set") { + target = ANull; + } else { + target = obj.defProp(name, key); + var val = target; + val.initializer = true; + if (prop.kind == "get") + target = new IsCallee(obj, [], null, val); + } + infer(prop.value, scope, target, name); + if (prop.value.type == "FunctionExpression") + prop.value.scope.fnType.self.addType(obj, WG_SPECULATIVE_THIS); + } + }); + return obj; + }), + FunctionExpression: ret(function(node, scope, name) { + var inner = node.scope, fn = inner.fnType; + if (name && !fn.name) fn.name = name; + connectParams(node, inner); + if (node.expression) + infer(node.body, inner, inner.fnType.retval = new AVal); + else + walk.recursive(node.body, inner, null, inferWrapper, "Statement"); + if (node.type == "ArrowFunctionExpression") + getThis(scope).propagate(fn.self); + maybeTagAsInstantiated(node, fn) || maybeTagAsGeneric(fn); + if (node.id) inner.getProp(node.id.name).addType(fn); + return fn; + }), + ClassExpression: ret(inferClass), + SequenceExpression: ret(function(node, scope) { + for (var i = 0, l = node.expressions.length - 1; i < l; ++i) + infer(node.expressions[i], scope, ANull); + return infer(node.expressions[l], scope); + }), + UnaryExpression: ret(function(node, scope) { + infer(node.argument, scope, ANull); + return unopResultType(node.operator); + }), + UpdateExpression: ret(function(node, scope) { + infer(node.argument, scope, ANull); + return cx.num; + }), + BinaryExpression: ret(function(node, scope) { + if (node.operator == "+") { + var lhs = infer(node.left, scope); + var rhs = infer(node.right, scope); + if (lhs.hasType(cx.str) || rhs.hasType(cx.str)) return cx.str; + if (lhs.hasType(cx.num) && rhs.hasType(cx.num)) return cx.num; + var result = new AVal; + lhs.propagate(new IsAdded(rhs, result)); + rhs.propagate(new IsAdded(lhs, result)); + return result; + } else { + infer(node.left, scope, ANull); + infer(node.right, scope, ANull); + return binopIsBoolean(node.operator) ? cx.bool : cx.num; + } + }), + AssignmentExpression: ret(function(node, scope, name) { + var rhs, pName; + if (node.left.type == "MemberExpression") { + pName = propName(node.left, scope); + if (!name) + name = node.left.object.type == "Identifier" ? node.left.object.name + "." + pName : pName; + } else if (!name && node.left.type == "Identifier") { + name = node.left.name; + } + + if (node.operator && node.operator != "=" && node.operator != "+=") { + infer(node.right, scope, ANull); + rhs = cx.num; + } else { + rhs = infer(node.right, scope, null, name); + } + + if (node.left.type == "MemberExpression") { + var obj = infer(node.left.object, scope); + if (pName == "prototype") maybeInstantiate(scope, 20); + if (pName == "") { + // This is a hack to recognize for/in loops that copy + // properties, and do the copying ourselves, insofar as we + // manage, because such loops tend to be relevant for type + // information. + var v = node.left.property.name, local = scope.props[v], over = local && local.iteratesOver; + if (over) { + maybeInstantiate(scope, 20); + var fromRight = node.right.type == "MemberExpression" && node.right.computed && node.right.property.name == v; + over.forAllProps(function(prop, val, local) { + if (local && prop != "prototype" && prop != "") + obj.propagate(new DefProp(prop, fromRight ? val : ANull)); + }); + return rhs; + } + } + + obj.propagate(new DefProp(pName, rhs, node.left.property)); + maybeAddPhantomObj(obj); + if (node.right.type == "FunctionExpression") + obj.propagate(node.right.scope.fnType.self, WG_SPECULATIVE_THIS); + } else { + connectPattern(node.left, scope, rhs); + } + return rhs; + }), + LogicalExpression: fill(function(node, scope, out) { + infer(node.left, scope, out); + infer(node.right, scope, out); + }), + ConditionalExpression: fill(function(node, scope, out) { + infer(node.test, scope, ANull); + infer(node.consequent, scope, out); + infer(node.alternate, scope, out); + }), + NewExpression: fill(function(node, scope, out, name) { + if (node.callee.type == "Identifier" && node.callee.name in scope.props) + maybeInstantiate(scope, 20); + + for (var i = 0, args = []; i < node.arguments.length; ++i) + args.push(infer(node.arguments[i], scope)); + var callee = infer(node.callee, scope); + var self = new AVal; + callee.propagate(new IsCtor(self, name && /\.prototype$/.test(name))); + self.propagate(out, WG_NEW_INSTANCE); + callee.propagate(new IsCallee(self, args, node.arguments, new IfObj(out))); + }), + CallExpression: fill(function(node, scope, out) { + for (var i = 0, args = []; i < node.arguments.length; ++i) + args.push(infer(node.arguments[i], scope)); + var outerFn = functionScope(scope).fnType; + if (node.callee.type == "MemberExpression") { + var self = infer(node.callee.object, scope); + var pName = propName(node.callee, scope); + if (outerFn && (pName == "call" || pName == "apply") && + outerFn.args.indexOf(self) > -1) + maybeInstantiate(scope, 30); + self.propagate(new HasMethodCall(pName, args, node.arguments, out)); + } else if (node.callee.type == "Super" && cx.curSuperCtor) { + node.callee.superType = cx.curSuperCtor; + cx.curSuperCtor.propagate(new IsCallee(getThis(scope), args, node.arguments, out)); + getThis(scope).propagate(out, WG_NEW_INSTANCE); + } else { + var callee = infer(node.callee, scope); + if (outerFn && outerFn.args.indexOf(callee) > -1) + maybeInstantiate(scope, 30); + var knownFn = callee.getFunctionType(); + if (knownFn && knownFn.instantiateScore && outerFn) + maybeInstantiate(scope, knownFn.instantiateScore / 5); + callee.propagate(new IsCallee(cx.topScope, args, node.arguments, out)); + } + }), + AwaitExpression: fill(function(node, scope, out, name) { + var arg = infer(node.argument, scope, null, name); + var tp = arg.getType(); + if (tp && tp.constructor == Obj && tp.name == "Promise") { + if (tp.hasProp(":t")) { + tp.getProp(":t").propagate(out); + } + } else { + arg.propagate(out); + } + }), + MemberExpression: fill(function(node, scope, out) { + var name = propName(node), wg; + if (name == "") { + var propType = infer(node.property, scope); + var symName = symbolName(propType); + if (symName) + name = node.propName = symName; + else if (!propType.hasType(cx.num)) + wg = WG_MULTI_MEMBER; + } + infer(node.object, scope).getProp(name).propagate(out, wg); + }), + Identifier: ret(function(node, scope) { + if (node.name == "arguments") { + var fnScope = functionScope(scope, false); + if (fnScope.fnType && !(node.name in fnScope.props)) + fnScope.defProp(node.name, fnScope.fnType.originNode) + .addType(new Arr(fnScope.fnType.arguments = new AVal)); + } + return scope.getProp(node.name); + }), + ThisExpression: ret(function(_node, scope) { + return getThis(scope); + }), + Super: ret(function(node) { + return node.superType = cx.curSuper || ANull; + }), + Literal: ret(function(node) { + return literalType(node); + }), + TemplateLiteral: ret(function(node, scope) { + for (var i = 0; i < node.expressions.length; ++i) + infer(node.expressions[i], scope, ANull); + return cx.str; + }), + TaggedTemplateExpression: fill(function(node, scope, out) { + var args = [new Arr(cx.str)]; + for (var i = 0; i < node.quasi.expressions.length; ++i) + args.push(infer(node.quasi.expressions[i], scope)); + infer(node.tag, scope, new IsCallee(cx.topScope, args, node.quasi.expressions, out)); + }), + YieldExpression: ret(function(node, scope) { + var output = ANull, fn = functionScope(scope).fnType; + if (fn) { + if (fn.retval == ANull) fn.retval = new AVal; + if (!fn.yieldval) fn.yieldval = new AVal; + output = fn.retval; + } + if (node.argument) { + if (node.delegate) { + infer(node.argument, scope, new HasMethodCall("next", [], null, + new GetProp("value", output))); + } else { + infer(node.argument, scope, output); + } + } + return fn ? fn.yieldval : ANull; + }) + }; + inferExprVisitor.ArrowFunctionExpression = inferExprVisitor.FunctionExpression; + + function infer(node, scope, out, name) { + var handler = inferExprVisitor[node.type]; + return handler ? handler(node, scope, out, name) : ANull; + } + + function loopPattern(init) { + return init.type == "VariableDeclaration" ? init.declarations[0].id : init; + } + + var inferWrapper = exports.inferWrapper = walk.make({ + Expression: function(node, scope) { + infer(node, node.scope || scope, ANull); + }, + + ObjectExpression: function(node, scope) { + infer(node, node.scope || scope, ANull); + }, + + FunctionDeclaration: function(node, scope, c) { + var inner = node.scope, fn = inner.fnType; + connectParams(node, inner); + c(node.body, inner, "Statement"); + maybeTagAsInstantiated(node, fn) || maybeTagAsGeneric(fn); + if (node.id) scope.getProp(node.id.name).addType(fn); + }, + + Statement: function(node, scope, c) { + c(node, node.scope || scope); + }, + + ExportDefaultDeclaration: function(node, scope, c) { + c(node.declaration, node.scope || scope); + }, + + VariableDeclaration: function(node, scope) { + for (var i = 0; i < node.declarations.length; ++i) { + var decl = node.declarations[i]; + if (decl.id.type == "Identifier") { + var prop = scope.getProp(decl.id.name); + if (decl.init) + infer(decl.init, scope, prop, decl.id.name); + } else if (decl.init) { + connectPattern(decl.id, scope, infer(decl.init, scope)); + } + } + }, + + ClassDeclaration: function(node, scope) { + if (!node.id) inferClass(node, scope); + else scope.getProp(node.id.name).addType(inferClass(node, scope, node.id.name)); + }, + + ReturnStatement: function(node, scope) { + if (!node.argument) return; + var output = ANull, fn = functionScope(scope).fnType; + if (fn) { + if (fn.retval == ANull) fn.retval = new AVal; + output = fn.retval; + } + infer(node.argument, scope, output); + }, + + ForInStatement: function(node, scope, c) { + var source = infer(node.right, scope); + if ((node.right.type == "Identifier" && node.right.name in scope.props) || + (node.right.type == "MemberExpression" && node.right.property.name == "prototype")) { + maybeInstantiate(scope, 5); + var pattern = loopPattern(node.left); + if (pattern.type == "Identifier") { + if (pattern.name in scope.props) + scope.getProp(pattern.name).iteratesOver = source; + source.getProp("").propagate(ensureVar(pattern, scope)); + } else { + connectPattern(pattern, scope, source.getProp("")); + } + } + c(node.body, scope, "Statement"); + }, + + ForOfStatement: function(node, scope, c) { + var pattern = loopPattern(node.left), target; + if (pattern.type == "Identifier") + target = ensureVar(pattern, scope); + else + connectPattern(pattern, scope, target = new AVal); + + if (node.await) { + infer(node.right, scope, new HasMethodCall(":Symbol.asyncIterator", [], null, + new HasMethodCall("next", [], null, + new GetProp(":t", + new GetProp("value", target))))); + } else { + infer(node.right, scope, new HasMethodCall(":Symbol.iterator", [], null, + new HasMethodCall("next", [], null, + new GetProp("value", target)))); + } + c(node.body, scope, "Statement"); + } + }); + + // PARSING + + var parse = exports.parse = function(text, options, thirdArg) { + if (!options || Array.isArray(options)) options = thirdArg; + var ast; + try { ast = acorn.parse(text, options); } + catch(e) { ast = acorn_loose.parse(text, options); } + return ast; + }; + + // ANALYSIS INTERFACE + + exports.analyze = function(ast, name, scope) { + if (typeof ast == "string") ast = parse(ast); + + if (!name) name = "file#" + cx.origins.length; + exports.addOrigin(cx.curOrigin = name); + + if (!scope) scope = cx.topScope; + cx.startAnalysis(); + + walk.recursive(ast, scope, null, scopeGatherer); + if (cx.parent) cx.parent.signal("preInfer", ast, scope); + walk.recursive(ast, scope, null, inferWrapper); + if (cx.parent) cx.parent.signal("postInfer", ast, scope); + + cx.curOrigin = null; + }; + + // PURGING + + exports.purge = function(origins, start, end) { + var test = makePredicate(origins, start, end); + ++cx.purgeGen; + cx.topScope.purge(test); + for (var prop in cx.props) { + var list = cx.props[prop]; + for (var i = 0; i < list.length; ++i) { + var obj = list[i], av = obj.props[prop]; + if (!av || test(av, av.originNode)) list.splice(i--, 1); + } + if (!list.length) delete cx.props[prop]; + } + }; + + function makePredicate(origins, start, end) { + var arr = Array.isArray(origins); + if (arr && origins.length == 1) { origins = origins[0]; arr = false; } + if (arr) { + if (end == null) return function(n) { return origins.indexOf(n.origin) > -1; }; + return function(n, pos) { return pos && pos.start >= start && pos.end <= end && origins.indexOf(n.origin) > -1; }; + } else { + if (end == null) return function(n) { return n.origin == origins; }; + return function(n, pos) { return pos && pos.start >= start && pos.end <= end && n.origin == origins; }; + } + } + + AVal.prototype.purge = function(test) { + if (this.purgeGen == cx.purgeGen) return; + this.purgeGen = cx.purgeGen; + for (var i = 0; i < this.types.length; ++i) { + var type = this.types[i]; + if (test(type, type.originNode)) + this.types.splice(i--, 1); + else + type.purge(test); + } + if (!this.types.length) this.maxWeight = 0; + + if (this.forward) for (var i = 0; i < this.forward.length; ++i) { + var f = this.forward[i]; + if (test(f)) { + this.forward.splice(i--, 1); + if (this.props) this.props = null; + } else if (f.purge) { + f.purge(test); + } + } + }; + ANull.purge = function() {}; + Obj.prototype.purge = function(test) { + if (this.purgeGen == cx.purgeGen) return true; + this.purgeGen = cx.purgeGen; + for (var p in this.props) { + var av = this.props[p]; + if (test(av, av.originNode)) + this.removeProp(p); + av.purge(test); + } + }; + Fn.prototype.purge = function(test) { + if (Obj.prototype.purge.call(this, test)) return; + this.self.purge(test); + this.retval.purge(test); + for (var i = 0; i < this.args.length; ++i) this.args[i].purge(test); + }; + + // EXPRESSION TYPE DETERMINATION + + function findByPropertyName(name) { + guessing = true; + var found = objsWithProp(name); + if (found) for (var i = 0; i < found.length; ++i) { + var val = found[i].getProp(name); + if (!val.isEmpty()) return val; + } + return ANull; + } + + function generatorResult(input, output, async) { + var defs = cx.definitions.ecmascript; + var valObj = new Obj(true); + valObj.defProp("done").addType(cx.bool); + output.propagate(valObj.defProp("value")); + var retObj = valObj; + if (async && defs) { + retObj = new Obj(defs["Promise.prototype"]); + retObj.getType().propagate(new DefProp(':t', valObj)); + } + var method = new Fn(null, ANull, input ? [input] : [], input ? ["?"] : [], retObj); + var result = new Obj(defs ? async ? defs.async_generator_prototype : defs.generator_prototype : true); + result.defProp("next").addType(method); + return result; + } + + function maybeIterator(fn, output) { + if (!fn.generator) return output; + if (!fn.computeRet) { // Reuse iterator objects for non-computed return types + if (fn.generator === true) fn.generator = generatorResult(fn.yieldval, output, fn.async); + return fn.generator; + } + return generatorResult(fn.yieldval, output, fn.async); + } + + function computeReturnType(funcNode, argNodes, scope) { + var fn = findType(funcNode, scope).getFunctionType(); + if (!fn) return ANull; + var result = fn.retval; + if (fn.computeRet) { + for (var i = 0, args = []; i < argNodes.length; ++i) + args.push(findType(argNodes[i], scope)); + var self = ANull; + if (funcNode.type == "MemberExpression") + self = findType(funcNode.object, scope); + result = fn.computeRet(self, args, argNodes); + } + return maybeIterator(fn, result); + } + + var typeFinder = exports.typeFinder = { + ArrayExpression: function(node, scope) { + return arrayLiteralType(node.elements, scope, findType); + }, + ObjectExpression: function(node) { + return node.objType; + }, + ClassDeclaration: function(node) { + return node.objType; + }, + ClassExpression: function(node) { + return node.objType; + }, + FunctionDeclaration: function(node) { + return node.scope.fnType; + }, + FunctionExpression: function(node) { + return node.scope.fnType; + }, + ArrowFunctionExpression: function(node) { + return node.scope.fnType; + }, + SequenceExpression: function(node, scope) { + return findType(node.expressions[node.expressions.length-1], scope); + }, + UnaryExpression: function(node) { + return unopResultType(node.operator); + }, + UpdateExpression: function() { + return cx.num; + }, + BinaryExpression: function(node, scope) { + if (binopIsBoolean(node.operator)) return cx.bool; + if (node.operator == "+") { + var lhs = findType(node.left, scope); + var rhs = findType(node.right, scope); + if (lhs.hasType(cx.str) || rhs.hasType(cx.str)) return cx.str; + } + return cx.num; + }, + AssignmentExpression: function(node, scope) { + return findType(node.right, scope); + }, + LogicalExpression: function(node, scope) { + var lhs = findType(node.left, scope); + return lhs.isEmpty() ? findType(node.right, scope) : lhs; + }, + ConditionalExpression: function(node, scope) { + var lhs = findType(node.consequent, scope); + return lhs.isEmpty() ? findType(node.alternate, scope) : lhs; + }, + NewExpression: function(node, scope) { + var f = findType(node.callee, scope).getFunctionType(); + var proto = f && f.getProp("prototype").getObjType(); + if (!proto) return ANull; + return getInstance(proto, f); + }, + CallExpression: function(node, scope) { + return computeReturnType(node.callee, node.arguments, scope); + }, + MemberExpression: function(node, scope) { + var propN = propName(node), obj = findType(node.object, scope).getType(); + if (obj) return obj.getProp(propN); + if (propN == "") return ANull; + return findByPropertyName(propN); + }, + MethodDefinition: function(node) { + var propN = propName(node), obj = getThis(node.value.scope).getType(); + if (obj) return obj.getProp(propN); + return ANull; + }, + Identifier: function(node, scope) { + return scope.hasProp(node.name) || ANull; + }, + ThisExpression: function(_node, scope) { + return getThis(scope); + }, + Literal: function(node) { + return literalType(node); + }, + Super: ret(function(node) { + return node.superType; + }), + TemplateLiteral: function() { + return cx.str; + }, + TaggedTemplateExpression: function(node, scope) { + return computeReturnType(node.tag, node.quasi.expressions, scope); + }, + YieldExpression: function(_node, scope) { + var fn = functionScope(scope).fnType; + return fn ? fn.yieldval : ANull; + } + }; + + function findType(node, scope) { + var finder = typeFinder[node.type]; + return finder ? finder(node, scope) : ANull; + } + + var searchVisitor = exports.searchVisitor = walk.make({ + Function: function(node, _st, c) { + walk.base.Function(node, node.scope, c); + }, + CatchClause: function(node, _st, c) { + walk.base.CatchClause(node, node.scope, c); + }, + Property: function(node, st, c) { + if (node.computed) c(node.key, st, "Expression"); + if (node.key != node.value) c(node.value, st, "Expression"); + }, + Statement: function(node, st, c) { + c(node, node.scope || st); + }, + ImportSpecifier: function(node, st, c) { + c(node.local, st); + }, + ImportDefaultSpecifier: function(node, st, c) { + c(node.local, st); + }, + ImportNamespaceSpecifier: function(node, st, c) { + c(node.local, st); + } + }); + var searchExprVisitor = exports.searchExprVisitor = walk.make({ + MemberExpression: function(node, st, c) { + c(node.object, st, "Expression"); + if (node.computed) { c(node.property, st, "Expression"); } + }, + Property: function(node, st, c) { + if (node.computed) c(node.key, st, "Expression"); + c(node.value, st, "Expression"); + } + }, searchVisitor); + exports.fullVisitor = walk.make({ + MemberExpression: function(node, st, c) { + c(node.object, st, "Expression"); + c(node.property, st, node.computed ? "Expression" : null); + }, + Property: function(node, st, c) { + if (node.computed) c(node.key, st, "Expression"); + c(node.value, st, "Expression"); + } + }, searchVisitor); + + exports.findExpressionAt = function(ast, start, end, defaultScope, filter) { + var test = filter || function(_t, node) { + if (node.type == "Identifier" && node.name == "✖") return false; + return typeFinder.hasOwnProperty(node.type); + }; + return walk.findNodeAt(ast, start, end, test, searchExprVisitor, defaultScope || cx.topScope); + }; + exports.findClosestExpression = function(ast, start, end, defaultScope, filter) { + var test = filter || function(_t, node) { + if (start != null && node.start > start) return false; + if (node.type == "Identifier" && node.name == "✖") return false; + return typeFinder.hasOwnProperty(node.type); + }; + return walk.findNodeAround(ast, end, test, searchExprVisitor, defaultScope || cx.topScope); + }; + + exports.findExpressionAround = function(ast, start, end, defaultScope, filter) { + var test = filter || function(_t, node) { + if (start != null && node.start > start) return false; + if (node.type == "Identifier" && node.name == "✖") return false; + return typeFinder.hasOwnProperty(node.type); + }; + return walk.findNodeAround(ast, end, test, searchVisitor, defaultScope || cx.topScope); + }; + + exports.expressionType = function(found) { + return findType(found.node, found.state); + }; + + // Finding the expected type of something, from context + + exports.parentNode = function(child, ast) { + var stack = []; + function c(node, st, override) { + if (node.start <= child.start && node.end >= child.end) { + var top = stack[stack.length - 1]; + if (node == child) throw {found: top}; + if (top != node) stack.push(node); + walk.base[override || node.type](node, st, c); + if (top != node) stack.pop(); + } + } + try { + c(ast, null); + } catch (e) { + if (e.found) return e.found; + throw e; + } + }; + + var findTypeFromContext = exports.findTypeFromContext = { + ArrayExpression: function(parent, _, get) { return get(parent, true).getProp(""); }, + ObjectExpression: function(parent, node, get) { + for (var i = 0; i < parent.properties.length; ++i) { + var prop = node.properties[i]; + if (prop.value == node) + return get(parent, true).getProp(propName(prop)); + } + }, + UnaryExpression: function(parent) { return unopResultType(parent.operator); }, + UpdateExpression: function() { return cx.num; }, + BinaryExpression: function(parent) { return binopIsBoolean(parent.operator) ? cx.bool : cx.num; }, + AssignmentExpression: function(parent, _, get) { return get(parent.left); }, + LogicalExpression: function(parent, _, get) { return get(parent, true); }, + ConditionalExpression: function(parent, node, get) { + if (parent.consequent == node || parent.alternate == node) return get(parent, true); + }, + CallExpression: function(parent, node, get) { + for (var i = 0; i < parent.arguments.length; i++) { + var arg = parent.arguments[i]; + if (arg == node) { + var calleeType = get(parent.callee).getFunctionType(); + if (calleeType instanceof Fn) + return calleeType.args[i]; + break; + } + } + }, + ReturnStatement: function(_parent, node, get) { + // tweaking search position to avoid endless recursion + // when looking for definition of key in fn ( return fn ( return object ) ) + // see ternjs/tern#777 + var fnNode = walk.findNodeAround(node.sourceFile.ast, node.start - 1, "Function"); + if (fnNode) { + var fnType = fnNode.node.type != "FunctionDeclaration" + ? get(fnNode.node, true).getFunctionType() + : fnNode.node.scope.fnType; + if (fnType) return fnType.retval.getType(); + } + }, + VariableDeclarator: function(parent, node, get) { + if (parent.init == node) return get(parent.id); + } + }; + findTypeFromContext.NewExpression = findTypeFromContext.CallExpression; + + exports.typeFromContext = function(ast, found) { + var parent = exports.parentNode(found.node, ast); + var type = null; + if (findTypeFromContext.hasOwnProperty(parent.type)) { + var finder = findTypeFromContext[parent.type]; + type = finder && finder(parent, found.node, function(node, fromContext) { + var obj = {node: node, state: found.state}; + var tp = fromContext ? exports.typeFromContext(ast, obj) : exports.expressionType(obj); + return tp || ANull; + }); + } + return type || exports.expressionType(found); + }; + + // Flag used to indicate that some wild guessing was used to produce + // a type or set of completions. + var guessing = false; + + exports.resetGuessing = function(val) { guessing = val; }; + exports.didGuess = function() { return guessing; }; + + exports.forAllPropertiesOf = function(type, f) { + type.gatherProperties(f, 0); + }; + + exports.findRefs = function(ast, baseScope, name, refScope, f) { + function handleId(node, scope, ancestors) { + var parent = ancestors[ancestors.length - 2]; + if (parent.type == "MemberExpression" && !parent.computed && !!node.object) return; + if (node.name != name || + (node == ast.id && ast.type == "FunctionDeclaration")) return; + if (parent.property === node) return; + for (var s = scope; s; s = s.prev) { + if (s == refScope) f(node, scope, ancestors); + if (name in s.props) return; + } + } + walk.ancestor(ast, {Identifier: handleId, VariablePattern: handleId}, + exports.fullVisitor, baseScope); + }; + + var simpleWalker = walk.make({ + Function: function(node, _scope, c) { + c(node.body, node.scope, node.expression ? "Expression" : "Statement"); + }, + Statement: function(node, scope, c) { + c(node, node.scope || scope); + } + }); + + exports.findPropRefs = function(ast, scope, objType, name, f) { + // Find the type which owns the property in hierarchy + while (objType && !objType.props[name] && !(objType.maybeProps && objType.maybeProps[name])) { + objType = objType.proto; + } + if (!objType) throw new Error("Couldn't locate property in the base object type."); + + function isObjTypeProto(type) { + // Check whether the found type has objType in its hierarchy + while (type && type != objType) { + // Ff property is overriden higher in the hierarchy, return false + if (type.props[name] || (type.maybeProps && type.maybeProps[name])) { + return false; + } + type = type.proto; + } + return type; + } + + walk.simple(ast, { + MemberExpression: function(node, scope) { + if (node.computed || propName(node) != name) return; + if (isObjTypeProto(findType(node.object, scope).getType())) f(node.property, scope); + }, + ObjectExpression: function(node, scope) { + if (findType(node, scope).getType() != objType) return; + for (var i = 0; i < node.properties.length; ++i) + if (propName(node.properties[i]) == name) f(node.properties[i].key, scope); + }, + MethodDefinition: function(node) { + if (propName(node) != name) return; + if (node.value && isObjTypeProto(getThis(node.value.scope).getType())) f(node.key, node.value.scope); + } + }, simpleWalker, scope); + }; + + // LOCAL-VARIABLE QUERIES + + var scopeAt = exports.scopeAt = function(ast, pos, defaultScope) { + var found = walk.findNodeAround(ast, pos, function(_, node) { + return node.scope; + }); + if (found) return found.node.scope; + else return defaultScope || cx.topScope; + }; + + exports.forAllLocalsAt = function(ast, pos, defaultScope, f) { + var scope = scopeAt(ast, pos, defaultScope); + scope.gatherProperties(f, 0); + }; + + // INIT DEF MODULE + + // Delayed initialization because of cyclic dependencies. + def = exports.def = def.init({}, exports); +}); +// When enabled, this plugin will gather (short) strings in your code, +// and completing when inside a string will try to complete to +// previously seen strings. Takes a single option, maxLength, which +// controls the maximum length of string values to gather, and +// defaults to 15. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + return mod(require("../lib/infer"), require("../lib/tern"), require("acorn-walk")); + if (typeof define == "function" && define.amd) // AMD + return define(["../lib/infer", "../lib/tern", "acorn-walk/dist/walk"], mod); + mod(tern, tern, acorn.walk); +})(function(infer, tern, walk) { + "use strict"; + + tern.registerPlugin("complete_strings", function(server, options) { + server.mod.completeStrings = { maxLen: options && options.maxLength || 15, + seen: Object.create(null) }; + server.on("reset", function() { + server.mod.completeStrings.seen = Object.create(null); + }); + server.on("postParse", postParse); + server.on("completion", complete); + }); + + function postParse(ast) { + var data = infer.cx().parent.mod.completeStrings; + walk.simple(ast, { + Literal: function(node) { + if (typeof node.value == "string" && node.value && node.value.length < data.maxLen) + data.seen[node.value] = ast.sourceFile.name; + } + }); + } + + function complete(file, query) { + var pos = tern.resolvePos(file, query.end); + var lit = infer.findExpressionAround(file.ast, null, pos, file.scope, "Literal"); + if (!lit || typeof lit.node.value != "string") return; + var before = lit.node.value.slice(0, pos - lit.node.start - 1); + var matches = [], seen = infer.cx().parent.mod.completeStrings.seen; + for (var str in seen) if (str.length > before.length && str.indexOf(before) == 0) { + if (query.types || query.docs || query.urls || query.origins) { + var rec = {name: JSON.stringify(str), displayName: str}; + matches.push(rec); + if (query.types) rec.type = "string"; + if (query.origins) rec.origin = seen[str]; + } else { + matches.push(JSON.stringify(str)); + } + } + if (matches.length) return { + start: tern.outputPos(query, file, lit.node.start), + end: tern.outputPos(query, file, pos + (file.text.charAt(pos) == file.text.charAt(lit.node.start) ? 1 : 0)), + isProperty: false, + completions: matches + }; + } +}); + diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 77ecf791..dba4e924 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1250,7 +1250,7 @@ return code; */; showFloorImg_s - : '显示贴图' 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline + : '显示贴图' '像素坐标' 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline /* showFloorImg_s @@ -1282,7 +1282,7 @@ return code; */; hideFloorImg_s - : '隐藏贴图' 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline + : '隐藏贴图' '像素坐标' 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline /* hideFloorImg_s diff --git a/_server/editor_multi.js b/_server/editor_multi.js index f0234d9a..8239aa21 100644 --- a/_server/editor_multi.js +++ b/_server/editor_multi.js @@ -18,17 +18,150 @@ editor_multi = function () { lint: true, autocomplete: true, autoCloseBrackets: true, + styleActiveLine: true, highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true } }); + var coredef = terndefs_f6783a0a_522d_417e_8407_94c67b692e50[2]; + Object.keys(core.material.enemys).forEach(function (name){ + coredef.core.material.enemys[name] = { + "!type": "enemy", + "!doc": core.material.enemys[name].name || "怪物" + } + }); + Object.keys(core.material.bgms).forEach(function (name) { + coredef.core.material.bgms[name] = { + "!type": "audio", + "!doc": "背景音乐" + } + }); + Object.keys(core.material.sounds).forEach(function (name) { + coredef.core.material.sounds[name] = { + "!type": "audio", + "!doc": "音效" + } + }); + Object.keys(core.material.animates).forEach(function (name) { + coredef.core.material.animates[name] = { + "!type": "animate", + "!doc": "动画" + } + }); + Object.keys(core.material.images).forEach(function (name) { + if (core.material.images[name] instanceof Image) { + coredef.core.material.images[name] = { + "!type": "image", + "!doc": "系统图片" + } + } else { + coredef.core.material.images[name] = { + "!doc": name == 'autotile' ? '自动元件' : name == 'tilesets' ? '额外素材' : name == 'images' ? '自定义图片' : '系统图片' + } + for (var v in core.material.images[name]) { + coredef.core.material.images[name][v] = { + "!type": "image", + } + } + } + + }) + Object.keys(core.material.items).forEach(function (name) { + coredef.core.material.items[name] = { + "!type": "item", + "!doc": core.material.items[name].name || "道具" + } + }); + functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys.getSpecials().forEach(function (one) { + var name = one[1]; + if (name instanceof Function) name = name({}); + coredef.core.enemys.hasSpecial["!doc"] += name + "(" + one[0] + "); "; + }); + Object.keys(core.canvas).forEach(function (name) { + coredef.core.canvas[name] = { + "!type": "CanvasRenderingContext2D", + "!doc": "系统画布" + } + }); + Object.keys(core.status.maps).forEach(function (name) { + coredef.core.status.maps[name] = { + "!type": "floor", + "!doc": core.status.maps[name].title || '' + } + coredef.core.status.bgmaps[name] = { + "!type": "[[number]]", + "!doc": core.status.maps[name].title || '' + } + coredef.core.status.fgmaps[name] = { + "!type": "[[number]]", + "!doc": core.status.maps[name].title || '' + } + }); + Object.keys(core.status.shops).forEach(function (id) { + coredef.core.status.shops[id] = { + "!doc": core.status.shops[id].textInList || "全局商店" + } + }); + Object.keys(core.status.textAttribute).forEach(function (id) { + coredef.core.status.textAttribute[id] = {}; + }); + // --- 转发函数 + for (var name in coredef.core) { + if (typeof coredef.core[name] === 'object') { + for (var funcname in coredef.core[name]) { + var one = coredef.core[name][funcname] || {}; + var type = one["!type"] || ""; + if (type.startsWith("fn(")) { + coredef.core[funcname] = { + "!type": one["!type"], + "!doc": one["!doc"] + "
(转发到 " + name + " 中)" + }; + if (one["!url"]) coredef.core[funcname]["!url"] = one["!url"]; + } + } + } + } + + Object.keys(core.values).forEach(function (id) { + var one = data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc._data.values._data[id]; + if (!one) return; + coredef.core.values[id] = { + "!type": "number", + "!doc": one._data, + } + }); + Object.keys(core.flags).forEach(function (id) { + var one = data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc._data.flags._data[id]; + if (!one) return; + coredef.core.flags[id] = { + "!type": id == 'statusBarItems' ? '[string]' : 'bool', + "!doc": one._data, + } + }); + + var ternServer = new CodeMirror.TernServer({ + defs: terndefs_f6783a0a_522d_417e_8407_94c67b692e50, + plugins: { + doc_comments: true, + complete_strings: true, + }, + useWorker: false + }); + editor_multi.codeEditor = codeEditor; + codeEditor.on("cursorActivity", function (cm) { + if (codeEditor.getOption("autocomplete")) { + ternServer.updateArgHints(cm); + ternServer.showDocs(cm); + } + }); + codeEditor.on("keyup", function (cm, event) { if (codeEditor.getOption("autocomplete") && !event.ctrlKey && ( (event.keyCode >= 65 && event.keyCode <= 90) || (!event.shiftKey && event.keyCode == 190) || (event.shiftKey && event.keyCode == 189))) { try { - CodeMirror.commands.autocomplete(cm, null, { completeSingle: false }); + ternServer.complete(cm); } catch (e) { } } @@ -66,13 +199,19 @@ editor_multi = function () { var _format = function () { if (!editor_multi.lintAutocomplete) return; - codeEditor.setValue(js_beautify(codeEditor.getValue(), { + _setValue(js_beautify(codeEditor.getValue(), { brace_style: "collapse-preserve-inline", indent_with_tabs: true, jslint_happy: true })); } + var _setValue = function (val) { + codeEditor.setValue(val || ''); + ternServer.delDoc('doc'); + ternServer.addDoc('doc', new CodeMirror.Doc(val || '', 'javascript')); + } + editor_multi.format = function () { if (!editor_multi.lintAutocomplete) { alert("只有代码才能进行格式化操作!"); @@ -103,7 +242,7 @@ editor_multi = function () { input.value = '"function () {\\n\\t// 在此增加新插件\\n\\t\\n}"'; if (input.value.slice(0, 1) === '"' || args.string) { editor_multi.isString = true; - codeEditor.setValue(JSON.parse(input.value) || ''); + _setValue(JSON.parse(input.value) || ''); } else { var num = editor_multi.indent(field); eval('var tobj=' + (input.value || 'null')); @@ -118,7 +257,7 @@ editor_multi = function () { for (var id_ in tmap) { tstr = tstr.replace('"' + id_ + '"', tmap[id_]) } - codeEditor.setValue(tstr || ''); + _setValue(tstr || ''); } document.getElementById('showPlugins').style.display = editor_mode.mode == 'plugins' ? 'block': 'none'; editor_multi.show(); @@ -194,7 +333,7 @@ editor_multi = function () { var multiLineArgs = [null, null, null]; editor_multi.multiLineEdit = function (value, b, f, args, callback) { editor_multi.id = 'callFromBlockly'; - codeEditor.setValue(value.split('\\n').join('\n') || ''); + _setValue(value.split('\\n').join('\n') || ''); multiLineArgs[0] = b; multiLineArgs[1] = f; multiLineArgs[2] = callback; @@ -212,16 +351,16 @@ editor_multi = function () { editor_multi.importFile = function (filename) { editor_multi.id = 'importFile' _fileValues[0] = filename - codeEditor.setValue('loading') + _setValue('loading') editor_multi.show(); fs.readFile(filename, 'base64', function (e, d) { if (e) { - codeEditor.setValue('加载文件失败:\n' + e) + _setValue('加载文件失败:\n' + e) editor_multi.id = '' return; } var str = editor.util.decode64(d) - codeEditor.setValue(str) + _setValue(str) _fileValues[1] = str }) } diff --git a/editor.html b/editor.html index f404418a..4b6fd2c9 100644 --- a/editor.html +++ b/editor.html @@ -451,9 +451,12 @@ - - + + + + + diff --git a/libs/events.js b/libs/events.js index 88c8bff0..b3f558ec 100644 --- a/libs/events.js +++ b/libs/events.js @@ -3023,6 +3023,7 @@ events.prototype.setHeroIcon = function (name, noDraw) { console.error("找不到图片: "+img); return; } + if (core.material.images.hero == img) return; core.status.hero.image = name; core.material.images.hero = img; core.material.icons.hero.width = img.width / 4; diff --git a/runtime.d.ts b/runtime.d.ts index f6cb996f..78a6016f 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -289,7 +289,6 @@ declare class control { /** 立刻聚集所有的跟随者 */ gatherFollowers(): void - /** 回放下一个操作 */ replay(): void @@ -367,7 +366,7 @@ declare class control { * @param status 绘制第几帧(默认支持1、2、4,推荐在project\icons.js中把第三帧也注册了,这里预留了一个'midFoot'作为其枚举值),不填视为静止帧(第一帧)。 * @param offset 相对主角逻辑位置的偏移量,不填视为无偏移。用于绘制行走中的主角(正数表示前进,负数表示后退,但跟随者的后退很难看)或表现一些特殊的演出效果 */ - drawHero(status?: 'stop' | 'leftFoot' | 'rightFoot' | 'midFoot', offset?: number): void + drawHero(status?: 'stop' | 'leftFoot' | 'rightFoot', offset?: number, frame?: number): void /** * 获取主角面前第n格的横坐标 @@ -474,8 +473,8 @@ declare class control { * @returns name ? core.status.hero.loc[name] : core.status.hero.loc */ getHeroLoc(): { x: number, y: number, direction: direction } - setHeroLoc(name: 'x' | 'y'): number - getHeroLoc(name: 'direction'): | direction + getHeroLoc(name: 'x' | 'y'): number + getHeroLoc(name: 'direction'): direction /** * 根据级别的数字获取对应的名称,后者定义在全塔属性 @@ -503,7 +502,6 @@ declare class control { /** * 读取一个flag变量 - * @example core.getFlag('heroIcon', 'hero.png'); // 读取主角当前的行走图文件名,默认为'hero.png' * @param name 变量名,支持中文 * @param defaultValue 当变量不存在时的返回值,可选(事件流中默认填0)。 * @returns flags[name] ?? defaultValue @@ -552,6 +550,240 @@ declare class control { * @param startTime 跳过前多少秒,不填则不跳过 */ playBgm(bgm: string, startTime?: number): void + + /** + * 注册一个 animationFrame + * @param name 名称,可用来作为注销使用 + * @param needPlaying 是否只在游戏运行时才执行(在标题界面不执行) + * @param func 要执行的函数,或插件中的函数名;可接受timestamp(从页面加载完毕到当前所经过的时间)作为参数 + */ + registerAnimationFrame(name: string, needPlaying: boolean, func?: (timestamp: number) => void): void + + /** 注销一个animationFrame */ + unregisterAnimationFrame(name: string): void + + /** 游戏是否已经开始 */ + isPlaying(): boolean + + /** 清除游戏状态和数据 */ + clearStatus(): void + + /** 清除自动寻路路线 */ + clearAutomaticRouteNode(x?: any, y?: any): void + + /** 停止自动寻路操作 */ + stopAutomaticRoute(): void + + /** 保存剩下的寻路,并停止 */ + saveAndStopAutomaticRoute(): void + + /** 继续剩下的自动寻路操作 */ + continueAutomaticRoute(): void + + /** 清空剩下的自动寻路列表 */ + clearContinueAutomaticRoute(callback?: () => any): void + + /** 显示离散的寻路点 */ + fillPosWithPoint(pos?: any): void + + /** 设置行走的效果动画 */ + setHeroMoveInterval(callback?: () => any): void + + /** 每移动一格后执行的事件 */ + moveOneStep(callback?: () => any): void + + /** 当前是否正在移动 */ + isMoving(): boolean + + /** 瞬间移动 */ + moveDirectly(destX?: any, destY?: any, ignoreSteps?: any): void + + /** 改变勇士的显隐状态 */ + triggerHero(type?: 'show' | 'hide', time?: any, callback?: () => any): void + + /** 加减画布偏移 */ + addGameCanvasTranslate(x?: number, y?: number): void + + /** 设置视野范围 */ + setViewport(x?: number, y?: number): void + + /** 移动视野范围 */ + moveViewport(steps?: any, time?: number, callback?: () => any): void + + /** 更新跟随者坐标 */ + updateFollowers(): void + + /** 更新领域、夹击、阻击的伤害地图 */ + updateCheckBlock(floorId?: string): void + + /** 检查并执行领域、夹击、阻击事件 */ + checkBlock(): void + + /** 选择录像文件 */ + chooseReplayFile(): void + + /** 开始播放 */ + startReplay(list?: any): void + + /** 更改播放状态 */ + triggerReplay(): void + + /** 暂停播放 */ + pauseReplay(): void + + /** 恢复播放 */ + resumeReplay(): void + + /** 单步播放 */ + stepReplay(): void + + /** 加速播放 */ + speedUpReplay(): void + + /** 减速播放 */ + speedDownReplay(): void + + /** 设置播放速度 */ + setReplaySpeed(speed?: number): void + + /** 停止播放 */ + stopReplay(force?: boolean): void + + /** 回退 */ + rewindReplay(): void + + /** 回放时存档 */ + saveReplay(): void + + /** 回放时查看怪物手册 */ + bookReplay(): void + + /** 回放录像时浏览地图 */ + viewMapReplay(): void + + /** 回放录像时打开道具栏 */ + toolboxReplay(): void + + /** 回放录像时打开装备栏 */ + equipboxReplay(): void + + /** 是否正在播放录像 */ + isReplaying(): boolean + + /** + * 注册一个录像行为 + * @param name 自定义名称,可用于注销使用 + * @param func 具体执行录像的函数,可为一个函数或插件中的函数名; + * 需要接受一个action参数,代表录像回放时的下一个操作 + * func返回true代表成功处理了此录像行为,false代表没有处理此录像行为。 + */ + registerReplayAction(name: string, func: (action?: string) => boolean): void + + /** 注销一个录像行为 */ + unregisterReplayAction(name: string): void + + /** 自动存档 */ + autosave(removeLast?: any): void + + /** 实际进行自动存档 */ + checkAutosave(): void + + /** 实际进行存读档事件 */ + doSL(id?: string, type?: any): void + + /** 同步存档到服务器 */ + syncSave(type?: any): void + + /** 从服务器加载存档 */ + syncLoad(): void + + /** 存档到本地 */ + saveData(): any + + /** 从本地读档 */ + loadData(data?: any, callback?: () => any): any + + /** 获得某个存档内容 */ + getSave(index?: any, callback?: () => any): any + + /** 获得某些存档内容 */ + getSaves(ids?: any, callback?: () => any): any + + /** 获得所有存档内容 */ + getAllSaves(callback?: () => any): any + + /** 获得所有存在存档的存档位 */ + getSaveIndexes(callback?: () => any): any + + /** 判断某个存档位是否存在存档 */ + hasSave(index?: number): boolean + + /** 删除某个存档 */ + removeSave(index?: number, callback?: () => any): void + + /** 从status中获得属性,如果不存在则从勇士属性中获取 */ + getStatusOrDefault(status?: any, name?: string): any + + /** 从status中获得实际属性(增幅后的),如果不存在则从勇士属性中获取 */ + getRealStatusOrDefault(status?: any, name?: string): any + + /** 获得勇士原始属性(无装备和衰弱影响) */ + getNakedStatus(name?: string): any + + /** 锁定状态栏,常常用于事件处理 */ + lockControl(): void + + /** 解锁状态栏 */ + unLockControl(): void + + /** 获得映射文件名 */ + getMappedName(name?: string): string + + /** 暂停背景音乐的播放 */ + pauseBgm(): void + + /** 恢复背景音乐的播放 */ + resumeBgm(resumeTime?: number): void + + /** 设置音乐图标的显隐状态 */ + setMusicBtn(): void + + /** 更改背景音乐的播放 */ + triggerBgm(): void + + /** 停止所有音频 */ + stopSound(): void + + /** 检查bgm状态 */ + checkBgm(): void + + /** 清空状态栏 */ + clearStatusBar(): void + + /** 显示状态栏 */ + showStatusBar(): void + + /** 隐藏状态栏 */ + hideStatusBar(showToolbox?: boolean): void + + /** 更新状态栏的勇士图标 */ + updateHeroIcon(name: string): void + + /** 改变工具栏为按钮1-8 */ + setToolbarButton(useButton?: boolean): void + + /** + * 注册一个resize函数 + * @param name 名称,可供注销使用 + * @param func 可以是一个函数,或者是插件中的函数名;可以接受obj参数,详见resize函数。 + */ + registerResize(name: string, func: (obj: any) => void): void + + /** 注销一个resize函数 */ + unregisterResize(name: string): void + + /** 屏幕分辨率改变后重新自适应 */ + resize(): void } /**@file events.js将处理所有和事件相关的操作。 */ @@ -754,18 +986,10 @@ declare class events { */ jumpHero(ex?: number, ey?: number, time?: number, callback?: () => void): void - /** - * 打开一个全局商店 - * @example core.openShop('moneyShop1', true); // 远程访问贪婪之神1来购买能力值,要求已经接触过神的本体 - * @param shopId 商店id - * @param needVisited true表示需要已接触过商店老板本体 - */ - openShop(shopId: string, needVisited?: boolean): void - /** * 更改主角行走图 - * @example core.setHeroIcon('npc48.png'); // 把主角从阳光变成样板0层左下角的小姐姐,但不立即刷新 - * @param name 新的行走图文件名,可以是全塔属性中映射前的中文名。映射后会被存入flags.heroIcon + * @example core.setHeroIcon('npc48.png', true); // 把主角从阳光变成样板0层左下角的小姐姐,但不立即刷新 + * @param name 新的行走图文件名,可以是全塔属性中映射前的中文名。映射后会被存入core.status.hero.image * @param noDraw true表示不立即刷新(刷新会导致大地图下视野重置到以主角为中心) */ setHeroIcon(name: string, noDraw?: boolean): void @@ -776,6 +1000,223 @@ declare class events { * @param itemId 道具id,其中敌人手册、传送器和飞行器会被特殊处理 */ tryUseItem(itemId: string): void + + /** 初始化游戏 */ + resetGame(hero?: any, hard?: any, floorId?: string, maps?: any, values?: any): void + + /** 游戏获胜事件 */ + win(reason?: string, norank?: boolean, noexit?: boolean): void + + /** 游戏失败事件 */ + lose(reason?: string): void + + /** 重新开始游戏;此函数将回到标题页面 */ + restart(): void + + /** 询问是否需要重新开始 */ + confirmRestart(): void + + /** + * 注册一个系统事件 + * @param type 事件名 + * @param func 为事件的处理函数,可接受(data,callback)参数 + */ + registerSystemEvent(type: string, func: (data?: any, callback?: () => void) => void): void + + /** 注销一个系统事件 */ + unregisterSystemEvent(type: string): void + + /** 执行一个系统事件 */ + doSystemEvent(type: string, data?: any, callback?: () => any): void + + /** 触发(x,y)点的事件 */ + trigger(x?: number, y?: number, callback?: () => any): void + + /** 战斗前触发的事件 */ + beforeBattle(enemyId?: string, x?: number, y?: number): void + + /** 战斗结束后触发的事件 */ + afterBattle(enemyId?: string, x?: number, y?: number): void + + /** 开一个门后触发的事件 */ + afterOpenDoor(doorId?: string, x?: number, y?: number): void + + /** 获得一个道具后的shij */ + afterGetItem(id?: string, x?: number, y?: number, isGentleClick?: boolean): void + + /** 获得面前的物品(轻按) */ + getNextItem(noRoute?: boolean): void + + /** 楼层转换中 */ + changingFloor(floorId?: string, heroLoc?: any): void + + /** 转换楼层结束的事件 */ + afterChangeFloor(floorId?: string): void + + /** 是否到达过某个楼层 */ + hasVisitedFloor(floorId?: string): boolean + + /** 到达某楼层 */ + visitFloor(floorId?: string): void + + /** 推箱子 */ + pushBox(data?: any): void + + /** 推箱子后的事件 */ + afterPushBox(): void + + /** 当前是否在冰上 */ + onSki(number?: number): boolean + + /** + * 注册一个自定义事件 + * @param type 事件类型 + * @param func 事件的处理函数,可接受(data, x, y, prefix)参数 + * data为事件内容,x和y为当前点坐标(可为null),prefix为当前点前缀 + */ + registerEvent(type: string, func: (data: any, x?: number, y?: number, prefix?: string) => void): void + + /** 注销一个自定义事件 */ + unregisterEvent(type: string): void + + /** 执行一个自定义事件 */ + doEvent(data?: any, x?: number, y?: number, prefix?: any): void + + /** 直接设置事件列表 */ + setEvents(list?: any, x?: number, y?: number, callback?: () => any): void + + /** 开始执行一系列自定义事件 */ + startEvents(list?: any, x?: number, y?: number, callback?: () => any): void + + /** 往当前事件列表之前或之后添加一个公共事件 */ + insertCommonEvent(name?: string, args?: any, x?: number, y?: number, callback?: () => any, addToLast?: boolean): void + + /** 获得一个公共事件 */ + getCommonEvent(name: string): any + + /** 恢复一个事件 */ + recoverEvents(data?: any): void + + /** 检测自动事件 */ + checkAutoEvents(): void + + /** 当前是否在执行某个自动事件 */ + autoEventExecuting(symbol?: string, value?: any): boolean + + /** 当前是否执行过某个自动事件 */ + autoEventExecuted(symbol?: string, value?: any): boolean + + /** 将当前点坐标入栈 */ + pushEventLoc(x?: number, y?: number, floorId?: string): boolean + + /** 将当前点坐标入栈 */ + popEventLoc(): any + + /** 预编辑事件 */ + precompile(data?: any): any + + /** 点击怪物手册时的打开操作 */ + openBook(fromUserAction?: boolean): void + + /** 点击楼层传送器时的打开操作 */ + useFly(fromUserAction?: boolean): void + + /** 飞往某一层 */ + flyTo(toId?: string, callback?: () => boolean): void + + /** 点击装备栏时的打开操作 */ + openEquipbox(fromUserAction?: boolean): void + + /** 点击工具栏时的打开操作 */ + openToolbox(fromUserAction?: boolean): void + + /** 点击快捷商店按钮时的打开操作 */ + openQuickShop(fromUserAction?: boolean): void + + /** 点击虚拟键盘时的打开操作 */ + openKeyBoard(fromUserAction?: boolean): void + + /** 点击设置按钮时的操作 */ + openSettings(fromUserAction?: boolean): void + + /** 当前是否有未处理完毕的异步事件 */ + hasAsync(): boolean + + /** 跟随 */ + follow(name: string): void + + /** 取消跟随 */ + unfollow(name?: string): void + + /** 数值操作 */ + setValue(name: string, operator: string, value: any, prefix?: string): void + + /** 数值增减 */ + addValue(name: string, value: any, prefix?: string): void + + /** 设置全塔属性 */ + setGlobalAttribute(name: string, value: any): void + + /** 检查升级事件 */ + checkLvUp(): void +} + +/** @file actions.js 定义了玩家的操作控制 */ +declare class actions { + /** + * 此函数将注册一个用户交互行为。 + * @param action 要注册的交互类型,如 ondown, onclick, keyDown 等等。 + * @param name 你的自定义名称,可被注销使用;同名重复注册将后者覆盖前者。 + * @param func 执行函数。 + * 如果func返回true,则不会再继续执行其他的交互函数;否则会继续执行其他的交互函数。 + * @param priority 优先级;优先级高的将会被执行。此项可不填,默认为0 + */ + registerAction(action: string, name: string, func: string | ((...params: any) => void), priority?: number): void + + /** 注销一个用户交互行为 */ + unregisterAction(action: string, name: string): void + + /** 执行一个用户交互行为 */ + doRegisteredAction(action: string, ...params: any): void + + /** 按下某个键时 */ + onkeyDown(e: KeyboardEvent): void + + /** 放开某个键时 */ + onkeyUp(e: KeyboardEvent): void + + /** 按住某个键时 */ + pressKey(keyCode: number): void + + /** 根据按下键的code来执行一系列操作 */ + keyDown(keyCode: number): void + + /** 根据放开键的code来执行一系列操作 */ + keyUp(keyCode: number, altKey?: boolean, fromReplay?: boolean): void + + /** 点击(触摸)事件按下时 */ + ondown(loc: number[]): void + + /** 当在触摸屏上滑动时 */ + onmove(loc: number[]): void + + /** 当点击(触摸)事件放开时 */ + onup(loc: number[]): void + + /** 具体点击屏幕上(x,y)点时,执行的操作 */ + onclick(x: number, y: number, stepPostfix?: any): void + + /** 滑动鼠标滚轮时的操作 */ + onmousewheel(direct: 1 | -1): void + + /** 长按Ctrl键时 */ + keyDownCtrl(): void + + /** 长按 */ + longClick(x: number, y: number, fromEvent?: boolean): void + + /** 点击自绘状态栏时 */ + onStatusBarClick(e?: MouseEvent): void } /** @file enemys.js 定义了一系列和敌人相关的API函数。 */ @@ -883,6 +1324,24 @@ declare class enemys { * @returns true表示有敌人被漏打,false表示敌人已死光 */ hasEnemyLeft(enemyId?: string, floorId?: string | string[]): boolean + + /** 获得所有怪物 */ + getEnemys(): any + + /** 获得所有特殊属性定义 */ + getSpecials(): void + + /** 获得所有特殊属性的颜色 */ + getSpecialColor(enemy: string | Enemy): void + + /** 获得所有特殊属性的额外标记 */ + getSpecialFlag(enemy: string | Enemy): void + + /** 获得怪物真实属性 */ + getEnemyInfo(enemy: string | Enemy, hero?: any, x?: number, y?: number, floorId?: string): void + + /** 获得战斗伤害信息(实际伤害计算函数) */ + getDamageInfo(enemy: string | Enemy, hero?: any, x?: number, y?: number, floorId?: string): void } /** @file maps.js负责一切和地图相关的处理内容 */ @@ -896,14 +1355,6 @@ declare class maps { */ getNumberById(id: string): number - /** - * 删除不可再到达的地图 - * @example core.removeMaps('MT0', 'MT99'); // 删除主塔0到99层,这些楼层不可再被飞到、不可再被浏览、也不计入存档 - * @param fromId 要删除的第一张地图id - * @param toId 要删除的最后一张地图id,不填视为只删除第一张 - */ - removeMaps(fromId: string, toId?: string): void - /** * 生成事件层矩阵 * @example core.getMapArray('MT0'); // 生成主塔0层的事件层矩阵,隐藏的图块视为0 @@ -911,7 +1362,7 @@ declare class maps { * @param showDisable 可选,true表示隐藏的图块也会被表示出来 * @returns 事件层矩阵,注意对其阵元的访问是[y][x] */ - getMapArray(floorId?: string, showDisable?: boolean): number[][] + getMapArray(floorId?: string): number[][] /** * 生成背景层矩阵 @@ -1189,6 +1640,144 @@ declare class maps { * @returns 一个数字,可作为core.stopAnimate()的参数来立即停止播放(届时还可选择是否执行此次播放的回调函数) */ drawAnimate(name: string, x: number, y: number, alignWindow: boolean, callback?: () => void): number + + /** 加载某个楼层(从剧本或存档中) */ + loadFloor(floorId?: string, map?: any): any + + /** 根据需求解析出blocks */ + extractBlocks(map?: any, flags?: any): void + + /** 根据数字获得图块 */ + getBlockByNumber(number: number): any + + /** 根据ID获得图块 */ + getBlockById(id: string): any + + /** 获得当前事件点的ID */ + getIdOfThis(id?: string): string + + /** 初始化一个图块 */ + initBlock(x?: number, y?: number, id?: string | number, addInfo?: boolean, eventFloor?: any, flags?: any): any + + /** 压缩地图 */ + compressMap(mapArr?: any, floorId?: string): any + + /** 解压缩地图 */ + decompressMap(mapArr?: any, floorId?: string): any + + /** 将当前地图重新变成数字,以便于存档 */ + saveMap(floorId?: string): any + + /** 将存档中的地图信息重新读取出来 */ + loadMap(data?: any, floorId?: string): any + + /** 更改地图画布的尺寸 */ + resizeMap(floorId?: string): void + + /** 以x,y的形式返回每个点的事件 */ + getMapBlocksObj(floorId?: string, showDisable?: any): any + + /** 获得某些点可否通行的信息 */ + canMoveDirectlyArray(locs?: any): any + + /** 绘制一个图块 */ + drawBlock(block?: any, animate?: any): void + + /** 生成groundPattern */ + generateGroundPattern(floorId?: string): void + + /** 某个点是否存在NPC */ + npcExists(x?: number, y?: number, floorId?: string): boolean + + /** 某个点是否存在(指定的)地形 */ + terrainExists(x?: number, y?: number, id?: string, floorId?: string): boolean + + /** 某个点是否存在楼梯 */ + stairExists(x?: number, y?: number, floorId?: string): boolean + + /** 当前位置是否在楼梯边 */ + nearStair(): boolean + + /** 某个点是否存在(指定的)怪物 */ + enemyExists(x?: number, y?: number, id?: string, floorId?: string): boolean + + /** 获得某个点的block */ + getBlock(x?: number, y?: number, floorId?: string, showDisable?: boolean): any + + /** 获得某个图块或素材的信息,包括ID,cls,图片,坐标,faceIds等等 */ + getBlockInfo(block?: any): any + + /** 根据图块的索引来隐藏图块 */ + hideBlockByIndex(index?: any, floorId?: string): void + + /** 一次性隐藏多个block */ + hideBlockByIndexes(indexes?: any, floorId?: string): void + + /** 根据block的索引(尽可能)删除该块 */ + removeBlockByIndex(index?: any, floorId?: string): void + + /** 一次性删除多个block */ + removeBlockByIndexes(indexes?: any, floorId?: string): void + + /** 显示前景/背景地图 */ + showBgFgMap(name?: string, loc?: any, floorId?: string, callback?: () => any): void + + /** 隐藏前景/背景地图 */ + hideBgFgMap(name?: string, loc?: any, floorId?: string, callback?: () => any): void + + /** 显示一个楼层贴图 */ + showFloorImage(loc?: any, floorId?: string, callback?: () => any): void + + /** 隐藏一个楼层贴图 */ + hideFloorImage(loc?: any, floorId?: string, callback?: () => any): void + + /** 动画形式转变某点图块 */ + animateSetBlock(number?: number | string, x?: number, y?: number, floorId?: string, time?: number, callback?: () => any): void + + /** 动画形式同时转变若干点图块 */ + animateSetBlocks(number?: number | string, locs?: any, floorId?: string, time?: number, callback?: () => any): void + + /** 事件转向 */ + turnBlock(direction?: string, x?: number, y?: number, floorId?: string): void + + /** 重置地图 */ + resetMap(floorId?: string | string[]): void + + /** 显示/隐藏某个块时的动画效果 */ + animateBlock(loc?: any, type?: any, time?: any, callback?: () => any): void + + /** 添加一个全局动画 */ + addGlobalAnimate(block?: any): void + + /** 删除一个或所有全局动画 */ + removeGlobalAnimate(x?: number, y?: number, name?: string): void + + /** 绘制UI层的box动画 */ + drawBoxAnimate(): void +} + +/** @file loader.js 主要负责资源的加载 */ +declare class loader { + /** 加载一系列图片 */ + loadImages(dir: any, names: any, toSave: any, callback?: () => any) : any + + /** 加载某一张图片 */ + loadImage(dir: any, imgName?: any, callback?: () => any): any + + /** 从zip中加载一系列图片 */ + loadImagesFromZip(url?: any, names?: any, toSave?: any, onprogress?: any, onfinished?: any): any + + /** 加载一个音乐 */ + loadOneMusic(name?: string): any + + /** 加载一个音效 */ + loadOneSound(name?: string): any + + /** 加载一个bgm */ + loadBgm(name?: string): any + + /** 释放一个bgm的缓存 */ + freeBgm(name?: string): any } /** @file items.js 主要负责一切和道具相关的内容。 */ @@ -1331,12 +1920,14 @@ declare class items { */ quickLoadEquip(index: number): void - /** - * 计算某种属性被当前套装增加的常数值 - * @example core.getEquippedStatus('atk') // 当前套装共加多少点攻击 - * @param name 属性的英文缩写 - */ - getEquippedStatus(name: string): number + /** 获得所有道具 */ + getItems(): void + + /** 删除某个物品 */ + removeItem(itemId?: string, itemNum?: number): void + + /** 根据类型获得一个可用的装备孔 */ + getEquipTypeByName(name?: string): void } /** @file ui.js 主要用来进行UI窗口的绘制,如对话框、怪物手册、楼传器、存读档界面等等。*/ @@ -1386,43 +1977,6 @@ declare class ui { */ strokeRect(name: CtxRefer, x: number, y: number, width: number, height: number, style: string): void - - - // core.ui.drawLine(name, x1, y1, x2, y2, style, lineWidth) - // 绘制一条线。lineWidth可选为线宽。 - - - // core.ui.drawArrow(name, x1, y1, x2, y2, style, lineWidth) - // 绘制一个箭头。 - - - // core.ui.setFont(name, font) / core.ui.setLineWidth(name, lineWidth) - // 设置一个画布的字体/线宽。 - - - // core.ui.setAlpha(name, font) / core.ui.setOpacity(name, font) - // 设置一个画布的绘制不透明度和画布本身的不透明度。 - // 两者区别如下: - // - setAlpha是设置"接下来绘制的内容的不透明度",不会对已经绘制的内容产生影响。比如setAlpha('ui', 0.5)则会在接下来的绘制中使用0.5的不透明度。 - // - setOpacity是设置"画布本身的不透明度",已经绘制的内容也会产生影响。比如我已经在UI层绘制了一段文字,再setOpacity则也会看起来变得透明。 - // 尽量不要对系统画布使用setOpacity(因为会对已经绘制的内容产生影响),自定义创建的画布则不受此限制。 - - - // core.ui.setFillStyle(name, style) / core.ui.setStrokeStyle(name, style) - // 设置一个画布的填充样式/描边样式。 - - - // core.ui.setTextAlign(name, align) - // 设置一个画布的文字对齐模式。 - - - // core.ui.calWidth(name, text, font) - // 计算一段文字在画布上的绘制宽度 - // font可选,如果存在则会先设置该画布上的字体。 - - - //---------------------// - /** * 动态创建一个画布。name为要创建的画布名,如果已存在则会直接取用当前存在的。 * x,y为创建的画布相对窗口左上角的像素坐标,width,height为创建的长宽。 @@ -1440,7 +1994,6 @@ declare class ui { /** 重新定位一个自定义画布 */ relocateCanvas(name: string, x: number, y: number): void - /** 重新设置一个自定义画布的大小 */ resizeCanvas(name: string, x: number, y: number): void @@ -1451,19 +2004,6 @@ declare class ui { /** 清空所有的自定义画布 */ deleteAllCanvas(): void - /** - * 绘制一个缩略图,比如楼传器界面,存读档界面等情况 - * @param floorId 目标楼层ID - * @param canvas 绘制到的图层 - * @param blocks 绘制的所有图块 - * @param x 该图层开始绘制的起始点坐标 - * @param y 该图层开始绘制的起始点坐标 - * @param size 每一格的像素 - * @param heroLoc 勇士坐标 - * @param heroIcon 勇士图标 - */ - drawThumbnail(floorId: string, canvas: CtxRefer, blocks: any[], x: number, y: number, size: number, heroLoc: any, heroIcon: string): void - /** * 在一个画布上绘制图片 * 后面的8个坐标参数与canvas的drawImage的八个参数完全相同。 @@ -1478,6 +2018,212 @@ declare class ui { drawImage(name: CtxRefer, image: CanvasImageSource | string, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void + + /** 根据最大宽度自动缩小字体 */ + setFontForMaxWidth(name: string | CanvasRenderingContext2D, text: string, maxWidth: number, font?: any): string + + /** 在某个canvas上绘制一个圆角矩形 */ + fillRoundRect(name: string | CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, style?: string, angle?: number): void + + /** 在某个canvas上绘制一个圆角矩形的边框 */ + strokeRoundRect(name: string | CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number, style?: string, lineWidth?: number, angle?: number): void + + /** 在某个canvas上绘制一个多边形 */ + fillPolygon(name: string | CanvasRenderingContext2D, nodes?: any, style?: string): void + + /** 在某个canvas上绘制一个多边形的边框 */ + strokePolygon(name: string | CanvasRenderingContext2D, nodes?: any, style?: string, lineWidth?: number): void + + /** 在某个canvas上绘制一个椭圆 */ + fillEllipse(name: string | CanvasRenderingContext2D, x: number, y: number, a: number, b: number, angle?: number, style?: any): void + + /** 在某个canvas上绘制一个圆 */ + fillCircle(name: string | CanvasRenderingContext2D, x: number, y: number, r: number, style?: string): void + + /** 在某个canvas上绘制一个椭圆的边框 */ + strokeEllipse(name: string | CanvasRenderingContext2D, x: number, y: number, a: number, b: number, angle?: number, style?: string, lineWidth?: number): void + + /** 在某个canvas上绘制一个圆的边框 */ + strokeCircle(name: string | CanvasRenderingContext2D, x: number, y: number, r: any, style?: string, lineWidth?: number): void + + /** 在某个canvas上绘制一个扇形 */ + fillArc(name: string | CanvasRenderingContext2D, x: number, y: number, r: number, start: number, end: number, style?: string): void + + /** 在某个canvas上绘制一段弧 */ + strokeArc(name: string | CanvasRenderingContext2D, x: number, y: number, r: number, start: number, end: number, style?: string, lineWidth?: number): void + + /** 保存某个canvas状态 */ + saveCanvas(name: string | CanvasRenderingContext2D): void + + /** 加载某个canvas状态 */ + loadCanvas(name: string | CanvasRenderingContext2D): void + + /** 设置某个canvas的baseline */ + setTextBaseline(name: string | CanvasRenderingContext2D, baseline: any): void + + /** 字符串自动换行的分割 */ + splitLines(name: string | CanvasRenderingContext2D, text: string, maxWidth?: number, font?: string): void + + /** 在某个canvas上绘制一个图标 */ + drawIcon(name: string | CanvasRenderingContext2D, id: string, x: number, y: number, w?: number, h?: number, frame?: number): void + + /** 结束一切事件和绘制,关闭UI窗口,返回游戏进程 */ + closePanel(): void + + /** 清空UI层内容 */ + clearUI(): void + + /** 左上角绘制一段提示 */ + drawTip(text: string, id?: string, frame?: number): void + + /** 清除提示内容 */ + clearTip(): void + + /** 地图中间绘制一段文字 */ + drawText(contents: string, callback?: () => any): void + + /** 绘制选择光标 */ + drawWindowSelector(background: any, x: number, y: number, w: number, h: number): void + + /** 绘制WindowSkin */ + drawWindowSkin(background: any, ctx: string | CanvasRenderingContext2D, x: number, y: number, w: string, h: string, direction?: any, px?: any, py?: any): void + + /** 绘制一个背景图,可绘制winskin或纯色背景;支持小箭头绘制 */ + drawBackground(left: string, top: string, right: string, bottom: string, posInfo?: any): void + + /** + * 绘制一段文字到某个画布上面 + * @param ctx 要绘制到的画布 + * @param content 要绘制的内容;转义字符不允许保留 \t, \b 和 \f + * @param config 绘制配置项,目前暂时包含如下内容(均为可选) + * left, top:起始点位置;maxWidth:单行最大宽度;color:默认颜色;align:左中右 + * fontSize:字体大小;lineHeight:行高;time:打字机间隔 + * @returns 绘制信息 + */ + drawTextContent(ctx: string | CanvasRenderingContext2D, content: string, config: any): any + + /** 获得某段文字的预计绘制高度;参见 drawTextContent */ + getTextContentHeight(content: string, config?: any): void + + /** 绘制一个对话框 */ + drawTextBox(content: string, showAll?: boolean): void + + /** 绘制滚动字幕 */ + drawScrollText(content: string, time: number, lineHeight?: number, callback?: () => any): void + + /** 文本图片化 */ + textImage(content: string, lineHeight?: number): any + + /** 绘制一个选项界面 */ + drawChoices(content: string, choices: any): void + + /** 绘制等待界面 */ + drawWaiting(text: string): void + + /** 绘制系统设置界面 */ + drawSwitchs(): void + + /** 绘制系统菜单栏 */ + drawSettings(): void + + /** 绘制快捷商店选择栏 */ + drawQuickShop(): void + + /** 绘制存档同步界面 */ + drawSyncSave(): void + + /** 绘制存档同步选择页面 */ + drawSyncSelect(): void + + /** 绘制单存档界面 */ + drawLocalSaveSelect(): void + + /** 绘制存档删除页面 */ + drawStorageRemove(): void + + /** 绘制回放界面 */ + drawReplay(): void + + /** 绘制游戏信息界面 */ + drawGameInfo(): void + + /** 绘制分页 */ + drawPagination(page?: any, totalPage?: any, y?: number): void + + /** 绘制键盘光标 */ + drawCursor(): void + + /** 绘制怪物手册 */ + drawBook(index?: any): void + + /** 绘制怪物属性的详细信息 */ + drawBookDetail(index?: any): void + + /** 绘制楼层传送器 */ + drawFly(page?: any): void + + /** 绘制中心对称飞行器 */ + drawCenterFly(): void + + /** 绘制浏览地图界面 */ + drawMaps(index?: any, x?: number, y?: number): void + + /** 绘制道具栏 */ + drawToolbox(index?: any): void + + /** 绘制装备界面 */ + drawEquipbox(index?: any): void + + /** 绘制存档/读档界面 */ + drawSLPanel(index?: any, refresh?: any): void + + /** 绘制虚拟键盘 */ + drawKeyBoard(): void + + /** 绘制状态栏 */ + drawStatusBar(): void + + /** 绘制“数据统计”界面 */ + drawStatistics(floorIds?: string): void + + /** 绘制“关于”界面 */ + drawAbout(): void + + /** 绘制帮助页面 */ + drawHelp(): void + + /** 绘制灯光效果 */ + drawLight(name: string | CanvasRenderingContext2D, color?: any, lights?: any, lightDec?: number): void + + /** 在某个canvas上绘制一条线 */ + drawLine(name: string | CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, style?: string, lineWidth?: number): void + + /** 在某个canvas上绘制一个箭头 */ + drawArrow(name: string | CanvasRenderingContext2D, x1: number, y1: number, x2: number, y2: number, style?: string, lineWidth?: number): void + + /** 设置某个canvas的文字字体 */ + setFont(name: string | CanvasRenderingContext2D, font: string): void + + /** 设置某个canvas的线宽度 */ + setLineWidth(name: string | CanvasRenderingContext2D, lineWidth: number): void + + /** 设置某个canvas的alpha值 */ + setAlpha(name: string | CanvasRenderingContext2D, alpha: number): void + + /** 设置某个canvas的透明度;尽量不要使用本函数,而是全部换成setAlpha实现 */ + setOpacity(name: string | CanvasRenderingContext2D, opacity: number): void + + /** 设置某个canvas的绘制属性(如颜色等) */ + setFillStyle(name: string | CanvasRenderingContext2D, style: string): void + + /** 设置某个canvas边框属性 */ + setStrokeStyle(name: string | CanvasRenderingContext2D, style: string): void + + /** 设置某个canvas的对齐 */ + setTextAlign(name: string | CanvasRenderingContext2D, align: string): void + + /** 计算某段文字的宽度 */ + calWidth(name: string | CanvasRenderingContext2D, text: string, font?: string): number } /** 工具类 主要用来进行一些辅助函数的计算 */ @@ -1487,11 +2233,9 @@ declare class utils { * 将一段文字中的${}(表达式)进行替换。 * @example core.replaceText('衬衫的价格是${status:hp}镑${item:yellowKey}便士。'); // 把主角的生命值和持有的黄钥匙数量代入这句话 * @param text 模板字符串,可以使用${}计算js表达式,支持“状态、物品、变量、独立开关、全局存储、图块id、图块类型、敌人数据、装备id”等量参与运算 - * @param need 全局商店价格,一般可省略 - * @param times 全局商店已购次数,一般可省略 * @returns 替换完毕后的字符串 */ - replaceText(text: string, prefix?: string, need?: number, times?: number): string + replaceText(text: string, prefix?: string): string /** * 对一个表达式中的特殊规则进行替换,如status:xxx等。 @@ -1506,11 +2250,9 @@ declare class utils { * @example core.calValue('status:hp + status:def'); // 计算主角的生命值加防御力 * @param value 待求值的表达式 * @param prefix 独立开关前缀,一般可省略 - * @param need 全局商店价格,一般可省略 - * @param times 全局商店已购次数,一般可省略 * @returns 求出的值 */ - calValue(value: string, prefix?: string, need?: number, times?: number): any + calValue(value: string, prefix?: string): any /** * 将b(可以是另一个数组)插入数组a的开头,此函数用于弥补a.unshift(b)中b只能是单项的不足。 @@ -1660,14 +2402,6 @@ declare class utils { */ strlen(str: string): number - /** - * 反转朝向,即旋转180° - * @example core.turnHero(core.reverseDirection(core.status.hero.loc.direction)); // 主角原地转身180° - * @param direction 原朝向,不填则取主角当前朝向 - * @returns 反转后的朝向 - */ - reverseDirection(direction?: direction): direction - /** * 通配符匹配,用于搜索图块等批量处理。 * @example core.playSound(core.matchWildcard('*Key', itemId) ? 'item.mp3' : 'door.mp3'); // 判断捡到的是钥匙还是别的道具,从而播放不同的音效 @@ -1760,6 +2494,83 @@ declare class utils { * @param error 失败后的回调 */ http(type: 'GET' | 'POST', url: string, formData: FormData, success: () => void, error: () => void): void + + /** 解压缩一个数据 */ + decompress(value: any): any + + /** 设置本地存储 */ + setLocalStorage(key: string, value?: any): void + + /** 获得本地存储 */ + getLocalStorage(key: string, defaultValue?: any): any + + /** 移除本地存储 */ + removeLocalStorage(key: string): void + + /** 往数据库写入一段数据 */ + setLocalForage(key: string, value?: any, successCallback?: () => void, errorCallback?: () => void): void + + /** 从数据库读出一段数据 */ + getLocalForage(key: string, defaultValue?: any, successCallback?: (data: any) => void, errorCallback?: () => void): void + + /** 移除数据库的数据 */ + removeLocalForage(key: string, successCallback?: () => void, errorCallback?: () => void): void + + /** 格式化日期为字符串 */ + formatDate(date: Date): string + + /** 格式化日期为最简字符串 */ + formatDate2(date: Date): string + + /** 格式化时间 */ + formatTime(time: number): string + + /** 两位数显示 */ + setTwoDigits(x: number): string + + /** 格式化文件大小 */ + formatSize(size: number): string + + /** 访问浏览器cookie */ + getCookie(name: string): string + + /** + * 转向某方向 + * @param turn 转向的方向 + * @param direction 当前方向 + */ + turnDirection(turn: 'up' | 'down' | 'left' | 'right' | ':left' | ':right' | ':back', direction?: string): string + + /** 是否满足正则表达式 */ + matchRegex(pattern: string, string: string): string + + /** 让用户输入一段文字 */ + myprompt(hint: string, value: string, callback?: (data?: string) => any): void + + /** 动画显示某对象 */ + showWithAnimate(obj?: any, speed?: number, callback?: () => any): void + + /** 动画使某对象消失 */ + hideWithAnimate(obj?: any, speed?: number, callback?: () => any): void + + /** 解压一段内容 */ + unzip(blobOrUrl?: any, success?: (data: any) => void, error?: (error: string) => void, convertToText?: boolean, onprogress?: (loaded: number, total: number) => void): void +} + +/** 和图标相关的函数 */ +declare class icons { + + /** 获得所有图标类型 */ + getIcons(): void + + /** 根据ID获得其类型 */ + getClsFromId(id?: string): void + + /** 获得所有图标的ID */ + getAllIconIds(): void + + /** 根据图块数字或ID获得所在的tileset和坐标信息 */ + getTilesetOffset(id?: string): void } type core = { @@ -1890,13 +2701,16 @@ type core = { floors: { [key: string]: Floor } control: control + loader: loader events: events enemys: enemys items: items maps: maps ui: ui utils: utils + icons: icons + actions: actions -} & control & events & enemys & items & maps & ui & utils +} & control & events & loader & enemys & items & maps & ui & utils & icons & actions declare var core: core