@teambit/graph 1.0.282 → 1.0.283
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/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_component_graph-preview.js +1 -1
- package/artifacts/schema.json +9 -9
- package/dist/component-graph/component-graph.js +1 -1
- package/dist/component-graph/component-graph.js.map +1 -1
- package/dist/component-id-graph.js +2 -2
- package/dist/component-id-graph.js.map +1 -1
- package/dist/duplicate-dependency.js +1 -1
- package/dist/graph-cmd.js +2 -2
- package/dist/graph-cmd.js.map +1 -1
- package/dist/graph.compare.section.js +2 -2
- package/dist/graph.compare.section.js.map +1 -1
- package/dist/graph.composition.js +1 -1
- package/dist/graph.composition.js.map +1 -1
- package/dist/graph.graphql.js.map +1 -1
- package/dist/graph.main.runtime.js +1 -1
- package/dist/graph.main.runtime.js.map +1 -1
- package/dist/graph.ui.runtime.js +1 -1
- package/dist/graph.ui.runtime.js.map +1 -1
- package/dist/model/dependency/dependency.js +1 -1
- package/dist/{preview-1716520879631.js → preview-1716607230882.js} +2 -2
- package/dist/ui/component-node/component-node.js +4 -4
- package/dist/ui/component-node/component-node.js.map +1 -1
- package/dist/ui/component-node/index.js +1 -1
- package/dist/ui/component-node/index.js.map +1 -1
- package/dist/ui/component-node/variants.js +1 -1
- package/dist/ui/component-node/variants.js.map +1 -1
- package/dist/ui/dependencies-compare/compare-node-model.js +1 -1
- package/dist/ui/dependencies-compare/compare-node-model.js.map +1 -1
- package/dist/ui/dependencies-compare/dependencies-compare.js +1 -1
- package/dist/ui/dependencies-compare/dependencies-compare.js.map +1 -1
- package/dist/ui/dependencies-compare/dependency-compare-node.js +4 -4
- package/dist/ui/dependencies-compare/dependency-compare-node.js.map +1 -1
- package/dist/ui/dependencies-compare/diff-graph.js +1 -1
- package/dist/ui/dependencies-compare/diff-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-elements.js.map +1 -1
- package/dist/ui/dependencies-graph/calc-layout.js +1 -1
- package/dist/ui/dependencies-graph/calc-layout.js.map +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js +1 -1
- package/dist/ui/dependencies-graph/dep-edge/dep-edge.js.map +1 -1
- package/dist/ui/dependencies-graph/dependencies-graph.js +4 -4
- package/dist/ui/dependencies-graph/dependencies-graph.js.map +1 -1
- package/dist/ui/dependencies-graph/index.js +1 -1
- package/dist/ui/dependencies-graph/index.js.map +1 -1
- package/dist/ui/graph-page/graph-filters.js +3 -3
- package/dist/ui/graph-page/graph-filters.js.map +1 -1
- package/dist/ui/graph-page/graph-page.js +1 -1
- package/dist/ui/graph-page/graph-page.js.map +1 -1
- package/dist/ui/graph-page/index.js +1 -1
- package/dist/ui/graph-page/index.js.map +1 -1
- package/dist/ui/graph.section.js +2 -2
- package/dist/ui/graph.section.js.map +1 -1
- package/dist/ui/query/edge-model.js +1 -1
- package/dist/ui/query/get-graph.query.js.map +1 -1
- package/dist/ui/query/node-model.js +1 -1
- package/dist/ui/query/node-model.js.map +1 -1
- package/package.json +8 -8
@@ -1,4 +1,4 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<testsuites tests="0" failures="0" errors="0" skipped="0">
|
3
|
-
<testsuite name="teambit.component/graph@1.0.
|
3
|
+
<testsuite name="teambit.component/graph@1.0.283" tests="0" failures="0" errors="0" skipped="0"/>
|
4
4
|
</testsuites>
|
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.component/graph-preview"]=t():e["teambit.component/graph-preview"]=t()}(self,(()=>(()=>{"use strict";var e={
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.component/graph-preview"]=t():e["teambit.component/graph-preview"]=t()}(self,(()=>(()=>{"use strict";var e={77450:(e,t,o)=>{var n={id:"teambit.component/graph@1.0.283",homepage:"https://bit.cloud/teambit/component/graph",exported:!0};function r(){const e=i(o(41594));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=n,i.__bit_component=n;const a=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/graph.svg"}));a.__bit_component=n,t.Logo=a},41594:e=>{e.exports=React}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{compositions:()=>d,compositions_metadata:()=>f,overview:()=>l});var e={};o.r(e),o.d(e,{default:()=>u});var t=o(77450);o(41594);const r=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var a=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)({}).hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},p.apply(null,arguments)}var c={},s="wrapper";function u(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,n,r=function(e,t){if(null==e)return{};var o={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;o[n]=e[n]}return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)o=i[n],t.indexOf(o)>=0||{}.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}(e,a);return(0,r.mdx)(s,p({},c,o,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}u.isMDXComponent=!0;const d=[t],l=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),n})()));
|
package/artifacts/schema.json
CHANGED
@@ -566,7 +566,7 @@
|
|
566
566
|
"_legacy": {
|
567
567
|
"scope": "teambit.component",
|
568
568
|
"name": "graph",
|
569
|
-
"version": "1.0.
|
569
|
+
"version": "1.0.283"
|
570
570
|
},
|
571
571
|
"_scope": "teambit.component"
|
572
572
|
}
|
@@ -3042,7 +3042,7 @@
|
|
3042
3042
|
"_legacy": {
|
3043
3043
|
"scope": "teambit.component",
|
3044
3044
|
"name": "graph",
|
3045
|
-
"version": "1.0.
|
3045
|
+
"version": "1.0.283"
|
3046
3046
|
},
|
3047
3047
|
"_scope": "teambit.component"
|
3048
3048
|
}
|
@@ -3556,7 +3556,7 @@
|
|
3556
3556
|
"_legacy": {
|
3557
3557
|
"scope": "teambit.component",
|
3558
3558
|
"name": "graph",
|
3559
|
-
"version": "1.0.
|
3559
|
+
"version": "1.0.283"
|
3560
3560
|
},
|
3561
3561
|
"_scope": "teambit.component"
|
3562
3562
|
}
|
@@ -3681,7 +3681,7 @@
|
|
3681
3681
|
"_legacy": {
|
3682
3682
|
"scope": "teambit.component",
|
3683
3683
|
"name": "graph",
|
3684
|
-
"version": "1.0.
|
3684
|
+
"version": "1.0.283"
|
3685
3685
|
},
|
3686
3686
|
"_scope": "teambit.component"
|
3687
3687
|
}
|
@@ -5197,7 +5197,7 @@
|
|
5197
5197
|
"_legacy": {
|
5198
5198
|
"scope": "teambit.component",
|
5199
5199
|
"name": "graph",
|
5200
|
-
"version": "1.0.
|
5200
|
+
"version": "1.0.283"
|
5201
5201
|
},
|
5202
5202
|
"_scope": "teambit.component"
|
5203
5203
|
}
|
@@ -7674,7 +7674,7 @@
|
|
7674
7674
|
"_legacy": {
|
7675
7675
|
"scope": "teambit.component",
|
7676
7676
|
"name": "graph",
|
7677
|
-
"version": "1.0.
|
7677
|
+
"version": "1.0.283"
|
7678
7678
|
},
|
7679
7679
|
"_scope": "teambit.component"
|
7680
7680
|
}
|
@@ -8287,7 +8287,7 @@
|
|
8287
8287
|
"_legacy": {
|
8288
8288
|
"scope": "teambit.component",
|
8289
8289
|
"name": "graph",
|
8290
|
-
"version": "1.0.
|
8290
|
+
"version": "1.0.283"
|
8291
8291
|
},
|
8292
8292
|
"_scope": "teambit.component"
|
8293
8293
|
}
|
@@ -8449,7 +8449,7 @@
|
|
8449
8449
|
"_legacy": {
|
8450
8450
|
"scope": "teambit.component",
|
8451
8451
|
"name": "graph",
|
8452
|
-
"version": "1.0.
|
8452
|
+
"version": "1.0.283"
|
8453
8453
|
},
|
8454
8454
|
"_scope": "teambit.component"
|
8455
8455
|
}
|
@@ -10073,7 +10073,7 @@
|
|
10073
10073
|
"componentId": {
|
10074
10074
|
"scope": "teambit.component",
|
10075
10075
|
"name": "graph",
|
10076
|
-
"version": "1.0.
|
10076
|
+
"version": "1.0.283"
|
10077
10077
|
},
|
10078
10078
|
"taggedModuleExports": []
|
10079
10079
|
}
|
@@ -18,7 +18,7 @@ function _duplicateDependency() {
|
|
18
18
|
};
|
19
19
|
return data;
|
20
20
|
}
|
21
|
-
function _defineProperty(
|
21
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
23
23
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
24
24
|
const DEPENDENCIES_TYPES = exports.DEPENDENCIES_TYPES = ['dependencies', 'devDependencies'];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graph","data","require","_duplicateDependency","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","DEPENDENCIES_TYPES","exports","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","has","get","prototype","hasOwnProperty","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 * @deprecate use graph.getGraphIds().findCycles()\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.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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,qBAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,oBAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+E,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YA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,UAAU,CAACyC,GAAG,CAACnC,YAAY,CAAC;QAC1C,IAAIhD,KAAK,EAAE;UACT,IAAIE,MAAM,CAACkF,SAAS,CAACC,cAAc,CAACvE,IAAI,CAACd,KAAK,EAAE,iBAAiB,CAAC,EAAE;YAClEA,KAAK,CAACkD,eAAe,CAACgB,IAAI,CAACe,OAAO,CAAC;UACrC;UACA,MAAMK,WAAW,GAAGN,IAAI;UACxB,MAAMO,UAAU,GAAG,IAAI,CAACR,IAAI,CAAC/E,KAAK,CAACuD,iBAAiB,CAAC,EAAEsB,IAAI;UAC3D;UACA;UACA;UACA;UACA;UACA,IACES,WAAW,CAACE,IAAI,IAChBD,UAAU,EAAEC,IAAI,IAChB,IAAIC,IAAI,CAACH,WAAW,CAACE,IAAI,CAACE,SAAS,CAAC,GAAG,IAAID,IAAI,CAACF,UAAU,CAACC,IAAI,CAACE,SAAS,CAAC,EAC1E;YACA1F,KAAK,CAACuD,iBAAiB,GAAG0B,OAAO;UACnC;QACF;MACF;IACF;IACA,OAAOvC,UAAU;EACnB;AACF;AAACvB,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_graph","data","require","_duplicateDependency","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEPENDENCIES_TYPES","exports","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","has","get","prototype","hasOwnProperty","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 * @deprecate use graph.getGraphIds().findCycles()\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.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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AAK,CAACiD,iBAAiB,GAAG0B,OAAO;UACnC;QACF;MACF;IACF;IACA,OAAOvC,UAAU;EACnB;AACF;AAACvB,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
@@ -32,8 +32,8 @@ function _lodash() {
|
|
32
32
|
};
|
33
33
|
return data;
|
34
34
|
}
|
35
|
-
function _interopRequireDefault(
|
36
|
-
function _defineProperty(
|
35
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
36
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
37
37
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
38
38
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
39
39
|
class ComponentIdGraph extends _graph().Graph {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_componentId","data","require","_graph","_graphlib","_interopRequireDefault","_lodash","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","ComponentIdGraph","Graph","constructor","nodes","edges","graphLib","_graphLib","GraphLib","forEach","node","setNode","id","toString","edge","setEdge","sourceId","targetId","attr","create","findIdsFromSourcesToTargets","sources","targets","through","removeVerFromIdStr","idStr","split","sourcesStr","map","s","toStringWithoutVersion","targetsStr","allFlattened","source","successors","flat","allFlattenedIds","uniq","f","results","idWithNoVer","includes","allSuccessors","allSuccessorsWithNoVersion","find","push","componentIds","getNodes","n","length","resultsWithThrough","throughStr","allGraph","subgraph","allGraphWithNoVersion","every","findAllPathsFromSourcesToTargets","findAllPathsBFS","start","end","paths","visited","Set","queue","path","shift","add","outEdges","successor","has","allPaths","filter","pathWithVer","pathWithoutVer","p","filtered","firstDep","sort","a","b","findCycles","graph","includeDeps","cycles","cycle","reverse","shouldLimitToSeedersOnly","seederIdsStr","seederIds","cyclesWithSeeders","some","cycleIdStr","buildFromCleargraph","runtimeOnly","successorsSubgraph","edgeFilter","getDependenciesInfo","dijkstraResults","alg","dijkstra","dependencies","keys","distance","Infinity","predecessor","dependencyType","depth","parent","getDependenciesAsObjectTree","depsInfo","ComponentID","fromString","populateTreeItems","treeItems","children","depInfo","child","compId","label","currentNodes","tree","exports"],"sources":["component-id-graph.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport type { DependenciesInfo } from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport GraphLib from 'graphlib';\nimport { uniq } from 'lodash';\n\nexport type DepEdgeType = 'prod' | 'dev' | 'ext' | 'peer';\n\ntype ComponentIdNode = Node<ComponentID>;\ntype DependencyEdge = Edge<DepEdgeType>;\nexport type CompIdGraph = Graph<ComponentID, DepEdgeType>;\n\nexport class ComponentIdGraph extends Graph<ComponentID, DepEdgeType> {\n private _graphLib: GraphLib.Graph;\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n get graphLib() {\n if (!this._graphLib) {\n // convert clearGraph to graphLib\n this._graphLib = new GraphLib.Graph();\n this.nodes.forEach((node) => {\n this._graphLib.setNode(node.id.toString());\n });\n this.edges.forEach((edge) => {\n this._graphLib.setEdge(edge.sourceId.toString(), edge.targetId.toString(), edge.attr);\n });\n }\n return this._graphLib;\n }\n\n protected create(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentIdGraph(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 * if through is provided, it will only return the components that are connected to the through components.\n * with the example above, if through is B, the results will be: [B, C].\n */\n findIdsFromSourcesToTargets(sources: ComponentID[], targets: ComponentID[], through?: 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 componentIds = this.getNodes(results).map((n) => n.attr);\n\n if (!through?.length) {\n return componentIds;\n }\n\n const resultsWithThrough: ComponentID[] = [];\n const throughStr = through.map((t) => t.toStringWithoutVersion());\n componentIds.forEach((id) => {\n const allGraph = this.subgraph(id.toString()).nodes.map((n) => n.id); // successors and predecessors\n const allGraphWithNoVersion = allGraph.map((s) => removeVerFromIdStr(s));\n if (throughStr.every((t) => allGraphWithNoVersion.includes(t))) resultsWithThrough.push(id);\n });\n\n return resultsWithThrough;\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 * if through is provided, it will only return the components that are connected to the through components.\n * with the example above, if through is B, the results will be: [B, C].\n */\n findAllPathsFromSourcesToTargets(\n sources: ComponentID[],\n targets: ComponentID[],\n through?: ComponentID[]\n ): string[][] {\n const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0];\n\n const findAllPathsBFS = (start: string[], end: string[]): string[][] => {\n const paths: string[][] = [];\n const visited = new Set<string>();\n const queue: { node: string; path: string[] }[] = [];\n start.forEach((s) => queue.push({ node: s, path: [s] }));\n while (queue.length) {\n const { node, path } = queue.shift()!;\n if (end.includes(removeVerFromIdStr(node))) {\n paths.push([...path]);\n } else {\n visited.add(node);\n const successors = this.outEdges(node).map((e) => e.targetId);\n for (const successor of successors) {\n if (!visited.has(successor)) {\n queue.push({ node: successor, path: [...path, successor] });\n }\n }\n }\n }\n return paths;\n };\n\n const targetsStr = targets.map((t) => t.toStringWithoutVersion());\n const sourcesStr = sources.map((s) => s.toString());\n\n let allPaths = findAllPathsBFS(sourcesStr, targetsStr);\n\n if (through?.length) {\n allPaths = allPaths.filter((pathWithVer) => {\n const pathWithoutVer = pathWithVer.map((p) => removeVerFromIdStr(p));\n return through.every((t) => pathWithoutVer.includes(t.toStringWithoutVersion()));\n });\n }\n\n const filtered = allPaths.filter((path) => {\n if (path.length < 3) {\n // if length is 1, the source and target are the same.\n // if length is 2, the target is a direct dependency of the source. we don't care about it.\n return false;\n }\n const [, firstDep] = path;\n if (sourcesStr.includes(firstDep)) {\n // the first item is the source. the second item \"firstDep\" can be a direct dependency of one of the sources.\n // if this is the case, we have already an exact path without this firstDep.\n return true;\n }\n return true;\n });\n\n return filtered.sort((a, b) => a.length - b.length);\n }\n\n /**\n * overrides the super class to eliminate non-seeders components\n */\n findCycles(graph?: this, includeDeps = false): string[][] {\n const cycles = super.findCycles(graph);\n // reverse the order to show a more intuitive cycle order. from the dependent to the dependency.\n cycles.forEach((cycle) => cycle.reverse());\n if (!this.shouldLimitToSeedersOnly() || includeDeps) {\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 buildFromCleargraph(graph: Graph<ComponentID, DepEdgeType>): ComponentIdGraph {\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 === 'prod',\n });\n }\n\n getDependenciesInfo(id: ComponentID): DependenciesInfo[] {\n const dijkstraResults = GraphLib.alg.dijkstra(this.graphLib, id.toString());\n const dependencies: DependenciesInfo[] = [];\n Object.keys(dijkstraResults).forEach((idStr) => {\n const distance = dijkstraResults[idStr].distance;\n if (distance === Infinity || distance === 0) {\n // there is no dependency or it's the same component (distance zero)\n return;\n }\n const predecessor = dijkstraResults[idStr].predecessor;\n const dependencyType = this.edge(predecessor, idStr);\n dependencies.push({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n id: this.node(idStr)!.attr,\n depth: distance,\n parent: predecessor,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dependencyType: dependencyType!.attr,\n });\n });\n dependencies.sort((a, b) => a.depth - b.depth);\n return dependencies;\n }\n\n getDependenciesAsObjectTree(idStr: string): Record<string, any> {\n const depsInfo = this.getDependenciesInfo(ComponentID.fromString(idStr));\n const populateTreeItems = (id: string, treeItems: Array<{ label: string; nodes?: Array<Record<string, any>> }>) => {\n const children = depsInfo.filter((depInfo) => depInfo.parent === id);\n if (!children || children.length === 0) {\n return;\n }\n children.forEach((child) => {\n const { id: compId } = child;\n const label = compId.toString();\n const currentNodes = [];\n treeItems.push({ label, nodes: currentNodes });\n populateTreeItems(label, currentNodes);\n });\n };\n\n const currentNodes = [];\n const tree = { label: idStr, nodes: currentNodes };\n populateTreeItems(idStr, currentNodes);\n return tree;\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA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G3B,CAAC,CAAC2B,KAAK,CAAC;IAC9C,OAAON,YAAY;EACrB;EAEAQ,2BAA2BA,CAACnF,KAAa,EAAuB;IAC9D,MAAMoF,QAAQ,GAAG,IAAI,CAACb,mBAAmB,CAACc,0BAAW,CAACC,UAAU,CAACtF,KAAK,CAAC,CAAC;IACxE,MAAMuF,iBAAiB,GAAGA,CAACpG,EAAU,EAAEqG,SAAuE,KAAK;MACjH,MAAMC,QAAQ,GAAGL,QAAQ,CAACtC,MAAM,CAAE4C,OAAO,IAAKA,OAAO,CAACR,MAAM,KAAK/F,EAAE,CAAC;MACpE,IAAI,CAACsG,QAAQ,IAAIA,QAAQ,CAACjE,MAAM,KAAK,CAAC,EAAE;QACtC;MACF;MACAiE,QAAQ,CAACzG,OAAO,CAAE2G,KAAK,IAAK;QAC1B,MAAM;UAAExG,EAAE,EAAEyG;QAAO,CAAC,GAAGD,KAAK;QAC5B,MAAME,KAAK,GAAGD,MAAM,CAACxG,QAAQ,CAAC,CAAC;QAC/B,MAAM0G,YAAY,GAAG,EAAE;QACvBN,SAAS,CAACpE,IAAI,CAAC;UAAEyE,KAAK;UAAElH,KAAK,EAAEmH;QAAa,CAAC,CAAC;QAC9CP,iBAAiB,CAACM,KAAK,EAAEC,YAAY,CAAC;MACxC,CAAC,CAAC;IACJ,CAAC;IAED,MAAMA,YAAY,GAAG,EAAE;IACvB,MAAMC,IAAI,GAAG;MAAEF,KAAK,EAAE7F,KAAK;MAAErB,KAAK,EAAEmH;IAAa,CAAC;IAClDP,iBAAiB,CAACvF,KAAK,EAAE8F,YAAY,CAAC;IACtC,OAAOC,IAAI;EACb;EAEQlC,wBAAwBA,CAAA,EAAG;IACjC,OAAO,IAAI,CAACE,SAAS,CAACvC,MAAM;EAC9B;AACF;AAACwE,OAAA,CAAAxH,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_componentId","data","require","_graph","_graphlib","_interopRequireDefault","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentIdGraph","Graph","constructor","nodes","edges","graphLib","_graphLib","GraphLib","forEach","node","setNode","id","toString","edge","setEdge","sourceId","targetId","attr","create","findIdsFromSourcesToTargets","sources","targets","through","removeVerFromIdStr","idStr","split","sourcesStr","map","s","toStringWithoutVersion","targetsStr","allFlattened","source","successors","flat","allFlattenedIds","uniq","f","results","idWithNoVer","includes","allSuccessors","allSuccessorsWithNoVersion","find","push","componentIds","getNodes","n","length","resultsWithThrough","throughStr","allGraph","subgraph","allGraphWithNoVersion","every","findAllPathsFromSourcesToTargets","findAllPathsBFS","start","end","paths","visited","Set","queue","path","shift","add","outEdges","successor","has","allPaths","filter","pathWithVer","pathWithoutVer","p","filtered","firstDep","sort","a","b","findCycles","graph","includeDeps","cycles","cycle","reverse","shouldLimitToSeedersOnly","seederIdsStr","seederIds","cyclesWithSeeders","some","cycleIdStr","buildFromCleargraph","runtimeOnly","successorsSubgraph","edgeFilter","getDependenciesInfo","dijkstraResults","alg","dijkstra","dependencies","keys","distance","Infinity","predecessor","dependencyType","depth","parent","getDependenciesAsObjectTree","depsInfo","ComponentID","fromString","populateTreeItems","treeItems","children","depInfo","child","compId","label","currentNodes","tree","exports"],"sources":["component-id-graph.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport type { DependenciesInfo } from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport GraphLib from 'graphlib';\nimport { uniq } from 'lodash';\n\nexport type DepEdgeType = 'prod' | 'dev' | 'ext' | 'peer';\n\ntype ComponentIdNode = Node<ComponentID>;\ntype DependencyEdge = Edge<DepEdgeType>;\nexport type CompIdGraph = Graph<ComponentID, DepEdgeType>;\n\nexport class ComponentIdGraph extends Graph<ComponentID, DepEdgeType> {\n private _graphLib: GraphLib.Graph;\n seederIds: ComponentID[] = []; // component IDs that started the graph. (if from workspace, the .bitmap ids normally)\n constructor(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []) {\n super(nodes, edges);\n }\n\n get graphLib() {\n if (!this._graphLib) {\n // convert clearGraph to graphLib\n this._graphLib = new GraphLib.Graph();\n this.nodes.forEach((node) => {\n this._graphLib.setNode(node.id.toString());\n });\n this.edges.forEach((edge) => {\n this._graphLib.setEdge(edge.sourceId.toString(), edge.targetId.toString(), edge.attr);\n });\n }\n return this._graphLib;\n }\n\n protected create(nodes: ComponentIdNode[] = [], edges: DependencyEdge[] = []): this {\n return new ComponentIdGraph(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 * if through is provided, it will only return the components that are connected to the through components.\n * with the example above, if through is B, the results will be: [B, C].\n */\n findIdsFromSourcesToTargets(sources: ComponentID[], targets: ComponentID[], through?: 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 componentIds = this.getNodes(results).map((n) => n.attr);\n\n if (!through?.length) {\n return componentIds;\n }\n\n const resultsWithThrough: ComponentID[] = [];\n const throughStr = through.map((t) => t.toStringWithoutVersion());\n componentIds.forEach((id) => {\n const allGraph = this.subgraph(id.toString()).nodes.map((n) => n.id); // successors and predecessors\n const allGraphWithNoVersion = allGraph.map((s) => removeVerFromIdStr(s));\n if (throughStr.every((t) => allGraphWithNoVersion.includes(t))) resultsWithThrough.push(id);\n });\n\n return resultsWithThrough;\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 * if through is provided, it will only return the components that are connected to the through components.\n * with the example above, if through is B, the results will be: [B, C].\n */\n findAllPathsFromSourcesToTargets(\n sources: ComponentID[],\n targets: ComponentID[],\n through?: ComponentID[]\n ): string[][] {\n const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0];\n\n const findAllPathsBFS = (start: string[], end: string[]): string[][] => {\n const paths: string[][] = [];\n const visited = new Set<string>();\n const queue: { node: string; path: string[] }[] = [];\n start.forEach((s) => queue.push({ node: s, path: [s] }));\n while (queue.length) {\n const { node, path } = queue.shift()!;\n if (end.includes(removeVerFromIdStr(node))) {\n paths.push([...path]);\n } else {\n visited.add(node);\n const successors = this.outEdges(node).map((e) => e.targetId);\n for (const successor of successors) {\n if (!visited.has(successor)) {\n queue.push({ node: successor, path: [...path, successor] });\n }\n }\n }\n }\n return paths;\n };\n\n const targetsStr = targets.map((t) => t.toStringWithoutVersion());\n const sourcesStr = sources.map((s) => s.toString());\n\n let allPaths = findAllPathsBFS(sourcesStr, targetsStr);\n\n if (through?.length) {\n allPaths = allPaths.filter((pathWithVer) => {\n const pathWithoutVer = pathWithVer.map((p) => removeVerFromIdStr(p));\n return through.every((t) => pathWithoutVer.includes(t.toStringWithoutVersion()));\n });\n }\n\n const filtered = allPaths.filter((path) => {\n if (path.length < 3) {\n // if length is 1, the source and target are the same.\n // if length is 2, the target is a direct dependency of the source. we don't care about it.\n return false;\n }\n const [, firstDep] = path;\n if (sourcesStr.includes(firstDep)) {\n // the first item is the source. the second item \"firstDep\" can be a direct dependency of one of the sources.\n // if this is the case, we have already an exact path without this firstDep.\n return true;\n }\n return true;\n });\n\n return filtered.sort((a, b) => a.length - b.length);\n }\n\n /**\n * overrides the super class to eliminate non-seeders components\n */\n findCycles(graph?: this, includeDeps = false): string[][] {\n const cycles = super.findCycles(graph);\n // reverse the order to show a more intuitive cycle order. from the dependent to the dependency.\n cycles.forEach((cycle) => cycle.reverse());\n if (!this.shouldLimitToSeedersOnly() || includeDeps) {\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 buildFromCleargraph(graph: Graph<ComponentID, DepEdgeType>): ComponentIdGraph {\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 === 'prod',\n });\n }\n\n getDependenciesInfo(id: ComponentID): DependenciesInfo[] {\n const dijkstraResults = GraphLib.alg.dijkstra(this.graphLib, id.toString());\n const dependencies: DependenciesInfo[] = [];\n Object.keys(dijkstraResults).forEach((idStr) => {\n const distance = dijkstraResults[idStr].distance;\n if (distance === Infinity || distance === 0) {\n // there is no dependency or it's the same component (distance zero)\n return;\n }\n const predecessor = dijkstraResults[idStr].predecessor;\n const dependencyType = this.edge(predecessor, idStr);\n dependencies.push({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n id: this.node(idStr)!.attr,\n depth: distance,\n parent: predecessor,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dependencyType: dependencyType!.attr,\n });\n });\n dependencies.sort((a, b) => a.depth - b.depth);\n return dependencies;\n }\n\n getDependenciesAsObjectTree(idStr: string): Record<string, any> {\n const depsInfo = this.getDependenciesInfo(ComponentID.fromString(idStr));\n const populateTreeItems = (id: string, treeItems: Array<{ label: string; nodes?: Array<Record<string, any>> }>) => {\n const children = depsInfo.filter((depInfo) => depInfo.parent === id);\n if (!children || children.length === 0) {\n return;\n }\n children.forEach((child) => {\n const { id: compId } = child;\n const label = compId.toString();\n const currentNodes = [];\n treeItems.push({ label, nodes: currentNodes });\n populateTreeItems(label, currentNodes);\n });\n };\n\n const currentNodes = [];\n const tree = { label: idStr, nodes: currentNodes };\n populateTreeItems(idStr, currentNodes);\n return tree;\n }\n\n private shouldLimitToSeedersOnly() {\n return this.seederIds.length;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM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,CAAC;IAED,MAAMA,YAAY,GAAG,EAAE;IACvB,MAAMC,IAAI,GAAG;MAAEF,KAAK,EAAE7F,KAAK;MAAErB,KAAK,EAAEmH;IAAa,CAAC;IAClDP,iBAAiB,CAACvF,KAAK,EAAE8F,YAAY,CAAC;IACtC,OAAOC,IAAI;EACb;EAEQlC,wBAAwBA,CAAA,EAAG;IACjC,OAAO,IAAI,CAACE,SAAS,CAACvC,MAAM;EAC9B;AACF;AAACwE,OAAA,CAAAxH,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.DuplicateDependency = void 0;
|
7
|
-
function _defineProperty(
|
7
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
9
9
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
10
10
|
// eslint-disable-next-line import/no-cycle
|
package/dist/graph-cmd.js
CHANGED
@@ -83,8 +83,8 @@ function _getRemoteByName() {
|
|
83
83
|
}
|
84
84
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
85
85
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
86
|
-
function _interopRequireDefault(
|
87
|
-
function _defineProperty(
|
86
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
87
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
88
88
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
89
89
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
90
90
|
class GraphCmd {
|
package/dist/graph-cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_os","path","_interopRequireWildcard","_graphlib","_componentId","_toolboxString","_vizgraph","_consumer","_scopeGraph","_exceptions","_getRemoteByName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","obj","_defineProperty","key","value","_toPropertyKey","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","GraphCmd","constructor","componentAspect","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","join","os","tmpdir","generateRandomStr","result","chalk","green","getBitId","undefined","ComponentID","fromString","getParsedId","bitId","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write","exports"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\nimport * as path from 'path';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { generateRandomStr } from '@teambit/toolbox.string.random';\nimport VisualDependencyGraph from '@teambit/legacy/dist/scope/graph/vizgraph';\nimport { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { ComponentMain } from '@teambit/component';\n\ntype GraphOpt = {\n image?: string;\n remote?: string;\n allVersions?: boolean;\n layout?: string;\n json?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = \"generate an image file with the workspace components' dependencies graph\";\n extendedDescription: 'black arrow is a runtime dependency. red arrow is either dev or peer';\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path and format. use one of the following extensions: [gif, png, svg, pdf]'],\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n ['', 'all-versions', 'enter all components versions into the graph, not only latest'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n constructor(private componentAspect: ComponentMain) {}\n\n async report([id]: [string], { remote, allVersions, layout, image }: GraphOpt): Promise<string> {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n\n const config = {};\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (layout) config.layout = layout;\n const visualDependencyGraph = await VisualDependencyGraph.loadFromGraphlib(graph, config);\n\n image = image || path.join(os.tmpdir(), `${generateRandomStr()}.png`);\n const result = await visualDependencyGraph.image(image);\n\n return chalk.green(`image created at ${result}`);\n }\n\n private async generateGraph(\n consumer?: Consumer,\n id?: string,\n remote?: string,\n allVersions?: boolean\n ): Promise<GraphLib.Graph> {\n if (!consumer && !remote) throw new ConsumerNotFound();\n const getBitId = (): ComponentID | undefined => {\n if (!id) return undefined;\n if (remote) return ComponentID.fromString(id); // user used --remote so we know it has a scope\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return consumer.getParsedId(id);\n };\n const bitId = getBitId();\n if (remote) {\n if (id) {\n // @ts-ignore scope must be set as it came from a remote\n const scopeName: string = typeof remote === 'string' ? remote : bitId.scope;\n const remoteScope = await getRemoteByName(scopeName, consumer);\n const componentDepGraph = await remoteScope.graph(bitId);\n return componentDepGraph.graph;\n }\n if (typeof remote !== 'string') {\n throw new Error('please specify remote scope name or enter an id');\n }\n const remoteScope = await getRemoteByName(remote, consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n\n const onlyLatest = !allVersions;\n // @ts-ignore consumer must be set here\n const workspaceGraph = await DependencyGraph.buildGraphFromWorkspace(consumer, onlyLatest);\n const dependencyGraph = new DependencyGraph(workspaceGraph);\n if (id) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);\n const componentDepGraph = new DependencyGraph(componentGraph);\n return componentDepGraph.graph;\n }\n return dependencyGraph.graph;\n }\n\n async json([id]: [string], { remote, allVersions }: GraphOpt) {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n return GraphLib.json.write(graph);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,I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KAAK,CAAC;MAC9E,MAAMK,iBAAiB,GAAG,KAAII,qBAAe,EAACG,cAAc,CAAC;MAC7D,OAAOP,iBAAiB,CAACvB,KAAK;IAChC;IACA,OAAO6B,eAAe,CAAC7B,KAAK;EAC9B;EAEA,MAAMgC,IAAIA,CAAC,CAACxC,EAAE,CAAW,EAAE;IAAEC,MAAM;IAAEC;EAAsB,CAAC,EAAE;IAC5D,MAAMG,QAAQ,GAAG,MAAM,IAAAC,+BAAmB,EAAC,CAAC;IAC5C,IAAI,CAACD,QAAQ,IAAI,CAACJ,MAAM,EAAE,MAAM,KAAIM,8BAAgB,EAAC,CAAC;IAEtD,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,aAAa,CAACJ,QAAQ,EAAEL,EAAE,EAAEC,MAAM,EAAEC,WAAW,CAAC;IACzE,OAAOuC,mBAAQ,CAACD,IAAI,CAACE,KAAK,CAAClC,KAAK,CAAC;EACnC;AACF;AAACmC,OAAA,CAAA/C,QAAA,GAAAA,QAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_os","path","_interopRequireWildcard","_graphlib","_componentId","_toolboxString","_vizgraph","_consumer","_scopeGraph","_exceptions","_getRemoteByName","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","GraphCmd","constructor","componentAspect","report","id","remote","allVersions","layout","image","consumer","loadConsumerIfExist","ConsumerNotFound","graph","generateGraph","config","visualDependencyGraph","VisualDependencyGraph","loadFromGraphlib","join","os","tmpdir","generateRandomStr","result","chalk","green","getBitId","undefined","ComponentID","fromString","getParsedId","bitId","scopeName","scope","remoteScope","getRemoteByName","componentDepGraph","Error","onlyLatest","workspaceGraph","DependencyGraph","buildGraphFromWorkspace","dependencyGraph","componentGraph","getSubGraphOfConnectedComponents","json","GraphLib","write","exports"],"sources":["graph-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\nimport * as path from 'path';\nimport GraphLib from 'graphlib';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component-id';\nimport { generateRandomStr } from '@teambit/toolbox.string.random';\nimport VisualDependencyGraph from '@teambit/legacy/dist/scope/graph/vizgraph';\nimport { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';\nimport { ComponentMain } from '@teambit/component';\n\ntype GraphOpt = {\n image?: string;\n remote?: string;\n allVersions?: boolean;\n layout?: string;\n json?: boolean;\n};\n\nexport class GraphCmd implements Command {\n name = 'graph [id]';\n description = \"generate an image file with the workspace components' dependencies graph\";\n extendedDescription: 'black arrow is a runtime dependency. red arrow is either dev or peer';\n group = 'discover';\n alias = '';\n options = [\n ['i', 'image <image>', 'image path and format. use one of the following extensions: [gif, png, svg, pdf]'],\n ['r', 'remote [remoteName]', 'remote name (name is optional, leave empty when id is specified)'],\n ['', 'all-versions', 'enter all components versions into the graph, not only latest'],\n [\n '',\n 'layout <name>',\n 'GraphVis layout. default to \"dot\". options are [circo, dot, fdp, neato, osage, patchwork, sfdp, twopi]',\n ],\n ['j', 'json', 'json format'],\n ] as CommandOptions;\n remoteOp = true;\n\n constructor(private componentAspect: ComponentMain) {}\n\n async report([id]: [string], { remote, allVersions, layout, image }: GraphOpt): Promise<string> {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n\n const config = {};\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n if (layout) config.layout = layout;\n const visualDependencyGraph = await VisualDependencyGraph.loadFromGraphlib(graph, config);\n\n image = image || path.join(os.tmpdir(), `${generateRandomStr()}.png`);\n const result = await visualDependencyGraph.image(image);\n\n return chalk.green(`image created at ${result}`);\n }\n\n private async generateGraph(\n consumer?: Consumer,\n id?: string,\n remote?: string,\n allVersions?: boolean\n ): Promise<GraphLib.Graph> {\n if (!consumer && !remote) throw new ConsumerNotFound();\n const getBitId = (): ComponentID | undefined => {\n if (!id) return undefined;\n if (remote) return ComponentID.fromString(id); // user used --remote so we know it has a scope\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return consumer.getParsedId(id);\n };\n const bitId = getBitId();\n if (remote) {\n if (id) {\n // @ts-ignore scope must be set as it came from a remote\n const scopeName: string = typeof remote === 'string' ? remote : bitId.scope;\n const remoteScope = await getRemoteByName(scopeName, consumer);\n const componentDepGraph = await remoteScope.graph(bitId);\n return componentDepGraph.graph;\n }\n if (typeof remote !== 'string') {\n throw new Error('please specify remote scope name or enter an id');\n }\n const remoteScope = await getRemoteByName(remote, consumer);\n const componentDepGraph = await remoteScope.graph();\n return componentDepGraph.graph;\n }\n\n const onlyLatest = !allVersions;\n // @ts-ignore consumer must be set here\n const workspaceGraph = await DependencyGraph.buildGraphFromWorkspace(consumer, onlyLatest);\n const dependencyGraph = new DependencyGraph(workspaceGraph);\n if (id) {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const componentGraph = dependencyGraph.getSubGraphOfConnectedComponents(bitId);\n const componentDepGraph = new DependencyGraph(componentGraph);\n return componentDepGraph.graph;\n }\n return dependencyGraph.graph;\n }\n\n async json([id]: [string], { remote, allVersions }: GraphOpt) {\n const consumer = await loadConsumerIfExist();\n if (!consumer && !remote) throw new ConsumerNotFound();\n\n const graph = await this.generateGraph(consumer, id, remote, allVersions);\n return GraphLib.json.write(graph);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAA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AAG,KAAII,qBAAe,EAACG,cAAc,CAAC;MAC7D,OAAOP,iBAAiB,CAACvB,KAAK;IAChC;IACA,OAAO6B,eAAe,CAAC7B,KAAK;EAC9B;EAEA,MAAMgC,IAAIA,CAAC,CAACxC,EAAE,CAAW,EAAE;IAAEC,MAAM;IAAEC;EAAsB,CAAC,EAAE;IAC5D,MAAMG,QAAQ,GAAG,MAAM,IAAAC,+BAAmB,EAAC,CAAC;IAC5C,IAAI,CAACD,QAAQ,IAAI,CAACJ,MAAM,EAAE,MAAM,KAAIM,8BAAgB,EAAC,CAAC;IAEtD,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,aAAa,CAACJ,QAAQ,EAAEL,EAAE,EAAEC,MAAM,EAAEC,WAAW,CAAC;IACzE,OAAOuC,mBAAQ,CAACD,IAAI,CAACE,KAAK,CAAClC,KAAK,CAAC;EACnC;AACF;AAACmC,OAAA,CAAA/C,QAAA,GAAAA,QAAA","ignoreList":[]}
|
@@ -25,8 +25,8 @@ function _dependenciesCompare() {
|
|
25
25
|
};
|
26
26
|
return data;
|
27
27
|
}
|
28
|
-
function _interopRequireDefault(
|
29
|
-
function _defineProperty(
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
30
30
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
31
31
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
32
32
|
class GraphCompareSection {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUiComponentCompareModels","_dependenciesCompare","
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUiComponentCompareModels","_dependenciesCompare","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphCompareSection","constructor","href","children","navigationLink","path","element","createElement","DependenciesCompare","ChangeType","DEPENDENCY","exports"],"sources":["graph.compare.section.tsx"],"sourcesContent":["import React from 'react';\nimport { Section } from '@teambit/component';\nimport { ChangeType } from '@teambit/component.ui.component-compare.models.component-compare-change-type';\nimport type { TabItem } from '@teambit/component.ui.component-compare.models.component-compare-props';\nimport { DependenciesCompare } from './ui/dependencies-compare';\n\nexport class GraphCompareSection implements Section, TabItem {\n navigationLink = {\n href: 'dependencies',\n children: 'Dependencies',\n };\n\n props = this.navigationLink;\n\n route = {\n path: 'dependencies/*',\n element: <DependenciesCompare />,\n };\n\n order = 25;\n changeType = ChangeType.DEPENDENCY;\n id = 'dependencies';\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,mCAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,kCAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,qBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,oBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgE,SAAAC,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAA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interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
15
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
16
16
|
style: {
|
17
17
|
height: '100%',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","e","__esModule","default","Logo","createElement","style","height","display","justifyContent","width","src","exports"],"sources":["graph.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/graph.svg\" />\n </div>\n);\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,MAAMG,IAAI,GAAGA,CAAA,kBAClBP,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxEZ,MAAA,GAAAM,OAAA,CAAAE,aAAA;EAAKC,KAAK,EAAE;IAAEI,KAAK,EAAE;EAAG,CAAE;EAACC,GAAG,EAAC;AAAmD,CAAE,CACjF,CACN;AAACC,OAAA,CAAAR,IAAA,GAAAA,IAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_graphqlTag","data","require","_edgeType","textCmp","Intl","Collator","compare","graphSchema","graphBuilder","componentAspect","typeDefs","gql","resolvers","ComponentGraph","nodes","graph","map","node","id","component","attr","sort","a","b","edges","edge","sourceId","targetId","dependencyLifecycleType","getDependencyLifecycleType","type","Query","_parent","ids","filter","componentsHost","getHost","resolvedIds","resolveMultipleComponentIds","list","x","getGraph","undefined","runtimeGraph","runtimeOnly","toString","edgeRawData","EdgeType","dev","runtime","peer"],"sources":["graph.graphql.ts"],"sourcesContent":["import { ComponentMain } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\n\nimport { GraphBuilder } from './graph-builder';\nimport { ComponentGraph } from './component-graph';\nimport { GraphFilter } from './model/graph-filters';\nimport { DependencyType } from './model/dependency';\nimport { EdgeType } from './edge-type';\n\nconst textCmp = new Intl.Collator().compare;\n\nexport function graphSchema(graphBuilder: GraphBuilder, componentAspect: ComponentMain): Schema {\n return {\n typeDefs: gql`\n type ComponentGraph {\n nodes: [ComponentGraphNode]\n edges: [ComponentGraphEdge]\n }\n\n type ComponentGraphNode {\n id: String\n component: Component\n }\n\n enum DependencyLifecycleType {\n PEER\n RUNTIME\n DEV\n }\n\n type ComponentGraphEdge {\n sourceId: String\n targetId: String\n dependencyLifecycleType: DependencyLifecycleType\n }\n\n extend type Query {\n graph(ids: [String], filter: String): ComponentGraph\n }\n `,\n resolvers: {\n ComponentGraph: {\n nodes: (graph: ComponentGraph) => {\n return graph.nodes\n .map((node) => {\n return {\n id: node.id,\n component: node.attr,\n };\n })\n .sort((a, b) => textCmp(a.id, b.id));\n },\n edges: (graph: ComponentGraph) => {\n return graph.edges\n .map(\n (edge) =>\n ({\n sourceId: edge.sourceId,\n targetId: edge.targetId,\n dependencyLifecycleType: getDependencyLifecycleType(edge.attr.type),\n } as { sourceId: string; targetId: string; dependencyLifecycleType: EdgeType })\n )\n .sort((a, b) => textCmp(a.sourceId, b.sourceId))\n .sort((a, b) => textCmp(a.targetId, b.targetId));\n },\n },\n Query: {\n graph: async (_parent, { ids, filter }: { ids?: string[]; filter?: GraphFilter }) => {\n const componentsHost = componentAspect.getHost();\n const resolvedIds = ids\n ? await componentsHost.resolveMultipleComponentIds(ids)\n : (await componentsHost.list()).map((x) => x.id);\n\n const graph = await graphBuilder.getGraph(resolvedIds);\n if (!graph) return undefined;\n\n if (filter === 'runtimeOnly') {\n const runtimeGraph = graph.runtimeOnly(resolvedIds.map((x) => x.toString()));\n return runtimeGraph;\n }\n\n return graph;\n },\n },\n },\n };\n}\n\nfunction getDependencyLifecycleType(edgeRawData: DependencyType): EdgeType {\n if (edgeRawData === 'dev') return EdgeType.dev;\n if (edgeRawData === 'runtime') return EdgeType.runtime;\n return EdgeType.peer;\n}\n"],"mappings":";;;;;;AAEA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMG,OAAO,GAAG,IAAIC,IAAI,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO;AAEpC,SAASC,WAAWA,CAACC,YAA0B,EAAEC,eAA8B,EAAU;EAC9F,OAAO;IACLC,QAAQ,EAAE,IAAAC,iBAAG
|
1
|
+
{"version":3,"names":["_graphqlTag","data","require","_edgeType","textCmp","Intl","Collator","compare","graphSchema","graphBuilder","componentAspect","typeDefs","gql","resolvers","ComponentGraph","nodes","graph","map","node","id","component","attr","sort","a","b","edges","edge","sourceId","targetId","dependencyLifecycleType","getDependencyLifecycleType","type","Query","_parent","ids","filter","componentsHost","getHost","resolvedIds","resolveMultipleComponentIds","list","x","getGraph","undefined","runtimeGraph","runtimeOnly","toString","edgeRawData","EdgeType","dev","runtime","peer"],"sources":["graph.graphql.ts"],"sourcesContent":["import { ComponentMain } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport { gql } from 'graphql-tag';\n\nimport { GraphBuilder } from './graph-builder';\nimport { ComponentGraph } from './component-graph';\nimport { GraphFilter } from './model/graph-filters';\nimport { DependencyType } from './model/dependency';\nimport { EdgeType } from './edge-type';\n\nconst textCmp = new Intl.Collator().compare;\n\nexport function graphSchema(graphBuilder: GraphBuilder, componentAspect: ComponentMain): Schema {\n return {\n typeDefs: gql`\n type ComponentGraph {\n nodes: [ComponentGraphNode]\n edges: [ComponentGraphEdge]\n }\n\n type ComponentGraphNode {\n id: String\n component: Component\n }\n\n enum DependencyLifecycleType {\n PEER\n RUNTIME\n DEV\n }\n\n type ComponentGraphEdge {\n sourceId: String\n targetId: String\n dependencyLifecycleType: DependencyLifecycleType\n }\n\n extend type Query {\n graph(ids: [String], filter: String): ComponentGraph\n }\n `,\n resolvers: {\n ComponentGraph: {\n nodes: (graph: ComponentGraph) => {\n return graph.nodes\n .map((node) => {\n return {\n id: node.id,\n component: node.attr,\n };\n })\n .sort((a, b) => textCmp(a.id, b.id));\n },\n edges: (graph: ComponentGraph) => {\n return graph.edges\n .map(\n (edge) =>\n ({\n sourceId: edge.sourceId,\n targetId: edge.targetId,\n dependencyLifecycleType: getDependencyLifecycleType(edge.attr.type),\n } as { sourceId: string; targetId: string; dependencyLifecycleType: EdgeType })\n )\n .sort((a, b) => textCmp(a.sourceId, b.sourceId))\n .sort((a, b) => textCmp(a.targetId, b.targetId));\n },\n },\n Query: {\n graph: async (_parent, { ids, filter }: { ids?: string[]; filter?: GraphFilter }) => {\n const componentsHost = componentAspect.getHost();\n const resolvedIds = ids\n ? await componentsHost.resolveMultipleComponentIds(ids)\n : (await componentsHost.list()).map((x) => x.id);\n\n const graph = await graphBuilder.getGraph(resolvedIds);\n if (!graph) return undefined;\n\n if (filter === 'runtimeOnly') {\n const runtimeGraph = graph.runtimeOnly(resolvedIds.map((x) => x.toString()));\n return runtimeGraph;\n }\n\n return graph;\n },\n },\n },\n };\n}\n\nfunction getDependencyLifecycleType(edgeRawData: DependencyType): EdgeType {\n if (edgeRawData === 'dev') return EdgeType.dev;\n if (edgeRawData === 'runt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ignoreList":[]}
|
@@ -60,7 +60,7 @@ function _graphCmd() {
|
|
60
60
|
};
|
61
61
|
return data;
|
62
62
|
}
|
63
|
-
function _defineProperty(
|
63
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
64
64
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
65
65
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
66
66
|
class GraphMain {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_component","_graphql","_logger","_graphBuilder","_graph","_graph2","_graphCmd","_defineProperty","
|
1
|
+
{"version":3,"names":["_cli","data","require","_component","_graphql","_logger","_graphBuilder","_graph","_graph2","_graphCmd","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphMain","constructor","componentAspect","logger","getGraph","ids","opts","graphBuilder","GraphBuilder","getGraphIds","provider","graphql","cli","loggerMain","createLogger","GraphAspect","id","register","graphSchema","graphMain","GraphCmd","exports","GraphqlAspect","ComponentAspect","CLIAspect","LoggerAspect","MainRuntime","addRuntime"],"sources":["graph.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { ComponentMain, ComponentAspect, ComponentID } from '@teambit/component';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { GetGraphOpts, GraphBuilder } from './graph-builder';\nimport { graphSchema } from './graph.graphql';\nimport { GraphAspect } from './graph.aspect';\nimport { GraphCmd } from './graph-cmd';\nimport { ComponentGraph } from './component-graph';\nimport { ComponentIdGraph } from './component-id-graph';\n\nexport class GraphMain {\n constructor(private componentAspect: ComponentMain, private logger: Logger) {}\n\n /**\n * important - prefer using `getGraphIds()` it's way better in terms of performance.\n */\n async getGraph(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentGraph> {\n const graphBuilder = new GraphBuilder(this.componentAspect);\n return graphBuilder.getGraph(ids, opts);\n }\n\n async getGraphIds(ids?: ComponentID[], opts: GetGraphOpts = {}): Promise<ComponentIdGraph> {\n const graphBuilder = new GraphBuilder(this.componentAspect);\n return graphBuilder.getGraphIds(ids, opts);\n }\n\n static slots = [];\n static dependencies = [GraphqlAspect, ComponentAspect, CLIAspect, LoggerAspect];\n static runtime = MainRuntime;\n static async provider([graphql, componentAspect, cli, loggerMain]: [\n GraphqlMain,\n ComponentMain,\n CLIMain,\n LoggerMain\n ]) {\n const logger = loggerMain.createLogger(GraphAspect.id);\n\n const graphBuilder = new GraphBuilder(componentAspect);\n graphql.register(graphSchema(graphBuilder, componentAspect));\n\n const graphMain = new GraphMain(componentAspect, logger);\n cli.register(new GraphCmd(componentAspect));\n\n return graphMain;\n }\n}\n\nGraphAspect.addRuntime(GraphMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OA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hBNmB,SAAS,kBAiBE,CAACsB,wBAAa,EAAEC,4BAAe,EAAEC,gBAAS,EAAEC,sBAAY,CAAC;AAAA5C,eAAA,CAjBpEmB,SAAS,aAkBH0B,kBAAW;AAmB9BX,qBAAW,CAACY,UAAU,CAAC3B,SAAS,CAAC","ignoreList":[]}
|
package/dist/graph.ui.runtime.js
CHANGED
@@ -60,7 +60,7 @@ function _dependenciesGraph() {
|
|
60
60
|
};
|
61
61
|
return data;
|
62
62
|
}
|
63
|
-
function _defineProperty(
|
63
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
64
64
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
65
65
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
66
66
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ui","data","require","_harmony","_componentCompare","_component","_graph","_graph2","_graphCompare","_dependenciesGraph","_defineProperty","
|
1
|
+
{"version":3,"names":["_ui","data","require","_harmony","_componentCompare","_component","_graph","_graph2","_graphCompare","_dependenciesGraph","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphUI","getDependenciesGraph","DependenciesGraph","registerComponentWidget","componentWidgetSlot","register","constructor","provider","componentUI","componentCompare","config","graphUI","section","GraphSection","graphSection","GraphCompareSection","componentTab","registerNavigation","navigationLink","order","registerRoute","route","registerRoutes","exports","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(graphSection);\n componentCompare.registerRoutes([graphSection.route]);\n return graphUI;\n }\n}\n\nGraphAspect.addRuntime(GraphUI);\n"],"mappings":";;;;;;AACA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,O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AC,CAACR,YAAY,CAACO,KAAK,CAAC,CAAC;IACrD,OAAOV,OAAO;EAChB;AACF;AAACY,OAAA,CAAAvB,OAAA,GAAAA,OAAA;AAAAnB,eAAA,CAnCYmB,OAAO,kBAcI,CAACwB,4BAAe,EAAEC,0CAAsB,CAAC;AAAA5C,eAAA,CAdpDmB,OAAO,aAeD0B,eAAS;AAAA7C,eAAA,CAffmB,OAAO,WAgBH,CAAC2B,eAAI,CAACC,QAAQ,CAAkB,CAAC,CAAC;AAAA/C,eAAA,CAhBtCmB,OAAO,mBAiBK;EACrBgB,YAAY,EAAE;AAChB,CAAC;AAkBHa,oBAAW,CAACC,UAAU,CAAC9B,OAAO,CAAC","ignoreList":[]}
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Dependency = void 0;
|
7
|
-
function _defineProperty(
|
7
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
9
9
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
10
10
|
class Dependency {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.283/dist/graph.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_graph@1.0.283/dist/graph.docs.md';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|