@teambit/component 0.0.560 → 0.0.561

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.
@@ -52,9 +52,10 @@ export interface ComponentFactory {
52
52
  */
53
53
  getSnap(id: ComponentID, snapId: string): Promise<Snap>;
54
54
  /**
55
- * load extension.
55
+ * load aspects.
56
+ * returns the loaded aspect ids including the loaded versions.
56
57
  */
57
- loadAspects: (ids: string[], throwOnError: boolean) => Promise<void>;
58
+ loadAspects: (ids: string[], throwOnError: boolean) => Promise<string[]>;
58
59
  /**
59
60
  * Resolve dirs for aspects
60
61
  */
@@ -2,7 +2,7 @@ import { CLIMain } from '@teambit/cli';
2
2
  import { ExpressMain, Route } from '@teambit/express';
3
3
  import { GraphqlMain } from '@teambit/graphql';
4
4
  import { SlotRegistry } from '@teambit/harmony';
5
- import { Config } from '@teambit/config';
5
+ import type { ConfigMain } from '@teambit/config';
6
6
  import { ComponentID } from '@teambit/component-id';
7
7
  import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';
8
8
  import { ComponentFactory } from './component-factory';
@@ -60,5 +60,5 @@ export declare class ComponentMain {
60
60
  static slots: (((registerFn: () => string) => SlotRegistry<Route[]>) | ((registerFn: () => string) => SlotRegistry<ComponentFactory>) | ((registerFn: () => string) => SlotRegistry<ShowFragment[]>))[];
61
61
  static runtime: import("@teambit/harmony").RuntimeDefinition;
62
62
  static dependencies: import("@teambit/harmony").Aspect[];
63
- static provider([graphql, express, cli, configAspect]: [GraphqlMain, ExpressMain, CLIMain, Config], config: any, [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]): Promise<ComponentMain>;
63
+ static provider([graphql, express, cli, configAspect]: [GraphqlMain, ExpressMain, CLIMain, ConfigMain], config: any, [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]): Promise<ComponentMain>;
64
64
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["component.main.runtime.ts"],"names":["ComponentMain","constructor","hostSlot","express","showFragmentSlot","registerHost","host","register","createAspectList","legacyExtensionDataList","scope","AspectList","fromLegacyExtensions","createAspectListFromEntries","entries","registerRoute","routes","routeEntries","map","route","ComponentRoute","setHostPriority","id","get","HostNotFound","_priorHost","getHost","getPriorHost","getRoute","routeName","toString","hosts","values","priorityHost","find","priority","getShowFragments","fragments","isHost","name","registerShowFragments","showFragments","provider","graphql","cli","configAspect","config","componentExtension","workspaceConfig","isLegacy","type","unregister","ShowCmd","NameFragment","MainFileFragment","IDFragment","ScopeFragment","FilesFragment","ExtensionsFragment","Slot","withType","MainRuntime","GraphqlAspect","ExpressAspect","CLIAspect","ConfigAspect","ComponentAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAeO,MAAMA,aAAN,CAAoB;AACzBC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,QAJC;AAMT;AACJ;AACA;AACYC,EAAAA,OATC,EAWDC,gBAXC,EAYT;AAAA,SARQF,QAQR,GARQA,QAQR;AAAA,SAHQC,OAGR,GAHQA,OAGR;AAAA,SADQC,gBACR,GADQA,gBACR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AsB,OAAtG,EAA+G;AAC7GN,MAAAA,GAAG,CAACO,UAAJ,CAAe,MAAf;AACAP,MAAAA,GAAG,CAACrC,QAAJ,CAAa,KAAI6C,eAAJ,EAAYL,kBAAZ,CAAb;AACD;;AAEDA,IAAAA,kBAAkB,CAACP,qBAAnB,CAAyC,CACvC,KAAIa,oBAAJ,GADuC,EAEvC,KAAIC,wBAAJ,GAFuC,EAGvC,KAAIC,kBAAJ,GAHuC,EAIvC,KAAIC,qBAAJ,GAJuC,EAKvC,KAAIC,qBAAJ,GALuC,EAMvC,KAAIC,0BAAJ,GANuC,CAAzC;AAQAf,IAAAA,OAAO,CAACpC,QAAR,CAAiB,mCAAgBwC,kBAAhB,CAAjB;AAEA,WAAOA,kBAAP;AACD;;AAhIwB;;;gCAAd/C,a,WAoGI,CAAC2D,gBAAKC,QAAL,EAAD,EAAoCD,gBAAKC,QAAL,EAApC,EAA8DD,gBAAKC,QAAL,EAA9D,C;gCApGJ5D,a,aAsGM6D,kB;gCAtGN7D,a,kBAuGW,CAAC8D,wBAAD,EAAgBC,wBAAhB,EAA+BC,gBAA/B,EAA0CC,sBAA1C,C;;AA4BxBC,6BAAgBC,UAAhB,CAA2BnE,aAA3B","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain, Route } from '@teambit/express';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ConfigAspect, Config } from '@teambit/config';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, orderBy } from 'lodash';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { ComponentFactory } from './component-factory';\nimport { ComponentAspect } from './component.aspect';\nimport { componentSchema } from './component.graphql';\nimport { ComponentRoute } from './component.route';\nimport { AspectList } from './aspect-list';\nimport { HostNotFound } from './exceptions';\nimport { AspectEntry } from './aspect-entry';\nimport {\n ShowCmd,\n ShowFragment,\n NameFragment,\n MainFileFragment,\n IDFragment,\n ScopeFragment,\n FilesFragment,\n ExtensionsFragment,\n} from './show';\n\nexport type ComponentHostSlot = SlotRegistry<ComponentFactory>;\n\nexport type ShowFragmentSlot = SlotRegistry<ShowFragment[]>;\n\nexport class ComponentMain {\n constructor(\n /**\n * slot for component hosts to register.\n */\n private hostSlot: ComponentHostSlot,\n\n /**\n * Express Extension\n */\n private express: ExpressMain,\n\n private showFragmentSlot: ShowFragmentSlot\n ) {}\n\n /**\n * register a new component host.\n */\n registerHost(host: ComponentFactory) {\n this.hostSlot.register(host);\n return this;\n }\n\n createAspectList(legacyExtensionDataList: ExtensionDataList, scope?: string) {\n return AspectList.fromLegacyExtensions(legacyExtensionDataList, scope);\n }\n\n createAspectListFromEntries(entries: AspectEntry[]) {\n return new AspectList(entries);\n }\n\n registerRoute(routes: Route[]) {\n const routeEntries = routes.map((route: Route) => {\n return new ComponentRoute(route, this);\n });\n\n this.express.register(flatten(routeEntries));\n return this;\n }\n\n /**\n * set the prior host.\n */\n setHostPriority(id: string) {\n const host = this.hostSlot.get(id);\n if (!host) {\n throw new HostNotFound(id);\n }\n\n this._priorHost = host;\n return this;\n }\n\n /**\n * get component host by extension ID.\n */\n getHost(id?: string): ComponentFactory {\n if (id) {\n const host = this.hostSlot.get(id);\n if (!host) throw new HostNotFound(id);\n return host;\n }\n\n return this.getPriorHost();\n }\n\n getRoute(id: ComponentID, routeName: string) {\n return `/api/${id.toString()}/~aspect/${routeName}`;\n }\n\n /**\n * get the prior host.\n */\n private getPriorHost() {\n if (this._priorHost) return this._priorHost;\n\n const hosts = this.hostSlot.values();\n const priorityHost = hosts.find((host) => host.priority);\n return priorityHost || hosts[0];\n }\n\n getShowFragments() {\n const fragments = orderBy(flatten(this.showFragmentSlot.values()), ['weight', ['asc']]);\n return fragments;\n }\n\n isHost(name: string) {\n return !!this.hostSlot.get(name);\n }\n\n /**\n * register a show fragment to display further information in the `bit show` command.\n */\n registerShowFragments(showFragments: ShowFragment[]) {\n this.showFragmentSlot.register(showFragments);\n return this;\n }\n\n private _priorHost: ComponentFactory | undefined;\n\n static slots = [Slot.withType<ComponentFactory>(), Slot.withType<Route[]>(), Slot.withType<ShowFragment[]>()];\n\n static runtime = MainRuntime;\n static dependencies = [GraphqlAspect, ExpressAspect, CLIAspect, ConfigAspect];\n\n static async provider(\n [graphql, express, cli, configAspect]: [GraphqlMain, ExpressMain, CLIMain, Config],\n config,\n [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]\n ) {\n const componentExtension = new ComponentMain(hostSlot, express, showFragmentSlot);\n\n if ((configAspect.workspaceConfig && !configAspect.workspaceConfig.isLegacy) || configAspect.type === 'scope') {\n cli.unregister('show');\n cli.register(new ShowCmd(componentExtension));\n }\n\n componentExtension.registerShowFragments([\n new NameFragment(),\n new MainFileFragment(),\n new IDFragment(),\n new ScopeFragment(),\n new FilesFragment(),\n new ExtensionsFragment(),\n ]);\n graphql.register(componentSchema(componentExtension));\n\n return componentExtension;\n }\n}\n\nComponentAspect.addRuntime(ComponentMain);\n"]}
1
+ {"version":3,"sources":["component.main.runtime.ts"],"names":["ComponentMain","constructor","hostSlot","express","showFragmentSlot","registerHost","host","register","createAspectList","legacyExtensionDataList","scope","AspectList","fromLegacyExtensions","createAspectListFromEntries","entries","registerRoute","routes","routeEntries","map","route","ComponentRoute","setHostPriority","id","get","HostNotFound","_priorHost","getHost","getPriorHost","getRoute","routeName","toString","hosts","values","priorityHost","find","priority","getShowFragments","fragments","isHost","name","registerShowFragments","showFragments","provider","graphql","cli","configAspect","config","componentExtension","workspaceConfig","isLegacy","type","unregister","ShowCmd","NameFragment","MainFileFragment","IDFragment","ScopeFragment","FilesFragment","ExtensionsFragment","Slot","withType","MainRuntime","GraphqlAspect","ExpressAspect","CLIAspect","ConfigAspect","ComponentAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;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,EAAD,EAAoCD,gBAAKC,QAAL,EAApC,EAA8DD,gBAAKC,QAAL,EAA9D,C;gCApGJ5D,a,aAsGM6D,kB;gCAtGN7D,a,kBAuGW,CAAC8D,wBAAD,EAAgBC,wBAAhB,EAA+BC,gBAA/B,EAA0CC,sBAA1C,C;;AA4BxBC,6BAAgBC,UAAhB,CAA2BnE,aAA3B","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ExpressAspect, ExpressMain, Route } from '@teambit/express';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ConfigAspect } from '@teambit/config';\nimport type { ConfigMain } from '@teambit/config';\nimport { ComponentID } from '@teambit/component-id';\nimport { flatten, orderBy } from 'lodash';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { ComponentFactory } from './component-factory';\nimport { ComponentAspect } from './component.aspect';\nimport { componentSchema } from './component.graphql';\nimport { ComponentRoute } from './component.route';\nimport { AspectList } from './aspect-list';\nimport { HostNotFound } from './exceptions';\nimport { AspectEntry } from './aspect-entry';\nimport {\n ShowCmd,\n ShowFragment,\n NameFragment,\n MainFileFragment,\n IDFragment,\n ScopeFragment,\n FilesFragment,\n ExtensionsFragment,\n} from './show';\n\nexport type ComponentHostSlot = SlotRegistry<ComponentFactory>;\n\nexport type ShowFragmentSlot = SlotRegistry<ShowFragment[]>;\n\nexport class ComponentMain {\n constructor(\n /**\n * slot for component hosts to register.\n */\n private hostSlot: ComponentHostSlot,\n\n /**\n * Express Extension\n */\n private express: ExpressMain,\n\n private showFragmentSlot: ShowFragmentSlot\n ) {}\n\n /**\n * register a new component host.\n */\n registerHost(host: ComponentFactory) {\n this.hostSlot.register(host);\n return this;\n }\n\n createAspectList(legacyExtensionDataList: ExtensionDataList, scope?: string) {\n return AspectList.fromLegacyExtensions(legacyExtensionDataList, scope);\n }\n\n createAspectListFromEntries(entries: AspectEntry[]) {\n return new AspectList(entries);\n }\n\n registerRoute(routes: Route[]) {\n const routeEntries = routes.map((route: Route) => {\n return new ComponentRoute(route, this);\n });\n\n this.express.register(flatten(routeEntries));\n return this;\n }\n\n /**\n * set the prior host.\n */\n setHostPriority(id: string) {\n const host = this.hostSlot.get(id);\n if (!host) {\n throw new HostNotFound(id);\n }\n\n this._priorHost = host;\n return this;\n }\n\n /**\n * get component host by extension ID.\n */\n getHost(id?: string): ComponentFactory {\n if (id) {\n const host = this.hostSlot.get(id);\n if (!host) throw new HostNotFound(id);\n return host;\n }\n\n return this.getPriorHost();\n }\n\n getRoute(id: ComponentID, routeName: string) {\n return `/api/${id.toString()}/~aspect/${routeName}`;\n }\n\n /**\n * get the prior host.\n */\n private getPriorHost() {\n if (this._priorHost) return this._priorHost;\n\n const hosts = this.hostSlot.values();\n const priorityHost = hosts.find((host) => host.priority);\n return priorityHost || hosts[0];\n }\n\n getShowFragments() {\n const fragments = orderBy(flatten(this.showFragmentSlot.values()), ['weight', ['asc']]);\n return fragments;\n }\n\n isHost(name: string) {\n return !!this.hostSlot.get(name);\n }\n\n /**\n * register a show fragment to display further information in the `bit show` command.\n */\n registerShowFragments(showFragments: ShowFragment[]) {\n this.showFragmentSlot.register(showFragments);\n return this;\n }\n\n private _priorHost: ComponentFactory | undefined;\n\n static slots = [Slot.withType<ComponentFactory>(), Slot.withType<Route[]>(), Slot.withType<ShowFragment[]>()];\n\n static runtime = MainRuntime;\n static dependencies = [GraphqlAspect, ExpressAspect, CLIAspect, ConfigAspect];\n\n static async provider(\n [graphql, express, cli, configAspect]: [GraphqlMain, ExpressMain, CLIMain, ConfigMain],\n config,\n [hostSlot, showFragmentSlot]: [ComponentHostSlot, ShowFragmentSlot]\n ) {\n const componentExtension = new ComponentMain(hostSlot, express, showFragmentSlot);\n\n if ((configAspect.workspaceConfig && !configAspect.workspaceConfig.isLegacy) || configAspect.type === 'scope') {\n cli.unregister('show');\n cli.register(new ShowCmd(componentExtension));\n }\n\n componentExtension.registerShowFragments([\n new NameFragment(),\n new MainFileFragment(),\n new IDFragment(),\n new ScopeFragment(),\n new FilesFragment(),\n new ExtensionsFragment(),\n ]);\n graphql.register(componentSchema(componentExtension));\n\n return componentExtension;\n }\n}\n\nComponentAspect.addRuntime(ComponentMain);\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/component",
3
- "version": "0.0.560",
3
+ "version": "0.0.561",
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.560"
9
+ "version": "0.0.561"
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.379",
30
- "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.468",
31
- "@teambit/aspect-loader": "0.0.560",
32
- "@teambit/legacy-bit-id": "0.0.378",
33
- "@teambit/toolbox.string.capitalize": "0.0.463",
34
- "@teambit/cli": "0.0.389",
35
- "@teambit/config": "0.0.400",
36
- "@teambit/express": "0.0.478",
37
- "@teambit/graphql": "0.0.560",
38
- "@teambit/bit-error": "0.0.375",
39
- "@teambit/command-bar": "0.0.560",
40
- "@teambit/preview": "0.0.560",
41
- "@teambit/pubsub": "0.0.560",
42
- "@teambit/ui-foundation.ui.is-browser": "0.0.466",
43
- "@teambit/ui-foundation.ui.main-dropdown": "0.0.466",
44
- "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.468",
45
- "@teambit/ui": "0.0.560",
46
- "@teambit/component-issues": "0.0.24",
47
- "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.467",
48
- "@teambit/cli-table": "0.0.12",
49
- "@teambit/ui-foundation.ui.react-router.use-query": "0.0.466",
29
+ "@teambit/component-id": "0.0.380",
30
+ "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.469",
31
+ "@teambit/aspect-loader": "0.0.561",
32
+ "@teambit/legacy-bit-id": "0.0.379",
33
+ "@teambit/toolbox.string.capitalize": "0.0.464",
34
+ "@teambit/cli": "0.0.390",
35
+ "@teambit/config": "0.0.401",
36
+ "@teambit/express": "0.0.479",
37
+ "@teambit/graphql": "0.0.561",
38
+ "@teambit/bit-error": "0.0.376",
39
+ "@teambit/command-bar": "0.0.561",
40
+ "@teambit/preview": "0.0.561",
41
+ "@teambit/pubsub": "0.0.561",
42
+ "@teambit/ui-foundation.ui.is-browser": "0.0.467",
43
+ "@teambit/ui-foundation.ui.main-dropdown": "0.0.467",
44
+ "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.469",
45
+ "@teambit/ui": "0.0.561",
46
+ "@teambit/component-issues": "0.0.25",
47
+ "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.468",
48
+ "@teambit/cli-table": "0.0.13",
49
+ "@teambit/ui-foundation.ui.react-router.use-query": "0.0.467",
50
50
  "@teambit/design.ui.empty-box": "0.0.352",
51
- "@teambit/harmony.ui.aspect-box": "0.0.466",
51
+ "@teambit/harmony.ui.aspect-box": "0.0.467",
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.560",
55
- "@teambit/deprecation": "0.0.560",
56
- "@teambit/envs": "0.0.560",
57
- "@teambit/component.ui.version-dropdown": "0.0.470",
58
- "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.87",
59
- "@teambit/ui-foundation.ui.use-box.menu": "0.0.87",
60
- "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.466"
54
+ "@teambit/compositions": "0.0.561",
55
+ "@teambit/deprecation": "0.0.561",
56
+ "@teambit/envs": "0.0.561",
57
+ "@teambit/component.ui.version-dropdown": "0.0.471",
58
+ "@teambit/ui-foundation.ui.use-box.dropdown": "0.0.88",
59
+ "@teambit/ui-foundation.ui.use-box.menu": "0.0.88",
60
+ "@teambit/ui-foundation.ui.react-router.extend-path": "0.0.467"
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.108"
75
+ "@teambit/component.aspect-docs.component": "0.0.109"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@apollo/client": "^3.0.0",
79
- "@teambit/legacy": "1.0.175",
79
+ "@teambit/legacy": "1.0.176",
80
80
  "react-dom": "^16.8.0 || ^17.0.0",
81
81
  "react": "^16.8.0 || ^17.0.0"
82
82
  },
@@ -104,7 +104,7 @@
104
104
  "react": "-"
105
105
  },
106
106
  "peerDependencies": {
107
- "@teambit/legacy": "1.0.175",
107
+ "@teambit/legacy": "1.0.176",
108
108
  "react-dom": "^16.8.0 || ^17.0.0",
109
109
  "react": "^16.8.0 || ^17.0.0"
110
110
  }