@teambit/graph 0.0.881 → 0.0.882
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/component-graph/component-graph.js +4 -46
- package/dist/component-graph/component-graph.js.map +1 -1
- package/dist/component-graph/index.js +0 -3
- package/dist/component-graph/index.js.map +1 -1
- package/dist/duplicate-dependency.js +1 -7
- package/dist/duplicate-dependency.js.map +1 -1
- package/dist/edge-type.js +0 -1
- package/dist/edge-type.js.map +1 -1
- package/dist/graph-builder.js +0 -17
- package/dist/graph-builder.js.map +1 -1
- package/dist/graph-cmd.js +4 -65
- package/dist/graph-cmd.js.map +1 -1
- package/dist/graph.aspect.js +0 -5
- package/dist/graph.aspect.js.map +1 -1
- package/dist/graph.compare.section.js +0 -13
- package/dist/graph.compare.section.js.map +1 -1
- package/dist/graph.composition.js +0 -6
- package/dist/graph.composition.js.map +1 -1
- package/dist/graph.graphql.js +0 -14
- package/dist/graph.graphql.js.map +1 -1
- package/dist/graph.main.runtime.js +0 -36
- package/dist/graph.main.runtime.js.map +1 -1
- package/dist/graph.ui.runtime.js +1 -38
- package/dist/graph.ui.runtime.js.map +1 -1
- package/dist/index.js +0 -33
- package/dist/index.js.map +1 -1
- package/dist/model/dependency/dependency.js +0 -8
- package/dist/model/dependency/dependency.js.map +1 -1
- package/dist/model/dependency/index.js +0 -3
- package/dist/model/dependency/index.js.map +1 -1
- package/dist/object-list-to-graph.js +0 -23
- package/dist/object-list-to-graph.js.map +1 -1
- package/dist/ui/component-node/component-node.js +9 -56
- package/dist/ui/component-node/component-node.js.map +1 -1
- package/dist/ui/component-node/index.js +0 -12
- package/dist/ui/component-node/index.js.map +1 -1
- package/dist/ui/component-node/variants.js +0 -6
- package/dist/ui/component-node/variants.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-graph-model.js +0 -6
- package/dist/ui/dependencies-compare/compare-graph-model.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-node-model.js +0 -11
- package/dist/ui/dependencies-compare/compare-node-model.js.map +1 -1
- package/dist/ui/dependencies-compare/dependencies-compare.js +0 -41
- package/dist/ui/dependencies-compare/dependencies-compare.js.map +1 -1
- package/dist/ui/dependencies-compare/dependency-compare-node.js +4 -66
- package/dist/ui/dependencies-compare/dependency-compare-node.js.map +1 -1
- package/dist/ui/dependencies-compare/diff-graph.js +2 -23
- package/dist/ui/dependencies-compare/diff-graph.js.map +1 -1
- package/dist/ui/dependencies-compare/index.js +0 -3
- package/dist/ui/dependencies-compare/index.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-elements.js +0 -14
- package/dist/ui/dependencies-graph/calc-elements.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-layout.js +5 -11
- package/dist/ui/dependencies-graph/calc-layout.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js +0 -15
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/index.js +0 -3
- package/dist/ui/dependencies-graph/dep-edge/index.js.map +1 -1
- package/dist/ui/dependencies-graph/dependencies-graph.js +12 -47
- package/dist/ui/dependencies-graph/dependencies-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/graph-context.js +0 -4
- package/dist/ui/dependencies-graph/graph-context.js.map +1 -1
- package/dist/ui/dependencies-graph/index.js +0 -24
- package/dist/ui/dependencies-graph/index.js.map +1 -1
- package/dist/ui/dependencies-graph/minimap.js +0 -8
- package/dist/ui/dependencies-graph/minimap.js.map +1 -1
- package/dist/ui/graph-page/graph-filters.js +5 -19
- package/dist/ui/graph-page/graph-filters.js.map +1 -1
- package/dist/ui/graph-page/graph-page.js +0 -37
- package/dist/ui/graph-page/graph-page.js.map +1 -1
- package/dist/ui/graph-page/index.js +0 -12
- package/dist/ui/graph-page/index.js.map +1 -1
- package/dist/ui/graph.section.js +0 -13
- package/dist/ui/graph.section.js.map +1 -1
- package/dist/ui/query/edge-model.js +0 -8
- package/dist/ui/query/edge-model.js.map +1 -1
- package/dist/ui/query/get-graph.query.js +1 -4
- package/dist/ui/query/get-graph.query.js.map +1 -1
- package/dist/ui/query/graph-model.js +0 -10
- package/dist/ui/query/graph-model.js.map +1 -1
- package/dist/ui/query/index.js +0 -18
- package/dist/ui/query/index.js.map +1 -1
- package/dist/ui/query/node-model.js +2 -13
- package/dist/ui/query/node-model.js.map +1 -1
- package/dist/ui/query/use-graph-query.js +0 -16
- package/dist/ui/query/use-graph-query.js.map +1 -1
- package/dist/ui/query/use-graph.js +0 -7
- package/dist/ui/query/use-graph.js.map +1 -1
- package/package-tar/teambit-graph-0.0.882.tgz +0 -0
- package/package.json +10 -10
- package/{preview-1666409808293.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-graph-0.0.881.tgz +0 -0
@@ -1,73 +1,54 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
require("core-js/modules/es.array.flat.js");
|
6
|
-
|
7
5
|
require("core-js/modules/es.array.iterator.js");
|
8
|
-
|
9
6
|
require("core-js/modules/es.array.unscopables.flat.js");
|
10
|
-
|
11
7
|
require("core-js/modules/es.regexp.exec.js");
|
12
|
-
|
13
8
|
Object.defineProperty(exports, "__esModule", {
|
14
9
|
value: true
|
15
10
|
});
|
16
11
|
exports.DEPENDENCIES_TYPES = exports.ComponentGraph = void 0;
|
17
|
-
|
18
12
|
function _defineProperty2() {
|
19
13
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
20
|
-
|
21
14
|
_defineProperty2 = function () {
|
22
15
|
return data;
|
23
16
|
};
|
24
|
-
|
25
17
|
return data;
|
26
18
|
}
|
27
|
-
|
28
19
|
function _graph() {
|
29
20
|
const data = require("@teambit/graph.cleargraph");
|
30
|
-
|
31
21
|
_graph = function () {
|
32
22
|
return data;
|
33
23
|
};
|
34
|
-
|
35
24
|
return data;
|
36
25
|
}
|
37
|
-
|
38
26
|
function _lodash() {
|
39
27
|
const data = require("lodash");
|
40
|
-
|
41
28
|
_lodash = function () {
|
42
29
|
return data;
|
43
30
|
};
|
44
|
-
|
45
31
|
return data;
|
46
32
|
}
|
47
|
-
|
48
33
|
function _duplicateDependency() {
|
49
34
|
const data = require("../duplicate-dependency");
|
50
|
-
|
51
35
|
_duplicateDependency = function () {
|
52
36
|
return data;
|
53
37
|
};
|
54
|
-
|
55
38
|
return data;
|
56
39
|
}
|
57
|
-
|
58
40
|
const DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];
|
59
41
|
exports.DEPENDENCIES_TYPES = DEPENDENCIES_TYPES;
|
60
|
-
|
61
42
|
class ComponentGraph extends _graph().Graph {
|
62
43
|
// component IDs that started the graph. (if from workspace, the .bitmap ids normally)
|
63
44
|
constructor(nodes = [], edges = []) {
|
64
45
|
super(nodes, edges);
|
65
46
|
(0, _defineProperty2().default)(this, "seederIds", []);
|
66
47
|
}
|
67
|
-
|
68
48
|
create(nodes = [], edges = []) {
|
69
49
|
return new ComponentGraph(nodes, edges);
|
70
50
|
}
|
51
|
+
|
71
52
|
/**
|
72
53
|
* check all the routes from the sources to targets and return the components found during this traversal.
|
73
54
|
* e.g.
|
@@ -76,11 +57,8 @@ class ComponentGraph extends _graph().Graph {
|
|
76
57
|
* B -> F -> G.
|
77
58
|
* given source: A, targets: N. The results will be: B, C, E
|
78
59
|
*/
|
79
|
-
|
80
|
-
|
81
60
|
findIdsFromSourcesToTargets(sources, targets) {
|
82
61
|
const removeVerFromIdStr = idStr => idStr.split('@')[0];
|
83
|
-
|
84
62
|
const sourcesStr = sources.map(s => s.toStringWithoutVersion());
|
85
63
|
const targetsStr = targets.map(t => t.toStringWithoutVersion());
|
86
64
|
const allFlattened = sources.map(source => this.successors(source.toString())).flat();
|
@@ -96,30 +74,25 @@ class ComponentGraph extends _graph().Graph {
|
|
96
74
|
const components = this.getNodes(results).map(n => n.attr);
|
97
75
|
return components.map(c => c.id);
|
98
76
|
}
|
77
|
+
|
99
78
|
/**
|
100
79
|
* overrides the super class to eliminate non-seeders components
|
101
80
|
*/
|
102
|
-
|
103
|
-
|
104
81
|
findCycles(graph) {
|
105
82
|
const cycles = super.findCycles(graph);
|
106
|
-
|
107
83
|
if (!this.shouldLimitToSeedersOnly()) {
|
108
84
|
return cycles;
|
109
85
|
}
|
110
|
-
|
111
86
|
const seederIdsStr = this.seederIds.map(id => id.toString());
|
112
87
|
const cyclesWithSeeders = cycles.filter(cycle => {
|
113
88
|
return cycle.some(cycleIdStr => seederIdsStr.includes(cycleIdStr));
|
114
89
|
});
|
115
90
|
return cyclesWithSeeders;
|
116
91
|
}
|
117
|
-
|
118
92
|
findDuplicateDependencies() {
|
119
93
|
const versionMap = this.calculateVersionMap();
|
120
94
|
const seederIdsNoVersions = this.seederIds.map(id => id.toStringWithoutVersion());
|
121
95
|
const duplicateDependencies = new Map();
|
122
|
-
|
123
96
|
for (const [compFullName, versions] of versionMap) {
|
124
97
|
if (versions.allVersionNodes.length > 1) {
|
125
98
|
const versionSubgraphs = [];
|
@@ -138,40 +111,31 @@ class ComponentGraph extends _graph().Graph {
|
|
138
111
|
});
|
139
112
|
const isSeeder = seederIdsNoVersions.includes(compFullName);
|
140
113
|
const shouldDisplayDueToBeingSeeder = !this.shouldLimitToSeedersOnly() || isSeeder;
|
141
|
-
|
142
114
|
if (shouldDisplayDueToBeingSeeder && versionSubgraphs.length > 0) {
|
143
115
|
const duplicateDep = new (_duplicateDependency().DuplicateDependency)(versions.latestVersionNode, versionSubgraphs);
|
144
116
|
duplicateDependencies.set(compFullName, duplicateDep);
|
145
117
|
}
|
146
118
|
}
|
147
119
|
}
|
148
|
-
|
149
120
|
return duplicateDependencies;
|
150
121
|
}
|
151
|
-
|
152
122
|
buildFromCleargraph(graph) {
|
153
123
|
return this.create(graph.nodes, graph.edges);
|
154
124
|
}
|
155
|
-
|
156
125
|
runtimeOnly(componentIds) {
|
157
126
|
return this.successorsSubgraph(componentIds, {
|
158
127
|
edgeFilter: edge => edge.attr.type === 'runtime'
|
159
128
|
});
|
160
129
|
}
|
161
|
-
|
162
130
|
shouldLimitToSeedersOnly() {
|
163
131
|
return this.seederIds.length;
|
164
132
|
}
|
165
|
-
|
166
133
|
calculateVersionMap() {
|
167
134
|
const versionMap = new Map();
|
168
|
-
|
169
135
|
for (const node of this.nodes) {
|
170
136
|
const comp = node.attr;
|
171
137
|
const compKey = node.id;
|
172
|
-
|
173
138
|
const compFullName = comp.id._legacy.toStringWithoutVersion();
|
174
|
-
|
175
139
|
if (!versionMap.has(compFullName)) {
|
176
140
|
versionMap.set(compFullName, {
|
177
141
|
allVersionNodes: [compKey],
|
@@ -179,33 +143,27 @@ class ComponentGraph extends _graph().Graph {
|
|
179
143
|
});
|
180
144
|
} else {
|
181
145
|
const value = versionMap.get(compFullName);
|
182
|
-
|
183
146
|
if (value) {
|
184
147
|
var _this$node;
|
185
|
-
|
186
148
|
if (Object.prototype.hasOwnProperty.call(value, 'allVersionNodes')) {
|
187
149
|
value.allVersionNodes.push(compKey);
|
188
150
|
}
|
189
|
-
|
190
151
|
const currentComp = comp;
|
191
|
-
const latestComp = (_this$node = this.node(value.latestVersionNode)) === null || _this$node === void 0 ? void 0 : _this$node.attr;
|
152
|
+
const latestComp = (_this$node = this.node(value.latestVersionNode)) === null || _this$node === void 0 ? void 0 : _this$node.attr;
|
153
|
+
// @todo: this check won't work when the component doesn't have head.
|
192
154
|
// it happens when a dependency is needed in an old version (not head). which Bit doesn't fetch the head
|
193
155
|
// Version object, and as a result, the `Component.head` is empty.
|
194
156
|
// for now it's probably good enough because it's used only for `findDuplicateDependencies`, which only
|
195
157
|
// checks the components on the workspace.
|
196
|
-
|
197
158
|
if (currentComp.head && latestComp !== null && latestComp !== void 0 && latestComp.head && new Date(currentComp.head.timestamp) > new Date(latestComp.head.timestamp)) {
|
198
159
|
value.latestVersionNode = compKey;
|
199
160
|
}
|
200
161
|
}
|
201
162
|
}
|
202
163
|
}
|
203
|
-
|
204
164
|
return versionMap;
|
205
165
|
}
|
206
|
-
|
207
166
|
}
|
208
|
-
|
209
167
|
exports.ComponentGraph = ComponentGraph;
|
210
168
|
|
211
169
|
//# sourceMappingURL=component-graph.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DEPENDENCIES_TYPES","ComponentGraph","Graph","constructor","nodes","edges","create","findIdsFromSourcesToTargets","sources","targets","removeVerFromIdStr","idStr","split","sourcesStr","map","s","toStringWithoutVersion","targetsStr","t","allFlattened","source","successors","toString","flat","allFlattenedIds","uniq","f","id","results","forEach","idWithNoVer","includes","allSuccessors","allSuccessorsWithNoVersion","find","push","components","getNodes","n","attr","c","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","cyclesWithSeeders","filter","cycle","some","cycleIdStr","findDuplicateDependencies","versionMap","calculateVersionMap","seederIdsNoVersions","duplicateDependencies","Map","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","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';\nimport { uniq } from 'lodash';\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 * check all the routes from the sources to targets and return the components found during this traversal.\n * e.g.\n * A -> B -> C -> N.\n * A -> E -> N.\n * B -> F -> G.\n * given source: A, targets: N. The results will be: B, C, E\n */\n findIdsFromSourcesToTargets(sources: ComponentID[], targets: ComponentID[]): ComponentID[] {\n const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0];\n const sourcesStr = sources.map((s) => s.toStringWithoutVersion());\n const targetsStr = targets.map((t) => t.toStringWithoutVersion());\n const allFlattened = sources.map((source) => this.successors(source.toString())).flat();\n const allFlattenedIds = uniq(allFlattened.map((f) => f.id));\n const results: string[] = [];\n allFlattenedIds.forEach((id) => {\n const idWithNoVer = removeVerFromIdStr(id);\n if (sourcesStr.includes(idWithNoVer) || targetsStr.includes(idWithNoVer)) return;\n const allSuccessors = this.successors(id);\n const allSuccessorsWithNoVersion = allSuccessors.map((s) => removeVerFromIdStr(s.id));\n if (allSuccessorsWithNoVersion.find((s) => targetsStr.includes(s))) results.push(id);\n });\n const components = this.getNodes(results).map((n) => n.attr);\n\n return components.map((c) => c.id);\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;;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,KAAnB,EAA0BC,KAA1B,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;EACEE,2BAA2B,CAACC,OAAD,EAAyBC,OAAzB,EAAgE;IACzF,MAAMC,kBAAkB,GAAIC,KAAD,IAAmBA,KAAK,CAACC,KAAN,CAAY,GAAZ,EAAiB,CAAjB,CAA9C;;IACA,MAAMC,UAAU,GAAGL,OAAO,CAACM,GAAR,CAAaC,CAAD,IAAOA,CAAC,CAACC,sBAAF,EAAnB,CAAnB;IACA,MAAMC,UAAU,GAAGR,OAAO,CAACK,GAAR,CAAaI,CAAD,IAAOA,CAAC,CAACF,sBAAF,EAAnB,CAAnB;IACA,MAAMG,YAAY,GAAGX,OAAO,CAACM,GAAR,CAAaM,M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Af,EAA6B;UAC3BE,eAAe,EAAE,CAAC4B,OAAD,CADU;UAE3BvB,iBAAiB,EAAEuB;QAFQ,CAA7B;MAID,CALD,MAKO;QACL,MAAMG,KAAK,GAAGtC,UAAU,CAACuC,GAAX,CAAelC,YAAf,CAAd;;QACA,IAAIiC,KAAJ,EAAW;UAAA;;UACT,IAAIE,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,KAArC,EAA4C,iBAA5C,CAAJ,EAAoE;YAClEA,KAAK,CAAC/B,eAAN,CAAsBzB,IAAtB,CAA2BqD,OAA3B;UACD;;UACD,MAAMS,WAAW,GAAGV,IAApB;UACA,MAAMW,UAAU,iBAAG,KAAKZ,IAAL,CAAUK,KAAK,CAAC1B,iBAAhB,CAAH,+CAAG,WAAoC1B,IAAvD,CALS,CAMT;UACA;UACA;UACA;UACA;;UACA,IACE0D,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,CAAC1B,iBAAN,GAA0BuB,OAA1B;UACD;QACF;MACF;IACF;;IACD,OAAOnC,UAAP;EACD;;AApI8D"}
|
1
|
+
{"version":3,"names":["DEPENDENCIES_TYPES","ComponentGraph","Graph","constructor","nodes","edges","create","findIdsFromSourcesToTargets","sources","targets","removeVerFromIdStr","idStr","split","sourcesStr","map","s","toStringWithoutVersion","targetsStr","t","allFlattened","source","successors","toString","flat","allFlattenedIds","uniq","f","id","results","forEach","idWithNoVer","includes","allSuccessors","allSuccessorsWithNoVersion","find","push","components","getNodes","n","attr","c","findCycles","graph","cycles","shouldLimitToSeedersOnly","seederIdsStr","seederIds","cyclesWithSeeders","filter","cycle","some","cycleIdStr","findDuplicateDependencies","versionMap","calculateVersionMap","seederIdsNoVersions","duplicateDependencies","Map","compFullName","versions","allVersionNodes","length","versionSubgraphs","notLatestVersions","version","latestVersionNode","predecessors","predecessorsSubgraph","immediatePredecessors","predecessor","subGraph","buildFromCleargraph","versionSubgraph","versionId","immediateDependents","isSeeder","shouldDisplayDueToBeingSeeder","duplicateDep","DuplicateDependency","set","runtimeOnly","componentIds","successorsSubgraph","edgeFilter","edge","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';\nimport { uniq } from 'lodash';\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 * check all the routes from the sources to targets and return the components found during this traversal.\n * e.g.\n * A -> B -> C -> N.\n * A -> E -> N.\n * B -> F -> G.\n * given source: A, targets: N. The results will be: B, C, E\n */\n findIdsFromSourcesToTargets(sources: ComponentID[], targets: ComponentID[]): ComponentID[] {\n const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0];\n const sourcesStr = sources.map((s) => s.toStringWithoutVersion());\n const targetsStr = targets.map((t) => t.toStringWithoutVersion());\n const allFlattened = sources.map((source) => this.successors(source.toString())).flat();\n const allFlattenedIds = uniq(allFlattened.map((f) => f.id));\n const results: string[] = [];\n allFlattenedIds.forEach((id) => {\n const idWithNoVer = removeVerFromIdStr(id);\n if (sourcesStr.includes(idWithNoVer) || targetsStr.includes(idWithNoVer)) return;\n const allSuccessors = this.successors(id);\n const allSuccessorsWithNoVersion = allSuccessors.map((s) => removeVerFromIdStr(s.id));\n if (allSuccessorsWithNoVersion.find((s) => targetsStr.includes(s))) results.push(id);\n });\n const components = this.getNodes(results).map((n) => n.attr);\n\n return components.map((c) => c.id);\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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,kBAAkB,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC;AAAC;AAK/D,MAAMC,cAAc,SAASC,cAAK,CAAwB;EAChC;EAC/BC,WAAW,CAACC,KAAsB,G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A;UACA,IACE0D,WAAW,CAACE,IAAI,IAChBD,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEC,IAAI,IAChB,IAAIC,IAAI,CAACH,WAAW,CAACE,IAAI,CAACE,SAAS,CAAC,GAAG,IAAID,IAAI,CAACF,UAAU,CAACC,IAAI,CAACE,SAAS,CAAC,EAC1E;YACAV,KAAK,CAAC1B,iBAAiB,GAAGuB,OAAO;UACnC;QACF;MACF;IACF;IACA,OAAOnC,UAAU;EACnB;AACF;AAAC"}
|
@@ -9,14 +9,11 @@ Object.defineProperty(exports, "ComponentGraph", {
|
|
9
9
|
return _componentGraph().ComponentGraph;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
|
13
12
|
function _componentGraph() {
|
14
13
|
const data = require("./component-graph");
|
15
|
-
|
16
14
|
_componentGraph = function () {
|
17
15
|
return data;
|
18
16
|
};
|
19
|
-
|
20
17
|
return data;
|
21
18
|
}
|
22
19
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line import/no-cycle\nexport { ComponentGraph } from './component-graph';\n"],"mappings":"
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line import/no-cycle\nexport { ComponentGraph } from './component-graph';\n"],"mappings":";;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
|
@@ -1,23 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.DuplicateDependency = void 0;
|
9
|
-
|
10
8
|
function _defineProperty2() {
|
11
9
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
12
|
-
|
13
10
|
_defineProperty2 = function () {
|
14
11
|
return data;
|
15
12
|
};
|
16
|
-
|
17
13
|
return data;
|
18
14
|
}
|
19
|
-
|
20
15
|
// eslint-disable-next-line import/no-cycle
|
16
|
+
|
21
17
|
class DuplicateDependency {
|
22
18
|
constructor(latestVersionId, priorVersions) {
|
23
19
|
(0, _defineProperty2().default)(this, "latestVersionId", void 0);
|
@@ -25,9 +21,7 @@ class DuplicateDependency {
|
|
25
21
|
this.latestVersionId = latestVersionId;
|
26
22
|
this.priorVersions = priorVersions;
|
27
23
|
}
|
28
|
-
|
29
24
|
}
|
30
|
-
|
31
25
|
exports.DuplicateDependency = DuplicateDependency;
|
32
26
|
|
33
27
|
//# sourceMappingURL=duplicate-dependency.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DuplicateDependency","constructor","latestVersionId","priorVersions"],"sources":["duplicate-dependency.ts"],"sourcesContent":["// eslint-disable-next-line import/no-cycle\nimport type { ComponentGraph } from './component-graph';\n\nexport class DuplicateDependency {\n latestVersionId: string;\n priorVersions: VersionSubgraph[];\n\n constructor(latestVersionId: string, priorVersions: VersionSubgraph[]) {\n this.latestVersionId = latestVersionId;\n this.priorVersions = priorVersions;\n }\n}\n\nexport type VersionSubgraph = {\n versionId: string;\n subGraph: ComponentGraph;\n immediateDependents: string[];\n};\n"],"mappings":"
|
1
|
+
{"version":3,"names":["DuplicateDependency","constructor","latestVersionId","priorVersions"],"sources":["duplicate-dependency.ts"],"sourcesContent":["// eslint-disable-next-line import/no-cycle\nimport type { ComponentGraph } from './component-graph';\n\nexport class DuplicateDependency {\n latestVersionId: string;\n priorVersions: VersionSubgraph[];\n\n constructor(latestVersionId: string, priorVersions: VersionSubgraph[]) {\n this.latestVersionId = latestVersionId;\n this.priorVersions = priorVersions;\n }\n}\n\nexport type VersionSubgraph = {\n versionId: string;\n subGraph: ComponentGraph;\n immediateDependents: string[];\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGO,MAAMA,mBAAmB,CAAC;EAI/BC,WAAW,CAACC,eAAuB,EAAEC,aAAgC,EAAE;IAAA;IAAA;IACrE,IAAI,CAACD,eAAe,GAAGA,eAAe;IACtC,IAAI,CAACC,aAAa,GAAGA,aAAa;EACpC;AACF;AAAC"}
|
package/dist/edge-type.js
CHANGED
package/dist/edge-type.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["EdgeType"],"sources":["edge-type.ts"],"sourcesContent":["export enum EdgeType {\n dev = 'DEV',\n runtime = 'RUNTIME',\n peer = 'PEER',\n}\n"],"mappings":";;;;;;IAAYA,
|
1
|
+
{"version":3,"names":["EdgeType"],"sources":["edge-type.ts"],"sourcesContent":["export enum EdgeType {\n dev = 'DEV',\n runtime = 'RUNTIME',\n peer = 'PEER',\n}\n"],"mappings":";;;;;;IAAYA,QAAQ;AAAA;AAAA,WAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;AAAA,GAARA,QAAQ,wBAARA,QAAQ"}
|
package/dist/graph-builder.js
CHANGED
@@ -1,49 +1,36 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
require("core-js/modules/es.array.iterator.js");
|
4
|
-
|
5
4
|
require("core-js/modules/es.promise.js");
|
6
|
-
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
8
6
|
value: true
|
9
7
|
});
|
10
8
|
exports.GraphBuilder = void 0;
|
11
|
-
|
12
9
|
function _graph() {
|
13
10
|
const data = require("@teambit/graph.cleargraph");
|
14
|
-
|
15
11
|
_graph = function () {
|
16
12
|
return data;
|
17
13
|
};
|
18
|
-
|
19
14
|
return data;
|
20
15
|
}
|
21
|
-
|
22
16
|
function _componentGraph() {
|
23
17
|
const data = require("./component-graph");
|
24
|
-
|
25
18
|
_componentGraph = function () {
|
26
19
|
return data;
|
27
20
|
};
|
28
|
-
|
29
21
|
return data;
|
30
22
|
}
|
31
|
-
|
32
23
|
function _dependency() {
|
33
24
|
const data = require("./model/dependency");
|
34
|
-
|
35
25
|
_dependency = function () {
|
36
26
|
return data;
|
37
27
|
};
|
38
|
-
|
39
28
|
return data;
|
40
29
|
}
|
41
|
-
|
42
30
|
class GraphBuilder {
|
43
31
|
constructor(componentAspect) {
|
44
32
|
this.componentAspect = componentAspect;
|
45
33
|
}
|
46
|
-
|
47
34
|
async getGraph(ids, opts = {}) {
|
48
35
|
const componentHost = opts.host || this.componentAspect.getHost();
|
49
36
|
const legacyGraph = await componentHost.getLegacyGraph(ids, false);
|
@@ -53,14 +40,12 @@ class GraphBuilder {
|
|
53
40
|
graph.seederIds = ids || (await componentHost.listIds());
|
54
41
|
return graph;
|
55
42
|
}
|
56
|
-
|
57
43
|
async buildFromLegacy(legacyGraph, opts = {}) {
|
58
44
|
const newGraph = new (_componentGraph().ComponentGraph)();
|
59
45
|
const componentHost = opts.host || this.componentAspect.getHost();
|
60
46
|
const setNodeP = legacyGraph.nodes().map(async nodeId => {
|
61
47
|
const componentId = await componentHost.resolveComponentId(nodeId);
|
62
48
|
const component = await componentHost.get(componentId);
|
63
|
-
|
64
49
|
if (component) {
|
65
50
|
newGraph.setNode(new (_graph().Node)(componentId.toString(), component));
|
66
51
|
}
|
@@ -75,9 +60,7 @@ class GraphBuilder {
|
|
75
60
|
await Promise.all(setEdgePromise);
|
76
61
|
return newGraph;
|
77
62
|
}
|
78
|
-
|
79
63
|
}
|
80
|
-
|
81
64
|
exports.GraphBuilder = GraphBuilder;
|
82
65
|
|
83
66
|
//# sourceMappingURL=graph-builder.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","legacyGraph","getLegacyGraph","graph","buildFromLegacy","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\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\ntype BuildFromLegacyGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\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, false);\n const graph = await this.buildFromLegacy(legacyGraph, { host: opts.host });\n graph.seederIds = ids || (await componentHost.listIds());\n return 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":"
|
1
|
+
{"version":3,"names":["GraphBuilder","constructor","componentAspect","getGraph","ids","opts","componentHost","host","getHost","legacyGraph","getLegacyGraph","graph","buildFromLegacy","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\nexport type GetGraphOpts = {\n host?: ComponentFactory;\n};\n\ntype BuildFromLegacyGraphOpts = {\n host?: ComponentFactory;\n};\n\nexport class GraphBuilder {\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, false);\n const graph = await this.buildFromLegacy(legacyGraph, { host: opts.host });\n graph.seederIds = ids || (await componentHost.listIds());\n return 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;EAA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