@teambit/component 1.0.108 → 1.0.110

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "1.0.108",
3
+ "version": "1.0.110",
4
4
  "homepage": "https://bit.cloud/teambit/component/component",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "component",
9
- "version": "1.0.108"
9
+ "version": "1.0.110"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/any-fs": "0.0.5",
@@ -33,39 +33,39 @@
33
33
  "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.505",
34
34
  "@teambit/legacy-component-log": "0.0.402",
35
35
  "@teambit/ui-foundation.ui.react-router.use-query": "0.0.501",
36
- "@teambit/design.ui.pages.not-found": "0.0.366",
37
- "@teambit/design.ui.pages.server-error": "0.0.366",
38
36
  "@teambit/design.ui.empty-box": "0.0.363",
39
37
  "@teambit/documenter.ui.heading": "4.1.1",
40
38
  "@teambit/documenter.ui.separator": "4.1.1",
41
- "@teambit/design.ui.styles.ellipsis": "0.0.357",
42
- "@teambit/explorer.ui.command-bar": "2.0.14",
39
+ "@teambit/design.ui.pages.not-found": "0.0.366",
40
+ "@teambit/design.ui.pages.server-error": "0.0.366",
43
41
  "@teambit/design.navigation.responsive-navbar": "0.0.7",
44
42
  "@teambit/base-ui.layout.breakpoints": "1.0.0",
45
43
  "@teambit/component.ui.version-dropdown": "0.0.852",
46
44
  "@teambit/lanes.hooks.use-lanes": "0.0.254",
47
45
  "@teambit/lanes.ui.models.lanes-model": "0.0.207",
48
46
  "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.141",
49
- "@teambit/aspect-loader": "1.0.108",
50
- "@teambit/graph": "1.0.108",
47
+ "@teambit/design.ui.styles.ellipsis": "0.0.357",
48
+ "@teambit/explorer.ui.command-bar": "2.0.14",
49
+ "@teambit/aspect-loader": "1.0.110",
50
+ "@teambit/graph": "1.0.110",
51
51
  "@teambit/toolbox.path.match-patterns": "0.0.13",
52
52
  "@teambit/toolbox.string.capitalize": "0.0.494",
53
- "@teambit/cli": "0.0.840",
54
- "@teambit/express": "0.0.939",
55
- "@teambit/graphql": "1.0.108",
56
- "@teambit/command-bar": "1.0.108",
53
+ "@teambit/cli": "0.0.842",
54
+ "@teambit/express": "0.0.941",
55
+ "@teambit/graphql": "1.0.110",
56
+ "@teambit/command-bar": "1.0.110",
57
57
  "@teambit/component-package-version": "0.0.431",
58
- "@teambit/preview": "1.0.108",
59
- "@teambit/pubsub": "1.0.108",
60
- "@teambit/react-router": "1.0.108",
61
- "@teambit/ui": "1.0.108",
58
+ "@teambit/preview": "1.0.110",
59
+ "@teambit/pubsub": "1.0.110",
60
+ "@teambit/react-router": "1.0.110",
61
+ "@teambit/ui": "1.0.110",
62
62
  "@teambit/component-issues": "0.0.138",
63
63
  "@teambit/cli-table": "0.0.46",
64
- "@teambit/component-descriptor": "0.0.408",
65
- "@teambit/compositions": "1.0.108",
66
- "@teambit/deprecation": "1.0.108",
67
- "@teambit/envs": "1.0.108",
64
+ "@teambit/component-descriptor": "0.0.410",
68
65
  "@teambit/harmony.ui.aspect-box": "0.0.505",
66
+ "@teambit/compositions": "1.0.110",
67
+ "@teambit/deprecation": "1.0.110",
68
+ "@teambit/envs": "1.0.110",
69
69
  "@teambit/envs.ui.env-icon": "0.0.503"
70
70
  },
71
71
  "devDependencies": {
@@ -78,7 +78,7 @@
78
78
  "@types/jest": "^29.2.2",
79
79
  "@types/testing-library__jest-dom": "^5.9.5",
80
80
  "@teambit/component.content.component-overview": "1.95.0",
81
- "@teambit/harmony.envs.core-aspect-env": "0.0.13"
81
+ "@teambit/harmony.envs.core-aspect-env": "0.0.15"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "@apollo/client": "^3.6.0",
@@ -91,11 +91,15 @@
91
91
  "optionalDependencies": {},
92
92
  "peerDependenciesMeta": {},
93
93
  "exports": {
94
- "node": {
95
- "require": "./dist/index.js",
96
- "import": "./dist/esm.mjs"
94
+ ".": {
95
+ "node": {
96
+ "require": "./dist/index.js",
97
+ "import": "./dist/esm.mjs"
98
+ },
99
+ "default": "./dist/index.js"
97
100
  },
98
- "default": "./dist/index.js"
101
+ "./dist/*": "./dist/*",
102
+ "./artifacts/*": "./artifacts/*"
99
103
  },
100
104
  "private": false,
101
105
  "engines": {
package/aspect-entry.ts DELETED
@@ -1,73 +0,0 @@
1
- /**
2
- * avoid importing any (non-type) legacy code here. otherwise, PreviewTask will throw cryptic errors
3
- */
4
-
5
- import type { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
6
- import { ComponentID } from '@teambit/component-id';
7
- import { RawComponentMetadata } from './component-interface';
8
-
9
- export type Serializable = {
10
- toString(): string;
11
- };
12
-
13
- export type SerializableMap = {
14
- [key: string]: Serializable;
15
- };
16
-
17
- export type AspectData = {
18
- [key: string]: any;
19
- };
20
-
21
- export type ResolveComponentIdFunc = (id: string) => Promise<ComponentID>;
22
- export class AspectEntry {
23
- constructor(public id: ComponentID, private legacyEntry: ExtensionDataEntry) {}
24
-
25
- get legacy() {
26
- return this.legacyEntry;
27
- }
28
-
29
- get isLegacy(): boolean {
30
- if (this.config?.__legacy) return true;
31
- return false;
32
- }
33
-
34
- get config() {
35
- return this.legacy.config;
36
- }
37
-
38
- set config(config) {
39
- this.legacy.config = config;
40
- }
41
-
42
- get data(): { [key: string]: any } {
43
- return this.legacy.data;
44
- }
45
-
46
- get isRemoved(): boolean {
47
- return this.legacy.isRemoved;
48
- }
49
-
50
- // eslint-disable-next-line @typescript-eslint/adjacent-overload-signatures
51
- set data(val: { [key: string]: any }) {
52
- this.legacy.data = val;
53
- }
54
-
55
- transform(newData: SerializableMap): AspectEntry {
56
- const newEntry = this.clone();
57
- newEntry.data = newData;
58
- return new AspectEntry(this.id, newEntry.legacy);
59
- }
60
-
61
- clone(): AspectEntry {
62
- return new AspectEntry(this.id, this.legacyEntry.clone());
63
- }
64
-
65
- serialize(): RawComponentMetadata {
66
- return {
67
- id: this.id.toString(),
68
- config: this.config,
69
- data: this.data,
70
- 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
71
- };
72
- }
73
- }
package/aspect-list.ts DELETED
@@ -1,132 +0,0 @@
1
- import {
2
- ExtensionDataList,
3
- ExtensionDataEntry,
4
- removeInternalConfigFields,
5
- } from '@teambit/legacy/dist/consumer/config/extension-data';
6
- import { ComponentID } from '@teambit/component-id';
7
- import { AspectEntry, SerializableMap } from './aspect-entry';
8
-
9
- /**
10
- * list of aspects, each may have data and artifacts saved per component.
11
- */
12
- export class AspectList {
13
- constructor(readonly entries: AspectEntry[]) {}
14
-
15
- addEntry(aspectId: ComponentID, data: SerializableMap = {}) {
16
- const extensionDataEntry = new ExtensionDataEntry(undefined, aspectId, undefined, {}, data);
17
- const entry = new AspectEntry(aspectId, extensionDataEntry);
18
- this.entries.push(entry);
19
- return entry;
20
- }
21
-
22
- upsertEntry(aspectId: ComponentID, data: SerializableMap = {}) {
23
- const existingEntry = this.entries.find((entry) => entry.id.isEqual(aspectId));
24
- if (existingEntry) {
25
- existingEntry.data = data;
26
- return existingEntry;
27
- }
28
- return this.addEntry(aspectId, data);
29
- }
30
-
31
- /**
32
- * transform an aspect list into a new one without the given aspect ids
33
- */
34
- withoutEntries(aspectIds: string[]): AspectList {
35
- const entries = this.entries.filter((entry) => !aspectIds.includes(entry.legacy.stringId));
36
- return new AspectList(entries);
37
- }
38
-
39
- /**
40
- * get all ids as strings from the aspect list.
41
- */
42
- get ids(): string[] {
43
- const list = this.entries.map((entry) => entry.id.toString());
44
- return list;
45
- }
46
-
47
- /**
48
- * get an aspect from the list using a serialized ID.
49
- */
50
- get(id: string): AspectEntry | undefined {
51
- return this.entries.find((entry) => {
52
- return entry.legacy.stringId === id || entry.id.toStringWithoutVersion() === id;
53
- });
54
- }
55
-
56
- /**
57
- * find aspect by component ID.
58
- */
59
- find(id: ComponentID, ignoreVersion = false): AspectEntry | undefined {
60
- return this.entries.find((aspectEntry) => {
61
- return id.isEqual(aspectEntry.id, { ignoreVersion });
62
- });
63
- }
64
-
65
- /**
66
- * transform an aspect list into a new one.
67
- */
68
- map(predicate: (entry: AspectEntry) => AspectEntry) {
69
- const entries = this.entries.map(predicate);
70
- return new AspectList(entries);
71
- }
72
-
73
- /**
74
- * transform an aspect list into a new one.
75
- */
76
- async pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>) {
77
- const entriesP = this.entries.map(predicate);
78
- const entries = await Promise.all(entriesP);
79
- return new AspectList(entries);
80
- }
81
-
82
- toConfigObject() {
83
- const res = {};
84
- this.entries.forEach((entry) => {
85
- if (entry.config) {
86
- res[entry.id.toString()] = removeInternalConfigFields(entry.legacy.rawConfig);
87
- }
88
- });
89
- return res;
90
- }
91
-
92
- serialize() {
93
- const serializedEntries = this.entries.map((entry) => entry.serialize());
94
- return serializedEntries;
95
- }
96
-
97
- filter(ids?: string[]): AspectList {
98
- if (!ids?.length) return new AspectList(this.entries);
99
- const entries = this.entries.filter((aspectEntry) => {
100
- return ids?.includes(aspectEntry.id.toStringWithoutVersion());
101
- });
102
- return new AspectList(entries);
103
- }
104
-
105
- toLegacy(): ExtensionDataList {
106
- const legacyEntries = this.entries.map((entry) => entry.legacy);
107
- return ExtensionDataList.fromArray(legacyEntries);
108
- }
109
-
110
- stringIds(): string[] {
111
- const ids = this.entries.map((entry) => entry.id.toString());
112
- return ids;
113
- }
114
-
115
- clone(): AspectList {
116
- return new AspectList(this.entries.map((entry) => entry.clone()));
117
- }
118
-
119
- static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList {
120
- const newEntries = legacyDataList.map((entry) => {
121
- return new AspectEntry(getAspectId(entry), entry);
122
- });
123
-
124
- return new AspectList(newEntries);
125
- }
126
- }
127
-
128
- function getAspectId(entry: ExtensionDataEntry) {
129
- if (!entry.extensionId && entry.name) return ComponentID.fromString(entry.name);
130
- if (entry.extensionId) return entry.extensionId;
131
- throw new Error('aspect cannot be loaded without setting an ID');
132
- }
@@ -1,190 +0,0 @@
1
- import { Graph } from '@teambit/graph.cleargraph';
2
- import { ComponentID } from '@teambit/component-id';
3
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
4
- import { CompIdGraph } from '@teambit/graph';
5
- import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
6
- import type { AspectDefinition } from '@teambit/aspect-loader';
7
- import { Component, InvalidComponent } from './component';
8
- import { State } from './state';
9
- import { Snap } from './snap';
10
-
11
- export type ResolveAspectsOptions = FilterAspectsOptions & {
12
- throwOnError?: boolean;
13
- useScopeAspectsCapsule?: boolean;
14
- workspaceName?: string;
15
- skipDeps?: boolean;
16
- resolveEnvsFromRoots?: boolean;
17
- packageManagerConfigRootDir?: string;
18
- };
19
-
20
- export type LoadAspectsOptions = {
21
- /* `throwOnError` is an optional parameter that can be passed to the loadAspects method in the `ComponentFactory` interface. If
22
- set to `true`, it will cause the method to throw an error if an error occurs during its execution. If set to `false`
23
- or not provided, the method will print a warning instead of throwing it. */
24
- throwOnError?: boolean;
25
- /* `hideMissingModuleError` is an optional parameter that can be passed to the `loadAspects` method in the
26
- `ComponentFactory` interface. If set to `true`, it will prevent the method from throwing/printing an error if a required module
27
- is missing during the loading of an aspect. Instead, it will continue loading the other
28
- aspects. If set to `false` or not provided, the method will print/throw an error if a required module is missing.
29
- (considering throwOnError as well) */
30
- hideMissingModuleError?: boolean;
31
-
32
- /* The `ignoreErrors` property is an optional boolean parameter that can be passed to the `LoadAspectsOptions` object in
33
- the `ComponentFactory` interface. If set to `true`, it will cause the `loadAspects` method to ignore any errors that
34
- occur during the loading of aspects and continue loading the other aspects. If set to `false` or not provided, the
35
- method will print/throw an error if a required module is missing or if any other error occurs during the loading of
36
- aspects. */
37
- ignoreErrors?: boolean;
38
- [key: string]: any;
39
- };
40
-
41
- export type FilterAspectsOptions = {
42
- /**
43
- * Do not return results for the core aspects
44
- */
45
- excludeCore?: boolean;
46
- /**
47
- * Only return results for the provided list of ids
48
- */
49
- requestedOnly?: boolean;
50
- /**
51
- * Only return results for aspects that have a path to the specified runtime name
52
- */
53
- filterByRuntime?: boolean;
54
- };
55
-
56
- export interface ComponentFactory {
57
- /**
58
- * name of the component host.
59
- */
60
- name: string;
61
-
62
- /**
63
- * path to the component host.
64
- */
65
- path: string;
66
-
67
- isLegacy: boolean;
68
-
69
- /**
70
- * resolve a `string` component ID to an instance of a ComponentID.
71
- */
72
- resolveComponentId(id: string | ComponentID | ComponentID): Promise<ComponentID>;
73
-
74
- /**
75
- * resolve multiple `string` component ID to an instance of a ComponentID.
76
- */
77
- resolveMultipleComponentIds(ids: (string | ComponentID | ComponentID)[]): Promise<ComponentID[]>;
78
-
79
- /**
80
- * returns a component by ID.
81
- */
82
- get(id: ComponentID): Promise<Component | undefined>;
83
-
84
- /**
85
- * returns the legacy representation of a component with minimal loading.
86
- * when loaded from the workspace, it won't run any Harmony hooks and even won't load dependencies.
87
- * it's good to get raw aspects data or some basic properties.
88
- * use carefully. prefer using `get()` instead.
89
- */
90
- getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;
91
-
92
- /**
93
- * returns many components by ids.
94
- */
95
- getMany(ids: ComponentID[]): Promise<Component[]>;
96
-
97
- /**
98
- * returns many components by their legacy representation.
99
- */
100
- getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
101
-
102
- /**
103
- * get a component from a remote without importing it
104
- */
105
- getRemoteComponent?: (id: ComponentID) => Promise<Component>;
106
-
107
- /**
108
- * important - prefer using `getGraphIds()` if you don't need the component objects.
109
- * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.
110
- */
111
- getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;
112
-
113
- /**
114
- * get graph of the given component-ids and all their dependencies (recursively/flattened).
115
- * the nodes are ComponentIds and is much faster than `this.getGraph()`.
116
- */
117
- getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;
118
-
119
- getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;
120
-
121
- /**
122
- * returns a specific state of a component by hash or semver.
123
- */
124
- getState(id: ComponentID, snapId: string): Promise<State>;
125
-
126
- /**
127
- * returns a specific snap of a component by hash.
128
- */
129
- getSnap(id: ComponentID, snapId: string): Promise<Snap>;
130
-
131
- /**
132
- * load aspects.
133
- * returns the loaded aspect ids including the loaded versions.
134
- */
135
- loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;
136
-
137
- /**
138
- * Resolve dirs for aspects
139
- */
140
- resolveAspects: (
141
- runtimeName?: string,
142
- componentIds?: ComponentID[],
143
- opts?: ResolveAspectsOptions
144
- ) => Promise<AspectDefinition[]>;
145
-
146
- /**
147
- * list all components in the host.
148
- */
149
- list(filter?: { offset: number; limit: number }): Promise<Component[]>;
150
-
151
- /**
152
- * list invalid components, such as components with missing files on the fs.
153
- */
154
- listInvalid(): Promise<InvalidComponent[]>;
155
-
156
- listIds(): Promise<ComponentID[]>;
157
-
158
- /**
159
- * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
160
- * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports
161
- * (among others) negate character "!" to exclude ids. See the package page for more supported characters.
162
- */
163
- idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;
164
-
165
- hasId(componentId: ComponentID): Promise<boolean>;
166
-
167
- /**
168
- * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)
169
- * @param componentId
170
- */
171
- hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
172
-
173
- /**
174
- * whether a component is not the same as its head.
175
- * for a new component, it'll return "true" as it has no head yet.
176
- * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false
177
- */
178
- isModified(component: Component): Promise<boolean>;
179
-
180
- /**
181
- * write the component to the filesystem when applicable (no-op for scope).
182
- * to change the component-path, specify the "rootPath", which should be a relative path inside the workspace.
183
- */
184
- write(component: Component, rootPath?: string): Promise<void>;
185
-
186
- /**
187
- * determine whether host should be the prior one in case multiple hosts persist.
188
- */
189
- priority?: boolean;
190
- }
package/component-fs.ts DELETED
@@ -1,66 +0,0 @@
1
- import { MemoryFS } from '@teambit/any-fs';
2
- import type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
3
- import { auto } from '@teambit/legacy/dist/utils/eol';
4
- import path from 'path';
5
- import { matchPatterns, splitPatterns } from '@teambit/toolbox.path.match-patterns';
6
-
7
- /**
8
- * The virtual component filesystem
9
- */
10
- export default class ComponentFS extends MemoryFS {
11
- constructor(
12
- /**
13
- * array of all fs files.
14
- */
15
- readonly files: AbstractVinyl[]
16
- ) {
17
- super();
18
- }
19
- /**
20
- * hash to represent all contents within this filesystem volume.
21
- */
22
- get hash() {
23
- return '';
24
- }
25
-
26
- /**
27
- * filter all component files by regex.
28
- */
29
- byRegex(extension: RegExp): AbstractVinyl[] {
30
- return this.files.filter((file) => file.path.match(extension));
31
- }
32
-
33
- /**
34
- * filter all files using an array of glob patterns.
35
- */
36
- byGlob(patterns: string[]) {
37
- const { includePatterns, excludePatterns } = splitPatterns(patterns);
38
-
39
- const files = this.files.filter((file) => {
40
- return matchPatterns(file.relative, includePatterns, excludePatterns);
41
- });
42
-
43
- return files;
44
- }
45
-
46
- toObject() {
47
- return this.files.map((file) => {
48
- return {
49
- path: file.path,
50
- contents: file.contents,
51
- };
52
- });
53
- }
54
-
55
- static fromVinyls(files: AbstractVinyl[]) {
56
- const fs = new ComponentFS(files);
57
- files.forEach((file) => {
58
- let dirPath = file.relativeDir;
59
- if (!dirPath.startsWith('/')) dirPath = path.join('/', dirPath);
60
- fs.mkdirpSync(dirPath);
61
- fs.writeFileSync(`/${file.relative}`, auto(file.contents || ''));
62
- });
63
-
64
- return fs;
65
- }
66
- }
@@ -1,26 +0,0 @@
1
- import { ComponentID } from '@teambit/component-id';
2
-
3
- export interface IComponent {
4
- /**
5
- * id of the component.
6
- */
7
- id: ComponentID;
8
-
9
- /**
10
- * get function to retrieve aspect
11
- */
12
- get(aspectId: string): RawComponentMetadata | undefined;
13
-
14
- /**
15
- * determines whether a component is a modified state.
16
- * TODO: consider to remove after handling component descriptors correctly.
17
- */
18
- isModified(): Promise<boolean>;
19
- }
20
-
21
- export type RawComponentMetadata = {
22
- id: string;
23
- config: Record<string, any>;
24
- data: Record<string, any>;
25
- icon?: string;
26
- };
package/component-meta.ts DELETED
@@ -1,29 +0,0 @@
1
- import { capitalize } from '@teambit/toolbox.string.capitalize';
2
- import { ComponentID } from '@teambit/component-id';
3
-
4
- export class ComponentMeta {
5
- constructor(
6
- /**
7
- * id the component.
8
- */
9
- readonly id: ComponentID
10
- ) {}
11
-
12
- /**
13
- * display name of the component.
14
- */
15
- get displayName() {
16
- const tokens = this.id.name.split('-').map((token) => capitalize(token));
17
- return tokens.join(' ');
18
- }
19
-
20
- toObject() {
21
- return {
22
- id: this.id.toObject(),
23
- };
24
- }
25
-
26
- static from(object: { [key: string]: any }) {
27
- return new ComponentMeta(ComponentID.fromObject(object.id));
28
- }
29
- }
@@ -1,9 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const ComponentAspect = Aspect.create({
4
- id: 'teambit.component/component',
5
- dependencies: [],
6
- defaultConfig: {},
7
- });
8
-
9
- export default ComponentAspect;