@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,192 +0,0 @@
1
- /// <reference types="@gtkx/config/env" />
2
-
3
- import { ELEMENT_PROPS } from "virtual:gtkx-config";
4
- import type { AppliedProp, Arg, ArgRef, Call, ContainerProp } from "@gtkx/config";
5
- import { typeFromName } from "@gtkx/gi/gobject";
6
- import { callMethod } from "@gtkx/utils";
7
- import { collectTypeNamesWithInterfaces, foldInheritedTableWithInterfaces } from "../utils/gtype.js";
8
-
9
- export type CallScope = {
10
- child?: unknown;
11
- item?: unknown;
12
- index?: number;
13
- sibling?: unknown;
14
- adopted?: unknown;
15
- props?: Record<string, unknown>;
16
- };
17
-
18
- const MISSING_ARG = Symbol("gtkx.missing-arg");
19
-
20
- const fieldOf = (source: unknown, name: string): unknown =>
21
- source == null ? undefined : Reflect.get(Object(source), name);
22
-
23
- const evalArg = (arg: Arg, scope: CallScope): unknown => {
24
- if (typeof arg === "string") {
25
- switch (arg) {
26
- case "child":
27
- return scope.child;
28
- case "item":
29
- return scope.item;
30
- case "index":
31
- return scope.index;
32
- case "sibling":
33
- return scope.sibling;
34
- case "adopted":
35
- return scope.adopted;
36
- }
37
- }
38
- if ("literal" in arg) return arg.literal;
39
- if ("prop" in arg) {
40
- const value = scope.props?.[arg.prop];
41
- return value == null ? MISSING_ARG : value;
42
- }
43
- const value = fieldOf(scope.item, arg.field);
44
- if (value == null && "or" in arg) return arg.or;
45
- return value;
46
- };
47
-
48
- type CallResult = {
49
- called: boolean;
50
- value: unknown;
51
- };
52
-
53
- export const runCallValue = (target: object, call: Call, defaults: unknown[], scope: CallScope): CallResult => {
54
- if (typeof call === "string") {
55
- return { called: true, value: callMethod(target, call, defaults) };
56
- }
57
- const args = call.args.map((arg) => evalArg(arg, scope));
58
- if (args.includes(MISSING_ARG)) return { called: false, value: undefined };
59
- return { called: true, value: callMethod(target, call.method, args) };
60
- };
61
-
62
- export const runCall = (target: object, call: Call, defaults: unknown[], scope: CallScope): boolean =>
63
- runCallValue(target, call, defaults, scope).called;
64
-
65
- export const callUsesRef = (call: Call | undefined, ref: ArgRef): boolean =>
66
- call !== undefined && typeof call !== "string" && call.args.some((arg) => arg === ref);
67
-
68
- export const nullSetterCurrentHolder = (target: object, call: Call): unknown => {
69
- if (typeof call === "string" || !call.method.startsWith("set")) return undefined;
70
- if (!call.args.some((arg) => typeof arg === "object" && "literal" in arg && arg.literal === null)) {
71
- return undefined;
72
- }
73
- const getter = `get${call.method.slice(3)}`;
74
- if (typeof Reflect.get(target, getter) !== "function") return undefined;
75
- return callMethod(target, getter, []);
76
- };
77
-
78
- const attachIndex = new Map<string, ContainerProp>();
79
- const adoptByParent = new Map<string, ContainerProp>();
80
- const namedContainerPropsByParent: Record<string, string[]> = {};
81
- const APPLIED_BY_TYPE: Record<string, AppliedProp[]> = {};
82
-
83
- for (const [parent, props] of Object.entries(ELEMENT_PROPS)) {
84
- for (const prop of props) {
85
- if (prop.kind === "container") {
86
- attachIndex.set(`${parent}:${prop.child}:${prop.prop === "children" ? "" : prop.prop}`, prop);
87
- if (prop.prop !== "children") {
88
- const propNames = namedContainerPropsByParent[parent] ?? [];
89
- propNames.push(prop.prop);
90
- namedContainerPropsByParent[parent] = propNames;
91
- }
92
- if (prop.adopt !== undefined) adoptByParent.set(parent, prop);
93
- } else {
94
- const applied = APPLIED_BY_TYPE[parent] ?? [];
95
- applied.push(prop);
96
- APPLIED_BY_TYPE[parent] = applied;
97
- }
98
- }
99
- }
100
-
101
- const attachCache = new Map<string, ContainerProp | null>();
102
-
103
- export const resolveContainerProp = (
104
- parentType: bigint,
105
- childType: bigint,
106
- propName: string | undefined,
107
- ): ContainerProp | null => {
108
- const cacheKey = `${parentType}:${childType}:${propName ?? ""}`;
109
- const cached = attachCache.get(cacheKey);
110
- if (cached !== undefined) return cached;
111
- let resolved: ContainerProp | null = null;
112
- const parentNames = collectTypeNamesWithInterfaces(parentType);
113
- for (const childName of collectTypeNamesWithInterfaces(childType)) {
114
- for (const parentName of parentNames) {
115
- resolved = attachIndex.get(`${parentName}:${childName}:${propName ?? ""}`) ?? null;
116
- if (resolved !== null) break;
117
- }
118
- if (resolved !== null) break;
119
- }
120
- attachCache.set(cacheKey, resolved);
121
- return resolved;
122
- };
123
-
124
- const adoptCache = new Map<bigint, ContainerProp | null>();
125
-
126
- export const adoptContainerPropFor = (parentType: bigint): ContainerProp | null => {
127
- const cached = adoptCache.get(parentType);
128
- if (cached !== undefined) return cached;
129
- let resolved: ContainerProp | null = null;
130
- for (const name of collectTypeNamesWithInterfaces(parentType)) {
131
- const cp = adoptByParent.get(name);
132
- if (cp !== undefined) {
133
- resolved = cp;
134
- break;
135
- }
136
- }
137
- adoptCache.set(parentType, resolved);
138
- return resolved;
139
- };
140
-
141
- const containerPropNamesCache = new Map<string, Set<string>>();
142
-
143
- export const containerPropNamesFor = (elementName: string): Set<string> => {
144
- const cached = containerPropNamesCache.get(elementName);
145
- if (cached) return cached;
146
- const names = foldInheritedTableWithInterfaces(
147
- typeFromName(elementName),
148
- namedContainerPropsByParent,
149
- (collected: Set<string>, propNames) => {
150
- for (const name of propNames) collected.add(name);
151
- return collected;
152
- },
153
- new Set<string>(),
154
- );
155
- containerPropNamesCache.set(elementName, names);
156
- return names;
157
- };
158
-
159
- const appliedCache = new Map<bigint, Map<string, AppliedProp>>();
160
-
161
- export const appliedPropsFor = (gtype: bigint): Map<string, AppliedProp> => {
162
- const cached = appliedCache.get(gtype);
163
- if (cached) return cached;
164
- const resolved = foldInheritedTableWithInterfaces<AppliedProp[], Map<string, AppliedProp>>(
165
- gtype,
166
- APPLIED_BY_TYPE,
167
- (collected, props) => {
168
- for (const prop of props) {
169
- if (!collected.has(prop.prop)) collected.set(prop.prop, prop);
170
- }
171
- return collected;
172
- },
173
- new Map(),
174
- );
175
- appliedCache.set(gtype, resolved);
176
- return resolved;
177
- };
178
-
179
- export const isAppliedProp = (gtype: bigint, name: string): boolean => appliedPropsFor(gtype).has(name);
180
-
181
- const constructionSkipCache = new Map<bigint, Set<string>>();
182
-
183
- export const constructionSkipProps = (gtype: bigint): Set<string> => {
184
- const cached = constructionSkipCache.get(gtype);
185
- if (cached) return cached;
186
- const skipped = new Set<string>();
187
- for (const prop of appliedPropsFor(gtype).values()) {
188
- if (prop.kind === "lazy") skipped.add(prop.prop);
189
- }
190
- constructionSkipCache.set(gtype, skipped);
191
- return skipped;
192
- };
@@ -1,26 +0,0 @@
1
- import * as Gtk from "@gtkx/gi/gtk";
2
- import { scheduleContentRebuild } from "./content-rebuild.js";
3
- import { type Node, stateOf } from "./state.js";
4
- import { isLabelTextNode } from "./text-node.js";
5
-
6
- const rebuildLabelText = (owner: Gtk.Label): void => {
7
- const state = stateOf(owner);
8
- const runs = state.children.filter(isLabelTextNode);
9
- if (state.props.label !== undefined) {
10
- if (runs.length === 0) 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
-
20
- export const scheduleLabelTextRebuild = (node: Node): void => {
21
- scheduleContentRebuild(
22
- node,
23
- (candidate): candidate is Gtk.Label => candidate instanceof Gtk.Label,
24
- (owner) => () => rebuildLabelText(owner),
25
- );
26
- };
@@ -1,28 +0,0 @@
1
- import type { ReactNode, ReactPortal } from "react";
2
- import type { Container } from "./types.js";
3
-
4
- type ObjectPortal = ReactPortal & {
5
- $$typeof: symbol;
6
- containerInfo: Container;
7
- implementation: null;
8
- };
9
-
10
- /**
11
- * Creates a React portal that renders `children` into a different container in the widget tree.
12
- *
13
- * @param children The nodes to render inside the container.
14
- * @param container The GObject or root element to render into.
15
- * @param key An optional React key for the portal.
16
- */
17
- export const createPortal = (children: ReactNode, container: Container, key?: string | null): ReactPortal => {
18
- const portal: ObjectPortal = {
19
- $$typeof: Symbol.for("react.portal"),
20
- type: "",
21
- props: { children },
22
- key: key ?? null,
23
- children,
24
- containerInfo: container,
25
- implementation: null,
26
- };
27
- return portal;
28
- };
@@ -1,29 +0,0 @@
1
- import { createLogger, type Logger } from "@gtkx/utils";
2
-
3
- export const log: Logger = createLogger("react");
4
-
5
- export type ReconcilerErrorHandler = (error: unknown) => void;
6
-
7
- let errorHandler: ReconcilerErrorHandler | null = null;
8
-
9
- export function setReconcilerErrorHandler(handler: ReconcilerErrorHandler | null): ReconcilerErrorHandler | null {
10
- const prior = errorHandler;
11
- errorHandler = handler;
12
- return prior;
13
- }
14
-
15
- export function reportReconcilerError(error: unknown): void {
16
- if (errorHandler) {
17
- errorHandler(error);
18
- return;
19
- }
20
- log.error("unhandled reconciler error", error);
21
- }
22
-
23
- export function catchReconcilerError(fn: () => void): void {
24
- try {
25
- fn();
26
- } catch (error) {
27
- reportReconcilerError(error);
28
- }
29
- }
@@ -1,57 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { reconciler } from "./reconciler.js";
3
- import type { Container } from "./types.js";
4
-
5
- const noop = (): void => {};
6
-
7
- type FiberRoot = ReturnType<typeof reconciler.createContainer>;
8
-
9
- type ReconcilerErrorCallback = (error: Error, info: { componentStack?: string | null }) => void;
10
-
11
- export type ReconcilerRootOptions = {
12
- containerInfo: Container;
13
- onUncaughtError: ReconcilerErrorCallback;
14
- onCaughtError: ReconcilerErrorCallback;
15
- onRecoverableError?: ReconcilerErrorCallback;
16
- };
17
-
18
- export type ReconcilerRoot = {
19
- update(element: ReactNode): void;
20
- unmount<R>(free: (root: ReconcilerRoot) => R): R | undefined;
21
- };
22
-
23
- const activeRoots = new Set<ReconcilerRoot>();
24
-
25
- export const createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {
26
- const fiberRoot: FiberRoot = reconciler.createContainer(
27
- options.containerInfo,
28
- 1,
29
- null,
30
- false,
31
- null,
32
- "",
33
- options.onUncaughtError,
34
- options.onCaughtError,
35
- options.onRecoverableError ?? noop,
36
- noop,
37
- );
38
-
39
- const root: ReconcilerRoot = {
40
- update: (element: ReactNode): void => {
41
- reconciler.updateContainer(element, fiberRoot, null, noop);
42
- },
43
- unmount: <R>(free: (root: ReconcilerRoot) => R): R | undefined => {
44
- if (!activeRoots.delete(root)) return undefined;
45
- return free(root);
46
- },
47
- };
48
-
49
- activeRoots.add(root);
50
- return root;
51
- };
52
-
53
- export const unmountAllReconcilerRoots = (free: (root: ReconcilerRoot) => void): void => {
54
- const roots = [...activeRoots];
55
- activeRoots.clear();
56
- roots.forEach(free);
57
- };
@@ -1,13 +0,0 @@
1
- import ReactReconciler from "react-reconciler";
2
- import packageJson from "../../package.json" with { type: "json" };
3
- import { createHostConfig, type ReconcilerInstance } from "./host-config.js";
4
-
5
- export const reconciler: ReconcilerInstance = ReactReconciler(createHostConfig());
6
-
7
- if (process.env.NODE_ENV !== "production") {
8
- reconciler.injectIntoDevTools({
9
- bundleType: 1,
10
- version: packageJson.version,
11
- rendererPackageName: "@gtkx/react",
12
- });
13
- }
@@ -1,61 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { log, type ReconcilerErrorHandler, setReconcilerErrorHandler } from "./reconciler-error-handler.js";
3
- import { createReconcilerRoot, type ReconcilerRoot, unmountAllReconcilerRoots } from "./reconciler-root.js";
4
- import { type RootElement, rootElement } from "./root-element.js";
5
- import { getSignalStore } from "./signal-store.js";
6
-
7
- const priorHandlers = new WeakMap<ReconcilerRoot, ReconcilerErrorHandler | null>();
8
-
9
- const teardownRoot = (root: ReconcilerRoot): void => {
10
- setReconcilerErrorHandler(priorHandlers.get(root) ?? null);
11
- root.update(null);
12
- };
13
-
14
- /**
15
- * A render root that mounts a React element tree into a container and can unmount it.
16
- */
17
- export type Root = {
18
- render(element: ReactNode): void;
19
- unmount(): void;
20
- };
21
-
22
- /**
23
- * Creates a render root for a container, wiring reconciler error handling to the container's signal store.
24
- *
25
- * @param container The root element to render into; defaults to the shared `rootElement`.
26
- * @returns A root with `render` and `unmount` methods.
27
- */
28
- export const createRoot = (container: RootElement = rootElement): Root => {
29
- const onUncaughtError = (error: unknown): void => {
30
- getSignalStore(container).unblock();
31
- throw error;
32
- };
33
- const onCaughtError = (error: unknown): void => {
34
- getSignalStore(container).unblock();
35
- log.error("caught render error", error);
36
- };
37
-
38
- const priorHandler = setReconcilerErrorHandler(onUncaughtError);
39
-
40
- const root = createReconcilerRoot({ containerInfo: container, onUncaughtError, onCaughtError });
41
- priorHandlers.set(root, priorHandler);
42
-
43
- return {
44
- render: (element: ReactNode): void => {
45
- root.update(element);
46
- },
47
- unmount: (): void => {
48
- root.unmount(teardownRoot);
49
- },
50
- };
51
- };
52
-
53
- /**
54
- * Unmounts all active render roots.
55
- *
56
- * @returns `true` once every root has been torn down.
57
- */
58
- export const quit = (): true => {
59
- unmountAllReconcilerRoots(teardownRoot);
60
- return true;
61
- };
@@ -1,103 +0,0 @@
1
- import type * as GObject from "@gtkx/gi/gobject";
2
- import type { SignalHandler } from "@gtkx/runtime";
3
-
4
- const UNBLOCKED_SIGNALS = new Set([
5
- "realize",
6
- "unrealize",
7
- "map",
8
- "unmap",
9
- "show",
10
- "hide",
11
- "destroy",
12
- "resize",
13
- "render",
14
- "input",
15
- "output",
16
- ]);
17
-
18
- type SignalBinding = {
19
- instance: GObject.Object;
20
- signal: string;
21
- handler?: SignalHandler | undefined;
22
- };
23
-
24
- export class SignalStore {
25
- private instanceHandlers: Map<GObject.Object, Map<string, number>> = new Map();
26
-
27
- private blockDepth: number = 0;
28
-
29
- private getInstanceMap(instance: GObject.Object): Map<string, number> {
30
- let instanceMap = this.instanceHandlers.get(instance);
31
- if (!instanceMap) {
32
- instanceMap = new Map();
33
- this.instanceHandlers.set(instance, instanceMap);
34
- }
35
- return instanceMap;
36
- }
37
-
38
- private gateHandler(handler: SignalHandler, signal: string, instance: GObject.Object): SignalHandler {
39
- return (...args: unknown[]) => {
40
- if (this.blockDepth > 0 && !UNBLOCKED_SIGNALS.has(signal)) {
41
- return;
42
- }
43
- return handler(...args, instance);
44
- };
45
- }
46
-
47
- private disconnect(instance: GObject.Object, signal: string): void {
48
- const instanceMap = this.instanceHandlers.get(instance);
49
- if (!instanceMap) return;
50
- const handlerId = instanceMap.get(signal);
51
- if (handlerId === undefined) return;
52
- instance.disconnect(handlerId);
53
- instanceMap.delete(signal);
54
- if (instanceMap.size === 0) this.instanceHandlers.delete(instance);
55
- }
56
-
57
- private connect(binding: SignalBinding & { handler: SignalHandler }): void {
58
- const { instance, signal, handler } = binding;
59
- const gatedHandler = this.gateHandler(handler, signal, instance);
60
- const handlerId = instance.connect(signal, gatedHandler);
61
- this.getInstanceMap(instance).set(signal, handlerId);
62
- }
63
-
64
- public set(binding: SignalBinding): void {
65
- const { instance, signal, handler } = binding;
66
- this.disconnect(instance, signal);
67
-
68
- if (handler) {
69
- this.connect({ instance, signal, handler });
70
- }
71
- }
72
-
73
- public clear(instance: GObject.Object): void {
74
- const instanceMap = this.instanceHandlers.get(instance);
75
-
76
- if (instanceMap) {
77
- for (const [, handlerId] of instanceMap) {
78
- instance.disconnect(handlerId);
79
- }
80
-
81
- this.instanceHandlers.delete(instance);
82
- }
83
- }
84
-
85
- public block(): void {
86
- this.blockDepth += 1;
87
- }
88
-
89
- public unblock(): void {
90
- if (this.blockDepth > 0) this.blockDepth -= 1;
91
- }
92
- }
93
-
94
- const signalStores = new WeakMap<object, SignalStore>();
95
-
96
- export function getSignalStore(rootContainer: object): SignalStore {
97
- let store = signalStores.get(rootContainer);
98
- if (!store) {
99
- store = new SignalStore();
100
- signalStores.set(rootContainer, store);
101
- }
102
- return store;
103
- }
@@ -1,72 +0,0 @@
1
- import * as GObject from "@gtkx/gi/gobject";
2
- import { isRootElement, type RootElement } from "./root-element.js";
3
- import { getSignalStore, type SignalStore } from "./signal-store.js";
4
- import type { Container, Props } from "./types.js";
5
- import { isWrapperNode, type WrapperNode } from "./wrapper-node.js";
6
- import type { WrapperKind } from "./wrapper-protocol.js";
7
-
8
- export type Node = GObject.Object | WrapperNode | RootElement;
9
-
10
- export type ElementHandler = {
11
- attach(anchor?: GObject.Object | null, fresh?: boolean): void;
12
- detach(): void;
13
- };
14
-
15
- export type ElementMapping = (child: Node, parent: Node) => ElementHandler | null;
16
-
17
- export type State = {
18
- kind?: WrapperKind | undefined;
19
- props: Props;
20
- parent: Node | null;
21
- children: Node[];
22
- rootContainer: Container;
23
- signalStore: SignalStore;
24
- adoptedInstance?: GObject.Object | undefined;
25
- hidden?: boolean | undefined;
26
- visibleWhenShown?: boolean | undefined;
27
- };
28
-
29
- const stateMap = new WeakMap<Node, State>();
30
-
31
- type StateSeed = {
32
- kind?: WrapperKind;
33
- props: Props;
34
- rootContainer: Container;
35
- };
36
-
37
- export const registerState = (node: Node, { kind, props, rootContainer }: StateSeed): State => {
38
- const state: State = {
39
- kind,
40
- props,
41
- parent: null,
42
- children: [],
43
- rootContainer,
44
- signalStore: getSignalStore(rootContainer),
45
- };
46
- stateMap.set(node, state);
47
- return state;
48
- };
49
-
50
- export const ensureState = (container: Container): State =>
51
- stateMap.get(container) ?? registerState(container, { props: {}, rootContainer: container });
52
-
53
- export const registeredStateOf = (node: Node): State | undefined => stateMap.get(node);
54
-
55
- export const stateOf = (node: Node): State => {
56
- const state = stateMap.get(node);
57
- if (state) return state;
58
- if (node instanceof GObject.Object || isRootElement(node)) return ensureState(node);
59
- throw new Error("reconciler node has no registered state");
60
- };
61
-
62
- export const hasWrapperKind = (node: Node, kind: WrapperKind): boolean =>
63
- isWrapperNode(node) && stateOf(node).kind === kind;
64
-
65
- export const closestInstance = <T extends Node>(node: Node, matches: (node: Node) => node is T): T | null => {
66
- let current: Node | null = node;
67
- while (current !== null) {
68
- if (matches(current)) return current;
69
- current = stateOf(current).parent;
70
- }
71
- return null;
72
- };
@@ -1,107 +0,0 @@
1
- import type * as Gdk from "@gtkx/gi/gdk";
2
- import * as GObject from "@gtkx/gi/gobject";
3
- import * as Gtk from "@gtkx/gi/gtk";
4
- import { unparentWidget } from "./container-attach.js";
5
- import { type Node, stateOf } from "./state.js";
6
- import { isAnchorNode, isBufferContentNode, isBufferTextNode, isPaintableNode } from "./text-node.js";
7
-
8
- export class TextBufferController {
9
- private managesContent = false;
10
- private owner: Gtk.TextBuffer;
11
-
12
- constructor(owner: Gtk.TextBuffer) {
13
- this.owner = owner;
14
- }
15
-
16
- private resolveView(): Gtk.TextView | null {
17
- let ancestor = stateOf(this.owner).parent;
18
- while (ancestor && !(ancestor instanceof GObject.Object)) ancestor = stateOf(ancestor).parent;
19
- return ancestor instanceof Gtk.TextView ? ancestor : null;
20
- }
21
-
22
- private hasManagedChildren(): boolean {
23
- return stateOf(this.owner).children.some((child) => isBufferContentNode(child) || child instanceof Gtk.TextTag);
24
- }
25
-
26
- public rebuild = (): void => {
27
- const buffer = this.owner;
28
-
29
- if (this.hasManagedChildren()) this.managesContent = true;
30
- if (!this.managesContent) return;
31
-
32
- const state = stateOf(this.owner);
33
- buffer.beginIrreversibleAction();
34
- try {
35
- this.clearBuffer(buffer);
36
- this.insertChildren(buffer, state.children);
37
- } finally {
38
- buffer.endIrreversibleAction();
39
- }
40
- };
41
-
42
- private clearBuffer(buffer: Gtk.TextBuffer): void {
43
- const start = buffer.getStartIter();
44
- const end = buffer.getEndIter();
45
- if (!start.equal(end)) buffer.delete(start, end);
46
-
47
- const tagTable = buffer.getTagTable();
48
- const tags: Gtk.TextTag[] = [];
49
- tagTable.foreach((tag) => tags.push(tag));
50
- for (const tag of tags) tagTable.remove(tag);
51
- }
52
-
53
- private insertChildren(buffer: Gtk.TextBuffer, children: Node[]): void {
54
- for (const child of children) {
55
- this.insertChild(buffer, child);
56
- }
57
- }
58
-
59
- private insertChild(buffer: Gtk.TextBuffer, child: Node): void {
60
- if (stateOf(child).hidden) return;
61
- if (isBufferTextNode(child)) {
62
- this.insertText(buffer, stateOf(child).props.text as string);
63
- } else if (isPaintableNode(child)) {
64
- this.insertPaintable(buffer, stateOf(child).props.paintable as Gdk.Paintable);
65
- } else if (isAnchorNode(child)) {
66
- this.insertAnchor(buffer, child);
67
- } else if (child instanceof Gtk.TextTag) {
68
- this.insertTag(buffer, child);
69
- }
70
- }
71
-
72
- private insertTag(buffer: Gtk.TextBuffer, tag: Gtk.TextTag): void {
73
- const tagTable = buffer.getTagTable();
74
- if (tag.name && !tagTable.lookup(tag.name)) tagTable.add(tag);
75
-
76
- const start = buffer.getCharCount();
77
- this.insertChildren(buffer, stateOf(tag).children);
78
- const end = buffer.getCharCount();
79
- if (end > start) {
80
- buffer.applyTag(tag, buffer.getIterAtOffset(start), buffer.getIterAtOffset(end));
81
- }
82
- }
83
-
84
- private insertAnchor(buffer: Gtk.TextBuffer, node: Node): void {
85
- const child = stateOf(node).children[0];
86
- const replacement = stateOf(node).props.replacementChar;
87
- const anchor =
88
- typeof replacement === "string"
89
- ? Gtk.TextChildAnchor.newWithReplacement(replacement)
90
- : Gtk.TextChildAnchor.new();
91
- buffer.insertChildAnchor(buffer.getEndIter(), anchor);
92
- const view = this.resolveView();
93
- if (view && child instanceof Gtk.Widget) {
94
- unparentWidget(child);
95
- view.addChildAtAnchor(child, anchor);
96
- }
97
- }
98
-
99
- private insertPaintable(buffer: Gtk.TextBuffer, paintable: Gdk.Paintable): void {
100
- buffer.insertPaintable(buffer.getEndIter(), paintable);
101
- }
102
-
103
- private insertText(buffer: Gtk.TextBuffer, text: string): void {
104
- if (text.length === 0) return;
105
- buffer.insert(buffer.getEndIter(), text, -1);
106
- }
107
- }