fediversity.eu/node_modules/prettier/plugins/meriyah.mjs

6 lines
117 KiB
JavaScript
Raw Normal View History

2024-03-26 16:28:28 +01:00
var Ie=Object.create;var Y2=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Ue=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports),Pu=(u,e)=>{for(var n in e)Y2(u,n,{get:e[n],enumerable:!0})},Me=(u,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ve(e))!Oe.call(u,i)&&i!==n&&Y2(u,i,{get:()=>e[i],enumerable:!(t=Ne(e,i))||t.enumerable});return u};var Je=(u,e,n)=>(n=u!=null?Ie(Re(u)):{},Me(e||!u||!u.__esModule?Y2(n,"default",{value:u,enumerable:!0}):n,u));var ve=Ue(a2=>{"use strict";Object.defineProperty(a2,"__esModule",{value:!0});a2.extract=F0;a2.parse=L0;a2.parseWithComments=Be;a2.print=I0;a2.strip=q0;var w0=/\*\/$/,S0=/^\/\*\*?/,we=/^\s*(\/\*\*?(.|\r?\n)*?\*\/)/,B0=/(^|\s+)\/\/([^\r\n]*)/g,Ce=/^(\r?\n)+/,v0=/(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g,Pe=/(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g,T0=/(\r?\n|^) *\* ?/g,Se=[];function F0(u){let e=u.match(we);return e?e[0].trimLeft():""}function q0(u){let e=u.match(we);return e&&e[0]?u.substring(e[0].length):u}function L0(u){return Be(u).pragmas}function Be(u){let e=`
`;u=u.replace(S0,"").replace(w0,"").replace(T0,"$1");let n="";for(;n!==u;)n=u,u=u.replace(v0,`${e}$1 $2${e}`);u=u.replace(Ce,"").trimRight();let t=Object.create(null),i=u.replace(Pe,"").replace(Ce,"").trimRight(),o;for(;o=Pe.exec(u);){let l=o[2].replace(B0,"");typeof t[o[1]]=="string"||Array.isArray(t[o[1]])?t[o[1]]=Se.concat(t[o[1]],l):t[o[1]]=l}return{comments:i,pragmas:t}}function I0({comments:u="",pragmas:e={}}){let n=`
`,t="/**",i=" *",o=" */",l=Object.keys(e),f=l.flatMap(a=>Ee(a,e[a])).map(a=>`${i} ${a}${n}`).join("");if(!u){if(l.length===0)return"";if(l.length===1&&!Array.isArray(e[l[0]])){let a=e[l[0]];return`${t} ${Ee(l[0],a)[0]}${o}`}}let c=u.split(n).map(a=>`${i} ${a}`).join(n)+n;return t+n+(u?c:"")+(u&&l.length?i+n:"")+f+o}function Ee(u,e){return Se.concat(e).map(n=>`@${u} ${n}`.trim())}});var Cu={};Pu(Cu,{parsers:()=>bu});var bu={};Pu(bu,{meriyah:()=>X0});var je={0:"Unexpected token",28:"Unexpected token: '%0'",1:"Octal escape sequences are not allowed in strict mode",2:"Octal escape sequences are not allowed in template strings",3:"Unexpected token `#`",4:"Illegal Unicode escape sequence",5:"Invalid code point %0",6:"Invalid hexadecimal escape sequence",8:"Octal literals are not allowed in strict mode",7:"Decimal integer literals with a leading zero are forbidden in strict mode",9:"Expected number in radix %0",146:"Invalid left-hand side assignment to a destructible right-hand side",10:"Non-number found after exponent indicator",11:"Invalid BigIntLiteral",12:"No identifiers allowed directly after numeric literal",13:"Escapes \\8 or \\9 are not syntactically valid escapes",14:"Unterminated string literal",15:"Unterminated template literal",16:"Multiline comment was not closed properly",17:"The identifier contained dynamic unicode escape that was not closed",18:"Illegal character '%0'",19:"Missing hexadecimal digits",20:"Invalid implicit octal",21:"Invalid line break in string literal",22:"Only unicode escapes are legal in identifier names",23:"Expected '%0'",24:"Invalid left-hand side in assignment",25:"Invalid left-hand side in async arrow",26:'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass',27:"Member access on super must be in a method",29:"Await expression not allowed in formal parameter",30:"Yield expression not allowed in formal parameter",93:"Unexpected token: 'escaped keyword'",31:"Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses",120:"Async functions can only be declared at the top level or inside a block",32:"Unterminated regular expression",33:"Unexpected regular expression flag",34:"Duplicate regular expression flag '%0'",35:"%0 functions must have exactly %1 argument%2",36:"Setter function argument must not be a rest parameter",37:"%0 declaration must have a name in this context",38:"Function name may not contain any reserved words or be eval or arguments in strict mode",39:"The rest operator is missing an argument",40:"A getter cannot be a generator",41:"A setter cannot be a generator",42:"A computed property name must be followed by a colon or paren",131:"Object literal keys that are strings or numbers must be a method or have a colon",44:"Found `* async x(){}` but this should be `async * x(){}`",43:"Getters and setters can not be generators",45:"'%0' can not be generator method",46:"No line break is allowed after '=>'",47:"The left-hand side of the arrow can only be destructed through assignment",48:"The binding declaration is not destructible",49:"Async arrow can not be followed by new expression",50:"Classes may not have a static property named 'prototype'",51:"Class constructor may not be a %0",52:"Duplicate constructor method in class",53:"Invalid increment/decrement operand",54:"Invalid use of `new` keyword on an increment/decrement expression",55:"`=>` is an invalid assignment target",56:"Rest element may not have a trailing comma",57:"Missing initializer in %0 declaration",58:"'for-%0' loop head declarations can not have an initializer",59:"Invalid left-hand side in for-%0 loop: Must have a single binding",60:"Invalid shorthand property initializer",61:"Property name __proto__ appears more than once in object literal",62:"Let is disallowed as a lexically bound name",63:"Invalid use of '%0' inside new expression",64:"Illegal 'use strict' directive in function with non-simple parameter list",65:'Identifier "let" disallowed as left-hand side expression in strict mode',66:"Illegal
`);return e.length>1&&e.every(n=>n.trimStart()[0]==="*")}var ku=A0;function D0(u){return T2(u)&&u.value[0]==="*"&&/@(?:type|satisfies)\b/.test(u.value)}var ye=D0;var F2=null;function q2(u){if(F2!==null&&typeof F2.property){let e=F2;return F2=q2.prototype=null,e}return F2=q2.prototype=u??Object.create(null),new q2}var b0=10;for(let u=0;u<=b0;u++)q2();function hu(u){return q2(u)}function C0(u,e="type"){hu(u);function n(t){let i=t[e],o=u[i];if(!Array.isArray(o))throw Object.assign(new Error(`Missing visitor keys for '${i}'.`),{node:t});return o}return n}var ke=C0;var he={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],ImportExpression:["source","options","attributes"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],Cla
`);return e===-1?u:u.slice(0,e)}var Te=N0;function V0(u){let e=Te(u);e&&(u=u.slice(e.length+1));let n=(0,C2.extract)(u),{pragmas:t,comments:i}=(0,C2.parseWithComments)(n);return{shebang:e,text:u,pragmas:t,comments:i}}function Fe(u){let{pragmas:e}=V0(u);return Object.prototype.hasOwnProperty.call(e,"prettier")||Object.prototype.hasOwnProperty.call(e,"format")}function R0(u){return u=typeof u=="function"?{parse:u}:u,{astFormat:"estree",hasPragma:Fe,locStart:$,locEnd:p,...u}}var qe=R0;function O0(u){let{filepath:e}=u;if(e){if(e=e.toLowerCase(),e.endsWith(".cjs"))return"script";if(e.endsWith(".mjs"))return"module"}}var Le=O0;var U0={next:!0,ranges:!0,webcompat:!0,loc:!0,raw:!0,directives:!0,globalReturn:!0,impliedStrict:!1,preserveParens:!1,lexical:!1,identifierPattern:!1,jsx:!0,specDeviation:!0,uniqueKeyInPattern:!1};function M0(u,e){let n=[],t=[],i=de(u,{...U0,module:e==="module",onComment:n,onToken:t});return i.comments=n,i.tokens=t,i}function J0(u){var o;let{message:e,line:n,column:t}=u,i=(o=e.match(/^\[(?<line>\d+):(?<column>\d+)]: (?<message>.*)$/))==null?void 0:o.groups;return i&&(e=i.message,typeof n!="number"&&(n=Number(i.line),t=Number(i.column))),typeof n!="number"?u:se(e,{loc:{start:{line:n,column:t}},cause:u})}function j0(u,e={}){let n=Le(e),t=(n?[n]:["module","script"]).map(o=>()=>M0(u,o)),i;try{i=ae(t)}catch({errors:[o]}){throw J0(o)}return be(i,{parser:"meriyah",text:u})}var X0=qe(j0);var Jn=Cu;export{Jn as default,bu as parsers};