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

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 +269 -0
  12. package/dist/adw/element-behaviors.js.map +1 -0
  13. package/dist/adw/element-config.d.ts +11 -0
  14. package/dist/adw/element-config.d.ts.map +1 -0
  15. package/dist/adw/element-config.js +127 -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 +22 -12
  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 +149 -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 +14 -7
  82. package/dist/hooks/use-signal.d.ts.map +1 -1
  83. package/dist/hooks/use-signal.js +33 -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 +7 -7
  90. package/dist/internal.d.ts.map +1 -1
  91. package/dist/internal.js +6 -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 +186 -82
  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 +177 -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 +171 -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 +191 -0
  128. package/dist/reconciler/placement.js.map +1 -0
  129. package/dist/reconciler/registry.d.ts +107 -0
  130. package/dist/reconciler/registry.d.ts.map +1 -0
  131. package/dist/reconciler/registry.js +74 -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 +106 -0
  140. package/dist/reconciler/root.js.map +1 -0
  141. package/dist/reconciler/signals.d.ts +9 -0
  142. package/dist/reconciler/signals.d.ts.map +1 -0
  143. package/dist/reconciler/signals.js +58 -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 +281 -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 +349 -0
  174. package/src/adw/element-config.ts +131 -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 +26 -14
  181. package/src/config.ts +10 -0
  182. package/src/element-behaviors.ts +424 -0
  183. package/src/element-config.ts +151 -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 +41 -48
  193. package/src/index.ts +7 -8
  194. package/src/internal.ts +8 -18
  195. package/src/prop-types.ts +142 -0
  196. package/src/reconciler/apply-props.ts +239 -85
  197. package/src/reconciler/behaviors.ts +330 -0
  198. package/src/reconciler/child-routing.ts +202 -0
  199. package/src/reconciler/host-config.ts +235 -367
  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 +275 -0
  204. package/src/reconciler/registry.ts +175 -0
  205. package/src/reconciler/root-element.ts +9 -11
  206. package/src/reconciler/root.ts +172 -0
  207. package/src/reconciler/signals.ts +92 -0
  208. package/src/reconciler/text.ts +414 -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,27 +1,49 @@
1
- import * as GObject from "@gtkx/gi/gobject";
2
- import { collectConstructableProps, requireClassByName } from "../utils/gtype.js";
3
- import { constructionSkipProps } from "./element-props.js";
4
- import { registerState } from "./state.js";
5
- import { createWrapperNode } from "./wrapper-node.js";
6
- const pickConstructProps = (gtype, props) => {
7
- const constructable = collectConstructableProps(gtype);
8
- const skipped = constructionSkipProps(gtype);
9
- const result = {};
10
- for (const name in props) {
11
- if (constructable.has(name) && !skipped.has(name))
12
- result[name] = props[name];
1
+ import { getWrapperClass, TYPE_INVALID, typeFromName, typeIsA } from "@gtkx/runtime";
2
+ import { pickBy } from "@gtkx/utils";
3
+ import { typeInfoFor } from "./metadata.js";
4
+ import { createElementNode, createLazyNode, } from "./node.js";
5
+ import { ELEMENTS } from "./registry.js";
6
+ const CONTENT_TYPE_NAMES = [
7
+ { kind: "label", name: "GtkLabel" },
8
+ { kind: "buffer", name: "GtkTextBuffer" },
9
+ { kind: "tag", name: "GtkTextTag" },
10
+ { kind: "anchor", name: "GtkTextChildAnchor" },
11
+ ];
12
+ const getContentTypes = createContentTypeCache();
13
+ function createContentTypeCache() {
14
+ let cached = null;
15
+ return () => {
16
+ cached ??= CONTENT_TYPE_NAMES.map((entry) => ({ kind: entry.kind, type: typeFromName(entry.name) }));
17
+ return cached;
18
+ };
19
+ }
20
+ const resolveContentKind = (type) => {
21
+ for (const entry of getContentTypes()) {
22
+ if (entry.type !== TYPE_INVALID && typeIsA(type, entry.type)) {
23
+ return entry.kind;
24
+ }
13
25
  }
14
- return result;
26
+ return null;
15
27
  };
16
- export const createElementInstance = (type, props, rootContainer) => {
17
- const cls = requireClassByName(type);
18
- const node = new cls(pickConstructProps(GObject.typeFromName(type), props));
19
- registerState(node, { props, rootContainer });
20
- return node;
28
+ const constructInput = (info, props) => pickBy(props, (value, name) => value !== undefined &&
29
+ !info.deferred.has(name) &&
30
+ (info.constructOnly.has(name) || info.construct.has(name)));
31
+ const instantiate = (type, input) => {
32
+ const cls = getWrapperClass(type);
33
+ return new cls(input);
21
34
  };
22
- export const createWrapperInstance = (kind, props, rootContainer) => {
23
- const node = createWrapperNode();
24
- registerState(node, { kind, props, rootContainer });
25
- return node;
35
+ const createObject = (typeName, type, input) => {
36
+ const create = ELEMENTS[typeName]?.behaviors?.find((behavior) => behavior.create !== undefined)?.create;
37
+ return create === undefined ? instantiate(type, input) : create(input);
26
38
  };
39
+ const resolveElementNode = (typeName, props, dispatch) => {
40
+ const info = typeInfoFor(typeName);
41
+ if (info.lazy) {
42
+ return createLazyNode(typeName, props, dispatch);
43
+ }
44
+ const type = typeFromName(typeName);
45
+ const object = createObject(typeName, type, constructInput(info, props));
46
+ return createElementNode(typeName, object, dispatch, resolveContentKind(type));
47
+ };
48
+ export { resolveElementNode };
27
49
  //# sourceMappingURL=instance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/reconciler/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAa,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,KAAY,EAAS,EAAE;IAC9D,MAAM,aAAa,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,KAAY,EAAE,aAAwB,EAAQ,EAAE;IAChG,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5E,aAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAiB,EAAE,KAAY,EAAE,aAAwB,EAAQ,EAAE;IACrG,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport { collectConstructableProps, requireClassByName } from \"../utils/gtype.js\";\nimport { constructionSkipProps } from \"./element-props.js\";\nimport { type Node, registerState } from \"./state.js\";\nimport type { Container, Props } from \"./types.js\";\nimport { createWrapperNode } from \"./wrapper-node.js\";\nimport type { WrapperKind } from \"./wrapper-protocol.js\";\n\nconst pickConstructProps = (gtype: bigint, props: Props): Props => {\n const constructable = collectConstructableProps(gtype);\n const skipped = constructionSkipProps(gtype);\n const result: Props = {};\n for (const name in props) {\n if (constructable.has(name) && !skipped.has(name)) result[name] = props[name];\n }\n return result;\n};\n\nexport const createElementInstance = (type: string, props: Props, rootContainer: Container): Node => {\n const cls = requireClassByName(type);\n const node = new cls(pickConstructProps(GObject.typeFromName(type), props));\n registerState(node, { props, rootContainer });\n return node;\n};\n\nexport const createWrapperInstance = (kind: WrapperKind, props: Props, rootContainer: Container): Node => {\n const node = createWrapperNode();\n registerState(node, { kind, props, rootContainer });\n return node;\n};\n"]}
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/reconciler/instance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACr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EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzE,OAAO,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { getWrapperClass, TYPE_INVALID, typeFromName, typeIsA } from \"@gtkx/runtime\";\nimport { pickBy } from \"@gtkx/utils\";\nimport type { Props } from \"./registry.js\";\nimport { type TypeInfo, typeInfoFor } from \"./metadata.js\";\nimport {\n type ContentKind,\n createElementNode,\n createLazyNode,\n type Dispatch,\n type ElementNode,\n type LazyNode,\n} from \"./node.js\";\nimport { ELEMENTS } from \"./registry.js\";\n\ntype WidgetConstructor = new (props: Props) => GObject.Object;\ntype ContentType = { kind: ContentKind; type: bigint };\n\nconst CONTENT_TYPE_NAMES: { kind: ContentKind; name: string }[] = [\n { kind: \"label\", name: \"GtkLabel\" },\n { kind: \"buffer\", name: \"GtkTextBuffer\" },\n { kind: \"tag\", name: \"GtkTextTag\" },\n { kind: \"anchor\", name: \"GtkTextChildAnchor\" },\n];\n\nconst getContentTypes = createContentTypeCache();\n\nfunction createContentTypeCache(): () => ContentType[] {\n let cached: ContentType[] | null = null;\n\n return () => {\n cached ??= CONTENT_TYPE_NAMES.map((entry) => ({ kind: entry.kind, type: typeFromName(entry.name) }));\n\n return cached;\n };\n}\n\nconst resolveContentKind = (type: bigint): ContentKind | null => {\n for (const entry of getContentTypes()) {\n if (entry.type !== TYPE_INVALID && typeIsA(type, entry.type)) {\n return entry.kind;\n }\n }\n\n return null;\n};\n\nconst constructInput = (info: TypeInfo, props: Props): Props =>\n pickBy(\n props,\n (value, name) =>\n value !== undefined &&\n !info.deferred.has(name) &&\n (info.constructOnly.has(name) || info.construct.has(name)),\n );\n\nconst instantiate = (type: bigint, input: Props): GObject.Object => {\n const cls = getWrapperClass(type) as WidgetConstructor;\n\n return new cls(input);\n};\n\nconst createObject = (typeName: string, type: bigint, input: Props): GObject.Object => {\n const create = ELEMENTS[typeName]?.behaviors?.find((behavior) => behavior.create !== undefined)?.create;\n\n return create === undefined ? instantiate(type, input) : create(input);\n};\n\nconst resolveElementNode = (typeName: string, props: Props, dispatch: Dispatch): ElementNode | LazyNode => {\n const info = typeInfoFor(typeName);\n\n if (info.lazy) {\n return createLazyNode(typeName, props, dispatch);\n }\n\n const type = typeFromName(typeName);\n const object = createObject(typeName, type, constructInput(info, props));\n\n return createElementNode(typeName, object, dispatch, resolveContentKind(type));\n};\n\nexport { resolveElementNode };\n"]}
@@ -0,0 +1,17 @@
1
+ import { type ElementBehavior } from "./registry.js";
2
+ type TypeInfo = {
3
+ typeName: string;
4
+ signals: Record<string, string>;
5
+ userEventSignals: Set<string>;
6
+ behaviors: ElementBehavior[];
7
+ deferred: Set<string>;
8
+ lazy: boolean;
9
+ hasFlush: boolean;
10
+ hasMount: boolean;
11
+ constructOnly: Set<string>;
12
+ construct: Set<string>;
13
+ defaults: Record<string, unknown>;
14
+ };
15
+ declare const typeInfoFor: (name: string) => TypeInfo;
16
+ export { typeInfoFor, type TypeInfo };
17
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/reconciler/metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,eAAe,EAAY,MAAM,eAAe,CAAC;AAE9E,KAAK,QAAQ,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAmGF,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,QAA2D,CAAC;AAEhG,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { TYPE_INVALID, typeFromName, typeInterfaces, typeName, typeParent } from "@gtkx/runtime";
2
+ import { getOrInsert } from "@gtkx/utils";
3
+ import { CONSTRUCT_ONLY_PROPS, CONSTRUCT_PROPS, DEFAULT_PROPS, SIGNALS, userEventSignals } from "virtual:gtkx-config";
4
+ import { deferredProps, ELEMENTS } from "./registry.js";
5
+ const ancestryCache = new Map();
6
+ const typeInfoCache = new Map();
7
+ const addAncestor = (names, seen, name) => {
8
+ if (name === null || seen.has(name)) {
9
+ return;
10
+ }
11
+ seen.add(name);
12
+ names.push(name);
13
+ };
14
+ const buildAncestry = (name) => {
15
+ const names = [];
16
+ const seen = new Set();
17
+ let type = typeFromName(name);
18
+ while (type !== TYPE_INVALID) {
19
+ addAncestor(names, seen, typeName(type));
20
+ for (const iface of typeInterfaces(type)) {
21
+ addAncestor(names, seen, typeName(iface));
22
+ }
23
+ type = typeParent(type);
24
+ }
25
+ return names;
26
+ };
27
+ const ancestryFor = (name) => getOrInsert(ancestryCache, name, buildAncestry);
28
+ const addAll = (target, source) => {
29
+ const items = source ?? [];
30
+ for (const item of items) {
31
+ target.add(item);
32
+ }
33
+ };
34
+ const accumulateAncestor = (info, ancestor) => {
35
+ Object.assign(info.signals, SIGNALS[ancestor] ?? {});
36
+ addAll(info.userEventSignals, userEventSignals[ancestor]);
37
+ addAll(info.constructOnly, CONSTRUCT_ONLY_PROPS[ancestor]);
38
+ addAll(info.construct, CONSTRUCT_PROPS[ancestor]);
39
+ info.behaviors.push(...(ELEMENTS[ancestor]?.behaviors ?? []));
40
+ };
41
+ const applyBehaviorFlags = (info, behavior) => {
42
+ if (behavior.flush !== undefined) {
43
+ info.hasFlush = true;
44
+ }
45
+ if (behavior.mount !== undefined) {
46
+ info.hasMount = true;
47
+ }
48
+ addAll(info.deferred, deferredProps(behavior));
49
+ };
50
+ const resolveBehaviorFlags = (info) => {
51
+ for (const behavior of info.behaviors) {
52
+ applyBehaviorFlags(info, behavior);
53
+ }
54
+ };
55
+ const buildTypeInfo = (name) => {
56
+ const chain = ancestryFor(name);
57
+ const info = {
58
+ typeName: name,
59
+ signals: {},
60
+ userEventSignals: new Set(),
61
+ behaviors: [],
62
+ deferred: new Set(),
63
+ lazy: false,
64
+ hasFlush: false,
65
+ hasMount: false,
66
+ constructOnly: new Set(),
67
+ construct: new Set(),
68
+ defaults: {},
69
+ };
70
+ for (const ancestor of chain) {
71
+ accumulateAncestor(info, ancestor);
72
+ }
73
+ resolveBehaviorFlags(info);
74
+ info.lazy = chain.some((ancestor) => ELEMENTS[ancestor]?.lazy === true);
75
+ for (const ancestor of chain.toReversed()) {
76
+ Object.assign(info.defaults, DEFAULT_PROPS[ancestor] ?? {});
77
+ }
78
+ return info;
79
+ };
80
+ const typeInfoFor = (name) => getOrInsert(typeInfoCache, name, buildTypeInfo);
81
+ export { typeInfoFor };
82
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/reconciler/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,OA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ent":["import { TYPE_INVALID, typeFromName, typeInterfaces, typeName, typeParent } from \"@gtkx/runtime\";\nimport { getOrInsert } from \"@gtkx/utils\";\nimport { CONSTRUCT_ONLY_PROPS, CONSTRUCT_PROPS, DEFAULT_PROPS, SIGNALS, userEventSignals } from \"virtual:gtkx-config\";\nimport { deferredProps, type ElementBehavior, ELEMENTS } from \"./registry.js\";\n\ntype TypeInfo = {\n typeName: string;\n signals: Record<string, string>;\n userEventSignals: Set<string>;\n behaviors: ElementBehavior[];\n deferred: Set<string>;\n lazy: boolean;\n hasFlush: boolean;\n hasMount: boolean;\n constructOnly: Set<string>;\n construct: Set<string>;\n defaults: Record<string, unknown>;\n};\n\nconst ancestryCache: Map<string, string[]> = new Map();\nconst typeInfoCache: Map<string, TypeInfo> = new Map();\n\nconst addAncestor = (names: string[], seen: Set<string>, name: string | null): void => {\n if (name === null || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n names.push(name);\n};\n\nconst buildAncestry = (name: string): string[] => {\n const names: string[] = [];\n const seen: Set<string> = new Set();\n let type = typeFromName(name);\n\n while (type !== TYPE_INVALID) {\n addAncestor(names, seen, typeName(type));\n\n for (const iface of typeInterfaces(type)) {\n addAncestor(names, seen, typeName(iface));\n }\n\n type = typeParent(type);\n }\n\n return names;\n};\n\nconst ancestryFor = (name: string): string[] => getOrInsert(ancestryCache, name, buildAncestry);\n\nconst addAll = <T>(target: Set<T>, source: Iterable<T> | undefined): void => {\n const items = source ?? [];\n\n for (const item of items) {\n target.add(item);\n }\n};\n\nconst accumulateAncestor = (info: TypeInfo, ancestor: string): void => {\n Object.assign(info.signals, SIGNALS[ancestor] ?? {});\n addAll(info.userEventSignals, userEventSignals[ancestor]);\n addAll(info.constructOnly, CONSTRUCT_ONLY_PROPS[ancestor]);\n addAll(info.construct, CONSTRUCT_PROPS[ancestor]);\n info.behaviors.push(...(ELEMENTS[ancestor]?.behaviors ?? []));\n};\n\nconst applyBehaviorFlags = (info: TypeInfo, behavior: ElementBehavior): void => {\n if (behavior.flush !== undefined) {\n info.hasFlush = true;\n }\n\n if (behavior.mount !== undefined) {\n info.hasMount = true;\n }\n\n addAll(info.deferred, deferredProps(behavior));\n};\n\nconst resolveBehaviorFlags = (info: TypeInfo): void => {\n for (const behavior of info.behaviors) {\n applyBehaviorFlags(info, behavior);\n }\n};\n\nconst buildTypeInfo = (name: string): TypeInfo => {\n const chain = ancestryFor(name);\n\n const info: TypeInfo = {\n typeName: name,\n signals: {},\n userEventSignals: new Set(),\n behaviors: [],\n deferred: new Set(),\n lazy: false,\n hasFlush: false,\n hasMount: false,\n constructOnly: new Set(),\n construct: new Set(),\n defaults: {},\n };\n\n for (const ancestor of chain) {\n accumulateAncestor(info, ancestor);\n }\n\n resolveBehaviorFlags(info);\n info.lazy = chain.some((ancestor) => ELEMENTS[ancestor]?.lazy === true);\n\n for (const ancestor of chain.toReversed()) {\n Object.assign(info.defaults, DEFAULT_PROPS[ancestor] ?? {});\n }\n\n return info;\n};\n\nconst typeInfoFor = (name: string): TypeInfo => getOrInsert(typeInfoCache, name, buildTypeInfo);\n\nexport { typeInfoFor, type TypeInfo };\n"]}
@@ -0,0 +1,76 @@
1
+ import type * as GObject from "@gtkx/gi/gobject";
2
+ import type * as Gtk from "@gtkx/gi/gtk";
3
+ import type { SignalHandler } from "@gtkx/runtime";
4
+ import type { ElementBehavior, Props } from "./registry.js";
5
+ type ContentKind = "label" | "buffer" | "tag" | "anchor";
6
+ type HandlerRecord = {
7
+ signal: string;
8
+ handler: SignalHandler;
9
+ wrapped: SignalHandler;
10
+ blockable: boolean;
11
+ };
12
+ type Dispatch = (fn: () => unknown) => unknown;
13
+ type SignalTarget = {
14
+ object: GObject.Object;
15
+ handlers: Map<string, HandlerRecord>;
16
+ typeName: string;
17
+ dispatch: Dispatch;
18
+ };
19
+ type PlacedChild = {
20
+ node: PlaceableNode;
21
+ object: GObject.Object;
22
+ adopted: GObject.Object | null;
23
+ slot: string;
24
+ behavior: ElementBehavior | null;
25
+ attached: boolean;
26
+ };
27
+ type ElementNode = SignalTarget & {
28
+ kind: typeof ELEMENT_KIND;
29
+ props: Props;
30
+ placements: Map<string, PlacedChild[]>;
31
+ contexts: Map<ElementBehavior, unknown>;
32
+ parent: ParentNode | null;
33
+ content: ContentChild[];
34
+ contentKind: ContentKind | null;
35
+ bufferView: Gtk.TextView | null;
36
+ };
37
+ type PropNode = {
38
+ kind: typeof PROP_KIND;
39
+ slot: string;
40
+ children: PlaceableNode[];
41
+ parent: ElementNode | null;
42
+ };
43
+ type LazyNode = {
44
+ kind: typeof LAZY_KIND;
45
+ typeName: string;
46
+ props: Props;
47
+ children: PlaceableNode[];
48
+ parent: ElementNode | null;
49
+ adopted: GObject.Object | null;
50
+ handlers: Map<string, HandlerRecord>;
51
+ dispatch: Dispatch;
52
+ };
53
+ type TextNode = {
54
+ kind: typeof TEXT_KIND;
55
+ text: string;
56
+ parent: ParentNode | null;
57
+ };
58
+ type PlaceableNode = ElementNode | LazyNode;
59
+ type ParentNode = ElementNode | PropNode | LazyNode;
60
+ type ContentChild = TextNode | ElementNode;
61
+ type Instance = ElementNode | PropNode | LazyNode;
62
+ type AnyNode = Instance | TextNode;
63
+ declare const ELEMENT_KIND = "element";
64
+ declare const PROP_KIND = "prop";
65
+ declare const TEXT_KIND = "text";
66
+ declare const LAZY_KIND = "lazy";
67
+ declare const DEFAULT_SLOT = "children";
68
+ declare const createPropNode: (slot: string) => PropNode;
69
+ declare const createLazyNode: (typeName: string, props: Props, dispatch: Dispatch) => LazyNode;
70
+ declare const createElementNode: (typeName: string, object: GObject.Object, dispatch: Dispatch, contentKind: ContentKind | null) => ElementNode;
71
+ declare const createTextNode: (text: string) => TextNode;
72
+ declare const nodeObject: (node: PlaceableNode) => GObject.Object | null;
73
+ declare const lazyTarget: (node: LazyNode, adopted: GObject.Object) => SignalTarget;
74
+ declare const getOrCreateContext: (node: ElementNode, behavior: ElementBehavior) => unknown;
75
+ export { ELEMENT_KIND, PROP_KIND, TEXT_KIND, LAZY_KIND, DEFAULT_SLOT, createPropNode, createLazyNode, createElementNode, createTextNode, nodeObject, lazyTarget, getOrCreateContext, type ContentKind, type HandlerRecord, type Dispatch, type SignalTarget, type PlacedChild, type ElementNode, type PropNode, type LazyNode, type TextNode, type PlaceableNode, type ParentNode, type ContentChild, type Instance, type AnyNode, };
76
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/reconciler/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5D,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;AACzD,KAAK,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAC5G,KAAK,QAAQ,GAAG,CAAC,EAAE,EAAE,MAAM,OAAO,KAAK,OAAO,CAAC;AAE/C,KAAK,YAAY,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACtB,CAAC;AAEF,KAAK,WAAW,GAAG;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;I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K,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,OAAO,GACf,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { getOrInsert } from "@gtkx/utils";
2
+ const ELEMENT_KIND = "element";
3
+ const PROP_KIND = "prop";
4
+ const TEXT_KIND = "text";
5
+ const LAZY_KIND = "lazy";
6
+ const DEFAULT_SLOT = "children";
7
+ const createPropNode = (slot) => ({
8
+ kind: PROP_KIND,
9
+ slot,
10
+ children: [],
11
+ parent: null,
12
+ });
13
+ const createLazyNode = (typeName, props, dispatch) => ({
14
+ kind: LAZY_KIND,
15
+ typeName,
16
+ props,
17
+ children: [],
18
+ parent: null,
19
+ adopted: null,
20
+ handlers: new Map(),
21
+ dispatch,
22
+ });
23
+ const createElementNode = (typeName, object, dispatch, contentKind) => ({
24
+ kind: ELEMENT_KIND,
25
+ typeName,
26
+ object,
27
+ props: {},
28
+ handlers: new Map(),
29
+ placements: new Map(),
30
+ contexts: new Map(),
31
+ parent: null,
32
+ content: [],
33
+ contentKind,
34
+ bufferView: null,
35
+ dispatch,
36
+ });
37
+ const createTextNode = (text) => ({ kind: TEXT_KIND, text, parent: null });
38
+ const nodeObject = (node) => {
39
+ if (node.kind === LAZY_KIND) {
40
+ const [child] = node.children;
41
+ return child === undefined ? null : nodeObject(child);
42
+ }
43
+ return node.object;
44
+ };
45
+ const lazyTarget = (node, adopted) => ({
46
+ object: adopted,
47
+ handlers: node.handlers,
48
+ typeName: node.typeName,
49
+ dispatch: node.dispatch,
50
+ });
51
+ const getOrCreateContext = (node, behavior) => getOrInsert(node.contexts, behavior, () => behavior.createContext?.(node.object));
52
+ export { ELEMENT_KIND, PROP_KIND, TEXT_KIND, LAZY_KIND, DEFAULT_SLOT, createPropNode, createLazyNode, createElementNode, createTextNode, nodeObject, lazyTarget, getOrCreateContext, };
53
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/reconciler/node.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgE1C,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,YAAY,GAAG,UAAU,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,CAAC;IAChD,IAAI,EAAE,SAAS;IACf,IAAI;IACJ,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,KAAY,EAAE,QAAkB,EAAY,EAAE,CAAC,CAAC;IACtF,IAAI,EAAE,SAAS;IACf,QAAQ;IACR,KAAK;IACL,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,QAAQ;CACX,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CACtB,QAAgB,EAChB,MAAsB,EACtB,QAAkB,EAClB,WAA+B,EACpB,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,YAAY;IAClB,QAAQ;IACR,MAAM;IACN,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,UAAU,EAAE,IAAI,GAAG,EAAE;IACrB,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,EAAE;IACX,WAAW;IACX,UAAU,EAAE,IAAI;IAChB,QAAQ;CACX,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAE7F,MAAM,UAAU,GAAG,CAAC,IAAmB,EAAyB,EAAE;IAC9D,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,IAAc,EAAE,OAAuB,EAAgB,EAAE,CAAC,CAAC;IAC3E,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;CAC1B,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAC,IAAiB,EAAE,QAAyB,EAAW,EAAE,CACjF,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtF,OAAO,EACH,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,EACV,kBAAkB,GAerB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { SignalHandler } from \"@gtkx/runtime\";\nimport { getOrInsert } from \"@gtkx/utils\";\nimport type { ElementBehavior, Props } from \"./registry.js\";\n\ntype ContentKind = \"label\" | \"buffer\" | \"tag\" | \"anchor\";\ntype HandlerRecord = { signal: string; handler: SignalHandler; wrapped: SignalHandler; blockable: boolean };\ntype Dispatch = (fn: () => unknown) => unknown;\n\ntype SignalTarget = {\n object: GObject.Object;\n handlers: Map<string, HandlerRecord>;\n typeName: string;\n dispatch: Dispatch;\n};\n\ntype PlacedChild = {\n node: PlaceableNode;\n object: GObject.Object;\n adopted: GObject.Object | null;\n slot: string;\n behavior: ElementBehavior | null;\n attached: boolean;\n};\n\ntype ElementNode = SignalTarget & {\n kind: typeof ELEMENT_KIND;\n props: Props;\n placements: Map<string, PlacedChild[]>;\n contexts: Map<ElementBehavior, unknown>;\n parent: ParentNode | null;\n content: ContentChild[];\n contentKind: ContentKind | null;\n bufferView: Gtk.TextView | null;\n};\n\ntype PropNode = {\n kind: typeof PROP_KIND;\n slot: string;\n children: PlaceableNode[];\n parent: ElementNode | null;\n};\n\ntype LazyNode = {\n kind: typeof LAZY_KIND;\n typeName: string;\n props: Props;\n children: PlaceableNode[];\n parent: ElementNode | null;\n adopted: GObject.Object | null;\n handlers: Map<string, HandlerRecord>;\n dispatch: Dispatch;\n};\n\ntype TextNode = {\n kind: typeof TEXT_KIND;\n text: string;\n parent: ParentNode | null;\n};\n\ntype PlaceableNode = ElementNode | LazyNode;\ntype ParentNode = ElementNode | PropNode | LazyNode;\ntype ContentChild = TextNode | ElementNode;\ntype Instance = ElementNode | PropNode | LazyNode;\ntype AnyNode = Instance | TextNode;\n\nconst ELEMENT_KIND = \"element\";\nconst PROP_KIND = \"prop\";\nconst TEXT_KIND = \"text\";\nconst LAZY_KIND = \"lazy\";\nconst DEFAULT_SLOT = \"children\";\n\nconst createPropNode = (slot: string): PropNode => ({\n kind: PROP_KIND,\n slot,\n children: [],\n parent: null,\n});\n\nconst createLazyNode = (typeName: string, props: Props, dispatch: Dispatch): LazyNode => ({\n kind: LAZY_KIND,\n typeName,\n props,\n children: [],\n parent: null,\n adopted: null,\n handlers: new Map(),\n dispatch,\n});\n\nconst createElementNode = (\n typeName: string,\n object: GObject.Object,\n dispatch: Dispatch,\n contentKind: ContentKind | null,\n): ElementNode => ({\n kind: ELEMENT_KIND,\n typeName,\n object,\n props: {},\n handlers: new Map(),\n placements: new Map(),\n contexts: new Map(),\n parent: null,\n content: [],\n contentKind,\n bufferView: null,\n dispatch,\n});\n\nconst createTextNode = (text: string): TextNode => ({ kind: TEXT_KIND, text, parent: null });\n\nconst nodeObject = (node: PlaceableNode): GObject.Object | null => {\n if (node.kind === LAZY_KIND) {\n const [child] = node.children;\n\n return child === undefined ? null : nodeObject(child);\n }\n\n return node.object;\n};\n\nconst lazyTarget = (node: LazyNode, adopted: GObject.Object): SignalTarget => ({\n object: adopted,\n handlers: node.handlers,\n typeName: node.typeName,\n dispatch: node.dispatch,\n});\n\nconst getOrCreateContext = (node: ElementNode, behavior: ElementBehavior): unknown =>\n getOrInsert(node.contexts, behavior, () => behavior.createContext?.(node.object));\n\nexport {\n ELEMENT_KIND,\n PROP_KIND,\n TEXT_KIND,\n LAZY_KIND,\n DEFAULT_SLOT,\n createPropNode,\n createLazyNode,\n createElementNode,\n createTextNode,\n nodeObject,\n lazyTarget,\n getOrCreateContext,\n type ContentKind,\n type HandlerRecord,\n type Dispatch,\n type SignalTarget,\n type PlacedChild,\n type ElementNode,\n type PropNode,\n type LazyNode,\n type TextNode,\n type PlaceableNode,\n type ParentNode,\n type ContentChild,\n type Instance,\n type AnyNode,\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import { type ElementNode, type PlaceableNode } from "./node.js";
2
+ declare const placeChild: (parent: ElementNode, slot: string, node: PlaceableNode, before: PlaceableNode | null) => void;
3
+ declare const unplaceChild: (parent: ElementNode, slot: string, node: PlaceableNode) => void;
4
+ export { placeChild, unplaceChild };
5
+ //# sourceMappingURL=placement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAMA,OAAO,EAGH,KAAK,WAAW,EAKhB,KAAK,aAAa,EAErB,MAAM,WAAW,CAAC;AA4MnB,QAAA,MAAM,UAAU,GACZ,QAAQ,WAAW,EACnB,MAAM,MAAM,EACZ,MAAM,aAAa,EACnB,QAAQ,aAAa,GAAG,IAAI,KAC7B,IAyBF,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,QAAQ,WAAW,EAAE,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,IAoB9E,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,191 @@
1
+ import * as GObject from "@gtkx/gi/gobject";
2
+ import * as Gtk from "@gtkx/gi/gtk";
3
+ import { getOrInsert, indexBeforeOrEnd, remove } from "@gtkx/utils";
4
+ import { applyAdoptedProps, markFlush } from "./apply-props.js";
5
+ import { typeInfoFor } from "./metadata.js";
6
+ import { DEFAULT_SLOT, ELEMENT_KIND, getOrCreateContext, LAZY_KIND, lazyTarget, nodeObject, } from "./node.js";
7
+ import { applyWrite } from "./signals.js";
8
+ import { markTextDirty } from "./text.js";
9
+ const createEntry = (slot, node) => {
10
+ const object = nodeObject(node);
11
+ if (object === null) {
12
+ return null;
13
+ }
14
+ return { node, object, adopted: null, slot, behavior: null, attached: false };
15
+ };
16
+ const siblingAt = (entries, index) => index > 0 ? (entries[index - 1]?.object ?? null) : null;
17
+ const placeInfo = (entry, index, sibling, context) => ({
18
+ slot: entry.slot,
19
+ index,
20
+ sibling,
21
+ adopted: entry.adopted,
22
+ props: entry.node.props,
23
+ context,
24
+ });
25
+ const adoptedFrom = (parent, entry, behavior, claim) => {
26
+ if (behavior.resolve !== undefined) {
27
+ entry.adopted = behavior.resolve(parent.object, entry.object);
28
+ return;
29
+ }
30
+ entry.adopted = claim instanceof GObject.Object ? claim : null;
31
+ };
32
+ const applyLazyProps = (entry) => {
33
+ if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {
34
+ return;
35
+ }
36
+ applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);
37
+ entry.node.adopted = entry.adopted;
38
+ };
39
+ const wireBufferView = (node, parent) => {
40
+ if (!(node.kind === ELEMENT_KIND && node.contentKind === "buffer" && parent.object instanceof Gtk.TextView)) {
41
+ return;
42
+ }
43
+ node.bufferView = parent.object;
44
+ markTextDirty(node);
45
+ };
46
+ const writeSlot = (parent, entry, value) => {
47
+ applyWrite(() => {
48
+ Reflect.set(parent.object, entry.slot, value);
49
+ });
50
+ };
51
+ const setObjectSlot = (parent, entry) => {
52
+ writeSlot(parent, entry, entry.object);
53
+ wireBufferView(entry.node, parent);
54
+ entry.behavior = null;
55
+ entry.attached = true;
56
+ };
57
+ const didAttach = (ctx, behavior) => {
58
+ const attach = behavior.attach;
59
+ if (attach === undefined) {
60
+ return false;
61
+ }
62
+ const context = getOrCreateContext(ctx.parent, behavior);
63
+ const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));
64
+ if (claim === undefined) {
65
+ return false;
66
+ }
67
+ ctx.entry.behavior = behavior;
68
+ adoptedFrom(ctx.parent, ctx.entry, behavior, claim);
69
+ ctx.entry.attached = true;
70
+ applyLazyProps(ctx.entry);
71
+ return true;
72
+ };
73
+ const runAttach = (parent, entry, index, sibling) => {
74
+ const ctx = { parent, entry, index, sibling };
75
+ for (const behavior of typeInfoFor(parent.typeName).behaviors) {
76
+ if (didAttach(ctx, behavior)) {
77
+ return;
78
+ }
79
+ }
80
+ if (entry.slot !== DEFAULT_SLOT) {
81
+ setObjectSlot(parent, entry);
82
+ }
83
+ };
84
+ const attachEntry = (parent, entry, index, sibling) => {
85
+ applyWrite(() => {
86
+ runAttach(parent, entry, index, sibling);
87
+ });
88
+ };
89
+ const detachInfo = (entry, context) => ({
90
+ slot: entry.slot,
91
+ adopted: entry.adopted,
92
+ props: entry.node.props,
93
+ context,
94
+ });
95
+ const runDetach = (parent, entry) => {
96
+ const behavior = entry.behavior;
97
+ if (behavior === null) {
98
+ if (entry.slot !== DEFAULT_SLOT) {
99
+ writeSlot(parent, entry, null);
100
+ }
101
+ return;
102
+ }
103
+ behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));
104
+ };
105
+ const detachEntry = (parent, entry) => {
106
+ if (!entry.attached) {
107
+ return;
108
+ }
109
+ entry.attached = false;
110
+ applyWrite(() => {
111
+ runDetach(parent, entry);
112
+ });
113
+ };
114
+ const rebuild = (parent, entries) => {
115
+ for (const entry of entries) {
116
+ detachEntry(parent, entry);
117
+ }
118
+ for (const [index, entry] of entries.entries()) {
119
+ entry.behavior = null;
120
+ attachEntry(parent, entry, index, siblingAt(entries, index));
121
+ }
122
+ };
123
+ const getPosition = (entries, before) => indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);
124
+ const placeNew = (parent, entry, entries, index) => {
125
+ attachEntry(parent, entry, index, siblingAt(entries, index));
126
+ if (!entry.attached) {
127
+ remove(entries, entry);
128
+ return;
129
+ }
130
+ const isInsertedBeforeEnd = index < entries.length - 1;
131
+ const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;
132
+ if (isInsertedBeforeEnd && isCannotReorderInPlace) {
133
+ rebuild(parent, entries);
134
+ }
135
+ };
136
+ const moveEntry = (parent, entry, entries, index) => {
137
+ const behavior = entry.behavior;
138
+ const reorder = behavior?.reorder;
139
+ if (behavior === null || reorder === undefined) {
140
+ rebuild(parent, entries);
141
+ return;
142
+ }
143
+ const context = getOrCreateContext(parent, behavior);
144
+ const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));
145
+ adoptedFrom(parent, entry, behavior, claim);
146
+ applyLazyProps(entry);
147
+ };
148
+ const resolveEntry = (entries, existing, slot, node) => {
149
+ if (existing >= 0) {
150
+ return entries[existing] ?? null;
151
+ }
152
+ return createEntry(slot, node);
153
+ };
154
+ const placeChild = (parent, slot, node, before) => {
155
+ const entries = getOrInsert(parent.placements, slot, () => []);
156
+ const existing = entries.findIndex((entry) => entry.node === node);
157
+ const entry = resolveEntry(entries, existing, slot, node);
158
+ if (entry === null) {
159
+ return;
160
+ }
161
+ const isMove = existing !== -1;
162
+ if (isMove) {
163
+ entries.splice(existing, 1);
164
+ }
165
+ const index = getPosition(entries, before);
166
+ entries.splice(index, 0, entry);
167
+ if (isMove) {
168
+ moveEntry(parent, entry, entries, index);
169
+ }
170
+ else {
171
+ placeNew(parent, entry, entries, index);
172
+ }
173
+ markFlush(parent);
174
+ };
175
+ const unplaceChild = (parent, slot, node) => {
176
+ const entries = parent.placements.get(slot);
177
+ if (entries === undefined) {
178
+ return;
179
+ }
180
+ const index = entries.findIndex((entry) => entry.node === node);
181
+ if (index === -1) {
182
+ return;
183
+ }
184
+ const [entry] = entries.splice(index, 1);
185
+ if (entry !== undefined) {
186
+ detachEntry(parent, entry);
187
+ }
188
+ markFlush(parent);
189
+ };
190
+ export { placeChild, unplaceChild };
191
+ //# sourceMappingURL=placement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GAGb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW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B,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd, remove } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n nodeObject,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const object = nodeObject(node);\n\n if (object === null) {\n return null;\n }\n\n return { node, object, adopted: null, slot, behavior: null, attached: false };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst writeSlot = (parent: ElementNode, entry: PlacedChild, value: GObject.Object | null): void => {\n applyWrite(() => {\n Reflect.set(parent.object, entry.slot, value);\n });\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n writeSlot(parent, entry, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n entry.attached = true;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n ctx.entry.attached = true;\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst runAttach = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot !== DEFAULT_SLOT) {\n setObjectSlot(parent, entry);\n }\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n applyWrite(() => {\n runAttach(parent, entry, index, sibling);\n });\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst runDetach = (parent: ElementNode, entry: PlacedChild): void => {\n const behavior = entry.behavior;\n\n if (behavior === null) {\n if (entry.slot !== DEFAULT_SLOT) {\n writeSlot(parent, entry, null);\n }\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n if (!entry.attached) {\n return;\n }\n\n entry.attached = false;\n\n applyWrite(() => {\n runDetach(parent, entry);\n });\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n\n if (!entry.attached) {\n remove(entries, entry);\n\n return;\n }\n\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}