@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
package/src/utils/gtype.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/// <reference types="@gtkx/config/env" />
|
|
2
|
-
|
|
3
|
-
import { CONSTRUCT_ONLY_PROPS, CONSTRUCT_PROPS, DEFAULT_PROPS, SIGNALS } from "virtual:gtkx-config";
|
|
4
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
5
|
-
import { getWrapperClass, type TypedClass } from "@gtkx/runtime";
|
|
6
|
-
import { NOTIFY_SIGNAL, propToNotifySignal } from "./notify-name.js";
|
|
7
|
-
|
|
8
|
-
const NOTIFY_PREFIX = "onNotify";
|
|
9
|
-
|
|
10
|
-
const resolveNotifySignal = (propName: string): string | null => {
|
|
11
|
-
if (propName === NOTIFY_PREFIX) return NOTIFY_SIGNAL;
|
|
12
|
-
if (!propName.startsWith(NOTIFY_PREFIX)) return null;
|
|
13
|
-
const tail = propName.slice(NOTIFY_PREFIX.length);
|
|
14
|
-
if (tail.charAt(0) !== tail.charAt(0).toUpperCase()) return null;
|
|
15
|
-
return propToNotifySignal(tail);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const typeNameChainCache = new Map<bigint, string[]>();
|
|
19
|
-
const interfaceNamesCache = new Map<bigint, string[]>();
|
|
20
|
-
const typeNameSetCache = new Map<bigint, Set<string>>();
|
|
21
|
-
const signalCache = new Map<bigint, Map<string, string | null>>();
|
|
22
|
-
const constructOnlyCache = new Map<bigint, Map<string, boolean>>();
|
|
23
|
-
const defaultPropCache = new Map<bigint, Map<string, DefaultPropLookup>>();
|
|
24
|
-
const constructablePropsCache = new Map<bigint, Set<string>>();
|
|
25
|
-
|
|
26
|
-
const memoizeGtype = <T>(cache: Map<bigint, T>, gtype: bigint, compute: () => T): T => {
|
|
27
|
-
const cached = cache.get(gtype);
|
|
28
|
-
if (cached !== undefined) return cached;
|
|
29
|
-
const result = compute();
|
|
30
|
-
cache.set(gtype, result);
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const collectTypeNameChain = (gtype: bigint): string[] =>
|
|
35
|
-
memoizeGtype(typeNameChainCache, gtype, () => {
|
|
36
|
-
const chain: string[] = [];
|
|
37
|
-
let current = gtype;
|
|
38
|
-
while (current !== 0n) {
|
|
39
|
-
const name = GObject.typeName(current);
|
|
40
|
-
if (!name) break;
|
|
41
|
-
chain.push(name);
|
|
42
|
-
current = GObject.typeParent(current);
|
|
43
|
-
}
|
|
44
|
-
return chain;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const collectInterfaceNames = (gtype: bigint): string[] =>
|
|
48
|
-
memoizeGtype(interfaceNamesCache, gtype, () => {
|
|
49
|
-
const names: string[] = [];
|
|
50
|
-
for (const iface of GObject.typeInterfaces(gtype)) {
|
|
51
|
-
const name = GObject.typeName(iface);
|
|
52
|
-
if (name) names.push(name);
|
|
53
|
-
}
|
|
54
|
-
return names;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const typeNamesWithInterfacesCache = new Map<bigint, string[]>();
|
|
58
|
-
|
|
59
|
-
export const collectTypeNamesWithInterfaces = (gtype: bigint): string[] =>
|
|
60
|
-
memoizeGtype(typeNamesWithInterfacesCache, gtype, () => [
|
|
61
|
-
...collectTypeNameChain(gtype),
|
|
62
|
-
...collectInterfaceNames(gtype),
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
const foldInheritedTable = <R, T>(
|
|
66
|
-
gtype: bigint,
|
|
67
|
-
table: Record<string, R>,
|
|
68
|
-
fold: (accumulator: T, row: R) => T,
|
|
69
|
-
seed: T,
|
|
70
|
-
): T => {
|
|
71
|
-
let accumulator = seed;
|
|
72
|
-
for (const name of collectTypeNameChain(gtype)) {
|
|
73
|
-
const row = table[name];
|
|
74
|
-
if (row !== undefined) accumulator = fold(accumulator, row);
|
|
75
|
-
}
|
|
76
|
-
return accumulator;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const foldInheritedTableWithInterfaces = <R, T>(
|
|
80
|
-
gtype: bigint,
|
|
81
|
-
table: Record<string, R>,
|
|
82
|
-
fold: (accumulator: T, row: R) => T,
|
|
83
|
-
seed: T,
|
|
84
|
-
): T => {
|
|
85
|
-
let accumulator = foldInheritedTable(gtype, table, fold, seed);
|
|
86
|
-
for (const name of collectInterfaceNames(gtype)) {
|
|
87
|
-
const row = table[name];
|
|
88
|
-
if (row !== undefined) accumulator = fold(accumulator, row);
|
|
89
|
-
}
|
|
90
|
-
return accumulator;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const typeChainIncludes = (gtype: bigint, name: string): boolean =>
|
|
94
|
-
memoizeGtype(typeNameSetCache, gtype, () => new Set(collectTypeNameChain(gtype))).has(name);
|
|
95
|
-
|
|
96
|
-
const memoize = <T>(
|
|
97
|
-
cache: Map<bigint, Map<string, T>>,
|
|
98
|
-
instance: TypedClass,
|
|
99
|
-
key: string,
|
|
100
|
-
compute: (typeNames: string[]) => T,
|
|
101
|
-
): T => {
|
|
102
|
-
const gtype = instance.__type__;
|
|
103
|
-
const perGtype = memoizeGtype(cache, gtype, () => new Map<string, T>());
|
|
104
|
-
const cached = perGtype.get(key);
|
|
105
|
-
if (cached !== undefined) return cached;
|
|
106
|
-
const result = compute(collectTypeNameChain(gtype));
|
|
107
|
-
perGtype.set(key, result);
|
|
108
|
-
return result;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const collectConstructableProps = (gtype: bigint): Set<string> =>
|
|
112
|
-
memoizeGtype(constructablePropsCache, gtype, () =>
|
|
113
|
-
foldInheritedTable(
|
|
114
|
-
gtype,
|
|
115
|
-
CONSTRUCT_PROPS,
|
|
116
|
-
(collected: Set<string>, props) => {
|
|
117
|
-
for (const prop of props) collected.add(prop);
|
|
118
|
-
return collected;
|
|
119
|
-
},
|
|
120
|
-
new Set<string>(),
|
|
121
|
-
),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
export const isConstructOnlyProp = (instance: TypedClass, key: string): boolean =>
|
|
125
|
-
memoize(constructOnlyCache, instance, key, (typeNames) => {
|
|
126
|
-
for (const name of typeNames) {
|
|
127
|
-
if (CONSTRUCT_ONLY_PROPS[name]?.has(key)) return true;
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
export const resolveSignal = (instance: TypedClass, propName: string): string | null => {
|
|
133
|
-
const notify = resolveNotifySignal(propName);
|
|
134
|
-
if (notify) return notify;
|
|
135
|
-
return memoize(signalCache, instance, propName, (typeNames) => {
|
|
136
|
-
for (const name of typeNames) {
|
|
137
|
-
const result = SIGNALS[name]?.[propName];
|
|
138
|
-
if (result) return result;
|
|
139
|
-
}
|
|
140
|
-
return null;
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
type DefaultPropLookup = { has: boolean; value: unknown };
|
|
145
|
-
|
|
146
|
-
const NO_DEFAULT_PROP: DefaultPropLookup = { has: false, value: undefined };
|
|
147
|
-
|
|
148
|
-
export const resolveDefaultProp = (instance: TypedClass, key: string): DefaultPropLookup =>
|
|
149
|
-
memoize(defaultPropCache, instance, key, (typeNames) => {
|
|
150
|
-
for (const name of typeNames) {
|
|
151
|
-
const table = DEFAULT_PROPS[name];
|
|
152
|
-
if (table && key in table) return { has: true, value: table[key] };
|
|
153
|
-
}
|
|
154
|
-
return NO_DEFAULT_PROP;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
export const requireClassByName = (typeName: string): (new (props: Record<string, unknown>) => GObject.Object) => {
|
|
158
|
-
const gtype = GObject.typeFromName(typeName);
|
|
159
|
-
if (gtype === GObject.TYPE_INVALID)
|
|
160
|
-
throw new Error(
|
|
161
|
-
`${typeName} is not registered. Import its @gtkx/jsx namespace module (e.g. \`import "@gtkx/jsx/adw"\`) before use.`,
|
|
162
|
-
);
|
|
163
|
-
return getWrapperClass(gtype) as new (
|
|
164
|
-
props: Record<string, unknown>,
|
|
165
|
-
) => GObject.Object;
|
|
166
|
-
};
|
package/src/utils/notify-name.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { toCamelCase, toKebabCase } from "@gtkx/utils";
|
|
2
|
-
|
|
3
|
-
export const NOTIFY_SIGNAL = "notify";
|
|
4
|
-
|
|
5
|
-
export const NOTIFY_DETAIL_PREFIX = "notify::";
|
|
6
|
-
|
|
7
|
-
export const propToNotifySignal = (property: string): `notify::${string}` =>
|
|
8
|
-
`${NOTIFY_DETAIL_PREFIX}${toKebabCase(property)}`;
|
|
9
|
-
|
|
10
|
-
export const notifyDetailToProp = (detail: string): string => toCamelCase(detail.slice(NOTIFY_DETAIL_PREFIX.length));
|
package/src/utils/object-prop.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import type { RefObject } from "react";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* An object accepted by the GObject-aware hooks: a GObject, a ref to one, or a nullish value.
|
|
6
|
-
*/
|
|
7
|
-
export type ObjectProp<T extends GObject.Object> = T | RefObject<T | null> | null | undefined;
|
|
8
|
-
|
|
9
|
-
export const resolveObjectProp = <T extends GObject.Object>(prop: ObjectProp<T>): T | null => {
|
|
10
|
-
if (!prop) return null;
|
|
11
|
-
if (prop instanceof GObject.Object) return prop;
|
|
12
|
-
return prop.current;
|
|
13
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type * as Gio from "@gtkx/gi/gio";
|
|
2
|
-
import * as GLib from "@gtkx/gi/glib";
|
|
3
|
-
|
|
4
|
-
type SettingAccessor = {
|
|
5
|
-
read: (settings: Gio.Settings, key: string) => unknown;
|
|
6
|
-
write: (settings: Gio.Settings, key: string, value: unknown) => void;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const settingTypeError = (expected: string, value: unknown): TypeError =>
|
|
10
|
-
new TypeError(`Expected ${expected} for the settings value, got ${typeof value}`);
|
|
11
|
-
|
|
12
|
-
const expect =
|
|
13
|
-
<T>(guard: (value: unknown) => value is T, label: string) =>
|
|
14
|
-
(value: unknown): T => {
|
|
15
|
-
if (!guard(value)) throw settingTypeError(label, value);
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const expectBoolean = expect((value): value is boolean => typeof value === "boolean", "a boolean");
|
|
20
|
-
|
|
21
|
-
const expectNumber = expect((value): value is number => typeof value === "number", "a number");
|
|
22
|
-
|
|
23
|
-
const expectString = expect((value): value is string => typeof value === "string", "a string");
|
|
24
|
-
|
|
25
|
-
const isStringArray = (value: unknown): value is string[] =>
|
|
26
|
-
Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
27
|
-
|
|
28
|
-
const expectStringArray = expect(isStringArray, "an array of strings");
|
|
29
|
-
|
|
30
|
-
const expectVariant = expect((value): value is GLib.Variant => value instanceof GLib.Variant, "a GLib.Variant");
|
|
31
|
-
|
|
32
|
-
const expectBigInt = (value: unknown): bigint => {
|
|
33
|
-
if (typeof value === "bigint") return value;
|
|
34
|
-
if (typeof value === "number") return BigInt(value);
|
|
35
|
-
throw settingTypeError("a bigint", value);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const STRING_ACCESSOR: SettingAccessor = {
|
|
39
|
-
read: (settings, key) => settings.getString(key),
|
|
40
|
-
write: (settings, key, value) => settings.setString(key, expectString(value)),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const STRV_ACCESSOR: SettingAccessor = {
|
|
44
|
-
read: (settings, key) => settings.getStrv(key),
|
|
45
|
-
write: (settings, key, value) => settings.setStrv(key, expectStringArray(value)),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const ACCESSORS: Record<string, SettingAccessor> = {
|
|
49
|
-
b: {
|
|
50
|
-
read: (settings, key) => settings.getBoolean(key),
|
|
51
|
-
write: (settings, key, value) => settings.setBoolean(key, expectBoolean(value)),
|
|
52
|
-
},
|
|
53
|
-
i: {
|
|
54
|
-
read: (settings, key) => settings.getInt(key),
|
|
55
|
-
write: (settings, key, value) => settings.setInt(key, expectNumber(value)),
|
|
56
|
-
},
|
|
57
|
-
u: {
|
|
58
|
-
read: (settings, key) => settings.getUint(key),
|
|
59
|
-
write: (settings, key, value) => settings.setUint(key, expectNumber(value)),
|
|
60
|
-
},
|
|
61
|
-
x: {
|
|
62
|
-
read: (settings, key) => settings.getInt64(key),
|
|
63
|
-
write: (settings, key, value) => settings.setInt64(key, expectBigInt(value)),
|
|
64
|
-
},
|
|
65
|
-
t: {
|
|
66
|
-
read: (settings, key) => settings.getUint64(key),
|
|
67
|
-
write: (settings, key, value) => settings.setUint64(key, expectBigInt(value)),
|
|
68
|
-
},
|
|
69
|
-
d: {
|
|
70
|
-
read: (settings, key) => settings.getDouble(key),
|
|
71
|
-
write: (settings, key, value) => settings.setDouble(key, expectNumber(value)),
|
|
72
|
-
},
|
|
73
|
-
s: STRING_ACCESSOR,
|
|
74
|
-
as: STRV_ACCESSOR,
|
|
75
|
-
enum: STRING_ACCESSOR,
|
|
76
|
-
flags: STRV_ACCESSOR,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const VARIANT_ACCESSOR: SettingAccessor = {
|
|
80
|
-
read: (settings, key) => settings.getValue(key),
|
|
81
|
-
write: (settings, key, value) => settings.setValue(key, expectVariant(value)),
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const resolveAccessor = (kind: string | undefined, key: string, schemaId: string): SettingAccessor => {
|
|
85
|
-
if (kind === undefined) {
|
|
86
|
-
throw new TypeError(`Key "${key}" is not declared by the GSettings schema "${schemaId}"`);
|
|
87
|
-
}
|
|
88
|
-
return ACCESSORS[kind] ?? VARIANT_ACCESSOR;
|
|
89
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type * as Gdk from "@gtkx/gi/gdk";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Props for a text anchor that embeds child widgets at a position within a text view's buffer.
|
|
6
|
-
*/
|
|
7
|
-
export type TextAnchorProps = {
|
|
8
|
-
/** The character used to represent the embedded widget in the buffer's text. */
|
|
9
|
-
replacementChar?: string;
|
|
10
|
-
children?: ReactNode;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Props for a node that embeds a `Gdk.Paintable` within a text view's buffer.
|
|
15
|
-
*/
|
|
16
|
-
export type TextPaintableProps = {
|
|
17
|
-
paintable: Gdk.Paintable;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type WrapperNodeElementProps = {
|
|
21
|
-
kind: string;
|
|
22
|
-
children?: ReactNode;
|
|
23
|
-
[key: string]: unknown;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
declare global {
|
|
27
|
-
namespace React {
|
|
28
|
-
namespace JSX {
|
|
29
|
-
interface IntrinsicElements {
|
|
30
|
-
__GTKX_WRAPPER_NODE__: WrapperNodeElementProps;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|