@teambit/scope 0.0.843 → 0.0.846

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,2 @@
1
1
  export { ComponentNotFound } from './component-not-found';
2
+ export { NoIdMatchPattern } from './no-id-match-pattern';
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "ComponentNotFound", {
9
9
  return _componentNotFound().ComponentNotFound;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "NoIdMatchPattern", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _noIdMatchPattern().NoIdMatchPattern;
16
+ }
17
+ });
12
18
 
13
19
  function _componentNotFound() {
14
20
  const data = require("./component-not-found");
@@ -20,4 +26,14 @@ function _componentNotFound() {
20
26
  return data;
21
27
  }
22
28
 
29
+ function _noIdMatchPattern() {
30
+ const data = require("./no-id-match-pattern");
31
+
32
+ _noIdMatchPattern = function () {
33
+ return data;
34
+ };
35
+
36
+ return data;
37
+ }
38
+
23
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ComponentNotFound } from './component-not-found';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ComponentNotFound } from './component-not-found';\nexport { NoIdMatchPattern } from './no-id-match-pattern';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -0,0 +1,4 @@
1
+ import { BitError } from '@teambit/bit-error';
2
+ export declare class NoIdMatchPattern extends BitError {
3
+ constructor(pattern: string);
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NoIdMatchPattern = void 0;
7
+
8
+ function _bitError() {
9
+ const data = require("@teambit/bit-error");
10
+
11
+ _bitError = function () {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ class NoIdMatchPattern extends _bitError().BitError {
19
+ constructor(pattern) {
20
+ super(`unable to find any matching for "${pattern}" pattern`);
21
+ }
22
+
23
+ }
24
+
25
+ exports.NoIdMatchPattern = NoIdMatchPattern;
26
+
27
+ //# sourceMappingURL=no-id-match-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NoIdMatchPattern","BitError","constructor","pattern"],"sources":["no-id-match-pattern.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\n\nexport class NoIdMatchPattern extends BitError {\n constructor(pattern: string) {\n super(`unable to find any matching for \"${pattern}\" pattern`);\n }\n}\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,gBAAN,SAA+BC,oBAA/B,CAAwC;EAC7CC,WAAW,CAACC,OAAD,EAAkB;IAC3B,MAAO,oCAAmCA,OAAQ,WAAlD;EACD;;AAH4C"}
@@ -5,4 +5,6 @@ export declare type GetScopeOptions = {
5
5
  scope: ScopeModel | undefined;
6
6
  };
7
7
  Corner?: ComponentType;
8
+ paneClassName?: string;
9
+ TargetScopeOverview?: ComponentType;
8
10
  };
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["get-scope-options.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport { ScopeModel } from '.';\n\nexport type GetScopeOptions = {\n useScope?: () => { scope: ScopeModel | undefined };\n Corner?: ComponentType;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["get-scope-options.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport { ScopeModel } from '.';\n\nexport type GetScopeOptions = {\n useScope?: () => { scope: ScopeModel | undefined };\n Corner?: ComponentType;\n paneClassName?: string;\n TargetScopeOverview?: ComponentType\n};\n"],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ScopeAspect } from './scope.aspect';
2
- export { ComponentNotFound } from './exceptions';
2
+ export { ComponentNotFound, NoIdMatchPattern } from './exceptions';
3
3
  export { ScopeComponentCard } from './ui/scope-overview/scope-overview';
4
4
  export type { ScopeMain, OnTag, OnTagResults } from './scope.main.runtime';
5
5
  export type { ScopeModel } from '@teambit/scope.models.scope-model';
package/dist/index.js CHANGED
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "ComponentNotFound", {
9
9
  return _exceptions().ComponentNotFound;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "NoIdMatchPattern", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _exceptions().NoIdMatchPattern;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "ScopeAspect", {
13
19
  enumerable: true,
14
20
  get: function () {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ScopeAspect"],"sources":["index.ts"],"sourcesContent":["import { ScopeAspect } from './scope.aspect';\n\nexport { ComponentNotFound } from './exceptions';\nexport { ScopeComponentCard } from './ui/scope-overview/scope-overview';\nexport type { ScopeMain, OnTag, OnTagResults } from './scope.main.runtime';\nexport type { ScopeModel } from '@teambit/scope.models.scope-model';\nexport { ScopeContext } from '@teambit/scope.ui.hooks.scope-context';\nexport type { ScopeUI, ScopeBadgeSlot, ScopeOverview, ScopeOverviewSlot, OverviewLineSlot } from './scope.ui.runtime';\nexport { ScopeAspect };\nexport default ScopeAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;eAGeA,oB"}
1
+ {"version":3,"names":["ScopeAspect"],"sources":["index.ts"],"sourcesContent":["import { ScopeAspect } from './scope.aspect';\n\nexport { ComponentNotFound, NoIdMatchPattern } from './exceptions';\nexport { ScopeComponentCard } from './ui/scope-overview/scope-overview';\nexport type { ScopeMain, OnTag, OnTagResults } from './scope.main.runtime';\nexport type { ScopeModel } from '@teambit/scope.models.scope-model';\nexport { ScopeContext } from '@teambit/scope.ui.hooks.scope-context';\nexport type { ScopeUI, ScopeBadgeSlot, ScopeOverview, ScopeOverviewSlot, OverviewLineSlot } from './scope.ui.runtime';\nexport { ScopeAspect };\nexport default ScopeAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;eAGeA,oB"}
@@ -173,13 +173,16 @@ export declare class ScopeMain implements ComponentFactory {
173
173
  * @param ids
174
174
  */
175
175
  groupAspectIdsByEnvOfTheList(ids: string[]): Promise<{
176
- envs: string[];
177
- other: string[];
176
+ envs?: string[];
177
+ other?: string[];
178
178
  }>;
179
179
  private getManifestsAndLoadAspects;
180
180
  getManifestsGraphRecursively(ids: string[], visited?: string[], throwOnError?: boolean, opts?: {
181
181
  packageManagerConfigRootDir?: string;
182
- }): Promise<ManifestOrAspect[]>;
182
+ }): Promise<{
183
+ manifests: ManifestOrAspect[];
184
+ potentialPluginsIds: string[];
185
+ }>;
183
186
  private getNonLoadedAspects;
184
187
  private resolveLocalAspects;
185
188
  getResolvedAspects(components: Component[], opts?: {
@@ -453,6 +453,16 @@ function _stagedConfig() {
453
453
  return data;
454
454
  }
455
455
 
456
+ function _noIdMatchPattern() {
457
+ const data = require("./exceptions/no-id-match-pattern");
458
+
459
+ _noIdMatchPattern = function () {
460
+ return data;
461
+ };
462
+
463
+ return data;
464
+ }
465
+
456
466
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
457
467
 
458
468
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -741,12 +751,20 @@ class ScopeMain {
741
751
  }
742
752
 
743
753
  async loadAspects(ids, throwOnError = false, neededFor) {
744
- this.logger.info(`loadAspects, loading ${ids.length} aspects.
754
+ var _grouped$envs, _grouped$other;
755
+
756
+ // generate a random callId to be able to identify the call from the logs
757
+ const callId = Math.floor(Math.random() * 1000);
758
+ const loggerPrefix = `[${callId}] loadAspects,`;
759
+ this.logger.info(`${loggerPrefix} loading ${ids.length} aspects.
745
760
  ids: ${ids.join(', ')}
746
761
  needed-for: ${neededFor || '<unknown>'}`);
747
762
  const grouped = await this.groupAspectIdsByEnvOfTheList(ids);
763
+ this.logger.info(`${loggerPrefix} getManifestsAndLoadAspects for grouped.envs, total ${((_grouped$envs = grouped.envs) === null || _grouped$envs === void 0 ? void 0 : _grouped$envs.length) || 0}`);
748
764
  const envsManifestsIds = await this.getManifestsAndLoadAspects(grouped.envs, throwOnError);
765
+ this.logger.info(`${loggerPrefix} getManifestsAndLoadAspects for grouped.other, total ${((_grouped$other = grouped.other) === null || _grouped$other === void 0 ? void 0 : _grouped$other.length) || 0}`);
749
766
  const otherManifestsIds = await this.getManifestsAndLoadAspects(grouped.other, throwOnError);
767
+ this.logger.debug(`${loggerPrefix} finish loading aspects`);
750
768
  return envsManifestsIds.concat(otherManifestsIds);
751
769
  }
752
770
  /**
@@ -765,10 +783,18 @@ needed-for: ${neededFor || '<unknown>'}`);
765
783
  return grouped;
766
784
  }
767
785
 
768
- async getManifestsAndLoadAspects(ids, throwOnError = false) {
769
- const scopeManifests = await this.getManifestsGraphRecursively(ids, [], throwOnError);
786
+ async getManifestsAndLoadAspects(ids = [], throwOnError = false) {
787
+ const {
788
+ manifests: scopeManifests,
789
+ potentialPluginsIds
790
+ } = await this.getManifestsGraphRecursively(ids, [], throwOnError);
770
791
  await this.aspectLoader.loadExtensionsByManifests(scopeManifests);
771
- return (0, _lodash().compact)(scopeManifests.map(manifest => manifest.id));
792
+ const {
793
+ manifests: scopePluginsManifests
794
+ } = await this.getManifestsGraphRecursively(potentialPluginsIds, [], throwOnError);
795
+ await this.aspectLoader.loadExtensionsByManifests(scopePluginsManifests);
796
+ const allManifests = scopeManifests.concat(scopePluginsManifests);
797
+ return (0, _lodash().compact)(allManifests.map(manifest => manifest.id));
772
798
  }
773
799
 
774
800
  async getManifestsGraphRecursively(ids, visited = [], throwOnError = false, opts = {}) {
@@ -777,12 +803,24 @@ needed-for: ${neededFor || '<unknown>'}`);
777
803
  const nonVisitedId = ids.filter(id => !visited.includes(id));
778
804
 
779
805
  if (!nonVisitedId.length) {
780
- return [];
806
+ return {
807
+ manifests: [],
808
+ potentialPluginsIds: []
809
+ };
781
810
  }
782
811
 
783
- const components = await this.getNonLoadedAspects(nonVisitedId);
812
+ const components = await this.getNonLoadedAspects(nonVisitedId); // Adding all the envs ids to the array to support case when one (or more) of the aspects has custom aspect env
813
+
814
+ const customEnvsIds = components.map(component => this.envs.getEnvId(component)).filter(envId => !this.aspectLoader.isCoreEnv(envId)); // In case there is custom env we need to load it right away, otherwise we will fail during the require aspects
815
+
816
+ await this.getManifestsAndLoadAspects(customEnvsIds);
784
817
  visited.push(...nonVisitedId);
785
818
  const manifests = await this.requireAspects(components, throwOnError, opts);
819
+ const potentialPluginsIds = (0, _lodash().compact)(manifests.map((manifest, index) => {
820
+ if (this.aspectLoader.isValidAspect(manifest)) return undefined; // return index;
821
+
822
+ return components[index].id.toString();
823
+ }));
786
824
  const depsToLoad = [];
787
825
  await (0, _pMapSeries().default)(manifests, async manifest => {
788
826
  depsToLoad.push(...(manifest.dependencies || [])); // @ts-ignore
@@ -791,10 +829,16 @@ needed-for: ${neededFor || '<unknown>'}`);
791
829
  depsToLoad.push(...(runtime.dependencies || []));
792
830
  });
793
831
  const depIds = depsToLoad.map(d => d.id).filter(id => id);
794
- const loaded = await this.getManifestsGraphRecursively(depIds, visited, throwOnError);
832
+ this.logger.debug(`getManifestsGraphRecursively, id: ${manifest.id || '<unknown>'}, found ${depIds.length}: ${depIds.join(', ')}`);
833
+ const {
834
+ manifests: loaded
835
+ } = await this.getManifestsGraphRecursively(depIds, visited, throwOnError);
795
836
  manifests.push(...loaded);
796
837
  });
797
- return manifests;
838
+ return {
839
+ manifests,
840
+ potentialPluginsIds
841
+ };
798
842
  }
799
843
 
800
844
  async getNonLoadedAspects(ids) {
@@ -985,7 +1029,8 @@ needed-for: ${neededFor || '<unknown>'}`);
985
1029
  useNesting: true
986
1030
  },
987
1031
  host: this
988
- }, this.legacyScope);
1032
+ }, this.legacyScope); // @ts-ignore
1033
+
989
1034
  const capsules = network.seedersCapsules;
990
1035
  const aspectDefs = await this.aspectLoader.resolveAspects(components, async component => {
991
1036
  const capsule = capsules.getCapsule(component.id);
@@ -1323,7 +1368,7 @@ needed-for: ${neededFor || '<unknown>'}`);
1323
1368
  const idsFiltered = ids.filter(id => (0, _multimatch().default)(idsToCheck(id), patterns).length);
1324
1369
 
1325
1370
  if (throwForNoMatch && !idsFiltered.length) {
1326
- throw new (_bitError().BitError)(`unable to find any matching for "${pattern}" pattern`);
1371
+ throw new (_noIdMatchPattern().NoIdMatchPattern)(pattern);
1327
1372
  }
1328
1373
 
1329
1374
  return idsFiltered;