@teambit/component 1.0.227 → 1.0.229

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 (88) hide show
  1. package/artifacts/__bit_junit.xml +1 -1
  2. package/artifacts/preview/teambit_component_component-preview.js +1 -1
  3. package/artifacts/schema.json +1643 -695
  4. package/dist/aspect-entry.d.ts +39 -0
  5. package/dist/aspect-list.d.ts +43 -0
  6. package/dist/aspect.section.d.ts +13 -0
  7. package/dist/component-factory.d.ts +150 -0
  8. package/dist/component-factory.js.map +1 -1
  9. package/dist/component-fs.d.ts +34 -0
  10. package/dist/component-interface.d.ts +22 -0
  11. package/dist/component-map/component-map.d.ts +63 -0
  12. package/dist/component-map/index.d.ts +1 -0
  13. package/dist/component-meta.d.ts +22 -0
  14. package/dist/component.aspect.d.ts +3 -0
  15. package/dist/component.composition.d.ts +1 -0
  16. package/dist/component.d.ts +183 -0
  17. package/dist/component.graphql.d.ts +83 -0
  18. package/dist/component.js +3 -0
  19. package/dist/component.js.map +1 -1
  20. package/dist/component.main.runtime.d.ts +75 -0
  21. package/dist/component.route.d.ts +18 -0
  22. package/dist/component.ui.runtime.d.ts +104 -0
  23. package/dist/config.d.ts +18 -0
  24. package/dist/dependencies/dependencies.d.ts +43 -0
  25. package/dist/dependencies/index.d.ts +1 -0
  26. package/dist/exceptions/could-not-find-latest.d.ts +4 -0
  27. package/dist/exceptions/host-not-found.d.ts +12 -0
  28. package/dist/exceptions/index.d.ts +4 -0
  29. package/dist/exceptions/main-file-not-found.d.ts +14 -0
  30. package/dist/exceptions/nothing-to-snap.d.ts +2 -0
  31. package/dist/get-component-opts.d.ts +13 -0
  32. package/dist/hash.d.ts +4 -0
  33. package/dist/head.d.ts +0 -0
  34. package/dist/history-graph.d.ts +2 -0
  35. package/dist/host/component-host-model.d.ts +7 -0
  36. package/dist/host/index.d.ts +2 -0
  37. package/dist/host/use-component-host.d.ts +6 -0
  38. package/dist/index.d.ts +37 -0
  39. package/dist/on-load.d.ts +0 -0
  40. package/dist/{preview-1712719054377.js → preview-1712822929999.js} +2 -2
  41. package/dist/section/index.d.ts +1 -0
  42. package/dist/section/section.d.ts +11 -0
  43. package/dist/show/extensions.fragment.d.ts +13 -0
  44. package/dist/show/files.fragment.d.ts +14 -0
  45. package/dist/show/id.fragment.d.ts +13 -0
  46. package/dist/show/index.d.ts +8 -0
  47. package/dist/show/main-file.fragment.d.ts +9 -0
  48. package/dist/show/name.fragment.d.ts +9 -0
  49. package/dist/show/scope.fragment.d.ts +10 -0
  50. package/dist/show/show-fragment.d.ts +37 -0
  51. package/dist/show/show.cmd.d.ts +26 -0
  52. package/dist/snap/author.d.ts +17 -0
  53. package/dist/snap/index.d.ts +2 -0
  54. package/dist/snap/snap.d.ts +56 -0
  55. package/dist/state.d.ts +65 -0
  56. package/dist/store.d.ts +3 -0
  57. package/dist/tag/index.d.ts +1 -0
  58. package/dist/tag/tag.d.ts +32 -0
  59. package/dist/tag-map.d.ts +35 -0
  60. package/dist/ui/aspect-page/aspect-page.d.ts +1 -0
  61. package/dist/ui/aspect-page/index.d.ts +1 -0
  62. package/dist/ui/component-error/component-error.d.ts +20 -0
  63. package/dist/ui/component-error/index.d.ts +1 -0
  64. package/dist/ui/component-model/component-model.d.ts +186 -0
  65. package/dist/ui/component-model/index.d.ts +1 -0
  66. package/dist/ui/component-searcher/component-result.d.ts +16 -0
  67. package/dist/ui/component-searcher/component-searcher.d.ts +22 -0
  68. package/dist/ui/component-searcher/index.d.ts +2 -0
  69. package/dist/ui/component.d.ts +26 -0
  70. package/dist/ui/context/component-context.d.ts +6 -0
  71. package/dist/ui/context/component-provider.d.ts +25 -0
  72. package/dist/ui/context/index.d.ts +3 -0
  73. package/dist/ui/index.d.ts +12 -0
  74. package/dist/ui/menu/index.d.ts +3 -0
  75. package/dist/ui/menu/menu-nav.d.ts +23 -0
  76. package/dist/ui/menu/menu.d.ts +97 -0
  77. package/dist/ui/menu/nav-plugin.d.ts +28 -0
  78. package/dist/ui/top-bar-nav/index.d.ts +1 -0
  79. package/dist/ui/top-bar-nav/top-bar-nav.d.ts +2 -0
  80. package/dist/ui/use-component-from-location.d.ts +1 -0
  81. package/dist/ui/use-component-logs.d.ts +16 -0
  82. package/dist/ui/use-component-query.d.ts +3 -0
  83. package/dist/ui/use-component.d.ts +3 -0
  84. package/dist/ui/use-component.fragments.d.ts +10 -0
  85. package/dist/ui/use-component.model.d.ts +44 -0
  86. package/dist/ui/use-component.utils.d.ts +1 -0
  87. package/package.json +20 -20
  88. package/tsconfig.json +1 -46
@@ -0,0 +1,39 @@
1
+ /**
2
+ * avoid importing any (non-type) legacy code here. otherwise, PreviewTask will throw cryptic errors
3
+ */
4
+ import type { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
5
+ import { ComponentID } from '@teambit/component-id';
6
+ import { RawComponentMetadata } from './component-interface';
7
+ export type Serializable = {
8
+ toString(): string;
9
+ };
10
+ export type SerializableMap = {
11
+ [key: string]: Serializable;
12
+ };
13
+ export type AspectData = {
14
+ [key: string]: any;
15
+ };
16
+ export type ResolveComponentIdFunc = (id: string) => Promise<ComponentID>;
17
+ export declare class AspectEntry {
18
+ id: ComponentID;
19
+ private legacyEntry;
20
+ constructor(id: ComponentID, legacyEntry: ExtensionDataEntry);
21
+ get legacy(): ExtensionDataEntry;
22
+ get isLegacy(): boolean;
23
+ get config(): {
24
+ [key: string]: any;
25
+ };
26
+ set config(config: {
27
+ [key: string]: any;
28
+ });
29
+ get data(): {
30
+ [key: string]: any;
31
+ };
32
+ get isRemoved(): boolean;
33
+ set data(val: {
34
+ [key: string]: any;
35
+ });
36
+ transform(newData: SerializableMap): AspectEntry;
37
+ clone(): AspectEntry;
38
+ serialize(): RawComponentMetadata;
39
+ }
@@ -0,0 +1,43 @@
1
+ import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { AspectEntry, SerializableMap } from './aspect-entry';
4
+ /**
5
+ * list of aspects, each may have data and artifacts saved per component.
6
+ */
7
+ export declare class AspectList {
8
+ readonly entries: AspectEntry[];
9
+ constructor(entries: AspectEntry[]);
10
+ addEntry(aspectId: ComponentID, data?: SerializableMap): AspectEntry;
11
+ upsertEntry(aspectId: ComponentID, data?: SerializableMap): AspectEntry;
12
+ /**
13
+ * transform an aspect list into a new one without the given aspect ids
14
+ */
15
+ withoutEntries(aspectIds: string[]): AspectList;
16
+ /**
17
+ * get all ids as strings from the aspect list.
18
+ */
19
+ get ids(): string[];
20
+ /**
21
+ * get an aspect from the list using a serialized ID.
22
+ */
23
+ get(id: string): AspectEntry | undefined;
24
+ /**
25
+ * find aspect by component ID.
26
+ */
27
+ find(id: ComponentID, ignoreVersion?: boolean): AspectEntry | undefined;
28
+ /**
29
+ * transform an aspect list into a new one.
30
+ */
31
+ map(predicate: (entry: AspectEntry) => AspectEntry): AspectList;
32
+ /**
33
+ * transform an aspect list into a new one.
34
+ */
35
+ pmap(predicate: (entry: AspectEntry) => Promise<AspectEntry>): Promise<AspectList>;
36
+ toConfigObject(): {};
37
+ serialize(): import("./component-interface").RawComponentMetadata[];
38
+ filter(ids?: string[]): AspectList;
39
+ toLegacy(): ExtensionDataList;
40
+ stringIds(): string[];
41
+ clone(): AspectList;
42
+ static fromLegacyExtensions(legacyDataList: ExtensionDataList): AspectList;
43
+ }
@@ -0,0 +1,13 @@
1
+ import { Section } from './section';
2
+ export declare class AspectSection implements Section {
3
+ route: {
4
+ path: string;
5
+ element: import("react/jsx-runtime").JSX.Element;
6
+ };
7
+ navigationLink: {
8
+ href: string;
9
+ children: import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
12
+ order: number;
13
+ }
@@ -0,0 +1,150 @@
1
+ import { Graph } from '@teambit/graph.cleargraph';
2
+ import { BitId } from '@teambit/legacy-bit-id';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
5
+ import { CompIdGraph } from '@teambit/graph';
6
+ import type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
7
+ import type { AspectDefinition } from '@teambit/aspect-loader';
8
+ import type { DependencyList } from '@teambit/dependency-resolver';
9
+ import { Component, InvalidComponent } from './component';
10
+ import { State } from './state';
11
+ import { Snap } from './snap';
12
+ export type ResolveAspectsOptions = FilterAspectsOptions & {
13
+ throwOnError?: boolean;
14
+ useScopeAspectsCapsule?: boolean;
15
+ workspaceName?: string;
16
+ skipDeps?: boolean;
17
+ resolveEnvsFromRoots?: boolean;
18
+ packageManagerConfigRootDir?: string;
19
+ };
20
+ export type LoadAspectsOptions = {
21
+ throwOnError?: boolean;
22
+ hideMissingModuleError?: boolean;
23
+ ignoreErrors?: boolean;
24
+ [key: string]: any;
25
+ };
26
+ export type FilterAspectsOptions = {
27
+ /**
28
+ * Do not return results for the core aspects
29
+ */
30
+ excludeCore?: boolean;
31
+ /**
32
+ * Only return results for the provided list of ids
33
+ */
34
+ requestedOnly?: boolean;
35
+ /**
36
+ * Only return results for aspects that have a path to the specified runtime name
37
+ */
38
+ filterByRuntime?: boolean;
39
+ };
40
+ export interface ComponentFactory {
41
+ /**
42
+ * name of the component host.
43
+ */
44
+ name: string;
45
+ /**
46
+ * path to the component host.
47
+ */
48
+ path: string;
49
+ isLegacy: boolean;
50
+ /**
51
+ * resolve a `string` component ID to an instance of a ComponentID.
52
+ */
53
+ resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>;
54
+ /**
55
+ * resolve multiple `string` component ID to an instance of a ComponentID.
56
+ */
57
+ resolveMultipleComponentIds(ids: (string | BitId | ComponentID)[]): Promise<ComponentID[]>;
58
+ /**
59
+ * returns a component by ID.
60
+ */
61
+ get(id: ComponentID): Promise<Component | undefined>;
62
+ /**
63
+ * returns the legacy representation of a component with minimal loading.
64
+ * when loaded from the workspace, it won't run any Harmony hooks and even won't load dependencies.
65
+ * it's good to get raw aspects data or some basic properties.
66
+ * use carefully. prefer using `get()` instead.
67
+ */
68
+ getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;
69
+ /**
70
+ * returns many components by ids.
71
+ */
72
+ getMany(ids: ComponentID[]): Promise<Component[]>;
73
+ /**
74
+ * returns many components by their legacy representation.
75
+ */
76
+ getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
77
+ /**
78
+ * get a component from a remote without importing it
79
+ */
80
+ getRemoteComponent?: (id: ComponentID) => Promise<Component>;
81
+ /**
82
+ * important - prefer using `getGraphIds()` if you don't need the component objects.
83
+ * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.
84
+ */
85
+ getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;
86
+ /**
87
+ * get graph of the given component-ids and all their dependencies (recursively/flattened).
88
+ * the nodes are ComponentIds and is much faster than `this.getGraph()`.
89
+ */
90
+ getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;
91
+ getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;
92
+ getDependencies(component: Component): DependencyList;
93
+ componentPackageName(component: Component): string;
94
+ /**
95
+ * returns a specific state of a component by hash or semver.
96
+ */
97
+ getState(id: ComponentID, snapId: string): Promise<State>;
98
+ /**
99
+ * returns a specific snap of a component by hash.
100
+ */
101
+ getSnap(id: ComponentID, snapId: string): Promise<Snap>;
102
+ /**
103
+ * load aspects.
104
+ * returns the loaded aspect ids including the loaded versions.
105
+ */
106
+ loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;
107
+ /**
108
+ * Resolve dirs for aspects
109
+ */
110
+ resolveAspects: (runtimeName?: string, componentIds?: ComponentID[], opts?: ResolveAspectsOptions) => Promise<AspectDefinition[]>;
111
+ /**
112
+ * list all components in the host.
113
+ */
114
+ list(filter?: {
115
+ offset: number;
116
+ limit: number;
117
+ }): Promise<Component[]>;
118
+ /**
119
+ * list invalid components, such as components with missing files on the fs.
120
+ */
121
+ listInvalid(): Promise<InvalidComponent[]>;
122
+ listIds(): Promise<ComponentID[]> | ComponentID[];
123
+ /**
124
+ * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
125
+ * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports
126
+ * (among others) negate character "!" to exclude ids. See the package page for more supported characters.
127
+ */
128
+ idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;
129
+ hasId(componentId: ComponentID): Promise<boolean>;
130
+ /**
131
+ * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)
132
+ * @param componentId
133
+ */
134
+ hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
135
+ /**
136
+ * whether a component is not the same as its head.
137
+ * for a new component, it'll return "true" as it has no head yet.
138
+ * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false
139
+ */
140
+ isModified(component: Component): Promise<boolean>;
141
+ /**
142
+ * write the component to the filesystem when applicable (no-op for scope).
143
+ * to change the component-path, specify the "rootPath", which should be a relative path inside the workspace.
144
+ */
145
+ write(component: Component, rootPath?: string): Promise<void>;
146
+ /**
147
+ * determine whether host should be the prior one in case multiple hosts persist.
148
+ */
149
+ priority?: boolean;
150
+ }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { CompIdGraph } from '@teambit/graph';\nimport type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport type { DependencyList } from '@teambit/dependency-resolver';\nimport { Component, InvalidComponent } from './component';\nimport { State } from './state';\nimport { Snap } from './snap';\n\nexport type ResolveAspectsOptions = FilterAspectsOptions & {\n throwOnError?: boolean;\n useScopeAspectsCapsule?: boolean;\n workspaceName?: string;\n skipDeps?: boolean;\n resolveEnvsFromRoots?: boolean;\n packageManagerConfigRootDir?: string;\n};\n\nexport type LoadAspectsOptions = {\n /* `throwOnError` is an optional parameter that can be passed to the loadAspects method in the `ComponentFactory` interface. If\n set to `true`, it will cause the method to throw an error if an error occurs during its execution. If set to `false`\n or not provided, the method will print a warning instead of throwing it. */\n throwOnError?: boolean;\n /* `hideMissingModuleError` is an optional parameter that can be passed to the `loadAspects` method in the\n `ComponentFactory` interface. If set to `true`, it will prevent the method from throwing/printing an error if a required module\n is missing during the loading of an aspect. Instead, it will continue loading the other\n aspects. If set to `false` or not provided, the method will print/throw an error if a required module is missing.\n (considering throwOnError as well) */\n hideMissingModuleError?: boolean;\n\n /* The `ignoreErrors` property is an optional boolean parameter that can be passed to the `LoadAspectsOptions` object in\n the `ComponentFactory` interface. If set to `true`, it will cause the `loadAspects` method to ignore any errors that\n occur during the loading of aspects and continue loading the other aspects. If set to `false` or not provided, the\n method will print/throw an error if a required module is missing or if any other error occurs during the loading of\n aspects. */\n ignoreErrors?: boolean;\n [key: string]: any;\n};\n\nexport type FilterAspectsOptions = {\n /**\n * Do not return results for the core aspects\n */\n excludeCore?: boolean;\n /**\n * Only return results for the provided list of ids\n */\n requestedOnly?: boolean;\n /**\n * Only return results for aspects that have a path to the specified runtime name\n */\n filterByRuntime?: boolean;\n};\n\nexport interface ComponentFactory {\n /**\n * name of the component host.\n */\n name: string;\n\n /**\n * path to the component host.\n */\n path: string;\n\n isLegacy: boolean;\n\n /**\n * resolve a `string` component ID to an instance of a ComponentID.\n */\n resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>;\n\n /**\n * resolve multiple `string` component ID to an instance of a ComponentID.\n */\n resolveMultipleComponentIds(ids: (string | BitId | ComponentID)[]): Promise<ComponentID[]>;\n\n /**\n * returns a component by ID.\n */\n get(id: ComponentID): Promise<Component | undefined>;\n\n /**\n * returns the legacy representation of a component with minimal loading.\n * when loaded from the workspace, it won't run any Harmony hooks and even won't load dependencies.\n * it's good to get raw aspects data or some basic properties.\n * use carefully. prefer using `get()` instead.\n */\n getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;\n\n /**\n * returns many components by ids.\n */\n getMany(ids: ComponentID[]): Promise<Component[]>;\n\n /**\n * returns many components by their legacy representation.\n */\n getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;\n\n /**\n * get a component from a remote without importing it\n */\n getRemoteComponent?: (id: ComponentID) => Promise<Component>;\n\n /**\n * important - prefer using `getGraphIds()` if you don't need the component objects.\n * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.\n */\n getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;\n\n /**\n * get graph of the given component-ids and all their dependencies (recursively/flattened).\n * the nodes are ComponentIds and is much faster than `this.getGraph()`.\n */\n getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;\n\n getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;\n\n getDependencies(component: Component): DependencyList;\n\n /**\n * returns a specific state of a component by hash or semver.\n */\n getState(id: ComponentID, snapId: string): Promise<State>;\n\n /**\n * returns a specific snap of a component by hash.\n */\n getSnap(id: ComponentID, snapId: string): Promise<Snap>;\n\n /**\n * load aspects.\n * returns the loaded aspect ids including the loaded versions.\n */\n loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;\n\n /**\n * Resolve dirs for aspects\n */\n resolveAspects: (\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ) => Promise<AspectDefinition[]>;\n\n /**\n * list all components in the host.\n */\n list(filter?: { offset: number; limit: number }): Promise<Component[]>;\n\n /**\n * list invalid components, such as components with missing files on the fs.\n */\n listInvalid(): Promise<InvalidComponent[]>;\n\n listIds(): Promise<ComponentID[]> | ComponentID[];\n\n /**\n * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.\n * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports\n * (among others) negate character \"!\" to exclude ids. See the package page for more supported characters.\n */\n idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;\n\n hasId(componentId: ComponentID): Promise<boolean>;\n\n /**\n * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)\n * @param componentId\n */\n hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;\n\n /**\n * whether a component is not the same as its head.\n * for a new component, it'll return \"true\" as it has no head yet.\n * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false\n */\n isModified(component: Component): Promise<boolean>;\n\n /**\n * write the component to the filesystem when applicable (no-op for scope).\n * to change the component-path, specify the \"rootPath\", which should be a relative path inside the workspace.\n */\n write(component: Component, rootPath?: string): Promise<void>;\n\n /**\n * determine whether host should be the prior one in case multiple hosts persist.\n */\n priority?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { CompIdGraph } from '@teambit/graph';\nimport type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport type { DependencyList } from '@teambit/dependency-resolver';\nimport { Component, InvalidComponent } from './component';\nimport { State } from './state';\nimport { Snap } from './snap';\n\nexport type ResolveAspectsOptions = FilterAspectsOptions & {\n throwOnError?: boolean;\n useScopeAspectsCapsule?: boolean;\n workspaceName?: string;\n skipDeps?: boolean;\n resolveEnvsFromRoots?: boolean;\n packageManagerConfigRootDir?: string;\n};\n\nexport type LoadAspectsOptions = {\n /* `throwOnError` is an optional parameter that can be passed to the loadAspects method in the `ComponentFactory` interface. If\n set to `true`, it will cause the method to throw an error if an error occurs during its execution. If set to `false`\n or not provided, the method will print a warning instead of throwing it. */\n throwOnError?: boolean;\n /* `hideMissingModuleError` is an optional parameter that can be passed to the `loadAspects` method in the\n `ComponentFactory` interface. If set to `true`, it will prevent the method from throwing/printing an error if a required module\n is missing during the loading of an aspect. Instead, it will continue loading the other\n aspects. If set to `false` or not provided, the method will print/throw an error if a required module is missing.\n (considering throwOnError as well) */\n hideMissingModuleError?: boolean;\n\n /* The `ignoreErrors` property is an optional boolean parameter that can be passed to the `LoadAspectsOptions` object in\n the `ComponentFactory` interface. If set to `true`, it will cause the `loadAspects` method to ignore any errors that\n occur during the loading of aspects and continue loading the other aspects. If set to `false` or not provided, the\n method will print/throw an error if a required module is missing or if any other error occurs during the loading of\n aspects. */\n ignoreErrors?: boolean;\n [key: string]: any;\n};\n\nexport type FilterAspectsOptions = {\n /**\n * Do not return results for the core aspects\n */\n excludeCore?: boolean;\n /**\n * Only return results for the provided list of ids\n */\n requestedOnly?: boolean;\n /**\n * Only return results for aspects that have a path to the specified runtime name\n */\n filterByRuntime?: boolean;\n};\n\nexport interface ComponentFactory {\n /**\n * name of the component host.\n */\n name: string;\n\n /**\n * path to the component host.\n */\n path: string;\n\n isLegacy: boolean;\n\n /**\n * resolve a `string` component ID to an instance of a ComponentID.\n */\n resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>;\n\n /**\n * resolve multiple `string` component ID to an instance of a ComponentID.\n */\n resolveMultipleComponentIds(ids: (string | BitId | ComponentID)[]): Promise<ComponentID[]>;\n\n /**\n * returns a component by ID.\n */\n get(id: ComponentID): Promise<Component | undefined>;\n\n /**\n * returns the legacy representation of a component with minimal loading.\n * when loaded from the workspace, it won't run any Harmony hooks and even won't load dependencies.\n * it's good to get raw aspects data or some basic properties.\n * use carefully. prefer using `get()` instead.\n */\n getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;\n\n /**\n * returns many components by ids.\n */\n getMany(ids: ComponentID[]): Promise<Component[]>;\n\n /**\n * returns many components by their legacy representation.\n */\n getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;\n\n /**\n * get a component from a remote without importing it\n */\n getRemoteComponent?: (id: ComponentID) => Promise<Component>;\n\n /**\n * important - prefer using `getGraphIds()` if you don't need the component objects.\n * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.\n */\n getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;\n\n /**\n * get graph of the given component-ids and all their dependencies (recursively/flattened).\n * the nodes are ComponentIds and is much faster than `this.getGraph()`.\n */\n getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;\n\n getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;\n\n getDependencies(component: Component): DependencyList;\n\n componentPackageName(component: Component): string;\n\n /**\n * returns a specific state of a component by hash or semver.\n */\n getState(id: ComponentID, snapId: string): Promise<State>;\n\n /**\n * returns a specific snap of a component by hash.\n */\n getSnap(id: ComponentID, snapId: string): Promise<Snap>;\n\n /**\n * load aspects.\n * returns the loaded aspect ids including the loaded versions.\n */\n loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;\n\n /**\n * Resolve dirs for aspects\n */\n resolveAspects: (\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ) => Promise<AspectDefinition[]>;\n\n /**\n * list all components in the host.\n */\n list(filter?: { offset: number; limit: number }): Promise<Component[]>;\n\n /**\n * list invalid components, such as components with missing files on the fs.\n */\n listInvalid(): Promise<InvalidComponent[]>;\n\n listIds(): Promise<ComponentID[]> | ComponentID[];\n\n /**\n * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.\n * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports\n * (among others) negate character \"!\" to exclude ids. See the package page for more supported characters.\n */\n idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;\n\n hasId(componentId: ComponentID): Promise<boolean>;\n\n /**\n * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)\n * @param componentId\n */\n hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;\n\n /**\n * whether a component is not the same as its head.\n * for a new component, it'll return \"true\" as it has no head yet.\n * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false\n */\n isModified(component: Component): Promise<boolean>;\n\n /**\n * write the component to the filesystem when applicable (no-op for scope).\n * to change the component-path, specify the \"rootPath\", which should be a relative path inside the workspace.\n */\n write(component: Component, rootPath?: string): Promise<void>;\n\n /**\n * determine whether host should be the prior one in case multiple hosts persist.\n */\n priority?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ /// <reference types="node" />
2
+ import { MemoryFS } from '@teambit/any-fs';
3
+ import type { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
4
+ /**
5
+ * The virtual component filesystem
6
+ */
7
+ export default class ComponentFS extends MemoryFS {
8
+ /**
9
+ * array of all fs files.
10
+ */
11
+ readonly files: AbstractVinyl[];
12
+ constructor(
13
+ /**
14
+ * array of all fs files.
15
+ */
16
+ files: AbstractVinyl[]);
17
+ /**
18
+ * hash to represent all contents within this filesystem volume.
19
+ */
20
+ get hash(): string;
21
+ /**
22
+ * filter all component files by regex.
23
+ */
24
+ byRegex(extension: RegExp): AbstractVinyl[];
25
+ /**
26
+ * filter all files using an array of glob patterns.
27
+ */
28
+ byGlob(patterns: string[]): AbstractVinyl[];
29
+ toObject(): {
30
+ path: string;
31
+ contents: Buffer;
32
+ }[];
33
+ static fromVinyls(files: AbstractVinyl[]): ComponentFS;
34
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ export interface IComponent {
3
+ /**
4
+ * id of the component.
5
+ */
6
+ id: ComponentID;
7
+ /**
8
+ * get function to retrieve aspect
9
+ */
10
+ get(aspectId: string): RawComponentMetadata | undefined;
11
+ /**
12
+ * determines whether a component is a modified state.
13
+ * TODO: consider to remove after handling component descriptors correctly.
14
+ */
15
+ isModified(): Promise<boolean>;
16
+ }
17
+ export type RawComponentMetadata = {
18
+ id: string;
19
+ config: Record<string, any>;
20
+ data: Record<string, any>;
21
+ icon?: string;
22
+ };
@@ -0,0 +1,63 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import { Component } from '../component';
3
+ /**
4
+ * allows to index components -> values.
5
+ */
6
+ export declare class ComponentMap<T> {
7
+ readonly hashMap: Map<string, [Component, T]>;
8
+ constructor(hashMap: Map<string, [Component, T]>);
9
+ /**
10
+ * @deprecated please use `get` instead
11
+ */
12
+ byComponent(component: Component): [Component, T] | undefined;
13
+ get components(): Component[];
14
+ /**
15
+ * get a value for a component.
16
+ */
17
+ get(component: Component): [Component, T] | undefined;
18
+ /**
19
+ * get a value by the component-id
20
+ */
21
+ getValueByComponentId(componentId: ComponentID): T | null;
22
+ /**
23
+ * returns an array.
24
+ */
25
+ toArray(): [Component, T][];
26
+ /**
27
+ * map entries and return a new component map.
28
+ */
29
+ map<NewType>(predicate: (value: T, component: Component) => NewType): ComponentMap<NewType>;
30
+ /**
31
+ * map entries and return a new component map.
32
+ */
33
+ asyncMap<NewType>(predicate: (value: T, component: Component) => Promise<NewType>): Promise<ComponentMap<NewType>>;
34
+ /**
35
+ * similar to Array.forEach, but here you get both, the value and the component.
36
+ */
37
+ forEach(predicate: (value: T, component: Component) => void): void;
38
+ /**
39
+ * flatten values of all components into a single array.
40
+ */
41
+ flattenValue(): T[];
42
+ /**
43
+ * filter all components with empty values and return a new map.
44
+ */
45
+ filter(predicate: (value: T) => boolean): ComponentMap<T>;
46
+ /**
47
+ * get all component ids.
48
+ */
49
+ keys(): IterableIterator<string>;
50
+ static create<U>(rawMap: [Component, U][]): ComponentMap<U>;
51
+ /**
52
+ * create a component map from components and a value predicate.
53
+ * @param components components to zip into the map.
54
+ * @param predicate predicate for returning desired value.
55
+ */
56
+ static as<U>(components: Component[], predicate: (component: Component) => U): ComponentMap<U>;
57
+ /**
58
+ * create a component map from components and a value predicate.
59
+ * @param components components to zip into the map.
60
+ * @param predicate predicate for returning desired value.
61
+ */
62
+ static asAsync<U>(components: Component[], predicate: (component: Component) => Promise<U>): Promise<ComponentMap<U>>;
63
+ }
@@ -0,0 +1 @@
1
+ export { ComponentMap } from './component-map';
@@ -0,0 +1,22 @@
1
+ import { ComponentID, ComponentIdObj } from '@teambit/component-id';
2
+ export declare class ComponentMeta {
3
+ /**
4
+ * id the component.
5
+ */
6
+ readonly id: ComponentID;
7
+ constructor(
8
+ /**
9
+ * id the component.
10
+ */
11
+ id: ComponentID);
12
+ /**
13
+ * display name of the component.
14
+ */
15
+ get displayName(): string;
16
+ toObject(): {
17
+ id: ComponentIdObj;
18
+ };
19
+ static from(object: {
20
+ [key: string]: any;
21
+ }): ComponentMeta;
22
+ }
@@ -0,0 +1,3 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const ComponentAspect: Aspect;
3
+ export default ComponentAspect;
@@ -0,0 +1 @@
1
+ export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,183 @@
1
+ import { AnyFS } from '@teambit/any-fs';
2
+ import { SemVer } from 'semver';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import { BuildStatus } from '@teambit/legacy/dist/constants';
5
+ import { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';
6
+ import type { DependencyList } from '@teambit/dependency-resolver';
7
+ import { ComponentFactory } from './component-factory';
8
+ import ComponentFS from './component-fs';
9
+ import { Config as ComponentConfig } from './config';
10
+ import { Snap } from './snap';
11
+ import { State } from './state';
12
+ import { TagMap } from './tag-map';
13
+ import { Tag } from './tag';
14
+ import { IComponent, RawComponentMetadata } from './component-interface';
15
+ type SnapsIterableOpts = {
16
+ firstParentOnly?: boolean;
17
+ stopFn?: (snap: Snap) => Promise<boolean>;
18
+ };
19
+ export type InvalidComponent = {
20
+ id: ComponentID;
21
+ err: Error;
22
+ };
23
+ /**
24
+ * in-memory representation of a component.
25
+ */
26
+ export declare class Component implements IComponent {
27
+ /**
28
+ * component ID represented by the `ComponentId` type.
29
+ */
30
+ readonly id: ComponentID;
31
+ /**
32
+ * head version of the component. can be `null` for new components.
33
+ * if on main, returns the head on main.
34
+ * if on a lane, returns the head on the lane.
35
+ */
36
+ readonly head: Snap | null;
37
+ /**
38
+ * state of the component.
39
+ */
40
+ private _state;
41
+ /**
42
+ * tags of the component.
43
+ */
44
+ readonly tags: TagMap;
45
+ /**
46
+ * the component factory
47
+ */
48
+ private factory;
49
+ constructor(
50
+ /**
51
+ * component ID represented by the `ComponentId` type.
52
+ */
53
+ id: ComponentID,
54
+ /**
55
+ * head version of the component. can be `null` for new components.
56
+ * if on main, returns the head on main.
57
+ * if on a lane, returns the head on the lane.
58
+ */
59
+ head: Snap | null,
60
+ /**
61
+ * state of the component.
62
+ */
63
+ _state: State,
64
+ /**
65
+ * tags of the component.
66
+ */
67
+ tags: TagMap,
68
+ /**
69
+ * the component factory
70
+ */
71
+ factory: ComponentFactory);
72
+ get mainFile(): import("@teambit/legacy/dist/consumer/component/sources").AbstractVinyl;
73
+ get state(): State;
74
+ set state(state: State);
75
+ /**
76
+ * component configuration which is later generated to a component `package.json` and `bit.json`.
77
+ */
78
+ get config(): ComponentConfig;
79
+ /**
80
+ * in-memory representation of the component current filesystem.
81
+ */
82
+ get filesystem(): ComponentFS;
83
+ /**
84
+ * build status of the component
85
+ */
86
+ get buildStatus(): BuildStatus;
87
+ get headTag(): Tag | undefined;
88
+ get latest(): string | undefined;
89
+ /**
90
+ * get aspect data from current state.
91
+ */
92
+ get(id: string): RawComponentMetadata | undefined;
93
+ getLogs(filter?: {
94
+ type?: string;
95
+ offset?: number;
96
+ limit?: number;
97
+ head?: string;
98
+ sort?: string;
99
+ }): Promise<ComponentLog[]>;
100
+ getDependencies(): DependencyList;
101
+ getPackageName(): string;
102
+ stringify(): string;
103
+ /**
104
+ * record component changes in the `Scope`.
105
+ */
106
+ /**
107
+ * display name of the component.
108
+ */
109
+ get displayName(): string;
110
+ /**
111
+ * tag a component `Snap` with a semantic version. we follow SemVer specs as defined [here](https://semver.org/)).
112
+ */
113
+ tag(version: SemVer): void;
114
+ /**
115
+ * determines whether this component is modified in the workspace.
116
+ */
117
+ isModified(): Promise<boolean>;
118
+ /**
119
+ * whether a component is marked as deleted.
120
+ */
121
+ isDeleted(): boolean;
122
+ /**
123
+ * is component isOutdated
124
+ */
125
+ isOutdated(): boolean;
126
+ /**
127
+ * determines whether this component is new.
128
+ */
129
+ isNew(): Promise<boolean>;
130
+ loadState(snapId: string): Promise<State>;
131
+ loadSnap(snapId?: string): Promise<Snap>;
132
+ /**
133
+ * Get iterable which iterate over snap parents lazily
134
+ * @param snapId
135
+ * @param options
136
+ */
137
+ snapsIterable(snapId?: string, options?: SnapsIterableOpts): AsyncIterable<Snap>;
138
+ /**
139
+ * traverse recursively from the provided snap (or head) upwards until it finds a tag
140
+ * @param snapToStartFrom
141
+ */
142
+ getClosestTag(snapToStartFrom?: string): Promise<Tag | undefined>;
143
+ /**
144
+ * id.version can be either a tag or a hash.
145
+ * if it's a hash, it may have a tag point to it. if it does, return the tag.
146
+ */
147
+ getTag(): Tag | undefined;
148
+ /**
149
+ * id.version can be either a tag or a hash.
150
+ * if it's a tag, find the hash it points to.
151
+ */
152
+ getSnapHash(): string | undefined;
153
+ /**
154
+ * in case a component is new, it returns undefined.
155
+ * otherwise, it returns the Snap object (hash/parents/log) of the current component (according to the version in the id)
156
+ */
157
+ getCurrentSnap(): Promise<Snap | undefined>;
158
+ /**
159
+ * checkout the component to a different version in its working tree.
160
+ */
161
+ checkout(version: SemVer): void;
162
+ /**
163
+ * examine difference between two components.
164
+ */
165
+ /**
166
+ * merge two different components
167
+ */
168
+ /**
169
+ * write a component to a given file system.
170
+ * @param path root path to write the component
171
+ * @param fs instance of any fs to use.
172
+ */
173
+ write(path: string, fs?: AnyFS): void;
174
+ /**
175
+ *
176
+ * Check if 2 components are equal
177
+ * @param {Component} component
178
+ * @returns {boolean}
179
+ * @memberof Component
180
+ */
181
+ equals(component: Component): boolean;
182
+ }
183
+ export {};