@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
package/dist/gml.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a8 as SYNTAX_CODE, p as plural, a as agree, ad as formatInteger, aP as formatGmlReal, R as ROLE_TAKEN_CODE$1, a7 as WIDENED_CODE$1, P as PRECISION_CODE$1, k as DUPLICATE_NODE_CODE$1, n as MISSING_ENDPOINT_CODE$1, o as MISSING_ID_CODE$1, i as MULTIPLE_GRAPHS_CODE, N as NO_GRAPH_CODE$1, Z as ImportReportBuilder, C as COLUMN_RENAMED_CODE, M as MIXED_DIRECTION_CODE, D as DIRECTION_FORCED_CODE, b as DIRECTION_REFUSED_CODE, S as SINK_OPTION_CODE, O as OPTION_IGNORED_CODE, I as ID_MERGED_CODE, a2 as AMBIGUOUS_GRAPH_NAME_CODE, a3 as GRAPH_NOT_FOUND_CODE, s as UNKNOWN_ENCODING_CODE, t as ENCODING_FALLBACK_CODE, u as INVALID_ENCODING_CODE, v as INVALID_UTF8_CODE, y as ELEMENT_ISSUE, z as INPUT_ISSUE } from "./chunks/format-BpQBx8MZ.js";
|
|
2
2
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
3
|
-
import { k as
|
|
3
|
+
import { c as capabilities, a as checkCapabilities, L as LOSS, p as pairFolding, G as sanitizeIds, ai as countMixedEdges, e as explicitWeights, r as resolveExportOptions, D as DictHeuristic, ag as DICT_SAMPLE_ROWS, g as resolveImportOptions, i as reportUnusedOptions, ab as readText, h as throwIfAborted, j as reportSinkOptions, k as graphChosen, I as IdCoercer, l as DirectionResolver, u as uniqueColumnName, w as weightFromValue, ak as reportWeightPrecision, s as parseWeightText, d as declareResolved } from "./chunks/export-BvqAXCKh.js";
|
|
4
|
+
import { n as decodeGmlString, o as quoteGmlString } from "./chunks/escape-CgzxiYPg.js";
|
|
4
5
|
import { j as joinText, e as encodeChunks } from "./chunks/writer-DxjgHwSe.js";
|
|
5
|
-
import {
|
|
6
|
+
import { y as yedValue, a as yedColor, b as yedSpelled, c as bendsToPoints, Y as YED_SHAPES, d as YED_LINES, v as valueColumns, e as canonBends, f as flowchartShape, F as FONT_STYLES, g as YED_ARROWS } from "./chunks/styles-yed-Cz9rLBCP.js";
|
|
7
|
+
import { w as writeStyleBlock, c as styleBlockLosses, t as StyleNotes, b as styleTag, p as plainCell, u as parseStyleBlock, s as styleFingerprint, v as blockStyles, o as canonText, r as resolveStyles, h as canonNumber, l as canonEnum, n as noteAt, M as MAX_STYLE_VALUE_LENGTH, a as STYLE_ISSUE, g as canonColor, x as colorOpacity, k as scalarText, S as STYLE_BLOCK_NAME } from "./chunks/block-CPCHkX42.js";
|
|
8
|
+
import { C as CYTOSCAPE_LEXICON } from "./chunks/lexicon-WMsNddyU.js";
|
|
9
|
+
import { S as StyleApproximations } from "./chunks/approximations-DJMHdDvv.js";
|
|
10
|
+
import { d as dataRead } from "./chunks/writer-gQ8kx99H.js";
|
|
11
|
+
import { r as gephiRules } from "./chunks/styles-DvoFBKCK.js";
|
|
12
|
+
import { i as importChosenGraph } from "./chunks/choose--jM0yYCo.js";
|
|
13
|
+
import { t as toolOf } from "./chunks/units-XMZFIFe1.js";
|
|
14
|
+
import { m as median } from "./chunks/convert-BcQ8_jMo.js";
|
|
6
15
|
const TOKEN_WORD = 0;
|
|
7
16
|
const TOKEN_INT = 1;
|
|
8
17
|
const TOKEN_REAL = 2;
|
|
@@ -45,6 +54,7 @@ class GmlTokens {
|
|
|
45
54
|
*/
|
|
46
55
|
constructor(text, capacity = 1024) {
|
|
47
56
|
this.count = 0;
|
|
57
|
+
this.backslashEscapes = false;
|
|
48
58
|
this.onUnknownEntity = null;
|
|
49
59
|
this.text = text;
|
|
50
60
|
this.kind = new Uint8Array(capacity);
|
|
@@ -88,6 +98,9 @@ class GmlTokens {
|
|
|
88
98
|
if (text.includes("\r")) {
|
|
89
99
|
text = text.replaceAll(/\r\n?/g, "\n");
|
|
90
100
|
}
|
|
101
|
+
if (this.backslashEscapes && text.includes("\\")) {
|
|
102
|
+
text = text.replaceAll(/\\([\s\S])/g, "$1");
|
|
103
|
+
}
|
|
91
104
|
if (!text.includes("&")) {
|
|
92
105
|
return text;
|
|
93
106
|
}
|
|
@@ -135,62 +148,95 @@ class GmlTokens {
|
|
|
135
148
|
}
|
|
136
149
|
function tokenizeGml(text) {
|
|
137
150
|
const tokens = new GmlTokens(text, Math.max(1024, text.length >>> 3));
|
|
138
|
-
|
|
151
|
+
tokens.backslashEscapes = writtenByOgdf(text);
|
|
152
|
+
const lex = { text, tokens, i: 0, line: 1, spanningLine: 0 };
|
|
153
|
+
while (lex.i < text.length) {
|
|
154
|
+
const c = text.codePointAt(lex.i) ?? 0;
|
|
155
|
+
if (c === 34) {
|
|
156
|
+
lexString(lex);
|
|
157
|
+
} else if (c === 91 || c === 93) {
|
|
158
|
+
tokens.push(c === 91 ? TOKEN_OPEN : TOKEN_CLOSE, lex.i, lex.i + 1, lex.line);
|
|
159
|
+
lex.i++;
|
|
160
|
+
} else if (!skipSpace(lex, c)) {
|
|
161
|
+
lexBare(lex);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
validateStructure(tokens);
|
|
165
|
+
return tokens;
|
|
166
|
+
}
|
|
167
|
+
function skipSpace(lex, c) {
|
|
168
|
+
const { text } = lex;
|
|
169
|
+
if (c === 10 || c === 13) {
|
|
170
|
+
lex.line++;
|
|
171
|
+
lex.i++;
|
|
172
|
+
if (c === 13 && lex.i < text.length && text.codePointAt(lex.i) === 10) {
|
|
173
|
+
lex.i++;
|
|
174
|
+
}
|
|
175
|
+
} else if (c === 32 || c === 9 || c === 11 || c === 12 || c === 65279) {
|
|
176
|
+
lex.i++;
|
|
177
|
+
} else if (c === 35) {
|
|
178
|
+
lex.i = endOfLine(text, lex.i);
|
|
179
|
+
} else {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
function lexString(lex) {
|
|
185
|
+
const { text, tokens, i } = lex;
|
|
186
|
+
const close = tokens.backslashEscapes ? escapedClose(text, i + 1) : text.indexOf('"', i + 1);
|
|
187
|
+
if (close < 0) {
|
|
188
|
+
const hint = lex.spanningLine === 0 ? "" : `; the string opened at line ${lex.spanningLine} spans lines, so a quote may be missing there`;
|
|
189
|
+
throw new GmlSyntaxError(SYNTAX_STRING_CODE, `unclosed string opened at line ${lex.line}${hint}`, lex.line);
|
|
190
|
+
}
|
|
191
|
+
tokens.push(TOKEN_STRING, i + 1, close, lex.line);
|
|
192
|
+
const opened = lex.line;
|
|
193
|
+
for (let k = i + 1; k < close; k++) {
|
|
194
|
+
const d = text.codePointAt(k);
|
|
195
|
+
if (d === 10 || d === 13 && text.codePointAt(k + 1) !== 10) {
|
|
196
|
+
lex.line++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (lex.line !== opened && lex.spanningLine === 0) {
|
|
200
|
+
lex.spanningLine = opened;
|
|
201
|
+
}
|
|
202
|
+
lex.i = close + 1;
|
|
203
|
+
}
|
|
204
|
+
function lexBare(lex) {
|
|
205
|
+
const { text, i } = lex;
|
|
206
|
+
let j = i + 1;
|
|
207
|
+
while (j < text.length && !isDelimiter(text.codePointAt(j) ?? 0)) {
|
|
208
|
+
j++;
|
|
209
|
+
}
|
|
210
|
+
lex.tokens.push(classifyBare(text, i, j, lex.line), i, j, lex.line);
|
|
211
|
+
lex.i = j;
|
|
212
|
+
}
|
|
213
|
+
function writtenByOgdf(text) {
|
|
214
|
+
const end = Math.min(text.length, 512);
|
|
139
215
|
let i = 0;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (c === 10) {
|
|
145
|
-
line++;
|
|
146
|
-
i++;
|
|
147
|
-
} else if (c === 13) {
|
|
148
|
-
line++;
|
|
149
|
-
i++;
|
|
150
|
-
if (i < n && text.charCodeAt(i) === 10) {
|
|
216
|
+
while (i < end) {
|
|
217
|
+
const c = text.codePointAt(i);
|
|
218
|
+
if (c === 35) {
|
|
219
|
+
while (i < end && text.codePointAt(i) !== 10 && text.codePointAt(i) !== 13) {
|
|
151
220
|
i++;
|
|
152
221
|
}
|
|
153
|
-
} else if (c === 32 || c === 9 || c ===
|
|
154
|
-
i++;
|
|
155
|
-
} else if (c === 65279) {
|
|
222
|
+
} else if (c === 32 || c === 9 || c === 10 || c === 13 || c === 12 || c === 11) {
|
|
156
223
|
i++;
|
|
157
|
-
} else if (c === 35) {
|
|
158
|
-
i = endOfLine(text, i);
|
|
159
|
-
} else if (c === 91) {
|
|
160
|
-
tokens.push(TOKEN_OPEN, i, i + 1, line);
|
|
161
|
-
i++;
|
|
162
|
-
} else if (c === 93) {
|
|
163
|
-
tokens.push(TOKEN_CLOSE, i, i + 1, line);
|
|
164
|
-
i++;
|
|
165
|
-
} else if (c === 34) {
|
|
166
|
-
const close = text.indexOf('"', i + 1);
|
|
167
|
-
if (close < 0) {
|
|
168
|
-
const hint = spanningLine === 0 ? "" : `; the string opened at line ${spanningLine} spans lines, so a quote may be missing there`;
|
|
169
|
-
throw new GmlSyntaxError(SYNTAX_STRING_CODE, `unclosed string opened at line ${line}${hint}`, line);
|
|
170
|
-
}
|
|
171
|
-
tokens.push(TOKEN_STRING, i + 1, close, line);
|
|
172
|
-
const opened = line;
|
|
173
|
-
for (let k = i + 1; k < close; k++) {
|
|
174
|
-
const d = text.codePointAt(k);
|
|
175
|
-
if (d === 10 || d === 13 && text.codePointAt(k + 1) !== 10) {
|
|
176
|
-
line++;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (line !== opened && spanningLine === 0) {
|
|
180
|
-
spanningLine = opened;
|
|
181
|
-
}
|
|
182
|
-
i = close + 1;
|
|
183
224
|
} else {
|
|
184
|
-
|
|
185
|
-
while (j < n && !isDelimiter(text.charCodeAt(j))) {
|
|
186
|
-
j++;
|
|
187
|
-
}
|
|
188
|
-
tokens.push(classifyBare(text, i, j, line), i, j, line);
|
|
189
|
-
i = j;
|
|
225
|
+
break;
|
|
190
226
|
}
|
|
191
227
|
}
|
|
192
|
-
|
|
193
|
-
|
|
228
|
+
return /^Creator\s+"ogdf::/.test(text.slice(i, i + 64));
|
|
229
|
+
}
|
|
230
|
+
function escapedClose(text, from) {
|
|
231
|
+
let k = from;
|
|
232
|
+
while (k < text.length) {
|
|
233
|
+
const c = text.codePointAt(k);
|
|
234
|
+
if (c === 34) {
|
|
235
|
+
return k;
|
|
236
|
+
}
|
|
237
|
+
k += c === 92 ? 2 : 1;
|
|
238
|
+
}
|
|
239
|
+
return -1;
|
|
194
240
|
}
|
|
195
241
|
function endOfLine(text, from) {
|
|
196
242
|
const n = text.length;
|
|
@@ -258,15 +304,8 @@ function validateStructure(tokens) {
|
|
|
258
304
|
tokens.line[i]
|
|
259
305
|
);
|
|
260
306
|
}
|
|
261
|
-
|
|
262
|
-
if (vk === TOKEN_OPEN) {
|
|
307
|
+
if (checkValue(tokens, i) === TOKEN_OPEN) {
|
|
263
308
|
stack.push(value);
|
|
264
|
-
} else if (vk === TOKEN_CLOSE || vk === TOKEN_WORD && !NON_FINITE_WORD.test(tokens.textOf(value))) {
|
|
265
|
-
throw new GmlSyntaxError(
|
|
266
|
-
SYNTAX_STRUCTURE_CODE,
|
|
267
|
-
`expected a value for key "${tokens.textOf(i)}" at line ${tokens.line[i]}, found ${describeToken(tokens, value)}`,
|
|
268
|
-
tokens.line[value]
|
|
269
|
-
);
|
|
270
309
|
}
|
|
271
310
|
i = value + 1;
|
|
272
311
|
}
|
|
@@ -280,6 +319,23 @@ function validateStructure(tokens) {
|
|
|
280
319
|
}
|
|
281
320
|
tokens.match = match;
|
|
282
321
|
}
|
|
322
|
+
function checkValue(tokens, key) {
|
|
323
|
+
const { kind } = tokens;
|
|
324
|
+
const value = key + 1;
|
|
325
|
+
const word = kind[value] === TOKEN_WORD && !NON_FINITE_WORD.test(tokens.textOf(value));
|
|
326
|
+
if (word && tokens.textOf(key) === "Creator") {
|
|
327
|
+
kind[value] = TOKEN_STRING;
|
|
328
|
+
return TOKEN_STRING;
|
|
329
|
+
}
|
|
330
|
+
if (kind[value] === TOKEN_CLOSE || word) {
|
|
331
|
+
throw new GmlSyntaxError(
|
|
332
|
+
SYNTAX_STRUCTURE_CODE,
|
|
333
|
+
`expected a value for key "${tokens.textOf(key)}" at line ${tokens.line[key]}, found ${describeToken(tokens, value)}`,
|
|
334
|
+
tokens.line[value]
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return kind[value];
|
|
338
|
+
}
|
|
283
339
|
function describeToken(tokens, i) {
|
|
284
340
|
switch (tokens.kind[i]) {
|
|
285
341
|
case TOKEN_OPEN:
|
|
@@ -305,6 +361,7 @@ function numberOfText(text) {
|
|
|
305
361
|
function isGmlKey(text) {
|
|
306
362
|
return STRICT_KEY_TEXT.test(text);
|
|
307
363
|
}
|
|
364
|
+
const KEY_MANGLED_CODE = "W_GML_KEY_MANGLED";
|
|
308
365
|
function mangleGmlKey(text) {
|
|
309
366
|
const body = text.replaceAll(/\W/g, "_");
|
|
310
367
|
return /^[A-Za-z]/.test(body) ? body : `x${body}`;
|
|
@@ -367,6 +424,758 @@ function storeValue(frame, key, value) {
|
|
|
367
424
|
function scalarOrRecord(tokens, v) {
|
|
368
425
|
return tokens.kind[v] === TOKEN_OPEN ? parseRecord(tokens, v) : numberOfText(tokens.textOf(v));
|
|
369
426
|
}
|
|
427
|
+
const WRITERS = [
|
|
428
|
+
[
|
|
429
|
+
/^\s*(yfiles|yed)\b/i,
|
|
430
|
+
{ dialect: "yed", tool: "yed", vocabulary: "yed", spelling: "yed", units: "px", labelKey: false }
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
/^\s*cytoscape\b/i,
|
|
434
|
+
{
|
|
435
|
+
dialect: "cytoscape",
|
|
436
|
+
tool: "cytoscape",
|
|
437
|
+
vocabulary: "cytoscape",
|
|
438
|
+
spelling: "cytoscape",
|
|
439
|
+
units: "px",
|
|
440
|
+
labelKey: true
|
|
441
|
+
}
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
/^\s*gephi\b/i,
|
|
445
|
+
{
|
|
446
|
+
dialect: "gephi",
|
|
447
|
+
tool: "gephi",
|
|
448
|
+
vocabulary: "graphlet",
|
|
449
|
+
spelling: "css",
|
|
450
|
+
units: "relative",
|
|
451
|
+
labelKey: false
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
[
|
|
455
|
+
/^\s*ogdf::/i,
|
|
456
|
+
{ dialect: "ogdf", tool: "ogdf", vocabulary: "ogdf", spelling: "css", units: "px", labelKey: true }
|
|
457
|
+
],
|
|
458
|
+
// igraph writes a Creator line, but no drawing defaults of igraph's are stated by a primary source
|
|
459
|
+
[
|
|
460
|
+
/^\s*igraph\b/i,
|
|
461
|
+
{ dialect: "igraph", tool: null, vocabulary: "graphlet", spelling: "css", units: "px", labelKey: true }
|
|
462
|
+
]
|
|
463
|
+
];
|
|
464
|
+
const UNKNOWN_WRITER = {
|
|
465
|
+
dialect: "gml",
|
|
466
|
+
tool: null,
|
|
467
|
+
vocabulary: "graphlet",
|
|
468
|
+
spelling: "css",
|
|
469
|
+
units: "px",
|
|
470
|
+
labelKey: true
|
|
471
|
+
};
|
|
472
|
+
const GRAPHTY_WRITER = { ...WRITERS[0][1], tool: null };
|
|
473
|
+
const GML_STYLE_BLOCK_KEY = mangleGmlKey(STYLE_BLOCK_NAME);
|
|
474
|
+
const TAG_PREFIX = mangleGmlKey("graphty.style.");
|
|
475
|
+
function tagKey(target, key) {
|
|
476
|
+
return mangleGmlKey(styleTag(target, key));
|
|
477
|
+
}
|
|
478
|
+
function graphText(snapshot, name) {
|
|
479
|
+
if (!snapshot.graph.has(name)) {
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
const v = plainCell(snapshot.graph.value(name, 0));
|
|
483
|
+
if (typeof v === "string") {
|
|
484
|
+
return v;
|
|
485
|
+
}
|
|
486
|
+
return typeof v === "number" ? String(v) : null;
|
|
487
|
+
}
|
|
488
|
+
function writerOf(snapshot) {
|
|
489
|
+
if (snapshot.graph.has(GML_STYLE_BLOCK_KEY)) {
|
|
490
|
+
return GRAPHTY_WRITER;
|
|
491
|
+
}
|
|
492
|
+
const creator = snapshot.meta.creator ?? graphText(snapshot, "Creator") ?? "";
|
|
493
|
+
for (const [pattern, writer] of WRITERS) {
|
|
494
|
+
if (pattern.test(creator)) {
|
|
495
|
+
return writer;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return UNKNOWN_WRITER;
|
|
499
|
+
}
|
|
500
|
+
const ARROW_ENDS = /* @__PURE__ */ new Map([
|
|
501
|
+
["none", ["none", "none"]],
|
|
502
|
+
["last", ["none", "triangle"]],
|
|
503
|
+
["first", ["triangle", "none"]],
|
|
504
|
+
["both", ["triangle", "triangle"]]
|
|
505
|
+
]);
|
|
506
|
+
const OGDF_STROKES = ["none", "solid", "dashed", "dotted", "dash-dot", "dash-dot"];
|
|
507
|
+
const OGDF_SHAPES = /* @__PURE__ */ new Map([
|
|
508
|
+
["rect", "rectangle"],
|
|
509
|
+
["rhomb", "diamond"],
|
|
510
|
+
["trapeze", "trapezoid"],
|
|
511
|
+
["invtrapeze", "trapezoid"],
|
|
512
|
+
["invtriangle", "triangle"],
|
|
513
|
+
["invparallelogram", "parallelogram"]
|
|
514
|
+
]);
|
|
515
|
+
const YED_LABEL_KEYS = [
|
|
516
|
+
"outline",
|
|
517
|
+
"autoSizePolicy",
|
|
518
|
+
"model",
|
|
519
|
+
"configuration",
|
|
520
|
+
"borderDistance",
|
|
521
|
+
"modelName",
|
|
522
|
+
"modelPosition"
|
|
523
|
+
];
|
|
524
|
+
const cytoscapeArrow = CYTOSCAPE_LEXICON.edge.get("targetArrow")?.[0]?.[1];
|
|
525
|
+
function sampleOf(raw) {
|
|
526
|
+
return typeof raw === "string" || typeof raw === "number" ? String(raw).slice(0, MAX_STYLE_VALUE_LENGTH) : "a record";
|
|
527
|
+
}
|
|
528
|
+
function isRec(v) {
|
|
529
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
530
|
+
}
|
|
531
|
+
function first(r, ...keys) {
|
|
532
|
+
for (const k of keys) {
|
|
533
|
+
if (Object.hasOwn(r, k) && r[k] !== void 0) {
|
|
534
|
+
return r[k];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return void 0;
|
|
538
|
+
}
|
|
539
|
+
function readColor(raw, property, opacity, writer, put, at) {
|
|
540
|
+
if (raw === void 0) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const c = canonColor(raw, writer.spelling, at(property));
|
|
544
|
+
if (c === null) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
put(property, c.color);
|
|
548
|
+
const alpha = colorOpacity(c, null, at(property), opacity !== null);
|
|
549
|
+
if (opacity !== null) {
|
|
550
|
+
put(opacity, alpha);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function strokeStyle(raw, kind, writer, at) {
|
|
554
|
+
if (raw === void 0) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
if (writer.vocabulary === "ogdf") {
|
|
558
|
+
const stroke = OGDF_STROKES[Number(raw)];
|
|
559
|
+
if (stroke === void 0 || stroke === "none") {
|
|
560
|
+
noteAt(at, STYLE_ISSUE.UNKNOWN_VALUE, sampleOf(raw));
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
return stroke;
|
|
564
|
+
}
|
|
565
|
+
return canonEnum(kind, raw, writer.spelling, at);
|
|
566
|
+
}
|
|
567
|
+
function readNodeGraphics(g, writer, put, at) {
|
|
568
|
+
const v = writer.vocabulary;
|
|
569
|
+
readNodeFill(g, writer, put, at);
|
|
570
|
+
readNodeOutline(g, writer, put, at);
|
|
571
|
+
put(
|
|
572
|
+
"borderStyle",
|
|
573
|
+
strokeStyle(v === "ogdf" ? g.stipple : g.outlineStyle, "borderStyle", writer, at("borderStyle"))
|
|
574
|
+
);
|
|
575
|
+
put("width", g.w === void 0 ? null : canonNumber(g.w, at("width")));
|
|
576
|
+
put("height", g.h === void 0 ? null : canonNumber(g.h, at("height")));
|
|
577
|
+
if (g.type !== void 0) {
|
|
578
|
+
const raw = v === "ogdf" && typeof g.type === "string" ? OGDF_SHAPES.get(g.type.toLowerCase()) ?? g.type : g.type;
|
|
579
|
+
put("shape", canonEnum("shape", raw, writer.spelling, at("shape")));
|
|
580
|
+
} else if (v === "yed" && typeof g.customconfiguration === "string") {
|
|
581
|
+
put("shape", flowchartShape(g.customconfiguration));
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
function readNodeFill(g, writer, put, at) {
|
|
585
|
+
if (writer.vocabulary === "yed" && Number(g.hasFill) === 0) {
|
|
586
|
+
noteAt(at("fill"), STYLE_ISSUE.NO_FILL, "hasFill 0");
|
|
587
|
+
put("fillOpacity", 0);
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
readColor(g.fill, "fill", "fillOpacity", writer, put, at);
|
|
591
|
+
if (g.fill2 !== void 0) {
|
|
592
|
+
noteAt(at("fill"), STYLE_ISSUE.GRADIENT, sampleOf(g.fill2));
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function readNodeOutline(g, writer, put, at) {
|
|
596
|
+
const v = writer.vocabulary;
|
|
597
|
+
if (v === "yed" && Number(g.hasOutline) === 0) {
|
|
598
|
+
put("borderWidth", 0);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
readColor(v === "ogdf" ? g.line : g.outline, "borderColor", null, writer, put, at);
|
|
602
|
+
const width = outlineWidthOf(g, v);
|
|
603
|
+
put("borderWidth", width === void 0 ? null : canonNumber(width, at("borderWidth")));
|
|
604
|
+
}
|
|
605
|
+
function outlineWidthOf(g, v) {
|
|
606
|
+
switch (v) {
|
|
607
|
+
case "yed":
|
|
608
|
+
return g.outlineWidth;
|
|
609
|
+
case "cytoscape":
|
|
610
|
+
return first(g, "outline_width", "width");
|
|
611
|
+
case "ogdf":
|
|
612
|
+
return g.lineWidth;
|
|
613
|
+
default:
|
|
614
|
+
return first(g, "width", "outlineWidth");
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function readEdgeGraphics(g, writer, put, at) {
|
|
618
|
+
const v = writer.vocabulary;
|
|
619
|
+
readColor(g.fill, "color", "opacity", writer, put, at);
|
|
620
|
+
const width = v === "ogdf" ? first(g, "lineWidth", "width") : g.width;
|
|
621
|
+
put("width", width === void 0 ? null : canonNumber(width, at("width")));
|
|
622
|
+
put("lineStyle", strokeStyle(v === "ogdf" ? g.stipple : g.style, "lineStyle", writer, at("lineStyle")));
|
|
623
|
+
if (typeof g.arrow === "string") {
|
|
624
|
+
const ends = ARROW_ENDS.get(g.arrow.trim().toLowerCase());
|
|
625
|
+
if (ends === void 0) {
|
|
626
|
+
noteAt(at("targetArrow"), STYLE_ISSUE.UNKNOWN_VALUE, g.arrow.slice(0, MAX_STYLE_VALUE_LENGTH));
|
|
627
|
+
} else {
|
|
628
|
+
put("sourceArrow", ends[0]);
|
|
629
|
+
put("targetArrow", ends[1]);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
for (const [keys, property] of [
|
|
633
|
+
[["sourceArrow", "source_arrow"], "sourceArrow"],
|
|
634
|
+
[["targetArrow", "target_arrow"], "targetArrow"]
|
|
635
|
+
]) {
|
|
636
|
+
const raw = first(g, ...keys);
|
|
637
|
+
if (raw === void 0) {
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
put(
|
|
641
|
+
property,
|
|
642
|
+
v === "cytoscape" && cytoscapeArrow !== void 0 ? cytoscapeArrow(raw, at(property)) : canonEnum("arrow", raw, writer.spelling, at(property))
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
if (v === "yed") {
|
|
646
|
+
readYedCurve(g, put);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function readYedCurve(g, put) {
|
|
650
|
+
if (g.smoothBends !== void 0) {
|
|
651
|
+
const points = isRec(g.Line) ? g.Line.point : void 0;
|
|
652
|
+
put("curved", Number(g.smoothBends) === 1 && Array.isArray(points) && points.length > 2);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function readLabelGraphics(raw, writer, put, at) {
|
|
656
|
+
const visible = (Array.isArray(raw) ? raw : [raw]).filter((l) => isRec(l) && Number(l.visible) !== 0);
|
|
657
|
+
const lg = visible.at(0);
|
|
658
|
+
if (lg === void 0) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const extra = visible.slice(1).filter((l) => l.text !== void 0).length;
|
|
662
|
+
if (extra > 0) {
|
|
663
|
+
noteAt(at("label"), STYLE_ISSUE.EXTRA_LABELS, `${String(extra + 1)} labels`);
|
|
664
|
+
}
|
|
665
|
+
if (lg.text !== void 0) {
|
|
666
|
+
put("label", canonText(lg.text, at("label")));
|
|
667
|
+
}
|
|
668
|
+
const yedLabel = writer.vocabulary === "yed" || YED_LABEL_KEYS.some((k) => Object.hasOwn(lg, k));
|
|
669
|
+
if (lg.color !== void 0) {
|
|
670
|
+
readColor(lg.color, "labelColor", null, writer, put, at);
|
|
671
|
+
} else if (lg.fill !== void 0 && !yedLabel) {
|
|
672
|
+
readColor(lg.fill, "labelColor", null, writer, put, at);
|
|
673
|
+
}
|
|
674
|
+
if (lg.fill !== void 0 && yedLabel) {
|
|
675
|
+
noteAt(at("label"), STYLE_ISSUE.NOT_CARRIED, "label background");
|
|
676
|
+
}
|
|
677
|
+
readLabelFont(lg, put, at);
|
|
678
|
+
}
|
|
679
|
+
function readLabelFont(lg, put, at) {
|
|
680
|
+
put("labelSize", lg.fontSize === void 0 ? null : canonNumber(lg.fontSize, at("labelSize")));
|
|
681
|
+
put("labelFont", lg.fontName === void 0 ? null : canonText(lg.fontName, at("labelFont")));
|
|
682
|
+
const style = scalarText(lg.fontStyle, at("labelWeight"))?.trim().toLowerCase();
|
|
683
|
+
if (style !== void 0) {
|
|
684
|
+
const known = FONT_STYLES.get(style);
|
|
685
|
+
if (known === void 0) {
|
|
686
|
+
noteAt(at("labelWeight"), STYLE_ISSUE.UNKNOWN_VALUE, style.slice(0, MAX_STYLE_VALUE_LENGTH));
|
|
687
|
+
} else {
|
|
688
|
+
put("labelWeight", known[0]);
|
|
689
|
+
put("labelItalic", known[1]);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function readElement(target, g, lg, label, writer, put, at) {
|
|
694
|
+
let text = false;
|
|
695
|
+
const putLabel = (property, value) => {
|
|
696
|
+
text ||= property === "label" && value !== null;
|
|
697
|
+
put(property, value);
|
|
698
|
+
};
|
|
699
|
+
if (isRec(g)) {
|
|
700
|
+
(target === "node" ? readNodeGraphics : readEdgeGraphics)(g, writer, put, at);
|
|
701
|
+
}
|
|
702
|
+
if (lg !== null && lg !== void 0) {
|
|
703
|
+
readLabelGraphics(lg, writer, putLabel, at);
|
|
704
|
+
}
|
|
705
|
+
const drawn = writer.vocabulary === "cytoscape" ? target === "node" : writer.labelKey && (isRec(g) || lg !== void 0);
|
|
706
|
+
if (!text && drawn && label !== null && label !== void 0) {
|
|
707
|
+
put("label", canonText(label, at("label")));
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function cellOf(table, name, i) {
|
|
711
|
+
if (!table.has(name)) {
|
|
712
|
+
return void 0;
|
|
713
|
+
}
|
|
714
|
+
const v = plainCell(table.value(name, i));
|
|
715
|
+
return v ?? void 0;
|
|
716
|
+
}
|
|
717
|
+
function centerOf(snapshot, i) {
|
|
718
|
+
const column = snapshot.nodes.byRole("position");
|
|
719
|
+
const v = column?.isSet(i) === true ? column.value(i) : null;
|
|
720
|
+
return v === null ? [Number.NaN, Number.NaN] : [v[0], v[1]];
|
|
721
|
+
}
|
|
722
|
+
function lineBends(snapshot, g, e) {
|
|
723
|
+
const raw = isRec(g) && isRec(g.Line) ? g.Line.point : void 0;
|
|
724
|
+
if (!Array.isArray(raw) || raw.length < 3) {
|
|
725
|
+
return null;
|
|
726
|
+
}
|
|
727
|
+
const points = raw.slice(1, -1).map((p) => isRec(p) ? [Number(p.x), Number(p.y)] : [Number.NaN, 0]);
|
|
728
|
+
return canonBends(
|
|
729
|
+
centerOf(snapshot, snapshot.edgeSource(e)),
|
|
730
|
+
centerOf(snapshot, snapshot.edgeTarget(e)),
|
|
731
|
+
points
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
function readValues(snapshot, writer, notes, context) {
|
|
735
|
+
let found = false;
|
|
736
|
+
const read = (target) => {
|
|
737
|
+
const table = target === "node" ? snapshot.nodes : snapshot.edges;
|
|
738
|
+
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
739
|
+
const out = valueColumns(n);
|
|
740
|
+
if (!table.has("graphics") && !table.has("LabelGraphics") && writer.vocabulary !== "cytoscape") {
|
|
741
|
+
return out.values;
|
|
742
|
+
}
|
|
743
|
+
for (let i = 0; i < n; i++) {
|
|
744
|
+
context.budget.spend(target, 1);
|
|
745
|
+
const at = (property) => ({ notes, target, property, element: i, budget: context.budget });
|
|
746
|
+
readElement(
|
|
747
|
+
target,
|
|
748
|
+
cellOf(table, "graphics", i),
|
|
749
|
+
cellOf(table, "LabelGraphics", i),
|
|
750
|
+
cellOf(table, "label", i),
|
|
751
|
+
writer,
|
|
752
|
+
(property, value) => {
|
|
753
|
+
if (value !== null) {
|
|
754
|
+
found = true;
|
|
755
|
+
out.put(i, property, value);
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
at
|
|
759
|
+
);
|
|
760
|
+
if (target === "edge") {
|
|
761
|
+
const bends = lineBends(snapshot, cellOf(table, "graphics", i), i);
|
|
762
|
+
if (bends !== null) {
|
|
763
|
+
found = true;
|
|
764
|
+
out.put(i, "bends", bends);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return out.values;
|
|
769
|
+
};
|
|
770
|
+
const node = read("node");
|
|
771
|
+
const edge = read("edge");
|
|
772
|
+
return { node, edge, found };
|
|
773
|
+
}
|
|
774
|
+
function blockWithValues(snapshot, text) {
|
|
775
|
+
const parsed = parseStyleBlock(text, styleFingerprint(snapshot));
|
|
776
|
+
if (!parsed.ok || parsed.block.values !== void 0) {
|
|
777
|
+
return text;
|
|
778
|
+
}
|
|
779
|
+
const node = tagValues(snapshot, "node", parsed.block.columns.node);
|
|
780
|
+
const edge = tagValues(snapshot, "edge", parsed.block.columns.edge);
|
|
781
|
+
if (node === null || edge === null) {
|
|
782
|
+
return text;
|
|
783
|
+
}
|
|
784
|
+
const raw = JSON.parse(text);
|
|
785
|
+
return JSON.stringify({ ...raw, values: { node, edge } });
|
|
786
|
+
}
|
|
787
|
+
function tagValues(snapshot, target, keys) {
|
|
788
|
+
const table = target === "node" ? snapshot.nodes : snapshot.edges;
|
|
789
|
+
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
790
|
+
const values = {};
|
|
791
|
+
for (const key of keys) {
|
|
792
|
+
const name = tagKey(target, key);
|
|
793
|
+
if (!table.has(name)) {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
values[key] = Array.from({ length: n }, (_, i) => {
|
|
797
|
+
const v = plainCell(table.value(name, i));
|
|
798
|
+
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? v : null;
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
return values;
|
|
802
|
+
}
|
|
803
|
+
function styleColumns(table) {
|
|
804
|
+
return [...table.names()].filter((c) => c === "graphics" || c === "LabelGraphics" || c.startsWith(TAG_PREFIX));
|
|
805
|
+
}
|
|
806
|
+
function gmlStyles(snapshot, context) {
|
|
807
|
+
const notes = new StyleNotes();
|
|
808
|
+
const writer = writerOf(snapshot);
|
|
809
|
+
const values = readValues(snapshot, writer, notes, context);
|
|
810
|
+
const blockText = graphText(snapshot, GML_STYLE_BLOCK_KEY);
|
|
811
|
+
const block = blockText === null ? null : blockWithValues(snapshot, blockText);
|
|
812
|
+
if (block !== null) {
|
|
813
|
+
exactFromBlock(snapshot, block, values);
|
|
814
|
+
}
|
|
815
|
+
if (writer.tool === null && !values.found && block === null) {
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
const gephi = writer.tool === "gephi" ? gephiRules(snapshot, values.node.fill, values.edge.color, context.budget, values.edge.width) : { rules: [], columns: /* @__PURE__ */ new Map() };
|
|
819
|
+
return {
|
|
820
|
+
canonical: true,
|
|
821
|
+
dialect: writer.dialect,
|
|
822
|
+
tool: writer.tool,
|
|
823
|
+
units: writer.units,
|
|
824
|
+
node: { values: values.node },
|
|
825
|
+
edge: { values: values.edge, rules: gephi.rules, columns: gephi.columns },
|
|
826
|
+
notes: notes.list(),
|
|
827
|
+
opacityInColor: true,
|
|
828
|
+
block,
|
|
829
|
+
// the graphics records and the per-element style values of a file graphty wrote hold styles, not data
|
|
830
|
+
readFrom: { node: styleColumns(snapshot.nodes), edge: styleColumns(snapshot.edges) }
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
const GML_STYLE_CAPABILITIES = Object.freeze({
|
|
834
|
+
node: Object.freeze([
|
|
835
|
+
"fill",
|
|
836
|
+
"fillOpacity",
|
|
837
|
+
"borderColor",
|
|
838
|
+
"borderWidth",
|
|
839
|
+
"borderStyle",
|
|
840
|
+
"shape",
|
|
841
|
+
"width",
|
|
842
|
+
"height",
|
|
843
|
+
"label",
|
|
844
|
+
"labelColor",
|
|
845
|
+
"labelSize",
|
|
846
|
+
"labelFont",
|
|
847
|
+
"labelWeight",
|
|
848
|
+
"labelItalic"
|
|
849
|
+
]),
|
|
850
|
+
edge: Object.freeze([
|
|
851
|
+
"color",
|
|
852
|
+
"opacity",
|
|
853
|
+
"width",
|
|
854
|
+
"lineStyle",
|
|
855
|
+
"sourceArrow",
|
|
856
|
+
"targetArrow",
|
|
857
|
+
"curved",
|
|
858
|
+
"bends",
|
|
859
|
+
"label",
|
|
860
|
+
"labelColor",
|
|
861
|
+
"labelSize",
|
|
862
|
+
"labelFont",
|
|
863
|
+
"labelWeight",
|
|
864
|
+
"labelItalic"
|
|
865
|
+
]),
|
|
866
|
+
block: "native"
|
|
867
|
+
});
|
|
868
|
+
const OWNED = {
|
|
869
|
+
node: /* @__PURE__ */ new Set([
|
|
870
|
+
"fill",
|
|
871
|
+
"fill2",
|
|
872
|
+
"hasFill",
|
|
873
|
+
"outline",
|
|
874
|
+
"hasOutline",
|
|
875
|
+
"outlineWidth",
|
|
876
|
+
"outline_width",
|
|
877
|
+
"outlineStyle",
|
|
878
|
+
"width",
|
|
879
|
+
"line",
|
|
880
|
+
"lineWidth",
|
|
881
|
+
"stipple",
|
|
882
|
+
"w",
|
|
883
|
+
"h",
|
|
884
|
+
"type"
|
|
885
|
+
]),
|
|
886
|
+
edge: /* @__PURE__ */ new Set([
|
|
887
|
+
"fill",
|
|
888
|
+
"width",
|
|
889
|
+
"lineWidth",
|
|
890
|
+
"style",
|
|
891
|
+
"stipple",
|
|
892
|
+
"arrow",
|
|
893
|
+
"sourceArrow",
|
|
894
|
+
"targetArrow",
|
|
895
|
+
"source_arrow",
|
|
896
|
+
"target_arrow",
|
|
897
|
+
"smoothBends"
|
|
898
|
+
]),
|
|
899
|
+
label: /* @__PURE__ */ new Set(["text", "color", "fill", "fontSize", "fontName", "fontStyle", "visible"])
|
|
900
|
+
};
|
|
901
|
+
function nodeGraphics(get, approximate) {
|
|
902
|
+
const g = {};
|
|
903
|
+
const width = get("width");
|
|
904
|
+
const height = get("height");
|
|
905
|
+
if (typeof width === "number") {
|
|
906
|
+
g.w = width;
|
|
907
|
+
}
|
|
908
|
+
if (typeof height === "number") {
|
|
909
|
+
g.h = height;
|
|
910
|
+
}
|
|
911
|
+
const shape = get("shape");
|
|
912
|
+
if (typeof shape === "string") {
|
|
913
|
+
const w = yedValue(YED_SHAPES, shape, shape === "vee" ? "triangle" : "rectangle");
|
|
914
|
+
if (!w.exact) {
|
|
915
|
+
approximate("shape", shape);
|
|
916
|
+
}
|
|
917
|
+
g.type = w.value;
|
|
918
|
+
}
|
|
919
|
+
const fill = get("fill");
|
|
920
|
+
const fillOpacity = get("fillOpacity");
|
|
921
|
+
if (typeof fill === "string") {
|
|
922
|
+
g.fill = yedColor(fill, fillOpacity);
|
|
923
|
+
} else if (fillOpacity === 0) {
|
|
924
|
+
g.hasFill = 0;
|
|
925
|
+
}
|
|
926
|
+
const borderColor = get("borderColor");
|
|
927
|
+
const borderWidth = get("borderWidth");
|
|
928
|
+
const borderStyle = get("borderStyle");
|
|
929
|
+
if (typeof borderColor === "string") {
|
|
930
|
+
g.outline = borderColor.toUpperCase();
|
|
931
|
+
}
|
|
932
|
+
if (typeof borderStyle === "string") {
|
|
933
|
+
const w = yedValue(YED_LINES, borderStyle, "line");
|
|
934
|
+
if (!w.exact) {
|
|
935
|
+
approximate("borderStyle", borderStyle);
|
|
936
|
+
}
|
|
937
|
+
g.outlineStyle = w.value;
|
|
938
|
+
}
|
|
939
|
+
if (borderWidth === 0) {
|
|
940
|
+
g.hasOutline = 0;
|
|
941
|
+
} else if (typeof borderWidth === "number") {
|
|
942
|
+
g.outlineWidth = borderWidth;
|
|
943
|
+
}
|
|
944
|
+
return g;
|
|
945
|
+
}
|
|
946
|
+
function edgeGraphics(get, approximate) {
|
|
947
|
+
const g = {};
|
|
948
|
+
const color = get("color");
|
|
949
|
+
if (typeof color === "string") {
|
|
950
|
+
g.fill = yedColor(color, get("opacity"));
|
|
951
|
+
}
|
|
952
|
+
const width = get("width");
|
|
953
|
+
if (typeof width === "number") {
|
|
954
|
+
g.width = width;
|
|
955
|
+
}
|
|
956
|
+
const lineStyle = get("lineStyle");
|
|
957
|
+
if (typeof lineStyle === "string") {
|
|
958
|
+
g.style = yedSpelled(
|
|
959
|
+
YED_LINES,
|
|
960
|
+
lineStyle,
|
|
961
|
+
lineStyle === "long-dash" ? "dashed" : "line",
|
|
962
|
+
"lineStyle",
|
|
963
|
+
approximate
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
for (const property of ["sourceArrow", "targetArrow"]) {
|
|
967
|
+
const arrow = get(property);
|
|
968
|
+
if (typeof arrow === "string") {
|
|
969
|
+
g[property] = yedSpelled(YED_ARROWS, arrow, "standard", property, approximate);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
const curved = get("curved");
|
|
973
|
+
if (typeof curved === "boolean") {
|
|
974
|
+
g.smoothBends = curved ? 1 : 0;
|
|
975
|
+
}
|
|
976
|
+
return g;
|
|
977
|
+
}
|
|
978
|
+
function labelGraphics(get) {
|
|
979
|
+
const text = get("label");
|
|
980
|
+
if (typeof text !== "string" || text.trim().length === 0) {
|
|
981
|
+
return null;
|
|
982
|
+
}
|
|
983
|
+
const lg = { text };
|
|
984
|
+
const color = get("labelColor");
|
|
985
|
+
if (typeof color === "string") {
|
|
986
|
+
lg.color = color.toUpperCase();
|
|
987
|
+
}
|
|
988
|
+
const size = get("labelSize");
|
|
989
|
+
if (typeof size === "number") {
|
|
990
|
+
lg.fontSize = size;
|
|
991
|
+
}
|
|
992
|
+
const font = get("labelFont");
|
|
993
|
+
if (typeof font === "string") {
|
|
994
|
+
lg.fontName = font;
|
|
995
|
+
}
|
|
996
|
+
const weight = get("labelWeight");
|
|
997
|
+
const italic = get("labelItalic");
|
|
998
|
+
if (weight !== null || italic !== null) {
|
|
999
|
+
const style = (weight === "bold" ? "bold" : "") + (italic === true ? "italic" : "");
|
|
1000
|
+
lg.fontStyle = style.length === 0 ? "plain" : style;
|
|
1001
|
+
}
|
|
1002
|
+
return lg;
|
|
1003
|
+
}
|
|
1004
|
+
function merged(old, owned, written) {
|
|
1005
|
+
const out = {};
|
|
1006
|
+
if (isRec(old)) {
|
|
1007
|
+
for (const [k, v] of Object.entries(old)) {
|
|
1008
|
+
if (!owned.has(k)) {
|
|
1009
|
+
out[k] = v;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
Object.assign(out, written);
|
|
1014
|
+
return Object.keys(out).length === 0 ? void 0 : out;
|
|
1015
|
+
}
|
|
1016
|
+
function mergedLabels(old, written) {
|
|
1017
|
+
const labels = Array.isArray(old) ? old : [old];
|
|
1018
|
+
const head = merged(labels[0], OWNED.label, written ?? {});
|
|
1019
|
+
const rest = labels.slice(1).filter((l) => l !== null && l !== void 0);
|
|
1020
|
+
if (rest.length === 0) {
|
|
1021
|
+
return head;
|
|
1022
|
+
}
|
|
1023
|
+
return head === void 0 ? rest : [head, ...rest];
|
|
1024
|
+
}
|
|
1025
|
+
function getter(picture, target) {
|
|
1026
|
+
const columns = /* @__PURE__ */ new Map();
|
|
1027
|
+
for (const p of GML_STYLE_CAPABILITIES[target]) {
|
|
1028
|
+
columns.set(p, picture(target, p));
|
|
1029
|
+
}
|
|
1030
|
+
return (i) => (property) => columns.get(property)?.[i] ?? null;
|
|
1031
|
+
}
|
|
1032
|
+
function exactFromBlock(snapshot, text, read) {
|
|
1033
|
+
const parsed = parseStyleBlock(text, styleFingerprint(snapshot));
|
|
1034
|
+
const ex = parsed.ok ? blockStyles(parsed.block, snapshot, "gml") : null;
|
|
1035
|
+
if (ex === null) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const notes = new StyleNotes();
|
|
1039
|
+
for (const target of ["node", "edge"]) {
|
|
1040
|
+
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
1041
|
+
const get = getter((t, p) => resolveStyles(ex, t, p, snapshot), target);
|
|
1042
|
+
const values = read[target];
|
|
1043
|
+
for (let i = 0; i < n; i++) {
|
|
1044
|
+
const want = get(i);
|
|
1045
|
+
const back = writtenAndReadBack(target, want, notes);
|
|
1046
|
+
for (const property of GML_STYLE_CAPABILITIES[target]) {
|
|
1047
|
+
const native = values[property]?.[i] ?? null;
|
|
1048
|
+
const w = want(property);
|
|
1049
|
+
if (native !== w && native === (back.get(property) ?? null)) {
|
|
1050
|
+
values[property] ??= new Array(n).fill(null);
|
|
1051
|
+
values[property][i] = w;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
function writtenAndReadBack(target, want, notes) {
|
|
1058
|
+
const ignore = () => void 0;
|
|
1059
|
+
const g = target === "node" ? nodeGraphics(want, ignore) : edgeGraphics(want, ignore);
|
|
1060
|
+
const back = /* @__PURE__ */ new Map();
|
|
1061
|
+
readElement(
|
|
1062
|
+
target,
|
|
1063
|
+
g,
|
|
1064
|
+
labelGraphics(want) ?? void 0,
|
|
1065
|
+
void 0,
|
|
1066
|
+
GRAPHTY_WRITER,
|
|
1067
|
+
(property, value) => {
|
|
1068
|
+
if (value !== null) {
|
|
1069
|
+
back.set(property, value);
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
(property) => ({ notes, target, property })
|
|
1073
|
+
);
|
|
1074
|
+
return back;
|
|
1075
|
+
}
|
|
1076
|
+
function gmlStyledExport(snapshot, input) {
|
|
1077
|
+
if (input === void 0) {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
const approximated = new StyleApproximations();
|
|
1081
|
+
const out = snapshot.withColumns();
|
|
1082
|
+
const renames = [];
|
|
1083
|
+
for (const target of ["node", "edge"]) {
|
|
1084
|
+
const table = target === "node" ? out.nodes : out.edges;
|
|
1085
|
+
writeGraphicsColumns(snapshot, input, target, table, approximated);
|
|
1086
|
+
const read = dataRead(input.rules.styles.rules, target);
|
|
1087
|
+
for (const name of table.names().filter((c) => mangleGmlKey(c).startsWith(TAG_PREFIX))) {
|
|
1088
|
+
const col = table.get(name);
|
|
1089
|
+
table.remove(name);
|
|
1090
|
+
if (col !== null && !(name.startsWith(TAG_PREFIX) && !read.has(name))) {
|
|
1091
|
+
renames.push(renameDataColumn(table, target, name, col));
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
let { block } = input;
|
|
1096
|
+
const keys = [...input.rules.columns.node.keys()].map((k) => tagKey("node", k));
|
|
1097
|
+
const edgeKeys = [...input.rules.columns.edge.keys()].map((k) => tagKey("edge", k));
|
|
1098
|
+
if (new Set(keys).size !== keys.length || new Set(edgeKeys).size !== edgeKeys.length) {
|
|
1099
|
+
block = writeStyleBlock(input.rules, { inlineColumns: true, snapshot });
|
|
1100
|
+
} else {
|
|
1101
|
+
setTagColumns(out, input);
|
|
1102
|
+
}
|
|
1103
|
+
out.graph.set(GML_STYLE_BLOCK_KEY, [block], { dtype: "string" });
|
|
1104
|
+
const notes = [
|
|
1105
|
+
...renames,
|
|
1106
|
+
...block === input.block ? [] : styleBlockLosses(block, input.rules.styles.rules.length, "size"),
|
|
1107
|
+
...approximated.notes("yEd's GML")
|
|
1108
|
+
];
|
|
1109
|
+
return { snapshot: out, notes };
|
|
1110
|
+
}
|
|
1111
|
+
function writeGraphicsColumns(snapshot, input, target, table, approximated) {
|
|
1112
|
+
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
1113
|
+
const approximate = (property, value) => {
|
|
1114
|
+
approximated.add(target, property, value);
|
|
1115
|
+
};
|
|
1116
|
+
const get = getter((t, p) => input.picture(t, p), target);
|
|
1117
|
+
const graphics = [];
|
|
1118
|
+
const labels = [];
|
|
1119
|
+
for (let i = 0; i < n; i++) {
|
|
1120
|
+
const g = target === "node" ? nodeGraphics(get(i), approximate) : edgeGraphics(get(i), approximate);
|
|
1121
|
+
if (target === "edge") {
|
|
1122
|
+
const line = bendsLine(snapshot, get(i)("bends"), i);
|
|
1123
|
+
if (line !== null) {
|
|
1124
|
+
g.Line = line;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
graphics.push(merged(cellOf(table, "graphics", i), OWNED[target], g));
|
|
1128
|
+
labels.push(mergedLabels(cellOf(table, "LabelGraphics", i), labelGraphics(get(i))));
|
|
1129
|
+
}
|
|
1130
|
+
for (const [name, cells] of [
|
|
1131
|
+
["graphics", graphics],
|
|
1132
|
+
["LabelGraphics", labels]
|
|
1133
|
+
]) {
|
|
1134
|
+
if (cells.some((c) => c !== void 0)) {
|
|
1135
|
+
table.set(name, cells, { dtype: "json", nullable: true });
|
|
1136
|
+
} else if (table.has(name)) {
|
|
1137
|
+
table.remove(name);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function bendsLine(snapshot, bends, e) {
|
|
1142
|
+
const source = centerOf(snapshot, snapshot.edgeSource(e));
|
|
1143
|
+
const target = centerOf(snapshot, snapshot.edgeTarget(e));
|
|
1144
|
+
const points = typeof bends === "string" ? bendsToPoints(source, target, bends) : null;
|
|
1145
|
+
if (points === null || ![...source, ...target].every(Number.isFinite)) {
|
|
1146
|
+
return null;
|
|
1147
|
+
}
|
|
1148
|
+
return { point: [source, ...points, target].map(([x, y]) => ({ x, y })) };
|
|
1149
|
+
}
|
|
1150
|
+
function renameDataColumn(table, target, name, col) {
|
|
1151
|
+
let renamed = `data_${name}`;
|
|
1152
|
+
let k = 2;
|
|
1153
|
+
while (table.has(renamed)) {
|
|
1154
|
+
renamed = `data_${name}_${String(k)}`;
|
|
1155
|
+
k++;
|
|
1156
|
+
}
|
|
1157
|
+
table.set(renamed, col);
|
|
1158
|
+
return Object.freeze({
|
|
1159
|
+
code: KEY_MANGLED_CODE,
|
|
1160
|
+
message: `${target} column "${name}" is written as "${renamed}": keys starting with ${TAG_PREFIX} hold graphty's style values`,
|
|
1161
|
+
column: name,
|
|
1162
|
+
count: null
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
function setTagColumns(out, input) {
|
|
1166
|
+
for (const target of ["node", "edge"]) {
|
|
1167
|
+
const table = target === "node" ? out.nodes : out.edges;
|
|
1168
|
+
for (const [key, col] of input.rules.columns[target]) {
|
|
1169
|
+
const kinds = new Set(col.filter((v) => v !== null).map((v) => typeof v));
|
|
1170
|
+
const text = kinds.size > 1 || kinds.has("string");
|
|
1171
|
+
let dtype = kinds.has("boolean") ? "bool" : "f64";
|
|
1172
|
+
if (text) {
|
|
1173
|
+
dtype = "string";
|
|
1174
|
+
}
|
|
1175
|
+
table.set(tagKey(target, key), text ? col.map((v) => v === null ? null : String(v)) : col, { dtype });
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
370
1179
|
const RECORD_NUMBER_TYPE_CODE = "W_GML_RECORD_NUMBER_TYPE";
|
|
371
1180
|
const RECORD_BOOLEAN_CODE = "W_GML_RECORD_BOOLEAN";
|
|
372
1181
|
const RECORD_NULL_CODE = "W_GML_RECORD_NULL";
|
|
@@ -374,7 +1183,6 @@ const NESTED_ARRAY_CODE = "E_GML_NESTED_ARRAY";
|
|
|
374
1183
|
const JSON_ARRAY_CODE = "W_GML_JSON_ARRAY";
|
|
375
1184
|
const INVALID_KEY_CODE = "E_GML_INVALID_KEY";
|
|
376
1185
|
const RESERVED_KEY_CODE = "E_GML_RESERVED_KEY";
|
|
377
|
-
const KEY_MANGLED_CODE = "W_GML_KEY_MANGLED";
|
|
378
1186
|
const POSITION_COMPONENTS_CODE = "W_GML_POSITION_COMPONENTS";
|
|
379
1187
|
const GRAPHICS_OVERRIDDEN_CODE = "W_GML_GRAPHICS_OVERRIDDEN";
|
|
380
1188
|
const GRAPHICS_CONFLICT_CODE = "E_GML_GRAPHICS_CONFLICT";
|
|
@@ -1330,7 +2138,21 @@ const gmlExporter = Object.freeze({
|
|
|
1330
2138
|
format: "gml",
|
|
1331
2139
|
options: Object.freeze(["sanitizeKeys", "weightKey"]),
|
|
1332
2140
|
capabilities: GML_CAPABILITIES,
|
|
1333
|
-
|
|
2141
|
+
styles: Object.freeze({ capabilities: GML_STYLE_CAPABILITIES }),
|
|
2142
|
+
/**
|
|
2143
|
+
* Pre-flight: the common capability notes, the GML-specific ones and, with styles, the values written as the
|
|
2144
|
+
* nearest ones yEd's GML has.
|
|
2145
|
+
* @param snapshot - the snapshot
|
|
2146
|
+
* @param options - the options
|
|
2147
|
+
* @returns the notes, empty when the export is exact
|
|
2148
|
+
*/
|
|
2149
|
+
check(snapshot, options) {
|
|
2150
|
+
const styled = gmlStyledExport(snapshot, options?.styles);
|
|
2151
|
+
if (styled === null) {
|
|
2152
|
+
return check(snapshot, options);
|
|
2153
|
+
}
|
|
2154
|
+
return Object.freeze([...check(styled.snapshot, options), ...styled.notes]);
|
|
2155
|
+
},
|
|
1334
2156
|
/**
|
|
1335
2157
|
* Write the snapshot as UTF-8 chunks; the context is resolved on the first pull, so the
|
|
1336
2158
|
* errors check() announced surface from the iteration.
|
|
@@ -1352,7 +2174,34 @@ const gmlExporter = Object.freeze({
|
|
|
1352
2174
|
}
|
|
1353
2175
|
});
|
|
1354
2176
|
function* lazyParts(snapshot, options) {
|
|
1355
|
-
yield* gmlParts(contextOf(snapshot, options));
|
|
2177
|
+
yield* gmlParts(contextOf(gmlStyledExport(snapshot, options?.styles)?.snapshot ?? snapshot, options));
|
|
2178
|
+
}
|
|
2179
|
+
const GRAPHICS_COLUMN = "graphics";
|
|
2180
|
+
function gmlPositions(snapshot) {
|
|
2181
|
+
if (snapshot.nodes.byRole("position") === null) {
|
|
2182
|
+
return null;
|
|
2183
|
+
}
|
|
2184
|
+
const tool = toolOf(snapshot.meta.creator);
|
|
2185
|
+
return {
|
|
2186
|
+
units: "px",
|
|
2187
|
+
// a z that is the same on every node collapses to 2D
|
|
2188
|
+
sourceDims: 3,
|
|
2189
|
+
yAxis: tool === "gephi" || tool === "tulip" ? "up" : "down",
|
|
2190
|
+
tool,
|
|
2191
|
+
medianNodeSize: graphicsMedian(snapshot)
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
function graphicsMedian(snapshot) {
|
|
2195
|
+
const graphics = snapshot.nodes.get(GRAPHICS_COLUMN);
|
|
2196
|
+
const sizes = [];
|
|
2197
|
+
for (let row = 0; graphics !== null && row < graphics.length; row++) {
|
|
2198
|
+
const g = graphics.isSet(row) ? graphics.value(row) : void 0;
|
|
2199
|
+
const { w, h } = typeof g === "object" && g !== null ? g : {};
|
|
2200
|
+
if (typeof w === "number" && typeof h === "number") {
|
|
2201
|
+
sizes.push((w + h) / 2);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
return median(sizes);
|
|
1356
2205
|
}
|
|
1357
2206
|
const NO_GRAPH_CODE = NO_GRAPH_CODE$1;
|
|
1358
2207
|
const SECOND_GRAPH_CODE = MULTIPLE_GRAPHS_CODE;
|
|
@@ -2507,13 +3356,13 @@ class GmlImport {
|
|
|
2507
3356
|
const t = this.requireTokens();
|
|
2508
3357
|
const { sink } = this;
|
|
2509
3358
|
const values = vs.map((v) => t.kind[v] === TOKEN_OPEN ? parseRecord(t, v) : this.scalarOf(plan, v));
|
|
2510
|
-
const
|
|
3359
|
+
const first2 = values[0];
|
|
2511
3360
|
const positionPlan = plan.position;
|
|
2512
|
-
let rest =
|
|
2513
|
-
if (isRecord(
|
|
2514
|
-
const left = this.writePosition(positionPlan, index, this.keepPositionSource ? { ...
|
|
2515
|
-
rest = this.keepPositionSource ?
|
|
2516
|
-
} else if (!isRecord(
|
|
3361
|
+
let rest = first2;
|
|
3362
|
+
if (isRecord(first2) && positionPlan !== null) {
|
|
3363
|
+
const left = this.writePosition(positionPlan, index, this.keepPositionSource ? { ...first2 } : first2, where);
|
|
3364
|
+
rest = this.keepPositionSource ? first2 : left;
|
|
3365
|
+
} else if (!isRecord(first2)) {
|
|
2517
3366
|
this.graphicsWarning("scalar", `node ${where.element}'s graphics is not a record`, where);
|
|
2518
3367
|
}
|
|
2519
3368
|
if (values.length > 1) {
|
|
@@ -2827,6 +3676,8 @@ const gmlImporter = Object.freeze({
|
|
|
2827
3676
|
extensions: Object.freeze([".gml"]),
|
|
2828
3677
|
mimeTypes: Object.freeze(["text/x-gml", "text/plain"]),
|
|
2829
3678
|
sniff: sniffGml,
|
|
3679
|
+
styles: gmlStyles,
|
|
3680
|
+
positions: gmlPositions,
|
|
2830
3681
|
/**
|
|
2831
3682
|
* Read a GML text into a sink.
|
|
2832
3683
|
* @param input - the text, bytes or stream
|
|
@@ -2866,14 +3717,14 @@ const gmlImporter = Object.freeze({
|
|
|
2866
3717
|
*/
|
|
2867
3718
|
async importAll(input, sinkFor, options) {
|
|
2868
3719
|
const resolved = resolveImportOptions(options, FORMAT_DEFAULTS);
|
|
2869
|
-
const
|
|
2870
|
-
reportUnusedOptions(options,
|
|
2871
|
-
const tokens = tokenize(await readText(input,
|
|
3720
|
+
const first2 = new ImportReportBuilder("gml", resolved.errorLimit);
|
|
3721
|
+
reportUnusedOptions(options, first2, USED_OPTIONS);
|
|
3722
|
+
const tokens = tokenize(await readText(input, first2, resolved), first2);
|
|
2872
3723
|
const reports = [];
|
|
2873
3724
|
let count = 1;
|
|
2874
3725
|
for (let i = 0; i < count; i++) {
|
|
2875
3726
|
throwIfAborted(resolved.signal);
|
|
2876
|
-
const report = i === 0 ?
|
|
3727
|
+
const report = i === 0 ? first2 : new ImportReportBuilder("gml", resolved.errorLimit);
|
|
2877
3728
|
const sink = sinkFor(i);
|
|
2878
3729
|
reportSinkOptions(sink, options, report);
|
|
2879
3730
|
const gml = new GmlImport(sink, report, resolved, options, i);
|
|
@@ -3016,7 +3867,7 @@ const GML_LOSS = Object.freeze({
|
|
|
3016
3867
|
INVALID_KEY: INVALID_KEY_CODE,
|
|
3017
3868
|
/** A column named like a structural key. */
|
|
3018
3869
|
RESERVED_KEY: RESERVED_KEY_CODE,
|
|
3019
|
-
/** A key rewritten under sanitizeKeys "mangle". */
|
|
3870
|
+
/** A key rewritten under sanitizeKeys "mangle", or a column renamed because its key would read back as a style value. */
|
|
3020
3871
|
KEY_MANGLED: KEY_MANGLED_CODE,
|
|
3021
3872
|
/** A position column with more than three components. */
|
|
3022
3873
|
POSITION_COMPONENTS: POSITION_COMPONENTS_CODE,
|
|
@@ -3028,6 +3879,8 @@ const GML_LOSS = Object.freeze({
|
|
|
3028
3879
|
export {
|
|
3029
3880
|
GML_ISSUE,
|
|
3030
3881
|
GML_LOSS,
|
|
3882
|
+
GML_STYLE_BLOCK_KEY,
|
|
3883
|
+
GML_STYLE_CAPABILITIES,
|
|
3031
3884
|
gmlExporter,
|
|
3032
3885
|
gmlImporter
|
|
3033
3886
|
};
|