@teambit/workspace 1.0.1135 → 1.0.1136
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/dist/auto-tag.d.ts +3 -3
- package/dist/auto-tag.js +6 -7
- package/dist/auto-tag.js.map +1 -1
- package/dist/{preview-1787765078175.js → preview-1787772816768.js} +2 -2
- package/dist/workspace-component/workspace-component-loader.d.ts +20 -0
- package/dist/workspace-component/workspace-component-loader.js +79 -2
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.js +2 -2
- package/dist/workspace.js.map +1 -1
- package/package.json +36 -36
- package/workspace-component/workspace-component-loader.ts +80 -1
package/dist/auto-tag.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ComponentIdList } from '@teambit/component-id';
|
|
2
|
-
import type { Consumer } from '@teambit/legacy.consumer';
|
|
3
2
|
import type { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';
|
|
4
|
-
|
|
3
|
+
import type { Workspace } from './workspace';
|
|
4
|
+
export declare function getAutoTagPending(workspace: Workspace, changedComponents: ComponentIdList): Promise<Component[]>;
|
|
5
5
|
export type AutoTagResult = {
|
|
6
6
|
component: Component;
|
|
7
7
|
triggeredBy: ComponentIdList;
|
|
8
8
|
};
|
|
9
|
-
export declare function getAutoTagInfo(
|
|
9
|
+
export declare function getAutoTagInfo(workspace: Workspace, changedComponents: ComponentIdList): Promise<AutoTagResult[]>;
|
package/dist/auto-tag.js
CHANGED
|
@@ -35,17 +35,16 @@ function _componentVersion() {
|
|
|
35
35
|
}
|
|
36
36
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
37
37
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
38
|
-
async function getAutoTagPending(
|
|
39
|
-
const autoTagInfo = await getAutoTagInfo(
|
|
38
|
+
async function getAutoTagPending(workspace, changedComponents) {
|
|
39
|
+
const autoTagInfo = await getAutoTagInfo(workspace, changedComponents);
|
|
40
40
|
return autoTagInfo.map(a => a.component);
|
|
41
41
|
}
|
|
42
|
-
async function getAutoTagInfo(
|
|
42
|
+
async function getAutoTagInfo(workspace, changedComponents) {
|
|
43
43
|
if (!changedComponents.length) return [];
|
|
44
|
-
const potentialComponents = potentialComponentsForAutoTagging(consumer, changedComponents);
|
|
44
|
+
const potentialComponents = potentialComponentsForAutoTagging(workspace.consumer, changedComponents);
|
|
45
45
|
const idsToLoad = new (_componentId().ComponentIdList)(...potentialComponents, ...changedComponents);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
} = await consumer.loadComponents(idsToLoad, false);
|
|
46
|
+
const workspaceComponents = await workspace.getMany(idsToLoad, undefined, false);
|
|
47
|
+
const components = workspaceComponents.map(workspaceComponent => workspaceComponent.state._consumer);
|
|
49
48
|
const graph = buildGraph(components);
|
|
50
49
|
const autoTagResults = [];
|
|
51
50
|
components.forEach(component => {
|
package/dist/auto-tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphlib","data","_interopRequireWildcard","require","_semver","_interopRequireDefault","_componentId","_componentVersion","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getAutoTagPending","consumer","changedComponents","autoTagInfo","getAutoTagInfo","map","a","component","length","potentialComponents","potentialComponentsForAutoTagging","idsToLoad","ComponentIdList","components","loadComponents","graph","buildGraph","autoTagResults","forEach","bitId","componentId","idStr","toStringWithoutVersion","hasNode","dependenciesStr","graphlib","alg","preorder","dependenciesBitIds","depStr","node","triggeredDependencies","filter","dependencyId","changedComponentId","searchWithoutVersion","isTag","version","semver","gte","push","triggeredBy","fromArray","Graph","componentsIds","c","id","getAllDependencies","dependency","depId","setNode","setEdge","modifiedComponents","candidateComponentsIds","bitMap","getAllBitIds","idsWithoutModified","candidateId","hasWithoutVersion"],"sources":["auto-tag.ts"],"sourcesContent":["import graphlib, { Graph } from 'graphlib';\nimport semver from 'semver';\nimport { ComponentIdList } from '@teambit/component-id';\nimport { isTag } from '@teambit/component-version';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport type { Dependency, ConsumerComponent as Component } from '@teambit/legacy.consumer-component';\n\nexport async function getAutoTagPending(consumer: Consumer, changedComponents: ComponentIdList): Promise<Component[]> {\n const autoTagInfo = await getAutoTagInfo(consumer, changedComponents);\n return autoTagInfo.map((a) => a.component);\n}\n\nexport type AutoTagResult = { component: Component; triggeredBy: ComponentIdList };\n\nexport async function getAutoTagInfo(consumer: Consumer, changedComponents: ComponentIdList): Promise<AutoTagResult[]> {\n if (!changedComponents.length) return [];\n const potentialComponents = potentialComponentsForAutoTagging(consumer, changedComponents);\n const idsToLoad = new ComponentIdList(...potentialComponents, ...changedComponents);\n const { components } = await consumer.loadComponents(idsToLoad, false);\n const graph = buildGraph(components);\n\n const autoTagResults: AutoTagResult[] = [];\n components.forEach((component) => {\n const bitId = component.componentId;\n const idStr = bitId.toStringWithoutVersion();\n if (!graph.hasNode(idStr)) return;\n // preorder gets all dependencies and dependencies of dependencies and so on.\n // we loop over the dependencies of a component\n // @ts-ignore\n const dependenciesStr = graphlib.alg.preorder(graph, idStr);\n const dependenciesBitIds = dependenciesStr.map((depStr) => graph.node(depStr));\n const triggeredDependencies = dependenciesBitIds.filter((dependencyId) => {\n const changedComponentId = changedComponents.searchWithoutVersion(dependencyId);\n if (!changedComponentId) {\n // the dependency hasn't changed, so the component is not auto-tag pending\n return false;\n }\n if (changedComponents.searchWithoutVersion(bitId)) {\n // the dependency has changed but also the component itself, so it's going to be tagged anyway\n return false;\n }\n // we only check whether a modified component may cause auto-tagging\n // since it's only modified on the file-system, its version might be the same as the version stored in its\n // dependents. That's why \"semver.gte\" is used instead of \"semver.gt\".\n // the case when it returns false is when the changedComponentId.version is smaller than\n // edgeId.version. it happens for example, when A => B (A depends on B), B has changed, A is\n // a candidate. A has the B dependency saved in the model with version 2.0.0 and B is now\n // tagged with 1.0.1. So, because A has B with a higher version already, we don't want to\n // auto-tag it and downgrade its B version.\n if (isTag(changedComponentId.version) && isTag(dependencyId.version)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return semver.gte(changedComponentId.version!, dependencyId.version!);\n }\n // when they're not tags but snaps, it is impossible to snap from a detached head so a\n // component is always candidate when its dependencies have changed.\n return true;\n });\n if (triggeredDependencies.length) {\n autoTagResults.push({ component, triggeredBy: ComponentIdList.fromArray(triggeredDependencies) });\n }\n });\n\n return autoTagResults;\n}\n\nfunction buildGraph(components: Component[]): Graph {\n const graph = new Graph();\n const componentsIds = ComponentIdList.fromArray(components.map((c) => c.id));\n\n components.forEach((component) => {\n const idStr = component.id.toStringWithoutVersion();\n component.getAllDependencies().forEach((dependency: Dependency) => {\n if (componentsIds.searchWithoutVersion(dependency.id)) {\n const depId = dependency.id.toStringWithoutVersion();\n // save the full ComponentID of a string id to be able to retrieve it later with no confusion\n if (!graph.hasNode(idStr)) graph.setNode(idStr, component.id);\n if (!graph.hasNode(depId)) graph.setNode(depId, dependency.id);\n graph.setEdge(idStr, depId);\n }\n });\n });\n return graph;\n}\n\nfunction potentialComponentsForAutoTagging(consumer: Consumer, modifiedComponents: ComponentIdList): ComponentIdList {\n const candidateComponentsIds = consumer.bitMap.getAllBitIds();\n // if a modified component is in candidates array, remove it from the array as it will be already\n // tagged with the correct version\n const idsWithoutModified = candidateComponentsIds.filter(\n (candidateId) => !modifiedComponents.hasWithoutVersion(candidateId)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AAC8B,SAAS,CAAC7B,UAAU,CAACR,GAAG,CAAEwC,CAAC,IAAKA,CAAC,CAACC,EAAE,CAAC,CAAC;EAE5EjC,UAAU,CAACK,OAAO,CAAEX,SAAS,IAAK;IAChC,MAAMc,KAAK,GAAGd,SAAS,CAACuC,EAAE,CAACxB,sBAAsB,CAAC,CAAC;IACnDf,SAAS,CAACwC,kBAAkB,CAAC,CAAC,CAAC7B,OAAO,CAAE8B,UAAsB,IAAK;MACjE,IAAIJ,aAAa,CAACT,oBAAoB,CAACa,UAAU,CAACF,EAAE,CAAC,EAAE;QACrD,MAAMG,KAAK,GAAGD,UAAU,CAACF,EAAE,CAACxB,sBAAsB,CAAC,CAAC;QACpD;QACA,IAAI,CAACP,KAAK,CAACQ,OAAO,CAACF,KAAK,CAAC,EAAEN,KAAK,CAACmC,OAAO,CAAC7B,KAAK,EAAEd,SAAS,CAACuC,EAAE,CAAC;QAC7D,IAAI,CAAC/B,KAAK,CAACQ,OAAO,CAAC0B,KAAK,CAAC,EAAElC,KAAK,CAACmC,OAAO,CAACD,KAAK,EAAED,UAAU,CAACF,EAAE,CAAC;QAC9D/B,KAAK,CAACoC,OAAO,CAAC9B,KAAK,EAAE4B,KAAK,CAAC;MAC7B;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOlC,KAAK;AACd;AAEA,SAASL,iCAAiCA,CAACT,QAAkB,EAAEmD,kBAAmC,EAAmB;EACnH,MAAMC,sBAAsB,GAAGpD,QAAQ,CAACqD,MAAM,CAACC,YAAY,CAAC,CAAC;EAC7D;EACA;EACA,MAAMC,kBAAkB,GAAGH,sBAAsB,CAACrB,MAAM,CACrDyB,WAAW,IAAK,CAACL,kBAAkB,CAACM,iBAAiB,CAACD,WAAW,CACpE,CAAC;EACD,OAAO7C,8BAAe,CAAC8B,SAAS,CAACc,kBAAkB,CAAC;AACtD","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_graphlib","data","_interopRequireWildcard","require","_semver","_interopRequireDefault","_componentId","_componentVersion","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","getAutoTagPending","workspace","changedComponents","autoTagInfo","getAutoTagInfo","map","a","component","length","potentialComponents","potentialComponentsForAutoTagging","consumer","idsToLoad","ComponentIdList","workspaceComponents","getMany","undefined","components","workspaceComponent","state","_consumer","graph","buildGraph","autoTagResults","forEach","bitId","componentId","idStr","toStringWithoutVersion","hasNode","dependenciesStr","graphlib","alg","preorder","dependenciesBitIds","depStr","node","triggeredDependencies","filter","dependencyId","changedComponentId","searchWithoutVersion","isTag","version","semver","gte","push","triggeredBy","fromArray","Graph","componentsIds","c","id","getAllDependencies","dependency","depId","setNode","setEdge","modifiedComponents","candidateComponentsIds","bitMap","getAllBitIds","idsWithoutModified","candidateId","hasWithoutVersion"],"sources":["auto-tag.ts"],"sourcesContent":["import graphlib, { Graph } from 'graphlib';\nimport semver from 'semver';\nimport { ComponentIdList } from '@teambit/component-id';\nimport { isTag } from '@teambit/component-version';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport type { Dependency, ConsumerComponent as Component } from '@teambit/legacy.consumer-component';\nimport type { Workspace } from './workspace';\n\nexport async function getAutoTagPending(\n workspace: Workspace,\n changedComponents: ComponentIdList\n): Promise<Component[]> {\n const autoTagInfo = await getAutoTagInfo(workspace, changedComponents);\n return autoTagInfo.map((a) => a.component);\n}\n\nexport type AutoTagResult = { component: Component; triggeredBy: ComponentIdList };\n\nexport async function getAutoTagInfo(\n workspace: Workspace,\n changedComponents: ComponentIdList\n): Promise<AutoTagResult[]> {\n if (!changedComponents.length) return [];\n const potentialComponents = potentialComponentsForAutoTagging(workspace.consumer, changedComponents);\n const idsToLoad = new ComponentIdList(...potentialComponents, ...changedComponents);\n const workspaceComponents = await workspace.getMany(idsToLoad, undefined, false);\n const components = workspaceComponents.map((workspaceComponent) => workspaceComponent.state._consumer);\n const graph = buildGraph(components);\n\n const autoTagResults: AutoTagResult[] = [];\n components.forEach((component) => {\n const bitId = component.componentId;\n const idStr = bitId.toStringWithoutVersion();\n if (!graph.hasNode(idStr)) return;\n // preorder gets all dependencies and dependencies of dependencies and so on.\n // we loop over the dependencies of a component\n // @ts-ignore\n const dependenciesStr = graphlib.alg.preorder(graph, idStr);\n const dependenciesBitIds = dependenciesStr.map((depStr) => graph.node(depStr));\n const triggeredDependencies = dependenciesBitIds.filter((dependencyId) => {\n const changedComponentId = changedComponents.searchWithoutVersion(dependencyId);\n if (!changedComponentId) {\n // the dependency hasn't changed, so the component is not auto-tag pending\n return false;\n }\n if (changedComponents.searchWithoutVersion(bitId)) {\n // the dependency has changed but also the component itself, so it's going to be tagged anyway\n return false;\n }\n // we only check whether a modified component may cause auto-tagging\n // since it's only modified on the file-system, its version might be the same as the version stored in its\n // dependents. That's why \"semver.gte\" is used instead of \"semver.gt\".\n // the case when it returns false is when the changedComponentId.version is smaller than\n // edgeId.version. it happens for example, when A => B (A depends on B), B has changed, A is\n // a candidate. A has the B dependency saved in the model with version 2.0.0 and B is now\n // tagged with 1.0.1. So, because A has B with a higher version already, we don't want to\n // auto-tag it and downgrade its B version.\n if (isTag(changedComponentId.version) && isTag(dependencyId.version)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return semver.gte(changedComponentId.version!, dependencyId.version!);\n }\n // when they're not tags but snaps, it is impossible to snap from a detached head so a\n // component is always candidate when its dependencies have changed.\n return true;\n });\n if (triggeredDependencies.length) {\n autoTagResults.push({ component, triggeredBy: ComponentIdList.fromArray(triggeredDependencies) });\n }\n });\n\n return autoTagResults;\n}\n\nfunction buildGraph(components: Component[]): Graph {\n const graph = new Graph();\n const componentsIds = ComponentIdList.fromArray(components.map((c) => c.id));\n\n components.forEach((component) => {\n const idStr = component.id.toStringWithoutVersion();\n component.getAllDependencies().forEach((dependency: Dependency) => {\n if (componentsIds.searchWithoutVersion(dependency.id)) {\n const depId = dependency.id.toStringWithoutVersion();\n // save the full ComponentID of a string id to be able to retrieve it later with no confusion\n if (!graph.hasNode(idStr)) graph.setNode(idStr, component.id);\n if (!graph.hasNode(depId)) graph.setNode(depId, dependency.id);\n graph.setEdge(idStr, depId);\n }\n });\n });\n return graph;\n}\n\nfunction potentialComponentsForAutoTagging(consumer: Consumer, modifiedComponents: ComponentIdList): ComponentIdList {\n const candidateComponentsIds = consumer.bitMap.getAllBitIds();\n // if a modified component is in candidates array, remove it from the array as it will be already\n // tagged with the correct version\n const idsWithoutModified = candidateComponentsIds.filter(\n (candidateId) => !modifiedComponents.hasWithoutVersion(candidateId)\n );\n return ComponentIdList.fromArray(idsWithoutModified);\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,aAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,YAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,kBAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,iBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmD,SAAAI,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAM,CAAA,EAAAG,CAAA,SAAAA,CAAA,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KAAK,CAAC;MAC7B;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOlC,KAAK;AACd;AAEA,SAASX,iCAAiCA,CAACC,QAAkB,EAAE+C,kBAAmC,EAAmB;EACnH,MAAMC,sBAAsB,GAAGhD,QAAQ,CAACiD,MAAM,CAACC,YAAY,CAAC,CAAC;EAC7D;EACA;EACA,MAAMC,kBAAkB,GAAGH,sBAAsB,CAACrB,MAAM,CACrDyB,WAAW,IAAK,CAACL,kBAAkB,CAACM,iBAAiB,CAACD,WAAW,CACpE,CAAC;EACD,OAAOlD,8BAAe,CAACmC,SAAS,CAACc,kBAAkB,CAAC;AACtD","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.1136/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.1136/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -61,6 +61,16 @@ export declare class WorkspaceComponentLoader {
|
|
|
61
61
|
*/
|
|
62
62
|
private componentsExtensionsCache;
|
|
63
63
|
private componentLoadedSelfAsAspects;
|
|
64
|
+
/**
|
|
65
|
+
* ids being loaded through the getMany pipeline within the current async call-chain, on behalf
|
|
66
|
+
* of a single `get` call. a re-entrant `get` of the same id from inside that pipeline (e.g. an
|
|
67
|
+
* onLoad subscriber asking for the component it's calculating) must use the direct flow,
|
|
68
|
+
* otherwise it recurses forever. an unrelated concurrent `get` of the same id is not part of
|
|
69
|
+
* the chain and awaits the in-flight load (singleLoadsInFlight) instead.
|
|
70
|
+
* see shouldDelegateToGetMany and loadOneThroughGetMany.
|
|
71
|
+
*/
|
|
72
|
+
private singleLoadChainContext;
|
|
73
|
+
private singleLoadsInFlight;
|
|
64
74
|
constructor(workspace: Workspace, logger: Logger, dependencyResolver: DependencyResolverMain, envs: EnvsMain, aspectLoader: AspectLoaderMain);
|
|
65
75
|
getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions, throwOnFailure?: boolean): Promise<GetManyRes>;
|
|
66
76
|
private getManyWithSpan;
|
|
@@ -103,6 +113,16 @@ export declare class WorkspaceComponentLoader {
|
|
|
103
113
|
getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]>;
|
|
104
114
|
get(componentId: ComponentID, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions, getOpts?: ComponentGetOneOptions): Promise<Component>;
|
|
105
115
|
private getWithSpan;
|
|
116
|
+
/**
|
|
117
|
+
* a cold single-component load resolves the component's env lazily in the middle of its own
|
|
118
|
+
* load, without the env-first group ordering of the getMany pipeline (see buildLoadGroups).
|
|
119
|
+
* when the env fails to load at that point, dependency policies silently fall back to defaults,
|
|
120
|
+
* producing a component with wrong dependency data (which then surfaces as phantom
|
|
121
|
+
* modifications in status/diff/merge). to keep one source of truth, a plain cache-miss load of
|
|
122
|
+
* a workspace component is delegated to the grouped pipeline.
|
|
123
|
+
*/
|
|
124
|
+
private shouldDelegateToGetMany;
|
|
125
|
+
private loadOneThroughGetMany;
|
|
106
126
|
getIfExist(componentId: ComponentID): Promise<Component | undefined>;
|
|
107
127
|
private resolveVersion;
|
|
108
128
|
private addMultipleEnvsIssueIfNeeded;
|
|
@@ -123,6 +123,13 @@ function _harmonyModules3() {
|
|
|
123
123
|
};
|
|
124
124
|
return data;
|
|
125
125
|
}
|
|
126
|
+
function _async_hooks() {
|
|
127
|
+
const data = require("async_hooks");
|
|
128
|
+
_async_hooks = function () {
|
|
129
|
+
return data;
|
|
130
|
+
};
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
126
133
|
function _workspaceComponent() {
|
|
127
134
|
const data = require("./workspace-component");
|
|
128
135
|
_workspaceComponent = function () {
|
|
@@ -144,7 +151,6 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
144
151
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
145
152
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
146
153
|
class WorkspaceComponentLoader {
|
|
147
|
-
// cache loaded components
|
|
148
154
|
constructor(workspace, logger, dependencyResolver, envs, aspectLoader) {
|
|
149
155
|
this.workspace = workspace;
|
|
150
156
|
this.logger = logger;
|
|
@@ -163,6 +169,17 @@ class WorkspaceComponentLoader {
|
|
|
163
169
|
*/
|
|
164
170
|
_defineProperty(this, "componentsExtensionsCache", void 0);
|
|
165
171
|
_defineProperty(this, "componentLoadedSelfAsAspects", void 0);
|
|
172
|
+
// cache loaded components
|
|
173
|
+
/**
|
|
174
|
+
* ids being loaded through the getMany pipeline within the current async call-chain, on behalf
|
|
175
|
+
* of a single `get` call. a re-entrant `get` of the same id from inside that pipeline (e.g. an
|
|
176
|
+
* onLoad subscriber asking for the component it's calculating) must use the direct flow,
|
|
177
|
+
* otherwise it recurses forever. an unrelated concurrent `get` of the same id is not part of
|
|
178
|
+
* the chain and awaits the in-flight load (singleLoadsInFlight) instead.
|
|
179
|
+
* see shouldDelegateToGetMany and loadOneThroughGetMany.
|
|
180
|
+
*/
|
|
181
|
+
_defineProperty(this, "singleLoadChainContext", new (_async_hooks().AsyncLocalStorage)());
|
|
182
|
+
_defineProperty(this, "singleLoadsInFlight", new Map());
|
|
166
183
|
this.componentsCache = (0, _harmonyModules2().createInMemoryCache)({
|
|
167
184
|
maxSize: (0, _harmonyModules2().getMaxSizeForComponents)()
|
|
168
185
|
});
|
|
@@ -878,8 +895,14 @@ class WorkspaceComponentLoader {
|
|
|
878
895
|
return fromCache;
|
|
879
896
|
}
|
|
880
897
|
span.setAttribute('componentsCache', 'miss');
|
|
881
|
-
let consumerComponent = legacyComponent;
|
|
882
898
|
const inWs = await this.isInWsIncludeDeleted(id);
|
|
899
|
+
if (!legacyComponent && this.shouldDelegateToGetMany(id, inWs, useCache, storeInCache, loadOpts)) {
|
|
900
|
+
const fromGetMany = await this.loadOneThroughGetMany(id);
|
|
901
|
+
if (fromGetMany) return fromGetMany;
|
|
902
|
+
// the grouped pipeline didn't yield the component (e.g. an out-of-sync id changed during
|
|
903
|
+
// the load). fall through so the flow below reports the precise error for the requested id.
|
|
904
|
+
}
|
|
905
|
+
let consumerComponent = legacyComponent;
|
|
883
906
|
if (inWs && !consumerComponent) {
|
|
884
907
|
consumerComponent = await (0, _harmonyModules3().loadSpan)('consumer-fs-load', {
|
|
885
908
|
id: id.toString()
|
|
@@ -896,6 +919,60 @@ class WorkspaceComponentLoader {
|
|
|
896
919
|
}
|
|
897
920
|
return component;
|
|
898
921
|
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* a cold single-component load resolves the component's env lazily in the middle of its own
|
|
925
|
+
* load, without the env-first group ordering of the getMany pipeline (see buildLoadGroups).
|
|
926
|
+
* when the env fails to load at that point, dependency policies silently fall back to defaults,
|
|
927
|
+
* producing a component with wrong dependency data (which then surfaces as phantom
|
|
928
|
+
* modifications in status/diff/merge). to keep one source of truth, a plain cache-miss load of
|
|
929
|
+
* a workspace component is delegated to the grouped pipeline.
|
|
930
|
+
*/
|
|
931
|
+
shouldDelegateToGetMany(id, inWs, useCache, storeInCache, loadOpts) {
|
|
932
|
+
if (!inWs) return false; // scope components load from the model, no dependency-policy calculation
|
|
933
|
+
if (!useCache || !storeInCache) return false; // getMany always uses and populates the cache
|
|
934
|
+
// any custom load-option means a caller-specific contract (partial load, docs/compositions
|
|
935
|
+
// flags, etc.). the getMany pipeline manages these options itself per load-stage, so only a
|
|
936
|
+
// plain full load can be delegated.
|
|
937
|
+
const isDefaultLoadOpts = !loadOpts || Object.entries(loadOpts).every(([key, value]) => value === undefined || (key === 'loadExtensions' || key === 'executeLoadSlot') && value === true);
|
|
938
|
+
if (!isDefaultLoadOpts) return false;
|
|
939
|
+
// re-entrance from within the pipeline of the same id (e.g. an onLoad subscriber asking for
|
|
940
|
+
// the component it's calculating) must use the direct flow, otherwise it recurses forever.
|
|
941
|
+
return !this.singleLoadChainContext.getStore()?.has(id.toString());
|
|
942
|
+
}
|
|
943
|
+
async loadOneThroughGetMany(id) {
|
|
944
|
+
const idStr = id.toString();
|
|
945
|
+
// an unrelated concurrent load of the same id joins the in-flight grouped load, rather than
|
|
946
|
+
// being mistaken for pipeline re-entrance and sent through the direct flow.
|
|
947
|
+
const inFlight = this.singleLoadsInFlight.get(idStr);
|
|
948
|
+
if (inFlight) return inFlight;
|
|
949
|
+
const chainIds = this.singleLoadChainContext.getStore() ?? new Set();
|
|
950
|
+
// the promise is created inside run() so the whole load executes within the chain context.
|
|
951
|
+
// (assigned via `let` because some @types/node versions type `run` as returning void)
|
|
952
|
+
let loadPromise;
|
|
953
|
+
this.singleLoadChainContext.run(new Set([...chainIds, idStr]), () => {
|
|
954
|
+
loadPromise = this.getMany([id]).then(({
|
|
955
|
+
components
|
|
956
|
+
}) => {
|
|
957
|
+
if (components.length === 1) return components[0];
|
|
958
|
+
// the load may have fixed an out-of-sync .bitmap and changed the component-id in the
|
|
959
|
+
// process (e.g. a stale version was removed or bumped). in that case getMany filtered the
|
|
960
|
+
// component out because it no longer matches the requested id. look it up by its updated
|
|
961
|
+
// .bitmap id.
|
|
962
|
+
const updatedBitmapId = this.workspace.consumer.bitmapIdsFromCurrentLaneIncludeRemoved.searchWithoutVersion(id);
|
|
963
|
+
if (updatedBitmapId && updatedBitmapId.version !== id.version) {
|
|
964
|
+
return this.getFromCache(updatedBitmapId, {
|
|
965
|
+
loadExtensions: true,
|
|
966
|
+
executeLoadSlot: true
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
return undefined;
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
const withCleanup = loadPromise.finally(() => this.singleLoadsInFlight.delete(idStr));
|
|
973
|
+
this.singleLoadsInFlight.set(idStr, withCleanup);
|
|
974
|
+
return withCleanup;
|
|
975
|
+
}
|
|
899
976
|
async getIfExist(componentId) {
|
|
900
977
|
try {
|
|
901
978
|
return await this.get(componentId);
|