@teambit/workspace 1.0.27 → 1.0.30

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.
@@ -1 +1 @@
1
- {"version":3,"names":["_sources","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","headFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Repository } from '@teambit/legacy/dist/scope/objects';\nimport { PathLinux } from '@teambit/legacy/dist/utils/path';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n private headFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.headFiles.length) return false;\n if (this.currentFiles.length !== this.headFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.headFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.headFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQO,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EACnBC,SAA4B,GAAG,EAAE,EACzC;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA,YAA0B;IAAA,KACzBC,OAAkB,GAAlBA,OAAkB;IAAA,KACnBC,SAA4B,GAA5BA,SAA4B;EACnC;EAEHC,UAAUA,CAAA,EAAY;IACpB,IAAI,CAAC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE,OAAO,KAAK;IACxC,IAAI,IAAI,CAACJ,YAAY,CAACI,MAAM,KAAK,IAAI,CAACF,SAAS,CAACE,MAAM,EAAE,OAAO,IAAI;IACnE,OAAO,IAAI,CAACJ,YAAY,CAACK,IAAI,CAAEC,IAAI,IAAK;MACtC,MAAMC,QAAQ,GAAG,IAAI,CAACL,SAAS,CAACM,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,YAAY,KAAKJ,IAAI,CAACK,QAAQ,CAAC;MAC7E,IAAI,CAACJ,QAAQ,EAAE,OAAO,IAAI;MAC1B,OAAO,CAACA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC;EACJ;EAEAC,e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;AAACO,OAAA,CAAAlC,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_sources","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","headFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Repository } from '@teambit/legacy/dist/scope/objects';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\ntype PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path.\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n private headFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.headFiles.length) return false;\n if (this.currentFiles.length !== this.headFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.headFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.headFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKyB;;AAGlB,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EACnBC,SAA4B,GAAG,EAAE,EACzC;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA,YAA0B;IAAA,KACzBC,OAAkB,GAAlBA,OAAkB;IAAA,KACnBC,SAA4B,GAA5BA,SAA4B;EACnC;EAEHC,UAAUA,CAAA,EAAY;IACpB,IAAI,CAAC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE,OAAO,KAAK;IACxC,IAAI,IAAI,CAACJ,YAAY,CAACI,MAAM,KAAK,IAAI,CAACF,SAAS,CAACE,MAAM,EAAE,OAAO,IAAI;IACnE,OAAO,IAAI,CAACJ,YAAY,CAACK,IAAI,CAAEC,IAAI,IAAK;MACtC,MAAMC,QAAQ,GAAG,IAAI,CAACL,SAAS,CAACM,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,YAAY,KAAKJ,IAAI,CAACK,QAAQ,CAAC;MAC7E,IAAI,CAACJ,QAAQ,EAAE,OAAO,IAAI;MAC1B,OAAO,CAACA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC;EACJ;EAEAC,eAAeA,CAAA,EAAiB;IAC9B,OAAO,IAAI,CAACf,YAAY;EAC1B;EA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@
1
- import { Component, ComponentID, InvalidComponent } from '@teambit/component';
1
+ import { Component, InvalidComponent } from '@teambit/component';
2
+ import { ComponentID } from '@teambit/component-id';
2
3
  import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
3
4
  import { DependencyResolverMain } from '@teambit/dependency-resolver';
4
5
  import { Logger } from '@teambit/logger';
@@ -11,6 +11,13 @@ function _component() {
11
11
  };
12
12
  return data;
13
13
  }
14
+ function _componentId() {
15
+ const data = require("@teambit/component-id");
16
+ _componentId = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
14
21
  function _pMapSeries() {
15
22
  const data = _interopRequireDefault(require("p-map-series"));
16
23
  _pMapSeries = function () {
@@ -53,13 +60,6 @@ function _componentIssues() {
53
60
  };
54
61
  return data;
55
62
  }
56
- function _bitId() {
57
- const data = require("@teambit/legacy/dist/bit-id");
58
- _bitId = function () {
59
- return data;
60
- };
61
- return data;
62
- }
63
63
  function _exceptions2() {
64
64
  const data = require("@teambit/legacy/dist/scope/exceptions");
65
65
  _exceptions2 = function () {
@@ -184,7 +184,7 @@ class WorkspaceComponentLoader {
184
184
  await (0, _pMapSeries().default)(idsWithoutEmpty, async id => {
185
185
  longProcessLogger.logProgress(id.toString());
186
186
  try {
187
- await this.workspace.consumer.loadComponent(id._legacy);
187
+ await this.workspace.consumer.loadComponent(id);
188
188
  } catch (err) {
189
189
  if (_component2().default.isComponentInvalidByErrorType(err)) {
190
190
  errors.push({
@@ -199,7 +199,7 @@ class WorkspaceComponentLoader {
199
199
  return errors;
200
200
  }
201
201
  async get(componentId, legacyComponent, useCache = true, storeInCache = true, loadOpts) {
202
- const bitIdWithVersion = (0, _utils().getLatestVersionNumber)(this.workspace.consumer.bitmapIdsFromCurrentLaneIncludeRemoved, componentId._legacy);
202
+ const bitIdWithVersion = (0, _utils().getLatestVersionNumber)(this.workspace.consumer.bitmapIdsFromCurrentLaneIncludeRemoved, componentId);
203
203
  const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;
204
204
  const fromCache = this.getFromCache(id, loadOpts);
205
205
  if (fromCache && useCache) {
@@ -207,7 +207,7 @@ class WorkspaceComponentLoader {
207
207
  }
208
208
  const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, loadOpts));
209
209
  // in case of out-of-sync, the id may changed during the load process
210
- const updatedId = consumerComponent ? _component().ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;
210
+ const updatedId = consumerComponent ? consumerComponent.id : id;
211
211
  const component = await this.loadOne(updatedId, consumerComponent, loadOpts);
212
212
  if (storeInCache) {
213
213
  this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded
@@ -287,7 +287,7 @@ class WorkspaceComponentLoader {
287
287
  getFromCache(id, loadOpts) {
288
288
  const cacheKey = createComponentCacheKey(id, loadOpts);
289
289
  const fromCache = this.componentsCache.get(cacheKey);
290
- if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {
290
+ if (fromCache && fromCache.id.isEqual(id)) {
291
291
  return fromCache;
292
292
  }
293
293
  return undefined;
@@ -298,7 +298,7 @@ class WorkspaceComponentLoader {
298
298
  const {
299
299
  components,
300
300
  removedComponents
301
- } = await this.workspace.consumer.loadComponents(_bitId().BitIds.fromArray([id._legacy]), true, loadOpts);
301
+ } = await this.workspace.consumer.loadComponents(_componentId().ComponentIdList.fromArray([id]), true, loadOpts);
302
302
  return (components === null || components === void 0 ? void 0 : components[0]) || (removedComponents === null || removedComponents === void 0 ? void 0 : removedComponents[0]);
303
303
  } catch (err) {
304
304
  // don't return undefined for any error. otherwise, if the component is invalid (e.g. main
@@ -328,7 +328,7 @@ class WorkspaceComponentLoader {
328
328
  });
329
329
 
330
330
  // Move to deps resolver main runtime once we switch ws<> deps resolver direction
331
- const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions, component.id._legacy, component.state._consumer.files);
331
+ const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions, component.id, component.state._consumer.files);
332
332
  const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);
333
333
  const depResolverData = {
334
334
  packageName: this.dependencyResolver.calcPackageName(component),
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_lodash","_component2","_exceptions","_utils","_componentIssues","_bitId","_exceptions2","_dependencyResolver","_envs","_config","_inMemoryCache","_cacheFactory","_componentNotFoundInPath","_workspaceComponent","_mergeConfigConflict","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","throwOnFailure","idsWithoutEmpty","compact","errors","invalidComponents","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","catch","err","ConsumerComponent","isComponentInvalidByErrorType","push","isComponentNotExistsError","ComponentNotFoundInPath","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","_legacy","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLaneIncludeRemoved","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","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","some","MergeConfigConflict","MergeConfigHasConflict","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","originatedFromHarmony","removedComponents","loadComponents","BitIds","fromArray","debug","name","message","ComponentNotFound","_consumer","removed","envsData","calcDescriptor","skipWarnings","inInstallContext","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","depResolverData","packageName","calcPackageName","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","extension","onLoad","upsertEntry","resolveComponentId","TagMap","existingExtension","findExtension","assign","getDataEntry","ExtensionDataEntry","exports","JSON","stringify","sortKeys","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 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 { BitIds } from '@teambit/legacy/dist/bit-id';\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';\nimport { MergeConfigConflict } from '../exceptions/merge-config-conflict';\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(\n ids: Array<ComponentID>,\n loadOpts?: ComponentLoadOptions,\n throwOnFailure = true\n ): Promise<{\n components: Component[];\n invalidComponents: InvalidComponent[];\n }> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const invalidComponents: InvalidComponent[] = [];\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, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (ConsumerComponent.isComponentInvalidByErrorType(err) && !throwOnFailure) {\n invalidComponents.push({\n id,\n err,\n });\n return undefined;\n }\n if (this.isComponentNotExistsError(err) || err instanceof ComponentNotFoundInPath) {\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 { components: filteredComponents, invalidComponents };\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.bitmapIdsFromCurrentLaneIncludeRemoved,\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, loadOpts));\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, errors } = await this.workspace.componentExtensions(id, componentFromScope);\n if (errors?.some((err) => err instanceof MergeConfigConflict)) {\n consumerComponent.issues.getOrCreate(IssuesClasses.MergeConfigHasConflict).data = true;\n }\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 = extensions;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensions),\n await this.workspace.createAspectList(extensions),\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 const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\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(\n id: ComponentID,\n loadOpts: ComponentLoadOptions = {}\n ): Promise<ConsumerComponent | undefined> {\n loadOpts.originatedFromHarmony = true;\n try {\n const { components, removedComponents } = await this.workspace.consumer.loadComponents(\n BitIds.fromArray([id._legacy]),\n true,\n loadOpts\n );\n return components?.[0] || removedComponents?.[0];\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 err instanceof ComponentNotFound || err instanceof MissingBitMapComponent;\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\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.envs.calcDescriptor(component, { skipWarnings: !!this.workspace.inInstallContext });\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(\n component.config.extensions,\n component.id._legacy,\n component.state._consumer.files\n );\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n packageName: this.dependencyResolver.calcPackageName(component),\n dependencies: dependenciesList.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n await mapSeries(entries, async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n await this.upsertExtensionData(component, extension, data);\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n component.state.aspects.upsertEntry(await this.workspace.resolveComponentId(extension), data);\n });\n\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 if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\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,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OA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,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
1
+ {"version":3,"names":["_component","data","require","_componentId","_pMapSeries","_interopRequireDefault","_lodash","_component2","_exceptions","_utils","_componentIssues","_exceptions2","_dependencyResolver","_envs","_config","_inMemoryCache","_cacheFactory","_componentNotFoundInPath","_workspaceComponent","_mergeConfigConflict","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","createInMemoryCache","maxSize","getMaxSizeForComponents","getMany","ids","loadOpts","throwOnFailure","idsWithoutEmpty","compact","errors","invalidComponents","longProcessLogger","createLongProcessLogger","length","componentsP","mapSeries","id","logProgress","toString","get","catch","err","ConsumerComponent","isComponentInvalidByErrorType","push","isComponentNotExistsError","ComponentNotFoundInPath","components","forEach","console","warn","filteredComponents","end","getInvalid","consumer","loadComponent","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","getLatestVersionNumber","bitmapIdsFromCurrentLaneIncludeRemoved","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","uniq","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","clearCache","deleteAll","clearComponentCache","idStr","cacheKey","keys","startsWith","delete","componentFromScope","scope","MissingBitMapComponent","extensions","componentExtensions","some","MergeConfigConflict","MergeConfigHasConflict","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","updatedComp","executeLoadSlot","newComponentFromState","createComponentCacheKey","set","isEqual","originatedFromHarmony","removedComponents","loadComponents","ComponentIdList","fromArray","debug","name","message","ComponentNotFound","_consumer","removed","envsData","calcDescriptor","skipWarnings","inInstallContext","policy","mergeVariantPolicies","config","dependenciesList","extractDepsFromLegacy","depResolverData","packageName","calcPackageName","serialize","Promise","all","upsertExtensionData","EnvsAspect","DependencyResolverAspect","aspectListWithEnvsAndDeps","aspects","entries","onComponentLoadSlot","toArray","extension","onLoad","upsertEntry","resolveComponentId","TagMap","existingExtension","findExtension","assign","getDataEntry","ExtensionDataEntry","exports","JSON","stringify","sortKeys","fromPairs","sort","k1","k2","localeCompare"],"sources":["workspace-component-loader.ts"],"sourcesContent":["import { Component, ComponentFS, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\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';\nimport { MergeConfigConflict } from '../exceptions/merge-config-conflict';\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(\n ids: Array<ComponentID>,\n loadOpts?: ComponentLoadOptions,\n throwOnFailure = true\n ): Promise<{\n components: Component[];\n invalidComponents: InvalidComponent[];\n }> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const invalidComponents: InvalidComponent[] = [];\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, undefined, undefined, undefined, loadOpts).catch((err) => {\n if (ConsumerComponent.isComponentInvalidByErrorType(err) && !throwOnFailure) {\n invalidComponents.push({\n id,\n err,\n });\n return undefined;\n }\n if (this.isComponentNotExistsError(err) || err instanceof ComponentNotFoundInPath) {\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 { components: filteredComponents, invalidComponents };\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);\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: ComponentID = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLaneIncludeRemoved,\n componentId\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, loadOpts));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? consumerComponent.id : 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, errors } = await this.workspace.componentExtensions(id, componentFromScope);\n if (errors?.some((err) => err instanceof MergeConfigConflict)) {\n consumerComponent.issues.getOrCreate(IssuesClasses.MergeConfigHasConflict).data = true;\n }\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 = extensions;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensions),\n await this.workspace.createAspectList(extensions),\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 const updatedComp = await this.executeLoadSlot(workspaceComponent, loadOpts);\n return updatedComp;\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.isEqual(id)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(\n id: ComponentID,\n loadOpts: ComponentLoadOptions = {}\n ): Promise<ConsumerComponent | undefined> {\n loadOpts.originatedFromHarmony = true;\n try {\n const { components, removedComponents } = await this.workspace.consumer.loadComponents(\n ComponentIdList.fromArray([id]),\n true,\n loadOpts\n );\n return components?.[0] || removedComponents?.[0];\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 err instanceof ComponentNotFound || err instanceof MissingBitMapComponent;\n }\n\n private async executeLoadSlot(component: Component, loadOpts?: ComponentLoadOptions) {\n if (component.state._consumer.removed) {\n // if it was soft-removed now, the component is not in the FS. loading aspects such as composition ends up with\n // errors as they try to read component files from the filesystem.\n return component;\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.envs.calcDescriptor(component, { skipWarnings: !!this.workspace.inInstallContext });\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(\n component.config.extensions,\n component.id,\n component.state._consumer.files\n );\n const dependenciesList = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n packageName: this.dependencyResolver.calcPackageName(component),\n dependencies: dependenciesList.serialize(),\n policy: policy.serialize(),\n };\n\n // Make sure we are adding the envs / deps data first because other on load events might depend on it\n await Promise.all([\n this.upsertExtensionData(component, EnvsAspect.id, envsData),\n this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData),\n ]);\n\n // We are updating the component state with the envs and deps data here, so in case we have other slots that depend on this data\n // they will be able to get it, as it's very common use case that during on load someone want to access to the component env for example\n const aspectListWithEnvsAndDeps = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = aspectListWithEnvsAndDeps;\n\n const entries = this.workspace.onComponentLoadSlot.toArray();\n await mapSeries(entries, async ([extension, onLoad]) => {\n const data = await onLoad(component, loadOpts);\n await this.upsertExtensionData(component, extension, data);\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n component.state.aspects.upsertEntry(await this.workspace.resolveComponentId(extension), data);\n });\n\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 if (!data) return;\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\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,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAK,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,YAAA;EAAA,M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CAAC;IACpF,IAAIK,iBAAiB,EAAE;MACrB;MACAnK,MAAM,CAACqK,MAAM,CAACF,iBAAiB,CAAC7L,IAAI,EAAEA,IAAI,CAAC;MAC3C;IACF;IACAqG,SAAS,CAACU,KAAK,CAACwD,MAAM,CAACxC,UAAU,CAACpD,IAAI,CAAC,MAAM,IAAI,CAACqH,YAAY,CAACR,SAAS,EAAExL,IAAI,CAAC,CAAC;EAClF;EAEA,MAAcgM,YAAYA,CAACR,SAAiB,EAAExL,IAA4B,EAA+B;IACvG;IACA,OAAO,KAAIiM,4BAAkB,EAAC1J,SAAS,EAAEA,SAAS,EAAEiJ,SAAS,EAAEjJ,SAAS,EAAEvC,IAAI,CAAC;EACjF;AACF;AAACkM,OAAA,CAAAtJ,wBAAA,GAAAA,wBAAA;AAED,SAASuG,uBAAuBA,CAAChF,EAAe,EAAEX,QAA+B,EAAU;EACzF,OAAQ,GAAEW,EAAE,CAACE,QAAQ,CAAC,CAAE,IAAG8H,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC7I,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAE,EAAC;AACvE;AAEA,SAAS6I,QAAQA,CAAClL,GAAW,EAAE;EAC7B,OAAO,IAAAmL,mBAAS,EAAC5K,MAAM,CAAC2J,OAAO,CAAClK,GAAG,CAAC,CAACoL,IAAI,CAAC,CAAC,CAACC,EAAE,CAAC,EAAE,CAACC,EAAE,CAAC,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC,CAAC;AAClF"}
@@ -2,7 +2,7 @@ import { Graph } from '@teambit/graph.cleargraph';
2
2
  import type { PubsubMain } from '@teambit/pubsub';
3
3
  import { IssuesList } from '@teambit/component-issues';
4
4
  import type { AspectLoaderMain, AspectDefinition } from '@teambit/aspect-loader';
5
- import { ComponentMain, Component, ComponentFactory, ComponentID, AspectList, InvalidComponent, ResolveAspectsOptions } from '@teambit/component';
5
+ import { ComponentMain, Component, ComponentFactory, AspectList, InvalidComponent, ResolveAspectsOptions } from '@teambit/component';
6
6
  import { ComponentScopeDirMap } from '@teambit/config';
7
7
  import { DependencyResolverMain } from '@teambit/dependency-resolver';
8
8
  import { EnvsMain } from '@teambit/envs';
@@ -11,6 +11,7 @@ import { Harmony } from '@teambit/harmony';
11
11
  import { Logger } from '@teambit/logger';
12
12
  import type { ScopeMain } from '@teambit/scope';
13
13
  import type { VariantsMain } from '@teambit/variants';
14
+ import { ComponentID } from '@teambit/component-id';
14
15
  import { BitId } from '@teambit/legacy-bit-id';
15
16
  import { LaneId } from '@teambit/lane-id';
16
17
  import { Consumer } from '@teambit/legacy/dist/consumer';
@@ -391,7 +392,7 @@ export declare class Workspace implements ComponentFactory {
391
392
  }>;
392
393
  getConfigMergeFilePath(): string;
393
394
  getConflictMergeFile(): MergeConflictFile;
394
- getDepsDataOfMergeConfig(id: BitId): Record<string, any> | undefined;
395
+ getDepsDataOfMergeConfig(id: ComponentID): Record<string, any> | undefined;
395
396
  getWorkspaceJsonConflictFromMergeConfig(): {
396
397
  data?: Record<string, any>;
397
398
  conflict: boolean;
@@ -401,6 +402,8 @@ export declare class Workspace implements ComponentFactory {
401
402
  getUnmergedComponent(componentId: ComponentID): Promise<Component | undefined>;
402
403
  isModified(component: Component): Promise<boolean>;
403
404
  isModifiedOrNew(component: Component): Promise<boolean>;
405
+ isExported(id: ComponentID): boolean;
406
+ getExportedFrom(ids: ComponentID[]): ComponentID[];
404
407
  /**
405
408
  * filter the given component-ids and set default-scope only to the new ones.
406
409
  * returns the affected components.
@@ -461,29 +464,22 @@ export declare class Workspace implements ComponentFactory {
461
464
  get legacyDefaultDirectory(): string;
462
465
  /**
463
466
  * Transform the id to ComponentId and get the exact id as appear in bitmap
464
- *
465
- * @param {(string | ComponentID | BitId)} id
466
- * @returns {Promise<ComponentID>}
467
- * @memberof Workspace
468
467
  */
469
- resolveComponentId(id: string | ComponentID | BitId): Promise<ComponentID>;
470
- resolveMultipleComponentIds(ids: Array<string | ComponentID | BitId>): Promise<ComponentID[]>;
468
+ resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>;
469
+ resolveMultipleComponentIds(ids: Array<string | ComponentID | ComponentID>): Promise<ComponentID[]>;
471
470
  /**
472
- * This will mutate the original extensions list and resolve it's ids
473
- *
474
- * @param {ExtensionDataList} extensions
475
- * @returns {Promise<void[]>}
476
- * @memberof Workspace
471
+ * component-id coming from Scope don't have the defaultScope, the legacyComponentId.scope is always populated.
472
+ * in the .bitmap we need to distinguish between the two, so the componentId needs to be corrected with the defaultScope.
477
473
  */
478
- resolveExtensionsList(extensions: ExtensionDataList): Promise<void[]>;
474
+ resolveIdWithDefaultScope(componentId: ComponentID): ComponentID;
479
475
  /**
480
- * This will mutate the original extensions list and make sure all extensions has the ids with the scope / default scope
476
+ * This will mutate the original extensions list and resolve it's ids
481
477
  *
482
478
  * @param {ExtensionDataList} extensions
483
479
  * @returns {Promise<void[]>}
484
480
  * @memberof Workspace
485
481
  */
486
- addDefaultScopeToExtensionsList(extensions: ExtensionDataList): Promise<void[]>;
482
+ resolveExtensionsList(extensions: ExtensionDataList): Promise<void[]>;
487
483
  /**
488
484
  * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
489
485
  * overrides in workspace.jsonc.
package/dist/workspace.js CHANGED
@@ -81,9 +81,9 @@ function _workspaceModules() {
81
81
  };
82
82
  return data;
83
83
  }
84
- function _bitId() {
85
- const data = require("@teambit/legacy/dist/bit-id");
86
- _bitId = function () {
84
+ function _componentId() {
85
+ const data = require("@teambit/component-id");
86
+ _componentId = function () {
87
87
  return data;
88
88
  };
89
89
  return data;
@@ -508,7 +508,7 @@ class Workspace {
508
508
  async hasModifiedDependencies(component) {
509
509
  const componentsList = new (_componentsList().default)(this.consumer);
510
510
  const listAutoTagPendingComponents = await componentsList.listAutoTagPendingComponents();
511
- const isAutoTag = listAutoTagPendingComponents.find(consumerComponent => consumerComponent.id.isEqualWithoutVersion(component.id._legacy));
511
+ const isAutoTag = listAutoTagPendingComponents.find(consumerComponent => consumerComponent.id.isEqualWithoutVersion(component.id));
512
512
  if (isAutoTag) return true;
513
513
  return false;
514
514
  }
@@ -524,7 +524,7 @@ class Workspace {
524
524
  * provides status of all components in the workspace.
525
525
  */
526
526
  async getComponentStatus(component) {
527
- const status = await this.consumer.getComponentStatusById(component.id._legacy);
527
+ const status = await this.consumer.getComponentStatusById(component.id);
528
528
  const hasModifiedDependencies = await this.hasModifiedDependencies(component);
529
529
  return _componentStatus().ComponentStatus.fromLegacy(status, hasModifiedDependencies, component.isOutdated());
530
530
  }
@@ -540,8 +540,7 @@ class Workspace {
540
540
  }
541
541
  async listWithInvalid(loadOpts) {
542
542
  const legacyIds = this.consumer.bitMap.getAllIdsAvailableOnLane();
543
- const ids = await this.resolveMultipleComponentIds(legacyIds);
544
- return this.componentLoader.getMany(ids, loadOpts, false);
543
+ return this.componentLoader.getMany(legacyIds, loadOpts, false);
545
544
  }
546
545
 
547
546
  /**
@@ -706,7 +705,7 @@ class Workspace {
706
705
  async getSavedGraphOfComponentIfExist(component) {
707
706
  let versionObj;
708
707
  try {
709
- versionObj = await this.scope.legacyScope.getVersionInstance(component.id._legacy);
708
+ versionObj = await this.scope.legacyScope.getVersionInstance(component.id);
710
709
  } catch (err) {
711
710
  return null;
712
711
  }
@@ -727,7 +726,7 @@ class Workspace {
727
726
  return tag || currentVer;
728
727
  };
729
728
  const currentVersion = getCurrentVersionAsTagIfPossible();
730
- flattenedBitIdCompIdMap[component.id._legacy.changeVersion(currentVersion).toString()] = component.id;
729
+ flattenedBitIdCompIdMap[component.id.changeVersion(currentVersion).toString()] = component.id;
731
730
  await Promise.all(versionObj.flattenedDependencies.map(async bitId => {
732
731
  flattenedBitIdCompIdMap[bitId.toString()] = await this.resolveComponentId(bitId);
733
732
  }));
@@ -757,9 +756,9 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
757
756
  async getDependentsIds(ids) {
758
757
  const workspaceGraph = await _scopeGraph().default.buildGraphFromWorkspace(this.consumer, true);
759
758
  const workspaceDependencyGraph = new (_scopeGraph().default)(workspaceGraph);
760
- const workspaceDependents = ids.map(id => workspaceDependencyGraph.getDependentsInfo(id._legacy));
759
+ const workspaceDependents = ids.map(id => workspaceDependencyGraph.getDependentsInfo(id));
761
760
  const dependentsLegacyIds = workspaceDependents.flat().map(_ => _.id);
762
- const dependentsLegacyNoDup = _bitId().BitIds.uniqFromArray(dependentsLegacyIds);
761
+ const dependentsLegacyNoDup = _componentId().ComponentIdList.uniqFromArray(dependentsLegacyIds);
763
762
  const dependentsIds = await this.resolveMultipleComponentIds(dependentsLegacyNoDup);
764
763
  return dependentsIds;
765
764
  }
@@ -778,10 +777,10 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
778
777
  */
779
778
  async getLegacyMinimal(id) {
780
779
  try {
781
- const componentMap = this.consumer.bitMap.getComponent(id._legacy);
780
+ const componentMap = this.consumer.bitMap.getComponent(id);
782
781
  return await _component2().default.loadFromFileSystem({
783
782
  componentMap,
784
- id: id._legacy,
783
+ id,
785
784
  consumer: this.consumer
786
785
  });
787
786
  } catch (err) {
@@ -800,7 +799,7 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
800
799
  });
801
800
  const repo = this.scope.legacyScope.objects;
802
801
  const getHeadFiles = async () => {
803
- const modelComp = await this.scope.legacyScope.getModelComponentIfExist(id._legacy);
802
+ const modelComp = await this.scope.legacyScope.getModelComponentIfExist(id);
804
803
  if (!modelComp) return [];
805
804
  const head = modelComp.getHeadRegardlessOfLane();
806
805
  if (!head) return [];
@@ -870,7 +869,7 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
870
869
  }
871
870
  clearComponentCache(id) {
872
871
  this.componentLoader.clearComponentCache(id);
873
- this.consumer.clearOneComponentCache(id._legacy);
872
+ this.consumer.clearOneComponentCache(id);
874
873
  this.componentList = new (_componentsList().default)(this.consumer);
875
874
  }
876
875
  async warmCache() {
@@ -1150,10 +1149,10 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1150
1149
  * whether a component exists in the workspace
1151
1150
  */
1152
1151
  exists(componentId) {
1153
- return Boolean(this.consumer.bitmapIdsFromCurrentLane.find(_ => _.isEqualWithoutVersion(componentId._legacy)));
1152
+ return Boolean(this.consumer.bitmapIdsFromCurrentLane.find(_ => _.isEqualWithoutVersion(componentId)));
1154
1153
  }
1155
1154
  getIdIfExist(componentId) {
1156
- const id = this.consumer.bitmapIdsFromCurrentLane.find(_ => _.isEqualWithoutVersion(componentId._legacy));
1155
+ const id = this.consumer.bitmapIdsFromCurrentLane.find(_ => _.isEqualWithoutVersion(componentId));
1157
1156
  if (!id) return undefined;
1158
1157
  return componentId.changeVersion(id.version);
1159
1158
  }
@@ -1191,7 +1190,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1191
1190
  this.logger.info(`current lane ${laneId.toString()} is missing, importing it`);
1192
1191
  await this.scope.legacyScope.objects.writeObjectsToTheFS([lane]);
1193
1192
  const scopeComponentsImporter = _scopeComponentsImporter().default.getInstance(this.scope.legacyScope);
1194
- const ids = _bitId().BitIds.fromArray(lane.toBitIds().filter(id => id.hasScope()));
1193
+ const ids = _componentId().ComponentIdList.fromArray(this.getExportedFrom(lane.toBitIds()));
1195
1194
  await scopeComponentsImporter.importWithoutDeps(ids.toVersionLatest(), {
1196
1195
  cache: false,
1197
1196
  lane,
@@ -1225,7 +1224,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1225
1224
  componentDir(componentId, bitMapOptions, options = {
1226
1225
  relative: false
1227
1226
  }) {
1228
- return this.componentDirFromLegacyId(componentId._legacy, bitMapOptions, options);
1227
+ return this.componentDirFromLegacyId(componentId, bitMapOptions, options);
1229
1228
  }
1230
1229
 
1231
1230
  /**
@@ -1347,11 +1346,11 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1347
1346
  }
1348
1347
  async listComponentsDuringMerge() {
1349
1348
  const unmergedComps = this.scope.legacyScope.objects.unmergedComponents.getComponents();
1350
- const bitIds = unmergedComps.map(u => new (_legacyBitId().BitId)(u.id));
1349
+ const bitIds = unmergedComps.map(u => _componentId().ComponentID.fromObject(u.id));
1351
1350
  return this.resolveMultipleComponentIds(bitIds);
1352
1351
  }
1353
1352
  async getUnmergedComponent(componentId) {
1354
- const unmerged = this.scope.legacyScope.objects.unmergedComponents.getEntry(componentId._legacy.name);
1353
+ const unmerged = this.scope.legacyScope.objects.unmergedComponents.getEntry(componentId.fullName);
1355
1354
  if (unmerged !== null && unmerged !== void 0 && unmerged.head) {
1356
1355
  return this.scope.get(componentId.changeVersion(unmerged === null || unmerged === void 0 ? void 0 : unmerged.head.toString()));
1357
1356
  }
@@ -1365,7 +1364,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1365
1364
 
1366
1365
  const consumerComp = component.state._consumer;
1367
1366
  if (typeof consumerComp._isModified === 'boolean') return consumerComp._isModified;
1368
- const componentStatus = await this.consumer.getComponentStatusById(component.id._legacy);
1367
+ const componentStatus = await this.consumer.getComponentStatusById(component.id);
1369
1368
  return componentStatus.modified === true;
1370
1369
  }
1371
1370
  async isModifiedOrNew(component) {
@@ -1376,6 +1375,13 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1376
1375
 
1377
1376
  return this.isModified(component);
1378
1377
  }
1378
+ isExported(id) {
1379
+ return this.consumer.isExported(id);
1380
+ }
1381
+ getExportedFrom(ids) {
1382
+ const notExported = this.consumer.getNotExportedIds();
1383
+ return ids.filter(id => !notExported.hasWithoutVersion(id));
1384
+ }
1379
1385
 
1380
1386
  /**
1381
1387
  * filter the given component-ids and set default-scope only to the new ones.
@@ -1604,15 +1610,11 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1604
1610
 
1605
1611
  /**
1606
1612
  * Transform the id to ComponentId and get the exact id as appear in bitmap
1607
- *
1608
- * @param {(string | ComponentID | BitId)} id
1609
- * @returns {Promise<ComponentID>}
1610
- * @memberof Workspace
1611
1613
  */
1612
1614
  async resolveComponentId(id) {
1613
1615
  if (id instanceof _legacyBitId().BitId && id.hasScope() && id.hasVersion()) {
1614
1616
  // an optimization to make it faster when BitId is passed
1615
- return _component().ComponentID.fromLegacy(id);
1617
+ return _componentId().ComponentID.fromLegacy(id);
1616
1618
  }
1617
1619
  const getDefaultScope = async (bitId, bitMapOptions) => {
1618
1620
  if (bitId.scope) {
@@ -1621,7 +1623,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1621
1623
  const relativeComponentDir = this.componentDirFromLegacyId(bitId, bitMapOptions, {
1622
1624
  relative: true
1623
1625
  });
1624
- const defaultScope = await this.componentDefaultScopeFromComponentDirAndName(relativeComponentDir, bitId.name);
1626
+ const defaultScope = await this.componentDefaultScopeFromComponentDirAndName(relativeComponentDir, bitId.fullName);
1625
1627
  return defaultScope;
1626
1628
  };
1627
1629
 
@@ -1632,7 +1634,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1632
1634
  // during this it will find the my-org.my-scope/react-native which is incorrect as the core one doesn't exist in the
1633
1635
  // workspace
1634
1636
  if (this.aspectLoader.isCoreAspect(id.toString())) {
1635
- return _component().ComponentID.fromString(id.toString());
1637
+ return _componentId().ComponentID.fromString(id.toString());
1636
1638
  }
1637
1639
  let legacyId = this.consumer.getParsedIdIfExist(id.toString(), true, true);
1638
1640
  if (legacyId) {
@@ -1643,7 +1645,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1643
1645
  const shouldSearchWithoutScopeInProvidedId = id.toString().startsWith(`${defaultScope}/`);
1644
1646
  legacyId = this.consumer.getParsedIdIfExist(id.toString(), true, shouldSearchWithoutScopeInProvidedId);
1645
1647
  if (legacyId) {
1646
- return _component().ComponentID.fromLegacy(legacyId, defaultScope);
1648
+ return _componentId().ComponentID.fromLegacy(legacyId._legacy, defaultScope);
1647
1649
  }
1648
1650
  }
1649
1651
  try {
@@ -1701,7 +1703,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1701
1703
  if (version) {
1702
1704
  _bitmapIdWithVersionForSource = _bitMapId.changeVersion(version);
1703
1705
  }
1704
- return _component().ComponentID.fromLegacy(_bitmapIdWithVersionForSource, defaultScopeForBitmapId);
1706
+ return _componentId().ComponentID.fromLegacy(_bitmapIdWithVersionForSource._legacy, defaultScopeForBitmapId);
1705
1707
  };
1706
1708
  // a case when the given id contains the default scope
1707
1709
  if (idWithVersion.startsWith(`${defaultScopeForBitmapId}/${_bitMapIdWithoutVersion}`)) {
@@ -1728,14 +1730,23 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1728
1730
  // Handle use case 3
1729
1731
  return await this.scope.resolveComponentId(idWithVersion);
1730
1732
  } catch (error) {
1731
- legacyId = _legacyBitId().BitId.parse(id.toString(), true);
1732
- return _component().ComponentID.fromLegacy(legacyId);
1733
+ return _componentId().ComponentID.fromString(id.toString());
1733
1734
  }
1734
1735
  }
1735
1736
  async resolveMultipleComponentIds(ids) {
1736
1737
  return Promise.all(ids.map(async id => this.resolveComponentId(id)));
1737
1738
  }
1738
1739
 
1740
+ /**
1741
+ * component-id coming from Scope don't have the defaultScope, the legacyComponentId.scope is always populated.
1742
+ * in the .bitmap we need to distinguish between the two, so the componentId needs to be corrected with the defaultScope.
1743
+ */
1744
+ resolveIdWithDefaultScope(componentId) {
1745
+ const isExported = !this.consumer.getNotExportedIds().searchWithoutVersion(componentId);
1746
+ const bitId = componentId._legacy.changeScope(isExported ? componentId.scope : undefined);
1747
+ return _componentId().ComponentID.fromLegacy(bitId, componentId.scope);
1748
+ }
1749
+
1739
1750
  /**
1740
1751
  * This will mutate the original extensions list and resolve it's ids
1741
1752
  *
@@ -1752,25 +1763,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1752
1763
 
1753
1764
  // Assuming extensionId always has scope - do not allow extension id without scope
1754
1765
  const resolvedId = await this.resolveComponentId(extensionEntry.extensionId);
1755
- extensionEntry.extensionId = resolvedId._legacy;
1756
- }
1757
- });
1758
- return Promise.all(resolveMergedExtensionsP);
1759
- }
1760
-
1761
- /**
1762
- * This will mutate the original extensions list and make sure all extensions has the ids with the scope / default scope
1763
- *
1764
- * @param {ExtensionDataList} extensions
1765
- * @returns {Promise<void[]>}
1766
- * @memberof Workspace
1767
- */
1768
- addDefaultScopeToExtensionsList(extensions) {
1769
- const resolveMergedExtensionsP = extensions.map(async extensionEntry => {
1770
- if (extensionEntry.extensionId && !extensionEntry.extensionId.hasScope()) {
1771
- const componentId = _component().ComponentID.fromLegacy(extensionEntry.extensionId);
1772
- const defaultScope = await this.componentDefaultScope(componentId);
1773
- extensionEntry.extensionId = extensionEntry.extensionId.changeScope(defaultScope);
1766
+ extensionEntry.extensionId = resolvedId;
1774
1767
  }
1775
1768
  });
1776
1769
  return Promise.all(resolveMergedExtensionsP);