@graphty/graph-io 0.3.47 → 0.3.49
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-wWjCRzKj.js → approximations-Bzn3L-je.js} +2 -2
- package/dist/chunks/{approximations-wWjCRzKj.js.map → approximations-Bzn3L-je.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-DiGq58c3.js → block-iptrlMBb.js} +947 -134
- package/dist/chunks/block-iptrlMBb.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-BE2xir2k.js +157 -0
- package/dist/chunks/codes-BE2xir2k.js.map +1 -0
- package/dist/chunks/{constants-BKwqelYD.js → constants-CKkYLPtt.js} +2 -2
- package/dist/chunks/{constants-BKwqelYD.js.map → constants-CKkYLPtt.js.map} +1 -1
- package/dist/chunks/context-C3p0RQxR.js +664 -0
- package/dist/chunks/context-C3p0RQxR.js.map +1 -0
- 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-DXHx7nwR.js +349 -0
- package/dist/chunks/credentials-DXHx7nwR.js.map +1 -0
- package/dist/chunks/cx-export-Bt6NoqTQ.js +259 -0
- package/dist/chunks/cx-export-Bt6NoqTQ.js.map +1 -0
- package/dist/chunks/descriptor-B28U25x4.js +60 -0
- package/dist/chunks/descriptor-B28U25x4.js.map +1 -0
- package/dist/chunks/descriptor-C-YDhtsn.js +48 -0
- package/dist/chunks/descriptor-C-YDhtsn.js.map +1 -0
- package/dist/chunks/descriptor-DLA5kINx.js +142 -0
- package/dist/chunks/descriptor-DLA5kINx.js.map +1 -0
- package/dist/chunks/{emit-CwU8cUmG.js → emit-BwHQkZle.js} +1690 -103
- package/dist/chunks/emit-BwHQkZle.js.map +1 -0
- package/dist/chunks/{escape-CgzxiYPg.js → escape-CuCIzNMB.js} +12 -12
- package/dist/chunks/{escape-CgzxiYPg.js.map → escape-CuCIzNMB.js.map} +1 -1
- package/dist/chunks/{export-BvqAXCKh.js → export-Cha4dRFz.js} +48 -1780
- package/dist/chunks/export-Cha4dRFz.js.map +1 -0
- package/dist/chunks/{exporter--Mk9gXCJ.js → exporter-BP6otMO6.js} +6 -4
- package/dist/chunks/{exporter--Mk9gXCJ.js.map → exporter-BP6otMO6.js.map} +1 -1
- package/dist/chunks/{exporter-CrDWIyiq.js → exporter-D2CETOMK.js} +1222 -154
- package/dist/chunks/exporter-D2CETOMK.js.map +1 -0
- package/dist/chunks/{exporter-DndFlGSa.js → exporter-D9yMtocA.js} +7 -6
- package/dist/chunks/{exporter-DndFlGSa.js.map → exporter-D9yMtocA.js.map} +1 -1
- package/dist/chunks/exporter-_jrBTnos.js +1009 -0
- package/dist/chunks/exporter-_jrBTnos.js.map +1 -0
- package/dist/chunks/{exporter-CJgfhF-l.js → exporter-nDfxIK5D.js} +9 -7
- package/dist/chunks/{exporter-CJgfhF-l.js.map → exporter-nDfxIK5D.js.map} +1 -1
- package/dist/chunks/format-BXiAb-1h.js +408 -0
- package/dist/chunks/format-BXiAb-1h.js.map +1 -0
- package/dist/chunks/{generic-Dq1ntt9q.js → generic-ymWCETAJ.js} +387 -31
- package/dist/chunks/generic-ymWCETAJ.js.map +1 -0
- package/dist/chunks/{importer-CMmeMWlC.js → importer-B92x1xY5.js} +15 -263
- package/dist/chunks/importer-B92x1xY5.js.map +1 -0
- package/dist/chunks/{importer-DiZRmOQG.js → importer-CT9mJ1nn.js} +328 -90
- package/dist/chunks/importer-CT9mJ1nn.js.map +1 -0
- package/dist/chunks/{importer-COTK9Tsl.js → importer-DaLTjbds.js} +116 -1099
- package/dist/chunks/importer-DaLTjbds.js.map +1 -0
- package/dist/chunks/{importer-iFYPEKaJ.js → importer-GREKMdIf.js} +28 -16
- package/dist/chunks/importer-GREKMdIf.js.map +1 -0
- package/dist/chunks/{importer-BSvfrX_h.js → importer-PqaaKKnY.js} +23 -1016
- package/dist/chunks/importer-PqaaKKnY.js.map +1 -0
- package/dist/chunks/{importer-yh_aBCU6.js → importer-Vn5QvmmJ.js} +66 -12
- package/dist/chunks/importer-Vn5QvmmJ.js.map +1 -0
- package/dist/chunks/{importer-e6LGpqHB.js → importer-vRq4h3j5.js} +1470 -354
- package/dist/chunks/importer-vRq4h3j5.js.map +1 -0
- package/dist/chunks/input-CAxt_aV-.js +1397 -0
- package/dist/chunks/input-CAxt_aV-.js.map +1 -0
- package/dist/chunks/{json-elements-DJZRZ6jd.js → json-elements-Cq76WjnZ.js} +4 -4
- package/dist/chunks/{json-elements-DJZRZ6jd.js.map → json-elements-Cq76WjnZ.js.map} +1 -1
- package/dist/chunks/{lexicon-CT69Kd87.js → lexicon-Clf4QIyl.js} +299 -77
- package/dist/chunks/lexicon-Clf4QIyl.js.map +1 -0
- package/dist/chunks/{ontology-export-G4MqRdux.js → ontology-export-OMo91mb0.js} +4 -3
- package/dist/chunks/{ontology-export-G4MqRdux.js.map → ontology-export-OMo91mb0.js.map} +1 -1
- package/dist/chunks/{records-CiaWZrFH.js → records-NJiYvekn.js} +2 -2
- package/dist/chunks/{records-CiaWZrFH.js.map → records-NJiYvekn.js.map} +1 -1
- package/dist/chunks/{format-BpQBx8MZ.js → report-CwMfYa9J.js} +70 -127
- package/dist/chunks/report-CwMfYa9J.js.map +1 -0
- package/dist/chunks/round-trip-Zm3_ivgq.js +79 -0
- package/dist/chunks/round-trip-Zm3_ivgq.js.map +1 -0
- package/dist/chunks/sigv4-EokFic1V.js +247 -0
- package/dist/chunks/sigv4-EokFic1V.js.map +1 -0
- package/dist/chunks/{styles-BQnsga7p.js → styles-CCs214_3.js} +1300 -168
- package/dist/chunks/styles-CCs214_3.js.map +1 -0
- package/dist/chunks/styles-Cm62yyQX.js +2812 -0
- package/dist/chunks/styles-Cm62yyQX.js.map +1 -0
- package/dist/chunks/styles-DPQQIig4.js +1928 -0
- package/dist/chunks/styles-DPQQIig4.js.map +1 -0
- package/dist/chunks/styles-yed-UMFdNqze.js +1213 -0
- package/dist/chunks/styles-yed-UMFdNqze.js.map +1 -0
- package/dist/chunks/{text-CzJNFOS9.js → text-ystE2bYi.js} +2 -2
- package/dist/chunks/{text-CzJNFOS9.js.map → text-ystE2bYi.js.map} +1 -1
- package/dist/csv.js +7 -5
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +5 -4
- package/dist/cx.js.map +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +5 -4
- package/dist/dot.js.map +1 -1
- package/dist/gexf.js +42 -10
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +850 -193
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +1189 -220
- 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 -4
- package/dist/neo4j.js.map +1 -1
- 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.d.ts +1 -0
- package/dist/sources-cypher.js +1351 -0
- package/dist/sources-cypher.js.map +1 -0
- package/dist/sources-ndex.d.ts +1 -0
- package/dist/sources-ndex.js +278 -0
- package/dist/sources-ndex.js.map +1 -0
- package/dist/sources-rest.d.ts +1 -0
- package/dist/sources-rest.js +1377 -0
- package/dist/sources-rest.js.map +1 -0
- package/dist/sources-sparql.d.ts +1 -0
- package/dist/sources-sparql.js +405 -0
- package/dist/sources-sparql.js.map +1 -0
- package/dist/src/common/report.d.ts +6 -3
- package/dist/src/common/report.d.ts.map +1 -1
- package/dist/src/common/report.js +15 -9
- package/dist/src/common/report.js.map +1 -1
- 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 +118 -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/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +108 -31
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/label-places.d.ts +34 -0
- package/dist/src/formats/dot/label-places.d.ts.map +1 -0
- package/dist/src/formats/dot/label-places.js +179 -0
- package/dist/src/formats/dot/label-places.js.map +1 -0
- 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 +62 -2
- package/dist/src/formats/dot/styles.d.ts.map +1 -1
- package/dist/src/formats/dot/styles.js +1457 -120
- 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 +60 -16
- package/dist/src/formats/gexf/styles.d.ts.map +1 -1
- package/dist/src/formats/gexf/styles.js +883 -131
- 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 +756 -103
- 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 +8 -12
- 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 +749 -148
- 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 +429 -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 +1755 -136
- package/dist/src/formats/json/styles.js.map +1 -1
- package/dist/src/formats/pajek/draw.d.ts +96 -0
- package/dist/src/formats/pajek/draw.d.ts.map +1 -0
- package/dist/src/formats/pajek/draw.js +372 -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 +1279 -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 +278 -60
- package/dist/src/formats/xgmml/styles.js.map +1 -1
- package/dist/src/index.d.ts +10 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -2
- 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/registry.d.ts +173 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +196 -1
- package/dist/src/registry.js.map +1 -1
- package/dist/src/sources/builtins.d.ts +11 -0
- package/dist/src/sources/builtins.d.ts.map +1 -0
- package/dist/src/sources/builtins.js +53 -0
- package/dist/src/sources/builtins.js.map +1 -0
- package/dist/src/sources/codes.d.ts +230 -0
- package/dist/src/sources/codes.d.ts.map +1 -0
- package/dist/src/sources/codes.js +58 -0
- package/dist/src/sources/codes.js.map +1 -0
- package/dist/src/sources/context.d.ts +112 -0
- package/dist/src/sources/context.d.ts.map +1 -0
- package/dist/src/sources/context.js +740 -0
- package/dist/src/sources/context.js.map +1 -0
- package/dist/src/sources/credentials.d.ts +179 -0
- package/dist/src/sources/credentials.d.ts.map +1 -0
- package/dist/src/sources/credentials.js +301 -0
- package/dist/src/sources/credentials.js.map +1 -0
- package/dist/src/sources/cypher/descriptor.d.ts +21 -0
- package/dist/src/sources/cypher/descriptor.d.ts.map +1 -0
- package/dist/src/sources/cypher/descriptor.js +124 -0
- package/dist/src/sources/cypher/descriptor.js.map +1 -0
- package/dist/src/sources/cypher/flatten.d.ts +72 -0
- package/dist/src/sources/cypher/flatten.d.ts.map +1 -0
- package/dist/src/sources/cypher/flatten.js +279 -0
- package/dist/src/sources/cypher/flatten.js.map +1 -0
- package/dist/src/sources/cypher/index.d.ts +33 -0
- package/dist/src/sources/cypher/index.d.ts.map +1 -0
- package/dist/src/sources/cypher/index.js +511 -0
- package/dist/src/sources/cypher/index.js.map +1 -0
- package/dist/src/sources/cypher/params.d.ts +40 -0
- package/dist/src/sources/cypher/params.d.ts.map +1 -0
- package/dist/src/sources/cypher/params.js +6 -0
- package/dist/src/sources/cypher/params.js.map +1 -0
- package/dist/src/sources/cypher/profiles.d.ts +44 -0
- package/dist/src/sources/cypher/profiles.d.ts.map +1 -0
- package/dist/src/sources/cypher/profiles.js +61 -0
- package/dist/src/sources/cypher/profiles.js.map +1 -0
- package/dist/src/sources/cypher/query-builder.d.ts +123 -0
- package/dist/src/sources/cypher/query-builder.d.ts.map +1 -0
- package/dist/src/sources/cypher/query-builder.js +267 -0
- package/dist/src/sources/cypher/query-builder.js.map +1 -0
- package/dist/src/sources/cypher/transports/bolt.d.ts +21 -0
- package/dist/src/sources/cypher/transports/bolt.d.ts.map +1 -0
- package/dist/src/sources/cypher/transports/bolt.js +185 -0
- package/dist/src/sources/cypher/transports/bolt.js.map +1 -0
- package/dist/src/sources/cypher/transports/neptune-analytics.d.ts +15 -0
- package/dist/src/sources/cypher/transports/neptune-analytics.d.ts.map +1 -0
- package/dist/src/sources/cypher/transports/neptune-analytics.js +38 -0
- package/dist/src/sources/cypher/transports/neptune-analytics.js.map +1 -0
- package/dist/src/sources/cypher/transports/neptune-https.d.ts +31 -0
- package/dist/src/sources/cypher/transports/neptune-https.d.ts.map +1 -0
- package/dist/src/sources/cypher/transports/neptune-https.js +104 -0
- package/dist/src/sources/cypher/transports/neptune-https.js.map +1 -0
- package/dist/src/sources/cypher/transports/query-api.d.ts +14 -0
- package/dist/src/sources/cypher/transports/query-api.d.ts.map +1 -0
- package/dist/src/sources/cypher/transports/query-api.js +80 -0
- package/dist/src/sources/cypher/transports/query-api.js.map +1 -0
- package/dist/src/sources/cypher/transports/transport.d.ts +78 -0
- package/dist/src/sources/cypher/transports/transport.d.ts.map +1 -0
- package/dist/src/sources/cypher/transports/transport.js +77 -0
- package/dist/src/sources/cypher/transports/transport.js.map +1 -0
- package/dist/src/sources/cypher/types-map.d.ts +91 -0
- package/dist/src/sources/cypher/types-map.d.ts.map +1 -0
- package/dist/src/sources/cypher/types-map.js +306 -0
- package/dist/src/sources/cypher/types-map.js.map +1 -0
- package/dist/src/sources/define.d.ts +47 -0
- package/dist/src/sources/define.d.ts.map +1 -0
- package/dist/src/sources/define.js +173 -0
- package/dist/src/sources/define.js.map +1 -0
- package/dist/src/sources/fail.d.ts +33 -0
- package/dist/src/sources/fail.d.ts.map +1 -0
- package/dist/src/sources/fail.js +49 -0
- package/dist/src/sources/fail.js.map +1 -0
- package/dist/src/sources/ids.d.ts +69 -0
- package/dist/src/sources/ids.d.ts.map +1 -0
- package/dist/src/sources/ids.js +69 -0
- package/dist/src/sources/ids.js.map +1 -0
- package/dist/src/sources/ndex/client.d.ts +31 -0
- package/dist/src/sources/ndex/client.d.ts.map +1 -0
- package/dist/src/sources/ndex/client.js +90 -0
- package/dist/src/sources/ndex/client.js.map +1 -0
- package/dist/src/sources/ndex/descriptor.d.ts +10 -0
- package/dist/src/sources/ndex/descriptor.d.ts.map +1 -0
- package/dist/src/sources/ndex/descriptor.js +55 -0
- package/dist/src/sources/ndex/descriptor.js.map +1 -0
- package/dist/src/sources/ndex/expand.d.ts +20 -0
- package/dist/src/sources/ndex/expand.d.ts.map +1 -0
- package/dist/src/sources/ndex/expand.js +87 -0
- package/dist/src/sources/ndex/expand.js.map +1 -0
- package/dist/src/sources/ndex/index.d.ts +25 -0
- package/dist/src/sources/ndex/index.d.ts.map +1 -0
- package/dist/src/sources/ndex/index.js +191 -0
- package/dist/src/sources/ndex/index.js.map +1 -0
- package/dist/src/sources/ndex/params.d.ts +17 -0
- package/dist/src/sources/ndex/params.d.ts.map +1 -0
- package/dist/src/sources/ndex/params.js +6 -0
- package/dist/src/sources/ndex/params.js.map +1 -0
- package/dist/src/sources/ndex/share-url.d.ts +40 -0
- package/dist/src/sources/ndex/share-url.d.ts.map +1 -0
- package/dist/src/sources/ndex/share-url.js +64 -0
- package/dist/src/sources/ndex/share-url.js.map +1 -0
- package/dist/src/sources/params.d.ts +31 -0
- package/dist/src/sources/params.d.ts.map +1 -0
- package/dist/src/sources/params.js +6 -0
- package/dist/src/sources/params.js.map +1 -0
- package/dist/src/sources/registry.d.ts +118 -0
- package/dist/src/sources/registry.d.ts.map +1 -0
- package/dist/src/sources/registry.js +193 -0
- package/dist/src/sources/registry.js.map +1 -0
- package/dist/src/sources/rest/descriptor.d.ts +16 -0
- package/dist/src/sources/rest/descriptor.d.ts.map +1 -0
- package/dist/src/sources/rest/descriptor.js +76 -0
- package/dist/src/sources/rest/descriptor.js.map +1 -0
- package/dist/src/sources/rest/index.d.ts +14 -0
- package/dist/src/sources/rest/index.d.ts.map +1 -0
- package/dist/src/sources/rest/index.js +13 -0
- package/dist/src/sources/rest/index.js.map +1 -0
- package/dist/src/sources/rest/mapping.d.ts +30 -0
- package/dist/src/sources/rest/mapping.d.ts.map +1 -0
- package/dist/src/sources/rest/mapping.js +362 -0
- package/dist/src/sources/rest/mapping.js.map +1 -0
- package/dist/src/sources/rest/openalex.d.ts +27 -0
- package/dist/src/sources/rest/openalex.d.ts.map +1 -0
- package/dist/src/sources/rest/openalex.js +269 -0
- package/dist/src/sources/rest/openalex.js.map +1 -0
- package/dist/src/sources/rest/paging.d.ts +53 -0
- package/dist/src/sources/rest/paging.d.ts.map +1 -0
- package/dist/src/sources/rest/paging.js +138 -0
- package/dist/src/sources/rest/paging.js.map +1 -0
- package/dist/src/sources/rest/params.d.ts +216 -0
- package/dist/src/sources/rest/params.d.ts.map +1 -0
- package/dist/src/sources/rest/params.js +7 -0
- package/dist/src/sources/rest/params.js.map +1 -0
- package/dist/src/sources/rest/records.d.ts +41 -0
- package/dist/src/sources/rest/records.d.ts.map +1 -0
- package/dist/src/sources/rest/records.js +240 -0
- package/dist/src/sources/rest/records.js.map +1 -0
- package/dist/src/sources/rest/samples/deps-dev.d.ts +10 -0
- package/dist/src/sources/rest/samples/deps-dev.d.ts.map +1 -0
- package/dist/src/sources/rest/samples/deps-dev.js +47 -0
- package/dist/src/sources/rest/samples/deps-dev.js.map +1 -0
- package/dist/src/sources/rest/samples/string.d.ts +9 -0
- package/dist/src/sources/rest/samples/string.d.ts.map +1 -0
- package/dist/src/sources/rest/samples/string.js +42 -0
- package/dist/src/sources/rest/samples/string.js.map +1 -0
- package/dist/src/sources/rest/selectors.d.ts +41 -0
- package/dist/src/sources/rest/selectors.d.ts.map +1 -0
- package/dist/src/sources/rest/selectors.js +81 -0
- package/dist/src/sources/rest/selectors.js.map +1 -0
- package/dist/src/sources/rest/source.d.ts +67 -0
- package/dist/src/sources/rest/source.d.ts.map +1 -0
- package/dist/src/sources/rest/source.js +650 -0
- package/dist/src/sources/rest/source.js.map +1 -0
- package/dist/src/sources/rest/templates.d.ts +38 -0
- package/dist/src/sources/rest/templates.d.ts.map +1 -0
- package/dist/src/sources/rest/templates.js +125 -0
- package/dist/src/sources/rest/templates.js.map +1 -0
- package/dist/src/sources/run.d.ts +93 -0
- package/dist/src/sources/run.d.ts.map +1 -0
- package/dist/src/sources/run.js +673 -0
- package/dist/src/sources/run.js.map +1 -0
- package/dist/src/sources/sha256.d.ts +12 -0
- package/dist/src/sources/sha256.d.ts.map +1 -0
- package/dist/src/sources/sha256.js +95 -0
- package/dist/src/sources/sha256.js.map +1 -0
- package/dist/src/sources/sigv4.d.ts +26 -0
- package/dist/src/sources/sigv4.d.ts.map +1 -0
- package/dist/src/sources/sigv4.js +184 -0
- package/dist/src/sources/sigv4.js.map +1 -0
- 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 +314 -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 +72 -0
- package/dist/src/sources/sparql/query.d.ts.map +1 -0
- package/dist/src/sources/sparql/query.js +113 -0
- package/dist/src/sources/sparql/query.js.map +1 -0
- package/dist/src/sources/testing.d.ts +96 -0
- package/dist/src/sources/testing.d.ts.map +1 -0
- package/dist/src/sources/testing.js +138 -0
- package/dist/src/sources/testing.js.map +1 -0
- package/dist/src/sources/types.d.ts +696 -0
- package/dist/src/sources/types.d.ts.map +1 -0
- package/dist/src/sources/types.js +10 -0
- package/dist/src/sources/types.js.map +1 -0
- 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 +82 -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 +1037 -35
- 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 +5 -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 +216 -12
- 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 +48 -2
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
- package/dist/src/styles/cyjs/mappers.js +463 -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 +204 -44
- package/dist/src/styles/cytoscape/emit.js.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.d.ts +97 -3
- package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/lexicon.js +413 -79
- 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 +46 -3
- package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/resolve.js +632 -22
- package/dist/src/styles/cytoscape/resolve.js.map +1 -1
- package/dist/src/styles/cytoscape/translate.d.ts.map +1 -1
- package/dist/src/styles/cytoscape/translate.js +10 -10
- package/dist/src/styles/cytoscape/translate.js.map +1 -1
- package/dist/src/styles/defaults.d.ts +50 -0
- package/dist/src/styles/defaults.d.ts.map +1 -1
- package/dist/src/styles/defaults.js +315 -37
- 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/block.d.ts.map +1 -1
- package/dist/src/styles/io/block.js +9 -0
- package/dist/src/styles/io/block.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 +13 -4
- 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 +13 -1
- package/dist/src/styles/plan/resolve.d.ts.map +1 -1
- package/dist/src/styles/plan/resolve.js +53 -6
- 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 +638 -5
- 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 +218 -1
- package/dist/src/styles/vocabulary.js.map +1 -1
- package/dist/src/types.d.ts +19 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/styles.js +29 -238
- package/dist/styles.js.map +1 -1
- package/dist/xgmml.js +3 -3
- package/docs/samples/people.json +6 -0
- package/package.json +53 -8
- package/src/common/report.ts +27 -7
- package/src/formats/cx/importer.ts +6 -1
- package/src/formats/cx/styles.ts +144 -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/importer.ts +120 -35
- package/src/formats/dot/label-places.ts +228 -0
- package/src/formats/dot/record.ts +336 -0
- package/src/formats/dot/styles.ts +1657 -154
- 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 +1144 -142
- 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 +854 -111
- package/src/formats/graphml/styles-plain.ts +8 -23
- package/src/formats/graphml/styles-yed.ts +821 -159
- package/src/formats/graphml/styles-yfiles3.ts +485 -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 +2041 -185
- package/src/formats/pajek/draw.ts +458 -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 +1382 -133
- package/src/formats/pajek/syntax.ts +27 -2
- package/src/formats/xgmml/emit.ts +73 -5
- package/src/formats/xgmml/styles.ts +331 -71
- package/src/index.ts +94 -0
- 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/registry.ts +326 -1
- package/src/sources/builtins.ts +63 -0
- package/src/sources/codes.ts +235 -0
- package/src/sources/context.ts +894 -0
- package/src/sources/credentials.ts +409 -0
- package/src/sources/cypher/descriptor.ts +131 -0
- package/src/sources/cypher/flatten.ts +323 -0
- package/src/sources/cypher/index.ts +628 -0
- package/src/sources/cypher/params.ts +41 -0
- package/src/sources/cypher/profiles.ts +78 -0
- package/src/sources/cypher/query-builder.ts +327 -0
- package/src/sources/cypher/transports/bolt.ts +228 -0
- package/src/sources/cypher/transports/neptune-analytics.ts +41 -0
- package/src/sources/cypher/transports/neptune-https.ts +122 -0
- package/src/sources/cypher/transports/query-api.ts +100 -0
- package/src/sources/cypher/transports/transport.ts +139 -0
- package/src/sources/cypher/types-map.ts +418 -0
- package/src/sources/define.ts +195 -0
- package/src/sources/fail.ts +70 -0
- package/src/sources/ids.ts +80 -0
- package/src/sources/ndex/client.ts +102 -0
- package/src/sources/ndex/descriptor.ts +64 -0
- package/src/sources/ndex/expand.ts +100 -0
- package/src/sources/ndex/index.ts +235 -0
- package/src/sources/ndex/params.ts +17 -0
- package/src/sources/ndex/share-url.ts +84 -0
- package/src/sources/params.ts +32 -0
- package/src/sources/registry.ts +325 -0
- package/src/sources/rest/descriptor.ts +79 -0
- package/src/sources/rest/index.ts +22 -0
- package/src/sources/rest/mapping.ts +401 -0
- package/src/sources/rest/openalex.ts +288 -0
- package/src/sources/rest/paging.ts +180 -0
- package/src/sources/rest/params.ts +243 -0
- package/src/sources/rest/records.ts +289 -0
- package/src/sources/rest/samples/deps-dev.ts +49 -0
- package/src/sources/rest/samples/string.ts +44 -0
- package/src/sources/rest/selectors.ts +91 -0
- package/src/sources/rest/source.ts +776 -0
- package/src/sources/rest/templates.ts +151 -0
- package/src/sources/run.ts +793 -0
- package/src/sources/sha256.ts +99 -0
- package/src/sources/sigv4.ts +209 -0
- package/src/sources/sparql/descriptor.ts +67 -0
- package/src/sources/sparql/index.ts +356 -0
- package/src/sources/sparql/ntriples.ts +219 -0
- package/src/sources/sparql/params.ts +28 -0
- package/src/sources/sparql/query.ts +162 -0
- package/src/sources/testing.ts +210 -0
- package/src/sources/types.ts +776 -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 +99 -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 +1193 -38
- package/src/styles/cyjs/defaults-table.ts +5 -0
- package/src/styles/cyjs/emit.ts +247 -16
- package/src/styles/cyjs/face.ts +372 -0
- package/src/styles/cyjs/mappers.ts +498 -28
- package/src/styles/cyjs/routes.ts +432 -0
- package/src/styles/cytoscape/charts.ts +684 -0
- package/src/styles/cytoscape/emit.ts +220 -44
- package/src/styles/cytoscape/lexicon.ts +459 -80
- package/src/styles/cytoscape/mappings.ts +108 -0
- package/src/styles/cytoscape/resolve.ts +763 -23
- package/src/styles/cytoscape/translate.ts +11 -11
- package/src/styles/defaults.ts +436 -38
- package/src/styles/index.ts +5 -0
- package/src/styles/internal.ts +1 -0
- package/src/styles/io/block.ts +10 -0
- package/src/styles/io/generic.ts +79 -23
- package/src/styles/io/round-trip.ts +202 -0
- package/src/styles/io/writer.ts +14 -4
- 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 +61 -6
- package/src/styles/slots.ts +25 -0
- package/src/styles/types.ts +658 -4
- package/src/styles/vocabulary.ts +226 -3
- package/src/types.ts +19 -5
- package/dist/chunks/block-DiGq58c3.js.map +0 -1
- package/dist/chunks/choose--jM0yYCo.js +0 -57
- package/dist/chunks/choose--jM0yYCo.js.map +0 -1
- package/dist/chunks/convert-BcQ8_jMo.js.map +0 -1
- package/dist/chunks/emit-CwU8cUmG.js.map +0 -1
- package/dist/chunks/export-BvqAXCKh.js.map +0 -1
- package/dist/chunks/exporter-CrDWIyiq.js.map +0 -1
- package/dist/chunks/format-BpQBx8MZ.js.map +0 -1
- package/dist/chunks/generic-Dq1ntt9q.js.map +0 -1
- package/dist/chunks/importer-BSvfrX_h.js.map +0 -1
- package/dist/chunks/importer-CMmeMWlC.js.map +0 -1
- package/dist/chunks/importer-COTK9Tsl.js.map +0 -1
- package/dist/chunks/importer-DiZRmOQG.js.map +0 -1
- package/dist/chunks/importer-e6LGpqHB.js.map +0 -1
- package/dist/chunks/importer-iFYPEKaJ.js.map +0 -1
- package/dist/chunks/importer-yh_aBCU6.js.map +0 -1
- package/dist/chunks/lexicon-CT69Kd87.js.map +0 -1
- package/dist/chunks/styles-BQnsga7p.js.map +0 -1
- package/dist/chunks/styles-D3fRphrO.js +0 -690
- package/dist/chunks/styles-D3fRphrO.js.map +0 -1
- package/dist/chunks/styles-yed-BF5x3_Y5.js +0 -842
- package/dist/chunks/styles-yed-BF5x3_Y5.js.map +0 -1
- package/dist/chunks/writer-DMKvthQE.js +0 -448
- package/dist/chunks/writer-DMKvthQE.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter-_jrBTnos.js","sources":["../../src/formats/cx/exporter.ts"],"sourcesContent":["/**\n * The CX version 1 exporter (design/graph-io/cytoscape-and-obo/design.md section 1.2): writes a\n * snapshot as the NDEx form of a CX document -- one network with at most one view, no\n * `cySubNetworks` -- which NDEx, ndex2 and Cytoscape's CX import all read.\n *\n * Aspects, in the order Cytoscape and NDEx write them: `numberVerification`, the pre-`metaData`\n * (element counts, `idCounter` on nodes, edges, citations and supports), `nodes` (`n` the label,\n * `r` the `represents` column), `edges` (`i` the `interaction` column), `nodeAttributes`,\n * `edgeAttributes` and `networkAttributes` (values as JSON strings, the spec's form), `cyTableColumn`\n * (so a column no element fills is still declared), `cartesianLayout` (y negated back to screen\n * coordinates), `cyGroups` from the parent / parents column, `cyVisualProperties` from the\n * `cx.bypass` columns, the provenance aspects a CX import created, the style rules and unknown\n * aspects a CX import kept, and `status`.\n *\n * Given styles (`exportGraph(..., { styles })`), `cyVisualProperties` holds the Cytoscape style of the rules\n * (`network`, `nodes:default` and `edges:default` with their mappings and dependencies) and a bypass for every\n * element whose value the style cannot give, and the style values the rules read are attributes. The\n * `graphty.styles` block, which graph-io hands over as a graph attribute, is written as an aspect of its own\n * (a kept one is written back the same way).\n *\n * What CX cannot hold is announced by check() before anything is written: every edge is directed\n * (W_CX_UNDIRECTED_AS_DIRECTED, W_MUTUAL_EXPANDED), node ids are integers (E_ID_CHARSET unless\n * `sanitizeIds: \"mangle\"`, which keeps the original in the `graphty:originalId` attribute the\n * importer restores), nested values are written as JSON text (W_CX_JSON_AS_STRING), and the generic\n * notes of checkCapabilities(). NaN and the infinities are written as \"NaN\" / \"Infinity\" in double\n * attributes, which read back as they were.\n */\n\nimport { type Column, GraphFormatError, type GraphSnapshot, type NodeId } from \"@graphty/graph-format\";\n\nimport { childrenCsr } from \"../../children.js\";\nimport {\n aspectBlock,\n type CxNoteFn,\n declaredType,\n directionNotes,\n nextNodeId,\n noteList,\n planEdgeIds,\n planNodeIds,\n stringify,\n type WrittenIds,\n} from \"../../common/cx-export.js\";\nimport { type PairFolding, pairFolding } from \"../../common/direction.js\";\nimport { capabilities, checkCapabilities, LOSS } from \"../../common/export.js\";\nimport { isRecord, POSITION_COLUMN } from \"../../common/json-elements.js\";\nimport { type ResolvedExportOptions, resolveExportOptions } from \"../../common/options.js\";\nimport { plural } from \"../../common/plural.js\";\nimport { type ExplicitWeights, explicitWeights } from \"../../common/weights.js\";\nimport { encodeChunks, joinText } from \"../../common/writer.js\";\nimport { cytoscapeCxAspect, type CytoscapeEmitted } from \"../../styles/cytoscape/emit.js\";\nimport { STYLE_BLOCK_NAME } from \"../../styles/io/block.js\";\nimport type { ExporterStyleOptions } from \"../../styles/io/writer.js\";\nimport { type CommonExportOptions, type ExportCapabilities, type GraphExporter, type LossNote } from \"../../types.js\";\nimport { ORIGINAL_ID_ATTRIBUTE } from \"../cx2/importer.js\";\nimport { blockAspect, CX_STYLE_CAPABILITIES, cytoscapeStyledExport, snapshotBlock } from \"./styles.js\";\n\n/** The format name. */\nconst CX_FORMAT = \"cx\";\n\n/**\n * The options of the CX exporter: the common export options; it has none of its own.\n * @category Built-in formats\n */\nexport type CxExportOptions = CommonExportOptions;\n\n/**\n * The loss notes the CX exporter's check() returns, by name. A key is the code without its\n * severity and format prefixes.\n * @category Built-in formats\n */\nexport const CX_LOSS = Object.freeze({\n /**\n * Every edge is written as directed, so an undirected graph, or the undirected edges of a mixed graph, read back\n * as directed.\n */\n UNDIRECTED_AS_DIRECTED: \"W_CX_UNDIRECTED_AS_DIRECTED\",\n /** A nested (json) column is written as a string attribute holding its JSON text. */\n JSON_AS_STRING: \"W_CX_JSON_AS_STRING\",\n /** A mutual pair is written as two directed edges without its mark. */\n MUTUAL_EXPANDED: LOSS.MUTUAL_EXPANDED,\n /**\n * An attribute named `weight` without the weight role reads back as the edge weight, or is not written when the\n * graph has weights of its own.\n */\n WEIGHT_KEY_CLASH: LOSS.WEIGHT_KEY_CLASH,\n /** A start / end / timestamp column: CX has no time. */\n TEMPORAL_DROPPED: LOSS.TEMPORAL,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: LOSS.ROLE,\n /**\n * An attribute without a role is written where the format keeps a role (for example, a `name` column as the label), and\n * reads back with that role.\n */\n ROLE_ASSUMED: LOSS.ROLE_ASSUMED,\n /**\n * An attribute type CX stores as another (a 32-bit float as double, an unsigned integer as long, a byte as\n * integer, a dictionary as string); it reads back with that type.\n */\n DTYPE_UNSUPPORTED: LOSS.DTYPE,\n /** A multi-component column (a second view's `position@2`, a vector) is written as a list of doubles. */\n COMPONENTS_FLATTENED: LOSS.COMPONENTS,\n /** A declared default: CX has none. */\n DEFAULT_DROPPED: LOSS.DEFAULT,\n /** Declared options: CX has no enumerations. */\n OPTIONS_DROPPED: LOSS.OPTIONS,\n /**\n * Node ids the format cannot write, under `sanitizeIds: \"error\"`; the save fails with E_INVALID_ID. Pass\n * `sanitizeIds: \"mangle\"` to rewrite them.\n */\n ID_CHARSET: LOSS.ID_CHARSET,\n /** Node ids that are not integers under sanitizeIds \"mangle\": renumbered, originals kept. */\n ID_MANGLED: LOSS.ID_MANGLED,\n /** Edges without a usable integer id get generated ids. */\n EDGE_IDS_GENERATED: LOSS.EDGE_IDS_GENERATED,\n /**\n * An attribute with a role (for example, the label) is written where the format keeps that role, and reads back under the\n * name the format's importer gives it.\n */\n COLUMN_NAME_CHANGED: LOSS.COLUMN_NAME_CHANGED,\n /** An extension table other than the `cx:citations` / `cx:supports` tables a CX import creates. */\n EXTENSION_TABLE_DROPPED: LOSS.EXTENSION_TABLE,\n /** A position, stacking order or weight that is NaN or infinite: CX spells no such number there. */\n NONFINITE_AS_NULL: LOSS.NONFINITE_AS_NULL,\n /** Visual columns (color, size, shape, thickness roles): CX keeps style as visual properties, not roles. */\n VIZ_DROPPED: LOSS.VIZ,\n});\n\n/**\n * What CX version 1 keeps: directed multigraphs with self-loops, integer node ids, required\n * integer edge ids, typed string / double / integer / boolean attributes and lists of them, network\n * attributes, the position role (one view), and containment as `cyGroups`. f32, u32, u8 and dict\n * columns are written as the nearest declared type and read back as it.\n * @category Built-in formats\n */\nexport const CX_CAPABILITIES: ExportCapabilities = capabilities({\n mixedDirection: false,\n multiEdges: true,\n selfLoops: true,\n edgeIds: \"required\",\n idCharset: \"integer\",\n dtypes: [\"string\", \"f64\", \"i32\", \"bool\"],\n components: false,\n lists: true,\n json: false,\n defaults: false,\n options: false,\n hierarchy: true,\n temporal: \"none\",\n graphAttributes: true,\n positions: true,\n viz: false,\n});\n\n/** The roles CX has a slot for, and the column names its importer gives them. */\nconst SLOT_ROLES: ReadonlySet<string> = new Set([\"label\", \"position\", \"id\"]);\nconst ROLE_NAMES: Readonly<Record<string, string>> = Object.freeze({\n label: \"name\",\n position: POSITION_COLUMN,\n id: \"id\",\n parent: \"parent\",\n});\n\n/** Roles whose columns are never written as attributes. */\nconst SKIPPED_ROLES: ReadonlySet<string> = new Set([\n \"directed\",\n \"pair\",\n \"mutual\",\n \"weight\",\n \"timeText\",\n \"originalId\",\n \"parent\",\n \"parents\",\n \"start\",\n \"end\",\n \"timestamp\",\n \"timestamps\",\n \"spells\",\n \"open\",\n \"spellsOpen\",\n \"position\",\n \"color\",\n \"size\",\n \"shape\",\n \"thickness\",\n \"id\",\n]);\n\n/** The origin namespace of the per-element visual property columns of a CX import. */\nconst BYPASS_NAMESPACE = \"cx.bypass\";\n\n/** The extension tables a CX import creates from the citations and supports aspects. */\nconst PROVENANCE_TABLES: Readonly<Record<string, string>> = Object.freeze({\n \"cx:citations\": \"citations\",\n \"cx:supports\": \"supports\",\n});\n\n/**\n * Kept aspects never written back: they describe the collection, views and SUIDs of the file the\n * snapshot came from, or are written by the exporter itself.\n */\nconst NEVER_WRITTEN: ReadonlySet<string> = new Set([\n \"nodes\",\n \"edges\",\n \"nodeAttributes\",\n \"edgeAttributes\",\n \"networkAttributes\",\n \"cartesianLayout\",\n \"cyGroups\",\n \"cyVisualProperties\",\n \"cyTableColumn\",\n \"cySubNetworks\",\n \"cyNetworkRelations\",\n \"cyViews\",\n \"CX Element ID\",\n \"citations\",\n \"supports\",\n \"nodeCitations\",\n \"edgeCitations\",\n \"nodeSupports\",\n \"edgeSupports\",\n \"functionTerms\",\n \"reifiedEdges\",\n \"numberVerification\",\n \"metaData\",\n \"status\",\n \"groups\",\n \"subnetwork\",\n STYLE_BLOCK_NAME,\n]);\n\n/** The weight attribute name (the CX importer's weightFrom default). */\nconst WEIGHT_ATTRIBUTE = \"weight\";\n\n/** The dtypes a plain `weight` column may have to be written as the weight. */\nconst NUMERIC_DTYPES: ReadonlySet<string> = new Set([\"f32\", \"f64\", \"i32\", \"u32\", \"u8\"]);\n\n/** One attribute column as it will be written. */\ninterface AttributePlan {\n readonly column: Column;\n /** The attribute name written in n. */\n readonly name: string;\n /** The declared type text. */\n readonly d: string;\n}\n\n/** A core field (n, r, i) and the column it comes from. */\ninterface CorePlan {\n readonly key: \"n\" | \"r\" | \"i\";\n readonly column: Column;\n}\n\n/** The edge weights as written: explicit weights or a plain numeric `weight` column. */\ninterface WeightPlan {\n /**\n * The weight of an edge, or undefined when none is written.\n * @param e - the edge index\n * @returns the value\n */\n value(e: number): number | undefined;\n}\n\n/** Everything export() and check() need, computed once. */\ninterface Plan {\n readonly notes: LossNote[];\n readonly fatal: GraphFormatError | null;\n readonly ids: WrittenIds | null;\n readonly folding: PairFolding;\n readonly edgeIds: readonly number[];\n readonly weight: WeightPlan | null;\n readonly nodeCore: readonly CorePlan[];\n readonly edgeCore: readonly CorePlan[];\n readonly nodeAttrs: readonly AttributePlan[];\n readonly edgeAttrs: readonly AttributePlan[];\n readonly graphAttrs: readonly AttributePlan[];\n readonly position: Column | null;\n readonly positionZ: boolean;\n readonly z: Column | null;\n readonly bypass: {\n readonly node: readonly Column[];\n readonly edge: readonly Column[];\n readonly graph: readonly Column[];\n };\n readonly collapsed: Column | null;\n readonly links: readonly LinkPlan[];\n readonly functionTerm: Column | null;\n readonly reifiedEdge: Column | null;\n}\n\n/** A citations / supports list column and the aspect it is written to. */\ninterface LinkPlan {\n readonly aspect: string;\n readonly key: \"citations\" | \"supports\";\n readonly domain: \"node\" | \"edge\";\n readonly column: Column;\n}\n\n/**\n * Whether a column was created by the CX importer in an origin namespace.\n * @param column - the column\n * @param namespace - the namespace\n * @returns true when it was\n */\nfunction fromCx(column: Column, namespace: string): boolean {\n return column.meta.origin?.format === CX_FORMAT && column.meta.origin.namespace === namespace;\n}\n\n/**\n * Whether a column is a bypass column of a CX import.\n * @param column - the column\n * @returns true for the cx.bypass namespace\n */\nfunction isBypass(column: Column): boolean {\n return column.meta.origin?.namespace === BYPASS_NAMESPACE;\n}\n\n/**\n * Whether a column is the z (stacking order) column.\n * @param column - the column\n * @returns true for the column marked by a Cytoscape-family importer\n */\nfunction isZ(column: Column): boolean {\n return column.meta.extra.cytoscape === \"z\";\n}\n\n/**\n * Whether a column is a provenance list column (citations / supports) of a CX import.\n * @param column - the column\n * @returns true for one\n */\nfunction isLink(column: Column): boolean {\n return (\n fromCx(column, \"provenance\") &&\n column.meta.dtype === \"list\" &&\n (column.meta.name === \"citations\" || column.meta.name === \"supports\")\n );\n}\n\n/**\n * Whether a column holds a text the core fields (n, r, i) cannot hold as itself.\n * @param column - the column\n * @returns true for every dtype but string (dict and json have their own notes)\n */\nfunction coreNeedsText(column: Column): boolean {\n const { dtype } = column.meta;\n return dtype !== \"string\" && dtype !== \"dict\" && dtype !== \"json\";\n}\n\n/**\n * The notes of checkCapabilities(), adapted to CX: json columns are written as JSON text, the id\n * notes are counted by planNodeIds(), the provenance tables and columns a CX import made are\n * written back.\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @param several - whether the parents column gives some node several parents\n * @param own - the functionTerm and reifiedEdge columns written as their own aspects\n * @param notes - the notes so far\n * @param note - records a note\n * @returns the error export() throws for mixed direction, or null\n */\nfunction genericNotes(\n snapshot: GraphSnapshot,\n common: ResolvedExportOptions,\n several: boolean,\n own: readonly (Column | null)[],\n notes: LossNote[],\n note: CxNoteFn,\n): GraphFormatError | null {\n let fatal: GraphFormatError | null = null;\n const edgeLabel = snapshot.edges.byRole(\"label\")?.meta.name;\n const ownNames = new Set(own.filter((c): c is Column => c !== null).map((c) => c.meta.name));\n for (const gen of checkCapabilities(snapshot, CX_CAPABILITIES, common, {\n roles: SLOT_ROLES,\n // a parents column reads back as parents only when some node has several parents\n roleNames: several ? { ...ROLE_NAMES, parents: \"parents\" } : ROLE_NAMES,\n })) {\n if (writtenOtherwise(gen, ownNames)) {\n continue;\n }\n if (gen.code === LOSS.JSON) {\n const which = gen.column === null ? \"a column\" : `column \"${gen.column}\"`;\n note(\n CX_LOSS.JSON_AS_STRING,\n `${which} holds nested values; written as a string attribute holding their JSON text`,\n gen.column,\n gen.count,\n );\n continue;\n }\n if (isEdgeLabelRename(gen, edgeLabel)) {\n // only nodes have a label slot (n); an edge label is a plain attribute\n note(\n LOSS.ROLE,\n `edge column \"${edgeLabel ?? \"\"}\" (label) is written as a plain attribute; CX edges have no label slot and the role is lost`,\n gen.column,\n gen.count,\n );\n continue;\n }\n if (gen.code === LOSS.MIXED_DIRECTION_ERROR && fatal === null) {\n fatal = new GraphFormatError(\"E_DIRECTED\", gen.message, { reason: \"mixed direction\" });\n }\n notes.push(gen);\n }\n if (edgeLabel === \"name\") {\n note(\n LOSS.ROLE,\n `edge column \"name\" (label) is written as a plain attribute; CX edges have no label slot and the role is lost`,\n \"name\",\n null,\n );\n }\n return fatal;\n}\n\n/**\n * Whether a generic note is about something CX writes another way: the functionTerm and\n * reifiedEdge columns (their own aspects), ids (counted by planNodeIds(), since CX also keeps\n * integer ids beyond 2^53, which the generic rule refuses) and the provenance tables.\n * @param gen - the generic note\n * @param ownNames - the names of the columns written as their own aspects\n * @returns true when the note does not apply\n */\nfunction writtenOtherwise(gen: LossNote, ownNames: ReadonlySet<string>): boolean {\n if (gen.column !== null && ownNames.has(gen.column) && (gen.code === LOSS.JSON || gen.code === LOSS.DTYPE)) {\n return true;\n }\n if (gen.code === LOSS.ID_CHARSET || gen.code === LOSS.ID_MANGLED) {\n return true;\n }\n return gen.code === LOSS.EXTENSION_TABLE && gen.column !== null && gen.column in PROVENANCE_TABLES;\n}\n\n/**\n * Whether a generic note is the rename of the edge label column.\n * @param gen - the generic note\n * @param edgeLabel - the edge label column's name, if any\n * @returns true when it is\n */\nfunction isEdgeLabelRename(gen: LossNote, edgeLabel: string | undefined): boolean {\n return gen.code === LOSS.COLUMN_NAME_CHANGED && gen.column === edgeLabel && gen.message.startsWith(\"edge column\");\n}\n\n/**\n * The node positions to write: the position column, the z column (when it fits the layout), whether\n * the position's third coordinate is written as z, and the count of non-finite values left out.\n * @param snapshot - the snapshot\n * @param note - records a note\n * @returns the position plan\n */\nfunction planPositions(\n snapshot: GraphSnapshot,\n note: CxNoteFn,\n): { position: Column | null; z: Column | null; positionZ: boolean; nonfinite: number } {\n const position = snapshot.nodes.byRole(\"position\");\n const zColumn = [...snapshot.nodes].find(isZ) ?? null;\n const z = zColumn !== null && zFitsLayout(zColumn, position) ? zColumn : null;\n if (position === null) {\n return { position, z, positionZ: false, nonfinite: 0 };\n }\n let nonfinite = nonFiniteCells(position, (v) => [v[0], v[1]]);\n const depth = nonFiniteCells(position, (v) => (v[2] === 0 ? [] : [Number.NaN]));\n const positionZ = zColumn === null && (position.meta.extra.sourceDims === 3 || depth > 0);\n if (positionZ) {\n nonfinite += nonFiniteCells(position, (v) => (Number.isFinite(v[0]) && Number.isFinite(v[1]) ? [v[2]] : []));\n note(\n LOSS.COMPONENTS,\n `node column \"${position.meta.name}\" (position) has a third coordinate; CX writes it as the layout's z, which reads back in the z column (a stacking order), not in the position`,\n position.meta.name,\n depth,\n );\n }\n return { position, z, positionZ, nonfinite };\n}\n\n/**\n * Note the graph columns that read back as the graph's name or description.\n * @param snapshot - the snapshot\n * @param note - records a note\n */\nfunction graphColumnNotes(snapshot: GraphSnapshot, note: CxNoteFn): void {\n for (const c of snapshot.graph) {\n const named = c.meta.name === \"name\" || c.meta.name === \"description\";\n if (!isBypass(c) && named && (c.dtype === \"string\" || c.dtype === \"dict\")) {\n note(\n LOSS.ROLE_ASSUMED,\n `graph column \"${c.meta.name}\" is written as the network attribute ${c.meta.name}, which reads back as the graph's ${c.meta.name}, not as a column`,\n c.meta.name,\n null,\n );\n }\n }\n}\n\n/**\n * Plan an export: the notes, the fatal condition and what is written.\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @returns the plan\n */\nfunction plan(snapshot: GraphSnapshot, common: ResolvedExportOptions): Plan {\n const { notes, note } = noteList();\n const functionTerm =\n [...snapshot.nodes].find((c) => fromCx(c, \"provenance\") && c.meta.name === \"functionTerm\") ?? null;\n const reifiedEdge = [...snapshot.nodes].find((c) => fromCx(c, \"reifiedEdges\") && c.dtype === \"u32\") ?? null;\n const children = childrenCsr(snapshot);\n const several = children.column?.meta.role === \"parents\" && severalParents(children.column);\n let fatal = genericNotes(snapshot, common, several, [functionTerm, reifiedEdge], notes, note);\n\n const folding = pairFolding(snapshot);\n directionNotes(snapshot, folding, common, CX_LOSS.UNDIRECTED_AS_DIRECTED, note);\n const planned = planNodeIds(snapshot, common, \"CX\", ORIGINAL_ID_ATTRIBUTE, note);\n const ids = planned instanceof GraphFormatError ? null : planned;\n if (planned instanceof GraphFormatError) {\n fatal ??= planned;\n }\n const edgeIds = planEdgeIds(snapshot, note, ids);\n if (snapshot.nodes.has(ORIGINAL_ID_ATTRIBUTE)) {\n note(\n LOSS.ROLE_ASSUMED,\n `node column \"${ORIGINAL_ID_ATTRIBUTE}\" is the importer's record of mangled ids: it reads back as the node ids unless restoreMangledIds is false`,\n ORIGINAL_ID_ATTRIBUTE,\n null,\n );\n }\n\n // nodes: n, r, the z column, the groups' collapsed flags, provenance\n const positions = planPositions(snapshot, note);\n const { position, z, positionZ } = positions;\n let { nonfinite } = positions;\n const collapsed = [...snapshot.nodes].find((c) => fromCx(c, \"cyGroups\") && c.dtype === \"bool\") ?? null;\n const nodeCore = corePlans(snapshot, note);\n const edgeCore: CorePlan[] = [];\n const interaction = snapshot.edges.get(\"interaction\");\n if (interaction !== null && (interaction.meta.role === null || !SKIPPED_ROLES.has(interaction.meta.role))) {\n edgeCore.push({ key: \"i\", column: interaction });\n coreTextNote(interaction, \"edge\", note);\n }\n\n const coreColumns = new Set<Column>([...nodeCore, ...edgeCore].map((c) => c.column));\n const special = (c: Column): boolean =>\n coreColumns.has(c) ||\n isBypass(c) ||\n isLink(c) ||\n c === z ||\n c === collapsed ||\n c === functionTerm ||\n c === reifiedEdge ||\n (c.meta.role !== null && SKIPPED_ROLES.has(c.meta.role));\n\n const label = snapshot.nodes.byRole(\"label\");\n const renamedName = label !== null && label.meta.name !== \"name\" ? snapshot.nodes.get(\"name\") : null;\n if (renamedName !== null) {\n note(\n LOSS.COLUMN_NAME_CHANGED,\n `node column \"name\" is written as the attribute \"name#2\" and reads back as \"name#2\", because the label column \"${label?.meta.name ?? \"\"}\" is written as n and takes the name \"name\"`,\n \"name\",\n renamedName.length - renamedName.nullCount,\n );\n }\n const nodeAttrs = attributePlans(snapshot.nodes, special, (c) => (c === renamedName ? \"name#2\" : c.meta.name));\n\n const weight = planWeight(snapshot, folding, note);\n const plainWeight = snapshot.edges.get(WEIGHT_ATTRIBUTE);\n const edgeAttrs = attributePlans(\n snapshot.edges,\n (c) => special(c) || (c === plainWeight && c.meta.role === null),\n (c) => c.meta.name,\n );\n nonfinite += weight.nonfinite;\n\n graphColumnNotes(snapshot, note);\n // the graphty.styles block is an aspect of its own\n const graphAttrs = attributePlans(\n snapshot.graph,\n (c) => isBypass(c) || c.meta.name === STYLE_BLOCK_NAME,\n (c) => c.meta.name,\n );\n\n if (children.column !== null && children.column.meta.role === \"parents\" && !several) {\n note(\n LOSS.COLUMN_NAME_CHANGED,\n `node column \"${children.column.meta.name}\" (parents) holds at most one parent per node; it reads back as the single-parent column \"parent\"`,\n children.column.meta.name,\n children.column.length - children.column.nullCount,\n );\n }\n\n if (nonfinite > 0) {\n note(\n LOSS.NONFINITE_AS_NULL,\n `${nonfinite} NaN or infinite position${plural(nonfinite)}, stacking orders or weights cannot be written in CX; they read back unset`,\n null,\n nonfinite,\n );\n }\n return {\n notes,\n fatal,\n ids,\n folding,\n edgeIds,\n weight: weight.plan,\n nodeCore,\n edgeCore,\n nodeAttrs,\n edgeAttrs,\n graphAttrs,\n position,\n positionZ,\n z,\n bypass: {\n node: [...snapshot.nodes].filter(isBypass),\n edge: [...snapshot.edges].filter(isBypass),\n graph: [...snapshot.graph].filter(isBypass),\n },\n collapsed,\n links: linkPlans(snapshot),\n functionTerm,\n reifiedEdge,\n };\n}\n\n/**\n * The node core fields: n from the label column (else a plain `name` column, which then reads back\n * as the label), r from a `represents` column.\n * @param snapshot - the snapshot\n * @param note - records a note\n * @returns the plans\n */\nfunction corePlans(snapshot: GraphSnapshot, note: CxNoteFn): CorePlan[] {\n const out: CorePlan[] = [];\n const label = snapshot.nodes.byRole(\"label\");\n const plainName = snapshot.nodes.get(\"name\");\n const n = label ?? (plainName !== null && plainName.meta.role === null ? plainName : null);\n if (n !== null) {\n out.push({ key: \"n\", column: n });\n coreTextNote(n, \"node\", note);\n if (n !== label) {\n note(\n LOSS.ROLE_ASSUMED,\n `node column \"name\" is written as n and reads back as the label`,\n \"name\",\n n.length - n.nullCount,\n );\n }\n }\n const represents = snapshot.nodes.get(\"represents\");\n if (\n represents !== null &&\n represents !== n &&\n (represents.meta.role === null || !SKIPPED_ROLES.has(represents.meta.role))\n ) {\n out.push({ key: \"r\", column: represents });\n coreTextNote(represents, \"node\", note);\n }\n return out;\n}\n\n/**\n * The note of a core field column that is not text: n, r and i are strings in CX.\n * @param column - the column\n * @param domain - node or edge\n * @param note - records a note\n */\nfunction coreTextNote(column: Column, domain: string, note: CxNoteFn): void {\n if (coreNeedsText(column)) {\n note(\n LOSS.DTYPE,\n `${domain} column \"${column.meta.name}\" is ${column.dtype}; CX writes it as text and it reads back as string`,\n column.meta.name,\n column.length - column.nullCount,\n );\n }\n}\n\n/**\n * The attribute plans of one table.\n * @param table - the table\n * @param skip - columns not written as attributes\n * @param rename - the written name of a column\n * @returns the plans\n */\nfunction attributePlans(\n table: Iterable<Column>,\n skip: (column: Column) => boolean,\n rename: (column: Column) => string,\n): AttributePlan[] {\n return [...table]\n .filter((c) => !skip(c))\n .map((column) => ({ column, name: rename(column), d: declaredType(column) }));\n}\n\n/**\n * The weights to write: the explicit weights, else a plain numeric `weight` column (which then\n * reads back as THE weight); a plain `weight` column that is not written is noted.\n * @param snapshot - the snapshot\n * @param folding - the pair folding\n * @param note - records a note\n * @returns the plan, or null for no weight attribute, and the count of non-finite weights skipped\n */\nfunction planWeight(\n snapshot: GraphSnapshot,\n folding: PairFolding,\n note: CxNoteFn,\n): { plan: WeightPlan | null; nonfinite: number } {\n const weights: ExplicitWeights = explicitWeights(snapshot);\n const plain = snapshot.edges.get(WEIGHT_ATTRIBUTE);\n const clash = plain !== null && plain.meta.role === null;\n let plan: WeightPlan | null = null;\n if (weights.weighted) {\n plan = { value: (e) => (weights.isExplicit(e) ? weights.value(e) : undefined) };\n if (clash) {\n note(\n LOSS.WEIGHT_KEY_CLASH,\n `edge column \"${WEIGHT_ATTRIBUTE}\" is not written: the explicit weights are written under that name`,\n WEIGHT_ATTRIBUTE,\n null,\n );\n }\n } else if (clash) {\n const numeric = NUMERIC_DTYPES.has(plain.dtype);\n note(\n LOSS.WEIGHT_KEY_CLASH,\n numeric\n ? `edge column \"${WEIGHT_ATTRIBUTE}\" is written as the weight attribute and reads back as the edge weight`\n : `edge column \"${WEIGHT_ATTRIBUTE}\" is ${plain.dtype}, and CX reads that attribute as the edge weight; it is not written`,\n WEIGHT_ATTRIBUTE,\n null,\n );\n if (numeric) {\n plan = { value: (e) => (plain.isSet(e) ? (plain.value(e) as number) : undefined) };\n }\n }\n return { plan, nonfinite: plan === null ? 0 : nanWeights(snapshot.edgeCount, plan, folding) };\n}\n\n/**\n * The written weights that are NaN, which is not a weight on re-import (the infinities are).\n * @param edgeCount - the number of edges\n * @param plan - the weight plan\n * @param folding - the pair folding\n * @returns the count\n */\nfunction nanWeights(edgeCount: number, plan: WeightPlan, folding: PairFolding): number {\n let nan = 0;\n for (let e = 0; e < edgeCount; e++) {\n const w = plan.value(e);\n if (!folding.folded(e) && w !== undefined && Number.isNaN(w)) {\n nan++;\n }\n }\n return nan;\n}\n\n/**\n * Whether the z column can go into cartesianLayout: every set z is finite and its node has a\n * finite position (a layout entry needs x and y). Otherwise it is written as an ordinary attribute.\n * @param z - the z column\n * @param position - the position column\n * @returns true when every z fits a layout entry\n */\nfunction zFitsLayout(z: Column, position: Column | null): boolean {\n for (let i = 0; i < z.length; i++) {\n if (!z.isSet(i)) {\n continue;\n }\n const value = z.value(i);\n const point = position?.isSet(i) === true ? (position.value(i) as ArrayLike<number>) : null;\n if (\n typeof value !== \"number\" ||\n !Number.isFinite(value) ||\n point === null ||\n !Number.isFinite(point[0]) ||\n !Number.isFinite(point[1])\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Count the set cells of a multi-component column with a non-finite component among those picked.\n * @param column - the column\n * @param pick - the components that are written\n * @returns the count\n */\nfunction nonFiniteCells(column: Column, pick: (value: ArrayLike<number>) => number[]): number {\n let count = 0;\n for (let i = 0; i < column.length; i++) {\n if (column.isSet(i) && pick(column.value(i) as ArrayLike<number>).some((v) => !Number.isFinite(v))) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Whether a parents column gives some node more than one parent.\n * @param column - the parents list column\n * @returns true when one does\n */\nfunction severalParents(column: Column): boolean {\n for (let i = 0; i < column.length; i++) {\n if (column.isSet(i) && (column.value(i) as ArrayLike<unknown>).length > 1) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * The citations / supports list columns of a CX import and the aspects they go to.\n * @param snapshot - the snapshot\n * @returns the plans\n */\nfunction linkPlans(snapshot: GraphSnapshot): LinkPlan[] {\n const out: LinkPlan[] = [];\n for (const [domain, table] of [\n [\"node\", snapshot.nodes],\n [\"edge\", snapshot.edges],\n ] as const) {\n for (const column of table) {\n if (isLink(column)) {\n const key = column.meta.name as \"citations\" | \"supports\";\n out.push({ aspect: `${domain}${key === \"citations\" ? \"Citations\" : \"Supports\"}`, key, domain, column });\n }\n }\n }\n return out;\n}\n\n// ============================================================ writing\n\n/**\n * The text of a scalar the way Cytoscape writes CX values: numbers by their shortest decimal\n * (\"-0\", \"NaN\", \"Infinity\" included), booleans as \"true\" / \"false\".\n * @param value - the value\n * @returns the text\n */\nfunction scalarText(value: unknown): string {\n if (typeof value === \"number\") {\n return Object.is(value, -0) ? \"-0\" : String(value);\n }\n if (typeof value === \"string\") {\n return value;\n }\n return typeof value === \"boolean\" ? String(value) : JSON.stringify(value);\n}\n\n/**\n * The v of one cell: a JSON string, or an array of strings for a list type.\n * @param column - the column\n * @param d - its declared type\n * @param row - the row\n * @returns the value, or undefined for an unset cell\n */\nfunction cellValue(column: Column, d: string, row: number): unknown {\n if (!column.isSet(row)) {\n return undefined;\n }\n const value = column.value(row);\n if (column.meta.dtype === \"json\") {\n return JSON.stringify(value);\n }\n if (column.meta.dtype === \"list\" || column.meta.components > 1) {\n const items = Array.from(value as ArrayLike<unknown>);\n return d === \"string\" ? JSON.stringify(items) : items.map(scalarText);\n }\n return scalarText(value);\n}\n\n/**\n * The text a core field (n, r, i) holds for one row.\n * @param column - the column\n * @param row - the row\n * @returns the text, or undefined for an unset cell\n */\nfunction coreText(column: Column, row: number): string | undefined {\n if (!column.isSet(row)) {\n return undefined;\n }\n const value = column.value(row);\n if (column.meta.dtype === \"json\" || column.meta.dtype === \"list\" || column.meta.components > 1) {\n return JSON.stringify(column.meta.dtype === \"json\" ? value : Array.from(value as ArrayLike<unknown>));\n }\n return scalarText(value);\n}\n\n/** One aspect to write: its name, its elements (produced twice: once to count them) and its idCounter. */\ninterface Aspect {\n readonly name: string;\n readonly elements: () => Iterable<unknown>;\n readonly idCounter?: NodeId | undefined;\n}\n\n/**\n * The written edges: every logical edge but the folded halves of pairs.\n * @param snapshot - the snapshot\n * @param folding - the pair folding\n * @returns the edge indexes\n */\nfunction writtenEdges(snapshot: GraphSnapshot, folding: PairFolding): number[] {\n const out: number[] = [];\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (!folding.folded(e)) {\n out.push(e);\n }\n }\n return out;\n}\n\n/**\n * Build every aspect of the document, in the order Cytoscape and NDEx write them.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param ids - the written node ids\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @returns the aspects (those without elements included; the writer skips them)\n */\nfunction aspects(snapshot: GraphSnapshot, p: Plan, ids: WrittenIds, styled: CytoscapeEmitted | null): Aspect[] {\n const { src, dst } = snapshot.edgeList();\n const edges = writtenEdges(snapshot, p.folding);\n const nodeRange = (): number[] => Array.from({ length: snapshot.nodeCount }, (_, i) => i);\n const nodeCore = (key: \"n\" | \"r\"): Column | null => p.nodeCore.find((c) => c.key === key)?.column ?? null;\n const n = nodeCore(\"n\");\n const r = nodeCore(\"r\");\n const i = p.edgeCore[0]?.column ?? null;\n const kept =\n snapshot.meta.sourceFormat === CX_FORMAT && isRecord(snapshot.meta.extra.cx) ? snapshot.meta.extra.cx : {};\n\n const out: Aspect[] = [\n {\n name: \"nodes\",\n idCounter: nextNodeId(ids, snapshot.nodeCount),\n *elements() {\n for (let row = 0; row < snapshot.nodeCount; row++) {\n const element: Record<string, unknown> = { \"@id\": ids.idAt(row) };\n const name = n === null ? undefined : coreText(n, row);\n const represents = r === null ? undefined : coreText(r, row);\n if (name !== undefined) {\n element.n = name;\n }\n if (represents !== undefined) {\n element.r = represents;\n }\n yield element;\n }\n },\n },\n {\n name: \"edges\",\n idCounter: edges.reduce((max, e) => Math.max(max, p.edgeIds[e] + 1), 0),\n *elements() {\n for (const e of edges) {\n const element: Record<string, unknown> = {\n \"@id\": p.edgeIds[e],\n s: ids.idAt(src[e]),\n t: ids.idAt(dst[e]),\n };\n const interaction = i === null ? undefined : coreText(i, e);\n if (interaction !== undefined) {\n element.i = interaction;\n }\n yield element;\n }\n },\n },\n {\n name: \"nodeAttributes\",\n *elements() {\n for (const a of p.nodeAttrs) {\n for (let row = 0; row < snapshot.nodeCount; row++) {\n const v = cellValue(a.column, a.d, row);\n if (v !== undefined) {\n yield { po: ids.idAt(row), n: a.name, v, d: a.d };\n }\n }\n }\n for (let row = 0; row < snapshot.nodeCount; row++) {\n if (ids.isChanged(row)) {\n yield {\n po: ids.idAt(row),\n n: ORIGINAL_ID_ATTRIBUTE,\n v: String(ids.originalAt(row)),\n d: \"string\",\n };\n }\n }\n },\n },\n {\n name: \"edgeAttributes\",\n *elements() {\n for (const a of p.edgeAttrs) {\n for (const e of edges) {\n const v = cellValue(a.column, a.d, e);\n if (v !== undefined) {\n yield { po: p.edgeIds[e], n: a.name, v, d: a.d };\n }\n }\n }\n if (p.weight !== null) {\n for (const e of edges) {\n const w = p.weight.value(e);\n if (w !== undefined && !Number.isNaN(w)) {\n yield { po: p.edgeIds[e], n: WEIGHT_ATTRIBUTE, v: scalarText(w), d: \"double\" };\n }\n }\n }\n },\n },\n {\n name: \"networkAttributes\",\n *elements() {\n for (const a of p.graphAttrs) {\n const v = cellValue(a.column, a.d, 0);\n if (v !== undefined) {\n yield { n: a.name, v, d: a.d };\n }\n }\n const { meta } = snapshot;\n for (const [key, value] of [\n [\"name\", meta.name],\n [\"description\", meta.description],\n ] as const) {\n if (value !== null && !p.graphAttrs.some((a) => a.name === key)) {\n yield { n: key, v: value, d: \"string\" };\n }\n }\n },\n },\n { name: \"cyTableColumn\", elements: () => tableColumns(p, ids) },\n { name: \"cartesianLayout\", elements: () => layoutElements(p, ids, nodeRange()) },\n { name: \"cyGroups\", elements: () => groupElements(snapshot, p, ids, edges) },\n {\n name: \"cyVisualProperties\",\n elements: () =>\n styled === null\n ? visualProperties(p, ids, nodeRange(), edges, kept)\n : styledVisualProperties(styled, ids, p.edgeIds, edges),\n },\n ];\n const block = snapshotBlock(snapshot);\n if (block !== null) {\n out.push({ name: STYLE_BLOCK_NAME, elements: () => blockAspect(block) });\n }\n out.push(...provenanceAspects(snapshot, p, ids, edges));\n for (const [name, value] of Object.entries(kept)) {\n if (!NEVER_WRITTEN.has(name) && Array.isArray(value)) {\n out.push({ name, elements: () => keptElements(value, kept.subnetwork, STYLE_ASPECTS.has(name)) });\n }\n }\n return out;\n}\n\n/**\n * The cyTableColumn entries: every written column with its type, so a column no element fills is\n * still declared on re-import.\n * @param p - the plan\n * @param ids - the written ids\n * @yields the entries\n */\nfunction* tableColumns(p: Plan, ids: WrittenIds): Generator<unknown, void, undefined> {\n for (const { key, column } of [...p.nodeCore, ...p.edgeCore]) {\n const n = { n: \"name\", r: \"represents\", i: \"interaction\" }[key];\n if (n !== undefined && column !== null) {\n yield { applies_to: key === \"i\" ? \"edge_table\" : \"node_table\", n, d: \"string\" };\n }\n }\n for (const a of p.nodeAttrs) {\n yield { applies_to: \"node_table\", n: a.name, d: a.d };\n }\n if (ids.changed > 0) {\n yield { applies_to: \"node_table\", n: ORIGINAL_ID_ATTRIBUTE, d: \"string\" };\n }\n for (const a of p.edgeAttrs) {\n yield { applies_to: \"edge_table\", n: a.name, d: a.d };\n }\n if (p.weight !== null) {\n yield { applies_to: \"edge_table\", n: WEIGHT_ATTRIBUTE, d: \"double\" };\n }\n for (const a of p.graphAttrs) {\n yield { applies_to: \"network_table\", n: a.name, d: a.d };\n }\n}\n\n/** Kept aspects whose view references are rewritten to the one view of the written file. */\nconst STYLE_ASPECTS: ReadonlySet<string> = new Set([\"tableVisualProperties\", \"cyTableVisualProperties\"]);\n\n/**\n * The elements of a kept aspect: those of the snapshot's own subnetwork (or unscoped), with the\n * scope dropped; style elements get their view references rewritten to view 0.\n * @param elements - the kept elements\n * @param subnetwork - the subnetwork the snapshot was read from, if any\n * @param style - whether the aspect is a style aspect\n * @yields the elements to write\n */\nfunction* keptElements(\n elements: readonly unknown[],\n subnetwork: unknown,\n style: boolean,\n): Generator<unknown, void, undefined> {\n for (const element of elements) {\n if (!isRecord(element)) {\n yield element;\n continue;\n }\n if (element.s !== undefined && element.s !== null && element.s !== subnetwork) {\n continue;\n }\n const { s: _scope, ...rest } = element;\n yield style ? rewriteView(rest) : rest;\n }\n}\n\n/**\n * A style element with its view and subnetwork references rewritten to 0, the written network.\n * @param element - the element\n * @returns the rewritten element\n */\nfunction rewriteView(element: Record<string, unknown>): Record<string, unknown> {\n const out = { ...element };\n if (\"view\" in out) {\n out.view = 0;\n }\n if (typeof out.applies_to === \"number\") {\n out.applies_to = 0;\n }\n return out;\n}\n\n/**\n * The cartesianLayout entries: x / y (y negated back to screen coordinates) and z.\n * @param p - the plan\n * @param ids - the written ids\n * @param rows - every node row\n * @yields the entries\n */\nfunction* layoutElements(p: Plan, ids: WrittenIds, rows: readonly number[]): Generator<unknown, void, undefined> {\n const { position } = p;\n if (position === null) {\n return;\n }\n for (const row of rows) {\n if (!position.isSet(row)) {\n continue;\n }\n const point = position.value(row) as ArrayLike<number>;\n if (!Number.isFinite(point[0]) || !Number.isFinite(point[1])) {\n continue;\n }\n const entry: Record<string, unknown> = { node: ids.idAt(row), x: point[0], y: point[1] === 0 ? 0 : -point[1] };\n if (p.z?.isSet(row) === true) {\n entry.z = p.z.value(row);\n } else if (p.positionZ && Number.isFinite(point[2])) {\n entry.z = point[2];\n }\n yield entry;\n }\n}\n\n/**\n * The cyGroups entries: one per node that has members (or a collapsed flag), its members, and the\n * edges with both ends (internal) or one end (external) among them.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param ids - the written ids\n * @param edges - the written edges\n * @yields the entries\n */\nfunction* groupElements(\n snapshot: GraphSnapshot,\n p: Plan,\n ids: WrittenIds,\n edges: readonly number[],\n): Generator<unknown, void, undefined> {\n const children = childrenCsr(snapshot);\n const groupsOf = new Map<number, number[]>();\n const groups: number[] = [];\n for (let g = 0; g < snapshot.nodeCount; g++) {\n const members = children.childrenOf(g);\n if (members.length > 0 || p.collapsed?.isSet(g) === true) {\n groups.push(g);\n }\n for (const c of members) {\n groupsOf.set(c, [...(groupsOf.get(c) ?? []), g]);\n }\n }\n if (groups.length === 0) {\n return;\n }\n const { internal, external } = groupEdges(snapshot, p, groupsOf, edges);\n const label = p.nodeCore.find((c) => c.key === \"n\")?.column ?? null;\n for (const g of groups) {\n const entry: Record<string, unknown> = { \"@id\": ids.idAt(g) };\n const name = label === null ? undefined : coreText(label, g);\n if (name !== undefined) {\n entry.n = name;\n }\n entry.nodes = Array.from(children.childrenOf(g), (c) => ids.idAt(c));\n entry.internal_edges = internal.get(g) ?? [];\n entry.external_edges = external.get(g) ?? [];\n if (p.collapsed?.isSet(g) === true) {\n entry.collapsed = p.collapsed.value(g);\n }\n yield entry;\n }\n}\n\n/**\n * The written edges of each group: internal (both ends among its members) and external (one end).\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param groupsOf - the groups each member node is in\n * @param edges - the written edges\n * @returns the edge ids by group\n */\nfunction groupEdges(\n snapshot: GraphSnapshot,\n p: Plan,\n groupsOf: ReadonlyMap<number, number[]>,\n edges: readonly number[],\n): { internal: Map<number, number[]>; external: Map<number, number[]> } {\n const internal = new Map<number, number[]>();\n const external = new Map<number, number[]>();\n const add = (table: Map<number, number[]>, g: number, id: number): void => {\n table.set(g, [...(table.get(g) ?? []), id]);\n };\n const { src, dst } = snapshot.edgeList();\n for (const e of edges) {\n const ofSource = groupsOf.get(src[e]) ?? [];\n const ofTarget = groupsOf.get(dst[e]) ?? [];\n for (const g of ofSource) {\n add(ofTarget.includes(g) ? internal : external, g, p.edgeIds[e]);\n }\n for (const g of ofTarget.filter((t) => !ofSource.includes(t))) {\n add(external, g, p.edgeIds[e]);\n }\n }\n return { internal, external };\n}\n\n/**\n * The visual property values of one row: property -> value text.\n * @param columns - the bypass columns\n * @param row - the row\n * @returns the properties, or null when none is set\n */\nfunction bypassValues(columns: readonly Column[], row: number): Record<string, string> | null {\n let out: Record<string, string> | null = null;\n for (const column of columns) {\n if (column.isSet(row)) {\n // the visual property's own name: a column renamed for a clash with an attribute keeps it in origin.id\n const property = column.meta.origin?.id;\n out ??= {};\n out[typeof property === \"string\" && property.length > 0 ? property : column.meta.name] = scalarText(\n column.value(row),\n );\n }\n }\n return out;\n}\n\n/**\n * The cyVisualProperties entries: the network values, the style rules a CX import kept (its own\n * view's, rewritten to view 0) and the per-element values.\n * @param p - the plan\n * @param ids - the written ids\n * @param rows - every node row\n * @param edges - the written edges\n * @param kept - meta.extra.cx of a CX import, else empty\n * @yields the entries\n */\nfunction* visualProperties(\n p: Plan,\n ids: WrittenIds,\n rows: readonly number[],\n edges: readonly number[],\n kept: Record<string, unknown>,\n): Generator<unknown, void, undefined> {\n const network = bypassValues(p.bypass.graph, 0);\n if (network !== null) {\n yield { properties_of: \"network\", properties: network };\n }\n const view = ownView(kept);\n for (const entry of Array.isArray(kept.cyVisualProperties) ? (kept.cyVisualProperties as unknown[]) : []) {\n if (\n isRecord(entry) &&\n ![\"nodes\", \"edges\", \"network\"].includes(String(entry.properties_of)) &&\n (view === null || entry.view === undefined || entry.view === null || entry.view === view)\n ) {\n yield rewriteView(entry);\n }\n }\n for (const row of rows) {\n const properties = bypassValues(p.bypass.node, row);\n if (properties !== null) {\n yield { properties_of: \"nodes\", applies_to: ids.idAt(row), properties };\n }\n }\n for (const e of edges) {\n const properties = bypassValues(p.bypass.edge, e);\n if (properties !== null) {\n yield { properties_of: \"edges\", applies_to: p.edgeIds[e], properties };\n }\n }\n}\n\n/**\n * The cyVisualProperties entries of a styled export: the style's defaults, mappings and dependencies, then every\n * element's bypasses (as text, Cytoscape's form).\n * @param styled - the styles as a Cytoscape style\n * @param ids - the written ids\n * @param edgeIds - the written edge ids\n * @param edges - the written edges\n * @yields the entries\n */\nfunction* styledVisualProperties(\n styled: CytoscapeEmitted,\n ids: WrittenIds,\n edgeIds: readonly number[],\n edges: readonly number[],\n): Generator<unknown, void, undefined> {\n yield* cytoscapeCxAspect(styled.style);\n const text = (m: ReadonlyMap<string, unknown>): Record<string, string> =>\n Object.fromEntries([...m].map(([k, v]) => [k, String(v)]));\n for (let row = 0; row < styled.bypasses.node.length; row++) {\n const m = styled.bypasses.node[row];\n if (m !== null && m.size > 0) {\n yield { properties_of: \"nodes\", applies_to: ids.idAt(row), properties: text(m) };\n }\n }\n for (const e of edges) {\n const m = styled.bypasses.edge[e];\n if (m !== null && m.size > 0) {\n yield { properties_of: \"edges\", applies_to: edgeIds[e], properties: text(m) };\n }\n }\n}\n\n/**\n * The view of the subnetwork a CX import read (the one its style rules belong to).\n * @param kept - meta.extra.cx\n * @returns the view id, or null when the file named none\n */\nfunction ownView(kept: Record<string, unknown>): unknown {\n const sub = kept.subnetwork;\n for (const r of Array.isArray(kept.cyNetworkRelations) ? (kept.cyNetworkRelations as unknown[]) : []) {\n if (isRecord(r) && r.r === \"view\" && (sub === undefined || r.p === sub)) {\n return r.c;\n }\n }\n for (const v of Array.isArray(kept.cyViews) ? (kept.cyViews as unknown[]) : []) {\n if (isRecord(v) && (sub === undefined || v.s === sub)) {\n return v[\"@id\"];\n }\n }\n return null;\n}\n\n/**\n * The provenance aspects a CX import turned into extension tables and columns, written back:\n * citations, supports, their node / edge links, functionTerms and reifiedEdges.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param ids - the written ids\n * @param edges - the written edges\n * @returns the aspects\n */\nfunction provenanceAspects(snapshot: GraphSnapshot, p: Plan, ids: WrittenIds, edges: readonly number[]): Aspect[] {\n const out: Aspect[] = [];\n for (const [table, aspect] of Object.entries(PROVENANCE_TABLES)) {\n const ext = snapshot.extensions.get(table);\n if (ext === undefined) {\n continue;\n }\n const idColumn = ext.get(\"id\");\n const fields = [...ext].filter((c) => c !== idColumn);\n let max = -1;\n for (let row = 0; row < ext.rowCount; row++) {\n if (idColumn?.isSet(row) === true) {\n max = Math.max(max, Number(idColumn.value(row)));\n }\n }\n out.push({\n name: aspect,\n idCounter: max + 1,\n *elements() {\n for (let row = 0; row < ext.rowCount; row++) {\n const element: Record<string, unknown> = {};\n if (idColumn?.isSet(row) === true) {\n element[\"@id\"] = idColumn.value(row);\n }\n for (const field of fields) {\n if (field.isSet(row)) {\n element[field.meta.name] = field.value(row);\n }\n }\n yield element;\n }\n },\n });\n }\n for (const link of p.links) {\n out.push({\n name: link.aspect,\n *elements() {\n const rows = link.domain === \"node\" ? Array.from({ length: snapshot.nodeCount }, (_, i) => i) : edges;\n for (const row of rows) {\n if (link.column.isSet(row)) {\n const po = link.domain === \"node\" ? ids.idAt(row) : p.edgeIds[row];\n yield { po: [po], [link.key]: Array.from(link.column.value(row) as ArrayLike<unknown>) };\n }\n }\n },\n });\n }\n const terms = p.functionTerm;\n if (terms !== null) {\n out.push({\n name: \"functionTerms\",\n *elements() {\n for (let row = 0; row < snapshot.nodeCount; row++) {\n const term = terms.isSet(row) ? terms.value(row) : null;\n if (isRecord(term)) {\n yield { po: ids.idAt(row), ...term };\n }\n }\n },\n });\n }\n const reified = p.reifiedEdge;\n if (reified !== null) {\n out.push({\n name: \"reifiedEdges\",\n *elements() {\n for (let row = 0; row < snapshot.nodeCount; row++) {\n const edge = reified.isSet(row) ? (reified.value(row) as number) : -1;\n if (edge >= 0 && edge < snapshot.edgeCount) {\n yield { node: ids.idAt(row), edge: p.edgeIds[edge] };\n }\n }\n },\n });\n }\n return out;\n}\n\n/**\n * Write the document as text parts.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @yields the document's text\n * @returns nothing\n */\nfunction* write(\n snapshot: GraphSnapshot,\n p: Plan,\n styled: CytoscapeEmitted | null = null,\n): Generator<string, void, undefined> {\n if (p.fatal !== null) {\n throw p.fatal;\n }\n const { ids } = p;\n if (ids === null) {\n throw new GraphFormatError(\"E_INVALID_ID\", \"node ids cannot be written as CX integers\", { reason: \"charset\" });\n }\n const all = aspects(snapshot, p, ids, styled);\n const written: { aspect: Aspect; count: number }[] = [];\n for (const aspect of all) {\n let count = 0;\n for (const _ of aspect.elements()) {\n count++;\n }\n if (count > 0 || aspect.name === \"nodes\") {\n written.push({ aspect, count });\n }\n }\n const metaData = written.map(({ aspect, count }) => ({\n name: aspect.name,\n version: \"1.0\",\n ...(aspect.idCounter === undefined ? {} : { idCounter: aspect.idCounter }),\n elementCount: count,\n consistencyGroup: 1,\n }));\n yield '[{\"numberVerification\":[{\"longNumber\":281474976710655}]},\\n';\n yield `{\"metaData\":${stringify(metaData)}},\\n`;\n for (const { aspect } of written) {\n yield* aspectBlock(aspect.name, mapIterable(aspect.elements(), stringify));\n }\n yield '{\"status\":[{\"error\":\"\",\"success\":true}]}]\\n';\n}\n\n/**\n * Map an iterable lazily.\n * @param items - the items\n * @param fn - the mapping\n * @yields the mapped items\n */\nfunction* mapIterable<T, U>(items: Iterable<T>, fn: (item: T) => U): Generator<U, void, undefined> {\n for (const item of items) {\n yield fn(item);\n }\n}\n\n/**\n * The CX version 1 exporter plugin.\n * @category Built-in formats\n */\nexport const cxExporter: GraphExporter<CxExportOptions> = Object.freeze({\n format: CX_FORMAT,\n options: Object.freeze([]),\n capabilities: CX_CAPABILITIES,\n styles: Object.freeze({ capabilities: CX_STYLE_CAPABILITIES }),\n\n /**\n * Pre-flight: what export() would lose, without writing anything.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the notes, empty when the export is exact\n */\n check(snapshot: GraphSnapshot, options?: CxExportOptions & ExporterStyleOptions): readonly LossNote[] {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"desktop\");\n return Object.freeze([\n ...plan(styled?.snapshot ?? snapshot, resolveExportOptions(options)).notes,\n ...(styled?.notes ?? []),\n ]);\n },\n\n /**\n * Write the document as UTF-8 chunks.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the chunks\n */\n export(snapshot: GraphSnapshot, options?: CxExportOptions & ExporterStyleOptions): AsyncIterable<Uint8Array> {\n return encodeChunks(written(snapshot, options));\n },\n\n /**\n * Write the document as one string.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the document\n */\n exportToString(snapshot: GraphSnapshot, options?: CxExportOptions & ExporterStyleOptions): Promise<string> {\n return joinText(written(snapshot, options));\n },\n});\n\n/**\n * The document's text, with the styles when they are given.\n * @param snapshot - the snapshot\n * @param options - the options\n * @returns the text parts\n */\nfunction written(\n snapshot: GraphSnapshot,\n options: (CxExportOptions & ExporterStyleOptions) | undefined,\n): Generator<string, void, undefined> {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"desktop\");\n const target = styled?.snapshot ?? snapshot;\n return write(target, plan(target, resolveExportOptions(options)), styled?.styled ?? null);\n}\n"],"names":["plan","i","written"],"mappings":";;;;;;;;;;;AA0DA,MAAM,YAAY;AAaX,MAAM,UAAU,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKjC,wBAAwB;AAAA;AAAA,EAExB,gBAAgB;AAAA;AAAA,EAEhB,iBAAiB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,cAAc,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,cAAc,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,mBAAmB,KAAK;AAAA;AAAA,EAExB,sBAAsB,KAAK;AAAA;AAAA,EAE3B,iBAAiB,KAAK;AAAA;AAAA,EAEtB,iBAAiB,KAAK;AAAA;A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O,EAAE;AAAA,EACzB,cAAc;AAAA,EACd,QAAQ,OAAO,OAAO,EAAE,cAAc,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7D,MAAM,UAAyB,SAAuE;AAClG,UAAM,SAAS,sBAAsB,UAAU,SAAS,QAAQ,SAAS;AACzE,WAAO,OAAO,OAAO;AAAA,MACjB,GAAG,KAAK,QAAQ,YAAY,UAAU,qBAAqB,OAAO,CAAC,EAAE;AAAA,MACrE,GAAI,QAAQ,SAAS,CAAA;AAAA,IAAC,CACzB;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,UAAyB,SAA6E;AACzG,WAAO,aAAa,QAAQ,UAAU,OAAO,CAAC;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,UAAyB,SAAmE;AACvG,WAAO,SAAS,QAAQ,UAAU,OAAO,CAAC;AAAA,EAC9C;AACJ,CAAC;AAQD,SAAS,QACL,UACA,SACkC;AAClC,QAAM,SAAS,sBAAsB,UAAU,SAAS,QAAQ,SAAS;AACzE,QAAM,SAAS,QAAQ,YAAY;AACnC,SAAO,MAAM,QAAQ,KAAK,QAAQ,qBAAqB,OAAO,CAAC,GAAG,QAAQ,UAAU,IAAI;AAC5F;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { GraphFormatError } from "@graphty/graph-format";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { d as directionNotes, p as planNodeIds, a as planEdgeIds, s as stringify, c as declaredType, f as nonFinitePositions, b as aspectBlock } from "./cx-export-Bt6NoqTQ.js";
|
|
3
|
+
import { p as pairFolding } from "./format-BXiAb-1h.js";
|
|
4
|
+
import { c as capabilities, L as LOSS, r as resolveExportOptions, e as explicitWeights, a as checkCapabilities } from "./export-Cha4dRFz.js";
|
|
5
|
+
import { i as isRecord, P as POSITION_COLUMN } from "./json-elements-Cq76WjnZ.js";
|
|
6
|
+
import { p as plural } from "./report-CwMfYa9J.js";
|
|
6
7
|
import { j as joinText, e as encodeChunks } from "./writer-DxjgHwSe.js";
|
|
7
|
-
import { c as cytoscapeStyledExport,
|
|
8
|
-
import { S as STYLE_BLOCK_NAME } from "./block-
|
|
8
|
+
import { c as cytoscapeStyledExport, e as cytoscapeCx2Aspects, s as snapshotBlock, b as blockAspect } from "./styles-CCs214_3.js";
|
|
9
|
+
import { S as STYLE_BLOCK_NAME } from "./block-iptrlMBb.js";
|
|
10
|
+
import { a as CX2_FORMAT, b as CX2_STYLE_CAPABILITIES, O as ORIGINAL_ID_ATTRIBUTE, B as BYPASS_NAMESPACE, d as cx2Type } from "./importer-B92x1xY5.js";
|
|
9
11
|
const CX2_LOSS = Object.freeze({
|
|
10
12
|
/**
|
|
11
13
|
* Every edge is written as directed, so an undirected graph, or the undirected edges of a mixed graph, read back
|
|
@@ -625,4 +627,4 @@ export {
|
|
|
625
627
|
CX2_LOSS as a,
|
|
626
628
|
cx2Exporter as c
|
|
627
629
|
};
|
|
628
|
-
//# sourceMappingURL=exporter-
|
|
630
|
+
//# sourceMappingURL=exporter-nDfxIK5D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter-CJgfhF-l.js","sources":["../../src/formats/cx2/exporter.ts"],"sourcesContent":["/**\n * The CX2 exporter (design/graph-io/cytoscape-and-obo/design.md section 1.3; graphty issue #307):\n * writes a snapshot as one CX2 document -- the descriptor, the pre-metadata, one\n * `attributeDeclarations` block (aliases from `origin.id`, defaults from `meta.default`),\n * `networkAttributes`, `nodes` (x / y from the position with y flipped back to screen coordinates,\n * `z` from the `z` column), `edges`, the `cx2.bypass` columns as `nodeBypasses` / `edgeBypasses`,\n * the opaque aspects a CX2 import kept (which returns its own style rules) and `status`.\n *\n * Given styles (`exportGraph(..., { styles })`), `visualProperties` and `visualEditorProperties` are the\n * Cytoscape style of the rules (defaults and mappings), the bypasses are every element whose value the style\n * cannot give, and the style values the rules read are attributes; the `graphty.styles` block, which graph-io\n * hands over as a graph attribute, is written as an aspect of its own (a kept one is written back the same way).\n *\n * What CX2 cannot hold is announced by check() before anything is written: every edge is\n * directed (W_CX2_UNDIRECTED_AS_DIRECTED, W_MUTUAL_EXPANDED), node ids are integers (E_ID_CHARSET\n * unless `sanitizeIds: \"mangle\"`, which keeps the original in the `graphty:originalId` attribute\n * the importer restores), nested values are written as JSON text (W_CX2_JSON_AS_STRING), NaN and\n * the infinities as null (W_CX2_NONFINITE_AS_NULL), and the generic notes of checkCapabilities().\n */\n\nimport { type Column, GraphFormatError, type GraphSnapshot } from \"@graphty/graph-format\";\n\nimport {\n aspectBlock,\n declaredType,\n directionNotes,\n nonFinitePositions,\n planEdgeIds,\n planNodeIds,\n stringify,\n type WrittenIds,\n} from \"../../common/cx-export.js\";\nimport { type PairFolding, pairFolding } from \"../../common/direction.js\";\nimport { capabilities, checkCapabilities, LOSS } from \"../../common/export.js\";\nimport { isRecord, POSITION_COLUMN } from \"../../common/json-elements.js\";\nimport { type ResolvedExportOptions, resolveExportOptions } from \"../../common/options.js\";\nimport { plural } from \"../../common/plural.js\";\nimport { type ExplicitWeights, explicitWeights } from \"../../common/weights.js\";\nimport { encodeChunks, joinText } from \"../../common/writer.js\";\nimport { cytoscapeCx2Aspects, type CytoscapeEmitted } from \"../../styles/cytoscape/emit.js\";\nimport { STYLE_BLOCK_NAME } from \"../../styles/io/block.js\";\nimport type { ExporterStyleOptions } from \"../../styles/io/writer.js\";\nimport { type CommonExportOptions, type ExportCapabilities, type GraphExporter, type LossNote } from \"../../types.js\";\nimport { blockAspect, cytoscapeStyledExport, snapshotBlock } from \"../cx/styles.js\";\nimport { BYPASS_NAMESPACE, CX2_FORMAT, cx2Type, ORIGINAL_ID_ATTRIBUTE } from \"./importer.js\";\nimport { CX2_STYLE_CAPABILITIES } from \"./styles.js\";\n\n/**\n * The options of the CX2 exporter: the common export options; it has none of its own.\n * @category Built-in formats\n */\nexport type Cx2ExportOptions = CommonExportOptions;\n\n/**\n * The loss notes the CX2 exporter's check() returns, by name. A key is the\n * code without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const CX2_LOSS = Object.freeze({\n /**\n * Every edge is written as directed, so an undirected graph, or the undirected edges of a mixed graph, read back\n * as directed.\n */\n UNDIRECTED_AS_DIRECTED: \"W_CX2_UNDIRECTED_AS_DIRECTED\",\n /** A nested (json) column is written as a string attribute holding its JSON text. */\n JSON_AS_STRING: \"W_CX2_JSON_AS_STRING\",\n /** NaN and the infinities cannot be written; they are written as null and read back unset. */\n NONFINITE_AS_NULL: \"W_CX2_NONFINITE_AS_NULL\",\n /** A mutual pair is written as two directed edges without its mark. */\n MUTUAL_EXPANDED: LOSS.MUTUAL_EXPANDED,\n /**\n * An attribute without the weight role is named like the key weights are written under; it reads back as the edge\n * weight, or is not written when the graph has weights of its own.\n */\n WEIGHT_KEY_CLASH: LOSS.WEIGHT_KEY_CLASH,\n /** A parent / parents column: CX2 has no containment. */\n HIERARCHY_DROPPED: LOSS.HIERARCHY,\n /** A start / end / timestamp column: CX2 has no time. */\n TEMPORAL_DROPPED: LOSS.TEMPORAL,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: LOSS.ROLE,\n /**\n * An attribute type CX2 stores as another (a 32-bit float as double, an unsigned integer as long, a dictionary as\n * string); it reads back with that type.\n */\n DTYPE_UNSUPPORTED: LOSS.DTYPE,\n /**\n * Node ids the format cannot write, under `sanitizeIds: \"error\"`; the save fails with E_INVALID_ID. Pass\n * `sanitizeIds: \"mangle\"` to rewrite them.\n */\n ID_CHARSET: LOSS.ID_CHARSET,\n /** Node ids that are not integers under sanitizeIds \"mangle\": renumbered, originals kept. */\n ID_MANGLED: LOSS.ID_MANGLED,\n /** Edges without a usable id get generated integer ids. */\n EDGE_IDS_GENERATED: LOSS.EDGE_IDS_GENERATED,\n});\n\n/**\n * What CX2 keeps: directed multigraphs with self-loops, integer node ids,\n * required integer edge ids, declared string / double / integer / boolean columns and lists of\n * them, declared defaults, network attributes and the position role. f32, u32, u8 and dict columns\n * are written as the nearest declared type and read back as it.\n * @category Built-in formats\n */\nexport const CX2_CAPABILITIES: ExportCapabilities = capabilities({\n mixedDirection: false,\n multiEdges: true,\n selfLoops: true,\n edgeIds: \"required\",\n idCharset: \"integer\",\n dtypes: [\"string\", \"f64\", \"i32\", \"bool\"],\n components: false,\n lists: true,\n json: false,\n defaults: true,\n options: false,\n hierarchy: false,\n temporal: \"none\",\n graphAttributes: true,\n positions: true,\n viz: false,\n});\n\n/** The roles CX2 has a slot for, and the column names its importer gives them. */\nconst SLOT_ROLES: ReadonlySet<string> = new Set([\"label\", \"position\", \"id\"]);\nconst ROLE_NAMES: Readonly<Record<string, string>> = Object.freeze({\n label: \"name\",\n position: POSITION_COLUMN,\n});\n\n/** Roles whose columns are never written as attributes. */\nconst SKIPPED_ROLES: ReadonlySet<string> = new Set([\n \"directed\",\n \"pair\",\n \"mutual\",\n \"weight\",\n \"timeText\",\n \"originalId\",\n \"parent\",\n \"parents\",\n \"start\",\n \"end\",\n \"timestamp\",\n \"timestamps\",\n \"spells\",\n \"open\",\n \"spellsOpen\",\n \"position\",\n \"color\",\n \"size\",\n \"shape\",\n \"thickness\",\n]);\n\n/** The style aspects; written from the styles when styles are given, else the kept ones. */\nconst STYLE_ASPECTS: ReadonlySet<string> = new Set([\"visualProperties\", \"visualEditorProperties\"]);\n\n/** The aspects the exporter writes itself; an opaque aspect of the same name is not written again. */\nconst CORE_ASPECTS: ReadonlySet<string> = new Set([\n STYLE_BLOCK_NAME,\n \"nodes\",\n \"edges\",\n \"attributeDeclarations\",\n \"networkAttributes\",\n \"nodeBypasses\",\n \"edgeBypasses\",\n \"metaData\",\n \"status\",\n]);\n\n/** The weight attribute name. */\nconst WEIGHT_ATTRIBUTE = \"weight\";\n\n/** One attribute column as it will be written. */\ninterface AttributePlan {\n readonly column: Column;\n /** The full attribute name. */\n readonly name: string;\n /** The key used in v (the alias, or the name). */\n readonly key: string;\n /** The declared type text. */\n readonly d: string;\n /** Whether values are written as their JSON text (a json column). */\n readonly jsonText: boolean;\n}\n\n/** Everything export() and check() need, computed once. */\ninterface Plan {\n readonly notes: LossNote[];\n readonly fatal: GraphFormatError | null;\n readonly ids: WrittenIds | null;\n readonly folding: PairFolding;\n readonly weights: ExplicitWeights;\n readonly nodeAttrs: readonly AttributePlan[];\n readonly edgeAttrs: readonly AttributePlan[];\n readonly graphAttrs: readonly AttributePlan[];\n readonly nodeBypasses: readonly Column[];\n readonly edgeBypasses: readonly Column[];\n readonly position: Column | null;\n readonly positionZ: boolean;\n readonly z: Column | null;\n readonly edgeIds: readonly number[];\n readonly originalIds: boolean;\n}\n\n/**\n * Whether a column is a bypass column of a CX2 import.\n * @param column - the column\n * @returns true for the cx2.bypass namespace\n */\nfunction isBypass(column: Column): boolean {\n return column.meta.origin?.namespace === BYPASS_NAMESPACE;\n}\n\n/**\n * Whether a column is the z (stacking order) column.\n * @param column - the column\n * @returns true for the column marked by a Cytoscape-family importer\n */\nfunction isZ(column: Column): boolean {\n return column.meta.extra.cytoscape === \"z\";\n}\n\n/**\n * Count the non-finite numbers of a column.\n * @param column - the column\n * @returns how many set cells (or list items) are NaN or infinite\n */\nfunction nonFiniteCount(column: Column): number {\n const { dtype, itemDtype } = column.meta;\n const numeric =\n dtype === \"f32\" || dtype === \"f64\" || (dtype === \"list\" && (itemDtype === \"f32\" || itemDtype === \"f64\"));\n if (!numeric) {\n return 0;\n }\n let count = 0;\n for (let i = 0; i < column.length; i++) {\n if (!column.isSet(i)) {\n continue;\n }\n const value = column.value(i);\n if (dtype === \"list\") {\n if ((value as readonly number[]).some((v) => !Number.isFinite(v))) {\n count++;\n }\n } else if (!Number.isFinite(value)) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Plan the attribute columns of one table.\n * @param table - the table\n * @param skip - columns not written as attributes\n * @param rename - the written name of a column, when it differs (the label as `name`)\n * @param reserved - keys already used in v\n * @returns the plans\n */\nfunction planAttributes(\n table: Iterable<Column>,\n skip: (column: Column) => boolean,\n rename: (column: Column) => string,\n reserved: ReadonlySet<string> = new Set(),\n): AttributePlan[] {\n const plans: AttributePlan[] = [];\n const used = new Set<string>(reserved);\n const candidates = [...table].filter((c) => !skip(c));\n for (const column of candidates) {\n used.add(rename(column));\n }\n for (const column of candidates) {\n const name = rename(column);\n const { origin } = column.meta;\n let key = name;\n const alias = origin?.format === CX2_FORMAT && typeof origin.id === \"string\" ? origin.id : null;\n if (alias !== null && alias.length > 0 && alias !== name && !used.has(alias)) {\n key = alias;\n used.add(alias);\n }\n plans.push({ column, name, key, d: declaredType(column), jsonText: column.meta.dtype === \"json\" });\n }\n return plans;\n}\n\n/** A note-recording callback. */\ntype Note = (code: string, message: string, column?: string | null, count?: number | null) => void;\n\n/**\n * The generic notes of checkCapabilities(), adapted to CX2: bypass columns hold any JSON value,\n * ids are counted by planNodeIds(), nested values are written as JSON text, and only the node\n * label is written into the \"n\" slot (an edge label keeps its own name but loses its role).\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @param notes - the notes so far, appended to\n * @param note - the recorder\n * @returns the fatal condition, or null\n */\nfunction capabilityNotes(\n snapshot: GraphSnapshot,\n common: ResolvedExportOptions,\n notes: LossNote[],\n note: Note,\n): GraphFormatError | null {\n let fatal: GraphFormatError | null = null;\n // bypass columns are written as bypasses, which hold any JSON value\n const bypassNames = new Set(\n [...snapshot.nodes, ...snapshot.edges].filter((c) => isBypass(c) || isZ(c)).map((c) => c.meta.name),\n );\n for (const gen of checkCapabilities(snapshot, CX2_CAPABILITIES, common, {\n roles: SLOT_ROLES,\n roleNames: ROLE_NAMES,\n // only the node label is written into the \"n\" slot; an edge label keeps its own name\n edgeRoleNames: {},\n })) {\n if (!keepGenericNote(gen, bypassNames)) {\n continue;\n }\n if (gen.code === LOSS.JSON) {\n const what = gen.column === null ? \"a column\" : `column \"${gen.column}\"`;\n note(\n CX2_LOSS.JSON_AS_STRING,\n `${what} holds nested values; written as a string attribute holding their JSON text`,\n gen.column,\n gen.count,\n );\n continue;\n }\n if (gen.code === LOSS.MIXED_DIRECTION_ERROR && fatal === null) {\n fatal = new GraphFormatError(\"E_DIRECTED\", gen.message, { reason: \"mixed direction\" });\n }\n notes.push(gen);\n }\n const edgeLabel = snapshot.edges.byRole(\"label\");\n if (edgeLabel !== null) {\n note(\n LOSS.ROLE,\n `edge column \"${edgeLabel.meta.name}\" (label) is written as a plain attribute; CX2 edges have no label slot and the role is lost`,\n edgeLabel.meta.name,\n edgeLabel.length - edgeLabel.nullCount,\n );\n }\n return fatal;\n}\n\n/**\n * Whether a generic note applies to CX2 as it stands.\n * @param gen - the generic note\n * @param bypassNames - the names of the columns written as bypasses\n * @returns false for a note CX2 drops or replaces\n */\nfunction keepGenericNote(gen: LossNote, bypassNames: ReadonlySet<string>): boolean {\n if (gen.column !== null && bypassNames.has(gen.column) && (gen.code === LOSS.JSON || gen.code === LOSS.DTYPE)) {\n return false;\n }\n // ids are counted by planNodeIds(): CX2 also keeps integer ids beyond 2^53, which the generic rule refuses\n return gen.code !== LOSS.ID_CHARSET && gen.code !== LOSS.ID_MANGLED;\n}\n\n/**\n * Note the NaN and infinite values written as null: attribute cells, explicit weights, positions.\n * @param snapshot - the snapshot\n * @param attrs - every planned attribute\n * @param weights - the explicit weights\n * @param position - the position column, or null\n * @param note - the recorder\n */\nfunction nonFiniteNote(\n snapshot: GraphSnapshot,\n attrs: readonly AttributePlan[],\n weights: ExplicitWeights,\n position: Column | null,\n note: Note,\n): void {\n let nonfinite = 0;\n for (const p of attrs) {\n nonfinite += nonFiniteCount(p.column);\n }\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (weights.isExplicit(e) && !Number.isFinite(weights.value(e))) {\n nonfinite++;\n }\n }\n if (position !== null) {\n nonfinite += nonFinitePositions(position);\n }\n if (nonfinite > 0) {\n note(\n CX2_LOSS.NONFINITE_AS_NULL,\n `${nonfinite} NaN or infinite value${plural(nonfinite)} cannot be written in CX2; written as null, they read back unset`,\n null,\n nonfinite,\n );\n }\n}\n\n/**\n * Plan the edge attributes, noting a plain `weight` column that clashes with the weight key.\n * @param snapshot - the snapshot\n * @param weights - the explicit weights\n * @param note - the recorder\n * @returns the edge attribute plans\n */\nfunction planEdgeAttributes(snapshot: GraphSnapshot, weights: ExplicitWeights, note: Note): AttributePlan[] {\n const plainWeight = snapshot.edges.get(WEIGHT_ATTRIBUTE);\n if (plainWeight !== null && plainWeight.meta.role === null) {\n note(\n LOSS.WEIGHT_KEY_CLASH,\n weights.weighted\n ? `edge column \"${WEIGHT_ATTRIBUTE}\" is not written: the explicit weights are written under that name`\n : `edge column \"${WEIGHT_ATTRIBUTE}\" reads back as the edge weight`,\n WEIGHT_ATTRIBUTE,\n null,\n );\n }\n return planAttributes(\n snapshot.edges,\n (c) =>\n (c.meta.role !== null && (SKIPPED_ROLES.has(c.meta.role) || c.meta.role === \"id\")) ||\n isBypass(c) ||\n (weights.weighted && c === plainWeight),\n (c) => c.meta.name,\n weights.weighted ? new Set([WEIGHT_ATTRIBUTE]) : new Set(),\n );\n}\n\n/**\n * Plan an export: the notes, the fatal condition and what is written.\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @returns the plan\n */\nfunction plan(snapshot: GraphSnapshot, common: ResolvedExportOptions): Plan {\n const notes: LossNote[] = [];\n const note: Note = (code, message, column = null, count = null) => {\n notes.push(Object.freeze({ code, message, column, count }));\n };\n let fatal = capabilityNotes(snapshot, common, notes, note);\n\n const folding = pairFolding(snapshot);\n directionNotes(snapshot, folding, common, CX2_LOSS.UNDIRECTED_AS_DIRECTED, note);\n\n const planned = planNodeIds(snapshot, common, \"CX2\", ORIGINAL_ID_ATTRIBUTE, note);\n const ids = planned instanceof GraphFormatError ? null : planned;\n if (planned instanceof GraphFormatError) {\n fatal ??= planned;\n }\n\n const weights = explicitWeights(snapshot);\n const label = snapshot.nodes.byRole(\"label\");\n const nodeAttrs = planAttributes(\n snapshot.nodes,\n (c) => (c.meta.role !== null && SKIPPED_ROLES.has(c.meta.role)) || isBypass(c) || isZ(c),\n (c) => (c === label && !snapshot.nodes.has(\"name\") ? \"name\" : c.meta.name),\n ids !== null && ids.changed > 0 ? new Set([ORIGINAL_ID_ATTRIBUTE]) : new Set(),\n );\n const edgeAttrs = planEdgeAttributes(snapshot, weights, note);\n const graphAttrs = planAttributes(\n snapshot.graph,\n // the graphty.styles block is an aspect of its own\n (c) => c.meta.name === STYLE_BLOCK_NAME,\n (c) => c.meta.name,\n ).map((p) => ({ ...p, key: p.name }));\n\n const position = snapshot.nodes.byRole(\"position\");\n nonFiniteNote(snapshot, [...nodeAttrs, ...edgeAttrs, ...graphAttrs], weights, position, note);\n\n const edgeIds = planEdgeIds(snapshot, note, ids);\n const z = [...snapshot.nodes].find(isZ) ?? null;\n const positionZ = position !== null && z === null && position.meta.extra.sourceDims === 3;\n return {\n notes,\n fatal,\n ids,\n folding,\n weights,\n nodeAttrs,\n edgeAttrs,\n graphAttrs,\n nodeBypasses: [...snapshot.nodes].filter(isBypass),\n edgeBypasses: [...snapshot.edges].filter(isBypass),\n position,\n positionZ,\n z,\n edgeIds,\n originalIds: ids !== null && ids.changed > 0,\n };\n}\n\n// ============================================================ writing\n\n/**\n * The value written for one cell.\n * @param p - the attribute plan\n * @param row - the row\n * @returns the value, or undefined for an unset cell\n */\nfunction cellValue(p: AttributePlan, row: number): unknown {\n const { column } = p;\n if (!column.isSet(row)) {\n return undefined;\n }\n const value = column.value(row);\n if (p.jsonText) {\n return JSON.stringify(value);\n }\n if (column.meta.dtype === \"list\" || column.meta.components > 1) {\n const items = Array.from(value as ArrayLike<unknown>);\n if (p.d === \"string\") {\n return JSON.stringify(items);\n }\n return items.some((v) => typeof v === \"number\" && !Number.isFinite(v)) ? null : items;\n }\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n return null;\n }\n return value;\n}\n\n/**\n * The declarations of one table.\n * @param plans - the attribute plans\n * @param defaults - whether defaults and aliases may be written (not for network attributes)\n * @returns the declaration object\n */\nfunction declarations(plans: readonly AttributePlan[], defaults: boolean): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const p of plans) {\n const decl: Record<string, unknown> = { d: p.d };\n if (defaults && p.key !== p.name) {\n decl.a = p.key;\n }\n const fallback = p.column.meta.default;\n if (defaults && fallback !== undefined && fallback !== null) {\n if (defaultFits(cx2Type(p.d), fallback)) {\n decl.v = fallback;\n }\n }\n out[p.name] = decl;\n }\n return out;\n}\n\n/**\n * Whether a declared default can be written as the value of a declared type.\n * @param type - the type\n * @param fallback - the default\n * @returns true when it matches\n */\nfunction defaultFits(type: ReturnType<typeof cx2Type>, fallback: unknown): boolean {\n if (type === null) {\n return false;\n }\n if (type.list) {\n return Array.isArray(fallback);\n }\n switch (type.scalar) {\n case \"string\":\n return typeof fallback === \"string\";\n case \"boolean\":\n return typeof fallback === \"boolean\";\n default:\n return typeof fallback === \"number\" && Number.isFinite(fallback);\n }\n}\n\n/**\n * The v object of one element.\n * @param plans - the attribute plans\n * @param row - the row\n * @returns the object, or null when empty\n */\nfunction attributesOf(plans: readonly AttributePlan[], row: number): Record<string, unknown> | null {\n let out: Record<string, unknown> | null = null;\n for (const p of plans) {\n const value = cellValue(p, row);\n if (value !== undefined) {\n out ??= {};\n out[p.key] = value;\n }\n }\n return out;\n}\n\n/**\n * The networkAttributes element and its declarations: the graph attributes, then the snapshot's name and\n * description where no attribute of that name is written.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @returns the element and the declarations\n */\nfunction networkOf(\n snapshot: GraphSnapshot,\n p: Plan,\n): { network: Record<string, unknown>; networkDecls: Record<string, unknown> } {\n const networkDecls = declarations(p.graphAttrs, false);\n const network: Record<string, unknown> = {};\n for (const a of p.graphAttrs) {\n const value = cellValue(a, 0);\n if (value !== undefined) {\n network[a.name] = value;\n }\n }\n const { meta } = snapshot;\n for (const [key, value] of [\n [\"name\", meta.name],\n [\"description\", meta.description],\n ] as const) {\n if (value !== null && !(key in network) && !(key in networkDecls)) {\n network[key] = value;\n networkDecls[key] = { d: \"string\" };\n }\n }\n return { network, networkDecls };\n}\n\n/**\n * The attributeDeclarations element: the kept declarations of other tables, then the network's, the nodes' and the\n * edges' where there are any.\n * @param p - the plan\n * @param kept - what an import kept in meta.extra.cx2\n * @param networkDecls - the network's declarations\n * @returns the element\n */\nfunction declarationsElementOf(\n p: Plan,\n kept: Record<string, unknown>,\n networkDecls: Record<string, unknown>,\n): Record<string, unknown> {\n const nodeDecls = declarations(p.nodeAttrs, true);\n if (p.originalIds) {\n nodeDecls[ORIGINAL_ID_ATTRIBUTE] = { d: \"string\" };\n }\n const edgeDecls = declarations(p.edgeAttrs, true);\n if (p.weights.weighted) {\n edgeDecls[WEIGHT_ATTRIBUTE] = { d: \"double\" };\n }\n const otherDecls = isRecord(kept.declarations) ? kept.declarations : {};\n const element: Record<string, unknown> = { ...otherDecls };\n for (const [key, table] of [\n [\"networkAttributes\", networkDecls],\n [\"nodes\", nodeDecls],\n [\"edges\", edgeDecls],\n ] as const) {\n if (Object.keys(table).length > 0) {\n element[key] = table;\n }\n }\n return element;\n}\n\n/**\n * One edge element.\n * @param p - the plan\n * @param ids - the written node ids\n * @param src - the source of each edge\n * @param dst - the target of each edge\n * @param e - the edge\n * @returns the element\n */\nfunction edgeElement(\n p: Plan,\n ids: WrittenIds,\n src: ArrayLike<number>,\n dst: ArrayLike<number>,\n e: number,\n): Record<string, unknown> {\n const element: Record<string, unknown> = {\n id: p.edgeIds[e],\n s: ids.idAt(src[e]),\n t: ids.idAt(dst[e]),\n };\n let v = attributesOf(p.edgeAttrs, e);\n if (p.weights.isExplicit(e)) {\n const w = p.weights.value(e);\n v ??= {};\n v[WEIGHT_ATTRIBUTE] = Number.isFinite(w) ? w : null;\n }\n if (v !== null) {\n element.v = v;\n }\n return element;\n}\n\n/**\n * The optional aspects of a document that are written: those with elements.\n * @param aspects - each aspect's name and element count\n * @returns the metaData counts\n */\nfunction presentAspects(aspects: readonly (readonly [string, number])[]): [string, number][] {\n return aspects.filter(([, n]) => n > 0).map(([name, n]) => [name, n]);\n}\n\n/**\n * Write the document as text parts.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @yields the document's text\n * @returns nothing\n */\nfunction* write(\n snapshot: GraphSnapshot,\n p: Plan,\n styled: CytoscapeEmitted | null = null,\n): Generator<string, void, undefined> {\n if (p.fatal !== null) {\n throw p.fatal;\n }\n const { ids } = p;\n if (ids === null) {\n throw new GraphFormatError(\"E_INVALID_ID\", \"node ids cannot be written as CX2 integers\", { reason: \"charset\" });\n }\n const edges: number[] = [];\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (!p.folding.folded(e)) {\n edges.push(e);\n }\n }\n const { network, networkDecls } = networkOf(snapshot, p);\n const { meta } = snapshot;\n const kept = isRecord(meta.extra.cx2) ? meta.extra.cx2 : {};\n const opaque = meta.sourceFormat === CX2_FORMAT && isRecord(kept.opaque) ? kept.opaque : {};\n const declarationsElement = declarationsElementOf(p, kept, networkDecls);\n const { bypassOf, nodeBypassRows, edgeBypassRows, opaqueAspects } = styleParts(snapshot, p, styled, opaque);\n const hasDeclarations = Object.keys(declarationsElement).length > 0;\n const hasNetwork = Object.keys(network).length > 0;\n const counts: [string, number][] = [\n ...presentAspects([\n [\"attributeDeclarations\", hasDeclarations ? 1 : 0],\n [\"networkAttributes\", hasNetwork ? 1 : 0],\n ]),\n [\"nodes\", snapshot.nodeCount],\n [\"edges\", edges.length],\n ...presentAspects([\n [\"nodeBypasses\", nodeBypassRows.length],\n [\"edgeBypasses\", edgeBypassRows.length],\n ]),\n ...opaqueAspects.map(([name, elements]): [string, number] => [name, elements.length]),\n ];\n\n yield '[{\"CXVersion\":\"2.0\",\"hasFragments\":false},\\n';\n yield `{\"metaData\":${stringify(counts.map(([name, elementCount]) => ({ name, elementCount })))}},\\n`;\n if (hasDeclarations) {\n yield `{\"attributeDeclarations\":[${stringify(declarationsElement)}]},\\n`;\n }\n if (hasNetwork) {\n yield `{\"networkAttributes\":[${stringify(network)}]},\\n`;\n }\n yield* block(\"nodes\", snapshot.nodeCount, (i) => stringify(nodeElement(p, ids, i)));\n const { src, dst } = snapshot.edgeList();\n yield* block(\"edges\", edges.length, (k) => stringify(edgeElement(p, ids, src, dst, edges[k])));\n if (nodeBypassRows.length > 0) {\n yield* block(\"nodeBypasses\", nodeBypassRows.length, (k) => {\n const i = nodeBypassRows[k];\n return stringify({ id: ids.idAt(i), v: bypassOf(\"node\", i) });\n });\n }\n if (edgeBypassRows.length > 0) {\n yield* block(\"edgeBypasses\", edgeBypassRows.length, (k) => {\n const e = edgeBypassRows[k];\n return stringify({ id: p.edgeIds[e], v: bypassOf(\"edge\", e) });\n });\n }\n for (const [name, elements] of opaqueAspects) {\n yield* block(name, elements.length, (k) => stringify(elements[k]));\n }\n yield '{\"status\":[{\"error\":\"\",\"success\":true}]}]\\n';\n}\n\n/** The bypasses and the extra aspects of a document. */\ninterface StyleParts {\n /** An element's bypasses, or null. */\n readonly bypassOf: (target: \"node\" | \"edge\", row: number) => Record<string, unknown> | null;\n /** The nodes with bypasses. */\n readonly nodeBypassRows: number[];\n /** The written edges with bypasses. */\n readonly edgeBypassRows: number[];\n /** The aspects written after the bypasses: the kept opaque ones, the style, the `graphty.styles` block. */\n readonly opaqueAspects: [string, unknown[]][];\n}\n\n/**\n * The bypasses and the extra aspects of a document. With styles, the bypasses and the style aspects are the\n * styles' own (the bypass columns and style aspects of an import are what the styles were read from); without, the\n * bypass columns and the kept aspects are written back.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @param opaque - the opaque aspects a CX2 import kept\n * @returns the parts\n */\nfunction styleParts(\n snapshot: GraphSnapshot,\n p: Plan,\n styled: CytoscapeEmitted | null,\n opaque: Record<string, unknown>,\n): StyleParts {\n const bypassOf = (target: \"node\" | \"edge\", row: number): Record<string, unknown> | null => {\n if (styled === null) {\n return bypassValues(target === \"node\" ? p.nodeBypasses : p.edgeBypasses, row);\n }\n const m = styled.bypasses[target][row];\n return m === null || m.size === 0 ? null : Object.fromEntries(m);\n };\n const rowsWith = (target: \"node\" | \"edge\", n: number): number[] => {\n if (styled === null) {\n return bypassRows(target === \"node\" ? p.nodeBypasses : p.edgeBypasses, n);\n }\n const out: number[] = [];\n for (let i = 0; i < n; i++) {\n if (bypassOf(target, i) !== null) {\n out.push(i);\n }\n }\n return out;\n };\n const nodeBypassRows = rowsWith(\"node\", snapshot.nodeCount);\n const edgeBypassRows = rowsWith(\"edge\", snapshot.edgeCount).filter((e) => !p.folding.folded(e));\n const opaqueAspects = Object.entries(opaque).filter(\n (entry): entry is [string, unknown[]] =>\n !CORE_ASPECTS.has(entry[0]) && !(styled !== null && STYLE_ASPECTS.has(entry[0])) && Array.isArray(entry[1]),\n );\n if (styled !== null) {\n const aspects = cytoscapeCx2Aspects(styled.style);\n opaqueAspects.push(\n [\"visualProperties\", aspects.visualProperties],\n [\"visualEditorProperties\", aspects.visualEditorProperties],\n );\n }\n const styleBlock = snapshotBlock(snapshot);\n if (styleBlock !== null) {\n opaqueAspects.push([STYLE_BLOCK_NAME, blockAspect(styleBlock)]);\n }\n\n return { bypassOf, nodeBypassRows, edgeBypassRows, opaqueAspects };\n}\n\n/**\n * The text of one aspect block, element by element.\n * @param aspect - the aspect name\n * @param count - its element count\n * @param element - the JSON text of element k\n * @returns the block's text parts\n */\nfunction block(aspect: string, count: number, element: (k: number) => string): Generator<string, void, undefined> {\n return aspectBlock(\n aspect,\n (function* elements(): Generator<string, void, undefined> {\n for (let k = 0; k < count; k++) {\n yield element(k);\n }\n })(),\n );\n}\n\n/**\n * The element of node i.\n * @param p - the plan\n * @param ids - the written ids\n * @param i - the node index\n * @returns the element\n */\nfunction nodeElement(p: Plan, ids: WrittenIds, i: number): Record<string, unknown> {\n const element: Record<string, unknown> = { id: ids.idAt(i) };\n if (p.position?.isSet(i) === true) {\n const point = p.position.value(i) as ArrayLike<number>;\n if (Number.isFinite(point[0]) && Number.isFinite(point[1])) {\n element.x = point[0];\n element.y = point[1] === 0 ? 0 : -point[1];\n if (p.positionZ && Number.isFinite(point[2])) {\n element.z = point[2];\n }\n }\n }\n if (p.z?.isSet(i) === true) {\n const z = p.z.value(i);\n if (typeof z === \"number\" && Number.isFinite(z)) {\n element.z = z;\n }\n }\n let v = attributesOf(p.nodeAttrs, i);\n if (p.originalIds && ids.isChanged(i)) {\n v ??= {};\n v[ORIGINAL_ID_ATTRIBUTE] = String(ids.originalAt(i));\n }\n if (v !== null) {\n element.v = v;\n }\n return element;\n}\n\n/**\n * The rows with at least one bypass value.\n * @param columns - the bypass columns\n * @param rows - the row count\n * @returns the rows, ascending\n */\nfunction bypassRows(columns: readonly Column[], rows: number): number[] {\n const out: number[] = [];\n if (columns.length === 0) {\n return out;\n }\n for (let i = 0; i < rows; i++) {\n if (columns.some((c) => c.isSet(i))) {\n out.push(i);\n }\n }\n return out;\n}\n\n/**\n * The bypass values of one row.\n * @param columns - the bypass columns\n * @param row - the row\n * @returns property -> value\n */\nfunction bypassValues(columns: readonly Column[], row: number): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const column of columns) {\n if (column.isSet(row)) {\n // the visual property's own name: a column renamed for a clash with an attribute keeps it in origin.id\n const property = column.meta.origin?.id;\n out[typeof property === \"string\" && property.length > 0 ? property : column.meta.name] = column.value(row);\n }\n }\n return out;\n}\n\n/**\n * The CX2 exporter plugin.\n * @category Built-in formats\n */\nexport const cx2Exporter: GraphExporter<Cx2ExportOptions> = Object.freeze({\n format: CX2_FORMAT,\n options: Object.freeze([]),\n capabilities: CX2_CAPABILITIES,\n styles: Object.freeze({ capabilities: CX2_STYLE_CAPABILITIES }),\n\n /**\n * Pre-flight: what export() would lose, without writing anything.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the notes, empty when the export is exact\n */\n check(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): readonly LossNote[] {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"cx2\");\n return Object.freeze([\n ...plan(styled?.snapshot ?? snapshot, resolveExportOptions(options)).notes,\n ...(styled?.notes ?? []),\n ]);\n },\n\n /**\n * Write the document as UTF-8 chunks.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the chunks\n */\n export(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): AsyncIterable<Uint8Array> {\n return encodeChunks(written(snapshot, options));\n },\n\n /**\n * Write the document as one string.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the document\n */\n exportToString(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): Promise<string> {\n return joinText(written(snapshot, options));\n },\n});\n\n/**\n * The document's text, with the styles when they are given.\n * @param snapshot - the snapshot\n * @param options - the options\n * @returns the text parts\n */\nfunction written(\n snapshot: GraphSnapshot,\n options: (Cx2ExportOptions & ExporterStyleOptions) | undefined,\n): Generator<string, void, undefined> {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"cx2\");\n const target = styled?.snapshot ?? snapshot;\n return write(target, plan(target, resolveExportOptions(options)), styled?.styled ?? null);\n}\n"],"names":[],"mappings":";;;;;;;;AA0DO,MAAM,WAAW,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,wBAAwB;AAAA;AAAA,EAExB,gBAAgB;AAAA;AAAA,EAEhB,mBAAmB;AAAA;AAAA,EAEnB,iBAAiB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,mBAAmB,KAAK;AAAA;AAAA,EAExB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,cAAc,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,mBAAmB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,KAAK;AAAA;AAAA,EAEjB,YAAY,KAAK;AAAA;AAAA,EAEjB,oBAAoB,KAAK;AAC7B,CAA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yB,SAA8E;AAC1G,WAAO,aAAa,QAAQ,UAAU,OAAO,CAAC;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,UAAyB,SAAoE;AACxG,WAAO,SAAS,QAAQ,UAAU,OAAO,CAAC;AAAA,EAC9C;AACJ,CAAC;AAQD,SAAS,QACL,UACA,SACkC;AAClC,QAAM,SAAS,sBAAsB,UAAU,SAAS,QAAQ,KAAK;AACrE,QAAM,SAAS,QAAQ,YAAY;AACnC,SAAO,MAAM,QAAQ,KAAK,QAAQ,qBAAqB,OAAO,CAAC,GAAG,QAAQ,UAAU,IAAI;AAC5F;"}
|
|
1
|
+
{"version":3,"file":"exporter-nDfxIK5D.js","sources":["../../src/formats/cx2/exporter.ts"],"sourcesContent":["/**\n * The CX2 exporter (design/graph-io/cytoscape-and-obo/design.md section 1.3; graphty issue #307):\n * writes a snapshot as one CX2 document -- the descriptor, the pre-metadata, one\n * `attributeDeclarations` block (aliases from `origin.id`, defaults from `meta.default`),\n * `networkAttributes`, `nodes` (x / y from the position with y flipped back to screen coordinates,\n * `z` from the `z` column), `edges`, the `cx2.bypass` columns as `nodeBypasses` / `edgeBypasses`,\n * the opaque aspects a CX2 import kept (which returns its own style rules) and `status`.\n *\n * Given styles (`exportGraph(..., { styles })`), `visualProperties` and `visualEditorProperties` are the\n * Cytoscape style of the rules (defaults and mappings), the bypasses are every element whose value the style\n * cannot give, and the style values the rules read are attributes; the `graphty.styles` block, which graph-io\n * hands over as a graph attribute, is written as an aspect of its own (a kept one is written back the same way).\n *\n * What CX2 cannot hold is announced by check() before anything is written: every edge is\n * directed (W_CX2_UNDIRECTED_AS_DIRECTED, W_MUTUAL_EXPANDED), node ids are integers (E_ID_CHARSET\n * unless `sanitizeIds: \"mangle\"`, which keeps the original in the `graphty:originalId` attribute\n * the importer restores), nested values are written as JSON text (W_CX2_JSON_AS_STRING), NaN and\n * the infinities as null (W_CX2_NONFINITE_AS_NULL), and the generic notes of checkCapabilities().\n */\n\nimport { type Column, GraphFormatError, type GraphSnapshot } from \"@graphty/graph-format\";\n\nimport {\n aspectBlock,\n declaredType,\n directionNotes,\n nonFinitePositions,\n planEdgeIds,\n planNodeIds,\n stringify,\n type WrittenIds,\n} from \"../../common/cx-export.js\";\nimport { type PairFolding, pairFolding } from \"../../common/direction.js\";\nimport { capabilities, checkCapabilities, LOSS } from \"../../common/export.js\";\nimport { isRecord, POSITION_COLUMN } from \"../../common/json-elements.js\";\nimport { type ResolvedExportOptions, resolveExportOptions } from \"../../common/options.js\";\nimport { plural } from \"../../common/plural.js\";\nimport { type ExplicitWeights, explicitWeights } from \"../../common/weights.js\";\nimport { encodeChunks, joinText } from \"../../common/writer.js\";\nimport { cytoscapeCx2Aspects, type CytoscapeEmitted } from \"../../styles/cytoscape/emit.js\";\nimport { STYLE_BLOCK_NAME } from \"../../styles/io/block.js\";\nimport type { ExporterStyleOptions } from \"../../styles/io/writer.js\";\nimport { type CommonExportOptions, type ExportCapabilities, type GraphExporter, type LossNote } from \"../../types.js\";\nimport { blockAspect, cytoscapeStyledExport, snapshotBlock } from \"../cx/styles.js\";\nimport { BYPASS_NAMESPACE, CX2_FORMAT, cx2Type, ORIGINAL_ID_ATTRIBUTE } from \"./importer.js\";\nimport { CX2_STYLE_CAPABILITIES } from \"./styles.js\";\n\n/**\n * The options of the CX2 exporter: the common export options; it has none of its own.\n * @category Built-in formats\n */\nexport type Cx2ExportOptions = CommonExportOptions;\n\n/**\n * The loss notes the CX2 exporter's check() returns, by name. A key is the\n * code without its severity and format prefixes.\n * @category Built-in formats\n */\nexport const CX2_LOSS = Object.freeze({\n /**\n * Every edge is written as directed, so an undirected graph, or the undirected edges of a mixed graph, read back\n * as directed.\n */\n UNDIRECTED_AS_DIRECTED: \"W_CX2_UNDIRECTED_AS_DIRECTED\",\n /** A nested (json) column is written as a string attribute holding its JSON text. */\n JSON_AS_STRING: \"W_CX2_JSON_AS_STRING\",\n /** NaN and the infinities cannot be written; they are written as null and read back unset. */\n NONFINITE_AS_NULL: \"W_CX2_NONFINITE_AS_NULL\",\n /** A mutual pair is written as two directed edges without its mark. */\n MUTUAL_EXPANDED: LOSS.MUTUAL_EXPANDED,\n /**\n * An attribute without the weight role is named like the key weights are written under; it reads back as the edge\n * weight, or is not written when the graph has weights of its own.\n */\n WEIGHT_KEY_CLASH: LOSS.WEIGHT_KEY_CLASH,\n /** A parent / parents column: CX2 has no containment. */\n HIERARCHY_DROPPED: LOSS.HIERARCHY,\n /** A start / end / timestamp column: CX2 has no time. */\n TEMPORAL_DROPPED: LOSS.TEMPORAL,\n /** An attribute with a role the format has no place for is written as a plain attribute; the role is lost. */\n ROLE_DROPPED: LOSS.ROLE,\n /**\n * An attribute type CX2 stores as another (a 32-bit float as double, an unsigned integer as long, a dictionary as\n * string); it reads back with that type.\n */\n DTYPE_UNSUPPORTED: LOSS.DTYPE,\n /**\n * Node ids the format cannot write, under `sanitizeIds: \"error\"`; the save fails with E_INVALID_ID. Pass\n * `sanitizeIds: \"mangle\"` to rewrite them.\n */\n ID_CHARSET: LOSS.ID_CHARSET,\n /** Node ids that are not integers under sanitizeIds \"mangle\": renumbered, originals kept. */\n ID_MANGLED: LOSS.ID_MANGLED,\n /** Edges without a usable id get generated integer ids. */\n EDGE_IDS_GENERATED: LOSS.EDGE_IDS_GENERATED,\n});\n\n/**\n * What CX2 keeps: directed multigraphs with self-loops, integer node ids,\n * required integer edge ids, declared string / double / integer / boolean columns and lists of\n * them, declared defaults, network attributes and the position role. f32, u32, u8 and dict columns\n * are written as the nearest declared type and read back as it.\n * @category Built-in formats\n */\nexport const CX2_CAPABILITIES: ExportCapabilities = capabilities({\n mixedDirection: false,\n multiEdges: true,\n selfLoops: true,\n edgeIds: \"required\",\n idCharset: \"integer\",\n dtypes: [\"string\", \"f64\", \"i32\", \"bool\"],\n components: false,\n lists: true,\n json: false,\n defaults: true,\n options: false,\n hierarchy: false,\n temporal: \"none\",\n graphAttributes: true,\n positions: true,\n viz: false,\n});\n\n/** The roles CX2 has a slot for, and the column names its importer gives them. */\nconst SLOT_ROLES: ReadonlySet<string> = new Set([\"label\", \"position\", \"id\"]);\nconst ROLE_NAMES: Readonly<Record<string, string>> = Object.freeze({\n label: \"name\",\n position: POSITION_COLUMN,\n});\n\n/** Roles whose columns are never written as attributes. */\nconst SKIPPED_ROLES: ReadonlySet<string> = new Set([\n \"directed\",\n \"pair\",\n \"mutual\",\n \"weight\",\n \"timeText\",\n \"originalId\",\n \"parent\",\n \"parents\",\n \"start\",\n \"end\",\n \"timestamp\",\n \"timestamps\",\n \"spells\",\n \"open\",\n \"spellsOpen\",\n \"position\",\n \"color\",\n \"size\",\n \"shape\",\n \"thickness\",\n]);\n\n/** The style aspects; written from the styles when styles are given, else the kept ones. */\nconst STYLE_ASPECTS: ReadonlySet<string> = new Set([\"visualProperties\", \"visualEditorProperties\"]);\n\n/** The aspects the exporter writes itself; an opaque aspect of the same name is not written again. */\nconst CORE_ASPECTS: ReadonlySet<string> = new Set([\n STYLE_BLOCK_NAME,\n \"nodes\",\n \"edges\",\n \"attributeDeclarations\",\n \"networkAttributes\",\n \"nodeBypasses\",\n \"edgeBypasses\",\n \"metaData\",\n \"status\",\n]);\n\n/** The weight attribute name. */\nconst WEIGHT_ATTRIBUTE = \"weight\";\n\n/** One attribute column as it will be written. */\ninterface AttributePlan {\n readonly column: Column;\n /** The full attribute name. */\n readonly name: string;\n /** The key used in v (the alias, or the name). */\n readonly key: string;\n /** The declared type text. */\n readonly d: string;\n /** Whether values are written as their JSON text (a json column). */\n readonly jsonText: boolean;\n}\n\n/** Everything export() and check() need, computed once. */\ninterface Plan {\n readonly notes: LossNote[];\n readonly fatal: GraphFormatError | null;\n readonly ids: WrittenIds | null;\n readonly folding: PairFolding;\n readonly weights: ExplicitWeights;\n readonly nodeAttrs: readonly AttributePlan[];\n readonly edgeAttrs: readonly AttributePlan[];\n readonly graphAttrs: readonly AttributePlan[];\n readonly nodeBypasses: readonly Column[];\n readonly edgeBypasses: readonly Column[];\n readonly position: Column | null;\n readonly positionZ: boolean;\n readonly z: Column | null;\n readonly edgeIds: readonly number[];\n readonly originalIds: boolean;\n}\n\n/**\n * Whether a column is a bypass column of a CX2 import.\n * @param column - the column\n * @returns true for the cx2.bypass namespace\n */\nfunction isBypass(column: Column): boolean {\n return column.meta.origin?.namespace === BYPASS_NAMESPACE;\n}\n\n/**\n * Whether a column is the z (stacking order) column.\n * @param column - the column\n * @returns true for the column marked by a Cytoscape-family importer\n */\nfunction isZ(column: Column): boolean {\n return column.meta.extra.cytoscape === \"z\";\n}\n\n/**\n * Count the non-finite numbers of a column.\n * @param column - the column\n * @returns how many set cells (or list items) are NaN or infinite\n */\nfunction nonFiniteCount(column: Column): number {\n const { dtype, itemDtype } = column.meta;\n const numeric =\n dtype === \"f32\" || dtype === \"f64\" || (dtype === \"list\" && (itemDtype === \"f32\" || itemDtype === \"f64\"));\n if (!numeric) {\n return 0;\n }\n let count = 0;\n for (let i = 0; i < column.length; i++) {\n if (!column.isSet(i)) {\n continue;\n }\n const value = column.value(i);\n if (dtype === \"list\") {\n if ((value as readonly number[]).some((v) => !Number.isFinite(v))) {\n count++;\n }\n } else if (!Number.isFinite(value)) {\n count++;\n }\n }\n return count;\n}\n\n/**\n * Plan the attribute columns of one table.\n * @param table - the table\n * @param skip - columns not written as attributes\n * @param rename - the written name of a column, when it differs (the label as `name`)\n * @param reserved - keys already used in v\n * @returns the plans\n */\nfunction planAttributes(\n table: Iterable<Column>,\n skip: (column: Column) => boolean,\n rename: (column: Column) => string,\n reserved: ReadonlySet<string> = new Set(),\n): AttributePlan[] {\n const plans: AttributePlan[] = [];\n const used = new Set<string>(reserved);\n const candidates = [...table].filter((c) => !skip(c));\n for (const column of candidates) {\n used.add(rename(column));\n }\n for (const column of candidates) {\n const name = rename(column);\n const { origin } = column.meta;\n let key = name;\n const alias = origin?.format === CX2_FORMAT && typeof origin.id === \"string\" ? origin.id : null;\n if (alias !== null && alias.length > 0 && alias !== name && !used.has(alias)) {\n key = alias;\n used.add(alias);\n }\n plans.push({ column, name, key, d: declaredType(column), jsonText: column.meta.dtype === \"json\" });\n }\n return plans;\n}\n\n/** A note-recording callback. */\ntype Note = (code: string, message: string, column?: string | null, count?: number | null) => void;\n\n/**\n * The generic notes of checkCapabilities(), adapted to CX2: bypass columns hold any JSON value,\n * ids are counted by planNodeIds(), nested values are written as JSON text, and only the node\n * label is written into the \"n\" slot (an edge label keeps its own name but loses its role).\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @param notes - the notes so far, appended to\n * @param note - the recorder\n * @returns the fatal condition, or null\n */\nfunction capabilityNotes(\n snapshot: GraphSnapshot,\n common: ResolvedExportOptions,\n notes: LossNote[],\n note: Note,\n): GraphFormatError | null {\n let fatal: GraphFormatError | null = null;\n // bypass columns are written as bypasses, which hold any JSON value\n const bypassNames = new Set(\n [...snapshot.nodes, ...snapshot.edges].filter((c) => isBypass(c) || isZ(c)).map((c) => c.meta.name),\n );\n for (const gen of checkCapabilities(snapshot, CX2_CAPABILITIES, common, {\n roles: SLOT_ROLES,\n roleNames: ROLE_NAMES,\n // only the node label is written into the \"n\" slot; an edge label keeps its own name\n edgeRoleNames: {},\n })) {\n if (!keepGenericNote(gen, bypassNames)) {\n continue;\n }\n if (gen.code === LOSS.JSON) {\n const what = gen.column === null ? \"a column\" : `column \"${gen.column}\"`;\n note(\n CX2_LOSS.JSON_AS_STRING,\n `${what} holds nested values; written as a string attribute holding their JSON text`,\n gen.column,\n gen.count,\n );\n continue;\n }\n if (gen.code === LOSS.MIXED_DIRECTION_ERROR && fatal === null) {\n fatal = new GraphFormatError(\"E_DIRECTED\", gen.message, { reason: \"mixed direction\" });\n }\n notes.push(gen);\n }\n const edgeLabel = snapshot.edges.byRole(\"label\");\n if (edgeLabel !== null) {\n note(\n LOSS.ROLE,\n `edge column \"${edgeLabel.meta.name}\" (label) is written as a plain attribute; CX2 edges have no label slot and the role is lost`,\n edgeLabel.meta.name,\n edgeLabel.length - edgeLabel.nullCount,\n );\n }\n return fatal;\n}\n\n/**\n * Whether a generic note applies to CX2 as it stands.\n * @param gen - the generic note\n * @param bypassNames - the names of the columns written as bypasses\n * @returns false for a note CX2 drops or replaces\n */\nfunction keepGenericNote(gen: LossNote, bypassNames: ReadonlySet<string>): boolean {\n if (gen.column !== null && bypassNames.has(gen.column) && (gen.code === LOSS.JSON || gen.code === LOSS.DTYPE)) {\n return false;\n }\n // ids are counted by planNodeIds(): CX2 also keeps integer ids beyond 2^53, which the generic rule refuses\n return gen.code !== LOSS.ID_CHARSET && gen.code !== LOSS.ID_MANGLED;\n}\n\n/**\n * Note the NaN and infinite values written as null: attribute cells, explicit weights, positions.\n * @param snapshot - the snapshot\n * @param attrs - every planned attribute\n * @param weights - the explicit weights\n * @param position - the position column, or null\n * @param note - the recorder\n */\nfunction nonFiniteNote(\n snapshot: GraphSnapshot,\n attrs: readonly AttributePlan[],\n weights: ExplicitWeights,\n position: Column | null,\n note: Note,\n): void {\n let nonfinite = 0;\n for (const p of attrs) {\n nonfinite += nonFiniteCount(p.column);\n }\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (weights.isExplicit(e) && !Number.isFinite(weights.value(e))) {\n nonfinite++;\n }\n }\n if (position !== null) {\n nonfinite += nonFinitePositions(position);\n }\n if (nonfinite > 0) {\n note(\n CX2_LOSS.NONFINITE_AS_NULL,\n `${nonfinite} NaN or infinite value${plural(nonfinite)} cannot be written in CX2; written as null, they read back unset`,\n null,\n nonfinite,\n );\n }\n}\n\n/**\n * Plan the edge attributes, noting a plain `weight` column that clashes with the weight key.\n * @param snapshot - the snapshot\n * @param weights - the explicit weights\n * @param note - the recorder\n * @returns the edge attribute plans\n */\nfunction planEdgeAttributes(snapshot: GraphSnapshot, weights: ExplicitWeights, note: Note): AttributePlan[] {\n const plainWeight = snapshot.edges.get(WEIGHT_ATTRIBUTE);\n if (plainWeight !== null && plainWeight.meta.role === null) {\n note(\n LOSS.WEIGHT_KEY_CLASH,\n weights.weighted\n ? `edge column \"${WEIGHT_ATTRIBUTE}\" is not written: the explicit weights are written under that name`\n : `edge column \"${WEIGHT_ATTRIBUTE}\" reads back as the edge weight`,\n WEIGHT_ATTRIBUTE,\n null,\n );\n }\n return planAttributes(\n snapshot.edges,\n (c) =>\n (c.meta.role !== null && (SKIPPED_ROLES.has(c.meta.role) || c.meta.role === \"id\")) ||\n isBypass(c) ||\n (weights.weighted && c === plainWeight),\n (c) => c.meta.name,\n weights.weighted ? new Set([WEIGHT_ATTRIBUTE]) : new Set(),\n );\n}\n\n/**\n * Plan an export: the notes, the fatal condition and what is written.\n * @param snapshot - the snapshot\n * @param common - the resolved common options\n * @returns the plan\n */\nfunction plan(snapshot: GraphSnapshot, common: ResolvedExportOptions): Plan {\n const notes: LossNote[] = [];\n const note: Note = (code, message, column = null, count = null) => {\n notes.push(Object.freeze({ code, message, column, count }));\n };\n let fatal = capabilityNotes(snapshot, common, notes, note);\n\n const folding = pairFolding(snapshot);\n directionNotes(snapshot, folding, common, CX2_LOSS.UNDIRECTED_AS_DIRECTED, note);\n\n const planned = planNodeIds(snapshot, common, \"CX2\", ORIGINAL_ID_ATTRIBUTE, note);\n const ids = planned instanceof GraphFormatError ? null : planned;\n if (planned instanceof GraphFormatError) {\n fatal ??= planned;\n }\n\n const weights = explicitWeights(snapshot);\n const label = snapshot.nodes.byRole(\"label\");\n const nodeAttrs = planAttributes(\n snapshot.nodes,\n (c) => (c.meta.role !== null && SKIPPED_ROLES.has(c.meta.role)) || isBypass(c) || isZ(c),\n (c) => (c === label && !snapshot.nodes.has(\"name\") ? \"name\" : c.meta.name),\n ids !== null && ids.changed > 0 ? new Set([ORIGINAL_ID_ATTRIBUTE]) : new Set(),\n );\n const edgeAttrs = planEdgeAttributes(snapshot, weights, note);\n const graphAttrs = planAttributes(\n snapshot.graph,\n // the graphty.styles block is an aspect of its own\n (c) => c.meta.name === STYLE_BLOCK_NAME,\n (c) => c.meta.name,\n ).map((p) => ({ ...p, key: p.name }));\n\n const position = snapshot.nodes.byRole(\"position\");\n nonFiniteNote(snapshot, [...nodeAttrs, ...edgeAttrs, ...graphAttrs], weights, position, note);\n\n const edgeIds = planEdgeIds(snapshot, note, ids);\n const z = [...snapshot.nodes].find(isZ) ?? null;\n const positionZ = position !== null && z === null && position.meta.extra.sourceDims === 3;\n return {\n notes,\n fatal,\n ids,\n folding,\n weights,\n nodeAttrs,\n edgeAttrs,\n graphAttrs,\n nodeBypasses: [...snapshot.nodes].filter(isBypass),\n edgeBypasses: [...snapshot.edges].filter(isBypass),\n position,\n positionZ,\n z,\n edgeIds,\n originalIds: ids !== null && ids.changed > 0,\n };\n}\n\n// ============================================================ writing\n\n/**\n * The value written for one cell.\n * @param p - the attribute plan\n * @param row - the row\n * @returns the value, or undefined for an unset cell\n */\nfunction cellValue(p: AttributePlan, row: number): unknown {\n const { column } = p;\n if (!column.isSet(row)) {\n return undefined;\n }\n const value = column.value(row);\n if (p.jsonText) {\n return JSON.stringify(value);\n }\n if (column.meta.dtype === \"list\" || column.meta.components > 1) {\n const items = Array.from(value as ArrayLike<unknown>);\n if (p.d === \"string\") {\n return JSON.stringify(items);\n }\n return items.some((v) => typeof v === \"number\" && !Number.isFinite(v)) ? null : items;\n }\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n return null;\n }\n return value;\n}\n\n/**\n * The declarations of one table.\n * @param plans - the attribute plans\n * @param defaults - whether defaults and aliases may be written (not for network attributes)\n * @returns the declaration object\n */\nfunction declarations(plans: readonly AttributePlan[], defaults: boolean): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const p of plans) {\n const decl: Record<string, unknown> = { d: p.d };\n if (defaults && p.key !== p.name) {\n decl.a = p.key;\n }\n const fallback = p.column.meta.default;\n if (defaults && fallback !== undefined && fallback !== null) {\n if (defaultFits(cx2Type(p.d), fallback)) {\n decl.v = fallback;\n }\n }\n out[p.name] = decl;\n }\n return out;\n}\n\n/**\n * Whether a declared default can be written as the value of a declared type.\n * @param type - the type\n * @param fallback - the default\n * @returns true when it matches\n */\nfunction defaultFits(type: ReturnType<typeof cx2Type>, fallback: unknown): boolean {\n if (type === null) {\n return false;\n }\n if (type.list) {\n return Array.isArray(fallback);\n }\n switch (type.scalar) {\n case \"string\":\n return typeof fallback === \"string\";\n case \"boolean\":\n return typeof fallback === \"boolean\";\n default:\n return typeof fallback === \"number\" && Number.isFinite(fallback);\n }\n}\n\n/**\n * The v object of one element.\n * @param plans - the attribute plans\n * @param row - the row\n * @returns the object, or null when empty\n */\nfunction attributesOf(plans: readonly AttributePlan[], row: number): Record<string, unknown> | null {\n let out: Record<string, unknown> | null = null;\n for (const p of plans) {\n const value = cellValue(p, row);\n if (value !== undefined) {\n out ??= {};\n out[p.key] = value;\n }\n }\n return out;\n}\n\n/**\n * The networkAttributes element and its declarations: the graph attributes, then the snapshot's name and\n * description where no attribute of that name is written.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @returns the element and the declarations\n */\nfunction networkOf(\n snapshot: GraphSnapshot,\n p: Plan,\n): { network: Record<string, unknown>; networkDecls: Record<string, unknown> } {\n const networkDecls = declarations(p.graphAttrs, false);\n const network: Record<string, unknown> = {};\n for (const a of p.graphAttrs) {\n const value = cellValue(a, 0);\n if (value !== undefined) {\n network[a.name] = value;\n }\n }\n const { meta } = snapshot;\n for (const [key, value] of [\n [\"name\", meta.name],\n [\"description\", meta.description],\n ] as const) {\n if (value !== null && !(key in network) && !(key in networkDecls)) {\n network[key] = value;\n networkDecls[key] = { d: \"string\" };\n }\n }\n return { network, networkDecls };\n}\n\n/**\n * The attributeDeclarations element: the kept declarations of other tables, then the network's, the nodes' and the\n * edges' where there are any.\n * @param p - the plan\n * @param kept - what an import kept in meta.extra.cx2\n * @param networkDecls - the network's declarations\n * @returns the element\n */\nfunction declarationsElementOf(\n p: Plan,\n kept: Record<string, unknown>,\n networkDecls: Record<string, unknown>,\n): Record<string, unknown> {\n const nodeDecls = declarations(p.nodeAttrs, true);\n if (p.originalIds) {\n nodeDecls[ORIGINAL_ID_ATTRIBUTE] = { d: \"string\" };\n }\n const edgeDecls = declarations(p.edgeAttrs, true);\n if (p.weights.weighted) {\n edgeDecls[WEIGHT_ATTRIBUTE] = { d: \"double\" };\n }\n const otherDecls = isRecord(kept.declarations) ? kept.declarations : {};\n const element: Record<string, unknown> = { ...otherDecls };\n for (const [key, table] of [\n [\"networkAttributes\", networkDecls],\n [\"nodes\", nodeDecls],\n [\"edges\", edgeDecls],\n ] as const) {\n if (Object.keys(table).length > 0) {\n element[key] = table;\n }\n }\n return element;\n}\n\n/**\n * One edge element.\n * @param p - the plan\n * @param ids - the written node ids\n * @param src - the source of each edge\n * @param dst - the target of each edge\n * @param e - the edge\n * @returns the element\n */\nfunction edgeElement(\n p: Plan,\n ids: WrittenIds,\n src: ArrayLike<number>,\n dst: ArrayLike<number>,\n e: number,\n): Record<string, unknown> {\n const element: Record<string, unknown> = {\n id: p.edgeIds[e],\n s: ids.idAt(src[e]),\n t: ids.idAt(dst[e]),\n };\n let v = attributesOf(p.edgeAttrs, e);\n if (p.weights.isExplicit(e)) {\n const w = p.weights.value(e);\n v ??= {};\n v[WEIGHT_ATTRIBUTE] = Number.isFinite(w) ? w : null;\n }\n if (v !== null) {\n element.v = v;\n }\n return element;\n}\n\n/**\n * The optional aspects of a document that are written: those with elements.\n * @param aspects - each aspect's name and element count\n * @returns the metaData counts\n */\nfunction presentAspects(aspects: readonly (readonly [string, number])[]): [string, number][] {\n return aspects.filter(([, n]) => n > 0).map(([name, n]) => [name, n]);\n}\n\n/**\n * Write the document as text parts.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @yields the document's text\n * @returns nothing\n */\nfunction* write(\n snapshot: GraphSnapshot,\n p: Plan,\n styled: CytoscapeEmitted | null = null,\n): Generator<string, void, undefined> {\n if (p.fatal !== null) {\n throw p.fatal;\n }\n const { ids } = p;\n if (ids === null) {\n throw new GraphFormatError(\"E_INVALID_ID\", \"node ids cannot be written as CX2 integers\", { reason: \"charset\" });\n }\n const edges: number[] = [];\n for (let e = 0; e < snapshot.edgeCount; e++) {\n if (!p.folding.folded(e)) {\n edges.push(e);\n }\n }\n const { network, networkDecls } = networkOf(snapshot, p);\n const { meta } = snapshot;\n const kept = isRecord(meta.extra.cx2) ? meta.extra.cx2 : {};\n const opaque = meta.sourceFormat === CX2_FORMAT && isRecord(kept.opaque) ? kept.opaque : {};\n const declarationsElement = declarationsElementOf(p, kept, networkDecls);\n const { bypassOf, nodeBypassRows, edgeBypassRows, opaqueAspects } = styleParts(snapshot, p, styled, opaque);\n const hasDeclarations = Object.keys(declarationsElement).length > 0;\n const hasNetwork = Object.keys(network).length > 0;\n const counts: [string, number][] = [\n ...presentAspects([\n [\"attributeDeclarations\", hasDeclarations ? 1 : 0],\n [\"networkAttributes\", hasNetwork ? 1 : 0],\n ]),\n [\"nodes\", snapshot.nodeCount],\n [\"edges\", edges.length],\n ...presentAspects([\n [\"nodeBypasses\", nodeBypassRows.length],\n [\"edgeBypasses\", edgeBypassRows.length],\n ]),\n ...opaqueAspects.map(([name, elements]): [string, number] => [name, elements.length]),\n ];\n\n yield '[{\"CXVersion\":\"2.0\",\"hasFragments\":false},\\n';\n yield `{\"metaData\":${stringify(counts.map(([name, elementCount]) => ({ name, elementCount })))}},\\n`;\n if (hasDeclarations) {\n yield `{\"attributeDeclarations\":[${stringify(declarationsElement)}]},\\n`;\n }\n if (hasNetwork) {\n yield `{\"networkAttributes\":[${stringify(network)}]},\\n`;\n }\n yield* block(\"nodes\", snapshot.nodeCount, (i) => stringify(nodeElement(p, ids, i)));\n const { src, dst } = snapshot.edgeList();\n yield* block(\"edges\", edges.length, (k) => stringify(edgeElement(p, ids, src, dst, edges[k])));\n if (nodeBypassRows.length > 0) {\n yield* block(\"nodeBypasses\", nodeBypassRows.length, (k) => {\n const i = nodeBypassRows[k];\n return stringify({ id: ids.idAt(i), v: bypassOf(\"node\", i) });\n });\n }\n if (edgeBypassRows.length > 0) {\n yield* block(\"edgeBypasses\", edgeBypassRows.length, (k) => {\n const e = edgeBypassRows[k];\n return stringify({ id: p.edgeIds[e], v: bypassOf(\"edge\", e) });\n });\n }\n for (const [name, elements] of opaqueAspects) {\n yield* block(name, elements.length, (k) => stringify(elements[k]));\n }\n yield '{\"status\":[{\"error\":\"\",\"success\":true}]}]\\n';\n}\n\n/** The bypasses and the extra aspects of a document. */\ninterface StyleParts {\n /** An element's bypasses, or null. */\n readonly bypassOf: (target: \"node\" | \"edge\", row: number) => Record<string, unknown> | null;\n /** The nodes with bypasses. */\n readonly nodeBypassRows: number[];\n /** The written edges with bypasses. */\n readonly edgeBypassRows: number[];\n /** The aspects written after the bypasses: the kept opaque ones, the style, the `graphty.styles` block. */\n readonly opaqueAspects: [string, unknown[]][];\n}\n\n/**\n * The bypasses and the extra aspects of a document. With styles, the bypasses and the style aspects are the\n * styles' own (the bypass columns and style aspects of an import are what the styles were read from); without, the\n * bypass columns and the kept aspects are written back.\n * @param snapshot - the snapshot\n * @param p - the plan\n * @param styled - the styles as a Cytoscape style, or null without styles\n * @param opaque - the opaque aspects a CX2 import kept\n * @returns the parts\n */\nfunction styleParts(\n snapshot: GraphSnapshot,\n p: Plan,\n styled: CytoscapeEmitted | null,\n opaque: Record<string, unknown>,\n): StyleParts {\n const bypassOf = (target: \"node\" | \"edge\", row: number): Record<string, unknown> | null => {\n if (styled === null) {\n return bypassValues(target === \"node\" ? p.nodeBypasses : p.edgeBypasses, row);\n }\n const m = styled.bypasses[target][row];\n return m === null || m.size === 0 ? null : Object.fromEntries(m);\n };\n const rowsWith = (target: \"node\" | \"edge\", n: number): number[] => {\n if (styled === null) {\n return bypassRows(target === \"node\" ? p.nodeBypasses : p.edgeBypasses, n);\n }\n const out: number[] = [];\n for (let i = 0; i < n; i++) {\n if (bypassOf(target, i) !== null) {\n out.push(i);\n }\n }\n return out;\n };\n const nodeBypassRows = rowsWith(\"node\", snapshot.nodeCount);\n const edgeBypassRows = rowsWith(\"edge\", snapshot.edgeCount).filter((e) => !p.folding.folded(e));\n const opaqueAspects = Object.entries(opaque).filter(\n (entry): entry is [string, unknown[]] =>\n !CORE_ASPECTS.has(entry[0]) && !(styled !== null && STYLE_ASPECTS.has(entry[0])) && Array.isArray(entry[1]),\n );\n if (styled !== null) {\n const aspects = cytoscapeCx2Aspects(styled.style);\n opaqueAspects.push(\n [\"visualProperties\", aspects.visualProperties],\n [\"visualEditorProperties\", aspects.visualEditorProperties],\n );\n }\n const styleBlock = snapshotBlock(snapshot);\n if (styleBlock !== null) {\n opaqueAspects.push([STYLE_BLOCK_NAME, blockAspect(styleBlock)]);\n }\n\n return { bypassOf, nodeBypassRows, edgeBypassRows, opaqueAspects };\n}\n\n/**\n * The text of one aspect block, element by element.\n * @param aspect - the aspect name\n * @param count - its element count\n * @param element - the JSON text of element k\n * @returns the block's text parts\n */\nfunction block(aspect: string, count: number, element: (k: number) => string): Generator<string, void, undefined> {\n return aspectBlock(\n aspect,\n (function* elements(): Generator<string, void, undefined> {\n for (let k = 0; k < count; k++) {\n yield element(k);\n }\n })(),\n );\n}\n\n/**\n * The element of node i.\n * @param p - the plan\n * @param ids - the written ids\n * @param i - the node index\n * @returns the element\n */\nfunction nodeElement(p: Plan, ids: WrittenIds, i: number): Record<string, unknown> {\n const element: Record<string, unknown> = { id: ids.idAt(i) };\n if (p.position?.isSet(i) === true) {\n const point = p.position.value(i) as ArrayLike<number>;\n if (Number.isFinite(point[0]) && Number.isFinite(point[1])) {\n element.x = point[0];\n element.y = point[1] === 0 ? 0 : -point[1];\n if (p.positionZ && Number.isFinite(point[2])) {\n element.z = point[2];\n }\n }\n }\n if (p.z?.isSet(i) === true) {\n const z = p.z.value(i);\n if (typeof z === \"number\" && Number.isFinite(z)) {\n element.z = z;\n }\n }\n let v = attributesOf(p.nodeAttrs, i);\n if (p.originalIds && ids.isChanged(i)) {\n v ??= {};\n v[ORIGINAL_ID_ATTRIBUTE] = String(ids.originalAt(i));\n }\n if (v !== null) {\n element.v = v;\n }\n return element;\n}\n\n/**\n * The rows with at least one bypass value.\n * @param columns - the bypass columns\n * @param rows - the row count\n * @returns the rows, ascending\n */\nfunction bypassRows(columns: readonly Column[], rows: number): number[] {\n const out: number[] = [];\n if (columns.length === 0) {\n return out;\n }\n for (let i = 0; i < rows; i++) {\n if (columns.some((c) => c.isSet(i))) {\n out.push(i);\n }\n }\n return out;\n}\n\n/**\n * The bypass values of one row.\n * @param columns - the bypass columns\n * @param row - the row\n * @returns property -> value\n */\nfunction bypassValues(columns: readonly Column[], row: number): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const column of columns) {\n if (column.isSet(row)) {\n // the visual property's own name: a column renamed for a clash with an attribute keeps it in origin.id\n const property = column.meta.origin?.id;\n out[typeof property === \"string\" && property.length > 0 ? property : column.meta.name] = column.value(row);\n }\n }\n return out;\n}\n\n/**\n * The CX2 exporter plugin.\n * @category Built-in formats\n */\nexport const cx2Exporter: GraphExporter<Cx2ExportOptions> = Object.freeze({\n format: CX2_FORMAT,\n options: Object.freeze([]),\n capabilities: CX2_CAPABILITIES,\n styles: Object.freeze({ capabilities: CX2_STYLE_CAPABILITIES }),\n\n /**\n * Pre-flight: what export() would lose, without writing anything.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the notes, empty when the export is exact\n */\n check(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): readonly LossNote[] {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"cx2\");\n return Object.freeze([\n ...plan(styled?.snapshot ?? snapshot, resolveExportOptions(options)).notes,\n ...(styled?.notes ?? []),\n ]);\n },\n\n /**\n * Write the document as UTF-8 chunks.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the chunks\n */\n export(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): AsyncIterable<Uint8Array> {\n return encodeChunks(written(snapshot, options));\n },\n\n /**\n * Write the document as one string.\n * @param snapshot - the snapshot\n * @param options - the common options\n * @returns the document\n */\n exportToString(snapshot: GraphSnapshot, options?: Cx2ExportOptions & ExporterStyleOptions): Promise<string> {\n return joinText(written(snapshot, options));\n },\n});\n\n/**\n * The document's text, with the styles when they are given.\n * @param snapshot - the snapshot\n * @param options - the options\n * @returns the text parts\n */\nfunction written(\n snapshot: GraphSnapshot,\n options: (Cx2ExportOptions & ExporterStyleOptions) | undefined,\n): Generator<string, void, undefined> {\n const styled = cytoscapeStyledExport(snapshot, options?.styles, \"cx2\");\n const target = styled?.snapshot ?? snapshot;\n return write(target, plan(target, resolveExportOptions(options)), styled?.styled ?? null);\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0DO,MAAM,WAAW,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,wBAAwB;AAAA;AAAA,EAExB,gBAAgB;AAAA;AAAA,EAEhB,mBAAmB;AAAA;AAAA,EAEnB,iBAAiB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,mBAAmB,KAAK;AAAA;AAAA,EAExB,kBAAkB,KAAK;AAAA;AAAA,EAEvB,cAAc,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,mBAAmB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxB,YAAY,KAAK;AAAA;AAAA,EAEjB,YAAY,KAAK;AAAA;AAAA,EAEjB,oBAAoB,KAAK;AAC7B,CAAC;AASM,MAAM,mBAAuC,aAAa;AAAA,EAC7D,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ,CAAC,UAAU,OAAO,OAAO,MAAM;AAAA,EACvC,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,KAAK;AACT,CAAC;AAGD,MAAM,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