@graphty/graph-io 0.3.43 → 0.3.45
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/chunks/approximations-DJMHdDvv.js +40 -0
- package/dist/chunks/approximations-DJMHdDvv.js.map +1 -0
- package/dist/chunks/block-CPCHkX42.js +2777 -0
- package/dist/chunks/block-CPCHkX42.js.map +1 -0
- package/dist/chunks/{choose-DvpbdRuz.js → choose--jM0yYCo.js} +3 -2
- package/dist/chunks/{choose-DvpbdRuz.js.map → choose--jM0yYCo.js.map} +1 -1
- package/dist/chunks/{constants-fT3E8JYY.js → constants-BKwqelYD.js} +6 -2
- package/dist/chunks/constants-BKwqelYD.js.map +1 -0
- package/dist/chunks/convert-BcQ8_jMo.js +59 -0
- package/dist/chunks/convert-BcQ8_jMo.js.map +1 -0
- package/dist/chunks/emit-DZy6JgdA.js +3456 -0
- package/dist/chunks/emit-DZy6JgdA.js.map +1 -0
- package/dist/chunks/{escape-B62ZGM_a.js → escape-CgzxiYPg.js} +44 -21
- package/dist/chunks/escape-CgzxiYPg.js.map +1 -0
- package/dist/chunks/{export-rKLeGQMo.js → export-BvqAXCKh.js} +196 -792
- package/dist/chunks/export-BvqAXCKh.js.map +1 -0
- package/dist/chunks/{exporter-yLxKBvLE.js → exporter--Mk9gXCJ.js} +4 -3
- package/dist/chunks/{exporter-yLxKBvLE.js.map → exporter--Mk9gXCJ.js.map} +1 -1
- package/dist/chunks/{exporter-RVtXVetw.js → exporter-C-9cgZKa.js} +1805 -287
- package/dist/chunks/exporter-C-9cgZKa.js.map +1 -0
- package/dist/chunks/{exporter-8hLNemFk.js → exporter-DFqJhBnj.js} +133 -74
- package/dist/chunks/exporter-DFqJhBnj.js.map +1 -0
- package/dist/chunks/{exporter-BWwEuOPT.js → exporter-DteVeJki.js} +22 -12
- package/dist/chunks/exporter-DteVeJki.js.map +1 -0
- package/dist/chunks/format-BpQBx8MZ.js +676 -0
- package/dist/chunks/format-BpQBx8MZ.js.map +1 -0
- package/dist/chunks/generic-BGO71QBv.js +1347 -0
- package/dist/chunks/generic-BGO71QBv.js.map +1 -0
- package/dist/chunks/{importer-C98dpSH4.js → importer-B-9Rc1zO.js} +141 -82
- package/dist/chunks/importer-B-9Rc1zO.js.map +1 -0
- package/dist/chunks/{importer-D794XUTe.js → importer-BVVR740x.js} +31 -8
- package/dist/chunks/importer-BVVR740x.js.map +1 -0
- package/dist/chunks/{importer-WrGRZb0N.js → importer-C0AjA3Ax.js} +449 -102
- package/dist/chunks/importer-C0AjA3Ax.js.map +1 -0
- package/dist/chunks/{importer-BbNb7eNg.js → importer-C7pvJe1L.js} +1398 -129
- package/dist/chunks/importer-C7pvJe1L.js.map +1 -0
- package/dist/chunks/{importer-xZ-3suY1.js → importer-ClwoVx3O.js} +791 -135
- package/dist/chunks/importer-ClwoVx3O.js.map +1 -0
- package/dist/chunks/{importer-Ht7LNg8L.js → importer-D0sC_6bO.js} +116 -296
- package/dist/chunks/importer-D0sC_6bO.js.map +1 -0
- package/dist/chunks/{importer-Dz7tI8Sa.js → importer-EHQk1jbM.js} +617 -115
- package/dist/chunks/importer-EHQk1jbM.js.map +1 -0
- package/dist/chunks/{json-elements-DKSqpNW1.js → json-elements-DJZRZ6jd.js} +123 -32
- package/dist/chunks/json-elements-DJZRZ6jd.js.map +1 -0
- package/dist/chunks/lexicon-WMsNddyU.js +509 -0
- package/dist/chunks/lexicon-WMsNddyU.js.map +1 -0
- package/dist/chunks/{ontology-export-CtRXjg_i.js → ontology-export-G4MqRdux.js} +3 -2
- package/dist/chunks/{ontology-export-CtRXjg_i.js.map → ontology-export-G4MqRdux.js.map} +1 -1
- package/dist/chunks/{records-Cu4bxYOm.js → records-CiaWZrFH.js} +2 -2
- package/dist/chunks/{records-Cu4bxYOm.js.map → records-CiaWZrFH.js.map} +1 -1
- package/dist/chunks/styles-DvoFBKCK.js +690 -0
- package/dist/chunks/styles-DvoFBKCK.js.map +1 -0
- package/dist/chunks/styles-yed-Cz9rLBCP.js +842 -0
- package/dist/chunks/styles-yed-Cz9rLBCP.js.map +1 -0
- package/dist/chunks/styles-zNTmz5R7.js +2102 -0
- package/dist/chunks/styles-zNTmz5R7.js.map +1 -0
- package/dist/chunks/{text-DHOJXnED.js → text-CzJNFOS9.js} +2 -2
- package/dist/chunks/{text-DHOJXnED.js.map → text-CzJNFOS9.js.map} +1 -1
- package/dist/chunks/units-XMZFIFe1.js +19 -0
- package/dist/chunks/units-XMZFIFe1.js.map +1 -0
- package/dist/chunks/writer-gQ8kx99H.js +448 -0
- package/dist/chunks/writer-gQ8kx99H.js.map +1 -0
- package/dist/csv.js +5 -4
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +5 -2
- package/dist/dot.js.map +1 -1
- package/dist/gexf.js +292 -412
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +927 -74
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +351 -236
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +4 -2
- package/dist/graphml.js.map +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +4 -3
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +1 -1
- package/dist/pajek.js +4 -2
- package/dist/positions.d.ts +1 -0
- package/dist/positions.js +427 -0
- package/dist/positions.js.map +1 -0
- package/dist/src/common/codes.d.ts +6 -0
- package/dist/src/common/codes.d.ts.map +1 -1
- package/dist/src/common/codes.js +6 -0
- package/dist/src/common/codes.js.map +1 -1
- package/dist/src/common/escape.d.ts.map +1 -1
- package/dist/src/common/escape.js +4 -2
- package/dist/src/common/escape.js.map +1 -1
- package/dist/src/common/export.d.ts +10 -0
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +123 -100
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +8 -1
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts +12 -9
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +160 -37
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/notes.d.ts +42 -0
- package/dist/src/common/notes.d.ts.map +1 -0
- package/dist/src/common/notes.js +72 -0
- package/dist/src/common/notes.js.map +1 -0
- package/dist/src/common/report.d.ts +18 -0
- package/dist/src/common/report.d.ts.map +1 -1
- package/dist/src/common/report.js +36 -1
- package/dist/src/common/report.js.map +1 -1
- package/dist/src/common/units.d.ts +24 -0
- package/dist/src/common/units.d.ts.map +1 -0
- package/dist/src/common/units.js +26 -0
- package/dist/src/common/units.js.map +1 -0
- package/dist/src/common/xml.d.ts +18 -0
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +42 -5
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/formats/cx/exporter.d.ts +6 -0
- package/dist/src/formats/cx/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx/exporter.js +71 -8
- package/dist/src/formats/cx/exporter.js.map +1 -1
- package/dist/src/formats/cx/importer.d.ts +5 -2
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +102 -72
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx/styles.d.ts +102 -0
- package/dist/src/formats/cx/styles.d.ts.map +1 -0
- package/dist/src/formats/cx/styles.js +225 -0
- package/dist/src/formats/cx/styles.js.map +1 -0
- package/dist/src/formats/cx2/exporter.d.ts +5 -0
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +181 -71
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts +4 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +19 -1
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cx2/styles.d.ts +18 -0
- package/dist/src/formats/cx2/styles.d.ts.map +1 -0
- package/dist/src/formats/cx2/styles.js +24 -0
- package/dist/src/formats/cx2/styles.js.map +1 -0
- package/dist/src/formats/cys/constants.d.ts +2 -0
- package/dist/src/formats/cys/constants.d.ts.map +1 -1
- package/dist/src/formats/cys/constants.js +2 -0
- package/dist/src/formats/cys/constants.js.map +1 -1
- package/dist/src/formats/cys/exporter.d.ts +6 -2
- package/dist/src/formats/cys/exporter.d.ts.map +1 -1
- package/dist/src/formats/cys/exporter.js +215 -53
- package/dist/src/formats/cys/exporter.js.map +1 -1
- package/dist/src/formats/cys/importer.d.ts +2 -1
- package/dist/src/formats/cys/importer.d.ts.map +1 -1
- package/dist/src/formats/cys/importer.js +119 -6
- package/dist/src/formats/cys/importer.js.map +1 -1
- package/dist/src/formats/cys/session.d.ts +2 -0
- package/dist/src/formats/cys/session.d.ts.map +1 -1
- package/dist/src/formats/cys/session.js +5 -0
- package/dist/src/formats/cys/session.js.map +1 -1
- package/dist/src/formats/cys/styles.d.ts +38 -0
- package/dist/src/formats/cys/styles.d.ts.map +1 -0
- package/dist/src/formats/cys/styles.js +213 -0
- package/dist/src/formats/cys/styles.js.map +1 -0
- package/dist/src/formats/cys/tables.d.ts +8 -3
- package/dist/src/formats/cys/tables.d.ts.map +1 -1
- package/dist/src/formats/cys/tables.js +88 -34
- package/dist/src/formats/cys/tables.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts +2 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +195 -81
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +100 -20
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +1 -0
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +1 -0
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/positions.d.ts +14 -0
- package/dist/src/formats/dot/positions.d.ts.map +1 -0
- package/dist/src/formats/dot/positions.js +70 -0
- package/dist/src/formats/dot/positions.js.map +1 -0
- package/dist/src/formats/dot/styles.d.ts +82 -0
- package/dist/src/formats/dot/styles.d.ts.map +1 -0
- package/dist/src/formats/dot/styles.js +1496 -0
- package/dist/src/formats/dot/styles.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +20 -5
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +8 -1
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +251 -131
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +8 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -1
- package/dist/src/formats/gexf/index.js +10 -2
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gexf/schema.d.ts +5 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +5 -0
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gexf/styles.d.ts +74 -0
- package/dist/src/formats/gexf/styles.d.ts.map +1 -0
- package/dist/src/formats/gexf/styles.js +604 -0
- package/dist/src/formats/gexf/styles.js.map +1 -0
- package/dist/src/formats/gml/exporter.d.ts +1 -5
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +19 -8
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +4 -0
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +2 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +2 -1
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/positions.d.ts +14 -0
- package/dist/src/formats/gml/positions.d.ts.map +1 -0
- package/dist/src/formats/gml/positions.js +46 -0
- package/dist/src/formats/gml/positions.js.map +1 -0
- package/dist/src/formats/gml/styles.d.ts +59 -0
- package/dist/src/formats/gml/styles.d.ts.map +1 -0
- package/dist/src/formats/gml/styles.js +1056 -0
- package/dist/src/formats/gml/styles.js.map +1 -0
- package/dist/src/formats/gml/syntax.d.ts +11 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -1
- package/dist/src/formats/gml/syntax.js +151 -62
- package/dist/src/formats/gml/syntax.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +4 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +5 -1
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +133 -65
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts +4 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +100 -44
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/graphml/index.d.ts +1 -0
- package/dist/src/formats/graphml/index.d.ts.map +1 -1
- package/dist/src/formats/graphml/index.js +1 -0
- package/dist/src/formats/graphml/index.js.map +1 -1
- package/dist/src/formats/graphml/styles-plain.d.ts +19 -0
- package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-plain.js +187 -0
- package/dist/src/formats/graphml/styles-plain.js.map +1 -0
- package/dist/src/formats/graphml/styles-yed.d.ts +179 -0
- package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-yed.js +1086 -0
- package/dist/src/formats/graphml/styles-yed.js.map +1 -0
- package/dist/src/formats/graphml/styles-yfiles3.d.ts +19 -0
- package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-yfiles3.js +508 -0
- package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -0
- package/dist/src/formats/graphml/tree.d.ts.map +1 -1
- package/dist/src/formats/graphml/tree.js +34 -19
- package/dist/src/formats/graphml/tree.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +16 -2
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +83 -12
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts +5 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +68 -25
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +22 -3
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +439 -264
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/positions.d.ts +16 -0
- package/dist/src/formats/json/positions.d.ts.map +1 -0
- package/dist/src/formats/json/positions.js +44 -0
- package/dist/src/formats/json/positions.js.map +1 -0
- package/dist/src/formats/json/styles.d.ts +102 -0
- package/dist/src/formats/json/styles.d.ts.map +1 -0
- package/dist/src/formats/json/styles.js +1753 -0
- package/dist/src/formats/json/styles.js.map +1 -0
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
- package/dist/src/formats/neo4j/exporter.js +2 -1
- package/dist/src/formats/neo4j/exporter.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts +2 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +142 -76
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +4 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +60 -6
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/index.d.ts +2 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -1
- package/dist/src/formats/pajek/index.js +2 -0
- package/dist/src/formats/pajek/index.js.map +1 -1
- package/dist/src/formats/pajek/styles.d.ts +50 -0
- package/dist/src/formats/pajek/styles.d.ts.map +1 -0
- package/dist/src/formats/pajek/styles.js +569 -0
- package/dist/src/formats/pajek/styles.js.map +1 -0
- package/dist/src/formats/pajek/syntax.d.ts +6 -0
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +6 -0
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/columns.d.ts.map +1 -1
- package/dist/src/formats/xgmml/columns.js +34 -9
- package/dist/src/formats/xgmml/columns.js.map +1 -1
- package/dist/src/formats/xgmml/constants.d.ts +2 -0
- package/dist/src/formats/xgmml/constants.d.ts.map +1 -1
- package/dist/src/formats/xgmml/constants.js +3 -1
- package/dist/src/formats/xgmml/constants.js.map +1 -1
- package/dist/src/formats/xgmml/document.d.ts +12 -8
- package/dist/src/formats/xgmml/document.d.ts.map +1 -1
- package/dist/src/formats/xgmml/document.js +56 -13
- package/dist/src/formats/xgmml/document.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +12 -6
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts +3 -1
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +22 -9
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/importer.d.ts +2 -1
- package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
- package/dist/src/formats/xgmml/importer.js +31 -24
- package/dist/src/formats/xgmml/importer.js.map +1 -1
- package/dist/src/formats/xgmml/styles.d.ts +104 -0
- package/dist/src/formats/xgmml/styles.d.ts.map +1 -0
- package/dist/src/formats/xgmml/styles.js +310 -0
- package/dist/src/formats/xgmml/styles.js.map +1 -0
- package/dist/src/index.d.ts +9 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/positions/codes.d.ts +31 -0
- package/dist/src/positions/codes.d.ts.map +1 -0
- package/dist/src/positions/codes.js +26 -0
- package/dist/src/positions/codes.js.map +1 -0
- package/dist/src/positions/convert.d.ts +58 -0
- package/dist/src/positions/convert.d.ts.map +1 -0
- package/dist/src/positions/convert.js +107 -0
- package/dist/src/positions/convert.js.map +1 -0
- package/dist/src/positions/extract.d.ts +27 -0
- package/dist/src/positions/extract.d.ts.map +1 -0
- package/dist/src/positions/extract.js +526 -0
- package/dist/src/positions/extract.js.map +1 -0
- package/dist/src/positions/index.d.ts +10 -0
- package/dist/src/positions/index.d.ts.map +1 -0
- package/dist/src/positions/index.js +9 -0
- package/dist/src/positions/index.js.map +1 -0
- package/dist/src/positions/types.d.ts +208 -0
- package/dist/src/positions/types.d.ts.map +1 -0
- package/dist/src/positions/types.js +10 -0
- package/dist/src/positions/types.js.map +1 -0
- package/dist/src/registry.d.ts +30 -0
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +130 -9
- package/dist/src/registry.js.map +1 -1
- package/dist/src/styles/annotations.d.ts +132 -0
- package/dist/src/styles/annotations.d.ts.map +1 -0
- package/dist/src/styles/annotations.js +320 -0
- package/dist/src/styles/annotations.js.map +1 -0
- package/dist/src/styles/budget.d.ts +45 -0
- package/dist/src/styles/budget.d.ts.map +1 -0
- package/dist/src/styles/budget.js +58 -0
- package/dist/src/styles/budget.js.map +1 -0
- package/dist/src/styles/canon/bends.d.ts +32 -0
- package/dist/src/styles/canon/bends.d.ts.map +1 -0
- package/dist/src/styles/canon/bends.js +74 -0
- package/dist/src/styles/canon/bends.js.map +1 -0
- package/dist/src/styles/canon/color-tables.d.ts +22 -0
- package/dist/src/styles/canon/color-tables.d.ts.map +1 -0
- package/dist/src/styles/canon/color-tables.js +369 -0
- package/dist/src/styles/canon/color-tables.js.map +1 -0
- package/dist/src/styles/canon/color.d.ts +66 -0
- package/dist/src/styles/canon/color.d.ts.map +1 -0
- package/dist/src/styles/canon/color.js +548 -0
- package/dist/src/styles/canon/color.js.map +1 -0
- package/dist/src/styles/canon/enums.d.ts +25 -0
- package/dist/src/styles/canon/enums.d.ts.map +1 -0
- package/dist/src/styles/canon/enums.js +187 -0
- package/dist/src/styles/canon/enums.js.map +1 -0
- package/dist/src/styles/canon/graphviz.d.ts +48 -0
- package/dist/src/styles/canon/graphviz.d.ts.map +1 -0
- package/dist/src/styles/canon/graphviz.js +160 -0
- package/dist/src/styles/canon/graphviz.js.map +1 -0
- package/dist/src/styles/canon/index.d.ts +13 -0
- package/dist/src/styles/canon/index.d.ts.map +1 -0
- package/dist/src/styles/canon/index.js +13 -0
- package/dist/src/styles/canon/index.js.map +1 -0
- package/dist/src/styles/canon/number.d.ts +59 -0
- package/dist/src/styles/canon/number.d.ts.map +1 -0
- package/dist/src/styles/canon/number.js +142 -0
- package/dist/src/styles/canon/number.js.map +1 -0
- package/dist/src/styles/canon/site.d.ts +51 -0
- package/dist/src/styles/canon/site.d.ts.map +1 -0
- package/dist/src/styles/canon/site.js +63 -0
- package/dist/src/styles/canon/site.js.map +1 -0
- package/dist/src/styles/canon/text.d.ts +61 -0
- package/dist/src/styles/canon/text.d.ts.map +1 -0
- package/dist/src/styles/canon/text.js +199 -0
- package/dist/src/styles/canon/text.js.map +1 -0
- package/dist/src/styles/codes.d.ts +95 -0
- package/dist/src/styles/codes.d.ts.map +1 -0
- package/dist/src/styles/codes.js +97 -0
- package/dist/src/styles/codes.js.map +1 -0
- package/dist/src/styles/cyjs/cascade.d.ts +134 -0
- package/dist/src/styles/cyjs/cascade.d.ts.map +1 -0
- package/dist/src/styles/cyjs/cascade.js +2252 -0
- package/dist/src/styles/cyjs/cascade.js.map +1 -0
- package/dist/src/styles/cyjs/defaults-table.d.ts +25 -0
- package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -0
- package/dist/src/styles/cyjs/defaults-table.js +76 -0
- package/dist/src/styles/cyjs/defaults-table.js.map +1 -0
- package/dist/src/styles/cyjs/emit.d.ts +82 -0
- package/dist/src/styles/cyjs/emit.d.ts.map +1 -0
- package/dist/src/styles/cyjs/emit.js +791 -0
- package/dist/src/styles/cyjs/emit.js.map +1 -0
- package/dist/src/styles/cyjs/index.d.ts +13 -0
- package/dist/src/styles/cyjs/index.d.ts.map +1 -0
- package/dist/src/styles/cyjs/index.js +13 -0
- package/dist/src/styles/cyjs/index.js.map +1 -0
- package/dist/src/styles/cyjs/live.d.ts +46 -0
- package/dist/src/styles/cyjs/live.d.ts.map +1 -0
- package/dist/src/styles/cyjs/live.js +108 -0
- package/dist/src/styles/cyjs/live.js.map +1 -0
- package/dist/src/styles/cyjs/mappers.d.ts +147 -0
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -0
- package/dist/src/styles/cyjs/mappers.js +744 -0
- package/dist/src/styles/cyjs/mappers.js.map +1 -0
- package/dist/src/styles/cyjs/selector.d.ts +113 -0
- package/dist/src/styles/cyjs/selector.d.ts.map +1 -0
- package/dist/src/styles/cyjs/selector.js +611 -0
- package/dist/src/styles/cyjs/selector.js.map +1 -0
- package/dist/src/styles/cyjs/stylesheet-text.d.ts +37 -0
- package/dist/src/styles/cyjs/stylesheet-text.d.ts.map +1 -0
- package/dist/src/styles/cyjs/stylesheet-text.js +181 -0
- package/dist/src/styles/cyjs/stylesheet-text.js.map +1 -0
- package/dist/src/styles/cytoscape/emit.d.ts +125 -0
- package/dist/src/styles/cytoscape/emit.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/emit.js +1025 -0
- package/dist/src/styles/cytoscape/emit.js.map +1 -0
- package/dist/src/styles/cytoscape/index.d.ts +10 -0
- package/dist/src/styles/cytoscape/index.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/index.js +10 -0
- package/dist/src/styles/cytoscape/index.js.map +1 -0
- package/dist/src/styles/cytoscape/lexicon.d.ts +49 -0
- package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/lexicon.js +605 -0
- package/dist/src/styles/cytoscape/lexicon.js.map +1 -0
- package/dist/src/styles/cytoscape/mappings.d.ts +171 -0
- package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/mappings.js +460 -0
- package/dist/src/styles/cytoscape/mappings.js.map +1 -0
- package/dist/src/styles/cytoscape/resolve.d.ts +137 -0
- package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/resolve.js +381 -0
- package/dist/src/styles/cytoscape/resolve.js.map +1 -0
- package/dist/src/styles/cytoscape/translate.d.ts +50 -0
- package/dist/src/styles/cytoscape/translate.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/translate.js +156 -0
- package/dist/src/styles/cytoscape/translate.js.map +1 -0
- package/dist/src/styles/defaults.d.ts +90 -0
- package/dist/src/styles/defaults.d.ts.map +1 -0
- package/dist/src/styles/defaults.js +414 -0
- package/dist/src/styles/defaults.js.map +1 -0
- package/dist/src/styles/index.d.ts +15 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/dist/src/styles/index.js +14 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/styles/internal.d.ts +17 -0
- package/dist/src/styles/internal.d.ts.map +1 -0
- package/dist/src/styles/internal.js +16 -0
- package/dist/src/styles/internal.js.map +1 -0
- package/dist/src/styles/io/approximations.d.ts +24 -0
- package/dist/src/styles/io/approximations.d.ts.map +1 -0
- package/dist/src/styles/io/approximations.js +51 -0
- package/dist/src/styles/io/approximations.js.map +1 -0
- package/dist/src/styles/io/block.d.ts +166 -0
- package/dist/src/styles/io/block.d.ts.map +1 -0
- package/dist/src/styles/io/block.js +930 -0
- package/dist/src/styles/io/block.js.map +1 -0
- package/dist/src/styles/io/generic.d.ts +88 -0
- package/dist/src/styles/io/generic.d.ts.map +1 -0
- package/dist/src/styles/io/generic.js +516 -0
- package/dist/src/styles/io/generic.js.map +1 -0
- package/dist/src/styles/io/index.d.ts +8 -0
- package/dist/src/styles/io/index.d.ts.map +1 -0
- package/dist/src/styles/io/index.js +7 -0
- package/dist/src/styles/io/index.js.map +1 -0
- package/dist/src/styles/io/writer.d.ts +89 -0
- package/dist/src/styles/io/writer.d.ts.map +1 -0
- package/dist/src/styles/io/writer.js +626 -0
- package/dist/src/styles/io/writer.js.map +1 -0
- package/dist/src/styles/notes.d.ts +47 -0
- package/dist/src/styles/notes.d.ts.map +1 -0
- package/dist/src/styles/notes.js +140 -0
- package/dist/src/styles/notes.js.map +1 -0
- package/dist/src/styles/plan/classes.d.ts +31 -0
- package/dist/src/styles/plan/classes.d.ts.map +1 -0
- package/dist/src/styles/plan/classes.js +139 -0
- package/dist/src/styles/plan/classes.js.map +1 -0
- package/dist/src/styles/plan/continuous.d.ts +32 -0
- package/dist/src/styles/plan/continuous.d.ts.map +1 -0
- package/dist/src/styles/plan/continuous.js +165 -0
- package/dist/src/styles/plan/continuous.js.map +1 -0
- package/dist/src/styles/plan/discrete.d.ts +39 -0
- package/dist/src/styles/plan/discrete.d.ts.map +1 -0
- package/dist/src/styles/plan/discrete.js +127 -0
- package/dist/src/styles/plan/discrete.js.map +1 -0
- package/dist/src/styles/plan/families.d.ts +31 -0
- package/dist/src/styles/plan/families.d.ts.map +1 -0
- package/dist/src/styles/plan/families.js +95 -0
- package/dist/src/styles/plan/families.js.map +1 -0
- package/dist/src/styles/plan/features.d.ts +58 -0
- package/dist/src/styles/plan/features.d.ts.map +1 -0
- package/dist/src/styles/plan/features.js +185 -0
- package/dist/src/styles/plan/features.js.map +1 -0
- package/dist/src/styles/plan/index.d.ts +7 -0
- package/dist/src/styles/plan/index.d.ts.map +1 -0
- package/dist/src/styles/plan/index.js +7 -0
- package/dist/src/styles/plan/index.js.map +1 -0
- package/dist/src/styles/plan/plan.d.ts +71 -0
- package/dist/src/styles/plan/plan.d.ts.map +1 -0
- package/dist/src/styles/plan/plan.js +893 -0
- package/dist/src/styles/plan/plan.js.map +1 -0
- package/dist/src/styles/plan/resolve.d.ts +137 -0
- package/dist/src/styles/plan/resolve.d.ts.map +1 -0
- package/dist/src/styles/plan/resolve.js +587 -0
- package/dist/src/styles/plan/resolve.js.map +1 -0
- package/dist/src/styles/types.d.ts +702 -0
- package/dist/src/styles/types.d.ts.map +1 -0
- package/dist/src/styles/types.js +10 -0
- package/dist/src/styles/types.js.map +1 -0
- package/dist/src/styles/vocabulary.d.ts +41 -0
- package/dist/src/styles/vocabulary.d.ts.map +1 -0
- package/dist/src/styles/vocabulary.js +140 -0
- package/dist/src/styles/vocabulary.js.map +1 -0
- package/dist/src/types.d.ts +64 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +322 -0
- package/dist/styles.js.map +1 -0
- package/dist/xgmml.js +5 -4
- package/dist/xgmml.js.map +1 -1
- package/package.json +13 -2
- package/src/common/codes.ts +7 -0
- package/src/common/escape.ts +5 -2
- package/src/common/export.ts +179 -140
- package/src/common/input.ts +8 -4
- package/src/common/json-elements.ts +169 -38
- package/src/common/notes.ts +94 -0
- package/src/common/report.ts +41 -1
- package/src/common/units.ts +42 -0
- package/src/common/xml.ts +45 -5
- package/src/formats/cx/exporter.ts +95 -11
- package/src/formats/cx/importer.ts +126 -90
- package/src/formats/cx/styles.ts +304 -0
- package/src/formats/cx2/exporter.ts +234 -77
- package/src/formats/cx2/importer.ts +19 -1
- package/src/formats/cx2/styles.ts +29 -0
- package/src/formats/cys/constants.ts +3 -0
- package/src/formats/cys/exporter.ts +246 -60
- package/src/formats/cys/importer.ts +125 -9
- package/src/formats/cys/session.ts +6 -0
- package/src/formats/cys/styles.ts +254 -0
- package/src/formats/cys/tables.ts +117 -48
- package/src/formats/dot/exporter.ts +262 -126
- package/src/formats/dot/importer.ts +111 -20
- package/src/formats/dot/index.ts +1 -0
- package/src/formats/dot/positions.ts +77 -0
- package/src/formats/dot/styles.ts +1755 -0
- package/src/formats/gexf/exporter.ts +27 -11
- package/src/formats/gexf/importer.ts +308 -158
- package/src/formats/gexf/index.ts +10 -0
- package/src/formats/gexf/schema.ts +5 -0
- package/src/formats/gexf/styles.ts +719 -0
- package/src/formats/gml/exporter.ts +33 -14
- package/src/formats/gml/importer.ts +4 -0
- package/src/formats/gml/index.ts +2 -1
- package/src/formats/gml/positions.ts +52 -0
- package/src/formats/gml/styles.ts +1248 -0
- package/src/formats/gml/syntax.ts +173 -62
- package/src/formats/graphml/constants.ts +5 -0
- package/src/formats/graphml/exporter.ts +163 -71
- package/src/formats/graphml/importer.ts +119 -45
- package/src/formats/graphml/index.ts +1 -0
- package/src/formats/graphml/styles-plain.ts +236 -0
- package/src/formats/graphml/styles-yed.ts +1221 -0
- package/src/formats/graphml/styles-yfiles3.ts +573 -0
- package/src/formats/graphml/tree.ts +36 -20
- package/src/formats/graphml/yfiles.ts +89 -13
- package/src/formats/json/exporter.ts +76 -26
- package/src/formats/json/importer.ts +541 -322
- package/src/formats/json/positions.ts +50 -0
- package/src/formats/json/styles.ts +2082 -0
- package/src/formats/neo4j/exporter.ts +2 -1
- package/src/formats/pajek/exporter.ts +195 -106
- package/src/formats/pajek/importer.ts +78 -9
- package/src/formats/pajek/index.ts +2 -0
- package/src/formats/pajek/styles.ts +685 -0
- package/src/formats/pajek/syntax.ts +7 -0
- package/src/formats/xgmml/columns.ts +39 -9
- package/src/formats/xgmml/constants.ts +3 -0
- package/src/formats/xgmml/document.ts +54 -12
- package/src/formats/xgmml/emit.ts +11 -6
- package/src/formats/xgmml/exporter.ts +32 -13
- package/src/formats/xgmml/importer.ts +43 -29
- package/src/formats/xgmml/styles.ts +400 -0
- package/src/index.ts +16 -0
- package/src/positions/codes.ts +32 -0
- package/src/positions/convert.ts +123 -0
- package/src/positions/extract.ts +619 -0
- package/src/positions/index.ts +23 -0
- package/src/positions/types.ts +221 -0
- package/src/registry.ts +179 -8
- package/src/styles/annotations.ts +478 -0
- package/src/styles/budget.ts +60 -0
- package/src/styles/canon/bends.ts +84 -0
- package/src/styles/canon/color-tables.ts +386 -0
- package/src/styles/canon/color.ts +624 -0
- package/src/styles/canon/enums.ts +211 -0
- package/src/styles/canon/graphviz.ts +189 -0
- package/src/styles/canon/index.ts +13 -0
- package/src/styles/canon/number.ts +152 -0
- package/src/styles/canon/site.ts +87 -0
- package/src/styles/canon/text.ts +221 -0
- package/src/styles/codes.ts +104 -0
- package/src/styles/cyjs/cascade.ts +2670 -0
- package/src/styles/cyjs/defaults-table.ts +82 -0
- package/src/styles/cyjs/emit.ts +952 -0
- package/src/styles/cyjs/index.ts +37 -0
- package/src/styles/cyjs/live.ts +147 -0
- package/src/styles/cyjs/mappers.ts +879 -0
- package/src/styles/cyjs/selector.ts +778 -0
- package/src/styles/cyjs/stylesheet-text.ts +214 -0
- package/src/styles/cytoscape/emit.ts +1264 -0
- package/src/styles/cytoscape/index.ts +40 -0
- package/src/styles/cytoscape/lexicon.ts +658 -0
- package/src/styles/cytoscape/mappings.ts +603 -0
- package/src/styles/cytoscape/resolve.ts +521 -0
- package/src/styles/cytoscape/translate.ts +237 -0
- package/src/styles/defaults.ts +504 -0
- package/src/styles/index.ts +57 -0
- package/src/styles/internal.ts +17 -0
- package/src/styles/io/approximations.ts +47 -0
- package/src/styles/io/block.ts +1138 -0
- package/src/styles/io/generic.ts +687 -0
- package/src/styles/io/index.ts +18 -0
- package/src/styles/io/writer.ts +780 -0
- package/src/styles/notes.ts +165 -0
- package/src/styles/plan/classes.ts +166 -0
- package/src/styles/plan/continuous.ts +218 -0
- package/src/styles/plan/discrete.ts +165 -0
- package/src/styles/plan/families.ts +115 -0
- package/src/styles/plan/features.ts +234 -0
- package/src/styles/plan/index.ts +7 -0
- package/src/styles/plan/plan.ts +1129 -0
- package/src/styles/plan/resolve.ts +685 -0
- package/src/styles/types.ts +814 -0
- package/src/styles/vocabulary.ts +172 -0
- package/src/types.ts +76 -1
- package/dist/chunks/constants-fT3E8JYY.js.map +0 -1
- package/dist/chunks/escape-B62ZGM_a.js.map +0 -1
- package/dist/chunks/export-rKLeGQMo.js.map +0 -1
- package/dist/chunks/exporter-8hLNemFk.js.map +0 -1
- package/dist/chunks/exporter-BWwEuOPT.js.map +0 -1
- package/dist/chunks/exporter-RVtXVetw.js.map +0 -1
- package/dist/chunks/importer-BbNb7eNg.js.map +0 -1
- package/dist/chunks/importer-C98dpSH4.js.map +0 -1
- package/dist/chunks/importer-D794XUTe.js.map +0 -1
- package/dist/chunks/importer-Dz7tI8Sa.js.map +0 -1
- package/dist/chunks/importer-Ht7LNg8L.js.map +0 -1
- package/dist/chunks/importer-WrGRZb0N.js.map +0 -1
- package/dist/chunks/importer-xZ-3suY1.js.map +0 -1
- package/dist/chunks/json-elements-DKSqpNW1.js.map +0 -1
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cytoscape desktop's visual style model: per target the defaults, the one mapping per visual property and the
|
|
3
|
+
* dependencies, read from CX version 1 (`cyVisualProperties`, mapping definitions as `COL=...,K=0=a` strings) and CX2
|
|
4
|
+
* (`visualProperties`, `visualEditorProperties`). Every table keyed by file text is a `Map`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { STYLE_ISSUE } from "../codes.js";
|
|
8
|
+
import type { StyleNotes } from "../notes.js";
|
|
9
|
+
import type { StyleTarget } from "../types.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One Cytoscape mapping, with the file's raw values (they are read per property when resolved or translated). A
|
|
13
|
+
* discrete table's keys are typed by the attribute's type (numbers for `integer`, `long` and `double`, booleans for
|
|
14
|
+
* `boolean`), so a key compares with a value the way Cytoscape compares them.
|
|
15
|
+
* @category Styles
|
|
16
|
+
*/
|
|
17
|
+
export type CytoscapeMapping =
|
|
18
|
+
| {
|
|
19
|
+
/** The column's value is the visual property's value. */
|
|
20
|
+
readonly kind: "passthrough";
|
|
21
|
+
/** The column read. */
|
|
22
|
+
readonly column: string;
|
|
23
|
+
/** The attribute type the file states, or null. */
|
|
24
|
+
readonly type: string | null;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
/** A table from the column's value to a raw visual property value. */
|
|
28
|
+
readonly kind: "discrete";
|
|
29
|
+
/** The column read. */
|
|
30
|
+
readonly column: string;
|
|
31
|
+
/** The attribute type the file states, or null. */
|
|
32
|
+
readonly type: string | null;
|
|
33
|
+
/** `[key, raw value]` in the file's order. */
|
|
34
|
+
readonly table: readonly (readonly [key: string | number | boolean, value: unknown])[];
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
/** Points between which Cytoscape interpolates. */
|
|
38
|
+
readonly kind: "continuous";
|
|
39
|
+
/** The column read. */
|
|
40
|
+
readonly column: string;
|
|
41
|
+
/** The attribute type the file states, or null. */
|
|
42
|
+
readonly type: string | null;
|
|
43
|
+
/** The points, in the file's order, with raw values. */
|
|
44
|
+
readonly points: readonly CytoscapeContinuousPoint[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* One point of a Cytoscape continuous mapping, with raw values: `below` just below `at`, `value` exactly at it,
|
|
49
|
+
* `above` just above it.
|
|
50
|
+
* @category Styles
|
|
51
|
+
*/
|
|
52
|
+
export interface CytoscapeContinuousPoint {
|
|
53
|
+
/** The attribute value. */
|
|
54
|
+
readonly at: number;
|
|
55
|
+
/** The raw value just below `at`. */
|
|
56
|
+
readonly below: unknown;
|
|
57
|
+
/** The raw value exactly at `at`. */
|
|
58
|
+
readonly value: unknown;
|
|
59
|
+
/** The raw value just above `at`. */
|
|
60
|
+
readonly above: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The style of one target: defaults and mappings by visual property name, and the dependencies
|
|
65
|
+
* (`nodeSizeLocked`, `arrowColorMatchesEdge`).
|
|
66
|
+
* @category Styles
|
|
67
|
+
*/
|
|
68
|
+
export interface CytoscapeTargetStyle {
|
|
69
|
+
/** Visual property name to raw default value. */
|
|
70
|
+
readonly defaults: Map<string, unknown>;
|
|
71
|
+
/** Visual property name to its mapping. */
|
|
72
|
+
readonly mappings: Map<string, CytoscapeMapping>;
|
|
73
|
+
/** Dependency name to whether it is on. */
|
|
74
|
+
readonly dependencies: Map<string, boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* Bypass names read as another visual property when the element has none of that one (CX2's `NODE_WIDTH` bypass
|
|
77
|
+
* drives a locked node size).
|
|
78
|
+
*/
|
|
79
|
+
readonly bypassAliases: Map<string, string>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A Cytoscape visual style: the network defaults and the style of nodes and edges.
|
|
84
|
+
* @category Styles
|
|
85
|
+
*/
|
|
86
|
+
export interface CytoscapeStyle {
|
|
87
|
+
/** The network's defaults (`NETWORK_BACKGROUND_PAINT`). */
|
|
88
|
+
readonly network: {
|
|
89
|
+
/** The network's default values by visual property name. */
|
|
90
|
+
readonly defaults: Map<string, unknown>;
|
|
91
|
+
};
|
|
92
|
+
/** Node style. */
|
|
93
|
+
readonly node: CytoscapeTargetStyle;
|
|
94
|
+
/** Edge style. */
|
|
95
|
+
readonly edge: CytoscapeTargetStyle;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* An empty style.
|
|
100
|
+
* @returns a style with no defaults, mappings or dependencies
|
|
101
|
+
* @category Styles
|
|
102
|
+
*/
|
|
103
|
+
export function emptyCytoscapeStyle(): CytoscapeStyle {
|
|
104
|
+
const target = (): CytoscapeTargetStyle => ({
|
|
105
|
+
defaults: new Map(),
|
|
106
|
+
mappings: new Map(),
|
|
107
|
+
dependencies: new Map(),
|
|
108
|
+
bypassAliases: new Map(),
|
|
109
|
+
});
|
|
110
|
+
return { network: { defaults: new Map() }, node: target(), edge: target() };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const NUMERIC_TYPES: ReadonlySet<string> = new Set(["integer", "long", "double", "float", "int", "short"]);
|
|
114
|
+
const DECIMAL = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A discrete key typed by its attribute's type: a number for a numeric type, a boolean for `boolean`, else the key
|
|
118
|
+
* as the file gives it. A list type (`list_of_integer`) types its items.
|
|
119
|
+
* @param raw - the key as the file gives it
|
|
120
|
+
* @param type - the attribute type, or null
|
|
121
|
+
* @returns the typed key, or null when it is not a scalar
|
|
122
|
+
* @category Styles
|
|
123
|
+
*/
|
|
124
|
+
export function typedKey(raw: unknown, type: string | null): string | number | boolean | null {
|
|
125
|
+
if (typeof raw === "number") {
|
|
126
|
+
return Number.isFinite(raw) ? raw : null;
|
|
127
|
+
}
|
|
128
|
+
if (typeof raw === "boolean") {
|
|
129
|
+
return raw;
|
|
130
|
+
}
|
|
131
|
+
if (typeof raw !== "string") {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const t = (type ?? "")
|
|
135
|
+
.toLowerCase()
|
|
136
|
+
.replace(/^list_of_/, "")
|
|
137
|
+
.replace(/^java\.lang\./, "");
|
|
138
|
+
if (NUMERIC_TYPES.has(t) && raw.length <= 64 && DECIMAL.test(raw.trim())) {
|
|
139
|
+
return Number(raw.trim());
|
|
140
|
+
}
|
|
141
|
+
if (t === "boolean") {
|
|
142
|
+
const b = raw.trim().toLowerCase();
|
|
143
|
+
if (b === "true" || b === "false") {
|
|
144
|
+
return b === "true";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return raw;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The tags of a CX version 1 mapping definition that are indexed.
|
|
152
|
+
* @category Styles
|
|
153
|
+
*/
|
|
154
|
+
export type Cx1IndexedTag = "K" | "V" | "L" | "E" | "G" | "OV";
|
|
155
|
+
const INDEXED: ReadonlySet<string> = new Set<Cx1IndexedTag>(["K", "V", "L", "E", "G", "OV"]);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A parsed CX version 1 mapping definition.
|
|
159
|
+
* @category Styles
|
|
160
|
+
*/
|
|
161
|
+
export interface Cx1Definition {
|
|
162
|
+
/** The column (`COL=`), or null. */
|
|
163
|
+
readonly column: string | null;
|
|
164
|
+
/** The attribute type (`T=`), or null. */
|
|
165
|
+
readonly type: string | null;
|
|
166
|
+
/** Each indexed tag's entries by index: `K` keys, `V` values, `L`/`E`/`G` below/at/above, `OV` points. */
|
|
167
|
+
readonly entries: ReadonlyMap<Cx1IndexedTag, ReadonlyMap<number, string>>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Splits a definition at single commas; `,,` is a literal comma.
|
|
172
|
+
* @param def - the definition
|
|
173
|
+
* @returns the tokens
|
|
174
|
+
*/
|
|
175
|
+
function definitionTokens(def: string): string[] {
|
|
176
|
+
const tokens: string[] = [];
|
|
177
|
+
let parts: string[] = [];
|
|
178
|
+
let start = 0;
|
|
179
|
+
let i = def.indexOf(",");
|
|
180
|
+
while (i >= 0) {
|
|
181
|
+
parts.push(def.slice(start, i));
|
|
182
|
+
if (def[i + 1] === ",") {
|
|
183
|
+
parts.push(",");
|
|
184
|
+
i++;
|
|
185
|
+
} else {
|
|
186
|
+
tokens.push(parts.join(""));
|
|
187
|
+
parts = [];
|
|
188
|
+
}
|
|
189
|
+
start = i + 1;
|
|
190
|
+
i = def.indexOf(",", start);
|
|
191
|
+
}
|
|
192
|
+
parts.push(def.slice(start));
|
|
193
|
+
tokens.push(parts.join(""));
|
|
194
|
+
return tokens;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* One indexed entry of a definition: `TAG=index=value`.
|
|
199
|
+
* @param t - the token
|
|
200
|
+
* @returns the tag, the index and the value, or null when the token is no indexed entry
|
|
201
|
+
*/
|
|
202
|
+
function indexedEntry(t: string): { tag: string; index: number; value: string } | null {
|
|
203
|
+
const eq1 = t.indexOf("=");
|
|
204
|
+
const eq2 = eq1 < 0 ? -1 : t.indexOf("=", eq1 + 1);
|
|
205
|
+
const tag = t.slice(0, eq1);
|
|
206
|
+
if (eq2 < 0 || !INDEXED.has(tag)) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const indexText = t.slice(eq1 + 1, eq2);
|
|
210
|
+
return /^\d{1,15}$/.test(indexText) ? { tag, index: Number(indexText), value: t.slice(eq2 + 1) } : null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Reads a CX version 1 mapping definition: `COL=a,T=string,K=0=x,V=0=y,...`, with `,,` a literal comma. Indexes are
|
|
215
|
+
* collected into Maps and never used as array positions (`K=4294967294=a` is one entry, not four billion holes); an
|
|
216
|
+
* index larger than the number of tokens is ignored and noted as `W_STYLE_BAD_MAPPING`.
|
|
217
|
+
* @param def - the definition string
|
|
218
|
+
* @param notes - where problems are noted
|
|
219
|
+
* @param target - nodes or edges, for the note
|
|
220
|
+
* @returns the definition
|
|
221
|
+
* @category Styles
|
|
222
|
+
*/
|
|
223
|
+
export function parseCx1Definition(def: string, notes?: StyleNotes, target: StyleTarget | null = null): Cx1Definition {
|
|
224
|
+
const tokens = definitionTokens(def);
|
|
225
|
+
const entries = new Map<Cx1IndexedTag, Map<number, string>>();
|
|
226
|
+
let column: string | null = null;
|
|
227
|
+
let type: string | null = null;
|
|
228
|
+
let beyond = 0;
|
|
229
|
+
for (const t of tokens) {
|
|
230
|
+
if (t.startsWith("COL=")) {
|
|
231
|
+
column = t.slice(4);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (t.startsWith("T=")) {
|
|
235
|
+
type = t.slice(2);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
const indexed = indexedEntry(t);
|
|
239
|
+
if (indexed === null) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const { tag, index, value } = indexed;
|
|
243
|
+
if (index > tokens.length) {
|
|
244
|
+
beyond++;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
let byIndex = entries.get(tag as Cx1IndexedTag);
|
|
248
|
+
if (byIndex === undefined) {
|
|
249
|
+
byIndex = new Map();
|
|
250
|
+
entries.set(tag as Cx1IndexedTag, byIndex);
|
|
251
|
+
}
|
|
252
|
+
byIndex.set(index, value);
|
|
253
|
+
}
|
|
254
|
+
if (beyond > 0) {
|
|
255
|
+
notes?.add(STYLE_ISSUE.BAD_MAPPING, target, column ?? "definition", {
|
|
256
|
+
sample: `${beyond} entries with an index beyond the definition`,
|
|
257
|
+
count: beyond,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return { column, type, entries };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The indexes of a tag's entries, ascending.
|
|
265
|
+
* @param d - the definition
|
|
266
|
+
* @param tag - the tag
|
|
267
|
+
* @returns the indexes
|
|
268
|
+
*/
|
|
269
|
+
function indexesOf(d: Cx1Definition, tag: Cx1IndexedTag): number[] {
|
|
270
|
+
return Array.from(d.entries.get(tag)?.keys() ?? []).sort((a, b) => a - b);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* A finite number from a number or decimal text.
|
|
275
|
+
* @param v - the value
|
|
276
|
+
* @returns the number, or null
|
|
277
|
+
*/
|
|
278
|
+
function finiteOf(v: unknown): number | null {
|
|
279
|
+
if (typeof v === "number") {
|
|
280
|
+
return Number.isFinite(v) ? v : null;
|
|
281
|
+
}
|
|
282
|
+
if (typeof v === "string" && v.length <= 64 && DECIMAL.test(v.trim())) {
|
|
283
|
+
return Number(v.trim());
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* A CX version 1 mapping (`{ type: "DISCRETE", definition: "COL=..." }`) as a Cytoscape mapping.
|
|
290
|
+
* @param m - the mapping object
|
|
291
|
+
* @param notes - where problems are noted
|
|
292
|
+
* @param target - nodes or edges, for notes
|
|
293
|
+
* @returns the mapping, or null when it cannot be read
|
|
294
|
+
* @category Styles
|
|
295
|
+
*/
|
|
296
|
+
export function mappingFromCx1(
|
|
297
|
+
m: unknown,
|
|
298
|
+
notes?: StyleNotes,
|
|
299
|
+
target: StyleTarget | null = null,
|
|
300
|
+
): CytoscapeMapping | null {
|
|
301
|
+
if (m === null || typeof m !== "object" || typeof (m as { definition?: unknown }).definition !== "string") {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
const { type: kind, definition } = m as { type?: unknown; definition: string };
|
|
305
|
+
const d = parseCx1Definition(definition, notes, target);
|
|
306
|
+
if (d.column === null) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
const at = (tag: Cx1IndexedTag, i: number): string | undefined => d.entries.get(tag)?.get(i);
|
|
310
|
+
switch (String(kind).toUpperCase()) {
|
|
311
|
+
case "PASSTHROUGH":
|
|
312
|
+
return { kind: "passthrough", column: d.column, type: d.type };
|
|
313
|
+
case "DISCRETE": {
|
|
314
|
+
const table: [string | number | boolean, unknown][] = [];
|
|
315
|
+
for (const i of indexesOf(d, "K")) {
|
|
316
|
+
const key = typedKey(at("K", i), d.type);
|
|
317
|
+
const value = at("V", i);
|
|
318
|
+
if (key !== null && value !== undefined) {
|
|
319
|
+
table.push([key, value]);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return { kind: "discrete", column: d.column, type: d.type, table };
|
|
323
|
+
}
|
|
324
|
+
case "CONTINUOUS": {
|
|
325
|
+
const points: CytoscapeContinuousPoint[] = [];
|
|
326
|
+
for (const i of indexesOf(d, "OV")) {
|
|
327
|
+
const x = finiteOf(at("OV", i));
|
|
328
|
+
if (x !== null) {
|
|
329
|
+
points.push({ at: x, below: at("L", i), value: at("E", i), above: at("G", i) });
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return { kind: "continuous", column: d.column, type: d.type, points };
|
|
333
|
+
}
|
|
334
|
+
default:
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* A property of an object, read only when it is the object's own.
|
|
341
|
+
* @param o - the object
|
|
342
|
+
* @param k - the key
|
|
343
|
+
* @returns the value, or undefined
|
|
344
|
+
*/
|
|
345
|
+
function own(o: unknown, k: string): unknown {
|
|
346
|
+
return o !== null && typeof o === "object" && Object.hasOwn(o, k) ? (o as Record<string, unknown>)[k] : undefined;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** A continuous point being assembled from CX2 intervals. */
|
|
350
|
+
interface PointDraft {
|
|
351
|
+
at: number;
|
|
352
|
+
below?: unknown;
|
|
353
|
+
value?: unknown;
|
|
354
|
+
above?: unknown;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* A CX2 mapping (`{ type, definition: { attribute, map } }`) as a Cytoscape mapping. Continuous intervals
|
|
359
|
+
* (`{ min, max, includeMin, includeMax, minVPValue, maxVPValue }`) become points: an interval's `minVPValue` is the
|
|
360
|
+
* value just above its `min` (and at it when `includeMin`), its `maxVPValue` the value just below its `max` (and at
|
|
361
|
+
* it when `includeMax` and the next interval does not include its `min`).
|
|
362
|
+
* @param m - the mapping object
|
|
363
|
+
* @returns the mapping, or null when it cannot be read
|
|
364
|
+
* @category Styles
|
|
365
|
+
*/
|
|
366
|
+
export function mappingFromCx2(m: unknown): CytoscapeMapping | null {
|
|
367
|
+
const def = own(m, "definition");
|
|
368
|
+
const column = own(def, "attribute");
|
|
369
|
+
if (typeof column !== "string") {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
const declared = own(def, "type");
|
|
373
|
+
const type = typeof declared === "string" ? declared : null;
|
|
374
|
+
const map = own(def, "map");
|
|
375
|
+
const entries = Array.isArray(map) ? (map as unknown[]) : [];
|
|
376
|
+
switch (String(own(m, "type")).toUpperCase()) {
|
|
377
|
+
case "PASSTHROUGH":
|
|
378
|
+
return { kind: "passthrough", column, type };
|
|
379
|
+
case "DISCRETE": {
|
|
380
|
+
const table: [string | number | boolean, unknown][] = [];
|
|
381
|
+
for (const e of entries) {
|
|
382
|
+
const key = typedKey(own(e, "v"), type);
|
|
383
|
+
const value = own(e, "vp");
|
|
384
|
+
if (key !== null && value !== undefined) {
|
|
385
|
+
table.push([key, value]);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return { kind: "discrete", column, type, table };
|
|
389
|
+
}
|
|
390
|
+
case "CONTINUOUS":
|
|
391
|
+
return { kind: "continuous", column, type, points: cx2Points(entries) };
|
|
392
|
+
default:
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* The points of CX2's continuous intervals.
|
|
399
|
+
* @param entries - the intervals
|
|
400
|
+
* @returns the points, ascending
|
|
401
|
+
*/
|
|
402
|
+
function cx2Points(entries: readonly unknown[]): CytoscapeContinuousPoint[] {
|
|
403
|
+
const byAt = new Map<number, PointDraft>();
|
|
404
|
+
const point = (x: number): PointDraft => {
|
|
405
|
+
let p = byAt.get(x);
|
|
406
|
+
if (p === undefined) {
|
|
407
|
+
p = { at: x };
|
|
408
|
+
byAt.set(x, p);
|
|
409
|
+
}
|
|
410
|
+
return p;
|
|
411
|
+
};
|
|
412
|
+
for (const iv of entries) {
|
|
413
|
+
if (iv !== null && typeof iv === "object") {
|
|
414
|
+
addInterval(iv, point);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return Array.from(byAt.values())
|
|
418
|
+
.sort((a, b) => a.at - b.at)
|
|
419
|
+
.map((p): CytoscapeContinuousPoint => {
|
|
420
|
+
const below = p.below ?? p.value ?? p.above;
|
|
421
|
+
const above = p.above ?? p.value ?? below;
|
|
422
|
+
return { at: p.at, below, value: p.value ?? below, above };
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* One CX2 interval into its points: its `minVPValue` is the value just above its `min` (and at it when
|
|
428
|
+
* `includeMin`), its `maxVPValue` the value just below its `max` (and at it when `includeMax` and the next interval
|
|
429
|
+
* does not include its `min`).
|
|
430
|
+
* @param iv - the interval
|
|
431
|
+
* @param point - the point at a position, made on first use
|
|
432
|
+
*/
|
|
433
|
+
function addInterval(iv: object, point: (x: number) => PointDraft): void {
|
|
434
|
+
const lo = finiteOf(own(iv, "min"));
|
|
435
|
+
const hi = finiteOf(own(iv, "max"));
|
|
436
|
+
const minValue = own(iv, "minVPValue") ?? own(iv, "maxVPValue");
|
|
437
|
+
const maxValue = own(iv, "maxVPValue") ?? own(iv, "minVPValue");
|
|
438
|
+
if (lo !== null) {
|
|
439
|
+
const p = point(lo);
|
|
440
|
+
p.above = minValue;
|
|
441
|
+
if (own(iv, "includeMin") !== false) {
|
|
442
|
+
p.value = minValue;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (hi !== null) {
|
|
446
|
+
const p = point(hi);
|
|
447
|
+
p.below = maxValue;
|
|
448
|
+
if (own(iv, "includeMax") !== false && p.value === undefined) {
|
|
449
|
+
p.value = maxValue;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The element's own record of values, or an empty one.
|
|
456
|
+
* @param x - the value
|
|
457
|
+
* @returns the record
|
|
458
|
+
*/
|
|
459
|
+
function record(x: unknown): Record<string, unknown> {
|
|
460
|
+
return x !== null && typeof x === "object" && !Array.isArray(x) ? (x as Record<string, unknown>) : {};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* The style of a CX version 1 file from its `cyVisualProperties` aspect: the first view's `network`,
|
|
465
|
+
* `nodes:default` and `edges:default` entries (defaults, mappings, dependencies). Other views are skipped with one
|
|
466
|
+
* `W_STYLE_OTHER_VIEWS` note; a mapping that cannot be read is noted as `W_STYLE_BAD_MAPPING`.
|
|
467
|
+
* @param entries - the aspect's entries
|
|
468
|
+
* @param notes - where problems are noted
|
|
469
|
+
* @returns the style
|
|
470
|
+
* @category Styles
|
|
471
|
+
*/
|
|
472
|
+
export function cytoscapeStyleFromCx(entries: readonly unknown[], notes?: StyleNotes): CytoscapeStyle {
|
|
473
|
+
const style = emptyCytoscapeStyle();
|
|
474
|
+
const viewOf = (v: unknown): unknown => own(v, "applies_to") ?? own(v, "view") ?? null;
|
|
475
|
+
const views: unknown[] = [];
|
|
476
|
+
for (const v of entries) {
|
|
477
|
+
if (/default|network/.test(String(own(v, "properties_of"))) && !views.includes(viewOf(v))) {
|
|
478
|
+
views.push(viewOf(v));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (views.length > 1) {
|
|
482
|
+
notes?.add(STYLE_ISSUE.OTHER_VIEWS, null, "cyVisualProperties", {
|
|
483
|
+
sample: `${views.length - 1} more`,
|
|
484
|
+
count: views.length - 1,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
for (const v of entries) {
|
|
488
|
+
const target =
|
|
489
|
+
v !== null && typeof v === "object" && viewOf(v) === views[0]
|
|
490
|
+
? CX_SECTIONS.get(String(own(v, "properties_of")))
|
|
491
|
+
: undefined;
|
|
492
|
+
if (target === undefined) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const props = record(own(v, "properties"));
|
|
496
|
+
for (const k of Object.keys(props)) {
|
|
497
|
+
style[target].defaults.set(k, props[k]);
|
|
498
|
+
}
|
|
499
|
+
if (target !== "network") {
|
|
500
|
+
readCxMappings(style, target, v, notes);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return style;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** The style section each `properties_of` of a CX `cyVisualProperties` entry fills. */
|
|
507
|
+
const CX_SECTIONS: ReadonlyMap<string, StyleTarget | "network"> = new Map([
|
|
508
|
+
["nodes:default", "node"],
|
|
509
|
+
["edges:default", "edge"],
|
|
510
|
+
["network", "network"],
|
|
511
|
+
]);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* The mappings and dependencies of a CX `nodes:default` or `edges:default` entry, into the style.
|
|
515
|
+
* @param style - the style, changed in place
|
|
516
|
+
* @param target - nodes or edges
|
|
517
|
+
* @param v - the entry
|
|
518
|
+
* @param notes - where a mapping that cannot be read is noted
|
|
519
|
+
*/
|
|
520
|
+
function readCxMappings(style: CytoscapeStyle, target: StyleTarget, v: unknown, notes: StyleNotes | undefined): void {
|
|
521
|
+
const mappings = record(own(v, "mappings"));
|
|
522
|
+
for (const vp of Object.keys(mappings)) {
|
|
523
|
+
const m = mappingFromCx1(mappings[vp], notes, target);
|
|
524
|
+
if (m === null) {
|
|
525
|
+
notes?.add(STYLE_ISSUE.BAD_MAPPING, target, vp, { sample: mappings[vp] });
|
|
526
|
+
} else {
|
|
527
|
+
style[target].mappings.set(vp, m);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const deps = record(own(v, "dependencies"));
|
|
531
|
+
for (const d of Object.keys(deps)) {
|
|
532
|
+
style[target].dependencies.set(d, String(deps[d]).toLowerCase() === "true");
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* The style of a CX2 file from its `visualProperties` and `visualEditorProperties` aspects (the first entry of
|
|
538
|
+
* each). CX2 has no `NODE_SIZE`, so a locked node size follows `NODE_WIDTH` (its default, mapping and bypasses)
|
|
539
|
+
* unless the file writes `NODE_SIZE` anyway.
|
|
540
|
+
* @param visualProperties - the `visualProperties` aspect
|
|
541
|
+
* @param visualEditorProperties - the `visualEditorProperties` aspect, or undefined
|
|
542
|
+
* @param notes - where problems are noted
|
|
543
|
+
* @returns the style
|
|
544
|
+
* @category Styles
|
|
545
|
+
*/
|
|
546
|
+
export function cytoscapeStyleFromCx2(
|
|
547
|
+
visualProperties: unknown,
|
|
548
|
+
visualEditorProperties?: unknown,
|
|
549
|
+
notes?: StyleNotes,
|
|
550
|
+
): CytoscapeStyle {
|
|
551
|
+
const style = emptyCytoscapeStyle();
|
|
552
|
+
const first = (x: unknown): unknown => (Array.isArray(x) ? x[0] : x);
|
|
553
|
+
const vp = record(first(visualProperties));
|
|
554
|
+
const editor = record(own(record(first(visualEditorProperties)), "properties"));
|
|
555
|
+
const defaults = record(own(vp, "default"));
|
|
556
|
+
for (const target of ["network", "node", "edge"] as const) {
|
|
557
|
+
const d = record(own(defaults, target));
|
|
558
|
+
for (const k of Object.keys(d)) {
|
|
559
|
+
style[target].defaults.set(k, d[k]);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
style.node.dependencies.set("nodeSizeLocked", own(editor, "nodeSizeLocked") === true);
|
|
563
|
+
style.edge.dependencies.set("arrowColorMatchesEdge", own(editor, "arrowColorMatchesEdge") === true);
|
|
564
|
+
for (const [target, key] of [
|
|
565
|
+
["node", "nodeMapping"],
|
|
566
|
+
["edge", "edgeMapping"],
|
|
567
|
+
] as const) {
|
|
568
|
+
const mappings = record(own(vp, key));
|
|
569
|
+
for (const name of Object.keys(mappings)) {
|
|
570
|
+
const m = mappingFromCx2(mappings[name]);
|
|
571
|
+
if (m === null) {
|
|
572
|
+
notes?.add(STYLE_ISSUE.BAD_MAPPING, target, name, { sample: mappings[name] });
|
|
573
|
+
} else {
|
|
574
|
+
style[target].mappings.set(name, m);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
lockedSizeFromWidth(style.node);
|
|
579
|
+
return style;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* CX2 has no `NODE_SIZE`: a locked node size follows `NODE_WIDTH` (its default, mapping and bypasses) unless the
|
|
584
|
+
* file writes `NODE_SIZE` anyway.
|
|
585
|
+
* @param node - the node section, changed in place
|
|
586
|
+
*/
|
|
587
|
+
function lockedSizeFromWidth(node: CytoscapeStyle["node"]): void {
|
|
588
|
+
if (
|
|
589
|
+
node.dependencies.get("nodeSizeLocked") !== true ||
|
|
590
|
+
node.defaults.has("NODE_SIZE") ||
|
|
591
|
+
node.mappings.has("NODE_SIZE")
|
|
592
|
+
) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
if (node.defaults.has("NODE_WIDTH")) {
|
|
596
|
+
node.defaults.set("NODE_SIZE", node.defaults.get("NODE_WIDTH"));
|
|
597
|
+
}
|
|
598
|
+
const width = node.mappings.get("NODE_WIDTH");
|
|
599
|
+
if (width !== undefined) {
|
|
600
|
+
node.mappings.set("NODE_SIZE", width);
|
|
601
|
+
}
|
|
602
|
+
node.bypassAliases.set("NODE_WIDTH", "NODE_SIZE");
|
|
603
|
+
}
|