@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.
- 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/{libraries/adw → adw}/dialog.d.ts +2 -2
- 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 +269 -0
- package/dist/adw/element-behaviors.js.map +1 -0
- package/dist/adw/element-config.d.ts +11 -0
- package/dist/adw/element-config.d.ts.map +1 -0
- package/dist/adw/element-config.js +127 -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 +2 -2
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +31 -18
- package/dist/components/application.js.map +1 -1
- 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 +2 -2
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +22 -12
- package/dist/components/window.js.map +1 -1
- 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 +149 -0
- package/dist/element-config.js.map +1 -0
- package/dist/hooks/use-application.d.ts +4 -3
- package/dist/hooks/use-application.d.ts.map +1 -1
- package/dist/hooks/use-application.js +5 -4
- package/dist/hooks/use-application.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +21 -4
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +27 -16
- package/dist/hooks/use-bind-setting.js.map +1 -1
- 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 +3 -2
- package/dist/hooks/use-object-value.d.ts.map +1 -1
- package/dist/hooks/use-object-value.js +18 -21
- package/dist/hooks/use-object-value.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -2
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -2
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-property.d.ts +5 -5
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +4 -3
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +5 -16
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +16 -11
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +14 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +33 -18
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +7 -7
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +6 -7
- package/dist/internal.js.map +1 -1
- 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 +10 -7
- package/dist/reconciler/apply-props.d.ts.map +1 -1
- package/dist/reconciler/apply-props.js +186 -82
- package/dist/reconciler/apply-props.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +59 -0
- package/dist/reconciler/behaviors.d.ts.map +1 -0
- package/dist/reconciler/behaviors.js +177 -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 +8 -12
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js +171 -270
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.d.ts +4 -5
- package/dist/reconciler/instance.d.ts.map +1 -1
- package/dist/reconciler/instance.js +44 -22
- package/dist/reconciler/instance.js.map +1 -1
- 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 +191 -0
- package/dist/reconciler/placement.js.map +1 -0
- package/dist/reconciler/registry.d.ts +107 -0
- package/dist/reconciler/registry.d.ts.map +1 -0
- package/dist/reconciler/registry.js +74 -0
- package/dist/reconciler/registry.js.map +1 -0
- package/dist/reconciler/root-element.d.ts +9 -12
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +6 -6
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +56 -0
- package/dist/reconciler/root.d.ts.map +1 -0
- package/dist/reconciler/root.js +106 -0
- package/dist/reconciler/root.js.map +1 -0
- package/dist/reconciler/signals.d.ts +9 -0
- package/dist/reconciler/signals.d.ts.map +1 -0
- package/dist/reconciler/signals.js +58 -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 +281 -0
- package/dist/reconciler/text.js.map +1 -0
- package/dist/utils/accessible-metadata.d.ts +11 -4
- package/dist/utils/accessible-metadata.d.ts.map +1 -1
- package/dist/utils/accessible-metadata.js +20 -17
- package/dist/utils/accessible-metadata.js.map +1 -1
- package/dist/{reconciler/accessible.d.ts → utils/accessible-props.d.ts} +7 -6
- 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 +36 -11
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +35 -0
- package/src/adw/element-behaviors.ts +349 -0
- package/src/adw/element-config.ts +131 -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 +42 -23
- package/src/components/element.tsx +47 -0
- package/src/components/window.tsx +26 -14
- package/src/config.ts +10 -0
- package/src/element-behaviors.ts +424 -0
- package/src/element-config.ts +151 -0
- package/src/env.d.ts +1 -0
- package/src/hooks/use-application.ts +6 -4
- package/src/hooks/use-bind-setting.ts +47 -31
- package/src/hooks/use-merged-refs.ts +64 -0
- package/src/hooks/use-object-value.ts +27 -23
- package/src/hooks/use-parent-window.ts +4 -2
- package/src/hooks/use-property.ts +11 -10
- package/src/hooks/use-setting.ts +20 -33
- package/src/hooks/use-signal.ts +41 -48
- package/src/index.ts +7 -8
- package/src/internal.ts +8 -18
- package/src/prop-types.ts +142 -0
- package/src/reconciler/apply-props.ts +239 -85
- package/src/reconciler/behaviors.ts +330 -0
- package/src/reconciler/child-routing.ts +202 -0
- package/src/reconciler/host-config.ts +235 -367
- package/src/reconciler/instance.ts +76 -24
- package/src/reconciler/metadata.ts +119 -0
- package/src/reconciler/node.ts +161 -0
- package/src/reconciler/placement.ts +275 -0
- package/src/reconciler/registry.ts +175 -0
- package/src/reconciler/root-element.ts +9 -11
- package/src/reconciler/root.ts +172 -0
- package/src/reconciler/signals.ts +92 -0
- package/src/reconciler/text.ts +414 -0
- package/src/utils/accessible-metadata.ts +23 -18
- 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/hooks/use-merge-refs.d.ts +0 -3
- package/dist/hooks/use-merge-refs.d.ts.map +0 -1
- package/dist/hooks/use-merge-refs.js +0 -48
- package/dist/hooks/use-merge-refs.js.map +0 -1
- package/dist/hooks/use-object-attachment.d.ts +0 -10
- package/dist/hooks/use-object-attachment.d.ts.map +0 -1
- package/dist/hooks/use-object-attachment.js +0 -24
- package/dist/hooks/use-object-attachment.js.map +0 -1
- package/dist/libraries/adw/dialog.d.ts.map +0 -1
- package/dist/libraries/adw/dialog.js +0 -25
- package/dist/libraries/adw/dialog.js.map +0 -1
- package/dist/libraries/adw/index.d.ts +0 -2
- package/dist/libraries/adw/index.d.ts.map +0 -1
- package/dist/libraries/adw/index.js +0 -2
- package/dist/libraries/adw/index.js.map +0 -1
- package/dist/reconciler/accessible.d.ts.map +0 -1
- package/dist/reconciler/accessible.js +0 -143
- package/dist/reconciler/accessible.js.map +0 -1
- package/dist/reconciler/commit-flush.d.ts +0 -3
- package/dist/reconciler/commit-flush.d.ts.map +0 -1
- package/dist/reconciler/commit-flush.js +0 -13
- package/dist/reconciler/commit-flush.js.map +0 -1
- package/dist/reconciler/container-attach.d.ts +0 -10
- package/dist/reconciler/container-attach.d.ts.map +0 -1
- package/dist/reconciler/container-attach.js +0 -216
- package/dist/reconciler/container-attach.js.map +0 -1
- package/dist/reconciler/content-rebuild.d.ts +0 -3
- package/dist/reconciler/content-rebuild.d.ts.map +0 -1
- package/dist/reconciler/content-rebuild.js +0 -15
- package/dist/reconciler/content-rebuild.js.map +0 -1
- package/dist/reconciler/dispatch.d.ts +0 -6
- package/dist/reconciler/dispatch.d.ts.map +0 -1
- package/dist/reconciler/dispatch.js +0 -61
- package/dist/reconciler/dispatch.js.map +0 -1
- package/dist/reconciler/element-prop-appliers.d.ts +0 -5
- package/dist/reconciler/element-prop-appliers.d.ts.map +0 -1
- package/dist/reconciler/element-prop-appliers.js +0 -104
- package/dist/reconciler/element-prop-appliers.js.map +0 -1
- package/dist/reconciler/element-props.d.ts +0 -25
- package/dist/reconciler/element-props.d.ts.map +0 -1
- package/dist/reconciler/element-props.js +0 -157
- package/dist/reconciler/element-props.js.map +0 -1
- package/dist/reconciler/label-text-rebuild.d.ts +0 -3
- package/dist/reconciler/label-text-rebuild.d.ts.map +0 -1
- package/dist/reconciler/label-text-rebuild.js +0 -22
- package/dist/reconciler/label-text-rebuild.js.map +0 -1
- package/dist/reconciler/portal.d.ts +0 -11
- package/dist/reconciler/portal.d.ts.map +0 -1
- package/dist/reconciler/portal.js +0 -20
- package/dist/reconciler/portal.js.map +0 -1
- package/dist/reconciler/reconciler-error-handler.d.ts +0 -7
- package/dist/reconciler/reconciler-error-handler.d.ts.map +0 -1
- package/dist/reconciler/reconciler-error-handler.js +0 -24
- package/dist/reconciler/reconciler-error-handler.js.map +0 -1
- package/dist/reconciler/reconciler-root.d.ts +0 -19
- package/dist/reconciler/reconciler-root.d.ts.map +0 -1
- package/dist/reconciler/reconciler-root.js +0 -24
- package/dist/reconciler/reconciler-root.js.map +0 -1
- package/dist/reconciler/reconciler.d.ts +0 -3
- package/dist/reconciler/reconciler.d.ts.map +0 -1
- package/dist/reconciler/reconciler.js +0 -12
- package/dist/reconciler/reconciler.js.map +0 -1
- package/dist/reconciler/render.d.ts +0 -23
- package/dist/reconciler/render.d.ts.map +0 -1
- package/dist/reconciler/render.js +0 -46
- package/dist/reconciler/render.js.map +0 -1
- package/dist/reconciler/signal-store.d.ts +0 -22
- package/dist/reconciler/signal-store.d.ts.map +0 -1
- package/dist/reconciler/signal-store.js +0 -84
- package/dist/reconciler/signal-store.js.map +0 -1
- package/dist/reconciler/state.d.ts +0 -36
- package/dist/reconciler/state.d.ts.map +0 -1
- package/dist/reconciler/state.js +0 -38
- package/dist/reconciler/state.js.map +0 -1
- package/dist/reconciler/text-buffer-controller.d.ts +0 -17
- package/dist/reconciler/text-buffer-controller.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-controller.js +0 -102
- package/dist/reconciler/text-buffer-controller.js.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.d.ts +0 -3
- package/dist/reconciler/text-buffer-rebuild.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.js +0 -7
- package/dist/reconciler/text-buffer-rebuild.js.map +0 -1
- package/dist/reconciler/text-node.d.ts +0 -7
- package/dist/reconciler/text-node.d.ts.map +0 -1
- package/dist/reconciler/text-node.js +0 -8
- package/dist/reconciler/text-node.js.map +0 -1
- package/dist/reconciler/types.d.ts +0 -5
- package/dist/reconciler/types.d.ts.map +0 -1
- package/dist/reconciler/types.js +0 -2
- package/dist/reconciler/types.js.map +0 -1
- package/dist/reconciler/visibility.d.ts +0 -6
- package/dist/reconciler/visibility.d.ts.map +0 -1
- package/dist/reconciler/visibility.js +0 -57
- package/dist/reconciler/visibility.js.map +0 -1
- package/dist/reconciler/wrapper-apply.d.ts +0 -6
- package/dist/reconciler/wrapper-apply.d.ts.map +0 -1
- package/dist/reconciler/wrapper-apply.js +0 -287
- package/dist/reconciler/wrapper-apply.js.map +0 -1
- package/dist/reconciler/wrapper-content.d.ts +0 -8
- package/dist/reconciler/wrapper-content.d.ts.map +0 -1
- package/dist/reconciler/wrapper-content.js +0 -19
- package/dist/reconciler/wrapper-content.js.map +0 -1
- package/dist/reconciler/wrapper-node.d.ts +0 -8
- package/dist/reconciler/wrapper-node.d.ts.map +0 -1
- package/dist/reconciler/wrapper-node.js +0 -4
- package/dist/reconciler/wrapper-node.js.map +0 -1
- package/dist/reconciler/wrapper-protocol.d.ts +0 -13
- package/dist/reconciler/wrapper-protocol.d.ts.map +0 -1
- package/dist/reconciler/wrapper-protocol.js +0 -20
- package/dist/reconciler/wrapper-protocol.js.map +0 -1
- package/dist/utils/create-element-component.d.ts +0 -4
- package/dist/utils/create-element-component.d.ts.map +0 -1
- package/dist/utils/create-element-component.js +0 -54
- package/dist/utils/create-element-component.js.map +0 -1
- package/dist/utils/gtype.d.ts +0 -16
- package/dist/utils/gtype.d.ts.map +0 -1
- package/dist/utils/gtype.js +0 -127
- package/dist/utils/gtype.js.map +0 -1
- package/dist/utils/notify-name.d.ts +0 -5
- package/dist/utils/notify-name.d.ts.map +0 -1
- package/dist/utils/notify-name.js +0 -6
- package/dist/utils/notify-name.js.map +0 -1
- package/dist/utils/object-prop.d.ts +0 -8
- package/dist/utils/object-prop.d.ts.map +0 -1
- package/dist/utils/object-prop.js +0 -9
- package/dist/utils/object-prop.js.map +0 -1
- package/dist/utils/settings-accessor.d.ts +0 -8
- package/dist/utils/settings-accessor.d.ts.map +0 -1
- package/dist/utils/settings-accessor.js +0 -69
- package/dist/utils/settings-accessor.js.map +0 -1
- package/dist/utils/wrapper-node-jsx.d.ts +0 -32
- package/dist/utils/wrapper-node-jsx.d.ts.map +0 -1
- package/dist/utils/wrapper-node-jsx.js +0 -2
- package/dist/utils/wrapper-node-jsx.js.map +0 -1
- package/src/hooks/use-merge-refs.ts +0 -53
- package/src/hooks/use-object-attachment.ts +0 -35
- package/src/libraries/adw/dialog.tsx +0 -34
- package/src/libraries/adw/index.ts +0 -1
- package/src/reconciler/accessible.ts +0 -232
- package/src/reconciler/commit-flush.ts +0 -13
- package/src/reconciler/container-attach.ts +0 -219
- package/src/reconciler/content-rebuild.ts +0 -19
- package/src/reconciler/dispatch.ts +0 -58
- package/src/reconciler/element-prop-appliers.ts +0 -110
- package/src/reconciler/element-props.ts +0 -192
- package/src/reconciler/label-text-rebuild.ts +0 -26
- package/src/reconciler/portal.ts +0 -28
- package/src/reconciler/reconciler-error-handler.ts +0 -29
- package/src/reconciler/reconciler-root.ts +0 -57
- package/src/reconciler/reconciler.ts +0 -13
- package/src/reconciler/render.ts +0 -61
- package/src/reconciler/signal-store.ts +0 -103
- package/src/reconciler/state.ts +0 -72
- package/src/reconciler/text-buffer-controller.ts +0 -107
- package/src/reconciler/text-buffer-rebuild.ts +0 -12
- package/src/reconciler/text-node.ts +0 -13
- package/src/reconciler/types.ts +0 -6
- package/src/reconciler/visibility.ts +0 -52
- package/src/reconciler/wrapper-apply.ts +0 -308
- package/src/reconciler/wrapper-content.ts +0 -24
- package/src/reconciler/wrapper-node.ts +0 -8
- package/src/reconciler/wrapper-protocol.ts +0 -32
- package/src/utils/create-element-component.ts +0 -77
- package/src/utils/gtype.ts +0 -166
- package/src/utils/notify-name.ts +0 -10
- package/src/utils/object-prop.ts +0 -13
- package/src/utils/settings-accessor.ts +0 -89
- package/src/utils/wrapper-node-jsx.ts +0 -34
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ElementConfig } from "./reconciler/registry.js";
|
|
2
|
+
declare const SINGLE_CHILD_TYPES: string[];
|
|
3
|
+
/**
|
|
4
|
+
* The static, runtime-free half of the built-in element configuration: which base props interface each
|
|
5
|
+
* generated element extends, which component wraps it, and whether its GObject is created lazily by its
|
|
6
|
+
* parent. Codegen imports this module, so it must never reach the GObject bindings.
|
|
7
|
+
*/
|
|
8
|
+
declare const BUILTIN_ELEMENTS: Record<string, ElementConfig>;
|
|
9
|
+
export { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };
|
|
10
|
+
//# sourceMappingURL=element-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-config.d.ts","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,0BAA0B,CAAC;AAElF,QAAA,MAAM,kBAAkB,EAAE,MAAM,EAsB/B,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAqHnD,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { forTypes, internal } from "./reconciler/registry.js";
|
|
2
|
+
const SINGLE_CHILD_TYPES = [
|
|
3
|
+
"GtkAspectFrame",
|
|
4
|
+
"GtkButton",
|
|
5
|
+
"GtkCheckButton",
|
|
6
|
+
"GtkComboBox",
|
|
7
|
+
"GtkDragIcon",
|
|
8
|
+
"GtkExpander",
|
|
9
|
+
"GtkFlowBoxChild",
|
|
10
|
+
"GtkFrame",
|
|
11
|
+
"GtkGraphicsOffload",
|
|
12
|
+
"GtkListBoxRow",
|
|
13
|
+
"GtkListHeader",
|
|
14
|
+
"GtkListItem",
|
|
15
|
+
"GtkMenuButton",
|
|
16
|
+
"GtkPopover",
|
|
17
|
+
"GtkPopoverBin",
|
|
18
|
+
"GtkRevealer",
|
|
19
|
+
"GtkScrolledWindow",
|
|
20
|
+
"GtkSearchBar",
|
|
21
|
+
"GtkTreeExpander",
|
|
22
|
+
"GtkViewport",
|
|
23
|
+
"GtkWindowHandle",
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* The static, runtime-free half of the built-in element configuration: which base props interface each
|
|
27
|
+
* generated element extends, which component wraps it, and whether its GObject is created lazily by its
|
|
28
|
+
* parent. Codegen imports this module, so it must never reach the GObject bindings.
|
|
29
|
+
*/
|
|
30
|
+
const BUILTIN_ELEMENTS = {
|
|
31
|
+
...forTypes(SINGLE_CHILD_TYPES, {
|
|
32
|
+
props: internal("ChildrenProps"),
|
|
33
|
+
omitProps: ["child"],
|
|
34
|
+
}),
|
|
35
|
+
...forTypes(["GtkHeaderBar", "GtkActionBar"], {
|
|
36
|
+
props: internal("GtkHeaderBarProps"),
|
|
37
|
+
}),
|
|
38
|
+
GtkWindow: {
|
|
39
|
+
props: internal("ChildrenProps"),
|
|
40
|
+
component: internal("createWindowComponent"),
|
|
41
|
+
omitProps: ["child"],
|
|
42
|
+
},
|
|
43
|
+
GtkLabel: {
|
|
44
|
+
props: internal("ChildrenProps"),
|
|
45
|
+
},
|
|
46
|
+
GtkTextBuffer: {
|
|
47
|
+
props: internal("ChildrenProps"),
|
|
48
|
+
},
|
|
49
|
+
GtkTextTag: {
|
|
50
|
+
props: internal("ChildrenProps"),
|
|
51
|
+
},
|
|
52
|
+
GtkTextChildAnchor: {
|
|
53
|
+
props: internal("GtkTextChildAnchorProps"),
|
|
54
|
+
},
|
|
55
|
+
GtkGridLayoutChild: {
|
|
56
|
+
lazy: true,
|
|
57
|
+
},
|
|
58
|
+
GtkFixedLayoutChild: {
|
|
59
|
+
lazy: true,
|
|
60
|
+
},
|
|
61
|
+
GtkOverlayLayoutChild: {
|
|
62
|
+
lazy: true,
|
|
63
|
+
},
|
|
64
|
+
GtkStackPage: {
|
|
65
|
+
lazy: true,
|
|
66
|
+
},
|
|
67
|
+
GtkNotebookPage: {
|
|
68
|
+
lazy: true,
|
|
69
|
+
},
|
|
70
|
+
GActionGroup: {
|
|
71
|
+
props: internal("GActionGroupProps"),
|
|
72
|
+
},
|
|
73
|
+
GtkWidget: {
|
|
74
|
+
props: internal("GtkWidgetProps"),
|
|
75
|
+
},
|
|
76
|
+
GtkBox: {
|
|
77
|
+
props: internal("ChildrenProps"),
|
|
78
|
+
},
|
|
79
|
+
GtkListBox: {
|
|
80
|
+
props: internal("ChildrenProps"),
|
|
81
|
+
},
|
|
82
|
+
GtkFlowBox: {
|
|
83
|
+
props: internal("ChildrenProps"),
|
|
84
|
+
},
|
|
85
|
+
GtkOverlay: {
|
|
86
|
+
props: internal("GtkOverlayProps"),
|
|
87
|
+
omitProps: ["child"],
|
|
88
|
+
},
|
|
89
|
+
GtkShortcutController: {
|
|
90
|
+
props: internal("GtkShortcutControllerProps"),
|
|
91
|
+
},
|
|
92
|
+
GtkTextView: {
|
|
93
|
+
props: internal("ChildrenProps"),
|
|
94
|
+
},
|
|
95
|
+
GActionMap: {
|
|
96
|
+
props: internal("GActionMapProps"),
|
|
97
|
+
},
|
|
98
|
+
GMenu: {
|
|
99
|
+
props: internal("GMenuProps"),
|
|
100
|
+
},
|
|
101
|
+
GtkColumnView: {
|
|
102
|
+
props: internal("ChildrenProps"),
|
|
103
|
+
},
|
|
104
|
+
GtkGrid: {
|
|
105
|
+
props: internal("ChildrenProps"),
|
|
106
|
+
},
|
|
107
|
+
GtkFixed: {
|
|
108
|
+
props: internal("ChildrenProps"),
|
|
109
|
+
},
|
|
110
|
+
GtkSizeGroup: {
|
|
111
|
+
props: internal("GtkSizeGroupProps"),
|
|
112
|
+
},
|
|
113
|
+
GtkConstraintLayout: {
|
|
114
|
+
props: internal("GtkConstraintLayoutProps"),
|
|
115
|
+
},
|
|
116
|
+
GtkStack: {
|
|
117
|
+
props: internal("ChildrenProps"),
|
|
118
|
+
},
|
|
119
|
+
GtkNotebook: {
|
|
120
|
+
props: internal("ChildrenProps"),
|
|
121
|
+
},
|
|
122
|
+
GtkApplication: {
|
|
123
|
+
props: internal("GtkApplicationProps"),
|
|
124
|
+
component: internal("createApplicationComponent"),
|
|
125
|
+
},
|
|
126
|
+
GtkAboutDialog: {
|
|
127
|
+
props: internal("GtkAboutDialogProps"),
|
|
128
|
+
},
|
|
129
|
+
GtkScale: {
|
|
130
|
+
props: internal("GtkScaleProps"),
|
|
131
|
+
},
|
|
132
|
+
GtkCalendar: {
|
|
133
|
+
props: internal("GtkCalendarProps"),
|
|
134
|
+
},
|
|
135
|
+
GtkLevelBar: {
|
|
136
|
+
props: internal("GtkLevelBarProps"),
|
|
137
|
+
},
|
|
138
|
+
GtkDropTarget: {
|
|
139
|
+
props: internal("GtkDropTargetProps"),
|
|
140
|
+
},
|
|
141
|
+
GtkDrawingArea: {
|
|
142
|
+
props: internal("GtkDrawingAreaProps"),
|
|
143
|
+
},
|
|
144
|
+
GtkDragSource: {
|
|
145
|
+
props: internal("GtkDragSourceProps"),
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
export { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };
|
|
149
|
+
//# sourceMappingURL=element-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-config.js","sourceRoot":"","sources":["../src/element-config.ts"],"names":[],"mappings":"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","sourcesContent":["import { type ElementConfig, forTypes, internal } from \"./reconciler/registry.js\";\n\nconst SINGLE_CHILD_TYPES: string[] = [\n \"GtkAspectFrame\",\n \"GtkButton\",\n \"GtkCheckButton\",\n \"GtkComboBox\",\n \"GtkDragIcon\",\n \"GtkExpander\",\n \"GtkFlowBoxChild\",\n \"GtkFrame\",\n \"GtkGraphicsOffload\",\n \"GtkListBoxRow\",\n \"GtkListHeader\",\n \"GtkListItem\",\n \"GtkMenuButton\",\n \"GtkPopover\",\n \"GtkPopoverBin\",\n \"GtkRevealer\",\n \"GtkScrolledWindow\",\n \"GtkSearchBar\",\n \"GtkTreeExpander\",\n \"GtkViewport\",\n \"GtkWindowHandle\",\n];\n\n/**\n * The static, runtime-free half of the built-in element configuration: which base props interface each\n * generated element extends, which component wraps it, and whether its GObject is created lazily by its\n * parent. Codegen imports this module, so it must never reach the GObject bindings.\n */\nconst BUILTIN_ELEMENTS: Record<string, ElementConfig> = {\n ...forTypes(SINGLE_CHILD_TYPES, {\n props: internal(\"ChildrenProps\"),\n omitProps: [\"child\"],\n }),\n ...forTypes([\"GtkHeaderBar\", \"GtkActionBar\"], {\n props: internal(\"GtkHeaderBarProps\"),\n }),\n GtkWindow: {\n props: internal(\"ChildrenProps\"),\n component: internal(\"createWindowComponent\"),\n omitProps: [\"child\"],\n },\n GtkLabel: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextBuffer: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextTag: {\n props: internal(\"ChildrenProps\"),\n },\n GtkTextChildAnchor: {\n props: internal(\"GtkTextChildAnchorProps\"),\n },\n GtkGridLayoutChild: {\n lazy: true,\n },\n GtkFixedLayoutChild: {\n lazy: true,\n },\n GtkOverlayLayoutChild: {\n lazy: true,\n },\n GtkStackPage: {\n lazy: true,\n },\n GtkNotebookPage: {\n lazy: true,\n },\n GActionGroup: {\n props: internal(\"GActionGroupProps\"),\n },\n GtkWidget: {\n props: internal(\"GtkWidgetProps\"),\n },\n GtkBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkListBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFlowBox: {\n props: internal(\"ChildrenProps\"),\n },\n GtkOverlay: {\n props: internal(\"GtkOverlayProps\"),\n omitProps: [\"child\"],\n },\n GtkShortcutController: {\n props: internal(\"GtkShortcutControllerProps\"),\n },\n GtkTextView: {\n props: internal(\"ChildrenProps\"),\n },\n GActionMap: {\n props: internal(\"GActionMapProps\"),\n },\n GMenu: {\n props: internal(\"GMenuProps\"),\n },\n GtkColumnView: {\n props: internal(\"ChildrenProps\"),\n },\n GtkGrid: {\n props: internal(\"ChildrenProps\"),\n },\n GtkFixed: {\n props: internal(\"ChildrenProps\"),\n },\n GtkSizeGroup: {\n props: internal(\"GtkSizeGroupProps\"),\n },\n GtkConstraintLayout: {\n props: internal(\"GtkConstraintLayoutProps\"),\n },\n GtkStack: {\n props: internal(\"ChildrenProps\"),\n },\n GtkNotebook: {\n props: internal(\"ChildrenProps\"),\n },\n GtkApplication: {\n props: internal(\"GtkApplicationProps\"),\n component: internal(\"createApplicationComponent\"),\n },\n GtkAboutDialog: {\n props: internal(\"GtkAboutDialogProps\"),\n },\n GtkScale: {\n props: internal(\"GtkScaleProps\"),\n },\n GtkCalendar: {\n props: internal(\"GtkCalendarProps\"),\n },\n GtkLevelBar: {\n props: internal(\"GtkLevelBarProps\"),\n },\n GtkDropTarget: {\n props: internal(\"GtkDropTargetProps\"),\n },\n GtkDrawingArea: {\n props: internal(\"GtkDrawingAreaProps\"),\n },\n GtkDragSource: {\n props: internal(\"GtkDragSourceProps\"),\n },\n};\n\nexport { SINGLE_CHILD_TYPES, BUILTIN_ELEMENTS };\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type Context } from "react";
|
|
3
|
-
|
|
3
|
+
declare const ApplicationContext: Context<Gtk.Application | null>;
|
|
4
4
|
/**
|
|
5
|
-
* Returns the `Gtk.Application` provided by the nearest `
|
|
5
|
+
* Returns the `Gtk.Application` provided by the nearest `GtkApplication` ancestor, throwing if used outside one.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare const useApplication: () => Gtk.Application;
|
|
8
|
+
export { ApplicationContext, useApplication };
|
|
8
9
|
//# sourceMappingURL=use-application.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-application.d.ts","sourceRoot":"","sources":["../../src/hooks/use-application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"use-application.d.ts","sourceRoot":"","sources":["../../src/hooks/use-application.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,QAAA,MAAM,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAA+C,CAAC;AAExG;;GAEG;AACH,QAAA,MAAM,cAAc,QAAO,GAAG,CAAC,WAQ9B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createContext, use } from "react";
|
|
2
|
-
|
|
2
|
+
const ApplicationContext = createContext(null);
|
|
3
3
|
/**
|
|
4
|
-
* Returns the `Gtk.Application` provided by the nearest `
|
|
4
|
+
* Returns the `Gtk.Application` provided by the nearest `GtkApplication` ancestor, throwing if used outside one.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const useApplication = () => {
|
|
7
7
|
const context = use(ApplicationContext);
|
|
8
8
|
if (!context) {
|
|
9
|
-
throw new Error("
|
|
9
|
+
throw new Error("useApplication must be called within GtkApplication");
|
|
10
10
|
}
|
|
11
11
|
return context;
|
|
12
12
|
};
|
|
13
|
+
export { ApplicationContext, useApplication };
|
|
13
14
|
//# sourceMappingURL=use-application.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-application.js","sourceRoot":"","sources":["../../src/hooks/use-application.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,
|
|
1
|
+
{"version":3,"file":"use-application.js","sourceRoot":"","sources":["../../src/hooks/use-application.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,kBAAkB,GAAoC,aAAa,CAAyB,IAAI,CAAC,CAAC;AAExG;;GAEG;AACH,MAAM,cAAc,GAAG,GAAoB,EAAE;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type Context, createContext, use } from \"react\";\n\nconst ApplicationContext: Context<Gtk.Application | null> = createContext<Gtk.Application | null>(null);\n\n/**\n * Returns the `Gtk.Application` provided by the nearest `GtkApplication` ancestor, throwing if used outside one.\n */\nconst useApplication = (): Gtk.Application => {\n const context = use(ApplicationContext);\n\n if (!context) {\n throw new Error(\"useApplication must be called within GtkApplication\");\n }\n\n return context;\n};\n\nexport { ApplicationContext, useApplication };\n"]}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import * as Gio from "@gtkx/gi/gio";
|
|
2
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import * as Gio from "@gtkx/gi/gio";
|
|
3
|
+
import type { SettingsSchema, SettingsSchemaKeys } from "../utils/settings.js";
|
|
4
|
+
import { type RefProp } from "../utils/ref-prop.js";
|
|
5
|
+
type UseBindSettingOptions<K extends SettingsSchemaKeys> = {
|
|
6
|
+
schema: SettingsSchema<K>;
|
|
7
|
+
key: keyof K & string;
|
|
8
|
+
object: RefProp<GObject.Object>;
|
|
9
|
+
property: string;
|
|
10
|
+
flags?: Gio.SettingsBindFlags;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.
|
|
14
|
+
*
|
|
15
|
+
* @param options.schema The schema reference identifying the settings backend.
|
|
16
|
+
* @param options.key The key within the schema to bind.
|
|
17
|
+
* @param options.object The GObject whose property is bound to the setting.
|
|
18
|
+
* @param options.property The name of the object property to bind.
|
|
19
|
+
* @param options.flags Flags controlling the binding's direction and behaviour.
|
|
20
|
+
*/
|
|
21
|
+
declare function useBindSetting<K extends SettingsSchemaKeys>({ schema, key, object, property, flags, }: UseBindSettingOptions<K>): void;
|
|
22
|
+
export { useBindSetting };
|
|
6
23
|
//# sourceMappingURL=use-bind-setting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-bind-setting.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"use-bind-setting.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,sBAAsB,CAAC;AAGpE,KAAK,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,IAAI;IACvD,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC;CACjC,CAAC;AAEF;;;;;;;;GAQG;AACH,iBAAS,cAAc,CAAC,CAAC,SAAS,kBAAkB,EAAE,EAClD,MAAM,EACN,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAqC,GACxC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI,CAiBjC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
import * as Gio from "@gtkx/gi/gio";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { kebabCase } from "@gtkx/utils";
|
|
3
|
+
import { useLayoutEffect } from "react";
|
|
4
|
+
import { resolveRefProp } from "../utils/ref-prop.js";
|
|
5
|
+
import { useSettings } from "./use-setting.js";
|
|
6
|
+
/**
|
|
7
|
+
* Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.
|
|
8
|
+
*
|
|
9
|
+
* @param options.schema The schema reference identifying the settings backend.
|
|
10
|
+
* @param options.key The key within the schema to bind.
|
|
11
|
+
* @param options.object The GObject whose property is bound to the setting.
|
|
12
|
+
* @param options.property The name of the object property to bind.
|
|
13
|
+
* @param options.flags Flags controlling the binding's direction and behaviour.
|
|
14
|
+
*/
|
|
15
|
+
function useBindSetting({ schema, key, object, property, flags = Gio.SettingsBindFlags.DEFAULT, }) {
|
|
16
|
+
const settings = useSettings(schema);
|
|
17
|
+
const propertyName = kebabCase(property);
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
const resolved = resolveRefProp(object);
|
|
20
|
+
if (!resolved) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
settings.bind(key, resolved, propertyName, flags);
|
|
24
|
+
return () => {
|
|
25
|
+
Gio.Settings.unbind(resolved, propertyName);
|
|
26
|
+
};
|
|
27
|
+
}, [settings, key, object, propertyName, flags]);
|
|
18
28
|
}
|
|
29
|
+
export { useBindSetting };
|
|
19
30
|
//# sourceMappingURL=use-bind-setting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-bind-setting.js","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-bind-setting.js","sourceRoot":"","sources":["../../src/hooks/use-bind-setting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAU/C;;;;;;;;GAQG;AACH,SAAS,cAAc,CAA+B,EAClD,MAAM,EACN,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,OAAO,GACd;IACvB,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEzC,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACR,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport { useLayoutEffect } from \"react\";\nimport type { SettingsSchema, SettingsSchemaKeys } from \"../utils/settings.js\";\nimport { type RefProp, resolveRefProp } from \"../utils/ref-prop.js\";\nimport { useSettings } from \"./use-setting.js\";\n\ntype UseBindSettingOptions<K extends SettingsSchemaKeys> = {\n schema: SettingsSchema<K>;\n key: keyof K & string;\n object: RefProp<GObject.Object>;\n property: string;\n flags?: Gio.SettingsBindFlags;\n};\n\n/**\n * Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.\n *\n * @param options.schema The schema reference identifying the settings backend.\n * @param options.key The key within the schema to bind.\n * @param options.object The GObject whose property is bound to the setting.\n * @param options.property The name of the object property to bind.\n * @param options.flags Flags controlling the binding's direction and behaviour.\n */\nfunction useBindSetting<K extends SettingsSchemaKeys>({\n schema,\n key,\n object,\n property,\n flags = Gio.SettingsBindFlags.DEFAULT,\n}: UseBindSettingOptions<K>): void {\n const settings = useSettings(schema);\n const propertyName = kebabCase(property);\n\n useLayoutEffect(() => {\n const resolved = resolveRefProp(object);\n\n if (!resolved) {\n return;\n }\n\n settings.bind(key, resolved, propertyName, flags);\n\n return () => {\n Gio.Settings.unbind(resolved, propertyName);\n };\n }, [settings, key, object, propertyName, flags]);\n}\n\nexport { useBindSetting };\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Ref, type RefCallback } from "react";
|
|
2
|
+
type PossibleRef<T> = Ref<T> | undefined;
|
|
3
|
+
type RefCleanup<T> = ReturnType<RefCallback<T>>;
|
|
4
|
+
declare function assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T>;
|
|
5
|
+
declare function mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T>;
|
|
6
|
+
declare function useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T>;
|
|
7
|
+
export { assignRef, mergeRefs, useMergedRef };
|
|
8
|
+
//# sourceMappingURL=use-merged-refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-merged-refs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAAW,MAAM,OAAO,CAAC;AAE5D,KAAK,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACzC,KAAK,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAGhD,iBAAS,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAQlE;AAsCD,iBAAS,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAI/D;AAED,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtF;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isRecord } from "@gtkx/utils";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
function assignRef(ref, value) {
|
|
4
|
+
if (typeof ref === "function") {
|
|
5
|
+
return ref(value);
|
|
6
|
+
}
|
|
7
|
+
if (isRecord(ref) && "current" in ref) {
|
|
8
|
+
ref.current = value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function collectCleanup(cleanupMap, ref, node) {
|
|
12
|
+
const cleanup = assignRef(ref, node);
|
|
13
|
+
if (cleanup) {
|
|
14
|
+
cleanupMap.set(ref, cleanup);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function cleanupRef(cleanupMap, ref) {
|
|
18
|
+
const cleanup = cleanupMap.get(ref);
|
|
19
|
+
if (cleanup && typeof cleanup === "function") {
|
|
20
|
+
cleanup();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
assignRef(ref, null);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function applyRefs(cleanupMap, refs, node) {
|
|
27
|
+
for (const ref of refs) {
|
|
28
|
+
collectCleanup(cleanupMap, ref, node);
|
|
29
|
+
}
|
|
30
|
+
if (cleanupMap.size === 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return () => {
|
|
34
|
+
for (const ref of refs) {
|
|
35
|
+
cleanupRef(cleanupMap, ref);
|
|
36
|
+
}
|
|
37
|
+
cleanupMap.clear();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function mergeRefs(...refs) {
|
|
41
|
+
const cleanupMap = new Map();
|
|
42
|
+
return (node) => applyRefs(cleanupMap, refs, node);
|
|
43
|
+
}
|
|
44
|
+
function useMergedRef(first, second) {
|
|
45
|
+
return useMemo(() => mergeRefs(first, second), [first, second]);
|
|
46
|
+
}
|
|
47
|
+
export { assignRef, mergeRefs, useMergedRef };
|
|
48
|
+
//# sourceMappingURL=use-merged-refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-merged-refs.js","sourceRoot":"","sources":["../../src/hooks/use-merged-refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAA8B,OAAO,EAAE,MAAM,OAAO,CAAC;AAM5D,SAAS,SAAS,CAAI,GAAmB,EAAE,KAAQ;IAC/C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACxB,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAI,UAAyB,EAAE,GAAmB,EAAE,IAAc;IACrF,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAErC,IAAI,OAAO,EAAE,CAAC;QACV,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAI,UAAyB,EAAE,GAAmB;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACd,CAAC;SAAM,CAAC;QACJ,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAI,UAAyB,EAAE,IAAsB,EAAE,IAAc;IACnF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACX,CAAC;IAED,OAAO,GAAG,EAAE;QACR,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAChC,CAAC;QAED,UAAU,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CAAC;AACN,CAAC;AAED,SAAS,SAAS,CAAI,GAAG,IAAsB;IAC3C,MAAM,UAAU,GAAkB,IAAI,GAAG,EAAE,CAAC;IAE5C,OAAO,CAAC,IAAc,EAAiB,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CAAI,KAAqB,EAAE,MAAsB;IAClE,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { isRecord } from \"@gtkx/utils\";\nimport { type Ref, type RefCallback, useMemo } from \"react\";\n\ntype PossibleRef<T> = Ref<T> | undefined;\ntype RefCleanup<T> = ReturnType<RefCallback<T>>;\ntype CleanupMap<T> = Map<PossibleRef<T>, Exclude<RefCleanup<T>, void>>;\n\nfunction assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T> {\n if (typeof ref === \"function\") {\n return ref(value);\n }\n\n if (isRecord(ref) && \"current\" in ref) {\n ref.current = value;\n }\n}\n\nfunction collectCleanup<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>, node: T | null): void {\n const cleanup = assignRef(ref, node);\n\n if (cleanup) {\n cleanupMap.set(ref, cleanup);\n }\n}\n\nfunction cleanupRef<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>): void {\n const cleanup = cleanupMap.get(ref);\n\n if (cleanup && typeof cleanup === \"function\") {\n cleanup();\n } else {\n assignRef(ref, null);\n }\n}\n\nfunction applyRefs<T>(cleanupMap: CleanupMap<T>, refs: PossibleRef<T>[], node: T | null): RefCleanup<T> {\n for (const ref of refs) {\n collectCleanup(cleanupMap, ref, node);\n }\n\n if (cleanupMap.size === 0) {\n return;\n }\n\n return () => {\n for (const ref of refs) {\n cleanupRef(cleanupMap, ref);\n }\n\n cleanupMap.clear();\n };\n}\n\nfunction mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T> {\n const cleanupMap: CleanupMap<T> = new Map();\n\n return (node: T | null): RefCleanup<T> => applyRefs(cleanupMap, refs, node);\n}\n\nfunction useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T> {\n return useMemo(() => mergeRefs(first, second), [first, second]);\n}\n\nexport { assignRef, mergeRefs, useMergedRef };\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import { type
|
|
3
|
-
|
|
2
|
+
import { type RefProp } from "../utils/ref-prop.js";
|
|
3
|
+
declare function useObjectValue<T extends GObject.Object, V>(object: RefProp<T>, signal: string, read: (object: T | null) => V): V;
|
|
4
|
+
export { useObjectValue };
|
|
4
5
|
//# sourceMappingURL=use-object-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-object-value.d.ts","sourceRoot":"","sources":["../../src/hooks/use-object-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"use-object-value.d.ts","sourceRoot":"","sources":["../../src/hooks/use-object-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,sBAAsB,CAAC;AAQpE,iBAAS,cAAc,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,EAC/C,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,GAC9B,CAAC,CAoCH;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const resolved =
|
|
5
|
-
const readRef = useRef(read);
|
|
6
|
-
readRef.current = read;
|
|
2
|
+
import { resolveRefProp } from "../utils/ref-prop.js";
|
|
3
|
+
function useObjectValue(object, signal, read) {
|
|
4
|
+
const resolved = resolveRefProp(object);
|
|
7
5
|
const cacheRef = useRef(null);
|
|
8
|
-
const readNow = useCallback(() => {
|
|
9
|
-
const cache = { object: resolved, signal, value: readRef.current(resolved) };
|
|
10
|
-
cacheRef.current = cache;
|
|
11
|
-
return cache;
|
|
12
|
-
}, [resolved, signal]);
|
|
13
|
-
const getSnapshot = useCallback(() => {
|
|
14
|
-
const cache = cacheRef.current;
|
|
15
|
-
if (cache !== null && cache.object === resolved && cache.signal === signal) {
|
|
16
|
-
return cache.value;
|
|
17
|
-
}
|
|
18
|
-
return readNow().value;
|
|
19
|
-
}, [resolved, signal, readNow]);
|
|
20
6
|
const subscribe = useCallback((onStoreChange) => {
|
|
21
|
-
if (resolved === null)
|
|
22
|
-
return () =>
|
|
7
|
+
if (resolved === null) {
|
|
8
|
+
return () => undefined;
|
|
9
|
+
}
|
|
23
10
|
const handler = () => {
|
|
24
|
-
|
|
11
|
+
cacheRef.current = null;
|
|
25
12
|
onStoreChange();
|
|
26
13
|
};
|
|
27
14
|
resolved.on(signal, handler);
|
|
28
15
|
return () => resolved.off(signal, handler);
|
|
29
|
-
}, [resolved, signal
|
|
16
|
+
}, [resolved, signal]);
|
|
17
|
+
const getSnapshot = () => {
|
|
18
|
+
const cache = cacheRef.current;
|
|
19
|
+
if (cache !== null && cache.object === resolved && cache.signal === signal) {
|
|
20
|
+
return cache.value;
|
|
21
|
+
}
|
|
22
|
+
const value = read(resolved);
|
|
23
|
+
cacheRef.current = { object: resolved, signal, value };
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
30
26
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
31
27
|
}
|
|
28
|
+
export { useObjectValue };
|
|
32
29
|
//# sourceMappingURL=use-object-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-object-value.js","sourceRoot":"","sources":["../../src/hooks/use-object-value.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"use-object-value.js","sourceRoot":"","sources":["../../src/hooks/use-object-value.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQpE,SAAS,cAAc,CACnB,MAAkB,EAClB,MAAc,EACd,IAA6B;IAE7B,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAgC,IAAI,CAAC,CAAC;IAE7D,MAAM,SAAS,GAAG,WAAW,CACzB,CAAC,aAAyB,EAAgB,EAAE;QACxC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,GAAS,EAAE,CAAC,SAAS,CAAC;QACjC,CAAC;QAED,MAAM,OAAO,GAAkB,GAAG,EAAE;YAChC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,aAAa,EAAE,CAAC;QACpB,CAAC,CAAC;QAEF,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE7B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC,EACD,CAAC,QAAQ,EAAE,MAAM,CAAC,CACrB,CAAC;IAEF,MAAM,WAAW,GAAG,GAAM,EAAE;QACxB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC;QAE/B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC,KAAK,CAAC;QACvB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,QAAQ,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAEvD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AACrE,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type { SignalHandler } from \"@gtkx/runtime\";\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\nimport { type RefProp, resolveRefProp } from \"../utils/ref-prop.js\";\n\ntype ObjectValueCache<T extends GObject.Object, V> = {\n object: T | null;\n signal: string;\n value: V;\n};\n\nfunction useObjectValue<T extends GObject.Object, V>(\n object: RefProp<T>,\n signal: string,\n read: (object: T | null) => V,\n): V {\n const resolved = resolveRefProp(object);\n const cacheRef = useRef<ObjectValueCache<T, V> | null>(null);\n\n const subscribe = useCallback(\n (onStoreChange: () => void): (() => void) => {\n if (resolved === null) {\n return (): void => undefined;\n }\n\n const handler: SignalHandler = () => {\n cacheRef.current = null;\n onStoreChange();\n };\n\n resolved.on(signal, handler);\n\n return () => resolved.off(signal, handler);\n },\n [resolved, signal],\n );\n\n const getSnapshot = (): V => {\n const cache = cacheRef.current;\n\n if (cache !== null && cache.object === resolved && cache.signal === signal) {\n return cache.value;\n }\n\n const value = read(resolved);\n cacheRef.current = { object: resolved, signal, value };\n\n return value;\n };\n\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport { useObjectValue };\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type Context } from "react";
|
|
3
|
-
|
|
3
|
+
declare const ParentWindowContext: Context<Gtk.Window | null>;
|
|
4
4
|
/**
|
|
5
5
|
* Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare const useParentWindow: () => Gtk.Window | null;
|
|
8
|
+
export { ParentWindowContext, useParentWindow };
|
|
8
9
|
//# sourceMappingURL=use-parent-window.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-parent-window.d.ts","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"use-parent-window.d.ts","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,OAAO,CAAC;AAEzD,QAAA,MAAM,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAA0C,CAAC;AAE/F;;GAEG;AACH,QAAA,MAAM,eAAe,QAAO,GAAG,CAAC,MAAM,GAAG,IAAgC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createContext, use } from "react";
|
|
2
|
-
|
|
2
|
+
const ParentWindowContext = createContext(null);
|
|
3
3
|
/**
|
|
4
4
|
* Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const useParentWindow = () => use(ParentWindowContext);
|
|
7
|
+
export { ParentWindowContext, useParentWindow };
|
|
7
8
|
//# sourceMappingURL=use-parent-window.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-parent-window.js","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,
|
|
1
|
+
{"version":3,"file":"use-parent-window.js","sourceRoot":"","sources":["../../src/hooks/use-parent-window.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,mBAAmB,GAA+B,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,eAAe,GAAG,GAAsB,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport { type Context, createContext, use } from \"react\";\n\nconst ParentWindowContext: Context<Gtk.Window | null> = createContext<Gtk.Window | null>(null);\n\n/**\n * Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.\n */\nconst useParentWindow = (): Gtk.Window | null => use(ParentWindowContext);\n\nexport { ParentWindowContext, useParentWindow };\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
4
|
-
|
|
2
|
+
import type { RefProp } from "../utils/ref-prop.js";
|
|
3
|
+
type Properties<T extends GObject.Object> = NonNullable<T["__properties__"]>;
|
|
4
|
+
type PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;
|
|
5
5
|
/**
|
|
6
6
|
* Subscribes to a GObject property and returns its current value, re-rendering when the property changes.
|
|
7
7
|
*
|
|
@@ -9,6 +9,6 @@ export type PropertyNameOf<T extends GObject.Object> = keyof PropertiesOf<T> & k
|
|
|
9
9
|
* @param propertyName The camelCase name of a readable property on the object.
|
|
10
10
|
* @returns The current property value, or `undefined` when the object is not resolved.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
export {};
|
|
12
|
+
declare function useProperty<T extends GObject.Object, P extends PropertyName<T>>(object: RefProp<T>, propertyName: P & string): T[P] | undefined;
|
|
13
|
+
export { useProperty, type PropertyName };
|
|
14
14
|
//# sourceMappingURL=use-property.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-property.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"use-property.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAC7E,KAAK,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI,MAAM,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,iBAAS,WAAW,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,YAAY,EAAE,CAAC,GAAG,MAAM,GACzB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAElB;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kebabCase } from "@gtkx/utils";
|
|
2
2
|
import { useObjectValue } from "./use-object-value.js";
|
|
3
3
|
/**
|
|
4
4
|
* Subscribes to a GObject property and returns its current value, re-rendering when the property changes.
|
|
@@ -7,7 +7,8 @@ import { useObjectValue } from "./use-object-value.js";
|
|
|
7
7
|
* @param propertyName The camelCase name of a readable property on the object.
|
|
8
8
|
* @returns The current property value, or `undefined` when the object is not resolved.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
return useObjectValue(object,
|
|
10
|
+
function useProperty(object, propertyName) {
|
|
11
|
+
return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);
|
|
12
12
|
}
|
|
13
|
+
export { useProperty };
|
|
13
14
|
//# sourceMappingURL=use-property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-property.js","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-property.js","sourceRoot":"","sources":["../../src/hooks/use-property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD;;;;;;GAMG;AACH,SAAS,WAAW,CAChB,MAAkB,EAClB,YAAwB;IAExB,OAAO,cAAc,CAAC,MAAM,EAAE,WAAW,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACtG,CAAC;AAED,OAAO,EAAE,WAAW,EAAqB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { kebabCase } from \"@gtkx/utils\";\nimport type { RefProp } from \"../utils/ref-prop.js\";\nimport { useObjectValue } from \"./use-object-value.js\";\n\ntype Properties<T extends GObject.Object> = NonNullable<T[\"__properties__\"]>;\ntype PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;\n\n/**\n * Subscribes to a GObject property and returns its current value, re-rendering when the property changes.\n *\n * @param object The GObject (or ref to one) whose property to observe.\n * @param propertyName The camelCase name of a readable property on the object.\n * @returns The current property value, or `undefined` when the object is not resolved.\n */\nfunction useProperty<T extends GObject.Object, P extends PropertyName<T>>(\n object: RefProp<T>,\n propertyName: P & string,\n): T[P] | undefined {\n return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);\n}\n\nexport { useProperty, type PropertyName };\n"]}
|