NET-Web-API-w-Angular/my-app/node_modules/@babel/traverse/lib/visitors.js.map

1 line
20 KiB
Text
Raw Normal View History

2024-02-09 00:38:41 +00:00
{"version":3,"names":["virtualTypes","require","virtualTypesValidators","_t","DEPRECATED_KEYS","DEPRECATED_ALIASES","FLIPPED_ALIAS_KEYS","TYPES","__internal__deprecationWarning","deprecationWarning","isVirtualType","type","isExplodedVisitor","visitor","_exploded","explode","nodeType","Object","keys","shouldIgnoreKey","parts","split","length","fns","part","verify","__esModule","ensureEntranceObjects","ensureCallbackArrays","wrapCheck","types","mergePair","aliases","deprecatedKey","deprecatedAlias","alias","existing","assign","_verified","Error","validateVisitorMethods","indexOf","visitors","visitorKey","path","val","concat","fn","TypeError","merge","states","wrapper","mergedVisitor","i","state","topVisitor","wrapWithStateOrWrapper","key","typeVisitor","nodeVisitor","oldVisitor","newVisitor","phase","Array","isArray","map","newFn","call","toString","obj","enter","exit","fnKey","validator","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-types.ts\";\nimport * as virtualTypesValidators from \"./path/lib/virtual-types-validator.ts\";\nimport type { Node } from \"@babel/types\";\nimport {\n DEPRECATED_KEYS,\n DEPRECATED_ALIASES,\n FLIPPED_ALIAS_KEYS,\n TYPES,\n __internal__deprecationWarning as deprecationWarning,\n} from \"@babel/types\";\nimport type { ExplodedVisitor, NodePath, Visitor } from \"./index.ts\";\nimport type { ExplVisitNode, VisitNodeFunction, VisitPhase } from \"./types.ts\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\n}\nexport type VisitWrapper<S = any> = (\n stateName: string | undefined,\n visitorType: VisitPhase,\n callback: VisitNodeFunction<S, Node>,\n) => VisitNodeFunction<S, Node>;\n\nexport function isExplodedVisitor(\n visitor: Visitor,\n): visitor is ExplodedVisitor {\n // @ts-expect-error _exploded is not defined on non-exploded Visitor\n return visitor?._exploded;\n}\n\n/**\n * explode() will take a visitor object with all of the various shorthands\n * that we support, and validates & normalizes it into a common format, ready\n * to be used in traversal\n *\n * The various shorthands are:\n * * `Identifier() { ... }` -> `Identifier: { enter() { ... } }`\n * * `\"Identifier|NumericLiteral\": { ... }` -> `Identifier: { ... }, NumericLiteral: { ... }`\n * * Aliases in `@babel/types`: e.g. `Property: { ... }` -> `ObjectProperty: { ... }, ClassProperty: { ... }`\n * Other normalizations are:\n * * Visitors of virtual types are wrapped, so that they are only visited when\n * their dynamic check passes\n * * `enter` and `exit` functions are wrapped in arrays, to ease merging of\n * visitors\n */\nexport function explode<S>(visitor: Visitor<S>): ExplodedVisitor<S> {\n if (isExplodedVisitor(visitor)) return visitor;\n // @ts-expect-error `visitor` will be cast to ExplodedVisitor by this function\n visitor._exploded = true;\n\n // normalise pipes\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n const parts: Array<string> = nodeType.split(\"|\");\n if (parts.length === 1) continue;\n\n const fns = visitor[nodeType];\n delete visitor[nodeType];\n\n for (const part of parts) {\n // @ts-expect-error part will be verified by `verify` later\n visitor[part] = fns;\n }\n }\n\n // verify data structure\n verify(visitor);\n\n // make sure there's no __esModule type since this is because we're using loose mode\n // and it sets __esModule to be enumerable on all modules :(\n // @ts-expect-error ESModule interop\n delete visitor.__esModule;\n\n // ensure visitors are objects\n ensureEntranceObjects(visitor);\n\n // ensure enter/exit callbacks are arrays\n ensureCallbackArrays(visitor);\n\n // add type wrappers\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (!isVirtualType(nodeType)) continue;\n\n // wrap all the functions\n const fns = vi