{"version":3,"names":["virtualTypes","require","_t","DEPRECATED_KEYS","DEPRECATED_ALIASES","FLIPPED_ALIAS_KEYS","TYPES","__internal__deprecationWarning","deprecationWarning","isVirtualType","type","explode","visitor","_exploded","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","rootVisitor","i","state","visitorType","wrapWithStateOrWrapper","nodeVisitor","oldVisitor","newVisitor","key","Array","isArray","map","newFn","call","toString","obj","enter","exit","apply","arguments","dest","src"],"sources":["../src/visitors.ts"],"sourcesContent":["import * as virtualTypes from \"./path/lib/virtual-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 { NodePath, Visitor } from \"./index\";\n\ntype VIRTUAL_TYPES = keyof typeof virtualTypes;\nfunction isVirtualType(type: string): type is VIRTUAL_TYPES {\n return type in virtualTypes;\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 *\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(visitor: Visitor) {\n if (visitor._exploded) return visitor;\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 = visitor[nodeType];\n for (const type of Object.keys(fns)) {\n // @ts-expect-error manipulating visitors\n fns[type] = wrapCheck(nodeType, fns[type]);\n }\n\n // clear it from the visitor\n delete visitor[nodeType];\n\n const types = virtualTypes[nodeType];\n if (types !== null) {\n for (const type of types) {\n // merge the visitor if necessary or just put it back in\n if (visitor[type]) {\n mergePair(visitor[type], fns);\n } else {\n // @ts-expect-error Expression produces too complex union\n visitor[type] = fns;\n }\n }\n } else {\n mergePair(visitor, fns);\n }\n }\n\n // add aliases\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n let aliases = FLIPPED_ALIAS_KEYS[nodeType];\n\n if (nodeType in DEPRECATED_KEYS) {\n const deprecatedKey = DEPRECATED_KEYS[nodeType];\n deprecationWarning(nodeType, deprecatedKey, \"Visitor \");\n aliases = [deprecatedKey];\n } else if (nodeType in DEPRECATED_ALIASES) {\n const deprecatedAlias =\n DEPRECATED_ALIASES[nodeType as keyof typeof DEPRECATED_ALIASES];\n deprecationWarning(nodeType, deprecatedAlias, \"Visitor \");\n aliases = FLIPPED_ALIAS_KEYS[deprecatedAlias];\n }\n\n if (!aliases) continue;\n\n const fns = visitor[nodeType];\n // clear it from the visitor\n delete visitor[nodeType];\n\n for (const alias of aliases) {\n const existing = visitor[alias];\n if (existing) {\n mergePair(existing, fns);\n } else {\n // @ts-expect-error Expression produces a union type that is too complex to represent.\n visitor[alias] = { ...fns };\n }\n }\n }\n\n for (const nodeType of Object.keys(visitor)) {\n if (shouldIgnoreKey(nodeType)) continue;\n\n ensureCallbackArrays(\n // @ts-expect-error nodeType must present in visitor after previous validations\n visitor[nodeType],\n );\n }\n\n return visitor;\n}\n\nexport function verify(visitor: Visitor) {\n if (visitor._verified) return;\n\n if (typeof visitor === \"function\") {\n throw new Error(\n \"You passed `traverse()` a function when it expected a visitor object, \" +\n \"are you sure you didn't mean `{ enter: Function }`?\",\n );\n }\n\n for (const nodeType of Object.keys(visitor) as (keyof Visitor)[]) {\n if (nodeType === \"enter\" || nodeType === \"exit\") {\n validateVisitorMethods(nodeType, visitor[nodeType]);\n }\n\n if (shouldIgnoreKey(nodeType)) continue;\n\n if (TYPES.indexOf(nodeType) < 0) {\n throw new Error(\n `You gave us a visitor for the node type ${nodeType} but it's not a valid type`,\n );\n }\n\n const visitors = visitor[nodeType];\n if (typeof visitors === \"object\") {\n for (const visitorKey of Object.keys(visitors)) {\n if (visitorKey === \"enter\" || visitorKey === \"exit\") {\n // verify that it just contains functions\n validateVisitorMethods(\n `${nodeType}.${visitorKey}`,\n visitors[visitorKey],\n );\n } else {\n throw new Error(\n \"You passed `traverse()` a visitor object with the property \" +\n `${nodeType} that has the invalid property ${visitorKey}`,\n );\n }\n }\n }\n }\n\n visitor._verified = true;\n}\n\nfunction validateVisitorMethods(\n path: string,\n val: any,\n): asserts val is Function | Function[] {\n const fns = [].concat(val);\n for (const fn of fns) {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `Non-function found defined in ${path} with type ${typeof fn}`,\n );\n }\n }\n}\n\nexport function merge<State>(visitors: Visitor<State>[]): Visitor<State>;\nexport function merge(\n visitors: Visitor<unknown>[],\n states?: any[],\n wrapper?: Function | null,\n): Visitor<unknown>;\nexport function merge(\n visitors: any[],\n states: any[] = [],\n wrapper?: Function | null,\n) {\n const rootVisitor: Visitor = {};\n\n for (let i = 0; i < visitors.length; i++) {\n const visitor = visitors[i];\n const state = states[i];\n\n explode(visitor);\n\n for (const type of Object.keys(visitor) as (keyof Visitor)[]) {\n let visitorType = visitor[type];\n\n // if we have state or wrapper then overload the callbacks to take it\n if (state || wrapper) {\n visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);\n }\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n const nodeVisitor = (rootVisitor[type] ||= {});\n mergePair(nodeVisitor, visitorType);\n }\n }\n\n return rootVisitor;\n}\n\nfunction wrapWithStateOrWrapper<State>(\n oldVisitor: Visitor<State>,\n state: State,\n wrapper?: Function | null,\n) {\n const newVisitor: Visitor = {};\n\n for (const key of Object.keys(oldVisitor) as (keyof Visitor<State>)[]) {\n let fns = oldVisitor[key];\n\n // not an enter/exit array of callbacks\n if (!Array.isArray(fns)) continue;\n\n // @ts-expect-error manipulating visitors\n fns = fns.map(function (fn) {\n let newFn = fn;\n\n if (state) {\n newFn = function (path: NodePath) {\n return fn.call(state, path, state);\n };\n }\n\n if (wrapper) {\n // @ts-expect-error Fixme: document state.key\n newFn = wrapper(state.key, key, newFn);\n }\n\n // Override toString in case this function is printed, we want to print the wrapped function, same as we do in `wrapCheck`\n if (newFn !== fn) {\n newFn.toString = () => fn.toString();\n }\n\n return newFn;\n });\n\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n newVisitor[key] = fns;\n }\n\n return newVisitor;\n}\n\nfunction ensureEntranceObjects(obj: Visitor) {\n for (const key of Object.keys(obj) as (keyof Visitor)[]) {\n if (shouldIgnoreKey(key)) continue;\n\n const fns = obj[key];\n if (typeof fns === \"function\") {\n // @ts-expect-error: Expression produces a union type that is too complex to represent.\n obj[key] = { enter: fns };\n }\n }\n}\n\nfunction ensureCallbackArrays(obj: Visitor) {\n // @ts-expect-error normalizing enter property\n if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];\n // @ts-expect-error normalizing exit property\n if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];\n}\n\nfunction wrapCheck(nodeType: VIRTUAL_TYPES, fn: Function) {\n const newFn = function (this: unknown, path: NodePath) {\n if (path[`is${nodeType}`]()) {\n return fn.apply(this, arguments);\n }\n };\n newFn.toString = () => fn.toString();\n return newFn;\n}\n\nfunction shouldIgnoreKey(\n key: string,\n): key is\n | \"enter\"\n | \"exit\"\n | \"shouldSkip\"\n | \"denylist\"\n | \"noScope\"\n | \"skipKeys\"\n | \"blacklist\" {\n // internal/hidden key\n if (key[0] === \"_\") return true;\n\n // ignore function keys\n if (key === \"enter\" || key === \"exit\" || key === \"shouldSkip\") return true;\n\n // ignore other options\n if (\n key === \"denylist\" ||\n key === \"noScope\" ||\n key === \"skipKeys\" ||\n // TODO: Remove in Babel 8\n key === \"blacklist\"\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction mergePair(dest: any, src: any) {\n for (const key of Object.keys(src)) {\n dest[key] = [].concat(dest[key] || [], src[key]);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAMsB;EALpBE,eAAe;EACfC,kBAAkB;EAClBC,kBAAkB;EAClBC,KAAK;EACLC,8BAA8B,EAAIC;AAAkB,IAAAN,EAAA;AAKtD,SAASO,aAAaA,CAACC,IAAY,EAAyB;EAC1D,OAAOA,IAAI,IAAIV,YAAY;AAC7B;AAkBO,SAASW,OAAOA,CAACC,OAAgB,EAAE;EACxC,IAAIA,OAAO,CAACC,SAAS,EAAE,OAAOD,OAAO;EACrCA,OAAO,CAACC,SAAS,GAAG,IAAI;EAGxB,KAAK,MAAMC,QAAQ,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAAC,EAAuB;IAChE,IAAIK,eAAe,CAACH,QAAQ,CAAC,EAA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