@graphty/graph-io 0.3.48 → 0.3.50
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-C2riR4NT.js → approximations-BRXsll0T.js} +2 -2
- package/dist/chunks/{approximations-C2riR4NT.js.map → approximations-BRXsll0T.js.map} +1 -1
- package/dist/chunks/bends-BGXjv_U4.js +129 -0
- package/dist/chunks/bends-BGXjv_U4.js.map +1 -0
- package/dist/chunks/{block-Cu22ewuS.js → block-yl0f_qLO.js} +931 -164
- package/dist/chunks/block-yl0f_qLO.js.map +1 -0
- package/dist/chunks/choose-CczZJaX_.js +717 -0
- package/dist/chunks/choose-CczZJaX_.js.map +1 -0
- package/dist/chunks/{codes-CV_Bhcyi.js → codes-BE2xir2k.js} +6 -2
- package/dist/chunks/codes-BE2xir2k.js.map +1 -0
- package/dist/chunks/{constants-D0LqcsLJ.js → constants-CKkYLPtt.js} +2 -2
- package/dist/chunks/{constants-D0LqcsLJ.js.map → constants-CKkYLPtt.js.map} +1 -1
- package/dist/chunks/{context-cgmmOxZ2.js → context-DizmppHy.js} +5 -4
- package/dist/chunks/{context-cgmmOxZ2.js.map → context-DizmppHy.js.map} +1 -1
- package/dist/chunks/{convert-BcQ8_jMo.js → convert-Ct2zelbQ.js} +7 -2
- package/dist/chunks/convert-Ct2zelbQ.js.map +1 -0
- package/dist/chunks/{credentials-BiQsnMTb.js → credentials-CmvJXYeH.js} +67 -16
- package/dist/chunks/credentials-CmvJXYeH.js.map +1 -0
- package/dist/chunks/{cx-export-BEeF6ymo.js → cx-export-Bt6NoqTQ.js} +3 -3
- package/dist/chunks/{cx-export-BEeF6ymo.js.map → cx-export-Bt6NoqTQ.js.map} +1 -1
- package/dist/chunks/descriptor-B28U25x4.js +60 -0
- package/dist/chunks/descriptor-B28U25x4.js.map +1 -0
- package/dist/chunks/{descriptor-BJ-W0Jd-.js → descriptor-Dhez_Cew.js} +11 -2
- package/dist/chunks/descriptor-Dhez_Cew.js.map +1 -0
- package/dist/chunks/{emit-CD8xnY8s.js → emit-7Jkpg0yd.js} +1788 -133
- package/dist/chunks/emit-7Jkpg0yd.js.map +1 -0
- package/dist/chunks/{escape-DH2Egt-l.js → escape-CuCIzNMB.js} +8 -8
- package/dist/chunks/{escape-DH2Egt-l.js.map → escape-CuCIzNMB.js.map} +1 -1
- package/dist/chunks/{export-CZ7VRm4I.js → export-Cha4dRFz.js} +45 -387
- package/dist/chunks/export-Cha4dRFz.js.map +1 -0
- package/dist/chunks/{exporter-ChjL5fmP.js → exporter-1Ajud15J.js} +9 -8
- package/dist/chunks/{exporter-ChjL5fmP.js.map → exporter-1Ajud15J.js.map} +1 -1
- package/dist/chunks/{exporter-BIdaoIgh.js → exporter-B6yvL3wy.js} +7 -7
- package/dist/chunks/{exporter-BIdaoIgh.js.map → exporter-B6yvL3wy.js.map} +1 -1
- package/dist/chunks/{exporter-Dcw7Ldtq.js → exporter-BP6otMO6.js} +6 -6
- package/dist/chunks/{exporter-Dcw7Ldtq.js.map → exporter-BP6otMO6.js.map} +1 -1
- package/dist/chunks/{exporter-DtVU80Fa.js → exporter-CA5q8ROP.js} +9 -8
- package/dist/chunks/{exporter-DtVU80Fa.js.map → exporter-CA5q8ROP.js.map} +1 -1
- package/dist/chunks/{exporter-bxxjOrDZ.js → exporter-CQQZFJ2v.js} +1284 -156
- package/dist/chunks/exporter-CQQZFJ2v.js.map +1 -0
- package/dist/chunks/format-BXiAb-1h.js +408 -0
- package/dist/chunks/format-BXiAb-1h.js.map +1 -0
- package/dist/chunks/{generic-CP6YD34u.js → generic-Dc21MAdg.js} +387 -31
- package/dist/chunks/generic-Dc21MAdg.js.map +1 -0
- package/dist/chunks/{importer-B87_fmVx.js → importer-C6NVpCXp.js} +327 -84
- package/dist/chunks/importer-C6NVpCXp.js.map +1 -0
- package/dist/chunks/{importer-DPZDN40-.js → importer-CKFe4q54.js} +25 -17
- package/dist/chunks/importer-CKFe4q54.js.map +1 -0
- package/dist/chunks/{importer-Bji2MeWr.js → importer-CKbUbsJA.js} +13 -10
- package/dist/chunks/{importer-Bji2MeWr.js.map → importer-CKbUbsJA.js.map} +1 -1
- package/dist/chunks/{importer-CB_zV5_L.js → importer-ClCsdgTJ.js} +208 -1104
- package/dist/chunks/importer-ClCsdgTJ.js.map +1 -0
- package/dist/chunks/{importer-e3huMZbm.js → importer-CyVZTrf0.js} +14 -10
- package/dist/chunks/importer-CyVZTrf0.js.map +1 -0
- package/dist/chunks/{importer-CVT-JyDE.js → importer-DgG4v1Ms.js} +1537 -355
- package/dist/chunks/importer-DgG4v1Ms.js.map +1 -0
- package/dist/chunks/{importer-Cyy6UseH.js → importer-asFUrIsj.js} +66 -13
- package/dist/chunks/importer-asFUrIsj.js.map +1 -0
- package/dist/chunks/{input-Ccg9I22A.js → input-CAxt_aV-.js} +4 -4
- package/dist/chunks/{input-Ccg9I22A.js.map → input-CAxt_aV-.js.map} +1 -1
- package/dist/chunks/{json-elements-By172SVq.js → json-elements-Cq76WjnZ.js} +4 -4
- package/dist/chunks/{json-elements-By172SVq.js.map → json-elements-Cq76WjnZ.js.map} +1 -1
- package/dist/chunks/{lexicon-u2SI5xcx.js → lexicon-IVRq2Uoo.js} +282 -74
- package/dist/chunks/lexicon-IVRq2Uoo.js.map +1 -0
- package/dist/chunks/{ontology-export-BwgMyuF0.js → ontology-export-OMo91mb0.js} +4 -4
- package/dist/chunks/{ontology-export-BwgMyuF0.js.map → ontology-export-OMo91mb0.js.map} +1 -1
- package/dist/chunks/{records-Cgvxz-Vx.js → records-NJiYvekn.js} +2 -2
- package/dist/chunks/{records-Cgvxz-Vx.js.map → records-NJiYvekn.js.map} +1 -1
- package/dist/chunks/{report-CgdsL9Hb.js → report-CwMfYa9J.js} +23 -23
- package/dist/chunks/{report-CgdsL9Hb.js.map → report-CwMfYa9J.js.map} +1 -1
- package/dist/chunks/round-trip-Cy3_SHRZ.js +79 -0
- package/dist/chunks/round-trip-Cy3_SHRZ.js.map +1 -0
- package/dist/chunks/{sigv4-LkAzsLAu.js → sigv4-BXwVbza3.js} +5 -5
- package/dist/chunks/sigv4-BXwVbza3.js.map +1 -0
- package/dist/chunks/{styles-CaABMoO1.js → styles-CAVmBLgp.js} +1237 -138
- package/dist/chunks/styles-CAVmBLgp.js.map +1 -0
- package/dist/chunks/styles-CPczw1Jz.js +1928 -0
- package/dist/chunks/styles-CPczw1Jz.js.map +1 -0
- package/dist/chunks/styles-boK6Ln54.js +2847 -0
- package/dist/chunks/styles-boK6Ln54.js.map +1 -0
- package/dist/chunks/{styles-yed-Cs1nmrjn.js → styles-yed-XeFBQ6VS.js} +506 -175
- package/dist/chunks/styles-yed-XeFBQ6VS.js.map +1 -0
- package/dist/chunks/{text-BuKQVMz2.js → text-ystE2bYi.js} +2 -2
- package/dist/chunks/{text-BuKQVMz2.js.map → text-ystE2bYi.js.map} +1 -1
- package/dist/csv.js +7 -7
- package/dist/cx.js +2 -2
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +8 -4
- package/dist/dot.js.map +1 -1
- package/dist/gexf.js +42 -12
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +848 -194
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +230 -193
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +3 -3
- package/dist/json.js +3 -2
- package/dist/neo4j.js +6 -6
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/positions.js +45 -3
- package/dist/positions.js.map +1 -1
- package/dist/sources-cypher.js +141 -23
- package/dist/sources-cypher.js.map +1 -1
- package/dist/sources-ndex.js +2 -2
- package/dist/sources-rest.js +32 -6
- package/dist/sources-rest.js.map +1 -1
- package/dist/sources-sparql.d.ts +1 -0
- package/dist/sources-sparql.js +439 -0
- package/dist/sources-sparql.js.map +1 -0
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +5 -1
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx/styles.d.ts +24 -1
- package/dist/src/formats/cx/styles.d.ts.map +1 -1
- package/dist/src/formats/cx/styles.js +117 -11
- package/dist/src/formats/cx/styles.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +1 -0
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cx2/styles.d.ts.map +1 -1
- package/dist/src/formats/cx2/styles.js +3 -1
- package/dist/src/formats/cx2/styles.js.map +1 -1
- package/dist/src/formats/cys/importer.d.ts.map +1 -1
- package/dist/src/formats/cys/importer.js +1 -0
- package/dist/src/formats/cys/importer.js.map +1 -1
- package/dist/src/formats/cys/styles.d.ts +2 -0
- package/dist/src/formats/cys/styles.d.ts.map +1 -1
- package/dist/src/formats/cys/styles.js +15 -7
- package/dist/src/formats/cys/styles.js.map +1 -1
- package/dist/src/formats/dot/drawing.d.ts +98 -0
- package/dist/src/formats/dot/drawing.d.ts.map +1 -0
- package/dist/src/formats/dot/drawing.js +734 -0
- package/dist/src/formats/dot/drawing.js.map +1 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +34 -2
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts +6 -1
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +170 -33
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +3 -1
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +2 -1
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/label-places.d.ts +41 -0
- package/dist/src/formats/dot/label-places.d.ts.map +1 -0
- package/dist/src/formats/dot/label-places.js +185 -0
- package/dist/src/formats/dot/label-places.js.map +1 -0
- package/dist/src/formats/dot/names.d.ts +13 -0
- package/dist/src/formats/dot/names.d.ts.map +1 -1
- package/dist/src/formats/dot/names.js +13 -0
- package/dist/src/formats/dot/names.js.map +1 -1
- package/dist/src/formats/dot/record.d.ts +50 -0
- package/dist/src/formats/dot/record.d.ts.map +1 -0
- package/dist/src/formats/dot/record.js +275 -0
- package/dist/src/formats/dot/record.js.map +1 -0
- package/dist/src/formats/dot/styles.d.ts +72 -2
- package/dist/src/formats/dot/styles.d.ts.map +1 -1
- package/dist/src/formats/dot/styles.js +1500 -119
- package/dist/src/formats/dot/styles.js.map +1 -1
- package/dist/src/formats/gexf/dialog-metrics.d.ts +15 -0
- package/dist/src/formats/gexf/dialog-metrics.d.ts.map +1 -0
- package/dist/src/formats/gexf/dialog-metrics.js +59 -0
- package/dist/src/formats/gexf/dialog-metrics.js.map +1 -0
- package/dist/src/formats/gexf/importer.d.ts +7 -0
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +41 -5
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/preview.d.ts +77 -0
- package/dist/src/formats/gexf/preview.d.ts.map +1 -0
- package/dist/src/formats/gexf/preview.js +191 -0
- package/dist/src/formats/gexf/preview.js.map +1 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +2 -1
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gexf/styles.d.ts +58 -31
- package/dist/src/formats/gexf/styles.d.ts.map +1 -1
- package/dist/src/formats/gexf/styles.js +848 -225
- package/dist/src/formats/gexf/styles.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts +5 -2
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +258 -71
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +1 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +1 -1
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/positions.d.ts +7 -0
- package/dist/src/formats/gml/positions.d.ts.map +1 -1
- package/dist/src/formats/gml/positions.js +29 -7
- package/dist/src/formats/gml/positions.js.map +1 -1
- package/dist/src/formats/gml/styles.d.ts.map +1 -1
- package/dist/src/formats/gml/styles.js +754 -102
- package/dist/src/formats/gml/styles.js.map +1 -1
- package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-plain.js +6 -10
- package/dist/src/formats/graphml/styles-plain.js.map +1 -1
- package/dist/src/formats/graphml/styles-yed.d.ts +21 -15
- package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-yed.js +695 -164
- package/dist/src/formats/graphml/styles-yed.js.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.d.ts +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -1
- package/dist/src/formats/graphml/styles-yfiles3.js +431 -64
- package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +3 -3
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +16 -6
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/dialect.d.ts +3 -2
- package/dist/src/formats/json/dialect.d.ts.map +1 -1
- package/dist/src/formats/json/dialect.js +39 -5
- package/dist/src/formats/json/dialect.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +13 -2
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +42 -6
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/index.d.ts +1 -1
- package/dist/src/formats/json/index.d.ts.map +1 -1
- package/dist/src/formats/json/index.js +1 -1
- package/dist/src/formats/json/index.js.map +1 -1
- package/dist/src/formats/json/positions.d.ts +5 -2
- package/dist/src/formats/json/positions.d.ts.map +1 -1
- package/dist/src/formats/json/positions.js +20 -4
- package/dist/src/formats/json/positions.js.map +1 -1
- package/dist/src/formats/json/styles.d.ts +12 -1
- package/dist/src/formats/json/styles.d.ts.map +1 -1
- package/dist/src/formats/json/styles.js +1843 -136
- package/dist/src/formats/json/styles.js.map +1 -1
- package/dist/src/formats/pajek/draw.d.ts +104 -0
- package/dist/src/formats/pajek/draw.d.ts.map +1 -0
- package/dist/src/formats/pajek/draw.js +382 -0
- package/dist/src/formats/pajek/draw.js.map +1 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +70 -51
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +9 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +233 -102
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/index.d.ts +1 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -1
- package/dist/src/formats/pajek/index.js.map +1 -1
- package/dist/src/formats/pajek/styles.d.ts +15 -7
- package/dist/src/formats/pajek/styles.d.ts.map +1 -1
- package/dist/src/formats/pajek/styles.js +1395 -114
- package/dist/src/formats/pajek/styles.js.map +1 -1
- package/dist/src/formats/pajek/syntax.d.ts +10 -1
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +26 -2
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts +1 -0
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +65 -5
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/styles.d.ts +23 -3
- package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
- package/dist/src/formats/xgmml/styles.js +277 -60
- package/dist/src/formats/xgmml/styles.js.map +1 -1
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/positions/convert.d.ts.map +1 -1
- package/dist/src/positions/convert.js +11 -1
- package/dist/src/positions/convert.js.map +1 -1
- package/dist/src/positions/extract.d.ts.map +1 -1
- package/dist/src/positions/extract.js +53 -1
- package/dist/src/positions/extract.js.map +1 -1
- package/dist/src/positions/index.d.ts +1 -1
- package/dist/src/positions/index.d.ts.map +1 -1
- package/dist/src/positions/types.d.ts +59 -0
- package/dist/src/positions/types.d.ts.map +1 -1
- package/dist/src/sources/builtins.d.ts +1 -1
- package/dist/src/sources/builtins.d.ts.map +1 -1
- package/dist/src/sources/builtins.js +8 -2
- package/dist/src/sources/builtins.js.map +1 -1
- package/dist/src/sources/context.d.ts.map +1 -1
- package/dist/src/sources/context.js +1 -0
- package/dist/src/sources/context.js.map +1 -1
- package/dist/src/sources/credentials.d.ts +50 -1
- package/dist/src/sources/credentials.d.ts.map +1 -1
- package/dist/src/sources/credentials.js +69 -0
- package/dist/src/sources/credentials.js.map +1 -1
- package/dist/src/sources/cypher/descriptor.d.ts.map +1 -1
- package/dist/src/sources/cypher/descriptor.js +5 -0
- package/dist/src/sources/cypher/descriptor.js.map +1 -1
- package/dist/src/sources/cypher/index.d.ts.map +1 -1
- package/dist/src/sources/cypher/index.js +125 -18
- package/dist/src/sources/cypher/index.js.map +1 -1
- package/dist/src/sources/cypher/params.d.ts +1 -1
- package/dist/src/sources/cypher/params.d.ts.map +1 -1
- package/dist/src/sources/cypher/query-builder.d.ts +17 -0
- package/dist/src/sources/cypher/query-builder.d.ts.map +1 -1
- package/dist/src/sources/cypher/query-builder.js +31 -0
- package/dist/src/sources/cypher/query-builder.js.map +1 -1
- package/dist/src/sources/ids.d.ts +5 -0
- package/dist/src/sources/ids.d.ts.map +1 -1
- package/dist/src/sources/ids.js +5 -0
- package/dist/src/sources/ids.js.map +1 -1
- package/dist/src/sources/params.d.ts +3 -0
- package/dist/src/sources/params.d.ts.map +1 -1
- package/dist/src/sources/rest/descriptor.d.ts.map +1 -1
- package/dist/src/sources/rest/descriptor.js +9 -0
- package/dist/src/sources/rest/descriptor.js.map +1 -1
- package/dist/src/sources/rest/openalex.d.ts +4 -2
- package/dist/src/sources/rest/openalex.d.ts.map +1 -1
- package/dist/src/sources/rest/openalex.js +4 -2
- package/dist/src/sources/rest/openalex.js.map +1 -1
- package/dist/src/sources/rest/source.d.ts.map +1 -1
- package/dist/src/sources/rest/source.js +38 -0
- package/dist/src/sources/rest/source.js.map +1 -1
- package/dist/src/sources/run.d.ts +2 -0
- package/dist/src/sources/run.d.ts.map +1 -1
- package/dist/src/sources/run.js +30 -3
- package/dist/src/sources/run.js.map +1 -1
- package/dist/src/sources/sigv4.d.ts +5 -3
- package/dist/src/sources/sigv4.d.ts.map +1 -1
- package/dist/src/sources/sigv4.js +6 -4
- package/dist/src/sources/sigv4.js.map +1 -1
- package/dist/src/sources/sparql/descriptor.d.ts +10 -0
- package/dist/src/sources/sparql/descriptor.d.ts.map +1 -0
- package/dist/src/sources/sparql/descriptor.js +64 -0
- package/dist/src/sources/sparql/descriptor.js.map +1 -0
- package/dist/src/sources/sparql/index.d.ts +28 -0
- package/dist/src/sources/sparql/index.d.ts.map +1 -0
- package/dist/src/sources/sparql/index.js +327 -0
- package/dist/src/sources/sparql/index.js.map +1 -0
- package/dist/src/sources/sparql/ntriples.d.ts +69 -0
- package/dist/src/sources/sparql/ntriples.d.ts.map +1 -0
- package/dist/src/sources/sparql/ntriples.js +180 -0
- package/dist/src/sources/sparql/ntriples.js.map +1 -0
- package/dist/src/sources/sparql/params.d.ts +27 -0
- package/dist/src/sources/sparql/params.d.ts.map +1 -0
- package/dist/src/sources/sparql/params.js +5 -0
- package/dist/src/sources/sparql/params.js.map +1 -0
- package/dist/src/sources/sparql/query.d.ts +73 -0
- package/dist/src/sources/sparql/query.d.ts.map +1 -0
- package/dist/src/sources/sparql/query.js +164 -0
- package/dist/src/sources/sparql/query.js.map +1 -0
- package/dist/src/sources/types.d.ts +60 -0
- package/dist/src/sources/types.d.ts.map +1 -1
- package/dist/src/styles/annotations.d.ts +61 -5
- package/dist/src/styles/annotations.d.ts.map +1 -1
- package/dist/src/styles/annotations.js +130 -22
- package/dist/src/styles/annotations.js.map +1 -1
- package/dist/src/styles/canon/bends.d.ts +46 -0
- package/dist/src/styles/canon/bends.d.ts.map +1 -1
- package/dist/src/styles/canon/bends.js +123 -0
- package/dist/src/styles/canon/bends.js.map +1 -1
- package/dist/src/styles/canon/color-tables.d.ts +6 -1
- package/dist/src/styles/canon/color-tables.d.ts.map +1 -1
- package/dist/src/styles/canon/color-tables.js +10 -4
- package/dist/src/styles/canon/color-tables.js.map +1 -1
- package/dist/src/styles/canon/color.d.ts +3 -1
- package/dist/src/styles/canon/color.d.ts.map +1 -1
- package/dist/src/styles/canon/color.js +103 -3
- package/dist/src/styles/canon/color.js.map +1 -1
- package/dist/src/styles/canon/enums.d.ts +2 -2
- package/dist/src/styles/canon/enums.d.ts.map +1 -1
- package/dist/src/styles/canon/enums.js +89 -7
- package/dist/src/styles/canon/enums.js.map +1 -1
- package/dist/src/styles/canon/graphviz.d.ts +12 -3
- package/dist/src/styles/canon/graphviz.d.ts.map +1 -1
- package/dist/src/styles/canon/graphviz.js +57 -9
- package/dist/src/styles/canon/graphviz.js.map +1 -1
- package/dist/src/styles/canon/number.d.ts +8 -0
- package/dist/src/styles/canon/number.d.ts.map +1 -1
- package/dist/src/styles/canon/number.js +18 -0
- package/dist/src/styles/canon/number.js.map +1 -1
- package/dist/src/styles/canon/text.d.ts +29 -2
- package/dist/src/styles/canon/text.d.ts.map +1 -1
- package/dist/src/styles/canon/text.js +156 -16
- package/dist/src/styles/canon/text.js.map +1 -1
- package/dist/src/styles/codes.d.ts +2 -0
- package/dist/src/styles/codes.d.ts.map +1 -1
- package/dist/src/styles/codes.js +2 -0
- package/dist/src/styles/codes.js.map +1 -1
- package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
- package/dist/src/styles/cyjs/cascade.js +1139 -79
- package/dist/src/styles/cyjs/cascade.js.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
- package/dist/src/styles/cyjs/defaults-table.js +4 -0
- package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
- package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
- package/dist/src/styles/cyjs/emit.js +232 -10
- package/dist/src/styles/cyjs/emit.js.map +1 -1
- package/dist/src/styles/cyjs/face.d.ts +20 -0
- package/dist/src/styles/cyjs/face.d.ts.map +1 -0
- package/dist/src/styles/cyjs/face.js +332 -0
- package/dist/src/styles/cyjs/face.js.map +1 -0
- package/dist/src/styles/cyjs/mappers.d.ts +44 -1
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
- package/dist/src/styles/cyjs/mappers.js +475 -26
- package/dist/src/styles/cyjs/mappers.js.map +1 -1
- package/dist/src/styles/cyjs/routes.d.ts +53 -0
- package/dist/src/styles/cyjs/routes.d.ts.map +1 -0
- package/dist/src/styles/cyjs/routes.js +360 -0
- package/dist/src/styles/cyjs/routes.js.map +1 -0
- package/dist/src/styles/cytoscape/charts.d.ts +23 -0
- package/dist/src/styles/cytoscape/charts.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/charts.js +560 -0
- package/dist/src/styles/cytoscape/charts.js.map +1 -0
- package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/emit.js +156 -48
- package/dist/src/styles/cytoscape/emit.js.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.d.ts +91 -3
- package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.js +387 -77
- package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
- package/dist/src/styles/cytoscape/mappings.d.ts +30 -0
- package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/mappings.js +92 -0
- package/dist/src/styles/cytoscape/mappings.js.map +1 -1
- package/dist/src/styles/cytoscape/resolve.d.ts +42 -2
- package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/resolve.js +623 -17
- package/dist/src/styles/cytoscape/resolve.js.map +1 -1
- package/dist/src/styles/defaults.d.ts +46 -26
- package/dist/src/styles/defaults.d.ts.map +1 -1
- package/dist/src/styles/defaults.js +308 -71
- package/dist/src/styles/defaults.js.map +1 -1
- package/dist/src/styles/index.d.ts +4 -3
- package/dist/src/styles/index.d.ts.map +1 -1
- package/dist/src/styles/index.js +3 -2
- package/dist/src/styles/index.js.map +1 -1
- package/dist/src/styles/internal.d.ts +1 -0
- package/dist/src/styles/internal.d.ts.map +1 -1
- package/dist/src/styles/internal.js +1 -0
- package/dist/src/styles/internal.js.map +1 -1
- package/dist/src/styles/io/generic.d.ts.map +1 -1
- package/dist/src/styles/io/generic.js +56 -16
- package/dist/src/styles/io/generic.js.map +1 -1
- package/dist/src/styles/io/round-trip.d.ts +56 -0
- package/dist/src/styles/io/round-trip.d.ts.map +1 -0
- package/dist/src/styles/io/round-trip.js +138 -0
- package/dist/src/styles/io/round-trip.js.map +1 -0
- package/dist/src/styles/io/writer.d.ts.map +1 -1
- package/dist/src/styles/io/writer.js +6 -1
- package/dist/src/styles/io/writer.js.map +1 -1
- package/dist/src/styles/notes.d.ts.map +1 -1
- package/dist/src/styles/notes.js +1 -0
- package/dist/src/styles/notes.js.map +1 -1
- package/dist/src/styles/plan/features.d.ts +1 -1
- package/dist/src/styles/plan/features.d.ts.map +1 -1
- package/dist/src/styles/plan/features.js +22 -2
- package/dist/src/styles/plan/features.js.map +1 -1
- package/dist/src/styles/plan/index.d.ts +1 -1
- package/dist/src/styles/plan/index.d.ts.map +1 -1
- package/dist/src/styles/plan/index.js +1 -1
- package/dist/src/styles/plan/index.js.map +1 -1
- package/dist/src/styles/plan/plan.d.ts.map +1 -1
- package/dist/src/styles/plan/plan.js +61 -4
- package/dist/src/styles/plan/plan.js.map +1 -1
- package/dist/src/styles/plan/resolve.d.ts +11 -0
- package/dist/src/styles/plan/resolve.d.ts.map +1 -1
- package/dist/src/styles/plan/resolve.js +40 -4
- package/dist/src/styles/plan/resolve.js.map +1 -1
- package/dist/src/styles/slots.d.ts +14 -0
- package/dist/src/styles/slots.d.ts.map +1 -0
- package/dist/src/styles/slots.js +20 -0
- package/dist/src/styles/slots.js.map +1 -0
- package/dist/src/styles/types.d.ts +687 -6
- package/dist/src/styles/types.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.d.ts +3 -2
- package/dist/src/styles/vocabulary.d.ts.map +1 -1
- package/dist/src/styles/vocabulary.js +224 -0
- package/dist/src/styles/vocabulary.js.map +1 -1
- package/dist/styles.js +30 -239
- package/dist/styles.js.map +1 -1
- package/dist/xgmml.js +3 -3
- package/package.json +27 -7
- package/src/formats/cx/importer.ts +6 -1
- package/src/formats/cx/styles.ts +143 -9
- package/src/formats/cx2/importer.ts +1 -0
- package/src/formats/cx2/styles.ts +3 -1
- package/src/formats/cys/importer.ts +1 -0
- package/src/formats/cys/styles.ts +27 -5
- package/src/formats/dot/drawing.ts +799 -0
- package/src/formats/dot/exporter.ts +37 -1
- package/src/formats/dot/importer.ts +192 -36
- package/src/formats/dot/index.ts +3 -1
- package/src/formats/dot/label-places.ts +241 -0
- package/src/formats/dot/names.ts +15 -0
- package/src/formats/dot/record.ts +336 -0
- package/src/formats/dot/styles.ts +1702 -149
- package/src/formats/gexf/dialog-metrics.ts +61 -0
- package/src/formats/gexf/importer.ts +50 -5
- package/src/formats/gexf/preview.ts +217 -0
- package/src/formats/gexf/schema.ts +2 -1
- package/src/formats/gexf/styles.ts +1099 -245
- package/src/formats/gml/importer.ts +291 -76
- package/src/formats/gml/index.ts +1 -1
- package/src/formats/gml/positions.ts +29 -7
- package/src/formats/gml/styles.ts +852 -110
- package/src/formats/graphml/styles-plain.ts +6 -15
- package/src/formats/graphml/styles-yed.ts +765 -176
- package/src/formats/graphml/styles-yfiles3.ts +487 -63
- package/src/formats/graphml/yfiles.ts +19 -6
- package/src/formats/json/dialect.ts +41 -5
- package/src/formats/json/importer.ts +59 -7
- package/src/formats/json/index.ts +1 -0
- package/src/formats/json/positions.ts +22 -5
- package/src/formats/json/styles.ts +2123 -171
- package/src/formats/pajek/draw.ts +469 -0
- package/src/formats/pajek/exporter.ts +81 -49
- package/src/formats/pajek/importer.ts +278 -103
- package/src/formats/pajek/index.ts +1 -0
- package/src/formats/pajek/styles.ts +1506 -133
- package/src/formats/pajek/syntax.ts +27 -2
- package/src/formats/xgmml/emit.ts +73 -5
- package/src/formats/xgmml/styles.ts +330 -71
- package/src/index.ts +12 -1
- package/src/positions/convert.ts +12 -1
- package/src/positions/extract.ts +55 -1
- package/src/positions/index.ts +1 -0
- package/src/positions/types.ts +60 -0
- package/src/sources/builtins.ts +8 -1
- package/src/sources/context.ts +1 -0
- package/src/sources/credentials.ts +90 -1
- package/src/sources/cypher/descriptor.ts +7 -1
- package/src/sources/cypher/index.ts +149 -18
- package/src/sources/cypher/params.ts +1 -1
- package/src/sources/cypher/query-builder.ts +33 -0
- package/src/sources/ids.ts +6 -0
- package/src/sources/params.ts +3 -0
- package/src/sources/rest/descriptor.ts +9 -0
- package/src/sources/rest/openalex.ts +4 -2
- package/src/sources/rest/source.ts +41 -0
- package/src/sources/run.ts +35 -3
- package/src/sources/sigv4.ts +6 -4
- package/src/sources/sparql/descriptor.ts +67 -0
- package/src/sources/sparql/index.ts +371 -0
- package/src/sources/sparql/ntriples.ts +219 -0
- package/src/sources/sparql/params.ts +28 -0
- package/src/sources/sparql/query.ts +216 -0
- package/src/sources/types.ts +68 -0
- package/src/styles/annotations.ts +201 -27
- package/src/styles/canon/bends.ts +137 -0
- package/src/styles/canon/color-tables.ts +10 -4
- package/src/styles/canon/color.ts +105 -3
- package/src/styles/canon/enums.ts +107 -8
- package/src/styles/canon/graphviz.ts +71 -10
- package/src/styles/canon/number.ts +19 -0
- package/src/styles/canon/text.ts +187 -16
- package/src/styles/codes.ts +2 -0
- package/src/styles/cyjs/cascade.ts +1303 -84
- package/src/styles/cyjs/defaults-table.ts +4 -0
- package/src/styles/cyjs/emit.ts +268 -14
- package/src/styles/cyjs/face.ts +372 -0
- package/src/styles/cyjs/mappers.ts +506 -27
- package/src/styles/cyjs/routes.ts +432 -0
- package/src/styles/cytoscape/charts.ts +684 -0
- package/src/styles/cytoscape/emit.ts +170 -48
- package/src/styles/cytoscape/lexicon.ts +431 -78
- package/src/styles/cytoscape/mappings.ts +108 -0
- package/src/styles/cytoscape/resolve.ts +741 -17
- package/src/styles/defaults.ts +417 -108
- package/src/styles/index.ts +5 -0
- package/src/styles/internal.ts +1 -0
- package/src/styles/io/generic.ts +79 -23
- package/src/styles/io/round-trip.ts +202 -0
- package/src/styles/io/writer.ts +6 -1
- package/src/styles/notes.ts +1 -0
- package/src/styles/plan/features.ts +23 -2
- package/src/styles/plan/index.ts +1 -1
- package/src/styles/plan/plan.ts +69 -5
- package/src/styles/plan/resolve.ts +47 -4
- package/src/styles/slots.ts +25 -0
- package/src/styles/types.ts +698 -5
- package/src/styles/vocabulary.ts +232 -2
- package/dist/chunks/block-Cu22ewuS.js.map +0 -1
- package/dist/chunks/choose-Cdx6Enl2.js +0 -57
- package/dist/chunks/choose-Cdx6Enl2.js.map +0 -1
- package/dist/chunks/codes-CV_Bhcyi.js.map +0 -1
- package/dist/chunks/convert-BcQ8_jMo.js.map +0 -1
- package/dist/chunks/credentials-BiQsnMTb.js.map +0 -1
- package/dist/chunks/descriptor-BJ-W0Jd-.js.map +0 -1
- package/dist/chunks/emit-CD8xnY8s.js.map +0 -1
- package/dist/chunks/export-CZ7VRm4I.js.map +0 -1
- package/dist/chunks/exporter-bxxjOrDZ.js.map +0 -1
- package/dist/chunks/format-BMS-1Nxb.js +0 -64
- package/dist/chunks/format-BMS-1Nxb.js.map +0 -1
- package/dist/chunks/generic-CP6YD34u.js.map +0 -1
- package/dist/chunks/importer-B87_fmVx.js.map +0 -1
- package/dist/chunks/importer-CB_zV5_L.js.map +0 -1
- package/dist/chunks/importer-CVT-JyDE.js.map +0 -1
- package/dist/chunks/importer-Cyy6UseH.js.map +0 -1
- package/dist/chunks/importer-DPZDN40-.js.map +0 -1
- package/dist/chunks/importer-e3huMZbm.js.map +0 -1
- package/dist/chunks/lexicon-u2SI5xcx.js.map +0 -1
- package/dist/chunks/sigv4-LkAzsLAu.js.map +0 -1
- package/dist/chunks/styles-CaABMoO1.js.map +0 -1
- package/dist/chunks/styles-P_gmFAOi.js +0 -770
- package/dist/chunks/styles-P_gmFAOi.js.map +0 -1
- package/dist/chunks/styles-yed-Cs1nmrjn.js.map +0 -1
- package/dist/chunks/writer-DvHTl36J.js +0 -449
- package/dist/chunks/writer-DvHTl36J.js.map +0 -1
|
@@ -82,3 +82,140 @@ export function bendsToPoints(source: BendPoint, target: BendPoint, value: strin
|
|
|
82
82
|
}
|
|
83
83
|
return out.length === 0 ? null : out;
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The points a piecewise cubic Bezier curve passes through, sampled evenly in its parameter: the first control point,
|
|
88
|
+
* then `steps` points along each segment, its last control point included. The input is `3n + 1` control points
|
|
89
|
+
* (a Graphviz spline, a cubic path), each segment sharing its first point with the one before.
|
|
90
|
+
* @param controls - the control points
|
|
91
|
+
* @param steps - how many points each segment is sampled at
|
|
92
|
+
* @returns the points, or null when the count is not `3n + 1` for some n >= 1
|
|
93
|
+
* @category Styles
|
|
94
|
+
*/
|
|
95
|
+
export function flattenCubic(controls: readonly BendPoint[], steps = 8): BendPoint[] | null {
|
|
96
|
+
if (controls.length < 4 || (controls.length - 1) % 3 !== 0) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const out: BendPoint[] = [controls[0]];
|
|
100
|
+
for (let s = 0; s + 3 < controls.length; s += 3) {
|
|
101
|
+
const [p0, p1, p2, p3] = controls.slice(s, s + 4);
|
|
102
|
+
for (let k = 1; k <= steps; k++) {
|
|
103
|
+
const t = k / steps;
|
|
104
|
+
const u = 1 - t;
|
|
105
|
+
const w = [u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t];
|
|
106
|
+
out.push([
|
|
107
|
+
w[0] * p0[0] + w[1] * p1[0] + w[2] * p2[0] + w[3] * p3[0],
|
|
108
|
+
w[0] * p0[1] + w[1] * p1[1] + w[2] * p2[1] + w[3] * p3[1],
|
|
109
|
+
]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Points placed on and around one node, each relative to its center as fractions of its half width and half height,
|
|
117
|
+
* y up: `"1,0"` is the middle of its right side, `"0,1"` the middle of its top. The value of an edge end's port
|
|
118
|
+
* (`sourcePort`, `targetPort`) and of a self-loop's `bends`, which have no line between two centers to be relative
|
|
119
|
+
* to. Relative to the node's size, so a drawing that draws the node larger keeps the point on the same spot.
|
|
120
|
+
* @param center - the node's center
|
|
121
|
+
* @param size - its width and height
|
|
122
|
+
* @param points - the points
|
|
123
|
+
* @param yDown - true when the file's y axis points down (the value is always y up)
|
|
124
|
+
* @returns the value, or null with no points, a size that is not positive, or a coordinate that is not finite
|
|
125
|
+
* @category Styles
|
|
126
|
+
*/
|
|
127
|
+
export function canonNodeOffsets(
|
|
128
|
+
center: BendPoint,
|
|
129
|
+
size: BendPoint,
|
|
130
|
+
points: readonly BendPoint[],
|
|
131
|
+
yDown: boolean,
|
|
132
|
+
): string | null {
|
|
133
|
+
const [hw, hh] = [size[0] / 2, size[1] / 2];
|
|
134
|
+
if (points.length === 0 || Number.isNaN(hw + hh) || hw <= 0 || hh <= 0) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const flip = yDown ? -1 : 1;
|
|
138
|
+
const out: string[] = [];
|
|
139
|
+
for (const [px, py] of points) {
|
|
140
|
+
const x = (px - center[0]) / hw;
|
|
141
|
+
const y = ((py - center[1]) * flip) / hh;
|
|
142
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
out.push(`${fraction(x)},${fraction(y)}`);
|
|
146
|
+
}
|
|
147
|
+
return out.join(" ");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The points a node-relative value places around a node: the inverse of {@link canonNodeOffsets}.
|
|
152
|
+
* @param center - the node's center
|
|
153
|
+
* @param size - its width and height
|
|
154
|
+
* @param value - the value
|
|
155
|
+
* @param yDown - true when the points are wanted in a y-down file's coordinates
|
|
156
|
+
* @returns the points, or null when the value is not `x,y` pairs or a coordinate is not finite
|
|
157
|
+
* @category Styles
|
|
158
|
+
*/
|
|
159
|
+
export function nodeOffsetsToPoints(
|
|
160
|
+
center: BendPoint,
|
|
161
|
+
size: BendPoint,
|
|
162
|
+
value: string,
|
|
163
|
+
yDown: boolean,
|
|
164
|
+
): BendPoint[] | null {
|
|
165
|
+
const flip = yDown ? -1 : 1;
|
|
166
|
+
const out: BendPoint[] = [];
|
|
167
|
+
for (const pair of value.trim().split(/\s+/)) {
|
|
168
|
+
const [a, b, extra] = pair.split(",").map(Number);
|
|
169
|
+
const x = center[0] + (a * size[0]) / 2;
|
|
170
|
+
const y = center[1] + (b * size[1] * flip) / 2;
|
|
171
|
+
if (extra !== undefined || !Number.isFinite(x) || !Number.isFinite(y)) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
out.push([x, y]);
|
|
175
|
+
}
|
|
176
|
+
return out.length === 0 ? null : out;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The points a quadratic spline passes through, as yEd draws a quad curve edge: its first and last control points are
|
|
181
|
+
* the ends, every control point between them pulls the curve without lying on it, and the curve runs from the middle
|
|
182
|
+
* of the leg before such a point to the middle of the leg after it (from the end itself on the first and last legs).
|
|
183
|
+
* `straightness` (0..1) keeps that share of every leg straight, so each curved piece covers only the part of its two
|
|
184
|
+
* legs nearest its control point: 0 is the smooth spline, 1 the control polygon.
|
|
185
|
+
* @param controls - the control points, ends included
|
|
186
|
+
* @param straightness - how straight the legs stay, 0..1
|
|
187
|
+
* @param steps - how many points each curved piece is sampled at
|
|
188
|
+
* @returns the points, ends included; the controls themselves with fewer than three
|
|
189
|
+
* @category Styles
|
|
190
|
+
*/
|
|
191
|
+
export function flattenQuadSpline(controls: readonly BendPoint[], straightness: number, steps = 8): BendPoint[] {
|
|
192
|
+
if (controls.length < 3) {
|
|
193
|
+
return [...controls];
|
|
194
|
+
}
|
|
195
|
+
const s = Math.min(1, Math.max(0, Number.isFinite(straightness) ? straightness : 0));
|
|
196
|
+
const lerp = (a: BendPoint, b: BendPoint, t: number): BendPoint => [
|
|
197
|
+
a[0] + (b[0] - a[0]) * t,
|
|
198
|
+
a[1] + (b[1] - a[1]) * t,
|
|
199
|
+
];
|
|
200
|
+
const last = controls.length - 1;
|
|
201
|
+
const out: BendPoint[] = [controls[0]];
|
|
202
|
+
for (let i = 1; i < last; i++) {
|
|
203
|
+
const c = controls[i];
|
|
204
|
+
// the joins either side: the middle of each leg, or the end itself on the first and last
|
|
205
|
+
const before = i === 1 ? controls[0] : lerp(controls[i - 1], c, 0.5);
|
|
206
|
+
const after = i === last - 1 ? controls[last] : lerp(c, controls[i + 1], 0.5);
|
|
207
|
+
const from = lerp(c, before, 1 - s);
|
|
208
|
+
const to = lerp(c, after, 1 - s);
|
|
209
|
+
for (let k = 0; k <= steps; k++) {
|
|
210
|
+
const t = k / steps;
|
|
211
|
+
const u = 1 - t;
|
|
212
|
+
out.push([
|
|
213
|
+
u * u * from[0] + 2 * u * t * c[0] + t * t * to[0],
|
|
214
|
+
u * u * from[1] + 2 * u * t * c[1] + t * t * to[1],
|
|
215
|
+
]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
out.push(controls[last]);
|
|
219
|
+
// a piece that starts where the one before ends (straightness 0) repeats the join
|
|
220
|
+
return out.filter((p, k) => k === 0 || p[0] !== out[k - 1][0] || p[1] !== out[k - 1][1]);
|
|
221
|
+
}
|
|
@@ -169,11 +169,19 @@ export const X11_COLORS: ReadonlyMap<string, string> = table(
|
|
|
169
169
|
"tomato3=cd4f39 tomato4=8b3626 turquoise=40e0d0 turquoise1=00f5ff turquoise2=00e5ee turquoise3=00c5cd " +
|
|
170
170
|
"turquoise4=00868b violet=ee82ee violetred=d02090 violetred1=ff3e96 violetred2=ee3a8c violetred3=cd3278 " +
|
|
171
171
|
"violetred4=8b2252 wheat=f5deb3 wheat1=ffe7ba wheat2=eed8ae wheat3=cdba96 wheat4=8b7e66 white=ffffff " +
|
|
172
|
+
// added in later Graphviz releases (measured on 14.1.2): the web and X11 spellings of the five clashing names
|
|
173
|
+
"webgray=808080 webgreen=008000 webgrey=808080 webmaroon=800000 webpurple=800080 x11gray=bebebe " +
|
|
174
|
+
"x11green=00ff00 x11grey=bebebe x11maroon=b03060 x11purple=a020f0 " +
|
|
172
175
|
"whitesmoke=f5f5f5 yellow=ffff00 yellow1=ffff00 yellow2=eeee00 yellow3=cdcd00 yellow4=8b8b00 " +
|
|
173
176
|
"yellowgreen=9acd32",
|
|
174
177
|
);
|
|
175
178
|
|
|
176
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* dvips names, case as Pajek spells them, and the ten Pajek adds (from LightYellow on: Pajek 6.02 manual, figure 19,
|
|
181
|
+
* with the CMYK values of the color dictionary in Pajek's own EPS export). LightOrange is the one its SVG export draws
|
|
182
|
+
* otherwise: #ffd9bc, Pajek's default vertex fill, not the EPS dictionary's #ffccb3 (`pajek-specimen-node-fills-borders-p2`
|
|
183
|
+
* `ic-lightorange`, `pajek-graphstream-b`: 18 vertices).
|
|
184
|
+
*/
|
|
177
185
|
export const DVIPS_COLORS: ReadonlyMap<string, string> = table(
|
|
178
186
|
"GreenYellow=d9ff4f Yellow=ffff00 Goldenrod=ffe629 Dandelion=ffb529 Apricot=ffad7a Peach=ff804d " +
|
|
179
187
|
"Melon=ff8a80 YellowOrange=ff9400 Orange=ff6321 BurntOrange=ff7d00 Bittersweet=c20300 RedOrange=ff3b21 " +
|
|
@@ -187,10 +195,8 @@ export const DVIPS_COLORS: ReadonlyMap<string, string> = table(
|
|
|
187
195
|
"JungleGreen=03ff7a SeaGreen=4fff80 Green=00ff00 ForestGreen=00e000 PineGreen=00bf29 LimeGreen=80ff00 " +
|
|
188
196
|
"YellowGreen=8fff42 SpringGreen=bdff3d OliveGreen=009900 RawSienna=8c0000 Sepia=4d0000 Brown=660000 " +
|
|
189
197
|
"Tan=db9470 Gray=808080 Black=000000 White=ffffff " +
|
|
190
|
-
// Pajek's own names, not in dvips: the RGB fill of each swatch in the Pajek 6.02 manual, Figure 19, p. 105
|
|
191
|
-
// (http://mrvar.fdv.uni-lj.si/pajek/pajekman.pdf); Pajek's SVG export draws LightCyan as rgb(204,255,255) too.
|
|
192
198
|
"LightYellow=ffff99 LightCyan=ccffff LightMagenta=ffccff LightPurple=ccccff LightGreen=ccffb3 " +
|
|
193
|
-
"LightOrange=
|
|
199
|
+
"LightOrange=ffd9bc Canary=ffff80 LFadedGreen=e6ffcc Pink=ffd9f2 LSkyBlue=d9f2ff",
|
|
194
200
|
);
|
|
195
201
|
|
|
196
202
|
/** Java's `java.awt.Color` constants, lowercase, with and without the underscore. */
|
|
@@ -405,6 +405,76 @@ function cssColor(text: string): { hex: StyleColor; alpha: number } | null {
|
|
|
405
405
|
return hexColor(text, false) ?? cssFunction(text);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
* sigma.js's `rgb()` / `rgba()` reader (sigma/utils parseColor, the regex
|
|
410
|
+
* `^\s*rgba?\s*\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)(?:\s*,\s*(.*)?)?\)\s*$`), read without backtracking: integer
|
|
411
|
+
* channels, no space before the `)` unless an alpha follows, the alpha on one line.
|
|
412
|
+
* @param text - the value
|
|
413
|
+
* @returns the three channels' digits and the alpha's text (empty when none), or null
|
|
414
|
+
*/
|
|
415
|
+
function sigmaRgba(text: string): [string, string, string, string] | null {
|
|
416
|
+
const t = text.trim();
|
|
417
|
+
const head = /^rgba?\s*\(/.exec(t);
|
|
418
|
+
if (head === null || !t.endsWith(")")) {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
const parts = t.slice(head[0].length, -1).split(",");
|
|
422
|
+
if (parts.length < 3) {
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
const alpha = parts.slice(3).join(",").trimStart();
|
|
426
|
+
// the third channel runs up to the `)` when no alpha follows it
|
|
427
|
+
const third = parts.length > 3 ? parts[2].trim() : parts[2].trimStart();
|
|
428
|
+
const channels = [parts[0].trim(), parts[1].trim(), third];
|
|
429
|
+
if (!channels.every((c) => /^\d*$/.test(c)) || /[\n\r\u2028\u2029]/.test(alpha)) {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
return [channels[0], channels[1], channels[2], alpha];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* A color as sigma.js 4.0.1 reads it (sigma/utils parseColor), untrimmed: `transparent`, the 148 HTML color names in
|
|
437
|
+
* any case, `#rgb`, `#rrggbb` and `#rrggbbaa` (any other length is read two digits a channel, so `#f80c` is
|
|
438
|
+
* `#f80c00`), and `rgb()` / `rgba()` with integer channels. Anything else, the empty string included, is black.
|
|
439
|
+
* @param text - the value as the file has it
|
|
440
|
+
* @returns the color and its alpha, and whether sigma read it as a color (else it is black, or garbled)
|
|
441
|
+
*/
|
|
442
|
+
function sigmaColor(text: string): { color: StyleColor; alpha: number; read: boolean } {
|
|
443
|
+
const lower = text.toLowerCase();
|
|
444
|
+
if (lower === "transparent") {
|
|
445
|
+
return { color: "#000000", alpha: 0, read: true };
|
|
446
|
+
}
|
|
447
|
+
const named = CSS_COLORS.get(lower);
|
|
448
|
+
if (named !== undefined) {
|
|
449
|
+
return sigmaColor(named);
|
|
450
|
+
}
|
|
451
|
+
let rgb = [0, 0, 0];
|
|
452
|
+
let a = 1;
|
|
453
|
+
let read = false;
|
|
454
|
+
if (text.startsWith("#")) {
|
|
455
|
+
read = /^#(?:[\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/i.test(text);
|
|
456
|
+
const at = text.length === 4 ? [1, 1, 2, 2, 3, 3] : [1, 2, 3, 4, 5, 6];
|
|
457
|
+
// parseInt reads a leading run of hex digits; NaN (no digit) is stored as 0
|
|
458
|
+
rgb = [0, 2, 4].map((k) => Number.parseInt(text.charAt(at[k]) + text.charAt(at[k + 1]), 16) || 0);
|
|
459
|
+
if (text.length === 9) {
|
|
460
|
+
a = Number.parseInt(text.slice(7, 9), 16) / 255;
|
|
461
|
+
}
|
|
462
|
+
} else {
|
|
463
|
+
const m = sigmaRgba(text);
|
|
464
|
+
if (m !== null) {
|
|
465
|
+
read = true;
|
|
466
|
+
rgb = [Number(m[0]), Number(m[1]), Number(m[2])];
|
|
467
|
+
if (m[3]) {
|
|
468
|
+
a = Number(m[3]);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
// sigma packs each channel into a byte (ponytail: a channel over 255 wraps here; sigma lets it spill into the
|
|
473
|
+
// next channel)
|
|
474
|
+
const [r, g, b] = rgb.map((v) => v & 255);
|
|
475
|
+
return { color: rgbHex(r, g, b), alpha: ((a * 255) & 255) / 255, read };
|
|
476
|
+
}
|
|
477
|
+
|
|
408
478
|
/** One of Pajek's decimal color channels in `RGB(1,0.8,0)`: 0..1, no spaces (Pajek 6.02 manual p. 76). */
|
|
409
479
|
const PAJEK_CHANNEL = /^(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
410
480
|
|
|
@@ -478,9 +548,11 @@ function channels(raw: object): { hex: StyleColor; alpha: number } | null {
|
|
|
478
548
|
/**
|
|
479
549
|
* A canonical color in the file's dialect, or null with a note.
|
|
480
550
|
*
|
|
481
|
-
* - CSS (`css`, `vis`, `
|
|
551
|
+
* - CSS (`css`, `vis`, `cytoscape-js`, `graphty` and any dialect not listed): `#rgb`, `#rgba`,
|
|
482
552
|
* `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()`, `hsl()`, `hsla()`, CSS names and `transparent`, resolved as
|
|
483
553
|
* graphty-element resolves them (out-of-range channels are gamut mapped).
|
|
554
|
+
* - `graphology`: sigma.js's own parser (see `sigmaColor`); a string it cannot read is BLACK, with a note, because
|
|
555
|
+
* that is what sigma draws, and a value that is not a string is null (sigma throws on it).
|
|
484
556
|
* - `graphviz`: Graphviz's own rules (see `graphvizColor`); an unknown color is BLACK, with a note, because that is
|
|
485
557
|
* what Graphviz draws. `x11`: the same names, and an unknown one is null.
|
|
486
558
|
* - `java`, `gephi`, `cytoscape`: the `java.awt.Color` names first, then CSS; a `java` integer is an RGB value.
|
|
@@ -511,6 +583,12 @@ export function canonColor(
|
|
|
511
583
|
const v = raw >>> 0;
|
|
512
584
|
return { color: rgbHex((v >>> 16) & 255, (v >>> 8) & 255, v & 255), alpha: 1 };
|
|
513
585
|
}
|
|
586
|
+
if (dialect === "graphology" && typeof raw === "string" && raw.trim() === "") {
|
|
587
|
+
// sigma draws a blank color black, where every other reader has no color
|
|
588
|
+
spendAt(site, 1);
|
|
589
|
+
noteAt(site, STYLE_ISSUE.BAD_VALUE, raw);
|
|
590
|
+
return { color: "#000000", alpha: 1 };
|
|
591
|
+
}
|
|
514
592
|
const text = scalarText(raw, site);
|
|
515
593
|
if (text === null) {
|
|
516
594
|
return null;
|
|
@@ -518,6 +596,9 @@ export function canonColor(
|
|
|
518
596
|
if (dialect === "graphviz" || dialect === "x11") {
|
|
519
597
|
return graphvizCanon(text, dialect === "x11" ? "x11" : "graphviz", site, options);
|
|
520
598
|
}
|
|
599
|
+
if (dialect === "graphology") {
|
|
600
|
+
return graphologyColor(raw, text, site);
|
|
601
|
+
}
|
|
521
602
|
const c = textColor(text.trim(), dialect);
|
|
522
603
|
if (c === null) {
|
|
523
604
|
noteAt(site, STYLE_ISSUE.BAD_VALUE, text);
|
|
@@ -526,6 +607,26 @@ export function canonColor(
|
|
|
526
607
|
return { color: c.hex, alpha: c.alpha };
|
|
527
608
|
}
|
|
528
609
|
|
|
610
|
+
/**
|
|
611
|
+
* A graphology color as sigma.js draws it; a value that is not a string is no color, as sigma throws drawing it.
|
|
612
|
+
* @param raw - the file's value
|
|
613
|
+
* @param text - the value as text
|
|
614
|
+
* @param site - where it was read
|
|
615
|
+
* @returns the color and its alpha, or null
|
|
616
|
+
*/
|
|
617
|
+
function graphologyColor(raw: unknown, text: string, site: CanonSite): CanonColor | null {
|
|
618
|
+
if (typeof raw !== "string") {
|
|
619
|
+
// sigma throws while drawing a color that is not a string
|
|
620
|
+
noteAt(site, STYLE_ISSUE.BAD_VALUE, text);
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
623
|
+
const c = sigmaColor(text);
|
|
624
|
+
if (!c.read) {
|
|
625
|
+
noteAt(site, STYLE_ISSUE.BAD_VALUE, text);
|
|
626
|
+
}
|
|
627
|
+
return { color: c.color, alpha: c.alpha };
|
|
628
|
+
}
|
|
629
|
+
|
|
529
630
|
/**
|
|
530
631
|
* A color given as an object: only GEXF and Gephi write one, as channels.
|
|
531
632
|
* @param raw - the object
|
|
@@ -557,10 +658,11 @@ function graphvizCanon(
|
|
|
557
658
|
site: CanonSite,
|
|
558
659
|
options: CanonColorOptions,
|
|
559
660
|
): CanonColor | null {
|
|
560
|
-
const
|
|
661
|
+
const x11 = dialect === "x11";
|
|
662
|
+
const g = graphvizColor(text, x11 ? null : (options.scheme ?? null), options.use ?? "line", !x11);
|
|
561
663
|
if (g.unknown) {
|
|
562
664
|
noteAt(site, STYLE_ISSUE.BAD_VALUE, text);
|
|
563
|
-
if (
|
|
665
|
+
if (x11) {
|
|
564
666
|
return null;
|
|
565
667
|
}
|
|
566
668
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical enumeration values: each dialect's spellings matched against an alias table without regard to case,
|
|
3
3
|
* spaces or underscores. An unknown value of an open enumeration (shapes, border and line styles, arrows) is kept as
|
|
4
|
-
* `other:<raw>` and noted; an unknown value of a closed one (weights, positions) gives no value and is noted.
|
|
4
|
+
* `other:<raw>` and noted; an unknown value of a closed one (weights, positions, label fits) gives no value and is noted.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { STYLE_ISSUE } from "../codes.js";
|
|
@@ -12,7 +12,17 @@ import { type CanonSite, noteAt, scalarText } from "./site.js";
|
|
|
12
12
|
* The enumerations a style value can belong to.
|
|
13
13
|
* @category Styles
|
|
14
14
|
*/
|
|
15
|
-
export type StyleEnumKind =
|
|
15
|
+
export type StyleEnumKind =
|
|
16
|
+
| "shape"
|
|
17
|
+
| "borderStyle"
|
|
18
|
+
| "borderPosition"
|
|
19
|
+
| "lineStyle"
|
|
20
|
+
| "arrow"
|
|
21
|
+
| "arrowSide"
|
|
22
|
+
| "weight"
|
|
23
|
+
| "position"
|
|
24
|
+
| "labelFit"
|
|
25
|
+
| "textAlign";
|
|
16
26
|
|
|
17
27
|
type Aliases = Readonly<Record<string, readonly string[]>>;
|
|
18
28
|
|
|
@@ -55,16 +65,34 @@ const SHAPES: Aliases = {
|
|
|
55
65
|
"roundedrectangle",
|
|
56
66
|
"round-rect",
|
|
57
67
|
"mrecord",
|
|
58
|
-
"cut-rectangle",
|
|
59
68
|
"round-tag",
|
|
60
69
|
"bottom-round-rectangle",
|
|
70
|
+
"bottomroundrectangle",
|
|
61
71
|
],
|
|
62
72
|
triangle: ["triangle", "invtriangle", "round-triangle", "tag"],
|
|
63
73
|
diamond: ["diamond", "rhombus", "mdiamond", "round-diamond"],
|
|
64
74
|
pentagon: ["pentagon", "round-pentagon"],
|
|
65
|
-
hexagon: [
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
hexagon: [
|
|
76
|
+
"hexagon",
|
|
77
|
+
"hexagon2",
|
|
78
|
+
"round-hexagon",
|
|
79
|
+
"concave-hexagon",
|
|
80
|
+
"concavehexagon",
|
|
81
|
+
"septagon",
|
|
82
|
+
"heptagon",
|
|
83
|
+
"round-heptagon",
|
|
84
|
+
],
|
|
85
|
+
// a cut rectangle is a rectangle with its four corners cut off: eight sides
|
|
86
|
+
octagon: [
|
|
87
|
+
"octagon",
|
|
88
|
+
"doubleoctagon",
|
|
89
|
+
"tripleoctagon",
|
|
90
|
+
"round-octagon",
|
|
91
|
+
"octagon2",
|
|
92
|
+
"cut-rectangle",
|
|
93
|
+
"cutrectangle",
|
|
94
|
+
],
|
|
95
|
+
parallelogram: ["parallelogram", "parallelogram2", "rhomboid", "right-rhomboid", "fat-arrow", "fatarrow"],
|
|
68
96
|
trapezoid: ["trapezoid", "trapezoid2", "invtrapezoid", "trapezium", "round-trapezoid"],
|
|
69
97
|
star: ["star", "star5", "star6", "star8", "polygon"],
|
|
70
98
|
vee: ["vee", "v"],
|
|
@@ -136,6 +164,35 @@ const POSITIONS: Aliases = {
|
|
|
136
164
|
"bottom-left": ["bottom-left", "south-west", "southwest"],
|
|
137
165
|
"bottom-right": ["bottom-right", "south-east", "southeast"],
|
|
138
166
|
"inside-top": ["inside-top"],
|
|
167
|
+
"inside-bottom": ["inside-bottom"],
|
|
168
|
+
"inside-left": ["inside-left"],
|
|
169
|
+
"inside-right": ["inside-right"],
|
|
170
|
+
"inside-top-left": ["inside-top-left"],
|
|
171
|
+
"inside-top-right": ["inside-top-right"],
|
|
172
|
+
"inside-bottom-left": ["inside-bottom-left"],
|
|
173
|
+
"inside-bottom-right": ["inside-bottom-right"],
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const BORDER_POSITIONS: Aliases = {
|
|
177
|
+
inside: ["inside"],
|
|
178
|
+
center: ["center", "centre", "middle"],
|
|
179
|
+
outside: ["outside"],
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const ARROW_SIDES: Aliases = {
|
|
183
|
+
left: ["left"],
|
|
184
|
+
right: ["right"],
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const TEXT_ALIGNS: Aliases = {
|
|
188
|
+
left: ["left", "start"],
|
|
189
|
+
center: ["center", "centre", "middle"],
|
|
190
|
+
right: ["right", "end"],
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const LABEL_FITS: Aliases = {
|
|
194
|
+
inside: ["inside"],
|
|
195
|
+
bounds: ["bounds"],
|
|
139
196
|
};
|
|
140
197
|
|
|
141
198
|
/** vis-network draws these spellings differently from the common reading. */
|
|
@@ -146,11 +203,49 @@ const VIS: Partial<Record<StyleEnumKind, Aliases>> = {
|
|
|
146
203
|
triangle: ["triangledown"],
|
|
147
204
|
none: ["text"],
|
|
148
205
|
},
|
|
149
|
-
|
|
206
|
+
// curve and inv_curve: an arc at the end, bulging toward the node and away from it
|
|
207
|
+
arrow: { inverted: ["inv-triangle"], square: ["box"], "other:curve": ["curve"], "other:inv-curve": ["inv-curve"] },
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Cytoscape.js's compound arrows (https://js.cytoscape.org/#style/edge-arrow): a triangle with a bar behind it, with a
|
|
212
|
+
* thin bar across the line behind it, a dot with a triangle behind it and its short chevron each keep their own name;
|
|
213
|
+
* its triangle-backcurve is a triangle whose back is hollowed out, which is how a vee is drawn.
|
|
214
|
+
*/
|
|
215
|
+
const CYJS: Partial<Record<StyleEnumKind, Aliases>> = {
|
|
216
|
+
arrow: {
|
|
217
|
+
"other:triangle-tee": ["triangle-tee"],
|
|
218
|
+
"other:triangle-cross": ["triangle-cross"],
|
|
219
|
+
"other:circle-triangle": ["circle-triangle"],
|
|
220
|
+
// a vee two thirds as long as its triangle (0.2 of the arrow width against 0.3)
|
|
221
|
+
"other:chevron": ["chevron"],
|
|
222
|
+
vee: ["triangle-backcurve"],
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Graphviz's curve and icurve (lib/common/arrows.c arrow_type_curve): a stem to the tip with an arc across it, bulging
|
|
228
|
+
* toward the tip and, inverted, away from it -- vis-network's curve and inv_curve.
|
|
229
|
+
*/
|
|
230
|
+
const GRAPHVIZ: Partial<Record<StyleEnumKind, Aliases>> = {
|
|
231
|
+
arrow: { "other:curve": ["curve"], "other:inv-curve": ["icurve"] },
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* yEd's (yFiles for Java's) STANDARD arrow is "a triangle with impressed bottom side", a notched arrow; its DELTA is the
|
|
236
|
+
* plain triangle (https://docs.yworks.com/yfiles/doc/api/y/view/Arrow.html).
|
|
237
|
+
*/
|
|
238
|
+
const YED: Partial<Record<StyleEnumKind, Aliases>> = {
|
|
239
|
+
arrow: { vee: ["standard"] },
|
|
150
240
|
};
|
|
151
241
|
|
|
152
242
|
/** Per-dialect overrides; a dialect not listed reads the common table alone. */
|
|
153
|
-
const OVERRIDES: ReadonlyMap<string, Partial<Record<StyleEnumKind, Aliases>>> = new Map([
|
|
243
|
+
const OVERRIDES: ReadonlyMap<string, Partial<Record<StyleEnumKind, Aliases>>> = new Map([
|
|
244
|
+
["vis", VIS],
|
|
245
|
+
["graphviz", GRAPHVIZ],
|
|
246
|
+
["cytoscape-js", CYJS],
|
|
247
|
+
["yed", YED],
|
|
248
|
+
]);
|
|
154
249
|
|
|
155
250
|
const OPEN: ReadonlySet<StyleEnumKind> = new Set<StyleEnumKind>(["shape", "borderStyle", "lineStyle", "arrow"]);
|
|
156
251
|
|
|
@@ -174,8 +269,12 @@ const COMMON: ReadonlyMap<StyleEnumKind, ReadonlyMap<string, string>> = new Map(
|
|
|
174
269
|
["borderStyle", lookup(BORDER_STYLES)],
|
|
175
270
|
["lineStyle", lookup(LINE_STYLES)],
|
|
176
271
|
["arrow", lookup(ARROWS)],
|
|
272
|
+
["arrowSide", lookup(ARROW_SIDES)],
|
|
177
273
|
["weight", lookup(WEIGHTS)],
|
|
178
274
|
["position", lookup(POSITIONS)],
|
|
275
|
+
["labelFit", lookup(LABEL_FITS)],
|
|
276
|
+
["borderPosition", lookup(BORDER_POSITIONS)],
|
|
277
|
+
["textAlign", lookup(TEXT_ALIGNS)],
|
|
179
278
|
]);
|
|
180
279
|
|
|
181
280
|
const DIALECT: ReadonlyMap<string, ReadonlyMap<StyleEnumKind, ReadonlyMap<string, string>>> = new Map(
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* scheme knows no names at all.
|
|
13
13
|
* - `transparent`, `none` and `invis` are `#fffffe` with alpha 0, whatever the scheme.
|
|
14
14
|
* - An unknown color is drawn BLACK.
|
|
15
|
+
* - A bare name SVG knows (`gray`, `purple`, `green`, `maroon`, `crimson` ...), not in a `/scheme/` and with no
|
|
16
|
+
* leading blanks, is drawn as the SVG color, whatever the scheme: Graphviz's SVG output writes such a name as it is
|
|
17
|
+
* (`fill="gray"`, gvrender_resolve_color) and every SVG reader draws it as CSS does, so `gray` is #808080 there,
|
|
18
|
+
* not X11's #c0c0c0. The SVG drawing is the one we read Graphviz by.
|
|
19
|
+
* - An outline or font color list whose first entry is such a name is written whole (`stroke="red:blue"`: Graphviz
|
|
20
|
+
* resolves the first entry in place and puts the `:` back), which no SVG reader can draw: an outline is not drawn
|
|
21
|
+
* and a text is black, SVG's own default.
|
|
15
22
|
* - A color list (`red:blue`, `red;0.3:blue`): an outline or a font color draws the text before the first `:` as one
|
|
16
23
|
* color, so `red:blue` is red and `red;0.3:blue` is black (`red;0.3` is not a color). A fill draws a gradient and
|
|
17
24
|
* an edge draws one line per color; both start with the first entry's color, its `;fraction` dropped. A value
|
|
@@ -24,7 +31,7 @@ import { BREWER_SCHEMES, CSS_COLORS, X11_COLORS } from "./color-tables.js";
|
|
|
24
31
|
* How Graphviz draws a color value, which decides how a color list is read.
|
|
25
32
|
* @category Styles
|
|
26
33
|
*/
|
|
27
|
-
export type GraphvizColorUse = "line" | "fill" | "edge";
|
|
34
|
+
export type GraphvizColorUse = "line" | "text" | "fill" | "edge";
|
|
28
35
|
|
|
29
36
|
/**
|
|
30
37
|
* A resolved Graphviz color, with how it was read.
|
|
@@ -159,30 +166,84 @@ function schemeColor(name: string, scheme: string): string | undefined {
|
|
|
159
166
|
return colors !== undefined && index >= 1 ? colors[index - 1] : undefined;
|
|
160
167
|
}
|
|
161
168
|
|
|
169
|
+
/**
|
|
170
|
+
* A color list whose first color is a bare SVG name, as Graphviz's SVG output draws it for a pen: no outline, black
|
|
171
|
+
* text.
|
|
172
|
+
* @param use - `line` or `text`
|
|
173
|
+
* @returns the color
|
|
174
|
+
*/
|
|
175
|
+
function svgPenList(use: GraphvizColorUse): GraphvizColor {
|
|
176
|
+
return use === "line"
|
|
177
|
+
? { hex: "#fffffe", alpha: 0, unknown: false, list: null }
|
|
178
|
+
: { hex: "#000000", alpha: 1, unknown: false, list: null };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A color list entry without its `;fraction`.
|
|
183
|
+
* @param text - the entry
|
|
184
|
+
* @returns the color part
|
|
185
|
+
*/
|
|
186
|
+
function beforeSemicolon(text: string): string {
|
|
187
|
+
const semi = text.indexOf(";");
|
|
188
|
+
return semi >= 0 ? text.slice(0, semi) : text;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* One Graphviz color, read from its scheme (X11 when none), a bare SVG name first when `svgNames` says so.
|
|
193
|
+
* @param raw - the whole value
|
|
194
|
+
* @param text - the color, without the list after it
|
|
195
|
+
* @param scheme - the object's `colorscheme`, or null
|
|
196
|
+
* @param svgNames - whether a bare SVG name is drawn as SVG's color
|
|
197
|
+
* @returns the color, or null when it is unknown
|
|
198
|
+
*/
|
|
199
|
+
function resolveColorText(
|
|
200
|
+
raw: string,
|
|
201
|
+
text: string,
|
|
202
|
+
scheme: string | null,
|
|
203
|
+
svgNames: boolean,
|
|
204
|
+
): { hex: string; alpha: number } | null {
|
|
205
|
+
const svgName = svgNames && raw.startsWith(text) ? CSS_COLORS.get(text.toLowerCase()) : undefined;
|
|
206
|
+
if (svgName !== undefined) {
|
|
207
|
+
return { hex: svgName, alpha: 1 };
|
|
208
|
+
}
|
|
209
|
+
if (text === "") {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const sc = scheme === null || scheme.trim() === "" ? "x11" : scheme.toLowerCase();
|
|
213
|
+
return resolveOne(text, sc);
|
|
214
|
+
}
|
|
215
|
+
|
|
162
216
|
/**
|
|
163
217
|
* Resolves a Graphviz color value the way Graphviz draws it for a use; an unknown color is black.
|
|
164
218
|
* @param raw - the value, at most 256 characters
|
|
165
219
|
* @param scheme - the object's `colorscheme`, or null
|
|
166
|
-
* @param use - an outline
|
|
220
|
+
* @param use - an outline color (`line`), a font color (`text`), a fill, or an edge's line color
|
|
221
|
+
* @param svgNames - whether a bare SVG name is drawn as SVG's color, as Graphviz's SVG output draws it (false: as
|
|
222
|
+
* every other Graphviz output draws it)
|
|
167
223
|
* @returns the color and how it was read
|
|
168
224
|
* @category Styles
|
|
169
225
|
*/
|
|
170
|
-
export function graphvizColor(
|
|
226
|
+
export function graphvizColor(
|
|
227
|
+
raw: string,
|
|
228
|
+
scheme: string | null,
|
|
229
|
+
use: GraphvizColorUse,
|
|
230
|
+
svgNames = true,
|
|
231
|
+
): GraphvizColor {
|
|
171
232
|
let text = raw.replace(/^[ \t\r\n]+/, "");
|
|
172
233
|
let list: GraphvizColor["list"] = null;
|
|
173
234
|
const colon = text.indexOf(":");
|
|
235
|
+
const pen = use === "line" || use === "text";
|
|
174
236
|
if (colon >= 0) {
|
|
175
237
|
text = text.slice(0, colon);
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
238
|
+
if (svgNames && pen && raw.startsWith(text) && CSS_COLORS.has(text.toLowerCase())) {
|
|
239
|
+
return svgPenList(use);
|
|
240
|
+
}
|
|
241
|
+
if (!pen) {
|
|
242
|
+
text = beforeSemicolon(text);
|
|
181
243
|
list = use === "fill" ? "gradient" : "lines";
|
|
182
244
|
}
|
|
183
245
|
}
|
|
184
|
-
const
|
|
185
|
-
const resolved = text === "" ? null : resolveOne(text, sc);
|
|
246
|
+
const resolved = resolveColorText(raw, text, scheme, svgNames);
|
|
186
247
|
return resolved === null
|
|
187
248
|
? { hex: "#000000", alpha: 1, unknown: true, list }
|
|
188
249
|
: { hex: resolved.hex, alpha: resolved.alpha, unknown: false, list };
|
|
@@ -82,6 +82,25 @@ export function canonNumber(raw: unknown, site: CanonSite, factor = 1): number |
|
|
|
82
82
|
return num6(scaled);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* A signed number (an offset): any finite value within the largest a style number may be, either way.
|
|
87
|
+
* @param raw - the file's value
|
|
88
|
+
* @param site - where it was read
|
|
89
|
+
* @returns the canonical number, or null (noted)
|
|
90
|
+
* @category Styles
|
|
91
|
+
*/
|
|
92
|
+
export function canonSigned(raw: unknown, site: CanonSite): number | null {
|
|
93
|
+
const value = finite(raw, site);
|
|
94
|
+
if (value === null) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
if (Math.abs(value) > MAX_STYLE_NUMBER) {
|
|
98
|
+
noteAt(site, STYLE_ISSUE.BAD_VALUE, typeof raw === "string" ? raw : String(raw));
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return num6(value);
|
|
102
|
+
}
|
|
103
|
+
|
|
85
104
|
/**
|
|
86
105
|
* An opacity from 0 to 1. Cytoscape desktop states opacities from 0 to 255 and is divided by 255; every other
|
|
87
106
|
* dialect states 0 to 1. A value outside the dialect's range is null with a `W_STYLE_BAD_VALUE` note.
|