@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/component.ts DELETED
@@ -1,278 +0,0 @@
1
- import { AnyFS } from '@teambit/any-fs';
2
- import { capitalize } from '@teambit/toolbox.string.capitalize';
3
- import { SemVer } from 'semver';
4
- import { ComponentID } from '@teambit/component-id';
5
- import { BitError } from '@teambit/bit-error';
6
- import { BuildStatus } from '@teambit/legacy/dist/constants';
7
-
8
- import { ComponentFactory } from './component-factory';
9
- import ComponentFS from './component-fs';
10
- // import { NothingToSnap } from './exceptions';
11
- import ComponentConfig from './config';
12
- // eslint-disable-next-line import/no-cycle
13
- import { Snap } from './snap';
14
- import { State } from './state';
15
- import { TagMap } from './tag-map';
16
- import { Tag } from './tag';
17
- import { CouldNotFindLatest } from './exceptions';
18
- // import { Author } from './types';
19
-
20
- type SnapsIterableOpts = {
21
- firstParentOnly?: boolean;
22
- stopFn?: (snap: Snap) => Promise<boolean>;
23
- };
24
-
25
- export type InvalidComponent = { id: ComponentID; err: Error };
26
-
27
- /**
28
- * in-memory representation of a component.
29
- */
30
- export class Component {
31
- constructor(
32
- /**
33
- * component ID represented by the `ComponentId` type.
34
- */
35
- readonly id: ComponentID,
36
-
37
- /**
38
- * head version of the component. can be `null` for new components.
39
- */
40
- readonly head: Snap | null = null,
41
-
42
- /**
43
- * state of the component.
44
- */
45
- private _state: State,
46
-
47
- /**
48
- * tags of the component.
49
- */
50
- readonly tags: TagMap = new TagMap(),
51
-
52
- /**
53
- * the component factory
54
- */
55
- private factory: ComponentFactory
56
- ) {}
57
-
58
- get state(): State {
59
- return this._state;
60
- }
61
-
62
- set state(state: State) {
63
- this._state = state;
64
- }
65
-
66
- /**
67
- * component configuration which is later generated to a component `package.json` and `bit.json`.
68
- */
69
- get config(): ComponentConfig {
70
- return this.state.config;
71
- }
72
-
73
- /**
74
- * in-memory representation of the component current filesystem.
75
- */
76
- get filesystem(): ComponentFS {
77
- return this.state.filesystem;
78
- }
79
-
80
- /**
81
- * build status of the component
82
- */
83
- get buildStatus(): BuildStatus {
84
- return this._state._consumer.buildStatus;
85
- }
86
-
87
- get headTag() {
88
- if (!this.head) return undefined;
89
- return this.tags.byHash(this.head.hash);
90
- }
91
-
92
- get latest(): string | undefined {
93
- if (!this.head) return undefined;
94
- try {
95
- return this.tags.getLatest();
96
- } catch (err: any) {
97
- if (err instanceof CouldNotFindLatest) {
98
- return this.head.toString();
99
- }
100
- throw err;
101
- }
102
- }
103
-
104
- stringify(): string {
105
- return JSON.stringify({
106
- id: this.id,
107
- head: this.head,
108
- });
109
- }
110
-
111
- /**
112
- * record component changes in the `Scope`.
113
- */
114
- // snap(author: Author, message = '') {
115
- // if (!this.isModified()) throw new NothingToSnap();
116
- // const snap = new Snap(this, author, message);
117
-
118
- // return new Component(this.id, snap, snap.state);
119
- // }
120
-
121
- /**
122
- * display name of the component.
123
- */
124
- get displayName() {
125
- const tokens = this.id.name.split('-').map((token) => capitalize(token));
126
- return tokens.join(' ');
127
- }
128
-
129
- /**
130
- * tag a component `Snap` with a semantic version. we follow SemVer specs as defined [here](https://semver.org/)).
131
- */
132
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
133
- tag(version: SemVer) {
134
- // const snap = this.snap();
135
- // const tag = new Tag(version, snap);
136
- // this.tags.set(tag);
137
- }
138
-
139
- /**
140
- * determines whether this component is modified in the workspace.
141
- */
142
- isModified(): Promise<boolean> {
143
- if (!this.head) return Promise.resolve(true);
144
- return Promise.resolve(this.state.isModified);
145
- // return Promise.resolve(this.state.hash !== this.head.hash);
146
- }
147
-
148
- /**
149
- * is component isOutdated
150
- */
151
- isOutdated(): boolean {
152
- if (!this.latest) return false;
153
- const latestTag = this.tags.byVersion(this.latest);
154
- if (!latestTag) return false;
155
- if (this.head?.hash !== latestTag?.hash) return true;
156
- return false;
157
- }
158
-
159
- /**
160
- * determines whether this component is new.
161
- */
162
- isNew(): Promise<boolean> {
163
- return Promise.resolve(this.head === null);
164
- }
165
-
166
- // TODO: @david after snap we need to make sure to refactor here.
167
- loadState(snapId: string): Promise<State> {
168
- return this.factory.getState(this.id, snapId);
169
- }
170
-
171
- loadSnap(snapId?: string): Promise<Snap> {
172
- const snapToGet = snapId || this.head?.hash;
173
- if (!snapToGet) {
174
- throw new BitError('could not load snap for new components');
175
- }
176
- return this.factory.getSnap(this.id, snapToGet);
177
- }
178
-
179
- /**
180
- * Get iterable which iterate over snap parents lazily
181
- * @param snapId
182
- * @param options
183
- */
184
- snapsIterable(snapId?: string, options: SnapsIterableOpts = {}): AsyncIterable<Snap> {
185
- const snapToStart = snapId || this.head?.hash;
186
- let nextSnaps = [snapToStart];
187
- let done;
188
- if (!snapToStart) {
189
- done = true;
190
- }
191
-
192
- const iterator: AsyncIterator<Snap> = {
193
- next: async () => {
194
- if (done) {
195
- return { value: undefined, done };
196
- }
197
- const currSnapId = nextSnaps.shift();
198
- const snap = await this.loadSnap(currSnapId);
199
- if (snap.parents && snap.parents.length) {
200
- if (options.firstParentOnly) {
201
- nextSnaps.push(snap.parents[0]);
202
- } else {
203
- nextSnaps = nextSnaps.concat(snap.parents);
204
- }
205
- }
206
- if (!nextSnaps.length) {
207
- done = true;
208
- } else if (options.stopFn) {
209
- done = await options.stopFn(snap);
210
- }
211
- return { value: snap, done: undefined };
212
- },
213
- };
214
- return {
215
- [Symbol.asyncIterator]: () => iterator,
216
- };
217
- }
218
-
219
- /**
220
- * traverse recursively from the provided snap (or head) upwards until it finds a tag
221
- * @param snapToStartFrom
222
- */
223
- async getClosestTag(snapToStartFrom?: string): Promise<Tag | undefined> {
224
- const tagsHashMap = this.tags.getHashMap();
225
- const stopFn = async (snap: Snap) => {
226
- if (tagsHashMap.has(snap.hash)) {
227
- return true;
228
- }
229
- return false;
230
- };
231
- const iterable = this.snapsIterable(snapToStartFrom, { firstParentOnly: true, stopFn });
232
- const snaps: Snap[] = [];
233
- for await (const snap of iterable) {
234
- snaps.push(snap);
235
- }
236
- if (snaps.length) {
237
- const hashOfLastSnap = snaps[snaps.length - 1].hash;
238
- return tagsHashMap.get(hashOfLastSnap);
239
- }
240
- return undefined;
241
- }
242
-
243
- /**
244
- * checkout the component to a different version in its working tree.
245
- */
246
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
247
- checkout(version: SemVer) {}
248
-
249
- /**
250
- * examine difference between two components.
251
- */
252
- // diff(other: Component): Difference {}
253
-
254
- /**
255
- * merge two different components
256
- */
257
- // merge(other: Component): Component {}
258
-
259
- /**
260
- * write a component to a given file system.
261
- * @param path root path to write the component
262
- * @param fs instance of any fs to use.
263
- */
264
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
265
- write(path: string, fs?: AnyFS) {}
266
-
267
- /**
268
- *
269
- * Check if 2 components are equal
270
- * @param {Component} component
271
- * @returns {boolean}
272
- * @memberof Component
273
- */
274
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
275
- equals(component: Component): boolean {
276
- return component.id.toString() === this.id.toString();
277
- }
278
- }
@@ -1,216 +0,0 @@
1
- import PubsubAspect, { PubsubUI, BitBaseEvent } from '@teambit/pubsub';
2
- import PreviewAspect, { ClickInsideAnIframeEvent } from '@teambit/preview';
3
- import { MenuItemSlot, MenuItem } from '@teambit/ui-foundation.ui.main-dropdown';
4
- import { Slot } from '@teambit/harmony';
5
- import { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
6
- import { NavLinkProps } from '@teambit/base-ui.routing.nav-link';
7
- import { UIRuntime } from '@teambit/ui';
8
- import { isBrowser } from '@teambit/ui-foundation.ui.is-browser';
9
- import React from 'react';
10
- import { RouteProps } from 'react-router-dom';
11
- import CommandBarAspect, { CommandBarUI, CommandEntry } from '@teambit/command-bar';
12
- import copy from 'copy-to-clipboard';
13
- import { ComponentAspect } from './component.aspect';
14
- import { Component, ComponentPageElement, ComponentPageSlot } from './ui/component';
15
- import { Menu, NavPlugin, OrderedNavigationSlot } from './ui/menu';
16
- import { AspectSection } from './aspect.section';
17
- import { ComponentModel } from './ui';
18
-
19
- export type Server = {
20
- env: string;
21
- url: string;
22
- };
23
-
24
- export type ComponentMeta = {
25
- id: string;
26
- };
27
-
28
- export const componentIdUrlRegex = '[\\w\\/-]*[\\w-]';
29
-
30
- export class ComponentUI {
31
- readonly routePath = `/:componentId(${componentIdUrlRegex})`;
32
-
33
- constructor(
34
- /**
35
- * Pubsub aspects
36
- */
37
- private pubsub: PubsubUI,
38
-
39
- private routeSlot: RouteSlot,
40
-
41
- private navSlot: OrderedNavigationSlot,
42
-
43
- /**
44
- * slot for registering a new widget to the menu.
45
- */
46
- private widgetSlot: OrderedNavigationSlot,
47
-
48
- private menuItemSlot: MenuItemSlot,
49
-
50
- private pageItemSlot: ComponentPageSlot,
51
-
52
- private commandBarUI: CommandBarUI
53
- ) {
54
- if (isBrowser) this.registerPubSub();
55
- }
56
-
57
- /**
58
- * the current visible component
59
- */
60
- private activeComponent?: ComponentModel;
61
-
62
- private copyNpmId = () => {
63
- const packageName = this.activeComponent?.packageName;
64
- if (packageName) {
65
- const version = this.activeComponent?.id.version;
66
- const versionString = version ? `@${version}` : '';
67
- copy(`${packageName}${versionString}`);
68
- }
69
- };
70
-
71
- /**
72
- * key bindings used by component aspect
73
- */
74
- private keyBindings: CommandEntry[] = [
75
- {
76
- id: 'component.copyBitId', // TODO - extract to a component!
77
- handler: () => {
78
- copy(this.activeComponent?.id.toString() || '');
79
- },
80
- displayName: 'Copy component ID',
81
- keybinding: '.',
82
- },
83
- {
84
- id: 'component.copyNpmId', // TODO - extract to a component!
85
- handler: this.copyNpmId,
86
- displayName: 'Copy component package name',
87
- keybinding: ',',
88
- },
89
- ];
90
-
91
- private menuItems: MenuItem[] = [
92
- {
93
- category: 'general',
94
- title: 'Open command bar',
95
- keyChar: 'mod+k',
96
- handler: () => this.commandBarUI?.run('command-bar.open'),
97
- },
98
- {
99
- category: 'general',
100
- title: 'Toggle component list',
101
- keyChar: 'alt+s',
102
- handler: () => this.commandBarUI?.run('sidebar.toggle'),
103
- },
104
- {
105
- category: 'workflow',
106
- title: 'Copy component ID',
107
- keyChar: '.',
108
- handler: () => this.commandBarUI?.run('component.copyBitId'),
109
- },
110
- {
111
- category: 'workflow',
112
- title: 'Copy component package name',
113
- keyChar: ',',
114
- handler: () => this.commandBarUI?.run('component.copyNpmId'),
115
- },
116
- ];
117
-
118
- registerPubSub() {
119
- this.pubsub.sub(PreviewAspect.id, (be: BitBaseEvent<any>) => {
120
- if (be.type === ClickInsideAnIframeEvent.TYPE) {
121
- const event = new MouseEvent('mousedown', {
122
- view: window,
123
- bubbles: true,
124
- cancelable: true,
125
- });
126
-
127
- const body = document.body;
128
- body?.dispatchEvent(event);
129
- }
130
- });
131
- }
132
-
133
- handleComponentChange = (activeComponent?: ComponentModel) => {
134
- this.activeComponent = activeComponent;
135
- };
136
-
137
- getComponentUI(host: string) {
138
- return (
139
- <Component
140
- routeSlot={this.routeSlot}
141
- containerSlot={this.pageItemSlot}
142
- onComponentChange={this.handleComponentChange}
143
- host={host}
144
- />
145
- );
146
- }
147
-
148
- getMenu(host: string) {
149
- return (
150
- <Menu navigationSlot={this.navSlot} widgetSlot={this.widgetSlot} host={host} menuItemSlot={this.menuItemSlot} />
151
- );
152
- }
153
-
154
- registerRoute(route: RouteProps) {
155
- this.routeSlot.register(route);
156
- return this;
157
- }
158
-
159
- registerNavigation(nav: NavLinkProps, order?: number) {
160
- this.navSlot.register({
161
- props: nav,
162
- order,
163
- });
164
- }
165
-
166
- registerWidget(widget: NavLinkProps, order?: number) {
167
- this.widgetSlot.register({ props: widget, order });
168
- }
169
-
170
- registerMenuItem = (menuItems: MenuItem[]) => {
171
- this.menuItemSlot.register(menuItems);
172
- };
173
-
174
- registerPageItem = (...items: ComponentPageElement[]) => {
175
- this.pageItemSlot.register(items);
176
- };
177
-
178
- static dependencies = [PubsubAspect, CommandBarAspect];
179
-
180
- static runtime = UIRuntime;
181
-
182
- static slots = [
183
- Slot.withType<RouteProps>(),
184
- Slot.withType<NavPlugin>(),
185
- Slot.withType<NavigationSlot>(),
186
- Slot.withType<MenuItemSlot>(),
187
- Slot.withType<ComponentPageSlot>(),
188
- ];
189
-
190
- static async provider(
191
- [pubsub, commandBarUI]: [PubsubUI, CommandBarUI],
192
- config,
193
- [routeSlot, navSlot, widgetSlot, menuItemSlot, pageSlot]: [
194
- RouteSlot,
195
- OrderedNavigationSlot,
196
- OrderedNavigationSlot,
197
- MenuItemSlot,
198
- ComponentPageSlot
199
- ]
200
- ) {
201
- // TODO: refactor ComponentHost to a separate extension (including sidebar, host, graphql, etc.)
202
- // TODO: add contextual hook for ComponentHost @uri/@oded
203
- const componentUI = new ComponentUI(pubsub, routeSlot, navSlot, widgetSlot, menuItemSlot, pageSlot, commandBarUI);
204
- const section = new AspectSection();
205
-
206
- componentUI.commandBarUI.addCommand(...componentUI.keyBindings);
207
- componentUI.registerMenuItem(componentUI.menuItems);
208
- componentUI.registerRoute(section.route);
209
- componentUI.registerWidget(section.navigationLink, section.order);
210
- return componentUI;
211
- }
212
- }
213
-
214
- export default ComponentUI;
215
-
216
- ComponentAspect.addRuntime(ComponentUI);
package/config.ts DELETED
@@ -1,34 +0,0 @@
1
- import { Compilers, Testers } from '@teambit/legacy/dist/consumer/config/abstract-config';
2
- import { ComponentOverridesData } from '@teambit/legacy/dist/consumer/config/component-overrides';
3
- import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
4
- import { PathLinux } from '@teambit/legacy/dist/utils/path';
5
- // import { CustomResolvedPath } from '@teambit/legacy/dist/consumer/component/consumer-component';
6
- // import { ComponentOverridesData } from '@teambit/legacy/dist/consumer/config/component-overrides';
7
-
8
- type LegacyConfigProps = {
9
- lang?: string;
10
- compiler?: string | Compilers;
11
- tester?: string | Testers;
12
- bindingPrefix: string;
13
- extensions?: ExtensionDataList;
14
- overrides?: ComponentOverridesData;
15
- };
16
-
17
- /**
18
- * in-memory representation of the component configuration.
19
- */
20
- export default class Config {
21
- constructor(
22
- /**
23
- * version main file
24
- */
25
- readonly main: PathLinux,
26
-
27
- /**
28
- * configured extensions
29
- */
30
- readonly extensions: ExtensionDataList,
31
-
32
- readonly legacyProperties?: LegacyConfigProps
33
- ) {}
34
- }
@@ -1,74 +0,0 @@
1
- /* eslint-disable max-classes-per-file */
2
- import { BitError } from '@teambit/bit-error';
3
- import { BitId } from '@teambit/legacy-bit-id';
4
-
5
- const DEV_ENV = 'development';
6
- const RUNTIME_ENV = 'runtime';
7
-
8
- // type Environment = DEV_ENV | RUNTIME_ENV;
9
- type Environment = 'development' | 'runtime';
10
- // type WrappingMethod = 'component' | 'package';
11
-
12
- export class DependencyId extends BitId {}
13
-
14
- export class Dependency {
15
- constructor(public id: DependencyId) {}
16
- }
17
-
18
- export class PackageDependency extends Dependency {}
19
-
20
- export class ComponentDependency extends Dependency {}
21
-
22
- export class DependencyList extends Array<Dependency> {
23
- /**
24
- * Get only package dependencies
25
- *
26
- * @readonly
27
- * @memberof DependencyList
28
- */
29
- get packages(): PackageDependency[] {
30
- return this.filter((dep) => dep instanceof PackageDependency);
31
- }
32
-
33
- get components(): ComponentDependency[] {
34
- return this.filter((dep) => dep instanceof ComponentDependency);
35
- }
36
-
37
- static fromArray(dependencies: Dependency[]): DependencyList {
38
- return new DependencyList(...dependencies);
39
- }
40
- }
41
-
42
- export class Dependencies {
43
- constructor(public runtime: DependencyList, public dev: DependencyList, public peer: DependencyList) {}
44
-
45
- private getByEnvironment(env: Environment): DependencyList {
46
- if (env === DEV_ENV) {
47
- return DependencyList.fromArray(this.runtime.concat(this.dev).concat(this.peer));
48
- }
49
- if (env === RUNTIME_ENV) {
50
- return DependencyList.fromArray(this.runtime.concat(this.peer));
51
- }
52
- throw new BitError(`env ${env} is not supported`);
53
- }
54
-
55
- /**
56
- * Get dependencies needed for development environnement such as runtime, dev and peer
57
- *
58
- * @returns {DependencyList}
59
- * @memberof Dependencies
60
- */
61
- computeDev(): DependencyList {
62
- return this.getByEnvironment(DEV_ENV);
63
- }
64
-
65
- /**
66
- * Get dependencies needed for runtime environnement such as runtime and peer
67
- *
68
- * @returns {DependencyList}
69
- * @memberof Dependencies
70
- */
71
- computeRuntime(): DependencyList {
72
- return this.getByEnvironment(RUNTIME_ENV);
73
- }
74
- }
@@ -1 +0,0 @@
1
- export { Dependencies } from './dependencies';
@@ -1,8 +0,0 @@
1
- export class CouldNotFindLatest extends Error {
2
- constructor(semverArray: string[]) {
3
- super(`could not find latest semver in array: ${semverArray.join(', ')}`);
4
- }
5
- report() {
6
- return this.message;
7
- }
8
- }
@@ -1,14 +0,0 @@
1
- export class HostNotFound extends Error {
2
- constructor(
3
- /**
4
- * name of the host.
5
- */
6
- private hostName: string
7
- ) {
8
- super();
9
- }
10
-
11
- toString() {
12
- return `[component] error: host '${this.hostName}' was not found`;
13
- }
14
- }
@@ -1,4 +0,0 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
- export { default as NothingToSnap } from './nothing-to-snap';
3
- export { HostNotFound } from './host-not-found';
4
- export { CouldNotFindLatest } from './could-not-find-latest';
@@ -1 +0,0 @@
1
- export default class NothingToSnap extends Error {}
package/hash.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * type for representing content-addressable filesystem hashes.
3
- */
4
- export type Hash = string;
package/head.ts DELETED
File without changes
package/history-graph.ts DELETED
@@ -1 +0,0 @@
1
- export default class HistoryGraph {}
@@ -1,9 +0,0 @@
1
- import { ComponentModel } from '../ui';
2
-
3
- export class ComponentHostModel {
4
- constructor(readonly name: string, readonly components: ComponentModel[]) {}
5
-
6
- static from(data: any) {
7
- return new ComponentHostModel(data.getHost.name, ComponentModel.fromArray(data.getHost.list));
8
- }
9
- }
package/host/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { useComponentHost } from './use-component-host';
2
- export * from './component-host-model';
@@ -1,39 +0,0 @@
1
- import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
2
- import { gql } from '@apollo/client';
3
-
4
- import { ComponentHostModel } from './component-host-model';
5
-
6
- const COMPONENT_HOST = gql`
7
- {
8
- getHost {
9
- id # used for GQL caching
10
- name
11
- list {
12
- id {
13
- name
14
- version
15
- scope
16
- }
17
- deprecation {
18
- isDeprecate
19
- }
20
- env {
21
- id
22
- icon
23
- }
24
- }
25
- }
26
- }
27
- `;
28
-
29
- export function useComponentHost() {
30
- const { data, loading } = useDataQuery(COMPONENT_HOST);
31
-
32
- if (!data || loading) {
33
- return {};
34
- }
35
-
36
- const host = ComponentHostModel.from(data);
37
-
38
- return { host };
39
- }