travel/admin/node_modules/@babel/plugin-transform-for-of/lib/index.js.map

1 line
18 KiB
Plaintext
Raw Normal View History

2024-06-24 11:28:18 +08:00
{"version":3,"names":["_helperPluginUtils","require","_core","_noHelperImplementation","_helperSkipTransparentExpressionWrappers","buildLoopBody","path","declar","newBody","block","bodyPath","get","body","node","t","isBlockStatement","Object","keys","getBindingIdentifiers","some","id","scope","hasOwnBinding","blockStatement","toBlock","unshift","_default","exports","default","declare","api","options","_options$assumeArray","_options$allowArrayLi","_api$assumption","assertVersion","assumeArray","allowArrayLike","loose","Error","test","version","iterableIsArray","assumption","arrayLikeIsIterable","skipIteratorClosing","name","visitor","ForOfStatement","left","await","isAwait","right","skipTransparentExprWrapperNodes","i","generateUidIdentifier","array","maybeGenerateMemoised","isIdentifier","inits","variableDeclarator","numericLiteral","push","item","memberExpression","cloneNode","assignment","isVariableDeclaration","declarations","init","expressionStatement","assignmentExpression","replaceWith","forStatement","variableDeclaration","binaryExpression","identifier","updateExpression","buildForOfArray","template","buildForOfNoIteratorClosing","statements","buildForOf","builder","build","helper","getContainer","nodes","_ForOfStatementArray","generateUidIdentifierBasedOnNode","iterationKey","loop","BODY","KEY","NAME","ARR","inherits","iterationValue","state","isArrayExpression","isGenericType","isArrayTypeAnnotation","getTypeAnnotation","availableHelper","transformWithoutHelper","parent","stepKey","generateUid","stepValue","kind","CREATE_ITERATOR_HELPER","addHelper","ITERATOR_HELPER","ARRAY_LIKE_IS_ITERABLE","booleanLiteral","STEP_KEY","OBJECT","container","isLabeledStatement","labeledStatement","label","parentPath","replaceWithMultiple","skip"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { template, types as t, type NodePath } from \"@babel/core\";\n\nimport transformWithoutHelper from \"./no-helper-implementation.ts\";\nimport { skipTransparentExprWrapperNodes } from \"@babel/helper-skip-transparent-expression-wrappers\";\n\nexport interface Options {\n allowArrayLike?: boolean;\n assumeArray?: boolean;\n loose?: boolean;\n}\n\nfunction buildLoopBody(\n path: NodePath<t.ForXStatement>,\n declar: t.Statement,\n newBody?: t.Statement | t.Expression,\n) {\n let block;\n const bodyPath = path.get(\"body\");\n const body = newBody ?? bodyPath.node;\n if (\n t.isBlockStatement(body) &&\n Object.keys(path.getBindingIdentifiers()).some(id =>\n bodyPath.scope.hasOwnBinding(id),\n )\n ) {\n block = t.blockStatement([declar, body]);\n } else {\n block = t.toBlock(body);\n block.body.unshift(declar);\n }\n return block;\n}\n\nexport default declare((api, options: Options) => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n {\n const { assumeArray, allowArrayLike, loose } = options;\n\n if (loose === true && assumeArray === true) {\n throw new Error(\n `The loose and assumeArray options cannot be used together in @babel/plugin-transform-for-of`,\n );\n }\n\n if (assumeArray === true && allowArrayLike === true) {\n throw new Error(\n `The assumeArray and allowArrayLike options cannot be used together in @babel/plugin-transform-for-of`,\n );\n }\n\n if (!process.env.BABEL_8_BREAKING) {\n // TODO: Remove in Babel 8\n if (allowArrayLike && /^7\\.\\d\\./.test(api.version)) {\n throw new Error(\n `The allowArrayLike is only supported when using @babel/core@^7.10.0`,\n );\n }\n }\n }\n\n const iterableIsArray =\n options.assumeArray ??\n // Loose mode is not compatible with 'assumeArray', so we shouldn't read\n // 'iterableIsArray' if 'loose' is true.\n (!options.loose && api.assumption(\"iterableIsArray\"));\n\n const arrayLikeIsIterable =\n options.allowArrayLike ?? api.assumption(\"arrayLikeIsIterable\");\n\n const skipIteratorClosing =\n api.assumption(\"skipForOfIteratorClosing\") ?? options.loose;\n\n if (iterableIsArra