@teambit/component 0.0.551 → 0.0.556

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.
Files changed (101) hide show
  1. package/dist/aspect-list.d.ts +18 -0
  2. package/dist/component-factory.d.ts +49 -0
  3. package/dist/component-fs.d.ts +20 -1
  4. package/dist/component-map/component-map.d.ts +32 -0
  5. package/dist/component-meta.d.ts +11 -1
  6. package/dist/component.d.ts +96 -1
  7. package/dist/component.main.runtime.d.ts +30 -1
  8. package/dist/component.ui.runtime.d.ts +21 -1
  9. package/dist/config.d.ts +18 -1
  10. package/dist/dependencies/dependencies.d.ts +18 -0
  11. package/dist/exceptions/host-not-found.d.ts +8 -1
  12. package/dist/hash.d.ts +3 -0
  13. package/dist/show/show-fragment.d.ts +23 -0
  14. package/dist/snap/author.d.ts +12 -0
  15. package/dist/snap/snap.d.ts +39 -1
  16. package/dist/state.d.ts +44 -1
  17. package/dist/tag/tag.d.ts +21 -1
  18. package/dist/tag-map.d.ts +19 -0
  19. package/dist/ui/component-error/component-error.d.ts +15 -1
  20. package/dist/ui/component-model/component-model.d.ts +102 -1
  21. package/dist/ui/component.d.ts +3 -0
  22. package/dist/ui/context/component-provider.d.ts +6 -0
  23. package/dist/ui/menu/menu.d.ts +12 -0
  24. package/dist/ui/use-component-query.d.ts +1 -0
  25. package/package.json +40 -34
  26. package/aspect-entry.ts +0 -67
  27. package/aspect-list.ts +0 -100
  28. package/aspect.section.tsx +0 -16
  29. package/component-factory.ts +0 -106
  30. package/component-fs.ts +0 -60
  31. package/component-map/component-map.ts +0 -106
  32. package/component-map/index.ts +0 -1
  33. package/component-meta.ts +0 -29
  34. package/component.aspect.ts +0 -9
  35. package/component.docs.mdx +0 -8
  36. package/component.graphql.ts +0 -202
  37. package/component.main.runtime.ts +0 -162
  38. package/component.route.ts +0 -26
  39. package/component.ts +0 -278
  40. package/component.ui.runtime.tsx +0 -216
  41. package/config.ts +0 -34
  42. package/dependencies/dependencies.ts +0 -74
  43. package/dependencies/index.ts +0 -1
  44. package/exceptions/could-not-find-latest.ts +0 -8
  45. package/exceptions/host-not-found.ts +0 -14
  46. package/exceptions/index.ts +0 -4
  47. package/exceptions/nothing-to-snap.ts +0 -1
  48. package/hash.ts +0 -4
  49. package/head.ts +0 -0
  50. package/history-graph.ts +0 -1
  51. package/host/component-host-model.ts +0 -9
  52. package/host/index.ts +0 -2
  53. package/host/use-component-host.ts +0 -39
  54. package/index.ts +0 -32
  55. package/on-load.ts +0 -0
  56. package/package-tar/teambit-component-0.0.551.tgz +0 -0
  57. package/section/index.ts +0 -1
  58. package/section/section.tsx +0 -8
  59. package/show/extensions.fragment.ts +0 -23
  60. package/show/files.fragment.ts +0 -24
  61. package/show/id.fragment.ts +0 -20
  62. package/show/index.ts +0 -8
  63. package/show/main-file.fragment.ts +0 -13
  64. package/show/name.fragment.ts +0 -13
  65. package/show/scope.fragment.ts +0 -15
  66. package/show/show-fragment.ts +0 -44
  67. package/show/show.cmd.ts +0 -85
  68. package/snap/author.ts +0 -19
  69. package/snap/index.ts +0 -2
  70. package/snap/snap.ts +0 -63
  71. package/state.ts +0 -73
  72. package/store.ts +0 -3
  73. package/tag/index.ts +0 -1
  74. package/tag/tag.ts +0 -37
  75. package/tag-map.ts +0 -87
  76. package/tsconfig.json +0 -35
  77. package/types/asset.d.ts +0 -29
  78. package/types/style.d.ts +0 -42
  79. package/ui/aspect-page/aspect-page.module.scss +0 -20
  80. package/ui/aspect-page/aspect-page.tsx +0 -64
  81. package/ui/aspect-page/index.ts +0 -1
  82. package/ui/component-error/component-error.tsx +0 -22
  83. package/ui/component-error/index.ts +0 -1
  84. package/ui/component-model/component-model.ts +0 -169
  85. package/ui/component-model/index.ts +0 -1
  86. package/ui/component.module.scss +0 -7
  87. package/ui/component.tsx +0 -48
  88. package/ui/context/component-context.ts +0 -5
  89. package/ui/context/component-provider.tsx +0 -20
  90. package/ui/context/index.ts +0 -2
  91. package/ui/index.ts +0 -3
  92. package/ui/menu/index.ts +0 -2
  93. package/ui/menu/menu-nav.tsx +0 -37
  94. package/ui/menu/menu.module.scss +0 -62
  95. package/ui/menu/menu.tsx +0 -94
  96. package/ui/menu/nav-plugin.tsx +0 -9
  97. package/ui/top-bar-nav/index.ts +0 -1
  98. package/ui/top-bar-nav/top-bar-nav.module.scss +0 -52
  99. package/ui/top-bar-nav/top-bar-nav.tsx +0 -26
  100. package/ui/use-component-query.ts +0 -195
  101. package/ui/use-component.tsx +0 -34
package/dist/tag/tag.d.ts CHANGED
@@ -3,10 +3,30 @@ export declare type TagProps = {
3
3
  hash: string;
4
4
  version: string;
5
5
  };
6
+ /**
7
+ * `Tag` provides a sematic reference to a specific state `Snap` in the working tree.
8
+ */
6
9
  export declare class Tag {
10
+ /**
11
+ * tag hash, can be used to load it by component-factory.getSnap
12
+ */
7
13
  readonly hash: string;
14
+ /**
15
+ * sematic version of the snap.
16
+ */
8
17
  readonly version: SemVer;
9
- constructor(hash: string, version: SemVer);
18
+ constructor(
19
+ /**
20
+ * tag hash, can be used to load it by component-factory.getSnap
21
+ */
22
+ hash: string,
23
+ /**
24
+ * sematic version of the snap.
25
+ */
26
+ version: SemVer);
27
+ /**
28
+ * create a plain tag object.
29
+ */
10
30
  toObject(): TagProps;
11
31
  static fromObject(tag: TagProps): Tag;
12
32
  }
package/dist/tag-map.d.ts CHANGED
@@ -2,13 +2,32 @@ import { SemVer } from 'semver';
2
2
  import { Hash } from './hash';
3
3
  import { Tag } from './tag';
4
4
  export declare class TagMap extends Map<SemVer, Tag> {
5
+ /**
6
+ * get snap by hash.
7
+ */
5
8
  byHash(hash: Hash): Tag | undefined;
9
+ /**
10
+ * e.g.
11
+ * {
12
+ * alpha: '1.0.0-alpha.5',
13
+ * dev: '2.2.4-dev.37
14
+ * }
15
+ */
6
16
  getPreReleaseLatestTags(): {
7
17
  [preRelease: string]: string;
8
18
  };
19
+ /**
20
+ * Get a map that map snap hash to tag
21
+ */
9
22
  getHashMap(): Map<Hash, Tag>;
23
+ /**
24
+ * get the latest semver from the tag map.
25
+ */
10
26
  getLatest(): string;
11
27
  isEmpty(): boolean;
28
+ /**
29
+ * get an array of all tags.
30
+ */
12
31
  toArray(): Tag[];
13
32
  byVersion(version: string): Tag | undefined;
14
33
  static fromArray(tags: Tag[]): TagMap;
@@ -1,6 +1,20 @@
1
1
  export declare class ComponentError {
2
+ /**
3
+ * http status code of error
4
+ */
2
5
  readonly code: number;
6
+ /**
7
+ * error message of the error
8
+ */
3
9
  readonly message?: string | undefined;
4
- constructor(code: number, message?: string | undefined);
10
+ constructor(
11
+ /**
12
+ * http status code of error
13
+ */
14
+ code: number,
15
+ /**
16
+ * error message of the error
17
+ */
18
+ message?: string | undefined);
5
19
  renderError(): JSX.Element;
6
20
  }
@@ -26,23 +26,124 @@ export declare type ComponentServer = {
26
26
  url: string;
27
27
  };
28
28
  export declare class ComponentModel {
29
+ /**
30
+ * id of the component
31
+ */
29
32
  readonly id: ComponentID;
33
+ /**
34
+ * display name of the component.
35
+ */
30
36
  readonly displayName: string;
37
+ /**
38
+ * package name of the component.
39
+ */
31
40
  readonly packageName: string;
41
+ /**
42
+ * the component server.
43
+ */
32
44
  readonly server: ComponentServer | undefined;
45
+ /**
46
+ * array of compositions
47
+ */
33
48
  readonly compositions: Composition[];
49
+ /**
50
+ * tags of the component.
51
+ */
34
52
  readonly tags: TagMap;
53
+ /**
54
+ * component build status
55
+ */
35
56
  readonly buildStatus?: string | undefined;
57
+ /**
58
+ * issues of component.
59
+ */
36
60
  readonly issuesCount?: number | undefined;
61
+ /**
62
+ * elements url
63
+ */
37
64
  readonly elementsUrl?: string | undefined;
65
+ /**
66
+ * status of component.
67
+ */
38
68
  readonly status?: any;
69
+ /**
70
+ * deprecation info of the component.
71
+ */
39
72
  readonly deprecation?: DeprecationInfo | undefined;
73
+ /**
74
+ * env descriptor.
75
+ */
40
76
  readonly environment?: Descriptor | undefined;
77
+ /**
78
+ * description of the component.
79
+ */
41
80
  readonly description: string;
42
81
  readonly labels: string[];
82
+ /**
83
+ * host of the component
84
+ */
43
85
  readonly host?: string | undefined;
44
- constructor(id: ComponentID, displayName: string, packageName: string, server: ComponentServer | undefined, compositions: Composition[], tags: TagMap, buildStatus?: string | undefined, issuesCount?: number | undefined, elementsUrl?: string | undefined, status?: any, deprecation?: DeprecationInfo | undefined, environment?: Descriptor | undefined, description?: string, labels?: string[], host?: string | undefined);
86
+ constructor(
87
+ /**
88
+ * id of the component
89
+ */
90
+ id: ComponentID,
91
+ /**
92
+ * display name of the component.
93
+ */
94
+ displayName: string,
95
+ /**
96
+ * package name of the component.
97
+ */
98
+ packageName: string,
99
+ /**
100
+ * the component server.
101
+ */
102
+ server: ComponentServer | undefined,
103
+ /**
104
+ * array of compositions
105
+ */
106
+ compositions: Composition[],
107
+ /**
108
+ * tags of the component.
109
+ */
110
+ tags: TagMap,
111
+ /**
112
+ * component build status
113
+ */
114
+ buildStatus?: string | undefined,
115
+ /**
116
+ * issues of component.
117
+ */
118
+ issuesCount?: number | undefined,
119
+ /**
120
+ * elements url
121
+ */
122
+ elementsUrl?: string | undefined,
123
+ /**
124
+ * status of component.
125
+ */
126
+ status?: any,
127
+ /**
128
+ * deprecation info of the component.
129
+ */
130
+ deprecation?: DeprecationInfo | undefined,
131
+ /**
132
+ * env descriptor.
133
+ */
134
+ environment?: Descriptor | undefined,
135
+ /**
136
+ * description of the component.
137
+ */
138
+ description?: string, labels?: string[],
139
+ /**
140
+ * host of the component
141
+ */
142
+ host?: string | undefined);
45
143
  get version(): string;
144
+ /**
145
+ * create an instance of a component from a plain object.
146
+ */
46
147
  static from({ id, server, displayName, compositions, packageName, elementsUrl, tags, deprecation, buildStatus, env, status, issuesCount, description, labels, host, }: ComponentModelProps): ComponentModel;
47
148
  static fromArray(componentsProps: ComponentModelProps[]): ComponentModel[];
48
149
  static empty(): ComponentModel;
@@ -13,4 +13,7 @@ export declare type ComponentProps = {
13
13
  host: string;
14
14
  onComponentChange?: (activeComponent?: ComponentModel) => void;
15
15
  };
16
+ /**
17
+ * main UI component of the Component extension.
18
+ */
16
19
  export declare function Component({ routeSlot, containerSlot, host, onComponentChange }: ComponentProps): JSX.Element;
@@ -1,7 +1,13 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { ComponentModel } from '../component-model';
3
3
  export declare type ComponentProviderProps = {
4
+ /**
5
+ * component model.
6
+ */
4
7
  component: ComponentModel;
8
+ /**
9
+ * component children.
10
+ */
5
11
  children: ReactNode;
6
12
  };
7
13
  export declare function ComponentProvider({ component, children }: ComponentProviderProps): JSX.Element;
@@ -2,9 +2,21 @@ import { MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';
2
2
  import { OrderedNavigationSlot } from './nav-plugin';
3
3
  export declare type MenuProps = {
4
4
  className?: string;
5
+ /**
6
+ * slot for top bar menu nav items
7
+ */
5
8
  navigationSlot: OrderedNavigationSlot;
9
+ /**
10
+ * right side menu item slot
11
+ */
6
12
  widgetSlot: OrderedNavigationSlot;
7
13
  host: string;
14
+ /**
15
+ * main dropdown item slot
16
+ */
8
17
  menuItemSlot: MenuItemSlot;
9
18
  };
19
+ /**
20
+ * top bar menu.
21
+ */
10
22
  export declare function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot }: MenuProps): JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { ComponentModel } from './component-model';
2
2
  import { ComponentError } from './component-error';
3
+ /** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
3
4
  export declare function useComponentQuery(componentId: string, host: string): {
4
5
  component: ComponentModel | undefined;
5
6
  error: ComponentError | undefined;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "0.0.551",
3
+ "version": "0.0.556",
4
4
  "homepage": "https://bit.dev/teambit/component/component",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component",
9
- "version": "0.0.551"
9
+ "version": "0.0.556"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -26,38 +26,38 @@
26
26
  "@teambit/base-ui.routing.nav-link": "1.0.0",
27
27
  "@teambit/documenter.ui.heading": "4.1.1",
28
28
  "@teambit/documenter.ui.separator": "4.1.1",
29
- "@teambit/component-id": "0.0.372",
30
- "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.461",
31
- "@teambit/aspect-loader": "0.0.551",
32
- "@teambit/legacy-bit-id": "0.0.371",
33
- "@teambit/toolbox.string.capitalize": "0.0.456",
34
- "@teambit/cli": "0.0.382",
35
- "@teambit/config": "0.0.393",
36
- "@teambit/express": "0.0.471",
37
- "@teambit/graphql": "0.0.551",
38
- "@teambit/bit-error": "0.0.368",
39
- "@teambit/command-bar": "0.0.551",
40
- "@teambit/preview": "0.0.551",
41
- "@teambit/pubsub": "0.0.551",
42
- "@teambit/ui-foundation.ui.is-browser": "0.0.459",
43
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.459",
44
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.461",
45
- "@teambit/ui": "0.0.551",
46
- "@teambit/component-issues": "0.0.17",
47
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.460",
48
- "@teambit/cli-table": "0.0.5",
49
- "@teambit/ui-foundation.ui.react-router.use-query": "0.0.459",
29
+ "@teambit/component-id": "0.0.377",
30
+ "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.466",
31
+ "@teambit/aspect-loader": "0.0.556",
32
+ "@teambit/legacy-bit-id": "0.0.376",
33
+ "@teambit/toolbox.string.capitalize": "0.0.461",
34
+ "@teambit/cli": "0.0.387",
35
+ "@teambit/config": "0.0.398",
36
+ "@teambit/express": "0.0.476",
37
+ "@teambit/graphql": "0.0.556",
38
+ "@teambit/bit-error": "0.0.373",
39
+ "@teambit/command-bar": "0.0.556",
40
+ "@teambit/preview": "0.0.556",
41
+ "@teambit/pubsub": "0.0.556",
42
+ "@teambit/ui-foundation.ui.is-browser": "0.0.464",
43
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.464",
44
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.466",
45
+ "@teambit/ui": "0.0.556",
46
+ "@teambit/component-issues": "0.0.22",
47
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.465",
48
+ "@teambit/cli-table": "0.0.10",
49
+ "@teambit/ui-foundation.ui.react-router.use-query": "0.0.464",
50
50
  "@teambit/design.ui.empty-box": "0.0.352",
51
- "@teambit/harmony.ui.aspect-box": "0.0.459",
51
+ "@teambit/harmony.ui.aspect-box": "0.0.464",
52
52
  "@teambit/design.ui.pages.not-found": "0.0.352",
53
53
  "@teambit/design.ui.pages.server-error": "0.0.352",
54
- "@teambit/compositions": "0.0.551",
55
- "@teambit/deprecation": "0.0.551",
56
- "@teambit/envs": "0.0.551",
57
- "@teambit/component.ui.version-dropdown": "0.0.463",
58
- "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.80",
59
- "@teambit/ui-foundation.ui.use-box.menu": "0.0.80",
60
- "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.459"
54
+ "@teambit/compositions": "0.0.556",
55
+ "@teambit/deprecation": "0.0.556",
56
+ "@teambit/envs": "0.0.556",
57
+ "@teambit/component.ui.version-dropdown": "0.0.468",
58
+ "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.85",
59
+ "@teambit/ui-foundation.ui.use-box.menu": "0.0.85",
60
+ "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.464"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/lodash": "4.14.165",
@@ -72,11 +72,11 @@
72
72
  "@types/jest": "^26.0.0",
73
73
  "@types/react-dom": "^17.0.5",
74
74
  "@types/node": "12.20.4",
75
- "@teambit/component.aspect-docs.component": "0.0.101"
75
+ "@teambit/component.aspect-docs.component": "0.0.106"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@apollo/client": "^3.0.0",
79
- "@teambit/legacy": "1.0.169",
79
+ "@teambit/legacy": "1.0.173",
80
80
  "react-dom": "^16.8.0 || ^17.0.0",
81
81
  "react": "^16.8.0 || ^17.0.0"
82
82
  },
@@ -104,12 +104,18 @@
104
104
  "react": "-"
105
105
  },
106
106
  "peerDependencies": {
107
- "@teambit/legacy": "1.0.169",
107
+ "@teambit/legacy": "1.0.173",
108
108
  "react-dom": "^16.8.0 || ^17.0.0",
109
109
  "react": "^16.8.0 || ^17.0.0"
110
110
  }
111
111
  }
112
112
  },
113
+ "files": [
114
+ "dist",
115
+ "!dist/tsconfig.tsbuildinfo",
116
+ "README.md",
117
+ "README.mdx"
118
+ ],
113
119
  "private": false,
114
120
  "engines": {
115
121
  "node": ">=12.22.0"
package/aspect-entry.ts DELETED
@@ -1,67 +0,0 @@
1
- import { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
2
- import { ComponentID } from '@teambit/component-id';
3
-
4
- export type Serializable = {
5
- toString(): string;
6
- };
7
-
8
- export type SerializableMap = {
9
- [key: string]: Serializable;
10
- };
11
-
12
- export type AspectData = {
13
- [key: string]: any;
14
- };
15
-
16
- export class AspectEntry {
17
- constructor(public id: ComponentID, private legacyEntry: ExtensionDataEntry) {}
18
-
19
- get legacy() {
20
- return this.legacyEntry;
21
- }
22
-
23
- get isLegacy(): boolean {
24
- if (this.config?.__legacy) return true;
25
- return false;
26
- }
27
-
28
- get config() {
29
- return this.legacy.config;
30
- }
31
-
32
- set config(config) {
33
- this.legacy.config = config;
34
- }
35
-
36
- get data(): { [key: string]: any } {
37
- return this.legacy.data;
38
- }
39
-
40
- get isRemoved(): boolean {
41
- return this.legacy.isRemoved;
42
- }
43
-
44
- // eslint-disable-next-line @typescript-eslint/adjacent-overload-signatures
45
- set data(val: { [key: string]: any }) {
46
- this.legacy.data = val;
47
- }
48
-
49
- transform(newData: SerializableMap): AspectEntry {
50
- const newEntry = this.clone();
51
- newEntry.data = newData;
52
- return new AspectEntry(this.id, newEntry.legacy);
53
- }
54
-
55
- clone(): AspectEntry {
56
- return new AspectEntry(this.id, this.legacyEntry.clone());
57
- }
58
-
59
- serialize() {
60
- return {
61
- id: this.id.toString(),
62
- config: this.config,
63
- data: this.data,
64
- icon: 'https://static.bit.dev/extensions-icons/default.svg', // TODO @gilad - once you connect the icon here please use this url as the default icon
65
- };
66
- }
67
- }
package/aspect-list.ts DELETED
@@ -1,100 +0,0 @@
1
- import { isEmpty } from 'lodash';
2
- import { ExtensionDataList, ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
3
- import { ComponentID } from '@teambit/component-id';
4
- import { AspectEntry, SerializableMap } from './aspect-entry';
5
-
6
- /**
7
- * list of aspects, each may have data and artifacts saved per component.
8
- */
9
- export class AspectList {
10
- constructor(readonly entries: AspectEntry[]) {}
11
-
12
- addEntry(aspectId: ComponentID, data: SerializableMap = {}) {
13
- const extensionDataEntry = new ExtensionDataEntry(undefined, aspectId._legacy, undefined, {}, data);
14
- const entry = new AspectEntry(aspectId, extensionDataEntry);
15
- this.entries.push(entry);
16
- return entry;
17
- }
18
-
19
- /**
20
- * get all ids as strings from the aspect list.
21
- */
22
- get ids(): string[] {
23
- const list = this.entries.map((entry) => entry.id.toString());
24
- return list;
25
- }
26
-
27
- /**
28
- * get an aspect from the list using a serialized ID.
29
- */
30
- get(id: string): AspectEntry | undefined {
31
- return this.entries.find((entry) => {
32
- return entry.legacy.stringId === id;
33
- });
34
- }
35
-
36
- /**
37
- * find aspect by component ID.
38
- */
39
- find(id: ComponentID, ignoreVersion = false): AspectEntry | undefined {
40
- return this.entries.find((aspectEntry) => {
41
- return id.isEqual(aspectEntry.id, { ignoreVersion });
42
- });
43
- }
44
-
45
- /**
46
- * transform an aspect list into a new one.
47
- */
48
- map(predicate: (entry: AspectEntry) => AspectEntry) {
49
- const entries = this.entries.map(predicate);
50
- return new AspectList(entries);
51
- }
52
-
53
- /**
54
- * transform an aspect list into a new one.
55
- */
56
- async pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>) {
57
- const entriesP = this.entries.map(predicate);
58
- const entries = await Promise.all(entriesP);
59
- return new AspectList(entries);
60
- }
61
-
62
- toConfigObject() {
63
- const res = {};
64
- this.entries.forEach((entry) => {
65
- if (entry.config && !isEmpty(entry.config)) {
66
- res[entry.id.toString()] = entry.config;
67
- }
68
- });
69
- return res;
70
- }
71
-
72
- serialize() {
73
- const serializedEntries = this.entries.map((entry) => entry.serialize());
74
- return serializedEntries;
75
- }
76
-
77
- toLegacy(): ExtensionDataList {
78
- const legacyEntries = this.entries.map((entry) => entry.legacy);
79
- return ExtensionDataList.fromArray(legacyEntries);
80
- }
81
-
82
- stringIds(): string[] {
83
- const ids = this.entries.map((entry) => entry.id.toString());
84
- return ids;
85
- }
86
-
87
- static fromLegacyExtensions(legacyDataList: ExtensionDataList, scope?: string): AspectList {
88
- const newEntries = legacyDataList.map((entry) => {
89
- return new AspectEntry(getAspectId(entry, scope), entry);
90
- });
91
-
92
- return new AspectList(newEntries);
93
- }
94
- }
95
-
96
- function getAspectId(entry: ExtensionDataEntry, scope?: string) {
97
- if (!entry.extensionId && entry.name) return ComponentID.fromString(entry.name);
98
- if (entry.extensionId) return ComponentID.fromLegacy(entry.extensionId, scope);
99
- throw new Error('aspect cannot be loaded without setting an ID');
100
- }
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';
3
- import { Section } from './section';
4
- import { AspectPage } from './ui/aspect-page';
5
-
6
- export class AspectSection implements Section {
7
- route = {
8
- path: '~aspect',
9
- children: <AspectPage />,
10
- };
11
- navigationLink = {
12
- href: '~aspect',
13
- children: <MenuWidgetIcon icon="configuration" tooltipContent="Configuration" />,
14
- };
15
- order = 50;
16
- }
@@ -1,106 +0,0 @@
1
- import { BitId } from '@teambit/legacy-bit-id';
2
- import LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';
3
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
4
- import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
5
- import type { AspectDefinition } from '@teambit/aspect-loader';
6
- import { ComponentID } from '@teambit/component-id';
7
- import { Component, InvalidComponent } from './component';
8
- import { State } from './state';
9
- import { Snap } from './snap';
10
-
11
- export interface ComponentFactory {
12
- /**
13
- * name of the component host.
14
- */
15
- name: string;
16
-
17
- /**
18
- * path to the component host.
19
- */
20
- path: string;
21
-
22
- isLegacy: boolean;
23
-
24
- /**
25
- * resolve a `string` component ID to an instance of a ComponentID.
26
- */
27
- resolveComponentId(id: string | ComponentID | BitId): Promise<ComponentID>;
28
-
29
- /**
30
- * resolve multiple `string` component ID to an instance of a ComponentID.
31
- */
32
- resolveMultipleComponentIds(ids: (string | ComponentID | BitId)[]): Promise<ComponentID[]>;
33
-
34
- /**
35
- * returns a component by ID.
36
- */
37
- get(
38
- id: ComponentID | string,
39
- withState?: boolean,
40
- consumerComponent?: ConsumerComponent
41
- ): Promise<Component | undefined>;
42
-
43
- /**
44
- * returns many components by ids.
45
- */
46
- getMany(ids: ComponentID[]): Promise<Component[]>;
47
-
48
- /**
49
- * returns many components by their legacy representation.
50
- */
51
- getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
52
-
53
- /**
54
- * get a component from a remote without importing it
55
- */
56
- getRemoteComponent?: (id: ComponentID) => Promise<Component>;
57
-
58
- getLegacyGraph(ids?: ComponentID[]): Promise<LegacyGraph>;
59
-
60
- getLogs(id: ComponentID): Promise<ComponentLog[]>;
61
-
62
- /**
63
- * returns a specific state of a component by hash or semver.
64
- */
65
- getState(id: ComponentID, snapId: string): Promise<State>;
66
-
67
- /**
68
- * returns a specific snap of a component by hash.
69
- */
70
- getSnap(id: ComponentID, snapId: string): Promise<Snap>;
71
-
72
- /**
73
- * load extension.
74
- */
75
- loadAspects: (ids: string[], throwOnError: boolean) => Promise<void>;
76
-
77
- /**
78
- * Resolve dirs for aspects
79
- */
80
- resolveAspects: (runtimeName?: string, componentIds?: ComponentID[]) => Promise<AspectDefinition[]>;
81
-
82
- /**
83
- * list all components in the host.
84
- */
85
- list(filter?: { offset: number; limit: number }): Promise<Component[]>;
86
-
87
- /**
88
- * list invalid components, such as components with missing files on the fs.
89
- */
90
- listInvalid(): Promise<InvalidComponent[]>;
91
-
92
- listIds(): Promise<ComponentID[]>;
93
-
94
- hasId(componentId: ComponentID): Promise<boolean>;
95
-
96
- /**
97
- * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)
98
- * @param componentId
99
- */
100
- hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
101
-
102
- /**
103
- * determine whether host should be the prior one in case multiple hosts persist.
104
- */
105
- priority?: boolean;
106
- }