@teambit/variants 0.0.0-0baf8ccb2596bb5d0eff8d7776f7eddc20593fab
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/esm.mjs +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1752604605264.js +7 -0
- package/dist/variants.aspect.d.ts +2 -0
- package/dist/variants.aspect.js +18 -0
- package/dist/variants.aspect.js.map +1 -0
- package/dist/variants.composition.d.ts +1 -0
- package/dist/variants.composition.js +29 -0
- package/dist/variants.composition.js.map +1 -0
- package/dist/variants.docs.mdx +8 -0
- package/dist/variants.main.runtime.d.ts +40 -0
- package/dist/variants.main.runtime.js +160 -0
- package/dist/variants.main.runtime.js.map +1 -0
- package/esm.mjs +7 -0
- package/package.json +63 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +42 -0
- package/variants.composition.tsx +7 -0
- package/variants.docs.mdx +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXT_NAME = "teambit.workspace/variants";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EXT_NAME","exports"],"sources":["constants.ts"],"sourcesContent":["export const EXT_NAME = 'teambit.workspace/variants';\n"],"mappings":";;;;;;AAAO,MAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,4BAA4B","ignoreList":[]}
|
package/dist/esm.mjs
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "VariantsAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _variants().VariantsAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function _variants() {
|
|
13
|
+
const data = require("./variants.aspect");
|
|
14
|
+
_variants = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_variants","data","require"],"sources":["index.ts"],"sourcesContent":["export type { VariantsMain, Patterns } from './variants.main.runtime';\nexport { VariantsAspect } from './variants.aspect';\n"],"mappings":";;;;;;;;;;;AACA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_variants@0baf8ccb2596bb5d0eff8d7776f7eddc20593fab/dist/variants.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_variants@0baf8ccb2596bb5d0eff8d7776f7eddc20593fab/dist/variants.docs.mdx';
|
|
3
|
+
|
|
4
|
+
export const compositions = [compositions_0];
|
|
5
|
+
export const overview = [overview_0];
|
|
6
|
+
|
|
7
|
+
export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VariantsAspect = void 0;
|
|
7
|
+
function _harmony() {
|
|
8
|
+
const data = require("@teambit/harmony");
|
|
9
|
+
_harmony = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
const VariantsAspect = exports.VariantsAspect = _harmony().Aspect.create({
|
|
15
|
+
id: 'teambit.workspace/variants'
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=variants.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","VariantsAspect","exports","Aspect","create","id"],"sources":["variants.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const VariantsAspect = Aspect.create({\n id: 'teambit.workspace/variants',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EAC1CC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Logo = void 0;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = _interopRequireDefault(require("react"));
|
|
9
|
+
_react = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
16
|
+
style: {
|
|
17
|
+
height: '100%',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'center'
|
|
20
|
+
}
|
|
21
|
+
}, /*#__PURE__*/_react().default.createElement("img", {
|
|
22
|
+
style: {
|
|
23
|
+
width: 70
|
|
24
|
+
},
|
|
25
|
+
src: "https://static.bit.dev/extensions-icons/variants.svg"
|
|
26
|
+
}));
|
|
27
|
+
exports.Logo = Logo;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=variants.composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","e","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"sources":["variants.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/variants.svg\" />\n </div>\n);\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAsD,CAAE,CACpF,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ConfigMain } from '@teambit/config';
|
|
2
|
+
import { ExtensionDataList } from '@teambit/legacy.extension-data';
|
|
3
|
+
import { PathLinuxRelative } from '@teambit/toolbox.path.path';
|
|
4
|
+
import { MatchedPatternWithConfig } from '@teambit/workspace.modules.match-pattern';
|
|
5
|
+
export type Patterns = {
|
|
6
|
+
[pattern: string]: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export type VariantsComponentConfig = {
|
|
9
|
+
propagate: boolean;
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
defaultScope?: string;
|
|
12
|
+
extensions: ExtensionDataList;
|
|
13
|
+
maxSpecificity: number;
|
|
14
|
+
sortedMatches: MatchedPatternWithConfig[];
|
|
15
|
+
};
|
|
16
|
+
export declare class VariantsMain {
|
|
17
|
+
private patterns;
|
|
18
|
+
private configAspect;
|
|
19
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
20
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
21
|
+
constructor(patterns: Patterns, configAspect: ConfigMain);
|
|
22
|
+
private validateConfig;
|
|
23
|
+
raw(): Patterns;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the config for specific component after merge all matching patterns of the component dir and id in the variants section
|
|
26
|
+
* @param rootDir
|
|
27
|
+
*/
|
|
28
|
+
byRootDirAndName(rootDir: PathLinuxRelative, componentName: string): VariantsComponentConfig | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Updates the specified extension object of the specified variant.
|
|
31
|
+
* @param {string} variant - The variant pattern.
|
|
32
|
+
* @param {string} extensionId - The extension ID.
|
|
33
|
+
* @param {Object} extensionConfig - The extension configuration.
|
|
34
|
+
* @param {boolean} opts.overrideExisting - When true, any existing entries are overriden.
|
|
35
|
+
*/
|
|
36
|
+
setExtension(variant: string, extensionId: string, extensionConfig: any, opts?: {
|
|
37
|
+
overrideExisting?: boolean;
|
|
38
|
+
}): void;
|
|
39
|
+
static provider([configAspect]: [ConfigMain], config: any): Promise<VariantsMain>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VariantsMain = void 0;
|
|
7
|
+
function _cli() {
|
|
8
|
+
const data = require("@teambit/cli");
|
|
9
|
+
_cli = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _config() {
|
|
15
|
+
const data = require("@teambit/config");
|
|
16
|
+
_config = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _legacy() {
|
|
22
|
+
const data = require("@teambit/legacy.extension-data");
|
|
23
|
+
_legacy = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _commentJson() {
|
|
29
|
+
const data = require("comment-json");
|
|
30
|
+
_commentJson = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _lodash() {
|
|
36
|
+
const data = require("lodash");
|
|
37
|
+
_lodash = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _workspaceModules() {
|
|
43
|
+
const data = require("@teambit/workspace.modules.match-pattern");
|
|
44
|
+
_workspaceModules = function () {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
function _legacyBitId() {
|
|
50
|
+
const data = require("@teambit/legacy-bit-id");
|
|
51
|
+
_legacyBitId = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
function _variants() {
|
|
57
|
+
const data = require("./variants.aspect");
|
|
58
|
+
_variants = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
64
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
65
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
66
|
+
const INTERNAL_FIELDS = ['propagate', 'exclude', 'defaultScope'];
|
|
67
|
+
class VariantsMain {
|
|
68
|
+
constructor(patterns, configAspect) {
|
|
69
|
+
this.patterns = patterns;
|
|
70
|
+
this.configAspect = configAspect;
|
|
71
|
+
this.validateConfig();
|
|
72
|
+
}
|
|
73
|
+
validateConfig() {
|
|
74
|
+
(0, _lodash().forEach)(this.patterns, (patternConfig, pattern) => {
|
|
75
|
+
if (patternConfig.defaultScope && !(0, _legacyBitId().isValidScopeName)(patternConfig.defaultScope)) {
|
|
76
|
+
throw new (_legacyBitId().InvalidScopeName)(patternConfig.defaultScope, undefined, pattern);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
raw() {
|
|
81
|
+
return this.patterns;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Gets the config for specific component after merge all matching patterns of the component dir and id in the variants section
|
|
86
|
+
* @param rootDir
|
|
87
|
+
*/
|
|
88
|
+
byRootDirAndName(rootDir, componentName) {
|
|
89
|
+
const matches = [];
|
|
90
|
+
(0, _lodash().forEach)(this.patterns, (patternConfig, pattern) => {
|
|
91
|
+
const match = (0, _workspaceModules().isMatchPattern)(rootDir, componentName, pattern);
|
|
92
|
+
|
|
93
|
+
// Ignore matches with exclude matches
|
|
94
|
+
if (match.match && !match.excluded) {
|
|
95
|
+
matches.push({
|
|
96
|
+
config: patternConfig,
|
|
97
|
+
specificity: match.maxSpecificity,
|
|
98
|
+
pattern: match.pattern
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const sortedMatches = (0, _workspaceModules().sortMatchesBySpecificity)(matches);
|
|
103
|
+
let defaultScope;
|
|
104
|
+
let propagate = true;
|
|
105
|
+
const extensionsToMerge = [];
|
|
106
|
+
sortedMatches.forEach(match => {
|
|
107
|
+
defaultScope = defaultScope || match.config.defaultScope;
|
|
108
|
+
if (propagate) {
|
|
109
|
+
extensionsToMerge.push(getExtensionFromPatternRawConfig(match.config));
|
|
110
|
+
}
|
|
111
|
+
if (match.config.propagate === false) {
|
|
112
|
+
propagate = false;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const mergedExtensions = _legacy().ExtensionDataList.mergeConfigs(extensionsToMerge);
|
|
116
|
+
const result = {
|
|
117
|
+
defaultScope,
|
|
118
|
+
extensions: mergedExtensions,
|
|
119
|
+
propagate,
|
|
120
|
+
maxSpecificity: sortedMatches.length ? sortedMatches[0].specificity : -1,
|
|
121
|
+
sortedMatches
|
|
122
|
+
};
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Updates the specified extension object of the specified variant.
|
|
128
|
+
* @param {string} variant - The variant pattern.
|
|
129
|
+
* @param {string} extensionId - The extension ID.
|
|
130
|
+
* @param {Object} extensionConfig - The extension configuration.
|
|
131
|
+
* @param {boolean} opts.overrideExisting - When true, any existing entries are overriden.
|
|
132
|
+
*/
|
|
133
|
+
setExtension(variant, extensionId, extensionConfig, opts) {
|
|
134
|
+
const newVariant = this.patterns[variant] ?? {};
|
|
135
|
+
(0, _commentJson().assign)(newVariant, {
|
|
136
|
+
[extensionId]: extensionConfig
|
|
137
|
+
});
|
|
138
|
+
(0, _commentJson().assign)(this.patterns, {
|
|
139
|
+
[variant]: newVariant
|
|
140
|
+
});
|
|
141
|
+
this.configAspect.setExtension(_variants().VariantsAspect.id, this.patterns, {
|
|
142
|
+
overrideExisting: opts?.overrideExisting === true,
|
|
143
|
+
ignoreVersion: true
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
static async provider([configAspect], config) {
|
|
147
|
+
return new VariantsMain(config, configAspect);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.VariantsMain = VariantsMain;
|
|
151
|
+
_defineProperty(VariantsMain, "runtime", _cli().MainRuntime);
|
|
152
|
+
_defineProperty(VariantsMain, "dependencies", [_config().ConfigAspect]);
|
|
153
|
+
function getExtensionFromPatternRawConfig(config) {
|
|
154
|
+
const rawExtensions = (0, _lodash().omit)(config, INTERNAL_FIELDS);
|
|
155
|
+
const extensions = _legacy().ExtensionDataList.fromConfigObject(rawExtensions);
|
|
156
|
+
return extensions;
|
|
157
|
+
}
|
|
158
|
+
_variants().VariantsAspect.addRuntime(VariantsMain);
|
|
159
|
+
|
|
160
|
+
//# sourceMappingURL=variants.main.runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_config","_legacy","_commentJson","_lodash","_workspaceModules","_legacyBitId","_variants","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","INTERNAL_FIELDS","VariantsMain","constructor","patterns","configAspect","validateConfig","forEach","patternConfig","pattern","defaultScope","isValidScopeName","InvalidScopeName","undefined","raw","byRootDirAndName","rootDir","componentName","matches","match","isMatchPattern","excluded","push","config","specificity","maxSpecificity","sortedMatches","sortMatchesBySpecificity","propagate","extensionsToMerge","getExtensionFromPatternRawConfig","mergedExtensions","ExtensionDataList","mergeConfigs","result","extensions","length","setExtension","variant","extensionId","extensionConfig","opts","newVariant","assign","VariantsAspect","id","overrideExisting","ignoreVersion","provider","exports","MainRuntime","ConfigAspect","rawExtensions","omit","fromConfigObject","addRuntime"],"sources":["variants.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { ConfigAspect } from '@teambit/config';\nimport type { ConfigMain } from '@teambit/config';\nimport { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport { PathLinuxRelative } from '@teambit/toolbox.path.path';\nimport { assign } from 'comment-json';\nimport { omit, forEach } from 'lodash';\nimport {\n MatchedPatternWithConfig,\n isMatchPattern,\n sortMatchesBySpecificity,\n} from '@teambit/workspace.modules.match-pattern';\nimport { InvalidScopeName, isValidScopeName } from '@teambit/legacy-bit-id';\nimport { VariantsAspect } from './variants.aspect';\n\nexport type Patterns = { [pattern: string]: Record<string, any> };\n\nexport type VariantsComponentConfig = {\n propagate: boolean;\n exclude?: string[];\n defaultScope?: string;\n extensions: ExtensionDataList;\n maxSpecificity: number;\n sortedMatches: MatchedPatternWithConfig[];\n};\n\nconst INTERNAL_FIELDS = ['propagate', 'exclude', 'defaultScope'];\n\nexport class VariantsMain {\n static runtime = MainRuntime;\n static dependencies = [ConfigAspect];\n\n constructor(\n private patterns: Patterns,\n private configAspect: ConfigMain\n ) {\n this.validateConfig();\n }\n\n private validateConfig() {\n forEach(this.patterns, (patternConfig: Record<string, any>, pattern: string) => {\n if (patternConfig.defaultScope && !isValidScopeName(patternConfig.defaultScope)) {\n throw new InvalidScopeName(patternConfig.defaultScope, undefined, pattern);\n }\n });\n }\n\n raw(): Patterns {\n return this.patterns;\n }\n\n /**\n * Gets the config for specific component after merge all matching patterns of the component dir and id in the variants section\n * @param rootDir\n */\n byRootDirAndName(rootDir: PathLinuxRelative, componentName: string): VariantsComponentConfig | undefined {\n const matches: MatchedPatternWithConfig[] = [];\n forEach(this.patterns, (patternConfig, pattern) => {\n const match = isMatchPattern(rootDir, componentName, pattern);\n\n // Ignore matches with exclude matches\n if (match.match && !match.excluded) {\n matches.push({\n config: patternConfig,\n specificity: match.maxSpecificity,\n pattern: match.pattern,\n });\n }\n });\n\n const sortedMatches: MatchedPatternWithConfig[] = sortMatchesBySpecificity(matches);\n\n let defaultScope;\n let propagate = true;\n const extensionsToMerge: ExtensionDataList[] = [];\n sortedMatches.forEach((match) => {\n defaultScope = defaultScope || match.config.defaultScope;\n if (propagate) {\n extensionsToMerge.push(getExtensionFromPatternRawConfig(match.config));\n }\n if (match.config.propagate === false) {\n propagate = false;\n }\n });\n\n const mergedExtensions = ExtensionDataList.mergeConfigs(extensionsToMerge);\n const result = {\n defaultScope,\n extensions: mergedExtensions,\n propagate,\n maxSpecificity: sortedMatches.length ? sortedMatches[0].specificity : -1,\n sortedMatches,\n };\n return result;\n }\n\n /**\n * Updates the specified extension object of the specified variant.\n * @param {string} variant - The variant pattern.\n * @param {string} extensionId - The extension ID.\n * @param {Object} extensionConfig - The extension configuration.\n * @param {boolean} opts.overrideExisting - When true, any existing entries are overriden.\n */\n setExtension(variant: string, extensionId: string, extensionConfig: any, opts?: { overrideExisting?: boolean }) {\n const newVariant = this.patterns[variant] ?? {};\n assign(newVariant, { [extensionId]: extensionConfig });\n assign(this.patterns, { [variant]: newVariant });\n this.configAspect.setExtension(VariantsAspect.id, this.patterns, {\n overrideExisting: opts?.overrideExisting === true,\n ignoreVersion: true,\n });\n }\n\n static async provider([configAspect]: [ConfigMain], config) {\n return new VariantsMain(config, configAspect);\n }\n}\n\nfunction getExtensionFromPatternRawConfig(config: Record<string, any>) {\n const rawExtensions = omit(config, INTERNAL_FIELDS);\n const extensions = ExtensionDataList.fromConfigObject(rawExtensions);\n return extensions;\n}\n\nVariantsAspect.addRuntime(VariantsMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OA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AC,CAAC;IAChD,IAAI,CAACrC,YAAY,CAACgC,YAAY,CAACO,0BAAc,CAACC,EAAE,EAAE,IAAI,CAACzC,QAAQ,EAAE;MAC/D0C,gBAAgB,EAAEL,IAAI,EAAEK,gBAAgB,KAAK,IAAI;MACjDC,aAAa,EAAE;IACjB,CAAC,CAAC;EACJ;EAEA,aAAaC,QAAQA,CAAC,CAAC3C,YAAY,CAAe,EAAEkB,MAAM,EAAE;IAC1D,OAAO,IAAIrB,YAAY,CAACqB,MAAM,EAAElB,YAAY,CAAC;EAC/C;AACF;AAAC4C,OAAA,CAAA/C,YAAA,GAAAA,YAAA;AAAApB,eAAA,CAxFYoB,YAAY,aACNgD,kBAAW;AAAApE,eAAA,CADjBoB,YAAY,kBAED,CAACiD,sBAAY,CAAC;AAwFtC,SAASrB,gCAAgCA,CAACP,MAA2B,EAAE;EACrE,MAAM6B,aAAa,GAAG,IAAAC,cAAI,EAAC9B,MAAM,EAAEtB,eAAe,CAAC;EACnD,MAAMkC,UAAU,GAAGH,2BAAiB,CAACsB,gBAAgB,CAACF,aAAa,CAAC;EACpE,OAAOjB,UAAU;AACnB;AAEAS,0BAAc,CAACW,UAAU,CAACrD,YAAY,CAAC","ignoreList":[]}
|
package/esm.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/variants",
|
|
3
|
+
"version": "0.0.0-0baf8ccb2596bb5d0eff8d7776f7eddc20593fab",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/workspace/variants",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.workspace",
|
|
8
|
+
"name": "variants",
|
|
9
|
+
"version": "0baf8ccb2596bb5d0eff8d7776f7eddc20593fab"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"comment-json": "4.2.5",
|
|
13
|
+
"lodash": "4.17.21",
|
|
14
|
+
"@teambit/harmony": "0.4.7",
|
|
15
|
+
"@teambit/legacy-bit-id": "1.1.3",
|
|
16
|
+
"@teambit/cli": "0.0.0-66f0f3d1fdc890d37a0d59a582d6928715f69720",
|
|
17
|
+
"@teambit/config": "0.0.0-ed7021f644204905557b73ca0bd4be32f04694d1",
|
|
18
|
+
"@teambit/legacy.extension-data": "0.0.57",
|
|
19
|
+
"@teambit/toolbox.path.path": "0.0.8",
|
|
20
|
+
"@teambit/workspace.modules.match-pattern": "0.0.509"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/lodash": "4.14.165",
|
|
24
|
+
"@types/mocha": "9.1.0",
|
|
25
|
+
"@teambit/workspace.content.variants": "1.95.9",
|
|
26
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.69"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
30
|
+
"@types/react": "^17.0.73"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"optionalDependencies": {},
|
|
34
|
+
"peerDependenciesMeta": {},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"node": {
|
|
38
|
+
"require": "./dist/index.js",
|
|
39
|
+
"import": "./dist/esm.mjs"
|
|
40
|
+
},
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./dist/*": "./dist/*",
|
|
44
|
+
"./artifacts/*": "./artifacts/*",
|
|
45
|
+
"./*": "./*.ts"
|
|
46
|
+
},
|
|
47
|
+
"private": false,
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.0.0"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/teambit/bit"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"bit",
|
|
57
|
+
"bit-aspect",
|
|
58
|
+
"bit-core-aspect",
|
|
59
|
+
"components",
|
|
60
|
+
"collaboration",
|
|
61
|
+
"web"
|
|
62
|
+
]
|
|
63
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|