@teambit/workspace 0.0.818 → 0.0.819

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.
@@ -241,7 +241,7 @@ class GraphFromFsBuilder {
241
241
  const isOnWorkspace = Boolean(componentMap);
242
242
 
243
243
  if (isOnWorkspace) {
244
- return this.consumer.loadComponentForCapsule(componentId);
244
+ return this.consumer.loadComponent(componentId);
245
245
  } // a dependency might have been installed as a package in the workspace, and as such doesn't
246
246
  // have a componentMap.
247
247
 
@@ -1 +1 @@
1
- {"version":3,"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","mapSeries","depId","shouldLoad","push","fromArray","compact","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","flatten","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","throwForDependencyNotFound","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","componentMap","bitMap","getComponentIfExist","isOnWorkspace","Boolean","loadComponentForCapsule","componentFromModel","loadComponentFromModel","clone"],"sources":["build-graph-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldLoadFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldLoadFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(allDepsWithScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n });\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return components;\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentId);\n const isOnWorkspace = Boolean(componentMap);\n if (isOnWorkspace) {\n return this.consumer.loadComponentForCapsule(componentId);\n }\n // a dependency might have been installed as a package in the workspace, and as such doesn't\n // have a componentMap.\n const componentFromModel = await this.consumer.loadComponentFromModel(componentId);\n return componentFromModel.clone();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKO,MAAMA,kBAAN,CAAyB;EAM9BC,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,SAAS,GAAG,KAAIC,iBAAJ,GAHX,EAIDC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qBAAA,EAAU2C,aAAV,EAAyB,MAAOE,IAAP,IAAuB;MACvE,MAAMlB,KAAK,GAAGkB,IAAI,CAAChB,QAAL,EAAd;MACA,MAAMiB,SAAS,GAAG,KAAKvD,KAAL,CAAWwD,IAAX,CAAgBpB,KAAhB,CAAlB;MACA,IAAImB,SAAJ,EAAe,OAAOA,SAAP;;MACf,IAAI;QACF,MAAMrD,SAAS,GAAG,MAAM,KAAKuD,aAAL,CAAmBH,IAAnB,CAAxB;QACA,KAAKtD,KAAL,CAAW0D,OAAX,CAAmBtB,KAAnB,EAA0BlC,SAA1B;QACA,OAAOA,SAAP;MACD,CAJD,CAIE,OAAOyD,GAAP,EAAiB;QACjB,IAAIA,GAAG,YAAYC,0BAAnB,EAAsC;UACpC,MAAM,KAAIC,oBAAJ,EACH,qBAAoBzB,KAAM,wDAAuDiB,cAAe,iDAD7F,CAAN;QAGD;;QACD,KAAKrE,MAAL,CAAY8E,KAAZ,CAAmB,kCAAiCT,cAAe,EAAnE;QACA,MAAMM,GAAN;MACD;IACF,CAjBwB,CAAzB;IAkBA,OAAO9D,UAAP;EACD;;EAC0B,MAAb4D,aAAa,CAACM,WAAD,EAAyC;IAClE,MAAMC,YAAY,GAAG,KAAK3E,QAAL,CAAc4E,MAAd,CAAqBC,mBAArB,CAAyCH,WAAzC,CAArB;IACA,MAAMI,aAAa,GAAGC,OAAO,CAACJ,YAAD,CAA7B;;IACA,IAAIG,aAAJ,EAAmB;MACjB,OAAO,KAAK9E,QAAL,CAAcgF,uBAAd,CAAsCN,WAAtC,CAAP;IACD,CALiE,CAMlE;IACA;;;IACA,MAAMO,kBAAkB,GAAG,MAAM,KAAKjF,QAAL,CAAckF,sBAAd,CAAqCR,WAArC,CAAjC;IACA,OAAOO,kBAAkB,CAACE,KAAnB,EAAP;EACD;;AA7I6B"}
1
+ {"version":3,"names":["GraphFromFsBuilder","constructor","workspace","logger","ignoreIds","BitIds","shouldLoadItsDeps","LegacyGraph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","getAllDepsUnfiltered","component","getAllDependenciesIds","difference","getAllDepsFiltered","depsWithoutIgnore","shouldLoadFunc","deps","mapSeries","depId","shouldLoad","push","fromArray","compact","depth","importObjects","allDependencies","processOneComponent","allDependenciesFlattened","flatten","allDeps","map","c","flat","allDepsWithScope","filter","dep","hasScope","scopeComponentsImporter","ScopeComponentsImporter","scope","importMany","uniqFromArray","throwForDependencyNotFound","shouldThrowOnMissingDep","idStr","id","toString","completed","includes","allIds","Object","entries","depsIdsGroupedByType","forEach","depType","depsIds","has","hasNode","Error","setEdge","componentsIds","dependenciesOf","comp","fromGraph","node","loadComponent","setNode","err","ComponentNotFound","BitError","error","componentId","componentMap","bitMap","getComponentIfExist","isOnWorkspace","Boolean","componentFromModel","loadComponentFromModel","clone"],"sources":["build-graph-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { flatten } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport Component from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport compact from 'lodash.compact';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport { ComponentNotFound } from '@teambit/scope';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport type ShouldLoadFunc = (bitId: BitId) => Promise<boolean>;\n\nexport class GraphFromFsBuilder {\n private graph = new LegacyGraph();\n private completed: string[] = [];\n private depth = 1;\n private shouldThrowOnMissingDep = true;\n private consumer: Consumer;\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private ignoreIds = new BitIds(),\n private shouldLoadItsDeps?: ShouldLoadFunc\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are components and the edges has a label of the dependency type.\n *\n * the way how it is done is iterations by depths. each depth we gather all the dependencies of\n * that depths, make sure all objects exist and then check their dependencies for the next depth.\n * once there is no dependency left, we're on the last depth level and the graph is ready.\n *\n * for example, imagine the following graph:\n * A1 -> A2 -> A3\n * B1 -> B2 -> B3\n * C1 -> C2 -> C3\n *\n * where the buildGraph is given [A1, B1, C1].\n * first, it saves all these components as nodes in the graph. then, it finds the dependencies of\n * the next level, in this case they're [A2, B2, C2]. it runs `importMany` in case some objects\n * are missing. then, it loads them all (some from FS, some from the model) and sets the edges\n * between the component and the dependencies.\n * once done, it finds all their dependencies, which are [A3, B3, C3] and repeat the process\n * above. since there are no more dependencies, the graph is completed.\n * in this case, the total depth levels are 3.\n *\n * even with a huge project, there are not many depth levels. by iterating through depth levels\n * we keep performance sane as the importMany doesn't run multiple time and therefore the round\n * trips to the remotes are minimal.\n *\n * normally, one importMany of the seeders is enough as importMany knows to fetch all flattened.\n * however, since this buildGraph is performed on the workspace, a dependency may be new or\n * modified and as such, we don't know its flattened yet.\n */\n async buildGraph(ids: BitId[]): Promise<LegacyGraph> {\n this.logger.debug(`GraphFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids, '<none>');\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private getAllDepsUnfiltered(component: Component) {\n return component.getAllDependenciesIds().difference(this.ignoreIds);\n }\n\n private async getAllDepsFiltered(component: Component): Promise<BitIds> {\n const depsWithoutIgnore = this.getAllDepsUnfiltered(component);\n const shouldLoadFunc = this.shouldLoadItsDeps;\n if (!shouldLoadFunc) return depsWithoutIgnore;\n const deps = await mapSeries(depsWithoutIgnore, async (depId) => {\n const shouldLoad = await shouldLoadFunc(depId);\n if (!shouldLoad) this.ignoreIds.push(depId);\n return shouldLoad ? depId : null;\n });\n return BitIds.fromArray(compact(deps));\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(`GraphFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`);\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n private async importObjects(components: Component[]) {\n const allDeps = components.map((c) => this.getAllDepsUnfiltered(c)).flat();\n const allDepsWithScope = allDeps.filter((dep) => dep.hasScope());\n const scopeComponentsImporter = new ScopeComponentsImporter(this.consumer.scope);\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(allDepsWithScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n });\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const allIds = await this.getAllDepsFiltered(component);\n\n const allDependencies = await this.loadManyComponents(allIds, idStr);\n Object.entries(component.depsIdsGroupedByType).forEach(([depType, depsIds]) => {\n depsIds.forEach((depId) => {\n if (this.ignoreIds.has(depId)) return;\n if (!this.graph.hasNode(depId.toString())) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.graph.setEdge(idStr, depId.toString(), depType);\n });\n });\n this.completed.push(idStr);\n return allDependencies;\n }\n\n private async loadManyComponents(componentsIds: BitId[], dependenciesOf: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp: BitId) => {\n const idStr = comp.toString();\n const fromGraph = this.graph.node(idStr);\n if (fromGraph) return fromGraph;\n try {\n const component = await this.loadComponent(comp);\n this.graph.setNode(idStr, component);\n return component;\n } catch (err: any) {\n if (err instanceof ComponentNotFound) {\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${dependenciesOf}\" and is needed as part of the graph generation`\n );\n }\n this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return components;\n }\n private async loadComponent(componentId: BitId): Promise<Component> {\n const componentMap = this.consumer.bitMap.getComponentIfExist(componentId);\n const isOnWorkspace = Boolean(componentMap);\n if (isOnWorkspace) {\n return this.consumer.loadComponent(componentId);\n }\n // a dependency might have been installed as a package in the workspace, and as such doesn't\n // have a componentMap.\n const componentFromModel = await this.consumer.loadComponentFromModel(componentId);\n return componentFromModel.clone();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKO,MAAMA,kBAAN,CAAyB;EAM9BC,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,SAAS,GAAG,KAAIC,iBAAJ,GAHX,EAIDC,iBAJC,EAKT;IAAA,KAJQJ,SAIR,GAJQA,SAIR;IAAA,KAHQC,MAGR,GAHQA,MAGR;IAAA,KAFQC,SAER,GAFQA,SAER;IAAA,KADQE,iBACR,GADQA,iBACR;IAAA,+CAVc,KAAIC,gBAAJ,GAUd;IAAA,mDAT4B,EAS5B;IAAA,+CARc,CAQd;IAAA,iEAPgC,IAOhC;IAAA;IACA,KAAKC,QAAL,GAAgB,KAAKN,SAAL,CAAeM,QAA/B;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACkB,MAAVC,U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AsC;UACpC,MAAM,KAAIC,oBAAJ,EACH,qBAAoBzB,KAAM,wDAAuDiB,cAAe,iDAD7F,CAAN;QAGD;;QACD,KAAKrE,MAAL,CAAY8E,KAAZ,CAAmB,kCAAiCT,cAAe,EAAnE;QACA,MAAMM,GAAN;MACD;IACF,CAjBwB,CAAzB;IAkBA,OAAO9D,UAAP;EACD;;EAC0B,MAAb4D,aAAa,CAACM,WAAD,EAAyC;IAClE,MAAMC,YAAY,GAAG,KAAK3E,QAAL,CAAc4E,MAAd,CAAqBC,mBAArB,CAAyCH,WAAzC,CAArB;IACA,MAAMI,aAAa,GAAGC,OAAO,CAACJ,YAAD,CAA7B;;IACA,IAAIG,aAAJ,EAAmB;MACjB,OAAO,KAAK9E,QAAL,CAAcoE,aAAd,CAA4BM,WAA5B,CAAP;IACD,CALiE,CAMlE;IACA;;;IACA,MAAMM,kBAAkB,GAAG,MAAM,KAAKhF,QAAL,CAAciF,sBAAd,CAAqCP,WAArC,CAAjC;IACA,OAAOM,kBAAkB,CAACE,KAAnB,EAAP;EACD;;AA7I6B"}
@@ -11,11 +11,10 @@ export declare class WorkspaceComponentLoader {
11
11
  private dependencyResolver;
12
12
  private envs;
13
13
  private componentsCache;
14
- private componentsCacheForCapsule;
15
14
  constructor(workspace: Workspace, logger: Logger, dependencyResolver: DependencyResolverMain, envs: EnvsMain);
16
- getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
15
+ getMany(ids: Array<ComponentID>): Promise<Component[]>;
17
16
  getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]>;
18
- get(componentId: ComponentID, forCapsule?: boolean, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions): Promise<Component>;
17
+ get(componentId: ComponentID, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions): Promise<Component>;
19
18
  getIfExist(componentId: ComponentID): Promise<Component | undefined>;
20
19
  private addMultipleEnvsIssueIfNeeded;
21
20
  clearCache(): void;
@@ -185,29 +185,24 @@ function _workspaceComponent() {
185
185
 
186
186
  class WorkspaceComponentLoader {
187
187
  // cache loaded components
188
- // cache loaded components for capsule, must not use the cache for the workspace
189
188
  constructor(workspace, logger, dependencyResolver, envs) {
190
189
  this.workspace = workspace;
191
190
  this.logger = logger;
192
191
  this.dependencyResolver = dependencyResolver;
193
192
  this.envs = envs;
194
193
  (0, _defineProperty2().default)(this, "componentsCache", void 0);
195
- (0, _defineProperty2().default)(this, "componentsCacheForCapsule", void 0);
196
194
  this.componentsCache = (0, _cacheFactory().createInMemoryCache)({
197
195
  maxSize: (0, _inMemoryCache().getMaxSizeForComponents)()
198
196
  });
199
- this.componentsCacheForCapsule = (0, _cacheFactory().createInMemoryCache)({
200
- maxSize: (0, _inMemoryCache().getMaxSizeForComponents)()
201
- });
202
197
  }
203
198
 
204
- async getMany(ids, forCapsule = false) {
199
+ async getMany(ids) {
205
200
  const idsWithoutEmpty = (0, _lodash().compact)(ids);
206
201
  const errors = [];
207
202
  const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);
208
203
  const componentsP = (0, _pMapSeries().default)(idsWithoutEmpty, async id => {
209
204
  longProcessLogger.logProgress(id.toString());
210
- return this.get(id, forCapsule).catch(err => {
205
+ return this.get(id).catch(err => {
211
206
  if (this.isComponentNotExistsError(err)) {
212
207
  errors.push({
213
208
  id,
@@ -254,16 +249,16 @@ class WorkspaceComponentLoader {
254
249
  return errors;
255
250
  }
256
251
 
257
- async get(componentId, forCapsule = false, legacyComponent, useCache = true, storeInCache = true, loadOpts) {
252
+ async get(componentId, legacyComponent, useCache = true, storeInCache = true, loadOpts) {
258
253
  const bitIdWithVersion = (0, _utils().getLatestVersionNumber)(this.workspace.consumer.bitmapIdsFromCurrentLane, componentId._legacy);
259
254
  const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;
260
- const fromCache = this.getFromCache(id, forCapsule, loadOpts);
255
+ const fromCache = this.getFromCache(id, loadOpts);
261
256
 
262
257
  if (fromCache && useCache) {
263
258
  return fromCache;
264
259
  }
265
260
 
266
- const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule)); // in case of out-of-sync, the id may changed during the load process
261
+ const consumerComponent = legacyComponent || (await this.getConsumerComponent(id)); // in case of out-of-sync, the id may changed during the load process
267
262
 
268
263
  const updatedId = consumerComponent ? _component().ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;
269
264
  const component = await this.loadOne(updatedId, consumerComponent, loadOpts);
@@ -271,7 +266,7 @@ class WorkspaceComponentLoader {
271
266
  if (storeInCache) {
272
267
  this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded
273
268
 
274
- this.saveInCache(component, forCapsule, loadOpts);
269
+ this.saveInCache(component, loadOpts);
275
270
  }
276
271
 
277
272
  return component;
@@ -302,7 +297,6 @@ class WorkspaceComponentLoader {
302
297
 
303
298
  clearCache() {
304
299
  this.componentsCache.deleteAll();
305
- this.componentsCacheForCapsule.deleteAll();
306
300
  }
307
301
 
308
302
  clearComponentCache(id) {
@@ -313,12 +307,6 @@ class WorkspaceComponentLoader {
313
307
  this.componentsCache.delete(cacheKey);
314
308
  }
315
309
  }
316
-
317
- for (const cacheKey of this.componentsCacheForCapsule.keys()) {
318
- if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {
319
- this.componentsCacheForCapsule.delete(cacheKey);
320
- }
321
- }
322
310
  }
323
311
 
324
312
  async loadOne(id, consumerComponent, loadOpts) {
@@ -352,14 +340,9 @@ class WorkspaceComponentLoader {
352
340
  return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);
353
341
  }
354
342
 
355
- saveInCache(component, forCapsule, loadOpts) {
343
+ saveInCache(component, loadOpts) {
356
344
  const cacheKey = createComponentCacheKey(component.id, loadOpts);
357
-
358
- if (forCapsule) {
359
- this.componentsCacheForCapsule.set(cacheKey, component);
360
- } else {
361
- this.componentsCache.set(cacheKey, component);
362
- }
345
+ this.componentsCache.set(cacheKey, component);
363
346
  }
364
347
  /**
365
348
  * make sure that not only the id-str match, but also the legacy-id.
@@ -370,9 +353,9 @@ class WorkspaceComponentLoader {
370
353
  */
371
354
 
372
355
 
373
- getFromCache(id, forCapsule, loadOpts) {
356
+ getFromCache(id, loadOpts) {
374
357
  const cacheKey = createComponentCacheKey(id, loadOpts);
375
- const fromCache = forCapsule ? this.componentsCacheForCapsule.get(cacheKey) : this.componentsCache.get(cacheKey);
358
+ const fromCache = this.componentsCache.get(cacheKey);
376
359
 
377
360
  if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {
378
361
  return fromCache;
@@ -381,11 +364,9 @@ class WorkspaceComponentLoader {
381
364
  return undefined;
382
365
  }
383
366
 
384
- async getConsumerComponent(id, forCapsule = false) {
367
+ async getConsumerComponent(id) {
385
368
  try {
386
- return forCapsule ? // eslint-disable-next-line @typescript-eslint/return-await
387
- await this.workspace.consumer.loadComponentForCapsule(id._legacy) : // eslint-disable-next-line @typescript-eslint/return-await
388
- await this.workspace.consumer.loadComponent(id._legacy);
369
+ return await this.workspace.consumer.loadComponent(id._legacy);
389
370
  } catch (err) {
390
371
  // don't return undefined for any error. otherwise, if the component is invalid (e.g. main
391
372
  // file is missing) it returns the model component later unexpectedly, or if it's new, it
@@ -1 +1 @@
1
- {"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","loadOpts","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n for (const cacheKey of this.componentsCacheForCapsule.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCacheForCapsule.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent, loadOpts);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, forCapsule: boolean, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n if (forCapsule) {\n this.componentsCacheForCapsule.set(cacheKey, component);\n } else {\n this.componentsCache.set(cacheKey, component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = forCapsule ? this.componentsCacheForCapsule.get(cacheKey) : this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension && data) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;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H,mBAAmB,CAAC9D,SAAD,EAAuB4D,SAAvB,EAA0C7C,IAA1C,EAAqD;IACpF,MAAM+D,iBAAiB,GAAG9E,SAAS,CAACU,KAAV,CAAgByD,MAAhB,CAAuBzC,UAAvB,CAAkCqD,aAAlC,CAAgDnB,SAAhD,CAA1B;;IACA,IAAIkB,iBAAiB,IAAI/D,IAAzB,EAA+B;MAC7B;MACAiE,MAAM,CAACC,MAAP,CAAcH,iBAAiB,CAAC/D,IAAhC,EAAsCA,IAAtC;MACA;IACD;;IACDf,SAAS,CAACU,KAAV,CAAgByD,MAAhB,CAAuBzC,UAAvB,CAAkC1D,IAAlC,CAAuC,MAAM,KAAKkH,YAAL,CAAkBtB,SAAlB,EAA6B7C,IAA7B,CAA7C;EACD;;EAEyB,MAAZmE,YAAY,CAACtB,SAAD,EAAoB7C,IAApB,EAA+E;IACvG;IACA,OAAO,KAAIoE,4BAAJ,EAAuBlH,SAAvB,EAAkCA,SAAlC,EAA6C2F,SAA7C,EAAwD3F,SAAxD,EAAmE8C,IAAnE,CAAP;EACD;;AAhRmC;;;;AAmRtC,SAASgC,uBAAT,CAAiCtF,EAAjC,EAAkDyB,QAAlD,EAA2F;EACzF,OAAQ,GAAEzB,EAAE,CAACE,QAAH,EAAc,IAAGyH,IAAI,CAACC,SAAL,CAAeC,QAAQ,CAACpG,QAAD,aAACA,QAAD,cAACA,QAAD,GAAa,EAAb,CAAvB,CAAyC,EAApE;AACD;;AAED,SAASoG,QAAT,CAAkBC,GAAlB,EAA+B;EAC7B,OAAO,IAAAC,mBAAA,EAAUR,MAAM,CAACxB,OAAP,CAAe+B,GAAf,EAAoBE,IAApB,CAAyB,CAAC,CAACC,EAAD,CAAD,EAAO,CAACC,EAAD,CAAP,KAAgBD,EAAE,CAACE,aAAH,CAAiBD,EAAjB,CAAzC,CAAV,CAAP;AACD"}
1
+ {"version":3,"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","idsWithoutEmpty","compact","errors","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","loadOpts","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry","JSON","stringify","sortKeys","obj","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, fromPairs, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true,\n loadOpts?: ComponentLoadOptions\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, loadOpts);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent, loadOpts);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, loadOpts);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n for (const cacheKey of this.componentsCache.keys()) {\n if (cacheKey === idStr || cacheKey.startsWith(`${idStr}:`)) {\n this.componentsCache.delete(cacheKey);\n }\n }\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent, loadOpts?: ComponentLoadOptions) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent, loadOpts);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state), loadOpts);\n }\n\n private saveInCache(component: Component, loadOpts?: ComponentLoadOptions): void {\n const cacheKey = createComponentCacheKey(component.id, loadOpts);\n this.componentsCache.set(cacheKey, component);\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, loadOpts?: ComponentLoadOptions): Component | undefined {\n const cacheKey = createComponentCacheKey(id, loadOpts);\n const fromCache = this.componentsCache.get(cacheKey);\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID): Promise<ConsumerComponent | undefined> {\n try {\n return await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension && data) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n\nfunction createComponentCacheKey(id: ComponentID, loadOpts?: ComponentLoadOptions): string {\n return `${id.toString()}:${JSON.stringify(sortKeys(loadOpts ?? {}))}`;\n}\n\nfunction sortKeys(obj: Object) {\n return fromPairs(Object.entries(obj).sort(([k1], [k2]) => k1.localeCompare(k2)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAA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}
@@ -251,7 +251,7 @@ export declare class Workspace implements ComponentFactory {
251
251
  * get a component from workspace
252
252
  * @param id component ID
253
253
  */
254
- get(componentId: ComponentID, forCapsule?: boolean, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions): Promise<Component>;
254
+ get(componentId: ComponentID, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions): Promise<Component>;
255
255
  getEnvSystemDescriptor(component: Component): Promise<AspectData>;
256
256
  clearCache(): void;
257
257
  clearComponentCache(id: ComponentID): void;
@@ -294,7 +294,7 @@ export declare class Workspace implements ComponentFactory {
294
294
  */
295
295
  getComponentsByUserInput(all?: boolean, pattern?: string, includeDependents?: boolean): Promise<Component[]>;
296
296
  getComponentsUsingEnv(env: string, ignoreVersion?: boolean, throwIfNotFound?: boolean): Promise<Component[]>;
297
- getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
297
+ getMany(ids: Array<ComponentID>): Promise<Component[]>;
298
298
  getManyByLegacy(components: ConsumerComponent[], loadOpts?: ComponentLoadOptions): Promise<Component[]>;
299
299
  /**
300
300
  * don't throw an error if the component was not found, simply return undefined.
@@ -310,9 +310,8 @@ export declare class Workspace implements ComponentFactory {
310
310
  * It will influence the performance
311
311
  * currently it used only for get many of aspects
312
312
  * @param ids
313
- * @param forCapsule
314
313
  */
315
- importAndGetMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
314
+ importAndGetMany(ids: Array<ComponentID>): Promise<Component[]>;
316
315
  importCurrentLaneIfMissing(): Promise<void>;
317
316
  /**
318
317
  * @deprecated use this.track() instead
package/dist/workspace.js CHANGED
@@ -836,9 +836,9 @@ class Workspace {
836
836
  */
837
837
 
838
838
 
839
- async get(componentId, forCapsule = false, legacyComponent, useCache = true, storeInCache = true, loadOpts) {
839
+ async get(componentId, legacyComponent, useCache = true, storeInCache = true, loadOpts) {
840
840
  this.logger.debug(`get ${componentId.toString()}`);
841
- const component = await this.componentLoader.get(componentId, forCapsule, legacyComponent, useCache, storeInCache, loadOpts); // When loading a component if it's an env make sure to load it as aspect as well
841
+ const component = await this.componentLoader.get(componentId, legacyComponent, useCache, storeInCache, loadOpts); // When loading a component if it's an env make sure to load it as aspect as well
842
842
  // We only want to try load it as aspect if it's the first time we load the component
843
843
 
844
844
  const tryLoadAsAspect = this.componentLoadedSelfAsAspects.get(component.id.toString()) === undefined; // const config = this.harmony.get<ConfigMain>('teambit.harmony/config');
@@ -1157,14 +1157,14 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1157
1157
  return (foundEnv === null || foundEnv === void 0 ? void 0 : foundEnv.components) || [];
1158
1158
  }
1159
1159
 
1160
- async getMany(ids, forCapsule = false) {
1161
- return this.componentLoader.getMany(ids, forCapsule);
1160
+ async getMany(ids) {
1161
+ return this.componentLoader.getMany(ids);
1162
1162
  }
1163
1163
 
1164
1164
  getManyByLegacy(components, loadOpts) {
1165
1165
  return (0, _pMapSeries().default)(components, async component => {
1166
1166
  const id = await this.resolveComponentId(component.id);
1167
- return this.get(id, undefined, component, true, true, loadOpts);
1167
+ return this.get(id, component, true, true, loadOpts);
1168
1168
  });
1169
1169
  }
1170
1170
  /**
@@ -1189,16 +1189,15 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1189
1189
  * It will influence the performance
1190
1190
  * currently it used only for get many of aspects
1191
1191
  * @param ids
1192
- * @param forCapsule
1193
1192
  */
1194
1193
 
1195
1194
 
1196
- async importAndGetMany(ids, forCapsule = false) {
1195
+ async importAndGetMany(ids) {
1197
1196
  await this.importCurrentLaneIfMissing();
1198
1197
  await this.scope.import(ids, {
1199
1198
  reFetchUnBuiltVersion: shouldReFetchUnBuiltVersion()
1200
1199
  });
1201
- return this.componentLoader.getMany(ids, forCapsule);
1200
+ return this.componentLoader.getMany(ids);
1202
1201
  }
1203
1202
 
1204
1203
  async importCurrentLaneIfMissing() {