1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.createConfigItem = createConfigItem;
|
7 | exports.createItemFromDescriptor = createItemFromDescriptor;
|
8 | exports.getItemDescriptor = getItemDescriptor;
|
9 | function _path() {
|
10 | const data = require("path");
|
11 | _path = function () {
|
12 | return data;
|
13 | };
|
14 | return data;
|
15 | }
|
16 | var _configDescriptors = require("./config-descriptors");
|
17 | function createItemFromDescriptor(desc) {
|
18 | return new ConfigItem(desc);
|
19 | }
|
20 | function* createConfigItem(value, {
|
21 | dirname = ".",
|
22 | type
|
23 | } = {}) {
|
24 | const descriptor = yield* (0, _configDescriptors.createDescriptor)(value, _path().resolve(dirname), {
|
25 | type,
|
26 | alias: "programmatic item"
|
27 | });
|
28 | return createItemFromDescriptor(descriptor);
|
29 | }
|
30 | const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
|
31 | function getItemDescriptor(item) {
|
32 | if (item != null && item[CONFIG_ITEM_BRAND]) {
|
33 | return item._descriptor;
|
34 | }
|
35 | return undefined;
|
36 | }
|
37 | class ConfigItem {
|
38 | constructor(descriptor) {
|
39 | this._descriptor = void 0;
|
40 | this[CONFIG_ITEM_BRAND] = true;
|
41 | this.value = void 0;
|
42 | this.options = void 0;
|
43 | this.dirname = void 0;
|
44 | this.name = void 0;
|
45 | this.file = void 0;
|
46 | this._descriptor = descriptor;
|
47 | Object.defineProperty(this, "_descriptor", {
|
48 | enumerable: false
|
49 | });
|
50 | Object.defineProperty(this, CONFIG_ITEM_BRAND, {
|
51 | enumerable: false
|
52 | });
|
53 | this.value = this._descriptor.value;
|
54 | this.options = this._descriptor.options;
|
55 | this.dirname = this._descriptor.dirname;
|
56 | this.name = this._descriptor.name;
|
57 | this.file = this._descriptor.file ? {
|
58 | request: this._descriptor.file.request,
|
59 | resolved: this._descriptor.file.resolved
|
60 | } : undefined;
|
61 | Object.freeze(this);
|
62 | }
|
63 | }
|
64 | Object.freeze(ConfigItem.prototype);
|
65 | 0 && 0;
|
66 |
|
67 |
|