@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
|
@@ -36,7 +36,9 @@ import { STYLE_ISSUE } from "../codes.js";
|
|
|
36
36
|
import { StyleNotes } from "../notes.js";
|
|
37
37
|
import { canonicalFor, degreeValues, evalContinuous, numberOf, plainCell } from "../plan/resolve.js";
|
|
38
38
|
import { CYJS_DEFAULT_STYLESHEET, CYJS_PROPERTY_DEFAULTS } from "./defaults-table.js";
|
|
39
|
-
import {
|
|
39
|
+
import { combineFace } from "./face.js";
|
|
40
|
+
import { applyCyjsMapper, CYJS_CURVE_STYLES, CYJS_THROWS, cyjsAliasOf, cyjsDashLook, cyjsNeutral, cyjsPolygonShapes, cyjsProperties, cyjsPropertyName, cyjsRendered, gradientStopColors, gradientStops, parseCyjsValue, } from "./mappers.js";
|
|
41
|
+
import { cyjsRoute } from "./routes.js";
|
|
40
42
|
import { parseCyjsSelector } from "./selector.js";
|
|
41
43
|
import { parseCyjsStylesheetText } from "./stylesheet-text.js";
|
|
42
44
|
/**
|
|
@@ -927,6 +929,17 @@ const POSITIONS = new Map([
|
|
|
927
929
|
["bottom,center", "bottom"],
|
|
928
930
|
["bottom,right", "bottom-right"],
|
|
929
931
|
]);
|
|
932
|
+
/** The positions inside the node, by the sides the `-inside` alignments name (`center` for neither). */
|
|
933
|
+
const INSIDE_POSITIONS = new Map([
|
|
934
|
+
["top,left", "inside-top-left"],
|
|
935
|
+
["top,center", "inside-top"],
|
|
936
|
+
["top,right", "inside-top-right"],
|
|
937
|
+
["center,left", "inside-left"],
|
|
938
|
+
["center,right", "inside-right"],
|
|
939
|
+
["bottom,left", "inside-bottom-left"],
|
|
940
|
+
["bottom,center", "inside-bottom"],
|
|
941
|
+
["bottom,right", "inside-bottom-right"],
|
|
942
|
+
]);
|
|
930
943
|
/**
|
|
931
944
|
* Applies a Cytoscape.js stylesheet to its elements as Cytoscape.js 3.34 does.
|
|
932
945
|
* @param input - the elements, the stylesheet, the graph and the options
|
|
@@ -977,8 +990,8 @@ export function evaluateCytoscapeJs(input) {
|
|
|
977
990
|
notes.add(STYLE_ISSUE.SELECTOR, null, "selector", { count: deep, sample: "nested too deep" });
|
|
978
991
|
}
|
|
979
992
|
const matcher = new Matcher(graph, notes);
|
|
980
|
-
const node = evaluateTarget("node", graph, sheet, matcher, input, notes, budget);
|
|
981
|
-
const edge = evaluateTarget("edge", graph, sheet, matcher, input, notes, budget);
|
|
993
|
+
const node = evaluateTarget("node", graph, sheet, matcher, input, { notes, budget, nodes: null });
|
|
994
|
+
const edge = evaluateTarget("edge", graph, sheet, matcher, input, { notes, budget, nodes: node });
|
|
982
995
|
return { node, edge, graph };
|
|
983
996
|
}
|
|
984
997
|
/**
|
|
@@ -1059,11 +1072,14 @@ function cellsOf(cells, name, n) {
|
|
|
1059
1072
|
* @param sheet - the entries
|
|
1060
1073
|
* @param matcher - the selector evaluator
|
|
1061
1074
|
* @param input - the input
|
|
1062
|
-
* @param
|
|
1063
|
-
* @param
|
|
1075
|
+
* @param env - where problems are noted, the counted budget, and for edges the nodes' values
|
|
1076
|
+
* @param env.notes - where problems are noted
|
|
1077
|
+
* @param env.budget - the counted budget
|
|
1078
|
+
* @param env.nodes - the nodes' values, which edge routes are measured against (null for nodes)
|
|
1064
1079
|
* @returns the target's values and rules
|
|
1065
1080
|
*/
|
|
1066
|
-
function evaluateTarget(kind, graph, sheet, matcher, input,
|
|
1081
|
+
function evaluateTarget(kind, graph, sheet, matcher, input, env) {
|
|
1082
|
+
const { notes, budget } = env;
|
|
1067
1083
|
const els = kind === "node" ? graph.nodes : graph.edges;
|
|
1068
1084
|
const spend = (ops) => {
|
|
1069
1085
|
budget.spend(kind, ops);
|
|
@@ -1081,6 +1097,22 @@ function evaluateTarget(kind, graph, sheet, matcher, input, notes, budget) {
|
|
|
1081
1097
|
forceLoopCurves(graph, cells.get("curve-style"));
|
|
1082
1098
|
}
|
|
1083
1099
|
const drawn = drawnValues(kind, els, cells, order, input.rendered, notes, spend);
|
|
1100
|
+
// a file read with Cytoscape.js's own defaults draws an edge no rule curves as a haystack (a file graphty wrote
|
|
1101
|
+
// is read with graphty's)
|
|
1102
|
+
if (kind === "edge" && input.toolDefaults !== false) {
|
|
1103
|
+
const read = { kind, els, cells, order, rendered: input.rendered, notes };
|
|
1104
|
+
const curves = drawnColumn(read, "curve-style", CURVE_PART);
|
|
1105
|
+
noArrowsOnHaystacks(curves, drawn);
|
|
1106
|
+
if (env.nodes !== null) {
|
|
1107
|
+
edgeRoutes(graph, read, curves, env.nodes, drawn);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (kind === "node") {
|
|
1111
|
+
const read = { kind, els, cells, order, rendered: input.rendered, notes };
|
|
1112
|
+
nodeSizes(graph, read, drawn);
|
|
1113
|
+
groupBoxes(graph, read, drawn);
|
|
1114
|
+
mixedLabelPlaces(graph, read, drawn);
|
|
1115
|
+
}
|
|
1084
1116
|
if (kind === "edge") {
|
|
1085
1117
|
straightenUnpairedBeziers(graph, curveStyles(graph, cells, input.rendered), coreToOut, drawn.curved);
|
|
1086
1118
|
}
|
|
@@ -1231,7 +1263,7 @@ function drawnValues(kind, els, cells, order, rendered, notes, spend) {
|
|
|
1231
1263
|
const col = drawnColumn(drawnOf, name, spec);
|
|
1232
1264
|
spend(2 * out);
|
|
1233
1265
|
if (spec.property.startsWith("_")) {
|
|
1234
|
-
words.set(spec.property, col.map((v) => (typeof v === "string" ? v : null)));
|
|
1266
|
+
words.set(spec.property, col.map((v) => (typeof v === "string" || typeof v === "number" ? String(v) : null)));
|
|
1235
1267
|
continue;
|
|
1236
1268
|
}
|
|
1237
1269
|
values[_a = spec.property] ?? (values[_a] = new Array(out).fill(null));
|
|
@@ -1243,6 +1275,9 @@ function drawnValues(kind, els, cells, order, rendered, notes, spend) {
|
|
|
1243
1275
|
});
|
|
1244
1276
|
}
|
|
1245
1277
|
combineParts(kind, out, words, values, notes);
|
|
1278
|
+
if (kind === "node") {
|
|
1279
|
+
cyjsPolygonShapes(values);
|
|
1280
|
+
}
|
|
1246
1281
|
const drawn = {};
|
|
1247
1282
|
for (const [p, col] of Object.entries(values)) {
|
|
1248
1283
|
if (col.some((v) => v !== null)) {
|
|
@@ -1389,7 +1424,7 @@ function forceLoopCurves(graph, col) {
|
|
|
1389
1424
|
function entryProperties(entry, kind, specs, notes, notCarried) {
|
|
1390
1425
|
const out = [];
|
|
1391
1426
|
for (const [name0, value] of entry.properties) {
|
|
1392
|
-
const name = entry.dashOnly ?
|
|
1427
|
+
const name = entry.dashOnly ? cyjsAliasOf(name0) : cyjsPropertyName(name0);
|
|
1393
1428
|
const spec = specs.get(name);
|
|
1394
1429
|
if (spec === undefined) {
|
|
1395
1430
|
if (kind === "node" && !CYJS_EDGE_ONLY.has(name) && !entry.tool) {
|
|
@@ -1409,28 +1444,39 @@ function entryProperties(entry, kind, specs, notes, notCarried) {
|
|
|
1409
1444
|
}
|
|
1410
1445
|
return out;
|
|
1411
1446
|
}
|
|
1412
|
-
/**
|
|
1413
|
-
* A property name of an entry Cytoscape.js reads in dash form only: `content` is `label`, any other name as it is.
|
|
1414
|
-
* @param name - the name as written
|
|
1415
|
-
* @returns the name
|
|
1416
|
-
*/
|
|
1417
|
-
function dashOnlyName(name) {
|
|
1418
|
-
return name === "content" ? "label" : name;
|
|
1419
|
-
}
|
|
1420
1447
|
/** Edge properties a node never carries: not noted as dropped on nodes. */
|
|
1421
1448
|
const CYJS_EDGE_ONLY = new Set([
|
|
1422
1449
|
"line-color",
|
|
1423
1450
|
"line-style",
|
|
1451
|
+
"line-outline-width",
|
|
1452
|
+
"line-outline-color",
|
|
1453
|
+
"line-fill",
|
|
1454
|
+
"line-gradient-stop-colors",
|
|
1455
|
+
"line-gradient-stop-positions",
|
|
1424
1456
|
"target-arrow-shape",
|
|
1425
1457
|
"source-arrow-shape",
|
|
1426
1458
|
"target-arrow-color",
|
|
1427
1459
|
"source-arrow-color",
|
|
1460
|
+
"mid-target-arrow-shape",
|
|
1461
|
+
"mid-source-arrow-shape",
|
|
1462
|
+
"mid-target-arrow-color",
|
|
1463
|
+
"mid-source-arrow-color",
|
|
1428
1464
|
"target-arrow-fill",
|
|
1429
1465
|
"source-arrow-fill",
|
|
1430
1466
|
"curve-style",
|
|
1431
1467
|
"arrow-scale",
|
|
1432
1468
|
"source-label",
|
|
1433
1469
|
"target-label",
|
|
1470
|
+
"source-text-offset",
|
|
1471
|
+
"target-text-offset",
|
|
1472
|
+
"source-text-margin-x",
|
|
1473
|
+
"source-text-margin-y",
|
|
1474
|
+
"target-text-margin-x",
|
|
1475
|
+
"target-text-margin-y",
|
|
1476
|
+
"source-text-rotation",
|
|
1477
|
+
"target-text-rotation",
|
|
1478
|
+
"source-distance-from-node",
|
|
1479
|
+
"target-distance-from-node",
|
|
1434
1480
|
]);
|
|
1435
1481
|
/**
|
|
1436
1482
|
* The elements of a target a selector matches, in order.
|
|
@@ -1548,7 +1594,8 @@ function neutralOfCell(spec, name, c, site) {
|
|
|
1548
1594
|
return cyjsNeutral(spec, flat, site);
|
|
1549
1595
|
}
|
|
1550
1596
|
/**
|
|
1551
|
-
* Combines the label alignments into `labelPosition`
|
|
1597
|
+
* Combines the label alignments into `labelPosition`, `text-wrap` with `text-max-width` and `text-overflow-wrap` into
|
|
1598
|
+
* `labelWrapWidth`, `labelWrapEllipsis` and `labelWrapAnywhere`, and `visibility` with `display` into `visible`.
|
|
1552
1599
|
* @param kind - the target
|
|
1553
1600
|
* @param n - the element count
|
|
1554
1601
|
* @param words - the parts by internal name
|
|
@@ -1556,106 +1603,1114 @@ function neutralOfCell(spec, name, c, site) {
|
|
|
1556
1603
|
* @param notes - where problems are noted
|
|
1557
1604
|
*/
|
|
1558
1605
|
function combineParts(kind, n, words, values, notes) {
|
|
1606
|
+
// the element's own opacity, before an edge's line opacity is multiplied in: its label is drawn at it
|
|
1607
|
+
const whole = [...(values.opacity ?? new Array(n).fill(null))];
|
|
1608
|
+
combineLabelOpacity(n, words, values);
|
|
1609
|
+
if (kind === "node") {
|
|
1610
|
+
combineNodeOpacity(n, words, values);
|
|
1611
|
+
}
|
|
1559
1612
|
const va = words.get("_valign");
|
|
1560
1613
|
const ha = words.get("_halign");
|
|
1561
1614
|
if (kind === "node" && (va !== undefined || ha !== undefined)) {
|
|
1562
|
-
values.labelPosition = Array.from({ length: n }, (_, i) => labelPosition(va?.[i] ?? null, ha?.[i] ?? null
|
|
1563
|
-
|
|
1564
|
-
|
|
1615
|
+
values.labelPosition = Array.from({ length: n }, (_, i) => labelPosition(va?.[i] ?? null, ha?.[i] ?? null));
|
|
1616
|
+
}
|
|
1617
|
+
// `text-max-width` wraps a label only under `text-wrap: wrap`; unset there, it is 9999 (cytoscape.js 3.34.3
|
|
1618
|
+
// dist/cytoscape.cjs.js line 18484), which wraps nothing but the label's own line breaks.
|
|
1619
|
+
// `text-wrap: ellipsis` cuts the label at the same width instead (3.34.3 line 25254), and
|
|
1620
|
+
// `text-overflow-wrap: anywhere` breaks a wrapped one between any two letters (line 25204).
|
|
1621
|
+
const wrap = words.get("_wrap");
|
|
1622
|
+
const maxWidth = words.get("_maxWidth");
|
|
1623
|
+
const overflow = words.get("_overflowWrap");
|
|
1624
|
+
if (wrap !== undefined) {
|
|
1625
|
+
const cut = (i) => wrap[i] === "wrap" || wrap[i] === "ellipsis";
|
|
1626
|
+
values.labelWrapWidth = Array.from({ length: n }, (_, i) => cut(i) && typeof maxWidth?.[i] === "string" ? Number(maxWidth[i]) : null);
|
|
1627
|
+
if (wrap.includes("ellipsis")) {
|
|
1628
|
+
values.labelWrapEllipsis = wrap.map((w) => (w === "ellipsis" ? true : null));
|
|
1629
|
+
}
|
|
1630
|
+
if (overflow?.includes("anywhere") === true) {
|
|
1631
|
+
values.labelWrapAnywhere = wrap.map((w, i) => (w === "wrap" && overflow[i] === "anywhere" ? true : null));
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
if (kind === "node") {
|
|
1635
|
+
combineFace(n, words, values);
|
|
1636
|
+
combineBackgroundGradient(n, words, values, notes);
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
combineArrowFills(n, words, values, notes);
|
|
1640
|
+
combineLineOpacity(n, words.get("_lineOpacity"), values);
|
|
1641
|
+
}
|
|
1642
|
+
combineDashes(kind, n, words, values);
|
|
1643
|
+
combineLabelText(kind, n, words, values);
|
|
1644
|
+
combineLabelDress(kind, n, words, values, notes, whole);
|
|
1645
|
+
combineVisibility(kind, n, words, values);
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* A label's opacity as Cytoscape.js draws it: its `text-opacity` times the element's `opacity` (cytoscape.js 3.34.3
|
|
1649
|
+
* `drawText`: `effectiveOpacity() * text-opacity`), which the label's box and its line round it are drawn at too.
|
|
1650
|
+
* ponytail: a compound parent's opacity, which Cytoscape.js multiplies in as well, is left out
|
|
1651
|
+
* @param n - the element count
|
|
1652
|
+
* @param words - the parts by internal name
|
|
1653
|
+
* @param values - the values, `opacity` still the element's own; changed in place
|
|
1654
|
+
*/
|
|
1655
|
+
function combineLabelOpacity(n, words, values) {
|
|
1656
|
+
const text = words.get("_textOpacity");
|
|
1657
|
+
const whole = values.opacity;
|
|
1658
|
+
if (text === undefined && whole === undefined) {
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
const col = new Array(n).fill(null);
|
|
1662
|
+
for (let i = 0; i < n; i++) {
|
|
1663
|
+
const t = text?.[i] ?? null;
|
|
1664
|
+
const o = whole?.[i];
|
|
1665
|
+
const v = Math.round((t === null ? 1 : Number(t)) * (typeof o === "number" ? o : 1) * 1e6) / 1e6;
|
|
1666
|
+
// a label at full strength is left unset, as one no rule fades
|
|
1667
|
+
col[i] = v === 1 || !Number.isFinite(v) ? null : v;
|
|
1668
|
+
}
|
|
1669
|
+
values.labelOpacity = col;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* A node's border and outline as Cytoscape.js draws them: at their own `border-opacity` / `outline-opacity` times the
|
|
1673
|
+
* node's `opacity` (cytoscape.js 3.34.3 `drawNode`: `parentOpacity * borderOpacity`). A ring at full strength is left
|
|
1674
|
+
* unset.
|
|
1675
|
+
* @param n - the element count
|
|
1676
|
+
* @param words - the parts by internal name
|
|
1677
|
+
* @param values - the values, `opacity` still the node's own; changed in place
|
|
1678
|
+
*/
|
|
1679
|
+
function combineNodeOpacity(n, words, values) {
|
|
1680
|
+
const whole = values.opacity;
|
|
1681
|
+
for (const [part, p] of [
|
|
1682
|
+
["_ringOpacity", "borderOpacity"],
|
|
1683
|
+
["_outlineRingOpacity", "outerBorderOpacity"],
|
|
1684
|
+
]) {
|
|
1685
|
+
const own = words.get(part);
|
|
1686
|
+
if (own === undefined && whole === undefined) {
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
values[p] = Array.from({ length: n }, (_, i) => {
|
|
1690
|
+
const a = own?.[i] ?? null;
|
|
1691
|
+
const o = whole?.[i];
|
|
1692
|
+
const v = Math.round((a === null ? 1 : Number(a)) * (typeof o === "number" ? o : 1) * 1e6) / 1e6;
|
|
1693
|
+
return v === 1 || !Number.isFinite(v) ? null : v;
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* A dashed line or border as the line it looks like. Cytoscape.js draws `dashed` with `line-dash-pattern` (6 3) or
|
|
1699
|
+
* `border-dash-pattern` (4 2) in pixels whatever the width, and `dotted` as 1 1 (cytoscape.js 3.34.3 `drawEdgePath`,
|
|
1700
|
+
* `drawNode`), so a wide dashed line shows dots and a pattern of long and short dashes a dash-dot. The class is read
|
|
1701
|
+
* from the dashes and gaps against the width, a round or square cap lengthening each dash by the width.
|
|
1702
|
+
* ponytail: the neutral line styles name a class, not a pattern; a dash pattern slot would carry the lengths exactly
|
|
1703
|
+
* @param kind - the target
|
|
1704
|
+
* @param n - the element count
|
|
1705
|
+
* @param words - the parts by internal name
|
|
1706
|
+
* @param values - the values; changed in place
|
|
1707
|
+
*/
|
|
1708
|
+
function combineDashes(kind, n, words, values) {
|
|
1709
|
+
// the line or border, and a node's outline, which is always dashed 4 2 with butt ends (`drawOutline`)
|
|
1710
|
+
const lines = kind === "edge"
|
|
1711
|
+
? [["lineStyle", "width", 3, "6 3", true]]
|
|
1712
|
+
: [
|
|
1713
|
+
["borderStyle", "borderWidth", 0, "4 2", true],
|
|
1714
|
+
["outerBorderStyle", "outerBorderWidth", 0, "4 2", false],
|
|
1715
|
+
];
|
|
1716
|
+
for (const [style, width, fallback, pattern, own] of lines) {
|
|
1717
|
+
const col = values[style];
|
|
1718
|
+
if (col !== undefined) {
|
|
1719
|
+
dashColumn(col, n, values[width], { fallback, pattern }, own ? words : null);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* One line style's dashed lines as the lines they look like.
|
|
1725
|
+
* @param col - the line styles; changed in place
|
|
1726
|
+
* @param n - the element count
|
|
1727
|
+
* @param widths - the lines' widths, when set
|
|
1728
|
+
* @param drawn - what Cytoscape.js draws when they are not set: the width and the dash pattern
|
|
1729
|
+
* @param drawn.fallback - the width
|
|
1730
|
+
* @param drawn.pattern - the dash pattern
|
|
1731
|
+
* @param words - the parts by internal name, or null for an outline, which has no pattern or cap of its own
|
|
1732
|
+
*/
|
|
1733
|
+
function dashColumn(col, n, widths, drawn, words) {
|
|
1734
|
+
for (let i = 0; i < n; i++) {
|
|
1735
|
+
if (col[i] !== "dashed") {
|
|
1736
|
+
continue;
|
|
1737
|
+
}
|
|
1738
|
+
const w = widths?.[i];
|
|
1739
|
+
const look = dashedLook(words, i, drawn.pattern, typeof w === "number" ? w : drawn.fallback);
|
|
1740
|
+
if (look !== null) {
|
|
1741
|
+
col[i] = look;
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* One dashed line's look, from its dash pattern (its own `line-dash-pattern` when it has one) and cap.
|
|
1747
|
+
* @param words - the parts by internal name, or null for an outline, which has no pattern or cap of its own
|
|
1748
|
+
* @param i - the element
|
|
1749
|
+
* @param pattern - the pattern Cytoscape.js draws when none is given
|
|
1750
|
+
* @param width - the line's width
|
|
1751
|
+
* @returns the line style, or null when the pattern is not a list of numbers
|
|
1752
|
+
*/
|
|
1753
|
+
function dashedLook(words, i, pattern, width) {
|
|
1754
|
+
const dashes = (words?.get("_dashPattern")?.[i] ?? pattern)
|
|
1755
|
+
.split(/[\s,[\]]+/)
|
|
1756
|
+
.filter((t) => t !== "")
|
|
1757
|
+
.map((t) => Number.parseFloat(t));
|
|
1758
|
+
if (dashes.length === 0 || !dashes.every((d) => Number.isFinite(d))) {
|
|
1759
|
+
return null;
|
|
1760
|
+
}
|
|
1761
|
+
return cyjsDashLook(dashes, width, words?.get("_dashCap")?.[i] ?? "butt");
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* A property's values, created (all null) when it has none yet.
|
|
1765
|
+
* @param values - the values by property; changed in place
|
|
1766
|
+
* @param property - the property
|
|
1767
|
+
* @param n - the element count
|
|
1768
|
+
* @returns its values
|
|
1769
|
+
*/
|
|
1770
|
+
function columnOf(values, property, n) {
|
|
1771
|
+
let column = values[property];
|
|
1772
|
+
if (column === undefined) {
|
|
1773
|
+
column = new Array(n).fill(null);
|
|
1774
|
+
values[property] = column;
|
|
1565
1775
|
}
|
|
1776
|
+
return column;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* `visibility` with `display` into `visible`. Cytoscape.js leaves the edges of a node hidden with `visibility:
|
|
1780
|
+
* hidden` drawn (only `display: none` takes them away), so such a node is kept and drawn at opacity 0 (its border and
|
|
1781
|
+
* outline too), with no label.
|
|
1782
|
+
* @param kind - the target
|
|
1783
|
+
* @param n - the element count
|
|
1784
|
+
* @param words - the parts by internal name
|
|
1785
|
+
* @param values - the values; changed in place
|
|
1786
|
+
*/
|
|
1787
|
+
function combineVisibility(kind, n, words, values) {
|
|
1566
1788
|
const vis = words.get("_visibility");
|
|
1567
1789
|
const disp = words.get("_display");
|
|
1568
|
-
if (vis
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1790
|
+
if (vis === undefined && disp === undefined) {
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
const col = new Array(n).fill(null);
|
|
1794
|
+
for (let i = 0; i < n; i++) {
|
|
1795
|
+
const a = vis?.[i] ?? null;
|
|
1796
|
+
const b = disp?.[i] ?? null;
|
|
1797
|
+
if (a === null && b === null) {
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
const keptInvisible = kind === "node" && a === "hidden" && b !== "none";
|
|
1801
|
+
col[i] = keptInvisible || (a !== "hidden" && b !== "none");
|
|
1802
|
+
if (keptInvisible) {
|
|
1803
|
+
// nothing of it is drawn: its body, its border, its outline or its label
|
|
1804
|
+
for (const p of ["opacity", "borderOpacity", "outerBorderOpacity", "labelOpacity"]) {
|
|
1805
|
+
columnOf(values, p, n)[i] = 0;
|
|
1575
1806
|
}
|
|
1576
|
-
|
|
1807
|
+
columnOf(values, "label", n)[i] = "";
|
|
1577
1808
|
}
|
|
1578
|
-
values.visible = col;
|
|
1579
|
-
}
|
|
1580
|
-
if (kind === "edge") {
|
|
1581
|
-
hollowArrows("target", words.get("_targetArrowFill"), values, notes);
|
|
1582
|
-
hollowArrows("source", words.get("_sourceArrowFill"), values, notes);
|
|
1583
1809
|
}
|
|
1810
|
+
values.visible = col;
|
|
1584
1811
|
}
|
|
1585
1812
|
/**
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1589
|
-
* @param
|
|
1813
|
+
* The label's words as Cytoscape.js draws them: `text-transform`, `text-justification`, and `text-rotation` (an
|
|
1814
|
+
* edge's end labels' `source-` / `target-text-rotation` too) as `labelRotation`, `sourceLabelRotation` and
|
|
1815
|
+
* `targetLabelRotation`.
|
|
1816
|
+
* @param kind - the target
|
|
1817
|
+
* @param n - the element count
|
|
1818
|
+
* @param words - the parts by internal name
|
|
1819
|
+
* @param values - the values; changed in place
|
|
1590
1820
|
*/
|
|
1591
|
-
function
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1821
|
+
function combineLabelText(kind, n, words, values) {
|
|
1822
|
+
transformLabels(n, words.get("_transform"), values.label);
|
|
1823
|
+
// cytoscape.js 3.34.3 `labelJustification`: auto lines the lines up against the node, a label beside it on the
|
|
1824
|
+
// left to its right edge
|
|
1825
|
+
const justification = words.get("_justification");
|
|
1826
|
+
if (justification !== undefined && kind === "edge") {
|
|
1827
|
+
combineEdgeJustification(n, justification, words.get("_wrap"), values);
|
|
1828
|
+
}
|
|
1829
|
+
else if (justification !== undefined) {
|
|
1830
|
+
const halign = words.get("_halign");
|
|
1831
|
+
const AUTO = {
|
|
1832
|
+
left: "right",
|
|
1833
|
+
right: "left",
|
|
1834
|
+
"left-inside": "left",
|
|
1835
|
+
"right-inside": "right",
|
|
1836
|
+
};
|
|
1837
|
+
values.labelTextAlign = justification.map((j, i) => {
|
|
1838
|
+
if (j === null) {
|
|
1839
|
+
return null;
|
|
1598
1840
|
}
|
|
1841
|
+
return j === "auto" ? (AUTO[halign?.[i] ?? "center"] ?? "center") : j;
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
// an edge's `autorotate` follows its line, which the routes work out (`autorotateLabels`)
|
|
1845
|
+
const rotations = [
|
|
1846
|
+
["_rotation", "labelRotation"],
|
|
1847
|
+
["_sourceRotation", "sourceLabelRotation"],
|
|
1848
|
+
["_targetRotation", "targetLabelRotation"],
|
|
1849
|
+
];
|
|
1850
|
+
for (const [part, property] of rotations) {
|
|
1851
|
+
const rotation = words.get(part);
|
|
1852
|
+
if (rotation !== undefined) {
|
|
1853
|
+
values[property] = rotation.map((r) => (r === null ? null : cyjsAngleDegrees(r)));
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* A label's `text-transform`: `uppercase` and `lowercase` change its words; anything else leaves them.
|
|
1859
|
+
* @param n - the element count
|
|
1860
|
+
* @param transform - each element's transform
|
|
1861
|
+
* @param label - each element's label; changed in place
|
|
1862
|
+
*/
|
|
1863
|
+
function transformLabels(n, transform, label) {
|
|
1864
|
+
if (transform === undefined || label === undefined) {
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
for (let i = 0; i < n; i++) {
|
|
1868
|
+
const text = label[i];
|
|
1869
|
+
if (typeof text === "string" && transform[i] === "uppercase") {
|
|
1870
|
+
label[i] = text.toUpperCase();
|
|
1599
1871
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
if (fill?.kind === "word" && fill.value === "hollow" && open !== undefined) {
|
|
1603
|
-
setting.set(`${end}Arrow`, open);
|
|
1872
|
+
else if (typeof text === "string" && transform[i] === "lowercase") {
|
|
1873
|
+
label[i] = text.toLowerCase();
|
|
1604
1874
|
}
|
|
1605
1875
|
}
|
|
1606
1876
|
}
|
|
1607
|
-
/**
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1877
|
+
/**
|
|
1878
|
+
* An edge label's `text-justification` as Cytoscape.js draws it: every line centered (an edge's text is always
|
|
1879
|
+
* centered, cytoscape.js 3.34.3 `setupTextStyle`), the block moved half its width left for `left` and right for
|
|
1880
|
+
* `right`, and only for a wrapped label (`drawText`), as `labelShiftX`.
|
|
1881
|
+
* @param n - the element count
|
|
1882
|
+
* @param justification - each edge's justification
|
|
1883
|
+
* @param wrap - each edge's `text-wrap`
|
|
1884
|
+
* @param values - the values; changed in place
|
|
1885
|
+
*/
|
|
1886
|
+
function combineEdgeJustification(n, justification, wrap, values) {
|
|
1887
|
+
const SHIFT = { left: -0.5, right: 0.5 };
|
|
1888
|
+
for (let i = 0; i < n; i++) {
|
|
1889
|
+
const shift = wrap?.[i] === "wrap" ? SHIFT[justification[i] ?? ""] : undefined;
|
|
1890
|
+
if (shift !== undefined) {
|
|
1891
|
+
columnOf(values, "labelShiftX", n)[i] = shift;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* A label's outline and background box as Cytoscape.js draws them: the outline only with a `text-outline-width` and
|
|
1897
|
+
* a `text-outline-opacity` above 0, a stroke of twice that width centered on the letters' edges (cytoscape.js
|
|
1898
|
+
* 3.34.3 `drawText`: `lineWidth = 2 * text-outline-width`); the box only with a `text-background-opacity` above 0
|
|
1899
|
+
* (its default is 0), and the line round the box (`labelBorder`); the box and the line reach `text-background-padding`
|
|
1900
|
+
* past the words.
|
|
1901
|
+
* @param kind - the target
|
|
1902
|
+
* @param n - the element count
|
|
1903
|
+
* @param words - the parts by internal name
|
|
1904
|
+
* @param values - the values; changed in place
|
|
1905
|
+
* @param notes - where problems are noted
|
|
1906
|
+
* @param whole - each element's own opacity, which the box is drawn at too
|
|
1907
|
+
*/
|
|
1908
|
+
function combineLabelDress(kind, n, words, values, notes, whole) {
|
|
1909
|
+
const num = (part, i, fallback) => {
|
|
1910
|
+
const v = words.get(part)?.[i];
|
|
1911
|
+
return v === null || v === undefined ? fallback : Number(v);
|
|
1912
|
+
};
|
|
1913
|
+
const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
|
|
1914
|
+
const outlined = words.has("_outlineWidth");
|
|
1915
|
+
const boxed = words.has("_backgroundOpacity");
|
|
1916
|
+
const bordered = words.has("_textBorderWidth") && words.has("_textBorderOpacity");
|
|
1917
|
+
// each part is drawn at its own opacity times the element's; the outline at the words' opacity too (drawText)
|
|
1918
|
+
const at = (v) => (typeof v === "number" ? v : 1);
|
|
1919
|
+
const faded = (v) => {
|
|
1920
|
+
const r = Math.round(v * 1e6) / 1e6;
|
|
1921
|
+
return r < 1 ? r : null;
|
|
1922
|
+
};
|
|
1923
|
+
for (let i = 0; i < n && (outlined || boxed || bordered); i++) {
|
|
1924
|
+
const width = num("_outlineWidth", i, 0);
|
|
1925
|
+
const outlineOpacity = num("_outlineOpacity", i, 1);
|
|
1926
|
+
if (outlined && width > 0 && outlineOpacity > 0) {
|
|
1927
|
+
col("labelOutlineColor")[i] = words.get("_outlineColor")?.[i] ?? "#000000";
|
|
1928
|
+
col("labelOutlineWidth")[i] = 2 * width;
|
|
1929
|
+
col("labelOutlineOpacity")[i] = faded(outlineOpacity * at(values.labelOpacity?.[i]));
|
|
1930
|
+
}
|
|
1931
|
+
const boxOpacity = num("_backgroundOpacity", i, 0);
|
|
1932
|
+
const box = boxed && boxOpacity > 0;
|
|
1933
|
+
if (box) {
|
|
1934
|
+
col("labelBackground")[i] = words.get("_backgroundColor")?.[i] ?? "#000000";
|
|
1935
|
+
col("labelBackgroundOpacity")[i] = faded(boxOpacity * at(whole[i]));
|
|
1936
|
+
}
|
|
1937
|
+
const border = bordered && labelBorder(kind, i, words, col, notes, at(whole[i]));
|
|
1938
|
+
if (box || border) {
|
|
1939
|
+
labelBoxShape(kind, i, words, col, notes);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* A label's box or line round it, sized and shaped: it reaches `text-background-padding` past the words on every
|
|
1945
|
+
* side (0 unset), one font size tall a line (cytoscape.js 3.34.3 `calculateLabelDimensions`), its corners rounded
|
|
1946
|
+
* 2px for round-rectangle (`drawText`); a circle is noted.
|
|
1947
|
+
* @param kind - the target
|
|
1948
|
+
* @param i - the element
|
|
1949
|
+
* @param words - the parts by internal name
|
|
1950
|
+
* @param col - a property's values, created when absent
|
|
1951
|
+
* @param notes - where problems are noted
|
|
1952
|
+
*/
|
|
1953
|
+
function labelBoxShape(kind, i, words, col, notes) {
|
|
1954
|
+
const padding = words.get("_backgroundPadding")?.[i];
|
|
1955
|
+
col("labelPadding")[i] = padding === null || padding === undefined ? 0 : Number(padding);
|
|
1956
|
+
col("labelLineHeight")[i] = 1;
|
|
1957
|
+
const shape = words.get("_backgroundShape")?.[i];
|
|
1958
|
+
if (shape === "round-rectangle" || shape === "roundrectangle") {
|
|
1959
|
+
col("labelCornerRadius")[i] = 2;
|
|
1960
|
+
}
|
|
1961
|
+
else if (shape === "circle") {
|
|
1962
|
+
// a disc as tall as the box, centered on it: no neutral box has that shape
|
|
1963
|
+
notes.add(STYLE_ISSUE.APPROXIMATED, kind, "labelBackground", { sample: "circle", element: i });
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* The line Cytoscape.js draws round a label's box: only with a `text-border-width` and a `text-border-opacity` above
|
|
1968
|
+
* 0 (both default to 0), in `text-border-color` (black unset), at its opacity times the element's. A double one is
|
|
1969
|
+
* one line a quarter of the width, where `drawText` strokes two such lines half the width apart (cytoscape.js 3.34.3),
|
|
1970
|
+
* noted; dotted and dashed are drawn solid, noted.
|
|
1971
|
+
* @param kind - the target
|
|
1972
|
+
* @param i - the element
|
|
1973
|
+
* @param words - the parts by internal name
|
|
1974
|
+
* @param col - a property's values, created when absent
|
|
1975
|
+
* @param notes - where problems are noted
|
|
1976
|
+
* @param whole - the element's opacity
|
|
1977
|
+
* @returns whether a line is drawn
|
|
1978
|
+
*/
|
|
1979
|
+
function labelBorder(kind, i, words, col, notes, whole) {
|
|
1980
|
+
const num = (part) => Number(words.get(part)?.[i] ?? 0);
|
|
1981
|
+
const [width, opacity] = [num("_textBorderWidth"), num("_textBorderOpacity")];
|
|
1982
|
+
if (!(width > 0 && opacity > 0)) {
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
const style = words.get("_textBorderStyle")?.[i] ?? "solid";
|
|
1986
|
+
col("labelBorderColor")[i] = words.get("_textBorderColor")?.[i] ?? "#000000";
|
|
1987
|
+
col("labelBorderWidth")[i] = style === "double" ? width / 4 : width;
|
|
1988
|
+
const drawn = Math.round(opacity * whole * 1e6) / 1e6;
|
|
1989
|
+
col("labelBorderOpacity")[i] = drawn < 1 ? drawn : null;
|
|
1990
|
+
if (style === "dotted" || style === "dashed" || style === "double") {
|
|
1991
|
+
notes.add(STYLE_ISSUE.APPROXIMATED, kind, "labelBorderColor", { sample: style, element: i });
|
|
1992
|
+
}
|
|
1993
|
+
return true;
|
|
1994
|
+
}
|
|
1995
|
+
/**
|
|
1996
|
+
* An autorotated label's turn: along the line between two centers, kept upright (cytoscape.js 3.34.3
|
|
1997
|
+
* `lineAngleFromDelta`: atan(dy / dx), a vertical line turned to +90 whichever way it runs), from 0 up to 360.
|
|
1998
|
+
* @param a - the source's center
|
|
1999
|
+
* @param b - the target's center
|
|
2000
|
+
* @returns the degrees
|
|
2001
|
+
*/
|
|
2002
|
+
function lineDegrees(a, b) {
|
|
2003
|
+
const dx = b[0] - a[0];
|
|
2004
|
+
const angle = Math.atan((b[1] - a[1]) / dx);
|
|
2005
|
+
const turn = ((dx === 0 ? Math.abs(angle) : angle) * 180) / Math.PI;
|
|
2006
|
+
return Number.isFinite(turn) ? Math.round((((turn % 360) + 360) % 360) * 1e6) / 1e6 + 0 : 0;
|
|
2007
|
+
}
|
|
2008
|
+
/**
|
|
2009
|
+
* A Cytoscape.js angle (`30deg`, `0.5rad`, a number of radians) in degrees; `none` and `autorotate` (which turns
|
|
2010
|
+
* only an edge's label) are 0.
|
|
2011
|
+
* @param text - the value
|
|
2012
|
+
* @returns the degrees, or null when it is not an angle
|
|
2013
|
+
*/
|
|
2014
|
+
function cyjsAngleDegrees(text) {
|
|
2015
|
+
const t = text.trim();
|
|
2016
|
+
if (t === "none" || t === "autorotate") {
|
|
2017
|
+
return 0;
|
|
2018
|
+
}
|
|
2019
|
+
const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(deg|rad)?$/i.exec(t);
|
|
2020
|
+
if (m === null) {
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
const x = Number(m[1]);
|
|
2024
|
+
const deg = m[2]?.toLowerCase() === "deg" ? x : (x * 180) / Math.PI;
|
|
2025
|
+
// the neutral rotation runs from 0 up to 360
|
|
2026
|
+
return Math.round((((deg % 360) + 360) % 360) * 1e6) / 1e6 + 0;
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* An edge's `line-opacity` times its `opacity`, which the line is drawn at (cytoscape.js 3.34.3 `drawEdge`:
|
|
2030
|
+
* `effectiveLineOpacity`).
|
|
2031
|
+
* @param n - the element count
|
|
2032
|
+
* @param line - the line opacities, as text
|
|
2033
|
+
* @param values - the values; changed in place
|
|
2034
|
+
*/
|
|
2035
|
+
function combineLineOpacity(n, line, values) {
|
|
2036
|
+
if (line === undefined) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
const whole = values.opacity;
|
|
2040
|
+
values.opacity = Array.from({ length: n }, (_, i) => {
|
|
2041
|
+
const a = line[i] === null ? null : Number(line[i]);
|
|
2042
|
+
const b = whole?.[i];
|
|
2043
|
+
if (a === null || !Number.isFinite(a)) {
|
|
2044
|
+
return b ?? null;
|
|
2045
|
+
}
|
|
2046
|
+
return Math.round(a * (typeof b === "number" ? b : 1) * 1e6) / 1e6;
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
/** Where each `background-gradient-direction` runs, in the neutral `fillGradientAngle` degrees. */
|
|
2050
|
+
const GRADIENT_ANGLES = new Map([
|
|
2051
|
+
["to-bottom", 90],
|
|
2052
|
+
["to-top", 270],
|
|
2053
|
+
["to-left", 180],
|
|
2054
|
+
["to-right", 0],
|
|
2055
|
+
["to-bottom-right", 45],
|
|
2056
|
+
["to-right-bottom", 45],
|
|
2057
|
+
["to-bottom-left", 135],
|
|
2058
|
+
["to-left-bottom", 135],
|
|
2059
|
+
["to-top-right", 315],
|
|
2060
|
+
["to-right-top", 315],
|
|
2061
|
+
["to-top-left", 225],
|
|
2062
|
+
["to-left-top", 225],
|
|
1612
2063
|
]);
|
|
1613
2064
|
/**
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
2065
|
+
* A node's `background-fill: linear-gradient` or `radial-gradient` as `fill` (its first stop), `fillGradient` (its
|
|
2066
|
+
* last), `fillGradientAngle` (a linear one's direction), `fillGradientKind`, `fillGradientColors` (every stop, when
|
|
2067
|
+
* there are more than two) and `fillGradientStops` (`background-gradient-stop-positions`, when there is one per
|
|
2068
|
+
* color, as Cytoscape.js uses them).
|
|
2069
|
+
* @param n - the element count
|
|
2070
|
+
* @param words - the parts by internal name
|
|
1618
2071
|
* @param values - the values; changed in place
|
|
1619
2072
|
* @param notes - where problems are noted
|
|
1620
2073
|
*/
|
|
1621
|
-
function
|
|
1622
|
-
const
|
|
1623
|
-
if (fill === undefined
|
|
2074
|
+
function combineBackgroundGradient(n, words, values, notes) {
|
|
2075
|
+
const fill = words.get("_backgroundFill");
|
|
2076
|
+
if (fill === undefined) {
|
|
1624
2077
|
return;
|
|
1625
2078
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
2079
|
+
const stops = words.get("_backgroundStops");
|
|
2080
|
+
const positions = words.get("_backgroundPositions");
|
|
2081
|
+
const direction = words.get("_backgroundDirection");
|
|
2082
|
+
const col = (name) => (values[name] ?? (values[name] = new Array(n).fill(null)));
|
|
2083
|
+
for (let i = 0; i < n; i++) {
|
|
2084
|
+
const radial = fill[i] === "radial-gradient";
|
|
2085
|
+
if (fill[i] !== "linear-gradient" && !radial) {
|
|
1629
2086
|
continue;
|
|
1630
2087
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
notes
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
2088
|
+
// Cytoscape.js's default stop colors are one gray, which draws flat
|
|
2089
|
+
const colors = gradientStopColors(stops?.[i] ?? "#999", {
|
|
2090
|
+
notes,
|
|
2091
|
+
target: "node",
|
|
2092
|
+
property: "fill",
|
|
2093
|
+
element: i,
|
|
2094
|
+
});
|
|
2095
|
+
if (colors.length < 2) {
|
|
2096
|
+
continue;
|
|
2097
|
+
}
|
|
2098
|
+
col("fill")[i] = colors[0];
|
|
2099
|
+
col("fillGradient")[i] = colors.at(-1) ?? null;
|
|
2100
|
+
if (colors.length > 2) {
|
|
2101
|
+
col("fillGradientColors")[i] = colors.join(" ");
|
|
2102
|
+
}
|
|
2103
|
+
const placed = gradientStops(positions?.[i] ?? "");
|
|
2104
|
+
if (placed?.split(" ").length === colors.length) {
|
|
2105
|
+
col("fillGradientStops")[i] = placed;
|
|
2106
|
+
}
|
|
2107
|
+
if (radial) {
|
|
2108
|
+
col("fillGradientKind")[i] = "radial";
|
|
1637
2109
|
}
|
|
1638
2110
|
else {
|
|
1639
|
-
|
|
2111
|
+
col("fillGradientAngle")[i] = GRADIENT_ANGLES.get(direction?.[i] ?? "to-bottom") ?? 90;
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
/** An edge's routing settings, each read as Cytoscape.js spells it. */
|
|
2116
|
+
const ROUTE_PARTS = [
|
|
2117
|
+
["segmentDistances", "segment-distances", { property: "_segmentDistances", type: "text" }],
|
|
2118
|
+
["segmentWeights", "segment-weights", { property: "_segmentWeights", type: "text" }],
|
|
2119
|
+
["controlPointDistances", "control-point-distances", { property: "_controlPointDistances", type: "text" }],
|
|
2120
|
+
["controlPointWeights", "control-point-weights", { property: "_controlPointWeights", type: "text" }],
|
|
2121
|
+
["controlPointStepSize", "control-point-step-size", { property: "_controlPointStepSize", type: "size" }],
|
|
2122
|
+
["taxiDirection", "taxi-direction", { property: "_taxiDirection", type: "text" }],
|
|
2123
|
+
["taxiTurn", "taxi-turn", { property: "_taxiTurn", type: "text" }],
|
|
2124
|
+
["taxiTurnMinDistance", "taxi-turn-min-distance", { property: "_taxiTurnMinDistance", type: "size" }],
|
|
2125
|
+
["edgeDistances", "edge-distances", { property: "_edgeDistances", type: "text" }],
|
|
2126
|
+
["loopDirection", "loop-direction", { property: "_loopDirection", type: "text" }],
|
|
2127
|
+
["loopSweep", "loop-sweep", { property: "_loopSweep", type: "text" }],
|
|
2128
|
+
["segmentRadii", "segment-radii", { property: "_segmentRadii", type: "text" }],
|
|
2129
|
+
["taxiRadius", "taxi-radius", { property: "_taxiRadius", type: "text" }],
|
|
2130
|
+
["radiusType", "radius-type", { property: "_radiusType", type: "text" }],
|
|
2131
|
+
];
|
|
2132
|
+
/**
|
|
2133
|
+
* The routes of the edges Cytoscape.js does not draw straight (`segments`, `taxi`, an `unbundled-bezier` with
|
|
2134
|
+
* control points, a loop) as `bends`, drawn straight through them (`curved` false).
|
|
2135
|
+
* @param graph - the core's elements
|
|
2136
|
+
* @param read - the edges' cells
|
|
2137
|
+
* @param curves - each edge's curve style, in output order
|
|
2138
|
+
* @param nodes - the nodes' values
|
|
2139
|
+
* @param values - the edges' values; changed in place
|
|
2140
|
+
*/
|
|
2141
|
+
function edgeRoutes(graph, read, curves, nodes, values) {
|
|
2142
|
+
const words = new Map(ROUTE_PARTS.map(([key, name, spec]) => [key, drawnColumn(read, name, spec)]));
|
|
2143
|
+
const nodeAt = new Map();
|
|
2144
|
+
nodes.elements.forEach((el, k) => {
|
|
2145
|
+
if (el !== null) {
|
|
2146
|
+
nodeAt.set(el, k);
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
const geometry = (core) => routeNode(graph.nodes[core], nodeAt, nodes);
|
|
2150
|
+
// an end label's autorotate turns it as the main label's does (cytoscape.js 3.34.3 `calculateLabelAngle`)
|
|
2151
|
+
const turned = [
|
|
2152
|
+
["labelRotation", drawnColumn(read, "text-rotation", TEXT_PART)],
|
|
2153
|
+
["sourceLabelRotation", drawnColumn(read, "source-text-rotation", TEXT_PART)],
|
|
2154
|
+
["targetLabelRotation", drawnColumn(read, "target-text-rotation", TEXT_PART)],
|
|
2155
|
+
];
|
|
2156
|
+
const ends = [drawnColumn(read, "source-endpoint", TEXT_PART), drawnColumn(read, "target-endpoint", TEXT_PART)];
|
|
2157
|
+
const loops = new Map();
|
|
2158
|
+
const n = read.order.length;
|
|
2159
|
+
let routed = null;
|
|
2160
|
+
for (let k = 0; k < n; k++) {
|
|
2161
|
+
const e = read.order[k];
|
|
2162
|
+
const between = edgeNodes(graph, e, geometry);
|
|
2163
|
+
if (between === null) {
|
|
2164
|
+
continue;
|
|
2165
|
+
}
|
|
2166
|
+
const { src, tgt, loop } = between;
|
|
2167
|
+
if (!loop) {
|
|
2168
|
+
autorotateLabels(values, turned, k, n, lineDegrees(src.center, tgt.center));
|
|
2169
|
+
}
|
|
2170
|
+
const edge = routeSettings(words, k, curves[k]);
|
|
2171
|
+
const bends = cyjsRoute(edge, src, tgt, loop ? nextLoopIndex(loops, graph.source[e], edge) : 0);
|
|
2172
|
+
if (bends !== null) {
|
|
2173
|
+
routed ?? (routed = values.bends ?? new Array(n).fill(null));
|
|
2174
|
+
routed[k] = bends;
|
|
2175
|
+
columnOf(values, "curved", n)[k] = false;
|
|
2176
|
+
}
|
|
2177
|
+
if (!loop) {
|
|
2178
|
+
edgePorts(edge.curveStyle, [ends[0][k], ends[1][k]], [src, tgt], (p, port) => {
|
|
2179
|
+
columnOf(values, p, n)[k] = port;
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
if (routed !== null) {
|
|
2184
|
+
values.bends = routed;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* A node's geometry as the routes measure it: its center, its outer size (its border taken in), its box and whether
|
|
2189
|
+
* it is an ellipse.
|
|
2190
|
+
* @param el - the node
|
|
2191
|
+
* @param nodeAt - each node's output index
|
|
2192
|
+
* @param nodes - the nodes' values
|
|
2193
|
+
* @returns the geometry, or null when the node has no position
|
|
2194
|
+
*/
|
|
2195
|
+
function routeNode(el, nodeAt, nodes) {
|
|
2196
|
+
const k = nodeAt.get(el);
|
|
2197
|
+
const pos = el.json.position;
|
|
2198
|
+
if (k === undefined || !isObject(pos) || typeof pos.x !== "number" || typeof pos.y !== "number") {
|
|
2199
|
+
return null;
|
|
2200
|
+
}
|
|
2201
|
+
const num = (p, fallback) => {
|
|
2202
|
+
const v = nodes.values[p]?.[k];
|
|
2203
|
+
return typeof v === "number" ? v : fallback;
|
|
2204
|
+
};
|
|
2205
|
+
const [w, h, bw] = [num("width", 30), num("height", 30), num("borderWidth", 0)];
|
|
2206
|
+
return {
|
|
2207
|
+
center: [pos.x, pos.y],
|
|
2208
|
+
size: [w + bw, h + bw],
|
|
2209
|
+
box: [w, h],
|
|
2210
|
+
ellipse: (nodes.values.shape?.[k] ?? "ellipse") === "ellipse",
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* An edge's two nodes' geometry, and whether it is a loop.
|
|
2215
|
+
* @param graph - the core's elements
|
|
2216
|
+
* @param e - the edge's core index, below 0 for none
|
|
2217
|
+
* @param geometry - a node's geometry
|
|
2218
|
+
* @returns the source's and the target's geometry, or null when either is not known
|
|
2219
|
+
*/
|
|
2220
|
+
function edgeNodes(graph, e, geometry) {
|
|
2221
|
+
if (e < 0) {
|
|
2222
|
+
return null;
|
|
2223
|
+
}
|
|
2224
|
+
const loop = graph.source[e] === graph.target[e];
|
|
2225
|
+
const src = geometry(graph.source[e]);
|
|
2226
|
+
const tgt = loop ? src : geometry(graph.target[e]);
|
|
2227
|
+
return src === null || tgt === null ? null : { src, tgt, loop };
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Turns each of an edge's labels set to `autorotate` along its line.
|
|
2231
|
+
* @param values - the edges' values; changed in place
|
|
2232
|
+
* @param turned - each label's rotation property and its `text-rotation` words
|
|
2233
|
+
* @param k - the edge's output index
|
|
2234
|
+
* @param n - the edge count
|
|
2235
|
+
* @param degrees - the line's turn
|
|
2236
|
+
*/
|
|
2237
|
+
function autorotateLabels(values, turned, k, n, degrees) {
|
|
2238
|
+
for (const [property, column] of turned) {
|
|
2239
|
+
if (column[k] === "autorotate") {
|
|
2240
|
+
columnOf(values, property, n)[k] = degrees;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2245
|
+
* A loop's place among the loops drawn before it on the same node in the same direction and sweep, which fans them.
|
|
2246
|
+
* @param loops - how many loops each node, direction and sweep has so far; changed in place
|
|
2247
|
+
* @param source - the loop's node
|
|
2248
|
+
* @param edge - the loop's settings
|
|
2249
|
+
* @returns its place, from 0
|
|
2250
|
+
*/
|
|
2251
|
+
function nextLoopIndex(loops, source, edge) {
|
|
2252
|
+
const key = `${String(source)} ${String(edge.loopDirection)} ${String(edge.loopSweep)}`;
|
|
2253
|
+
const index = loops.get(key) ?? 0;
|
|
2254
|
+
loops.set(key, index + 1);
|
|
2255
|
+
return index;
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Where an edge's ends meet its nodes, when not where the line from the centers crosses the outlines (cytoscape.js
|
|
2259
|
+
* 3.34.3 `findEndpoints`, `manualEndptToPx`): `inside-to-node` at the center, `x y` offsets from the center (pixels,
|
|
2260
|
+
* or percentages of the node's outer size), an angle clockwise from 12 o'clock on the outline. A `haystack` edge
|
|
2261
|
+
* runs between points `haystack-radius` of the way from the centers to the outlines in a random direction
|
|
2262
|
+
* (`findHaystackPoints`), drawn from the centers, where a radius of 0 (the default) puts them; a taxi edge ignores its
|
|
2263
|
+
* endpoints.
|
|
2264
|
+
* ponytail: an angle meets a polygon's outline where it meets its box; per-shape outlines if a file angles one
|
|
2265
|
+
* @param curve - the curve style
|
|
2266
|
+
* @param words - the source endpoint and the target endpoint, as Cytoscape.js spells them
|
|
2267
|
+
* @param nodes - the source's and the target's geometry
|
|
2268
|
+
* @param put - sets `sourcePort` or `targetPort`
|
|
2269
|
+
*/
|
|
2270
|
+
function edgePorts(curve, words, nodes, put) {
|
|
2271
|
+
if (curve === "taxi" || curve === "round-taxi") {
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
["sourcePort", "targetPort"].forEach((p, a) => {
|
|
2275
|
+
const port = curve === "haystack" ? "0,0" : endpointPort(String(words[a] ?? ""), nodes[a]);
|
|
2276
|
+
if (port !== null) {
|
|
2277
|
+
put(p, port);
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
}
|
|
2281
|
+
/**
|
|
2282
|
+
* One `source-endpoint` / `target-endpoint` as a neutral port.
|
|
2283
|
+
* @param text - the value
|
|
2284
|
+
* @param node - the node's geometry
|
|
2285
|
+
* @returns the port, or null where the line meets the outline as it does by default
|
|
2286
|
+
*/
|
|
2287
|
+
function endpointPort(text, node) {
|
|
2288
|
+
const t = text.trim();
|
|
2289
|
+
if (t === "inside-to-node") {
|
|
2290
|
+
return "0,0";
|
|
2291
|
+
}
|
|
2292
|
+
const parts = t.split(/\s+/);
|
|
2293
|
+
const [w, h] = node.size;
|
|
2294
|
+
const r6 = (v) => String(Math.round(v * 1e6) / 1e6 + 0);
|
|
2295
|
+
const fraction = (part, size) => {
|
|
2296
|
+
const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+))(%|px)?$/.exec(part);
|
|
2297
|
+
if (m === null || Number.isNaN(size) || size <= 0) {
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
const px = m[2] === "%" ? (Number(m[1]) / 100) * size : Number(m[1]);
|
|
2301
|
+
return px / (size / 2);
|
|
2302
|
+
};
|
|
2303
|
+
if (parts.length === 2) {
|
|
2304
|
+
const [x, y] = [fraction(parts[0], w), fraction(parts[1], h)];
|
|
2305
|
+
return x === null || y === null ? null : `${r6(x)},${r6(-y)}`;
|
|
2306
|
+
}
|
|
2307
|
+
const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+))(deg|rad)$/.exec(t);
|
|
2308
|
+
if (m === null) {
|
|
2309
|
+
return null;
|
|
2310
|
+
}
|
|
2311
|
+
const turn = m[2] === "deg" ? (Number(m[1]) * Math.PI) / 180 : Number(m[1]);
|
|
2312
|
+
// the direction in half sizes, y up, from 12 o'clock clockwise; scaled until it meets the outline
|
|
2313
|
+
const [dx, dy] = [Math.sin(turn) / (w / 2), Math.cos(turn) / (h / 2)];
|
|
2314
|
+
const reach = node.ellipse ? Math.hypot(dx, dy) : Math.max(Math.abs(dx), Math.abs(dy));
|
|
2315
|
+
return reach > 0 ? `${r6(dx / reach)},${r6(dy / reach)}` : null;
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* One edge's routing settings.
|
|
2319
|
+
* @param words - each setting's values, in output order
|
|
2320
|
+
* @param k - the edge's output index
|
|
2321
|
+
* @param curve - its curve style
|
|
2322
|
+
* @returns the settings
|
|
2323
|
+
*/
|
|
2324
|
+
function routeSettings(words, k, curve) {
|
|
2325
|
+
const text = (key) => {
|
|
2326
|
+
const v = words.get(key)?.[k];
|
|
2327
|
+
return v === null || v === undefined ? null : String(v);
|
|
2328
|
+
};
|
|
2329
|
+
const num = (key) => {
|
|
2330
|
+
const v = text(key);
|
|
2331
|
+
return v === null ? null : Number(v);
|
|
2332
|
+
};
|
|
2333
|
+
return {
|
|
2334
|
+
curveStyle: String(curve ?? "haystack"),
|
|
2335
|
+
segmentDistances: text("segmentDistances"),
|
|
2336
|
+
segmentWeights: text("segmentWeights"),
|
|
2337
|
+
controlPointDistances: text("controlPointDistances"),
|
|
2338
|
+
controlPointWeights: text("controlPointWeights"),
|
|
2339
|
+
controlPointStepSize: num("controlPointStepSize"),
|
|
2340
|
+
taxiDirection: text("taxiDirection"),
|
|
2341
|
+
taxiTurn: text("taxiTurn"),
|
|
2342
|
+
taxiTurnMinDistance: num("taxiTurnMinDistance"),
|
|
2343
|
+
edgeDistances: text("edgeDistances"),
|
|
2344
|
+
loopDirection: text("loopDirection"),
|
|
2345
|
+
loopSweep: text("loopSweep"),
|
|
2346
|
+
segmentRadii: text("segmentRadii"),
|
|
2347
|
+
taxiRadius: text("taxiRadius"),
|
|
2348
|
+
radiusType: text("radiusType"),
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2351
|
+
/** A padding read as Cytoscape.js spells it. */
|
|
2352
|
+
const TEXT_PART = { property: "_text", type: "text" };
|
|
2353
|
+
/**
|
|
2354
|
+
* A node's size as Cytoscape.js draws it: a node that is no compound parent is drawn `padding` larger on every side
|
|
2355
|
+
* (cytoscape.js 3.34.3 draws its shape `width() + 2 * padding()` across).
|
|
2356
|
+
* @param graph - the core's elements
|
|
2357
|
+
* @param read - the nodes' cells
|
|
2358
|
+
* @param values - the nodes' values; changed in place
|
|
2359
|
+
*/
|
|
2360
|
+
function nodeSizes(graph, read, values) {
|
|
2361
|
+
const padding = drawnColumn(read, "padding", TEXT_PART);
|
|
2362
|
+
const toLabel = ["width", "height"].map((p) => drawnColumn(read, p, SIZE_PART));
|
|
2363
|
+
const n = read.order.length;
|
|
2364
|
+
const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
|
|
2365
|
+
for (let k = 0; k < n; k++) {
|
|
2366
|
+
const core = read.order[k];
|
|
2367
|
+
const pad = core < 0 || graph.children[core].length > 0 ? 0 : paddingOf(padding[k]);
|
|
2368
|
+
const fitted = toLabel.map((c) => c[k] === "label");
|
|
2369
|
+
if (fitted[0] || fitted[1]) {
|
|
2370
|
+
// `width: label` sizes the node to its label's box (cytoscape.js 3.34.3 `width()` reads the label's
|
|
2371
|
+
// width), padding on each side: the label's side is a minimum of 0, the other keeps its own size
|
|
2372
|
+
col("labelFit")[k] = "bounds";
|
|
2373
|
+
col("labelPaddingX")[k] = pad;
|
|
2374
|
+
col("labelPaddingY")[k] = pad;
|
|
2375
|
+
["width", "height"].forEach((p, a) => {
|
|
2376
|
+
const v = values[p]?.[k];
|
|
2377
|
+
const side = typeof v === "number" ? v : 30;
|
|
2378
|
+
col(p)[k] = fitted[a] ? 0 : side + 2 * pad;
|
|
2379
|
+
});
|
|
2380
|
+
continue;
|
|
2381
|
+
}
|
|
2382
|
+
if (pad <= 0) {
|
|
2383
|
+
continue;
|
|
2384
|
+
}
|
|
2385
|
+
for (const p of ["width", "height"]) {
|
|
2386
|
+
const v = values[p]?.[k];
|
|
2387
|
+
col(p)[k] = (typeof v === "number" ? v : 30) + 2 * pad;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
/** The words of a compound parent's sizing properties. */
|
|
2392
|
+
const PADDING_OF_PART = {
|
|
2393
|
+
property: "_paddingOf",
|
|
2394
|
+
type: "enum",
|
|
2395
|
+
enums: ["width", "height", "average", "min", "max"],
|
|
2396
|
+
};
|
|
2397
|
+
const LABELS_PART = { property: "_compoundLabels", type: "enum", enums: ["include", "exclude"] };
|
|
2398
|
+
/**
|
|
2399
|
+
* A length or a percentage as Cytoscape.js spells it.
|
|
2400
|
+
* @param text - the value, or null
|
|
2401
|
+
* @returns the number and whether it is a percentage, or null for none or a non-number
|
|
2402
|
+
*/
|
|
2403
|
+
function measureOf(text) {
|
|
2404
|
+
if (typeof text !== "string" && typeof text !== "number") {
|
|
2405
|
+
return null;
|
|
2406
|
+
}
|
|
2407
|
+
const value = Number.parseFloat(String(text));
|
|
2408
|
+
return Number.isFinite(value) ? { value, percent: String(text).trim().endsWith("%") } : null;
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* The share of a minimum's growth on the near side (left, top), as Cytoscape.js 3.34.3 `updateCompoundBounds`
|
|
2412
|
+
* splits it: each bias a percentage, a length read as its percentage of the minimum, the near side's share of
|
|
2413
|
+
* their sum; no bias on either side grows both sides alike.
|
|
2414
|
+
* @param near - the near side's bias
|
|
2415
|
+
* @param far - the far side's bias
|
|
2416
|
+
* @param min - the minimum
|
|
2417
|
+
* @returns the near side's share, or null for half
|
|
2418
|
+
*/
|
|
2419
|
+
function biasShare(near, far, min) {
|
|
2420
|
+
const percent = (text) => {
|
|
2421
|
+
const m = measureOf(text);
|
|
2422
|
+
if (m === null || m.value <= 0) {
|
|
2423
|
+
return 0;
|
|
2424
|
+
}
|
|
2425
|
+
return m.percent ? m.value : (m.value * 100) / min;
|
|
2426
|
+
};
|
|
2427
|
+
const a = percent(near);
|
|
2428
|
+
const total = a + percent(far);
|
|
2429
|
+
return total > 0 ? a / total : null;
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* How Cytoscape.js sizes a compound parent round its children (cytoscape.js 3.34.3 `updateCompoundBounds`): its
|
|
2433
|
+
* `padding` past their box (a percentage is of the box, `padding-relative-to`), at least `min-width` by `min-height`
|
|
2434
|
+
* before the padding, grown by the biases' shares, its children's labels counted unless `compound-sizing-wrt-labels`
|
|
2435
|
+
* is `exclude`. Written for every compound parent, so the group is drawn as Cytoscape.js draws it.
|
|
2436
|
+
* @param graph - the core's elements
|
|
2437
|
+
* @param read - the nodes' cells
|
|
2438
|
+
* @param values - the nodes' values; changed in place
|
|
2439
|
+
*/
|
|
2440
|
+
function groupBoxes(graph, read, values) {
|
|
2441
|
+
const word = (name, spec = TEXT_PART) => drawnColumn(read, name, spec);
|
|
2442
|
+
const padding = word("padding");
|
|
2443
|
+
const paddingOf = word("padding-relative-to", PADDING_OF_PART);
|
|
2444
|
+
const labels = word("compound-sizing-wrt-labels", LABELS_PART);
|
|
2445
|
+
const axes = [
|
|
2446
|
+
{ min: word("min-width"), near: word("min-width-bias-left"), far: word("min-width-bias-right") },
|
|
2447
|
+
{ min: word("min-height"), near: word("min-height-bias-top"), far: word("min-height-bias-bottom") },
|
|
2448
|
+
];
|
|
2449
|
+
const names = [
|
|
2450
|
+
["groupMinWidth", "groupMinWidthBiasLeft"],
|
|
2451
|
+
["groupMinHeight", "groupMinHeightBiasTop"],
|
|
2452
|
+
];
|
|
2453
|
+
const n = read.order.length;
|
|
2454
|
+
const put = (p, k, v) => {
|
|
2455
|
+
const column = values[p] ?? new Array(n).fill(null);
|
|
2456
|
+
values[p] = column;
|
|
2457
|
+
column[k] = v;
|
|
2458
|
+
};
|
|
2459
|
+
for (let k = 0; k < n; k++) {
|
|
2460
|
+
const core = read.order[k];
|
|
2461
|
+
if (core < 0 || graph.children[core].length === 0) {
|
|
2462
|
+
continue;
|
|
2463
|
+
}
|
|
2464
|
+
for (const [p, v] of groupPaddingValues(padding[k], paddingOf[k])) {
|
|
2465
|
+
put(p, k, v);
|
|
2466
|
+
}
|
|
2467
|
+
put("groupIncludeLabels", k, labels[k] !== "exclude");
|
|
2468
|
+
axes.forEach((axis, a) => {
|
|
2469
|
+
for (const [p, v] of groupMinValues(axis.min[k], axis.near[k], axis.far[k], names[a])) {
|
|
2470
|
+
put(p, k, v);
|
|
2471
|
+
}
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* A compound parent's padding as neutral values: a length, or a fraction of the side `padding-relative-to` names.
|
|
2477
|
+
* @param padding - the padding as Cytoscape.js spells it
|
|
2478
|
+
* @param of - its `padding-relative-to`
|
|
2479
|
+
* @returns the properties and their values
|
|
2480
|
+
*/
|
|
2481
|
+
function groupPaddingValues(padding, of) {
|
|
2482
|
+
const pad = measureOf(padding);
|
|
2483
|
+
if (pad?.percent !== true) {
|
|
2484
|
+
return [["groupPadding", Math.max(0, pad?.value ?? 0)]];
|
|
2485
|
+
}
|
|
2486
|
+
return [
|
|
2487
|
+
["groupPaddingRatio", Math.max(0, pad.value / 100)],
|
|
2488
|
+
["groupPaddingOf", typeof of === "string" ? of : "width"],
|
|
2489
|
+
];
|
|
2490
|
+
}
|
|
2491
|
+
/**
|
|
2492
|
+
* A compound parent's minimum size on one axis and the share of its growth on the near side, as neutral values.
|
|
2493
|
+
* @param min - the minimum as Cytoscape.js spells it
|
|
2494
|
+
* @param near - the near side's bias (left, top)
|
|
2495
|
+
* @param far - the far side's bias
|
|
2496
|
+
* @param names - the neutral names of the minimum and of the near side's share
|
|
2497
|
+
* @returns the properties and their values; none without a minimum
|
|
2498
|
+
*/
|
|
2499
|
+
function groupMinValues(min, near, far, names) {
|
|
2500
|
+
const m = measureOf(min);
|
|
2501
|
+
if (m === null || m.percent || m.value <= 0) {
|
|
2502
|
+
return [];
|
|
2503
|
+
}
|
|
2504
|
+
const share = biasShare(near, far, m.value);
|
|
2505
|
+
return share === null
|
|
2506
|
+
? [[names[0], m.value]]
|
|
2507
|
+
: [
|
|
2508
|
+
[names[0], m.value],
|
|
2509
|
+
[names[1], share],
|
|
2510
|
+
];
|
|
2511
|
+
}
|
|
2512
|
+
/** The label alignments read as Cytoscape.js's words. */
|
|
2513
|
+
const VALIGN_PART = {
|
|
2514
|
+
property: "_valign",
|
|
2515
|
+
type: "enum",
|
|
2516
|
+
enums: ["top", "top-inside", "center", "bottom", "bottom-inside"],
|
|
2517
|
+
};
|
|
2518
|
+
const HALIGN_PART = {
|
|
2519
|
+
property: "_halign",
|
|
2520
|
+
type: "enum",
|
|
2521
|
+
enums: ["left", "left-inside", "center", "right", "right-inside"],
|
|
2522
|
+
};
|
|
2523
|
+
/**
|
|
2524
|
+
* Where Cytoscape.js pins a label on one axis (cytoscape.js 3.34.3 `recalculateNodeLabelProjection` and
|
|
2525
|
+
* `labelHalign` / `labelValign`): outside, `padding` past the node's side with the label's far edge there; inside,
|
|
2526
|
+
* `padding` short of it with the label's near edge there; centered, at the node's middle.
|
|
2527
|
+
* @param align - the alignment (`left`, `left-inside`, `top`, ...)
|
|
2528
|
+
* @param half - half the node's drawn size on that axis, `padding` included
|
|
2529
|
+
* @param pad - the node's padding
|
|
2530
|
+
* @returns the offset from the node's center and the shift by the label's own size
|
|
2531
|
+
*/
|
|
2532
|
+
function pinnedAxis(align, half, pad) {
|
|
2533
|
+
const near = /^(left|top)/.test(align);
|
|
2534
|
+
if (!near && !/^(right|bottom)/.test(align)) {
|
|
2535
|
+
return { offset: 0, shift: 0 };
|
|
2536
|
+
}
|
|
2537
|
+
const side = near ? -1 : 1;
|
|
2538
|
+
return align.endsWith("-inside")
|
|
2539
|
+
? { offset: side * (half - 2 * pad), shift: -side / 2 }
|
|
2540
|
+
: { offset: side * half, shift: side / 2 };
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* A node label with one alignment inside the node and the other outside it (`text-valign: bottom-inside` with
|
|
2544
|
+
* `text-halign: left`): no neutral position says that, so the label is centered, moved to the point Cytoscape.js
|
|
2545
|
+
* puts it at by `labelOffsetX` / `labelOffsetY` (its `text-margin` added) and pinned there by `labelShiftX` /
|
|
2546
|
+
* `labelShiftY`. A node sized to its label keeps the outside side's position, noted.
|
|
2547
|
+
* @param graph - the core's elements
|
|
2548
|
+
* @param read - the nodes' cells
|
|
2549
|
+
* @param values - the nodes' values, sizes already drawn (`nodeSizes`); changed in place
|
|
2550
|
+
*/
|
|
2551
|
+
function mixedLabelPlaces(graph, read, values) {
|
|
2552
|
+
const va = drawnColumn(read, "text-valign", VALIGN_PART);
|
|
2553
|
+
const ha = drawnColumn(read, "text-halign", HALIGN_PART);
|
|
2554
|
+
const padding = drawnColumn(read, "padding", TEXT_PART);
|
|
2555
|
+
const n = read.order.length;
|
|
2556
|
+
const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
|
|
2557
|
+
for (let k = 0; k < n; k++) {
|
|
2558
|
+
const v = typeof va[k] === "string" ? String(va[k]) : "top";
|
|
2559
|
+
const h = typeof ha[k] === "string" ? String(ha[k]) : "center";
|
|
2560
|
+
const inside = v.endsWith("-inside") || h.endsWith("-inside");
|
|
2561
|
+
const outside = v === "top" || v === "bottom" || h === "left" || h === "right";
|
|
2562
|
+
if (!inside || !outside) {
|
|
2563
|
+
continue;
|
|
2564
|
+
}
|
|
2565
|
+
if (values.labelFit?.[k] !== undefined && values.labelFit[k] !== null) {
|
|
2566
|
+
read.notes.add(STYLE_ISSUE.APPROXIMATED, "node", "labelPosition", { sample: `${v} ${h}`, element: k });
|
|
2567
|
+
continue;
|
|
1640
2568
|
}
|
|
2569
|
+
const core = read.order[k];
|
|
2570
|
+
const pad = core < 0 || graph.children[core].length > 0 ? 0 : paddingOf(padding[k]);
|
|
2571
|
+
const size = (p) => {
|
|
2572
|
+
const s = values[p]?.[k];
|
|
2573
|
+
return typeof s === "number" ? s : 30 + 2 * pad;
|
|
2574
|
+
};
|
|
2575
|
+
const x = pinnedAxis(h, size("width") / 2, pad);
|
|
2576
|
+
const y = pinnedAxis(v, size("height") / 2, pad);
|
|
2577
|
+
const add = (p, d) => {
|
|
2578
|
+
const was = values[p]?.[k];
|
|
2579
|
+
col(p)[k] = (typeof was === "number" ? was : 0) + d;
|
|
2580
|
+
};
|
|
2581
|
+
col("labelPosition")[k] = "center";
|
|
2582
|
+
add("labelOffsetX", x.offset);
|
|
2583
|
+
add("labelOffsetY", y.offset);
|
|
2584
|
+
col("labelShiftX")[k] = x.shift;
|
|
2585
|
+
col("labelShiftY")[k] = y.shift;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
/** A node size read as Cytoscape.js's word, so `label` is seen. */
|
|
2589
|
+
const SIZE_PART = { property: "_size", type: "nodeSize" };
|
|
2590
|
+
/**
|
|
2591
|
+
* A node's padding in pixels. A percentage is relative only on a compound parent; on any other node Cytoscape.js
|
|
2592
|
+
* draws its fraction as pixels (`padding()` returns the property's `pfValue`, 0.2 for `20%`).
|
|
2593
|
+
* @param text - the padding as Cytoscape.js spells it, or null
|
|
2594
|
+
* @returns the pixels, 0 for none
|
|
2595
|
+
*/
|
|
2596
|
+
function paddingOf(text) {
|
|
2597
|
+
if (typeof text !== "string") {
|
|
2598
|
+
return 0;
|
|
2599
|
+
}
|
|
2600
|
+
const x = Number.parseFloat(text);
|
|
2601
|
+
if (!Number.isFinite(x) || x <= 0) {
|
|
2602
|
+
return 0;
|
|
1641
2603
|
}
|
|
2604
|
+
return text.trim().endsWith("%") ? x / 100 : x;
|
|
1642
2605
|
}
|
|
2606
|
+
/** The curve style read as Cytoscape.js's word. */
|
|
2607
|
+
const CURVE_PART = { property: "_curve", type: "enum", enums: CYJS_CURVE_STYLES };
|
|
1643
2608
|
/**
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
2609
|
+
* Cytoscape.js draws no source or target arrow on a `haystack` edge, its default curve style (cytoscape.js 3.34.3
|
|
2610
|
+
* `drawArrowheads` skips them on haystacks, but still draws the mid arrows): each end arrow of one is `none`.
|
|
2611
|
+
* @param curves - each edge's curve style, null where no rule sets it
|
|
2612
|
+
* @param values - the values; changed in place
|
|
2613
|
+
*/
|
|
2614
|
+
function noArrowsOnHaystacks(curves, values) {
|
|
2615
|
+
const n = curves.length;
|
|
2616
|
+
for (const p of ["targetArrow", "sourceArrow"]) {
|
|
2617
|
+
const col = values[p];
|
|
2618
|
+
if (col === undefined) {
|
|
2619
|
+
continue;
|
|
2620
|
+
}
|
|
2621
|
+
for (let i = 0; i < n; i++) {
|
|
2622
|
+
if ((curves[i] ?? "haystack") === "haystack" && col[i] !== null) {
|
|
2623
|
+
col[i] = "none";
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
/**
|
|
2629
|
+
* The outline arrow a hollow `*-arrow-fill` draws for each filled shape that has one (cytoscape.js 3.34.3 strokes the
|
|
2630
|
+
* arrow's path instead of filling it). A hollow square has no outline cap of its own in the neutral vocabulary;
|
|
2631
|
+
* `other:open-square` is drawn as the nearest one.
|
|
2632
|
+
*/
|
|
2633
|
+
const HOLLOW_ARROWS = new Map([
|
|
2634
|
+
["triangle", "triangle-open"],
|
|
2635
|
+
["diamond", "diamond-open"],
|
|
2636
|
+
["circle", "circle-open"],
|
|
2637
|
+
["square", "other:open-square"],
|
|
2638
|
+
]);
|
|
2639
|
+
/**
|
|
2640
|
+
* A rule that sets an arrow shape and makes it hollow sets the outline shape (`combineArrowFills` does the same per
|
|
2641
|
+
* element, for a fill and a shape set by different rules).
|
|
2642
|
+
* @param set - the rule's values; changed in place
|
|
2643
|
+
* @param all - every property of the rule
|
|
2644
|
+
*/
|
|
2645
|
+
function hollowArrowsOfRule(set, all) {
|
|
2646
|
+
for (const p of all) {
|
|
2647
|
+
const shapeProp = /^_(\w+Arrow)Fill$/.exec(p.spec.property)?.[1];
|
|
2648
|
+
const shape = shapeProp === undefined ? undefined : set[shapeProp];
|
|
2649
|
+
if (shapeProp === undefined || shape === undefined || p.parsed.kind !== "word") {
|
|
2650
|
+
continue;
|
|
2651
|
+
}
|
|
2652
|
+
const open = HOLLOW_ARROWS.get(shape);
|
|
2653
|
+
if (open !== undefined && p.parsed.value === "hollow") {
|
|
2654
|
+
set[shapeProp] = open;
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Turns each arrow whose `*-arrow-fill` is `hollow` into its outline shape. A hollow arrow the vocabulary has no
|
|
2660
|
+
* outline shape for keeps its filled shape and is noted.
|
|
2661
|
+
* @param n - the element count
|
|
2662
|
+
* @param words - the parts by internal name
|
|
2663
|
+
* @param values - the values; changed in place
|
|
2664
|
+
* @param notes - where a hollow arrow drawn filled is noted
|
|
2665
|
+
*/
|
|
2666
|
+
function combineArrowFills(n, words, values, notes) {
|
|
2667
|
+
for (const p of ["targetArrow", "sourceArrow", "midTargetArrow", "midSourceArrow"]) {
|
|
2668
|
+
const fill = words.get(`_${p}Fill`);
|
|
2669
|
+
const shapes = values[p];
|
|
2670
|
+
if (fill === undefined || shapes === undefined) {
|
|
2671
|
+
continue;
|
|
2672
|
+
}
|
|
2673
|
+
for (let i = 0; i < n; i++) {
|
|
2674
|
+
const shape = shapes[i];
|
|
2675
|
+
if (fill[i] !== "hollow" || shape === null || shape === "none") {
|
|
2676
|
+
continue;
|
|
2677
|
+
}
|
|
2678
|
+
const open = HOLLOW_ARROWS.get(shape);
|
|
2679
|
+
if (open !== undefined) {
|
|
2680
|
+
shapes[i] = open;
|
|
2681
|
+
}
|
|
2682
|
+
else if (!String(shape).includes("open")) {
|
|
2683
|
+
const property = p.replaceAll(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace("-arrow", "-arrow-fill");
|
|
2684
|
+
notes.add(STYLE_ISSUE.NOT_CARRIED, "edge", property, { sample: `hollow ${String(shape)}`, element: i });
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
/**
|
|
2690
|
+
* A node label's position from its vertical and horizontal alignments. Cytoscape.js 3.34 places an `-inside`
|
|
2691
|
+
* alignment against that side of the node, inside it (`recalculateNodeLabelProjection`): `top-inside` with
|
|
2692
|
+
* `center` is `inside-top`, `top-inside` with `left-inside` is `inside-top-left`. One inside and one outside
|
|
2693
|
+
* alignment have no neutral position of their own: the outside side here, its inside part read as centered, which
|
|
2694
|
+
* `mixedLabelPlaces()` replaces with the pinned place once the node's size is known.
|
|
1646
2695
|
* @param v - the vertical alignment, or null
|
|
1647
2696
|
* @param h - the horizontal alignment, or null
|
|
1648
|
-
* @param note - notes an alignment read as another
|
|
1649
2697
|
* @returns the position, or null
|
|
1650
2698
|
*/
|
|
1651
|
-
function labelPosition(v, h
|
|
2699
|
+
function labelPosition(v, h) {
|
|
1652
2700
|
if (v === null && h === null) {
|
|
1653
2701
|
return null;
|
|
1654
2702
|
}
|
|
2703
|
+
const vIn = (v ?? "").endsWith("-inside");
|
|
2704
|
+
const hIn = (h ?? "").endsWith("-inside");
|
|
1655
2705
|
const vv = (v ?? "top").replace("-inside", "");
|
|
1656
2706
|
const hh = (h ?? "center").replace("-inside", "");
|
|
1657
|
-
if (
|
|
1658
|
-
|
|
2707
|
+
if (vIn || hIn) {
|
|
2708
|
+
const vOut = vv !== "center" && !vIn;
|
|
2709
|
+
const hOut = hh !== "center" && !hIn;
|
|
2710
|
+
if (!vOut && !hOut) {
|
|
2711
|
+
return INSIDE_POSITIONS.get(`${vv},${hh}`) ?? null;
|
|
2712
|
+
}
|
|
2713
|
+
return POSITIONS.get(`${vIn ? "center" : vv},${hIn ? "center" : hh}`) ?? null;
|
|
1659
2714
|
}
|
|
1660
2715
|
return POSITIONS.get(`${vv},${hh}`) ?? null;
|
|
1661
2716
|
}
|
|
@@ -1716,10 +2771,10 @@ function buildRules(kind, applied, core, input, truth, env) {
|
|
|
1716
2771
|
* @param entry - the entry
|
|
1717
2772
|
* @param list - the matched core elements
|
|
1718
2773
|
* @param props - the carried properties
|
|
1719
|
-
* @param
|
|
2774
|
+
* @param all - every property of the entry, the parts combined afterward too
|
|
1720
2775
|
* @returns the draft
|
|
1721
2776
|
*/
|
|
1722
|
-
function draftOf(ctx, entry, list, props,
|
|
2777
|
+
function draftOf(ctx, entry, list, props, all) {
|
|
1723
2778
|
const setting = new Map();
|
|
1724
2779
|
const mapping = new Map();
|
|
1725
2780
|
let flattened = false;
|
|
@@ -1752,8 +2807,13 @@ function draftOf(ctx, entry, list, props, parts) {
|
|
|
1752
2807
|
mapping.set(p.spec.property, mapperMapping(ctx, entry, list, p));
|
|
1753
2808
|
}
|
|
1754
2809
|
}
|
|
1755
|
-
openArrows(setting, parts);
|
|
1756
2810
|
const set = Object.fromEntries(setting);
|
|
2811
|
+
if (ctx.kind === "node") {
|
|
2812
|
+
cyjsPolygonShapes(set);
|
|
2813
|
+
}
|
|
2814
|
+
else {
|
|
2815
|
+
hollowArrowsOfRule(set, all);
|
|
2816
|
+
}
|
|
1757
2817
|
const map = Object.fromEntries(mapping);
|
|
1758
2818
|
const hasMap = mapping.size > 0;
|
|
1759
2819
|
// the predicate is built only for a rule that is not collapsed into a run: a run's rules need no column each
|