@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,368 @@
|
|
|
1
|
+
import * as GLib from "@gtkx/gi/glib";
|
|
2
|
+
|
|
3
|
+
type BasicValueMap = {
|
|
4
|
+
b: boolean;
|
|
5
|
+
y: number;
|
|
6
|
+
n: number;
|
|
7
|
+
q: number;
|
|
8
|
+
i: number;
|
|
9
|
+
u: number;
|
|
10
|
+
h: number;
|
|
11
|
+
d: number;
|
|
12
|
+
x: bigint;
|
|
13
|
+
t: bigint;
|
|
14
|
+
s: string;
|
|
15
|
+
o: string;
|
|
16
|
+
g: string;
|
|
17
|
+
v: GLib.Variant;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type BasicCode = keyof BasicValueMap;
|
|
21
|
+
type ParseArray<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V[], R] : never;
|
|
22
|
+
type ParseMaybe<S extends string> = Parse<S> extends [infer V, infer R extends string] ? [V | null, R] : never;
|
|
23
|
+
|
|
24
|
+
type ParseTuple<S extends string, Acc extends unknown[]> = S extends `)${infer Rest}`
|
|
25
|
+
? [Acc, Rest]
|
|
26
|
+
: [Parse<S>] extends [never]
|
|
27
|
+
? never
|
|
28
|
+
: Parse<S> extends [infer V, infer R extends string]
|
|
29
|
+
? ParseTuple<R, [...Acc, V]>
|
|
30
|
+
: never;
|
|
31
|
+
|
|
32
|
+
type DictKey = string | number | bigint | boolean;
|
|
33
|
+
|
|
34
|
+
type ParsePair<S extends string> =
|
|
35
|
+
Parse<S> extends [infer K, infer R1 extends string]
|
|
36
|
+
? Parse<R1> extends [infer V, infer R2 extends string]
|
|
37
|
+
? R2 extends `}${infer R3}`
|
|
38
|
+
? [K] extends [DictKey]
|
|
39
|
+
? [K, V, R3]
|
|
40
|
+
: never
|
|
41
|
+
: never
|
|
42
|
+
: never
|
|
43
|
+
: never;
|
|
44
|
+
|
|
45
|
+
type ParseDict<S extends string> =
|
|
46
|
+
ParsePair<S> extends [infer K, infer V, infer R extends string]
|
|
47
|
+
? [[K] extends [string] ? Record<string, V> : Map<K, V>, R]
|
|
48
|
+
: never;
|
|
49
|
+
|
|
50
|
+
type ParseEntry<S extends string> =
|
|
51
|
+
ParsePair<S> extends [infer K, infer V, infer R extends string] ? [[K, V], R] : never;
|
|
52
|
+
|
|
53
|
+
type ParseArrayOrDict<S extends string> = S extends `{${infer Rest}` ? ParseDict<Rest> : ParseArray<S>;
|
|
54
|
+
|
|
55
|
+
type Parse<S extends string> = S extends `a${infer Rest}`
|
|
56
|
+
? ParseArrayOrDict<Rest>
|
|
57
|
+
: S extends `m${infer Rest}`
|
|
58
|
+
? ParseMaybe<Rest>
|
|
59
|
+
: S extends `(${infer Rest}`
|
|
60
|
+
? ParseTuple<Rest, []>
|
|
61
|
+
: S extends `{${infer Rest}`
|
|
62
|
+
? ParseEntry<Rest>
|
|
63
|
+
: S extends `${infer C}${infer Rest}`
|
|
64
|
+
? C extends BasicCode
|
|
65
|
+
? [BasicValueMap[C], Rest]
|
|
66
|
+
: never
|
|
67
|
+
: never;
|
|
68
|
+
|
|
69
|
+
type VariantValue<S extends string> = [Parse<S>] extends [never]
|
|
70
|
+
? unknown
|
|
71
|
+
: Parse<S> extends [infer V, ""]
|
|
72
|
+
? V
|
|
73
|
+
: unknown;
|
|
74
|
+
|
|
75
|
+
type VariantTypeNode =
|
|
76
|
+
| { kind: "basic"; code: BasicCode } |
|
|
77
|
+
{ kind: "array"; elementTypeString: string; element: VariantTypeNode } |
|
|
78
|
+
{ kind: "dict"; entryTypeString: string; key: VariantTypeNode; value: VariantTypeNode } |
|
|
79
|
+
{ kind: "entry"; key: VariantTypeNode; value: VariantTypeNode } |
|
|
80
|
+
{ kind: "tuple"; items: VariantTypeNode[] } |
|
|
81
|
+
{ kind: "maybe"; elementTypeString: string; element: VariantTypeNode };
|
|
82
|
+
|
|
83
|
+
const BASIC_CODES = "bynqiuxthdsogv";
|
|
84
|
+
const STRING_KEY_CODES: Set<string> = new Set(["s", "o", "g"]);
|
|
85
|
+
|
|
86
|
+
const CONTAINER_PARSERS: Record<string, (source: string, start: number) => [VariantTypeNode, number]> = {
|
|
87
|
+
a: parseArrayNode,
|
|
88
|
+
m: parseMaybeNode,
|
|
89
|
+
"(": parseTupleNode,
|
|
90
|
+
"{": parseEntryNode,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const parsedTypes: Map<string, VariantTypeNode> = new Map();
|
|
94
|
+
|
|
95
|
+
const unpackBasic: Record<BasicCode, (variant: GLib.Variant) => unknown> = {
|
|
96
|
+
b: (variant) => variant.getBoolean(),
|
|
97
|
+
y: (variant) => variant.getByte(),
|
|
98
|
+
n: (variant) => variant.getInt16(),
|
|
99
|
+
q: (variant) => variant.getUint16(),
|
|
100
|
+
i: (variant) => variant.getInt32(),
|
|
101
|
+
u: (variant) => variant.getUint32(),
|
|
102
|
+
h: (variant) => variant.getHandle(),
|
|
103
|
+
d: (variant) => variant.getDouble(),
|
|
104
|
+
x: (variant) => variant.getInt64(),
|
|
105
|
+
t: (variant) => variant.getUint64(),
|
|
106
|
+
s: (variant) => variant.getString()[0],
|
|
107
|
+
o: (variant) => variant.getString()[0],
|
|
108
|
+
g: (variant) => variant.getString()[0],
|
|
109
|
+
v: (variant) => variant.getVariant(),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const packBasic: Record<BasicCode, (value: unknown) => GLib.Variant> = {
|
|
113
|
+
b: (value) => GLib.Variant.newBoolean(value as boolean),
|
|
114
|
+
y: (value) => GLib.Variant.newByte(value as number),
|
|
115
|
+
n: (value) => GLib.Variant.newInt16(value as number),
|
|
116
|
+
q: (value) => GLib.Variant.newUint16(value as number),
|
|
117
|
+
i: (value) => GLib.Variant.newInt32(value as number),
|
|
118
|
+
u: (value) => GLib.Variant.newUint32(value as number),
|
|
119
|
+
h: (value) => GLib.Variant.newHandle(value as number),
|
|
120
|
+
d: (value) => GLib.Variant.newDouble(value as number),
|
|
121
|
+
x: (value) => GLib.Variant.newInt64(value as bigint),
|
|
122
|
+
t: (value) => GLib.Variant.newUint64(value as bigint),
|
|
123
|
+
s: (value) => GLib.Variant.newString(value as string),
|
|
124
|
+
o: packObjectPath,
|
|
125
|
+
g: packSignature,
|
|
126
|
+
v: (value) => GLib.Variant.newVariant(value as GLib.Variant),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const isBasicCode = (code: string): code is BasicCode => BASIC_CODES.includes(code);
|
|
130
|
+
const isStringKeyed = (key: VariantTypeNode): boolean => key.kind === "basic" && STRING_KEY_CODES.has(key.code);
|
|
131
|
+
const invalidType = (source: string): Error => new Error(`Invalid GVariant type string "${source}"`);
|
|
132
|
+
|
|
133
|
+
const parsePair = (source: string, start: number): [VariantTypeNode, VariantTypeNode, number] => {
|
|
134
|
+
const [key, keyEnd] = parseNode(source, start);
|
|
135
|
+
|
|
136
|
+
if (key.kind !== "basic" || key.code === "v") {
|
|
137
|
+
throw invalidType(source);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const [value, valueEnd] = parseNode(source, keyEnd);
|
|
141
|
+
|
|
142
|
+
if (source[valueEnd] !== "}") {
|
|
143
|
+
throw invalidType(source);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return [key, value, valueEnd + 1];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
function parseArrayNode(source: string, start: number): [VariantTypeNode, number] {
|
|
150
|
+
if (source[start] === "{") {
|
|
151
|
+
const [key, value, end] = parsePair(source, start + 1);
|
|
152
|
+
|
|
153
|
+
return [{ kind: "dict", entryTypeString: source.slice(start, end), key, value }, end];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const [element, end] = parseNode(source, start);
|
|
157
|
+
|
|
158
|
+
return [{ kind: "array", elementTypeString: source.slice(start, end), element }, end];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function parseMaybeNode(source: string, start: number): [VariantTypeNode, number] {
|
|
162
|
+
const [element, end] = parseNode(source, start);
|
|
163
|
+
|
|
164
|
+
return [{ kind: "maybe", elementTypeString: source.slice(start, end), element }, end];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function parseTupleNode(source: string, start: number): [VariantTypeNode, number] {
|
|
168
|
+
const items: VariantTypeNode[] = [];
|
|
169
|
+
let position = start;
|
|
170
|
+
|
|
171
|
+
while (source[position] !== ")") {
|
|
172
|
+
if (position >= source.length) {
|
|
173
|
+
throw invalidType(source);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const [item, end] = parseNode(source, position);
|
|
177
|
+
items.push(item);
|
|
178
|
+
position = end;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return [{ kind: "tuple", items }, position + 1];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function parseEntryNode(source: string, start: number): [VariantTypeNode, number] {
|
|
185
|
+
const [key, value, end] = parsePair(source, start);
|
|
186
|
+
|
|
187
|
+
return [{ kind: "entry", key, value }, end];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const parseNode = (source: string, start: number): [VariantTypeNode, number] => {
|
|
191
|
+
const code = source[start];
|
|
192
|
+
|
|
193
|
+
if (code === undefined) {
|
|
194
|
+
throw invalidType(source);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const container = CONTAINER_PARSERS[code];
|
|
198
|
+
|
|
199
|
+
if (container !== undefined) {
|
|
200
|
+
return container(source, start + 1);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (isBasicCode(code)) {
|
|
204
|
+
return [{ kind: "basic", code }, start + 1];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
throw invalidType(source);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const parseVariantType = (typeString: string): VariantTypeNode => {
|
|
211
|
+
const cached = parsedTypes.get(typeString);
|
|
212
|
+
|
|
213
|
+
if (cached !== undefined) {
|
|
214
|
+
return cached;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const [node, end] = parseNode(typeString, 0);
|
|
218
|
+
|
|
219
|
+
if (end !== typeString.length) {
|
|
220
|
+
throw invalidType(typeString);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
parsedTypes.set(typeString, node);
|
|
224
|
+
|
|
225
|
+
return node;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const unpackChildren = (variant: GLib.Variant, unpackChild: (child: GLib.Variant) => unknown): unknown[] => {
|
|
229
|
+
const children: unknown[] = [];
|
|
230
|
+
const count = variant.nChildren();
|
|
231
|
+
|
|
232
|
+
for (let index = 0; index < count; index += 1) {
|
|
233
|
+
children.push(unpackChild(variant.getChildValue(index)));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return children;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const unpackPair = (key: VariantTypeNode, value: VariantTypeNode, entry: GLib.Variant): [unknown, unknown] => [
|
|
240
|
+
unpackVariant(key, entry.getChildValue(0)),
|
|
241
|
+
unpackVariant(value, entry.getChildValue(1)),
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
const unpackDict = (
|
|
245
|
+
node: { key: VariantTypeNode; value: VariantTypeNode },
|
|
246
|
+
variant: GLib.Variant,
|
|
247
|
+
): Record<string, unknown> | Map<unknown, unknown> => {
|
|
248
|
+
const entries = unpackChildren(variant, (entry) => unpackPair(node.key, node.value, entry)) as [unknown, unknown][];
|
|
249
|
+
|
|
250
|
+
if (!isStringKeyed(node.key)) {
|
|
251
|
+
return new Map(entries);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const stringEntries: [string, unknown][] = entries.map(([key, value]) => [key as string, value]);
|
|
255
|
+
|
|
256
|
+
return Object.fromEntries(stringEntries);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const unpackMaybe = (element: VariantTypeNode, variant: GLib.Variant): unknown => {
|
|
260
|
+
const child = variant.getMaybe();
|
|
261
|
+
|
|
262
|
+
return child === null ? null : unpackVariant(element, child);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const unpackVariant = (node: VariantTypeNode, variant: GLib.Variant): unknown => {
|
|
266
|
+
switch (node.kind) {
|
|
267
|
+
case "basic": {
|
|
268
|
+
return unpackBasic[node.code](variant);
|
|
269
|
+
}
|
|
270
|
+
case "array": {
|
|
271
|
+
return unpackChildren(variant, (child) => unpackVariant(node.element, child));
|
|
272
|
+
}
|
|
273
|
+
case "dict": {
|
|
274
|
+
return unpackDict(node, variant);
|
|
275
|
+
}
|
|
276
|
+
case "entry": {
|
|
277
|
+
return unpackPair(node.key, node.value, variant);
|
|
278
|
+
}
|
|
279
|
+
case "tuple": {
|
|
280
|
+
return node.items.map((item, index) => unpackVariant(item, variant.getChildValue(index)));
|
|
281
|
+
}
|
|
282
|
+
case "maybe": {
|
|
283
|
+
return unpackMaybe(node.element, variant);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const packValidatedString = (
|
|
289
|
+
value: unknown,
|
|
290
|
+
isValid: (value: string) => boolean,
|
|
291
|
+
description: string,
|
|
292
|
+
construct: (value: string) => GLib.Variant,
|
|
293
|
+
): GLib.Variant => {
|
|
294
|
+
if (typeof value !== "string" || !isValid(value)) {
|
|
295
|
+
throw new Error(`"${String(value)}" is not a valid GVariant ${description}`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return construct(value);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
function packObjectPath(value: unknown): GLib.Variant {
|
|
302
|
+
return packValidatedString(
|
|
303
|
+
value,
|
|
304
|
+
(path) => GLib.Variant.isObjectPath(path),
|
|
305
|
+
"object path",
|
|
306
|
+
(path) => GLib.Variant.newObjectPath(path),
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function packSignature(value: unknown): GLib.Variant {
|
|
311
|
+
return packValidatedString(
|
|
312
|
+
value,
|
|
313
|
+
(signature) => GLib.Variant.isSignature(signature),
|
|
314
|
+
"type signature",
|
|
315
|
+
(signature) => GLib.Variant.newSignature(signature),
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const packEntry = (key: VariantTypeNode, value: VariantTypeNode, pair: [unknown, unknown]): GLib.Variant =>
|
|
320
|
+
GLib.Variant.newDictEntry(packVariant(key, pair[0]), packVariant(value, pair[1]));
|
|
321
|
+
|
|
322
|
+
const dictEntries = (value: unknown): [unknown, unknown][] =>
|
|
323
|
+
value instanceof Map ? [...value] : Object.entries(value as Record<string, unknown>);
|
|
324
|
+
|
|
325
|
+
const packDict = (
|
|
326
|
+
node: { entryTypeString: string; key: VariantTypeNode; value: VariantTypeNode },
|
|
327
|
+
value: unknown,
|
|
328
|
+
): GLib.Variant =>
|
|
329
|
+
GLib.Variant.newArray(
|
|
330
|
+
GLib.VariantType.new(node.entryTypeString),
|
|
331
|
+
dictEntries(value).map((pair) => packEntry(node.key, node.value, pair)),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
const packMaybe = (node: { elementTypeString: string; element: VariantTypeNode }, value: unknown): GLib.Variant =>
|
|
335
|
+
GLib.Variant.newMaybe(
|
|
336
|
+
GLib.VariantType.new(node.elementTypeString),
|
|
337
|
+
value === null ? null : packVariant(node.element, value),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const packVariant = (node: VariantTypeNode, value: unknown): GLib.Variant => {
|
|
341
|
+
switch (node.kind) {
|
|
342
|
+
case "basic": {
|
|
343
|
+
return packBasic[node.code](value);
|
|
344
|
+
}
|
|
345
|
+
case "array": {
|
|
346
|
+
return GLib.Variant.newArray(
|
|
347
|
+
GLib.VariantType.new(node.elementTypeString),
|
|
348
|
+
(value as unknown[]).map((item) => packVariant(node.element, item)),
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
case "dict": {
|
|
352
|
+
return packDict(node, value);
|
|
353
|
+
}
|
|
354
|
+
case "entry": {
|
|
355
|
+
return packEntry(node.key, node.value, value as [unknown, unknown]);
|
|
356
|
+
}
|
|
357
|
+
case "tuple": {
|
|
358
|
+
return GLib.Variant.newTuple(
|
|
359
|
+
node.items.map((item, index) => packVariant(item, (value as unknown[])[index])),
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
case "maybe": {
|
|
363
|
+
return packMaybe(node, value);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export { parseVariantType, unpackVariant, packVariant, type VariantValue, type VariantTypeNode };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-merge-refs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-merge-refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAAwC,MAAM,OAAO,CAAC;AAqBzF,eAAO,MAAM,YAAY,GAAI,CAAC,WAAW,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC,KAAG,WAAW,CAAC,CAAC,CA+BxF,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
2
|
-
const attachRef = (ref, value) => {
|
|
3
|
-
if (typeof ref === "function") {
|
|
4
|
-
const cleanup = ref(value);
|
|
5
|
-
return typeof cleanup === "function" ? cleanup : () => ref(null);
|
|
6
|
-
}
|
|
7
|
-
if (ref) {
|
|
8
|
-
ref.current = value;
|
|
9
|
-
return () => {
|
|
10
|
-
ref.current = null;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return undefined;
|
|
14
|
-
};
|
|
15
|
-
export const useMergeRefs = (...refs) => {
|
|
16
|
-
const latestRefs = useRef(refs);
|
|
17
|
-
latestRefs.current = refs;
|
|
18
|
-
const attachedRef = useRef(null);
|
|
19
|
-
useLayoutEffect(() => {
|
|
20
|
-
const attached = attachedRef.current;
|
|
21
|
-
if (attached === null)
|
|
22
|
-
return;
|
|
23
|
-
const next = latestRefs.current;
|
|
24
|
-
for (let index = next.length; index < attached.entries.length; index += 1) {
|
|
25
|
-
attached.entries[index]?.cleanup?.();
|
|
26
|
-
}
|
|
27
|
-
attached.entries = next.map((ref, index) => {
|
|
28
|
-
const entry = attached.entries[index];
|
|
29
|
-
if (entry !== undefined && entry.ref === ref)
|
|
30
|
-
return entry;
|
|
31
|
-
entry?.cleanup?.();
|
|
32
|
-
return { ref, cleanup: attachRef(ref, attached.value) };
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
return useCallback((value) => {
|
|
36
|
-
const entries = latestRefs.current.map((ref) => ({ ref, cleanup: attachRef(ref, value) }));
|
|
37
|
-
attachedRef.current = { value, entries };
|
|
38
|
-
return () => {
|
|
39
|
-
const attached = attachedRef.current;
|
|
40
|
-
attachedRef.current = null;
|
|
41
|
-
if (attached) {
|
|
42
|
-
for (const entry of attached.entries)
|
|
43
|
-
entry.cleanup?.();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=use-merge-refs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-merge-refs.js","sourceRoot":"","sources":["../../src/hooks/use-merge-refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAOzF,MAAM,SAAS,GAAG,CAAI,GAA8B,EAAE,KAAQ,EAA4B,EAAE;IACxF,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;QACN,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;QACpB,OAAO,GAAG,EAAE;YACR,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC,C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AAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3F,WAAW,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QACzC,OAAO,GAAG,EAAE;YACR,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC;YACrC,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;YAC3B,IAAI,QAAQ,EAAE,CAAC;gBACX,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO;oBAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5D,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC,CAAC","sourcesContent":["import { type Ref, type RefCallback, useCallback, useLayoutEffect, useRef } from \"react\";\n\ntype MergedRefEntry<T> = {\n ref: Ref<T | null> | undefined;\n cleanup: (() => void) | undefined;\n};\n\nconst attachRef = <T>(ref: Ref<T | null> | undefined, value: T): (() => void) | undefined => {\n if (typeof ref === \"function\") {\n const cleanup = ref(value);\n return typeof cleanup === \"function\" ? cleanup : () => ref(null);\n }\n if (ref) {\n ref.current = value;\n return () => {\n ref.current = null;\n };\n }\n return undefined;\n};\n\nexport const useMergeRefs = <T>(...refs: Array<Ref<T | null> | undefined>): RefCallback<T> => {\n const latestRefs = useRef(refs);\n latestRefs.current = refs;\n const attachedRef = useRef<{ value: T; entries: MergedRefEntry<T>[] } | null>(null);\n\n useLayoutEffect(() => {\n const attached = attachedRef.current;\n if (attached === null) return;\n const next = latestRefs.current;\n for (let index = next.length; index < attached.entries.length; index += 1) {\n attached.entries[index]?.cleanup?.();\n }\n attached.entries = next.map((ref, index) => {\n const entry = attached.entries[index];\n if (entry !== undefined && entry.ref === ref) return entry;\n entry?.cleanup?.();\n return { ref, cleanup: attachRef(ref, attached.value) };\n });\n });\n\n return useCallback((value: T) => {\n const entries = latestRefs.current.map((ref) => ({ ref, cleanup: attachRef(ref, value) }));\n attachedRef.current = { value, entries };\n return () => {\n const attached = attachedRef.current;\n attachedRef.current = null;\n if (attached) {\n for (const entry of attached.entries) entry.cleanup?.();\n }\n };\n }, []);\n};\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import { type ObjectProp } from "../utils/object-prop.js";
|
|
3
|
-
type ObjectAttachmentOps<T extends GObject.Object, A> = {
|
|
4
|
-
attach(object: T): A;
|
|
5
|
-
detach(attachment: A): void;
|
|
6
|
-
isSame(attachment: A, object: T): boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare const useObjectAttachment: <T extends GObject.Object, A>(object: ObjectProp<T>, ops: ObjectAttachmentOps<T, A>) => void;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=use-object-attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-object-attachment.d.ts","sourceRoot":"","sources":["../../src/hooks/use-object-attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,yBAAyB,CAAC;AAE7E,KAAK,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI;IACpD,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB,MAAM,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,UACnD,UAAU,CAAC,CAAC,CAAC,OAChB,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,KAC/B,IAqBF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useRef } from "react";
|
|
2
|
-
import { resolveObjectProp } from "../utils/object-prop.js";
|
|
3
|
-
export const useObjectAttachment = (object, ops) => {
|
|
4
|
-
const attachmentRef = useRef(null);
|
|
5
|
-
const drop = () => {
|
|
6
|
-
const attachment = attachmentRef.current;
|
|
7
|
-
if (attachment !== null) {
|
|
8
|
-
ops.detach(attachment);
|
|
9
|
-
attachmentRef.current = null;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
useLayoutEffect(() => {
|
|
13
|
-
const resolved = resolveObjectProp(object);
|
|
14
|
-
const attachment = attachmentRef.current;
|
|
15
|
-
if (attachment !== null && resolved !== null && ops.isSame(attachment, resolved))
|
|
16
|
-
return;
|
|
17
|
-
drop();
|
|
18
|
-
if (resolved === null)
|
|
19
|
-
return;
|
|
20
|
-
attachmentRef.current = ops.attach(resolved);
|
|
21
|
-
});
|
|
22
|
-
useLayoutEffect(() => () => drop(), []);
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=use-object-attachment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-object-attachment.js","sourceRoot":"","sources":["../../src/hooks/use-object-attachment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAmB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAQ7E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAC/B,MAAqB,EACrB,GAA8B,EAC1B,EAAE;IACN,MAAM,aAAa,GAAG,MAAM,CAAW,IAAI,CAAC,CAAC;IAE7C,MAAM,IAAI,GAAG,GAAS,EAAE;QACpB,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC;QACzC,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACtB,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACvB,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QACjC,CAAC;IACL,CAAC,CAAC;IAEF,eAAe,CAAC,GAAG,EAAE;QACjB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC;QACzC,IAAI,UAAU,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC;YAAE,OAAO;QACzF,IAAI,EAAE,CAAC;QACP,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO;QAC9B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport { type ObjectProp, resolveObjectProp } from \"../utils/object-prop.js\";\n\ntype ObjectAttachmentOps<T extends GObject.Object, A> = {\n attach(object: T): A;\n detach(attachment: A): void;\n isSame(attachment: A, object: T): boolean;\n};\n\nexport const useObjectAttachment = <T extends GObject.Object, A>(\n object: ObjectProp<T>,\n ops: ObjectAttachmentOps<T, A>,\n): void => {\n const attachmentRef = useRef<A | null>(null);\n\n const drop = (): void => {\n const attachment = attachmentRef.current;\n if (attachment !== null) {\n ops.detach(attachment);\n attachmentRef.current = null;\n }\n };\n\n useLayoutEffect(() => {\n const resolved = resolveObjectProp(object);\n const attachment = attachmentRef.current;\n if (attachment !== null && resolved !== null && ops.isSame(attachment, resolved)) return;\n drop();\n if (resolved === null) return;\n attachmentRef.current = ops.attach(resolved);\n });\n\n useLayoutEffect(() => () => drop(), []);\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../../src/libraries/adw/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAA0C,MAAM,OAAO,CAAC;AAM3G,KAAK,oBAAoB,GAAG;IACxB,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,cAAe,WAAW,KAAG,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAsBzG,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useLayoutEffect, useState } from "react";
|
|
3
|
-
import { useMergeRefs } from "../../hooks/use-merge-refs.js";
|
|
4
|
-
import { useParentWindow } from "../../hooks/use-parent-window.js";
|
|
5
|
-
import { createPortal } from "../../reconciler/portal.js";
|
|
6
|
-
import { rootElement } from "../../reconciler/root-element.js";
|
|
7
|
-
export const createDialogComponent = (Component) => {
|
|
8
|
-
return ({ ref, ...rest }) => {
|
|
9
|
-
const parent = useParentWindow();
|
|
10
|
-
const [dialog, setDialog] = useState(null);
|
|
11
|
-
const handleMount = useCallback((instance) => {
|
|
12
|
-
setDialog(instance);
|
|
13
|
-
return () => {
|
|
14
|
-
instance.forceClose();
|
|
15
|
-
setDialog(null);
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
18
|
-
useLayoutEffect(() => {
|
|
19
|
-
dialog?.present(parent);
|
|
20
|
-
}, [dialog, parent]);
|
|
21
|
-
const mergedRef = useMergeRefs(ref, handleMount);
|
|
22
|
-
return createPortal(_jsx(Component, { ref: mergedRef, ...rest }), rootElement);
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
//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C9E,CAAC,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport { type ElementType, type ReactNode, type Ref, useCallback, useLayoutEffect, useState } from \"react\";\nimport { useMergeRefs } from \"../../hooks/use-merge-refs.js\";\nimport { useParentWindow } from \"../../hooks/use-parent-window.js\";\nimport { createPortal } from \"../../reconciler/portal.js\";\nimport { rootElement } from \"../../reconciler/root-element.js\";\n\ntype DialogComponentProps = {\n ref?: Ref<Adw.Dialog | null> | undefined;\n};\n\nexport const createDialogComponent = (Component: ElementType): ((props: DialogComponentProps) => ReactNode) => {\n return ({ ref, ...rest }: DialogComponentProps): ReactNode => {\n const parent = useParentWindow();\n const [dialog, setDialog] = useState<Adw.Dialog | null>(null);\n\n const handleMount = useCallback((instance: Adw.Dialog) => {\n setDialog(instance);\n\n return () => {\n instance.forceClose();\n setDialog(null);\n };\n }, []);\n\n useLayoutEffect(() => {\n dialog?.present(parent);\n }, [dialog, parent]);\n\n const mergedRef = useMergeRefs<Adw.Dialog>(ref, handleMount);\n\n return createPortal(<Component ref={mergedRef} {...rest} />, rootElement);\n };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/libraries/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/libraries/adw/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { createDialogComponent } from \"./dialog.js\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accessible.d.ts","sourceRoot":"","sources":["../../src/reconciler/accessible.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,E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