@graphty/graph-io 0.3.48 → 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.
Files changed (570) hide show
  1. package/dist/chunks/{approximations-C2riR4NT.js → approximations-Bzn3L-je.js} +2 -2
  2. package/dist/chunks/{approximations-C2riR4NT.js.map → approximations-Bzn3L-je.js.map} +1 -1
  3. package/dist/chunks/bends-BGXjv_U4.js +129 -0
  4. package/dist/chunks/bends-BGXjv_U4.js.map +1 -0
  5. package/dist/chunks/{block-Cu22ewuS.js → block-iptrlMBb.js} +906 -164
  6. package/dist/chunks/block-iptrlMBb.js.map +1 -0
  7. package/dist/chunks/choose-CczZJaX_.js +717 -0
  8. package/dist/chunks/choose-CczZJaX_.js.map +1 -0
  9. package/dist/chunks/{codes-CV_Bhcyi.js → codes-BE2xir2k.js} +6 -2
  10. package/dist/chunks/codes-BE2xir2k.js.map +1 -0
  11. package/dist/chunks/{constants-D0LqcsLJ.js → constants-CKkYLPtt.js} +2 -2
  12. package/dist/chunks/{constants-D0LqcsLJ.js.map → constants-CKkYLPtt.js.map} +1 -1
  13. package/dist/chunks/{context-cgmmOxZ2.js → context-C3p0RQxR.js} +5 -4
  14. package/dist/chunks/{context-cgmmOxZ2.js.map → context-C3p0RQxR.js.map} +1 -1
  15. package/dist/chunks/{convert-BcQ8_jMo.js → convert-Ct2zelbQ.js} +7 -2
  16. package/dist/chunks/convert-Ct2zelbQ.js.map +1 -0
  17. package/dist/chunks/{credentials-BiQsnMTb.js → credentials-DXHx7nwR.js} +16 -14
  18. package/dist/chunks/credentials-DXHx7nwR.js.map +1 -0
  19. package/dist/chunks/{cx-export-BEeF6ymo.js → cx-export-Bt6NoqTQ.js} +3 -3
  20. package/dist/chunks/{cx-export-BEeF6ymo.js.map → cx-export-Bt6NoqTQ.js.map} +1 -1
  21. package/dist/chunks/descriptor-B28U25x4.js +60 -0
  22. package/dist/chunks/descriptor-B28U25x4.js.map +1 -0
  23. package/dist/chunks/{descriptor-BJ-W0Jd-.js → descriptor-DLA5kINx.js} +7 -2
  24. package/dist/chunks/descriptor-DLA5kINx.js.map +1 -0
  25. package/dist/chunks/{emit-CD8xnY8s.js → emit-BwHQkZle.js} +1660 -133
  26. package/dist/chunks/emit-BwHQkZle.js.map +1 -0
  27. package/dist/chunks/{escape-DH2Egt-l.js → escape-CuCIzNMB.js} +8 -8
  28. package/dist/chunks/{escape-DH2Egt-l.js.map → escape-CuCIzNMB.js.map} +1 -1
  29. package/dist/chunks/{export-CZ7VRm4I.js → export-Cha4dRFz.js} +45 -387
  30. package/dist/chunks/export-Cha4dRFz.js.map +1 -0
  31. package/dist/chunks/{exporter-Dcw7Ldtq.js → exporter-BP6otMO6.js} +6 -6
  32. package/dist/chunks/{exporter-Dcw7Ldtq.js.map → exporter-BP6otMO6.js.map} +1 -1
  33. package/dist/chunks/{exporter-bxxjOrDZ.js → exporter-D2CETOMK.js} +1222 -156
  34. package/dist/chunks/exporter-D2CETOMK.js.map +1 -0
  35. package/dist/chunks/{exporter-BIdaoIgh.js → exporter-D9yMtocA.js} +7 -7
  36. package/dist/chunks/{exporter-BIdaoIgh.js.map → exporter-D9yMtocA.js.map} +1 -1
  37. package/dist/chunks/{exporter-DtVU80Fa.js → exporter-_jrBTnos.js} +9 -8
  38. package/dist/chunks/{exporter-DtVU80Fa.js.map → exporter-_jrBTnos.js.map} +1 -1
  39. package/dist/chunks/{exporter-ChjL5fmP.js → exporter-nDfxIK5D.js} +9 -8
  40. package/dist/chunks/{exporter-ChjL5fmP.js.map → exporter-nDfxIK5D.js.map} +1 -1
  41. package/dist/chunks/format-BXiAb-1h.js +408 -0
  42. package/dist/chunks/format-BXiAb-1h.js.map +1 -0
  43. package/dist/chunks/{generic-CP6YD34u.js → generic-ymWCETAJ.js} +387 -31
  44. package/dist/chunks/generic-ymWCETAJ.js.map +1 -0
  45. package/dist/chunks/{importer-e3huMZbm.js → importer-B92x1xY5.js} +14 -10
  46. package/dist/chunks/importer-B92x1xY5.js.map +1 -0
  47. package/dist/chunks/{importer-B87_fmVx.js → importer-CT9mJ1nn.js} +326 -84
  48. package/dist/chunks/importer-CT9mJ1nn.js.map +1 -0
  49. package/dist/chunks/{importer-CB_zV5_L.js → importer-DaLTjbds.js} +116 -1102
  50. package/dist/chunks/importer-DaLTjbds.js.map +1 -0
  51. package/dist/chunks/{importer-DPZDN40-.js → importer-GREKMdIf.js} +25 -17
  52. package/dist/chunks/importer-GREKMdIf.js.map +1 -0
  53. package/dist/chunks/{importer-Bji2MeWr.js → importer-PqaaKKnY.js} +13 -10
  54. package/dist/chunks/{importer-Bji2MeWr.js.map → importer-PqaaKKnY.js.map} +1 -1
  55. package/dist/chunks/{importer-Cyy6UseH.js → importer-Vn5QvmmJ.js} +66 -13
  56. package/dist/chunks/importer-Vn5QvmmJ.js.map +1 -0
  57. package/dist/chunks/{importer-CVT-JyDE.js → importer-vRq4h3j5.js} +1469 -356
  58. package/dist/chunks/importer-vRq4h3j5.js.map +1 -0
  59. package/dist/chunks/{input-Ccg9I22A.js → input-CAxt_aV-.js} +4 -4
  60. package/dist/chunks/{input-Ccg9I22A.js.map → input-CAxt_aV-.js.map} +1 -1
  61. package/dist/chunks/{json-elements-By172SVq.js → json-elements-Cq76WjnZ.js} +4 -4
  62. package/dist/chunks/{json-elements-By172SVq.js.map → json-elements-Cq76WjnZ.js.map} +1 -1
  63. package/dist/chunks/{lexicon-u2SI5xcx.js → lexicon-Clf4QIyl.js} +282 -74
  64. package/dist/chunks/lexicon-Clf4QIyl.js.map +1 -0
  65. package/dist/chunks/{ontology-export-BwgMyuF0.js → ontology-export-OMo91mb0.js} +4 -4
  66. package/dist/chunks/{ontology-export-BwgMyuF0.js.map → ontology-export-OMo91mb0.js.map} +1 -1
  67. package/dist/chunks/{records-Cgvxz-Vx.js → records-NJiYvekn.js} +2 -2
  68. package/dist/chunks/{records-Cgvxz-Vx.js.map → records-NJiYvekn.js.map} +1 -1
  69. package/dist/chunks/{report-CgdsL9Hb.js → report-CwMfYa9J.js} +23 -23
  70. package/dist/chunks/{report-CgdsL9Hb.js.map → report-CwMfYa9J.js.map} +1 -1
  71. package/dist/chunks/round-trip-Zm3_ivgq.js +79 -0
  72. package/dist/chunks/round-trip-Zm3_ivgq.js.map +1 -0
  73. package/dist/chunks/{sigv4-LkAzsLAu.js → sigv4-EokFic1V.js} +5 -5
  74. package/dist/chunks/sigv4-EokFic1V.js.map +1 -0
  75. package/dist/chunks/{styles-CaABMoO1.js → styles-CCs214_3.js} +1237 -138
  76. package/dist/chunks/styles-CCs214_3.js.map +1 -0
  77. package/dist/chunks/styles-Cm62yyQX.js +2812 -0
  78. package/dist/chunks/styles-Cm62yyQX.js.map +1 -0
  79. package/dist/chunks/styles-DPQQIig4.js +1928 -0
  80. package/dist/chunks/styles-DPQQIig4.js.map +1 -0
  81. package/dist/chunks/{styles-yed-Cs1nmrjn.js → styles-yed-UMFdNqze.js} +503 -172
  82. package/dist/chunks/styles-yed-UMFdNqze.js.map +1 -0
  83. package/dist/chunks/{text-BuKQVMz2.js → text-ystE2bYi.js} +2 -2
  84. package/dist/chunks/{text-BuKQVMz2.js.map → text-ystE2bYi.js.map} +1 -1
  85. package/dist/csv.js +7 -7
  86. package/dist/cx.js +2 -2
  87. package/dist/cx2.js +2 -2
  88. package/dist/cys.js +1 -1
  89. package/dist/dot.js +5 -4
  90. package/dist/dot.js.map +1 -1
  91. package/dist/gexf.js +42 -12
  92. package/dist/gexf.js.map +1 -1
  93. package/dist/gml.js +847 -193
  94. package/dist/gml.js.map +1 -1
  95. package/dist/graph-io.js +232 -220
  96. package/dist/graph-io.js.map +1 -1
  97. package/dist/graphml.js +3 -3
  98. package/dist/json.js +3 -2
  99. package/dist/neo4j.js +6 -6
  100. package/dist/obo.js +1 -1
  101. package/dist/pajek.js +1 -1
  102. package/dist/positions.js +45 -3
  103. package/dist/positions.js.map +1 -1
  104. package/dist/sources-cypher.js +138 -23
  105. package/dist/sources-cypher.js.map +1 -1
  106. package/dist/sources-ndex.js +2 -2
  107. package/dist/sources-rest.js +16 -6
  108. package/dist/sources-rest.js.map +1 -1
  109. package/dist/sources-sparql.d.ts +1 -0
  110. package/dist/sources-sparql.js +405 -0
  111. package/dist/sources-sparql.js.map +1 -0
  112. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  113. package/dist/src/formats/cx/importer.js +5 -1
  114. package/dist/src/formats/cx/importer.js.map +1 -1
  115. package/dist/src/formats/cx/styles.d.ts +24 -1
  116. package/dist/src/formats/cx/styles.d.ts.map +1 -1
  117. package/dist/src/formats/cx/styles.js +117 -11
  118. package/dist/src/formats/cx/styles.js.map +1 -1
  119. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  120. package/dist/src/formats/cx2/importer.js +1 -0
  121. package/dist/src/formats/cx2/importer.js.map +1 -1
  122. package/dist/src/formats/cx2/styles.d.ts.map +1 -1
  123. package/dist/src/formats/cx2/styles.js +3 -1
  124. package/dist/src/formats/cx2/styles.js.map +1 -1
  125. package/dist/src/formats/cys/importer.d.ts.map +1 -1
  126. package/dist/src/formats/cys/importer.js +1 -0
  127. package/dist/src/formats/cys/importer.js.map +1 -1
  128. package/dist/src/formats/cys/styles.d.ts +2 -0
  129. package/dist/src/formats/cys/styles.d.ts.map +1 -1
  130. package/dist/src/formats/cys/styles.js +15 -7
  131. package/dist/src/formats/cys/styles.js.map +1 -1
  132. package/dist/src/formats/dot/drawing.d.ts +98 -0
  133. package/dist/src/formats/dot/drawing.d.ts.map +1 -0
  134. package/dist/src/formats/dot/drawing.js +734 -0
  135. package/dist/src/formats/dot/drawing.js.map +1 -0
  136. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  137. package/dist/src/formats/dot/importer.js +108 -31
  138. package/dist/src/formats/dot/importer.js.map +1 -1
  139. package/dist/src/formats/dot/label-places.d.ts +34 -0
  140. package/dist/src/formats/dot/label-places.d.ts.map +1 -0
  141. package/dist/src/formats/dot/label-places.js +179 -0
  142. package/dist/src/formats/dot/label-places.js.map +1 -0
  143. package/dist/src/formats/dot/record.d.ts +50 -0
  144. package/dist/src/formats/dot/record.d.ts.map +1 -0
  145. package/dist/src/formats/dot/record.js +275 -0
  146. package/dist/src/formats/dot/record.js.map +1 -0
  147. package/dist/src/formats/dot/styles.d.ts +62 -2
  148. package/dist/src/formats/dot/styles.d.ts.map +1 -1
  149. package/dist/src/formats/dot/styles.js +1454 -119
  150. package/dist/src/formats/dot/styles.js.map +1 -1
  151. package/dist/src/formats/gexf/dialog-metrics.d.ts +15 -0
  152. package/dist/src/formats/gexf/dialog-metrics.d.ts.map +1 -0
  153. package/dist/src/formats/gexf/dialog-metrics.js +59 -0
  154. package/dist/src/formats/gexf/dialog-metrics.js.map +1 -0
  155. package/dist/src/formats/gexf/importer.d.ts +7 -0
  156. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  157. package/dist/src/formats/gexf/importer.js +41 -5
  158. package/dist/src/formats/gexf/importer.js.map +1 -1
  159. package/dist/src/formats/gexf/preview.d.ts +77 -0
  160. package/dist/src/formats/gexf/preview.d.ts.map +1 -0
  161. package/dist/src/formats/gexf/preview.js +191 -0
  162. package/dist/src/formats/gexf/preview.js.map +1 -0
  163. package/dist/src/formats/gexf/schema.d.ts.map +1 -1
  164. package/dist/src/formats/gexf/schema.js +2 -1
  165. package/dist/src/formats/gexf/schema.js.map +1 -1
  166. package/dist/src/formats/gexf/styles.d.ts +58 -31
  167. package/dist/src/formats/gexf/styles.d.ts.map +1 -1
  168. package/dist/src/formats/gexf/styles.js +848 -225
  169. package/dist/src/formats/gexf/styles.js.map +1 -1
  170. package/dist/src/formats/gml/importer.d.ts +5 -2
  171. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  172. package/dist/src/formats/gml/importer.js +258 -71
  173. package/dist/src/formats/gml/importer.js.map +1 -1
  174. package/dist/src/formats/gml/index.d.ts +1 -1
  175. package/dist/src/formats/gml/index.d.ts.map +1 -1
  176. package/dist/src/formats/gml/index.js +1 -1
  177. package/dist/src/formats/gml/index.js.map +1 -1
  178. package/dist/src/formats/gml/positions.d.ts +7 -0
  179. package/dist/src/formats/gml/positions.d.ts.map +1 -1
  180. package/dist/src/formats/gml/positions.js +29 -7
  181. package/dist/src/formats/gml/positions.js.map +1 -1
  182. package/dist/src/formats/gml/styles.d.ts.map +1 -1
  183. package/dist/src/formats/gml/styles.js +753 -101
  184. package/dist/src/formats/gml/styles.js.map +1 -1
  185. package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
  186. package/dist/src/formats/graphml/styles-plain.js +6 -10
  187. package/dist/src/formats/graphml/styles-plain.js.map +1 -1
  188. package/dist/src/formats/graphml/styles-yed.d.ts +21 -15
  189. package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
  190. package/dist/src/formats/graphml/styles-yed.js +692 -161
  191. package/dist/src/formats/graphml/styles-yed.js.map +1 -1
  192. package/dist/src/formats/graphml/styles-yfiles3.d.ts +1 -1
  193. package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -1
  194. package/dist/src/formats/graphml/styles-yfiles3.js +429 -64
  195. package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -1
  196. package/dist/src/formats/graphml/yfiles.d.ts +3 -3
  197. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  198. package/dist/src/formats/graphml/yfiles.js +16 -6
  199. package/dist/src/formats/graphml/yfiles.js.map +1 -1
  200. package/dist/src/formats/json/dialect.d.ts +3 -2
  201. package/dist/src/formats/json/dialect.d.ts.map +1 -1
  202. package/dist/src/formats/json/dialect.js +39 -5
  203. package/dist/src/formats/json/dialect.js.map +1 -1
  204. package/dist/src/formats/json/importer.d.ts +13 -2
  205. package/dist/src/formats/json/importer.d.ts.map +1 -1
  206. package/dist/src/formats/json/importer.js +42 -6
  207. package/dist/src/formats/json/importer.js.map +1 -1
  208. package/dist/src/formats/json/index.d.ts +1 -1
  209. package/dist/src/formats/json/index.d.ts.map +1 -1
  210. package/dist/src/formats/json/index.js +1 -1
  211. package/dist/src/formats/json/index.js.map +1 -1
  212. package/dist/src/formats/json/positions.d.ts +5 -2
  213. package/dist/src/formats/json/positions.d.ts.map +1 -1
  214. package/dist/src/formats/json/positions.js +20 -4
  215. package/dist/src/formats/json/positions.js.map +1 -1
  216. package/dist/src/formats/json/styles.d.ts +12 -1
  217. package/dist/src/formats/json/styles.d.ts.map +1 -1
  218. package/dist/src/formats/json/styles.js +1755 -136
  219. package/dist/src/formats/json/styles.js.map +1 -1
  220. package/dist/src/formats/pajek/draw.d.ts +96 -0
  221. package/dist/src/formats/pajek/draw.d.ts.map +1 -0
  222. package/dist/src/formats/pajek/draw.js +372 -0
  223. package/dist/src/formats/pajek/draw.js.map +1 -0
  224. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  225. package/dist/src/formats/pajek/exporter.js +70 -51
  226. package/dist/src/formats/pajek/exporter.js.map +1 -1
  227. package/dist/src/formats/pajek/importer.d.ts +9 -0
  228. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  229. package/dist/src/formats/pajek/importer.js +233 -102
  230. package/dist/src/formats/pajek/importer.js.map +1 -1
  231. package/dist/src/formats/pajek/index.d.ts +1 -0
  232. package/dist/src/formats/pajek/index.d.ts.map +1 -1
  233. package/dist/src/formats/pajek/index.js.map +1 -1
  234. package/dist/src/formats/pajek/styles.d.ts +15 -7
  235. package/dist/src/formats/pajek/styles.d.ts.map +1 -1
  236. package/dist/src/formats/pajek/styles.js +1278 -114
  237. package/dist/src/formats/pajek/styles.js.map +1 -1
  238. package/dist/src/formats/pajek/syntax.d.ts +10 -1
  239. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  240. package/dist/src/formats/pajek/syntax.js +26 -2
  241. package/dist/src/formats/pajek/syntax.js.map +1 -1
  242. package/dist/src/formats/xgmml/emit.d.ts +1 -0
  243. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  244. package/dist/src/formats/xgmml/emit.js +65 -5
  245. package/dist/src/formats/xgmml/emit.js.map +1 -1
  246. package/dist/src/formats/xgmml/styles.d.ts +23 -3
  247. package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
  248. package/dist/src/formats/xgmml/styles.js +277 -60
  249. package/dist/src/formats/xgmml/styles.js.map +1 -1
  250. package/dist/src/index.d.ts +4 -3
  251. package/dist/src/index.d.ts.map +1 -1
  252. package/dist/src/index.js +4 -3
  253. package/dist/src/index.js.map +1 -1
  254. package/dist/src/positions/convert.d.ts.map +1 -1
  255. package/dist/src/positions/convert.js +11 -1
  256. package/dist/src/positions/convert.js.map +1 -1
  257. package/dist/src/positions/extract.d.ts.map +1 -1
  258. package/dist/src/positions/extract.js +53 -1
  259. package/dist/src/positions/extract.js.map +1 -1
  260. package/dist/src/positions/index.d.ts +1 -1
  261. package/dist/src/positions/index.d.ts.map +1 -1
  262. package/dist/src/positions/types.d.ts +59 -0
  263. package/dist/src/positions/types.d.ts.map +1 -1
  264. package/dist/src/sources/builtins.d.ts +1 -1
  265. package/dist/src/sources/builtins.d.ts.map +1 -1
  266. package/dist/src/sources/builtins.js +8 -2
  267. package/dist/src/sources/builtins.js.map +1 -1
  268. package/dist/src/sources/context.d.ts.map +1 -1
  269. package/dist/src/sources/context.js +1 -0
  270. package/dist/src/sources/context.js.map +1 -1
  271. package/dist/src/sources/cypher/descriptor.d.ts.map +1 -1
  272. package/dist/src/sources/cypher/descriptor.js +5 -0
  273. package/dist/src/sources/cypher/descriptor.js.map +1 -1
  274. package/dist/src/sources/cypher/index.d.ts.map +1 -1
  275. package/dist/src/sources/cypher/index.js +124 -18
  276. package/dist/src/sources/cypher/index.js.map +1 -1
  277. package/dist/src/sources/cypher/params.d.ts +1 -1
  278. package/dist/src/sources/cypher/params.d.ts.map +1 -1
  279. package/dist/src/sources/cypher/query-builder.d.ts +17 -0
  280. package/dist/src/sources/cypher/query-builder.d.ts.map +1 -1
  281. package/dist/src/sources/cypher/query-builder.js +31 -0
  282. package/dist/src/sources/cypher/query-builder.js.map +1 -1
  283. package/dist/src/sources/ids.d.ts +5 -0
  284. package/dist/src/sources/ids.d.ts.map +1 -1
  285. package/dist/src/sources/ids.js +5 -0
  286. package/dist/src/sources/ids.js.map +1 -1
  287. package/dist/src/sources/params.d.ts +3 -0
  288. package/dist/src/sources/params.d.ts.map +1 -1
  289. package/dist/src/sources/rest/descriptor.d.ts.map +1 -1
  290. package/dist/src/sources/rest/descriptor.js +5 -0
  291. package/dist/src/sources/rest/descriptor.js.map +1 -1
  292. package/dist/src/sources/rest/source.d.ts.map +1 -1
  293. package/dist/src/sources/rest/source.js +15 -0
  294. package/dist/src/sources/rest/source.js.map +1 -1
  295. package/dist/src/sources/sigv4.d.ts +5 -3
  296. package/dist/src/sources/sigv4.d.ts.map +1 -1
  297. package/dist/src/sources/sigv4.js +6 -4
  298. package/dist/src/sources/sigv4.js.map +1 -1
  299. package/dist/src/sources/sparql/descriptor.d.ts +10 -0
  300. package/dist/src/sources/sparql/descriptor.d.ts.map +1 -0
  301. package/dist/src/sources/sparql/descriptor.js +64 -0
  302. package/dist/src/sources/sparql/descriptor.js.map +1 -0
  303. package/dist/src/sources/sparql/index.d.ts +28 -0
  304. package/dist/src/sources/sparql/index.d.ts.map +1 -0
  305. package/dist/src/sources/sparql/index.js +314 -0
  306. package/dist/src/sources/sparql/index.js.map +1 -0
  307. package/dist/src/sources/sparql/ntriples.d.ts +69 -0
  308. package/dist/src/sources/sparql/ntriples.d.ts.map +1 -0
  309. package/dist/src/sources/sparql/ntriples.js +180 -0
  310. package/dist/src/sources/sparql/ntriples.js.map +1 -0
  311. package/dist/src/sources/sparql/params.d.ts +27 -0
  312. package/dist/src/sources/sparql/params.d.ts.map +1 -0
  313. package/dist/src/sources/sparql/params.js +5 -0
  314. package/dist/src/sources/sparql/params.js.map +1 -0
  315. package/dist/src/sources/sparql/query.d.ts +72 -0
  316. package/dist/src/sources/sparql/query.d.ts.map +1 -0
  317. package/dist/src/sources/sparql/query.js +113 -0
  318. package/dist/src/sources/sparql/query.js.map +1 -0
  319. package/dist/src/sources/types.d.ts +31 -0
  320. package/dist/src/sources/types.d.ts.map +1 -1
  321. package/dist/src/styles/annotations.d.ts +61 -5
  322. package/dist/src/styles/annotations.d.ts.map +1 -1
  323. package/dist/src/styles/annotations.js +130 -22
  324. package/dist/src/styles/annotations.js.map +1 -1
  325. package/dist/src/styles/canon/bends.d.ts +46 -0
  326. package/dist/src/styles/canon/bends.d.ts.map +1 -1
  327. package/dist/src/styles/canon/bends.js +123 -0
  328. package/dist/src/styles/canon/bends.js.map +1 -1
  329. package/dist/src/styles/canon/color-tables.d.ts +6 -1
  330. package/dist/src/styles/canon/color-tables.d.ts.map +1 -1
  331. package/dist/src/styles/canon/color-tables.js +10 -4
  332. package/dist/src/styles/canon/color-tables.js.map +1 -1
  333. package/dist/src/styles/canon/color.d.ts +3 -1
  334. package/dist/src/styles/canon/color.d.ts.map +1 -1
  335. package/dist/src/styles/canon/color.js +103 -3
  336. package/dist/src/styles/canon/color.js.map +1 -1
  337. package/dist/src/styles/canon/enums.d.ts +2 -2
  338. package/dist/src/styles/canon/enums.d.ts.map +1 -1
  339. package/dist/src/styles/canon/enums.js +81 -7
  340. package/dist/src/styles/canon/enums.js.map +1 -1
  341. package/dist/src/styles/canon/graphviz.d.ts +12 -3
  342. package/dist/src/styles/canon/graphviz.d.ts.map +1 -1
  343. package/dist/src/styles/canon/graphviz.js +57 -9
  344. package/dist/src/styles/canon/graphviz.js.map +1 -1
  345. package/dist/src/styles/canon/number.d.ts +8 -0
  346. package/dist/src/styles/canon/number.d.ts.map +1 -1
  347. package/dist/src/styles/canon/number.js +18 -0
  348. package/dist/src/styles/canon/number.js.map +1 -1
  349. package/dist/src/styles/canon/text.d.ts +29 -2
  350. package/dist/src/styles/canon/text.d.ts.map +1 -1
  351. package/dist/src/styles/canon/text.js +156 -16
  352. package/dist/src/styles/canon/text.js.map +1 -1
  353. package/dist/src/styles/codes.d.ts +2 -0
  354. package/dist/src/styles/codes.d.ts.map +1 -1
  355. package/dist/src/styles/codes.js +2 -0
  356. package/dist/src/styles/codes.js.map +1 -1
  357. package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
  358. package/dist/src/styles/cyjs/cascade.js +1015 -79
  359. package/dist/src/styles/cyjs/cascade.js.map +1 -1
  360. package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
  361. package/dist/src/styles/cyjs/defaults-table.js +3 -0
  362. package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
  363. package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
  364. package/dist/src/styles/cyjs/emit.js +202 -9
  365. package/dist/src/styles/cyjs/emit.js.map +1 -1
  366. package/dist/src/styles/cyjs/face.d.ts +20 -0
  367. package/dist/src/styles/cyjs/face.d.ts.map +1 -0
  368. package/dist/src/styles/cyjs/face.js +332 -0
  369. package/dist/src/styles/cyjs/face.js.map +1 -0
  370. package/dist/src/styles/cyjs/mappers.d.ts +44 -1
  371. package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
  372. package/dist/src/styles/cyjs/mappers.js +461 -26
  373. package/dist/src/styles/cyjs/mappers.js.map +1 -1
  374. package/dist/src/styles/cyjs/routes.d.ts +53 -0
  375. package/dist/src/styles/cyjs/routes.d.ts.map +1 -0
  376. package/dist/src/styles/cyjs/routes.js +360 -0
  377. package/dist/src/styles/cyjs/routes.js.map +1 -0
  378. package/dist/src/styles/cytoscape/charts.d.ts +23 -0
  379. package/dist/src/styles/cytoscape/charts.d.ts.map +1 -0
  380. package/dist/src/styles/cytoscape/charts.js +560 -0
  381. package/dist/src/styles/cytoscape/charts.js.map +1 -0
  382. package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
  383. package/dist/src/styles/cytoscape/emit.js +156 -48
  384. package/dist/src/styles/cytoscape/emit.js.map +1 -1
  385. package/dist/src/styles/cytoscape/lexicon.d.ts +91 -3
  386. package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
  387. package/dist/src/styles/cytoscape/lexicon.js +387 -77
  388. package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
  389. package/dist/src/styles/cytoscape/mappings.d.ts +30 -0
  390. package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -1
  391. package/dist/src/styles/cytoscape/mappings.js +92 -0
  392. package/dist/src/styles/cytoscape/mappings.js.map +1 -1
  393. package/dist/src/styles/cytoscape/resolve.d.ts +42 -2
  394. package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
  395. package/dist/src/styles/cytoscape/resolve.js +623 -17
  396. package/dist/src/styles/cytoscape/resolve.js.map +1 -1
  397. package/dist/src/styles/defaults.d.ts +46 -26
  398. package/dist/src/styles/defaults.d.ts.map +1 -1
  399. package/dist/src/styles/defaults.js +308 -71
  400. package/dist/src/styles/defaults.js.map +1 -1
  401. package/dist/src/styles/index.d.ts +4 -3
  402. package/dist/src/styles/index.d.ts.map +1 -1
  403. package/dist/src/styles/index.js +3 -2
  404. package/dist/src/styles/index.js.map +1 -1
  405. package/dist/src/styles/internal.d.ts +1 -0
  406. package/dist/src/styles/internal.d.ts.map +1 -1
  407. package/dist/src/styles/internal.js +1 -0
  408. package/dist/src/styles/internal.js.map +1 -1
  409. package/dist/src/styles/io/generic.d.ts.map +1 -1
  410. package/dist/src/styles/io/generic.js +56 -16
  411. package/dist/src/styles/io/generic.js.map +1 -1
  412. package/dist/src/styles/io/round-trip.d.ts +56 -0
  413. package/dist/src/styles/io/round-trip.d.ts.map +1 -0
  414. package/dist/src/styles/io/round-trip.js +138 -0
  415. package/dist/src/styles/io/round-trip.js.map +1 -0
  416. package/dist/src/styles/io/writer.d.ts.map +1 -1
  417. package/dist/src/styles/io/writer.js +6 -1
  418. package/dist/src/styles/io/writer.js.map +1 -1
  419. package/dist/src/styles/notes.d.ts.map +1 -1
  420. package/dist/src/styles/notes.js +1 -0
  421. package/dist/src/styles/notes.js.map +1 -1
  422. package/dist/src/styles/plan/features.d.ts +1 -1
  423. package/dist/src/styles/plan/features.d.ts.map +1 -1
  424. package/dist/src/styles/plan/features.js +22 -2
  425. package/dist/src/styles/plan/features.js.map +1 -1
  426. package/dist/src/styles/plan/index.d.ts +1 -1
  427. package/dist/src/styles/plan/index.d.ts.map +1 -1
  428. package/dist/src/styles/plan/index.js +1 -1
  429. package/dist/src/styles/plan/index.js.map +1 -1
  430. package/dist/src/styles/plan/plan.d.ts.map +1 -1
  431. package/dist/src/styles/plan/plan.js +61 -4
  432. package/dist/src/styles/plan/plan.js.map +1 -1
  433. package/dist/src/styles/plan/resolve.d.ts +11 -0
  434. package/dist/src/styles/plan/resolve.d.ts.map +1 -1
  435. package/dist/src/styles/plan/resolve.js +40 -4
  436. package/dist/src/styles/plan/resolve.js.map +1 -1
  437. package/dist/src/styles/slots.d.ts +14 -0
  438. package/dist/src/styles/slots.d.ts.map +1 -0
  439. package/dist/src/styles/slots.js +20 -0
  440. package/dist/src/styles/slots.js.map +1 -0
  441. package/dist/src/styles/types.d.ts +622 -6
  442. package/dist/src/styles/types.d.ts.map +1 -1
  443. package/dist/src/styles/vocabulary.d.ts +3 -2
  444. package/dist/src/styles/vocabulary.d.ts.map +1 -1
  445. package/dist/src/styles/vocabulary.js +203 -0
  446. package/dist/src/styles/vocabulary.js.map +1 -1
  447. package/dist/styles.js +30 -239
  448. package/dist/styles.js.map +1 -1
  449. package/dist/xgmml.js +3 -3
  450. package/package.json +27 -7
  451. package/src/formats/cx/importer.ts +6 -1
  452. package/src/formats/cx/styles.ts +143 -9
  453. package/src/formats/cx2/importer.ts +1 -0
  454. package/src/formats/cx2/styles.ts +3 -1
  455. package/src/formats/cys/importer.ts +1 -0
  456. package/src/formats/cys/styles.ts +27 -5
  457. package/src/formats/dot/drawing.ts +799 -0
  458. package/src/formats/dot/importer.ts +120 -35
  459. package/src/formats/dot/label-places.ts +228 -0
  460. package/src/formats/dot/record.ts +336 -0
  461. package/src/formats/dot/styles.ts +1654 -153
  462. package/src/formats/gexf/dialog-metrics.ts +61 -0
  463. package/src/formats/gexf/importer.ts +50 -5
  464. package/src/formats/gexf/preview.ts +217 -0
  465. package/src/formats/gexf/schema.ts +2 -1
  466. package/src/formats/gexf/styles.ts +1099 -245
  467. package/src/formats/gml/importer.ts +291 -76
  468. package/src/formats/gml/index.ts +1 -1
  469. package/src/formats/gml/positions.ts +29 -7
  470. package/src/formats/gml/styles.ts +851 -109
  471. package/src/formats/graphml/styles-plain.ts +6 -15
  472. package/src/formats/graphml/styles-yed.ts +762 -173
  473. package/src/formats/graphml/styles-yfiles3.ts +485 -63
  474. package/src/formats/graphml/yfiles.ts +19 -6
  475. package/src/formats/json/dialect.ts +41 -5
  476. package/src/formats/json/importer.ts +59 -7
  477. package/src/formats/json/index.ts +1 -0
  478. package/src/formats/json/positions.ts +22 -5
  479. package/src/formats/json/styles.ts +2041 -185
  480. package/src/formats/pajek/draw.ts +458 -0
  481. package/src/formats/pajek/exporter.ts +81 -49
  482. package/src/formats/pajek/importer.ts +278 -103
  483. package/src/formats/pajek/index.ts +1 -0
  484. package/src/formats/pajek/styles.ts +1381 -133
  485. package/src/formats/pajek/syntax.ts +27 -2
  486. package/src/formats/xgmml/emit.ts +73 -5
  487. package/src/formats/xgmml/styles.ts +330 -71
  488. package/src/index.ts +5 -1
  489. package/src/positions/convert.ts +12 -1
  490. package/src/positions/extract.ts +55 -1
  491. package/src/positions/index.ts +1 -0
  492. package/src/positions/types.ts +60 -0
  493. package/src/sources/builtins.ts +8 -1
  494. package/src/sources/context.ts +1 -0
  495. package/src/sources/cypher/descriptor.ts +7 -1
  496. package/src/sources/cypher/index.ts +148 -18
  497. package/src/sources/cypher/params.ts +1 -1
  498. package/src/sources/cypher/query-builder.ts +33 -0
  499. package/src/sources/ids.ts +6 -0
  500. package/src/sources/params.ts +3 -0
  501. package/src/sources/rest/descriptor.ts +5 -0
  502. package/src/sources/rest/source.ts +16 -0
  503. package/src/sources/sigv4.ts +6 -4
  504. package/src/sources/sparql/descriptor.ts +67 -0
  505. package/src/sources/sparql/index.ts +356 -0
  506. package/src/sources/sparql/ntriples.ts +219 -0
  507. package/src/sources/sparql/params.ts +28 -0
  508. package/src/sources/sparql/query.ts +162 -0
  509. package/src/sources/types.ts +35 -0
  510. package/src/styles/annotations.ts +201 -27
  511. package/src/styles/canon/bends.ts +137 -0
  512. package/src/styles/canon/color-tables.ts +10 -4
  513. package/src/styles/canon/color.ts +105 -3
  514. package/src/styles/canon/enums.ts +98 -8
  515. package/src/styles/canon/graphviz.ts +71 -10
  516. package/src/styles/canon/number.ts +19 -0
  517. package/src/styles/canon/text.ts +187 -16
  518. package/src/styles/codes.ts +2 -0
  519. package/src/styles/cyjs/cascade.ts +1160 -84
  520. package/src/styles/cyjs/defaults-table.ts +3 -0
  521. package/src/styles/cyjs/emit.ts +233 -13
  522. package/src/styles/cyjs/face.ts +372 -0
  523. package/src/styles/cyjs/mappers.ts +492 -27
  524. package/src/styles/cyjs/routes.ts +432 -0
  525. package/src/styles/cytoscape/charts.ts +684 -0
  526. package/src/styles/cytoscape/emit.ts +170 -48
  527. package/src/styles/cytoscape/lexicon.ts +431 -78
  528. package/src/styles/cytoscape/mappings.ts +108 -0
  529. package/src/styles/cytoscape/resolve.ts +741 -17
  530. package/src/styles/defaults.ts +417 -108
  531. package/src/styles/index.ts +5 -0
  532. package/src/styles/internal.ts +1 -0
  533. package/src/styles/io/generic.ts +79 -23
  534. package/src/styles/io/round-trip.ts +202 -0
  535. package/src/styles/io/writer.ts +6 -1
  536. package/src/styles/notes.ts +1 -0
  537. package/src/styles/plan/features.ts +23 -2
  538. package/src/styles/plan/index.ts +1 -1
  539. package/src/styles/plan/plan.ts +69 -5
  540. package/src/styles/plan/resolve.ts +47 -4
  541. package/src/styles/slots.ts +25 -0
  542. package/src/styles/types.ts +633 -5
  543. package/src/styles/vocabulary.ts +211 -2
  544. package/dist/chunks/block-Cu22ewuS.js.map +0 -1
  545. package/dist/chunks/choose-Cdx6Enl2.js +0 -57
  546. package/dist/chunks/choose-Cdx6Enl2.js.map +0 -1
  547. package/dist/chunks/codes-CV_Bhcyi.js.map +0 -1
  548. package/dist/chunks/convert-BcQ8_jMo.js.map +0 -1
  549. package/dist/chunks/credentials-BiQsnMTb.js.map +0 -1
  550. package/dist/chunks/descriptor-BJ-W0Jd-.js.map +0 -1
  551. package/dist/chunks/emit-CD8xnY8s.js.map +0 -1
  552. package/dist/chunks/export-CZ7VRm4I.js.map +0 -1
  553. package/dist/chunks/exporter-bxxjOrDZ.js.map +0 -1
  554. package/dist/chunks/format-BMS-1Nxb.js +0 -64
  555. package/dist/chunks/format-BMS-1Nxb.js.map +0 -1
  556. package/dist/chunks/generic-CP6YD34u.js.map +0 -1
  557. package/dist/chunks/importer-B87_fmVx.js.map +0 -1
  558. package/dist/chunks/importer-CB_zV5_L.js.map +0 -1
  559. package/dist/chunks/importer-CVT-JyDE.js.map +0 -1
  560. package/dist/chunks/importer-Cyy6UseH.js.map +0 -1
  561. package/dist/chunks/importer-DPZDN40-.js.map +0 -1
  562. package/dist/chunks/importer-e3huMZbm.js.map +0 -1
  563. package/dist/chunks/lexicon-u2SI5xcx.js.map +0 -1
  564. package/dist/chunks/sigv4-LkAzsLAu.js.map +0 -1
  565. package/dist/chunks/styles-CaABMoO1.js.map +0 -1
  566. package/dist/chunks/styles-P_gmFAOi.js +0 -770
  567. package/dist/chunks/styles-P_gmFAOi.js.map +0 -1
  568. package/dist/chunks/styles-yed-Cs1nmrjn.js.map +0 -1
  569. package/dist/chunks/writer-DvHTl36J.js +0 -449
  570. package/dist/chunks/writer-DvHTl36J.js.map +0 -1
@@ -36,7 +36,9 @@ import { STYLE_ISSUE } from "../codes.js";
36
36
  import { StyleNotes } from "../notes.js";
37
37
  import { canonicalFor, degreeValues, evalContinuous, numberOf, plainCell } from "../plan/resolve.js";
38
38
  import { CYJS_DEFAULT_STYLESHEET, CYJS_PROPERTY_DEFAULTS } from "./defaults-table.js";
39
- import { applyCyjsMapper, CYJS_THROWS, cyjsNeutral, cyjsProperties, cyjsPropertyName, cyjsRendered, parseCyjsValue, } from "./mappers.js";
39
+ import { combineFace } from "./face.js";
40
+ import { applyCyjsMapper, CYJS_CURVE_STYLES, CYJS_THROWS, cyjsAliasOf, cyjsDashLook, cyjsNeutral, cyjsPolygonShapes, cyjsProperties, cyjsPropertyName, cyjsRendered, gradientStopColors, gradientStops, parseCyjsValue, } from "./mappers.js";
41
+ import { cyjsRoute } from "./routes.js";
40
42
  import { parseCyjsSelector } from "./selector.js";
41
43
  import { parseCyjsStylesheetText } from "./stylesheet-text.js";
42
44
  /**
@@ -927,6 +929,17 @@ const POSITIONS = new Map([
927
929
  ["bottom,center", "bottom"],
928
930
  ["bottom,right", "bottom-right"],
929
931
  ]);
932
+ /** The positions inside the node, by the sides the `-inside` alignments name (`center` for neither). */
933
+ const INSIDE_POSITIONS = new Map([
934
+ ["top,left", "inside-top-left"],
935
+ ["top,center", "inside-top"],
936
+ ["top,right", "inside-top-right"],
937
+ ["center,left", "inside-left"],
938
+ ["center,right", "inside-right"],
939
+ ["bottom,left", "inside-bottom-left"],
940
+ ["bottom,center", "inside-bottom"],
941
+ ["bottom,right", "inside-bottom-right"],
942
+ ]);
930
943
  /**
931
944
  * Applies a Cytoscape.js stylesheet to its elements as Cytoscape.js 3.34 does.
932
945
  * @param input - the elements, the stylesheet, the graph and the options
@@ -977,8 +990,8 @@ export function evaluateCytoscapeJs(input) {
977
990
  notes.add(STYLE_ISSUE.SELECTOR, null, "selector", { count: deep, sample: "nested too deep" });
978
991
  }
979
992
  const matcher = new Matcher(graph, notes);
980
- const node = evaluateTarget("node", graph, sheet, matcher, input, notes, budget);
981
- const edge = evaluateTarget("edge", graph, sheet, matcher, input, notes, budget);
993
+ const node = evaluateTarget("node", graph, sheet, matcher, input, { notes, budget, nodes: null });
994
+ const edge = evaluateTarget("edge", graph, sheet, matcher, input, { notes, budget, nodes: node });
982
995
  return { node, edge, graph };
983
996
  }
984
997
  /**
@@ -1059,11 +1072,14 @@ function cellsOf(cells, name, n) {
1059
1072
  * @param sheet - the entries
1060
1073
  * @param matcher - the selector evaluator
1061
1074
  * @param input - the input
1062
- * @param notes - where problems are noted
1063
- * @param budget - the counted budget
1075
+ * @param env - where problems are noted, the counted budget, and for edges the nodes' values
1076
+ * @param env.notes - where problems are noted
1077
+ * @param env.budget - the counted budget
1078
+ * @param env.nodes - the nodes' values, which edge routes are measured against (null for nodes)
1064
1079
  * @returns the target's values and rules
1065
1080
  */
1066
- function evaluateTarget(kind, graph, sheet, matcher, input, notes, budget) {
1081
+ function evaluateTarget(kind, graph, sheet, matcher, input, env) {
1082
+ const { notes, budget } = env;
1067
1083
  const els = kind === "node" ? graph.nodes : graph.edges;
1068
1084
  const spend = (ops) => {
1069
1085
  budget.spend(kind, ops);
@@ -1081,6 +1097,21 @@ function evaluateTarget(kind, graph, sheet, matcher, input, notes, budget) {
1081
1097
  forceLoopCurves(graph, cells.get("curve-style"));
1082
1098
  }
1083
1099
  const drawn = drawnValues(kind, els, cells, order, input.rendered, notes, spend);
1100
+ // a file read with Cytoscape.js's own defaults draws an edge no rule curves as a haystack (a file graphty wrote
1101
+ // is read with graphty's)
1102
+ if (kind === "edge" && input.toolDefaults !== false) {
1103
+ const read = { kind, els, cells, order, rendered: input.rendered, notes };
1104
+ const curves = drawnColumn(read, "curve-style", CURVE_PART);
1105
+ noArrowsOnHaystacks(curves, drawn);
1106
+ if (env.nodes !== null) {
1107
+ edgeRoutes(graph, read, curves, env.nodes, drawn);
1108
+ }
1109
+ }
1110
+ if (kind === "node") {
1111
+ const read = { kind, els, cells, order, rendered: input.rendered, notes };
1112
+ nodeSizes(graph, read, drawn);
1113
+ mixedLabelPlaces(graph, read, drawn);
1114
+ }
1084
1115
  if (kind === "edge") {
1085
1116
  straightenUnpairedBeziers(graph, curveStyles(graph, cells, input.rendered), coreToOut, drawn.curved);
1086
1117
  }
@@ -1231,7 +1262,7 @@ function drawnValues(kind, els, cells, order, rendered, notes, spend) {
1231
1262
  const col = drawnColumn(drawnOf, name, spec);
1232
1263
  spend(2 * out);
1233
1264
  if (spec.property.startsWith("_")) {
1234
- words.set(spec.property, col.map((v) => (typeof v === "string" ? v : null)));
1265
+ words.set(spec.property, col.map((v) => (typeof v === "string" || typeof v === "number" ? String(v) : null)));
1235
1266
  continue;
1236
1267
  }
1237
1268
  values[_a = spec.property] ?? (values[_a] = new Array(out).fill(null));
@@ -1243,6 +1274,9 @@ function drawnValues(kind, els, cells, order, rendered, notes, spend) {
1243
1274
  });
1244
1275
  }
1245
1276
  combineParts(kind, out, words, values, notes);
1277
+ if (kind === "node") {
1278
+ cyjsPolygonShapes(values);
1279
+ }
1246
1280
  const drawn = {};
1247
1281
  for (const [p, col] of Object.entries(values)) {
1248
1282
  if (col.some((v) => v !== null)) {
@@ -1389,7 +1423,7 @@ function forceLoopCurves(graph, col) {
1389
1423
  function entryProperties(entry, kind, specs, notes, notCarried) {
1390
1424
  const out = [];
1391
1425
  for (const [name0, value] of entry.properties) {
1392
- const name = entry.dashOnly ? dashOnlyName(name0) : cyjsPropertyName(name0);
1426
+ const name = entry.dashOnly ? cyjsAliasOf(name0) : cyjsPropertyName(name0);
1393
1427
  const spec = specs.get(name);
1394
1428
  if (spec === undefined) {
1395
1429
  if (kind === "node" && !CYJS_EDGE_ONLY.has(name) && !entry.tool) {
@@ -1409,28 +1443,37 @@ function entryProperties(entry, kind, specs, notes, notCarried) {
1409
1443
  }
1410
1444
  return out;
1411
1445
  }
1412
- /**
1413
- * A property name of an entry Cytoscape.js reads in dash form only: `content` is `label`, any other name as it is.
1414
- * @param name - the name as written
1415
- * @returns the name
1416
- */
1417
- function dashOnlyName(name) {
1418
- return name === "content" ? "label" : name;
1419
- }
1420
1446
  /** Edge properties a node never carries: not noted as dropped on nodes. */
1421
1447
  const CYJS_EDGE_ONLY = new Set([
1422
1448
  "line-color",
1423
1449
  "line-style",
1450
+ "line-outline-width",
1451
+ "line-outline-color",
1452
+ "line-fill",
1453
+ "line-gradient-stop-colors",
1454
+ "line-gradient-stop-positions",
1424
1455
  "target-arrow-shape",
1425
1456
  "source-arrow-shape",
1426
1457
  "target-arrow-color",
1427
1458
  "source-arrow-color",
1459
+ "mid-target-arrow-shape",
1460
+ "mid-source-arrow-shape",
1461
+ "mid-target-arrow-color",
1462
+ "mid-source-arrow-color",
1428
1463
  "target-arrow-fill",
1429
1464
  "source-arrow-fill",
1430
1465
  "curve-style",
1431
1466
  "arrow-scale",
1432
1467
  "source-label",
1433
1468
  "target-label",
1469
+ "source-text-offset",
1470
+ "target-text-offset",
1471
+ "source-text-margin-x",
1472
+ "source-text-margin-y",
1473
+ "target-text-margin-x",
1474
+ "target-text-margin-y",
1475
+ "source-text-rotation",
1476
+ "target-text-rotation",
1434
1477
  ]);
1435
1478
  /**
1436
1479
  * The elements of a target a selector matches, in order.
@@ -1548,7 +1591,8 @@ function neutralOfCell(spec, name, c, site) {
1548
1591
  return cyjsNeutral(spec, flat, site);
1549
1592
  }
1550
1593
  /**
1551
- * Combines the label alignments into `labelPosition` and `visibility` with `display` into `visible`.
1594
+ * Combines the label alignments into `labelPosition`, `text-wrap` with `text-max-width` and `text-overflow-wrap` into
1595
+ * `labelWrapWidth`, `labelWrapEllipsis` and `labelWrapAnywhere`, and `visibility` with `display` into `visible`.
1552
1596
  * @param kind - the target
1553
1597
  * @param n - the element count
1554
1598
  * @param words - the parts by internal name
@@ -1556,106 +1600,993 @@ function neutralOfCell(spec, name, c, site) {
1556
1600
  * @param notes - where problems are noted
1557
1601
  */
1558
1602
  function combineParts(kind, n, words, values, notes) {
1603
+ // the element's own opacity, before an edge's line opacity is multiplied in: its label is drawn at it
1604
+ const whole = [...(values.opacity ?? new Array(n).fill(null))];
1605
+ combineLabelOpacity(n, words, values);
1606
+ if (kind === "node") {
1607
+ combineNodeOpacity(n, words, values);
1608
+ }
1559
1609
  const va = words.get("_valign");
1560
1610
  const ha = words.get("_halign");
1561
1611
  if (kind === "node" && (va !== undefined || ha !== undefined)) {
1562
- values.labelPosition = Array.from({ length: n }, (_, i) => labelPosition(va?.[i] ?? null, ha?.[i] ?? null, (sample) => {
1563
- notes.add(STYLE_ISSUE.UNKNOWN_VALUE, kind, "labelPosition", { sample, element: i });
1564
- }));
1612
+ values.labelPosition = Array.from({ length: n }, (_, i) => labelPosition(va?.[i] ?? null, ha?.[i] ?? null));
1613
+ }
1614
+ // `text-max-width` wraps a label only under `text-wrap: wrap`; unset there, it is 9999 (cytoscape.js 3.34.3
1615
+ // dist/cytoscape.cjs.js line 18484), which wraps nothing but the label's own line breaks.
1616
+ // `text-wrap: ellipsis` cuts the label at the same width instead (3.34.3 line 25254), and
1617
+ // `text-overflow-wrap: anywhere` breaks a wrapped one between any two letters (line 25204).
1618
+ const wrap = words.get("_wrap");
1619
+ const maxWidth = words.get("_maxWidth");
1620
+ const overflow = words.get("_overflowWrap");
1621
+ if (wrap !== undefined) {
1622
+ const cut = (i) => wrap[i] === "wrap" || wrap[i] === "ellipsis";
1623
+ values.labelWrapWidth = Array.from({ length: n }, (_, i) => cut(i) && typeof maxWidth?.[i] === "string" ? Number(maxWidth[i]) : null);
1624
+ if (wrap.includes("ellipsis")) {
1625
+ values.labelWrapEllipsis = wrap.map((w) => (w === "ellipsis" ? true : null));
1626
+ }
1627
+ if (overflow?.includes("anywhere") === true) {
1628
+ values.labelWrapAnywhere = wrap.map((w, i) => (w === "wrap" && overflow[i] === "anywhere" ? true : null));
1629
+ }
1630
+ }
1631
+ if (kind === "node") {
1632
+ combineFace(n, words, values);
1633
+ combineBackgroundGradient(n, words, values, notes);
1634
+ }
1635
+ else {
1636
+ combineArrowFills(n, words, values, notes);
1637
+ combineLineOpacity(n, words.get("_lineOpacity"), values);
1638
+ }
1639
+ combineDashes(kind, n, words, values);
1640
+ combineLabelText(kind, n, words, values);
1641
+ combineLabelDress(kind, n, words, values, notes, whole);
1642
+ combineVisibility(kind, n, words, values);
1643
+ }
1644
+ /**
1645
+ * A label's opacity as Cytoscape.js draws it: its `text-opacity` times the element's `opacity` (cytoscape.js 3.34.3
1646
+ * `drawText`: `effectiveOpacity() * text-opacity`), which the label's box and its line round it are drawn at too.
1647
+ * ponytail: a compound parent's opacity, which Cytoscape.js multiplies in as well, is left out
1648
+ * @param n - the element count
1649
+ * @param words - the parts by internal name
1650
+ * @param values - the values, `opacity` still the element's own; changed in place
1651
+ */
1652
+ function combineLabelOpacity(n, words, values) {
1653
+ const text = words.get("_textOpacity");
1654
+ const whole = values.opacity;
1655
+ if (text === undefined && whole === undefined) {
1656
+ return;
1657
+ }
1658
+ const col = new Array(n).fill(null);
1659
+ for (let i = 0; i < n; i++) {
1660
+ const t = text?.[i] ?? null;
1661
+ const o = whole?.[i];
1662
+ const v = Math.round((t === null ? 1 : Number(t)) * (typeof o === "number" ? o : 1) * 1e6) / 1e6;
1663
+ // a label at full strength is left unset, as one no rule fades
1664
+ col[i] = v === 1 || !Number.isFinite(v) ? null : v;
1665
+ }
1666
+ values.labelOpacity = col;
1667
+ }
1668
+ /**
1669
+ * A node's border and outline as Cytoscape.js draws them: at their own `border-opacity` / `outline-opacity` times the
1670
+ * node's `opacity` (cytoscape.js 3.34.3 `drawNode`: `parentOpacity * borderOpacity`). A ring at full strength is left
1671
+ * unset.
1672
+ * @param n - the element count
1673
+ * @param words - the parts by internal name
1674
+ * @param values - the values, `opacity` still the node's own; changed in place
1675
+ */
1676
+ function combineNodeOpacity(n, words, values) {
1677
+ const whole = values.opacity;
1678
+ for (const [part, p] of [
1679
+ ["_ringOpacity", "borderOpacity"],
1680
+ ["_outlineRingOpacity", "outerBorderOpacity"],
1681
+ ]) {
1682
+ const own = words.get(part);
1683
+ if (own === undefined && whole === undefined) {
1684
+ continue;
1685
+ }
1686
+ values[p] = Array.from({ length: n }, (_, i) => {
1687
+ const a = own?.[i] ?? null;
1688
+ const o = whole?.[i];
1689
+ const v = Math.round((a === null ? 1 : Number(a)) * (typeof o === "number" ? o : 1) * 1e6) / 1e6;
1690
+ return v === 1 || !Number.isFinite(v) ? null : v;
1691
+ });
1692
+ }
1693
+ }
1694
+ /**
1695
+ * A dashed line or border as the line it looks like. Cytoscape.js draws `dashed` with `line-dash-pattern` (6 3) or
1696
+ * `border-dash-pattern` (4 2) in pixels whatever the width, and `dotted` as 1 1 (cytoscape.js 3.34.3 `drawEdgePath`,
1697
+ * `drawNode`), so a wide dashed line shows dots and a pattern of long and short dashes a dash-dot. The class is read
1698
+ * from the dashes and gaps against the width, a round or square cap lengthening each dash by the width.
1699
+ * ponytail: the neutral line styles name a class, not a pattern; a dash pattern slot would carry the lengths exactly
1700
+ * @param kind - the target
1701
+ * @param n - the element count
1702
+ * @param words - the parts by internal name
1703
+ * @param values - the values; changed in place
1704
+ */
1705
+ function combineDashes(kind, n, words, values) {
1706
+ // the line or border, and a node's outline, which is always dashed 4 2 with butt ends (`drawOutline`)
1707
+ const lines = kind === "edge"
1708
+ ? [["lineStyle", "width", 3, "6 3", true]]
1709
+ : [
1710
+ ["borderStyle", "borderWidth", 0, "4 2", true],
1711
+ ["outerBorderStyle", "outerBorderWidth", 0, "4 2", false],
1712
+ ];
1713
+ for (const [style, width, fallback, pattern, own] of lines) {
1714
+ const col = values[style];
1715
+ if (col !== undefined) {
1716
+ dashColumn(col, n, values[width], { fallback, pattern }, own ? words : null);
1717
+ }
1718
+ }
1719
+ }
1720
+ /**
1721
+ * One line style's dashed lines as the lines they look like.
1722
+ * @param col - the line styles; changed in place
1723
+ * @param n - the element count
1724
+ * @param widths - the lines' widths, when set
1725
+ * @param drawn - what Cytoscape.js draws when they are not set: the width and the dash pattern
1726
+ * @param drawn.fallback - the width
1727
+ * @param drawn.pattern - the dash pattern
1728
+ * @param words - the parts by internal name, or null for an outline, which has no pattern or cap of its own
1729
+ */
1730
+ function dashColumn(col, n, widths, drawn, words) {
1731
+ for (let i = 0; i < n; i++) {
1732
+ if (col[i] !== "dashed") {
1733
+ continue;
1734
+ }
1735
+ const w = widths?.[i];
1736
+ const look = dashedLook(words, i, drawn.pattern, typeof w === "number" ? w : drawn.fallback);
1737
+ if (look !== null) {
1738
+ col[i] = look;
1739
+ }
1565
1740
  }
1741
+ }
1742
+ /**
1743
+ * One dashed line's look, from its dash pattern (its own `line-dash-pattern` when it has one) and cap.
1744
+ * @param words - the parts by internal name, or null for an outline, which has no pattern or cap of its own
1745
+ * @param i - the element
1746
+ * @param pattern - the pattern Cytoscape.js draws when none is given
1747
+ * @param width - the line's width
1748
+ * @returns the line style, or null when the pattern is not a list of numbers
1749
+ */
1750
+ function dashedLook(words, i, pattern, width) {
1751
+ const dashes = (words?.get("_dashPattern")?.[i] ?? pattern)
1752
+ .split(/[\s,[\]]+/)
1753
+ .filter((t) => t !== "")
1754
+ .map((t) => Number.parseFloat(t));
1755
+ if (dashes.length === 0 || !dashes.every((d) => Number.isFinite(d))) {
1756
+ return null;
1757
+ }
1758
+ return cyjsDashLook(dashes, width, words?.get("_dashCap")?.[i] ?? "butt");
1759
+ }
1760
+ /**
1761
+ * A property's values, created (all null) when it has none yet.
1762
+ * @param values - the values by property; changed in place
1763
+ * @param property - the property
1764
+ * @param n - the element count
1765
+ * @returns its values
1766
+ */
1767
+ function columnOf(values, property, n) {
1768
+ let column = values[property];
1769
+ if (column === undefined) {
1770
+ column = new Array(n).fill(null);
1771
+ values[property] = column;
1772
+ }
1773
+ return column;
1774
+ }
1775
+ /**
1776
+ * `visibility` with `display` into `visible`. Cytoscape.js leaves the edges of a node hidden with `visibility:
1777
+ * hidden` drawn (only `display: none` takes them away), so such a node is kept and drawn at opacity 0 (its border and
1778
+ * outline too), with no label.
1779
+ * @param kind - the target
1780
+ * @param n - the element count
1781
+ * @param words - the parts by internal name
1782
+ * @param values - the values; changed in place
1783
+ */
1784
+ function combineVisibility(kind, n, words, values) {
1566
1785
  const vis = words.get("_visibility");
1567
1786
  const disp = words.get("_display");
1568
- if (vis !== undefined || disp !== undefined) {
1569
- const col = new Array(n).fill(null);
1570
- for (let i = 0; i < n; i++) {
1571
- const a = vis?.[i] ?? null;
1572
- const b = disp?.[i] ?? null;
1573
- if (a === null && b === null) {
1574
- continue;
1787
+ if (vis === undefined && disp === undefined) {
1788
+ return;
1789
+ }
1790
+ const col = new Array(n).fill(null);
1791
+ for (let i = 0; i < n; i++) {
1792
+ const a = vis?.[i] ?? null;
1793
+ const b = disp?.[i] ?? null;
1794
+ if (a === null && b === null) {
1795
+ continue;
1796
+ }
1797
+ const keptInvisible = kind === "node" && a === "hidden" && b !== "none";
1798
+ col[i] = keptInvisible || (a !== "hidden" && b !== "none");
1799
+ if (keptInvisible) {
1800
+ // nothing of it is drawn: its body, its border, its outline or its label
1801
+ for (const p of ["opacity", "borderOpacity", "outerBorderOpacity", "labelOpacity"]) {
1802
+ columnOf(values, p, n)[i] = 0;
1575
1803
  }
1576
- col[i] = a !== "hidden" && b !== "none";
1804
+ columnOf(values, "label", n)[i] = "";
1577
1805
  }
1578
- values.visible = col;
1579
- }
1580
- if (kind === "edge") {
1581
- hollowArrows("target", words.get("_targetArrowFill"), values, notes);
1582
- hollowArrows("source", words.get("_sourceArrowFill"), values, notes);
1583
1806
  }
1807
+ values.visible = col;
1584
1808
  }
1585
1809
  /**
1586
- * An entry's arrows drawn open where the same entry sets them hollow. A fill set by another entry is left to the
1587
- * per-element values the rules are checked against.
1588
- * @param setting - the entry's constants; changed in place
1589
- * @param parts - every property of the entry
1810
+ * The label's words as Cytoscape.js draws them: `text-transform`, `text-justification`, and `text-rotation` (an
1811
+ * edge's end labels' `source-` / `target-text-rotation` too) as `labelRotation`, `sourceLabelRotation` and
1812
+ * `targetLabelRotation`.
1813
+ * @param kind - the target
1814
+ * @param n - the element count
1815
+ * @param words - the parts by internal name
1816
+ * @param values - the values; changed in place
1590
1817
  */
1591
- function openArrows(setting, parts) {
1592
- for (const end of ["target", "source"]) {
1593
- // a later duplicate of a property replaces the earlier one
1594
- let fill;
1595
- for (const p of parts) {
1596
- if (p.spec.property === `_${end}ArrowFill`) {
1597
- fill = p.parsed;
1818
+ function combineLabelText(kind, n, words, values) {
1819
+ transformLabels(n, words.get("_transform"), values.label);
1820
+ // cytoscape.js 3.34.3 `labelJustification`: auto lines the lines up against the node, a label beside it on the
1821
+ // left to its right edge
1822
+ const justification = words.get("_justification");
1823
+ if (justification !== undefined && kind === "edge") {
1824
+ combineEdgeJustification(n, justification, words.get("_wrap"), values);
1825
+ }
1826
+ else if (justification !== undefined) {
1827
+ const halign = words.get("_halign");
1828
+ const AUTO = {
1829
+ left: "right",
1830
+ right: "left",
1831
+ "left-inside": "left",
1832
+ "right-inside": "right",
1833
+ };
1834
+ values.labelTextAlign = justification.map((j, i) => {
1835
+ if (j === null) {
1836
+ return null;
1598
1837
  }
1838
+ return j === "auto" ? (AUTO[halign?.[i] ?? "center"] ?? "center") : j;
1839
+ });
1840
+ }
1841
+ // an edge's `autorotate` follows its line, which the routes work out (`autorotateLabels`)
1842
+ const rotations = [
1843
+ ["_rotation", "labelRotation"],
1844
+ ["_sourceRotation", "sourceLabelRotation"],
1845
+ ["_targetRotation", "targetLabelRotation"],
1846
+ ];
1847
+ for (const [part, property] of rotations) {
1848
+ const rotation = words.get(part);
1849
+ if (rotation !== undefined) {
1850
+ values[property] = rotation.map((r) => (r === null ? null : cyjsAngleDegrees(r)));
1851
+ }
1852
+ }
1853
+ }
1854
+ /**
1855
+ * A label's `text-transform`: `uppercase` and `lowercase` change its words; anything else leaves them.
1856
+ * @param n - the element count
1857
+ * @param transform - each element's transform
1858
+ * @param label - each element's label; changed in place
1859
+ */
1860
+ function transformLabels(n, transform, label) {
1861
+ if (transform === undefined || label === undefined) {
1862
+ return;
1863
+ }
1864
+ for (let i = 0; i < n; i++) {
1865
+ const text = label[i];
1866
+ if (typeof text === "string" && transform[i] === "uppercase") {
1867
+ label[i] = text.toUpperCase();
1599
1868
  }
1600
- const shape = setting.get(`${end}Arrow`);
1601
- const open = shape === undefined ? undefined : OPEN_ARROWS.get(shape);
1602
- if (fill?.kind === "word" && fill.value === "hollow" && open !== undefined) {
1603
- setting.set(`${end}Arrow`, open);
1869
+ else if (typeof text === "string" && transform[i] === "lowercase") {
1870
+ label[i] = text.toLowerCase();
1604
1871
  }
1605
1872
  }
1606
1873
  }
1607
- /** The arrows the vocabulary has an open shape for, by their filled shape. */
1608
- const OPEN_ARROWS = new Map([
1609
- ["triangle", "triangle-open"],
1610
- ["circle", "circle-open"],
1611
- ["diamond", "diamond-open"],
1874
+ /**
1875
+ * An edge label's `text-justification` as Cytoscape.js draws it: every line centered (an edge's text is always
1876
+ * centered, cytoscape.js 3.34.3 `setupTextStyle`), the block moved half its width left for `left` and right for
1877
+ * `right`, and only for a wrapped label (`drawText`), as `labelShiftX`.
1878
+ * @param n - the element count
1879
+ * @param justification - each edge's justification
1880
+ * @param wrap - each edge's `text-wrap`
1881
+ * @param values - the values; changed in place
1882
+ */
1883
+ function combineEdgeJustification(n, justification, wrap, values) {
1884
+ const SHIFT = { left: -0.5, right: 0.5 };
1885
+ for (let i = 0; i < n; i++) {
1886
+ const shift = wrap?.[i] === "wrap" ? SHIFT[justification[i] ?? ""] : undefined;
1887
+ if (shift !== undefined) {
1888
+ columnOf(values, "labelShiftX", n)[i] = shift;
1889
+ }
1890
+ }
1891
+ }
1892
+ /**
1893
+ * A label's outline and background box as Cytoscape.js draws them: the outline only with a `text-outline-width` and
1894
+ * a `text-outline-opacity` above 0, a stroke of twice that width centered on the letters' edges (cytoscape.js
1895
+ * 3.34.3 `drawText`: `lineWidth = 2 * text-outline-width`); the box only with a `text-background-opacity` above 0
1896
+ * (its default is 0), and the line round the box (`labelBorder`); the box and the line reach `text-background-padding`
1897
+ * past the words.
1898
+ * @param kind - the target
1899
+ * @param n - the element count
1900
+ * @param words - the parts by internal name
1901
+ * @param values - the values; changed in place
1902
+ * @param notes - where problems are noted
1903
+ * @param whole - each element's own opacity, which the box is drawn at too
1904
+ */
1905
+ function combineLabelDress(kind, n, words, values, notes, whole) {
1906
+ const num = (part, i, fallback) => {
1907
+ const v = words.get(part)?.[i];
1908
+ return v === null || v === undefined ? fallback : Number(v);
1909
+ };
1910
+ const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
1911
+ const outlined = words.has("_outlineWidth");
1912
+ const boxed = words.has("_backgroundOpacity");
1913
+ const bordered = words.has("_textBorderWidth") && words.has("_textBorderOpacity");
1914
+ // each part is drawn at its own opacity times the element's; the outline at the words' opacity too (drawText)
1915
+ const at = (v) => (typeof v === "number" ? v : 1);
1916
+ const faded = (v) => {
1917
+ const r = Math.round(v * 1e6) / 1e6;
1918
+ return r < 1 ? r : null;
1919
+ };
1920
+ for (let i = 0; i < n && (outlined || boxed || bordered); i++) {
1921
+ const width = num("_outlineWidth", i, 0);
1922
+ const outlineOpacity = num("_outlineOpacity", i, 1);
1923
+ if (outlined && width > 0 && outlineOpacity > 0) {
1924
+ col("labelOutlineColor")[i] = words.get("_outlineColor")?.[i] ?? "#000000";
1925
+ col("labelOutlineWidth")[i] = 2 * width;
1926
+ col("labelOutlineOpacity")[i] = faded(outlineOpacity * at(values.labelOpacity?.[i]));
1927
+ }
1928
+ const boxOpacity = num("_backgroundOpacity", i, 0);
1929
+ const box = boxed && boxOpacity > 0;
1930
+ if (box) {
1931
+ col("labelBackground")[i] = words.get("_backgroundColor")?.[i] ?? "#000000";
1932
+ col("labelBackgroundOpacity")[i] = faded(boxOpacity * at(whole[i]));
1933
+ }
1934
+ const border = bordered && labelBorder(kind, i, words, col, notes, at(whole[i]));
1935
+ if (box || border) {
1936
+ labelBoxShape(kind, i, words, col, notes);
1937
+ }
1938
+ }
1939
+ }
1940
+ /**
1941
+ * A label's box or line round it, sized and shaped: it reaches `text-background-padding` past the words on every
1942
+ * side (0 unset), one font size tall a line (cytoscape.js 3.34.3 `calculateLabelDimensions`), its corners rounded
1943
+ * 2px for round-rectangle (`drawText`); a circle is noted.
1944
+ * @param kind - the target
1945
+ * @param i - the element
1946
+ * @param words - the parts by internal name
1947
+ * @param col - a property's values, created when absent
1948
+ * @param notes - where problems are noted
1949
+ */
1950
+ function labelBoxShape(kind, i, words, col, notes) {
1951
+ const padding = words.get("_backgroundPadding")?.[i];
1952
+ col("labelPadding")[i] = padding === null || padding === undefined ? 0 : Number(padding);
1953
+ col("labelLineHeight")[i] = 1;
1954
+ const shape = words.get("_backgroundShape")?.[i];
1955
+ if (shape === "round-rectangle" || shape === "roundrectangle") {
1956
+ col("labelCornerRadius")[i] = 2;
1957
+ }
1958
+ else if (shape === "circle") {
1959
+ // a disc as tall as the box, centered on it: no neutral box has that shape
1960
+ notes.add(STYLE_ISSUE.APPROXIMATED, kind, "labelBackground", { sample: "circle", element: i });
1961
+ }
1962
+ }
1963
+ /**
1964
+ * The line Cytoscape.js draws round a label's box: only with a `text-border-width` and a `text-border-opacity` above
1965
+ * 0 (both default to 0), in `text-border-color` (black unset), at its opacity times the element's. A double one is
1966
+ * one line a quarter of the width, where `drawText` strokes two such lines half the width apart (cytoscape.js 3.34.3),
1967
+ * noted; dotted and dashed are drawn solid, noted.
1968
+ * @param kind - the target
1969
+ * @param i - the element
1970
+ * @param words - the parts by internal name
1971
+ * @param col - a property's values, created when absent
1972
+ * @param notes - where problems are noted
1973
+ * @param whole - the element's opacity
1974
+ * @returns whether a line is drawn
1975
+ */
1976
+ function labelBorder(kind, i, words, col, notes, whole) {
1977
+ const num = (part) => Number(words.get(part)?.[i] ?? 0);
1978
+ const [width, opacity] = [num("_textBorderWidth"), num("_textBorderOpacity")];
1979
+ if (!(width > 0 && opacity > 0)) {
1980
+ return false;
1981
+ }
1982
+ const style = words.get("_textBorderStyle")?.[i] ?? "solid";
1983
+ col("labelBorderColor")[i] = words.get("_textBorderColor")?.[i] ?? "#000000";
1984
+ col("labelBorderWidth")[i] = style === "double" ? width / 4 : width;
1985
+ const drawn = Math.round(opacity * whole * 1e6) / 1e6;
1986
+ col("labelBorderOpacity")[i] = drawn < 1 ? drawn : null;
1987
+ if (style === "dotted" || style === "dashed" || style === "double") {
1988
+ notes.add(STYLE_ISSUE.APPROXIMATED, kind, "labelBorderColor", { sample: style, element: i });
1989
+ }
1990
+ return true;
1991
+ }
1992
+ /**
1993
+ * An autorotated label's turn: along the line between two centers, kept upright (cytoscape.js 3.34.3
1994
+ * `lineAngleFromDelta`: atan(dy / dx), a vertical line turned to +90 whichever way it runs), from 0 up to 360.
1995
+ * @param a - the source's center
1996
+ * @param b - the target's center
1997
+ * @returns the degrees
1998
+ */
1999
+ function lineDegrees(a, b) {
2000
+ const dx = b[0] - a[0];
2001
+ const angle = Math.atan((b[1] - a[1]) / dx);
2002
+ const turn = ((dx === 0 ? Math.abs(angle) : angle) * 180) / Math.PI;
2003
+ return Number.isFinite(turn) ? Math.round((((turn % 360) + 360) % 360) * 1e6) / 1e6 + 0 : 0;
2004
+ }
2005
+ /**
2006
+ * A Cytoscape.js angle (`30deg`, `0.5rad`, a number of radians) in degrees; `none` and `autorotate` (which turns
2007
+ * only an edge's label) are 0.
2008
+ * @param text - the value
2009
+ * @returns the degrees, or null when it is not an angle
2010
+ */
2011
+ function cyjsAngleDegrees(text) {
2012
+ const t = text.trim();
2013
+ if (t === "none" || t === "autorotate") {
2014
+ return 0;
2015
+ }
2016
+ const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(deg|rad)?$/i.exec(t);
2017
+ if (m === null) {
2018
+ return null;
2019
+ }
2020
+ const x = Number(m[1]);
2021
+ const deg = m[2]?.toLowerCase() === "deg" ? x : (x * 180) / Math.PI;
2022
+ // the neutral rotation runs from 0 up to 360
2023
+ return Math.round((((deg % 360) + 360) % 360) * 1e6) / 1e6 + 0;
2024
+ }
2025
+ /**
2026
+ * An edge's `line-opacity` times its `opacity`, which the line is drawn at (cytoscape.js 3.34.3 `drawEdge`:
2027
+ * `effectiveLineOpacity`).
2028
+ * @param n - the element count
2029
+ * @param line - the line opacities, as text
2030
+ * @param values - the values; changed in place
2031
+ */
2032
+ function combineLineOpacity(n, line, values) {
2033
+ if (line === undefined) {
2034
+ return;
2035
+ }
2036
+ const whole = values.opacity;
2037
+ values.opacity = Array.from({ length: n }, (_, i) => {
2038
+ const a = line[i] === null ? null : Number(line[i]);
2039
+ const b = whole?.[i];
2040
+ if (a === null || !Number.isFinite(a)) {
2041
+ return b ?? null;
2042
+ }
2043
+ return Math.round(a * (typeof b === "number" ? b : 1) * 1e6) / 1e6;
2044
+ });
2045
+ }
2046
+ /** Where each `background-gradient-direction` runs, in the neutral `fillGradientAngle` degrees. */
2047
+ const GRADIENT_ANGLES = new Map([
2048
+ ["to-bottom", 90],
2049
+ ["to-top", 270],
2050
+ ["to-left", 180],
2051
+ ["to-right", 0],
2052
+ ["to-bottom-right", 45],
2053
+ ["to-right-bottom", 45],
2054
+ ["to-bottom-left", 135],
2055
+ ["to-left-bottom", 135],
2056
+ ["to-top-right", 315],
2057
+ ["to-right-top", 315],
2058
+ ["to-top-left", 225],
2059
+ ["to-left-top", 225],
1612
2060
  ]);
1613
2061
  /**
1614
- * Combines an end's arrow shape with its fill: a hollow arrow is the open shape. A hollow arrow the vocabulary has no
1615
- * open shape for keeps its filled shape and is noted.
1616
- * @param end - the edge end
1617
- * @param fill - the fill per element, or undefined when no rule sets it
2062
+ * A node's `background-fill: linear-gradient` or `radial-gradient` as `fill` (its first stop), `fillGradient` (its
2063
+ * last), `fillGradientAngle` (a linear one's direction), `fillGradientKind`, `fillGradientColors` (every stop, when
2064
+ * there are more than two) and `fillGradientStops` (`background-gradient-stop-positions`, when there is one per
2065
+ * color, as Cytoscape.js uses them).
2066
+ * @param n - the element count
2067
+ * @param words - the parts by internal name
1618
2068
  * @param values - the values; changed in place
1619
2069
  * @param notes - where problems are noted
1620
2070
  */
1621
- function hollowArrows(end, fill, values, notes) {
1622
- const shapes = values[`${end}Arrow`];
1623
- if (fill === undefined || shapes === undefined) {
2071
+ function combineBackgroundGradient(n, words, values, notes) {
2072
+ const fill = words.get("_backgroundFill");
2073
+ if (fill === undefined) {
1624
2074
  return;
1625
2075
  }
1626
- for (let i = 0; i < shapes.length; i++) {
1627
- const shape = shapes[i];
1628
- if (fill[i] !== "hollow" || shape === null || shape === "none") {
2076
+ const stops = words.get("_backgroundStops");
2077
+ const positions = words.get("_backgroundPositions");
2078
+ const direction = words.get("_backgroundDirection");
2079
+ const col = (name) => (values[name] ?? (values[name] = new Array(n).fill(null)));
2080
+ for (let i = 0; i < n; i++) {
2081
+ const radial = fill[i] === "radial-gradient";
2082
+ if (fill[i] !== "linear-gradient" && !radial) {
1629
2083
  continue;
1630
2084
  }
1631
- const open = OPEN_ARROWS.get(shape);
1632
- if (open === undefined) {
1633
- notes.add(STYLE_ISSUE.NOT_CARRIED, "edge", `${end}-arrow-fill`, {
1634
- sample: `hollow ${String(shape)}`,
1635
- element: i,
1636
- });
2085
+ // Cytoscape.js's default stop colors are one gray, which draws flat
2086
+ const colors = gradientStopColors(stops?.[i] ?? "#999", {
2087
+ notes,
2088
+ target: "node",
2089
+ property: "fill",
2090
+ element: i,
2091
+ });
2092
+ if (colors.length < 2) {
2093
+ continue;
2094
+ }
2095
+ col("fill")[i] = colors[0];
2096
+ col("fillGradient")[i] = colors.at(-1) ?? null;
2097
+ if (colors.length > 2) {
2098
+ col("fillGradientColors")[i] = colors.join(" ");
2099
+ }
2100
+ const placed = gradientStops(positions?.[i] ?? "");
2101
+ if (placed?.split(" ").length === colors.length) {
2102
+ col("fillGradientStops")[i] = placed;
2103
+ }
2104
+ if (radial) {
2105
+ col("fillGradientKind")[i] = "radial";
1637
2106
  }
1638
2107
  else {
1639
- shapes[i] = open;
2108
+ col("fillGradientAngle")[i] = GRADIENT_ANGLES.get(direction?.[i] ?? "to-bottom") ?? 90;
2109
+ }
2110
+ }
2111
+ }
2112
+ /** An edge's routing settings, each read as Cytoscape.js spells it. */
2113
+ const ROUTE_PARTS = [
2114
+ ["segmentDistances", "segment-distances", { property: "_segmentDistances", type: "text" }],
2115
+ ["segmentWeights", "segment-weights", { property: "_segmentWeights", type: "text" }],
2116
+ ["controlPointDistances", "control-point-distances", { property: "_controlPointDistances", type: "text" }],
2117
+ ["controlPointWeights", "control-point-weights", { property: "_controlPointWeights", type: "text" }],
2118
+ ["controlPointStepSize", "control-point-step-size", { property: "_controlPointStepSize", type: "size" }],
2119
+ ["taxiDirection", "taxi-direction", { property: "_taxiDirection", type: "text" }],
2120
+ ["taxiTurn", "taxi-turn", { property: "_taxiTurn", type: "text" }],
2121
+ ["taxiTurnMinDistance", "taxi-turn-min-distance", { property: "_taxiTurnMinDistance", type: "size" }],
2122
+ ["edgeDistances", "edge-distances", { property: "_edgeDistances", type: "text" }],
2123
+ ["loopDirection", "loop-direction", { property: "_loopDirection", type: "text" }],
2124
+ ["loopSweep", "loop-sweep", { property: "_loopSweep", type: "text" }],
2125
+ ["segmentRadii", "segment-radii", { property: "_segmentRadii", type: "text" }],
2126
+ ["taxiRadius", "taxi-radius", { property: "_taxiRadius", type: "text" }],
2127
+ ["radiusType", "radius-type", { property: "_radiusType", type: "text" }],
2128
+ ];
2129
+ /**
2130
+ * The routes of the edges Cytoscape.js does not draw straight (`segments`, `taxi`, an `unbundled-bezier` with
2131
+ * control points, a loop) as `bends`, drawn straight through them (`curved` false).
2132
+ * @param graph - the core's elements
2133
+ * @param read - the edges' cells
2134
+ * @param curves - each edge's curve style, in output order
2135
+ * @param nodes - the nodes' values
2136
+ * @param values - the edges' values; changed in place
2137
+ */
2138
+ function edgeRoutes(graph, read, curves, nodes, values) {
2139
+ const words = new Map(ROUTE_PARTS.map(([key, name, spec]) => [key, drawnColumn(read, name, spec)]));
2140
+ const nodeAt = new Map();
2141
+ nodes.elements.forEach((el, k) => {
2142
+ if (el !== null) {
2143
+ nodeAt.set(el, k);
2144
+ }
2145
+ });
2146
+ const geometry = (core) => routeNode(graph.nodes[core], nodeAt, nodes);
2147
+ // an end label's autorotate turns it as the main label's does (cytoscape.js 3.34.3 `calculateLabelAngle`)
2148
+ const turned = [
2149
+ ["labelRotation", drawnColumn(read, "text-rotation", TEXT_PART)],
2150
+ ["sourceLabelRotation", drawnColumn(read, "source-text-rotation", TEXT_PART)],
2151
+ ["targetLabelRotation", drawnColumn(read, "target-text-rotation", TEXT_PART)],
2152
+ ];
2153
+ const ends = [drawnColumn(read, "source-endpoint", TEXT_PART), drawnColumn(read, "target-endpoint", TEXT_PART)];
2154
+ const loops = new Map();
2155
+ const n = read.order.length;
2156
+ let routed = null;
2157
+ for (let k = 0; k < n; k++) {
2158
+ const e = read.order[k];
2159
+ const between = edgeNodes(graph, e, geometry);
2160
+ if (between === null) {
2161
+ continue;
2162
+ }
2163
+ const { src, tgt, loop } = between;
2164
+ if (!loop) {
2165
+ autorotateLabels(values, turned, k, n, lineDegrees(src.center, tgt.center));
2166
+ }
2167
+ const edge = routeSettings(words, k, curves[k]);
2168
+ const bends = cyjsRoute(edge, src, tgt, loop ? nextLoopIndex(loops, graph.source[e], edge) : 0);
2169
+ if (bends !== null) {
2170
+ routed ?? (routed = values.bends ?? new Array(n).fill(null));
2171
+ routed[k] = bends;
2172
+ columnOf(values, "curved", n)[k] = false;
2173
+ }
2174
+ if (!loop) {
2175
+ edgePorts(edge.curveStyle, [ends[0][k], ends[1][k]], [src, tgt], (p, port) => {
2176
+ columnOf(values, p, n)[k] = port;
2177
+ });
2178
+ }
2179
+ }
2180
+ if (routed !== null) {
2181
+ values.bends = routed;
2182
+ }
2183
+ }
2184
+ /**
2185
+ * A node's geometry as the routes measure it: its center, its outer size (its border taken in), its box and whether
2186
+ * it is an ellipse.
2187
+ * @param el - the node
2188
+ * @param nodeAt - each node's output index
2189
+ * @param nodes - the nodes' values
2190
+ * @returns the geometry, or null when the node has no position
2191
+ */
2192
+ function routeNode(el, nodeAt, nodes) {
2193
+ const k = nodeAt.get(el);
2194
+ const pos = el.json.position;
2195
+ if (k === undefined || !isObject(pos) || typeof pos.x !== "number" || typeof pos.y !== "number") {
2196
+ return null;
2197
+ }
2198
+ const num = (p, fallback) => {
2199
+ const v = nodes.values[p]?.[k];
2200
+ return typeof v === "number" ? v : fallback;
2201
+ };
2202
+ const [w, h, bw] = [num("width", 30), num("height", 30), num("borderWidth", 0)];
2203
+ return {
2204
+ center: [pos.x, pos.y],
2205
+ size: [w + bw, h + bw],
2206
+ box: [w, h],
2207
+ ellipse: (nodes.values.shape?.[k] ?? "ellipse") === "ellipse",
2208
+ };
2209
+ }
2210
+ /**
2211
+ * An edge's two nodes' geometry, and whether it is a loop.
2212
+ * @param graph - the core's elements
2213
+ * @param e - the edge's core index, below 0 for none
2214
+ * @param geometry - a node's geometry
2215
+ * @returns the source's and the target's geometry, or null when either is not known
2216
+ */
2217
+ function edgeNodes(graph, e, geometry) {
2218
+ if (e < 0) {
2219
+ return null;
2220
+ }
2221
+ const loop = graph.source[e] === graph.target[e];
2222
+ const src = geometry(graph.source[e]);
2223
+ const tgt = loop ? src : geometry(graph.target[e]);
2224
+ return src === null || tgt === null ? null : { src, tgt, loop };
2225
+ }
2226
+ /**
2227
+ * Turns each of an edge's labels set to `autorotate` along its line.
2228
+ * @param values - the edges' values; changed in place
2229
+ * @param turned - each label's rotation property and its `text-rotation` words
2230
+ * @param k - the edge's output index
2231
+ * @param n - the edge count
2232
+ * @param degrees - the line's turn
2233
+ */
2234
+ function autorotateLabels(values, turned, k, n, degrees) {
2235
+ for (const [property, column] of turned) {
2236
+ if (column[k] === "autorotate") {
2237
+ columnOf(values, property, n)[k] = degrees;
2238
+ }
2239
+ }
2240
+ }
2241
+ /**
2242
+ * A loop's place among the loops drawn before it on the same node in the same direction and sweep, which fans them.
2243
+ * @param loops - how many loops each node, direction and sweep has so far; changed in place
2244
+ * @param source - the loop's node
2245
+ * @param edge - the loop's settings
2246
+ * @returns its place, from 0
2247
+ */
2248
+ function nextLoopIndex(loops, source, edge) {
2249
+ const key = `${String(source)} ${String(edge.loopDirection)} ${String(edge.loopSweep)}`;
2250
+ const index = loops.get(key) ?? 0;
2251
+ loops.set(key, index + 1);
2252
+ return index;
2253
+ }
2254
+ /**
2255
+ * Where an edge's ends meet its nodes, when not where the line from the centers crosses the outlines (cytoscape.js
2256
+ * 3.34.3 `findEndpoints`, `manualEndptToPx`): `inside-to-node` at the center, `x y` offsets from the center (pixels,
2257
+ * or percentages of the node's outer size), an angle clockwise from 12 o'clock on the outline. A `haystack` edge
2258
+ * runs between points `haystack-radius` of the way from the centers to the outlines in a random direction
2259
+ * (`findHaystackPoints`), drawn from the centers, where a radius of 0 (the default) puts them; a taxi edge ignores its
2260
+ * endpoints.
2261
+ * ponytail: an angle meets a polygon's outline where it meets its box; per-shape outlines if a file angles one
2262
+ * @param curve - the curve style
2263
+ * @param words - the source endpoint and the target endpoint, as Cytoscape.js spells them
2264
+ * @param nodes - the source's and the target's geometry
2265
+ * @param put - sets `sourcePort` or `targetPort`
2266
+ */
2267
+ function edgePorts(curve, words, nodes, put) {
2268
+ if (curve === "taxi" || curve === "round-taxi") {
2269
+ return;
2270
+ }
2271
+ ["sourcePort", "targetPort"].forEach((p, a) => {
2272
+ const port = curve === "haystack" ? "0,0" : endpointPort(String(words[a] ?? ""), nodes[a]);
2273
+ if (port !== null) {
2274
+ put(p, port);
2275
+ }
2276
+ });
2277
+ }
2278
+ /**
2279
+ * One `source-endpoint` / `target-endpoint` as a neutral port.
2280
+ * @param text - the value
2281
+ * @param node - the node's geometry
2282
+ * @returns the port, or null where the line meets the outline as it does by default
2283
+ */
2284
+ function endpointPort(text, node) {
2285
+ const t = text.trim();
2286
+ if (t === "inside-to-node") {
2287
+ return "0,0";
2288
+ }
2289
+ const parts = t.split(/\s+/);
2290
+ const [w, h] = node.size;
2291
+ const r6 = (v) => String(Math.round(v * 1e6) / 1e6 + 0);
2292
+ const fraction = (part, size) => {
2293
+ const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+))(%|px)?$/.exec(part);
2294
+ if (m === null || Number.isNaN(size) || size <= 0) {
2295
+ return null;
2296
+ }
2297
+ const px = m[2] === "%" ? (Number(m[1]) / 100) * size : Number(m[1]);
2298
+ return px / (size / 2);
2299
+ };
2300
+ if (parts.length === 2) {
2301
+ const [x, y] = [fraction(parts[0], w), fraction(parts[1], h)];
2302
+ return x === null || y === null ? null : `${r6(x)},${r6(-y)}`;
2303
+ }
2304
+ const m = /^(-?(?:\d+(?:\.\d*)?|\.\d+))(deg|rad)$/.exec(t);
2305
+ if (m === null) {
2306
+ return null;
2307
+ }
2308
+ const turn = m[2] === "deg" ? (Number(m[1]) * Math.PI) / 180 : Number(m[1]);
2309
+ // the direction in half sizes, y up, from 12 o'clock clockwise; scaled until it meets the outline
2310
+ const [dx, dy] = [Math.sin(turn) / (w / 2), Math.cos(turn) / (h / 2)];
2311
+ const reach = node.ellipse ? Math.hypot(dx, dy) : Math.max(Math.abs(dx), Math.abs(dy));
2312
+ return reach > 0 ? `${r6(dx / reach)},${r6(dy / reach)}` : null;
2313
+ }
2314
+ /**
2315
+ * One edge's routing settings.
2316
+ * @param words - each setting's values, in output order
2317
+ * @param k - the edge's output index
2318
+ * @param curve - its curve style
2319
+ * @returns the settings
2320
+ */
2321
+ function routeSettings(words, k, curve) {
2322
+ const text = (key) => {
2323
+ const v = words.get(key)?.[k];
2324
+ return v === null || v === undefined ? null : String(v);
2325
+ };
2326
+ const num = (key) => {
2327
+ const v = text(key);
2328
+ return v === null ? null : Number(v);
2329
+ };
2330
+ return {
2331
+ curveStyle: String(curve ?? "haystack"),
2332
+ segmentDistances: text("segmentDistances"),
2333
+ segmentWeights: text("segmentWeights"),
2334
+ controlPointDistances: text("controlPointDistances"),
2335
+ controlPointWeights: text("controlPointWeights"),
2336
+ controlPointStepSize: num("controlPointStepSize"),
2337
+ taxiDirection: text("taxiDirection"),
2338
+ taxiTurn: text("taxiTurn"),
2339
+ taxiTurnMinDistance: num("taxiTurnMinDistance"),
2340
+ edgeDistances: text("edgeDistances"),
2341
+ loopDirection: text("loopDirection"),
2342
+ loopSweep: text("loopSweep"),
2343
+ segmentRadii: text("segmentRadii"),
2344
+ taxiRadius: text("taxiRadius"),
2345
+ radiusType: text("radiusType"),
2346
+ };
2347
+ }
2348
+ /** A padding read as Cytoscape.js spells it. */
2349
+ const TEXT_PART = { property: "_text", type: "text" };
2350
+ /**
2351
+ * A node's size as Cytoscape.js draws it: a node that is no compound parent is drawn `padding` larger on every side
2352
+ * (cytoscape.js 3.34.3 draws its shape `width() + 2 * padding()` across).
2353
+ * @param graph - the core's elements
2354
+ * @param read - the nodes' cells
2355
+ * @param values - the nodes' values; changed in place
2356
+ */
2357
+ function nodeSizes(graph, read, values) {
2358
+ const padding = drawnColumn(read, "padding", TEXT_PART);
2359
+ const toLabel = ["width", "height"].map((p) => drawnColumn(read, p, SIZE_PART));
2360
+ const n = read.order.length;
2361
+ const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
2362
+ for (let k = 0; k < n; k++) {
2363
+ const core = read.order[k];
2364
+ const pad = core < 0 || graph.children[core].length > 0 ? 0 : paddingOf(padding[k]);
2365
+ const fitted = toLabel.map((c) => c[k] === "label");
2366
+ if (fitted[0] || fitted[1]) {
2367
+ // `width: label` sizes the node to its label's box (cytoscape.js 3.34.3 `width()` reads the label's
2368
+ // width), padding on each side: the label's side is a minimum of 0, the other keeps its own size
2369
+ col("labelFit")[k] = "bounds";
2370
+ col("labelPaddingX")[k] = pad;
2371
+ col("labelPaddingY")[k] = pad;
2372
+ ["width", "height"].forEach((p, a) => {
2373
+ const v = values[p]?.[k];
2374
+ const side = typeof v === "number" ? v : 30;
2375
+ col(p)[k] = fitted[a] ? 0 : side + 2 * pad;
2376
+ });
2377
+ continue;
2378
+ }
2379
+ if (pad <= 0) {
2380
+ continue;
2381
+ }
2382
+ for (const p of ["width", "height"]) {
2383
+ const v = values[p]?.[k];
2384
+ col(p)[k] = (typeof v === "number" ? v : 30) + 2 * pad;
2385
+ }
2386
+ }
2387
+ }
2388
+ /** The label alignments read as Cytoscape.js's words. */
2389
+ const VALIGN_PART = {
2390
+ property: "_valign",
2391
+ type: "enum",
2392
+ enums: ["top", "top-inside", "center", "bottom", "bottom-inside"],
2393
+ };
2394
+ const HALIGN_PART = {
2395
+ property: "_halign",
2396
+ type: "enum",
2397
+ enums: ["left", "left-inside", "center", "right", "right-inside"],
2398
+ };
2399
+ /**
2400
+ * Where Cytoscape.js pins a label on one axis (cytoscape.js 3.34.3 `recalculateNodeLabelProjection` and
2401
+ * `labelHalign` / `labelValign`): outside, `padding` past the node's side with the label's far edge there; inside,
2402
+ * `padding` short of it with the label's near edge there; centered, at the node's middle.
2403
+ * @param align - the alignment (`left`, `left-inside`, `top`, ...)
2404
+ * @param half - half the node's drawn size on that axis, `padding` included
2405
+ * @param pad - the node's padding
2406
+ * @returns the offset from the node's center and the shift by the label's own size
2407
+ */
2408
+ function pinnedAxis(align, half, pad) {
2409
+ const near = /^(left|top)/.test(align);
2410
+ if (!near && !/^(right|bottom)/.test(align)) {
2411
+ return { offset: 0, shift: 0 };
2412
+ }
2413
+ const side = near ? -1 : 1;
2414
+ return align.endsWith("-inside")
2415
+ ? { offset: side * (half - 2 * pad), shift: -side / 2 }
2416
+ : { offset: side * half, shift: side / 2 };
2417
+ }
2418
+ /**
2419
+ * A node label with one alignment inside the node and the other outside it (`text-valign: bottom-inside` with
2420
+ * `text-halign: left`): no neutral position says that, so the label is centered, moved to the point Cytoscape.js
2421
+ * puts it at by `labelOffsetX` / `labelOffsetY` (its `text-margin` added) and pinned there by `labelShiftX` /
2422
+ * `labelShiftY`. A node sized to its label keeps the outside side's position, noted.
2423
+ * @param graph - the core's elements
2424
+ * @param read - the nodes' cells
2425
+ * @param values - the nodes' values, sizes already drawn (`nodeSizes`); changed in place
2426
+ */
2427
+ function mixedLabelPlaces(graph, read, values) {
2428
+ const va = drawnColumn(read, "text-valign", VALIGN_PART);
2429
+ const ha = drawnColumn(read, "text-halign", HALIGN_PART);
2430
+ const padding = drawnColumn(read, "padding", TEXT_PART);
2431
+ const n = read.order.length;
2432
+ const col = (p) => (values[p] ?? (values[p] = new Array(n).fill(null)));
2433
+ for (let k = 0; k < n; k++) {
2434
+ const v = typeof va[k] === "string" ? String(va[k]) : "top";
2435
+ const h = typeof ha[k] === "string" ? String(ha[k]) : "center";
2436
+ const inside = v.endsWith("-inside") || h.endsWith("-inside");
2437
+ const outside = v === "top" || v === "bottom" || h === "left" || h === "right";
2438
+ if (!inside || !outside) {
2439
+ continue;
2440
+ }
2441
+ if (values.labelFit?.[k] !== undefined && values.labelFit[k] !== null) {
2442
+ read.notes.add(STYLE_ISSUE.APPROXIMATED, "node", "labelPosition", { sample: `${v} ${h}`, element: k });
2443
+ continue;
2444
+ }
2445
+ const core = read.order[k];
2446
+ const pad = core < 0 || graph.children[core].length > 0 ? 0 : paddingOf(padding[k]);
2447
+ const size = (p) => {
2448
+ const s = values[p]?.[k];
2449
+ return typeof s === "number" ? s : 30 + 2 * pad;
2450
+ };
2451
+ const x = pinnedAxis(h, size("width") / 2, pad);
2452
+ const y = pinnedAxis(v, size("height") / 2, pad);
2453
+ const add = (p, d) => {
2454
+ const was = values[p]?.[k];
2455
+ col(p)[k] = (typeof was === "number" ? was : 0) + d;
2456
+ };
2457
+ col("labelPosition")[k] = "center";
2458
+ add("labelOffsetX", x.offset);
2459
+ add("labelOffsetY", y.offset);
2460
+ col("labelShiftX")[k] = x.shift;
2461
+ col("labelShiftY")[k] = y.shift;
2462
+ }
2463
+ }
2464
+ /** A node size read as Cytoscape.js's word, so `label` is seen. */
2465
+ const SIZE_PART = { property: "_size", type: "nodeSize" };
2466
+ /**
2467
+ * A node's padding in pixels. A percentage is relative only on a compound parent; on any other node Cytoscape.js
2468
+ * draws its fraction as pixels (`padding()` returns the property's `pfValue`, 0.2 for `20%`).
2469
+ * @param text - the padding as Cytoscape.js spells it, or null
2470
+ * @returns the pixels, 0 for none
2471
+ */
2472
+ function paddingOf(text) {
2473
+ if (typeof text !== "string") {
2474
+ return 0;
2475
+ }
2476
+ const x = Number.parseFloat(text);
2477
+ if (!Number.isFinite(x) || x <= 0) {
2478
+ return 0;
2479
+ }
2480
+ return text.trim().endsWith("%") ? x / 100 : x;
2481
+ }
2482
+ /** The curve style read as Cytoscape.js's word. */
2483
+ const CURVE_PART = { property: "_curve", type: "enum", enums: CYJS_CURVE_STYLES };
2484
+ /**
2485
+ * Cytoscape.js draws no source or target arrow on a `haystack` edge, its default curve style (cytoscape.js 3.34.3
2486
+ * `drawArrowheads` skips them on haystacks, but still draws the mid arrows): each end arrow of one is `none`.
2487
+ * @param curves - each edge's curve style, null where no rule sets it
2488
+ * @param values - the values; changed in place
2489
+ */
2490
+ function noArrowsOnHaystacks(curves, values) {
2491
+ const n = curves.length;
2492
+ for (const p of ["targetArrow", "sourceArrow"]) {
2493
+ const col = values[p];
2494
+ if (col === undefined) {
2495
+ continue;
2496
+ }
2497
+ for (let i = 0; i < n; i++) {
2498
+ if ((curves[i] ?? "haystack") === "haystack" && col[i] !== null) {
2499
+ col[i] = "none";
2500
+ }
2501
+ }
2502
+ }
2503
+ }
2504
+ /**
2505
+ * The outline arrow a hollow `*-arrow-fill` draws for each filled shape that has one (cytoscape.js 3.34.3 strokes the
2506
+ * arrow's path instead of filling it). A hollow square has no outline cap of its own in the neutral vocabulary;
2507
+ * `other:open-square` is drawn as the nearest one.
2508
+ */
2509
+ const HOLLOW_ARROWS = new Map([
2510
+ ["triangle", "triangle-open"],
2511
+ ["diamond", "diamond-open"],
2512
+ ["circle", "circle-open"],
2513
+ ["square", "other:open-square"],
2514
+ ]);
2515
+ /**
2516
+ * A rule that sets an arrow shape and makes it hollow sets the outline shape (`combineArrowFills` does the same per
2517
+ * element, for a fill and a shape set by different rules).
2518
+ * @param set - the rule's values; changed in place
2519
+ * @param all - every property of the rule
2520
+ */
2521
+ function hollowArrowsOfRule(set, all) {
2522
+ for (const p of all) {
2523
+ const shapeProp = /^_(\w+Arrow)Fill$/.exec(p.spec.property)?.[1];
2524
+ const shape = shapeProp === undefined ? undefined : set[shapeProp];
2525
+ if (shapeProp === undefined || shape === undefined || p.parsed.kind !== "word") {
2526
+ continue;
2527
+ }
2528
+ const open = HOLLOW_ARROWS.get(shape);
2529
+ if (open !== undefined && p.parsed.value === "hollow") {
2530
+ set[shapeProp] = open;
2531
+ }
2532
+ }
2533
+ }
2534
+ /**
2535
+ * Turns each arrow whose `*-arrow-fill` is `hollow` into its outline shape. A hollow arrow the vocabulary has no
2536
+ * outline shape for keeps its filled shape and is noted.
2537
+ * @param n - the element count
2538
+ * @param words - the parts by internal name
2539
+ * @param values - the values; changed in place
2540
+ * @param notes - where a hollow arrow drawn filled is noted
2541
+ */
2542
+ function combineArrowFills(n, words, values, notes) {
2543
+ for (const p of ["targetArrow", "sourceArrow", "midTargetArrow", "midSourceArrow"]) {
2544
+ const fill = words.get(`_${p}Fill`);
2545
+ const shapes = values[p];
2546
+ if (fill === undefined || shapes === undefined) {
2547
+ continue;
2548
+ }
2549
+ for (let i = 0; i < n; i++) {
2550
+ const shape = shapes[i];
2551
+ if (fill[i] !== "hollow" || shape === null || shape === "none") {
2552
+ continue;
2553
+ }
2554
+ const open = HOLLOW_ARROWS.get(shape);
2555
+ if (open !== undefined) {
2556
+ shapes[i] = open;
2557
+ }
2558
+ else if (!String(shape).includes("open")) {
2559
+ const property = p.replaceAll(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace("-arrow", "-arrow-fill");
2560
+ notes.add(STYLE_ISSUE.NOT_CARRIED, "edge", property, { sample: `hollow ${String(shape)}`, element: i });
2561
+ }
1640
2562
  }
1641
2563
  }
1642
2564
  }
1643
2565
  /**
1644
- * A node label's position from its vertical and horizontal alignments; an `-inside` alignment is read as its
1645
- * outside one, noted.
2566
+ * A node label's position from its vertical and horizontal alignments. Cytoscape.js 3.34 places an `-inside`
2567
+ * alignment against that side of the node, inside it (`recalculateNodeLabelProjection`): `top-inside` with
2568
+ * `center` is `inside-top`, `top-inside` with `left-inside` is `inside-top-left`. One inside and one outside
2569
+ * alignment have no neutral position of their own: the outside side here, its inside part read as centered, which
2570
+ * `mixedLabelPlaces()` replaces with the pinned place once the node's size is known.
1646
2571
  * @param v - the vertical alignment, or null
1647
2572
  * @param h - the horizontal alignment, or null
1648
- * @param note - notes an alignment read as another
1649
2573
  * @returns the position, or null
1650
2574
  */
1651
- function labelPosition(v, h, note) {
2575
+ function labelPosition(v, h) {
1652
2576
  if (v === null && h === null) {
1653
2577
  return null;
1654
2578
  }
2579
+ const vIn = (v ?? "").endsWith("-inside");
2580
+ const hIn = (h ?? "").endsWith("-inside");
1655
2581
  const vv = (v ?? "top").replace("-inside", "");
1656
2582
  const hh = (h ?? "center").replace("-inside", "");
1657
- if ((v ?? "").endsWith("-inside") || (h ?? "").endsWith("-inside")) {
1658
- note(`${v ?? ""} ${h ?? ""}`);
2583
+ if (vIn || hIn) {
2584
+ const vOut = vv !== "center" && !vIn;
2585
+ const hOut = hh !== "center" && !hIn;
2586
+ if (!vOut && !hOut) {
2587
+ return INSIDE_POSITIONS.get(`${vv},${hh}`) ?? null;
2588
+ }
2589
+ return POSITIONS.get(`${vIn ? "center" : vv},${hIn ? "center" : hh}`) ?? null;
1659
2590
  }
1660
2591
  return POSITIONS.get(`${vv},${hh}`) ?? null;
1661
2592
  }
@@ -1716,10 +2647,10 @@ function buildRules(kind, applied, core, input, truth, env) {
1716
2647
  * @param entry - the entry
1717
2648
  * @param list - the matched core elements
1718
2649
  * @param props - the carried properties
1719
- * @param parts - every property of the entry, the combined parts too: a hollow fill makes the entry's own arrow open
2650
+ * @param all - every property of the entry, the parts combined afterward too
1720
2651
  * @returns the draft
1721
2652
  */
1722
- function draftOf(ctx, entry, list, props, parts) {
2653
+ function draftOf(ctx, entry, list, props, all) {
1723
2654
  const setting = new Map();
1724
2655
  const mapping = new Map();
1725
2656
  let flattened = false;
@@ -1752,8 +2683,13 @@ function draftOf(ctx, entry, list, props, parts) {
1752
2683
  mapping.set(p.spec.property, mapperMapping(ctx, entry, list, p));
1753
2684
  }
1754
2685
  }
1755
- openArrows(setting, parts);
1756
2686
  const set = Object.fromEntries(setting);
2687
+ if (ctx.kind === "node") {
2688
+ cyjsPolygonShapes(set);
2689
+ }
2690
+ else {
2691
+ hollowArrowsOfRule(set, all);
2692
+ }
1757
2693
  const map = Object.fromEntries(mapping);
1758
2694
  const hasMap = mapping.size > 0;
1759
2695
  // the predicate is built only for a rule that is not collapsed into a run: a run's rules need no column each