@teambit/variants 0.0.471 → 0.0.475

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.
@@ -19,7 +19,14 @@ export declare class VariantsMain {
19
19
  constructor(patterns: Patterns);
20
20
  private validateConfig;
21
21
  raw(): Patterns;
22
+ /**
23
+ * Get all the patterns defined in the variants section of the workspace as the legacy ConsumerOverrides format
24
+ */
22
25
  legacy(): ConsumerOverrides;
26
+ /**
27
+ * Gets the config for specific component after merge all matching patterns of the component dir and id in the variants section
28
+ * @param rootDir
29
+ */
23
30
  byRootDirAndName(rootDir: PathLinuxRelative, componentName: string): VariantsComponentConfig | undefined;
24
31
  static provider(_deps: any, config: any): Promise<VariantsMain>;
25
32
  }
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@teambit/variants",
3
- "version": "0.0.471",
3
+ "version": "0.0.475",
4
4
  "homepage": "https://bit.dev/teambit/workspace/variants",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.workspace",
8
8
  "name": "variants",
9
- "version": "0.0.471"
9
+ "version": "0.0.475"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
13
13
  "lodash": "4.17.21",
14
14
  "@babel/runtime": "7.12.18",
15
15
  "core-js": "^3.0.0",
16
- "@teambit/cli": "0.0.384",
17
- "@teambit/legacy-bit-id": "0.0.373",
18
- "@teambit/workspace.modules.match-pattern": "0.0.463"
16
+ "@teambit/cli": "0.0.388",
17
+ "@teambit/legacy-bit-id": "0.0.377",
18
+ "@teambit/workspace.modules.match-pattern": "0.0.467"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/lodash": "4.14.165",
@@ -25,10 +25,10 @@
25
25
  "@types/react-dom": "^17.0.5",
26
26
  "@types/react": "^17.0.8",
27
27
  "@types/node": "12.20.4",
28
- "@teambit/workspace.aspect-docs.variants": "0.0.103"
28
+ "@teambit/workspace.aspect-docs.variants": "0.0.107"
29
29
  },
30
30
  "peerDependencies": {
31
- "@teambit/legacy": "1.0.170",
31
+ "@teambit/legacy": "1.0.174",
32
32
  "react-dom": "^16.8.0 || ^17.0.0",
33
33
  "react": "^16.8.0 || ^17.0.0"
34
34
  },
@@ -56,12 +56,20 @@
56
56
  "react": "-"
57
57
  },
58
58
  "peerDependencies": {
59
- "@teambit/legacy": "1.0.170",
59
+ "@teambit/legacy": "1.0.174",
60
60
  "react-dom": "^16.8.0 || ^17.0.0",
61
61
  "react": "^16.8.0 || ^17.0.0"
62
62
  }
63
63
  }
64
64
  },
65
+ "files": [
66
+ "dist",
67
+ "!dist/tsconfig.tsbuildinfo",
68
+ "README.md",
69
+ "README.mdx",
70
+ "*.js",
71
+ "*.json"
72
+ ],
65
73
  "private": false,
66
74
  "engines": {
67
75
  "node": ">=12.22.0"
package/tsconfig.json CHANGED
@@ -15,9 +15,9 @@
15
15
  "skipLibCheck": true,
16
16
  "moduleResolution": "node",
17
17
  "esModuleInterop": true,
18
- "outDir": "dist",
19
18
  "composite": true,
20
19
  "emitDeclarationOnly": true,
20
+ "outDir": "dist",
21
21
  "experimentalDecorators": true,
22
22
  "emitDecoratorMetadata": true,
23
23
  "allowSyntheticDefaultImports": true,
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },
package/constants.ts DELETED
@@ -1 +0,0 @@
1
- export const EXT_NAME = 'teambit.workspace/variants';
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export type { VariantsMain } from './variants.main.runtime';
2
- export { VariantsAspect } from './variants.aspect';
package/types/asset.d.ts DELETED
@@ -1,29 +0,0 @@
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<SVGProps<SVGSVGElement> & { title?: string }>;
9
- const src: string;
10
- export default src;
11
- }
12
-
13
- // @TODO Gilad
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
- }
package/types/style.d.ts DELETED
@@ -1,42 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const VariantsAspect = Aspect.create({
4
- id: 'teambit.workspace/variants',
5
- });
package/variants.docs.mdx DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- description: teambit.workspace/variants enables cascading configurations by selection of component groupings or sets in the workspace and applying configurations to these cascading groups
3
- labels: ['variants', 'workspace', 'bit', 'extension', 'aspect']
4
- ---
5
-
6
- import { Variants } from '@teambit/workspace.aspect-docs.variants';
7
-
8
- <Variants />
@@ -1,111 +0,0 @@
1
- import { MainRuntime } from '@teambit/cli';
2
- import ConsumerOverrides from '@teambit/legacy/dist/consumer/config/consumer-overrides';
3
- import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
4
- import { PathLinuxRelative } from '@teambit/legacy/dist/utils/path';
5
- import { omit, forEach } from 'lodash';
6
- import {
7
- MatchedPatternWithConfig,
8
- isMatchPattern,
9
- sortMatchesBySpecificity,
10
- } from '@teambit/workspace.modules.match-pattern';
11
- import { InvalidScopeName, isValidScopeName } from '@teambit/legacy-bit-id';
12
- import { VariantsAspect } from './variants.aspect';
13
-
14
- export type Patterns = { [pattern: string]: Record<string, any> };
15
-
16
- export type VariantsComponentConfig = {
17
- propagate: boolean;
18
- exclude?: string[];
19
- defaultScope?: string;
20
- extensions: ExtensionDataList;
21
- maxSpecificity: number;
22
- };
23
-
24
- const INTERNAL_FIELDS = ['propagate', 'exclude', 'defaultScope'];
25
-
26
- export class VariantsMain {
27
- static runtime = MainRuntime;
28
- static dependencies = [];
29
-
30
- _loadedLegacy: ConsumerOverrides;
31
-
32
- constructor(private patterns: Patterns) {
33
- this._loadedLegacy = ConsumerOverrides.load(this.patterns);
34
- this.validateConfig();
35
- }
36
-
37
- private validateConfig() {
38
- forEach(this.patterns, (patternConfig: Record<string, any>, pattern: string) => {
39
- if (patternConfig.defaultScope && !isValidScopeName(patternConfig.defaultScope)) {
40
- throw new InvalidScopeName(patternConfig.defaultScope, undefined, pattern);
41
- }
42
- });
43
- }
44
-
45
- raw(): Patterns {
46
- return this.patterns;
47
- }
48
-
49
- /**
50
- * Get all the patterns defined in the variants section of the workspace as the legacy ConsumerOverrides format
51
- */
52
- legacy(): ConsumerOverrides {
53
- // return ConsumerOverrides.load(this.patterns);
54
- return this._loadedLegacy;
55
- }
56
-
57
- /**
58
- * Gets the config for specific component after merge all matching patterns of the component dir and id in the variants section
59
- * @param rootDir
60
- */
61
- byRootDirAndName(rootDir: PathLinuxRelative, componentName: string): VariantsComponentConfig | undefined {
62
- const matches: MatchedPatternWithConfig[] = [];
63
- forEach(this.patterns, (patternConfig, pattern) => {
64
- const match = isMatchPattern(rootDir, componentName, pattern);
65
-
66
- // Ignore matches with exclude matches
67
- if (match.match && !match.excluded) {
68
- matches.push({
69
- config: patternConfig,
70
- specificity: match.maxSpecificity,
71
- });
72
- }
73
- });
74
-
75
- const sortedMatches: MatchedPatternWithConfig[] = sortMatchesBySpecificity(matches);
76
-
77
- let defaultScope;
78
- let propagate = true;
79
- const extensionsToMerge: ExtensionDataList[] = [];
80
- sortedMatches.forEach((match) => {
81
- defaultScope = defaultScope || match.config.defaultScope;
82
- if (propagate) {
83
- extensionsToMerge.push(getExtensionFromPatternRawConfig(match.config));
84
- }
85
- if (match.config.propagate === false) {
86
- propagate = false;
87
- }
88
- });
89
-
90
- const mergedExtensions = ExtensionDataList.mergeConfigs(extensionsToMerge);
91
- const result = {
92
- defaultScope,
93
- extensions: mergedExtensions,
94
- propagate,
95
- maxSpecificity: sortedMatches.length ? sortedMatches[0].specificity : -1,
96
- };
97
- return result;
98
- }
99
-
100
- static async provider(_deps, config) {
101
- return new VariantsMain(config);
102
- }
103
- }
104
-
105
- function getExtensionFromPatternRawConfig(config: Record<string, any>) {
106
- const rawExtensions = omit(config, INTERNAL_FIELDS);
107
- const extensions = ExtensionDataList.fromConfigObject(rawExtensions);
108
- return extensions;
109
- }
110
-
111
- VariantsAspect.addRuntime(VariantsMain);
@@ -1,13 +0,0 @@
1
- // import { Variants, Patterns } from './variants.extension';
2
- // import { Config } from '../config';
3
-
4
- // export type VariantsDeps = [Config];
5
-
6
- // export async function provideVariants([hostConfig]: VariantsDeps, config: Patterns) {
7
- // const variants = new Variants(config, hostConfig);
8
- // // TODO: fix when config become maybe
9
- // if (hostConfig.type) {
10
- // hostConfig.registerGetVariantsConfig(variants.legacy.bind(variants));
11
- // }
12
- // return variants;
13
- // }