1 line
248 KiB
JavaScript
1 line
248 KiB
JavaScript
|
|
var t={214(t,e,i){const s=i(591),r=/^[\da-fA-F]+$/,a=/^\d+$/,n=new WeakMap;function o(t){t=t.Parser.acorn||t;let e=n.get(t);if(!e){const i=t.tokTypes,s=t.TokContext,r=t.TokenType,a=new s("<tag",!1),o=new s("</tag",!1),h=new s("<tag>...</tag>",!0,!0),p={tc_oTag:a,tc_cTag:o,tc_expr:h},c={jsxName:new r("jsxName"),jsxText:new r("jsxText",{beforeExpr:!0}),jsxTagStart:new r("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new r("jsxTagEnd")};c.jsxTagStart.updateContext=function(){this.context.push(h),this.context.push(a),this.exprAllowed=!1},c.jsxTagEnd.updateContext=function(t){let e=this.context.pop();e===a&&t===i.slash||e===o?(this.context.pop(),this.exprAllowed=this.curContext()===h):this.exprAllowed=!0},e={tokContexts:p,tokTypes:c},n.set(t,e)}return e}function h(t){return t?"JSXIdentifier"===t.type?t.name:"JSXNamespacedName"===t.type?t.namespace.name+":"+t.name.name:"JSXMemberExpression"===t.type?h(t.object)+"."+h(t.property):void 0:t}t.exports=function(t){return t=t||{},function(e){return function(t,e){const n=e.acorn||i(630),p=o(n),c=n.tokTypes,l=p.tokTypes,u=n.tokContexts,d=p.tokContexts.tc_oTag,f=p.tokContexts.tc_cTag,m=p.tokContexts.tc_expr,g=n.isNewLine,x=n.isIdentifierStart,v=n.isIdentifierChar;return class extends e{static get acornJsx(){return p}jsx_readToken(){let t="",e=this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");let i=this.input.charCodeAt(this.pos);switch(i){case 60:case 123:return this.pos===this.start?60===i&&this.exprAllowed?(++this.pos,this.finishToken(l.jsxTagStart)):this.getTokenFromCode(i):(t+=this.input.slice(e,this.pos),this.finishToken(l.jsxText,t));case 38:t+=this.input.slice(e,this.pos),t+=this.jsx_readEntity(),e=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(62===i?">":"}")+'` or `{"'+this.input[this.pos]+'"}`?');default:g(i)?(t+=this.input.slice(e,this.pos),t+=this.jsx_readNewLine(!0),e=this.pos):++this.pos}}}jsx_readNewLine(t){let e,i=this.input.charCodeAt(this.pos);return++this.pos,13===i&&10===this.input.charCodeAt(this.pos)?(++this.pos,e=t?"\n":"\r\n"):e=String.fromCharCode(i),this.options.locations&&(++this.curLine,this.lineStart=this.pos),e}jsx_readString(t){let e="",i=++this.pos;for(;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");let s=this.input.charCodeAt(this.pos);if(s===t)break;38===s?(e+=this.input.slice(i,this.pos),e+=this.jsx_readEntity(),i=this.pos):g(s)?(e+=this.input.slice(i,this.pos),e+=this.jsx_readNewLine(!1),i=this.pos):++this.pos}return e+=this.input.slice(i,this.pos++),this.finishToken(c.string,e)}jsx_readEntity(){let t,e="",i=0,n=this.input[this.pos];"&"!==n&&this.raise(this.pos,"Entity must start with an ampersand");let o=++this.pos;for(;this.pos<this.input.length&&i++<10;){if(n=this.input[this.pos++],";"===n){"#"===e[0]?"x"===e[1]?(e=e.substr(2),r.test(e)&&(t=String.fromCharCode(parseInt(e,16)))):(e=e.substr(1),a.test(e)&&(t=String.fromCharCode(parseInt(e,10)))):t=s[e];break}e+=n}return t||(this.pos=o,"&")}jsx_readWord(){let t,e=this.pos;do{t=this.input.charCodeAt(++this.pos)}while(v(t)||45===t);return this.finishToken(l.jsxName,this.input.slice(e,this.pos))}jsx_parseIdentifier(){let t=this.startNode();return this.type===l.jsxName?t.name=this.value:this.type.keyword?t.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(t,"JSXIdentifier")}jsx_parseNamespacedName(){let e=this.start,i=this.startLoc,s=this.jsx_parseIdentifier();if(!t.allowNamespaces||!this.eat(c.colon))return s;var r=this.startNodeAt(e,i);return r.namespace=s,r.name=this.jsx_parseIdentifier(),this.finishNode(r,"JSXNamespacedName")}jsx_parseElementName(){if(this.type===l.jsxTagEnd)return"";let e=this.start,i=this.startLoc,s=this.jsx_parseNamespacedName();for(this.type!==c.dot||"JSXNamespacedName"!==s.type||t.allowNamespacedObjects||this.unexpected();this.eat(c.dot);){let t=this.startNodeAt(e,i);t.object=s,t.property=this.jsx_parseIdentifier(),s=this.finishNode(t,"JSXMemberExpression")}return s}jsx_parseAttributeValue(){switch(this.
|