@graphrefly/graphrefly 0.25.0 → 0.27.0

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 (231) hide show
  1. package/README.md +8 -0
  2. package/dist/ai-CaR_912Q.d.cts +1033 -0
  3. package/dist/ai-WlRltJV7.d.ts +1033 -0
  4. package/dist/audit-ClmqGOCx.d.cts +245 -0
  5. package/dist/audit-DRlSzBu9.d.ts +245 -0
  6. package/dist/{chunk-QOWVNWOC.js → chunk-3ZWCKRHX.js} +27 -25
  7. package/dist/{chunk-QOWVNWOC.js.map → chunk-3ZWCKRHX.js.map} +1 -1
  8. package/dist/chunk-APFNLIRG.js +62 -0
  9. package/dist/chunk-APFNLIRG.js.map +1 -0
  10. package/dist/chunk-AT5LKYNL.js +395 -0
  11. package/dist/chunk-AT5LKYNL.js.map +1 -0
  12. package/dist/{chunk-IAHGTNOZ.js → chunk-BQ6RQQFF.js} +351 -2095
  13. package/dist/chunk-BQ6RQQFF.js.map +1 -0
  14. package/dist/{chunk-L2GLW2U7.js → chunk-BVZYTZ5H.js} +9 -103
  15. package/dist/chunk-BVZYTZ5H.js.map +1 -0
  16. package/dist/{chunk-EVR6UFUV.js → chunk-DST5DKZS.js} +19 -15
  17. package/dist/{chunk-EVR6UFUV.js.map → chunk-DST5DKZS.js.map} +1 -1
  18. package/dist/{chunk-TKE3JGOH.js → chunk-GTE6PWRZ.js} +5 -692
  19. package/dist/chunk-GTE6PWRZ.js.map +1 -0
  20. package/dist/chunk-HXZEYDUR.js +94 -0
  21. package/dist/chunk-HXZEYDUR.js.map +1 -0
  22. package/dist/chunk-J22W6HV3.js +107 -0
  23. package/dist/chunk-J22W6HV3.js.map +1 -0
  24. package/dist/{chunk-PY4XCDLR.js → chunk-J2VBW3DZ.js} +6 -95
  25. package/dist/chunk-J2VBW3DZ.js.map +1 -0
  26. package/dist/{chunk-HWPIFSW2.js → chunk-JSCT3CR4.js} +6 -4
  27. package/dist/{chunk-HWPIFSW2.js.map → chunk-JSCT3CR4.js.map} +1 -1
  28. package/dist/chunk-JWBCY4NC.js +330 -0
  29. package/dist/chunk-JWBCY4NC.js.map +1 -0
  30. package/dist/chunk-K2AUJHVP.js +2251 -0
  31. package/dist/chunk-K2AUJHVP.js.map +1 -0
  32. package/dist/chunk-MJ2NKQQL.js +119 -0
  33. package/dist/chunk-MJ2NKQQL.js.map +1 -0
  34. package/dist/chunk-N6UR7YVY.js +198 -0
  35. package/dist/chunk-N6UR7YVY.js.map +1 -0
  36. package/dist/chunk-NC6S43JJ.js +456 -0
  37. package/dist/chunk-NC6S43JJ.js.map +1 -0
  38. package/dist/chunk-OFVJBJXR.js +98 -0
  39. package/dist/chunk-OFVJBJXR.js.map +1 -0
  40. package/dist/chunk-OHISZPOJ.js +97 -0
  41. package/dist/chunk-OHISZPOJ.js.map +1 -0
  42. package/dist/chunk-OU5CQKNW.js +102 -0
  43. package/dist/chunk-OU5CQKNW.js.map +1 -0
  44. package/dist/{chunk-XOFWRC73.js → chunk-PF7GRZMW.js} +316 -21
  45. package/dist/chunk-PF7GRZMW.js.map +1 -0
  46. package/dist/{chunk-5DJTTKX3.js → chunk-PHOUUNK7.js} +74 -111
  47. package/dist/chunk-PHOUUNK7.js.map +1 -0
  48. package/dist/chunk-RNHBMHKA.js +1665 -0
  49. package/dist/chunk-RNHBMHKA.js.map +1 -0
  50. package/dist/chunk-SX52TAR4.js +110 -0
  51. package/dist/chunk-SX52TAR4.js.map +1 -0
  52. package/dist/{chunk-H4RVA4VE.js → chunk-VYPWMZ6H.js} +2 -2
  53. package/dist/chunk-WBZOVTYK.js +171 -0
  54. package/dist/chunk-WBZOVTYK.js.map +1 -0
  55. package/dist/chunk-WKNUIZOY.js +354 -0
  56. package/dist/chunk-WKNUIZOY.js.map +1 -0
  57. package/dist/chunk-X3VMZYBT.js +713 -0
  58. package/dist/chunk-X3VMZYBT.js.map +1 -0
  59. package/dist/chunk-X5R3GL6H.js +525 -0
  60. package/dist/chunk-X5R3GL6H.js.map +1 -0
  61. package/dist/chunk-XGPU467M.js +136 -0
  62. package/dist/chunk-XGPU467M.js.map +1 -0
  63. package/dist/compat/index.cjs +7656 -0
  64. package/dist/compat/index.cjs.map +1 -0
  65. package/dist/compat/index.d.cts +18 -0
  66. package/dist/compat/index.d.ts +18 -0
  67. package/dist/compat/index.js +50 -0
  68. package/dist/compat/index.js.map +1 -0
  69. package/dist/compat/jotai/index.cjs +2048 -0
  70. package/dist/compat/jotai/index.cjs.map +1 -0
  71. package/dist/compat/jotai/index.d.cts +2 -0
  72. package/dist/compat/jotai/index.d.ts +2 -0
  73. package/dist/compat/jotai/index.js +9 -0
  74. package/dist/compat/jotai/index.js.map +1 -0
  75. package/dist/compat/nanostores/index.cjs +2175 -0
  76. package/dist/compat/nanostores/index.cjs.map +1 -0
  77. package/dist/compat/nanostores/index.d.cts +2 -0
  78. package/dist/compat/nanostores/index.d.ts +2 -0
  79. package/dist/compat/nanostores/index.js +23 -0
  80. package/dist/compat/nanostores/index.js.map +1 -0
  81. package/dist/compat/nestjs/index.cjs +350 -16
  82. package/dist/compat/nestjs/index.cjs.map +1 -1
  83. package/dist/compat/nestjs/index.d.cts +6 -6
  84. package/dist/compat/nestjs/index.d.ts +6 -6
  85. package/dist/compat/nestjs/index.js +11 -9
  86. package/dist/compat/react/index.cjs +141 -0
  87. package/dist/compat/react/index.cjs.map +1 -0
  88. package/dist/compat/react/index.d.cts +2 -0
  89. package/dist/compat/react/index.d.ts +2 -0
  90. package/dist/compat/react/index.js +12 -0
  91. package/dist/compat/react/index.js.map +1 -0
  92. package/dist/compat/solid/index.cjs +128 -0
  93. package/dist/compat/solid/index.cjs.map +1 -0
  94. package/dist/compat/solid/index.d.cts +2 -0
  95. package/dist/compat/solid/index.d.ts +2 -0
  96. package/dist/compat/solid/index.js +12 -0
  97. package/dist/compat/solid/index.js.map +1 -0
  98. package/dist/compat/svelte/index.cjs +131 -0
  99. package/dist/compat/svelte/index.cjs.map +1 -0
  100. package/dist/compat/svelte/index.d.cts +2 -0
  101. package/dist/compat/svelte/index.d.ts +2 -0
  102. package/dist/compat/svelte/index.js +12 -0
  103. package/dist/compat/svelte/index.js.map +1 -0
  104. package/dist/compat/vue/index.cjs +146 -0
  105. package/dist/compat/vue/index.cjs.map +1 -0
  106. package/dist/compat/vue/index.d.cts +3 -0
  107. package/dist/compat/vue/index.d.ts +3 -0
  108. package/dist/compat/vue/index.js +12 -0
  109. package/dist/compat/vue/index.js.map +1 -0
  110. package/dist/compat/zustand/index.cjs +4931 -0
  111. package/dist/compat/zustand/index.cjs.map +1 -0
  112. package/dist/compat/zustand/index.d.cts +5 -0
  113. package/dist/compat/zustand/index.d.ts +5 -0
  114. package/dist/compat/zustand/index.js +12 -0
  115. package/dist/compat/zustand/index.js.map +1 -0
  116. package/dist/composite-C7PcQvcs.d.cts +303 -0
  117. package/dist/composite-aUCvjZVR.d.ts +303 -0
  118. package/dist/core/index.cjs +53 -4
  119. package/dist/core/index.cjs.map +1 -1
  120. package/dist/core/index.d.cts +4 -3
  121. package/dist/core/index.d.ts +4 -3
  122. package/dist/core/index.js +26 -24
  123. package/dist/demo-shell-BDkOptd6.d.ts +102 -0
  124. package/dist/demo-shell-Crid1WdR.d.cts +102 -0
  125. package/dist/extra/index.cjs +222 -110
  126. package/dist/extra/index.cjs.map +1 -1
  127. package/dist/extra/index.d.cts +6 -4
  128. package/dist/extra/index.d.ts +6 -4
  129. package/dist/extra/index.js +72 -65
  130. package/dist/extra/sources.cjs +2486 -0
  131. package/dist/extra/sources.cjs.map +1 -0
  132. package/dist/extra/sources.d.cts +465 -0
  133. package/dist/extra/sources.d.ts +465 -0
  134. package/dist/extra/sources.js +57 -0
  135. package/dist/extra/sources.js.map +1 -0
  136. package/dist/graph/index.cjs +408 -14
  137. package/dist/graph/index.cjs.map +1 -1
  138. package/dist/graph/index.d.cts +5 -5
  139. package/dist/graph/index.d.ts +5 -5
  140. package/dist/graph/index.js +13 -5
  141. package/dist/{graph-D-3JIQme.d.cts → graph-CCwGKLCm.d.ts} +195 -4
  142. package/dist/{graph-B6NFqv3z.d.ts → graph-DNCrvZSn.d.cts} +195 -4
  143. package/dist/index-3lsddbbS.d.ts +86 -0
  144. package/dist/index-B1tloyhO.d.cts +34 -0
  145. package/dist/{index-CYkjxu3s.d.ts → index-B6D3QNSA.d.ts} +33 -4
  146. package/dist/index-B6EhDnjH.d.cts +37 -0
  147. package/dist/index-B9B7_HEY.d.ts +37 -0
  148. package/dist/{index-Ds23Wvou.d.ts → index-BHlKbUwO.d.cts} +131 -883
  149. package/dist/{index-DiobMNwE.d.ts → index-BPVt8kqc.d.ts} +3 -3
  150. package/dist/index-BaSM3aYt.d.ts +195 -0
  151. package/dist/index-BuEoe-Qu.d.ts +121 -0
  152. package/dist/{index-Ch0IpIO0.d.cts → index-BwfLUNw4.d.ts} +131 -883
  153. package/dist/index-ByQxazQJ.d.cts +86 -0
  154. package/dist/index-C0svESO4.d.ts +127 -0
  155. package/dist/{index-OXImXMq6.d.ts → index-C8oil6M6.d.ts} +18 -196
  156. package/dist/{index-DKE1EATr.d.cts → index-CI3DprxP.d.cts} +18 -196
  157. package/dist/{index-AMWewNDe.d.cts → index-CO8uBlUh.d.cts} +33 -4
  158. package/dist/index-CxFrXH4m.d.ts +45 -0
  159. package/dist/index-D8wS_PeY.d.cts +121 -0
  160. package/dist/index-DO_6JN9Z.d.cts +127 -0
  161. package/dist/index-DVGiGFGT.d.cts +195 -0
  162. package/dist/index-DYme44FM.d.cts +44 -0
  163. package/dist/{index-J7Kc0oIQ.d.cts → index-DlLp-2Xn.d.cts} +3 -3
  164. package/dist/index-Dzk2hrlR.d.ts +44 -0
  165. package/dist/index-VHqptjhu.d.cts +45 -0
  166. package/dist/index-VdHQMPy1.d.ts +36 -0
  167. package/dist/index-Xi3u0HCQ.d.cts +36 -0
  168. package/dist/index-wEn0eFe8.d.ts +34 -0
  169. package/dist/index.cjs +1780 -176
  170. package/dist/index.cjs.map +1 -1
  171. package/dist/index.d.cts +784 -2082
  172. package/dist/index.d.ts +784 -2082
  173. package/dist/index.js +955 -4349
  174. package/dist/index.js.map +1 -1
  175. package/dist/memory-C6Z2tGpC.d.cts +139 -0
  176. package/dist/memory-li6FL5RM.d.ts +139 -0
  177. package/dist/messaging-Gt4LPbyA.d.cts +269 -0
  178. package/dist/messaging-XDoYablx.d.ts +269 -0
  179. package/dist/{meta-DWbkoq1s.d.cts → meta-BxCA7rcr.d.cts} +1 -1
  180. package/dist/{meta-CnkLA_43.d.ts → meta-CbznRPYJ.d.ts} +1 -1
  181. package/dist/{node-B-f-Lu-k.d.cts → node-BmerH3kS.d.cts} +26 -1
  182. package/dist/{node-B-f-Lu-k.d.ts → node-BmerH3kS.d.ts} +26 -1
  183. package/dist/{observable-uP-wy_uK.d.ts → observable-BgGUwcqp.d.ts} +1 -1
  184. package/dist/{observable-DBnrwcar.d.cts → observable-DJt_AxzQ.d.cts} +1 -1
  185. package/dist/patterns/ai.cjs +7930 -0
  186. package/dist/patterns/ai.cjs.map +1 -0
  187. package/dist/patterns/ai.d.cts +10 -0
  188. package/dist/patterns/ai.d.ts +10 -0
  189. package/dist/patterns/ai.js +71 -0
  190. package/dist/patterns/ai.js.map +1 -0
  191. package/dist/patterns/audit.cjs +5805 -0
  192. package/dist/patterns/audit.cjs.map +1 -0
  193. package/dist/patterns/audit.d.cts +6 -0
  194. package/dist/patterns/audit.d.ts +6 -0
  195. package/dist/patterns/audit.js +29 -0
  196. package/dist/patterns/audit.js.map +1 -0
  197. package/dist/patterns/demo-shell.cjs +5604 -0
  198. package/dist/patterns/demo-shell.cjs.map +1 -0
  199. package/dist/patterns/demo-shell.d.cts +6 -0
  200. package/dist/patterns/demo-shell.d.ts +6 -0
  201. package/dist/patterns/demo-shell.js +15 -0
  202. package/dist/patterns/demo-shell.js.map +1 -0
  203. package/dist/patterns/memory.cjs +5283 -0
  204. package/dist/patterns/memory.cjs.map +1 -0
  205. package/dist/patterns/memory.d.cts +5 -0
  206. package/dist/patterns/memory.d.ts +5 -0
  207. package/dist/patterns/memory.js +20 -0
  208. package/dist/patterns/memory.js.map +1 -0
  209. package/dist/patterns/reactive-layout/index.cjs +355 -13
  210. package/dist/patterns/reactive-layout/index.cjs.map +1 -1
  211. package/dist/patterns/reactive-layout/index.d.cts +6 -5
  212. package/dist/patterns/reactive-layout/index.d.ts +6 -5
  213. package/dist/patterns/reactive-layout/index.js +15 -12
  214. package/dist/reactive-layout-MQP--J3F.d.cts +183 -0
  215. package/dist/reactive-layout-u5Ulnqag.d.ts +183 -0
  216. package/dist/{storage-BuTdpCI1.d.cts → storage-CMjUUuxn.d.ts} +10 -2
  217. package/dist/{storage-F2X1U1x0.d.ts → storage-DdWlZo6U.d.cts} +10 -2
  218. package/dist/sugar-CCOxXK1e.d.ts +201 -0
  219. package/dist/sugar-D02n5JjF.d.cts +201 -0
  220. package/package.json +63 -3
  221. package/dist/chunk-5DJTTKX3.js.map +0 -1
  222. package/dist/chunk-IAHGTNOZ.js.map +0 -1
  223. package/dist/chunk-L2GLW2U7.js.map +0 -1
  224. package/dist/chunk-MW4VAKAO.js +0 -47
  225. package/dist/chunk-MW4VAKAO.js.map +0 -1
  226. package/dist/chunk-PY4XCDLR.js.map +0 -1
  227. package/dist/chunk-TKE3JGOH.js.map +0 -1
  228. package/dist/chunk-XOFWRC73.js.map +0 -1
  229. package/dist/index-BJB7t9gg.d.cts +0 -392
  230. package/dist/index-C-TXEa7C.d.ts +0 -392
  231. /package/dist/{chunk-H4RVA4VE.js.map → chunk-VYPWMZ6H.js.map} +0 -0
@@ -0,0 +1,713 @@
1
+ import {
2
+ analyzeAndMeasure,
3
+ carveTextLineSlots,
4
+ computeCharPositions,
5
+ computeLineBreaks,
6
+ layoutNextLine,
7
+ reactiveLayout
8
+ } from "./chunk-GTE6PWRZ.js";
9
+ import {
10
+ emitToMeta
11
+ } from "./chunk-JSCT3CR4.js";
12
+ import {
13
+ Graph
14
+ } from "./chunk-PF7GRZMW.js";
15
+ import {
16
+ derived,
17
+ monotonicNs,
18
+ node,
19
+ state
20
+ } from "./chunk-PHOUUNK7.js";
21
+ import {
22
+ __export
23
+ } from "./chunk-SX52TAR4.js";
24
+
25
+ // src/patterns/reactive-layout/index.ts
26
+ var reactive_layout_exports = {};
27
+ __export(reactive_layout_exports, {
28
+ CanvasMeasureAdapter: () => CanvasMeasureAdapter,
29
+ CliMeasureAdapter: () => CliMeasureAdapter,
30
+ ImageSizeAdapter: () => ImageSizeAdapter,
31
+ NodeCanvasMeasureAdapter: () => NodeCanvasMeasureAdapter,
32
+ PrecomputedAdapter: () => PrecomputedAdapter,
33
+ SvgBoundsAdapter: () => SvgBoundsAdapter,
34
+ analyzeAndMeasure: () => analyzeAndMeasure,
35
+ carveTextLineSlots: () => carveTextLineSlots,
36
+ circleIntervalForBand: () => circleIntervalForBand,
37
+ computeBlockFlow: () => computeBlockFlow,
38
+ computeCharPositions: () => computeCharPositions,
39
+ computeFlowLines: () => computeFlowLines,
40
+ computeLineBreaks: () => computeLineBreaks,
41
+ computeTotalHeight: () => computeTotalHeight,
42
+ layoutNextLine: () => layoutNextLine,
43
+ measureBlock: () => measureBlock,
44
+ measureBlocks: () => measureBlocks,
45
+ reactiveBlockLayout: () => reactiveBlockLayout,
46
+ reactiveFlowLayout: () => reactiveFlowLayout,
47
+ reactiveLayout: () => reactiveLayout,
48
+ rectIntervalForBand: () => rectIntervalForBand
49
+ });
50
+
51
+ // src/patterns/reactive-layout/measurement-adapters.ts
52
+ function cellWidth(code) {
53
+ if (code >= 768 && code <= 879 || // Combining Diacritical Marks
54
+ code >= 1155 && code <= 1161 || // Cyrillic combining marks
55
+ code >= 1425 && code <= 1469 || // Hebrew combining marks
56
+ code >= 1552 && code <= 1562 || // Arabic combining marks
57
+ code >= 1611 && code <= 1631 || // Arabic combining marks
58
+ code >= 1648 && code === 1648 || // Arabic superscript alef
59
+ code >= 1750 && code <= 1756 || // Arabic combining marks
60
+ code >= 1759 && code <= 1764 || // Arabic combining marks
61
+ code >= 1767 && code <= 1768 || // Arabic combining marks
62
+ code >= 1770 && code <= 1773 || // Arabic combining marks
63
+ code >= 1840 && code <= 1866 || // Syriac combining marks
64
+ code >= 1958 && code <= 1968 || // Thaana combining marks
65
+ code >= 2304 && code <= 2307 || // Devanagari combining marks
66
+ code >= 2362 && code <= 2383 || // Devanagari combining marks
67
+ code >= 2385 && code <= 2391 || // Devanagari combining marks
68
+ code >= 2402 && code <= 2403 || // Devanagari combining marks
69
+ code >= 2433 && code <= 2435 || // Bengali combining marks
70
+ code >= 2492 && code <= 2509 || // Bengali combining marks
71
+ code >= 2561 && code <= 2563 || // Gurmukhi combining marks
72
+ code >= 2620 && code <= 2641 || // Gurmukhi combining marks
73
+ code >= 2672 && code <= 2673 || // Gurmukhi combining marks
74
+ code >= 2677 && code === 2677 || // Gurmukhi combining mark
75
+ code >= 3633 && code === 3633 || // Thai combining mark
76
+ code >= 3636 && code <= 3642 || // Thai combining marks
77
+ code >= 3655 && code <= 3662 || // Thai combining marks
78
+ code >= 3761 && code === 3761 || // Lao combining mark
79
+ code >= 3764 && code <= 3772 || // Lao combining marks
80
+ code >= 3784 && code <= 3790 || // Lao combining marks
81
+ code >= 7616 && code <= 7679 || // Combining Diacritical Marks Supplement
82
+ code >= 8400 && code <= 8447 || // Combining Diacritical Marks for Symbols
83
+ code >= 65024 && code <= 65039 || // Variation Selectors
84
+ code >= 65056 && code <= 65071 || // Combining Half Marks
85
+ code === 8205) {
86
+ return 0;
87
+ }
88
+ if (code >= 4352 && code <= 4447 || // Hangul Jamo
89
+ code >= 8986 && code <= 8987 || // Watch, Hourglass
90
+ code >= 9001 && code <= 9002 || // Angle brackets
91
+ code >= 9193 && code <= 9203 || // Media control symbols
92
+ code >= 9208 && code <= 9210 || // Media control symbols
93
+ code >= 9725 && code <= 9726 || // Medium squares
94
+ code >= 9748 && code <= 9749 || // Umbrella, Hot Beverage
95
+ code >= 9800 && code <= 9811 || // Zodiac symbols
96
+ code === 9855 || // Wheelchair
97
+ code === 9875 || // Anchor
98
+ code === 9889 || // High Voltage
99
+ code >= 9898 && code <= 9899 || // Medium circles
100
+ code >= 9917 && code <= 9918 || // Soccer, Baseball
101
+ code >= 9924 && code <= 9925 || // Snowman, Sun behind cloud
102
+ code === 9934 || // Ophiuchus
103
+ code === 9940 || // No Entry
104
+ code === 9962 || // Church
105
+ code >= 9970 && code <= 9971 || // Fountain, Golf
106
+ code === 9973 || // Sailboat
107
+ code === 9978 || // Tent
108
+ code === 9981 || // Fuel Pump
109
+ code === 9986 || // Scissors
110
+ code === 9989 || // Check Mark
111
+ code >= 9992 && code <= 9997 || // Airplane...Writing Hand
112
+ code === 9999 || // Pencil
113
+ code >= 10067 && code <= 10069 || // Question marks
114
+ code === 10071 || // Exclamation
115
+ code >= 10133 && code <= 10135 || // Plus, Minus, Divide
116
+ code === 10160 || // Curly Loop
117
+ code === 10175 || // Double Curly Loop
118
+ code >= 10548 && code <= 10549 || // Arrows
119
+ code >= 11013 && code <= 11015 || // Arrows
120
+ code >= 11035 && code <= 11036 || // Squares
121
+ code === 11088 || // Star
122
+ code === 11093 || // Circle
123
+ code >= 11904 && code <= 12350 || // CJK Radicals, Symbols, Punctuation
124
+ code >= 12352 && code <= 12447 || // Hiragana
125
+ code >= 12448 && code <= 12543 || // Katakana
126
+ code >= 12549 && code <= 12591 || // Bopomofo
127
+ code >= 12593 && code <= 12686 || // Hangul Compatibility Jamo
128
+ code >= 12688 && code <= 12771 || // Kanbun, CJK Strokes
129
+ code >= 12784 && code <= 12830 || // Katakana Phonetic Extensions
130
+ code >= 12832 && code <= 12871 || // Enclosed CJK
131
+ code >= 12880 && code <= 19903 || // CJK Extensions + Unified block
132
+ code >= 19968 && code <= 40959 || // CJK Unified Ideographs
133
+ code >= 43360 && code <= 43388 || // Hangul Jamo Extended-A
134
+ code >= 44032 && code <= 55203 || // Hangul Syllables
135
+ code >= 63744 && code <= 64255 || // CJK Compatibility Ideographs
136
+ code >= 65040 && code <= 65049 || // Vertical forms
137
+ code >= 65072 && code <= 65131 || // CJK Compatibility Forms
138
+ code >= 65281 && code <= 65376 || // Fullwidth Forms (excl. halfwidth)
139
+ code >= 65504 && code <= 65510 || // Fullwidth Signs
140
+ code >= 126980 && code === 126980 || // Mahjong Red Dragon
141
+ code === 127183 || // Joker
142
+ code >= 127344 && code <= 127345 || // A/B buttons
143
+ code === 127358 || // O button
144
+ code === 127359 || // P button
145
+ code === 127374 || // AB button
146
+ code >= 127377 && code <= 127386 || // Squared symbols
147
+ code >= 127456 && code <= 127487 || // Regional Indicator Symbols
148
+ code >= 127488 && code <= 127490 || // Enclosed ideographic
149
+ code === 127514 || // Squared CJK
150
+ code === 127535 || // Squared CJK
151
+ code >= 127538 && code <= 127546 || // Squared CJK
152
+ code >= 127568 && code <= 127569 || // Circled ideographic
153
+ code >= 127744 && code <= 129535 || // Misc Symbols / Emoticons / Emoji
154
+ code >= 129536 && code <= 129791 || // Chess, Symbols Extended-A
155
+ code >= 129792 && code <= 130047 || // Symbols for Legacy Computing
156
+ code >= 131072 && code <= 196605 || // CJK Extension B-F (excl. nonchars)
157
+ code >= 196608 && code <= 262141) {
158
+ return 2;
159
+ }
160
+ return 1;
161
+ }
162
+ function countCells(text) {
163
+ let cells = 0;
164
+ for (const ch of text) {
165
+ cells += cellWidth(ch.codePointAt(0));
166
+ }
167
+ return cells;
168
+ }
169
+ var CliMeasureAdapter = class {
170
+ cellPx;
171
+ constructor(opts) {
172
+ this.cellPx = opts?.cellPx ?? 8;
173
+ }
174
+ measureSegment(text, _font) {
175
+ return { width: countCells(text) * this.cellPx };
176
+ }
177
+ };
178
+ var PrecomputedAdapterKeyError = class extends Error {
179
+ name = "KeyError";
180
+ };
181
+ var PrecomputedAdapter = class {
182
+ metrics;
183
+ fallback;
184
+ constructor(opts) {
185
+ this.metrics = opts.metrics;
186
+ const fb = opts.fallback ?? "per-char";
187
+ if (fb !== "per-char" && fb !== "error") {
188
+ throw new Error(
189
+ `fallback must be 'per-char' or 'error', got ${JSON.stringify(opts.fallback)}`
190
+ );
191
+ }
192
+ this.fallback = fb;
193
+ }
194
+ measureSegment(text, font) {
195
+ const fontMap = this.metrics[font];
196
+ if (fontMap) {
197
+ const w = fontMap[text];
198
+ if (w !== void 0) return { width: w };
199
+ }
200
+ if (this.fallback === "error") {
201
+ throw new PrecomputedAdapterKeyError(
202
+ `PrecomputedAdapter: no metrics for segment ${JSON.stringify(text)} in font ${JSON.stringify(font)}`
203
+ );
204
+ }
205
+ let total = 0;
206
+ if (fontMap) {
207
+ for (const ch of text) {
208
+ const cw = fontMap[ch];
209
+ if (cw !== void 0) {
210
+ total += cw;
211
+ }
212
+ }
213
+ }
214
+ return { width: total };
215
+ }
216
+ };
217
+ var CanvasMeasureAdapter = class {
218
+ ctx = null;
219
+ currentFont = "";
220
+ emojiCorrection;
221
+ constructor(opts) {
222
+ this.emojiCorrection = opts?.emojiCorrection ?? 1;
223
+ }
224
+ getContext() {
225
+ if (!this.ctx) {
226
+ if (typeof OffscreenCanvas === "undefined") {
227
+ throw new Error(
228
+ "CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js."
229
+ );
230
+ }
231
+ const canvas = new OffscreenCanvas(0, 0);
232
+ const ctx = canvas.getContext("2d");
233
+ if (!ctx) throw new Error("CanvasMeasureAdapter: failed to get 2d context");
234
+ this.ctx = ctx;
235
+ }
236
+ return this.ctx;
237
+ }
238
+ measureSegment(text, font) {
239
+ const ctx = this.getContext();
240
+ if (font !== this.currentFont) {
241
+ ctx.font = font;
242
+ this.currentFont = font;
243
+ }
244
+ let width = ctx.measureText(text).width;
245
+ if (this.emojiCorrection !== 1 && new RegExp("\\p{Emoji_Presentation}", "u").test(text)) {
246
+ width *= this.emojiCorrection;
247
+ }
248
+ return { width };
249
+ }
250
+ clearCache() {
251
+ this.currentFont = "";
252
+ }
253
+ };
254
+ var NodeCanvasMeasureAdapter = class {
255
+ ctx = null;
256
+ currentFont = "";
257
+ canvasModule;
258
+ constructor(canvasModule) {
259
+ this.canvasModule = canvasModule;
260
+ }
261
+ getContext() {
262
+ if (!this.ctx) {
263
+ const canvas = this.canvasModule.createCanvas(0, 0);
264
+ const ctx = canvas.getContext("2d");
265
+ if (!ctx) throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");
266
+ this.ctx = ctx;
267
+ }
268
+ return this.ctx;
269
+ }
270
+ measureSegment(text, font) {
271
+ const ctx = this.getContext();
272
+ if (font !== this.currentFont) {
273
+ ctx.font = font;
274
+ this.currentFont = font;
275
+ }
276
+ return { width: ctx.measureText(text).width };
277
+ }
278
+ clearCache() {
279
+ this.currentFont = "";
280
+ }
281
+ };
282
+ var SvgBoundsAdapter = class {
283
+ measureSvg(content) {
284
+ const viewBoxMatch = content.match(/viewBox\s*=\s*["']([^"']+)["']/);
285
+ if (viewBoxMatch) {
286
+ const parts = viewBoxMatch[1].trim().split(/[\s,]+/);
287
+ if (parts.length >= 4) {
288
+ const w = Number.parseFloat(parts[2]);
289
+ const h = Number.parseFloat(parts[3]);
290
+ if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {
291
+ return { width: w, height: h };
292
+ }
293
+ throw new Error(
294
+ "SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive"
295
+ );
296
+ }
297
+ }
298
+ const widthMatch = content.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/);
299
+ const heightMatch = content.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);
300
+ if (widthMatch && heightMatch) {
301
+ const w = Number.parseFloat(widthMatch[1]);
302
+ const h = Number.parseFloat(heightMatch[1]);
303
+ if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {
304
+ return { width: w, height: h };
305
+ }
306
+ throw new Error(
307
+ "SvgBoundsAdapter: svg width/height attributes are non-finite or not positive"
308
+ );
309
+ }
310
+ throw new Error(
311
+ "SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes"
312
+ );
313
+ }
314
+ };
315
+ var ImageSizeAdapter = class {
316
+ sizes;
317
+ constructor(sizes) {
318
+ this.sizes = new Map(Object.entries(sizes));
319
+ }
320
+ measureImage(src) {
321
+ const dims = this.sizes.get(src);
322
+ if (!dims) {
323
+ throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(src)}`);
324
+ }
325
+ return { width: dims.width, height: dims.height };
326
+ }
327
+ };
328
+
329
+ // src/patterns/reactive-layout/reactive-block-layout.ts
330
+ function measureBlock(block, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight, index) {
331
+ switch (block.type) {
332
+ case "text": {
333
+ const font = block.font ?? defaultFont;
334
+ const lineHeight = block.lineHeight ?? defaultLineHeight;
335
+ const segments = analyzeAndMeasure(block.text, font, adapters.text, measureCache);
336
+ const lineBreaks = computeLineBreaks(segments, maxWidth, adapters.text, font, measureCache);
337
+ const charPositions = computeCharPositions(lineBreaks, segments, lineHeight);
338
+ const height = lineBreaks.lineCount * lineHeight;
339
+ let width = 0;
340
+ for (const line of lineBreaks.lines) {
341
+ if (line.width > width) width = line.width;
342
+ }
343
+ return {
344
+ index,
345
+ type: "text",
346
+ width: Math.min(width, maxWidth),
347
+ height,
348
+ textSegments: segments,
349
+ textLineBreaks: lineBreaks,
350
+ textCharPositions: charPositions
351
+ };
352
+ }
353
+ case "image": {
354
+ let w;
355
+ let h;
356
+ if (block.naturalWidth != null && block.naturalHeight != null) {
357
+ w = block.naturalWidth;
358
+ h = block.naturalHeight;
359
+ } else if (adapters.image) {
360
+ const dims = adapters.image.measureImage(block.src);
361
+ w = dims.width;
362
+ h = dims.height;
363
+ } else {
364
+ throw new Error(
365
+ `Image block at index ${index} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`
366
+ );
367
+ }
368
+ if (w > maxWidth) {
369
+ h = h * maxWidth / w;
370
+ w = maxWidth;
371
+ }
372
+ return { index, type: "image", width: w, height: h };
373
+ }
374
+ case "svg": {
375
+ let w;
376
+ let h;
377
+ if (block.viewBox) {
378
+ w = block.viewBox.width;
379
+ h = block.viewBox.height;
380
+ } else if (adapters.svg) {
381
+ const dims = adapters.svg.measureSvg(block.content);
382
+ w = dims.width;
383
+ h = dims.height;
384
+ } else {
385
+ throw new Error(`SVG block at index ${index} has no viewBox and no SvgMeasurer adapter`);
386
+ }
387
+ if (w > maxWidth) {
388
+ h = h * maxWidth / w;
389
+ w = maxWidth;
390
+ }
391
+ return { index, type: "svg", width: w, height: h };
392
+ }
393
+ }
394
+ }
395
+ function measureBlocks(blocks, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight) {
396
+ return blocks.map(
397
+ (block, i) => measureBlock(block, maxWidth, adapters, measureCache, defaultFont, defaultLineHeight, i)
398
+ );
399
+ }
400
+ function computeBlockFlow(measured, gap) {
401
+ const result = [];
402
+ let y = 0;
403
+ for (let i = 0; i < measured.length; i++) {
404
+ const m = measured[i];
405
+ result.push({ ...m, x: 0, y });
406
+ y += m.height + (i < measured.length - 1 ? gap : 0);
407
+ }
408
+ return result;
409
+ }
410
+ function computeTotalHeight(flow) {
411
+ if (flow.length === 0) return 0;
412
+ const last = flow[flow.length - 1];
413
+ return last.y + last.height;
414
+ }
415
+ function reactiveBlockLayout(opts) {
416
+ const {
417
+ adapters,
418
+ name = "reactive-block-layout",
419
+ defaultFont = "16px sans-serif",
420
+ defaultLineHeight = 20
421
+ } = opts;
422
+ const g = new Graph(name);
423
+ const measureCache = /* @__PURE__ */ new Map();
424
+ const blocksNode = state(opts.blocks ?? [], { name: "blocks" });
425
+ const maxWidthNode = state(Math.max(0, opts.maxWidth ?? 800), { name: "max-width" });
426
+ const gapNode = state(opts.gap ?? 0, { name: "gap" });
427
+ const measuredBlocksNode = node(
428
+ [blocksNode, maxWidthNode],
429
+ (data, actions, ctx) => {
430
+ const blocksVal = data[0] != null && data[0].length > 0 ? data[0].at(-1) : ctx.prevData[0];
431
+ const mwVal = data[1] != null && data[1].length > 0 ? data[1].at(-1) : ctx.prevData[1];
432
+ const t0 = monotonicNs();
433
+ const result = measureBlocks(
434
+ blocksVal,
435
+ mwVal,
436
+ adapters,
437
+ measureCache,
438
+ defaultFont,
439
+ defaultLineHeight
440
+ );
441
+ const elapsed = monotonicNs() - t0;
442
+ const meta = measuredBlocksNode.meta;
443
+ if (meta) {
444
+ emitToMeta(meta["block-count"], result.length);
445
+ emitToMeta(meta["layout-time-ns"], elapsed);
446
+ }
447
+ actions.emit(result);
448
+ return () => {
449
+ measureCache.clear();
450
+ adapters.text.clearCache?.();
451
+ };
452
+ },
453
+ {
454
+ name: "measured-blocks",
455
+ describeKind: "derived",
456
+ meta: { "block-count": 0, "layout-time-ns": 0 },
457
+ equals: (a, b) => {
458
+ const ma = a;
459
+ const mb = b;
460
+ if (ma == null || mb == null) return ma === mb;
461
+ if (ma.length !== mb.length) return false;
462
+ for (let i = 0; i < ma.length; i++) {
463
+ const ba = ma[i];
464
+ const bb = mb[i];
465
+ if (ba.type !== bb.type || ba.width !== bb.width || ba.height !== bb.height || ba.index !== bb.index)
466
+ return false;
467
+ }
468
+ return true;
469
+ }
470
+ }
471
+ );
472
+ const blockFlowNode = derived(
473
+ [measuredBlocksNode, gapNode],
474
+ ([measured, gapVal]) => {
475
+ return computeBlockFlow(measured, gapVal);
476
+ },
477
+ {
478
+ name: "block-flow",
479
+ equals: (a, b) => {
480
+ const fa = a;
481
+ const fb = b;
482
+ if (fa == null || fb == null) return fa === fb;
483
+ if (fa.length !== fb.length) return false;
484
+ for (let i = 0; i < fa.length; i++) {
485
+ const pa = fa[i];
486
+ const pb = fb[i];
487
+ if (pa.x !== pb.x || pa.y !== pb.y || pa.width !== pb.width || pa.height !== pb.height)
488
+ return false;
489
+ }
490
+ return true;
491
+ }
492
+ }
493
+ );
494
+ const totalHeightNode = derived(
495
+ [blockFlowNode],
496
+ ([flow]) => computeTotalHeight(flow),
497
+ { name: "total-height" }
498
+ );
499
+ g.add("blocks", blocksNode);
500
+ g.add("max-width", maxWidthNode);
501
+ g.add("gap", gapNode);
502
+ g.add("measured-blocks", measuredBlocksNode);
503
+ g.add("block-flow", blockFlowNode);
504
+ g.add("total-height", totalHeightNode);
505
+ return {
506
+ graph: g,
507
+ setBlocks: (blocks) => g.set("blocks", blocks),
508
+ setMaxWidth: (mw) => g.set("max-width", Math.max(0, mw)),
509
+ setGap: (gap) => g.set("gap", gap),
510
+ measuredBlocks: measuredBlocksNode,
511
+ blockFlow: blockFlowNode,
512
+ totalHeight: totalHeightNode
513
+ };
514
+ }
515
+
516
+ // src/patterns/reactive-layout/reactive-flow-layout.ts
517
+ function circleIntervalForBand(o, bandTop, bandBottom) {
518
+ const hPad = o.hPad ?? 0;
519
+ const vPad = o.vPad ?? 0;
520
+ const top = bandTop - vPad;
521
+ const bottom = bandBottom + vPad;
522
+ if (top >= o.cy + o.r || bottom <= o.cy - o.r) return null;
523
+ const minDy = o.cy >= top && o.cy <= bottom ? 0 : o.cy < top ? top - o.cy : o.cy - bottom;
524
+ if (minDy >= o.r) return null;
525
+ const maxDx = Math.sqrt(o.r * o.r - minDy * minDy);
526
+ return { left: o.cx - maxDx - hPad, right: o.cx + maxDx + hPad };
527
+ }
528
+ function rectIntervalForBand(o, bandTop, bandBottom) {
529
+ const hPad = o.hPad ?? 0;
530
+ const vPad = o.vPad ?? 0;
531
+ if (bandBottom <= o.y - vPad) return null;
532
+ if (bandTop >= o.y + o.h + vPad) return null;
533
+ return { left: o.x - hPad, right: o.x + o.w + hPad };
534
+ }
535
+ function obstacleIntervalForBand(o, bandTop, bandBottom) {
536
+ return o.kind === "circle" ? circleIntervalForBand(o, bandTop, bandBottom) : rectIntervalForBand(o, bandTop, bandBottom);
537
+ }
538
+ function computeFlowLines(segments, container, columns, obstacles, lineHeight, minSlotWidth) {
539
+ const lines = [];
540
+ let cursor = { segmentIndex: 0, graphemeIndex: 0 };
541
+ if (segments.length === 0 || columns.count <= 0 || lineHeight <= 0) {
542
+ return { lines, cursor };
543
+ }
544
+ const padX = container.paddingX ?? 0;
545
+ const padY = container.paddingY ?? 0;
546
+ const availWidth = Math.max(0, container.width - padX * 2);
547
+ const availHeight = Math.max(0, container.height - padY * 2);
548
+ const gapTotal = columns.gap * Math.max(0, columns.count - 1);
549
+ const colWidth = Math.max(0, (availWidth - gapTotal) / columns.count);
550
+ if (colWidth <= 0) return { lines, cursor };
551
+ outerCol: for (let col = 0; col < columns.count; col++) {
552
+ const colLeft = padX + col * (colWidth + columns.gap);
553
+ const colRight = colLeft + colWidth;
554
+ let bandTop = padY;
555
+ while (bandTop + lineHeight <= padY + availHeight) {
556
+ const bandBottom = bandTop + lineHeight;
557
+ const blocked = [];
558
+ for (let oi = 0; oi < obstacles.length; oi++) {
559
+ const iv = obstacleIntervalForBand(obstacles[oi], bandTop, bandBottom);
560
+ if (iv !== null) blocked.push(iv);
561
+ }
562
+ const slots = carveTextLineSlots({ left: colLeft, right: colRight }, blocked, minSlotWidth);
563
+ if (slots.length === 0) {
564
+ bandTop += lineHeight;
565
+ continue;
566
+ }
567
+ let hardBreakThisBand = false;
568
+ for (let si = 0; si < slots.length; si++) {
569
+ const slot = slots[si];
570
+ const slotW = slot.right - slot.left;
571
+ const line = layoutNextLine(segments, cursor, slotW);
572
+ if (line === null) {
573
+ return { lines, cursor };
574
+ }
575
+ if (line.text.length === 0 && line.width === 0) {
576
+ cursor = line.end;
577
+ hardBreakThisBand = true;
578
+ break;
579
+ }
580
+ lines.push({
581
+ x: slot.left,
582
+ y: bandTop,
583
+ width: line.width,
584
+ slotWidth: slotW,
585
+ text: line.text,
586
+ columnIndex: col,
587
+ flushToRight: slot.right < colRight - 0.5
588
+ });
589
+ cursor = line.end;
590
+ }
591
+ bandTop += lineHeight;
592
+ if (hardBreakThisBand) continue;
593
+ if (cursor.segmentIndex >= segments.length) break outerCol;
594
+ }
595
+ if (cursor.segmentIndex >= segments.length) break;
596
+ }
597
+ return { lines, cursor };
598
+ }
599
+ function reactiveFlowLayout(opts) {
600
+ const { adapter, name = "reactive-flow-layout", minSlotWidth = 20 } = opts;
601
+ const g = new Graph(name);
602
+ const measureCache = /* @__PURE__ */ new Map();
603
+ const textNode = state(opts.text ?? "", { name: "text" });
604
+ const fontNode = state(opts.font ?? "16px sans-serif", { name: "font" });
605
+ const lineHeightNode = state(opts.lineHeight ?? 20, { name: "line-height" });
606
+ const containerNode = state(
607
+ opts.container ?? { width: 800, height: 600, paddingX: 0, paddingY: 0 },
608
+ { name: "container" }
609
+ );
610
+ const columnsNode = state(opts.columns ?? { count: 1, gap: 0 }, {
611
+ name: "columns"
612
+ });
613
+ const obstaclesNode = state(opts.obstacles ?? [], { name: "obstacles" });
614
+ const segmentsNode = node(
615
+ [textNode, fontNode],
616
+ (data, actions, ctx) => {
617
+ const b0 = data[0];
618
+ const textVal = b0 != null && b0.length > 0 ? b0.at(-1) : ctx.prevData[0];
619
+ const b1 = data[1];
620
+ const fontVal = b1 != null && b1.length > 0 ? b1.at(-1) : ctx.prevData[1];
621
+ const result = analyzeAndMeasure(textVal, fontVal, adapter, measureCache);
622
+ actions.emit(result);
623
+ return () => {
624
+ measureCache.clear();
625
+ adapter.clearCache?.();
626
+ };
627
+ },
628
+ { name: "segments", describeKind: "derived" }
629
+ );
630
+ const flowLinesNode = derived(
631
+ [segmentsNode, containerNode, columnsNode, obstaclesNode, lineHeightNode],
632
+ ([segs, cont, cols, obs, lh]) => {
633
+ const segments = segs;
634
+ const t0 = monotonicNs();
635
+ const { lines: result, cursor } = computeFlowLines(
636
+ segments,
637
+ cont,
638
+ cols,
639
+ obs,
640
+ lh,
641
+ minSlotWidth
642
+ );
643
+ const elapsed = monotonicNs() - t0;
644
+ const overflow = Math.max(0, segments.length - cursor.segmentIndex);
645
+ const meta = flowLinesNode.meta;
646
+ if (meta) {
647
+ emitToMeta(meta["line-count"], result.length);
648
+ emitToMeta(meta["layout-time-ns"], elapsed);
649
+ emitToMeta(meta["overflow-segments"], overflow);
650
+ }
651
+ return result;
652
+ },
653
+ {
654
+ name: "flow-lines",
655
+ meta: {
656
+ "line-count": 0,
657
+ "layout-time-ns": 0,
658
+ "overflow-segments": 0
659
+ },
660
+ equals: (a, b) => {
661
+ const la = a;
662
+ const lb = b;
663
+ if (la.length !== lb.length) return false;
664
+ for (let i = 0; i < la.length; i++) {
665
+ const pa = la[i];
666
+ const pb = lb[i];
667
+ if (pa.x !== pb.x || pa.y !== pb.y || pa.width !== pb.width || pa.slotWidth !== pb.slotWidth || pa.text !== pb.text || pa.columnIndex !== pb.columnIndex || pa.flushToRight !== pb.flushToRight)
668
+ return false;
669
+ }
670
+ return true;
671
+ }
672
+ }
673
+ );
674
+ g.add("text", textNode);
675
+ g.add("font", fontNode);
676
+ g.add("line-height", lineHeightNode);
677
+ g.add("container", containerNode);
678
+ g.add("columns", columnsNode);
679
+ g.add("obstacles", obstaclesNode);
680
+ g.add("segments", segmentsNode);
681
+ g.add("flow-lines", flowLinesNode);
682
+ return {
683
+ graph: g,
684
+ setText: (t) => g.set("text", t),
685
+ setFont: (f) => g.set("font", f),
686
+ setLineHeight: (lh) => g.set("line-height", lh),
687
+ setContainer: (c) => g.set("container", c),
688
+ setColumns: (c) => g.set("columns", c),
689
+ setObstacles: (o) => g.set("obstacles", o),
690
+ segments: segmentsNode,
691
+ flowLines: flowLinesNode
692
+ };
693
+ }
694
+
695
+ export {
696
+ CliMeasureAdapter,
697
+ PrecomputedAdapter,
698
+ CanvasMeasureAdapter,
699
+ NodeCanvasMeasureAdapter,
700
+ SvgBoundsAdapter,
701
+ ImageSizeAdapter,
702
+ measureBlock,
703
+ measureBlocks,
704
+ computeBlockFlow,
705
+ computeTotalHeight,
706
+ reactiveBlockLayout,
707
+ circleIntervalForBand,
708
+ rectIntervalForBand,
709
+ computeFlowLines,
710
+ reactiveFlowLayout,
711
+ reactive_layout_exports
712
+ };
713
+ //# sourceMappingURL=chunk-X3VMZYBT.js.map