@teambit/workspace 0.0.1095 → 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/bit-map.d.ts +1 -0
- package/dist/bit-map.js +10 -0
- package/dist/bit-map.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/on-component-events.d.ts +1 -1
- package/dist/on-component-events.js.map +1 -1
- package/dist/{preview-1688354260415.js → preview-1688532377504.js} +2 -2
- package/dist/workspace-component/comp-files.d.ts +13 -1
- package/dist/workspace-component/comp-files.js +37 -1
- package/dist/workspace-component/comp-files.js.map +1 -1
- package/dist/workspace.d.ts +6 -2
- package/dist/workspace.js +22 -5
- 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-tar/teambit-workspace-0.0.1097.tgz +0 -0
- package/package.json +36 -36
- package/workspace-component/comp-files.ts +35 -0
- package/package-tar/teambit-workspace-0.0.1095.tgz +0 -0
package/dist/bit-map.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class BitMap {
|
|
|
12
12
|
private legacyBitMap;
|
|
13
13
|
private consumer;
|
|
14
14
|
constructor(legacyBitMap: LegacyBitMap, consumer: Consumer);
|
|
15
|
+
mergeBitmaps(bitmapContent: string, otherBitmapContent: string): string;
|
|
15
16
|
/**
|
|
16
17
|
* adds component config to the .bitmap file.
|
|
17
18
|
* later, upon `bit tag`, the data is saved in the scope.
|
package/dist/bit-map.js
CHANGED
|
@@ -13,6 +13,13 @@ function _lodash() {
|
|
|
13
13
|
};
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
+
function _bitMap() {
|
|
17
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/bit-map"));
|
|
18
|
+
_bitMap = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
16
23
|
function _config() {
|
|
17
24
|
const data = require("@teambit/legacy/dist/consumer/config");
|
|
18
25
|
_config = function () {
|
|
@@ -43,6 +50,9 @@ class BitMap {
|
|
|
43
50
|
this.legacyBitMap = legacyBitMap;
|
|
44
51
|
this.consumer = consumer;
|
|
45
52
|
}
|
|
53
|
+
mergeBitmaps(bitmapContent, otherBitmapContent) {
|
|
54
|
+
return _bitMap().default.mergeContent(bitmapContent, otherBitmapContent);
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
58
|
* adds component config to the .bitmap file.
|
package/dist/bit-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","defaultScope","setDefaultScope","write","writeBitMap","ignoreVersion","getComponent","_legacy","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","Object","keys","filter","startsWith","toStringWithoutVersion","length","BitError","join","renameNewComponent","sourceId","targetId","hasVersion","fullName","removeComponent","setComponent","scope","renameAspectInConfig","components","forEach","componentMap","EnvsAspect","envConfig","env","getExportedLaneId","isLaneExported","laneId","makeComponentsAvailableOnMain","ids","onLanesOnly","isAvailableOnCurrentLane","hasChanged","takeSnapshot","map","comp","clone","restoreFromSnapshot","componentMaps","_invalidateCache"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport EnvsAspect from '@teambit/envs';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n markAsChanged() {\n this.legacyBitMap.markAsChanged();\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n if (sourceId.isEqual(targetId)) {\n throw new Error(`source-id and target-id are equal: \"${sourceId.toString()}\"`);\n }\n if (sourceId.fullName !== targetId.fullName) {\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n if (sourceId.scope !== targetId.scope) {\n this.setDefaultScope(targetId, targetId.scope);\n }\n }\n\n /**\n * helpful when reaming an aspect and this aspect is used in the config of other components.\n */\n renameAspectInConfig(sourceId: ComponentID, targetId: ComponentID) {\n this.legacyBitMap.components.forEach((componentMap) => {\n const config = componentMap.config;\n if (!config) return;\n Object.keys(config).forEach((aspectId) => {\n if (aspectId === sourceId.toString()) {\n config[targetId.toString()] = config[aspectId];\n delete config[aspectId];\n this.markAsChanged();\n }\n if (aspectId === EnvsAspect.id) {\n const envConfig = config[aspectId];\n if (envConfig !== REMOVE_EXTENSION_SPECIAL_SIGN && envConfig.env === sourceId.toString()) {\n envConfig.env = targetId.toString();\n this.markAsChanged();\n }\n }\n });\n componentMap.config = config;\n });\n }\n\n removeComponent(id: ComponentID) {\n this.legacyBitMap.removeComponent(id._legacy);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n makeComponentsAvailableOnMain(ids: ComponentID[]) {\n ids.forEach((id) => {\n const componentMap = this.getBitmapEntry(id);\n delete componentMap.onLanesOnly;\n delete componentMap.isAvailableOnCurrentLane;\n });\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n\n takeSnapshot(): ComponentMap[] {\n return this.legacyBitMap.components.map((comp) => comp.clone());\n }\n\n restoreFromSnapshot(componentMaps: ComponentMap[]) {\n this.legacyBitMap.components = componentMaps;\n this.legacyBitMap._invalidateCache();\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAC;EAClBC,WAAW,CAASC,YAA0B,EAAUC,QAAkB,EAAE;IAAA,KAAxDD,YAA0B,GAA1BA,YAA0B;IAAA,KAAUC,QAAkB,GAAlBA,QAAkB;EAAG;;EAE7E;AACF;AACA;AACA;AACA;EACEC,kBAAkB,CAChBC,EAAe,EACfC,QAAgB,EAChBC,MAA2B,GAAG,CAAC,CAAC,EAChCC,iBAAiB,GAAG,KAAK,EAChB;IACT,IAAI,CAACF,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE,MAAM,IAAIG,KAAK,CAAE,qCAAoCH,QAAS,EAAC,CAAC;IAC/G,MAAMI,WAAW,GAAG,IAAI,CAACC,cAAc,CAACN,EAAE,EAAE;MAAEO,qBAAqB,EAAE;IAAK,CAAC,CAAC;IAC5E,MAAMC,aAAa,GAAG,CAACH,WAAW,CAACH,MAAM,KAAlBG,WAAW,CAACH,MAAM,GAAK,CAAC,CAAC,GAAED,QAAQ,CAAC;IAC3D,IAAI,IAAAQ,i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ACnE,YAAY,CAACqD,UAAU,CAACe,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,KAAK,EAAE,CAAC;EACjE;EAEAC,mBAAmB,CAACC,aAA6B,EAAE;IACjD,IAAI,CAACxE,YAAY,CAACqD,UAAU,GAAGmB,aAAa;IAC5C,IAAI,CAACxE,YAAY,CAACyE,gBAAgB,EAAE;EACtC;AACF;AAAC"}
|
|
1
|
+
{"version":3,"names":["BitMap","constructor","legacyBitMap","consumer","mergeBitmaps","bitmapContent","otherBitmapContent","LegacyBitMap","mergeContent","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","defaultScope","setDefaultScope","write","writeBitMap","ignoreVersion","getComponent","_legacy","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","Object","keys","filter","startsWith","toStringWithoutVersion","length","BitError","join","renameNewComponent","sourceId","targetId","hasVersion","fullName","removeComponent","setComponent","scope","renameAspectInConfig","components","forEach","componentMap","EnvsAspect","envConfig","env","getExportedLaneId","isLaneExported","laneId","makeComponentsAvailableOnMain","ids","onLanesOnly","isAvailableOnCurrentLane","hasChanged","takeSnapshot","map","comp","clone","restoreFromSnapshot","componentMaps","_invalidateCache"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport EnvsAspect from '@teambit/envs';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n mergeBitmaps(bitmapContent: string, otherBitmapContent: string): string {\n return LegacyBitMap.mergeContent(bitmapContent, otherBitmapContent);\n }\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n markAsChanged() {\n this.legacyBitMap.markAsChanged();\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n if (sourceId.isEqual(targetId)) {\n throw new Error(`source-id and target-id are equal: \"${sourceId.toString()}\"`);\n }\n if (sourceId.fullName !== targetId.fullName) {\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n if (sourceId.scope !== targetId.scope) {\n this.setDefaultScope(targetId, targetId.scope);\n }\n }\n\n /**\n * helpful when reaming an aspect and this aspect is used in the config of other components.\n */\n renameAspectInConfig(sourceId: ComponentID, targetId: ComponentID) {\n this.legacyBitMap.components.forEach((componentMap) => {\n const config = componentMap.config;\n if (!config) return;\n Object.keys(config).forEach((aspectId) => {\n if (aspectId === sourceId.toString()) {\n config[targetId.toString()] = config[aspectId];\n delete config[aspectId];\n this.markAsChanged();\n }\n if (aspectId === EnvsAspect.id) {\n const envConfig = config[aspectId];\n if (envConfig !== REMOVE_EXTENSION_SPECIAL_SIGN && envConfig.env === sourceId.toString()) {\n envConfig.env = targetId.toString();\n this.markAsChanged();\n }\n }\n });\n componentMap.config = config;\n });\n }\n\n removeComponent(id: ComponentID) {\n this.legacyBitMap.removeComponent(id._legacy);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n makeComponentsAvailableOnMain(ids: ComponentID[]) {\n ids.forEach((id) => {\n const componentMap = this.getBitmapEntry(id);\n delete componentMap.onLanesOnly;\n delete componentMap.isAvailableOnCurrentLane;\n });\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n\n takeSnapshot(): ComponentMap[] {\n return this.legacyBitMap.components.map((comp) => comp.clone());\n }\n\n restoreFromSnapshot(componentMaps: ComponentMap[]) {\n this.legacyBitMap.components = componentMaps;\n this.legacyBitMap._invalidateCache();\n }\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAC;EAClBC,WAAW,CAASC,YAA0B,EAAUC,QAAkB,EAAE;IAAA,KAAxDD,YAA0B,GAA1BA,YAA0B;IAAA,KAAUC,QAAkB,GAAlBA,QAAkB;EAAG;EAE7EC,YAAY,CAACC,aAAqB,EAAEC,kBAA0B,EAAU;IACtE,OAAOC,iBAAY,CAACC,YAAY,CAACH,aAAa,EAAEC,kBAAkB,CAAC;EACrE;;EAEA;AACF;AACA;AACA;AACA;EACEG,kBAAkB,CAChBC,EAAe,EACfC,QAAgB,EAChBC,MAA2B,GAAG,CAAC,CAAC,EAChCC,iBAAiB,GAAG,KAAK,EAChB;IACT,IAAI,CAACF,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE,MAAM,IAAIG,KAAK,CAAE,qCAAoCH,QAAS,EAAC,CAAC;IAC/G,MAAMI,WAAW,GAAG,IAAI,CAACC,cAAc,CAACN,EAAE,EAAE;MAAEO,qBAAqB,EAAE;IAAK,CAAC,CAAC;IAC5E,MAAMC,aAAa,GAAG,CAACH,WAAW,CAACH,MAAM,KAAlBG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,CAACvE,YAAY,CAACuE,UAAU;EACrC;EAEAC,YAAY,GAAmB;IAC7B,OAAO,IAAI,CAACxE,YAAY,CAAC0D,UAAU,CAACe,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,KAAK,EAAE,CAAC;EACjE;EAEAC,mBAAmB,CAACC,aAA6B,EAAE;IACjD,IAAI,CAAC7E,YAAY,CAAC0D,UAAU,GAAGmB,aAAa;IAC5C,IAAI,CAAC7E,YAAY,CAAC8E,gBAAgB,EAAE;EACtC;AACF;AAAC"}
|
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,
|
|
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.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
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":"
|
|
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;I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ist/workspace.d.ts
CHANGED
|
@@ -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;
|
|
@@ -304,6 +307,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
304
307
|
*/
|
|
305
308
|
exists(componentId: ComponentID): boolean;
|
|
306
309
|
getIdIfExist(componentId: ComponentID): ComponentID | undefined;
|
|
310
|
+
mergeBitmaps(bitmapContent: string, otherBitmapContent: string): string;
|
|
307
311
|
/**
|
|
308
312
|
* This will make sure to fetch the objects prior to load them
|
|
309
313
|
* do not use it if you are not sure you need it.
|
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
|
|
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(),
|
|
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
|
}
|
|
@@ -1045,6 +1058,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1045
1058
|
if (!id) return undefined;
|
|
1046
1059
|
return componentId.changeVersion(id.version);
|
|
1047
1060
|
}
|
|
1061
|
+
mergeBitmaps(bitmapContent, otherBitmapContent) {
|
|
1062
|
+
return this.bitMap.mergeBitmaps(bitmapContent, otherBitmapContent);
|
|
1063
|
+
}
|
|
1048
1064
|
|
|
1049
1065
|
/**
|
|
1050
1066
|
* This will make sure to fetch the objects prior to load them
|
|
@@ -1449,6 +1465,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1449
1465
|
*/
|
|
1450
1466
|
async _reloadConsumer() {
|
|
1451
1467
|
this.consumer = await (0, _consumer().loadConsumer)(this.path, true);
|
|
1468
|
+
this.bitMap = new (_bitMap().BitMap)(this.consumer.bitMap, this.consumer);
|
|
1452
1469
|
this.clearCache();
|
|
1453
1470
|
}
|
|
1454
1471
|
getComponentPackagePath(component) {
|