@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,744 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cytoscape.js's property values: the properties graph-io carries, how Cytoscape.js 3.34 parses each value
|
|
3
|
+
* (`style.parse`), the `data()` and `mapData()` mappers and how they evaluate per element, and the neutral value
|
|
4
|
+
* each parsed value is drawn as.
|
|
5
|
+
*
|
|
6
|
+
* What Cytoscape.js does and this module repeats:
|
|
7
|
+
* - a number property takes `px`, `em` or no unit; a value with any other suffix is read with `parseFloat`, so
|
|
8
|
+
* `width: 50%` draws 50 pixels wide. Unitless properties (opacities, `arrow-scale`) are read with `parseFloat`.
|
|
9
|
+
* - a color is a name, `#rgb`, `#rrggbb`, `rgb()`, `rgba()`, `hsl()` or `hsla()` with Cytoscape.js's own limits; its
|
|
10
|
+
* alpha is never drawn (the opacity properties are).
|
|
11
|
+
* - `mapData(field, a, b, x, y)` maps a numeric field linearly from [a, b] to [x, y], clamped at the ends; a reversed
|
|
12
|
+
* range runs backwards, a zero range gives x, equal x and y make it the constant x. A color is interpolated per
|
|
13
|
+
* channel and rounded.
|
|
14
|
+
* - a mapper that fails for an element (no field, a value the property refuses, a non-number for `mapData`) resets the
|
|
15
|
+
* property to its Cytoscape.js default, whatever the rules beneath say.
|
|
16
|
+
*/
|
|
17
|
+
import { CSS_COLORS } from "../canon/color-tables.js";
|
|
18
|
+
import { canonEnum } from "../canon/enums.js";
|
|
19
|
+
import { num6 } from "../canon/number.js";
|
|
20
|
+
import { STYLE_ISSUE } from "../codes.js";
|
|
21
|
+
const NODE_SHAPES = [
|
|
22
|
+
"rectangle",
|
|
23
|
+
"roundrectangle",
|
|
24
|
+
"round-rectangle",
|
|
25
|
+
"cutrectangle",
|
|
26
|
+
"cut-rectangle",
|
|
27
|
+
"bottomroundrectangle",
|
|
28
|
+
"bottom-round-rectangle",
|
|
29
|
+
"barrel",
|
|
30
|
+
"ellipse",
|
|
31
|
+
"triangle",
|
|
32
|
+
"round-triangle",
|
|
33
|
+
"square",
|
|
34
|
+
"pentagon",
|
|
35
|
+
"round-pentagon",
|
|
36
|
+
"hexagon",
|
|
37
|
+
"round-hexagon",
|
|
38
|
+
"concavehexagon",
|
|
39
|
+
"concave-hexagon",
|
|
40
|
+
"heptagon",
|
|
41
|
+
"round-heptagon",
|
|
42
|
+
"octagon",
|
|
43
|
+
"round-octagon",
|
|
44
|
+
"tag",
|
|
45
|
+
"round-tag",
|
|
46
|
+
"star",
|
|
47
|
+
"diamond",
|
|
48
|
+
"round-diamond",
|
|
49
|
+
"vee",
|
|
50
|
+
"rhomboid",
|
|
51
|
+
"right-rhomboid",
|
|
52
|
+
"polygon",
|
|
53
|
+
];
|
|
54
|
+
const ARROWS = [
|
|
55
|
+
"tee",
|
|
56
|
+
"triangle",
|
|
57
|
+
"triangle-tee",
|
|
58
|
+
"circle-triangle",
|
|
59
|
+
"triangle-cross",
|
|
60
|
+
"triangle-backcurve",
|
|
61
|
+
"vee",
|
|
62
|
+
"square",
|
|
63
|
+
"circle",
|
|
64
|
+
"diamond",
|
|
65
|
+
"chevron",
|
|
66
|
+
"none",
|
|
67
|
+
];
|
|
68
|
+
const FONT_WEIGHTS = [
|
|
69
|
+
"normal",
|
|
70
|
+
"bold",
|
|
71
|
+
"bolder",
|
|
72
|
+
"lighter",
|
|
73
|
+
"100",
|
|
74
|
+
"200",
|
|
75
|
+
"300",
|
|
76
|
+
"400",
|
|
77
|
+
"500",
|
|
78
|
+
"600",
|
|
79
|
+
"800",
|
|
80
|
+
"900",
|
|
81
|
+
100,
|
|
82
|
+
200,
|
|
83
|
+
300,
|
|
84
|
+
400,
|
|
85
|
+
500,
|
|
86
|
+
600,
|
|
87
|
+
700,
|
|
88
|
+
800,
|
|
89
|
+
900,
|
|
90
|
+
];
|
|
91
|
+
const CURVES = [
|
|
92
|
+
"bezier",
|
|
93
|
+
"unbundled-bezier",
|
|
94
|
+
"haystack",
|
|
95
|
+
"segments",
|
|
96
|
+
"straight",
|
|
97
|
+
"straight-triangle",
|
|
98
|
+
"taxi",
|
|
99
|
+
"round-segments",
|
|
100
|
+
"round-taxi",
|
|
101
|
+
];
|
|
102
|
+
/** The curve styles Cytoscape.js draws as straight lines or straight pieces: only the beziers bow. */
|
|
103
|
+
const STRAIGHT = new Set([
|
|
104
|
+
"haystack",
|
|
105
|
+
"straight",
|
|
106
|
+
"straight-triangle",
|
|
107
|
+
"segments",
|
|
108
|
+
"taxi",
|
|
109
|
+
"round-segments",
|
|
110
|
+
"round-taxi",
|
|
111
|
+
]);
|
|
112
|
+
const LABEL = [
|
|
113
|
+
["label", { property: "label", type: "text" }],
|
|
114
|
+
["color", { property: "labelColor", type: "color" }],
|
|
115
|
+
["font-size", { property: "labelSize", type: "size" }],
|
|
116
|
+
["font-family", { property: "labelFont", type: "fontFamily" }],
|
|
117
|
+
["font-weight", { property: "labelWeight", type: "fontWeight" }],
|
|
118
|
+
["font-style", { property: "labelItalic", type: "enum", enums: ["italic", "normal", "oblique"] }],
|
|
119
|
+
["visibility", { property: "_visibility", type: "enum", enums: ["hidden", "visible"] }],
|
|
120
|
+
["display", { property: "_display", type: "enum", enums: ["element", "none"] }],
|
|
121
|
+
["opacity", { property: "opacity", type: "zeroOne" }],
|
|
122
|
+
];
|
|
123
|
+
/** The node properties graph-io carries, by Cytoscape.js name. */
|
|
124
|
+
export const CYJS_NODE_PROPERTIES = new Map([
|
|
125
|
+
["background-color", { property: "fill", type: "color" }],
|
|
126
|
+
["background-opacity", { property: "fillOpacity", type: "zeroOne" }],
|
|
127
|
+
["border-color", { property: "borderColor", type: "color" }],
|
|
128
|
+
["border-width", { property: "borderWidth", type: "size" }],
|
|
129
|
+
["border-style", { property: "borderStyle", type: "enum", enums: ["solid", "dotted", "dashed", "double"] }],
|
|
130
|
+
["shape", { property: "shape", type: "enum", enums: NODE_SHAPES }],
|
|
131
|
+
["corner-radius", { property: "cornerRadius", type: "size" }],
|
|
132
|
+
["width", { property: "width", type: "nodeSize" }],
|
|
133
|
+
["height", { property: "height", type: "nodeSize" }],
|
|
134
|
+
[
|
|
135
|
+
"text-valign",
|
|
136
|
+
{ property: "_valign", type: "enum", enums: ["top", "top-inside", "center", "bottom", "bottom-inside"] },
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
"text-halign",
|
|
140
|
+
{ property: "_halign", type: "enum", enums: ["left", "left-inside", "center", "right", "right-inside"] },
|
|
141
|
+
],
|
|
142
|
+
...LABEL,
|
|
143
|
+
]);
|
|
144
|
+
/** The edge properties graph-io carries, by Cytoscape.js name. */
|
|
145
|
+
export const CYJS_EDGE_PROPERTIES = new Map([
|
|
146
|
+
["line-color", { property: "color", type: "color" }],
|
|
147
|
+
["width", { property: "width", type: "nodeSize" }],
|
|
148
|
+
["line-style", { property: "lineStyle", type: "enum", enums: ["solid", "dotted", "dashed"] }],
|
|
149
|
+
["target-arrow-shape", { property: "targetArrow", type: "enum", enums: ARROWS }],
|
|
150
|
+
["source-arrow-shape", { property: "sourceArrow", type: "enum", enums: ARROWS }],
|
|
151
|
+
["target-arrow-color", { property: "targetArrowColor", type: "color" }],
|
|
152
|
+
["source-arrow-color", { property: "sourceArrowColor", type: "color" }],
|
|
153
|
+
["curve-style", { property: "curved", type: "enum", enums: CURVES }],
|
|
154
|
+
["arrow-scale", { property: "arrowSize", type: "positive" }],
|
|
155
|
+
["source-label", { property: "sourceLabel", type: "text" }],
|
|
156
|
+
["target-label", { property: "targetLabel", type: "text" }],
|
|
157
|
+
...LABEL,
|
|
158
|
+
]);
|
|
159
|
+
/**
|
|
160
|
+
* The carried properties of a target.
|
|
161
|
+
* @param target - nodes or edges
|
|
162
|
+
* @returns Cytoscape.js name to its spec
|
|
163
|
+
*/
|
|
164
|
+
export function cyjsProperties(target) {
|
|
165
|
+
return target === "node" ? CYJS_NODE_PROPERTIES : CYJS_EDGE_PROPERTIES;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A property name in Cytoscape.js's dash form, aliases resolved (`backgroundColor` and `content` are read as
|
|
169
|
+
* `background-color` and `label`).
|
|
170
|
+
* @param name - the name as written
|
|
171
|
+
* @returns the dash-form name
|
|
172
|
+
*/
|
|
173
|
+
export function cyjsPropertyName(name) {
|
|
174
|
+
const dashed = name.replaceAll(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
175
|
+
return dashed === "content" ? "label" : dashed;
|
|
176
|
+
}
|
|
177
|
+
/** Thrown by Cytoscape.js itself: a color given as a number makes its parser call `toLowerCase` on a number. */
|
|
178
|
+
export const CYJS_THROWS = "throws";
|
|
179
|
+
const NUM = String.raw `[-+]?(?:(?:\d+|\d*\.\d+)(?:[Ee][+-]?\d+)?)`;
|
|
180
|
+
const NUMBER_UNITS = new RegExp(`^(${NUM})(px|em)?$`);
|
|
181
|
+
const NUMBER_ONLY = new RegExp(String.raw `^\s*${NUM}\s*$`);
|
|
182
|
+
const RGBA = new RegExp(String.raw `^rgb[a]?\((${NUM}[%]?)\s*,\s*(${NUM}[%]?)\s*,\s*(${NUM}[%]?)(?:\s*,\s*(${NUM}))?\)$`);
|
|
183
|
+
const HSLA = new RegExp(String.raw `^hsl[a]?\((${NUM})\s*,\s*(${NUM}[%])\s*,\s*(${NUM}[%])(?:\s*,\s*(${NUM}))?\)$`);
|
|
184
|
+
const MAP_ARG = new RegExp(String.raw `^(?:${NUM}|\w+|rgb[a]?\((?:${NUM}[%]?)\s*,\s*(?:${NUM}[%]?)\s*,\s*(?:${NUM}[%]?)(?:\s*,\s*(?:${NUM}))?\)` +
|
|
185
|
+
String.raw `|hsl[a]?\((?:${NUM})\s*,\s*(?:${NUM}[%])\s*,\s*(?:${NUM}[%])(?:\s*,\s*(?:${NUM}))?\)` +
|
|
186
|
+
String.raw `|\#[0-9a-fA-F]{3}|\#[0-9a-fA-F]{6})$`);
|
|
187
|
+
const FIELD = /^[\w.]+$/;
|
|
188
|
+
const WORD_FONT = /^[\w\- "]$/;
|
|
189
|
+
/**
|
|
190
|
+
* Cytoscape.js's color names: the CSS names without `rebeccapurple`, plus `transparent` (black with no alpha).
|
|
191
|
+
* @param name - the lowercased name
|
|
192
|
+
* @returns `#rrggbb`, or undefined
|
|
193
|
+
*/
|
|
194
|
+
function namedColor(name) {
|
|
195
|
+
if (name === "transparent") {
|
|
196
|
+
return "#000000";
|
|
197
|
+
}
|
|
198
|
+
return name === "rebeccapurple" ? undefined : CSS_COLORS.get(name);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A color as Cytoscape.js reads it (`color2tuple`).
|
|
202
|
+
* @param value - the trimmed text
|
|
203
|
+
* @returns red, green and blue, or null when Cytoscape.js refuses it
|
|
204
|
+
*/
|
|
205
|
+
function colorTuple(value) {
|
|
206
|
+
const named = namedColor(value.toLowerCase());
|
|
207
|
+
if (named !== undefined) {
|
|
208
|
+
return [
|
|
209
|
+
Number.parseInt(named.slice(1, 3), 16),
|
|
210
|
+
Number.parseInt(named.slice(3, 5), 16),
|
|
211
|
+
Number.parseInt(named.slice(5, 7), 16),
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
if ((value.length === 4 || value.length === 7) && value.startsWith("#")) {
|
|
215
|
+
const short = value.length === 4;
|
|
216
|
+
const pair = (k) => Number.parseInt(short ? value[k] + value[k] : value.slice(2 * k - 1, 2 * k + 1), 16);
|
|
217
|
+
return [pair(1), pair(2), pair(3)];
|
|
218
|
+
}
|
|
219
|
+
const m = RGBA.exec(value);
|
|
220
|
+
return m === null ? hslTuple(value) : rgbaTuple(m);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* `rgb()` and `rgba()` as Cytoscape.js reads them: channels all numbers or all percentages, within 0..255, and an
|
|
224
|
+
* alpha within 0..1.
|
|
225
|
+
* @param m - the match of the pattern
|
|
226
|
+
* @returns red, green and blue, or null
|
|
227
|
+
*/
|
|
228
|
+
function rgbaTuple(m) {
|
|
229
|
+
const pct = [1, 2, 3].map((k) => m[k].endsWith("%"));
|
|
230
|
+
if (pct.some(Boolean) && !pct.every(Boolean)) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const channels = [1, 2, 3].map((k) => {
|
|
234
|
+
const c = Number.parseFloat(m[k]);
|
|
235
|
+
return pct[k - 1] ? (c / 100) * 255 : c;
|
|
236
|
+
});
|
|
237
|
+
if (channels.some((c) => c < 0 || c > 255)) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const alpha = m.at(4);
|
|
241
|
+
if (alpha !== undefined && (Number.parseFloat(alpha) < 0 || Number.parseFloat(alpha) > 1)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return [Math.floor(channels[0]), Math.floor(channels[1]), Math.floor(channels[2])];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* `hsl()` and `hsla()` as Cytoscape.js reads them.
|
|
248
|
+
* @param value - the trimmed text
|
|
249
|
+
* @returns red, green and blue, or null
|
|
250
|
+
*/
|
|
251
|
+
function hslTuple(value) {
|
|
252
|
+
const m = HSLA.exec(value);
|
|
253
|
+
if (m === null) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
let h = Number.parseInt(m[1], 10);
|
|
257
|
+
if (h < 0) {
|
|
258
|
+
h = (360 - ((-1 * h) % 360)) % 360;
|
|
259
|
+
}
|
|
260
|
+
else if (h > 360) {
|
|
261
|
+
h = h % 360;
|
|
262
|
+
}
|
|
263
|
+
h /= 360;
|
|
264
|
+
const s = Number.parseFloat(m[2]);
|
|
265
|
+
const l = Number.parseFloat(m[3]);
|
|
266
|
+
if (s < 0 || s > 100 || l < 0 || l > 100) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
const alpha = m.at(4);
|
|
270
|
+
if (alpha !== undefined && (Number.parseFloat(alpha) < 0 || Number.parseFloat(alpha) > 1)) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
const sn = s / 100;
|
|
274
|
+
const ln = l / 100;
|
|
275
|
+
if (sn === 0) {
|
|
276
|
+
const g = Math.round(ln * 255);
|
|
277
|
+
return [g, g, g];
|
|
278
|
+
}
|
|
279
|
+
const hue = (p, q, t0) => {
|
|
280
|
+
let t = t0;
|
|
281
|
+
if (t < 0) {
|
|
282
|
+
t += 1;
|
|
283
|
+
}
|
|
284
|
+
if (t > 1) {
|
|
285
|
+
t -= 1;
|
|
286
|
+
}
|
|
287
|
+
if (t < 1 / 6) {
|
|
288
|
+
return p + (q - p) * 6 * t;
|
|
289
|
+
}
|
|
290
|
+
if (t < 1 / 2) {
|
|
291
|
+
return q;
|
|
292
|
+
}
|
|
293
|
+
if (t < 2 / 3) {
|
|
294
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
295
|
+
}
|
|
296
|
+
return p;
|
|
297
|
+
};
|
|
298
|
+
const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;
|
|
299
|
+
const p = 2 * ln - q;
|
|
300
|
+
return [
|
|
301
|
+
Math.round(255 * hue(p, q, h + 1 / 3)),
|
|
302
|
+
Math.round(255 * hue(p, q, h)),
|
|
303
|
+
Math.round(255 * hue(p, q, h - 1 / 3)),
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether a value matches Cytoscape.js's font family pattern `^([\w- "]+(?:\s*,\s*[\w- "]+)*)$`, checked part by
|
|
308
|
+
* part in one pass instead of with the backtracking pattern: items of word characters, `-`, space and `"`, joined
|
|
309
|
+
* by commas with any whitespace around them.
|
|
310
|
+
* @param value - the text
|
|
311
|
+
* @returns true when Cytoscape.js accepts it
|
|
312
|
+
*/
|
|
313
|
+
export function isFontFamily(value) {
|
|
314
|
+
const parts = value.split(",");
|
|
315
|
+
if (parts.length === 1) {
|
|
316
|
+
return parts[0].length > 0 && allOf(parts[0], isFontChar);
|
|
317
|
+
}
|
|
318
|
+
return (firstFontPart(parts[0]) &&
|
|
319
|
+
lastFontPart(parts.at(-1) ?? "") &&
|
|
320
|
+
parts.slice(1, -1).every((part) => middleFontPart(part)));
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Whether a character may be part of a font family item: a word character, `-`, space or `"`.
|
|
324
|
+
* @param c - the character
|
|
325
|
+
* @returns true when it may
|
|
326
|
+
*/
|
|
327
|
+
function isFontChar(c) {
|
|
328
|
+
return WORD_FONT.test(c);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Whether a character is whitespace.
|
|
332
|
+
* @param c - the character
|
|
333
|
+
* @returns true for whitespace
|
|
334
|
+
*/
|
|
335
|
+
function isSpace(c) {
|
|
336
|
+
return /\s/.test(c);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Whether every character of a text passes a test.
|
|
340
|
+
* @param text - the text
|
|
341
|
+
* @param test - the test
|
|
342
|
+
* @returns true when all do (and for an empty text)
|
|
343
|
+
*/
|
|
344
|
+
function allOf(text, test) {
|
|
345
|
+
return Array.from(text).every(test);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* The part before the first comma: an item, then whitespace before the comma.
|
|
349
|
+
* @param part - the part
|
|
350
|
+
* @returns true when it is one
|
|
351
|
+
*/
|
|
352
|
+
function firstFontPart(part) {
|
|
353
|
+
let a = 0;
|
|
354
|
+
while (a < part.length && isFontChar(part[a])) {
|
|
355
|
+
a++;
|
|
356
|
+
}
|
|
357
|
+
return a > 0 && allOf(part.slice(a), isSpace);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The part after the last comma: whitespace after the comma, then an item to the end.
|
|
361
|
+
* @param part - the part
|
|
362
|
+
* @returns true when it is one
|
|
363
|
+
*/
|
|
364
|
+
function lastFontPart(part) {
|
|
365
|
+
let b = part.length;
|
|
366
|
+
while (b > 0 && isFontChar(part[b - 1])) {
|
|
367
|
+
b--;
|
|
368
|
+
}
|
|
369
|
+
return b < part.length && allOf(part.slice(0, b), isSpace);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* A part between two commas: whitespace, an item, whitespace; a part of whitespace only holds an item when one of its
|
|
373
|
+
* characters is a space.
|
|
374
|
+
* @param part - the part
|
|
375
|
+
* @returns true when it is one
|
|
376
|
+
*/
|
|
377
|
+
function middleFontPart(part) {
|
|
378
|
+
let a = 0;
|
|
379
|
+
let b = part.length;
|
|
380
|
+
while (a < b && isSpace(part[a])) {
|
|
381
|
+
a++;
|
|
382
|
+
}
|
|
383
|
+
while (b > a && isSpace(part[b - 1])) {
|
|
384
|
+
b--;
|
|
385
|
+
}
|
|
386
|
+
return a === b ? part.includes(" ") : allOf(part.slice(a, b), isFontChar);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Parses a flat value (no mappers) the way Cytoscape.js does.
|
|
390
|
+
* @param spec - the property
|
|
391
|
+
* @param raw - the value
|
|
392
|
+
* @param rendered - the value is one Cytoscape.js reported (`ele.style(name)`), where every enumeration is text
|
|
393
|
+
* @returns the parsed value, null when Cytoscape.js refuses it, or `CYJS_THROWS` where Cytoscape.js itself throws
|
|
394
|
+
*/
|
|
395
|
+
function parseFlat(spec, raw, rendered = false) {
|
|
396
|
+
const value = typeof raw === "string" ? raw.trim() : raw;
|
|
397
|
+
switch (spec.type) {
|
|
398
|
+
case "color":
|
|
399
|
+
return parseColorValue(value);
|
|
400
|
+
case "zeroOne":
|
|
401
|
+
case "positive": {
|
|
402
|
+
const x = Number.parseFloat(String(value));
|
|
403
|
+
const ok = spec.type === "zeroOne" ? x >= 0 && x <= 1 : x > 0;
|
|
404
|
+
return ok ? { kind: "number", value: x, units: null, str: String(x) } : null;
|
|
405
|
+
}
|
|
406
|
+
case "size":
|
|
407
|
+
case "nodeSize":
|
|
408
|
+
return parseSizeValue(spec, value, raw);
|
|
409
|
+
case "text":
|
|
410
|
+
return { kind: "word", value: String(value), str: String(value) };
|
|
411
|
+
case "fontFamily": {
|
|
412
|
+
const text = String(value);
|
|
413
|
+
return isFontFamily(text) ? { kind: "word", value: text, str: text } : null;
|
|
414
|
+
}
|
|
415
|
+
case "fontWeight":
|
|
416
|
+
case "enum": {
|
|
417
|
+
const enums = spec.type === "fontWeight" ? FONT_WEIGHTS : (spec.enums ?? []);
|
|
418
|
+
const e = enums.find((x) => x === value || (rendered && String(x) === value));
|
|
419
|
+
return e === undefined ? null : { kind: "word", value: e, str: String(e) };
|
|
420
|
+
}
|
|
421
|
+
default:
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* A color as Cytoscape.js reads it: an `[r, g, b]` array as it is, else text.
|
|
427
|
+
* @param value - the value, trimmed
|
|
428
|
+
* @returns the color, null when refused, or `CYJS_THROWS` for a value that is neither
|
|
429
|
+
*/
|
|
430
|
+
function parseColorValue(value) {
|
|
431
|
+
if (Array.isArray(value)) {
|
|
432
|
+
const [r, g, b] = value;
|
|
433
|
+
const t = [Number(r), Number(g), Number(b)];
|
|
434
|
+
return { kind: "color", rgb: t, str: `rgb(${t[0]},${t[1]},${t[2]})` };
|
|
435
|
+
}
|
|
436
|
+
if (typeof value !== "string") {
|
|
437
|
+
return CYJS_THROWS;
|
|
438
|
+
}
|
|
439
|
+
const t = colorTuple(value);
|
|
440
|
+
return t === null ? null : { kind: "color", rgb: t, str: `rgb(${t[0]},${t[1]},${t[2]})` };
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* A size as Cytoscape.js reads it: a non-negative number in `px` or `em`, a number read past an unknown suffix, and
|
|
444
|
+
* a node size of `label`.
|
|
445
|
+
* @param spec - the property
|
|
446
|
+
* @param value - the value, trimmed
|
|
447
|
+
* @param raw - the value as given
|
|
448
|
+
* @returns the size, or null when refused
|
|
449
|
+
*/
|
|
450
|
+
function parseSizeValue(spec, value, raw) {
|
|
451
|
+
let units = "px";
|
|
452
|
+
let text = value;
|
|
453
|
+
if (typeof value === "string") {
|
|
454
|
+
const m = NUMBER_UNITS.exec(value);
|
|
455
|
+
if (m === null) {
|
|
456
|
+
units = null;
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
text = m[1];
|
|
460
|
+
units = m.at(2) === "em" ? "em" : "px";
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const x = Number.parseFloat(String(text));
|
|
464
|
+
if (Number.isNaN(x)) {
|
|
465
|
+
return spec.type === "nodeSize" && raw === "label" ? { kind: "word", value: "label", str: "label" } : null;
|
|
466
|
+
}
|
|
467
|
+
return x < 0 ? null : { kind: "number", value: x, units, str: `${String(x)}${units ?? ""}` };
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Splits the arguments of `mapData(...)` at the commas outside parentheses.
|
|
471
|
+
* @param inner - the text between the outer parentheses
|
|
472
|
+
* @returns the arguments
|
|
473
|
+
*/
|
|
474
|
+
function splitArgs(inner) {
|
|
475
|
+
const out = [];
|
|
476
|
+
let depth = 0;
|
|
477
|
+
let start = 0;
|
|
478
|
+
for (let i = 0; i < inner.length; i++) {
|
|
479
|
+
const c = inner[i];
|
|
480
|
+
if (c === "(") {
|
|
481
|
+
depth++;
|
|
482
|
+
}
|
|
483
|
+
else if (c === ")") {
|
|
484
|
+
depth--;
|
|
485
|
+
}
|
|
486
|
+
else if (c === "," && depth === 0) {
|
|
487
|
+
out.push(inner.slice(start, i));
|
|
488
|
+
start = i + 1;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
out.push(inner.slice(start));
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* The text between the parentheses of `name(...)`, found by position: the name, optional whitespace, `(`, and a
|
|
496
|
+
* last character `)`.
|
|
497
|
+
* @param value - the trimmed value
|
|
498
|
+
* @param name - `data` or `mapData`
|
|
499
|
+
* @returns the inner text, or null
|
|
500
|
+
*/
|
|
501
|
+
function callArgs(value, name) {
|
|
502
|
+
if (!value.startsWith(name) || !value.endsWith(")")) {
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
let i = name.length;
|
|
506
|
+
while (i < value.length && /\s/.test(value[i])) {
|
|
507
|
+
i++;
|
|
508
|
+
}
|
|
509
|
+
return value[i] === "(" ? value.slice(i + 1, -1) : null;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Parses a property value the way Cytoscape.js does: a mapper in a rule, else a flat value.
|
|
513
|
+
* @param spec - the property
|
|
514
|
+
* @param raw - the value as given
|
|
515
|
+
* @param mode - a stylesheet rule, an element bypass, or a mapper's per-element value
|
|
516
|
+
* @returns the parsed value, null when Cytoscape.js refuses it, or `CYJS_THROWS`
|
|
517
|
+
*/
|
|
518
|
+
export function parseCyjsValue(spec, raw, mode) {
|
|
519
|
+
if (raw === undefined) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
if (typeof raw === "function") {
|
|
523
|
+
return mode === "flat" ? null : { kind: "fn" };
|
|
524
|
+
}
|
|
525
|
+
const value = typeof raw === "string" ? raw.trim() : raw;
|
|
526
|
+
if (mode !== "flat" && typeof value === "string" && value.length >= 7 && value[1] === "a") {
|
|
527
|
+
const mapper = parseMapper(spec, value, mode);
|
|
528
|
+
if (mapper !== undefined) {
|
|
529
|
+
return mapper;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return parseFlat(spec, raw);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* A `data()` or `mapData()` value.
|
|
536
|
+
* @param spec - the property
|
|
537
|
+
* @param value - the trimmed value
|
|
538
|
+
* @param mode - a rule or a bypass
|
|
539
|
+
* @returns the mapper, null when it is refused (or its constant), or undefined when the value is not a mapper
|
|
540
|
+
*/
|
|
541
|
+
function parseMapper(spec, value, mode) {
|
|
542
|
+
if (value.startsWith("d")) {
|
|
543
|
+
const field = callArgs(value, "data")?.trim();
|
|
544
|
+
if (field === undefined || !FIELD.test(field)) {
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
return mode === "bypass" ? null : { kind: "data", field };
|
|
548
|
+
}
|
|
549
|
+
if (!value.startsWith("m") || value.length < 10) {
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
return parseMapData(spec, value, mode);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* A `mapData()` value.
|
|
556
|
+
* @param spec - the property
|
|
557
|
+
* @param value - the trimmed value, starting with `m`
|
|
558
|
+
* @param mode - a rule or a bypass
|
|
559
|
+
* @returns the mapper, null when it is refused (or its constant), or undefined when the value is not a mapper
|
|
560
|
+
*/
|
|
561
|
+
function parseMapData(spec, value, mode) {
|
|
562
|
+
const inner = callArgs(value, "mapData");
|
|
563
|
+
if (inner === null) {
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
566
|
+
const args = splitArgs(inner);
|
|
567
|
+
if (!isMapDataArgs(args)) {
|
|
568
|
+
return undefined;
|
|
569
|
+
}
|
|
570
|
+
if (mode === "bypass") {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
const numeric = spec.type === "zeroOne" || spec.type === "positive" || spec.type === "size" || spec.type === "nodeSize";
|
|
574
|
+
if (spec.type !== "color" && !numeric) {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
const min = parseFlat(spec, args[3].trim());
|
|
578
|
+
const max = parseFlat(spec, args[4].trim());
|
|
579
|
+
if (min === null || max === null || min === CYJS_THROWS || max === CYJS_THROWS) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
if (min.str === max.str || (min.kind === "number" && max.kind === "number" && pfValue(min) === pfValue(max))) {
|
|
583
|
+
const constant = parseFlat(spec, min.str);
|
|
584
|
+
return constant === CYJS_THROWS ? null : constant;
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
kind: "mapData",
|
|
588
|
+
field: args[0].trim(),
|
|
589
|
+
fieldMin: Number.parseFloat(args[1]),
|
|
590
|
+
fieldMax: Number.parseFloat(args[2]),
|
|
591
|
+
min,
|
|
592
|
+
max,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Whether `mapData`'s arguments have Cytoscape.js's shape: a field, two numbers and two values.
|
|
597
|
+
* @param args - the arguments
|
|
598
|
+
* @returns true when they do
|
|
599
|
+
*/
|
|
600
|
+
function isMapDataArgs(args) {
|
|
601
|
+
return (args.length === 5 &&
|
|
602
|
+
/^[\w.]+\s*$/.test(args[0]) &&
|
|
603
|
+
NUMBER_ONLY.test(args[1]) &&
|
|
604
|
+
NUMBER_ONLY.test(args[2]) &&
|
|
605
|
+
MAP_ARG.test(args[3].trim()) &&
|
|
606
|
+
MAP_ARG.test(args[4].replace(/^\s+/, "")));
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* A number's value in pixels as Cytoscape.js normalizes it in a headless core (an `em` is 1 pixel there).
|
|
610
|
+
* @param v - the number
|
|
611
|
+
* @returns the normalized value
|
|
612
|
+
*/
|
|
613
|
+
function pfValue(v) {
|
|
614
|
+
return v.value;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* A field of an element's data as a mapper reads it: the dotted path walked while each step is truthy.
|
|
618
|
+
* @param data - the element's data object
|
|
619
|
+
* @param field - the field
|
|
620
|
+
* @returns the value
|
|
621
|
+
*/
|
|
622
|
+
function mapperField(data, field) {
|
|
623
|
+
let v = data;
|
|
624
|
+
for (const step of field.split(".")) {
|
|
625
|
+
if (!v) {
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
v = v[step];
|
|
629
|
+
}
|
|
630
|
+
return v;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Evaluates a mapper for one element the way Cytoscape.js applies it.
|
|
634
|
+
* @param spec - the property
|
|
635
|
+
* @param m - the mapper
|
|
636
|
+
* @param data - the element's data object
|
|
637
|
+
* @returns the flat value, null when the mapper fails (the property resets to its default), or `CYJS_THROWS`
|
|
638
|
+
*/
|
|
639
|
+
export function applyCyjsMapper(spec, m, data) {
|
|
640
|
+
const v = mapperField(data, m.field);
|
|
641
|
+
if (v === null || v === undefined) {
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
if (m.kind === "data") {
|
|
645
|
+
return parseFlat(spec, v);
|
|
646
|
+
}
|
|
647
|
+
if (typeof v !== "number" || Number.isNaN(v)) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
const width = m.fieldMax - m.fieldMin;
|
|
651
|
+
const p = Math.min(1, Math.max(0, width === 0 ? 0 : (v - m.fieldMin) / width));
|
|
652
|
+
const { min, max } = m;
|
|
653
|
+
if (min.kind === "color" && max.kind === "color") {
|
|
654
|
+
const c = [0, 1, 2].map((k) => Math.round(min.rgb[k] + (max.rgb[k] - min.rgb[k]) * p));
|
|
655
|
+
return { kind: "color", rgb: c, str: `rgb(${c[0]}, ${c[1]}, ${c[2]})` };
|
|
656
|
+
}
|
|
657
|
+
if (min.kind === "number" && max.kind === "number") {
|
|
658
|
+
return parseFlat(spec, min.value + (max.value - min.value) * p);
|
|
659
|
+
}
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* The neutral value a flat value is drawn as, for one property. A value Cytoscape.js draws from the page (an `em`
|
|
664
|
+
* size, a node sized to its label) cannot be evaluated: it is noted and undefined is returned.
|
|
665
|
+
* @param spec - the property
|
|
666
|
+
* @param v - the flat value
|
|
667
|
+
* @param site - where it was read
|
|
668
|
+
* @returns the neutral value (for the combined parts, the Cytoscape.js word), or undefined
|
|
669
|
+
*/
|
|
670
|
+
export function cyjsNeutral(spec, v, site) {
|
|
671
|
+
switch (v.kind) {
|
|
672
|
+
case "color": {
|
|
673
|
+
if (v.rgb.some((c) => !Number.isFinite(c) || c < 0 || c > 255)) {
|
|
674
|
+
site.notes.add(STYLE_ISSUE.BAD_VALUE, site.target, site.property, {
|
|
675
|
+
sample: v.str,
|
|
676
|
+
element: site.element,
|
|
677
|
+
});
|
|
678
|
+
return undefined;
|
|
679
|
+
}
|
|
680
|
+
return `#${v.rgb.map((c) => Math.round(c).toString(16).padStart(2, "0")).join("")}`;
|
|
681
|
+
}
|
|
682
|
+
case "number":
|
|
683
|
+
if (v.units === "em") {
|
|
684
|
+
site.notes.add(STYLE_ISSUE.BAD_VALUE, site.target, site.property, {
|
|
685
|
+
sample: v.str,
|
|
686
|
+
element: site.element,
|
|
687
|
+
});
|
|
688
|
+
return undefined;
|
|
689
|
+
}
|
|
690
|
+
return num6(v.value);
|
|
691
|
+
default:
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
const word = v.value;
|
|
695
|
+
switch (spec.property) {
|
|
696
|
+
case "width":
|
|
697
|
+
case "height":
|
|
698
|
+
site.notes.add(STYLE_ISSUE.BAD_VALUE, site.target, site.property, { sample: v.str, element: site.element });
|
|
699
|
+
return undefined;
|
|
700
|
+
case "label":
|
|
701
|
+
case "sourceLabel":
|
|
702
|
+
case "targetLabel":
|
|
703
|
+
case "labelFont":
|
|
704
|
+
return String(word);
|
|
705
|
+
case "labelItalic":
|
|
706
|
+
return word === "italic" || word === "oblique";
|
|
707
|
+
case "curved":
|
|
708
|
+
return !STRAIGHT.has(String(word));
|
|
709
|
+
case "shape":
|
|
710
|
+
return canonEnum("shape", String(word), "cytoscape-js", site) ?? undefined;
|
|
711
|
+
case "borderStyle":
|
|
712
|
+
return canonEnum("borderStyle", String(word), "cytoscape-js", site) ?? undefined;
|
|
713
|
+
case "lineStyle":
|
|
714
|
+
return canonEnum("lineStyle", String(word), "cytoscape-js", site) ?? undefined;
|
|
715
|
+
case "sourceArrow":
|
|
716
|
+
case "targetArrow":
|
|
717
|
+
return canonEnum("arrow", String(word), "cytoscape-js", site) ?? undefined;
|
|
718
|
+
case "labelWeight":
|
|
719
|
+
return canonEnum("weight", String(word), "cytoscape-js", site) ?? undefined;
|
|
720
|
+
default:
|
|
721
|
+
return word;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* What a value a Cytoscape.js core reports for an element (`ele.style(name)`, always text) is drawn as.
|
|
726
|
+
* @param target - nodes or edges
|
|
727
|
+
* @param name - the Cytoscape.js property name
|
|
728
|
+
* @param str - the reported value
|
|
729
|
+
* @param site - where it was read
|
|
730
|
+
* @returns the neutral value (for the combined parts, the Cytoscape.js word), null when the property is not carried
|
|
731
|
+
* or the value does not parse, or undefined when it cannot be evaluated (noted)
|
|
732
|
+
*/
|
|
733
|
+
export function cyjsRendered(target, name, str, site) {
|
|
734
|
+
const spec = cyjsProperties(target).get(cyjsPropertyName(name));
|
|
735
|
+
if (spec === undefined || typeof str !== "string") {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
const v = parseFlat(spec, str, true);
|
|
739
|
+
if (v === null || v === CYJS_THROWS) {
|
|
740
|
+
return null;
|
|
741
|
+
}
|
|
742
|
+
return cyjsNeutral(spec, v, site);
|
|
743
|
+
}
|
|
744
|
+
//# sourceMappingURL=mappers.js.map
|