challenge-algorithms-v2.0-D.../node_modules/@babel/helper-plugin-utils/lib/index.js.map

1 line
7.2 KiB
Plaintext

{"version":3,"names":["declare","builder","api","options","dirname","clonedApi","name","Object","keys","apiPolyfills","copyApiObject","declarePreset","assertVersion","range","throwVersionError","version","targets","assumption","undefined","proto","test","getPrototypeOf","has","obj","key","prototype","hasOwnProperty","call","Number","isInteger","Error","limit","stackTraceLimit","err","slice","assign","code"],"sources":["../src/index.ts"],"sourcesContent":["import type {\n PluginAPI,\n PluginObject,\n PluginPass,\n PresetAPI,\n PresetObject,\n} from \"@babel/core\";\n\nexport function declare<State = {}, Option = {}>(\n builder: (\n api: PluginAPI,\n options: Option,\n dirname: string,\n ) => PluginObject<State & PluginPass>,\n): (\n api: PluginAPI,\n options: Option,\n dirname: string,\n) => PluginObject<State & PluginPass> {\n return (api, options: Option, dirname: string) => {\n let clonedApi: PluginAPI;\n\n for (const name of Object.keys(\n apiPolyfills,\n ) as (keyof typeof apiPolyfills)[]) {\n if (api[name]) continue;\n\n // TODO: Use ??= when flow lets us to do so\n clonedApi = clonedApi ?? copyApiObject(api);\n // @ts-expect-error The shape of API polyfill is guaranteed by APIPolyfillFactory\n clonedApi[name] = apiPolyfills[name](clonedApi);\n }\n\n // @ts-expect-error options || {} may not be assigned to Options\n return builder(clonedApi ?? api, options || {}, dirname);\n };\n}\n\nexport const declarePreset = declare as <Option = {}>(\n builder: (api: PresetAPI, options: Option, dirname: string) => PresetObject,\n) => (api: PresetAPI, options: Option, dirname: string) => PresetObject;\n\ntype APIPolyfillFactory<T extends keyof PluginAPI> = (\n api: PluginAPI,\n) => PluginAPI[T];\n\ntype APIPolyfills = {\n assertVersion: APIPolyfillFactory<\"assertVersion\">;\n targets: APIPolyfillFactory<\"targets\">;\n assumption: APIPolyfillFactory<\"assumption\">;\n};\n\nconst apiPolyfills: APIPolyfills = {\n // Not supported by Babel 7 and early versions of Babel 7 beta.\n // It's important that this is polyfilled for older Babel versions\n // since it's needed to report the version mismatch.\n assertVersion: (api: PluginAPI) => (range: number | string) => {\n throwVersionError(range, api.version);\n },\n // This is supported starting from Babel 7.13\n // TODO(Babel 8): Remove this polyfill\n targets: () => () => {\n return {};\n },\n // This is supported starting from Babel 7.13\n // TODO(Babel 8): Remove this polyfill\n assumption: () => () => {\n return undefined;\n },\n};\n\nfunction copyApiObject(api: PluginAPI): PluginAPI {\n // Babel >= 7 <= beta.41 passed the API as a new object that had\n // babel/core as the prototype. While slightly faster, it also\n // means that the Object.assign copy below fails. Rather than\n // keep complexity, the Babel 6 behavior has been reverted and this\n // normalizes all that for Babel 7.\n let proto = null;\n if (typeof api.version === \"string\" && /^7\\./.test(api.version)) {\n proto = Object.getPrototypeOf(api);\n if (\n proto &&\n (!has(proto, \"version\") ||\n !has(proto, \"transform\") ||\n !has(proto, \"template\") ||\n !has(proto, \"types\"))\n ) {\n proto = null;\n }\n }\n\n return {\n ...proto,\n ...api,\n };\n}\n\nfunction has(obj: {}, key: string) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n}\n\nfunction throwVersionError(range: string | number, version: string) {\n if (typeof range === \"number\") {\n if (!Number.isInteger(range)) {\n throw new Error(\"Expected string or integer value.\");\n }\n range = `^${range}.0.0-0`;\n }\n if (typeof range !== \"string\") {\n throw new Error(\"Expected string or integer value.\");\n }\n\n const limit = Error.stackTraceLimit;\n\n if (typeof limit === \"number\" && limit < 25) {\n // Bump up the limit if needed so that users are more likely\n // to be able to see what is calling Babel.\n Error.stackTraceLimit = 25;\n }\n\n let err;\n if (version.slice(0, 2) === \"7.\") {\n err = new Error(\n `Requires Babel \"^7.0.0-beta.41\", but was loaded with \"${version}\". ` +\n `You'll need to update your @babel/core version.`,\n );\n } else {\n err = new Error(\n `Requires Babel \"${range}\", but was loaded with \"${version}\". ` +\n `If you are sure you have a compatible version of @babel/core, ` +\n `it is likely that something in your build process is loading the ` +\n `wrong version. Inspect the stack trace of this error to look for ` +\n `the first entry that doesn't mention \"@babel/core\" or \"babel-core\" ` +\n `to see what is calling Babel.`,\n );\n }\n\n if (typeof limit === \"number\") {\n Error.stackTraceLimit = limit;\n }\n\n throw Object.assign(err, {\n code: \"BABEL_VERSION_UNSUPPORTED\",\n version,\n range,\n } as any);\n}\n"],"mappings":";;;;;;;;AAQO,SAASA,OAAT,CACLC,OADK,EAU+B;EACpC,OAAO,CAACC,GAAD,EAAMC,OAAN,EAAuBC,OAAvB,KAA2C;IAAA;;IAChD,IAAIC,SAAJ;;IAEA,KAAK,MAAMC,IAAX,IAAmBC,MAAM,CAACC,IAAP,CACjBC,YADiB,CAAnB,EAEoC;MAAA;;MAClC,IAAIP,GAAG,CAACI,IAAD,CAAP,EAAe;MAGfD,SAAS,iBAAGA,SAAH,yBAAgBK,aAAa,CAACR,GAAD,CAAtC;MAEAG,SAAS,CAACC,IAAD,CAAT,GAAkBG,YAAY,CAACH,IAAD,CAAZ,CAAmBD,SAAnB,CAAlB;IACD;;IAGD,OAAOJ,OAAO,gBAACI,SAAD,0BAAcH,GAAd,EAAmBC,OAAO,IAAI,EAA9B,EAAkCC,OAAlC,CAAd;EACD,CAhBD;AAiBD;;AAEM,MAAMO,aAAa,GAAGX,OAAtB;;AAcP,MAAMS,YAA0B,GAAG;EAIjCG,aAAa,EAAGV,GAAD,IAAqBW,KAAD,IAA4B;IAC7DC,iBAAiB,CAACD,KAAD,EAAQX,GAAG,CAACa,OAAZ,CAAjB;EACD,CANgC;EASjCC,OAAO,EAAE,MAAM,MAAM;IACnB,OAAO,EAAP;EACD,CAXgC;EAcjCC,UAAU,EAAE,MAAM,MAAM;IACtB,OAAOC,SAAP;EACD;AAhBgC,CAAnC;;AAmBA,SAASR,aAAT,CAAuBR,GAAvB,EAAkD;EAMhD,IAAIiB,KAAK,GAAG,IAAZ;;EACA,IAAI,OAAOjB,GAAG,CAACa,OAAX,KAAuB,QAAvB,IAAmC,OAAOK,IAAP,CAAYlB,GAAG,CAACa,OAAhB,CAAvC,EAAiE;IAC/DI,KAAK,GAAGZ,MAAM,CAACc,c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