@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
|
@@ -1,35 +1,51 @@
|
|
|
1
|
-
import * as Gio from "@gtkx/gi/gio";
|
|
2
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import * as Gio from "@gtkx/gi/gio";
|
|
3
|
+
import { kebabCase } from "@gtkx/utils";
|
|
4
|
+
import { useLayoutEffect } from "react";
|
|
5
|
+
import type { SettingsSchema, SettingsSchemaKeys } from "../utils/settings.js";
|
|
6
|
+
import { type RefProp, resolveRefProp } from "../utils/ref-prop.js";
|
|
7
|
+
import { useSettings } from "./use-setting.js";
|
|
8
|
+
|
|
9
|
+
type UseBindSettingOptions<K extends SettingsSchemaKeys> = {
|
|
10
|
+
schema: SettingsSchema<K>;
|
|
11
|
+
key: keyof K & string;
|
|
12
|
+
object: RefProp<GObject.Object>;
|
|
13
|
+
property: string;
|
|
14
|
+
flags?: Gio.SettingsBindFlags;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Binds a GSettings key to a property of a GObject, keeping the two in sync for the object's lifetime.
|
|
19
|
+
*
|
|
20
|
+
* @param options.schema The schema reference identifying the settings backend.
|
|
21
|
+
* @param options.key The key within the schema to bind.
|
|
22
|
+
* @param options.object The GObject whose property is bound to the setting.
|
|
23
|
+
* @param options.property The name of the object property to bind.
|
|
24
|
+
* @param options.flags Flags controlling the binding's direction and behaviour.
|
|
25
|
+
*/
|
|
26
|
+
function useBindSetting<K extends SettingsSchemaKeys>({
|
|
27
|
+
schema,
|
|
28
|
+
key,
|
|
29
|
+
object,
|
|
30
|
+
property,
|
|
31
|
+
flags = Gio.SettingsBindFlags.DEFAULT,
|
|
32
|
+
}: UseBindSettingOptions<K>): void {
|
|
33
|
+
const settings = useSettings(schema);
|
|
34
|
+
const propertyName = kebabCase(property);
|
|
7
35
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
key: P,
|
|
11
|
-
object: ObjectProp<GObject.Object>,
|
|
12
|
-
property: string,
|
|
13
|
-
flags?: Gio.SettingsBindFlags,
|
|
14
|
-
): void;
|
|
15
|
-
export function useBindSetting(
|
|
16
|
-
schema: SchemaRef,
|
|
17
|
-
key: string,
|
|
18
|
-
object: ObjectProp<GObject.Object>,
|
|
19
|
-
property: string,
|
|
20
|
-
flags: Gio.SettingsBindFlags = Gio.SettingsBindFlags.DEFAULT,
|
|
21
|
-
): void {
|
|
22
|
-
const settings = useSettingsInstance(schema);
|
|
23
|
-
const propertyName = toKebabCase(property);
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
const resolved = resolveRefProp(object);
|
|
24
38
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
39
|
+
if (!resolved) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
settings.bind(key, resolved, propertyName, flags);
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
Gio.Settings.unbind(resolved, propertyName);
|
|
47
|
+
};
|
|
48
|
+
}, [settings, key, object, propertyName, flags]);
|
|
35
49
|
}
|
|
50
|
+
|
|
51
|
+
export { useBindSetting };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isRecord } from "@gtkx/utils";
|
|
2
|
+
import { type Ref, type RefCallback, useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
type PossibleRef<T> = Ref<T> | undefined;
|
|
5
|
+
type RefCleanup<T> = ReturnType<RefCallback<T>>;
|
|
6
|
+
type CleanupMap<T> = Map<PossibleRef<T>, Exclude<RefCleanup<T>, void>>;
|
|
7
|
+
|
|
8
|
+
function assignRef<T>(ref: PossibleRef<T>, value: T): RefCleanup<T> {
|
|
9
|
+
if (typeof ref === "function") {
|
|
10
|
+
return ref(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (isRecord(ref) && "current" in ref) {
|
|
14
|
+
ref.current = value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function collectCleanup<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>, node: T | null): void {
|
|
19
|
+
const cleanup = assignRef(ref, node);
|
|
20
|
+
|
|
21
|
+
if (cleanup) {
|
|
22
|
+
cleanupMap.set(ref, cleanup);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function cleanupRef<T>(cleanupMap: CleanupMap<T>, ref: PossibleRef<T>): void {
|
|
27
|
+
const cleanup = cleanupMap.get(ref);
|
|
28
|
+
|
|
29
|
+
if (cleanup && typeof cleanup === "function") {
|
|
30
|
+
cleanup();
|
|
31
|
+
} else {
|
|
32
|
+
assignRef(ref, null);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function applyRefs<T>(cleanupMap: CleanupMap<T>, refs: PossibleRef<T>[], node: T | null): RefCleanup<T> {
|
|
37
|
+
for (const ref of refs) {
|
|
38
|
+
collectCleanup(cleanupMap, ref, node);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (cleanupMap.size === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
for (const ref of refs) {
|
|
47
|
+
cleanupRef(cleanupMap, ref);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
cleanupMap.clear();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function mergeRefs<T>(...refs: PossibleRef<T>[]): RefCallback<T> {
|
|
55
|
+
const cleanupMap: CleanupMap<T> = new Map();
|
|
56
|
+
|
|
57
|
+
return (node: T | null): RefCleanup<T> => applyRefs(cleanupMap, refs, node);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function useMergedRef<T>(first: PossibleRef<T>, second: PossibleRef<T>): RefCallback<T> {
|
|
61
|
+
return useMemo(() => mergeRefs(first, second), [first, second]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { assignRef, mergeRefs, useMergedRef };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
2
|
import type { SignalHandler } from "@gtkx/runtime";
|
|
3
3
|
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
4
|
-
import { type
|
|
4
|
+
import { type RefProp, resolveRefProp } from "../utils/ref-prop.js";
|
|
5
5
|
|
|
6
6
|
type ObjectValueCache<T extends GObject.Object, V> = {
|
|
7
7
|
object: T | null;
|
|
@@ -9,42 +9,46 @@ type ObjectValueCache<T extends GObject.Object, V> = {
|
|
|
9
9
|
value: V;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
object:
|
|
12
|
+
function useObjectValue<T extends GObject.Object, V>(
|
|
13
|
+
object: RefProp<T>,
|
|
14
14
|
signal: string,
|
|
15
15
|
read: (object: T | null) => V,
|
|
16
16
|
): V {
|
|
17
|
-
const resolved =
|
|
18
|
-
const readRef = useRef(read);
|
|
19
|
-
readRef.current = read;
|
|
17
|
+
const resolved = resolveRefProp(object);
|
|
20
18
|
const cacheRef = useRef<ObjectValueCache<T, V> | null>(null);
|
|
21
19
|
|
|
22
|
-
const readNow = useCallback((): ObjectValueCache<T, V> => {
|
|
23
|
-
const cache = { object: resolved, signal, value: readRef.current(resolved) };
|
|
24
|
-
cacheRef.current = cache;
|
|
25
|
-
return cache;
|
|
26
|
-
}, [resolved, signal]);
|
|
27
|
-
|
|
28
|
-
const getSnapshot = useCallback((): V => {
|
|
29
|
-
const cache = cacheRef.current;
|
|
30
|
-
if (cache !== null && cache.object === resolved && cache.signal === signal) {
|
|
31
|
-
return cache.value;
|
|
32
|
-
}
|
|
33
|
-
return readNow().value;
|
|
34
|
-
}, [resolved, signal, readNow]);
|
|
35
|
-
|
|
36
20
|
const subscribe = useCallback(
|
|
37
21
|
(onStoreChange: () => void): (() => void) => {
|
|
38
|
-
if (resolved === null)
|
|
22
|
+
if (resolved === null) {
|
|
23
|
+
return (): void => undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
39
26
|
const handler: SignalHandler = () => {
|
|
40
|
-
|
|
27
|
+
cacheRef.current = null;
|
|
41
28
|
onStoreChange();
|
|
42
29
|
};
|
|
30
|
+
|
|
43
31
|
resolved.on(signal, handler);
|
|
32
|
+
|
|
44
33
|
return () => resolved.off(signal, handler);
|
|
45
34
|
},
|
|
46
|
-
[resolved, signal
|
|
35
|
+
[resolved, signal],
|
|
47
36
|
);
|
|
48
37
|
|
|
38
|
+
const getSnapshot = (): V => {
|
|
39
|
+
const cache = cacheRef.current;
|
|
40
|
+
|
|
41
|
+
if (cache !== null && cache.object === resolved && cache.signal === signal) {
|
|
42
|
+
return cache.value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const value = read(resolved);
|
|
46
|
+
cacheRef.current = { object: resolved, signal, value };
|
|
47
|
+
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
|
|
49
51
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
50
52
|
}
|
|
53
|
+
|
|
54
|
+
export { useObjectValue };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import { type Context, createContext, use } from "react";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const ParentWindowContext: Context<Gtk.Window | null> = createContext<Gtk.Window | null>(null);
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns the `Gtk.Window` provided by the nearest window ancestor, or `null` when there is none.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const useParentWindow = (): Gtk.Window | null => use(ParentWindowContext);
|
|
10
|
+
|
|
11
|
+
export { ParentWindowContext, useParentWindow };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import { kebabCase } from "@gtkx/utils";
|
|
3
|
+
import type { RefProp } from "../utils/ref-prop.js";
|
|
4
4
|
import { useObjectValue } from "./use-object-value.js";
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
export type PropertyNameOf<T extends GObject.Object> = keyof PropertiesOf<T> & keyof T & string;
|
|
6
|
+
type Properties<T extends GObject.Object> = NonNullable<T["__properties__"]>;
|
|
7
|
+
type PropertyName<T extends GObject.Object> = keyof Properties<T> & keyof T;
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Subscribes to a GObject property and returns its current value, re-rendering when the property changes.
|
|
@@ -14,9 +13,11 @@ export type PropertyNameOf<T extends GObject.Object> = keyof PropertiesOf<T> & k
|
|
|
14
13
|
* @param propertyName The camelCase name of a readable property on the object.
|
|
15
14
|
* @returns The current property value, or `undefined` when the object is not resolved.
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
object:
|
|
19
|
-
propertyName:
|
|
20
|
-
): T[
|
|
21
|
-
return useObjectValue(object,
|
|
16
|
+
function useProperty<T extends GObject.Object, P extends PropertyName<T>>(
|
|
17
|
+
object: RefProp<T>,
|
|
18
|
+
propertyName: P & string,
|
|
19
|
+
): T[P] | undefined {
|
|
20
|
+
return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);
|
|
22
21
|
}
|
|
22
|
+
|
|
23
|
+
export { useProperty, type PropertyName };
|
package/src/hooks/use-setting.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import * as Gio from "@gtkx/gi/gio";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import {
|
|
4
|
+
resolveSettingAccessor,
|
|
5
|
+
type SettingsSchema,
|
|
6
|
+
type SettingsSchemaKeys,
|
|
7
|
+
type SettingValue,
|
|
8
|
+
} from "../utils/settings.js";
|
|
4
9
|
import { useObjectValue } from "./use-object-value.js";
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
* A typed reference to a GSettings schema: its id, path, and the mapping of typed keys to their setting names.
|
|
8
|
-
*/
|
|
9
|
-
export type SchemaRef<K extends object = Record<string, unknown>> = {
|
|
10
|
-
id: string;
|
|
11
|
-
/** The schema's object path, or `null` to use the schema's default path. */
|
|
12
|
-
path: string | null;
|
|
13
|
-
/** Maps each typed key of `K` to its corresponding GSettings key name. */
|
|
14
|
-
keys: { [P in keyof K]: string };
|
|
15
|
-
/** Phantom field carrying the value type `K`; never populated at runtime. */
|
|
16
|
-
__keys__?: K;
|
|
17
|
-
};
|
|
11
|
+
type UseSettingsProps<K extends SettingsSchemaKeys> = Pick<SettingsSchema<K>, "id" | "path">;
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
useMemo(() => (path
|
|
13
|
+
const useSettings = <K extends SettingsSchemaKeys>({ id, path }: UseSettingsProps<K>): Gio.Settings =>
|
|
14
|
+
useMemo(() => (path ? new Gio.Settings({ schema: id, path }) : Gio.Settings.new(id)), [id, path]);
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* Reads and writes a single key of a GSettings schema, re-rendering when the stored value changes.
|
|
@@ -26,22 +20,15 @@ export const useSettingsInstance = ({ id, path }: Pick<SchemaRef, "id" | "path">
|
|
|
26
20
|
* @param key The key within the schema to read and write.
|
|
27
21
|
* @returns A tuple of the current value and a setter that persists a new value.
|
|
28
22
|
*/
|
|
29
|
-
|
|
30
|
-
schema:
|
|
31
|
-
key: P,
|
|
32
|
-
): [K
|
|
33
|
-
|
|
34
|
-
const accessor =
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const value = useObjectValue(settings, `changed::${key}`, () => accessor.read(settings, key));
|
|
23
|
+
function useSetting<K extends SettingsSchemaKeys, P extends keyof K>(
|
|
24
|
+
schema: SettingsSchema<K>,
|
|
25
|
+
key: P & string,
|
|
26
|
+
): [SettingValue<K, P>, (value: SettingValue<K, P>) => void] {
|
|
27
|
+
const settings = useSettings({ id: schema.id, path: schema.path });
|
|
28
|
+
const accessor = resolveSettingAccessor(settings, schema, key);
|
|
29
|
+
const value = useObjectValue(settings, `changed::${key}`, () => accessor.get());
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
(newValue: unknown) => {
|
|
41
|
-
accessor.write(settings, key, newValue);
|
|
42
|
-
},
|
|
43
|
-
[accessor, settings, key],
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return [value, set];
|
|
31
|
+
return [value, accessor.set];
|
|
47
32
|
}
|
|
33
|
+
|
|
34
|
+
export { useSettings, useSetting };
|
package/src/hooks/use-signal.ts
CHANGED
|
@@ -1,71 +1,64 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
2
|
import type { SignalHandler } from "@gtkx/runtime";
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
5
|
-
import { useObjectAttachment } from "./use-object-attachment.js";
|
|
3
|
+
import { useEffectEvent, useLayoutEffect } from "react";
|
|
4
|
+
import { type RefProp, resolveRefProp } from "../utils/ref-prop.js";
|
|
6
5
|
|
|
7
|
-
type
|
|
6
|
+
type Signals<T extends GObject.Object> = NonNullable<T["__signals__"]>;
|
|
7
|
+
type SignalName<T extends GObject.Object> = keyof Signals<T> | `${keyof Signals<T> & string}::${string}`;
|
|
8
8
|
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
export type SignalNameOf<T extends GObject.Object> =
|
|
12
|
-
| (keyof SignalsOf<T> & string)
|
|
13
|
-
| `${keyof SignalsOf<T> & string}::${string}`;
|
|
14
|
-
|
|
15
|
-
export type SignalHandlerFor<T extends GObject.Object, S extends string> = S extends keyof SignalsOf<T>
|
|
16
|
-
? SignalsOf<T>[S]
|
|
9
|
+
type TypedSignalHandler<T extends GObject.Object, S extends string> = S extends keyof Signals<T>
|
|
10
|
+
? Signals<T>[S]
|
|
17
11
|
: S extends `${infer TBase}::${string}`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
? TBase extends keyof Signals<T>
|
|
13
|
+
? Signals<T>[TBase]
|
|
14
|
+
: SignalHandler
|
|
15
|
+
: SignalHandler;
|
|
22
16
|
|
|
23
17
|
type UseSignalOptions = {
|
|
24
18
|
after?: boolean;
|
|
25
19
|
immediate?: boolean;
|
|
26
20
|
};
|
|
27
21
|
|
|
28
|
-
type SignalSubscription = {
|
|
29
|
-
obj: GObject.Object;
|
|
30
|
-
signal: string;
|
|
31
|
-
after: boolean;
|
|
32
|
-
listener: SignalHandler;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
22
|
/**
|
|
36
23
|
* Connects a handler to a GObject signal for the lifetime of the component, reconnecting when the object changes.
|
|
37
24
|
*
|
|
25
|
+
* Each emission runs the handler from the latest render, so it does not have to be stable and a
|
|
26
|
+
* changing handler never reconnects the signal.
|
|
27
|
+
*
|
|
28
|
+
* On React 19.2 this does not hold inside a component wrapped in `memo` or `forwardRef`, where every emission
|
|
29
|
+
* runs the handler captured on the first render. Keep the calling component unwrapped, or read the values the
|
|
30
|
+
* handler needs off the GObject itself. React fixes this on the 19.3 line.
|
|
31
|
+
*
|
|
38
32
|
* @param object The GObject (or ref to one) to connect to.
|
|
39
33
|
* @param signal The signal name, optionally with a detail suffix.
|
|
40
34
|
* @param handler The callback invoked when the signal is emitted.
|
|
41
35
|
* @param options Connection options such as running after the default handler or invoking immediately.
|
|
42
36
|
*/
|
|
43
|
-
|
|
44
|
-
object:
|
|
37
|
+
function useSignal<T extends GObject.Object, S extends SignalName<T> & string>(
|
|
38
|
+
object: RefProp<T>,
|
|
45
39
|
signal: S,
|
|
46
|
-
handler:
|
|
47
|
-
|
|
48
|
-
): void;
|
|
49
|
-
export function useSignal(
|
|
50
|
-
object: ObjectProp<GObject.Object>,
|
|
51
|
-
signal: string,
|
|
52
|
-
handler: AnySignalHandler,
|
|
53
|
-
options?: UseSignalOptions,
|
|
40
|
+
handler: TypedSignalHandler<T, S>,
|
|
41
|
+
{ after = false, immediate = false }: UseSignalOptions = {},
|
|
54
42
|
): void {
|
|
55
|
-
const
|
|
56
|
-
handlerRef.current = handler;
|
|
57
|
-
const after = options?.after ?? false;
|
|
58
|
-
const immediate = options?.immediate ?? false;
|
|
43
|
+
const emit = useEffectEvent(handler as SignalHandler);
|
|
59
44
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
const resolved = resolveRefProp(object);
|
|
47
|
+
|
|
48
|
+
if (!resolved) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
resolved.on(signal, emit, after);
|
|
53
|
+
|
|
54
|
+
if (immediate) {
|
|
55
|
+
emit();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
resolved.off(signal, emit);
|
|
60
|
+
};
|
|
61
|
+
}, [object, signal, after, immediate]);
|
|
71
62
|
}
|
|
63
|
+
|
|
64
|
+
export { useSignal, type SignalName, type TypedSignalHandler };
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./bootstrap.js";
|
|
2
2
|
|
|
3
|
-
export type { ElementProp } from "@gtkx/config";
|
|
4
3
|
export { useApplication } from "./hooks/use-application.js";
|
|
5
4
|
export { useBindSetting } from "./hooks/use-bind-setting.js";
|
|
6
5
|
export { useParentWindow } from "./hooks/use-parent-window.js";
|
|
7
6
|
export { useProperty } from "./hooks/use-property.js";
|
|
8
|
-
export {
|
|
7
|
+
export { useSetting } from "./hooks/use-setting.js";
|
|
9
8
|
export { useSignal } from "./hooks/use-signal.js";
|
|
10
|
-
export type {
|
|
11
|
-
export { createPortal } from "./reconciler/portal.js";
|
|
12
|
-
export { createRoot, quit, type Root } from "./reconciler/render.js";
|
|
9
|
+
export type { MenuItem, VflConstraints } from "./prop-types.js";
|
|
13
10
|
export { type RootElement, rootElement } from "./reconciler/root-element.js";
|
|
14
|
-
export type
|
|
15
|
-
export type {
|
|
11
|
+
export { createPortal, createRoot, quit, type Root } from "./reconciler/root.js";
|
|
12
|
+
export type { AccessibleProps } from "./utils/accessible-props.js";
|
|
13
|
+
export type { RefProp } from "./utils/ref-prop.js";
|
|
14
|
+
export type { SettingsSchema, SettingsSchemaKeys, SettingValue } from "./utils/settings.js";
|
package/src/internal.ts
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
+
import "./bootstrap.js";
|
|
2
|
+
|
|
1
3
|
export { createApplicationComponent } from "./components/application.js";
|
|
4
|
+
export { createElementComponent } from "./components/element.js";
|
|
2
5
|
export { createWindowComponent } from "./components/window.js";
|
|
3
6
|
export { ApplicationContext } from "./hooks/use-application.js";
|
|
4
|
-
export {
|
|
5
|
-
export { useObjectAttachment } from "./hooks/use-object-attachment.js";
|
|
7
|
+
export { useMergedRef } from "./hooks/use-merged-refs.js";
|
|
6
8
|
export { useObjectValue } from "./hooks/use-object-value.js";
|
|
7
|
-
export
|
|
8
|
-
export { createReconcilerRoot, type ReconcilerRoot } from "./reconciler/reconciler-root.js";
|
|
9
|
+
export type * from "./prop-types.js";
|
|
9
10
|
export { isRootElement } from "./reconciler/root-element.js";
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
CONTAINER_PROP_KIND,
|
|
13
|
-
isWrapperKind,
|
|
14
|
-
LABEL_TEXT_KIND,
|
|
15
|
-
LAZY_ELEMENT_KIND,
|
|
16
|
-
OBJECT_PROP_KIND,
|
|
17
|
-
TEXT_ANCHOR_KIND,
|
|
18
|
-
TEXT_PAINTABLE_KIND,
|
|
19
|
-
WRAPPER_NODE_ELEMENT,
|
|
20
|
-
type WrapperKind,
|
|
21
|
-
} from "./reconciler/wrapper-protocol.js";
|
|
11
|
+
export { createReconcilerRoot, type ReconcilerRoot, setReconcilerErrorHandler } from "./reconciler/root.js";
|
|
12
|
+
export { applyWrite } from "./reconciler/signals.js";
|
|
22
13
|
export { getAccessibleMetadata } from "./utils/accessible-metadata.js";
|
|
23
|
-
export {
|
|
24
|
-
export { type ObjectProp, resolveObjectProp } from "./utils/object-prop.js";
|
|
14
|
+
export { type RefProp, resolveRefProp } from "./utils/ref-prop.js";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type * as Gdk from "@gtkx/gi/gdk";
|
|
2
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
3
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
/** One entry of a `GMenu`'s `items` prop; `submenu` and `section` nest further menus. */
|
|
7
|
+
type MenuItem = {
|
|
8
|
+
label?: string | null;
|
|
9
|
+
action?: string | null;
|
|
10
|
+
submenu?: MenuItem[];
|
|
11
|
+
section?: MenuItem[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** One Visual Format Language block applied to a `Gtk.ConstraintLayout`. */
|
|
15
|
+
type VflConstraints = {
|
|
16
|
+
lines: string[];
|
|
17
|
+
hspacing?: number;
|
|
18
|
+
vspacing?: number;
|
|
19
|
+
views?: Map<string, Gtk.ConstraintTarget>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** One mark on a `Gtk.Scale`. */
|
|
23
|
+
type ScaleMark = { value?: number; position: Gtk.PositionType; markup?: string | null };
|
|
24
|
+
/** One labelled offset on a `Gtk.LevelBar`. */
|
|
25
|
+
type LevelBarOffset = { name: string; value?: number };
|
|
26
|
+
/** One credit section on a `Gtk.AboutDialog`. */
|
|
27
|
+
type CreditSection = { sectionName: string; people: string[] };
|
|
28
|
+
/** One accelerator binding on a `Gtk.Application`. */
|
|
29
|
+
type ActionAccel = { detailedActionName: string; accels: string[] };
|
|
30
|
+
/** The drag icon of a `Gtk.DragSource`, with its hotspot. */
|
|
31
|
+
type DragSourceIcon = { paintable?: Gdk.Paintable | null; hotX?: number; hotY?: number };
|
|
32
|
+
|
|
33
|
+
/** Props of an element that accepts children. */
|
|
34
|
+
type ChildrenProps = {
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type GtkWidgetProps = {
|
|
39
|
+
controllers?: ReactNode | null | undefined;
|
|
40
|
+
actionGroups?: ReactNode | null | undefined;
|
|
41
|
+
} & ChildrenProps;
|
|
42
|
+
|
|
43
|
+
type GActionGroupProps = {
|
|
44
|
+
prefix?: string | null | undefined;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type GActionMapProps = {
|
|
48
|
+
actions?: ReactNode | null | undefined;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type GMenuProps = {
|
|
52
|
+
items?: MenuItem[] | null | undefined;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type GtkShortcutControllerProps = {
|
|
56
|
+
shortcuts?: ReactNode | null | undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type GtkOverlayProps = {
|
|
60
|
+
overlays?: ReactNode | null | undefined;
|
|
61
|
+
} & ChildrenProps;
|
|
62
|
+
|
|
63
|
+
type GtkConstraintLayoutProps = {
|
|
64
|
+
constraints?: ReactNode | null | undefined;
|
|
65
|
+
guides?: ReactNode | null | undefined;
|
|
66
|
+
vfl?: VflConstraints[] | null | undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** Props of `GtkTextChildAnchor`, which embeds either a child widget or a paintable in a text buffer. */
|
|
70
|
+
type GtkTextChildAnchorProps = {
|
|
71
|
+
paintable?: Gdk.Paintable | null | undefined;
|
|
72
|
+
} & ChildrenProps;
|
|
73
|
+
|
|
74
|
+
type GtkHeaderBarProps = {
|
|
75
|
+
start?: ReactNode | null | undefined;
|
|
76
|
+
end?: ReactNode | null | undefined;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type GtkScaleProps = {
|
|
80
|
+
marks?: ScaleMark[] | null | undefined;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
type GtkCalendarProps = {
|
|
84
|
+
markedDays?: number[] | null | undefined;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type GtkLevelBarProps = {
|
|
88
|
+
offsets?: LevelBarOffset[] | null | undefined;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type GtkSizeGroupProps = {
|
|
92
|
+
widgets?: Gtk.Widget[] | null | undefined;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type GtkAboutDialogProps = {
|
|
96
|
+
creditSections?: CreditSection[] | null | undefined;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type GtkApplicationProps = {
|
|
100
|
+
actionAccels?: ActionAccel[] | null | undefined;
|
|
101
|
+
} & ChildrenProps;
|
|
102
|
+
|
|
103
|
+
type GtkDropTargetProps = {
|
|
104
|
+
types?: GObject.Type[] | null | undefined;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type GtkDrawingAreaProps = {
|
|
108
|
+
drawFunc?: Gtk.DrawingAreaDrawFunc | null | undefined;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type GtkDragSourceProps = {
|
|
112
|
+
icon?: DragSourceIcon | null | undefined;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
type MenuItem,
|
|
117
|
+
type VflConstraints,
|
|
118
|
+
type ScaleMark,
|
|
119
|
+
type LevelBarOffset,
|
|
120
|
+
type CreditSection,
|
|
121
|
+
type ActionAccel,
|
|
122
|
+
type DragSourceIcon,
|
|
123
|
+
type ChildrenProps,
|
|
124
|
+
type GtkWidgetProps,
|
|
125
|
+
type GActionGroupProps,
|
|
126
|
+
type GActionMapProps,
|
|
127
|
+
type GMenuProps,
|
|
128
|
+
type GtkShortcutControllerProps,
|
|
129
|
+
type GtkOverlayProps,
|
|
130
|
+
type GtkTextChildAnchorProps,
|
|
131
|
+
type GtkConstraintLayoutProps,
|
|
132
|
+
type GtkHeaderBarProps,
|
|
133
|
+
type GtkScaleProps,
|
|
134
|
+
type GtkCalendarProps,
|
|
135
|
+
type GtkLevelBarProps,
|
|
136
|
+
type GtkSizeGroupProps,
|
|
137
|
+
type GtkAboutDialogProps,
|
|
138
|
+
type GtkApplicationProps,
|
|
139
|
+
type GtkDropTargetProps,
|
|
140
|
+
type GtkDrawingAreaProps,
|
|
141
|
+
type GtkDragSourceProps,
|
|
142
|
+
};
|