@teambit/graph 0.0.785 → 0.0.788
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/component-graph/component-graph.ts +14 -14
- package/dist/component-graph/component-graph.d.ts +1 -8
- package/dist/component-graph/component-graph.js +11 -16
- package/dist/component-graph/component-graph.js.map +1 -1
- package/dist/graph-builder.js +0 -1
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph.ui.runtime.d.ts +9 -1
- package/dist/graph.ui.runtime.js +19 -1
- package/dist/graph.ui.runtime.js.map +1 -1
- package/graph.ui.runtime.tsx +15 -2
- package/package-tar/teambit-graph-0.0.788.tgz +0 -0
- package/package.json +10 -10
- package/{preview-1657337177086.js → preview-1657709114119.js} +2 -2
- package/package-tar/teambit-graph-0.0.785.tgz +0 -0
@@ -10,11 +10,9 @@ type ComponentNode = Node<Component>;
|
|
10
10
|
type DependencyEdge = Edge<Dependency>;
|
11
11
|
|
12
12
|
export class ComponentGraph extends Graph<Component, Dependency> {
|
13
|
-
versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }>;
|
14
13
|
seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)
|
15
14
|
constructor(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []) {
|
16
15
|
super(nodes, edges);
|
17
|
-
this.versionMap = new Map();
|
18
16
|
}
|
19
17
|
|
20
18
|
protected create(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []): this {
|
@@ -37,9 +35,10 @@ export class ComponentGraph extends Graph<Component, Dependency> {
|
|
37
35
|
}
|
38
36
|
|
39
37
|
findDuplicateDependencies(): Map<string, DuplicateDependency> {
|
38
|
+
const versionMap = this.calculateVersionMap();
|
40
39
|
const seederIdsNoVersions = this.seederIds.map((id) => id.toStringWithoutVersion());
|
41
40
|
const duplicateDependencies: Map<string, DuplicateDependency> = new Map();
|
42
|
-
for (const [compFullName, versions] of
|
41
|
+
for (const [compFullName, versions] of versionMap) {
|
43
42
|
if (versions.allVersionNodes.length > 1) {
|
44
43
|
const versionSubgraphs: VersionSubgraph[] = [];
|
45
44
|
const notLatestVersions = versions.allVersionNodes.filter((version) => version !== versions.latestVersionNode);
|
@@ -80,7 +79,7 @@ export class ComponentGraph extends Graph<Component, Dependency> {
|
|
80
79
|
return this.seederIds.length;
|
81
80
|
}
|
82
81
|
|
83
|
-
|
82
|
+
private calculateVersionMap(): Map<string, { allVersionNodes: string[]; latestVersionNode: string }> {
|
84
83
|
const versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }> = new Map();
|
85
84
|
for (const node of this.nodes) {
|
86
85
|
const comp = node.attr;
|
@@ -97,17 +96,18 @@ export class ComponentGraph extends Graph<Component, Dependency> {
|
|
97
96
|
if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {
|
98
97
|
value.allVersionNodes.push(compKey);
|
99
98
|
}
|
100
|
-
const currentComp =
|
99
|
+
const currentComp = comp;
|
101
100
|
const latestComp = this.node(value.latestVersionNode)?.attr;
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
101
|
+
// @todo: this check won't work when the component doesn't have head.
|
102
|
+
// it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head
|
103
|
+
// Version object, and as a result, the `Component.head` is empty.
|
104
|
+
// for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only
|
105
|
+
// checks the components on the workspace.
|
106
|
+
if (
|
107
|
+
currentComp.head &&
|
108
|
+
latestComp?.head &&
|
109
|
+
new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)
|
110
|
+
) {
|
111
111
|
value.latestVersionNode = compKey;
|
112
112
|
}
|
113
113
|
}
|
@@ -6,10 +6,6 @@ export declare const DEPENDENCIES_TYPES: string[];
|
|
6
6
|
declare type ComponentNode = Node<Component>;
|
7
7
|
declare type DependencyEdge = Edge<Dependency>;
|
8
8
|
export declare class ComponentGraph extends Graph<Component, Dependency> {
|
9
|
-
versionMap: Map<string, {
|
10
|
-
allVersionNodes: string[];
|
11
|
-
latestVersionNode: string;
|
12
|
-
}>;
|
13
9
|
seederIds: ComponentID[];
|
14
10
|
constructor(nodes?: ComponentNode[], edges?: DependencyEdge[]);
|
15
11
|
protected create(nodes?: ComponentNode[], edges?: DependencyEdge[]): this;
|
@@ -21,9 +17,6 @@ export declare class ComponentGraph extends Graph<Component, Dependency> {
|
|
21
17
|
buildFromCleargraph(graph: Graph<Component, Dependency>): ComponentGraph;
|
22
18
|
runtimeOnly(componentIds: string[]): this;
|
23
19
|
private shouldLimitToSeedersOnly;
|
24
|
-
|
25
|
-
allVersionNodes: string[];
|
26
|
-
latestVersionNode: string;
|
27
|
-
}>;
|
20
|
+
private calculateVersionMap;
|
28
21
|
}
|
29
22
|
export {};
|
@@ -46,9 +46,7 @@ class ComponentGraph extends _graph().Graph {
|
|
46
46
|
// component IDs that started the graph. (if from workspace, the .bitmap ids normally)
|
47
47
|
constructor(nodes = [], edges = []) {
|
48
48
|
super(nodes, edges);
|
49
|
-
(0, _defineProperty2().default)(this, "versionMap", void 0);
|
50
49
|
(0, _defineProperty2().default)(this, "seederIds", []);
|
51
|
-
this.versionMap = new Map();
|
52
50
|
}
|
53
51
|
|
54
52
|
create(nodes = [], edges = []) {
|
@@ -74,10 +72,11 @@ class ComponentGraph extends _graph().Graph {
|
|
74
72
|
}
|
75
73
|
|
76
74
|
findDuplicateDependencies() {
|
75
|
+
const versionMap = this.calculateVersionMap();
|
77
76
|
const seederIdsNoVersions = this.seederIds.map(id => id.toStringWithoutVersion());
|
78
77
|
const duplicateDependencies = new Map();
|
79
78
|
|
80
|
-
for (const [compFullName, versions] of
|
79
|
+
for (const [compFullName, versions] of versionMap) {
|
81
80
|
if (versions.allVersionNodes.length > 1) {
|
82
81
|
const versionSubgraphs = [];
|
83
82
|
const notLatestVersions = versions.allVersionNodes.filter(version => version !== versions.latestVersionNode);
|
@@ -120,7 +119,7 @@ class ComponentGraph extends _graph().Graph {
|
|
120
119
|
return this.seederIds.length;
|
121
120
|
}
|
122
121
|
|
123
|
-
|
122
|
+
calculateVersionMap() {
|
124
123
|
const versionMap = new Map();
|
125
124
|
|
126
125
|
for (const node of this.nodes) {
|
@@ -138,24 +137,20 @@ class ComponentGraph extends _graph().Graph {
|
|
138
137
|
const value = versionMap.get(compFullName);
|
139
138
|
|
140
139
|
if (value) {
|
141
|
-
var _this$node
|
140
|
+
var _this$node;
|
142
141
|
|
143
142
|
if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {
|
144
143
|
value.allVersionNodes.push(compKey);
|
145
144
|
}
|
146
145
|
|
147
|
-
const currentComp =
|
148
|
-
const latestComp = (_this$
|
149
|
-
|
146
|
+
const currentComp = comp;
|
147
|
+
const latestComp = (_this$node = this.node(value.latestVersionNode)) === null || _this$node === void 0 ? void 0 : _this$node.attr; // @todo: this check won't work when the component doesn't have head.
|
148
|
+
// it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head
|
149
|
+
// Version object, and as a result, the `Component.head` is empty.
|
150
|
+
// for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only
|
151
|
+
// checks the components on the workspace.
|
150
152
|
|
151
|
-
if (
|
152
|
-
const currentCompVersion = currentComp === null || currentComp === void 0 ? void 0 : currentComp.id._legacy.getVersion();
|
153
|
-
const latestCompVersion = latestComp === null || latestComp === void 0 ? void 0 : latestComp.id._legacy.getVersion();
|
154
|
-
|
155
|
-
if (!!currentCompVersion && !!latestCompVersion && currentCompVersion.isLaterThan(latestCompVersion)) {
|
156
|
-
value.latestVersionNode = compKey;
|
157
|
-
}
|
158
|
-
} else if (new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)) {
|
153
|
+
if (currentComp.head && latestComp !== null && latestComp !== void 0 && latestComp.head && new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)) {
|
159
154
|
value.latestVersionNode = compKey;
|
160
155
|
}
|
161
156
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DEPENDENCIES_TYPES","ComponentGraph","Graph","constructor","nodes","edges","versionMap","Map","create","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","map","id","toString","cyclesWithSeeders","filter","cycle","some","cycleIdStr","includes","findDuplicateDependencies","seederIdsNoVersions","toStringWithoutVersion","duplicateDependencies","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","forEach","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","push","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","attr","type","_calculateVersionMap","node","comp","compKey","_legacy","has","value","get","Object","prototype","hasOwnProperty","call","currentComp","latestComp","isLegacy","head","currentCompVersion","getVersion","latestCompVersion","isLaterThan","Date","timestamp"],"sources":["component-graph.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\n\nimport { Dependency } from '../model/dependency';\nimport { DuplicateDependency, VersionSubgraph } from '../duplicate-dependency';\n\nexport const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];\n\ntype ComponentNode = Node<Component>;\ntype DependencyEdge = Edge<Dependency>;\n\nexport class ComponentGraph extends Graph<Component, Dependency> {\n versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }>;\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n this.versionMap = new Map();\n }\n\n protected create(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentGraph(nodes, edges) as this;\n }\n\n /**\n * overrides the super class to eliminate non-seeders components\n */\n findCycles(graph?: this): string[][] {\n const cycles = super.findCycles(graph);\n if (!this.shouldLimitToSeedersOnly()) {\n return cycles;\n }\n const seederIdsStr = this.seederIds.map((id) => id.toString());\n const cyclesWithSeeders = cycles.filter((cycle) => {\n return cycle.some((cycleIdStr) => seederIdsStr.includes(cycleIdStr));\n });\n return cyclesWithSeeders;\n }\n\n findDuplicateDependencies(): Map<string, DuplicateDependency> {\n const seederIdsNoVersions = this.seederIds.map((id) => id.toStringWithoutVersion());\n const duplicateDependencies: Map<string, DuplicateDependency> = new Map();\n for (const [compFullName, versions] of this.versionMap) {\n if (versions.allVersionNodes.length > 1) {\n const versionSubgraphs: VersionSubgraph[] = [];\n const notLatestVersions = versions.allVersionNodes.filter((version) => version !== versions.latestVersionNode);\n notLatestVersions.forEach((version) => {\n const predecessors = this.predecessorsSubgraph(version);\n const immediatePredecessors = this.predecessors(version).map((predecessor) => predecessor.id);\n const subGraph = this.buildFromCleargraph(predecessors);\n const versionSubgraph: VersionSubgraph = {\n versionId: version,\n subGraph,\n // TODO: validate that this is working correctly\n immediateDependents: immediatePredecessors,\n };\n versionSubgraphs.push(versionSubgraph);\n });\n const isSeeder = seederIdsNoVersions.includes(compFullName);\n const shouldDisplayDueToBeingSeeder = !this.shouldLimitToSeedersOnly() || isSeeder;\n if (shouldDisplayDueToBeingSeeder && versionSubgraphs.length > 0) {\n const duplicateDep = new DuplicateDependency(versions.latestVersionNode, versionSubgraphs);\n duplicateDependencies.set(compFullName, duplicateDep);\n }\n }\n }\n return duplicateDependencies;\n }\n\n buildFromCleargraph(graph: Graph<Component, Dependency>): ComponentGraph {\n return this.create(graph.nodes, graph.edges);\n }\n\n runtimeOnly(componentIds: string[]) {\n return this.successorsSubgraph(componentIds, {\n edgeFilter: (edge: DependencyEdge) => edge.attr.type === 'runtime',\n });\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n\n _calculateVersionMap() {\n const versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }> = new Map();\n for (const node of this.nodes) {\n const comp = node.attr;\n const compKey = node.id;\n const compFullName = comp.id._legacy.toStringWithoutVersion();\n if (!versionMap.has(compFullName)) {\n versionMap.set(compFullName, {\n allVersionNodes: [compKey],\n latestVersionNode: compKey,\n });\n } else {\n const value = versionMap.get(compFullName);\n if (value) {\n if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {\n value.allVersionNodes.push(compKey);\n }\n const currentComp = this.node(compKey)?.attr;\n const latestComp = this.node(value.latestVersionNode)?.attr;\n const isLegacy = !currentComp?.head || !latestComp?.head;\n\n if (isLegacy) {\n const currentCompVersion = currentComp?.id._legacy.getVersion();\n const latestCompVersion = latestComp?.id._legacy.getVersion();\n if (!!currentCompVersion && !!latestCompVersion && currentCompVersion.isLaterThan(latestCompVersion)) {\n value.latestVersionNode = compKey;\n }\n } else if (new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)) {\n value.latestVersionNode = compKey;\n }\n }\n }\n }\n return versionMap;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,kBAAkB,GAAG,CAAC,cAAD,EAAiB,iBAAjB,CAA3B;;;AAKA,MAAMC,cAAN,SAA6BC,cAA7B,CAA0D;EAEhC;EAC/BC,WAAW,CAACC,KAAsB,GAAG,EAA1B,EAA8BC,KAAuB,GAAG,EAAxD,EAA4D;IACrE,MAAMD,KAAN,EAAaC,KAAb;IADqE;IAAA,mDAD5C,EAC4C;IAErE,KAAKC,UAAL,GAAkB,IAAIC,GAAJ,EAAlB;EACD;;EAESC,MAAM,CAACJ,KAAsB,GAAG,EAA1B,EAA8BC,KAAuB,GAAG,EAAxD,EAAkE;IAChF,OAAO,IAAIJ,cAAJ,CAAmBG,KAAnB,EAA0BC,KAA1B,CAAP;EACD;EAED;AACF;AACA;;;EACEI,UAAU,CAACC,KAAD,EAA2B;IACnC,MAAMC,MAAM,GAAG,MAAMF,UAAN,CA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A1B;YACD;UACF,CAND,MAMO,IAAI,IAAIiB,IAAJ,CAASR,WAAW,CAACG,IAAZ,CAAiBM,SAA1B,IAAuC,IAAID,IAAJ,CAASP,UAAU,CAACE,IAAX,CAAgBM,SAAzB,CAA3C,EAAgF;YACrFf,KAAK,CAAC9B,iBAAN,GAA0B2B,OAA1B;UACD;QACF;MACF;IACF;;IACD,OAAOxD,UAAP;EACD;;AAzG8D"}
|
1
|
+
{"version":3,"names":["DEPENDENCIES_TYPES","ComponentGraph","Graph","constructor","nodes","edges","create","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","map","id","toString","cyclesWithSeeders","filter","cycle","some","cycleIdStr","includes","findDuplicateDependencies","versionMap","calculateVersionMap","seederIdsNoVersions","toStringWithoutVersion","duplicateDependencies","Map","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","forEach","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","push","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","attr","type","node","comp","compKey","_legacy","has","value","get","Object","prototype","hasOwnProperty","call","currentComp","latestComp","head","Date","timestamp"],"sources":["component-graph.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\n\nimport { Dependency } from '../model/dependency';\nimport { DuplicateDependency, VersionSubgraph } from '../duplicate-dependency';\n\nexport const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];\n\ntype ComponentNode = Node<Component>;\ntype DependencyEdge = Edge<Dependency>;\n\nexport class ComponentGraph extends Graph<Component, Dependency> {\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n protected create(nodes: ComponentNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentGraph(nodes, edges) as this;\n }\n\n /**\n * overrides the super class to eliminate non-seeders components\n */\n findCycles(graph?: this): string[][] {\n const cycles = super.findCycles(graph);\n if (!this.shouldLimitToSeedersOnly()) {\n return cycles;\n }\n const seederIdsStr = this.seederIds.map((id) => id.toString());\n const cyclesWithSeeders = cycles.filter((cycle) => {\n return cycle.some((cycleIdStr) => seederIdsStr.includes(cycleIdStr));\n });\n return cyclesWithSeeders;\n }\n\n findDuplicateDependencies(): Map<string, DuplicateDependency> {\n const versionMap = this.calculateVersionMap();\n const seederIdsNoVersions = this.seederIds.map((id) => id.toStringWithoutVersion());\n const duplicateDependencies: Map<string, DuplicateDependency> = new Map();\n for (const [compFullName, versions] of versionMap) {\n if (versions.allVersionNodes.length > 1) {\n const versionSubgraphs: VersionSubgraph[] = [];\n const notLatestVersions = versions.allVersionNodes.filter((version) => version !== versions.latestVersionNode);\n notLatestVersions.forEach((version) => {\n const predecessors = this.predecessorsSubgraph(version);\n const immediatePredecessors = this.predecessors(version).map((predecessor) => predecessor.id);\n const subGraph = this.buildFromCleargraph(predecessors);\n const versionSubgraph: VersionSubgraph = {\n versionId: version,\n subGraph,\n // TODO: validate that this is working correctly\n immediateDependents: immediatePredecessors,\n };\n versionSubgraphs.push(versionSubgraph);\n });\n const isSeeder = seederIdsNoVersions.includes(compFullName);\n const shouldDisplayDueToBeingSeeder = !this.shouldLimitToSeedersOnly() || isSeeder;\n if (shouldDisplayDueToBeingSeeder && versionSubgraphs.length > 0) {\n const duplicateDep = new DuplicateDependency(versions.latestVersionNode, versionSubgraphs);\n duplicateDependencies.set(compFullName, duplicateDep);\n }\n }\n }\n return duplicateDependencies;\n }\n\n buildFromCleargraph(graph: Graph<Component, Dependency>): ComponentGraph {\n return this.create(graph.nodes, graph.edges);\n }\n\n runtimeOnly(componentIds: string[]) {\n return this.successorsSubgraph(componentIds, {\n edgeFilter: (edge: DependencyEdge) => edge.attr.type === 'runtime',\n });\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n\n private calculateVersionMap(): Map<string, { allVersionNodes: string[]; latestVersionNode: string }> {\n const versionMap: Map<string, { allVersionNodes: string[]; latestVersionNode: string }> = new Map();\n for (const node of this.nodes) {\n const comp = node.attr;\n const compKey = node.id;\n const compFullName = comp.id._legacy.toStringWithoutVersion();\n if (!versionMap.has(compFullName)) {\n versionMap.set(compFullName, {\n allVersionNodes: [compKey],\n latestVersionNode: compKey,\n });\n } else {\n const value = versionMap.get(compFullName);\n if (value) {\n if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {\n value.allVersionNodes.push(compKey);\n }\n const currentComp = comp;\n const latestComp = this.node(value.latestVersionNode)?.attr;\n // @todo: this check won't work when the component doesn't have head.\n // it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head\n // Version object, and as a result, the `Component.head` is empty.\n // for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only\n // checks the components on the workspace.\n if (\n currentComp.head &&\n latestComp?.head &&\n new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)\n ) {\n value.latestVersionNode = compKey;\n }\n }\n }\n }\n return versionMap;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,kBAAkB,GAAG,CAAC,cAAD,EAAiB,iBAAjB,CAA3B;;;AAKA,MAAMC,cAAN,SAA6BC,cAA7B,CAA0D;EAChC;EAC/BC,WAAW,CAACC,KAAsB,GAAG,EAA1B,EAA8BC,KAAuB,GAAG,EAAxD,EAA4D;IACrE,MAAMD,KAAN,EAAaC,KAAb;IADqE,mDAD5C,EAC4C;EAEtE;;EAESC,MAAM,CAACF,KAAsB,GAAG,EAA1B,EAA8BC,KAAuB,GAAG,EAAxD,EAAkE;IAChF,OAAO,IAAIJ,cAAJ,CAAmBG,KA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AAMyD,IAAI,GAAGD,IAAI,CAACF,IAAlB;MACA,MAAMI,OAAO,GAAGF,IAAI,CAAC9C,EAArB;;MACA,MAAMe,YAAY,GAAGgC,IAAI,CAAC/C,EAAL,CAAQiD,OAAR,CAAgBrC,sBAAhB,EAArB;;MACA,IAAI,CAACH,UAAU,CAACyC,GAAX,CAAenC,YAAf,CAAL,EAAmC;QACjCN,UAAU,CAAC6B,GAAX,CAAevB,YAAf,EAA6B;UAC3BE,eAAe,EAAE,CAAC+B,OAAD,CADU;UAE3B1B,iBAAiB,EAAE0B;QAFQ,CAA7B;MAID,CALD,MAKO;QACL,MAAMG,KAAK,GAAG1C,UAAU,CAAC2C,GAAX,CAAerC,YAAf,CAAd;;QACA,IAAIoC,KAAJ,EAAW;UAAA;;UACT,IAAIE,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,KAArC,EAA4C,iBAA5C,CAAJ,EAAoE;YAClEA,KAAK,CAAClC,eAAN,CAAsBgB,IAAtB,CAA2Be,OAA3B;UACD;;UACD,MAAMS,WAAW,GAAGV,IAApB;UACA,MAAMW,UAAU,iBAAG,KAAKZ,IAAL,CAAUK,KAAK,CAAC7B,iBAAhB,CAAH,+CAAG,WAAoCsB,IAAvD,CALS,CAMT;UACA;UACA;UACA;UACA;;UACA,IACEa,WAAW,CAACE,IAAZ,IACAD,UADA,aACAA,UADA,eACAA,UAAU,CAAEC,IADZ,IAEA,IAAIC,IAAJ,CAASH,WAAW,CAACE,IAAZ,CAAiBE,SAA1B,IAAuC,IAAID,IAAJ,CAASF,UAAU,CAACC,IAAX,CAAgBE,SAAzB,CAHzC,EAIE;YACAV,KAAK,CAAC7B,iBAAN,GAA0B0B,OAA1B;UACD;QACF;MACF;IACF;;IACD,OAAOvC,UAAP;EACD;;AAzG8D"}
|
package/dist/graph-builder.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","legacyGraph","getLegacyGraph","graph","buildFromLegacy","_graph","_initialized","seederIds","listIds","newGraph","ComponentGraph","setNodeP","nodes","map","nodeId","componentId","resolveComponentId","component","get","setNode","Node","toString","Promise","all","setEdgePromise","edges","edgeId","source","v","target","w","edgeObj","edge","Dependency","setEdge","Edge"
|
1
|
+
{"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","legacyGraph","getLegacyGraph","graph","buildFromLegacy","_graph","_initialized","seederIds","listIds","newGraph","ComponentGraph","setNodeP","nodes","map","nodeId","componentId","resolveComponentId","component","get","setNode","Node","toString","Promise","all","setEdgePromise","edges","edgeId","source","v","target","w","edgeObj","edge","Dependency","setEdge","Edge"],"sources":["graph-builder.ts"],"sourcesContent":["import { ComponentFactory, ComponentID, ComponentMain } from '@teambit/component';\nimport { Node, Edge } from '@teambit/graph.cleargraph';\nimport type LegacyGraph from '@teambit/legacy/dist/scope/graph/graph';\nimport { ComponentGraph } from './component-graph';\nimport { Dependency } from './model/dependency';\n\ntype GetGraphOpts = {\n host?: ComponentFactory;\n};\n\ntype BuildFromLegacyGraphOpts = {\n host?: ComponentFactory;\n};\n\n/**\n * @todo: potential issues with the current way the class is built.\n * it's possible to call `getGraph` multiple times and at the same time (Promise.all).\n * which makes the _graph prop and other props unpredictable.\n */\nexport class GraphBuilder {\n _graph?: ComponentGraph;\n _initialized = false;\n constructor(private componentAspect: ComponentMain) {}\n\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const legacyGraph = await componentHost.getLegacyGraph(ids);\n const graph = await this.buildFromLegacy(legacyGraph, { host: opts.host });\n this._graph = graph;\n this._initialized = true;\n graph.seederIds = ids || (await componentHost.listIds());\n return this._graph;\n }\n\n private async buildFromLegacy(\n legacyGraph: LegacyGraph,\n opts: BuildFromLegacyGraphOpts = {}\n ): Promise<ComponentGraph> {\n const newGraph = new ComponentGraph();\n const componentHost = opts.host || this.componentAspect.getHost();\n\n const setNodeP = legacyGraph.nodes().map(async (nodeId) => {\n const componentId = await componentHost.resolveComponentId(nodeId);\n const component = await componentHost.get(componentId);\n if (component) {\n newGraph.setNode(new Node(componentId.toString(), component));\n }\n });\n await Promise.all(setNodeP);\n\n const setEdgePromise = legacyGraph.edges().map(async (edgeId) => {\n const source = await componentHost.resolveComponentId(edgeId.v);\n const target = await componentHost.resolveComponentId(edgeId.w);\n const edgeObj =\n legacyGraph.edge(edgeId.v, edgeId.w) === 'dependencies' ? new Dependency('runtime') : new Dependency('dev');\n newGraph.setEdge(new Edge(source.toString(), target.toString(), edgeObj));\n });\n await Promise.all(setEdgePromise);\n\n return newGraph;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAUA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAN,CAAmB;EAGxBC,WAAW,CAASC,eAAT,EAAyC;IAAA,KAAhCA,eAAgC,GAAhCA,eAAgC;IAAA;IAAA,sDADrC,KACqC;EAAE;;EAExC,MAARC,QAAQ,CAACC,GAAD,EAAsBC,IAAkB,GAAG,EAA3C,EAAwE;IACpF,MAAMC,aAAa,GAAGD,IAAI,CAACE,IAAL,IAAa,KAAKL,eAAL,CAAqBM,OAArB,EAAnC;IAEA,MAAMC,WAAW,GAAG,MAAMH,aAAa,CAACI,cAAd,CAA6BN,GAA7B,CAA1B;IACA,MAAMO,KAAK,GAAG,MAAM,KAAKC,eAAL,CAAqBH,WAArB,EAAkC;MAAEF,IAAI,EAAEF,IAAI,CAACE;IAAb,CAAlC,CAApB;IACA,KAAKM,MAAL,GAAcF,KAAd;IACA,KAAKG,YAAL,GAAoB,IAApB;IACAH,KAAK,CAACI,SAAN,GAAkBX,GAAG,KAAK,M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,EAASR,MAAM,CAACN,QAAP,EAAT,EAA4BQ,MAAM,CAACR,QAAP,EAA5B,EAA+CU,OAA/C,CAAjB;IACD,CANsB,CAAvB;IAOA,MAAMT,OAAO,CAACC,GAAR,CAAYC,cAAZ,CAAN;IAEA,OAAOf,QAAP;EACD;;AA1CuB"}
|
@@ -2,16 +2,21 @@ import { ComponentType } from 'react';
|
|
2
2
|
import { SlotRegistry } from '@teambit/harmony';
|
3
3
|
import { ComponentCompareUI } from '@teambit/component-compare';
|
4
4
|
import { ComponentUI, ComponentModel } from '@teambit/component';
|
5
|
+
import { DependenciesGraph } from './ui/dependencies-graph';
|
5
6
|
export interface ComponentWidgetProps extends React.HTMLAttributes<HTMLDivElement> {
|
6
7
|
component: ComponentModel;
|
7
8
|
}
|
8
9
|
export declare type ComponentWidget = ComponentType<ComponentWidgetProps>;
|
9
10
|
export declare type ComponentWidgetSlot = SlotRegistry<ComponentWidget>;
|
11
|
+
export declare type GraphUIConfig = {
|
12
|
+
componentTab: boolean;
|
13
|
+
};
|
10
14
|
/**
|
11
15
|
* Presents dependencies graph in the component page
|
12
16
|
*/
|
13
17
|
export declare class GraphUI {
|
14
18
|
private componentWidgetSlot;
|
19
|
+
getDependenciesGraph(): typeof DependenciesGraph;
|
15
20
|
/**
|
16
21
|
* adds plugins to component nodes
|
17
22
|
* @param value
|
@@ -21,5 +26,8 @@ export declare class GraphUI {
|
|
21
26
|
static dependencies: import("@teambit/harmony").Aspect[];
|
22
27
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
23
28
|
static slots: ((registerFn: () => string) => SlotRegistry<ComponentWidget>)[];
|
24
|
-
static
|
29
|
+
static defaultConfig: {
|
30
|
+
componentTab: boolean;
|
31
|
+
};
|
32
|
+
static provider([componentUI, componentCompare]: [ComponentUI, ComponentCompareUI], config: GraphUIConfig, [componentWidgetSlot]: [ComponentWidgetSlot]): Promise<GraphUI>;
|
25
33
|
}
|
package/dist/graph.ui.runtime.js
CHANGED
@@ -91,14 +91,29 @@ function _graphCompare() {
|
|
91
91
|
return data;
|
92
92
|
}
|
93
93
|
|
94
|
+
function _dependenciesGraph() {
|
95
|
+
const data = require("./ui/dependencies-graph");
|
96
|
+
|
97
|
+
_dependenciesGraph = function () {
|
98
|
+
return data;
|
99
|
+
};
|
100
|
+
|
101
|
+
return data;
|
102
|
+
}
|
103
|
+
|
94
104
|
/**
|
95
105
|
* Presents dependencies graph in the component page
|
96
106
|
*/
|
97
107
|
class GraphUI {
|
108
|
+
getDependenciesGraph() {
|
109
|
+
return _dependenciesGraph().DependenciesGraph;
|
110
|
+
}
|
98
111
|
/**
|
99
112
|
* adds plugins to component nodes
|
100
113
|
* @param value
|
101
114
|
*/
|
115
|
+
|
116
|
+
|
102
117
|
registerComponentWidget(value) {
|
103
118
|
this.componentWidgetSlot.register(value);
|
104
119
|
}
|
@@ -111,7 +126,7 @@ class GraphUI {
|
|
111
126
|
const graphUI = new GraphUI(componentWidgetSlot);
|
112
127
|
const section = new (_graph2().GraphSection)(componentWidgetSlot);
|
113
128
|
const graphSection = new (_graphCompare().GraphCompareSection)();
|
114
|
-
componentUI.registerNavigation(section.navigationLink, section.order);
|
129
|
+
if (config.componentTab) componentUI.registerNavigation(section.navigationLink, section.order);
|
115
130
|
componentUI.registerRoute(section.route);
|
116
131
|
componentCompare.registerNavigation({
|
117
132
|
props: graphSection.navigationLink,
|
@@ -127,6 +142,9 @@ exports.GraphUI = GraphUI;
|
|
127
142
|
(0, _defineProperty2().default)(GraphUI, "dependencies", [_component().ComponentAspect, _componentCompare().ComponentCompareAspect]);
|
128
143
|
(0, _defineProperty2().default)(GraphUI, "runtime", _ui().UIRuntime);
|
129
144
|
(0, _defineProperty2().default)(GraphUI, "slots", [_harmony().Slot.withType()]);
|
145
|
+
(0, _defineProperty2().default)(GraphUI, "defaultConfig", {
|
146
|
+
componentTab: true
|
147
|
+
});
|
130
148
|
|
131
149
|
_graph().GraphAspect.addRuntime(GraphUI);
|
132
150
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphUI","registerComponentWidget","value","componentWidgetSlot","register","constructor","provider","componentUI","componentCompare","config","graphUI","section","GraphSection","graphSection","GraphCompareSection","registerNavigation","navigationLink","order","registerRoute","route","props","registerRoutes","ComponentAspect","ComponentCompareAspect","UIRuntime","Slot","withType","GraphAspect","addRuntime"],"sources":["graph.ui.runtime.tsx"],"sourcesContent":["import { ComponentType } from 'react';\nimport { UIRuntime } from '@teambit/ui';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentCompareUI, ComponentCompareAspect } from '@teambit/component-compare';\nimport { ComponentAspect, ComponentUI, ComponentModel } from '@teambit/component';\nimport { GraphAspect } from './graph.aspect';\nimport { GraphSection } from './ui/graph.section';\nimport { GraphCompareSection } from './graph.compare.section';\n\nexport interface ComponentWidgetProps extends React.HTMLAttributes<HTMLDivElement> {\n component: ComponentModel;\n}\nexport type ComponentWidget = ComponentType<ComponentWidgetProps>;\nexport type ComponentWidgetSlot = SlotRegistry<ComponentWidget>;\n\n/**\n * Presents dependencies graph in the component page\n */\nexport class GraphUI {\n /**\n * adds plugins to component nodes\n * @param value\n */\n registerComponentWidget(value: ComponentWidget) {\n this.componentWidgetSlot.register(value);\n }\n\n constructor(private componentWidgetSlot: ComponentWidgetSlot) {}\n static dependencies = [ComponentAspect, ComponentCompareAspect];\n static runtime = UIRuntime;\n static slots = [Slot.withType<ComponentWidget>()];\n static async provider(\n [componentUI, componentCompare]: [ComponentUI, ComponentCompareUI],\n config,\n [componentWidgetSlot]: [ComponentWidgetSlot]\n ) {\n const graphUI = new GraphUI(componentWidgetSlot);\n const section = new GraphSection(componentWidgetSlot);\n const graphSection = new GraphCompareSection();\n componentUI.registerNavigation(section.navigationLink, section.order);\n componentUI.registerRoute(section.route);\n componentCompare.registerNavigation({\n props: graphSection.navigationLink,\n order: graphSection.navigationLink.order,\n });\n componentCompare.registerRoutes([graphSection.route]);\n return graphUI;\n }\n}\n\nGraphAspect.addRuntime(GraphUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;
|
1
|
+
{"version":3,"names":["GraphUI","getDependenciesGraph","DependenciesGraph","registerComponentWidget","value","componentWidgetSlot","register","constructor","provider","componentUI","componentCompare","config","graphUI","section","GraphSection","graphSection","GraphCompareSection","componentTab","registerNavigation","navigationLink","order","registerRoute","route","props","registerRoutes","ComponentAspect","ComponentCompareAspect","UIRuntime","Slot","withType","GraphAspect","addRuntime"],"sources":["graph.ui.runtime.tsx"],"sourcesContent":["import { ComponentType } from 'react';\nimport { UIRuntime } from '@teambit/ui';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { ComponentCompareUI, ComponentCompareAspect } from '@teambit/component-compare';\nimport { ComponentAspect, ComponentUI, ComponentModel } from '@teambit/component';\nimport { GraphAspect } from './graph.aspect';\nimport { GraphSection } from './ui/graph.section';\nimport { GraphCompareSection } from './graph.compare.section';\nimport { DependenciesGraph } from './ui/dependencies-graph';\n\nexport interface ComponentWidgetProps extends React.HTMLAttributes<HTMLDivElement> {\n component: ComponentModel;\n}\nexport type ComponentWidget = ComponentType<ComponentWidgetProps>;\nexport type ComponentWidgetSlot = SlotRegistry<ComponentWidget>;\n\nexport type GraphUIConfig = {\n componentTab: boolean;\n};\n\n/**\n * Presents dependencies graph in the component page\n */\nexport class GraphUI {\n getDependenciesGraph() {\n return DependenciesGraph;\n }\n\n /**\n * adds plugins to component nodes\n * @param value\n */\n registerComponentWidget(value: ComponentWidget) {\n this.componentWidgetSlot.register(value);\n }\n\n constructor(private componentWidgetSlot: ComponentWidgetSlot) {}\n static dependencies = [ComponentAspect, ComponentCompareAspect];\n static runtime = UIRuntime;\n static slots = [Slot.withType<ComponentWidget>()];\n static defaultConfig = {\n componentTab: true,\n };\n\n static async provider(\n [componentUI, componentCompare]: [ComponentUI, ComponentCompareUI],\n config: GraphUIConfig,\n [componentWidgetSlot]: [ComponentWidgetSlot]\n ) {\n const graphUI = new GraphUI(componentWidgetSlot);\n const section = new GraphSection(componentWidgetSlot);\n const graphSection = new GraphCompareSection();\n if (config.componentTab) componentUI.registerNavigation(section.navigationLink, section.order);\n componentUI.registerRoute(section.route);\n componentCompare.registerNavigation({\n props: graphSection.navigationLink,\n order: graphSection.navigationLink.order,\n });\n componentCompare.registerRoutes([graphSection.route]);\n return graphUI;\n }\n}\n\nGraphAspect.addRuntime(GraphUI);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;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;;AACA;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;;AAYA;AACA;AACA;AACO,MAAMA,OAAN,CAAc;EACnBC,oBAAoB,GAAG;IACrB,OAAOC,sCAAP;EACD;EAED;AACF;AACA;AACA;;;EACEC,uBAAuB,CAACC,KAAD,EAAyB;IAC9C,KAAKC,mBAAL,CAAyBC,QAAzB,CAAkCF,KAAlC;EACD;;EAEDG,WAAW,CAASF,mBAAT,EAAmD;IAAA,KAA1CA,mBAA0C,GAA1CA,mBAA0C;EAAE;;EAQ3C,aAARG,QAAQ,CACnB,CAACC,WAAD,EAAcC,gBAAd,CADmB,EAEnBC,MAFmB,EAGnB,CAACN,mBAAD,CAHmB,EAInB;IACA,MAAMO,OAAO,GAAG,IAAIZ,OAAJ,CAAYK,mBAAZ,CAAhB;IACA,MAAMQ,OAAO,GAAG,KAAIC,sBAAJ,EAAiBT,mBAAjB,CAAhB;IACA,MAAMU,YAAY,GAAG,KAAIC,mCAAJ,GAArB;IACA,IAAIL,MAAM,CAACM,YAAX,EAAyBR,WAAW,CAACS,kBAAZ,CAA+BL,OAAO,CAACM,cAAvC,EAAuDN,OAAO,CAACO,KAA/D;IACzBX,WAAW,CAACY,aAAZ,CAA0BR,OAAO,CAACS,KAAlC;IACAZ,gBAAgB,CAACQ,kBAAjB,CAAoC;MAClCK,KAAK,EAAER,YAAY,CAACI,cADc;MAElCC,KAAK,EAAEL,YAAY,CAACI,cAAb,CAA4BC;IAFD,CAApC;IAIAV,gBAAgB,CAACc,cAAjB,CAAgC,CAACT,YAAY,CAACO,KAAd,CAAhC;IACA,OAAOV,OAAP;EACD;;AArCkB;;;gCAARZ,O,kBAcW,CAACyB,4BAAD,EAAkBC,0CAAlB,C;gCAdX1B,O,aAeM2B,e;gCAfN3B,O,WAgBI,CAAC4B,eAAA,CAAKC,QAAL,EAAD,C;gCAhBJ7B,O,mBAiBY;EACrBiB,YAAY,EAAE;AADO,C;;AAuBzBa,oBAAA,CAAYC,UAAZ,CAAuB/B,OAAvB"}
|
package/graph.ui.runtime.tsx
CHANGED
@@ -6,6 +6,7 @@ import { ComponentAspect, ComponentUI, ComponentModel } from '@teambit/component
|
|
6
6
|
import { GraphAspect } from './graph.aspect';
|
7
7
|
import { GraphSection } from './ui/graph.section';
|
8
8
|
import { GraphCompareSection } from './graph.compare.section';
|
9
|
+
import { DependenciesGraph } from './ui/dependencies-graph';
|
9
10
|
|
10
11
|
export interface ComponentWidgetProps extends React.HTMLAttributes<HTMLDivElement> {
|
11
12
|
component: ComponentModel;
|
@@ -13,10 +14,18 @@ export interface ComponentWidgetProps extends React.HTMLAttributes<HTMLDivElemen
|
|
13
14
|
export type ComponentWidget = ComponentType<ComponentWidgetProps>;
|
14
15
|
export type ComponentWidgetSlot = SlotRegistry<ComponentWidget>;
|
15
16
|
|
17
|
+
export type GraphUIConfig = {
|
18
|
+
componentTab: boolean;
|
19
|
+
};
|
20
|
+
|
16
21
|
/**
|
17
22
|
* Presents dependencies graph in the component page
|
18
23
|
*/
|
19
24
|
export class GraphUI {
|
25
|
+
getDependenciesGraph() {
|
26
|
+
return DependenciesGraph;
|
27
|
+
}
|
28
|
+
|
20
29
|
/**
|
21
30
|
* adds plugins to component nodes
|
22
31
|
* @param value
|
@@ -29,15 +38,19 @@ export class GraphUI {
|
|
29
38
|
static dependencies = [ComponentAspect, ComponentCompareAspect];
|
30
39
|
static runtime = UIRuntime;
|
31
40
|
static slots = [Slot.withType<ComponentWidget>()];
|
41
|
+
static defaultConfig = {
|
42
|
+
componentTab: true,
|
43
|
+
};
|
44
|
+
|
32
45
|
static async provider(
|
33
46
|
[componentUI, componentCompare]: [ComponentUI, ComponentCompareUI],
|
34
|
-
config,
|
47
|
+
config: GraphUIConfig,
|
35
48
|
[componentWidgetSlot]: [ComponentWidgetSlot]
|
36
49
|
) {
|
37
50
|
const graphUI = new GraphUI(componentWidgetSlot);
|
38
51
|
const section = new GraphSection(componentWidgetSlot);
|
39
52
|
const graphSection = new GraphCompareSection();
|
40
|
-
componentUI.registerNavigation(section.navigationLink, section.order);
|
53
|
+
if (config.componentTab) componentUI.registerNavigation(section.navigationLink, section.order);
|
41
54
|
componentUI.registerRoute(section.route);
|
42
55
|
componentCompare.registerNavigation({
|
43
56
|
props: graphSection.navigationLink,
|
Binary file
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/graph",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.788",
|
4
4
|
"homepage": "https://bit.dev/teambit/component/graph",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.component",
|
8
8
|
"name": "graph",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.788"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"graphql-tag": "2.12.1",
|
@@ -24,18 +24,18 @@
|
|
24
24
|
"@teambit/base-ui.text.muted-text": "1.0.1",
|
25
25
|
"@teambit/evangelist.input.checkbox.label": "1.0.3",
|
26
26
|
"@teambit/documenter.ui.heading": "4.1.1",
|
27
|
-
"@teambit/component": "0.0.
|
28
|
-
"@teambit/graphql": "0.0.
|
29
|
-
"@teambit/cli": "0.0.
|
30
|
-
"@teambit/component-compare": "0.0.
|
31
|
-
"@teambit/ui": "0.0.
|
27
|
+
"@teambit/component": "0.0.788",
|
28
|
+
"@teambit/graphql": "0.0.788",
|
29
|
+
"@teambit/cli": "0.0.521",
|
30
|
+
"@teambit/component-compare": "0.0.36",
|
31
|
+
"@teambit/ui": "0.0.788",
|
32
32
|
"@teambit/legacy-bit-id": "0.0.399",
|
33
|
-
"@teambit/component.ui.compare": "0.0.26",
|
34
|
-
"@teambit/design.ui.round-loader": "0.0.346",
|
35
33
|
"@teambit/component.modules.component-url": "0.0.125",
|
36
34
|
"@teambit/component.ui.deprecation-icon": "0.0.494",
|
37
35
|
"@teambit/design.ui.styles.ellipsis": "0.0.347",
|
38
36
|
"@teambit/envs.ui.env-icon": "0.0.486",
|
37
|
+
"@teambit/component.ui.compare": "0.0.28",
|
38
|
+
"@teambit/design.ui.round-loader": "0.0.346",
|
39
39
|
"@teambit/design.ui.pages.not-found": "0.0.356",
|
40
40
|
"@teambit/design.ui.pages.server-error": "0.0.356",
|
41
41
|
"@teambit/ui-foundation.ui.full-loader": "0.0.486",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
},
|
57
57
|
"peerDependencies": {
|
58
58
|
"@apollo/client": "^3.0.0",
|
59
|
-
"@teambit/legacy": "1.0.
|
59
|
+
"@teambit/legacy": "1.0.303",
|
60
60
|
"react-dom": "^16.8.0 || ^17.0.0",
|
61
61
|
"react": "^16.8.0 || ^17.0.0"
|
62
62
|
},
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.788/dist/graph.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_graph@0.0.788/dist/graph.docs.md';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
Binary file
|