@graphrefly/ts 0.0.0 → 0.0.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 (307) hide show
  1. package/README.md +135 -0
  2. package/dist/adapters/index.cjs +105 -66
  3. package/dist/adapters/index.cjs.map +1 -1
  4. package/dist/adapters/index.d.cts +11 -136
  5. package/dist/adapters/index.d.ts +11 -136
  6. package/dist/adapters/index.js +27 -225
  7. package/dist/adapters/index.js.map +1 -1
  8. package/dist/adapters/observe-storage.d.cts +4 -4
  9. package/dist/adapters/observe-storage.d.ts +4 -4
  10. package/dist/adapters/observe-storage.js +1 -0
  11. package/dist/adapters/observe-storage.js.map +1 -1
  12. package/dist/adapters/react.cjs +166 -0
  13. package/dist/adapters/react.cjs.map +1 -0
  14. package/dist/adapters/react.d.cts +31 -0
  15. package/dist/adapters/react.d.ts +31 -0
  16. package/dist/adapters/react.js +51 -0
  17. package/dist/adapters/react.js.map +1 -0
  18. package/dist/adapters/solid.cjs +157 -0
  19. package/dist/adapters/solid.cjs.map +1 -0
  20. package/dist/adapters/solid.d.cts +26 -0
  21. package/dist/adapters/solid.d.ts +26 -0
  22. package/dist/adapters/solid.js +48 -0
  23. package/dist/adapters/solid.js.map +1 -0
  24. package/dist/adapters/svelte.cjs +148 -0
  25. package/dist/adapters/svelte.cjs.map +1 -0
  26. package/dist/adapters/svelte.d.cts +31 -0
  27. package/dist/adapters/svelte.d.ts +31 -0
  28. package/dist/adapters/svelte.js +46 -0
  29. package/dist/adapters/svelte.js.map +1 -0
  30. package/dist/adapters/vue.cjs +155 -0
  31. package/dist/adapters/vue.cjs.map +1 -0
  32. package/dist/adapters/vue.d.cts +26 -0
  33. package/dist/adapters/vue.d.ts +26 -0
  34. package/dist/adapters/vue.js +46 -0
  35. package/dist/adapters/vue.js.map +1 -0
  36. package/dist/agent-runtime-BesGDZcB.d.ts +555 -0
  37. package/dist/agent-runtime-DZTJ3C-p.d.cts +555 -0
  38. package/dist/agentic-memory-BmRCvh0d.d.ts +517 -0
  39. package/dist/agentic-memory-DfuVZ-lY.d.cts +517 -0
  40. package/dist/capability-admission-B0BzqAm5.d.cts +102 -0
  41. package/dist/capability-admission-g0mn9hpq.d.ts +102 -0
  42. package/dist/{chunk-JR4IKCR2.js → chunk-2747WN4Y.js} +5 -5
  43. package/dist/{chunk-2ILL7HQI.js → chunk-3JR3EDB2.js} +17 -17
  44. package/dist/{chunk-2ILL7HQI.js.map → chunk-3JR3EDB2.js.map} +1 -1
  45. package/dist/{chunk-GDL26N2T.js → chunk-3KN7NJDR.js} +2 -2
  46. package/dist/{chunk-DJC4CHLQ.js → chunk-43BKLFZU.js} +9 -9
  47. package/dist/chunk-6XAIOL3X.js +2407 -0
  48. package/dist/chunk-6XAIOL3X.js.map +1 -0
  49. package/dist/{chunk-SCRFRCGR.js → chunk-BSQGE5PS.js} +1 -1
  50. package/dist/{chunk-Y3ZLRGHC.js → chunk-CZNV3VXM.js} +16 -16
  51. package/dist/chunk-DGUM43GV.js +11 -0
  52. package/dist/chunk-DGUM43GV.js.map +1 -0
  53. package/dist/{chunk-JIMUDQN3.js → chunk-FBUU43PM.js} +2 -2
  54. package/dist/chunk-H75VXTGT.js +219 -0
  55. package/dist/chunk-H75VXTGT.js.map +1 -0
  56. package/dist/{chunk-RIIOUTGM.js → chunk-HKK2JD7Z.js} +12 -9
  57. package/dist/chunk-HKK2JD7Z.js.map +1 -0
  58. package/dist/{chunk-D6BG7U6A.js → chunk-IXZBUWSP.js} +3 -3
  59. package/dist/chunk-PC3BTTBE.js +3217 -0
  60. package/dist/chunk-PC3BTTBE.js.map +1 -0
  61. package/dist/chunk-QFY4AFY4.js +879 -0
  62. package/dist/chunk-QFY4AFY4.js.map +1 -0
  63. package/dist/{chunk-DK554R7P.js → chunk-S6HXABGL.js} +2 -1
  64. package/dist/chunk-S6HXABGL.js.map +1 -0
  65. package/dist/{chunk-PKVBHGBM.js → chunk-SS2A464I.js} +7 -7
  66. package/dist/chunk-UT3MHJCW.js +49 -0
  67. package/dist/chunk-UT3MHJCW.js.map +1 -0
  68. package/dist/{chunk-G4M3NHRJ.js → chunk-V7CIJE4B.js} +3 -3
  69. package/dist/{chunk-TEW47IVR.js → chunk-VPEFSDME.js} +2 -2
  70. package/dist/chunk-VTHLCFN4.js +368 -0
  71. package/dist/chunk-VTHLCFN4.js.map +1 -0
  72. package/dist/{chunk-SWTLEQL6.js → chunk-WQIA3GFB.js} +2 -2
  73. package/dist/chunk-WQIA3GFB.js.map +1 -0
  74. package/dist/{chunk-I3IHOHCJ.js → chunk-XKXWK2KP.js} +108 -64
  75. package/dist/chunk-XKXWK2KP.js.map +1 -0
  76. package/dist/{chunk-COHO25CZ.js → chunk-YDSIVHRR.js} +553 -7
  77. package/dist/chunk-YDSIVHRR.js.map +1 -0
  78. package/dist/chunk-YXMZ2N6J.js +1884 -0
  79. package/dist/chunk-YXMZ2N6J.js.map +1 -0
  80. package/dist/composition/index.cjs +102 -57
  81. package/dist/composition/index.cjs.map +1 -1
  82. package/dist/composition/index.d.cts +4 -4
  83. package/dist/composition/index.d.ts +4 -4
  84. package/dist/composition/index.js +6 -5
  85. package/dist/core/index.cjs +102 -57
  86. package/dist/core/index.cjs.map +1 -1
  87. package/dist/core/index.d.cts +2 -2
  88. package/dist/core/index.d.ts +2 -2
  89. package/dist/core/index.js +5 -4
  90. package/dist/cqrs/index.cjs.map +1 -1
  91. package/dist/cqrs/index.d.cts +4 -4
  92. package/dist/cqrs/index.d.ts +4 -4
  93. package/dist/cqrs/index.js +3 -2
  94. package/dist/cqrs/index.js.map +1 -1
  95. package/dist/cqrs/messaging.cjs +312 -0
  96. package/dist/cqrs/messaging.cjs.map +1 -0
  97. package/dist/cqrs/messaging.d.cts +57 -0
  98. package/dist/cqrs/messaging.d.ts +57 -0
  99. package/dist/cqrs/messaging.js +274 -0
  100. package/dist/cqrs/messaging.js.map +1 -0
  101. package/dist/cqrs/work-queue.cjs +329 -0
  102. package/dist/cqrs/work-queue.cjs.map +1 -0
  103. package/dist/cqrs/work-queue.d.cts +90 -0
  104. package/dist/cqrs/work-queue.d.ts +90 -0
  105. package/dist/cqrs/work-queue.js +292 -0
  106. package/dist/cqrs/work-queue.js.map +1 -0
  107. package/dist/data/index.cjs +19 -0
  108. package/dist/data/index.cjs.map +1 -0
  109. package/dist/data/index.d.cts +36 -0
  110. package/dist/data/index.d.ts +36 -0
  111. package/dist/data/index.js +1 -0
  112. package/dist/data/index.js.map +1 -0
  113. package/dist/data-structures/index.cjs +105 -57
  114. package/dist/data-structures/index.cjs.map +1 -1
  115. package/dist/data-structures/index.d.cts +8 -8
  116. package/dist/data-structures/index.d.ts +8 -8
  117. package/dist/data-structures/index.js +7 -6
  118. package/dist/{describe-BZb7AS2y.d.ts → describe-BpyJuWkw.d.ts} +1 -1
  119. package/dist/{describe-Ciu8SUnN.d.cts → describe-DYMw_l1C.d.cts} +1 -1
  120. package/dist/executors/work-queue.cjs +342 -0
  121. package/dist/executors/work-queue.cjs.map +1 -0
  122. package/dist/executors/work-queue.d.cts +90 -0
  123. package/dist/executors/work-queue.d.ts +90 -0
  124. package/dist/executors/work-queue.js +306 -0
  125. package/dist/executors/work-queue.js.map +1 -0
  126. package/dist/graph/index.cjs +112 -58
  127. package/dist/graph/index.cjs.map +1 -1
  128. package/dist/graph/index.d.cts +9 -9
  129. package/dist/graph/index.d.ts +9 -9
  130. package/dist/graph/index.js +18 -17
  131. package/dist/{graph-DfdF9zy4.d.ts → graph-D-1-SQeC.d.ts} +3 -3
  132. package/dist/{graph-s23RbbFO.d.cts → graph-DCEWh4T2.d.cts} +3 -3
  133. package/dist/{index-CAEmLCYF.d.cts → index-72VZC0-E.d.cts} +2 -2
  134. package/dist/{index-SnzZu3x7.d.ts → index-Bmxeu0nK.d.ts} +2 -2
  135. package/dist/index.cjs +112 -58
  136. package/dist/index.cjs.map +1 -1
  137. package/dist/index.d.cts +11 -10
  138. package/dist/index.d.ts +11 -10
  139. package/dist/index.js +118 -113
  140. package/dist/inspection/boundary.cjs +98 -0
  141. package/dist/inspection/boundary.cjs.map +1 -0
  142. package/dist/inspection/boundary.d.cts +61 -0
  143. package/dist/inspection/boundary.d.ts +61 -0
  144. package/dist/inspection/boundary.js +75 -0
  145. package/dist/inspection/boundary.js.map +1 -0
  146. package/dist/{messages-BZqrGGm1.d.ts → messages-CAzUPPJM.d.cts} +10 -5
  147. package/dist/{messages-BZqrGGm1.d.cts → messages-CAzUPPJM.d.ts} +10 -5
  148. package/dist/messaging/index.cjs +744 -613
  149. package/dist/messaging/index.cjs.map +1 -1
  150. package/dist/messaging/index.d.cts +216 -160
  151. package/dist/messaging/index.d.ts +216 -160
  152. package/dist/messaging/index.js +19 -749
  153. package/dist/messaging/index.js.map +1 -1
  154. package/dist/operators/index.cjs +102 -57
  155. package/dist/operators/index.cjs.map +1 -1
  156. package/dist/operators/index.d.cts +6 -6
  157. package/dist/operators/index.d.ts +6 -6
  158. package/dist/operators/index.js +8 -7
  159. package/dist/orchestration/index.cjs +3333 -59
  160. package/dist/orchestration/index.cjs.map +1 -1
  161. package/dist/orchestration/index.d.cts +7 -4
  162. package/dist/orchestration/index.d.ts +7 -4
  163. package/dist/orchestration/index.js +49 -8
  164. package/dist/orchestration/index.js.map +1 -1
  165. package/dist/orchestration/messaging.cjs +314 -0
  166. package/dist/orchestration/messaging.cjs.map +1 -0
  167. package/dist/orchestration/messaging.d.cts +59 -0
  168. package/dist/orchestration/messaging.d.ts +59 -0
  169. package/dist/orchestration/messaging.js +276 -0
  170. package/dist/orchestration/messaging.js.map +1 -0
  171. package/dist/orchestration/work-queue.cjs +262 -0
  172. package/dist/orchestration/work-queue.cjs.map +1 -0
  173. package/dist/orchestration/work-queue.d.cts +85 -0
  174. package/dist/orchestration/work-queue.d.ts +85 -0
  175. package/dist/orchestration/work-queue.js +226 -0
  176. package/dist/orchestration/work-queue.js.map +1 -0
  177. package/dist/patterns/event-flow.cjs +447 -0
  178. package/dist/patterns/event-flow.cjs.map +1 -0
  179. package/dist/patterns/event-flow.d.cts +115 -0
  180. package/dist/patterns/event-flow.d.ts +115 -0
  181. package/dist/patterns/event-flow.js +14 -0
  182. package/dist/patterns/event-flow.js.map +1 -0
  183. package/dist/patterns/index.cjs +423 -18
  184. package/dist/patterns/index.cjs.map +1 -1
  185. package/dist/patterns/index.d.cts +8 -5
  186. package/dist/patterns/index.d.ts +8 -5
  187. package/dist/patterns/index.js +13 -4
  188. package/dist/{reactive-collection-Cb1II1Fi.d.ts → reactive-collection-BAmfrGjd.d.ts} +9 -9
  189. package/dist/{reactive-collection-BxBqtIOE.d.cts → reactive-collection-DNV0-gFi.d.cts} +9 -9
  190. package/dist/{reactive-collection-storage-D-KmjE0J.d.cts → reactive-collection-storage-BNEldDyi.d.cts} +5 -5
  191. package/dist/{reactive-collection-storage-BNiEc-Gd.d.ts → reactive-collection-storage-YZsAQsWK.d.ts} +5 -5
  192. package/dist/{reactive-map-D-g3dv8I.d.cts → reactive-map-DRD1LJ2H.d.cts} +6 -6
  193. package/dist/{reactive-map-BcB4KsQR.d.ts → reactive-map-EsDiCmJk.d.ts} +6 -6
  194. package/dist/render/index.d.cts +3 -3
  195. package/dist/render/index.d.ts +3 -3
  196. package/dist/render/index.js +1 -0
  197. package/dist/{semantic-memory-graph-BYoIlP35.d.cts → semantic-memory-graph-DKuNzuWw.d.cts} +2 -2
  198. package/dist/{semantic-memory-graph-CxyXLms3.d.ts → semantic-memory-graph-uwbwJdhe.d.ts} +2 -2
  199. package/dist/solutions/index.cjs +4478 -2
  200. package/dist/solutions/index.cjs.map +1 -1
  201. package/dist/solutions/index.d.cts +13 -519
  202. package/dist/solutions/index.d.ts +13 -519
  203. package/dist/solutions/index.js +90 -6
  204. package/dist/solutions/reactive-layout/browser/index.cjs +449 -0
  205. package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -0
  206. package/dist/solutions/reactive-layout/browser/index.d.cts +44 -0
  207. package/dist/solutions/reactive-layout/browser/index.d.ts +44 -0
  208. package/dist/solutions/reactive-layout/browser/index.js +69 -0
  209. package/dist/solutions/reactive-layout/browser/index.js.map +1 -0
  210. package/dist/solutions/reactive-layout/index.cjs +4266 -0
  211. package/dist/solutions/reactive-layout/index.cjs.map +1 -0
  212. package/dist/solutions/reactive-layout/index.d.cts +581 -0
  213. package/dist/solutions/reactive-layout/index.d.ts +581 -0
  214. package/dist/solutions/reactive-layout/index.js +86 -0
  215. package/dist/solutions/reactive-layout/index.js.map +1 -0
  216. package/dist/solutions/reactive-layout/node-canvas/index.cjs +545 -0
  217. package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -0
  218. package/dist/solutions/reactive-layout/node-canvas/index.d.cts +54 -0
  219. package/dist/solutions/reactive-layout/node-canvas/index.d.ts +54 -0
  220. package/dist/solutions/reactive-layout/node-canvas/index.js +131 -0
  221. package/dist/solutions/reactive-layout/node-canvas/index.js.map +1 -0
  222. package/dist/solutions/reactive-layout/react-native/index.cjs +494 -0
  223. package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -0
  224. package/dist/solutions/reactive-layout/react-native/index.d.cts +51 -0
  225. package/dist/solutions/reactive-layout/react-native/index.d.ts +51 -0
  226. package/dist/solutions/reactive-layout/react-native/index.js +77 -0
  227. package/dist/solutions/reactive-layout/react-native/index.js.map +1 -0
  228. package/dist/solutions/reactive-layout/skia/index.cjs +547 -0
  229. package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -0
  230. package/dist/solutions/reactive-layout/skia/index.d.cts +64 -0
  231. package/dist/solutions/reactive-layout/skia/index.d.ts +64 -0
  232. package/dist/solutions/reactive-layout/skia/index.js +70 -0
  233. package/dist/solutions/reactive-layout/skia/index.js.map +1 -0
  234. package/dist/solutions/work-item/actions.cjs +2164 -0
  235. package/dist/solutions/work-item/actions.cjs.map +1 -0
  236. package/dist/solutions/work-item/actions.d.cts +201 -0
  237. package/dist/solutions/work-item/actions.d.ts +201 -0
  238. package/dist/solutions/work-item/actions.js +1454 -0
  239. package/dist/solutions/work-item/actions.js.map +1 -0
  240. package/dist/solutions/work-item/scheduling.cjs +2454 -0
  241. package/dist/solutions/work-item/scheduling.cjs.map +1 -0
  242. package/dist/solutions/work-item/scheduling.d.cts +433 -0
  243. package/dist/solutions/work-item/scheduling.d.ts +433 -0
  244. package/dist/solutions/work-item/scheduling.js +32 -0
  245. package/dist/solutions/work-item/scheduling.js.map +1 -0
  246. package/dist/solutions/work-item/work-queue.cjs +306 -0
  247. package/dist/solutions/work-item/work-queue.cjs.map +1 -0
  248. package/dist/solutions/work-item/work-queue.d.cts +71 -0
  249. package/dist/solutions/work-item/work-queue.d.ts +71 -0
  250. package/dist/solutions/work-item/work-queue.js +270 -0
  251. package/dist/solutions/work-item/work-queue.js.map +1 -0
  252. package/dist/sources/browser.cjs +169 -57
  253. package/dist/sources/browser.cjs.map +1 -1
  254. package/dist/sources/browser.d.cts +33 -6
  255. package/dist/sources/browser.d.ts +33 -6
  256. package/dist/sources/browser.js +73 -6
  257. package/dist/sources/browser.js.map +1 -1
  258. package/dist/sources/index.cjs +102 -57
  259. package/dist/sources/index.cjs.map +1 -1
  260. package/dist/sources/index.d.cts +5 -5
  261. package/dist/sources/index.d.ts +5 -5
  262. package/dist/sources/index.js +6 -5
  263. package/dist/sources/node.cjs.map +1 -1
  264. package/dist/sources/node.d.cts +4 -4
  265. package/dist/sources/node.d.ts +4 -4
  266. package/dist/sources/node.js +2 -1
  267. package/dist/sources/node.js.map +1 -1
  268. package/dist/storage/browser.js +1 -0
  269. package/dist/storage/browser.js.map +1 -1
  270. package/dist/storage/index.d.cts +5 -5
  271. package/dist/storage/index.d.ts +5 -5
  272. package/dist/storage/index.js +5 -4
  273. package/dist/storage/node.js +1 -0
  274. package/dist/storage/node.js.map +1 -1
  275. package/dist/store-C-joM4gh.d.ts +123 -0
  276. package/dist/store-CNJwmT-h.d.cts +123 -0
  277. package/dist/testing/index.cjs +1 -0
  278. package/dist/testing/index.cjs.map +1 -1
  279. package/dist/testing/index.d.cts +1 -1
  280. package/dist/testing/index.d.ts +1 -1
  281. package/dist/testing/index.js +3 -2
  282. package/dist/{types-h12mNYbq.d.ts → types-BsJvElYZ.d.ts} +31 -31
  283. package/dist/{types-bNMSWKqF.d.cts → types-CcPIn7sy.d.cts} +31 -31
  284. package/dist/work-item-runtime-C3M79vE9.d.ts +228 -0
  285. package/dist/work-item-runtime-qaVgsL0T.d.cts +228 -0
  286. package/dist/work-queue/index.cjs +1132 -0
  287. package/dist/work-queue/index.cjs.map +1 -0
  288. package/dist/work-queue/index.d.cts +369 -0
  289. package/dist/work-queue/index.d.ts +369 -0
  290. package/dist/work-queue/index.js +1078 -0
  291. package/dist/work-queue/index.js.map +1 -0
  292. package/package.json +266 -2
  293. package/dist/chunk-COHO25CZ.js.map +0 -1
  294. package/dist/chunk-DK554R7P.js.map +0 -1
  295. package/dist/chunk-I3IHOHCJ.js.map +0 -1
  296. package/dist/chunk-RIIOUTGM.js.map +0 -1
  297. package/dist/chunk-SWTLEQL6.js.map +0 -1
  298. /package/dist/{chunk-JR4IKCR2.js.map → chunk-2747WN4Y.js.map} +0 -0
  299. /package/dist/{chunk-GDL26N2T.js.map → chunk-3KN7NJDR.js.map} +0 -0
  300. /package/dist/{chunk-DJC4CHLQ.js.map → chunk-43BKLFZU.js.map} +0 -0
  301. /package/dist/{chunk-SCRFRCGR.js.map → chunk-BSQGE5PS.js.map} +0 -0
  302. /package/dist/{chunk-Y3ZLRGHC.js.map → chunk-CZNV3VXM.js.map} +0 -0
  303. /package/dist/{chunk-JIMUDQN3.js.map → chunk-FBUU43PM.js.map} +0 -0
  304. /package/dist/{chunk-D6BG7U6A.js.map → chunk-IXZBUWSP.js.map} +0 -0
  305. /package/dist/{chunk-PKVBHGBM.js.map → chunk-SS2A464I.js.map} +0 -0
  306. /package/dist/{chunk-G4M3NHRJ.js.map → chunk-V7CIJE4B.js.map} +0 -0
  307. /package/dist/{chunk-TEW47IVR.js.map → chunk-VPEFSDME.js.map} +0 -0
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/solutions/reactive-layout/node-canvas/index.ts
21
+ var node_canvas_exports = {};
22
+ __export(node_canvas_exports, {
23
+ nodeCanvasPackageTextMeasurements: () => nodeCanvasPackageTextMeasurements,
24
+ nodeCanvasTextMeasurements: () => nodeCanvasTextMeasurements
25
+ });
26
+ module.exports = __toCommonJS(node_canvas_exports);
27
+ var import_node_module = require("module");
28
+
29
+ // src/ctx/types.ts
30
+ var CTX_DEP_CACHE = /* @__PURE__ */ Symbol("graphrefly.ctx.depCache");
31
+ function depLatest(ctx, depIndex) {
32
+ return ctx[CTX_DEP_CACHE]?.latest[depIndex];
33
+ }
34
+
35
+ // src/solutions/reactive-layout/index.ts
36
+ var TEXT_SEGMENTS_MEASUREMENT_KIND = "text-segments";
37
+ var kinsokuStart = /* @__PURE__ */ new Set([
38
+ "\u3001",
39
+ "\u3002",
40
+ "\u30FB",
41
+ "\uFF09",
42
+ "\u3015",
43
+ "\u3009",
44
+ "\u300B",
45
+ "\u300D",
46
+ "\u300F",
47
+ "\u3011"
48
+ ]);
49
+ var leftStickyPunctuation = /* @__PURE__ */ new Set([
50
+ ".",
51
+ ",",
52
+ "!",
53
+ "?",
54
+ ":",
55
+ ";",
56
+ ")",
57
+ "]",
58
+ "}",
59
+ "%",
60
+ '"',
61
+ "\u201D",
62
+ "\u2019",
63
+ "\xBB",
64
+ "\u203A",
65
+ "\u2026"
66
+ ]);
67
+ function isCJK(text) {
68
+ for (const ch of text) {
69
+ const c = ch.codePointAt(0);
70
+ if (c !== void 0 && c >= 19968 && c <= 40959 || c !== void 0 && c >= 13312 && c <= 19903 || c !== void 0 && c >= 12288 && c <= 12351 || c !== void 0 && c >= 12352 && c <= 12447 || c !== void 0 && c >= 44032 && c <= 55215 || c !== void 0 && c >= 65280 && c <= 65519) {
71
+ return true;
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+ function normalizeWhitespace(text) {
77
+ return text.replace(/[\t\f ]+/g, " ").replace(/^ | $/g, "");
78
+ }
79
+ function segmentText(text, segmentAdapter) {
80
+ const pieces = [];
81
+ for (const s of segmentAdapter.segmentWords(text)) {
82
+ const wordSegment = s.segment;
83
+ const rawWordLike = s.isWordLike ?? false;
84
+ const pieceTexts = [];
85
+ const pieceWordLikes = [];
86
+ const pieceKinds = [];
87
+ let currentText = "";
88
+ let currentKind = null;
89
+ for (const ch of wordSegment) {
90
+ let kind;
91
+ if (ch === " ") {
92
+ kind = "space";
93
+ } else if (ch === "\u200B") {
94
+ kind = "zero-width-break";
95
+ } else if (ch === "\xAD") {
96
+ kind = "soft-hyphen";
97
+ } else if (ch === "\n") {
98
+ kind = "hard-break";
99
+ } else {
100
+ kind = "text";
101
+ }
102
+ if (currentKind !== null && kind === currentKind) {
103
+ currentText += ch;
104
+ } else {
105
+ if (currentKind !== null) {
106
+ pieceTexts.push(currentText);
107
+ pieceWordLikes.push(currentKind === "text" && rawWordLike);
108
+ pieceKinds.push(currentKind);
109
+ }
110
+ currentText = ch;
111
+ currentKind = kind;
112
+ }
113
+ }
114
+ if (currentKind !== null) {
115
+ pieceTexts.push(currentText);
116
+ pieceWordLikes.push(currentKind === "text" && rawWordLike);
117
+ pieceKinds.push(currentKind);
118
+ }
119
+ pieces.push({ texts: pieceTexts, isWordLike: pieceWordLikes, kinds: pieceKinds });
120
+ }
121
+ return pieces;
122
+ }
123
+ function* fallbackSegmentWords(text) {
124
+ let index = 0;
125
+ let current = "";
126
+ let currentIndex = 0;
127
+ let currentWordLike = null;
128
+ const flush = () => {
129
+ if (current.length === 0 || currentWordLike === null) return void 0;
130
+ const out2 = { segment: current, index: currentIndex, isWordLike: currentWordLike };
131
+ current = "";
132
+ currentWordLike = null;
133
+ return out2;
134
+ };
135
+ for (const ch of text) {
136
+ const isWordLike = !/[\s\u200B\u00AD]/u.test(ch);
137
+ if (currentWordLike !== null && currentWordLike !== isWordLike) {
138
+ const out2 = flush();
139
+ if (out2) yield out2;
140
+ }
141
+ if (currentWordLike === null) {
142
+ currentWordLike = isWordLike;
143
+ currentIndex = index;
144
+ }
145
+ current += ch;
146
+ index += ch.length;
147
+ }
148
+ const out = flush();
149
+ if (out) yield out;
150
+ }
151
+ function* fallbackSegmentGraphemes(text) {
152
+ let index = 0;
153
+ for (const ch of text) {
154
+ yield { segment: ch, index };
155
+ index += ch.length;
156
+ }
157
+ }
158
+ function createDefaultSegmentAdapter() {
159
+ return {
160
+ segmentWords(text) {
161
+ return fallbackSegmentWords(text);
162
+ },
163
+ segmentGraphemes(text) {
164
+ return fallbackSegmentGraphemes(text);
165
+ }
166
+ };
167
+ }
168
+ var defaultSegmentAdapter = null;
169
+ function getDefaultSegmentAdapter() {
170
+ if (defaultSegmentAdapter === null) {
171
+ defaultSegmentAdapter = createDefaultSegmentAdapter();
172
+ }
173
+ return defaultSegmentAdapter;
174
+ }
175
+ function measuredWidth(value) {
176
+ const width = typeof value === "number" ? value : value.width;
177
+ return Number.isFinite(width) && width >= 0 ? width : 0;
178
+ }
179
+ var CapabilityMeasureAdapter = class {
180
+ capability;
181
+ constructor(capability) {
182
+ this.capability = capability;
183
+ }
184
+ measureSegment(text, font) {
185
+ return { width: measuredWidth(this.capability.measureText(text, font)) };
186
+ }
187
+ clearCache() {
188
+ this.capability.clearCache?.();
189
+ }
190
+ };
191
+ function measurementIssue(code, message, targetId, measurementKind, opts = {}) {
192
+ return {
193
+ kind: "issue",
194
+ code,
195
+ message,
196
+ severity: opts.severity ?? "warning",
197
+ source: opts.source,
198
+ subjectId: targetId,
199
+ measurementKind,
200
+ details: opts.details,
201
+ metadata: opts.metadata
202
+ };
203
+ }
204
+ function measurementOk(targetId, measurementKind, value, opts = {}) {
205
+ return {
206
+ kind: "ok",
207
+ targetId,
208
+ measurementKind,
209
+ value,
210
+ source: opts.source,
211
+ metadata: opts.metadata
212
+ };
213
+ }
214
+ function tryMeasureHyphenWidth(adapter, font) {
215
+ try {
216
+ return nonNegativeFinite(adapter.measureSegment("-", font).width, 0);
217
+ } catch {
218
+ return void 0;
219
+ }
220
+ }
221
+ function textMeasurementFacts(text, font, adapter, cache, segmentAdapter, targetId, source) {
222
+ try {
223
+ const segments = analyzeAndMeasure(text, font, adapter, cache, void 0, segmentAdapter);
224
+ const hyphenWidth = tryMeasureHyphenWidth(adapter, font);
225
+ const facts = [
226
+ measurementOk(
227
+ targetId,
228
+ TEXT_SEGMENTS_MEASUREMENT_KIND,
229
+ hyphenWidth === void 0 ? { segments } : { segments, hyphenWidth },
230
+ { source }
231
+ )
232
+ ];
233
+ if (hyphenWidth === void 0) {
234
+ facts.push(
235
+ measurementIssue(
236
+ "measurement.hyphen.failed",
237
+ `Hyphen measurement failed for '${targetId}'`,
238
+ targetId,
239
+ TEXT_SEGMENTS_MEASUREMENT_KIND,
240
+ { source, severity: "warning" }
241
+ )
242
+ );
243
+ }
244
+ return facts;
245
+ } catch (error) {
246
+ return [
247
+ measurementIssue(
248
+ "measurement.failed",
249
+ `Text measurement failed for '${targetId}'`,
250
+ targetId,
251
+ TEXT_SEGMENTS_MEASUREMENT_KIND,
252
+ { source, details: error, severity: "error" }
253
+ )
254
+ ];
255
+ }
256
+ }
257
+ function scopedName(scope, local) {
258
+ return scope === local ? local : `${scope}:${local}`;
259
+ }
260
+ function textMeasurementProvider(opts) {
261
+ const targetId = opts.targetId ?? "text";
262
+ const name = opts.name ?? `${targetId}-measurements`;
263
+ const source = opts.source ?? name;
264
+ const cache = /* @__PURE__ */ new Map();
265
+ let activeAdapter = null;
266
+ return opts.graph.node(
267
+ opts.segmentAdapter ? [opts.text, opts.font, opts.adapter, opts.segmentAdapter] : [opts.text, opts.font, opts.adapter],
268
+ (ctx) => {
269
+ const flush = () => {
270
+ cache.clear();
271
+ depLatest(ctx, 2).clearCache?.();
272
+ };
273
+ ctx.onDeactivation(flush);
274
+ ctx.onInvalidate(flush);
275
+ const text = depLatest(ctx, 0);
276
+ const font = depLatest(ctx, 1);
277
+ const adapter = depLatest(ctx, 2);
278
+ if (adapter !== activeAdapter) {
279
+ cache.clear();
280
+ activeAdapter = adapter;
281
+ }
282
+ const segmentAdapter = opts.segmentAdapter === void 0 ? getDefaultSegmentAdapter() : depLatest(ctx, 3);
283
+ ctx.down([
284
+ [
285
+ "DATA",
286
+ textMeasurementFacts(text, font, adapter, cache, segmentAdapter, targetId, source)
287
+ ]
288
+ ]);
289
+ },
290
+ { name }
291
+ );
292
+ }
293
+ function capabilityTextMeasurements(opts) {
294
+ const targetId = opts.targetId ?? "text";
295
+ const adapter = opts.graph.node(
296
+ [opts.capability],
297
+ (ctx) => {
298
+ ctx.down([
299
+ ["DATA", new CapabilityMeasureAdapter(depLatest(ctx, 0))]
300
+ ]);
301
+ },
302
+ {
303
+ name: opts.name ? scopedName(opts.name, "measure-capability") : `${targetId}-measure-capability`
304
+ }
305
+ );
306
+ return textMeasurementProvider({
307
+ ...opts,
308
+ adapter,
309
+ source: opts.source ?? "capabilityTextMeasurements"
310
+ });
311
+ }
312
+ function analyzeAndMeasure(text, font, adapter, cache, stats, segmentAdapter) {
313
+ const normalized = normalizeWhitespace(text);
314
+ if (normalized.length === 0) {
315
+ return [];
316
+ }
317
+ const segAdapter = segmentAdapter ?? getDefaultSegmentAdapter();
318
+ const pieces = segmentText(normalized, segAdapter);
319
+ const rawTexts = [];
320
+ const rawKinds = [];
321
+ const rawWordLike = [];
322
+ for (const piece of pieces) {
323
+ for (let i = 0; i < piece.texts.length; i += 1) {
324
+ rawTexts.push(piece.texts[i]);
325
+ rawKinds.push(piece.kinds[i]);
326
+ rawWordLike.push(piece.isWordLike[i]);
327
+ }
328
+ }
329
+ const mergedTexts = [];
330
+ const mergedKinds = [];
331
+ const mergedWordLike = [];
332
+ for (let i = 0; i < rawTexts.length; i += 1) {
333
+ const t = rawTexts[i];
334
+ const k = rawKinds[i];
335
+ const wl = rawWordLike[i];
336
+ if (k === "text" && !wl && mergedTexts.length > 0 && mergedKinds[mergedTexts.length - 1] === "text") {
337
+ const isSticky = t.length === 1 && (leftStickyPunctuation.has(t) || kinsokuStart.has(t));
338
+ if (isSticky) {
339
+ mergedTexts[mergedTexts.length - 1] += t;
340
+ continue;
341
+ }
342
+ }
343
+ if (t === "-" && mergedTexts.length > 0 && mergedKinds[mergedKinds.length - 1] === "text" && mergedWordLike[mergedWordLike.length - 1]) {
344
+ mergedTexts[mergedTexts.length - 1] += t;
345
+ continue;
346
+ }
347
+ mergedTexts.push(t);
348
+ mergedKinds.push(k);
349
+ mergedWordLike.push(wl);
350
+ }
351
+ const fontCache = cache.get(font) ?? /* @__PURE__ */ new Map();
352
+ if (!cache.has(font)) cache.set(font, fontCache);
353
+ function measureCached(segment) {
354
+ const cached = fontCache.get(segment);
355
+ if (cached === void 0) {
356
+ if (stats) stats.misses += 1;
357
+ const measured = adapter.measureSegment(segment, font).width;
358
+ const width = Number.isFinite(measured) && measured >= 0 ? measured : 0;
359
+ fontCache.set(segment, width);
360
+ return width;
361
+ }
362
+ if (stats) stats.hits += 1;
363
+ return cached;
364
+ }
365
+ const out = [];
366
+ for (let i = 0; i < mergedTexts.length; i += 1) {
367
+ const t = mergedTexts[i];
368
+ const kind = mergedKinds[i];
369
+ if (kind !== "text") {
370
+ out.push({
371
+ text: t,
372
+ width: kind === "space" ? measureCached(" ") * t.length : 0,
373
+ kind,
374
+ graphemeWidths: null
375
+ });
376
+ continue;
377
+ }
378
+ if (isCJK(t)) {
379
+ let unitText = "";
380
+ for (const graphemeSegment of segAdapter.segmentGraphemes(t)) {
381
+ const grapheme = graphemeSegment.segment;
382
+ if (unitText.length > 0 && kinsokuStart.has(grapheme)) {
383
+ unitText += grapheme;
384
+ continue;
385
+ }
386
+ if (unitText.length > 0) {
387
+ out.push({
388
+ text: unitText,
389
+ width: measureCached(unitText),
390
+ kind: "text",
391
+ graphemeWidths: null
392
+ });
393
+ }
394
+ unitText = grapheme;
395
+ }
396
+ if (unitText.length > 0) {
397
+ out.push({
398
+ text: unitText,
399
+ width: measureCached(unitText),
400
+ kind: "text",
401
+ graphemeWidths: null
402
+ });
403
+ }
404
+ continue;
405
+ }
406
+ const textWidth = measureCached(t);
407
+ let graphemeWidths = null;
408
+ if (mergedWordLike[i] && t.length > 1) {
409
+ const widths = [];
410
+ for (const grapheme of segAdapter.segmentGraphemes(t)) {
411
+ widths.push(measureCached(grapheme.segment));
412
+ }
413
+ if (widths.length > 1) graphemeWidths = widths;
414
+ }
415
+ out.push({
416
+ text: t,
417
+ width: textWidth,
418
+ kind: "text",
419
+ graphemeWidths
420
+ });
421
+ }
422
+ return out;
423
+ }
424
+ function nonNegativeFinite(value, fallback) {
425
+ return Number.isFinite(value) ? Math.max(0, value) : fallback;
426
+ }
427
+
428
+ // src/solutions/reactive-layout/node-canvas/index.ts
429
+ var requireOptionalPeer = (0, import_node_module.createRequire)(`${process.cwd()}/package.json`);
430
+ function loadCanvasPackage() {
431
+ const errors = [];
432
+ if (typeof require === "function") {
433
+ try {
434
+ return require("canvas");
435
+ } catch (error) {
436
+ errors.push(error);
437
+ }
438
+ }
439
+ try {
440
+ return requireOptionalPeer("canvas");
441
+ } catch (error) {
442
+ errors.push(error);
443
+ throw new TypeError(
444
+ "nodeCanvasPackageTextMeasurements requires optional peer dependency 'canvas'. Install canvas, pass { canvas }, or use nodeCanvasTextMeasurements({ context }) with a caller-owned 2D context.",
445
+ { cause: errors.at(-1) }
446
+ );
447
+ }
448
+ }
449
+ var NodeCanvasPackageTextCapability = class {
450
+ canvasPackage;
451
+ width;
452
+ height;
453
+ context = null;
454
+ constructor(opts) {
455
+ this.canvasPackage = opts.canvas;
456
+ this.width = opts.width;
457
+ this.height = opts.height;
458
+ }
459
+ getContext() {
460
+ if (this.context !== null) return this.context;
461
+ const canvas = (this.canvasPackage ?? loadCanvasPackage()).createCanvas(
462
+ this.width,
463
+ this.height
464
+ );
465
+ const context = canvas.getContext("2d");
466
+ if (context === null) {
467
+ throw new TypeError("nodeCanvasPackageTextMeasurements: failed to create a 2D context");
468
+ }
469
+ this.context = context;
470
+ return context;
471
+ }
472
+ measureText(text, font) {
473
+ const context = this.getContext();
474
+ const previousFont = context.font;
475
+ context.font = font;
476
+ try {
477
+ return context.measureText(text);
478
+ } finally {
479
+ context.font = previousFont;
480
+ }
481
+ }
482
+ };
483
+ function nodeCanvasTextMeasurements(opts) {
484
+ const targetId = opts.targetId ?? "text";
485
+ const capability = opts.graph.node(
486
+ [opts.context],
487
+ (ctx) => {
488
+ const context = depLatest(ctx, 0);
489
+ const value = {
490
+ measureText(text, font) {
491
+ const previousFont = context.font;
492
+ context.font = font;
493
+ try {
494
+ return context.measureText(text);
495
+ } finally {
496
+ context.font = previousFont;
497
+ }
498
+ }
499
+ };
500
+ ctx.down([["DATA", value]]);
501
+ },
502
+ {
503
+ name: opts.name ? `${opts.name}:node-canvas-measure-capability` : `${targetId}-node-canvas-measure-capability`
504
+ }
505
+ );
506
+ return capabilityTextMeasurements({
507
+ graph: opts.graph,
508
+ text: opts.text,
509
+ font: opts.font,
510
+ capability,
511
+ segmentAdapter: opts.segmentAdapter,
512
+ targetId: opts.targetId,
513
+ source: opts.source ?? "nodeCanvasTextMeasurements",
514
+ name: opts.name
515
+ });
516
+ }
517
+ function nodeCanvasPackageTextMeasurements(opts) {
518
+ const targetId = opts.targetId ?? "text";
519
+ const capability = opts.graph.state(
520
+ new NodeCanvasPackageTextCapability({
521
+ canvas: opts.canvas,
522
+ width: opts.width ?? 0,
523
+ height: opts.height ?? 0
524
+ }),
525
+ {
526
+ name: opts.name ? `${opts.name}:node-canvas-measure-capability` : `${targetId}-node-canvas-measure-capability`
527
+ }
528
+ );
529
+ return capabilityTextMeasurements({
530
+ graph: opts.graph,
531
+ text: opts.text,
532
+ font: opts.font,
533
+ capability,
534
+ segmentAdapter: opts.segmentAdapter,
535
+ targetId: opts.targetId,
536
+ source: opts.source ?? "nodeCanvasPackageTextMeasurements",
537
+ name: opts.name
538
+ });
539
+ }
540
+ // Annotate the CommonJS export names for ESM import in node:
541
+ 0 && (module.exports = {
542
+ nodeCanvasPackageTextMeasurements,
543
+ nodeCanvasTextMeasurements
544
+ });
545
+ //# sourceMappingURL=index.cjs.map