@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
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
|
|
2
|
-
import { R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, l as DUPLICATE_ATTRIBUTE_CODE, d as UNKNOWN_ELEMENT_CODE,
|
|
3
|
-
import {
|
|
4
|
-
import { f as
|
|
2
|
+
import { R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, l as DUPLICATE_ATTRIBUTE_CODE, d as UNKNOWN_ELEMENT_CODE, az as EMPTY_COLUMN_DROPPED_CODE, a1 as PARENT_CYCLE_CODE, P as PRECISION_CODE, s as UNKNOWN_ENCODING_CODE, Z as JSON_NONSTANDARD_NUMBER_CODE, t as ENCODING_FALLBACK_CODE, u as INVALID_ENCODING_CODE, v as INVALID_UTF8_CODE, O as OPTION_IGNORED_CODE, S as SINK_OPTION_CODE, H as HYPEREDGE_CODE, V as TOO_LARGE_CODE, f as DANGLING_REFERENCE_CODE, W as AMBIGUOUS_GRAPH_NAME_CODE, Y as GRAPH_NOT_FOUND_CODE, i as MULTIPLE_GRAPHS_CODE, I as ID_MERGED_CODE, j as DUPLICATE_EDGE_ID_CODE, k as DUPLICATE_NODE_CODE, m as UNKNOWN_PARENT_CODE, T as BAD_VALUE_CODE, n as MISSING_ENDPOINT_CODE, o as MISSING_ID_CODE, Q as SYNTAX_CODE, E as EMPTY_INPUT_CODE, y as ELEMENT_ISSUE, z as INPUT_ISSUE, K as ImportReportBuilder, p as plural, a as agree, ae as GRAPH_COLUMN_AS_METADATA_CODE, af as TYPEDEF_NODES_CODE, ag as RELATION_ASSUMED_CODE, a8 as COLUMN_AS_PROPERTY_VALUE_CODE, aD as NONFINITE_AS_NULL_CODE, ax as DIRECTION_DROPPED_CODE, ad as NODE_ORDER_CODE } from "./report-CwMfYa9J.js";
|
|
3
|
+
import { D as DirectionResolver, p as pairFolding, f as formatF32, a as formatF64 } from "./format-BXiAb-1h.js";
|
|
4
|
+
import { c as capabilities, b as resolveImportOptions, f as reportSinkOptions, d as reportUnusedOptions, I as IdCoercer, w as weightFromValue, u as uniqueColumnName, g as chooseGraph, h as graphChosen, i as declareResolved, e as explicitWeights, L as LOSS, a as checkCapabilities, r as resolveExportOptions, P as otherFormatDialect, G as countMixedEdges } from "./export-Cha4dRFz.js";
|
|
5
5
|
import { j as joinText, e as encodeChunks, i as indentUnit } from "./writer-DxjgHwSe.js";
|
|
6
|
-
import { S as STYLE_BLOCK_NAME,
|
|
7
|
-
import { t as trimTrailingZeros } from "./text-
|
|
8
|
-
import { d as OBOGRAPHS_PREDICATE_TAGS, g as compactOboIri, o as oboColumnDecl, P as PLACEHOLDER_COLUMN, h as synonymScopeOf, O as OBO_NODE_COLUMNS, c as capabilityNotes, s as slotColumn, e as emptyColumnNotes, j as OBO_PURL, f as framelessNodes, m as movedNodes, U as UNWRITTEN_ROLES, n as notePropertyColumn, a as cellOf, v as valuesOf$1, k as OBO_IN_OWL, b as fitsVocabulary, t as textOf, S as SYNONYM_SCOPES } from "./ontology-export-
|
|
9
|
-
import { r as readText, b as throwIfAborted } from "./input-
|
|
10
|
-
import { M as MAYBE_UNSAFE_INTEGER, g as MAYBE_INEXACT_EXPONENT, j as rewriteNumbers, l as findDuplicateKeys, m as keysInTextOrder } from "./json-elements-
|
|
11
|
-
import { c as cytoscapeJsStyles, C as CYTOSCAPE_IMPORT_KEY, t as toCytoscapeStylesheet, a as cyjsHoldsExactly, b as CYJS_EDGE_PROPERTIES, d as CYJS_NODE_PROPERTIES } from "./emit-
|
|
12
|
-
import { S as StyleApproximations } from "./approximations-
|
|
13
|
-
import {
|
|
6
|
+
import { S as STYLE_BLOCK_NAME, y as toolDefaults, h as StyleNotes, m as parseStyleBlock, o as styleFingerprint, b as STYLE_ISSUE, p as plainCell, k as canonBoolean, f as canonText, c as canonNumber, d as canonColor, a as canonEnum, j as canonOpacity } from "./block-yl0f_qLO.js";
|
|
7
|
+
import { t as trimTrailingZeros } from "./text-ystE2bYi.js";
|
|
8
|
+
import { d as OBOGRAPHS_PREDICATE_TAGS, g as compactOboIri, o as oboColumnDecl, P as PLACEHOLDER_COLUMN, h as synonymScopeOf, O as OBO_NODE_COLUMNS, c as capabilityNotes, s as slotColumn, e as emptyColumnNotes, j as OBO_PURL, f as framelessNodes, m as movedNodes, U as UNWRITTEN_ROLES, n as notePropertyColumn, a as cellOf, v as valuesOf$1, k as OBO_IN_OWL, b as fitsVocabulary, t as textOf, S as SYNONYM_SCOPES } from "./ontology-export-OMo91mb0.js";
|
|
9
|
+
import { r as readText, b as throwIfAborted } from "./input-CAxt_aV-.js";
|
|
10
|
+
import { M as MAYBE_UNSAFE_INTEGER, g as MAYBE_INEXACT_EXPONENT, j as rewriteNumbers, l as findDuplicateKeys, m as keysInTextOrder } from "./json-elements-Cq76WjnZ.js";
|
|
11
|
+
import { c as cytoscapeJsStyles, C as CYTOSCAPE_IMPORT_KEY, t as toCytoscapeStylesheet, a as cyjsHoldsExactly, b as CYJS_EDGE_PROPERTIES, d as CYJS_NODE_PROPERTIES } from "./emit-7Jkpg0yd.js";
|
|
12
|
+
import { S as StyleApproximations } from "./approximations-BRXsll0T.js";
|
|
13
|
+
import { t as takeFromBlock } from "./round-trip-Cy3_SHRZ.js";
|
|
14
|
+
import { f as flipY } from "./convert-Ct2zelbQ.js";
|
|
14
15
|
const JSON_DIALECTS = Object.freeze([
|
|
15
16
|
"node-link",
|
|
16
17
|
"d3",
|
|
@@ -85,15 +86,37 @@ function sniffEdgeListDialect(root) {
|
|
|
85
86
|
if (record !== void 0) {
|
|
86
87
|
return record;
|
|
87
88
|
}
|
|
89
|
+
if (!networkx && firstEdge === null && isVisOptions(root.options)) {
|
|
90
|
+
return "vis";
|
|
91
|
+
}
|
|
88
92
|
const bare = !hasKey(root, "directed") && !hasKey(root, "multigraph") && !hasKey(root, "graph");
|
|
89
93
|
return bare && hasKey(root, "links") ? "d3" : "node-link";
|
|
90
94
|
}
|
|
95
|
+
const VIS_OPTION_GROUPS = [
|
|
96
|
+
"nodes",
|
|
97
|
+
"edges",
|
|
98
|
+
"groups",
|
|
99
|
+
"physics",
|
|
100
|
+
"layout",
|
|
101
|
+
"interaction",
|
|
102
|
+
"manipulation",
|
|
103
|
+
"configure",
|
|
104
|
+
"autoResize",
|
|
105
|
+
"clickToUse",
|
|
106
|
+
"locale",
|
|
107
|
+
"locales",
|
|
108
|
+
"height",
|
|
109
|
+
"width"
|
|
110
|
+
];
|
|
111
|
+
function isVisOptions(options) {
|
|
112
|
+
return isJsonObject(options) && VIS_OPTION_GROUPS.some((k) => hasKey(options, k));
|
|
113
|
+
}
|
|
91
114
|
function sniffRecordDialect(firstNode, firstEdge) {
|
|
92
115
|
if (firstNode !== null && hasKey(firstNode, "key") && !hasKey(firstNode, "id")) {
|
|
93
116
|
return "graphology";
|
|
94
117
|
}
|
|
95
118
|
if (firstEdge === null) {
|
|
96
|
-
return void 0;
|
|
119
|
+
return firstNode !== null && hasKey(firstNode, "id") && isJsonObject(firstNode.attributes) ? "graphology" : void 0;
|
|
97
120
|
}
|
|
98
121
|
if (!hasKey(firstEdge, "from")) {
|
|
99
122
|
return hasKey(firstEdge, "undirected") || isJsonObject(firstEdge.attributes) ? "graphology" : void 0;
|
|
@@ -251,8 +274,8 @@ function exponentIfUnsafe(text) {
|
|
|
251
274
|
}
|
|
252
275
|
const [, sign, digits] = match;
|
|
253
276
|
const mantissa = trimTrailingZeros(digits);
|
|
254
|
-
const
|
|
255
|
-
return `${sign}${mantissa[0]}${
|
|
277
|
+
const fraction2 = mantissa.length > 1 ? `.${mantissa.slice(1)}` : "";
|
|
278
|
+
return `${sign}${mantissa[0]}${fraction2}e+${digits.length - 1}`;
|
|
256
279
|
}
|
|
257
280
|
const GRAPH_FORMATS = Object.freeze([
|
|
258
281
|
"json",
|
|
@@ -572,10 +595,11 @@ function clamp(value) {
|
|
|
572
595
|
}
|
|
573
596
|
return Math.min(value, 1);
|
|
574
597
|
}
|
|
598
|
+
const SIGMA_FIT = { padding: 30 };
|
|
575
599
|
const Y_DOWN_MARKERS = ["vx", "vy", "fx", "fy", "index", "physics"];
|
|
576
600
|
function jsonPositions(snapshot) {
|
|
577
601
|
if (snapshot.nodes.byRole("position") !== null) {
|
|
578
|
-
return null;
|
|
602
|
+
return jsonShapeOf(snapshot)?.dialect === "cytoscape" ? { containersFollowChildren: true } : null;
|
|
579
603
|
}
|
|
580
604
|
const x = numeric(snapshot.nodes.get("x"));
|
|
581
605
|
const y = numeric(snapshot.nodes.get("y"));
|
|
@@ -583,19 +607,23 @@ function jsonPositions(snapshot) {
|
|
|
583
607
|
return null;
|
|
584
608
|
}
|
|
585
609
|
const z = numeric(snapshot.nodes.get("z"));
|
|
586
|
-
const
|
|
610
|
+
const dialect = jsonShapeOf(snapshot)?.dialect;
|
|
611
|
+
const markers = dialect !== "graphology" && Y_DOWN_MARKERS.some((name) => snapshot.nodes.get(name) !== null);
|
|
612
|
+
const down = z === null && (dialect === "vis" || markers);
|
|
587
613
|
return {
|
|
588
614
|
x: x.meta.name,
|
|
589
615
|
y: y.meta.name,
|
|
590
616
|
...z === null ? {} : { z: z.meta.name },
|
|
591
617
|
yAxis: down ? "down" : "up",
|
|
592
|
-
units: down ? "px" : "file"
|
|
618
|
+
units: down ? "px" : "file",
|
|
619
|
+
...dialect === "graphology" ? { viewerFit: SIGMA_FIT } : {}
|
|
593
620
|
};
|
|
594
621
|
}
|
|
595
622
|
function numeric(column) {
|
|
596
623
|
const numericDtypes = ["f64", "f32", "i32", "u32", "u8"];
|
|
597
624
|
return column !== null && column.meta.components === 1 && numericDtypes.includes(column.dtype) ? column : null;
|
|
598
625
|
}
|
|
626
|
+
const SIGMA_DEFAULT_SETTINGS = { renderEdgeLabels: false, edgeLabelAnchors: "nodeLabels" };
|
|
599
627
|
const TARGETS = ["node", "edge"];
|
|
600
628
|
function jsonStyles(snapshot, context) {
|
|
601
629
|
const src = context.kept;
|
|
@@ -736,14 +764,17 @@ function graphologyStyles(snapshot, src, context) {
|
|
|
736
764
|
const notes = new StyleNotes();
|
|
737
765
|
const out = { node: {}, edge: {} };
|
|
738
766
|
const readFrom = { node: [], edge: [] };
|
|
767
|
+
const edgeLabel = sigmaEdgeLabels(snapshot, src.sigma ?? SIGMA_DEFAULT_SETTINGS);
|
|
739
768
|
for (const target of TARGETS) {
|
|
740
769
|
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
741
770
|
const { values, put } = valuesOf(n);
|
|
742
771
|
const keys = {
|
|
743
772
|
color: cells(snapshot, target, "color"),
|
|
744
773
|
size: cells(snapshot, target, "size"),
|
|
745
|
-
|
|
746
|
-
|
|
774
|
+
// sigma 4's default styles bind nothing else: it draws an element marked `hidden: true` (sigma 3's key)
|
|
775
|
+
// or `visibility: "hidden"` (its own display-data name) like any other (specimen sheets
|
|
776
|
+
// graphology-specimen-node-sizes-opacity, -edges-lines)
|
|
777
|
+
label: cells(snapshot, target, "label")
|
|
747
778
|
};
|
|
748
779
|
readFrom[target].push(...Object.entries(keys).flatMap(([name, c]) => c === null ? [] : [name]));
|
|
749
780
|
for (let i = 0; i < n; i++) {
|
|
@@ -754,7 +785,7 @@ function graphologyStyles(snapshot, src, context) {
|
|
|
754
785
|
element: i,
|
|
755
786
|
budget: context.budget
|
|
756
787
|
});
|
|
757
|
-
readSigmaRow(keys, target, i, put, site);
|
|
788
|
+
readSigmaRow(keys, target, target === "node" || edgeLabel(i), i, put, site);
|
|
758
789
|
}
|
|
759
790
|
out[target] = values;
|
|
760
791
|
}
|
|
@@ -771,31 +802,50 @@ function graphologyStyles(snapshot, src, context) {
|
|
|
771
802
|
readFrom
|
|
772
803
|
};
|
|
773
804
|
}
|
|
774
|
-
function
|
|
775
|
-
|
|
805
|
+
function sigmaEdgeLabels(snapshot, settings) {
|
|
806
|
+
if (!settings.renderEdgeLabels) {
|
|
807
|
+
return () => false;
|
|
808
|
+
}
|
|
809
|
+
if (settings.edgeLabelAnchors === "allNodes") {
|
|
810
|
+
return () => true;
|
|
811
|
+
}
|
|
812
|
+
const label = cells(snapshot, "node", "label");
|
|
813
|
+
const shows = (node) => {
|
|
814
|
+
const text = label?.(node);
|
|
815
|
+
return typeof text === "string" ? text !== "" : text !== null && text !== void 0;
|
|
816
|
+
};
|
|
817
|
+
return (i) => shows(snapshot.edgeSource(i)) && shows(snapshot.edgeTarget(i));
|
|
818
|
+
}
|
|
819
|
+
function readSigmaRow(keys, target, labeled, i, put, site) {
|
|
820
|
+
const { color, size, label } = keys;
|
|
776
821
|
if (color !== null) {
|
|
777
822
|
const [fill, opacity] = target === "node" ? ["fill", "fillOpacity"] : ["color", "opacity"];
|
|
778
823
|
putColor(put, fill, opacity, i, color(i), site(fill));
|
|
779
824
|
}
|
|
780
825
|
if (size !== null) {
|
|
781
|
-
|
|
782
|
-
put("width", i, v);
|
|
783
|
-
if (target === "node") {
|
|
784
|
-
put("height", i, v);
|
|
785
|
-
}
|
|
826
|
+
putSigmaSize(put, target, i, size(i), site);
|
|
786
827
|
}
|
|
787
|
-
if (label !== null) {
|
|
788
|
-
|
|
828
|
+
if (label !== null && labeled) {
|
|
829
|
+
const text = canonText(label(i), site("label"));
|
|
830
|
+
put("label", i, text === null ? null : text.replaceAll(/[\t\n\f\r]/g, " "));
|
|
789
831
|
}
|
|
790
|
-
|
|
791
|
-
|
|
832
|
+
}
|
|
833
|
+
function putSigmaSize(put, target, i, raw, site) {
|
|
834
|
+
if (target === "node") {
|
|
835
|
+
const v = Number(raw) < 0 ? 0 : canonNumber(raw, site("width"));
|
|
836
|
+
const d = v === null ? null : v * 2;
|
|
837
|
+
put("width", i, d);
|
|
838
|
+
put("height", i, d);
|
|
839
|
+
} else {
|
|
840
|
+
const w = canonNumber(raw, site("width"));
|
|
841
|
+
put("width", i, w === null ? null : w / 2);
|
|
792
842
|
}
|
|
793
843
|
}
|
|
794
844
|
function putColor(put, property, opacity, i, raw, site) {
|
|
795
|
-
if (raw === null || raw === void 0
|
|
845
|
+
if (raw === null || raw === void 0) {
|
|
796
846
|
return;
|
|
797
847
|
}
|
|
798
|
-
const c = canonColor(raw, "
|
|
848
|
+
const c = canonColor(raw, "graphology", site);
|
|
799
849
|
if (c === null) {
|
|
800
850
|
return;
|
|
801
851
|
}
|
|
@@ -819,48 +869,27 @@ function blockText(snapshot, src) {
|
|
|
819
869
|
return typeof v === "string" ? v : null;
|
|
820
870
|
}
|
|
821
871
|
function exactFromBlock(snapshot, text, values, written, holdsExactly) {
|
|
822
|
-
|
|
823
|
-
return;
|
|
824
|
-
}
|
|
825
|
-
const parsed = parseStyleBlock(text, styleFingerprint(snapshot));
|
|
826
|
-
const ex = parsed.ok ? blockStyles(parsed.block, snapshot, "json") : null;
|
|
827
|
-
if (ex === null) {
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
for (const target of TARGETS) {
|
|
872
|
+
takeFromBlock(snapshot, text, "json", (target, block, ex) => {
|
|
831
873
|
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
832
|
-
const cache = /* @__PURE__ */ new Map();
|
|
833
|
-
const resolved = (p) => {
|
|
834
|
-
let r = cache.get(p);
|
|
835
|
-
if (r === void 0) {
|
|
836
|
-
r = resolveStyles(ex, target, p, snapshot);
|
|
837
|
-
cache.set(p, r);
|
|
838
|
-
}
|
|
839
|
-
return r;
|
|
840
|
-
};
|
|
841
874
|
if (holdsExactly !== void 0) {
|
|
842
875
|
const properties = new Set(
|
|
843
876
|
ex.styles.rules.filter((r) => r.target === target).flatMap((r) => [...Object.keys(r.set ?? {}), ...Object.keys(r.map ?? {})])
|
|
844
877
|
);
|
|
845
878
|
for (const property of properties) {
|
|
846
879
|
const held = (w) => holdsExactly(target, property, w);
|
|
847
|
-
takeUnheld(values[target], property,
|
|
880
|
+
takeUnheld(values[target], property, block(target, property), n, held);
|
|
848
881
|
}
|
|
849
882
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (native !== w && native !== null && native === write2((p) => resolved(p)[i], i, snapshot)) {
|
|
861
|
-
setValue(column, property, n, i, w);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
883
|
+
const writes = written[target] ?? {};
|
|
884
|
+
return {
|
|
885
|
+
values: values[target],
|
|
886
|
+
properties: Object.keys(writes),
|
|
887
|
+
// a native value the writer made from the block's other values (vis.js's one size for a width) is the
|
|
888
|
+
// block's own value, none included
|
|
889
|
+
readBack: (i, want) => (property) => writes[property](want, i, snapshot),
|
|
890
|
+
take: (_property, _wanted, native) => native !== null
|
|
891
|
+
};
|
|
892
|
+
});
|
|
864
893
|
}
|
|
865
894
|
function takeUnheld(values, property, want, n, held) {
|
|
866
895
|
for (let i = 0; i < n; i++) {
|
|
@@ -888,6 +917,15 @@ const VIS_SIZED = /* @__PURE__ */ new Set([
|
|
|
888
917
|
"square",
|
|
889
918
|
"icon"
|
|
890
919
|
]);
|
|
920
|
+
const VIS_LABEL_FIT = /* @__PURE__ */ new Map([
|
|
921
|
+
["box", { square: false, ellipse: false }],
|
|
922
|
+
["text", { square: false, ellipse: false }],
|
|
923
|
+
["circle", { square: true, ellipse: false }],
|
|
924
|
+
["database", { square: true, ellipse: false }],
|
|
925
|
+
["ellipse", { square: false, ellipse: true }]
|
|
926
|
+
]);
|
|
927
|
+
const VIS_MARGIN = 5;
|
|
928
|
+
const VIS_FONT_SIZE = 14;
|
|
891
929
|
const VIS_GROUP_PALETTE = [
|
|
892
930
|
["#2B7CE9", "#97C2FC"],
|
|
893
931
|
["#FFA500", "#FFFF00"],
|
|
@@ -910,6 +948,8 @@ const VIS_GROUP_PALETTE = [
|
|
|
910
948
|
["#C2FABC", "#74D66A"],
|
|
911
949
|
["#EE0000", "#990000"]
|
|
912
950
|
];
|
|
951
|
+
const VIS_NODE_FILL = "#97C2FC";
|
|
952
|
+
const VIS_NODE_BORDER = "#2B7CE9";
|
|
913
953
|
const VIS_EDGE_COLOR = "#848484";
|
|
914
954
|
function visParseColor(text) {
|
|
915
955
|
let hex = text;
|
|
@@ -978,7 +1018,14 @@ function visLayer(o, target) {
|
|
|
978
1018
|
set("hidden", o.hidden);
|
|
979
1019
|
set("label", o.label);
|
|
980
1020
|
set("title", o.title);
|
|
1021
|
+
set("wrapWidth", isJsonObject(o.widthConstraint) ? o.widthConstraint.maximum : o.widthConstraint);
|
|
1022
|
+
if (isJsonObject(o.scaling)) {
|
|
1023
|
+
set("scalingLabel", o.scaling.label);
|
|
1024
|
+
}
|
|
981
1025
|
visFontLayer(o.font, set);
|
|
1026
|
+
if (target === "edge" && o.font !== void 0 && o.font !== null) {
|
|
1027
|
+
set("fontText", typeof o.font === "string");
|
|
1028
|
+
}
|
|
982
1029
|
return layer;
|
|
983
1030
|
}
|
|
984
1031
|
function visNodeLayer(o, set) {
|
|
@@ -993,8 +1040,104 @@ function visNodeLayer(o, set) {
|
|
|
993
1040
|
}
|
|
994
1041
|
set("shape", o.shape);
|
|
995
1042
|
set("size", o.size);
|
|
1043
|
+
set("value", o.value);
|
|
1044
|
+
if (isJsonObject(o.scaling)) {
|
|
1045
|
+
set("scalingMin", o.scaling.min);
|
|
1046
|
+
set("scalingMax", o.scaling.max);
|
|
1047
|
+
}
|
|
996
1048
|
set("borderWidth", o.borderWidth);
|
|
997
1049
|
set("opacity", o.opacity);
|
|
1050
|
+
set("margin", o.margin);
|
|
1051
|
+
set("widthMin", isJsonObject(o.widthConstraint) ? o.widthConstraint.minimum : o.widthConstraint);
|
|
1052
|
+
set("heightMin", isJsonObject(o.heightConstraint) ? o.heightConstraint.minimum : o.heightConstraint);
|
|
1053
|
+
set("valign", isJsonObject(o.heightConstraint) ? o.heightConstraint.valign : void 0);
|
|
1054
|
+
set("image", isJsonObject(o.image) ? o.image.unselected : o.image);
|
|
1055
|
+
set("brokenImage", o.brokenImage);
|
|
1056
|
+
set("imagePadding", o.imagePadding);
|
|
1057
|
+
if (isJsonObject(o.icon)) {
|
|
1058
|
+
set("iconCode", o.icon.code);
|
|
1059
|
+
set("iconFace", o.icon.face);
|
|
1060
|
+
set("iconSize", o.icon.size);
|
|
1061
|
+
set("iconColor", o.icon.color);
|
|
1062
|
+
set("iconWeight", o.icon.weight);
|
|
1063
|
+
}
|
|
1064
|
+
if (isJsonObject(o.shapeProperties)) {
|
|
1065
|
+
set("useImageSize", o.shapeProperties.useImageSize);
|
|
1066
|
+
set("useBorderWithImage", o.shapeProperties.useBorderWithImage);
|
|
1067
|
+
set("interpolation", o.shapeProperties.interpolation);
|
|
1068
|
+
set("coordinateOrigin", o.shapeProperties.coordinateOrigin);
|
|
1069
|
+
set("borderDashes", o.shapeProperties.borderDashes);
|
|
1070
|
+
set("borderRadius", o.shapeProperties.borderRadius);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
function visImage(layer, shape, box) {
|
|
1074
|
+
const text = (v) => typeof v === "string" && v !== "" ? v : null;
|
|
1075
|
+
const [own, broken] = [text(layer.image), text(layer.brokenImage)];
|
|
1076
|
+
const src = own ?? broken;
|
|
1077
|
+
if (shape !== "image" && shape !== "circularImage" || src === null) {
|
|
1078
|
+
return {};
|
|
1079
|
+
}
|
|
1080
|
+
const circular = shape === "circularImage";
|
|
1081
|
+
const row = {
|
|
1082
|
+
image: src,
|
|
1083
|
+
...own !== null && broken !== null ? { imageFallback: broken } : {},
|
|
1084
|
+
imageFit: layer.useImageSize === true ? "none" : "cover",
|
|
1085
|
+
imageClip: circular ? "node" : "none",
|
|
1086
|
+
shape: "ellipse"
|
|
1087
|
+
};
|
|
1088
|
+
if (!circular) {
|
|
1089
|
+
row.shape = layer.useBorderWithImage === true ? "rectangle" : "none";
|
|
1090
|
+
}
|
|
1091
|
+
if (layer.interpolation === false) {
|
|
1092
|
+
row.imageSmoothing = false;
|
|
1093
|
+
}
|
|
1094
|
+
const opacity = typeof layer.opacity === "number" && layer.opacity >= 0 && layer.opacity < 1 ? layer.opacity : null;
|
|
1095
|
+
if (opacity !== null) {
|
|
1096
|
+
row.imageOpacity = opacity;
|
|
1097
|
+
}
|
|
1098
|
+
visImagePlace(row, layer, box);
|
|
1099
|
+
return row;
|
|
1100
|
+
}
|
|
1101
|
+
function visImagePlace(row, layer, box) {
|
|
1102
|
+
const pad = visImagePadding(layer.imagePadding);
|
|
1103
|
+
if (pad !== null && layer.useImageSize !== true) {
|
|
1104
|
+
row.imageFit = "none";
|
|
1105
|
+
row.imageWidth = Math.max(0, box.width - pad.left - pad.right);
|
|
1106
|
+
row.imageHeight = Math.max(0, box.height - pad.top - pad.bottom);
|
|
1107
|
+
row.imageOffsetX = (pad.left - pad.right) / 2;
|
|
1108
|
+
row.imageOffsetY = (pad.top - pad.bottom) / 2;
|
|
1109
|
+
}
|
|
1110
|
+
if (layer.coordinateOrigin === "top-left" && row.shape === "none") {
|
|
1111
|
+
row.imageOffsetX = box.width / 2 + (typeof row.imageOffsetX === "number" ? row.imageOffsetX : 0);
|
|
1112
|
+
row.imageOffsetY = box.height / 2 + (typeof row.imageOffsetY === "number" ? row.imageOffsetY : 0);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
function visIcon(layer, site) {
|
|
1116
|
+
const code = typeof layer.iconCode === "string" && layer.iconCode !== "" ? layer.iconCode : null;
|
|
1117
|
+
if (code === null) {
|
|
1118
|
+
return {};
|
|
1119
|
+
}
|
|
1120
|
+
const size = typeof layer.iconSize === "number" && layer.iconSize >= 0 ? layer.iconSize : 50;
|
|
1121
|
+
const color = typeof layer.iconColor === "string" ? canonColor(layer.iconColor, "vis", site) : null;
|
|
1122
|
+
const weight = layer.iconWeight;
|
|
1123
|
+
const bold = weight === "bold" || weight === "bolder" || typeof weight === "number" && weight >= 600;
|
|
1124
|
+
return {
|
|
1125
|
+
glyph: code,
|
|
1126
|
+
glyphFont: typeof layer.iconFace === "string" && layer.iconFace !== "" ? layer.iconFace : "FontAwesome",
|
|
1127
|
+
glyphSize: size,
|
|
1128
|
+
glyphColor: color?.color ?? "#2b7ce9",
|
|
1129
|
+
glyphWeight: bold ? "bold" : "normal"
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
function visImagePadding(raw) {
|
|
1133
|
+
const side = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0;
|
|
1134
|
+
let pad = null;
|
|
1135
|
+
if (typeof raw === "number") {
|
|
1136
|
+
pad = { top: side(raw), right: side(raw), bottom: side(raw), left: side(raw) };
|
|
1137
|
+
} else if (isJsonObject(raw)) {
|
|
1138
|
+
pad = { top: side(raw.top), right: side(raw.right), bottom: side(raw.bottom), left: side(raw.left) };
|
|
1139
|
+
}
|
|
1140
|
+
return pad === null || pad.top + pad.right + pad.bottom + pad.left === 0 ? null : pad;
|
|
998
1141
|
}
|
|
999
1142
|
function visEdgeLayer(o, set) {
|
|
1000
1143
|
const { color } = o;
|
|
@@ -1008,14 +1151,35 @@ function visEdgeLayer(o, set) {
|
|
|
1008
1151
|
set("inherit", own ? false : color.inherit);
|
|
1009
1152
|
}
|
|
1010
1153
|
set("width", o.width);
|
|
1154
|
+
set("value", o.value);
|
|
1155
|
+
if (isJsonObject(o.scaling)) {
|
|
1156
|
+
set("scalingMin", o.scaling.min);
|
|
1157
|
+
set("scalingMax", o.scaling.max);
|
|
1158
|
+
}
|
|
1011
1159
|
set("dashes", o.dashes);
|
|
1012
1160
|
set("arrows", o.arrows);
|
|
1161
|
+
set("background", o.background);
|
|
1162
|
+
set("smooth", o.smooth);
|
|
1163
|
+
set("selfReference", o.selfReference);
|
|
1164
|
+
set("selfReferenceSize", o.selfReferenceSize);
|
|
1165
|
+
set("physics", o.physics);
|
|
1166
|
+
set("length", o.length);
|
|
1013
1167
|
}
|
|
1014
1168
|
function visFontLayer(font, set) {
|
|
1015
1169
|
if (isJsonObject(font)) {
|
|
1170
|
+
set("fontMulti", font.multi);
|
|
1171
|
+
set("fontStrokeWidth", font.strokeWidth);
|
|
1172
|
+
set("fontStrokeColor", font.strokeColor);
|
|
1173
|
+
set("fontBackground", font.background);
|
|
1174
|
+
set("fontAlign", font.align);
|
|
1016
1175
|
set("fontColor", font.color);
|
|
1017
1176
|
set("fontSize", font.size);
|
|
1018
1177
|
set("fontFace", font.face);
|
|
1178
|
+
set("fontVadjust", font.vadjust);
|
|
1179
|
+
const mods = ["bold", "ital", "boldital", "mono"].filter((m) => font[m] !== void 0 && font[m] !== null);
|
|
1180
|
+
if (mods.length > 0) {
|
|
1181
|
+
set("fontMods", Object.fromEntries(mods.map((m) => [m, font[m]])));
|
|
1182
|
+
}
|
|
1019
1183
|
} else if (typeof font === "string") {
|
|
1020
1184
|
const m = /^\s*(\d+(?:\.\d+)?)(?:px)?\s+(\S+)(?:\s+(\S+))?/.exec(font.slice(0, 256));
|
|
1021
1185
|
if (m !== null) {
|
|
@@ -1046,44 +1210,328 @@ function visValues(layer, target, site, sized) {
|
|
|
1046
1210
|
};
|
|
1047
1211
|
if (target === "node") {
|
|
1048
1212
|
color("fill", "fillOpacity", layer.fill);
|
|
1049
|
-
color("borderColor",
|
|
1213
|
+
color("borderColor", "borderOpacity", layer.border);
|
|
1050
1214
|
visNodeValues(layer, sized, put, site);
|
|
1051
1215
|
} else {
|
|
1052
1216
|
color("color", "opacity", layer.edgeColor);
|
|
1053
1217
|
visEdgeValues(layer, put, site);
|
|
1218
|
+
visEdgeBackground(layer, put, color);
|
|
1054
1219
|
}
|
|
1055
1220
|
if (layer.hidden !== void 0 && canonBoolean(layer.hidden, site("visible")) === true) {
|
|
1056
1221
|
put("visible", false);
|
|
1057
1222
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1223
|
+
visLabelValues(layer, target, put, color, site);
|
|
1224
|
+
return out;
|
|
1225
|
+
}
|
|
1226
|
+
function visEdgeBackground(layer, put, color) {
|
|
1227
|
+
if (!isJsonObject(layer.background)) {
|
|
1228
|
+
return;
|
|
1060
1229
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1230
|
+
const bg = layer.background;
|
|
1231
|
+
const straight = layer.smooth === false || isJsonObject(layer.smooth) && layer.smooth.enabled === false;
|
|
1232
|
+
color("outlineColor", "outlineOpacity", bg.color);
|
|
1233
|
+
if (bg.enabled !== void 0) {
|
|
1234
|
+
const size = typeof bg.size === "number" ? bg.size : 10;
|
|
1235
|
+
const width = typeof layer.width === "number" ? layer.width : 1;
|
|
1236
|
+
put("outlineWidth", bg.enabled === true && !straight ? Math.max(0, size - width) : 0);
|
|
1063
1237
|
}
|
|
1064
|
-
|
|
1238
|
+
const band = visBandStyle(bg, false);
|
|
1239
|
+
if (band !== null) {
|
|
1240
|
+
put("outlineStyle", band);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
function visLabelValues(layer, target, put, color, site) {
|
|
1065
1244
|
if (layer.fontSize !== void 0) {
|
|
1066
1245
|
put("labelSize", canonNumber(layer.fontSize, site("labelSize")));
|
|
1067
1246
|
}
|
|
1068
1247
|
if (layer.fontFace !== void 0) {
|
|
1069
1248
|
put("labelFont", canonText(layer.fontFace, site("labelFont")));
|
|
1070
1249
|
}
|
|
1071
|
-
|
|
1250
|
+
if (layer.label !== void 0) {
|
|
1251
|
+
visLabelText(layer, target, put, site);
|
|
1252
|
+
}
|
|
1253
|
+
if (typeof layer.wrapWidth === "number" && Number.isFinite(layer.wrapWidth) && layer.wrapWidth > 0) {
|
|
1254
|
+
put("labelWrapWidth", layer.wrapWidth);
|
|
1255
|
+
put("labelWrapSpaceCount", 3);
|
|
1256
|
+
}
|
|
1257
|
+
if (layer.title !== void 0) {
|
|
1258
|
+
put("tooltip", canonText(layer.title, site("tooltip")));
|
|
1259
|
+
}
|
|
1260
|
+
const threshold = isJsonObject(layer.scalingLabel) ? layer.scalingLabel.drawThreshold : void 0;
|
|
1261
|
+
if (typeof threshold === "number" && Number.isFinite(threshold)) {
|
|
1262
|
+
put("labelMinScreenSize", Math.max(0, threshold - 1));
|
|
1263
|
+
}
|
|
1264
|
+
visLabelLook(layer, target, put, color, site);
|
|
1265
|
+
}
|
|
1266
|
+
function visLabelText(layer, target, put, site) {
|
|
1267
|
+
const text = target === "edge" && layer.fontText === true ? "" : canonText(layer.label, site("label"));
|
|
1268
|
+
const marked = typeof text === "string" ? visMarkup(text, layer.fontMulti) : null;
|
|
1269
|
+
put("label", marked?.text ?? text);
|
|
1270
|
+
if (marked !== null) {
|
|
1271
|
+
const runs = visRuns(marked.runs, layer, site("labelRuns"));
|
|
1272
|
+
put("labelRuns", runs);
|
|
1273
|
+
if (runs !== null) {
|
|
1274
|
+
put("labelRunAlign", visRunAlign(layer, target));
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
for (const [p, v] of Object.entries(VIS_MOD_VALUES[marked?.mod ?? "normal"] ?? {})) {
|
|
1278
|
+
put(p, v);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
function visLabelLook(layer, target, put, color, site) {
|
|
1282
|
+
color("labelColor", null, layer.fontColor);
|
|
1283
|
+
color("labelBackground", null, layer.fontBackground === "none" ? void 0 : layer.fontBackground);
|
|
1284
|
+
if (typeof layer.fontBackground === "string" && layer.fontBackground !== "none") {
|
|
1285
|
+
put("labelPadding", 0);
|
|
1286
|
+
put("labelLineHeight", 1);
|
|
1287
|
+
}
|
|
1288
|
+
const stroked = typeof layer.fontStrokeWidth === "number" && layer.fontStrokeWidth > 0;
|
|
1289
|
+
color("labelOutlineColor", null, layer.fontStrokeColor ?? (stroked ? "#ffffff" : void 0));
|
|
1290
|
+
if (layer.fontStrokeWidth !== void 0) {
|
|
1291
|
+
put("labelOutlineWidth", canonNumber(layer.fontStrokeWidth, site("labelOutlineWidth")));
|
|
1292
|
+
}
|
|
1293
|
+
if (target === "edge" && typeof layer.fontAlign === "string") {
|
|
1294
|
+
put("labelPosition", layer.fontAlign === "top" || layer.fontAlign === "bottom" ? layer.fontAlign : "center");
|
|
1295
|
+
} else if (target === "node" && typeof layer.fontAlign === "string") {
|
|
1296
|
+
put("labelTextAlign", { center: "center", right: "right" }[layer.fontAlign] ?? "left");
|
|
1297
|
+
}
|
|
1298
|
+
if (typeof layer.fontVadjust === "number" && Number.isFinite(layer.fontVadjust) && layer.fontVadjust !== 0) {
|
|
1299
|
+
put("labelOffsetY", layer.fontVadjust);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
const VIS_MOD_VALUES = {
|
|
1303
|
+
bold: { labelWeight: "bold" },
|
|
1304
|
+
ital: { labelItalic: true },
|
|
1305
|
+
boldital: { labelWeight: "bold", labelItalic: true },
|
|
1306
|
+
mono: { labelFont: "monospace" }
|
|
1307
|
+
};
|
|
1308
|
+
function visTakesOpacity(color) {
|
|
1309
|
+
if (color === void 0) {
|
|
1310
|
+
return true;
|
|
1311
|
+
}
|
|
1312
|
+
return typeof color === "string" && !color.includes("rgba") && (color.includes("rgb") || /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(color.trim()));
|
|
1313
|
+
}
|
|
1314
|
+
function visBandStyle(bg, round) {
|
|
1315
|
+
if (bg.dashes === void 0 || bg.dashes === false) {
|
|
1316
|
+
return null;
|
|
1317
|
+
}
|
|
1318
|
+
return visDashStyle(bg.dashes === true ? [5, 5] : bg.dashes, typeof bg.size === "number" ? bg.size : 10, round);
|
|
1319
|
+
}
|
|
1320
|
+
function visDashStyle(dashes, width, round) {
|
|
1321
|
+
if (!Array.isArray(dashes)) {
|
|
1322
|
+
return dashes === false ? "solid" : "dashed";
|
|
1323
|
+
}
|
|
1324
|
+
const lengths = dashes.filter((d) => typeof d === "number" && Number.isFinite(d));
|
|
1325
|
+
const pairs = lengths.length % 2 === 1 ? [...lengths, ...lengths] : lengths;
|
|
1326
|
+
const grow = round ? width : 0;
|
|
1327
|
+
const on = pairs.filter((_d, i) => i % 2 === 0).map((d) => Math.max(0, d) + grow);
|
|
1328
|
+
const off = pairs.filter((_d, i) => i % 2 === 1).map((d) => Math.max(0, d - grow));
|
|
1329
|
+
const sum = (xs) => xs.reduce((a, b) => a + b, 0);
|
|
1330
|
+
if (on.length === 0 || sum(off) < 0.1 * (sum(on) + sum(off))) {
|
|
1331
|
+
return "solid";
|
|
1332
|
+
}
|
|
1333
|
+
if (on.every((d) => d <= 1.5 * Math.max(1, width))) {
|
|
1334
|
+
return "dotted";
|
|
1335
|
+
}
|
|
1336
|
+
return Math.max(...on) >= 2 * Math.min(...on) ? "dash-dot" : "dashed";
|
|
1337
|
+
}
|
|
1338
|
+
function visMarkup(text, multi) {
|
|
1339
|
+
const system = VIS_MARKUP_SYSTEM.get(multi);
|
|
1340
|
+
if (system === void 0) {
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
const state = { bold: false, ital: false, mono: false };
|
|
1344
|
+
const runs = [];
|
|
1345
|
+
const source = text.slice(0, 4096);
|
|
1346
|
+
let i = 0;
|
|
1347
|
+
while (i < source.length) {
|
|
1348
|
+
const tagged = visMarkTag(source, i, system, state);
|
|
1349
|
+
if (tagged > 0) {
|
|
1350
|
+
i += tagged;
|
|
1351
|
+
continue;
|
|
1352
|
+
}
|
|
1353
|
+
const [ch, next] = visMarkChar(source, i, system);
|
|
1354
|
+
runs.push({ text: ch, mod: visMarkMod(state) });
|
|
1355
|
+
i = next;
|
|
1356
|
+
}
|
|
1357
|
+
const mods = new Set(runs.filter((r) => /\S/.test(r.text)).map((r) => r.mod));
|
|
1358
|
+
const only = mods.size === 1 ? [...mods][0] : null;
|
|
1359
|
+
const merged = [];
|
|
1360
|
+
for (const r of runs) {
|
|
1361
|
+
const last = merged.at(-1);
|
|
1362
|
+
if (last?.mod === r.mod) {
|
|
1363
|
+
last.text += r.text;
|
|
1364
|
+
} else {
|
|
1365
|
+
merged.push({ ...r });
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
return { text: runs.map((r) => r.text).join(""), mod: only === "normal" ? null : only, runs: merged };
|
|
1369
|
+
}
|
|
1370
|
+
const VIS_MOD_DEFAULTS = {
|
|
1371
|
+
bold: { mod: "bold" },
|
|
1372
|
+
ital: { mod: "italic" },
|
|
1373
|
+
boldital: { mod: "bold italic" },
|
|
1374
|
+
mono: { mod: "", face: "monospace", size: 15, vadjust: 2 }
|
|
1375
|
+
};
|
|
1376
|
+
function visRuns(runs, layer, site) {
|
|
1377
|
+
const own = {
|
|
1378
|
+
face: typeof layer.fontFace === "string" ? layer.fontFace : "arial",
|
|
1379
|
+
size: typeof layer.fontSize === "number" ? layer.fontSize : VIS_FONT_SIZE,
|
|
1380
|
+
color: typeof layer.fontColor === "string" ? layer.fontColor : null,
|
|
1381
|
+
vadjust: typeof layer.fontVadjust === "number" && Number.isFinite(layer.fontVadjust) ? layer.fontVadjust : 0
|
|
1382
|
+
};
|
|
1383
|
+
const mods = isJsonObject(layer.fontMods) ? layer.fontMods : {};
|
|
1384
|
+
let differs = false;
|
|
1385
|
+
const out = runs.map((r) => {
|
|
1386
|
+
const run = { text: r.text };
|
|
1387
|
+
const base = VIS_MOD_DEFAULTS[r.mod];
|
|
1388
|
+
if (base === void 0) {
|
|
1389
|
+
return run;
|
|
1390
|
+
}
|
|
1391
|
+
const given = visModOptions(mods[r.mod]);
|
|
1392
|
+
const modText = typeof given.mod === "string" ? given.mod : base.mod;
|
|
1393
|
+
const face = typeof given.face === "string" ? given.face : base.face ?? own.face;
|
|
1394
|
+
const size = typeof given.size === "number" ? given.size : base.size ?? own.size;
|
|
1395
|
+
const vadjust = typeof given.vadjust === "number" ? given.vadjust : base.vadjust ?? own.vadjust;
|
|
1396
|
+
const color = typeof given.color === "string" ? canonColor(given.color, "vis", site)?.color : null;
|
|
1397
|
+
if (modText.includes("bold")) {
|
|
1398
|
+
run.weight = "bold";
|
|
1399
|
+
}
|
|
1400
|
+
if (modText.includes("italic")) {
|
|
1401
|
+
run.italic = true;
|
|
1402
|
+
}
|
|
1403
|
+
if (face !== null && face !== own.face) {
|
|
1404
|
+
run.font = face;
|
|
1405
|
+
}
|
|
1406
|
+
if (size !== own.size) {
|
|
1407
|
+
run.size = size;
|
|
1408
|
+
}
|
|
1409
|
+
if (Number.isFinite(vadjust) && vadjust !== own.vadjust) {
|
|
1410
|
+
run.shift = vadjust - own.vadjust;
|
|
1411
|
+
}
|
|
1412
|
+
if (typeof color === "string") {
|
|
1413
|
+
run.color = color;
|
|
1414
|
+
}
|
|
1415
|
+
differs ||= Object.keys(run).length > 1;
|
|
1416
|
+
return run;
|
|
1417
|
+
});
|
|
1418
|
+
return differs ? JSON.stringify(out) : null;
|
|
1419
|
+
}
|
|
1420
|
+
function visRunAlign(layer, target) {
|
|
1421
|
+
if (target === "edge") {
|
|
1422
|
+
return { top: "baseline", bottom: "hanging" }[String(layer.fontAlign)] ?? "middle";
|
|
1423
|
+
}
|
|
1424
|
+
const shape = typeof layer.shape === "string" ? layer.shape : "ellipse";
|
|
1425
|
+
return VIS_SIZED.has(shape) ? "hanging" : "middle";
|
|
1426
|
+
}
|
|
1427
|
+
function visBelowGap(size) {
|
|
1428
|
+
return 2 + size / 6;
|
|
1429
|
+
}
|
|
1430
|
+
function visRunsDrop(runs, size) {
|
|
1431
|
+
let parsed;
|
|
1432
|
+
try {
|
|
1433
|
+
parsed = JSON.parse(runs);
|
|
1434
|
+
} catch {
|
|
1435
|
+
return 0;
|
|
1436
|
+
}
|
|
1437
|
+
if (!Array.isArray(parsed)) {
|
|
1438
|
+
return 0;
|
|
1439
|
+
}
|
|
1440
|
+
const lines = [size];
|
|
1441
|
+
for (const run of parsed) {
|
|
1442
|
+
const runSize = typeof run.size === "number" ? run.size : size;
|
|
1443
|
+
(typeof run.text === "string" ? run.text : "").split("\n").forEach((piece, i) => {
|
|
1444
|
+
if (i > 0) {
|
|
1445
|
+
lines.push(size);
|
|
1446
|
+
}
|
|
1447
|
+
if (piece !== "") {
|
|
1448
|
+
lines[lines.length - 1] = Math.max(lines.at(-1) ?? size, runSize);
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
return lines.reduce((sum, h) => sum + h - size, 0) / 2;
|
|
1453
|
+
}
|
|
1454
|
+
function visModOptions(raw) {
|
|
1455
|
+
if (isJsonObject(raw)) {
|
|
1456
|
+
return raw;
|
|
1457
|
+
}
|
|
1458
|
+
if (typeof raw === "string") {
|
|
1459
|
+
const m = /^\s*(\d+(?:\.\d+)?)(?:px)?\s+(\S+)(?:\s+(\S+))?/.exec(raw.slice(0, 256));
|
|
1460
|
+
if (m !== null) {
|
|
1461
|
+
return { size: Number(m[1]), face: m[2], ...m[3] === void 0 ? {} : { color: m[3] } };
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return {};
|
|
1465
|
+
}
|
|
1466
|
+
const VIS_MARKUP_SYSTEM = /* @__PURE__ */ new Map([
|
|
1467
|
+
[true, "html"],
|
|
1468
|
+
["html", "html"],
|
|
1469
|
+
["markdown", "md"],
|
|
1470
|
+
["md", "md"]
|
|
1471
|
+
]);
|
|
1472
|
+
const VIS_MARKS = {
|
|
1473
|
+
html: { "<b>": "bold", "</b>": "bold", "<i>": "ital", "</i>": "ital", "<code>": "mono", "</code>": "mono" },
|
|
1474
|
+
md: { "*": "bold", _: "ital", "`": "mono" }
|
|
1475
|
+
};
|
|
1476
|
+
function visMarkTag(source, i, system, state) {
|
|
1477
|
+
const marks = VIS_MARKS[system];
|
|
1478
|
+
const tag = Object.keys(marks).find((m) => source.startsWith(m, i));
|
|
1479
|
+
if (tag === void 0) {
|
|
1480
|
+
return 0;
|
|
1481
|
+
}
|
|
1482
|
+
const key = marks[tag];
|
|
1483
|
+
const toggles = system === "html" ? state[key] === tag.startsWith("</") : state[key] || i === 0 || /\s/.test(source[i - 1]);
|
|
1484
|
+
if (!toggles) {
|
|
1485
|
+
return 0;
|
|
1486
|
+
}
|
|
1487
|
+
state[key] = !state[key];
|
|
1488
|
+
return tag.length;
|
|
1489
|
+
}
|
|
1490
|
+
function visMarkChar(source, i, system) {
|
|
1491
|
+
if (system === "md") {
|
|
1492
|
+
return source[i] === "\\" && i + 1 < source.length ? [source[i + 1], i + 2] : [source[i], i + 1];
|
|
1493
|
+
}
|
|
1494
|
+
const entity = [
|
|
1495
|
+
["<", "<"],
|
|
1496
|
+
["&", "&"]
|
|
1497
|
+
].find(([e]) => source.startsWith(e, i));
|
|
1498
|
+
return entity === void 0 ? [source[i], i + 1] : [entity[1], i + entity[0].length];
|
|
1499
|
+
}
|
|
1500
|
+
function visMarkMod(state) {
|
|
1501
|
+
if (state.mono) {
|
|
1502
|
+
return "mono";
|
|
1503
|
+
}
|
|
1504
|
+
if (state.bold) {
|
|
1505
|
+
return state.ital ? "boldital" : "bold";
|
|
1506
|
+
}
|
|
1507
|
+
return state.ital ? "ital" : "normal";
|
|
1072
1508
|
}
|
|
1073
1509
|
function visNodeValues(layer, sized, put, site) {
|
|
1074
1510
|
if (layer.shape !== void 0) {
|
|
1075
1511
|
put("shape", canonEnum("shape", layer.shape, "vis", site("shape")));
|
|
1512
|
+
if (typeof layer.shape === "string") {
|
|
1513
|
+
put("labelPosition", VIS_SIZED.has(layer.shape) ? "bottom" : "center");
|
|
1514
|
+
}
|
|
1076
1515
|
}
|
|
1077
1516
|
if (sized && layer.size !== void 0) {
|
|
1078
1517
|
const v = canonNumber(layer.size, site("width"));
|
|
1079
|
-
put("width", v);
|
|
1080
|
-
put("height", v);
|
|
1518
|
+
put("width", v === null ? null : 2 * v);
|
|
1519
|
+
put("height", v === null ? null : 2 * v);
|
|
1081
1520
|
}
|
|
1082
1521
|
if (layer.borderWidth !== void 0) {
|
|
1083
1522
|
put("borderWidth", canonNumber(layer.borderWidth, site("borderWidth")));
|
|
1084
1523
|
}
|
|
1524
|
+
visNodeOpacityAndDashes(layer, put, site);
|
|
1525
|
+
}
|
|
1526
|
+
function visNodeOpacityAndDashes(layer, put, site) {
|
|
1085
1527
|
if (layer.opacity !== void 0) {
|
|
1086
|
-
|
|
1528
|
+
const opacity = canonOpacity(layer.opacity, "vis", site("opacity"));
|
|
1529
|
+
put("opacity", visTakesOpacity(layer.fill) ? opacity : null);
|
|
1530
|
+
put("borderOpacity", visTakesOpacity(layer.border) ? opacity : null);
|
|
1531
|
+
}
|
|
1532
|
+
if (layer.borderDashes !== void 0) {
|
|
1533
|
+
const width = typeof layer.borderWidth === "number" ? layer.borderWidth : 1;
|
|
1534
|
+
put("borderStyle", visDashStyle(layer.borderDashes === true ? [5, 15] : layer.borderDashes, width, false));
|
|
1087
1535
|
}
|
|
1088
1536
|
}
|
|
1089
1537
|
function visEdgeValues(layer, put, site) {
|
|
@@ -1094,18 +1542,52 @@ function visEdgeValues(layer, put, site) {
|
|
|
1094
1542
|
put("width", canonNumber(layer.width, site("width")));
|
|
1095
1543
|
}
|
|
1096
1544
|
if (layer.dashes !== void 0) {
|
|
1097
|
-
|
|
1545
|
+
const width = typeof layer.width === "number" ? layer.width : 1;
|
|
1546
|
+
const dashes = layer.dashes === true ? [5, 5] : layer.dashes;
|
|
1547
|
+
put("lineStyle", layer.dashes === "false" ? "solid" : visDashStyle(dashes, width, true));
|
|
1098
1548
|
}
|
|
1099
1549
|
if (layer.arrows !== void 0) {
|
|
1100
|
-
const [to, from] = visArrows(layer.arrows, site);
|
|
1550
|
+
const [to, from, middle] = visArrows(layer.arrows, site);
|
|
1101
1551
|
put("targetArrow", to);
|
|
1102
1552
|
put("sourceArrow", from);
|
|
1553
|
+
put("midTargetArrow", middle);
|
|
1554
|
+
const scaled = (name) => {
|
|
1555
|
+
const a = isJsonObject(layer.arrows) ? layer.arrows[name] : void 0;
|
|
1556
|
+
return isJsonObject(a) ? a.scaleFactor : void 0;
|
|
1557
|
+
};
|
|
1558
|
+
const scale = scaled("to") ?? scaled("from") ?? scaled("middle");
|
|
1559
|
+
if (scale !== void 0) {
|
|
1560
|
+
put("arrowSize", canonNumber(scale, site("arrowSize")));
|
|
1561
|
+
}
|
|
1562
|
+
visArrowImages(layer.arrows, put, site);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function visArrowImages(arrows, put, site) {
|
|
1566
|
+
if (!isJsonObject(arrows)) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
for (const [name, property] of [
|
|
1570
|
+
["to", "targetArrow"],
|
|
1571
|
+
["from", "sourceArrow"],
|
|
1572
|
+
["middle", "midTargetArrow"]
|
|
1573
|
+
]) {
|
|
1574
|
+
const a = arrows[name];
|
|
1575
|
+
if (!isJsonObject(a) || a.type !== "image" || typeof a.src !== "string" || a.src === "") {
|
|
1576
|
+
continue;
|
|
1577
|
+
}
|
|
1578
|
+
put(`${property}Image`, a.src);
|
|
1579
|
+
if (a.imageWidth !== void 0) {
|
|
1580
|
+
put(`${property}ImageWidth`, canonNumber(a.imageWidth, site(`${property}ImageWidth`)));
|
|
1581
|
+
}
|
|
1582
|
+
if (a.imageHeight !== void 0) {
|
|
1583
|
+
put(`${property}ImageHeight`, canonNumber(a.imageHeight, site(`${property}ImageHeight`)));
|
|
1584
|
+
}
|
|
1103
1585
|
}
|
|
1104
1586
|
}
|
|
1105
1587
|
function visArrows(arrows, site) {
|
|
1106
|
-
const end = (name, property) => {
|
|
1588
|
+
const end = (name, property, absent = "none") => {
|
|
1107
1589
|
if (typeof arrows === "string") {
|
|
1108
|
-
return new RegExp(String.raw`\b${name}\b`).test(arrows.slice(0, 256)) ? "triangle" :
|
|
1590
|
+
return new RegExp(String.raw`\b${name}\b`).test(arrows.slice(0, 256)) ? "triangle" : absent;
|
|
1109
1591
|
}
|
|
1110
1592
|
if (!isJsonObject(arrows)) {
|
|
1111
1593
|
return null;
|
|
@@ -1114,12 +1596,15 @@ function visArrows(arrows, site) {
|
|
|
1114
1596
|
if (a === true) {
|
|
1115
1597
|
return "triangle";
|
|
1116
1598
|
}
|
|
1599
|
+
if (a === void 0) {
|
|
1600
|
+
return absent;
|
|
1601
|
+
}
|
|
1117
1602
|
if (!isJsonObject(a) || a.enabled === false) {
|
|
1118
1603
|
return "none";
|
|
1119
1604
|
}
|
|
1120
1605
|
return canonEnum("arrow", a.type ?? "arrow", "vis", site(property));
|
|
1121
1606
|
};
|
|
1122
|
-
return [end("to", "targetArrow"), end("from", "sourceArrow")];
|
|
1607
|
+
return [end("to", "targetArrow"), end("from", "sourceArrow"), end("middle", "midTargetArrow", null)];
|
|
1123
1608
|
}
|
|
1124
1609
|
function visStyles(snapshot, src, context) {
|
|
1125
1610
|
const notes = new StyleNotes();
|
|
@@ -1137,13 +1622,17 @@ function visStyles(snapshot, src, context) {
|
|
|
1137
1622
|
const { groupLayers, paletteRows } = visGroupLayers(n, groupOf, visGroupDefs(src, options));
|
|
1138
1623
|
context.budget.spend("node", n);
|
|
1139
1624
|
const node = valuesOf(n);
|
|
1140
|
-
const
|
|
1141
|
-
const
|
|
1625
|
+
const shapes = [];
|
|
1626
|
+
const rawRecords = elementRaw(snapshot, "node");
|
|
1627
|
+
const range = visNodeValueRange(n, groupOf, rawRecords, groupLayers, nodeDefaults);
|
|
1628
|
+
const ownGroup = visOwnGroup(groupLayers, visGroupDefs(src, options));
|
|
1142
1629
|
for (let i = 0; i < n; i++) {
|
|
1143
1630
|
const g = groupOf(i);
|
|
1144
|
-
const
|
|
1145
|
-
const
|
|
1146
|
-
const
|
|
1631
|
+
const raw = rawRecords(i);
|
|
1632
|
+
const own = visLayer(raw, "node");
|
|
1633
|
+
const group = g === null ? {} : ownGroup(g, raw);
|
|
1634
|
+
const shape = visShapeOf(own) ?? visShapeOf(group) ?? visShapeOf(nodeDefaults) ?? "ellipse";
|
|
1635
|
+
shapes.push(shape);
|
|
1147
1636
|
const site = (property) => ({
|
|
1148
1637
|
notes,
|
|
1149
1638
|
target: "node",
|
|
@@ -1151,8 +1640,8 @@ function visStyles(snapshot, src, context) {
|
|
|
1151
1640
|
element: i,
|
|
1152
1641
|
budget: context.budget
|
|
1153
1642
|
});
|
|
1154
|
-
const merged =
|
|
1155
|
-
for (const [p, v] of Object.entries(
|
|
1643
|
+
const merged = visMergedNode(nodeDefaults, group, own, g !== null && raw.color !== void 0);
|
|
1644
|
+
for (const [p, v] of Object.entries(visNodeRow(merged, shape, range, site))) {
|
|
1156
1645
|
node.put(p, i, v);
|
|
1157
1646
|
}
|
|
1158
1647
|
}
|
|
@@ -1160,26 +1649,15 @@ function visStyles(snapshot, src, context) {
|
|
|
1160
1649
|
if (Object.keys(declaredNode).length > 0) {
|
|
1161
1650
|
nodeRules.push(rule("node.vis.defaults", "node", "defaults", "declared", { all: true }, declaredNode));
|
|
1162
1651
|
}
|
|
1163
|
-
|
|
1164
|
-
for (const [g, layer] of groupLayers) {
|
|
1165
|
-
const set = paletteRows.get(g) ?? visValues(layer, "node", ruleSite("node"), true);
|
|
1166
|
-
if (Object.keys(set).length === 0) {
|
|
1167
|
-
continue;
|
|
1168
|
-
}
|
|
1169
|
-
const key = `group.${String(k)}`;
|
|
1170
|
-
nodeColumns.set(
|
|
1171
|
-
key,
|
|
1172
|
-
Array.from({ length: n }, (_v, i) => groupOf(i) === g ? true : null)
|
|
1173
|
-
);
|
|
1174
|
-
const origin = paletteRows.has(g) ? "tool" : "declared";
|
|
1175
|
-
const r = rule(`node.vis.group.${String(k++)}`, "node", "group", origin, { has: { style: key } }, set);
|
|
1176
|
-
nodeRules.push({ ...r, facts: { names: [[key, g]] } });
|
|
1177
|
-
}
|
|
1652
|
+
visGroupRules(n, groupOf, groupLayers, paletteRows, ruleSite("node"), nodeRules, nodeColumns);
|
|
1178
1653
|
const toolNode = toolDefaults("vis-network")?.node;
|
|
1179
1654
|
const borderOf = (i) => node.values.borderColor?.[i] ?? toolNode?.borderColor?.value ?? "#2b7ce9";
|
|
1180
|
-
const
|
|
1655
|
+
const geometry = visGeometry(snapshot, node.values, shapes);
|
|
1656
|
+
const support = visSupport(options.physics, options.layout);
|
|
1657
|
+
const edges = visLayer(options.edges, "edge");
|
|
1658
|
+
const edge = visEdges(snapshot, edges, borderOf, { ...geometry, support }, notes, context);
|
|
1181
1659
|
const values = { node: node.values, edge: edge.values };
|
|
1182
|
-
exactFromBlock(snapshot, src.block, values,
|
|
1660
|
+
exactFromBlock(snapshot, src.block, values, visWritten(snapshot, values.edge));
|
|
1183
1661
|
return {
|
|
1184
1662
|
canonical: true,
|
|
1185
1663
|
dialect: "vis",
|
|
@@ -1196,6 +1674,202 @@ function visStyles(snapshot, src, context) {
|
|
|
1196
1674
|
}
|
|
1197
1675
|
};
|
|
1198
1676
|
}
|
|
1677
|
+
function visShapeOf(layer) {
|
|
1678
|
+
return typeof layer.shape === "string" ? layer.shape : null;
|
|
1679
|
+
}
|
|
1680
|
+
function visNodeValueRange(n, groupOf, rawRecords, groupLayers, nodeDefaults) {
|
|
1681
|
+
return visValueRange(n, (i) => {
|
|
1682
|
+
const g = groupOf(i);
|
|
1683
|
+
const own = visLayer(rawRecords(i), "node").value;
|
|
1684
|
+
const value = own ?? (g === null ? void 0 : groupLayers.get(g)?.value) ?? nodeDefaults.value;
|
|
1685
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
function visMergedNode(nodeDefaults, group, own, ownColorInGroup) {
|
|
1689
|
+
const merged = { ...nodeDefaults, ...group, ...own };
|
|
1690
|
+
if (ownColorInGroup) {
|
|
1691
|
+
merged.fill ??= VIS_NODE_FILL;
|
|
1692
|
+
merged.border ??= VIS_NODE_BORDER;
|
|
1693
|
+
}
|
|
1694
|
+
return merged;
|
|
1695
|
+
}
|
|
1696
|
+
function visNodeRow(merged, shape, range, site) {
|
|
1697
|
+
const sized = VIS_SIZED.has(shape);
|
|
1698
|
+
const row = visValues(merged, "node", site, sized);
|
|
1699
|
+
const shaped = sized ? visSizedShape(merged, shape, visRadius(merged, range, site), site) : visFitShape(merged, shape);
|
|
1700
|
+
if (sized && merged.label !== void 0) {
|
|
1701
|
+
const size = visLabelScaled(merged, range) ?? (typeof merged.fontSize === "number" ? merged.fontSize : VIS_FONT_SIZE);
|
|
1702
|
+
const drop = typeof row.labelRuns === "string" ? visRunsDrop(row.labelRuns, size) : 0;
|
|
1703
|
+
const below = typeof row.labelOffsetY === "number" ? row.labelOffsetY : 0;
|
|
1704
|
+
row.labelOffsetY = below + drop + visBelowGap(size);
|
|
1705
|
+
}
|
|
1706
|
+
for (const p of ["labelOffsetX", "labelOffsetY"]) {
|
|
1707
|
+
const [a, b] = [row[p], shaped[p]];
|
|
1708
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
1709
|
+
shaped[p] = a + b;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
Object.assign(row, shaped);
|
|
1713
|
+
const labelSize = visLabelScaled(merged, range);
|
|
1714
|
+
if (labelSize !== null) {
|
|
1715
|
+
row.labelSize = labelSize;
|
|
1716
|
+
}
|
|
1717
|
+
return row;
|
|
1718
|
+
}
|
|
1719
|
+
function visGroupRules(n, groupOf, groupLayers, paletteRows, site, rules, columns) {
|
|
1720
|
+
let k = 0;
|
|
1721
|
+
for (const [g, layer] of groupLayers) {
|
|
1722
|
+
const set = paletteRows.get(g) ?? visValues(layer, "node", site, true);
|
|
1723
|
+
if (Object.keys(set).length === 0) {
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
const key = `group.${String(k)}`;
|
|
1727
|
+
columns.set(
|
|
1728
|
+
key,
|
|
1729
|
+
Array.from({ length: n }, (_v, i) => groupOf(i) === g ? true : null)
|
|
1730
|
+
);
|
|
1731
|
+
const origin = paletteRows.has(g) ? "tool" : "declared";
|
|
1732
|
+
const r = rule(`node.vis.group.${String(k++)}`, "node", "group", origin, { has: { style: key } }, set);
|
|
1733
|
+
rules.push({ ...r, facts: { names: [[key, g]] } });
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function visSizedShape(merged, shape, radius, site) {
|
|
1737
|
+
const row = { width: 2 * radius, height: 2 * radius };
|
|
1738
|
+
if (shape === "hexagon") {
|
|
1739
|
+
row.height = Math.sqrt(3) * radius;
|
|
1740
|
+
row.labelOffsetY = (2 - Math.sqrt(3)) * radius / 2;
|
|
1741
|
+
}
|
|
1742
|
+
Object.assign(row, visImage(merged, shape, { width: 2 * radius, height: 2 * radius }));
|
|
1743
|
+
if (shape === "icon") {
|
|
1744
|
+
Object.assign(row, { shape: "none" }, visIcon(merged, site("glyphColor")));
|
|
1745
|
+
}
|
|
1746
|
+
if (shape === "triangleDown") {
|
|
1747
|
+
row.shape = "polygon";
|
|
1748
|
+
row.shapePoints = "-1,1 0,-1 1,1";
|
|
1749
|
+
}
|
|
1750
|
+
return row;
|
|
1751
|
+
}
|
|
1752
|
+
function visFitShape(merged, shape) {
|
|
1753
|
+
const row = visLabelFit(merged, shape);
|
|
1754
|
+
if (merged.margin === 0 && (shape === "box" || shape === "circle" || shape === "database")) {
|
|
1755
|
+
row.visible = false;
|
|
1756
|
+
}
|
|
1757
|
+
if (merged.valign === "top" || merged.valign === "bottom") {
|
|
1758
|
+
row.labelPosition = `inside-${merged.valign}`;
|
|
1759
|
+
} else if (shape === "database") {
|
|
1760
|
+
const m = merged.margin;
|
|
1761
|
+
const top = isJsonObject(m) ? m.top : m;
|
|
1762
|
+
row.labelPosition = "inside-top";
|
|
1763
|
+
row.labelOffsetY = typeof top === "number" && Number.isFinite(top) && top >= 0 ? top : VIS_MARGIN;
|
|
1764
|
+
}
|
|
1765
|
+
if (shape === "box" && typeof merged.borderRadius === "number" && Number.isFinite(merged.borderRadius)) {
|
|
1766
|
+
row.cornerRadius = Math.max(0, merged.borderRadius);
|
|
1767
|
+
}
|
|
1768
|
+
return row;
|
|
1769
|
+
}
|
|
1770
|
+
function visLabelFit(layer, shape) {
|
|
1771
|
+
const fit = VIS_LABEL_FIT.get(shape);
|
|
1772
|
+
if (fit === void 0) {
|
|
1773
|
+
return {};
|
|
1774
|
+
}
|
|
1775
|
+
const length = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
1776
|
+
const fontSize = length(layer.fontSize) ?? VIS_FONT_SIZE;
|
|
1777
|
+
const lines = typeof layer.label === "string" ? Math.max(1, layer.label.split("\n").length) : 1;
|
|
1778
|
+
const minW = length(layer.widthMin) ?? 0;
|
|
1779
|
+
const minH = length(layer.heightMin) ?? 0;
|
|
1780
|
+
let padX;
|
|
1781
|
+
let padY;
|
|
1782
|
+
let offset = {};
|
|
1783
|
+
if (fit.ellipse) {
|
|
1784
|
+
padX = Math.max(lines * fontSize, minH) / 2;
|
|
1785
|
+
padY = padX;
|
|
1786
|
+
} else {
|
|
1787
|
+
({ padX, padY, offset } = visMarginPads(layer.margin, fit.square));
|
|
1788
|
+
}
|
|
1789
|
+
const empty = typeof layer.label !== "string" || layer.label === "";
|
|
1790
|
+
const [boxW, boxH] = empty ? [Math.max(minW, 14), Math.max(minH, 14)] : [minW, minH];
|
|
1791
|
+
if (empty && fit.ellipse) {
|
|
1792
|
+
padX = boxH / 2;
|
|
1793
|
+
padY = padX;
|
|
1794
|
+
}
|
|
1795
|
+
const row = {
|
|
1796
|
+
...offset,
|
|
1797
|
+
labelFit: "bounds",
|
|
1798
|
+
labelPaddingX: padX,
|
|
1799
|
+
labelPaddingY: padY,
|
|
1800
|
+
width: boxW > 0 ? boxW + 2 * padX : 0,
|
|
1801
|
+
height: boxH > 0 ? boxH + 2 * padY : 0
|
|
1802
|
+
};
|
|
1803
|
+
if (fit.square) {
|
|
1804
|
+
row.labelFitSquare = true;
|
|
1805
|
+
}
|
|
1806
|
+
return row;
|
|
1807
|
+
}
|
|
1808
|
+
function visMarginPads(m, square) {
|
|
1809
|
+
const length = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
1810
|
+
const side = (key) => (isJsonObject(m) ? length(m[key]) : length(m)) ?? VIS_MARGIN;
|
|
1811
|
+
const offset = {};
|
|
1812
|
+
if (!square && side("left") !== side("right")) {
|
|
1813
|
+
offset.labelOffsetX = (side("left") - side("right")) / 2;
|
|
1814
|
+
}
|
|
1815
|
+
if (!square && side("top") !== side("bottom")) {
|
|
1816
|
+
offset.labelOffsetY = (side("top") - side("bottom")) / 2;
|
|
1817
|
+
}
|
|
1818
|
+
return { padX: (side("left") + side("right")) / 2, padY: (side("top") + side("bottom")) / 2, offset };
|
|
1819
|
+
}
|
|
1820
|
+
function visLabelScaled(layer, range) {
|
|
1821
|
+
const value = finiteValue(layer.value);
|
|
1822
|
+
const label = layer.scalingLabel;
|
|
1823
|
+
if (value === null || range === null || !isJsonObject(label) || label.enabled !== true) {
|
|
1824
|
+
return null;
|
|
1825
|
+
}
|
|
1826
|
+
const min = typeof label.min === "number" ? label.min : 14;
|
|
1827
|
+
const max = typeof label.max === "number" ? label.max : 30;
|
|
1828
|
+
return visScaled(value, range, min, max);
|
|
1829
|
+
}
|
|
1830
|
+
const VIS_SIZE = 25;
|
|
1831
|
+
const VIS_SCALING = [10, 30];
|
|
1832
|
+
function visValueRange(n, valueOf) {
|
|
1833
|
+
let min = Infinity;
|
|
1834
|
+
let max = -Infinity;
|
|
1835
|
+
for (let i = 0; i < n; i++) {
|
|
1836
|
+
const v = valueOf(i);
|
|
1837
|
+
if (v !== null) {
|
|
1838
|
+
min = Math.min(min, v);
|
|
1839
|
+
max = Math.max(max, v);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
return min <= max ? [min, max] : null;
|
|
1843
|
+
}
|
|
1844
|
+
const finiteValue = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1845
|
+
function visScaled(value, range, min, max) {
|
|
1846
|
+
const [lo, hi] = range;
|
|
1847
|
+
const scale = hi === lo ? 0.5 : Math.max(0, (value - lo) / (hi - lo));
|
|
1848
|
+
return min + scale * (max - min);
|
|
1849
|
+
}
|
|
1850
|
+
const VIS_EDGE_SCALING = [1, 15];
|
|
1851
|
+
function visEdgeWidth(layer, defaults, range, site) {
|
|
1852
|
+
if (range === null) {
|
|
1853
|
+
return {};
|
|
1854
|
+
}
|
|
1855
|
+
const value = finiteValue(layer.value);
|
|
1856
|
+
if (value !== null) {
|
|
1857
|
+
const min = typeof layer.scalingMin === "number" ? layer.scalingMin : VIS_EDGE_SCALING[0];
|
|
1858
|
+
const max = typeof layer.scalingMax === "number" ? layer.scalingMax : VIS_EDGE_SCALING[1];
|
|
1859
|
+
return { width: visScaled(value, range, min, max) };
|
|
1860
|
+
}
|
|
1861
|
+
return { width: (defaults.width === void 0 ? null : canonNumber(defaults.width, site("width"))) ?? 1 };
|
|
1862
|
+
}
|
|
1863
|
+
function visRadius(layer, range, site) {
|
|
1864
|
+
const value = finiteValue(layer.value);
|
|
1865
|
+
if (value !== null && range !== null) {
|
|
1866
|
+
const min = typeof layer.scalingMin === "number" ? layer.scalingMin : VIS_SCALING[0];
|
|
1867
|
+
const max = typeof layer.scalingMax === "number" ? layer.scalingMax : VIS_SCALING[1];
|
|
1868
|
+
return visScaled(value, range, min, max);
|
|
1869
|
+
}
|
|
1870
|
+
const size = layer.size === void 0 ? null : canonNumber(layer.size, site("width"));
|
|
1871
|
+
return size ?? VIS_SIZE;
|
|
1872
|
+
}
|
|
1199
1873
|
function visGroupDefs(src, options) {
|
|
1200
1874
|
if (isJsonObject(options.groups)) {
|
|
1201
1875
|
return options.groups;
|
|
@@ -1221,15 +1895,38 @@ function visGroupLayers(n, groupOf, groupDefs) {
|
|
|
1221
1895
|
}
|
|
1222
1896
|
return { groupLayers, paletteRows };
|
|
1223
1897
|
}
|
|
1224
|
-
function
|
|
1898
|
+
function visOwnGroup(groupLayers, groupDefs) {
|
|
1899
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1900
|
+
return (g, own) => {
|
|
1901
|
+
const whole = groupLayers.get(g) ?? {};
|
|
1902
|
+
const def = Object.hasOwn(groupDefs, g) ? groupDefs[g] : null;
|
|
1903
|
+
const skip = Object.keys(own).filter(
|
|
1904
|
+
(k) => k !== "font" && (isJsonObject(def) ? Object.hasOwn(def, k) : k === "color")
|
|
1905
|
+
);
|
|
1906
|
+
if (skip.length === 0) {
|
|
1907
|
+
return whole;
|
|
1908
|
+
}
|
|
1909
|
+
const key = `${g}\0${skip.join("\0")}`;
|
|
1910
|
+
let layer = cache.get(key);
|
|
1911
|
+
if (layer === void 0) {
|
|
1912
|
+
layer = isJsonObject(def) ? visLayer(Object.fromEntries(Object.entries(def).filter(([k]) => !skip.includes(k))), "node") : {};
|
|
1913
|
+
cache.set(key, layer);
|
|
1914
|
+
}
|
|
1915
|
+
return layer;
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
function visEdges(snapshot, edgeDefaults, borderOf, geometry, notes, context) {
|
|
1225
1919
|
const m = snapshot.edgeCount;
|
|
1226
1920
|
const edge = valuesOf(m);
|
|
1227
1921
|
const edgeRecords = elementRecords(snapshot, "edge");
|
|
1228
1922
|
const inherited = new Array(m).fill(null);
|
|
1229
1923
|
let inheriting = 0;
|
|
1924
|
+
const range = visValueRange(m, (e) => finiteValue({ ...edgeDefaults, ...edgeRecords(e) }.value));
|
|
1925
|
+
let roundCaps = false;
|
|
1230
1926
|
for (let e = 0; e < m; e++) {
|
|
1231
1927
|
const own = edgeRecords(e);
|
|
1232
|
-
const
|
|
1928
|
+
const bridged = own.dashes === void 0 && Array.isArray(edgeDefaults.dashes) ? { dashes: true } : {};
|
|
1929
|
+
const merged = { ...edgeDefaults, ...own, ...bridged };
|
|
1233
1930
|
const site = (property) => ({
|
|
1234
1931
|
notes,
|
|
1235
1932
|
target: "edge",
|
|
@@ -1237,24 +1934,49 @@ function visEdges(snapshot, edgeDefaults, borderOf, notes, context) {
|
|
|
1237
1934
|
element: e,
|
|
1238
1935
|
budget: context.budget
|
|
1239
1936
|
});
|
|
1240
|
-
const
|
|
1937
|
+
const [s, t] = [snapshot.edgeSource(e), snapshot.edgeTarget(e)];
|
|
1938
|
+
const vals = {
|
|
1939
|
+
...visValues(merged, "edge", site, true),
|
|
1940
|
+
...visEdgeWidth(merged, edgeDefaults, range, site),
|
|
1941
|
+
...visRoute(edgeDefaults, own, s, t, geometry),
|
|
1942
|
+
...visEdgeLabel(merged, range, geometry.at(s), geometry.at(t))
|
|
1943
|
+
};
|
|
1944
|
+
roundCaps ||= merged.hidden !== true && ![void 0, false, "false"].includes(merged.dashes);
|
|
1945
|
+
const band = roundCaps && isJsonObject(merged.background) ? visBandStyle(merged.background, true) : null;
|
|
1946
|
+
if (band !== null) {
|
|
1947
|
+
vals.outlineStyle = band;
|
|
1948
|
+
}
|
|
1949
|
+
const from = visEdgeInherit(vals, own.inherit ?? edgeDefaults.inherit ?? "from", borderOf, s, t);
|
|
1241
1950
|
for (const [p, v] of Object.entries(vals)) {
|
|
1242
1951
|
edge.put(p, e, v);
|
|
1243
1952
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
edge.put("color", e, VIS_EDGE_COLOR);
|
|
1248
|
-
}
|
|
1249
|
-
continue;
|
|
1250
|
-
}
|
|
1251
|
-
if (inherit === "both") {
|
|
1252
|
-
notes.add(STYLE_ISSUE.GRADIENT, "edge", "color", { sample: "inherit both", element: e });
|
|
1953
|
+
if (from !== null) {
|
|
1954
|
+
inherited[e] = from;
|
|
1955
|
+
inheriting++;
|
|
1253
1956
|
}
|
|
1254
|
-
inherited[e] = borderOf(inherit === "to" ? snapshot.edgeTarget(e) : snapshot.edgeSource(e));
|
|
1255
|
-
inheriting++;
|
|
1256
1957
|
}
|
|
1257
1958
|
context.budget.spend("edge", m);
|
|
1959
|
+
const { rules, columns } = visEdgeRules(edgeDefaults, notes, inherited, inheriting);
|
|
1960
|
+
return { values: edge.values, rules, columns };
|
|
1961
|
+
}
|
|
1962
|
+
function visEdgeInherit(vals, inherit, borderOf, s, t) {
|
|
1963
|
+
const inherits = inherit !== false && inherit !== "false";
|
|
1964
|
+
if (inherits) {
|
|
1965
|
+
delete vals.color;
|
|
1966
|
+
}
|
|
1967
|
+
if (inherit === "both") {
|
|
1968
|
+
vals.gradientKind = "linear";
|
|
1969
|
+
vals.gradientColors = `${String(borderOf(s))} ${String(borderOf(t))}`;
|
|
1970
|
+
}
|
|
1971
|
+
if (!inherits) {
|
|
1972
|
+
if (vals.color === void 0) {
|
|
1973
|
+
vals.color = VIS_EDGE_COLOR;
|
|
1974
|
+
}
|
|
1975
|
+
return null;
|
|
1976
|
+
}
|
|
1977
|
+
return borderOf(inherit === "to" ? t : s);
|
|
1978
|
+
}
|
|
1979
|
+
function visEdgeRules(edgeDefaults, notes, inherited, inheriting) {
|
|
1258
1980
|
const edgeRules = [];
|
|
1259
1981
|
const edgeColumns = /* @__PURE__ */ new Map();
|
|
1260
1982
|
const declaredEdge = visValues(edgeDefaults, "edge", (property) => ({ notes, target: "edge", property }), true);
|
|
@@ -1273,16 +1995,317 @@ function visEdges(snapshot, edgeDefaults, borderOf, notes, context) {
|
|
|
1273
1995
|
facts: { elements: inheriting, reason: "SOURCE_NODE_COLOR" }
|
|
1274
1996
|
});
|
|
1275
1997
|
}
|
|
1276
|
-
return {
|
|
1998
|
+
return { rules: edgeRules, columns: edgeColumns };
|
|
1277
1999
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
2000
|
+
function visGeometry(snapshot, nodeValues, shapes) {
|
|
2001
|
+
const whole = (v) => {
|
|
2002
|
+
if (typeof v === "string") {
|
|
2003
|
+
return Number.parseInt(v, 10);
|
|
2004
|
+
}
|
|
2005
|
+
return typeof v === "number" && Number.isFinite(v) ? Math.trunc(v) : Number.NaN;
|
|
2006
|
+
};
|
|
2007
|
+
const [xs, ys] = [cells(snapshot, "node", "x"), cells(snapshot, "node", "y")];
|
|
2008
|
+
const num = (v) => typeof v === "number" && v > 0 ? v : null;
|
|
2009
|
+
return {
|
|
2010
|
+
at: (i) => {
|
|
2011
|
+
const p = [whole(xs?.(i)), whole(ys?.(i))];
|
|
2012
|
+
return Number.isNaN(p[0]) || Number.isNaN(p[1]) ? null : p;
|
|
2013
|
+
},
|
|
2014
|
+
box: (i) => {
|
|
2015
|
+
const [w, h] = [num(nodeValues.width?.[i]), num(nodeValues.height?.[i])];
|
|
2016
|
+
const bw = nodeValues.borderWidth?.[i];
|
|
2017
|
+
return w === null || h === null ? null : [w / 2, h / 2, typeof bw === "number" ? bw : 1, shapes[i]];
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
}
|
|
2021
|
+
function visSmooth(...layers) {
|
|
2022
|
+
const s = { enabled: true, type: "dynamic", roundness: 0.5, forceDirection: "none" };
|
|
2023
|
+
for (const l of layers) {
|
|
2024
|
+
if (typeof l === "boolean") {
|
|
2025
|
+
s.enabled = l;
|
|
2026
|
+
} else if (isJsonObject(l)) {
|
|
2027
|
+
s.enabled = typeof l.enabled === "boolean" ? l.enabled : s.enabled;
|
|
2028
|
+
s.type = typeof l.type === "string" ? l.type : s.type;
|
|
2029
|
+
s.roundness = typeof l.roundness === "number" && Number.isFinite(l.roundness) ? l.roundness : s.roundness;
|
|
2030
|
+
s.forceDirection = l.forceDirection ?? s.forceDirection;
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
return s;
|
|
2034
|
+
}
|
|
2035
|
+
function visEdgeLabel(merged, range, a, b) {
|
|
2036
|
+
const row = {};
|
|
2037
|
+
const size = visLabelScaled(merged, range);
|
|
2038
|
+
if (size !== null) {
|
|
2039
|
+
row.labelSize = size;
|
|
2040
|
+
}
|
|
2041
|
+
const turn = visLabelTurn(merged.fontAlign, a, b);
|
|
2042
|
+
if (turn !== null) {
|
|
2043
|
+
row.labelRotation = turn;
|
|
2044
|
+
}
|
|
2045
|
+
return row;
|
|
2046
|
+
}
|
|
2047
|
+
function visLabelTurn(align, a, b) {
|
|
2048
|
+
if (typeof align !== "string" || align === "horizontal" || a === null || b === null) {
|
|
2049
|
+
return null;
|
|
2050
|
+
}
|
|
2051
|
+
const [dx, dy] = [a[0] - b[0], a[1] - b[1]];
|
|
2052
|
+
let angle = Math.atan2(dy, dx);
|
|
2053
|
+
if (angle < -1 && dx < 0 || angle > 0 && dx < 0) {
|
|
2054
|
+
angle += Math.PI;
|
|
2055
|
+
}
|
|
2056
|
+
const degrees = Math.round(angle * 180 / Math.PI * 1e4) / 1e4;
|
|
2057
|
+
return degrees < 0 ? degrees + 360 : degrees;
|
|
2058
|
+
}
|
|
2059
|
+
function visStaticVia(from, to, smooth) {
|
|
2060
|
+
const f = smooth.roundness;
|
|
2061
|
+
const [fx, fy] = from;
|
|
2062
|
+
const [tx, ty] = to;
|
|
2063
|
+
const dx = Math.abs(fx - tx);
|
|
2064
|
+
const dy = Math.abs(fy - ty);
|
|
2065
|
+
const step = f * Math.max(dx, dy);
|
|
2066
|
+
const sx = step * (Math.sign(tx - fx) || 1);
|
|
2067
|
+
const sy = step * (Math.sign(ty - fy) || -1);
|
|
2068
|
+
const backX = (1 - f) * dx * (Math.sign(fx - tx) || 1);
|
|
2069
|
+
const backY = (1 - f) * dy * (Math.sign(fy - ty) || 1);
|
|
2070
|
+
switch (smooth.type) {
|
|
2071
|
+
case "discrete":
|
|
2072
|
+
return visDiscreteVia(from, [fx + sx, fy + sy], dx, dy, f);
|
|
2073
|
+
case "diagonalCross":
|
|
2074
|
+
return [fx + sx, fy + sy];
|
|
2075
|
+
case "straightCross":
|
|
2076
|
+
return dx <= dy ? [tx, ty + backY] : [tx + backX, ty];
|
|
2077
|
+
case "horizontal":
|
|
2078
|
+
return [tx + backX, fy];
|
|
2079
|
+
case "vertical":
|
|
2080
|
+
return [fx, ty + backY];
|
|
2081
|
+
case "curvedCW":
|
|
2082
|
+
return visCurvedVia(from, to, f, f * 0.5 + 0.5);
|
|
2083
|
+
case "curvedCCW":
|
|
2084
|
+
return visCurvedVia(from, to, f, -f * 0.5 + 0.5);
|
|
2085
|
+
default:
|
|
2086
|
+
return dx <= dy ? [fx + Math.sign(sx) * Math.min(step, dx), fy + sy] : [fx + sx, fy + Math.sign(sy) * Math.min(step, dy)];
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
function visDiscreteVia(from, diagonal, dx, dy, f) {
|
|
2090
|
+
if (dx <= dy) {
|
|
2091
|
+
return [dx < f * dy ? from[0] : diagonal[0], diagonal[1]];
|
|
2092
|
+
}
|
|
2093
|
+
return [diagonal[0], dy < f * dx ? from[1] : diagonal[1]];
|
|
2094
|
+
}
|
|
2095
|
+
function visCurvedVia(from, to, f, turn) {
|
|
2096
|
+
const ex = to[0] - from[0];
|
|
2097
|
+
const ey = from[1] - to[1];
|
|
2098
|
+
const r = (f * 0.5 + 0.5) * Math.hypot(ex, ey);
|
|
2099
|
+
const angle = (Math.atan2(ey, ex) + turn * Math.PI) % (2 * Math.PI);
|
|
2100
|
+
return [from[0] + r * Math.sin(angle), from[1] + r * Math.cos(angle)];
|
|
2101
|
+
}
|
|
2102
|
+
function visCubicVia(from, to, smooth) {
|
|
2103
|
+
const [dx, dy] = [from[0] - to[0], from[1] - to[1]];
|
|
2104
|
+
const r = smooth.roundness;
|
|
2105
|
+
const force = smooth.forceDirection;
|
|
2106
|
+
const across = (Math.abs(dx) > Math.abs(dy) || force === true || force === "horizontal") && force !== "vertical";
|
|
2107
|
+
return across ? [
|
|
2108
|
+
[from[0] - r * dx, from[1]],
|
|
2109
|
+
[to[0] + r * dx, to[1]]
|
|
2110
|
+
] : [
|
|
2111
|
+
[from[0], from[1] - r * dy],
|
|
2112
|
+
[to[0], to[1] + r * dy]
|
|
2113
|
+
];
|
|
2114
|
+
}
|
|
2115
|
+
function alongAcross(a, b, p) {
|
|
2116
|
+
const [dx, dy] = [b[0] - a[0], b[1] - a[1]];
|
|
2117
|
+
const [qx, qy] = [p[0] - a[0], p[1] - a[1]];
|
|
2118
|
+
const l2 = dx * dx + dy * dy;
|
|
2119
|
+
return `${fraction((qx * dx + qy * dy) / l2)},${fraction((dy * qx - dx * qy) / l2)}`;
|
|
2120
|
+
}
|
|
2121
|
+
const fraction = (v) => String(Math.round(v * 1e4) / 1e4 || 0);
|
|
2122
|
+
function visRoute(defaults, own, s, t, g) {
|
|
2123
|
+
if (s === t) {
|
|
2124
|
+
return visLoop(defaults, own, g.box(s));
|
|
2125
|
+
}
|
|
2126
|
+
const smooth = visSmooth(defaults.smooth, own.smooth);
|
|
2127
|
+
if (smooth.enabled && smooth.type === "dynamic") {
|
|
2128
|
+
return visDynamic(defaults, own, g.support ?? null);
|
|
2129
|
+
}
|
|
2130
|
+
const [a, b] = [g.at(s), g.at(t)];
|
|
2131
|
+
if (!smooth.enabled || a === null || b === null || a[0] === b[0] && a[1] === b[1]) {
|
|
2132
|
+
return {};
|
|
2133
|
+
}
|
|
2134
|
+
const controls = smooth.type === "cubicBezier" ? visCubicVia(a, b, smooth) : [visStaticVia(a, b, smooth)];
|
|
2135
|
+
return { curved: true, bendCurve: "bezier", bends: controls.map((p) => alongAcross(a, b, p)).join(" ") };
|
|
2136
|
+
}
|
|
2137
|
+
function visDynamic(defaults, own, support) {
|
|
2138
|
+
if (support === null || own.physics === false || own.physics === void 0 && defaults.physics === false) {
|
|
2139
|
+
return {};
|
|
2140
|
+
}
|
|
2141
|
+
const length = [own.length, defaults.length].find((v) => typeof v === "number" && Number.isFinite(v) && v >= 0);
|
|
2142
|
+
return { curved: true, ...support, ...length === void 0 ? {} : { supportSpringLength: length } };
|
|
2143
|
+
}
|
|
2144
|
+
const VIS_SOLVERS = {
|
|
2145
|
+
barnesHut: { model: "barnesHut", g: -2e3, cg: 0.3, length: 95, k: 0.04 },
|
|
2146
|
+
forceAtlas2Based: { model: "forceAtlas2", g: -50, cg: 0.01, length: 100, k: 0.08 }
|
|
1281
2147
|
};
|
|
1282
|
-
function
|
|
1283
|
-
|
|
2148
|
+
function visSupport(physics, layout) {
|
|
2149
|
+
const hierarchical = isJsonObject(layout) ? layout.hierarchical : void 0;
|
|
2150
|
+
if (hierarchical === true || isJsonObject(hierarchical) && hierarchical.enabled !== false) {
|
|
2151
|
+
return null;
|
|
2152
|
+
}
|
|
2153
|
+
if (physics === false || isJsonObject(physics) && physics.enabled === false) {
|
|
2154
|
+
return null;
|
|
2155
|
+
}
|
|
2156
|
+
const o = isJsonObject(physics) ? physics : {};
|
|
2157
|
+
const solver = typeof o.solver === "string" ? o.solver : "barnesHut";
|
|
2158
|
+
const base = VIS_SOLVERS[solver];
|
|
2159
|
+
if (base === void 0) {
|
|
2160
|
+
return null;
|
|
2161
|
+
}
|
|
2162
|
+
const given = isJsonObject(o[solver]) ? o[solver] : {};
|
|
2163
|
+
const num = (v, fallback) => typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
|
2164
|
+
return {
|
|
2165
|
+
supportModel: base.model,
|
|
2166
|
+
supportSpringLength: Math.max(0, num(given.springLength, base.length)),
|
|
2167
|
+
supportSpringConstant: Math.max(0, num(given.springConstant, base.k)),
|
|
2168
|
+
supportRepulsion: Math.max(0, -num(given.gravitationalConstant, base.g)),
|
|
2169
|
+
supportCentralGravity: Math.max(0, num(given.centralGravity, base.cg))
|
|
2170
|
+
};
|
|
1284
2171
|
}
|
|
2172
|
+
function visLoop(defaults, own, box) {
|
|
2173
|
+
if (box === null) {
|
|
2174
|
+
return {};
|
|
2175
|
+
}
|
|
2176
|
+
const field = (layer, key) => isJsonObject(layer.selfReference) ? layer.selfReference[key] : void 0;
|
|
2177
|
+
const pick = (...vs) => vs.find((v) => typeof v === "number" && Number.isFinite(v)) ?? null;
|
|
2178
|
+
const radius = pick(field(own, "size"), own.selfReferenceSize, field(defaults, "size"), defaults.selfReferenceSize) ?? 20;
|
|
2179
|
+
const angle = pick(field(own, "angle"), field(defaults, "angle")) ?? Math.PI / 4;
|
|
2180
|
+
const [hw, hh] = box;
|
|
2181
|
+
const reach = visToBorder(box, angle);
|
|
2182
|
+
const [cx, cy] = [Math.cos(angle) * reach, Math.sin(angle) * reach];
|
|
2183
|
+
const behind = [field(own, "renderBehindTheNode"), field(defaults, "renderBehindTheNode")].find(
|
|
2184
|
+
(v) => typeof v === "boolean"
|
|
2185
|
+
);
|
|
2186
|
+
if (behind === false) {
|
|
2187
|
+
return visFrontArc(cx, cy, radius, angle, box);
|
|
2188
|
+
}
|
|
2189
|
+
const round = box[3] === "dot" || box[3] === "circle" || box[3] === "circularImage";
|
|
2190
|
+
if (reach + (round ? hw : Math.hypot(hw, hh)) < radius) {
|
|
2191
|
+
return visRing(cx, cy, radius, angle, box);
|
|
2192
|
+
}
|
|
2193
|
+
const corners = [];
|
|
2194
|
+
for (let k = 0; k <= 4; k++) {
|
|
2195
|
+
const a = angle + Math.PI + k % 4 * Math.PI / 2;
|
|
2196
|
+
const [x, y] = [cx + Math.SQRT2 * radius * Math.cos(a), cy + Math.SQRT2 * radius * Math.sin(a)];
|
|
2197
|
+
corners.push(`${fraction(x / hw)},${fraction(y / hh)}`);
|
|
2198
|
+
}
|
|
2199
|
+
return { curved: true, bendCurve: "midpoints", bends: corners.join(" ") };
|
|
2200
|
+
}
|
|
2201
|
+
const VIS_RING_STEPS = 96;
|
|
2202
|
+
function visRing(cx, cy, radius, angle, box) {
|
|
2203
|
+
const [hw, hh] = box;
|
|
2204
|
+
const points = [];
|
|
2205
|
+
for (let k = 0; k <= VIS_RING_STEPS; k++) {
|
|
2206
|
+
const a = angle + Math.PI + 2 * Math.PI * (k % VIS_RING_STEPS) / VIS_RING_STEPS;
|
|
2207
|
+
points.push(`${fraction((cx + radius * Math.cos(a)) / hw)},${fraction((cy + radius * Math.sin(a)) / hh)}`);
|
|
2208
|
+
}
|
|
2209
|
+
return { curved: false, bends: points.join(" ") };
|
|
2210
|
+
}
|
|
2211
|
+
function visFrontArc(cx, cy, radius, angle, box) {
|
|
2212
|
+
const [x, y] = [cx, -cy];
|
|
2213
|
+
const search = (direction) => {
|
|
2214
|
+
let [low, high] = [angle, angle + Math.PI];
|
|
2215
|
+
let pos = [x, y];
|
|
2216
|
+
for (let iteration = 0; low <= high && iteration < 10; iteration++) {
|
|
2217
|
+
const middle = (low + high) * 0.5;
|
|
2218
|
+
const turn = middle * 2 * Math.PI;
|
|
2219
|
+
pos = [x + radius * Math.cos(turn), y - radius * Math.sin(turn)];
|
|
2220
|
+
const difference = visToBorder(box, Math.atan2(-pos[1], -pos[0])) - Math.hypot(pos[0], pos[1]);
|
|
2221
|
+
if (Math.abs(difference) < 0.05) {
|
|
2222
|
+
break;
|
|
2223
|
+
}
|
|
2224
|
+
if (difference > 0 === direction > 0) {
|
|
2225
|
+
low = middle;
|
|
2226
|
+
} else {
|
|
2227
|
+
high = middle;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
return pos;
|
|
2231
|
+
};
|
|
2232
|
+
const [from, to] = [search(-1), search(1)];
|
|
2233
|
+
const start = Math.atan2(from[1] - y, from[0] - x);
|
|
2234
|
+
let end = Math.atan2(to[1] - y, to[0] - x);
|
|
2235
|
+
if (end < start) {
|
|
2236
|
+
end += 2 * Math.PI;
|
|
2237
|
+
}
|
|
2238
|
+
const [hw, hh] = box;
|
|
2239
|
+
const steps = Math.max(2, Math.ceil((end - start) / (2 * Math.PI) * VIS_RING_STEPS));
|
|
2240
|
+
const points = [];
|
|
2241
|
+
for (let k = 0; k <= steps; k++) {
|
|
2242
|
+
const a = start + (end - start) * k / steps;
|
|
2243
|
+
points.push(`${fraction((x + radius * Math.cos(a)) / hw)},${fraction(-(y + radius * Math.sin(a)) / hh)}`);
|
|
2244
|
+
}
|
|
2245
|
+
return {
|
|
2246
|
+
curved: false,
|
|
2247
|
+
sourcePort: points[0],
|
|
2248
|
+
bends: points.slice(1, -1).join(" "),
|
|
2249
|
+
targetPort: points.at(-1) ?? points[0]
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
function visToBorder(box, angle) {
|
|
2253
|
+
const [hw, hh, bw, shape] = box;
|
|
2254
|
+
if (shape === "dot" || shape === "circle" || shape === "circularImage") {
|
|
2255
|
+
return hw;
|
|
2256
|
+
}
|
|
2257
|
+
if (shape === "ellipse") {
|
|
2258
|
+
return hw * hh / Math.hypot(Math.sin(angle) * hw, Math.cos(angle) * hh);
|
|
2259
|
+
}
|
|
2260
|
+
return Math.min(Math.abs(hw / Math.cos(angle)), Math.abs(hh / Math.sin(angle))) + bw;
|
|
2261
|
+
}
|
|
2262
|
+
const VIS_KEYS = {
|
|
2263
|
+
node: [
|
|
2264
|
+
"color",
|
|
2265
|
+
"shape",
|
|
2266
|
+
"size",
|
|
2267
|
+
"value",
|
|
2268
|
+
"scaling",
|
|
2269
|
+
"borderWidth",
|
|
2270
|
+
"opacity",
|
|
2271
|
+
"hidden",
|
|
2272
|
+
"label",
|
|
2273
|
+
"title",
|
|
2274
|
+
"font",
|
|
2275
|
+
"margin",
|
|
2276
|
+
"widthConstraint",
|
|
2277
|
+
"heightConstraint",
|
|
2278
|
+
"image",
|
|
2279
|
+
"brokenImage",
|
|
2280
|
+
"imagePadding",
|
|
2281
|
+
"icon",
|
|
2282
|
+
"shapeProperties"
|
|
2283
|
+
],
|
|
2284
|
+
edge: [
|
|
2285
|
+
"color",
|
|
2286
|
+
"width",
|
|
2287
|
+
"value",
|
|
2288
|
+
"scaling",
|
|
2289
|
+
"dashes",
|
|
2290
|
+
"arrows",
|
|
2291
|
+
"hidden",
|
|
2292
|
+
"label",
|
|
2293
|
+
"title",
|
|
2294
|
+
"font",
|
|
2295
|
+
"background",
|
|
2296
|
+
"smooth",
|
|
2297
|
+
"selfReference",
|
|
2298
|
+
"selfReferenceSize",
|
|
2299
|
+
"physics",
|
|
2300
|
+
"length",
|
|
2301
|
+
"widthConstraint"
|
|
2302
|
+
]
|
|
2303
|
+
};
|
|
1285
2304
|
function elementRecords(snapshot, target) {
|
|
2305
|
+
const raw = elementRaw(snapshot, target);
|
|
2306
|
+
return (i) => visLayer(raw(i), target);
|
|
2307
|
+
}
|
|
2308
|
+
function elementRaw(snapshot, target) {
|
|
1286
2309
|
const readers = VIS_KEYS[target].map((name) => [name, cells(snapshot, target, name)]).filter((x) => x[1] !== null);
|
|
1287
2310
|
return (i) => {
|
|
1288
2311
|
const record = {};
|
|
@@ -1292,7 +2315,7 @@ function elementRecords(snapshot, target) {
|
|
|
1292
2315
|
record[name] = v;
|
|
1293
2316
|
}
|
|
1294
2317
|
}
|
|
1295
|
-
return
|
|
2318
|
+
return record;
|
|
1296
2319
|
};
|
|
1297
2320
|
}
|
|
1298
2321
|
function rule(id, target, role, origin, where, set) {
|
|
@@ -1355,10 +2378,59 @@ const visSize = (want) => {
|
|
|
1355
2378
|
const shape = typeof s === "string" ? visShape(s)[0] : "ellipse";
|
|
1356
2379
|
return VIS_SIZED.has(shape) ? oneSize(want) : null;
|
|
1357
2380
|
};
|
|
2381
|
+
const visShapeBack = (want) => {
|
|
2382
|
+
const s = want("shape");
|
|
2383
|
+
return typeof s === "string" ? visShape(s)[0] : "ellipse";
|
|
2384
|
+
};
|
|
2385
|
+
const visShapeFactBack = (property) => (want) => {
|
|
2386
|
+
const shape = visShapeBack(want);
|
|
2387
|
+
const size = visSize(want);
|
|
2388
|
+
if (shape === "hexagon" && typeof size === "number") {
|
|
2389
|
+
return property === "height" ? Math.sqrt(3) * size / 2 : (2 - Math.sqrt(3)) * size / 4;
|
|
2390
|
+
}
|
|
2391
|
+
return property === "labelOffsetY" && shape === "database" ? VIS_MARGIN : null;
|
|
2392
|
+
};
|
|
2393
|
+
const visFitBack = (property) => (want) => {
|
|
2394
|
+
const s = want("shape");
|
|
2395
|
+
const shape = typeof s === "string" ? visShape(s)[0] : "ellipse";
|
|
2396
|
+
return visLabelFit({ fontSize: want("labelSize"), label: want("label") }, shape)[property] ?? null;
|
|
2397
|
+
};
|
|
2398
|
+
function visWritten(snapshot, edgeValues) {
|
|
2399
|
+
const isLoop = (i) => snapshot.edgeSource(i) === snapshot.edgeTarget(i);
|
|
2400
|
+
const loop = (property) => (want, i) => isLoop(i) ? edgeValues[property]?.[i] ?? null : want(property);
|
|
2401
|
+
const dynamic = visSupport(void 0, void 0) ?? {};
|
|
2402
|
+
const support = (property) => (_want, i) => isLoop(i) ? edgeValues[property]?.[i] ?? null : dynamic[property] ?? null;
|
|
2403
|
+
const supports = Object.fromEntries(Object.keys(dynamic).map((property) => [property, support(property)]));
|
|
2404
|
+
const lengths = cells(snapshot, "edge", "length");
|
|
2405
|
+
supports.supportSpringLength = (want, i) => {
|
|
2406
|
+
const own = lengths?.(i);
|
|
2407
|
+
return typeof own === "number" && Number.isFinite(own) && own >= 0 && !isLoop(i) ? own : support("supportSpringLength")(want, i);
|
|
2408
|
+
};
|
|
2409
|
+
return {
|
|
2410
|
+
node: VIS_WRITTEN.node,
|
|
2411
|
+
edge: {
|
|
2412
|
+
...VIS_WRITTEN.edge,
|
|
2413
|
+
...supports,
|
|
2414
|
+
bends: loop("bends"),
|
|
2415
|
+
bendCurve: loop("bendCurve"),
|
|
2416
|
+
curved: (_want, i) => isLoop(i) ? edgeValues.curved?.[i] ?? null : true
|
|
2417
|
+
}
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
1358
2420
|
const VIS_WRITTEN = {
|
|
1359
2421
|
node: {
|
|
1360
|
-
width: visSize,
|
|
1361
|
-
height: visSize,
|
|
2422
|
+
width: (want) => visSize(want) ?? visFitBack("width")(want),
|
|
2423
|
+
height: (want) => visShapeFactBack("height")(want) ?? visSize(want) ?? visFitBack("height")(want),
|
|
2424
|
+
labelOffsetY: visShapeFactBack("labelOffsetY"),
|
|
2425
|
+
labelFit: visFitBack("labelFit"),
|
|
2426
|
+
labelPaddingX: visFitBack("labelPaddingX"),
|
|
2427
|
+
labelPaddingY: visFitBack("labelPaddingY"),
|
|
2428
|
+
labelFitSquare: visFitBack("labelFitSquare"),
|
|
2429
|
+
// the writer writes hex colors, whose alpha vis-network's node opacity replaces, the border's too
|
|
2430
|
+
borderOpacity: (want) => {
|
|
2431
|
+
const opacity = want("opacity");
|
|
2432
|
+
return typeof opacity === "number" ? opacity : want("borderOpacity");
|
|
2433
|
+
},
|
|
1362
2434
|
shape: (want) => {
|
|
1363
2435
|
const s = want("shape");
|
|
1364
2436
|
if (typeof s !== "string") {
|
|
@@ -1366,6 +2438,17 @@ const VIS_WRITTEN = {
|
|
|
1366
2438
|
}
|
|
1367
2439
|
const site = { notes: new StyleNotes(), target: "node", property: "shape" };
|
|
1368
2440
|
return canonEnum("shape", visShape(s)[0], "vis", site);
|
|
2441
|
+
},
|
|
2442
|
+
labelPosition: (want) => {
|
|
2443
|
+
const s = want("shape");
|
|
2444
|
+
if (typeof s !== "string") {
|
|
2445
|
+
return null;
|
|
2446
|
+
}
|
|
2447
|
+
const shape = visShape(s)[0];
|
|
2448
|
+
if (shape === "database") {
|
|
2449
|
+
return "inside-top";
|
|
2450
|
+
}
|
|
2451
|
+
return VIS_SIZED.has(shape) ? "bottom" : "center";
|
|
1369
2452
|
}
|
|
1370
2453
|
},
|
|
1371
2454
|
edge: {
|
|
@@ -1374,7 +2457,11 @@ const VIS_WRITTEN = {
|
|
|
1374
2457
|
if (s === null) {
|
|
1375
2458
|
return null;
|
|
1376
2459
|
}
|
|
1377
|
-
|
|
2460
|
+
if (s === "solid") {
|
|
2461
|
+
return "solid";
|
|
2462
|
+
}
|
|
2463
|
+
const width = want("width");
|
|
2464
|
+
return visDashStyle([5, 5], typeof width === "number" ? width : 1, true);
|
|
1378
2465
|
},
|
|
1379
2466
|
targetArrow: (want) => arrowBack(want("targetArrow")),
|
|
1380
2467
|
sourceArrow: (want) => arrowBack(want("sourceArrow"))
|
|
@@ -1406,8 +2493,8 @@ const NATIVE = {
|
|
|
1406
2493
|
edge: cyjsProperties(CYJS_EDGE_PROPERTIES, ["curved", "labelItalic", "visible"])
|
|
1407
2494
|
},
|
|
1408
2495
|
graphology: {
|
|
1409
|
-
node: ["fill", "fillOpacity", "width", "height", "label"
|
|
1410
|
-
edge: ["color", "opacity", "width", "label"
|
|
2496
|
+
node: ["fill", "fillOpacity", "width", "height", "label"],
|
|
2497
|
+
edge: ["color", "opacity", "width", "label"]
|
|
1411
2498
|
},
|
|
1412
2499
|
vis: {
|
|
1413
2500
|
node: [
|
|
@@ -1797,18 +2884,27 @@ function writeGraphology$1(out, input, approximated, replaced) {
|
|
|
1797
2884
|
writeKey(
|
|
1798
2885
|
table,
|
|
1799
2886
|
"size",
|
|
1800
|
-
target === "node" ? nodeSizes(p("node", "width"), p("node", "height"), approximated)
|
|
2887
|
+
target === "node" ? nodeSizes(p("node", "width"), p("node", "height"), approximated).map(
|
|
2888
|
+
(d) => d === null ? null : d / 2
|
|
2889
|
+
) : (
|
|
2890
|
+
// sigma draws an edge half as wide as its size (readSigmaRow)
|
|
2891
|
+
p("edge", "width").map((w) => typeof w === "number" ? w * 2 : w)
|
|
2892
|
+
),
|
|
1801
2893
|
replaced
|
|
1802
2894
|
);
|
|
1803
2895
|
writeKey(table, "label", p(target, "label"), replaced);
|
|
1804
|
-
writeKey(
|
|
1805
|
-
table,
|
|
1806
|
-
"hidden",
|
|
1807
|
-
p(target, "visible").map((v) => v === false ? true : null),
|
|
1808
|
-
replaced
|
|
1809
|
-
);
|
|
1810
2896
|
}
|
|
1811
2897
|
}
|
|
2898
|
+
function keepScaled(table, sizes, replaced) {
|
|
2899
|
+
const value = table.get("value");
|
|
2900
|
+
if (value === null) {
|
|
2901
|
+
return;
|
|
2902
|
+
}
|
|
2903
|
+
const scaling = sizes.map(
|
|
2904
|
+
(v, i) => typeof v !== "number" || typeof plainCell(value.value(i)) !== "number" ? null : { min: v, max: v }
|
|
2905
|
+
);
|
|
2906
|
+
writeKey(table, "scaling", scaling, replaced);
|
|
2907
|
+
}
|
|
1812
2908
|
function writeVis$1(out, input, approximated, replaced) {
|
|
1813
2909
|
const p = (target, property) => input.picture(target, property);
|
|
1814
2910
|
const font = (target) => {
|
|
@@ -1861,7 +2957,8 @@ function writeVis$1(out, input, approximated, replaced) {
|
|
|
1861
2957
|
);
|
|
1862
2958
|
const sizes = nodeSizes(p("node", "width"), p("node", "height"), approximated);
|
|
1863
2959
|
const shapes = p("node", "shape").map((s, i) => {
|
|
1864
|
-
const [
|
|
2960
|
+
const [written, exact] = typeof s === "string" ? visShape(s) : [null, true];
|
|
2961
|
+
const shape = written === "dot" && s === "ellipse" && sizes[i] === null ? "ellipse" : written;
|
|
1865
2962
|
if (!exact) {
|
|
1866
2963
|
approximated.add("node", "shape", s);
|
|
1867
2964
|
}
|
|
@@ -1871,7 +2968,9 @@ function writeVis$1(out, input, approximated, replaced) {
|
|
|
1871
2968
|
return shape;
|
|
1872
2969
|
});
|
|
1873
2970
|
writeKey(out.nodes, "shape", shapes, replaced);
|
|
1874
|
-
|
|
2971
|
+
const radii = sizes.map((d) => d === null ? null : d / 2);
|
|
2972
|
+
writeKey(out.nodes, "size", radii, replaced);
|
|
2973
|
+
keepScaled(out.nodes, radii, replaced);
|
|
1875
2974
|
writeKey(out.nodes, "borderWidth", p("node", "borderWidth"), replaced);
|
|
1876
2975
|
writeKey(out.nodes, "opacity", p("node", "opacity"), replaced);
|
|
1877
2976
|
label(out.nodes, "node");
|
|
@@ -1892,7 +2991,9 @@ function writeVis$1(out, input, approximated, replaced) {
|
|
|
1892
2991
|
}),
|
|
1893
2992
|
replaced
|
|
1894
2993
|
);
|
|
1895
|
-
|
|
2994
|
+
const widths = p("edge", "width");
|
|
2995
|
+
writeKey(out.edges, "width", widths, replaced);
|
|
2996
|
+
keepScaled(out.edges, widths, replaced);
|
|
1896
2997
|
writeKey(
|
|
1897
2998
|
out.edges,
|
|
1898
2999
|
"dashes",
|
|
@@ -2100,6 +3201,8 @@ const GRAPHOLOGY_NODE_KEYS = /* @__PURE__ */ new Set(["key", "attributes"]);
|
|
|
2100
3201
|
const GRAPHOLOGY_EDGE_KEYS = /* @__PURE__ */ new Set(["key", "source", "target", "attributes", "undirected"]);
|
|
2101
3202
|
const GEPHI_NODE_KEYS = /* @__PURE__ */ new Set(["id", "attributes"]);
|
|
2102
3203
|
const GEPHI_EDGE_KEYS = /* @__PURE__ */ new Set([...GRAPHOLOGY_EDGE_KEYS, "id"]);
|
|
3204
|
+
const GEPHI_NODE_DISPLAY_KEYS = /* @__PURE__ */ new Set(["label", "x", "y", "size", "color"]);
|
|
3205
|
+
const GEPHI_EDGE_DISPLAY_KEYS = /* @__PURE__ */ new Set(["label", "size", "color"]);
|
|
2103
3206
|
const VIS_SOURCE_KEYS = Object.freeze(["from"]);
|
|
2104
3207
|
const VIS_TARGET_KEYS = Object.freeze(["to"]);
|
|
2105
3208
|
const PATH_DIALECTS = /* @__PURE__ */ new Set([
|
|
@@ -2147,9 +3250,26 @@ function resolveJsonOptions(options) {
|
|
|
2147
3250
|
oboIds,
|
|
2148
3251
|
typedefs,
|
|
2149
3252
|
nodesPath,
|
|
2150
|
-
edgesPath
|
|
3253
|
+
edgesPath,
|
|
3254
|
+
sigma: sigmaSettingsOption(o.sigmaSettings)
|
|
2151
3255
|
};
|
|
2152
3256
|
}
|
|
3257
|
+
function sigmaSettingsOption(value) {
|
|
3258
|
+
if (value === void 0) {
|
|
3259
|
+
return SIGMA_DEFAULT_SETTINGS;
|
|
3260
|
+
}
|
|
3261
|
+
if (!isJsonObject(value)) {
|
|
3262
|
+
throw unsupportedOption("sigmaSettings", value, ["an object of sigma.js settings"]);
|
|
3263
|
+
}
|
|
3264
|
+
const { renderEdgeLabels = false, edgeLabelAnchors = "nodeLabels" } = value;
|
|
3265
|
+
if (typeof renderEdgeLabels !== "boolean") {
|
|
3266
|
+
throw unsupportedOption("sigmaSettings.renderEdgeLabels", renderEdgeLabels, ["true", "false"]);
|
|
3267
|
+
}
|
|
3268
|
+
if (edgeLabelAnchors !== "nodeLabels" && edgeLabelAnchors !== "allNodes") {
|
|
3269
|
+
throw unsupportedOption("sigmaSettings.edgeLabelAnchors", edgeLabelAnchors, ["nodeLabels", "allNodes"]);
|
|
3270
|
+
}
|
|
3271
|
+
return { renderEdgeLabels, edgeLabelAnchors };
|
|
3272
|
+
}
|
|
2153
3273
|
function pathOption(name, value) {
|
|
2154
3274
|
if (value === void 0) {
|
|
2155
3275
|
return null;
|
|
@@ -2778,15 +3898,17 @@ class ImportContext {
|
|
|
2778
3898
|
* @param structural - the element keys that are not attributes
|
|
2779
3899
|
* @param element - the element name for issues
|
|
2780
3900
|
* @param how - `weightFrom`: the weight key to skip in the dict; `plain`: write the element-level keys under their
|
|
2781
|
-
* own names, not with the `#element` suffix
|
|
3901
|
+
* own names, not with the `#element` suffix; `dataKeys`: the dict keys written with the `#data` suffix
|
|
2782
3902
|
* @param how.weightFrom - the weight key to skip in the dict, or null (the default)
|
|
2783
3903
|
* @param how.plain - write the element-level keys under their own names (default false)
|
|
3904
|
+
* @param how.dataKeys - the dict keys that name an element-level key, written as `<key>#data` (default none)
|
|
2784
3905
|
*/
|
|
2785
3906
|
writeNested(writer, row, record, dict, structural, element, how = {}) {
|
|
2786
|
-
const { weightFrom = null, plain = false } = how;
|
|
3907
|
+
const { weightFrom = null, plain = false, dataKeys } = how;
|
|
2787
3908
|
for (const key of Object.keys(dict)) {
|
|
2788
3909
|
if (key !== weightFrom) {
|
|
2789
|
-
|
|
3910
|
+
const name = dataKeys?.has(key) === true ? `${key}${SUFFIX.data}` : key;
|
|
3911
|
+
writer.write(row, name, dict[key], SUFFIX.data, element);
|
|
2790
3912
|
}
|
|
2791
3913
|
}
|
|
2792
3914
|
for (const key of Object.keys(record)) {
|
|
@@ -3776,7 +4898,7 @@ function importGraphology(ctx, root) {
|
|
|
3776
4898
|
ctx.writeGraphDict(root.attributes, "attributes");
|
|
3777
4899
|
const firstNode = nodes.find((n) => isJsonObject(n));
|
|
3778
4900
|
const gephi = isJsonObject(firstNode) && !hasKey(firstNode, "key") && hasKey(firstNode, "id");
|
|
3779
|
-
ctx.styleSource = { dialect: "graphology", block: blockOf(root), gephi };
|
|
4901
|
+
ctx.styleSource = { dialect: "graphology", block: blockOf(root), gephi, sigma: ctx.json.sigma };
|
|
3780
4902
|
ctx.reportNodeIdFrom("graphology", "the node key");
|
|
3781
4903
|
ctx.sink.reserve(nodes.length, edges.length);
|
|
3782
4904
|
importGraphologyNodes(ctx, nodes, gephi);
|
|
@@ -3888,7 +5010,8 @@ function pushGraphologyEdge(ctx, record, element, ids, declared, violations) {
|
|
|
3888
5010
|
ctx.setEdgeId(ids, edge, idValue);
|
|
3889
5011
|
ctx.writeNested(ctx.edges, edge, record, attributes, gephi ? GEPHI_EDGE_KEYS : GRAPHOLOGY_EDGE_KEYS, element, {
|
|
3890
5012
|
weightFrom: ctx.options.weightFrom,
|
|
3891
|
-
plain: gephi
|
|
5013
|
+
plain: gephi,
|
|
5014
|
+
dataKeys: gephi ? GEPHI_EDGE_DISPLAY_KEYS : void 0
|
|
3892
5015
|
});
|
|
3893
5016
|
if (declared.allowSelfLoops === false && u === v) {
|
|
3894
5017
|
violations.selfLoops++;
|
|
@@ -3933,7 +5056,10 @@ function pushNestedNode(ctx, id, record, dictKey, structural, element, plain = f
|
|
|
3933
5056
|
{ element }
|
|
3934
5057
|
);
|
|
3935
5058
|
}
|
|
3936
|
-
ctx.writeNested(ctx.nodes, index, record, isJsonObject(dict) ? dict : {}, structural, element, {
|
|
5059
|
+
ctx.writeNested(ctx.nodes, index, record, isJsonObject(dict) ? dict : {}, structural, element, {
|
|
5060
|
+
plain,
|
|
5061
|
+
dataKeys: plain ? GEPHI_NODE_DISPLAY_KEYS : void 0
|
|
5062
|
+
});
|
|
3937
5063
|
} catch (err) {
|
|
3938
5064
|
ctx.report.recordError(err, { element: String(id) });
|
|
3939
5065
|
}
|
|
@@ -3951,7 +5077,7 @@ function importJgf(ctx, root) {
|
|
|
3951
5077
|
`graph.nodes must be an object keyed by id or an array, found ${describe(nodesRaw)}`
|
|
3952
5078
|
);
|
|
3953
5079
|
}
|
|
3954
|
-
const
|
|
5080
|
+
const nodeRecords = Array.isArray(nodesRaw) ? nodesRaw : Object.values(nodesRaw ?? {});
|
|
3955
5081
|
const directed = jgfDirected(ctx, graph, edges);
|
|
3956
5082
|
ctx.setHeader(directed);
|
|
3957
5083
|
ctx.writeGraphDict(graph.metadata, "graph.metadata");
|
|
@@ -3962,18 +5088,18 @@ function importJgf(ctx, root) {
|
|
|
3962
5088
|
};
|
|
3963
5089
|
const label = typeof graph.label === "string" ? graph.label : null;
|
|
3964
5090
|
ctx.reportNodeIdFrom("jgf", "the node keys");
|
|
3965
|
-
ctx.sink.reserve(
|
|
5091
|
+
ctx.sink.reserve(nodeRecords.length, edges.length);
|
|
3966
5092
|
const labelColumn = ctx.nodes.declareIf(
|
|
3967
5093
|
{ name: "label", dtype: "string", role: "label", nullable: true },
|
|
3968
|
-
anyHas(
|
|
5094
|
+
anyHas(nodeRecords, "label")
|
|
3969
5095
|
);
|
|
3970
5096
|
if (isJsonObject(nodesRaw)) {
|
|
3971
5097
|
for (const key of jgfNodeKeys(ctx, root, graph, nodesRaw)) {
|
|
3972
5098
|
pushJgfKeyedNode(ctx, key, nodesRaw[key], labelColumn);
|
|
3973
5099
|
}
|
|
3974
5100
|
} else {
|
|
3975
|
-
for (let i = 0; i <
|
|
3976
|
-
pushJgfListedNode(ctx,
|
|
5101
|
+
for (let i = 0; i < nodeRecords.length; i++) {
|
|
5102
|
+
pushJgfListedNode(ctx, nodeRecords[i], labelColumn, `nodes[${i}]`);
|
|
3977
5103
|
}
|
|
3978
5104
|
}
|
|
3979
5105
|
throwIfAborted(ctx.options.signal);
|
|
@@ -4700,6 +5826,7 @@ const jsonImporter = Object.freeze({
|
|
|
4700
5826
|
"nodeIdKey",
|
|
4701
5827
|
"nodesPath",
|
|
4702
5828
|
"oboIds",
|
|
5829
|
+
"sigmaSettings",
|
|
4703
5830
|
"sourceKey",
|
|
4704
5831
|
"targetKey",
|
|
4705
5832
|
"typedefs"
|
|
@@ -7560,10 +8687,11 @@ export {
|
|
|
7560
8687
|
jsonShapeOf as f,
|
|
7561
8688
|
extensionOf as g,
|
|
7562
8689
|
headBytes as h,
|
|
7563
|
-
|
|
8690
|
+
sniffFormat as i,
|
|
7564
8691
|
jsonCapabilities as j,
|
|
8692
|
+
sniffJsonDialectHead as k,
|
|
7565
8693
|
normalizeMimeType as n,
|
|
7566
8694
|
rankFormats as r,
|
|
7567
|
-
|
|
8695
|
+
sniffJsonDialect as s
|
|
7568
8696
|
};
|
|
7569
|
-
//# sourceMappingURL=exporter-
|
|
8697
|
+
//# sourceMappingURL=exporter-CQQZFJ2v.js.map
|