{"version":3,"names":["_path","data","require","_configDescriptors","createItemFromDescriptor","desc","ConfigItem","createConfigItem","value","dirname","type","descriptor","createDescriptor","path","resolve","alias","CONFIG_ITEM_BRAND","Symbol","for","getItemDescriptor","item","_descriptor","undefined","constructor","options","name","file","Object","defineProperty","enumerable","request","resolved","freeze","prototype"],"sources":["../../src/config/item.ts"],"sourcesContent":["import type { Handler } from \"gensync\";\nimport type { PluginTarget, PluginOptions } from \"./validation/options.ts\";\n\nimport path from \"path\";\nimport { createDescriptor } from \"./config-descriptors.ts\";\n\nimport type { UnloadedDescriptor } from \"./config-descriptors.ts\";\n\nexport function createItemFromDescriptor(\n desc: UnloadedDescriptor,\n): ConfigItem {\n return new ConfigItem(desc);\n}\n\n/**\n * Create a config item using the same value format used in Babel's config\n * files. Items returned from this function should be cached by the caller\n * ideally, as recreating the config item will mean re-resolving the item\n * and re-evaluating the plugin/preset function.\n */\nexport function* createConfigItem(\n value:\n | PluginTarget\n | [PluginTarget, PluginOptions]\n | [PluginTarget, PluginOptions, string | void],\n {\n dirname = \".\",\n type,\n }: {\n dirname?: string;\n type?: \"preset\" | \"plugin\";\n } = {},\n): Handler> {\n const descriptor = yield* createDescriptor(value, path.resolve(dirname), {\n type,\n alias: \"programmatic item\",\n });\n\n return createItemFromDescriptor(descriptor);\n}\n\nconst CONFIG_ITEM_BRAND = Symbol.for(\"@babel/core@7 - ConfigItem\");\n\nexport function getItemDescriptor(\n item: unknown,\n): UnloadedDescriptor | void {\n if ((item as any)?.[CONFIG_ITEM_BRAND]) {\n return (item as ConfigItem)._descriptor;\n }\n\n return undefined;\n}\n\nexport type { ConfigItem };\n\n/**\n * A public representation of a plugin/preset that will _eventually_ be load.\n * Users can use this to interact with the results of a loaded Babel\n * configuration.\n *\n * Any changes to public properties of this class should be considered a\n * breaking change to Babel's API.\n */\nclass ConfigItem {\n /**\n * The private underlying descriptor that Babel actually cares about.\n * If you access this, you are a bad person.\n */\n _descriptor: UnloadedDescriptor;\n\n // TODO(Babel 9): Check if this symbol needs to be updated\n /**\n * Used to detect ConfigItem instances from other Babel instances.\n */\n [CONFIG_ITEM_BRAND] = true;\n\n /**\n * The resolved value of the item itself.\n */\n value: {} | Function;\n\n /**\n * The options, if any, that were passed to the item.\n * Mutating this will lead to undefined behavior.\n *\n * \"false\" means that this item has been disabled.\n */\n options: {} | void | false;\n\n /**\n * The directory that the options for this item are relative to.\n */\n dirname: string;\n\n /**\n * Get the name of the plugin, if the user gave it one.\n */\n name: string | void;\n\n /**\n * Data about the file that the item was loaded from, if Babel knows it.\n */\n file: {\n // The requested path, e.g. \"@babel/env\".\n request: string;\n // The resolved absolute path of the file.\n resolved: string;\n } | void;\n\n constructor(descriptor: UnloadedDescriptor) {\n // Make people less likely to stumble onto this if they are exploring\n // programmatically, and also make sure that if people happen to\n // pass the item through JSON.stringify, it doesn't show up.\n this._descriptor = descriptor;\n Object.defineProperty(this, \"_descriptor\", { enumerable: false });\n\n Object.defineProperty(this, CONFIG_ITEM_BRAND, { enumerable: false });\n\n this.value = this._descriptor.value;\n this.options = this._descriptor.options;\n this.dirname = this._descriptor.dirname;\n this.name = this._descriptor.name;\n this.file = this._descriptor.file\n ? {\n request: this._descriptor.file.request,\n resolved: this._descriptor.file.resolved,\n }\n : undefined;\n\n // Freeze the object to make it clear that people shouldn't expect mutating\n // this object to do anything. A new item should be created if they want\n // to change something.\n Object.freeze(this);\n }\n}\n\nObject.freeze(ConfigItem.prototype);\n"],"mappings":";;;;;;;;AAGA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,IAAAE,kBAAA,GAAAD,OAAA;AAIO,SAASE,wBAAwBA,CACtCC,IAA6B,EACZ;EACjB,OAAO,IAAIC,UAAU,CAACD,IAAI,CAAC;AAC7B;AAQO,UAAUE,gBAAgBA,CAC/BC,KAGgD,EAChD;EACEC,OAAO,GAAG,GA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