@retikz/core 0.0.1-rc.3 → 0.1.0-alpha.1

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 (427) hide show
  1. package/LICENSE +21 -21
  2. package/dist/es/compile/compile.d.ts +27 -0
  3. package/dist/es/compile/compile.d.ts.map +1 -0
  4. package/dist/es/compile/compile.js +43 -0
  5. package/dist/es/compile/index.d.ts +9 -0
  6. package/dist/es/compile/index.d.ts.map +1 -0
  7. package/dist/es/compile/node.d.ts +76 -0
  8. package/dist/es/compile/node.d.ts.map +1 -0
  9. package/dist/es/compile/node.js +240 -0
  10. package/dist/es/compile/parseTarget.d.ts +25 -0
  11. package/dist/es/compile/parseTarget.d.ts.map +1 -0
  12. package/dist/es/compile/parseTarget.js +48 -0
  13. package/dist/es/compile/path.d.ts +29 -0
  14. package/dist/es/compile/path.d.ts.map +1 -0
  15. package/dist/es/compile/path.js +298 -0
  16. package/dist/es/compile/position.d.ts +9 -0
  17. package/dist/es/compile/position.d.ts.map +1 -0
  18. package/dist/es/compile/position.js +24 -0
  19. package/dist/es/compile/precision.d.ts +5 -0
  20. package/dist/es/compile/precision.d.ts.map +1 -0
  21. package/dist/es/compile/precision.js +8 -0
  22. package/dist/es/compile/text-metrics.d.ts +32 -0
  23. package/dist/es/compile/text-metrics.d.ts.map +1 -0
  24. package/dist/es/compile/text-metrics.js +8 -0
  25. package/dist/es/compile/view-box.d.ts +8 -0
  26. package/dist/es/compile/view-box.d.ts.map +1 -0
  27. package/dist/es/compile/view-box.js +31 -0
  28. package/dist/es/geometry/circle.d.ts +32 -0
  29. package/dist/es/geometry/circle.d.ts.map +1 -0
  30. package/dist/es/geometry/circle.js +79 -0
  31. package/dist/es/geometry/diamond.d.ts +44 -0
  32. package/dist/es/geometry/diamond.d.ts.map +1 -0
  33. package/dist/es/geometry/diamond.js +87 -0
  34. package/dist/es/geometry/ellipse.d.ts +38 -0
  35. package/dist/es/geometry/ellipse.d.ts.map +1 -0
  36. package/dist/es/geometry/ellipse.js +86 -0
  37. package/dist/es/geometry/index.d.ts +7 -0
  38. package/dist/es/geometry/index.d.ts.map +1 -0
  39. package/dist/es/geometry/point.d.ts +25 -0
  40. package/dist/es/geometry/point.d.ts.map +1 -0
  41. package/dist/es/geometry/point.js +34 -0
  42. package/dist/es/geometry/polar.d.ts +44 -0
  43. package/dist/es/geometry/polar.d.ts.map +1 -0
  44. package/dist/es/geometry/polar.js +45 -0
  45. package/dist/es/geometry/rect.d.ts +59 -0
  46. package/dist/es/geometry/rect.d.ts.map +1 -0
  47. package/dist/es/geometry/rect.js +120 -0
  48. package/dist/es/index.d.ts +20 -10
  49. package/dist/es/index.d.ts.map +1 -0
  50. package/dist/es/index.js +18 -12
  51. package/dist/es/ir/index.d.ts +5 -0
  52. package/dist/es/ir/index.d.ts.map +1 -0
  53. package/dist/es/ir/node.d.ts +73 -0
  54. package/dist/es/ir/node.d.ts.map +1 -0
  55. package/dist/es/ir/node.js +41 -0
  56. package/dist/es/ir/path/arrow.d.ts +26 -0
  57. package/dist/es/ir/path/arrow.d.ts.map +1 -0
  58. package/dist/es/ir/path/arrow.js +25 -0
  59. package/dist/es/ir/path/index.d.ts +5 -0
  60. package/dist/es/ir/path/index.d.ts.map +1 -0
  61. package/dist/es/ir/path/path.d.ts +123 -0
  62. package/dist/es/ir/path/path.d.ts.map +1 -0
  63. package/dist/es/ir/path/path.js +22 -0
  64. package/dist/es/ir/path/step.d.ts +116 -0
  65. package/dist/es/ir/path/step.d.ts.map +1 -0
  66. package/dist/es/ir/path/step.js +31 -0
  67. package/dist/es/ir/path/target.d.ts +5 -0
  68. package/dist/es/ir/path/target.d.ts.map +1 -0
  69. package/dist/es/ir/path/target.js +11 -0
  70. package/dist/es/ir/position/index.d.ts +3 -0
  71. package/dist/es/ir/position/index.d.ts.map +1 -0
  72. package/dist/es/ir/position/polar-position.d.ts +9 -0
  73. package/dist/es/ir/position/polar-position.d.ts.map +1 -0
  74. package/dist/es/ir/position/polar-position.js +18 -0
  75. package/dist/es/ir/position/position.d.ts +5 -0
  76. package/dist/es/ir/position/position.d.ts.map +1 -0
  77. package/dist/es/ir/position/position.js +5 -0
  78. package/dist/es/ir/scene.d.ts +424 -0
  79. package/dist/es/ir/scene.d.ts.map +1 -0
  80. package/dist/es/ir/scene.js +14 -0
  81. package/dist/es/parsers/index.d.ts +2 -0
  82. package/dist/es/parsers/index.d.ts.map +1 -0
  83. package/dist/es/parsers/parseWay.d.ts +71 -0
  84. package/dist/es/parsers/parseWay.d.ts.map +1 -0
  85. package/dist/es/parsers/parseWay.js +92 -0
  86. package/dist/es/primitive/ellipse.d.ts +32 -0
  87. package/dist/es/primitive/ellipse.d.ts.map +1 -0
  88. package/dist/es/primitive/group.d.ts +11 -0
  89. package/dist/es/primitive/group.d.ts.map +1 -0
  90. package/dist/es/primitive/index.d.ts +8 -0
  91. package/dist/es/primitive/index.d.ts.map +1 -0
  92. package/dist/es/primitive/path.d.ts +29 -0
  93. package/dist/es/primitive/path.d.ts.map +1 -0
  94. package/dist/es/primitive/rect.d.ts +28 -0
  95. package/dist/es/primitive/rect.d.ts.map +1 -0
  96. package/dist/es/primitive/scene.d.ts +21 -0
  97. package/dist/es/primitive/scene.d.ts.map +1 -0
  98. package/dist/es/primitive/text.d.ts +32 -0
  99. package/dist/es/primitive/text.d.ts.map +1 -0
  100. package/dist/es/primitive/view-box.d.ts +12 -0
  101. package/dist/es/primitive/view-box.d.ts.map +1 -0
  102. package/dist/es/types.d.ts +3 -0
  103. package/dist/es/types.d.ts.map +1 -0
  104. package/dist/lib/compile/compile.cjs +43 -0
  105. package/dist/lib/compile/compile.d.ts +27 -0
  106. package/dist/lib/compile/compile.d.ts.map +1 -0
  107. package/dist/lib/compile/index.d.ts +9 -0
  108. package/dist/lib/compile/index.d.ts.map +1 -0
  109. package/dist/lib/compile/node.cjs +244 -0
  110. package/dist/lib/compile/node.d.ts +76 -0
  111. package/dist/lib/compile/node.d.ts.map +1 -0
  112. package/dist/lib/compile/parseTarget.cjs +48 -0
  113. package/dist/lib/compile/parseTarget.d.ts +25 -0
  114. package/dist/lib/compile/parseTarget.d.ts.map +1 -0
  115. package/dist/lib/compile/path.cjs +298 -0
  116. package/dist/lib/compile/path.d.ts +29 -0
  117. package/dist/lib/compile/path.d.ts.map +1 -0
  118. package/dist/lib/compile/position.cjs +24 -0
  119. package/dist/lib/compile/position.d.ts +9 -0
  120. package/dist/lib/compile/position.d.ts.map +1 -0
  121. package/dist/lib/compile/precision.cjs +8 -0
  122. package/dist/lib/compile/precision.d.ts +5 -0
  123. package/dist/lib/compile/precision.d.ts.map +1 -0
  124. package/dist/lib/compile/text-metrics.cjs +8 -0
  125. package/dist/lib/compile/text-metrics.d.ts +32 -0
  126. package/dist/lib/compile/text-metrics.d.ts.map +1 -0
  127. package/dist/lib/compile/view-box.cjs +31 -0
  128. package/dist/lib/compile/view-box.d.ts +8 -0
  129. package/dist/lib/compile/view-box.d.ts.map +1 -0
  130. package/dist/lib/geometry/circle.cjs +79 -0
  131. package/dist/lib/geometry/circle.d.ts +32 -0
  132. package/dist/lib/geometry/circle.d.ts.map +1 -0
  133. package/dist/lib/geometry/diamond.cjs +87 -0
  134. package/dist/lib/geometry/diamond.d.ts +44 -0
  135. package/dist/lib/geometry/diamond.d.ts.map +1 -0
  136. package/dist/lib/geometry/ellipse.cjs +86 -0
  137. package/dist/lib/geometry/ellipse.d.ts +38 -0
  138. package/dist/lib/geometry/ellipse.d.ts.map +1 -0
  139. package/dist/lib/geometry/index.d.ts +7 -0
  140. package/dist/lib/geometry/index.d.ts.map +1 -0
  141. package/dist/lib/geometry/point.cjs +34 -0
  142. package/dist/lib/geometry/point.d.ts +25 -0
  143. package/dist/lib/geometry/point.d.ts.map +1 -0
  144. package/dist/lib/geometry/polar.cjs +45 -0
  145. package/dist/lib/geometry/polar.d.ts +44 -0
  146. package/dist/lib/geometry/polar.d.ts.map +1 -0
  147. package/dist/lib/geometry/rect.cjs +121 -0
  148. package/dist/lib/geometry/rect.d.ts +59 -0
  149. package/dist/lib/geometry/rect.d.ts.map +1 -0
  150. package/dist/lib/index.cjs +43 -11
  151. package/dist/lib/index.d.ts +20 -10
  152. package/dist/lib/index.d.ts.map +1 -0
  153. package/dist/lib/ir/index.d.ts +5 -0
  154. package/dist/lib/ir/index.d.ts.map +1 -0
  155. package/dist/lib/ir/node.cjs +42 -0
  156. package/dist/lib/ir/node.d.ts +73 -0
  157. package/dist/lib/ir/node.d.ts.map +1 -0
  158. package/dist/lib/ir/path/arrow.cjs +25 -0
  159. package/dist/lib/ir/path/arrow.d.ts +26 -0
  160. package/dist/lib/ir/path/arrow.d.ts.map +1 -0
  161. package/dist/lib/ir/path/index.d.ts +5 -0
  162. package/dist/lib/ir/path/index.d.ts.map +1 -0
  163. package/dist/lib/ir/path/path.cjs +22 -0
  164. package/dist/lib/ir/path/path.d.ts +123 -0
  165. package/dist/lib/ir/path/path.d.ts.map +1 -0
  166. package/dist/lib/ir/path/step.cjs +35 -0
  167. package/dist/lib/ir/path/step.d.ts +116 -0
  168. package/dist/lib/ir/path/step.d.ts.map +1 -0
  169. package/dist/lib/ir/path/target.cjs +11 -0
  170. package/dist/lib/ir/path/target.d.ts +5 -0
  171. package/dist/lib/ir/path/target.d.ts.map +1 -0
  172. package/dist/lib/ir/position/index.d.ts +3 -0
  173. package/dist/lib/ir/position/index.d.ts.map +1 -0
  174. package/dist/lib/ir/position/polar-position.cjs +18 -0
  175. package/dist/lib/ir/position/polar-position.d.ts +9 -0
  176. package/dist/lib/ir/position/polar-position.d.ts.map +1 -0
  177. package/dist/lib/ir/position/position.cjs +5 -0
  178. package/dist/lib/ir/position/position.d.ts +5 -0
  179. package/dist/lib/ir/position/position.d.ts.map +1 -0
  180. package/dist/lib/ir/scene.cjs +16 -0
  181. package/dist/lib/ir/scene.d.ts +424 -0
  182. package/dist/lib/ir/scene.d.ts.map +1 -0
  183. package/dist/lib/parsers/index.d.ts +2 -0
  184. package/dist/lib/parsers/index.d.ts.map +1 -0
  185. package/dist/lib/parsers/parseWay.cjs +93 -0
  186. package/dist/lib/parsers/parseWay.d.ts +71 -0
  187. package/dist/lib/parsers/parseWay.d.ts.map +1 -0
  188. package/dist/lib/primitive/ellipse.d.ts +32 -0
  189. package/dist/lib/primitive/ellipse.d.ts.map +1 -0
  190. package/dist/lib/primitive/group.d.ts +11 -0
  191. package/dist/lib/primitive/group.d.ts.map +1 -0
  192. package/dist/lib/primitive/index.d.ts +8 -0
  193. package/dist/lib/primitive/index.d.ts.map +1 -0
  194. package/dist/lib/primitive/path.d.ts +29 -0
  195. package/dist/lib/primitive/path.d.ts.map +1 -0
  196. package/dist/lib/primitive/rect.d.ts +28 -0
  197. package/dist/lib/primitive/rect.d.ts.map +1 -0
  198. package/dist/lib/primitive/scene.d.ts +21 -0
  199. package/dist/lib/primitive/scene.d.ts.map +1 -0
  200. package/dist/lib/primitive/text.d.ts +32 -0
  201. package/dist/lib/primitive/text.d.ts.map +1 -0
  202. package/dist/lib/primitive/view-box.d.ts +12 -0
  203. package/dist/lib/primitive/view-box.d.ts.map +1 -0
  204. package/dist/lib/types.d.ts +3 -0
  205. package/dist/lib/types.d.ts.map +1 -0
  206. package/package.json +26 -34
  207. package/README.md +0 -2
  208. package/dist/es/components/Scope.d.ts +0 -6
  209. package/dist/es/components/Scope.js +0 -12
  210. package/dist/es/components/TikZ.d.ts +0 -9
  211. package/dist/es/components/TikZ.js +0 -12
  212. package/dist/es/components/draw/Draw.d.ts +0 -26
  213. package/dist/es/components/draw/Draw.js +0 -59
  214. package/dist/es/components/draw/InnerDraw.d.ts +0 -17
  215. package/dist/es/components/draw/InnerDraw.js +0 -52
  216. package/dist/es/components/draw/arrow/circle.d.ts +0 -7
  217. package/dist/es/components/draw/arrow/circle.js +0 -20
  218. package/dist/es/components/draw/arrow/index.d.ts +0 -9
  219. package/dist/es/components/draw/arrow/index.js +0 -13
  220. package/dist/es/components/draw/arrow/stealth.d.ts +0 -7
  221. package/dist/es/components/draw/arrow/stealth.js +0 -29
  222. package/dist/es/components/draw/arrow/types.d.ts +0 -21
  223. package/dist/es/components/draw/common.d.ts +0 -4
  224. package/dist/es/components/draw/common.js +0 -12
  225. package/dist/es/components/draw/index.d.ts +0 -3
  226. package/dist/es/components/draw/index.js +0 -4
  227. package/dist/es/components/draw/segment/Segment.d.ts +0 -12
  228. package/dist/es/components/draw/segment/Segment.js +0 -41
  229. package/dist/es/components/draw/segment/index.d.ts +0 -15
  230. package/dist/es/components/draw/segment/index.js +0 -41
  231. package/dist/es/components/draw/segment/useArrow.d.ts +0 -12
  232. package/dist/es/components/draw/segment/useArrow.js +0 -52
  233. package/dist/es/components/draw/segment/useConvertWay.d.ts +0 -14
  234. package/dist/es/components/draw/segment/useConvertWay.js +0 -117
  235. package/dist/es/components/draw/types.d.ts +0 -29
  236. package/dist/es/components/node/InnerNode.d.ts +0 -33
  237. package/dist/es/components/node/InnerNode.js +0 -88
  238. package/dist/es/components/node/Node.d.ts +0 -93
  239. package/dist/es/components/node/Node.js +0 -88
  240. package/dist/es/components/node/_hooks/useNodeConfig.d.ts +0 -3
  241. package/dist/es/components/node/_hooks/useNodeConfig.js +0 -13
  242. package/dist/es/components/node/_hooks/useNodeContent.d.ts +0 -4
  243. package/dist/es/components/node/_hooks/useNodeContent.js +0 -30
  244. package/dist/es/components/node/_hooks/useNodeShape.d.ts +0 -4
  245. package/dist/es/components/node/_hooks/useNodeShape.js +0 -34
  246. package/dist/es/components/node/index.d.ts +0 -3
  247. package/dist/es/components/node/index.js +0 -4
  248. package/dist/es/components/path-node/PathNode.d.ts +0 -48
  249. package/dist/es/components/path-node/PathNode.js +0 -76
  250. package/dist/es/components/path-node/index.d.ts +0 -3
  251. package/dist/es/components/path-node/index.js +0 -4
  252. package/dist/es/components/path-node/useAnchor.d.ts +0 -6
  253. package/dist/es/components/path-node/useAnchor.js +0 -49
  254. package/dist/es/container/Group.d.ts +0 -6
  255. package/dist/es/container/Group.js +0 -8
  256. package/dist/es/container/Surface.d.ts +0 -19
  257. package/dist/es/container/Surface.js +0 -23
  258. package/dist/es/elements/Path.d.ts +0 -4
  259. package/dist/es/elements/Path.js +0 -14
  260. package/dist/es/elements/Rect.d.ts +0 -4
  261. package/dist/es/elements/Rect.js +0 -9
  262. package/dist/es/elements/Text.d.ts +0 -18
  263. package/dist/es/elements/Text.js +0 -35
  264. package/dist/es/hooks/context/useCalculate.d.ts +0 -7
  265. package/dist/es/hooks/context/useCalculate.js +0 -9
  266. package/dist/es/hooks/context/useNodes.d.ts +0 -9
  267. package/dist/es/hooks/context/useNodes.js +0 -33
  268. package/dist/es/hooks/context/usePath.d.ts +0 -13
  269. package/dist/es/hooks/context/usePath.js +0 -20
  270. package/dist/es/hooks/context/useScope.d.ts +0 -11
  271. package/dist/es/hooks/context/useScope.js +0 -7
  272. package/dist/es/hooks/useForceUpdate.d.ts +0 -2
  273. package/dist/es/hooks/useForceUpdate.js +0 -8
  274. package/dist/es/model/component/node.d.ts +0 -45
  275. package/dist/es/model/component/node.js +0 -164
  276. package/dist/es/model/component/path.d.ts +0 -19
  277. package/dist/es/model/component/path.js +0 -47
  278. package/dist/es/model/equation/line.d.ts +0 -21
  279. package/dist/es/model/equation/line.js +0 -76
  280. package/dist/es/model/geometry/point/DescartesPoint.d.ts +0 -21
  281. package/dist/es/model/geometry/point/DescartesPoint.js +0 -50
  282. package/dist/es/model/geometry/point/PolarPoint.d.ts +0 -14
  283. package/dist/es/model/geometry/point/PolarPoint.js +0 -27
  284. package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js +0 -338
  285. package/dist/es/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js +0 -13
  286. package/dist/es/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.js +0 -88
  287. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.js +0 -6
  288. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.js +0 -8
  289. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.js +0 -39
  290. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.js +0 -41
  291. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.js +0 -19
  292. package/dist/es/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.js +0 -10
  293. package/dist/es/test.d.ts +0 -3
  294. package/dist/es/types/coordinate/descartes.d.ts +0 -23
  295. package/dist/es/types/coordinate/index.d.ts +0 -5
  296. package/dist/es/types/coordinate/polar.d.ts +0 -5
  297. package/dist/es/types/distance/index.d.ts +0 -8
  298. package/dist/es/types/distance/sep.d.ts +0 -9
  299. package/dist/es/types/shape/index.d.ts +0 -8
  300. package/dist/es/types/shape/index.js +0 -9
  301. package/dist/es/types/shape/rect.d.ts +0 -25
  302. package/dist/es/types/shape/rect.js +0 -30
  303. package/dist/es/types/svg/font.d.ts +0 -10
  304. package/dist/es/types/svg/stroke.d.ts +0 -10
  305. package/dist/es/types/tikz/index.d.ts +0 -6
  306. package/dist/es/utils/compare.d.ts +0 -4
  307. package/dist/es/utils/compare.js +0 -20
  308. package/dist/es/utils/css.d.ts +0 -6
  309. package/dist/es/utils/css.js +0 -26
  310. package/dist/es/utils/math.d.ts +0 -9
  311. package/dist/es/utils/math.js +0 -26
  312. package/dist/es/utils/string.d.ts +0 -7
  313. package/dist/es/utils/string.js +0 -7
  314. package/dist/es/utils/style/font.d.ts +0 -17
  315. package/dist/es/utils/style/font.js +0 -34
  316. package/dist/es/utils/style/stroke.d.ts +0 -20
  317. package/dist/es/utils/style/stroke.js +0 -42
  318. package/dist/lib/components/Scope.cjs +0 -12
  319. package/dist/lib/components/Scope.d.ts +0 -6
  320. package/dist/lib/components/TikZ.cjs +0 -12
  321. package/dist/lib/components/TikZ.d.ts +0 -9
  322. package/dist/lib/components/draw/Draw.cjs +0 -59
  323. package/dist/lib/components/draw/Draw.d.ts +0 -26
  324. package/dist/lib/components/draw/InnerDraw.cjs +0 -52
  325. package/dist/lib/components/draw/InnerDraw.d.ts +0 -17
  326. package/dist/lib/components/draw/arrow/circle.cjs +0 -20
  327. package/dist/lib/components/draw/arrow/circle.d.ts +0 -7
  328. package/dist/lib/components/draw/arrow/index.cjs +0 -13
  329. package/dist/lib/components/draw/arrow/index.d.ts +0 -9
  330. package/dist/lib/components/draw/arrow/stealth.cjs +0 -29
  331. package/dist/lib/components/draw/arrow/stealth.d.ts +0 -7
  332. package/dist/lib/components/draw/arrow/types.d.ts +0 -21
  333. package/dist/lib/components/draw/common.cjs +0 -12
  334. package/dist/lib/components/draw/common.d.ts +0 -4
  335. package/dist/lib/components/draw/index.cjs +0 -4
  336. package/dist/lib/components/draw/index.d.ts +0 -3
  337. package/dist/lib/components/draw/segment/Segment.cjs +0 -41
  338. package/dist/lib/components/draw/segment/Segment.d.ts +0 -12
  339. package/dist/lib/components/draw/segment/index.cjs +0 -41
  340. package/dist/lib/components/draw/segment/index.d.ts +0 -15
  341. package/dist/lib/components/draw/segment/useArrow.cjs +0 -52
  342. package/dist/lib/components/draw/segment/useArrow.d.ts +0 -12
  343. package/dist/lib/components/draw/segment/useConvertWay.cjs +0 -117
  344. package/dist/lib/components/draw/segment/useConvertWay.d.ts +0 -14
  345. package/dist/lib/components/draw/types.d.ts +0 -29
  346. package/dist/lib/components/node/InnerNode.cjs +0 -88
  347. package/dist/lib/components/node/InnerNode.d.ts +0 -33
  348. package/dist/lib/components/node/Node.cjs +0 -88
  349. package/dist/lib/components/node/Node.d.ts +0 -93
  350. package/dist/lib/components/node/_hooks/useNodeConfig.cjs +0 -13
  351. package/dist/lib/components/node/_hooks/useNodeConfig.d.ts +0 -3
  352. package/dist/lib/components/node/_hooks/useNodeContent.cjs +0 -30
  353. package/dist/lib/components/node/_hooks/useNodeContent.d.ts +0 -4
  354. package/dist/lib/components/node/_hooks/useNodeShape.cjs +0 -34
  355. package/dist/lib/components/node/_hooks/useNodeShape.d.ts +0 -4
  356. package/dist/lib/components/node/index.cjs +0 -4
  357. package/dist/lib/components/node/index.d.ts +0 -3
  358. package/dist/lib/components/path-node/PathNode.cjs +0 -76
  359. package/dist/lib/components/path-node/PathNode.d.ts +0 -48
  360. package/dist/lib/components/path-node/index.cjs +0 -4
  361. package/dist/lib/components/path-node/index.d.ts +0 -3
  362. package/dist/lib/components/path-node/useAnchor.cjs +0 -49
  363. package/dist/lib/components/path-node/useAnchor.d.ts +0 -6
  364. package/dist/lib/container/Group.cjs +0 -8
  365. package/dist/lib/container/Group.d.ts +0 -6
  366. package/dist/lib/container/Surface.cjs +0 -23
  367. package/dist/lib/container/Surface.d.ts +0 -19
  368. package/dist/lib/elements/Path.cjs +0 -14
  369. package/dist/lib/elements/Path.d.ts +0 -4
  370. package/dist/lib/elements/Rect.cjs +0 -9
  371. package/dist/lib/elements/Rect.d.ts +0 -4
  372. package/dist/lib/elements/Text.cjs +0 -35
  373. package/dist/lib/elements/Text.d.ts +0 -18
  374. package/dist/lib/hooks/context/useCalculate.cjs +0 -9
  375. package/dist/lib/hooks/context/useCalculate.d.ts +0 -7
  376. package/dist/lib/hooks/context/useNodes.cjs +0 -33
  377. package/dist/lib/hooks/context/useNodes.d.ts +0 -9
  378. package/dist/lib/hooks/context/usePath.cjs +0 -20
  379. package/dist/lib/hooks/context/usePath.d.ts +0 -13
  380. package/dist/lib/hooks/context/useScope.cjs +0 -7
  381. package/dist/lib/hooks/context/useScope.d.ts +0 -11
  382. package/dist/lib/hooks/useForceUpdate.cjs +0 -8
  383. package/dist/lib/hooks/useForceUpdate.d.ts +0 -2
  384. package/dist/lib/model/component/node.cjs +0 -164
  385. package/dist/lib/model/component/node.d.ts +0 -45
  386. package/dist/lib/model/component/path.cjs +0 -47
  387. package/dist/lib/model/component/path.d.ts +0 -19
  388. package/dist/lib/model/equation/line.cjs +0 -76
  389. package/dist/lib/model/equation/line.d.ts +0 -21
  390. package/dist/lib/model/geometry/point/DescartesPoint.cjs +0 -50
  391. package/dist/lib/model/geometry/point/DescartesPoint.d.ts +0 -21
  392. package/dist/lib/model/geometry/point/PolarPoint.cjs +0 -27
  393. package/dist/lib/model/geometry/point/PolarPoint.d.ts +0 -14
  394. package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.cjs +0 -338
  395. package/dist/lib/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.cjs +0 -13
  396. package/dist/lib/node_modules/.pnpm/d3-path@3.1.0/node_modules/d3-path/src/path.cjs +0 -88
  397. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/array.cjs +0 -6
  398. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/constant.cjs +0 -8
  399. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/linear.cjs +0 -39
  400. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/line.cjs +0 -41
  401. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/path.cjs +0 -19
  402. package/dist/lib/node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/point.cjs +0 -10
  403. package/dist/lib/test.d.ts +0 -3
  404. package/dist/lib/types/coordinate/descartes.d.ts +0 -23
  405. package/dist/lib/types/coordinate/index.d.ts +0 -5
  406. package/dist/lib/types/coordinate/polar.d.ts +0 -5
  407. package/dist/lib/types/distance/index.d.ts +0 -8
  408. package/dist/lib/types/distance/sep.d.ts +0 -9
  409. package/dist/lib/types/shape/index.cjs +0 -9
  410. package/dist/lib/types/shape/index.d.ts +0 -8
  411. package/dist/lib/types/shape/rect.cjs +0 -30
  412. package/dist/lib/types/shape/rect.d.ts +0 -25
  413. package/dist/lib/types/svg/font.d.ts +0 -10
  414. package/dist/lib/types/svg/stroke.d.ts +0 -10
  415. package/dist/lib/types/tikz/index.d.ts +0 -6
  416. package/dist/lib/utils/compare.cjs +0 -20
  417. package/dist/lib/utils/compare.d.ts +0 -4
  418. package/dist/lib/utils/css.cjs +0 -26
  419. package/dist/lib/utils/css.d.ts +0 -6
  420. package/dist/lib/utils/math.cjs +0 -26
  421. package/dist/lib/utils/math.d.ts +0 -9
  422. package/dist/lib/utils/string.cjs +0 -7
  423. package/dist/lib/utils/string.d.ts +0 -7
  424. package/dist/lib/utils/style/font.cjs +0 -34
  425. package/dist/lib/utils/style/font.d.ts +0 -17
  426. package/dist/lib/utils/style/stroke.cjs +0 -42
  427. package/dist/lib/utils/style/stroke.d.ts +0 -20
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 pionpill
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 pionpill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ import { IR } from '../ir';
2
+ import { Scene } from '../primitive';
3
+ import { TextMeasurer } from './text-metrics';
4
+ /** compileToScene 的可选参数 */
5
+ export type CompileOptions = {
6
+ /** 注入文字度量函数;不传则用 fallback(不准但可跑) */
7
+ measureText?: TextMeasurer;
8
+ /** viewBox 周围的留白(user units),默认 10 */
9
+ padding?: number;
10
+ /**
11
+ * 输出坐标的小数位精度;默认 2(保留 2 位小数四舍五入)。
12
+ * 仅在写入 Scene primitive / path d 字符串 / viewBox 时生效;
13
+ * 内部几何计算保持完整 double 精度,避免误差累积。
14
+ */
15
+ precision?: number;
16
+ };
17
+ /**
18
+ * IR → Scene。纯函数。
19
+ * 这是所有 adapter 共享的最深层共享代码。
20
+ *
21
+ * 流程:
22
+ * 1. Pass 1:按 IR children 源码顺序处理 Node——计算 layout、注册 nodeIndex、发出 RectPrim/TextPrim、累积 bbox 角点
23
+ * 2. Pass 2:处理 Path——解析每个 step 端点(节点 ref 走 boundaryPoint,其他走 resolvePosition),写 d 字符串
24
+ * 3. 末端用 computeViewBox 折算最终 viewBox(按 precision 四舍五入)
25
+ */
26
+ export declare const compileToScene: (ir: IR, options?: CompileOptions) => Scene;
27
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/compile/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,cAAc,CAAC;AAI1D,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAGrE,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,IAAI,EAAE,EAAE,UAAS,cAAmB,KAAG,KA2CrE,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { rect } from "../geometry/rect.js";
2
+ import { emitNodePrimitives, layoutNode } from "./node.js";
3
+ import { emitPathPrimitive } from "./path.js";
4
+ import { makeRound } from "./precision.js";
5
+ import { fallbackMeasurer } from "./text-metrics.js";
6
+ import { computeViewBox } from "./view-box.js";
7
+ //#region src/compile/compile.ts
8
+ /**
9
+ * IR → Scene。纯函数。
10
+ * 这是所有 adapter 共享的最深层共享代码。
11
+ *
12
+ * 流程:
13
+ * 1. Pass 1:按 IR children 源码顺序处理 Node——计算 layout、注册 nodeIndex、发出 RectPrim/TextPrim、累积 bbox 角点
14
+ * 2. Pass 2:处理 Path——解析每个 step 端点(节点 ref 走 boundaryPoint,其他走 resolvePosition),写 d 字符串
15
+ * 3. 末端用 computeViewBox 折算最终 viewBox(按 precision 四舍五入)
16
+ */
17
+ var compileToScene = (ir, options = {}) => {
18
+ const measureText = options.measureText ?? fallbackMeasurer;
19
+ const viewBoxPadding = options.padding ?? 10;
20
+ const round = makeRound(options.precision ?? 2);
21
+ const primitives = [];
22
+ const nodeIndex = /* @__PURE__ */ new Map();
23
+ const allPoints = [];
24
+ for (const child of ir.children) if (child.type === "node") {
25
+ const layout = layoutNode(child, measureText, nodeIndex);
26
+ if (child.id) nodeIndex.set(child.id, layout);
27
+ for (const prim of emitNodePrimitives(layout, round)) primitives.push(prim);
28
+ allPoints.push(rect.anchor(layout.rect, "north-west"), rect.anchor(layout.rect, "north-east"), rect.anchor(layout.rect, "south-west"), rect.anchor(layout.rect, "south-east"));
29
+ }
30
+ for (const child of ir.children) if (child.type === "path") {
31
+ const result = emitPathPrimitive(child, nodeIndex, round);
32
+ if (result) {
33
+ primitives.push(result.primitive);
34
+ for (const p of result.points) allPoints.push(p);
35
+ }
36
+ }
37
+ return {
38
+ primitives,
39
+ viewBox: computeViewBox(allPoints, viewBoxPadding, round)
40
+ };
41
+ };
42
+ //#endregion
43
+ export { compileToScene };
@@ -0,0 +1,9 @@
1
+ export * from './compile';
2
+ export * from './node';
3
+ export * from './parseTarget';
4
+ export * from './path';
5
+ export * from './position';
6
+ export * from './precision';
7
+ export * from './text-metrics';
8
+ export * from './view-box';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compile/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { Position } from '../geometry/point';
2
+ import { Rect, RectAnchor } from '../geometry/rect';
3
+ import { IRNode, NodeShape } from '../ir';
4
+ import { ScenePrimitive } from '../primitive';
5
+ import { TextMeasurer } from './text-metrics';
6
+ export type NodeLayout = {
7
+ /** 节点 id(如 IR Node 提供);其他位置可通过 id 引用本节点 */
8
+ id?: string;
9
+ /** 节点形状——所有几何 / boundaryPoint 计算按 shape 多态 */
10
+ shape: NodeShape;
11
+ /**
12
+ * 节点视觉边界框(所有 shape 共享语义):
13
+ * - rectangle: rect 即矩形本身
14
+ * - circle: rect.width = rect.height = 2 × radius(外接正方形)
15
+ * - ellipse: rect.width = 2 × rx,rect.height = 2 × ry(外接矩形)
16
+ * - diamond: rect.width = 2 × halfA,rect.height = 2 × halfB(外接矩形)
17
+ *
18
+ * x, y 是几何中心;rotate 是弧度(与 packages/core/AGENTS.md 对齐)。
19
+ */
20
+ rect: Rect;
21
+ /** IR 中原始的旋转角(度数),保留供 emit 阶段写 SVG transform */
22
+ rotateDeg: number;
23
+ /** 外边距(user units,≥ 0);path 附着到形状外扩 margin 的虚拟边界上 */
24
+ margin: number;
25
+ /** 节点文本内容;空字符串视为无文本(undefined) */
26
+ text?: string;
27
+ /** 文本宽度(user units),由 TextMeasurer 算出 */
28
+ textWidth: number;
29
+ /** 文本高度(user units),由 TextMeasurer 算出 */
30
+ textHeight: number;
31
+ /** 文本字号(user units) */
32
+ fontSize: number;
33
+ /** 节点背景色,CSS 颜色字符串;emit 时用 'transparent' 兜底 */
34
+ fill?: string;
35
+ /** 节点边框色,CSS 颜色字符串;emit 时用 'currentColor' 兜底 */
36
+ stroke?: string;
37
+ /** 节点边框宽度(user units);emit 时用 1 兜底 */
38
+ strokeWidth?: number;
39
+ };
40
+ /**
41
+ * 取节点 shape 在 toward 方向上的"附着点"——path 端点贴边用。
42
+ * 按 shape 多态:rect / circle / ellipse / diamond 各自的 boundaryPoint。
43
+ * margin > 0 时形状先外扩,让 path 在 border 外停 margin 个 user units。
44
+ */
45
+ export declare const boundaryPointOf: (layout: NodeLayout, toward: Position) => Position;
46
+ /**
47
+ * 取节点 shape 的命名 anchor(center / north / east / north-east 等 9 个)。
48
+ * **不应用 margin**——TikZ 语义中 explicit anchor 取的是视觉边界点,不涉及 outer sep。
49
+ * 用于 `'A.north'` 这种语法落点。
50
+ */
51
+ export declare const anchorOf: (layout: NodeLayout, name: RectAnchor) => Position;
52
+ /**
53
+ * 取节点 shape 在指定角度方向上的边界点。角度约定与 PolarPosition 一致(度数):
54
+ * 0° = +x(east),90° = +y(screen 下方)。
55
+ * **不应用 margin**——同 anchorOf。用于 `'A.30'` 这种语法落点。
56
+ */
57
+ export declare const angleBoundaryOf: (layout: NodeLayout, angleDeg: number) => Position;
58
+ /**
59
+ * 把 IR Node 解析为内部 NodeLayout:
60
+ * - 算出文本度量与 padding 推导出"内框"半轴 (innerHalfW/H)
61
+ * - 按 shape 决定外接边界尺寸(circle 取半对角线、ellipse 各 ×√2、diamond 各 ×2)
62
+ * - 解析 position(笛卡尔或极坐标)为几何中心
63
+ * - IR 的 rotate(度数)转弧度存进 Rect.rotate
64
+ * - 透传 margin / 样式属性
65
+ */
66
+ export declare const layoutNode: (node: IRNode, measureText: TextMeasurer, nodeIndex: Map<string, NodeLayout>) => NodeLayout;
67
+ /**
68
+ * 把 NodeLayout 翻译为 Scene primitives:
69
+ * - shape 主体:按 shape 分发(rect / ellipse / path)
70
+ * - text(如有内容):始终走 TextPrim
71
+ * - 若有旋转:外面套一层 GroupPrim 用 SVG `rotate(deg cx cy)` 实现
72
+ * (PathPrim 的 diamond 顶点已自带旋转坐标,但 text 需要 group 旋转,
73
+ * 所以仍统一用 group 包裹)
74
+ */
75
+ export declare const emitNodePrimitives: (layout: NodeLayout, round: (n: number) => number) => Array<ScenePrimitive>;
76
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/compile/node.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOnD,MAAM,MAAM,UAAU,GAAG;IACvB,2CAA2C;IAC3C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,KAAK,EAAE,SAAS,CAAC;IACjB;;;;;;;;OAQG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAsCF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,QAAQ,QAAQ,KAAG,QAYtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,UAAU,EAAE,MAAM,UAAU,KAAG,QAW/D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,EAAE,UAAU,MAAM,KAAG,QActE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,aAAa,YAAY,EACzB,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,KACjC,UAmEF,CAAC;AAyDF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,EAClB,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B,KAAK,CAAC,cAAc,CAyCtB,CAAC"}
@@ -0,0 +1,240 @@
1
+ import { rect } from "../geometry/rect.js";
2
+ import { circle } from "../geometry/circle.js";
3
+ import { diamond } from "../geometry/diamond.js";
4
+ import { ellipse } from "../geometry/ellipse.js";
5
+ import { resolvePosition } from "./position.js";
6
+ //#region src/compile/node.ts
7
+ var DEFAULT_FONT_SIZE = 14;
8
+ var DEFAULT_PADDING = 8;
9
+ var DEG_TO_RAD = Math.PI / 180;
10
+ var SQRT2 = Math.SQRT2;
11
+ /** 由 layout 构造的 Rect(带 margin 扩张) */
12
+ var rectOf = (layout, marginAdd) => ({
13
+ x: layout.rect.x,
14
+ y: layout.rect.y,
15
+ width: layout.rect.width + 2 * marginAdd,
16
+ height: layout.rect.height + 2 * marginAdd,
17
+ rotate: layout.rect.rotate
18
+ });
19
+ /** 由 layout 构造的 Circle(圆心 + 半径,半径=外接框边长/2 + margin) */
20
+ var circleOf = (layout, marginAdd) => ({
21
+ x: layout.rect.x,
22
+ y: layout.rect.y,
23
+ radius: layout.rect.width / 2 + marginAdd,
24
+ rotate: layout.rect.rotate
25
+ });
26
+ /** 由 layout 构造的 Ellipse(rx/ry 各加 margin) */
27
+ var ellipseOf = (layout, marginAdd) => ({
28
+ x: layout.rect.x,
29
+ y: layout.rect.y,
30
+ rx: layout.rect.width / 2 + marginAdd,
31
+ ry: layout.rect.height / 2 + marginAdd,
32
+ rotate: layout.rect.rotate
33
+ });
34
+ /** 由 layout 构造的 Diamond(halfA/halfB 各加 margin) */
35
+ var diamondOf = (layout, marginAdd) => ({
36
+ x: layout.rect.x,
37
+ y: layout.rect.y,
38
+ halfA: layout.rect.width / 2 + marginAdd,
39
+ halfB: layout.rect.height / 2 + marginAdd,
40
+ rotate: layout.rect.rotate
41
+ });
42
+ /**
43
+ * 取节点 shape 在 toward 方向上的"附着点"——path 端点贴边用。
44
+ * 按 shape 多态:rect / circle / ellipse / diamond 各自的 boundaryPoint。
45
+ * margin > 0 时形状先外扩,让 path 在 border 外停 margin 个 user units。
46
+ */
47
+ var boundaryPointOf = (layout, toward) => {
48
+ const m = layout.margin;
49
+ switch (layout.shape) {
50
+ case "rectangle": return rect.boundaryPoint(rectOf(layout, m), toward);
51
+ case "circle": return circle.boundaryPoint(circleOf(layout, m), toward);
52
+ case "ellipse": return ellipse.boundaryPoint(ellipseOf(layout, m), toward);
53
+ case "diamond": return diamond.boundaryPoint(diamondOf(layout, m), toward);
54
+ }
55
+ };
56
+ /**
57
+ * 取节点 shape 的命名 anchor(center / north / east / north-east 等 9 个)。
58
+ * **不应用 margin**——TikZ 语义中 explicit anchor 取的是视觉边界点,不涉及 outer sep。
59
+ * 用于 `'A.north'` 这种语法落点。
60
+ */
61
+ var anchorOf = (layout, name) => {
62
+ switch (layout.shape) {
63
+ case "rectangle": return rect.anchor(rectOf(layout, 0), name);
64
+ case "circle": return circle.anchor(circleOf(layout, 0), name);
65
+ case "ellipse": return ellipse.anchor(ellipseOf(layout, 0), name);
66
+ case "diamond": return diamond.anchor(diamondOf(layout, 0), name);
67
+ }
68
+ };
69
+ /**
70
+ * 取节点 shape 在指定角度方向上的边界点。角度约定与 PolarPosition 一致(度数):
71
+ * 0° = +x(east),90° = +y(screen 下方)。
72
+ * **不应用 margin**——同 anchorOf。用于 `'A.30'` 这种语法落点。
73
+ */
74
+ var angleBoundaryOf = (layout, angleDeg) => {
75
+ const rad = angleDeg * Math.PI / 180;
76
+ const toward = [layout.rect.x + Math.cos(rad), layout.rect.y + Math.sin(rad)];
77
+ switch (layout.shape) {
78
+ case "rectangle": return rect.boundaryPoint(rectOf(layout, 0), toward);
79
+ case "circle": return circle.boundaryPoint(circleOf(layout, 0), toward);
80
+ case "ellipse": return ellipse.boundaryPoint(ellipseOf(layout, 0), toward);
81
+ case "diamond": return diamond.boundaryPoint(diamondOf(layout, 0), toward);
82
+ }
83
+ };
84
+ /**
85
+ * 把 IR Node 解析为内部 NodeLayout:
86
+ * - 算出文本度量与 padding 推导出"内框"半轴 (innerHalfW/H)
87
+ * - 按 shape 决定外接边界尺寸(circle 取半对角线、ellipse 各 ×√2、diamond 各 ×2)
88
+ * - 解析 position(笛卡尔或极坐标)为几何中心
89
+ * - IR 的 rotate(度数)转弧度存进 Rect.rotate
90
+ * - 透传 margin / 样式属性
91
+ */
92
+ var layoutNode = (node, measureText, nodeIndex) => {
93
+ const fontSize = node.fontSize ?? DEFAULT_FONT_SIZE;
94
+ const padding = node.padding ?? DEFAULT_PADDING;
95
+ const metrics = node.text ? measureText(node.text, { size: fontSize }) : {
96
+ width: 0,
97
+ height: 0
98
+ };
99
+ const innerHalfW = Math.max(metrics.width / 2 + padding, padding);
100
+ const innerHalfH = Math.max(metrics.height / 2 + padding, padding);
101
+ const shape = node.shape ?? "rectangle";
102
+ let boundsHalfW;
103
+ let boundsHalfH;
104
+ switch (shape) {
105
+ case "rectangle":
106
+ boundsHalfW = innerHalfW;
107
+ boundsHalfH = innerHalfH;
108
+ break;
109
+ case "circle": {
110
+ const r = Math.sqrt(innerHalfW * innerHalfW + innerHalfH * innerHalfH);
111
+ boundsHalfW = r;
112
+ boundsHalfH = r;
113
+ break;
114
+ }
115
+ case "ellipse":
116
+ boundsHalfW = innerHalfW * SQRT2;
117
+ boundsHalfH = innerHalfH * SQRT2;
118
+ break;
119
+ case "diamond":
120
+ boundsHalfW = innerHalfW * 2;
121
+ boundsHalfH = innerHalfH * 2;
122
+ break;
123
+ }
124
+ const rotateDeg = node.rotate ?? 0;
125
+ const center = resolvePosition(node.position, nodeIndex);
126
+ if (!center) throw new Error(`Cannot resolve position for node ${node.id ?? "(unnamed)"}; polar.origin may reference an undefined node`);
127
+ return {
128
+ id: node.id,
129
+ shape,
130
+ rect: {
131
+ x: center[0],
132
+ y: center[1],
133
+ width: 2 * boundsHalfW,
134
+ height: 2 * boundsHalfH,
135
+ rotate: rotateDeg * DEG_TO_RAD
136
+ },
137
+ rotateDeg,
138
+ margin: node.margin ?? 0,
139
+ text: node.text,
140
+ textWidth: metrics.width,
141
+ textHeight: metrics.height,
142
+ fontSize,
143
+ fill: node.fill,
144
+ stroke: node.stroke,
145
+ strokeWidth: node.strokeWidth
146
+ };
147
+ };
148
+ /** rectangle shape 的 RectPrim */
149
+ var emitRectShape = (layout, round) => {
150
+ const halfW = layout.rect.width / 2;
151
+ const halfH = layout.rect.height / 2;
152
+ return {
153
+ type: "rect",
154
+ x: round(layout.rect.x - halfW),
155
+ y: round(layout.rect.y - halfH),
156
+ width: round(layout.rect.width),
157
+ height: round(layout.rect.height),
158
+ fill: layout.fill ?? "transparent",
159
+ stroke: layout.stroke ?? "currentColor",
160
+ strokeWidth: layout.strokeWidth ?? 1
161
+ };
162
+ };
163
+ /** circle / ellipse shape 的 EllipsePrim(圆形 rx=ry) */
164
+ var emitEllipseShape = (layout, round) => ({
165
+ type: "ellipse",
166
+ cx: round(layout.rect.x),
167
+ cy: round(layout.rect.y),
168
+ rx: round(layout.rect.width / 2),
169
+ ry: round(layout.rect.height / 2),
170
+ fill: layout.fill ?? "transparent",
171
+ stroke: layout.stroke ?? "currentColor",
172
+ strokeWidth: layout.strokeWidth ?? 1
173
+ });
174
+ /** diamond shape 的 PathPrim(4 顶点 + Z 闭合) */
175
+ var emitDiamondShape = (layout, round) => {
176
+ const diam = diamondOf(layout, 0);
177
+ const e = diamond.anchor(diam, "east");
178
+ const n = diamond.anchor(diam, "north");
179
+ const w = diamond.anchor(diam, "west");
180
+ const s = diamond.anchor(diam, "south");
181
+ return {
182
+ type: "path",
183
+ d: `M ${round(e[0])} ${round(e[1])} L ${round(n[0])} ${round(n[1])} L ${round(w[0])} ${round(w[1])} L ${round(s[0])} ${round(s[1])} Z`,
184
+ fill: layout.fill ?? "transparent",
185
+ stroke: layout.stroke ?? "currentColor",
186
+ strokeWidth: layout.strokeWidth ?? 1
187
+ };
188
+ };
189
+ /**
190
+ * 把 NodeLayout 翻译为 Scene primitives:
191
+ * - shape 主体:按 shape 分发(rect / ellipse / path)
192
+ * - text(如有内容):始终走 TextPrim
193
+ * - 若有旋转:外面套一层 GroupPrim 用 SVG `rotate(deg cx cy)` 实现
194
+ * (PathPrim 的 diamond 顶点已自带旋转坐标,但 text 需要 group 旋转,
195
+ * 所以仍统一用 group 包裹)
196
+ */
197
+ var emitNodePrimitives = (layout, round) => {
198
+ let shapePrim;
199
+ switch (layout.shape) {
200
+ case "rectangle":
201
+ shapePrim = emitRectShape(layout, round);
202
+ break;
203
+ case "circle":
204
+ case "ellipse":
205
+ shapePrim = emitEllipseShape(layout, round);
206
+ break;
207
+ case "diamond":
208
+ shapePrim = emitDiamondShape(unrotated(layout), round);
209
+ break;
210
+ }
211
+ const inner = [shapePrim];
212
+ if (layout.text) inner.push({
213
+ type: "text",
214
+ x: round(layout.rect.x),
215
+ y: round(layout.rect.y),
216
+ content: layout.text,
217
+ fontSize: layout.fontSize,
218
+ align: "middle",
219
+ baseline: "middle",
220
+ fill: "currentColor",
221
+ measuredWidth: round(layout.textWidth),
222
+ measuredHeight: round(layout.textHeight)
223
+ });
224
+ if (layout.rotateDeg === 0) return inner;
225
+ return [{
226
+ type: "group",
227
+ transform: `rotate(${round(layout.rotateDeg)} ${round(layout.rect.x)} ${round(layout.rect.y)})`,
228
+ children: inner
229
+ }];
230
+ };
231
+ /** 返回 layout 的"未旋转"副本——用于先把 diamond 顶点按未旋转算,再由外层 group 统一旋转 */
232
+ var unrotated = (layout) => ({
233
+ ...layout,
234
+ rect: {
235
+ ...layout.rect,
236
+ rotate: 0
237
+ }
238
+ });
239
+ //#endregion
240
+ export { anchorOf, angleBoundaryOf, boundaryPointOf, emitNodePrimitives, layoutNode };
@@ -0,0 +1,25 @@
1
+ import { RectAnchor } from '../geometry/rect';
2
+ /** 解析后的节点 ref 三态 */
3
+ export type ParsedNodeRef = {
4
+ kind: 'node';
5
+ id: string;
6
+ } | {
7
+ kind: 'anchor';
8
+ id: string;
9
+ anchor: RectAnchor;
10
+ } | {
11
+ kind: 'angle';
12
+ id: string;
13
+ angle: number;
14
+ };
15
+ /**
16
+ * 解析节点 ref 字符串。
17
+ *
18
+ * - 不带 `.`:node(auto-clip)
19
+ * - 带 `.` 后纯数字:angle(toward 方向上的边界点,与 PolarPosition 同角度约定)
20
+ * - 带 `.` 后字母 / 连字符:anchor(命中 ANCHOR_NAMES 才合法,否则抛错)
21
+ *
22
+ * 抛错路径:未知 anchor 名(避免静默吞掉拼写错误)。
23
+ */
24
+ export declare const parseNodeRef: (s: string) => ParsedNodeRef;
25
+ //# sourceMappingURL=parseTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseTarget.d.ts","sourceRoot":"","sources":["../../../src/compile/parseTarget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQjE,oBAAoB;AACpB,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,aAcxC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { RECT_ANCHORS } from "../geometry/rect.js";
2
+ //#region src/compile/parseTarget.ts
3
+ /**
4
+ * 节点 ref 字符串扩展语法(ADR-0004):
5
+ *
6
+ * `'A'` → 节点 A,由 path 自动 boundary clip(auto 模式)
7
+ * `'A.<name>'` → 节点 A 的命名 anchor(center/north/south/east/west/north-east/...)
8
+ * `'A.<deg>'` → 节点 A 在 degree 角度方向上的边界点(同 PolarPosition 角度约定)
9
+ *
10
+ * id 约束:`[A-Za-z_][\w-]*`——禁数字开头、禁含 `.`(与 anchor 分隔符冲突);
11
+ * anchor 名只接受 alpha.1 首批 9 个 RECT_ANCHORS(其余如 'text' / 'base' / 'mid'
12
+ * 留 alpha.2 + 字体改造时再支持);角度纯数字(含可选 `.`/`-`)。
13
+ */
14
+ /** alpha.1 支持的 anchor 名集合(RECT_ANCHORS 的 9 个值) */
15
+ var ANCHOR_NAMES = new Set(Object.values(RECT_ANCHORS));
16
+ /** 纯数字(可选小数 / 负号),用于识别 `A.30` / `A.-45` / `A.180.5` */
17
+ var ANGLE_RE = /^-?\d+(\.\d+)?$/;
18
+ /**
19
+ * 解析节点 ref 字符串。
20
+ *
21
+ * - 不带 `.`:node(auto-clip)
22
+ * - 带 `.` 后纯数字:angle(toward 方向上的边界点,与 PolarPosition 同角度约定)
23
+ * - 带 `.` 后字母 / 连字符:anchor(命中 ANCHOR_NAMES 才合法,否则抛错)
24
+ *
25
+ * 抛错路径:未知 anchor 名(避免静默吞掉拼写错误)。
26
+ */
27
+ var parseNodeRef = (s) => {
28
+ const dot = s.indexOf(".");
29
+ if (dot < 0) return {
30
+ kind: "node",
31
+ id: s
32
+ };
33
+ const id = s.slice(0, dot);
34
+ const tail = s.slice(dot + 1);
35
+ if (ANGLE_RE.test(tail)) return {
36
+ kind: "angle",
37
+ id,
38
+ angle: Number(tail)
39
+ };
40
+ if (!ANCHOR_NAMES.has(tail)) throw new Error(`parseNodeRef: unknown anchor '${tail}' in '${s}' (alpha.1 supports: ${[...ANCHOR_NAMES].join(", ")})`);
41
+ return {
42
+ kind: "anchor",
43
+ id,
44
+ anchor: tail
45
+ };
46
+ };
47
+ //#endregion
48
+ export { parseNodeRef };
@@ -0,0 +1,29 @@
1
+ import { IRPath, IRPosition } from '../ir';
2
+ import { ScenePrimitive } from '../primitive';
3
+ import { NodeLayout } from './node';
4
+ /**
5
+ * 把 IR Path 翻译为单个 PathPrim。
6
+ *
7
+ * 关键算法(v0.1.0-alpha.1):每个绘制段(line / fold)**独立**地用节点中心
8
+ * 算两端 boundary clip——一个节点在路径中段时,"入边"和"出边" boundary 点
9
+ * 通常不同,路径会在该节点处可见地"断开"。这与 TikZ 原生语义一致:
10
+ *
11
+ * `\draw (A) -- (B) -- (C);`
12
+ * 段 1:A.center → B.center 决定 A 出口、B 入口的 boundary 交点
13
+ * 段 2:B.center → C.center 决定 B 出口、C 入口的 boundary 交点
14
+ * B 在两段里 clip 出来的点不同——视觉上看到两条独立线段。
15
+ *
16
+ * 实现上仍只产一个 PathPrim:d 字符串里以多组 `M ... L ...` 表达多个 sub-path。
17
+ * 当某段起点恰好等于上一段终点(例如直接坐标连续,或未触发 clip 差异)时,
18
+ * 复用 cursor,省掉冗余 M。
19
+ *
20
+ * cycle 段:闭回最近一次 move 起点。若 cycle 起点 == lastEnd 且终点 == subPathStart,
21
+ * 输出 `Z`(最优雅);否则显式画一段 line(与"段独立 clip"一致)。
22
+ *
23
+ * 引用未定义节点 / 解析失败时返回 null(path 整体跳过)。
24
+ */
25
+ export declare const emitPathPrimitive: (path: IRPath, nodeIndex: Map<string, NodeLayout>, round: (n: number) => number) => {
26
+ primitive: ScenePrimitive;
27
+ points: Array<IRPosition>;
28
+ } | null;
29
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/compile/path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,MAAM,EAAE,UAAU,EAAoB,MAAM,OAAO,CAAC;AAC9E,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAA8C,MAAM,QAAQ,CAAC;AAuIrF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,WAAW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAClC,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,KAC3B;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,IAsN7D,CAAC"}