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