@gtkx/react 1.0.0-rc.1 → 1.0.0-rc.2

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 (381) hide show
  1. package/dist/adw/config.d.ts +2 -0
  2. package/dist/adw/config.d.ts.map +1 -0
  3. package/dist/adw/config.js +2 -0
  4. package/dist/adw/config.js.map +1 -0
  5. package/dist/{libraries/adw → adw}/dialog.d.ts +2 -2
  6. package/dist/adw/dialog.d.ts.map +1 -0
  7. package/dist/adw/dialog.js +25 -0
  8. package/dist/adw/dialog.js.map +1 -0
  9. package/dist/adw/element-behaviors.d.ts +2 -0
  10. package/dist/adw/element-behaviors.d.ts.map +1 -0
  11. package/dist/adw/element-behaviors.js +299 -0
  12. package/dist/adw/element-behaviors.js.map +1 -0
  13. package/dist/adw/element-config.d.ts +9 -0
  14. package/dist/adw/element-config.d.ts.map +1 -0
  15. package/dist/adw/element-config.js +137 -0
  16. package/dist/adw/element-config.js.map +1 -0
  17. package/dist/adw/index.d.ts +4 -0
  18. package/dist/adw/index.d.ts.map +1 -0
  19. package/dist/adw/index.js +3 -0
  20. package/dist/adw/index.js.map +1 -0
  21. package/dist/adw/prop-types.d.ts +29 -0
  22. package/dist/adw/prop-types.d.ts.map +1 -0
  23. package/dist/adw/prop-types.js +2 -0
  24. package/dist/adw/prop-types.js.map +1 -0
  25. package/dist/bootstrap.d.ts +2 -0
  26. package/dist/bootstrap.d.ts.map +1 -0
  27. package/dist/bootstrap.js +5 -0
  28. package/dist/bootstrap.js.map +1 -0
  29. package/dist/components/application.d.ts +2 -2
  30. package/dist/components/application.d.ts.map +1 -1
  31. package/dist/components/application.js +31 -18
  32. package/dist/components/application.js.map +1 -1
  33. package/dist/components/element.d.ts +6 -0
  34. package/dist/components/element.d.ts.map +1 -0
  35. package/dist/components/element.js +29 -0
  36. package/dist/components/element.js.map +1 -0
  37. package/dist/components/window.d.ts +2 -2
  38. package/dist/components/window.d.ts.map +1 -1
  39. package/dist/components/window.js +10 -11
  40. package/dist/components/window.js.map +1 -1
  41. package/dist/config.d.ts +4 -0
  42. package/dist/config.d.ts.map +1 -0
  43. package/dist/config.js +3 -0
  44. package/dist/config.js.map +1 -0
  45. package/dist/element-behaviors.d.ts +2 -0
  46. package/dist/element-behaviors.d.ts.map +1 -0
  47. package/dist/element-behaviors.js +348 -0
  48. package/dist/element-behaviors.js.map +1 -0
  49. package/dist/element-config.d.ts +10 -0
  50. package/dist/element-config.d.ts.map +1 -0
  51. package/dist/element-config.js +146 -0
  52. package/dist/element-config.js.map +1 -0
  53. package/dist/hooks/use-application.d.ts +4 -3
  54. package/dist/hooks/use-application.d.ts.map +1 -1
  55. package/dist/hooks/use-application.js +5 -4
  56. package/dist/hooks/use-application.js.map +1 -1
  57. package/dist/hooks/use-bind-setting.d.ts +21 -4
  58. package/dist/hooks/use-bind-setting.d.ts.map +1 -1
  59. package/dist/hooks/use-bind-setting.js +27 -16
  60. package/dist/hooks/use-bind-setting.js.map +1 -1
  61. package/dist/hooks/use-merged-refs.d.ts +8 -0
  62. package/dist/hooks/use-merged-refs.d.ts.map +1 -0
  63. package/dist/hooks/use-merged-refs.js +48 -0
  64. package/dist/hooks/use-merged-refs.js.map +1 -0
  65. package/dist/hooks/use-object-value.d.ts +3 -2
  66. package/dist/hooks/use-object-value.d.ts.map +1 -1
  67. package/dist/hooks/use-object-value.js +18 -21
  68. package/dist/hooks/use-object-value.js.map +1 -1
  69. package/dist/hooks/use-parent-window.d.ts +3 -2
  70. package/dist/hooks/use-parent-window.d.ts.map +1 -1
  71. package/dist/hooks/use-parent-window.js +3 -2
  72. package/dist/hooks/use-parent-window.js.map +1 -1
  73. package/dist/hooks/use-property.d.ts +5 -5
  74. package/dist/hooks/use-property.d.ts.map +1 -1
  75. package/dist/hooks/use-property.js +4 -3
  76. package/dist/hooks/use-property.js.map +1 -1
  77. package/dist/hooks/use-setting.d.ts +5 -16
  78. package/dist/hooks/use-setting.d.ts.map +1 -1
  79. package/dist/hooks/use-setting.js +16 -11
  80. package/dist/hooks/use-setting.js.map +1 -1
  81. package/dist/hooks/use-signal.d.ts +10 -7
  82. package/dist/hooks/use-signal.d.ts.map +1 -1
  83. package/dist/hooks/use-signal.js +29 -18
  84. package/dist/hooks/use-signal.js.map +1 -1
  85. package/dist/index.d.ts +7 -8
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -3
  88. package/dist/index.js.map +1 -1
  89. package/dist/internal.d.ts +6 -7
  90. package/dist/internal.d.ts.map +1 -1
  91. package/dist/internal.js +5 -7
  92. package/dist/internal.js.map +1 -1
  93. package/dist/prop-types.d.ts +110 -0
  94. package/dist/prop-types.d.ts.map +1 -0
  95. package/dist/prop-types.js +2 -0
  96. package/dist/prop-types.js.map +1 -0
  97. package/dist/reconciler/apply-props.d.ts +10 -7
  98. package/dist/reconciler/apply-props.d.ts.map +1 -1
  99. package/dist/reconciler/apply-props.js +182 -84
  100. package/dist/reconciler/apply-props.js.map +1 -1
  101. package/dist/reconciler/behaviors.d.ts +59 -0
  102. package/dist/reconciler/behaviors.d.ts.map +1 -0
  103. package/dist/reconciler/behaviors.js +172 -0
  104. package/dist/reconciler/behaviors.js.map +1 -0
  105. package/dist/reconciler/child-routing.d.ts +5 -0
  106. package/dist/reconciler/child-routing.d.ts.map +1 -0
  107. package/dist/reconciler/child-routing.js +156 -0
  108. package/dist/reconciler/child-routing.js.map +1 -0
  109. package/dist/reconciler/host-config.d.ts +8 -12
  110. package/dist/reconciler/host-config.d.ts.map +1 -1
  111. package/dist/reconciler/host-config.js +175 -270
  112. package/dist/reconciler/host-config.js.map +1 -1
  113. package/dist/reconciler/instance.d.ts +4 -5
  114. package/dist/reconciler/instance.d.ts.map +1 -1
  115. package/dist/reconciler/instance.js +44 -22
  116. package/dist/reconciler/instance.js.map +1 -1
  117. package/dist/reconciler/metadata.d.ts +17 -0
  118. package/dist/reconciler/metadata.d.ts.map +1 -0
  119. package/dist/reconciler/metadata.js +82 -0
  120. package/dist/reconciler/metadata.js.map +1 -0
  121. package/dist/reconciler/node.d.ts +76 -0
  122. package/dist/reconciler/node.d.ts.map +1 -0
  123. package/dist/reconciler/node.js +53 -0
  124. package/dist/reconciler/node.js.map +1 -0
  125. package/dist/reconciler/placement.d.ts +5 -0
  126. package/dist/reconciler/placement.d.ts.map +1 -0
  127. package/dist/reconciler/placement.js +175 -0
  128. package/dist/reconciler/placement.js.map +1 -0
  129. package/dist/reconciler/registry.d.ts +92 -0
  130. package/dist/reconciler/registry.d.ts.map +1 -0
  131. package/dist/reconciler/registry.js +64 -0
  132. package/dist/reconciler/registry.js.map +1 -0
  133. package/dist/reconciler/root-element.d.ts +9 -12
  134. package/dist/reconciler/root-element.d.ts.map +1 -1
  135. package/dist/reconciler/root-element.js +6 -6
  136. package/dist/reconciler/root-element.js.map +1 -1
  137. package/dist/reconciler/root.d.ts +56 -0
  138. package/dist/reconciler/root.d.ts.map +1 -0
  139. package/dist/reconciler/root.js +109 -0
  140. package/dist/reconciler/root.js.map +1 -0
  141. package/dist/reconciler/signals.d.ts +10 -0
  142. package/dist/reconciler/signals.d.ts.map +1 -0
  143. package/dist/reconciler/signals.js +70 -0
  144. package/dist/reconciler/signals.js.map +1 -0
  145. package/dist/reconciler/text.d.ts +19 -0
  146. package/dist/reconciler/text.d.ts.map +1 -0
  147. package/dist/reconciler/text.js +276 -0
  148. package/dist/reconciler/text.js.map +1 -0
  149. package/dist/utils/accessible-metadata.d.ts +11 -4
  150. package/dist/utils/accessible-metadata.d.ts.map +1 -1
  151. package/dist/utils/accessible-metadata.js +20 -17
  152. package/dist/utils/accessible-metadata.js.map +1 -1
  153. package/dist/{reconciler/accessible.d.ts → utils/accessible-props.d.ts} +7 -6
  154. package/dist/utils/accessible-props.d.ts.map +1 -0
  155. package/dist/utils/accessible-props.js +181 -0
  156. package/dist/utils/accessible-props.js.map +1 -0
  157. package/dist/utils/ref-prop.d.ts +15 -0
  158. package/dist/utils/ref-prop.d.ts.map +1 -0
  159. package/dist/utils/ref-prop.js +18 -0
  160. package/dist/utils/ref-prop.js.map +1 -0
  161. package/dist/utils/settings.d.ts +17 -0
  162. package/dist/utils/settings.d.ts.map +1 -0
  163. package/dist/utils/settings.js +37 -0
  164. package/dist/utils/settings.js.map +1 -0
  165. package/dist/utils/variant.d.ts +57 -0
  166. package/dist/utils/variant.d.ts.map +1 -0
  167. package/dist/utils/variant.js +197 -0
  168. package/dist/utils/variant.js.map +1 -0
  169. package/env.d.ts +9 -0
  170. package/package.json +36 -11
  171. package/src/adw/config.ts +1 -0
  172. package/src/adw/dialog.tsx +35 -0
  173. package/src/adw/element-behaviors.ts +379 -0
  174. package/src/adw/element-config.ts +140 -0
  175. package/src/adw/index.ts +4 -0
  176. package/src/adw/prop-types.ts +42 -0
  177. package/src/bootstrap.ts +5 -0
  178. package/src/components/application.tsx +42 -23
  179. package/src/components/element.tsx +47 -0
  180. package/src/components/window.tsx +12 -13
  181. package/src/config.ts +3 -0
  182. package/src/element-behaviors.ts +424 -0
  183. package/src/element-config.ts +148 -0
  184. package/src/env.d.ts +1 -0
  185. package/src/hooks/use-application.ts +6 -4
  186. package/src/hooks/use-bind-setting.ts +47 -31
  187. package/src/hooks/use-merged-refs.ts +64 -0
  188. package/src/hooks/use-object-value.ts +27 -23
  189. package/src/hooks/use-parent-window.ts +4 -2
  190. package/src/hooks/use-property.ts +11 -10
  191. package/src/hooks/use-setting.ts +20 -33
  192. package/src/hooks/use-signal.ts +37 -48
  193. package/src/index.ts +7 -8
  194. package/src/internal.ts +7 -18
  195. package/src/prop-types.ts +142 -0
  196. package/src/reconciler/apply-props.ts +233 -85
  197. package/src/reconciler/behaviors.ts +324 -0
  198. package/src/reconciler/child-routing.ts +202 -0
  199. package/src/reconciler/host-config.ts +239 -366
  200. package/src/reconciler/instance.ts +76 -24
  201. package/src/reconciler/metadata.ts +119 -0
  202. package/src/reconciler/node.ts +161 -0
  203. package/src/reconciler/placement.ts +255 -0
  204. package/src/reconciler/registry.ts +161 -0
  205. package/src/reconciler/root-element.ts +9 -11
  206. package/src/reconciler/root.ts +175 -0
  207. package/src/reconciler/signals.ts +113 -0
  208. package/src/reconciler/text.ts +407 -0
  209. package/src/utils/accessible-metadata.ts +23 -18
  210. package/src/utils/accessible-props.ts +279 -0
  211. package/src/utils/ref-prop.ts +30 -0
  212. package/src/utils/settings.ts +69 -0
  213. package/src/utils/variant.ts +368 -0
  214. package/dist/hooks/use-merge-refs.d.ts +0 -3
  215. package/dist/hooks/use-merge-refs.d.ts.map +0 -1
  216. package/dist/hooks/use-merge-refs.js +0 -48
  217. package/dist/hooks/use-merge-refs.js.map +0 -1
  218. package/dist/hooks/use-object-attachment.d.ts +0 -10
  219. package/dist/hooks/use-object-attachment.d.ts.map +0 -1
  220. package/dist/hooks/use-object-attachment.js +0 -24
  221. package/dist/hooks/use-object-attachment.js.map +0 -1
  222. package/dist/libraries/adw/dialog.d.ts.map +0 -1
  223. package/dist/libraries/adw/dialog.js +0 -25
  224. package/dist/libraries/adw/dialog.js.map +0 -1
  225. package/dist/libraries/adw/index.d.ts +0 -2
  226. package/dist/libraries/adw/index.d.ts.map +0 -1
  227. package/dist/libraries/adw/index.js +0 -2
  228. package/dist/libraries/adw/index.js.map +0 -1
  229. package/dist/reconciler/accessible.d.ts.map +0 -1
  230. package/dist/reconciler/accessible.js +0 -143
  231. package/dist/reconciler/accessible.js.map +0 -1
  232. package/dist/reconciler/commit-flush.d.ts +0 -3
  233. package/dist/reconciler/commit-flush.d.ts.map +0 -1
  234. package/dist/reconciler/commit-flush.js +0 -13
  235. package/dist/reconciler/commit-flush.js.map +0 -1
  236. package/dist/reconciler/container-attach.d.ts +0 -10
  237. package/dist/reconciler/container-attach.d.ts.map +0 -1
  238. package/dist/reconciler/container-attach.js +0 -216
  239. package/dist/reconciler/container-attach.js.map +0 -1
  240. package/dist/reconciler/content-rebuild.d.ts +0 -3
  241. package/dist/reconciler/content-rebuild.d.ts.map +0 -1
  242. package/dist/reconciler/content-rebuild.js +0 -15
  243. package/dist/reconciler/content-rebuild.js.map +0 -1
  244. package/dist/reconciler/dispatch.d.ts +0 -6
  245. package/dist/reconciler/dispatch.d.ts.map +0 -1
  246. package/dist/reconciler/dispatch.js +0 -61
  247. package/dist/reconciler/dispatch.js.map +0 -1
  248. package/dist/reconciler/element-prop-appliers.d.ts +0 -5
  249. package/dist/reconciler/element-prop-appliers.d.ts.map +0 -1
  250. package/dist/reconciler/element-prop-appliers.js +0 -104
  251. package/dist/reconciler/element-prop-appliers.js.map +0 -1
  252. package/dist/reconciler/element-props.d.ts +0 -25
  253. package/dist/reconciler/element-props.d.ts.map +0 -1
  254. package/dist/reconciler/element-props.js +0 -157
  255. package/dist/reconciler/element-props.js.map +0 -1
  256. package/dist/reconciler/label-text-rebuild.d.ts +0 -3
  257. package/dist/reconciler/label-text-rebuild.d.ts.map +0 -1
  258. package/dist/reconciler/label-text-rebuild.js +0 -22
  259. package/dist/reconciler/label-text-rebuild.js.map +0 -1
  260. package/dist/reconciler/portal.d.ts +0 -11
  261. package/dist/reconciler/portal.d.ts.map +0 -1
  262. package/dist/reconciler/portal.js +0 -20
  263. package/dist/reconciler/portal.js.map +0 -1
  264. package/dist/reconciler/reconciler-error-handler.d.ts +0 -7
  265. package/dist/reconciler/reconciler-error-handler.d.ts.map +0 -1
  266. package/dist/reconciler/reconciler-error-handler.js +0 -24
  267. package/dist/reconciler/reconciler-error-handler.js.map +0 -1
  268. package/dist/reconciler/reconciler-root.d.ts +0 -19
  269. package/dist/reconciler/reconciler-root.d.ts.map +0 -1
  270. package/dist/reconciler/reconciler-root.js +0 -24
  271. package/dist/reconciler/reconciler-root.js.map +0 -1
  272. package/dist/reconciler/reconciler.d.ts +0 -3
  273. package/dist/reconciler/reconciler.d.ts.map +0 -1
  274. package/dist/reconciler/reconciler.js +0 -12
  275. package/dist/reconciler/reconciler.js.map +0 -1
  276. package/dist/reconciler/render.d.ts +0 -23
  277. package/dist/reconciler/render.d.ts.map +0 -1
  278. package/dist/reconciler/render.js +0 -46
  279. package/dist/reconciler/render.js.map +0 -1
  280. package/dist/reconciler/signal-store.d.ts +0 -22
  281. package/dist/reconciler/signal-store.d.ts.map +0 -1
  282. package/dist/reconciler/signal-store.js +0 -84
  283. package/dist/reconciler/signal-store.js.map +0 -1
  284. package/dist/reconciler/state.d.ts +0 -36
  285. package/dist/reconciler/state.d.ts.map +0 -1
  286. package/dist/reconciler/state.js +0 -38
  287. package/dist/reconciler/state.js.map +0 -1
  288. package/dist/reconciler/text-buffer-controller.d.ts +0 -17
  289. package/dist/reconciler/text-buffer-controller.d.ts.map +0 -1
  290. package/dist/reconciler/text-buffer-controller.js +0 -102
  291. package/dist/reconciler/text-buffer-controller.js.map +0 -1
  292. package/dist/reconciler/text-buffer-rebuild.d.ts +0 -3
  293. package/dist/reconciler/text-buffer-rebuild.d.ts.map +0 -1
  294. package/dist/reconciler/text-buffer-rebuild.js +0 -7
  295. package/dist/reconciler/text-buffer-rebuild.js.map +0 -1
  296. package/dist/reconciler/text-node.d.ts +0 -7
  297. package/dist/reconciler/text-node.d.ts.map +0 -1
  298. package/dist/reconciler/text-node.js +0 -8
  299. package/dist/reconciler/text-node.js.map +0 -1
  300. package/dist/reconciler/types.d.ts +0 -5
  301. package/dist/reconciler/types.d.ts.map +0 -1
  302. package/dist/reconciler/types.js +0 -2
  303. package/dist/reconciler/types.js.map +0 -1
  304. package/dist/reconciler/visibility.d.ts +0 -6
  305. package/dist/reconciler/visibility.d.ts.map +0 -1
  306. package/dist/reconciler/visibility.js +0 -57
  307. package/dist/reconciler/visibility.js.map +0 -1
  308. package/dist/reconciler/wrapper-apply.d.ts +0 -6
  309. package/dist/reconciler/wrapper-apply.d.ts.map +0 -1
  310. package/dist/reconciler/wrapper-apply.js +0 -287
  311. package/dist/reconciler/wrapper-apply.js.map +0 -1
  312. package/dist/reconciler/wrapper-content.d.ts +0 -8
  313. package/dist/reconciler/wrapper-content.d.ts.map +0 -1
  314. package/dist/reconciler/wrapper-content.js +0 -19
  315. package/dist/reconciler/wrapper-content.js.map +0 -1
  316. package/dist/reconciler/wrapper-node.d.ts +0 -8
  317. package/dist/reconciler/wrapper-node.d.ts.map +0 -1
  318. package/dist/reconciler/wrapper-node.js +0 -4
  319. package/dist/reconciler/wrapper-node.js.map +0 -1
  320. package/dist/reconciler/wrapper-protocol.d.ts +0 -13
  321. package/dist/reconciler/wrapper-protocol.d.ts.map +0 -1
  322. package/dist/reconciler/wrapper-protocol.js +0 -20
  323. package/dist/reconciler/wrapper-protocol.js.map +0 -1
  324. package/dist/utils/create-element-component.d.ts +0 -4
  325. package/dist/utils/create-element-component.d.ts.map +0 -1
  326. package/dist/utils/create-element-component.js +0 -54
  327. package/dist/utils/create-element-component.js.map +0 -1
  328. package/dist/utils/gtype.d.ts +0 -16
  329. package/dist/utils/gtype.d.ts.map +0 -1
  330. package/dist/utils/gtype.js +0 -127
  331. package/dist/utils/gtype.js.map +0 -1
  332. package/dist/utils/notify-name.d.ts +0 -5
  333. package/dist/utils/notify-name.d.ts.map +0 -1
  334. package/dist/utils/notify-name.js +0 -6
  335. package/dist/utils/notify-name.js.map +0 -1
  336. package/dist/utils/object-prop.d.ts +0 -8
  337. package/dist/utils/object-prop.d.ts.map +0 -1
  338. package/dist/utils/object-prop.js +0 -9
  339. package/dist/utils/object-prop.js.map +0 -1
  340. package/dist/utils/settings-accessor.d.ts +0 -8
  341. package/dist/utils/settings-accessor.d.ts.map +0 -1
  342. package/dist/utils/settings-accessor.js +0 -69
  343. package/dist/utils/settings-accessor.js.map +0 -1
  344. package/dist/utils/wrapper-node-jsx.d.ts +0 -32
  345. package/dist/utils/wrapper-node-jsx.d.ts.map +0 -1
  346. package/dist/utils/wrapper-node-jsx.js +0 -2
  347. package/dist/utils/wrapper-node-jsx.js.map +0 -1
  348. package/src/hooks/use-merge-refs.ts +0 -53
  349. package/src/hooks/use-object-attachment.ts +0 -35
  350. package/src/libraries/adw/dialog.tsx +0 -34
  351. package/src/libraries/adw/index.ts +0 -1
  352. package/src/reconciler/accessible.ts +0 -232
  353. package/src/reconciler/commit-flush.ts +0 -13
  354. package/src/reconciler/container-attach.ts +0 -219
  355. package/src/reconciler/content-rebuild.ts +0 -19
  356. package/src/reconciler/dispatch.ts +0 -58
  357. package/src/reconciler/element-prop-appliers.ts +0 -110
  358. package/src/reconciler/element-props.ts +0 -192
  359. package/src/reconciler/label-text-rebuild.ts +0 -26
  360. package/src/reconciler/portal.ts +0 -28
  361. package/src/reconciler/reconciler-error-handler.ts +0 -29
  362. package/src/reconciler/reconciler-root.ts +0 -57
  363. package/src/reconciler/reconciler.ts +0 -13
  364. package/src/reconciler/render.ts +0 -61
  365. package/src/reconciler/signal-store.ts +0 -103
  366. package/src/reconciler/state.ts +0 -72
  367. package/src/reconciler/text-buffer-controller.ts +0 -107
  368. package/src/reconciler/text-buffer-rebuild.ts +0 -12
  369. package/src/reconciler/text-node.ts +0 -13
  370. package/src/reconciler/types.ts +0 -6
  371. package/src/reconciler/visibility.ts +0 -52
  372. package/src/reconciler/wrapper-apply.ts +0 -308
  373. package/src/reconciler/wrapper-content.ts +0 -24
  374. package/src/reconciler/wrapper-node.ts +0 -8
  375. package/src/reconciler/wrapper-protocol.ts +0 -32
  376. package/src/utils/create-element-component.ts +0 -77
  377. package/src/utils/gtype.ts +0 -166
  378. package/src/utils/notify-name.ts +0 -10
  379. package/src/utils/object-prop.ts +0 -13
  380. package/src/utils/settings-accessor.ts +0 -89
  381. package/src/utils/wrapper-node-jsx.ts +0 -34
@@ -1,104 +0,0 @@
1
- import { callMethod, isShallowEqual } from "@gtkx/utils";
2
- import { appliedPropsFor, runCall } from "./element-props.js";
3
- const asArray = (value) => (Array.isArray(value) ? value : []);
4
- const isRecord = (value) => typeof value === "object" && value !== null;
5
- const itemsEqual = (a, b) => {
6
- if (a === b)
7
- return true;
8
- return isRecord(a) && isRecord(b) && isShallowEqual(a, b);
9
- };
10
- const listValuesEqual = (oldValue, newValue) => {
11
- if (oldValue === newValue)
12
- return true;
13
- const a = asArray(oldValue);
14
- const b = asArray(newValue);
15
- return a.length === b.length && a.every((item, index) => itemsEqual(item, b[index]));
16
- };
17
- const runAdd = (instance, add, item) => {
18
- if (Array.isArray(add)) {
19
- for (const call of add)
20
- runCall(instance, call, [item], { item });
21
- return;
22
- }
23
- runCall(instance, add, [item], { item });
24
- };
25
- const snapshotItems = (items) => items.map((item) => (isRecord(item) ? { ...item } : item));
26
- const appliedLists = new WeakMap();
27
- const rememberAppliedList = (instance, prop, items) => {
28
- const byProp = appliedLists.get(instance) ?? new Map();
29
- byProp.set(prop, snapshotItems(items));
30
- appliedLists.set(instance, byProp);
31
- };
32
- const applyList = (instance, prop, newValue) => {
33
- const applied = appliedLists.get(instance)?.get(prop.prop);
34
- const newItems = asArray(newValue);
35
- if (applied !== undefined && listValuesEqual(applied, newItems))
36
- return;
37
- if (prop.clear !== undefined) {
38
- runCall(instance, prop.clear, [], {});
39
- }
40
- else if (prop.remove !== undefined) {
41
- for (const item of asArray(applied))
42
- runCall(instance, prop.remove, [item], { item });
43
- }
44
- else if (asArray(applied).length !== 0) {
45
- return;
46
- }
47
- for (const item of newItems)
48
- runAdd(instance, prop.add, item);
49
- rememberAppliedList(instance, prop.prop, newItems);
50
- };
51
- const applyValue = (instance, prop, oldValue, newValue) => {
52
- if (oldValue === newValue)
53
- return;
54
- runCall(instance, prop.call, [newValue], { item: newValue });
55
- if (prop.after !== undefined)
56
- callMethod(instance, prop.after, []);
57
- };
58
- const applyControlledText = (instance, prop, oldValue, newValue) => {
59
- if (oldValue === newValue || typeof newValue !== "string")
60
- return;
61
- if (oldValue !== undefined && Reflect.get(instance, prop.prop) !== oldValue)
62
- return;
63
- Reflect.set(instance, prop.prop, newValue);
64
- };
65
- const applyLazy = (instance, prop, props) => {
66
- const value = props[prop.prop];
67
- if (value == null || value === "")
68
- return;
69
- if (Reflect.get(instance, prop.prop) === value)
70
- return;
71
- if (prop.lookup !== undefined && !callMethod(instance, prop.lookup, [value]))
72
- return;
73
- Reflect.set(instance, prop.prop, value);
74
- };
75
- const applyProp = (instance, prop, oldProps, newProps) => {
76
- const oldValue = oldProps?.[prop.prop];
77
- const newValue = newProps[prop.prop];
78
- switch (prop.kind) {
79
- case "value":
80
- applyValue(instance, prop, oldValue, newValue);
81
- return;
82
- case "controlled-text":
83
- applyControlledText(instance, prop, oldValue, newValue);
84
- return;
85
- case "lazy":
86
- applyLazy(instance, prop, newProps);
87
- return;
88
- case "list":
89
- applyList(instance, prop, newValue);
90
- return;
91
- }
92
- };
93
- export const applyElementProps = (instance, oldProps, newProps) => {
94
- for (const prop of appliedPropsFor(instance.__type__).values()) {
95
- applyProp(instance, prop, oldProps, newProps);
96
- }
97
- };
98
- export const reapplyLazyProps = (instance, props) => {
99
- for (const prop of appliedPropsFor(instance.__type__).values()) {
100
- if (prop.kind === "lazy")
101
- applyLazy(instance, prop, props);
102
- }
103
- };
104
- //# sourceMappingURL=element-prop-appliers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-prop-appliers.js","sourceRoot":"","sources":["../../src/reconciler/element-prop-appliers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG9D,MAAM,OAAO,GAAG,CAAC,KAAc,EAAa,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEnF,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AAEnH,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IACnD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,QA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GAAG,CAAC,QAA6B,EAAE,KAAY,EAAQ,EAAE;IAClF,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;YAAE,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { AppliedProp, Call, ControlledTextProp, LazyProp, ListProp, ValueProp } from \"@gtkx/config\";\nimport type { TypedClass } from \"@gtkx/runtime\";\nimport { callMethod, isShallowEqual } from \"@gtkx/utils\";\nimport { appliedPropsFor, runCall } from \"./element-props.js\";\nimport type { Props } from \"./types.js\";\n\nconst asArray = (value: unknown): unknown[] => (Array.isArray(value) ? value : []);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst itemsEqual = (a: unknown, b: unknown): boolean => {\n if (a === b) return true;\n return isRecord(a) && isRecord(b) && isShallowEqual(a, b);\n};\n\nconst listValuesEqual = (oldValue: unknown, newValue: unknown): boolean => {\n if (oldValue === newValue) return true;\n const a = asArray(oldValue);\n const b = asArray(newValue);\n return a.length === b.length && a.every((item, index) => itemsEqual(item, b[index]));\n};\n\nconst runAdd = (instance: object, add: Call | Call[], item: unknown): void => {\n if (Array.isArray(add)) {\n for (const call of add) runCall(instance, call, [item], { item });\n return;\n }\n runCall(instance, add, [item], { item });\n};\n\nconst snapshotItems = (items: unknown[]): unknown[] => items.map((item) => (isRecord(item) ? { ...item } : item));\n\nconst appliedLists = new WeakMap<object, Map<string, unknown[]>>();\n\nconst rememberAppliedList = (instance: object, prop: string, items: unknown[]): void => {\n const byProp = appliedLists.get(instance) ?? new Map<string, unknown[]>();\n byProp.set(prop, snapshotItems(items));\n appliedLists.set(instance, byProp);\n};\n\nconst applyList = (instance: object, prop: ListProp, newValue: unknown): void => {\n const applied = appliedLists.get(instance)?.get(prop.prop);\n const newItems = asArray(newValue);\n if (applied !== undefined && listValuesEqual(applied, newItems)) return;\n if (prop.clear !== undefined) {\n runCall(instance, prop.clear, [], {});\n } else if (prop.remove !== undefined) {\n for (const item of asArray(applied)) runCall(instance, prop.remove, [item], { item });\n } else if (asArray(applied).length !== 0) {\n return;\n }\n for (const item of newItems) runAdd(instance, prop.add, item);\n rememberAppliedList(instance, prop.prop, newItems);\n};\n\nconst applyValue = (instance: object, prop: ValueProp, oldValue: unknown, newValue: unknown): void => {\n if (oldValue === newValue) return;\n runCall(instance, prop.call, [newValue], { item: newValue });\n if (prop.after !== undefined) callMethod(instance, prop.after, []);\n};\n\nconst applyControlledText = (\n instance: object,\n prop: ControlledTextProp,\n oldValue: unknown,\n newValue: unknown,\n): void => {\n if (oldValue === newValue || typeof newValue !== \"string\") return;\n if (oldValue !== undefined && Reflect.get(instance, prop.prop) !== oldValue) return;\n Reflect.set(instance, prop.prop, newValue);\n};\n\nconst applyLazy = (instance: object, prop: LazyProp, props: Props): void => {\n const value = props[prop.prop];\n if (value == null || value === \"\") return;\n if (Reflect.get(instance, prop.prop) === value) return;\n if (prop.lookup !== undefined && !callMethod(instance, prop.lookup, [value])) return;\n Reflect.set(instance, prop.prop, value);\n};\n\nconst applyProp = (instance: object, prop: AppliedProp, oldProps: Props | null, newProps: Props): void => {\n const oldValue = oldProps?.[prop.prop];\n const newValue = newProps[prop.prop];\n switch (prop.kind) {\n case \"value\":\n applyValue(instance, prop, oldValue, newValue);\n return;\n case \"controlled-text\":\n applyControlledText(instance, prop, oldValue, newValue);\n return;\n case \"lazy\":\n applyLazy(instance, prop, newProps);\n return;\n case \"list\":\n applyList(instance, prop, newValue);\n return;\n }\n};\n\nexport const applyElementProps = (instance: TypedClass & object, oldProps: Props | null, newProps: Props): void => {\n for (const prop of appliedPropsFor(instance.__type__).values()) {\n applyProp(instance, prop, oldProps, newProps);\n }\n};\n\nexport const reapplyLazyProps = (instance: TypedClass & object, props: Props): void => {\n for (const prop of appliedPropsFor(instance.__type__).values()) {\n if (prop.kind === \"lazy\") applyLazy(instance, prop, props);\n }\n};\n"]}
@@ -1,25 +0,0 @@
1
- import type { AppliedProp, ArgRef, Call, ContainerProp } from "@gtkx/config";
2
- export type CallScope = {
3
- child?: unknown;
4
- item?: unknown;
5
- index?: number;
6
- sibling?: unknown;
7
- adopted?: unknown;
8
- props?: Record<string, unknown>;
9
- };
10
- type CallResult = {
11
- called: boolean;
12
- value: unknown;
13
- };
14
- export declare const runCallValue: (target: object, call: Call, defaults: unknown[], scope: CallScope) => CallResult;
15
- export declare const runCall: (target: object, call: Call, defaults: unknown[], scope: CallScope) => boolean;
16
- export declare const callUsesRef: (call: Call | undefined, ref: ArgRef) => boolean;
17
- export declare const nullSetterCurrentHolder: (target: object, call: Call) => unknown;
18
- export declare const resolveContainerProp: (parentType: bigint, childType: bigint, propName: string | undefined) => ContainerProp | null;
19
- export declare const adoptContainerPropFor: (parentType: bigint) => ContainerProp | null;
20
- export declare const containerPropNamesFor: (elementName: string) => Set<string>;
21
- export declare const appliedPropsFor: (gtype: bigint) => Map<string, AppliedProp>;
22
- export declare const isAppliedProp: (gtype: bigint, name: string) => boolean;
23
- export declare const constructionSkipProps: (gtype: bigint) => Set<string>;
24
- export {};
25
- //# sourceMappingURL=element-props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../../src/reconciler/element-props.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAO,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlF,MAAM,MAAM,SAAS,GAAG;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAgCF,KAAK,UAAU,GAAG;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,MAAM,QAAQ,IAAI,YAAY,OAAO,EAAE,SAAS,SAAS,KAAG,UAOhG,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,MAAM,QAAQ,IAAI,YAAY,OAAO,EAAE,SAAS,SAAS,KAAG,OACtC,CAAC;AAEvD,eAAO,MAAM,WAAW,SAAU,IAAI,GAAG,SAAS,OAAO,MAAM,KAAG,OACwB,CAAC;AAE3F,eAAO,MAAM,uBAAuB,WAAY,MAAM,QAAQ,IAAI,KAAG,OAQpE,CAAC;AA2BF,eAAO,MAAM,oBAAoB,eACjB,MAAM,aACP,MAAM,YACP,MAAM,GAAG,SAAS,KAC7B,aAAa,GAAG,IAelB,CAAC;AAIF,eAAO,MAAM,qBAAqB,eAAgB,MAAM,KAAG,aAAa,GAAG,IAa1E,CAAC;AAIF,eAAO,MAAM,qBAAqB,gBAAiB,MAAM,KAAG,GAAG,CAAC,MAAM,CAcrE,CAAC;AAIF,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAgBtE,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,MAAM,QAAQ,MAAM,KAAG,OAA2C,CAAC;AAIxG,eAAO,MAAM,qBAAqB,UAAW,MAAM,KAAG,GAAG,CAAC,MAAM,CAS/D,CAAC"}
@@ -1,157 +0,0 @@
1
- /// <reference types="@gtkx/config/env" />
2
- import { ELEMENT_PROPS } from "virtual:gtkx-config";
3
- import { typeFromName } from "@gtkx/gi/gobject";
4
- import { callMethod } from "@gtkx/utils";
5
- import { collectTypeNamesWithInterfaces, foldInheritedTableWithInterfaces } from "../utils/gtype.js";
6
- const MISSING_ARG = Symbol("gtkx.missing-arg");
7
- const fieldOf = (source, name) => source == null ? undefined : Reflect.get(Object(source), name);
8
- const evalArg = (arg, scope) => {
9
- if (typeof arg === "string") {
10
- switch (arg) {
11
- case "child":
12
- return scope.child;
13
- case "item":
14
- return scope.item;
15
- case "index":
16
- return scope.index;
17
- case "sibling":
18
- return scope.sibling;
19
- case "adopted":
20
- return scope.adopted;
21
- }
22
- }
23
- if ("literal" in arg)
24
- return arg.literal;
25
- if ("prop" in arg) {
26
- const value = scope.props?.[arg.prop];
27
- return value == null ? MISSING_ARG : value;
28
- }
29
- const value = fieldOf(scope.item, arg.field);
30
- if (value == null && "or" in arg)
31
- return arg.or;
32
- return value;
33
- };
34
- export const runCallValue = (target, call, defaults, scope) => {
35
- if (typeof call === "string") {
36
- return { called: true, value: callMethod(target, call, defaults) };
37
- }
38
- const args = call.args.map((arg) => evalArg(arg, scope));
39
- if (args.includes(MISSING_ARG))
40
- return { called: false, value: undefined };
41
- return { called: true, value: callMethod(target, call.method, args) };
42
- };
43
- export const runCall = (target, call, defaults, scope) => runCallValue(target, call, defaults, scope).called;
44
- export const callUsesRef = (call, ref) => call !== undefined && typeof call !== "string" && call.args.some((arg) => arg === ref);
45
- export const nullSetterCurrentHolder = (target, call) => {
46
- if (typeof call === "string" || !call.method.startsWith("set"))
47
- return undefined;
48
- if (!call.args.some((arg) => typeof arg === "object" && "literal" in arg && arg.literal === null)) {
49
- return undefined;
50
- }
51
- const getter = `get${call.method.slice(3)}`;
52
- if (typeof Reflect.get(target, getter) !== "function")
53
- return undefined;
54
- return callMethod(target, getter, []);
55
- };
56
- const attachIndex = new Map();
57
- const adoptByParent = new Map();
58
- const namedContainerPropsByParent = {};
59
- const APPLIED_BY_TYPE = {};
60
- for (const [parent, props] of Object.entries(ELEMENT_PROPS)) {
61
- for (const prop of props) {
62
- if (prop.kind === "container") {
63
- attachIndex.set(`${parent}:${prop.child}:${prop.prop === "children" ? "" : prop.prop}`, prop);
64
- if (prop.prop !== "children") {
65
- const propNames = namedContainerPropsByParent[parent] ?? [];
66
- propNames.push(prop.prop);
67
- namedContainerPropsByParent[parent] = propNames;
68
- }
69
- if (prop.adopt !== undefined)
70
- adoptByParent.set(parent, prop);
71
- }
72
- else {
73
- const applied = APPLIED_BY_TYPE[parent] ?? [];
74
- applied.push(prop);
75
- APPLIED_BY_TYPE[parent] = applied;
76
- }
77
- }
78
- }
79
- const attachCache = new Map();
80
- export const resolveContainerProp = (parentType, childType, propName) => {
81
- const cacheKey = `${parentType}:${childType}:${propName ?? ""}`;
82
- const cached = attachCache.get(cacheKey);
83
- if (cached !== undefined)
84
- return cached;
85
- let resolved = null;
86
- const parentNames = collectTypeNamesWithInterfaces(parentType);
87
- for (const childName of collectTypeNamesWithInterfaces(childType)) {
88
- for (const parentName of parentNames) {
89
- resolved = attachIndex.get(`${parentName}:${childName}:${propName ?? ""}`) ?? null;
90
- if (resolved !== null)
91
- break;
92
- }
93
- if (resolved !== null)
94
- break;
95
- }
96
- attachCache.set(cacheKey, resolved);
97
- return resolved;
98
- };
99
- const adoptCache = new Map();
100
- export const adoptContainerPropFor = (parentType) => {
101
- const cached = adoptCache.get(parentType);
102
- if (cached !== undefined)
103
- return cached;
104
- let resolved = null;
105
- for (const name of collectTypeNamesWithInterfaces(parentType)) {
106
- const cp = adoptByParent.get(name);
107
- if (cp !== undefined) {
108
- resolved = cp;
109
- break;
110
- }
111
- }
112
- adoptCache.set(parentType, resolved);
113
- return resolved;
114
- };
115
- const containerPropNamesCache = new Map();
116
- export const containerPropNamesFor = (elementName) => {
117
- const cached = containerPropNamesCache.get(elementName);
118
- if (cached)
119
- return cached;
120
- const names = foldInheritedTableWithInterfaces(typeFromName(elementName), namedContainerPropsByParent, (collected, propNames) => {
121
- for (const name of propNames)
122
- collected.add(name);
123
- return collected;
124
- }, new Set());
125
- containerPropNamesCache.set(elementName, names);
126
- return names;
127
- };
128
- const appliedCache = new Map();
129
- export const appliedPropsFor = (gtype) => {
130
- const cached = appliedCache.get(gtype);
131
- if (cached)
132
- return cached;
133
- const resolved = foldInheritedTableWithInterfaces(gtype, APPLIED_BY_TYPE, (collected, props) => {
134
- for (const prop of props) {
135
- if (!collected.has(prop.prop))
136
- collected.set(prop.prop, prop);
137
- }
138
- return collected;
139
- }, new Map());
140
- appliedCache.set(gtype, resolved);
141
- return resolved;
142
- };
143
- export const isAppliedProp = (gtype, name) => appliedPropsFor(gtype).has(name);
144
- const constructionSkipCache = new Map();
145
- export const constructionSkipProps = (gtype) => {
146
- const cached = constructionSkipCache.get(gtype);
147
- if (cached)
148
- return cached;
149
- const skipped = new Set();
150
- for (const prop of appliedPropsFor(gtype).values()) {
151
- if (prop.kind === "lazy")
152
- skipped.add(prop.prop);
153
- }
154
- constructionSkipCache.set(gtype, skipped);
155
- return skipped;
156
- };
157
- //# sourceMappingURL=element-props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-props.js","sourceRoot":"","sources":["../../src/reconciler/element-props.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,8BAA8B,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAWrG,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE/C,MAAM,OAAO,GAAG,CAAC,MAAe,EAAE,IAAY,EAAW,EAAE,CACvD,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAEnE,MAAM,OAAO,GAAG,CAAC,GAAQ,EAAE,KAAgB,EAAW,EAAE;IACpD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,QAAQ,GAAG,EAAE,CAAC;YACV,KAAK,O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Call, ContainerProp } from \"@gtkx/config\";\nimport { typeFromName } from \"@gtkx/gi/gobject\";\nimport { callMethod } from \"@gtkx/utils\";\nimport { collectTypeNamesWithInterfaces, foldInheritedTableWithInterfaces } from \"../utils/gtype.js\";\n\nexport type CallScope = {\n child?: unknown;\n item?: unknown;\n index?: number;\n sibling?: unknown;\n adopted?: unknown;\n props?: Record<string, unknown>;\n};\n\nconst MISSING_ARG = Symbol(\"gtkx.missing-arg\");\n\nconst fieldOf = (source: unknown, name: string): unknown =>\n source == null ? undefined : Reflect.get(Object(source), name);\n\nconst evalArg = (arg: Arg, scope: CallScope): unknown => {\n if (typeof arg === \"string\") {\n switch (arg) {\n case \"child\":\n return scope.child;\n case \"item\":\n return scope.item;\n case \"index\":\n return scope.index;\n case \"sibling\":\n return scope.sibling;\n case \"adopted\":\n return scope.adopted;\n }\n }\n if (\"literal\" in arg) return arg.literal;\n if (\"prop\" in arg) {\n const value = scope.props?.[arg.prop];\n return value == null ? MISSING_ARG : value;\n }\n const value = fieldOf(scope.item, arg.field);\n if (value == null && \"or\" in arg) return arg.or;\n return value;\n};\n\ntype CallResult = {\n called: boolean;\n value: unknown;\n};\n\nexport const runCallValue = (target: object, call: Call, defaults: unknown[], scope: CallScope): CallResult => {\n if (typeof call === \"string\") {\n return { called: true, value: callMethod(target, call, defaults) };\n }\n const args = call.args.map((arg) => evalArg(arg, scope));\n if (args.includes(MISSING_ARG)) return { called: false, value: undefined };\n return { called: true, value: callMethod(target, call.method, args) };\n};\n\nexport const runCall = (target: object, call: Call, defaults: unknown[], scope: CallScope): boolean =>\n runCallValue(target, call, defaults, scope).called;\n\nexport const callUsesRef = (call: Call | undefined, ref: ArgRef): boolean =>\n call !== undefined && typeof call !== \"string\" && call.args.some((arg) => arg === ref);\n\nexport const nullSetterCurrentHolder = (target: object, call: Call): unknown => {\n if (typeof call === \"string\" || !call.method.startsWith(\"set\")) return undefined;\n if (!call.args.some((arg) => typeof arg === \"object\" && \"literal\" in arg && arg.literal === null)) {\n return undefined;\n }\n const getter = `get${call.method.slice(3)}`;\n if (typeof Reflect.get(target, getter) !== \"function\") return undefined;\n return callMethod(target, getter, []);\n};\n\nconst attachIndex = new Map<string, ContainerProp>();\nconst adoptByParent = new Map<string, ContainerProp>();\nconst namedContainerPropsByParent: Record<string, string[]> = {};\nconst APPLIED_BY_TYPE: Record<string, AppliedProp[]> = {};\n\nfor (const [parent, props] of Object.entries(ELEMENT_PROPS)) {\n for (const prop of props) {\n if (prop.kind === \"container\") {\n attachIndex.set(`${parent}:${prop.child}:${prop.prop === \"children\" ? \"\" : prop.prop}`, prop);\n if (prop.prop !== \"children\") {\n const propNames = namedContainerPropsByParent[parent] ?? [];\n propNames.push(prop.prop);\n namedContainerPropsByParent[parent] = propNames;\n }\n if (prop.adopt !== undefined) adoptByParent.set(parent, prop);\n } else {\n const applied = APPLIED_BY_TYPE[parent] ?? [];\n applied.push(prop);\n APPLIED_BY_TYPE[parent] = applied;\n }\n }\n}\n\nconst attachCache = new Map<string, ContainerProp | null>();\n\nexport const resolveContainerProp = (\n parentType: bigint,\n childType: bigint,\n propName: string | undefined,\n): ContainerProp | null => {\n const cacheKey = `${parentType}:${childType}:${propName ?? \"\"}`;\n const cached = attachCache.get(cacheKey);\n if (cached !== undefined) return cached;\n let resolved: ContainerProp | null = null;\n const parentNames = collectTypeNamesWithInterfaces(parentType);\n for (const childName of collectTypeNamesWithInterfaces(childType)) {\n for (const parentName of parentNames) {\n resolved = attachIndex.get(`${parentName}:${childName}:${propName ?? \"\"}`) ?? null;\n if (resolved !== null) break;\n }\n if (resolved !== null) break;\n }\n attachCache.set(cacheKey, resolved);\n return resolved;\n};\n\nconst adoptCache = new Map<bigint, ContainerProp | null>();\n\nexport const adoptContainerPropFor = (parentType: bigint): ContainerProp | null => {\n const cached = adoptCache.get(parentType);\n if (cached !== undefined) return cached;\n let resolved: ContainerProp | null = null;\n for (const name of collectTypeNamesWithInterfaces(parentType)) {\n const cp = adoptByParent.get(name);\n if (cp !== undefined) {\n resolved = cp;\n break;\n }\n }\n adoptCache.set(parentType, resolved);\n return resolved;\n};\n\nconst containerPropNamesCache = new Map<string, Set<string>>();\n\nexport const containerPropNamesFor = (elementName: string): Set<string> => {\n const cached = containerPropNamesCache.get(elementName);\n if (cached) return cached;\n const names = foldInheritedTableWithInterfaces(\n typeFromName(elementName),\n namedContainerPropsByParent,\n (collected: Set<string>, propNames) => {\n for (const name of propNames) collected.add(name);\n return collected;\n },\n new Set<string>(),\n );\n containerPropNamesCache.set(elementName, names);\n return names;\n};\n\nconst appliedCache = new Map<bigint, Map<string, AppliedProp>>();\n\nexport const appliedPropsFor = (gtype: bigint): Map<string, AppliedProp> => {\n const cached = appliedCache.get(gtype);\n if (cached) return cached;\n const resolved = foldInheritedTableWithInterfaces<AppliedProp[], Map<string, AppliedProp>>(\n gtype,\n APPLIED_BY_TYPE,\n (collected, props) => {\n for (const prop of props) {\n if (!collected.has(prop.prop)) collected.set(prop.prop, prop);\n }\n return collected;\n },\n new Map(),\n );\n appliedCache.set(gtype, resolved);\n return resolved;\n};\n\nexport const isAppliedProp = (gtype: bigint, name: string): boolean => appliedPropsFor(gtype).has(name);\n\nconst constructionSkipCache = new Map<bigint, Set<string>>();\n\nexport const constructionSkipProps = (gtype: bigint): Set<string> => {\n const cached = constructionSkipCache.get(gtype);\n if (cached) return cached;\n const skipped = new Set<string>();\n for (const prop of appliedPropsFor(gtype).values()) {\n if (prop.kind === \"lazy\") skipped.add(prop.prop);\n }\n constructionSkipCache.set(gtype, skipped);\n return skipped;\n};\n"]}
@@ -1,3 +0,0 @@
1
- import { type Node } from "./state.js";
2
- export declare const scheduleLabelTextRebuild: (node: Node) => void;
3
- //# sourceMappingURL=label-text-rebuild.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"label-text-rebuild.d.ts","sourceRoot":"","sources":["../../src/reconciler/label-text-rebuild.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAW,MAAM,YAAY,CAAC;AAiBhD,eAAO,MAAM,wBAAwB,SAAU,IAAI,KAAG,IAMrD,CAAC"}
@@ -1,22 +0,0 @@
1
- import * as Gtk from "@gtkx/gi/gtk";
2
- import { scheduleContentRebuild } from "./content-rebuild.js";
3
- import { stateOf } from "./state.js";
4
- import { isLabelTextNode } from "./text-node.js";
5
- const rebuildLabelText = (owner) => {
6
- const state = stateOf(owner);
7
- const runs = state.children.filter(isLabelTextNode);
8
- if (state.props.label !== undefined) {
9
- if (runs.length === 0)
10
- return;
11
- throw new Error("<GtkLabel> cannot mix a `label` prop with text children; use one or the other");
12
- }
13
- const text = runs
14
- .filter((run) => !stateOf(run).hidden)
15
- .map((run) => String(stateOf(run).props.text))
16
- .join("");
17
- owner.setLabel(text);
18
- };
19
- export const scheduleLabelTextRebuild = (node) => {
20
- scheduleContentRebuild(node, (candidate) => candidate instanceof Gtk.Label, (owner) => () => rebuildLabelText(owner));
21
- };
22
- //# sourceMappingURL=label-text-rebuild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"label-text-rebuild.js","sourceRoot":"","sources":["../../src/reconciler/label-text-rebuild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAa,OAAO,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,gBAAgB,GAAG,CAAC,KAAgB,EAAQ,EAAE;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC9B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACrG,CAAC;IACD,MAAM,IAAI,GAAG,IAAI;SACZ,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SACrC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC7C,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAU,EAAQ,EAAE;IACzD,sBAAsB,CAClB,IAAI,EACJ,CAAC,SAAS,EAA0B,EAAE,CAAC,SAAS,YAAY,GAAG,CAAC,KAAK,EACrE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAC3C,CAAC;AACN,CAAC,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { scheduleContentRebuild } from \"./content-rebuild.js\";\nimport { type Node, stateOf } from \"./state.js\";\nimport { isLabelTextNode } from \"./text-node.js\";\n\nconst rebuildLabelText = (owner: Gtk.Label): void => {\n const state = stateOf(owner);\n const runs = state.children.filter(isLabelTextNode);\n if (state.props.label !== undefined) {\n if (runs.length === 0) return;\n throw new Error(\"<GtkLabel> cannot mix a `label` prop with text children; use one or the other\");\n }\n const text = runs\n .filter((run) => !stateOf(run).hidden)\n .map((run) => String(stateOf(run).props.text))\n .join(\"\");\n owner.setLabel(text);\n};\n\nexport const scheduleLabelTextRebuild = (node: Node): void => {\n scheduleContentRebuild(\n node,\n (candidate): candidate is Gtk.Label => candidate instanceof Gtk.Label,\n (owner) => () => rebuildLabelText(owner),\n );\n};\n"]}
@@ -1,11 +0,0 @@
1
- import type { ReactNode, ReactPortal } from "react";
2
- import type { Container } from "./types.js";
3
- /**
4
- * Creates a React portal that renders `children` into a different container in the widget tree.
5
- *
6
- * @param children The nodes to render inside the container.
7
- * @param container The GObject or root element to render into.
8
- * @param key An optional React key for the portal.
9
- */
10
- export declare const createPortal: (children: ReactNode, container: Container, key?: string | null) => ReactPortal;
11
- //# sourceMappingURL=portal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/reconciler/portal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5C;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,aAAc,SAAS,aAAa,SAAS,QAAQ,MAAM,GAAG,IAAI,KAAG,WAW7F,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Creates a React portal that renders `children` into a different container in the widget tree.
3
- *
4
- * @param children The nodes to render inside the container.
5
- * @param container The GObject or root element to render into.
6
- * @param key An optional React key for the portal.
7
- */
8
- export const createPortal = (children, container, key) => {
9
- const portal = {
10
- $$typeof: Symbol.for("react.portal"),
11
- type: "",
12
- props: { children },
13
- key: key ?? null,
14
- children,
15
- containerInfo: container,
16
- implementation: null,
17
- };
18
- return portal;
19
- };
20
- //# sourceMappingURL=portal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"portal.js","sourceRoot":"","sources":["../../src/reconciler/portal.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAmB,EAAE,SAAoB,EAAE,GAAmB,EAAe,EAAE;IACxG,MAAM,MAAM,GAAiB;QACzB,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;QACpC,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE,QAAQ,EAAE;QACnB,GAAG,EAAE,GAAG,IAAI,IAAI;QAChB,QAAQ;QACR,aAAa,EAAE,SAAS;QACxB,cAAc,EAAE,IAAI;KACvB,CAAC;IACF,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { ReactNode, ReactPortal } from \"react\";\nimport type { Container } from \"./types.js\";\n\ntype ObjectPortal = ReactPortal & {\n $$typeof: symbol;\n containerInfo: Container;\n implementation: null;\n};\n\n/**\n * Creates a React portal that renders `children` into a different container in the widget tree.\n *\n * @param children The nodes to render inside the container.\n * @param container The GObject or root element to render into.\n * @param key An optional React key for the portal.\n */\nexport const createPortal = (children: ReactNode, container: Container, key?: string | null): ReactPortal => {\n const portal: ObjectPortal = {\n $$typeof: Symbol.for(\"react.portal\"),\n type: \"\",\n props: { children },\n key: key ?? null,\n children,\n containerInfo: container,\n implementation: null,\n };\n return portal;\n};\n"]}
@@ -1,7 +0,0 @@
1
- import { type Logger } from "@gtkx/utils";
2
- export declare const log: Logger;
3
- export type ReconcilerErrorHandler = (error: unknown) => void;
4
- export declare function setReconcilerErrorHandler(handler: ReconcilerErrorHandler | null): ReconcilerErrorHandler | null;
5
- export declare function reportReconcilerError(error: unknown): void;
6
- export declare function catchReconcilerError(fn: () => void): void;
7
- //# sourceMappingURL=reconciler-error-handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler-error-handler.d.ts","sourceRoot":"","sources":["../../src/reconciler/reconciler-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,GAAG,EAAE,MAA8B,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAI9D,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,GAAG,sBAAsB,GAAG,IAAI,CAI/G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAM1D;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAMzD"}
@@ -1,24 +0,0 @@
1
- import { createLogger } from "@gtkx/utils";
2
- export const log = createLogger("react");
3
- let errorHandler = null;
4
- export function setReconcilerErrorHandler(handler) {
5
- const prior = errorHandler;
6
- errorHandler = handler;
7
- return prior;
8
- }
9
- export function reportReconcilerError(error) {
10
- if (errorHandler) {
11
- errorHandler(error);
12
- return;
13
- }
14
- log.error("unhandled reconciler error", error);
15
- }
16
- export function catchReconcilerError(fn) {
17
- try {
18
- fn();
19
- }
20
- catch (error) {
21
- reportReconcilerError(error);
22
- }
23
- }
24
- //# sourceMappingURL=reconciler-error-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler-error-handler.js","sourceRoot":"","sources":["../../src/reconciler/reconciler-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAExD,MAAM,CAAC,MAAM,GAAG,GAAW,YAAY,CAAC,OAAO,CAAC,CAAC;AAIjD,IAAI,YAAY,GAAkC,IAAI,CAAC;AAEvD,MAAM,UAAU,yBAAyB,CAAC,OAAsC;IAC5E,MAAM,KAAK,GAAG,YAAY,CAAC;IAC3B,YAAY,GAAG,OAAO,CAAC;IACvB,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAChD,IAAI,YAAY,EAAE,CAAC;QACf,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO;IACX,CAAC;IACD,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAc;IAC/C,IAAI,CAAC;QACD,EAAE,EAAE,CAAC;IACT,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;AACL,CAAC","sourcesContent":["import { createLogger, type Logger } from \"@gtkx/utils\";\n\nexport const log: Logger = createLogger(\"react\");\n\nexport type ReconcilerErrorHandler = (error: unknown) => void;\n\nlet errorHandler: ReconcilerErrorHandler | null = null;\n\nexport function setReconcilerErrorHandler(handler: ReconcilerErrorHandler | null): ReconcilerErrorHandler | null {\n const prior = errorHandler;\n errorHandler = handler;\n return prior;\n}\n\nexport function reportReconcilerError(error: unknown): void {\n if (errorHandler) {\n errorHandler(error);\n return;\n }\n log.error(\"unhandled reconciler error\", error);\n}\n\nexport function catchReconcilerError(fn: () => void): void {\n try {\n fn();\n } catch (error) {\n reportReconcilerError(error);\n }\n}\n"]}
@@ -1,19 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import type { Container } from "./types.js";
3
- type ReconcilerErrorCallback = (error: Error, info: {
4
- componentStack?: string | null;
5
- }) => void;
6
- export type ReconcilerRootOptions = {
7
- containerInfo: Container;
8
- onUncaughtError: ReconcilerErrorCallback;
9
- onCaughtError: ReconcilerErrorCallback;
10
- onRecoverableError?: ReconcilerErrorCallback;
11
- };
12
- export type ReconcilerRoot = {
13
- update(element: ReactNode): void;
14
- unmount<R>(free: (root: ReconcilerRoot) => R): R | undefined;
15
- };
16
- export declare const createReconcilerRoot: (options: ReconcilerRootOptions) => ReconcilerRoot;
17
- export declare const unmountAllReconcilerRoots: (free: (root: ReconcilerRoot) => void) => void;
18
- export {};
19
- //# sourceMappingURL=reconciler-root.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler-root.d.ts","sourceRoot":"","sources":["../../src/reconciler/reconciler-root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5C,KAAK,uBAAuB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KAAK,IAAI,CAAC;AAEhG,MAAM,MAAM,qBAAqB,GAAG;IAChC,aAAa,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,uBAAuB,CAAC;IACzC,aAAa,EAAE,uBAAuB,CAAC;IACvC,kBAAkB,CAAC,EAAE,uBAAuB,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;CAChE,CAAC;AAIF,eAAO,MAAM,oBAAoB,YAAa,qBAAqB,KAAG,cA0BrE,CAAC;AAEF,eAAO,MAAM,yBAAyB,SAAU,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,KAAG,IAIhF,CAAC"}
@@ -1,24 +0,0 @@
1
- import { reconciler } from "./reconciler.js";
2
- const noop = () => { };
3
- const activeRoots = new Set();
4
- export const createReconcilerRoot = (options) => {
5
- const fiberRoot = reconciler.createContainer(options.containerInfo, 1, null, false, null, "", options.onUncaughtError, options.onCaughtError, options.onRecoverableError ?? noop, noop);
6
- const root = {
7
- update: (element) => {
8
- reconciler.updateContainer(element, fiberRoot, null, noop);
9
- },
10
- unmount: (free) => {
11
- if (!activeRoots.delete(root))
12
- return undefined;
13
- return free(root);
14
- },
15
- };
16
- activeRoots.add(root);
17
- return root;
18
- };
19
- export const unmountAllReconcilerRoots = (free) => {
20
- const roots = [...activeRoots];
21
- activeRoots.clear();
22
- roots.forEach(free);
23
- };
24
- //# sourceMappingURL=reconciler-root.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler-root.js","sourceRoot":"","sources":["../../src/reconciler/reconciler-root.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;AAkB5B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAA8B,EAAkB,EAAE;IACnF,MAAM,SAAS,GAAc,UAAU,CAAC,eAAe,CACnD,OAAO,CAAC,aAAa,EACrB,CAAC,EACD,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,EAAE,EACF,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,kBAAkB,IAAI,IAAI,EAClC,IAAI,CACP,CAAC;IAEF,MAAM,IAAI,GAAmB;QACzB,MAAM,EAAE,CAAC,OAAkB,EAAQ,EAAE;YACjC,UAAU,CAAC,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,EAAE,CAAI,IAAiC,EAAiB,EAAE;YAC7D,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;gBAAE,OAAO,SAAS,CAAC;YAChD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;KACJ,CAAC;IAEF,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,IAAoC,EAAQ,EAAE;IACpF,MAAM,KAAK,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;IAC/B,WAAW,CAAC,KAAK,EAAE,CAAC;IACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { reconciler } from \"./reconciler.js\";\nimport type { Container } from \"./types.js\";\n\nconst noop = (): void => {};\n\ntype FiberRoot = ReturnType<typeof reconciler.createContainer>;\n\ntype ReconcilerErrorCallback = (error: Error, info: { componentStack?: string | null }) => void;\n\nexport type ReconcilerRootOptions = {\n containerInfo: Container;\n onUncaughtError: ReconcilerErrorCallback;\n onCaughtError: ReconcilerErrorCallback;\n onRecoverableError?: ReconcilerErrorCallback;\n};\n\nexport type ReconcilerRoot = {\n update(element: ReactNode): void;\n unmount<R>(free: (root: ReconcilerRoot) => R): R | undefined;\n};\n\nconst activeRoots = new Set<ReconcilerRoot>();\n\nexport const createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {\n const fiberRoot: FiberRoot = reconciler.createContainer(\n options.containerInfo,\n 1,\n null,\n false,\n null,\n \"\",\n options.onUncaughtError,\n options.onCaughtError,\n options.onRecoverableError ?? noop,\n noop,\n );\n\n const root: ReconcilerRoot = {\n update: (element: ReactNode): void => {\n reconciler.updateContainer(element, fiberRoot, null, noop);\n },\n unmount: <R>(free: (root: ReconcilerRoot) => R): R | undefined => {\n if (!activeRoots.delete(root)) return undefined;\n return free(root);\n },\n };\n\n activeRoots.add(root);\n return root;\n};\n\nexport const unmountAllReconcilerRoots = (free: (root: ReconcilerRoot) => void): void => {\n const roots = [...activeRoots];\n activeRoots.clear();\n roots.forEach(free);\n};\n"]}
@@ -1,3 +0,0 @@
1
- import { type ReconcilerInstance } from "./host-config.js";
2
- export declare const reconciler: ReconcilerInstance;
3
- //# sourceMappingURL=reconciler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../src/reconciler/reconciler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,eAAO,MAAM,UAAU,EAAE,kBAAwD,CAAC"}
@@ -1,12 +0,0 @@
1
- import ReactReconciler from "react-reconciler";
2
- import packageJson from "../../package.json" with { type: "json" };
3
- import { createHostConfig } from "./host-config.js";
4
- export const reconciler = ReactReconciler(createHostConfig());
5
- if (process.env.NODE_ENV !== "production") {
6
- reconciler.injectIntoDevTools({
7
- bundleType: 1,
8
- version: packageJson.version,
9
- rendererPackageName: "@gtkx/react",
10
- });
11
- }
12
- //# sourceMappingURL=reconciler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconciler.js","sourceRoot":"","sources":["../../src/reconciler/reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,WAAW,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAA2B,MAAM,kBAAkB,CAAC;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAuB,eAAe,CAAC,gBAAgB,EAAE,CAAC,CAAC;AAElF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IACxC,UAAU,CAAC,kBAAkB,CAAC;QAC1B,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,mBAAmB,EAAE,aAAa;KACrC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import ReactReconciler from \"react-reconciler\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\nimport { createHostConfig, type ReconcilerInstance } from \"./host-config.js\";\n\nexport const reconciler: ReconcilerInstance = ReactReconciler(createHostConfig());\n\nif (process.env.NODE_ENV !== \"production\") {\n reconciler.injectIntoDevTools({\n bundleType: 1,\n version: packageJson.version,\n rendererPackageName: \"@gtkx/react\",\n });\n}\n"]}
@@ -1,23 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { type RootElement } from "./root-element.js";
3
- /**
4
- * A render root that mounts a React element tree into a container and can unmount it.
5
- */
6
- export type Root = {
7
- render(element: ReactNode): void;
8
- unmount(): void;
9
- };
10
- /**
11
- * Creates a render root for a container, wiring reconciler error handling to the container's signal store.
12
- *
13
- * @param container The root element to render into; defaults to the shared `rootElement`.
14
- * @returns A root with `render` and `unmount` methods.
15
- */
16
- export declare const createRoot: (container?: RootElement) => Root;
17
- /**
18
- * Unmounts all active render roots.
19
- *
20
- * @returns `true` once every root has been torn down.
21
- */
22
- export declare const quit: () => true;
23
- //# sourceMappingURL=render.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/reconciler/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAUlE;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG;IACf,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,eAAe,WAAW,KAAiB,IAuBjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,QAAO,IAGvB,CAAC"}
@@ -1,46 +0,0 @@
1
- import { log, setReconcilerErrorHandler } from "./reconciler-error-handler.js";
2
- import { createReconcilerRoot, unmountAllReconcilerRoots } from "./reconciler-root.js";
3
- import { rootElement } from "./root-element.js";
4
- import { getSignalStore } from "./signal-store.js";
5
- const priorHandlers = new WeakMap();
6
- const teardownRoot = (root) => {
7
- setReconcilerErrorHandler(priorHandlers.get(root) ?? null);
8
- root.update(null);
9
- };
10
- /**
11
- * Creates a render root for a container, wiring reconciler error handling to the container's signal store.
12
- *
13
- * @param container The root element to render into; defaults to the shared `rootElement`.
14
- * @returns A root with `render` and `unmount` methods.
15
- */
16
- export const createRoot = (container = rootElement) => {
17
- const onUncaughtError = (error) => {
18
- getSignalStore(container).unblock();
19
- throw error;
20
- };
21
- const onCaughtError = (error) => {
22
- getSignalStore(container).unblock();
23
- log.error("caught render error", error);
24
- };
25
- const priorHandler = setReconcilerErrorHandler(onUncaughtError);
26
- const root = createReconcilerRoot({ containerInfo: container, onUncaughtError, onCaughtError });
27
- priorHandlers.set(root, priorHandler);
28
- return {
29
- render: (element) => {
30
- root.update(element);
31
- },
32
- unmount: () => {
33
- root.unmount(teardownRoot);
34
- },
35
- };
36
- };
37
- /**
38
- * Unmounts all active render roots.
39
- *
40
- * @returns `true` once every root has been torn down.
41
- */
42
- export const quit = () => {
43
- unmountAllReconcilerRoots(teardownRoot);
44
- return true;
45
- };
46
- //# sourceMappingURL=render.js.map