@teambit/workspace 0.0.1096 → 0.0.1097

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/index.d.ts CHANGED
@@ -12,5 +12,6 @@ export { WorkspaceContext } from './ui/workspace/workspace-context';
12
12
  export { OutsideWorkspaceError } from './exceptions/outside-workspace';
13
13
  export type { WorkspaceComponent } from './workspace-component';
14
14
  export type { ComponentConfigFile } from './component-config-file';
15
+ export type { CompFiles, FilesStatus } from './workspace-component/comp-files';
15
16
  export { WorkspaceAspect };
16
17
  export default WorkspaceAspect;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport { OutsideWorkspaceError } from './exceptions/outside-workspace';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAuE,eAKxDA,4BAAe;AAAA"}
1
+ {"version":3,"names":["WorkspaceAspect"],"sources":["index.ts"],"sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentLoad, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent, Workspace as WorkspaceModel } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport { OutsideWorkspaceError } from './exceptions/outside-workspace';\nexport type { WorkspaceComponent } from './workspace-component';\nexport type { ComponentConfigFile } from './component-config-file';\nexport type { CompFiles, FilesStatus } from './workspace-component/comp-files';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAuE,eAMxDA,4BAAe;AAAA"}
@@ -7,7 +7,7 @@ export declare type SerializableResults = {
7
7
  };
8
8
  export declare type OnComponentChange = (component: Component, files: string[], // os absolute paths
9
9
  removedFiles?: string[], // os absolute paths
10
- initiator?: CompilationInitiator) => Promise<SerializableResults>;
10
+ initiator?: CompilationInitiator) => Promise<SerializableResults | void>;
11
11
  export declare type OnComponentAdd = (component: Component, files: string[]) => Promise<SerializableResults>;
12
12
  export declare type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;
13
13
  export declare type OnComponentEventResult = {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["on-component-events.ts"],"sourcesContent":["import { Component, ComponentID, AspectData } from '@teambit/component';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\n\nexport type SerializableResults = { results: any; toString: () => string };\nexport type OnComponentChange = (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[], // os absolute paths\n initiator?: CompilationInitiator\n) => Promise<SerializableResults>;\nexport type OnComponentAdd = (component: Component, files: string[]) => Promise<SerializableResults>;\nexport type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;\nexport type OnComponentEventResult = { extensionId: string; results: SerializableResults };\n\nexport type OnComponentLoad = (\n component: Component,\n loadOpts?: ComponentLoadOptions\n) => Promise<AspectData | undefined>;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["on-component-events.ts"],"sourcesContent":["import { Component, ComponentID, AspectData } from '@teambit/component';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\n\nexport type SerializableResults = { results: any; toString: () => string };\nexport type OnComponentChange = (\n component: Component,\n files: string[], // os absolute paths\n removedFiles?: string[], // os absolute paths\n initiator?: CompilationInitiator\n) => Promise<SerializableResults | void>;\nexport type OnComponentAdd = (component: Component, files: string[]) => Promise<SerializableResults>;\nexport type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;\nexport type OnComponentEventResult = { extensionId: string; results: SerializableResults };\n\nexport type OnComponentLoad = (\n component: Component,\n loadOpts?: ComponentLoadOptions\n) => Promise<AspectData | undefined>;\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1096/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1096/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1097/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.1097/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -1,10 +1,22 @@
1
1
  import { ComponentID } from '@teambit/component-id';
2
2
  import { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';
3
3
  import { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';
4
+ import { Repository } from '@teambit/legacy/dist/scope/objects';
5
+ import { PathLinux } from '@teambit/legacy/dist/utils/path';
6
+ declare type FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';
7
+ export declare type FilesStatus = {
8
+ [pathRelativeToCompDir: PathLinux]: FILE_STATUS;
9
+ };
4
10
  export declare class CompFiles {
5
11
  readonly id: ComponentID;
12
+ private repository;
6
13
  private currentFiles;
14
+ readonly compDir: PathLinux;
7
15
  private headFiles;
8
- constructor(id: ComponentID, currentFiles: SourceFile[], headFiles?: SourceFileModel[]);
16
+ constructor(id: ComponentID, repository: Repository, currentFiles: SourceFile[], compDir: PathLinux, headFiles?: SourceFileModel[]);
9
17
  isModified(): boolean;
18
+ getCurrentFiles(): SourceFile[];
19
+ getHeadFiles(): Promise<SourceFile[]>;
20
+ getFilesStatus(): FilesStatus;
10
21
  }
22
+ export {};
@@ -1,13 +1,24 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.array.iterator.js");
4
+ require("core-js/modules/es.promise.js");
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.CompFiles = void 0;
9
+ function _sources() {
10
+ const data = require("@teambit/legacy/dist/consumer/component/sources");
11
+ _sources = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
7
16
  class CompFiles {
8
- constructor(id, currentFiles, headFiles = []) {
17
+ constructor(id, repository, currentFiles, compDir, headFiles = []) {
9
18
  this.id = id;
19
+ this.repository = repository;
10
20
  this.currentFiles = currentFiles;
21
+ this.compDir = compDir;
11
22
  this.headFiles = headFiles;
12
23
  }
13
24
  isModified() {
@@ -19,6 +30,31 @@ class CompFiles {
19
30
  return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());
20
31
  });
21
32
  }
33
+ getCurrentFiles() {
34
+ return this.currentFiles;
35
+ }
36
+ async getHeadFiles() {
37
+ return Promise.all(this.headFiles.map(file => _sources().SourceFile.loadFromSourceFileModel(file, this.repository)));
38
+ }
39
+ getFilesStatus() {
40
+ const result = this.currentFiles.reduce((acc, file) => {
41
+ const headFile = this.headFiles.find(h => h.relativePath === file.relative);
42
+ const getType = () => {
43
+ if (!headFile) return 'new';
44
+ if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';
45
+ return 'modified';
46
+ };
47
+ acc[file.relative] = getType();
48
+ return acc;
49
+ }, {});
50
+ this.headFiles.forEach(headFile => {
51
+ const currentFile = this.currentFiles.find(c => c.relative === headFile.relativePath);
52
+ if (!currentFile) {
53
+ result[headFile.relativePath] = 'deleted';
54
+ }
55
+ });
56
+ return result;
57
+ }
22
58
  }
23
59
  exports.CompFiles = CompFiles;
24
60
 
@@ -1 +1 @@
1
- {"version":3,"names":["CompFiles","constructor","id","currentFiles","headFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash"],"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';\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private currentFiles: SourceFile[],\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"],"mappings":";;;;;;AAIO,MAAMA,SAAS,CAAC;EACrBC,WAAW,CACAC,EAAe,EAChBC,YAA0B,EAC1BC,SAA4B,GAAG,EAAE,EACzC;IAAA,KAHSF,EAAe,GAAfA,EAAe;IAAA,KAChBC,YAA0B,GAA1BA,YAA0B;IAAA,KAC1BC,SAA4B,GAA5BA,SAA4B;EACnC;EAEHC,UAAU,GAAY;IACpB,IAAI,CAAC,IAAI,CAACD,SAAS,CAACE,MAAM,EAAE,OAAO,KAAK;IACxC,IAAI,IAAI,CAACH,YAAY,CAACG,MAAM,KAAK,IAAI,CAACF,SAAS,CAACE,MAAM,EAAE,OAAO,IAAI;IACnE,OAAO,IAAI,CAACH,YAAY,CAACI,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,EAAE,CAACC,IAAI,EAAE,CAAC;IACjE,CAAC,CAAC;EACJ;AACF;AAAC"}
1
+ {"version":3,"names":["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"],"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;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQO,MAAMA,SAAS,CAAC;EACrBC,WAAW,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,UAAU,GAAY;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,EAAE,CAACC,IAAI,EAAE,CAAC;IACjE,CAAC,CAAC;EACJ;EAEAC,eAAe,GAAiB;IAC9B,OAAO,IAAI,CAACf,YAAY;EAC1B;EAEA,MAAMgB,YAAY,GAA0B;IAC1C,OAAOC,OAAO,CAACC,GAAG,CAAC,IAAI,CAAChB,SAAS,CAACiB,GAAG,CAAEb,IAAI,IAAKc,qBAAU,CAACC,uBAAuB,CAACf,IAAI,EAAE,IAAI,CAACP,UAAU,CAAC,CAAC,CAAC;EAC7G;EAEAuB,cAAc,GAAgB;IAC5B,MAAMC,MAAM,GAAG,IAAI,CAACvB,YAAY,CAACwB,MAAM,CAAC,CAACC,GAAG,EAAEnB,IAAI,KAAK;MACrD,MAAMC,QAAQ,GAAG,IAAI,CAACL,SAAS,CAACM,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,YAAY,KAAKJ,IAAI,CAACK,QAAQ,CAAC;MAC7E,MAAMe,OAAO,GAAG,MAAmB;QACjC,IAAI,CAACnB,QAAQ,EAAE,OAAO,KAAK;QAC3B,IAAIA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,EAAE,CAACC,IAAI,EAAE,CAAC,EAAE,OAAO,WAAW;QAC/E,OAAO,UAAU;MACnB,CAAC;MACDW,GAAG,CAACnB,IAAI,CAACK,QAAQ,CAAC,GAAGe,OAAO,EAAE;MAC9B,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,IAAI,CAACvB,SAAS,CAACyB,OAAO,CAAEpB,QAAQ,IAAK;MACnC,MAAMqB,WAAW,GAAG,IAAI,CAAC5B,YAAY,CAACQ,IAAI,CAAEqB,CAAC,IAAKA,CAAC,CAAClB,QAAQ,KAAKJ,QAAQ,CAACG,YAAY,CAAC;MACvF,IAAI,CAACkB,WAAW,EAAE;QAChBL,MAAM,CAAChB,QAAQ,CAACG,YAAY,CAAC,GAAG,SAAS;MAC3C;IACF,CAAC,CAAC;IACF,OAAOa,MAAM;EACf;AACF;AAAC"}
@@ -29,7 +29,7 @@ import { ComponentConfigFile } from './component-config-file';
29
29
  import { OnComponentAdd, OnComponentChange, OnComponentEventResult, OnComponentLoad, OnComponentRemove } from './on-component-events';
30
30
  import { WorkspaceExtConfig } from './types';
31
31
  import { ComponentStatus } from './workspace-component/component-status';
32
- import { OnAspectsResolve, OnAspectsResolveSlot, OnComponentAddSlot, OnComponentChangeSlot, OnComponentLoadSlot, OnComponentRemoveSlot, OnRootAspectAdded, OnRootAspectAddedSlot } from './workspace.provider';
32
+ import { OnAspectsResolve, OnAspectsResolveSlot, OnBitmapChange, OnBitmapChangeSlot, OnComponentAddSlot, OnComponentChangeSlot, OnComponentLoadSlot, OnComponentRemoveSlot, OnRootAspectAdded, OnRootAspectAddedSlot } from './workspace.provider';
33
33
  import { WorkspaceComponentLoader } from './workspace-component/workspace-component-loader';
34
34
  import { ShouldLoadFunc } from './build-graph-from-fs';
35
35
  import { BitMap } from './bit-map';
@@ -99,6 +99,7 @@ export declare class Workspace implements ComponentFactory {
99
99
  private onAspectsResolveSlot;
100
100
  private onRootAspectAddedSlot;
101
101
  private graphql;
102
+ private onBitmapChangeSlot;
102
103
  priority: boolean;
103
104
  owner?: string;
104
105
  componentsScopeDirsMap: ComponentScopeDirMap;
@@ -146,7 +147,7 @@ export declare class Workspace implements ComponentFactory {
146
147
  /**
147
148
  * on component add slot.
148
149
  */
149
- onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, graphql: GraphqlMain);
150
+ onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, graphql: GraphqlMain, onBitmapChangeSlot: OnBitmapChangeSlot);
150
151
  private validateConfig;
151
152
  /**
152
153
  * root path of the Workspace.
@@ -159,6 +160,7 @@ export declare class Workspace implements ComponentFactory {
159
160
  registerOnComponentChange(onComponentChangeFunc: OnComponentChange): this;
160
161
  registerOnComponentAdd(onComponentAddFunc: OnComponentAdd): this;
161
162
  registerOnComponentRemove(onComponentRemoveFunc: OnComponentRemove): this;
163
+ registerOnBitmapChange(OnBitmapChangeFunc: OnBitmapChange): this;
162
164
  registerOnAspectsResolve(onAspectsResolveFunc: OnAspectsResolve): this;
163
165
  registerOnRootAspectAdded(onRootAspectAddedFunc: OnRootAspectAdded): this;
164
166
  /**
@@ -253,6 +255,7 @@ export declare class Workspace implements ComponentFactory {
253
255
  triggerOnComponentChange(id: ComponentID, files: string[], removedFiles: string[], initiator?: CompilationInitiator): Promise<OnComponentEventResult[]>;
254
256
  triggerOnComponentAdd(id: ComponentID): Promise<OnComponentEventResult[]>;
255
257
  triggerOnComponentRemove(id: ComponentID): Promise<OnComponentEventResult[]>;
258
+ triggerOnBitmapChange(): Promise<void>;
256
259
  getState(id: ComponentID, hash: string): Promise<import("@teambit/component").State>;
257
260
  getSnap(id: ComponentID, hash: string): Promise<import("@teambit/component").Snap>;
258
261
  getCurrentLaneId(): LaneId;
package/dist/workspace.js CHANGED
@@ -366,7 +366,7 @@ class Workspace {
366
366
  /**
367
367
  * on component add slot.
368
368
  */
369
- onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql) {
369
+ onComponentAddSlot, onComponentRemoveSlot, onAspectsResolveSlot, onRootAspectAddedSlot, graphql, onBitmapChangeSlot) {
370
370
  var _this$config;
371
371
  this.pubsub = pubsub;
372
372
  this.config = config;
@@ -388,6 +388,7 @@ class Workspace {
388
388
  this.onAspectsResolveSlot = onAspectsResolveSlot;
389
389
  this.onRootAspectAddedSlot = onRootAspectAddedSlot;
390
390
  this.graphql = graphql;
391
+ this.onBitmapChangeSlot = onBitmapChangeSlot;
391
392
  (0, _defineProperty2().default)(this, "priority", true);
392
393
  (0, _defineProperty2().default)(this, "owner", void 0);
393
394
  (0, _defineProperty2().default)(this, "componentsScopeDirsMap", void 0);
@@ -455,6 +456,10 @@ class Workspace {
455
456
  this.onComponentRemoveSlot.register(onComponentRemoveFunc);
456
457
  return this;
457
458
  }
459
+ registerOnBitmapChange(OnBitmapChangeFunc) {
460
+ this.onBitmapChangeSlot.register(OnBitmapChangeFunc);
461
+ return this;
462
+ }
458
463
  registerOnAspectsResolve(onAspectsResolveFunc) {
459
464
  this.onAspectsResolveSlot.register(onAspectsResolveFunc);
460
465
  return this;
@@ -717,20 +722,22 @@ class Workspace {
717
722
  }
718
723
  async getFilesModification(id) {
719
724
  const bitMapEntry = this.bitMap.getBitmapEntry(id);
720
- const compDirAbs = _path2().default.join(this.path, bitMapEntry.getComponentDir());
725
+ const compDir = bitMapEntry.getComponentDir();
726
+ const compDirAbs = _path2().default.join(this.path, compDir);
721
727
  const sourceFilesVinyls = bitMapEntry.files.map(file => {
722
728
  const filePath = _path2().default.join(compDirAbs, file.relativePath);
723
729
  return _sources().SourceFile.load(filePath, compDirAbs, this.path, {});
724
730
  });
731
+ const repo = this.scope.legacyScope.objects;
725
732
  const getHeadFiles = async () => {
726
733
  const modelComp = await this.scope.legacyScope.getModelComponentIfExist(id._legacy);
727
734
  if (!modelComp) return [];
728
735
  const head = modelComp.getHeadRegardlessOfLane();
729
736
  if (!head) return [];
730
- const verObj = await modelComp.loadVersion(head.toString(), this.scope.legacyScope.objects);
737
+ const verObj = await modelComp.loadVersion(head.toString(), repo);
731
738
  return verObj.files;
732
739
  };
733
- return new (_compFiles().CompFiles)(id, sourceFilesVinyls, await getHeadFiles());
740
+ return new (_compFiles().CompFiles)(id, repo, sourceFilesVinyls, compDir, await getHeadFiles());
734
741
  }
735
742
 
736
743
  /**
@@ -797,7 +804,7 @@ class Workspace {
797
804
  const results = [];
798
805
  await (0, _pMapSeries().default)(onChangeEntries, async ([extension, onChangeFunc]) => {
799
806
  const onChangeResult = await onChangeFunc(component, files, removedFiles, initiator);
800
- results.push({
807
+ if (onChangeResult) results.push({
801
808
  extensionId: extension,
802
809
  results: onChangeResult
803
810
  });
@@ -847,6 +854,12 @@ class Workspace {
847
854
  });
848
855
  return results;
849
856
  }
857
+ async triggerOnBitmapChange() {
858
+ const onBitmapChangeEntries = this.onBitmapChangeSlot.toArray(); // e.g. [ [ 'teambit.bit/compiler', [Function: bound onComponentChange] ] ]
859
+ await (0, _pMapSeries().default)(onBitmapChangeEntries, async ([, onBitmapChangeFunc]) => {
860
+ await onBitmapChangeFunc();
861
+ });
862
+ }
850
863
  getState(id, hash) {
851
864
  return this.scope.getState(id, hash);
852
865
  }
@@ -1452,6 +1465,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1452
1465
  */
1453
1466
  async _reloadConsumer() {
1454
1467
  this.consumer = await (0, _consumer().loadConsumer)(this.path, true);
1468
+ this.bitMap = new (_bitMap().BitMap)(this.consumer.bitMap, this.consumer);
1455
1469
  this.clearCache();
1456
1470
  }
1457
1471
  getComponentPackagePath(component) {