@gtkx/react 0.21.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -34
- package/dist/adw/config.d.ts +2 -0
- package/dist/adw/config.d.ts.map +1 -0
- package/dist/adw/config.js +2 -0
- package/dist/adw/config.js.map +1 -0
- package/dist/adw/dialog.d.ts +8 -0
- package/dist/adw/dialog.d.ts.map +1 -0
- package/dist/adw/dialog.js +25 -0
- package/dist/adw/dialog.js.map +1 -0
- package/dist/adw/element-behaviors.d.ts +2 -0
- package/dist/adw/element-behaviors.d.ts.map +1 -0
- package/dist/adw/element-behaviors.js +299 -0
- package/dist/adw/element-behaviors.js.map +1 -0
- package/dist/adw/element-config.d.ts +9 -0
- package/dist/adw/element-config.d.ts.map +1 -0
- package/dist/adw/element-config.js +137 -0
- package/dist/adw/element-config.js.map +1 -0
- package/dist/adw/index.d.ts +4 -0
- package/dist/adw/index.d.ts.map +1 -0
- package/dist/adw/index.js +3 -0
- package/dist/adw/index.js.map +1 -0
- package/dist/adw/prop-types.d.ts +29 -0
- package/dist/adw/prop-types.d.ts.map +1 -0
- package/dist/adw/prop-types.js +2 -0
- package/dist/adw/prop-types.js.map +1 -0
- package/dist/bootstrap.d.ts +2 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +5 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/components/application.d.ts +10 -0
- package/dist/components/application.d.ts.map +1 -0
- package/dist/components/application.js +39 -0
- package/dist/components/application.js.map +1 -0
- package/dist/components/element.d.ts +6 -0
- package/dist/components/element.d.ts.map +1 -0
- package/dist/components/element.js +29 -0
- package/dist/components/element.js.map +1 -0
- package/dist/components/window.d.ts +8 -0
- package/dist/components/window.d.ts.map +1 -0
- package/dist/components/window.js +22 -0
- package/dist/components/window.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/element-behaviors.d.ts +2 -0
- package/dist/element-behaviors.d.ts.map +1 -0
- package/dist/element-behaviors.js +348 -0
- package/dist/element-behaviors.js.map +1 -0
- package/dist/element-config.d.ts +10 -0
- package/dist/element-config.d.ts.map +1 -0
- package/dist/element-config.js +146 -0
- package/dist/element-config.js.map +1 -0
- package/dist/hooks/use-application.d.ts +9 -0
- package/dist/hooks/use-application.d.ts.map +1 -0
- package/dist/hooks/use-application.js +14 -0
- package/dist/hooks/use-application.js.map +1 -0
- package/dist/hooks/use-bind-setting.d.ts +23 -0
- package/dist/hooks/use-bind-setting.d.ts.map +1 -0
- package/dist/hooks/use-bind-setting.js +30 -0
- package/dist/hooks/use-bind-setting.js.map +1 -0
- package/dist/hooks/use-merged-refs.d.ts +8 -0
- package/dist/hooks/use-merged-refs.d.ts.map +1 -0
- package/dist/hooks/use-merged-refs.js +48 -0
- package/dist/hooks/use-merged-refs.js.map +1 -0
- package/dist/hooks/use-object-value.d.ts +5 -0
- package/dist/hooks/use-object-value.d.ts.map +1 -0
- package/dist/hooks/use-object-value.js +29 -0
- package/dist/hooks/use-object-value.js.map +1 -0
- package/dist/hooks/use-parent-window.d.ts +9 -0
- package/dist/hooks/use-parent-window.d.ts.map +1 -0
- package/dist/hooks/use-parent-window.js +8 -0
- package/dist/hooks/use-parent-window.js.map +1 -0
- package/dist/hooks/use-property.d.ts +14 -0
- package/dist/hooks/use-property.d.ts.map +1 -0
- package/dist/hooks/use-property.js +14 -0
- package/dist/hooks/use-property.js.map +1 -0
- package/dist/hooks/use-setting.d.ts +14 -0
- package/dist/hooks/use-setting.d.ts.map +1 -0
- package/dist/hooks/use-setting.js +20 -0
- package/dist/hooks/use-setting.js.map +1 -0
- package/dist/hooks/use-signal.d.ts +24 -0
- package/dist/hooks/use-signal.d.ts.map +1 -0
- package/dist/hooks/use-signal.js +31 -0
- package/dist/hooks/use-signal.js.map +1 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +12 -0
- package/dist/internal.js.map +1 -0
- package/dist/prop-types.d.ts +110 -0
- package/dist/prop-types.d.ts.map +1 -0
- package/dist/prop-types.js +2 -0
- package/dist/prop-types.js.map +1 -0
- package/dist/reconciler/apply-props.d.ts +11 -0
- package/dist/reconciler/apply-props.d.ts.map +1 -0
- package/dist/reconciler/apply-props.js +190 -0
- package/dist/reconciler/apply-props.js.map +1 -0
- package/dist/reconciler/behaviors.d.ts +59 -0
- package/dist/reconciler/behaviors.d.ts.map +1 -0
- package/dist/reconciler/behaviors.js +172 -0
- package/dist/reconciler/behaviors.js.map +1 -0
- package/dist/reconciler/child-routing.d.ts +5 -0
- package/dist/reconciler/child-routing.d.ts.map +1 -0
- package/dist/reconciler/child-routing.js +156 -0
- package/dist/reconciler/child-routing.js.map +1 -0
- package/dist/reconciler/host-config.d.ts +9 -0
- package/dist/reconciler/host-config.d.ts.map +1 -0
- package/dist/reconciler/host-config.js +214 -0
- package/dist/reconciler/host-config.js.map +1 -0
- package/dist/reconciler/instance.d.ts +5 -0
- package/dist/reconciler/instance.d.ts.map +1 -0
- package/dist/reconciler/instance.js +49 -0
- package/dist/reconciler/instance.js.map +1 -0
- package/dist/reconciler/metadata.d.ts +17 -0
- package/dist/reconciler/metadata.d.ts.map +1 -0
- package/dist/reconciler/metadata.js +82 -0
- package/dist/reconciler/metadata.js.map +1 -0
- package/dist/reconciler/node.d.ts +76 -0
- package/dist/reconciler/node.d.ts.map +1 -0
- package/dist/reconciler/node.js +53 -0
- package/dist/reconciler/node.js.map +1 -0
- package/dist/reconciler/placement.d.ts +5 -0
- package/dist/reconciler/placement.d.ts.map +1 -0
- package/dist/reconciler/placement.js +175 -0
- package/dist/reconciler/placement.js.map +1 -0
- package/dist/reconciler/registry.d.ts +92 -0
- package/dist/reconciler/registry.d.ts.map +1 -0
- package/dist/reconciler/registry.js +64 -0
- package/dist/reconciler/registry.js.map +1 -0
- package/dist/reconciler/root-element.d.ts +11 -0
- package/dist/reconciler/root-element.d.ts.map +1 -0
- package/dist/reconciler/root-element.js +7 -0
- package/dist/reconciler/root-element.js.map +1 -0
- package/dist/reconciler/root.d.ts +56 -0
- package/dist/reconciler/root.d.ts.map +1 -0
- package/dist/reconciler/root.js +109 -0
- package/dist/reconciler/root.js.map +1 -0
- package/dist/reconciler/signals.d.ts +10 -0
- package/dist/reconciler/signals.d.ts.map +1 -0
- package/dist/reconciler/signals.js +70 -0
- package/dist/reconciler/signals.js.map +1 -0
- package/dist/reconciler/text.d.ts +19 -0
- package/dist/reconciler/text.d.ts.map +1 -0
- package/dist/reconciler/text.js +276 -0
- package/dist/reconciler/text.js.map +1 -0
- package/dist/utils/accessible-metadata.d.ts +12 -0
- package/dist/utils/accessible-metadata.d.ts.map +1 -0
- package/dist/utils/accessible-metadata.js +25 -0
- package/dist/utils/accessible-metadata.js.map +1 -0
- package/dist/utils/accessible-props.d.ts +60 -0
- package/dist/utils/accessible-props.d.ts.map +1 -0
- package/dist/utils/accessible-props.js +181 -0
- package/dist/utils/accessible-props.js.map +1 -0
- package/dist/utils/ref-prop.d.ts +15 -0
- package/dist/utils/ref-prop.d.ts.map +1 -0
- package/dist/utils/ref-prop.js +18 -0
- package/dist/utils/ref-prop.js.map +1 -0
- package/dist/utils/settings.d.ts +17 -0
- package/dist/utils/settings.d.ts.map +1 -0
- package/dist/utils/settings.js +37 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/variant.d.ts +57 -0
- package/dist/utils/variant.d.ts.map +1 -0
- package/dist/utils/variant.js +197 -0
- package/dist/utils/variant.js.map +1 -0
- package/env.d.ts +9 -0
- package/package.json +49 -10
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +35 -0
- package/src/adw/element-behaviors.ts +379 -0
- package/src/adw/element-config.ts +140 -0
- package/src/adw/index.ts +4 -0
- package/src/adw/prop-types.ts +42 -0
- package/src/bootstrap.ts +5 -0
- package/src/components/application.tsx +62 -0
- package/src/components/element.tsx +47 -0
- package/src/components/window.tsx +35 -0
- package/src/config.ts +3 -0
- package/src/element-behaviors.ts +424 -0
- package/src/element-config.ts +148 -0
- package/src/env.d.ts +1 -0
- package/src/hooks/use-application.ts +19 -0
- package/src/hooks/use-bind-setting.ts +51 -0
- package/src/hooks/use-merged-refs.ts +64 -0
- package/src/hooks/use-object-value.ts +54 -0
- package/src/hooks/use-parent-window.ts +11 -0
- package/src/hooks/use-property.ts +23 -0
- package/src/hooks/use-setting.ts +34 -0
- package/src/hooks/use-signal.ts +60 -0
- package/src/index.ts +14 -14
- package/src/internal.ts +13 -0
- package/src/prop-types.ts +142 -0
- package/src/reconciler/apply-props.ts +265 -0
- package/src/reconciler/behaviors.ts +324 -0
- package/src/reconciler/child-routing.ts +202 -0
- package/src/reconciler/host-config.ts +278 -0
- package/src/reconciler/instance.ts +82 -0
- package/src/reconciler/metadata.ts +119 -0
- package/src/reconciler/node.ts +161 -0
- package/src/reconciler/placement.ts +255 -0
- package/src/reconciler/registry.ts +161 -0
- package/src/reconciler/root-element.ts +12 -0
- package/src/reconciler/root.ts +175 -0
- package/src/reconciler/signals.ts +113 -0
- package/src/reconciler/text.ts +407 -0
- package/src/utils/accessible-metadata.ts +31 -0
- package/src/utils/accessible-props.ts +279 -0
- package/src/utils/ref-prop.ts +30 -0
- package/src/utils/settings.ts +69 -0
- package/src/utils/variant.ts +368 -0
- package/dist/components/compound.d.ts +0 -40
- package/dist/components/compound.d.ts.map +0 -1
- package/dist/components/compound.js +0 -46
- package/dist/components/compound.js.map +0 -1
- package/dist/components/list.d.ts +0 -75
- package/dist/components/list.d.ts.map +0 -1
- package/dist/components/list.js +0 -81
- package/dist/components/list.js.map +0 -1
- package/dist/components/slot-widget.d.ts +0 -15
- package/dist/components/slot-widget.d.ts.map +0 -1
- package/dist/components/slot-widget.js +0 -37
- package/dist/components/slot-widget.js.map +0 -1
- package/dist/errors.d.ts +0 -15
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -44
- package/dist/errors.js.map +0 -1
- package/dist/factory.d.ts +0 -5
- package/dist/factory.d.ts.map +0 -1
- package/dist/factory.js +0 -37
- package/dist/factory.js.map +0 -1
- package/dist/generated/compounds.d.ts +0 -2672
- package/dist/generated/compounds.d.ts.map +0 -1
- package/dist/generated/compounds.js +0 -2624
- package/dist/generated/compounds.js.map +0 -1
- package/dist/generated/internal.d.ts +0 -16
- package/dist/generated/internal.d.ts.map +0 -1
- package/dist/generated/internal.js +0 -3638
- package/dist/generated/internal.js.map +0 -1
- package/dist/generated/jsx.d.ts +0 -17074
- package/dist/generated/jsx.d.ts.map +0 -1
- package/dist/generated/jsx.js +0 -6715
- package/dist/generated/jsx.js.map +0 -1
- package/dist/generated/registry.d.ts +0 -5
- package/dist/generated/registry.d.ts.map +0 -1
- package/dist/generated/registry.js +0 -13
- package/dist/generated/registry.js.map +0 -1
- package/dist/host-config.d.ts +0 -24
- package/dist/host-config.d.ts.map +0 -1
- package/dist/host-config.js +0 -172
- package/dist/host-config.js.map +0 -1
- package/dist/jsx.d.ts +0 -974
- package/dist/jsx.d.ts.map +0 -1
- package/dist/jsx.js +0 -8
- package/dist/jsx.js.map +0 -1
- package/dist/metadata.d.ts +0 -5
- package/dist/metadata.d.ts.map +0 -1
- package/dist/metadata.js +0 -33
- package/dist/metadata.js.map +0 -1
- package/dist/node.d.ts +0 -25
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -85
- package/dist/node.js.map +0 -1
- package/dist/nodes/adjustable.d.ts +0 -11
- package/dist/nodes/adjustable.d.ts.map +0 -1
- package/dist/nodes/adjustable.js +0 -46
- package/dist/nodes/adjustable.js.map +0 -1
- package/dist/nodes/alert-dialog-response.d.ts +0 -15
- package/dist/nodes/alert-dialog-response.d.ts.map +0 -1
- package/dist/nodes/alert-dialog-response.js +0 -61
- package/dist/nodes/alert-dialog-response.js.map +0 -1
- package/dist/nodes/alert-dialog.d.ts +0 -14
- package/dist/nodes/alert-dialog.d.ts.map +0 -1
- package/dist/nodes/alert-dialog.js +0 -41
- package/dist/nodes/alert-dialog.js.map +0 -1
- package/dist/nodes/animation.d.ts +0 -39
- package/dist/nodes/animation.d.ts.map +0 -1
- package/dist/nodes/animation.js +0 -326
- package/dist/nodes/animation.js.map +0 -1
- package/dist/nodes/application.d.ts +0 -12
- package/dist/nodes/application.d.ts.map +0 -1
- package/dist/nodes/application.js +0 -51
- package/dist/nodes/application.js.map +0 -1
- package/dist/nodes/calendar.d.ts +0 -18
- package/dist/nodes/calendar.d.ts.map +0 -1
- package/dist/nodes/calendar.js +0 -28
- package/dist/nodes/calendar.js.map +0 -1
- package/dist/nodes/color-dialog-button.d.ts +0 -15
- package/dist/nodes/color-dialog-button.d.ts.map +0 -1
- package/dist/nodes/color-dialog-button.js +0 -43
- package/dist/nodes/color-dialog-button.js.map +0 -1
- package/dist/nodes/column-view-column.d.ts +0 -36
- package/dist/nodes/column-view-column.d.ts.map +0 -1
- package/dist/nodes/column-view-column.js +0 -168
- package/dist/nodes/column-view-column.js.map +0 -1
- package/dist/nodes/container-slot.d.ts +0 -18
- package/dist/nodes/container-slot.d.ts.map +0 -1
- package/dist/nodes/container-slot.js +0 -81
- package/dist/nodes/container-slot.js.map +0 -1
- package/dist/nodes/dialog.d.ts +0 -10
- package/dist/nodes/dialog.d.ts.map +0 -1
- package/dist/nodes/dialog.js +0 -20
- package/dist/nodes/dialog.js.map +0 -1
- package/dist/nodes/drawing-area.d.ts +0 -19
- package/dist/nodes/drawing-area.d.ts.map +0 -1
- package/dist/nodes/drawing-area.js +0 -40
- package/dist/nodes/drawing-area.js.map +0 -1
- package/dist/nodes/event-controller.d.ts +0 -15
- package/dist/nodes/event-controller.d.ts.map +0 -1
- package/dist/nodes/event-controller.js +0 -73
- package/dist/nodes/event-controller.js.map +0 -1
- package/dist/nodes/fixed-child.d.ts +0 -19
- package/dist/nodes/fixed-child.d.ts.map +0 -1
- package/dist/nodes/fixed-child.js +0 -99
- package/dist/nodes/fixed-child.js.map +0 -1
- package/dist/nodes/font-dialog-button.d.ts +0 -15
- package/dist/nodes/font-dialog-button.d.ts.map +0 -1
- package/dist/nodes/font-dialog-button.js +0 -76
- package/dist/nodes/font-dialog-button.js.map +0 -1
- package/dist/nodes/grid-child.d.ts +0 -19
- package/dist/nodes/grid-child.d.ts.map +0 -1
- package/dist/nodes/grid-child.js +0 -94
- package/dist/nodes/grid-child.js.map +0 -1
- package/dist/nodes/internal/accessible.d.ts +0 -5
- package/dist/nodes/internal/accessible.d.ts.map +0 -1
- package/dist/nodes/internal/accessible.js +0 -119
- package/dist/nodes/internal/accessible.js.map +0 -1
- package/dist/nodes/internal/bound-item.d.ts +0 -4
- package/dist/nodes/internal/bound-item.d.ts.map +0 -1
- package/dist/nodes/internal/bound-item.js +0 -2
- package/dist/nodes/internal/bound-item.js.map +0 -1
- package/dist/nodes/internal/construct.d.ts +0 -3
- package/dist/nodes/internal/construct.d.ts.map +0 -1
- package/dist/nodes/internal/construct.js +0 -44
- package/dist/nodes/internal/construct.js.map +0 -1
- package/dist/nodes/internal/predicates.d.ts +0 -51
- package/dist/nodes/internal/predicates.d.ts.map +0 -1
- package/dist/nodes/internal/predicates.js +0 -36
- package/dist/nodes/internal/predicates.js.map +0 -1
- package/dist/nodes/internal/props.d.ts +0 -6
- package/dist/nodes/internal/props.d.ts.map +0 -1
- package/dist/nodes/internal/props.js +0 -43
- package/dist/nodes/internal/props.js.map +0 -1
- package/dist/nodes/internal/signal-store.d.ts +0 -22
- package/dist/nodes/internal/signal-store.d.ts.map +0 -1
- package/dist/nodes/internal/signal-store.js +0 -98
- package/dist/nodes/internal/signal-store.js.map +0 -1
- package/dist/nodes/internal/text-buffer-controller.d.ts +0 -40
- package/dist/nodes/internal/text-buffer-controller.d.ts.map +0 -1
- package/dist/nodes/internal/text-buffer-controller.js +0 -327
- package/dist/nodes/internal/text-buffer-controller.js.map +0 -1
- package/dist/nodes/internal/widget.d.ts +0 -8
- package/dist/nodes/internal/widget.d.ts.map +0 -1
- package/dist/nodes/internal/widget.js +0 -68
- package/dist/nodes/internal/widget.js.map +0 -1
- package/dist/nodes/level-bar.d.ts +0 -12
- package/dist/nodes/level-bar.d.ts.map +0 -1
- package/dist/nodes/level-bar.js +0 -24
- package/dist/nodes/level-bar.js.map +0 -1
- package/dist/nodes/list-item-node.d.ts +0 -12
- package/dist/nodes/list-item-node.d.ts.map +0 -1
- package/dist/nodes/list-item-node.js +0 -45
- package/dist/nodes/list-item-node.js.map +0 -1
- package/dist/nodes/list.d.ts +0 -100
- package/dist/nodes/list.d.ts.map +0 -1
- package/dist/nodes/list.js +0 -950
- package/dist/nodes/list.js.map +0 -1
- package/dist/nodes/menu.d.ts +0 -7
- package/dist/nodes/menu.d.ts.map +0 -1
- package/dist/nodes/menu.js +0 -20
- package/dist/nodes/menu.js.map +0 -1
- package/dist/nodes/models/menu.d.ts +0 -47
- package/dist/nodes/models/menu.d.ts.map +0 -1
- package/dist/nodes/models/menu.js +0 -240
- package/dist/nodes/models/menu.js.map +0 -1
- package/dist/nodes/navigation-page.d.ts +0 -19
- package/dist/nodes/navigation-page.d.ts.map +0 -1
- package/dist/nodes/navigation-page.js +0 -129
- package/dist/nodes/navigation-page.js.map +0 -1
- package/dist/nodes/navigation-view.d.ts +0 -19
- package/dist/nodes/navigation-view.d.ts.map +0 -1
- package/dist/nodes/navigation-view.js +0 -51
- package/dist/nodes/navigation-view.js.map +0 -1
- package/dist/nodes/notebook-page-tab.d.ts +0 -15
- package/dist/nodes/notebook-page-tab.d.ts.map +0 -1
- package/dist/nodes/notebook-page-tab.js +0 -40
- package/dist/nodes/notebook-page-tab.js.map +0 -1
- package/dist/nodes/notebook-page.d.ts +0 -29
- package/dist/nodes/notebook-page.d.ts.map +0 -1
- package/dist/nodes/notebook-page.js +0 -151
- package/dist/nodes/notebook-page.js.map +0 -1
- package/dist/nodes/notebook.d.ts +0 -16
- package/dist/nodes/notebook.d.ts.map +0 -1
- package/dist/nodes/notebook.js +0 -31
- package/dist/nodes/notebook.js.map +0 -1
- package/dist/nodes/overlay-child.d.ts +0 -20
- package/dist/nodes/overlay-child.d.ts.map +0 -1
- package/dist/nodes/overlay-child.js +0 -109
- package/dist/nodes/overlay-child.js.map +0 -1
- package/dist/nodes/popover-menu.d.ts +0 -19
- package/dist/nodes/popover-menu.d.ts.map +0 -1
- package/dist/nodes/popover-menu.js +0 -54
- package/dist/nodes/popover-menu.js.map +0 -1
- package/dist/nodes/scale.d.ts +0 -10
- package/dist/nodes/scale.d.ts.map +0 -1
- package/dist/nodes/scale.js +0 -19
- package/dist/nodes/scale.js.map +0 -1
- package/dist/nodes/scrolled-window.d.ts +0 -11
- package/dist/nodes/scrolled-window.d.ts.map +0 -1
- package/dist/nodes/scrolled-window.js +0 -18
- package/dist/nodes/scrolled-window.js.map +0 -1
- package/dist/nodes/search-bar.d.ts +0 -11
- package/dist/nodes/search-bar.d.ts.map +0 -1
- package/dist/nodes/search-bar.js +0 -16
- package/dist/nodes/search-bar.js.map +0 -1
- package/dist/nodes/shortcut.d.ts +0 -19
- package/dist/nodes/shortcut.d.ts.map +0 -1
- package/dist/nodes/shortcut.js +0 -72
- package/dist/nodes/shortcut.js.map +0 -1
- package/dist/nodes/slot.d.ts +0 -21
- package/dist/nodes/slot.d.ts.map +0 -1
- package/dist/nodes/slot.js +0 -102
- package/dist/nodes/slot.js.map +0 -1
- package/dist/nodes/source-view.d.ts +0 -18
- package/dist/nodes/source-view.d.ts.map +0 -1
- package/dist/nodes/source-view.js +0 -94
- package/dist/nodes/source-view.js.map +0 -1
- package/dist/nodes/spin-row.d.ts +0 -14
- package/dist/nodes/spin-row.d.ts.map +0 -1
- package/dist/nodes/spin-row.js +0 -46
- package/dist/nodes/spin-row.js.map +0 -1
- package/dist/nodes/stack-page.d.ts +0 -22
- package/dist/nodes/stack-page.d.ts.map +0 -1
- package/dist/nodes/stack-page.js +0 -140
- package/dist/nodes/stack-page.js.map +0 -1
- package/dist/nodes/stack.d.ts +0 -13
- package/dist/nodes/stack.d.ts.map +0 -1
- package/dist/nodes/stack.js +0 -21
- package/dist/nodes/stack.js.map +0 -1
- package/dist/nodes/switch-row.d.ts +0 -11
- package/dist/nodes/switch-row.d.ts.map +0 -1
- package/dist/nodes/switch-row.js +0 -15
- package/dist/nodes/switch-row.js.map +0 -1
- package/dist/nodes/text-anchor.d.ts +0 -23
- package/dist/nodes/text-anchor.d.ts.map +0 -1
- package/dist/nodes/text-anchor.js +0 -74
- package/dist/nodes/text-anchor.js.map +0 -1
- package/dist/nodes/text-content.d.ts +0 -12
- package/dist/nodes/text-content.d.ts.map +0 -1
- package/dist/nodes/text-content.js +0 -2
- package/dist/nodes/text-content.js.map +0 -1
- package/dist/nodes/text-paintable.d.ts +0 -19
- package/dist/nodes/text-paintable.d.ts.map +0 -1
- package/dist/nodes/text-paintable.js +0 -42
- package/dist/nodes/text-paintable.js.map +0 -1
- package/dist/nodes/text-segment.d.ts +0 -18
- package/dist/nodes/text-segment.d.ts.map +0 -1
- package/dist/nodes/text-segment.js +0 -38
- package/dist/nodes/text-segment.js.map +0 -1
- package/dist/nodes/text-tag.d.ts +0 -38
- package/dist/nodes/text-tag.d.ts.map +0 -1
- package/dist/nodes/text-tag.js +0 -247
- package/dist/nodes/text-tag.js.map +0 -1
- package/dist/nodes/text-view.d.ts +0 -29
- package/dist/nodes/text-view.d.ts.map +0 -1
- package/dist/nodes/text-view.js +0 -80
- package/dist/nodes/text-view.js.map +0 -1
- package/dist/nodes/toggle-group.d.ts +0 -17
- package/dist/nodes/toggle-group.d.ts.map +0 -1
- package/dist/nodes/toggle-group.js +0 -65
- package/dist/nodes/toggle-group.js.map +0 -1
- package/dist/nodes/toggle.d.ts +0 -16
- package/dist/nodes/toggle.d.ts.map +0 -1
- package/dist/nodes/toggle.js +0 -61
- package/dist/nodes/toggle.js.map +0 -1
- package/dist/nodes/virtual.d.ts +0 -7
- package/dist/nodes/virtual.d.ts.map +0 -1
- package/dist/nodes/virtual.js +0 -9
- package/dist/nodes/virtual.js.map +0 -1
- package/dist/nodes/web-view.d.ts +0 -11
- package/dist/nodes/web-view.d.ts.map +0 -1
- package/dist/nodes/web-view.js +0 -16
- package/dist/nodes/web-view.js.map +0 -1
- package/dist/nodes/widget.d.ts +0 -26
- package/dist/nodes/widget.d.ts.map +0 -1
- package/dist/nodes/widget.js +0 -308
- package/dist/nodes/widget.js.map +0 -1
- package/dist/nodes/window.d.ts +0 -31
- package/dist/nodes/window.d.ts.map +0 -1
- package/dist/nodes/window.js +0 -122
- package/dist/nodes/window.js.map +0 -1
- package/dist/portal.d.ts +0 -29
- package/dist/portal.d.ts.map +0 -1
- package/dist/portal.js +0 -35
- package/dist/portal.js.map +0 -1
- package/dist/reconciler.d.ts +0 -34
- package/dist/reconciler.d.ts.map +0 -1
- package/dist/reconciler.js +0 -48
- package/dist/reconciler.js.map +0 -1
- package/dist/registry.d.ts +0 -18
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -98
- package/dist/registry.js.map +0 -1
- package/dist/render.d.ts +0 -117
- package/dist/render.d.ts.map +0 -1
- package/dist/render.js +0 -159
- package/dist/render.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/use-property.d.ts +0 -29
- package/dist/use-property.d.ts.map +0 -1
- package/dist/use-property.js +0 -44
- package/dist/use-property.js.map +0 -1
- package/dist/use-setting.d.ts +0 -36
- package/dist/use-setting.d.ts.map +0 -1
- package/dist/use-setting.js +0 -68
- package/dist/use-setting.js.map +0 -1
- package/src/components/compound.tsx +0 -57
- package/src/components/list.tsx +0 -140
- package/src/components/slot-widget.tsx +0 -46
- package/src/errors.ts +0 -53
- package/src/factory.ts +0 -62
- package/src/generated/compounds.ts +0 -2741
- package/src/generated/internal.ts +0 -3642
- package/src/generated/jsx.ts +0 -17383
- package/src/generated/registry.ts +0 -17
- package/src/host-config.ts +0 -219
- package/src/jsx.ts +0 -1033
- package/src/metadata.ts +0 -43
- package/src/node.ts +0 -107
- package/src/nodes/adjustable.ts +0 -68
- package/src/nodes/alert-dialog-response.ts +0 -78
- package/src/nodes/alert-dialog.ts +0 -55
- package/src/nodes/animation.ts +0 -409
- package/src/nodes/application.ts +0 -61
- package/src/nodes/calendar.ts +0 -42
- package/src/nodes/color-dialog-button.ts +0 -69
- package/src/nodes/column-view-column.ts +0 -189
- package/src/nodes/container-slot.ts +0 -100
- package/src/nodes/dialog.ts +0 -25
- package/src/nodes/drawing-area.ts +0 -53
- package/src/nodes/event-controller.ts +0 -96
- package/src/nodes/fixed-child.ts +0 -122
- package/src/nodes/font-dialog-button.ts +0 -107
- package/src/nodes/grid-child.ts +0 -116
- package/src/nodes/internal/accessible.ts +0 -155
- package/src/nodes/internal/bound-item.ts +0 -4
- package/src/nodes/internal/construct.ts +0 -60
- package/src/nodes/internal/predicates.ts +0 -80
- package/src/nodes/internal/props.ts +0 -51
- package/src/nodes/internal/signal-store.ts +0 -141
- package/src/nodes/internal/text-buffer-controller.ts +0 -417
- package/src/nodes/internal/widget.ts +0 -74
- package/src/nodes/level-bar.ts +0 -36
- package/src/nodes/list-item-node.ts +0 -53
- package/src/nodes/list.ts +0 -1082
- package/src/nodes/menu.ts +0 -27
- package/src/nodes/models/menu.ts +0 -314
- package/src/nodes/navigation-page.ts +0 -154
- package/src/nodes/navigation-view.ts +0 -66
- package/src/nodes/notebook-page-tab.ts +0 -55
- package/src/nodes/notebook-page.ts +0 -189
- package/src/nodes/notebook.ts +0 -42
- package/src/nodes/overlay-child.ts +0 -130
- package/src/nodes/popover-menu.ts +0 -67
- package/src/nodes/scale.ts +0 -28
- package/src/nodes/scrolled-window.ts +0 -23
- package/src/nodes/search-bar.ts +0 -27
- package/src/nodes/shortcut.ts +0 -86
- package/src/nodes/slot.ts +0 -138
- package/src/nodes/source-view.ts +0 -130
- package/src/nodes/spin-row.ts +0 -72
- package/src/nodes/stack-page.ts +0 -170
- package/src/nodes/stack.ts +0 -35
- package/src/nodes/switch-row.ts +0 -26
- package/src/nodes/text-anchor.ts +0 -88
- package/src/nodes/text-content.ts +0 -14
- package/src/nodes/text-paintable.ts +0 -51
- package/src/nodes/text-segment.ts +0 -55
- package/src/nodes/text-tag.ts +0 -298
- package/src/nodes/text-view.ts +0 -100
- package/src/nodes/toggle-group.ts +0 -81
- package/src/nodes/toggle.ts +0 -72
- package/src/nodes/virtual.ts +0 -16
- package/src/nodes/web-view.ts +0 -22
- package/src/nodes/widget.ts +0 -369
- package/src/nodes/window.ts +0 -172
- package/src/portal.ts +0 -37
- package/src/reconciler.ts +0 -52
- package/src/registry.ts +0 -119
- package/src/render.tsx +0 -192
- package/src/types.ts +0 -13
- package/src/use-property.ts +0 -58
- package/src/use-setting.ts +0 -96
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import { drain, kebabCase } from "@gtkx/utils";
|
|
3
|
+
import { applyAccessibleProps, isAccessibleProp } from "../utils/accessible-props.js";
|
|
4
|
+
import { typeInfoFor } from "./metadata.js";
|
|
5
|
+
import { getOrCreateContext } from "./node.js";
|
|
6
|
+
import { connectHandler, disconnectHandler } from "./signals.js";
|
|
7
|
+
import { bufferText, hasSameText, isContentPaintableProp, markTextDirty, TEXT_PROP } from "./text.js";
|
|
8
|
+
const REACT_RESERVED_PROPS = new Set(["children", "ref", "key"]);
|
|
9
|
+
const NOTIFY_PREFIX = "onNotify";
|
|
10
|
+
const HANDLER_PREFIX = "on";
|
|
11
|
+
const flushDirty = new Set();
|
|
12
|
+
const isHandlerName = (name) => /^on[A-Z]/.test(name);
|
|
13
|
+
const signalForProp = (info, name) => {
|
|
14
|
+
if (name === NOTIFY_PREFIX) {
|
|
15
|
+
return "notify";
|
|
16
|
+
}
|
|
17
|
+
if (name.startsWith(NOTIFY_PREFIX) && name.length > NOTIFY_PREFIX.length) {
|
|
18
|
+
return `notify::${kebabCase(name.slice(NOTIFY_PREFIX.length))}`;
|
|
19
|
+
}
|
|
20
|
+
return info.signals[name] ?? kebabCase(name.slice(HANDLER_PREFIX.length));
|
|
21
|
+
};
|
|
22
|
+
const isReservedName = (name, info) => REACT_RESERVED_PROPS.has(name) || isHandlerName(name) || isAccessibleProp(name) || info.constructOnly.has(name);
|
|
23
|
+
const isSkippedValueName = (name, info, consumed) => isReservedName(name, info) || consumed.has(name);
|
|
24
|
+
const writeValue = (object, name, value) => {
|
|
25
|
+
if (hasSameText(object, name, value)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
Reflect.set(object, name, value);
|
|
29
|
+
};
|
|
30
|
+
const resetPlain = (object, info, name) => {
|
|
31
|
+
if (Object.hasOwn(info.defaults, name)) {
|
|
32
|
+
writeValue(object, name, info.defaults[name]);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const setOrReset = (object, info, name, value) => {
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
resetPlain(object, info, name);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
writeValue(object, name, value);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const applyBufferText = (buffer, text) => {
|
|
44
|
+
if (bufferText(buffer) === text) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
buffer.beginIrreversibleAction();
|
|
48
|
+
buffer.setText(text, -1);
|
|
49
|
+
buffer.endIrreversibleAction();
|
|
50
|
+
};
|
|
51
|
+
const isBufferText = (node, name) => name === TEXT_PROP && node.contentKind === "buffer" && node.object instanceof Gtk.TextBuffer;
|
|
52
|
+
const propText = (value) => (typeof value === "string" ? value : JSON.stringify(value));
|
|
53
|
+
const applyEntry = (node, info, delta) => {
|
|
54
|
+
const { name, value, prevValue } = delta;
|
|
55
|
+
if (value !== undefined && isBufferText(node, name)) {
|
|
56
|
+
applyBufferText(node.object, propText(value));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (isContentPaintableProp(node, name)) {
|
|
60
|
+
markTextDirty(node);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const isInitialNull = value === null && prevValue === undefined;
|
|
64
|
+
if (!isInitialNull) {
|
|
65
|
+
setOrReset(node.object, info, name, value);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const eachChangedName = (prev, next, visit) => {
|
|
69
|
+
const names = new Set([...Object.keys(prev), ...Object.keys(next)]);
|
|
70
|
+
for (const name of names) {
|
|
71
|
+
visit(name);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const constructOnlyChangeError = (typeName, name) => new Error(`Cannot change the construct-only prop '${name}' of <${typeName}> after it is created. ` +
|
|
75
|
+
"GTK accepts it only while the object is being built, so give the element a key that " +
|
|
76
|
+
`changes with '${name}' and React will build a new one.`);
|
|
77
|
+
const assertConstructOnlyUnchanged = (typeName, prev, next) => {
|
|
78
|
+
const info = typeInfoFor(typeName);
|
|
79
|
+
eachChangedName(prev, next, (name) => {
|
|
80
|
+
if (!info.constructOnly.has(name) || Object.is(prev[name], next[name])) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw constructOnlyChangeError(typeName, name);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const collectConsumed = (ctx, behavior) => {
|
|
87
|
+
if (behavior.update === undefined) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const result = behavior.update(ctx.node.object, ctx.prev, ctx.next, getOrCreateContext(ctx.node, behavior));
|
|
91
|
+
if (result === undefined) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
for (const name of result) {
|
|
95
|
+
ctx.consumed.add(name);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const runBehaviorUpdates = (node, info, prev, next) => {
|
|
99
|
+
const consumed = new Set();
|
|
100
|
+
const ctx = { node, prev, next, consumed };
|
|
101
|
+
for (const behavior of info.behaviors) {
|
|
102
|
+
collectConsumed(ctx, behavior);
|
|
103
|
+
}
|
|
104
|
+
return consumed;
|
|
105
|
+
};
|
|
106
|
+
const applyValueEntries = (node, info, change, consumed) => {
|
|
107
|
+
eachChangedName(change.prev, change.next, (name) => {
|
|
108
|
+
if (isSkippedValueName(name, info, consumed) || Object.is(change.prev[name], change.next[name])) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
applyEntry(node, info, { name, value: change.next[name], prevValue: change.prev[name] });
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const restoreActionableSensitivity = (node, info, prev, next) => {
|
|
115
|
+
if (prev.actionName === undefined || next.actionName !== undefined) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const desired = "sensitive" in next ? next.sensitive : info.defaults.sensitive;
|
|
119
|
+
if (typeof desired === "boolean") {
|
|
120
|
+
Reflect.set(node.object, "sensitive", desired);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const applyHandlers = (target, info, prev, next) => {
|
|
124
|
+
eachChangedName(prev, next, (name) => {
|
|
125
|
+
if (!isHandlerName(name)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const value = next[name];
|
|
129
|
+
if (typeof value === "function") {
|
|
130
|
+
connectHandler(target, name, signalForProp(info, name), value);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
disconnectHandler(target, name);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
const markFlush = (node) => {
|
|
138
|
+
if (typeInfoFor(node.typeName).hasFlush) {
|
|
139
|
+
flushDirty.add(node);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const eachBehavior = (node, visit) => {
|
|
143
|
+
for (const behavior of typeInfoFor(node.typeName).behaviors) {
|
|
144
|
+
visit(behavior, getOrCreateContext(node, behavior));
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const flushBehaviors = () => {
|
|
148
|
+
drain(flushDirty, (node) => {
|
|
149
|
+
eachBehavior(node, (behavior, context) => behavior.flush?.(node.object, context));
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const mountBehaviors = (node) => {
|
|
153
|
+
if (!typeInfoFor(node.typeName).hasMount) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
eachBehavior(node, (behavior, context) => behavior.mount?.(node.object, context));
|
|
157
|
+
};
|
|
158
|
+
const unmountBehaviors = (node) => {
|
|
159
|
+
eachBehavior(node, (behavior, context) => behavior.unmount?.(node.object, context));
|
|
160
|
+
};
|
|
161
|
+
const applyAccessible = (object, prev, next) => {
|
|
162
|
+
if (object instanceof Gtk.Widget) {
|
|
163
|
+
applyAccessibleProps(object, prev, next);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const applyElementProps = (node, prev, next) => {
|
|
167
|
+
const info = typeInfoFor(node.typeName);
|
|
168
|
+
const consumed = runBehaviorUpdates(node, info, prev, next);
|
|
169
|
+
applyValueEntries(node, info, { prev, next }, consumed);
|
|
170
|
+
restoreActionableSensitivity(node, info, prev, next);
|
|
171
|
+
applyAccessible(node.object, prev, next);
|
|
172
|
+
applyHandlers(node, info, prev, next);
|
|
173
|
+
markFlush(node);
|
|
174
|
+
node.props = next;
|
|
175
|
+
};
|
|
176
|
+
const isSkippedAdoptedName = (info, name) => isReservedName(name, info);
|
|
177
|
+
const applyAdoptedProps = (target, prev, next) => {
|
|
178
|
+
const { object, typeName } = target;
|
|
179
|
+
const info = typeInfoFor(typeName);
|
|
180
|
+
eachChangedName(prev, next, (name) => {
|
|
181
|
+
if (isSkippedAdoptedName(info, name) || Object.is(prev[name], next[name])) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
setOrReset(object, info, name, next[name]);
|
|
185
|
+
});
|
|
186
|
+
applyAccessible(object, prev, next);
|
|
187
|
+
applyHandlers(target, info, prev, next);
|
|
188
|
+
};
|
|
189
|
+
export { markFlush, flushBehaviors, mountBehaviors, unmountBehaviors, applyElementProps, applyAdoptedProps, assertConstructOnlyUnchanged, };
|
|
190
|
+
//# sourceMappingURL=apply-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-props.js","sourceRoot":"","sources":["../../src/reconciler/apply-props.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAoB,kBAAkB,EAAqB,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAMtG,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,UAAU,GAAqB,IAAI,GAAG,EAAE,CAAC;AAE/C,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEvE,MAAM,aAAa,GAAG,CAAC,IAAc,EAAE,IAAY,EAAU,EAAE;IAC3D,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC;QACvE,OAAO,WAAW,SAAS,CAAC,IAAI,CAAC,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,oBAAoB,GAAG,CAAC,IAAc,EAAE,IAAY,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAEnG,MAAM,iBAAiB,GAAG,CAAC,MAAoB,EAAE,IAAW,EAAE,IAAW,EAAQ,EAAE;IAC/E,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEnC,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;QACjC,IAAI,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxE,OAAO;QACX,CAAC;QAED,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,OAAO,EACH,SAAS,EACT,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,GAC/B,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { SignalHandler } from \"@gtkx/runtime\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { drain, kebabCase } from \"@gtkx/utils\";\nimport type { ElementBehavior, Props } from \"./registry.js\";\nimport { applyAccessibleProps, isAccessibleProp } from \"../utils/accessible-props.js\";\nimport { type TypeInfo, typeInfoFor } from \"./metadata.js\";\nimport { type ElementNode, getOrCreateContext, type SignalTarget } from \"./node.js\";\nimport { connectHandler, disconnectHandler } from \"./signals.js\";\nimport { bufferText, hasSameText, isContentPaintableProp, markTextDirty, TEXT_PROP } from \"./text.js\";\n\ntype PropDelta = { name: string; value: unknown; prevValue: unknown };\ntype BehaviorUpdateContext = { node: ElementNode; prev: Props; next: Props; consumed: Set<string> };\ntype PropChange = { prev: Props; next: Props };\n\nconst REACT_RESERVED_PROPS = new Set([\"children\", \"ref\", \"key\"]);\nconst NOTIFY_PREFIX = \"onNotify\";\nconst HANDLER_PREFIX = \"on\";\nconst flushDirty: Set<ElementNode> = new Set();\n\nconst isHandlerName = (name: string): boolean => /^on[A-Z]/.test(name);\n\nconst signalForProp = (info: TypeInfo, name: string): string => {\n if (name === NOTIFY_PREFIX) {\n return \"notify\";\n }\n\n if (name.startsWith(NOTIFY_PREFIX) && name.length > NOTIFY_PREFIX.length) {\n return `notify::${kebabCase(name.slice(NOTIFY_PREFIX.length))}`;\n }\n\n return info.signals[name] ?? kebabCase(name.slice(HANDLER_PREFIX.length));\n};\n\nconst isReservedName = (name: string, info: TypeInfo): boolean =>\n REACT_RESERVED_PROPS.has(name) || isHandlerName(name) || isAccessibleProp(name) || info.constructOnly.has(name);\n\nconst isSkippedValueName = (name: string, info: TypeInfo, consumed: Set<string>): boolean =>\n isReservedName(name, info) || consumed.has(name);\n\nconst writeValue = (object: GObject.Object, name: string, value: unknown): void => {\n if (hasSameText(object, name, value)) {\n return;\n }\n\n Reflect.set(object, name, value);\n};\n\nconst resetPlain = (object: GObject.Object, info: TypeInfo, name: string): void => {\n if (Object.hasOwn(info.defaults, name)) {\n writeValue(object, name, info.defaults[name]);\n }\n};\n\nconst setOrReset = (object: GObject.Object, info: TypeInfo, name: string, value: unknown): void => {\n if (value === undefined) {\n resetPlain(object, info, name);\n } else {\n writeValue(object, name, value);\n }\n};\n\nconst applyBufferText = (buffer: Gtk.TextBuffer, text: string): void => {\n if (bufferText(buffer) === text) {\n return;\n }\n\n buffer.beginIrreversibleAction();\n buffer.setText(text, -1);\n buffer.endIrreversibleAction();\n};\n\nconst isBufferText = (node: ElementNode, name: string): node is ElementNode & { object: Gtk.TextBuffer } =>\n name === TEXT_PROP && node.contentKind === \"buffer\" && node.object instanceof Gtk.TextBuffer;\n\nconst propText = (value: unknown): string => (typeof value === \"string\" ? value : JSON.stringify(value));\n\nconst applyEntry = (node: ElementNode, info: TypeInfo, delta: PropDelta): void => {\n const { name, value, prevValue } = delta;\n\n if (value !== undefined && isBufferText(node, name)) {\n applyBufferText(node.object, propText(value));\n\n return;\n }\n\n if (isContentPaintableProp(node, name)) {\n markTextDirty(node);\n\n return;\n }\n\n const isInitialNull = value === null && prevValue === undefined;\n\n if (!isInitialNull) {\n setOrReset(node.object, info, name, value);\n }\n};\n\nconst eachChangedName = (prev: Props, next: Props, visit: (name: string) => void): void => {\n const names = new Set([...Object.keys(prev), ...Object.keys(next)]);\n\n for (const name of names) {\n visit(name);\n }\n};\n\nconst constructOnlyChangeError = (typeName: string, name: string): Error =>\n new Error(\n `Cannot change the construct-only prop '${name}' of <${typeName}> after it is created. ` +\n \"GTK accepts it only while the object is being built, so give the element a key that \" +\n `changes with '${name}' and React will build a new one.`,\n );\n\nconst assertConstructOnlyUnchanged = (typeName: string, prev: Props, next: Props): void => {\n const info = typeInfoFor(typeName);\n\n eachChangedName(prev, next, (name) => {\n if (!info.constructOnly.has(name) || Object.is(prev[name], next[name])) {\n return;\n }\n\n throw constructOnlyChangeError(typeName, name);\n });\n};\n\nconst collectConsumed = (ctx: BehaviorUpdateContext, behavior: ElementBehavior): void => {\n if (behavior.update === undefined) {\n return;\n }\n\n const result = behavior.update(ctx.node.object, ctx.prev, ctx.next, getOrCreateContext(ctx.node, behavior));\n\n if (result === undefined) {\n return;\n }\n\n for (const name of result) {\n ctx.consumed.add(name);\n }\n};\n\nconst runBehaviorUpdates = (node: ElementNode, info: TypeInfo, prev: Props, next: Props): Set<string> => {\n const consumed: Set<string> = new Set();\n const ctx: BehaviorUpdateContext = { node, prev, next, consumed };\n\n for (const behavior of info.behaviors) {\n collectConsumed(ctx, behavior);\n }\n\n return consumed;\n};\n\nconst applyValueEntries = (node: ElementNode, info: TypeInfo, change: PropChange, consumed: Set<string>): void => {\n eachChangedName(change.prev, change.next, (name) => {\n if (isSkippedValueName(name, info, consumed) || Object.is(change.prev[name], change.next[name])) {\n return;\n }\n\n applyEntry(node, info, { name, value: change.next[name], prevValue: change.prev[name] });\n });\n};\n\nconst restoreActionableSensitivity = (node: ElementNode, info: TypeInfo, prev: Props, next: Props): void => {\n if (prev.actionName === undefined || next.actionName !== undefined) {\n return;\n }\n\n const desired = \"sensitive\" in next ? next.sensitive : info.defaults.sensitive;\n\n if (typeof desired === \"boolean\") {\n Reflect.set(node.object, \"sensitive\", desired);\n }\n};\n\nconst applyHandlers = (target: SignalTarget, info: TypeInfo, prev: Props, next: Props): void => {\n eachChangedName(prev, next, (name) => {\n if (!isHandlerName(name)) {\n return;\n }\n\n const value = next[name];\n\n if (typeof value === \"function\") {\n connectHandler(target, name, signalForProp(info, name), value as SignalHandler);\n } else {\n disconnectHandler(target, name);\n }\n });\n};\n\nconst markFlush = (node: ElementNode): void => {\n if (typeInfoFor(node.typeName).hasFlush) {\n flushDirty.add(node);\n }\n};\n\nconst eachBehavior = (node: ElementNode, visit: (behavior: ElementBehavior, context: unknown) => void): void => {\n for (const behavior of typeInfoFor(node.typeName).behaviors) {\n visit(behavior, getOrCreateContext(node, behavior));\n }\n};\n\nconst flushBehaviors = (): void => {\n drain(flushDirty, (node) => {\n eachBehavior(node, (behavior, context) => behavior.flush?.(node.object, context));\n });\n};\n\nconst mountBehaviors = (node: ElementNode): void => {\n if (!typeInfoFor(node.typeName).hasMount) {\n return;\n }\n\n eachBehavior(node, (behavior, context) => behavior.mount?.(node.object, context));\n};\n\nconst unmountBehaviors = (node: ElementNode): void => {\n eachBehavior(node, (behavior, context) => behavior.unmount?.(node.object, context));\n};\n\nconst applyAccessible = (object: GObject.Object, prev: Props, next: Props): void => {\n if (object instanceof Gtk.Widget) {\n applyAccessibleProps(object, prev, next);\n }\n};\n\nconst applyElementProps = (node: ElementNode, prev: Props, next: Props): void => {\n const info = typeInfoFor(node.typeName);\n const consumed = runBehaviorUpdates(node, info, prev, next);\n applyValueEntries(node, info, { prev, next }, consumed);\n restoreActionableSensitivity(node, info, prev, next);\n applyAccessible(node.object, prev, next);\n applyHandlers(node, info, prev, next);\n markFlush(node);\n node.props = next;\n};\n\nconst isSkippedAdoptedName = (info: TypeInfo, name: string): boolean => isReservedName(name, info);\n\nconst applyAdoptedProps = (target: SignalTarget, prev: Props, next: Props): void => {\n const { object, typeName } = target;\n const info = typeInfoFor(typeName);\n\n eachChangedName(prev, next, (name) => {\n if (isSkippedAdoptedName(info, name) || Object.is(prev[name], next[name])) {\n return;\n }\n\n setOrReset(object, info, name, next[name]);\n });\n\n applyAccessible(object, prev, next);\n applyHandlers(target, info, prev, next);\n};\n\nexport {\n markFlush,\n flushBehaviors,\n mountBehaviors,\n unmountBehaviors,\n applyElementProps,\n applyAdoptedProps,\n assertConstructOnlyUnchanged,\n};\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
+
import type { DetachInfo, ElementBehavior, PlaceInfo, Props } from "./registry.js";
|
|
4
|
+
type SlotHooks<P extends GObject.Object, C extends GObject.Object> = {
|
|
5
|
+
attach: (parent: P, child: C, info: PlaceInfo) => unknown;
|
|
6
|
+
detach?: (parent: P, child: C, info: DetachInfo) => void;
|
|
7
|
+
reorder?: (parent: P, child: C, info: PlaceInfo) => unknown;
|
|
8
|
+
resolve?: (parent: P, child: C) => GObject.Object | null;
|
|
9
|
+
};
|
|
10
|
+
type ValueApply<P extends GObject.Object, V> = (object: P, value: V) => void;
|
|
11
|
+
type ListHooks<P extends GObject.Object, I, H> = {
|
|
12
|
+
add?: (parent: P, item: I) => H;
|
|
13
|
+
remove?: (parent: P, item: I, handle: H) => void;
|
|
14
|
+
clear?: (parent: P) => void;
|
|
15
|
+
};
|
|
16
|
+
type CanApply<P extends GObject.Object, V> = (object: P, value: V) => boolean;
|
|
17
|
+
type ChildSetter = GObject.Object & {
|
|
18
|
+
setChild: (child: Gtk.Widget | null) => void;
|
|
19
|
+
};
|
|
20
|
+
type ContentSetter<C extends Gtk.Widget> = GObject.Object & {
|
|
21
|
+
setContent: (content: C | null) => void;
|
|
22
|
+
};
|
|
23
|
+
type BoxLike = GObject.Object & {
|
|
24
|
+
remove: (child: Gtk.Widget) => void;
|
|
25
|
+
insertChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => unknown;
|
|
26
|
+
reorderChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => void;
|
|
27
|
+
};
|
|
28
|
+
type IndexedInserter = GObject.Object & {
|
|
29
|
+
remove: (child: Gtk.Widget) => void;
|
|
30
|
+
insert: (child: Gtk.Widget, position: number) => unknown;
|
|
31
|
+
};
|
|
32
|
+
/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */
|
|
33
|
+
declare const slot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childType: string, hooks: SlotHooks<P, C>) => ElementBehavior;
|
|
34
|
+
/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */
|
|
35
|
+
declare const value: <P extends GObject.Object, V>(prop: string, apply: ValueApply<P, V>) => ElementBehavior<P>;
|
|
36
|
+
/**
|
|
37
|
+
* Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural
|
|
38
|
+
* change. `add` may return a handle that the same item's later `remove` receives, for items whose
|
|
39
|
+
* teardown needs what `add` produced (as VFL constraints need the objects the layout created).
|
|
40
|
+
*/
|
|
41
|
+
declare const list: <P extends GObject.Object, I, H = void>(prop: string, hooks: ListHooks<P, I, H>) => ElementBehavior<P>;
|
|
42
|
+
/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */
|
|
43
|
+
declare const deferred: <P extends GObject.Object, V>(prop: string, canApply?: CanApply<P, V>) => ElementBehavior<P>;
|
|
44
|
+
/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */
|
|
45
|
+
declare const controlledText: (prop: string) => ElementBehavior;
|
|
46
|
+
/** Behavior for a container that installs its single child with `setChild`. */
|
|
47
|
+
declare const childSetterSlot: <P extends ChildSetter>() => ElementBehavior<P>;
|
|
48
|
+
/** Behavior for a container that installs its single child with `setContent`. */
|
|
49
|
+
declare const contentSetterSlot: <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(childType?: string) => ElementBehavior<P>;
|
|
50
|
+
/** Behavior for a `GtkBox`-style container that orders children by sibling. */
|
|
51
|
+
declare const boxSlot: <P extends BoxLike>() => ElementBehavior<P>;
|
|
52
|
+
/** Behavior for a container whose children are added and removed by a pair of methods. */
|
|
53
|
+
declare const addRemoveSlot: <C extends GObject.Object, P extends GObject.Object>(slotName: string, childType: string, add: (parent: P, child: C) => unknown, remove: (parent: P, child: C) => void) => ElementBehavior;
|
|
54
|
+
/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */
|
|
55
|
+
declare const adoptedChildrenSlot: <P extends GObject.Object, C extends GObject.Object>(childType: string, add: (parent: P, item: C) => unknown, remove: (parent: P, item: C) => void) => ElementBehavior;
|
|
56
|
+
/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */
|
|
57
|
+
declare const wrappingIndexedSlot: <W extends Gtk.Widget, P extends IndexedInserter>(Wrapper: new (props: Props) => W, setChild: (wrapper: W, inner: Gtk.Widget) => void) => ElementBehavior<P>;
|
|
58
|
+
export { slot, value, list, deferred, controlledText, childSetterSlot, contentSetterSlot, boxSlot, addRemoveSlot, adoptedChildrenSlot, wrappingIndexedSlot, };
|
|
59
|
+
//# sourceMappingURL=behaviors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviors.d.ts","sourceRoot":"","sources":["../../src/reconciler/behaviors.ts"],"names":[],"mappings":"AAAA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AC,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,EACrE,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,EACrC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,KACtC,eAAmF,CAAC;AAEvF,qGAAqG;AACrG,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,EAC3E,WAAW,MAAM,EACjB,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,EACpC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,KACrC,eAA0E,CAAC;AAsC9E,kGAAkG;AAClG,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,SAAS,eAAe,EACxE,SAAS,KAAK,KAAK,EAAE,KAAK,KAAK,CAAC,EAChC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,KAAK,IAAI,KAClD,eAAe,CAAC,CAAC,CASlB,CAAC;AAEH,OAAO,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACtB,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { getInstanceType, TYPE_INVALID, typeFromName, typeIsA } from "@gtkx/runtime";
|
|
2
|
+
import { getOrInsert, isDeepEqual, structuredClone } from "@gtkx/utils";
|
|
3
|
+
import { hasSameText } from "./text.js";
|
|
4
|
+
const childTypeCache = new Map();
|
|
5
|
+
const childTypeFor = (name) => getOrInsert(childTypeCache, name, typeFromName);
|
|
6
|
+
const childMatcher = (name) => (child) => {
|
|
7
|
+
const type = childTypeFor(name);
|
|
8
|
+
return type === TYPE_INVALID || typeIsA(getInstanceType(child), type);
|
|
9
|
+
};
|
|
10
|
+
const slotAttach = (slotName, isMatch, attach) => (object, child, info) => {
|
|
11
|
+
if (info.slot !== slotName || !isMatch(child)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
return attach(object, child, info) ?? true;
|
|
15
|
+
};
|
|
16
|
+
/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */
|
|
17
|
+
const slot = (slotName, childType, hooks) => {
|
|
18
|
+
const matches = childMatcher(childType);
|
|
19
|
+
const { attach, detach, reorder, resolve } = hooks;
|
|
20
|
+
const behavior = { attach: slotAttach(slotName, matches, attach) };
|
|
21
|
+
if (reorder !== undefined) {
|
|
22
|
+
behavior.reorder = (object, child, info) => reorder(object, child, info) ?? true;
|
|
23
|
+
}
|
|
24
|
+
if (detach !== undefined) {
|
|
25
|
+
behavior.detach = (object, child, info) => {
|
|
26
|
+
detach(object, child, info);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (resolve !== undefined) {
|
|
30
|
+
behavior.resolve = (object, child) => resolve(object, child);
|
|
31
|
+
}
|
|
32
|
+
return behavior;
|
|
33
|
+
};
|
|
34
|
+
/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */
|
|
35
|
+
const value = (prop, apply) => ({
|
|
36
|
+
update: (object, prev, next) => {
|
|
37
|
+
if (!Object.is(prev[prop], next[prop]) && next[prop] !== undefined) {
|
|
38
|
+
apply(object, next[prop]);
|
|
39
|
+
}
|
|
40
|
+
return [prop];
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const teardownList = (object, entries, hooks) => {
|
|
44
|
+
if (hooks.clear !== undefined) {
|
|
45
|
+
hooks.clear(object);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const remove = hooks.remove;
|
|
49
|
+
if (remove === undefined) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
remove(object, entry.item, entry.handle);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural
|
|
58
|
+
* change. `add` may return a handle that the same item's later `remove` receives, for items whose
|
|
59
|
+
* teardown needs what `add` produced (as VFL constraints need the objects the layout created).
|
|
60
|
+
*/
|
|
61
|
+
const list = (prop, hooks) => {
|
|
62
|
+
const { add } = hooks;
|
|
63
|
+
return {
|
|
64
|
+
createContext: () => ({ snapshot: [], entries: [] }),
|
|
65
|
+
update: (object, _prev, next, context) => {
|
|
66
|
+
const state = context;
|
|
67
|
+
const raw = next[prop];
|
|
68
|
+
const items = Array.isArray(raw) ? raw : [];
|
|
69
|
+
if (isDeepEqual(state.snapshot, items)) {
|
|
70
|
+
return [prop];
|
|
71
|
+
}
|
|
72
|
+
teardownList(object, state.entries, hooks);
|
|
73
|
+
state.entries = items.map((item) => ({ item, handle: add?.(object, item) }));
|
|
74
|
+
state.snapshot = structuredClone(items);
|
|
75
|
+
return [prop];
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const flushDeferred = (object, context, prop, canApply) => {
|
|
80
|
+
const state = context;
|
|
81
|
+
if (!state.present || Object.is(state.applied, state.desired)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (canApply !== undefined && !canApply(object, state.desired)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
Reflect.set(object, prop, state.desired);
|
|
88
|
+
state.applied = state.desired;
|
|
89
|
+
};
|
|
90
|
+
/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */
|
|
91
|
+
const deferred = (prop, canApply) => ({
|
|
92
|
+
deferred: [prop],
|
|
93
|
+
createContext: () => ({ desired: undefined, present: false, applied: undefined }),
|
|
94
|
+
update: (_object, _prev, next, context) => {
|
|
95
|
+
const state = context;
|
|
96
|
+
state.desired = next[prop];
|
|
97
|
+
state.present = next[prop] !== undefined;
|
|
98
|
+
return [prop];
|
|
99
|
+
},
|
|
100
|
+
flush: (object, context) => {
|
|
101
|
+
flushDeferred(object, context, prop, canApply);
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */
|
|
105
|
+
const controlledText = (prop) => value(prop, (object, next) => {
|
|
106
|
+
if (!hasSameText(object, prop, next)) {
|
|
107
|
+
Reflect.set(object, prop, next);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
/** Behavior for a container that installs its single child with `setChild`. */
|
|
111
|
+
const childSetterSlot = () => slot("children", "GtkWidget", {
|
|
112
|
+
attach: (parent, child) => {
|
|
113
|
+
parent.setChild(child);
|
|
114
|
+
},
|
|
115
|
+
detach: (parent) => {
|
|
116
|
+
parent.setChild(null);
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
/** Behavior for a container that installs its single child with `setContent`. */
|
|
120
|
+
const contentSetterSlot = (childType = "GtkWidget") => slot("children", childType, {
|
|
121
|
+
attach: (parent, child) => {
|
|
122
|
+
parent.setContent(child);
|
|
123
|
+
},
|
|
124
|
+
detach: (parent) => {
|
|
125
|
+
parent.setContent(null);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
/** Behavior for a `GtkBox`-style container that orders children by sibling. */
|
|
129
|
+
const boxSlot = () => slot("children", "GtkWidget", {
|
|
130
|
+
attach: (box, child, info) => box.insertChildAfter(child, info.sibling),
|
|
131
|
+
detach: (box, child) => {
|
|
132
|
+
box.remove(child);
|
|
133
|
+
},
|
|
134
|
+
reorder: (box, child, info) => {
|
|
135
|
+
box.reorderChildAfter(child, info.sibling);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
/** Behavior for a container whose children are added and removed by a pair of methods. */
|
|
139
|
+
const addRemoveSlot = (slotName, childType, add, remove) => slot(slotName, childType, { attach: add, detach: remove });
|
|
140
|
+
/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */
|
|
141
|
+
const adoptedChildrenSlot = (childType, add, remove) => addRemoveSlot("children", childType, add, remove);
|
|
142
|
+
const wrappedRow = (Wrapper, setChild, rows, child) => {
|
|
143
|
+
if (child instanceof Wrapper) {
|
|
144
|
+
return child;
|
|
145
|
+
}
|
|
146
|
+
const existing = rows.get(child);
|
|
147
|
+
if (existing !== undefined) {
|
|
148
|
+
return existing;
|
|
149
|
+
}
|
|
150
|
+
const wrapper = new Wrapper({});
|
|
151
|
+
setChild(wrapper, child);
|
|
152
|
+
rows.set(child, wrapper);
|
|
153
|
+
return wrapper;
|
|
154
|
+
};
|
|
155
|
+
const removeWrappedRow = (Wrapper, parent, child, rows) => {
|
|
156
|
+
const row = child instanceof Wrapper ? child : rows.get(child);
|
|
157
|
+
if (row !== undefined) {
|
|
158
|
+
parent.remove(row);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */
|
|
162
|
+
const wrappingIndexedSlot = (Wrapper, setChild) => ({
|
|
163
|
+
...slot("children", "GtkWidget", {
|
|
164
|
+
attach: (parent, child, info) => parent.insert(wrappedRow(Wrapper, setChild, info.context, child), info.index),
|
|
165
|
+
detach: (parent, child, info) => {
|
|
166
|
+
removeWrappedRow(Wrapper, parent, child, info.context);
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
createContext: () => new WeakMap(),
|
|
170
|
+
});
|
|
171
|
+
export { slot, value, list, deferred, controlledText, childSetterSlot, contentSetterSlot, boxSlot, addRemoveSlot, adoptedChildrenSlot, wrappingIndexedSlot, };
|
|
172
|
+
//# sourceMappingURL=behaviors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviors.js","sourceRoot":"","sources":["../../src/reconciler/behaviors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eA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,mBAAmB,GACtB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport { getInstanceType, TYPE_INVALID, typeFromName, typeIsA } from \"@gtkx/runtime\";\nimport { getOrInsert, isDeepEqual, structuredClone } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo, Props } from \"./registry.js\";\nimport { hasSameText } from \"./text.js\";\n\ntype SlotHooks<P extends GObject.Object, C extends GObject.Object> = {\n attach: (parent: P, child: C, info: PlaceInfo) => unknown;\n detach?: (parent: P, child: C, info: DetachInfo) => void;\n reorder?: (parent: P, child: C, info: PlaceInfo) => unknown;\n resolve?: (parent: P, child: C) => GObject.Object | null;\n};\n\ntype ValueApply<P extends GObject.Object, V> = (object: P, value: V) => void;\n\ntype ListHooks<P extends GObject.Object, I, H> = {\n add?: (parent: P, item: I) => H;\n remove?: (parent: P, item: I, handle: H) => void;\n clear?: (parent: P) => void;\n};\n\ntype ListEntry = { item: unknown; handle: unknown };\ntype ListState = { snapshot: unknown[]; entries: ListEntry[] };\ntype DeferredState = { desired: unknown; present: boolean; applied: unknown };\ntype CanApply<P extends GObject.Object, V> = (object: P, value: V) => boolean;\ntype ChildSetter = GObject.Object & { setChild: (child: Gtk.Widget | null) => void };\ntype ContentSetter<C extends Gtk.Widget> = GObject.Object & { setContent: (content: C | null) => void };\n\ntype BoxLike = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insertChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => unknown;\n reorderChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => void;\n};\n\ntype RowCache = WeakMap<GObject.Object, Gtk.Widget>;\n\ntype IndexedInserter = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insert: (child: Gtk.Widget, position: number) => unknown;\n};\n\nconst childTypeCache: Map<string, bigint> = new Map();\n\nconst childTypeFor = (name: string): bigint => getOrInsert(childTypeCache, name, typeFromName);\n\nconst childMatcher =\n (name: string): ((child: GObject.Object) => boolean) =>\n (child) => {\n const type = childTypeFor(name);\n\n return type === TYPE_INVALID || typeIsA(getInstanceType(child), type);\n };\n\nconst slotAttach =\n <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n isMatch: (child: GObject.Object) => boolean,\n attach: SlotHooks<P, C>[\"attach\"],\n ): NonNullable<ElementBehavior[\"attach\"]> =>\n (object, child, info) => {\n if (info.slot !== slotName || !isMatch(child)) {\n return;\n }\n\n return attach(object as P, child as C, info) ?? true;\n };\n\n/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */\nconst slot = <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n childType: string,\n hooks: SlotHooks<P, C>,\n): ElementBehavior => {\n const matches = childMatcher(childType);\n const { attach, detach, reorder, resolve } = hooks;\n const behavior: ElementBehavior = { attach: slotAttach(slotName, matches, attach) };\n\n if (reorder !== undefined) {\n behavior.reorder = (object, child, info) => reorder(object as P, child as C, info) ?? true;\n }\n\n if (detach !== undefined) {\n behavior.detach = (object, child, info) => {\n detach(object as P, child as C, info);\n };\n }\n\n if (resolve !== undefined) {\n behavior.resolve = (object, child) => resolve(object as P, child as C);\n }\n\n return behavior;\n};\n\n/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */\nconst value = <P extends GObject.Object, V>(\n prop: string,\n apply: ValueApply<P, V>,\n): ElementBehavior<P> => ({\n update: (object, prev, next) => {\n if (!Object.is(prev[prop], next[prop]) && next[prop] !== undefined) {\n apply(object, next[prop] as V);\n }\n\n return [prop];\n },\n});\n\nconst teardownList = <P extends GObject.Object, I, H>(\n object: P,\n entries: ListEntry[],\n hooks: ListHooks<P, I, H>,\n): void => {\n if (hooks.clear !== undefined) {\n hooks.clear(object);\n\n return;\n }\n\n const remove = hooks.remove;\n\n if (remove === undefined) {\n return;\n }\n\n for (const entry of entries) {\n remove(object, entry.item as I, entry.handle as H);\n }\n};\n\n/**\n * Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural\n * change. `add` may return a handle that the same item's later `remove` receives, for items whose\n * teardown needs what `add` produced (as VFL constraints need the objects the layout created).\n */\nconst list = <P extends GObject.Object, I, H = void>(\n prop: string,\n hooks: ListHooks<P, I, H>,\n): ElementBehavior<P> => {\n const { add } = hooks;\n\n return {\n createContext: (): ListState => ({ snapshot: [], entries: [] }),\n update: (object, _prev, next, context) => {\n const state = context as ListState;\n const raw = next[prop];\n const items: unknown[] = Array.isArray(raw) ? raw : [];\n\n if (isDeepEqual(state.snapshot, items)) {\n return [prop];\n }\n\n teardownList(object, state.entries, hooks);\n state.entries = items.map((item) => ({ item, handle: add?.(object, item as I) }));\n state.snapshot = structuredClone(items);\n\n return [prop];\n },\n };\n};\n\nconst flushDeferred = <P extends GObject.Object, V>(\n object: GObject.Object,\n context: unknown,\n prop: string,\n canApply: CanApply<P, V> | undefined,\n): void => {\n const state = context as DeferredState;\n\n if (!state.present || Object.is(state.applied, state.desired)) {\n return;\n }\n\n if (canApply !== undefined && !canApply(object as P, state.desired as V)) {\n return;\n }\n\n Reflect.set(object, prop, state.desired);\n state.applied = state.desired;\n};\n\n/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */\nconst deferred = <P extends GObject.Object, V>(\n prop: string,\n canApply?: CanApply<P, V>,\n): ElementBehavior<P> => ({\n deferred: [prop],\n createContext: (): DeferredState => ({ desired: undefined, present: false, applied: undefined }),\n update: (_object, _prev, next, context) => {\n const state = context as DeferredState;\n state.desired = next[prop];\n state.present = next[prop] !== undefined;\n\n return [prop];\n },\n flush: (object, context) => {\n flushDeferred(object, context, prop, canApply);\n },\n});\n\n/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */\nconst controlledText = (prop: string): ElementBehavior =>\n value(prop, (object, next) => {\n if (!hasSameText(object, prop, next)) {\n Reflect.set(object, prop, next);\n }\n });\n\n/** Behavior for a container that installs its single child with `setChild`. */\nconst childSetterSlot = <P extends ChildSetter>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child) => {\n parent.setChild(child);\n },\n detach: (parent) => {\n parent.setChild(null);\n },\n });\n\n/** Behavior for a container that installs its single child with `setContent`. */\nconst contentSetterSlot = <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(\n childType = \"GtkWidget\",\n): ElementBehavior<P> =>\n slot<P, C>(\"children\", childType, {\n attach: (parent, child) => {\n parent.setContent(child);\n },\n detach: (parent) => {\n parent.setContent(null);\n },\n });\n\n/** Behavior for a `GtkBox`-style container that orders children by sibling. */\nconst boxSlot = <P extends BoxLike>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (box, child, info) => box.insertChildAfter(child, info.sibling as Gtk.Widget | null),\n detach: (box, child) => {\n box.remove(child);\n },\n reorder: (box, child, info) => {\n box.reorderChildAfter(child, info.sibling as Gtk.Widget | null);\n },\n });\n\n/** Behavior for a container whose children are added and removed by a pair of methods. */\nconst addRemoveSlot = <C extends GObject.Object, P extends GObject.Object>(\n slotName: string,\n childType: string,\n add: (parent: P, child: C) => unknown,\n remove: (parent: P, child: C) => void,\n): ElementBehavior => slot<P, C>(slotName, childType, { attach: add, detach: remove });\n\n/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */\nconst adoptedChildrenSlot = <P extends GObject.Object, C extends GObject.Object>(\n childType: string,\n add: (parent: P, item: C) => unknown,\n remove: (parent: P, item: C) => void,\n): ElementBehavior => addRemoveSlot<C, P>(\"children\", childType, add, remove);\n\nconst wrappedRow = <W extends Gtk.Widget>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n rows: RowCache,\n child: Gtk.Widget,\n): Gtk.Widget => {\n if (child instanceof Wrapper) {\n return child;\n }\n\n const existing = rows.get(child);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const wrapper = new Wrapper({});\n setChild(wrapper, child);\n rows.set(child, wrapper);\n\n return wrapper;\n};\n\nconst removeWrappedRow = (\n Wrapper: new (props: Props) => Gtk.Widget,\n parent: IndexedInserter,\n child: Gtk.Widget,\n rows: RowCache,\n): void => {\n const row = child instanceof Wrapper ? child : rows.get(child);\n\n if (row !== undefined) {\n parent.remove(row);\n }\n};\n\n/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */\nconst wrappingIndexedSlot = <W extends Gtk.Widget, P extends IndexedInserter>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n): ElementBehavior<P> => ({\n ...slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child, info) =>\n parent.insert(wrappedRow(Wrapper, setChild, info.context as RowCache, child), info.index),\n detach: (parent, child, info) => {\n removeWrappedRow(Wrapper, parent, child, info.context as RowCache);\n },\n }),\n createContext: (): RowCache => new WeakMap(),\n});\n\nexport {\n slot,\n value,\n list,\n deferred,\n controlledText,\n childSetterSlot,\n contentSetterSlot,\n boxSlot,\n addRemoveSlot,\n adoptedChildrenSlot,\n wrappingIndexedSlot,\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyNode, ParentNode } from "./node.js";
|
|
2
|
+
declare const attachChild: (parent: ParentNode, child: AnyNode, before: AnyNode | null) => void;
|
|
3
|
+
declare const detachChild: (parent: ParentNode, child: AnyNode) => void;
|
|
4
|
+
export { attachChild, detachChild };
|
|
5
|
+
//# sourceMappingURL=child-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-routing.d.ts","sourceRoot":"","sources":["../../src/reconciler/child-routing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAuC,UAAU,EAA2B,MAAM,WAAW,CAAC;AAiInH,QAAA,MAAM,WAAW,GAAI,QAAQ,UAAU,EAAE,OAAO,OAAO,EAAE,QAAQ,OAAO,GAAG,IAAI,KAAG,IAQjF,CAAC;AAqDF,QAAA,MAAM,WAAW,GAAI,QAAQ,UAAU,EAAE,OAAO,OAAO,KAAG,IAQzD,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC"}
|