@teambit/workspace 1.0.124 → 1.0.125
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/artifacts/preview/static/css/teambit.workspace/{workspace-preview.4f943af0.css → workspace-preview.24e04ec1.css} +2 -2
- package/artifacts/preview/teambit_workspace_workspace-preview.js +1 -1
- package/dist/{preview-1704358107276.js → preview-1704425059407.js} +2 -2
- package/dist/workspace-component/component-status-loader.d.ts +38 -0
- package/dist/workspace-component/component-status-loader.js +189 -0
- package/dist/workspace-component/component-status-loader.js.map +1 -0
- package/dist/workspace-component/component-status.d.ts +2 -2
- package/dist/workspace-component/component-status.js.map +1 -1
- package/dist/workspace.d.ts +11 -5
- package/dist/workspace.js +46 -11
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.main.runtime.js +1 -1
- package/dist/workspace.main.runtime.js.map +1 -1
- package/dist/workspace.provider.d.ts +5 -2
- package/dist/workspace.provider.js +2 -2
- package/dist/workspace.provider.js.map +1 -1
- package/package.json +21 -21
- package/workspace-component/component-status-loader.ts +135 -0
- package/workspace-component/component-status.ts +2 -2
package/dist/workspace.js
CHANGED
|
@@ -319,6 +319,13 @@ function _filter() {
|
|
|
319
319
|
};
|
|
320
320
|
return data;
|
|
321
321
|
}
|
|
322
|
+
function _componentStatusLoader() {
|
|
323
|
+
const data = require("./workspace-component/component-status-loader");
|
|
324
|
+
_componentStatusLoader = function () {
|
|
325
|
+
return data;
|
|
326
|
+
};
|
|
327
|
+
return data;
|
|
328
|
+
}
|
|
322
329
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
323
330
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
324
331
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -367,7 +374,7 @@ class Workspace {
|
|
|
367
374
|
/**
|
|
368
375
|
* on component add slot.
|
|
369
376
|
*/
|
|
370
|
-
onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql, onBitmapChangeSlot) {
|
|
377
|
+
onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql, onBitmapChangeSlot, onWorkspaceConfigChangeSlot) {
|
|
371
378
|
this.pubsub = pubsub;
|
|
372
379
|
this.config = config;
|
|
373
380
|
this.consumer = consumer;
|
|
@@ -389,12 +396,14 @@ class Workspace {
|
|
|
389
396
|
this.onRootAspectAddedSlot = onRootAspectAddedSlot;
|
|
390
397
|
this.graphql = graphql;
|
|
391
398
|
this.onBitmapChangeSlot = onBitmapChangeSlot;
|
|
399
|
+
this.onWorkspaceConfigChangeSlot = onWorkspaceConfigChangeSlot;
|
|
392
400
|
_defineProperty(this, "warnedAboutMisconfiguredEnvs", []);
|
|
393
401
|
// cache env-ids that have been errored about not having "env" type
|
|
394
402
|
_defineProperty(this, "priority", true);
|
|
395
403
|
_defineProperty(this, "owner", void 0);
|
|
396
404
|
_defineProperty(this, "componentsScopeDirsMap", void 0);
|
|
397
405
|
_defineProperty(this, "componentLoader", void 0);
|
|
406
|
+
_defineProperty(this, "componentStatusLoader", void 0);
|
|
398
407
|
_defineProperty(this, "bitMap", void 0);
|
|
399
408
|
/**
|
|
400
409
|
* Indicate that we are now running installation process
|
|
@@ -427,6 +436,7 @@ class Workspace {
|
|
|
427
436
|
});
|
|
428
437
|
this.aspectsMerger = new (_aspectsMerger().AspectsMerger)(this, this.harmony);
|
|
429
438
|
this.filter = new (_filter().Filter)(this);
|
|
439
|
+
this.componentStatusLoader = new (_componentStatusLoader().ComponentStatusLoader)(this);
|
|
430
440
|
}
|
|
431
441
|
validateConfig() {
|
|
432
442
|
if (this.consumer.isLegacy) return;
|
|
@@ -470,6 +480,9 @@ class Workspace {
|
|
|
470
480
|
this.onBitmapChangeSlot.register(OnBitmapChangeFunc);
|
|
471
481
|
return this;
|
|
472
482
|
}
|
|
483
|
+
registerOnWorkspaceConfigChange(onWorkspaceConfigChangeFunc) {
|
|
484
|
+
this.onWorkspaceConfigChangeSlot.register(onWorkspaceConfigChangeFunc);
|
|
485
|
+
}
|
|
473
486
|
registerOnAspectsResolve(onAspectsResolveFunc) {
|
|
474
487
|
this.onAspectsResolveSlot.register(onAspectsResolveFunc);
|
|
475
488
|
return this;
|
|
@@ -491,10 +504,18 @@ class Workspace {
|
|
|
491
504
|
get icon() {
|
|
492
505
|
return this.config.icon;
|
|
493
506
|
}
|
|
494
|
-
async
|
|
507
|
+
async listAutoTagPendingComponentIds() {
|
|
495
508
|
const componentsList = new (_componentsList().default)(this.consumer);
|
|
496
|
-
const
|
|
497
|
-
const
|
|
509
|
+
const modifiedComponents = (await this.modified()).map(c => c.id);
|
|
510
|
+
const newComponents = await componentsList.listNewComponents();
|
|
511
|
+
if (!modifiedComponents || !modifiedComponents.length) return [];
|
|
512
|
+
const autoTagPending = await this.consumer.listComponentsForAutoTagging(_componentId().ComponentIdList.fromArray(modifiedComponents));
|
|
513
|
+
const comps = autoTagPending.filter(autoTagComp => !newComponents.has(autoTagComp.componentId));
|
|
514
|
+
return comps.map(c => c.id);
|
|
515
|
+
}
|
|
516
|
+
async hasModifiedDependencies(component) {
|
|
517
|
+
const listAutoTagPendingComponents = await this.listAutoTagPendingComponentIds();
|
|
518
|
+
const isAutoTag = listAutoTagPendingComponents.find(id => id.isEqualWithoutVersion(component.id));
|
|
498
519
|
if (isAutoTag) return true;
|
|
499
520
|
return false;
|
|
500
521
|
}
|
|
@@ -510,7 +531,7 @@ class Workspace {
|
|
|
510
531
|
* provides status of all components in the workspace.
|
|
511
532
|
*/
|
|
512
533
|
async getComponentStatus(component) {
|
|
513
|
-
const status = await this.
|
|
534
|
+
const status = await this.getComponentStatusById(component.id);
|
|
514
535
|
const hasModifiedDependencies = await this.hasModifiedDependencies(component);
|
|
515
536
|
return _componentStatus().ComponentStatus.fromLegacy(status, hasModifiedDependencies, component.isOutdated());
|
|
516
537
|
}
|
|
@@ -599,9 +620,11 @@ class Workspace {
|
|
|
599
620
|
/**
|
|
600
621
|
* list all modified components in the workspace.
|
|
601
622
|
*/
|
|
602
|
-
async modified() {
|
|
603
|
-
const
|
|
604
|
-
|
|
623
|
+
async modified(loadOpts) {
|
|
624
|
+
const {
|
|
625
|
+
components
|
|
626
|
+
} = await this.listWithInvalid(loadOpts);
|
|
627
|
+
const modifiedIncludeNulls = await (0, _pMapSeries().default)(components, async component => {
|
|
605
628
|
const modified = await this.isModified(component);
|
|
606
629
|
return modified ? component : null;
|
|
607
630
|
});
|
|
@@ -847,6 +870,7 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
847
870
|
this.logger.debug('clearing the workspace and scope caches');
|
|
848
871
|
delete this._cachedListIds;
|
|
849
872
|
this.componentLoader.clearCache();
|
|
873
|
+
this.componentStatusLoader.clearCache();
|
|
850
874
|
await this.scope.clearCache();
|
|
851
875
|
this.componentList = new (_componentsList().default)(this.consumer);
|
|
852
876
|
this.componentDefaultScopeFromComponentDirAndNameWithoutConfigFileMemoized.clear();
|
|
@@ -854,10 +878,12 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
854
878
|
clearAllComponentsCache() {
|
|
855
879
|
this.componentLoader.clearCache();
|
|
856
880
|
this.consumer.componentLoader.clearComponentsCache();
|
|
881
|
+
this.componentStatusLoader.clearCache();
|
|
857
882
|
this.componentList = new (_componentsList().default)(this.consumer);
|
|
858
883
|
}
|
|
859
884
|
clearComponentCache(id) {
|
|
860
885
|
this.componentLoader.clearComponentCache(id);
|
|
886
|
+
this.componentStatusLoader.clearOneComponentCache(id);
|
|
861
887
|
this.consumer.clearOneComponentCache(id);
|
|
862
888
|
this.componentList = new (_componentsList().default)(this.consumer);
|
|
863
889
|
}
|
|
@@ -937,8 +963,7 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
937
963
|
}
|
|
938
964
|
|
|
939
965
|
/**
|
|
940
|
-
*
|
|
941
|
-
* currently, the purpose is to reload the workspace config when it changes, so entries like "defaultScope" are updated.
|
|
966
|
+
* the purpose is mostly to reload the workspace config when it changes, so entries like "defaultScope" are updated.
|
|
942
967
|
* it also updates the DependencyResolver config. I couldn't find a good way to update all aspects in workspace.jsonc.
|
|
943
968
|
*/
|
|
944
969
|
async triggerOnWorkspaceConfigChange() {
|
|
@@ -953,6 +978,10 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
953
978
|
const configOfDepResolverAspect = workspaceConfig.extensions.findExtension(_dependencyResolver().DependencyResolverAspect.id);
|
|
954
979
|
if (configOfDepResolverAspect) this.dependencyResolver.setConfig(configOfDepResolverAspect.config);
|
|
955
980
|
this.dependencyResolver.clearCache();
|
|
981
|
+
const onWorkspaceConfigChangeEntries = this.onWorkspaceConfigChangeSlot.toArray(); // e.g. [ [ 'teambit.bit/compiler', [Function: bound onComponentChange] ] ]
|
|
982
|
+
await (0, _pMapSeries().default)(onWorkspaceConfigChangeEntries, async ([, onWorkspaceConfigFunc]) => {
|
|
983
|
+
await onWorkspaceConfigFunc();
|
|
984
|
+
});
|
|
956
985
|
}
|
|
957
986
|
getState(id, hash) {
|
|
958
987
|
return this.scope.getState(id, hash);
|
|
@@ -1407,7 +1436,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1407
1436
|
}
|
|
1408
1437
|
const consumerComp = component.state._consumer;
|
|
1409
1438
|
if (typeof consumerComp._isModified === 'boolean') return consumerComp._isModified;
|
|
1410
|
-
const componentStatus = await this.
|
|
1439
|
+
const componentStatus = await this.getComponentStatusById(component.id);
|
|
1411
1440
|
return componentStatus.modified === true;
|
|
1412
1441
|
}
|
|
1413
1442
|
async isModifiedOrNew(component) {
|
|
@@ -1995,6 +2024,12 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1995
2024
|
}
|
|
1996
2025
|
return undefined;
|
|
1997
2026
|
}
|
|
2027
|
+
async getManyComponentsStatuses(ids) {
|
|
2028
|
+
return this.componentStatusLoader.getManyComponentsStatuses(ids);
|
|
2029
|
+
}
|
|
2030
|
+
async getComponentStatusById(id) {
|
|
2031
|
+
return this.componentStatusLoader.getComponentStatusById(id);
|
|
2032
|
+
}
|
|
1998
2033
|
}
|
|
1999
2034
|
|
|
2000
2035
|
/**
|