google_forms/node_modules/@babel/helper-define-polyfill-prov.../esm/index.browser.mjs.map

1 line
61 KiB
Plaintext
Raw Normal View History

2024-08-09 12:04:48 +00:00
{"version":3,"file":"index.browser.mjs","sources":["../src/utils.ts","../src/imports-injector.ts","../src/debug-utils.ts","../src/normalize-options.ts","../src/visitors/usage.ts","../src/visitors/entry.ts","../src/browser/dependencies.ts","../src/meta-resolver.ts","../src/index.ts"],"sourcesContent":["import { types as t, template } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type { Utils } from \"./types\";\nimport type ImportsCachedInjector from \"./imports-injector\";\n\nexport function intersection<T>(a: Set<T>, b: Set<T>): Set<T> {\n const result = new Set<T>();\n a.forEach(v => b.has(v) && result.add(v));\n return result;\n}\n\nexport function has(object: any, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nfunction getType(target: any): string {\n return Object.prototype.toString.call(target).slice(8, -1);\n}\n\nfunction resolveId(path): string {\n if (\n path.isIdentifier() &&\n !path.scope.hasBinding(path.node.name, /* noGlobals */ true)\n ) {\n return path.node.name;\n }\n\n if (path.isPure()) {\n const { deopt } = path.evaluate();\n if (deopt && deopt.isIdentifier()) {\n return deopt.node.name;\n }\n }\n}\n\nexport function resolveKey(\n path: NodePath<t.Expression | t.PrivateName>,\n computed: boolean = false,\n) {\n const { scope } = path;\n if (path.isStringLiteral()) return path.node.value;\n const isIdentifier = path.isIdentifier();\n if (\n isIdentifier &&\n !(computed || (path.parent as t.MemberExpression).computed)\n ) {\n return path.node.name;\n }\n\n if (\n computed &&\n path.isMemberExpression() &&\n path.get(\"object\").isIdentifier({ name: \"Symbol\" }) &&\n !scope.hasBinding(\"Symbol\", /* noGlobals */ true)\n ) {\n const sym = resolveKey(path.get(\"property\"), path.node.computed);\n if (sym) return \"Symbol.\" + sym;\n }\n\n if (\n isIdentifier\n ? scope.hasBinding(path.node.name, /* noGlobals */ true)\n : path.isPure()\n ) {\n const { value } = path.evaluate();\n if (typeof value === \"string\") return value;\n }\n}\n\nexport function resolveSource(obj: NodePath): {\n id: string | null;\n placement: \"prototype\" | \"static\" | null;\n} {\n if (\n obj.isMemberExpression() &&\n obj.get(\"property\").isIdentifier({ name: \"prototype\" })\n ) {\n const id = resolveId(obj.get(\"object\"));\n\n if (id) {\n return { id, placement: \"prototype\" };\n }\n return { id: null, placement: null };\n }\n\n const id = resolveId(obj);\n if (id) {\n return { id, placement: \"static\" };\n }\n\n if (obj.isRegExpLiteral()) {\n return { id: \"RegExp\", placement: \"prototype\" };\n } else if (obj.isFunction()) {\n return { id: \"Function\", placement: \"prototype\" };\n } else if (obj.isPure()) {\n const { value } = obj.evaluate();\n if (value !== undefined) {\n return { id: getType(value), placement: \"prototype\" };\n }\n }\n\n return { id: null, placement: null };\n}\n\nexport function getImportSource({ node }: NodePath<t.ImportDeclaration>) {\n if (node.specifiers.length === 0) return node.source.value;\n}\n\nexport function getRequireSource({ node }: NodePath<t.Statement>) {\n if (!t.isExpressionStatement(node)) return;\n const { expression } = node;\n if (\n t.isCallExpression(expression) &&\n t.isIdentifier(expression.callee) &&\n expression.callee.name === \"require\" &&\n expression.arguments.length === 1 &&\n t.isStringLiteral(expression.arguments[0])\n ) {\n return expression.arguments[0].value;\n }\n}\n\nfunction hoist(node: t.Node) {\n // @ts-expect-error\n node._blockHoist = 3;\n return node;\n}\n\nexport function createUtilsGetter(cache: ImportsCachedInjector) {\n return (path: NodePath): Utils => {\n const prog = path.findParent(p => p.isProgram()) as NodePath<t.Program>;\n\n return {\n injectGlobalImport(url, moduleName) {\n cache.storeAnonymous(prog, url, moduleName, (isScript, source) => {\n return isScript\n