@teambit/workspace 0.0.634 → 0.0.638
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.
- package/{__preview-1643301042596.js → __preview-1643685814554.js} +0 -0
- package/dist/workspace-component/workspace-component-loader.js +5 -2
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +9 -1
- package/dist/workspace.js +29 -9
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.provider.js +3 -1
- package/dist/workspace.provider.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.638.tgz +0 -0
- package/package.json +28 -28
- package/workspace-component/workspace-component-loader.ts +3 -4
- package/package-tar/teambit-workspace-0.0.634.tgz +0 -0
|
File without changes
|
|
@@ -320,12 +320,15 @@ class WorkspaceComponentLoader {
|
|
|
320
320
|
return componentFromScope;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
const {
|
|
324
|
+
extensions
|
|
325
|
+
} = await this.workspace.componentExtensions(id, componentFromScope);
|
|
324
326
|
const extensionsFromConsumerComponent = consumerComponent.extensions || new (_extensionData().ExtensionDataList)(); // Merge extensions added by the legacy code in memory (for example data of dependency resolver)
|
|
325
327
|
|
|
326
|
-
extensionDataList = _extensionData().ExtensionDataList.mergeConfigs([extensionsFromConsumerComponent,
|
|
328
|
+
const extensionDataList = _extensionData().ExtensionDataList.mergeConfigs([extensionsFromConsumerComponent, extensions]).filterRemovedExtensions(); // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data
|
|
327
329
|
// TODO: remove this once we remove all direct access from legacy code to extensions data
|
|
328
330
|
|
|
331
|
+
|
|
329
332
|
consumerComponent.extensions = extensionDataList;
|
|
330
333
|
const state = new (_component().State)(new (_component().Config)(consumerComponent.mainFile, extensionDataList), await this.workspace.createAspectList(extensionDataList), _component().ComponentFS.fromVinyls(consumerComponent.files), consumerComponent.dependencies, consumerComponent);
|
|
331
334
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAA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B,CAA7C;AACD;;AAEyB,QAAZ+D,YAAY,CAACtB,SAAD,EAAoBzC,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AA1QmC","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, 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 { 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 if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\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 ): 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);\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);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\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 this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\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\n let extensionDataList = 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 extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\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);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), 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): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\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) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\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) {\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"]}
|
|
1
|
+
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAA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,CAAP;AACD;;AAzQmC","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, 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 { 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 if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\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 ): 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);\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);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\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 this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\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);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), 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): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\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) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\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) {\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"]}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare type TrackData = {
|
|
|
67
67
|
[aspectName: string]: any;
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
+
export declare type ExtensionsOrigin = 'BitmapFile' | 'Model' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'WorkspaceDefault' | 'FinalAfterMerge';
|
|
70
71
|
export declare type TrackResult = {
|
|
71
72
|
componentName: string;
|
|
72
73
|
files: string[];
|
|
@@ -362,7 +363,14 @@ export declare class Workspace implements ComponentFactory {
|
|
|
362
363
|
* defaults extensions from workspace config
|
|
363
364
|
* extensions from the model.
|
|
364
365
|
*/
|
|
365
|
-
componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<
|
|
366
|
+
componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<{
|
|
367
|
+
extensions: ExtensionDataList;
|
|
368
|
+
beforeMerge: Array<{
|
|
369
|
+
extensions: ExtensionDataList;
|
|
370
|
+
origin: ExtensionsOrigin;
|
|
371
|
+
extraData: any;
|
|
372
|
+
}>;
|
|
373
|
+
}>;
|
|
366
374
|
private filterEnvsFromExtensionsIfNeeded;
|
|
367
375
|
triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
|
|
368
376
|
/**
|
package/dist/workspace.js
CHANGED
|
@@ -1389,7 +1389,11 @@ class Workspace {
|
|
|
1389
1389
|
const extensionsToMerge = [];
|
|
1390
1390
|
let envWasFoundPreviously = false;
|
|
1391
1391
|
|
|
1392
|
-
const addAndLoadExtensions = async extensions => {
|
|
1392
|
+
const addAndLoadExtensions = async (extensions, origin, extraData) => {
|
|
1393
|
+
if (!extensions.length) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1393
1397
|
const extsWithoutRemoved = extensions.filterRemovedExtensions();
|
|
1394
1398
|
const selfInMergedExtensions = extsWithoutRemoved.findExtension(componentId._legacy.toStringWithoutScopeAndVersion(), true, true);
|
|
1395
1399
|
const extsWithoutSelf = selfInMergedExtensions !== null && selfInMergedExtensions !== void 0 && selfInMergedExtensions.extensionId ? extsWithoutRemoved.remove(selfInMergedExtensions.extensionId) : extsWithoutRemoved;
|
|
@@ -1399,24 +1403,37 @@ class Workspace {
|
|
|
1399
1403
|
envIsCurrentlySet
|
|
1400
1404
|
} = this.filterEnvsFromExtensionsIfNeeded(extsWithoutSelf, envWasFoundPreviously);
|
|
1401
1405
|
if (envIsCurrentlySet) envWasFoundPreviously = true;
|
|
1402
|
-
extensionsToMerge.push(
|
|
1406
|
+
extensionsToMerge.push({
|
|
1407
|
+
origin,
|
|
1408
|
+
extensions: extensionDataListFiltered,
|
|
1409
|
+
extraData
|
|
1410
|
+
});
|
|
1403
1411
|
};
|
|
1404
1412
|
|
|
1405
1413
|
if (bitMapExtensions) {
|
|
1406
1414
|
const extensionsDataEntries = Object.keys(bitMapExtensions).map(aspectId => new (_extensionData().ExtensionDataEntry)(aspectId, undefined, aspectId, bitMapExtensions[aspectId]));
|
|
1407
1415
|
const extensionDataList = new (_extensionData().ExtensionDataList)(...extensionsDataEntries);
|
|
1408
|
-
await addAndLoadExtensions(extensionDataList);
|
|
1416
|
+
await addAndLoadExtensions(extensionDataList, 'BitmapFile');
|
|
1409
1417
|
}
|
|
1410
1418
|
|
|
1411
1419
|
if (configFileExtensions) {
|
|
1412
|
-
await addAndLoadExtensions(configFileExtensions);
|
|
1420
|
+
await addAndLoadExtensions(configFileExtensions, 'ComponentJsonFile');
|
|
1413
1421
|
}
|
|
1414
1422
|
|
|
1415
1423
|
let continuePropagating = (_componentConfigFile$ = componentConfigFile === null || componentConfigFile === void 0 ? void 0 : componentConfigFile.propagate) !== null && _componentConfigFile$ !== void 0 ? _componentConfigFile$ : true;
|
|
1416
1424
|
|
|
1417
1425
|
if (variantsExtensions && continuePropagating) {
|
|
1418
1426
|
// Put it in the start to make sure the config file is stronger
|
|
1419
|
-
|
|
1427
|
+
const appliedRules = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.sortedMatches.map(({
|
|
1428
|
+
pattern,
|
|
1429
|
+
specificity
|
|
1430
|
+
}) => ({
|
|
1431
|
+
pattern,
|
|
1432
|
+
specificity
|
|
1433
|
+
}));
|
|
1434
|
+
await addAndLoadExtensions(variantsExtensions, 'WorkspaceVariants', {
|
|
1435
|
+
appliedRules
|
|
1436
|
+
});
|
|
1420
1437
|
}
|
|
1421
1438
|
|
|
1422
1439
|
continuePropagating = continuePropagating && ((_variantConfig$propag = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.propagate) !== null && _variantConfig$propag !== void 0 ? _variantConfig$propag : true); // Do not apply default extensions on the default extensions (it will create infinite loop when loading them)
|
|
@@ -1425,19 +1442,22 @@ class Workspace {
|
|
|
1425
1442
|
|
|
1426
1443
|
if (wsDefaultExtensions && continuePropagating && !isDefaultExtension) {
|
|
1427
1444
|
// Put it in the start to make sure the config file is stronger
|
|
1428
|
-
await addAndLoadExtensions(wsDefaultExtensions);
|
|
1445
|
+
await addAndLoadExtensions(wsDefaultExtensions, 'WorkspaceDefault');
|
|
1429
1446
|
} // It's before the scope extensions, since there is no need to resolve extensions from scope they are already resolved
|
|
1430
1447
|
// await Promise.all(extensionsToMerge.map((extensions) => this.resolveExtensionsList(extensions)));
|
|
1431
1448
|
|
|
1432
1449
|
|
|
1433
1450
|
if (mergeFromScope && continuePropagating) {
|
|
1434
|
-
await addAndLoadExtensions(scopeExtensions);
|
|
1451
|
+
await addAndLoadExtensions(scopeExtensions, 'Model');
|
|
1435
1452
|
} // It's important to do this resolution before the merge, otherwise we have issues with extensions
|
|
1436
1453
|
// coming from scope with local scope name, as opposed to the same extension comes from the workspace with default scope name
|
|
1437
1454
|
|
|
1438
1455
|
|
|
1439
|
-
await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list)));
|
|
1440
|
-
return
|
|
1456
|
+
await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list.extensions)));
|
|
1457
|
+
return {
|
|
1458
|
+
extensions: _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge.map(ext => ext.extensions)),
|
|
1459
|
+
beforeMerge: extensionsToMerge
|
|
1460
|
+
};
|
|
1441
1461
|
}
|
|
1442
1462
|
|
|
1443
1463
|
filterEnvsFromExtensionsIfNeeded(extensionDataList, envWasFoundPreviously) {
|