@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,107 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
/** The props of a host element or node, as React passes them through the reconciler. */
|
|
3
|
+
type Props = Record<string, unknown>;
|
|
4
|
+
/** Per-child values a slot hook receives while placing or moving one child. */
|
|
5
|
+
type PlaceInfo = {
|
|
6
|
+
slot: string;
|
|
7
|
+
index: number;
|
|
8
|
+
sibling: GObject.Object | null;
|
|
9
|
+
adopted: GObject.Object | null;
|
|
10
|
+
props: Props;
|
|
11
|
+
context: unknown;
|
|
12
|
+
};
|
|
13
|
+
/** Per-child values a slot hook receives while removing one child. */
|
|
14
|
+
type DetachInfo = {
|
|
15
|
+
slot: string;
|
|
16
|
+
adopted: GObject.Object | null;
|
|
17
|
+
props: Props;
|
|
18
|
+
context: unknown;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Customizes how one element type places children and applies props. Every hook receives the
|
|
22
|
+
* GObject instance and a private per-node `context` built once by `createContext`. A slot hook
|
|
23
|
+
* claims a child by returning a non-`undefined` value; that value, or `resolve`, is the object
|
|
24
|
+
* the container adopts for the child. `update` returns the prop names it consumed so those props
|
|
25
|
+
* are not also set as plain GObject properties. `create` builds the GObject for types whose
|
|
26
|
+
* constructor does more than set properties, and is consulted for its own type only, never
|
|
27
|
+
* inherited by subtypes.
|
|
28
|
+
*/
|
|
29
|
+
type ElementBehavior<T extends GObject.Object = GObject.Object> = {
|
|
30
|
+
create?: (props: Props) => GObject.Object;
|
|
31
|
+
createContext?: (object: T) => unknown;
|
|
32
|
+
attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;
|
|
33
|
+
reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;
|
|
34
|
+
detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;
|
|
35
|
+
resolve?: (object: T, child: GObject.Object) => GObject.Object | null;
|
|
36
|
+
update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;
|
|
37
|
+
flush?: (object: T, context: unknown) => void;
|
|
38
|
+
mount?: (object: T, context: unknown) => void;
|
|
39
|
+
unmount?: (object: T, context: unknown) => void;
|
|
40
|
+
deferred?: string[];
|
|
41
|
+
};
|
|
42
|
+
/** A named export in a module, referenced as plain data (the module is never imported at runtime). */
|
|
43
|
+
type ModuleExport = {
|
|
44
|
+
module: string;
|
|
45
|
+
export: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Per-element configuration keyed by GLib type name: whether the element is lazy (its GObject is
|
|
49
|
+
* created by its parent container, as pages and layout children are), the custom behaviors bound to
|
|
50
|
+
* its type, an optional component that wraps the generated element, the base props interface its
|
|
51
|
+
* generated props extend, and the GObject properties to leave out of the generated props (those a
|
|
52
|
+
* behavior already writes from children, such as the `child` and `content` properties). `component`,
|
|
53
|
+
* `props` and `omitProps` are inert at runtime; they are read only by codegen.
|
|
54
|
+
*/
|
|
55
|
+
type ElementConfig<T extends GObject.Object = GObject.Object> = {
|
|
56
|
+
lazy?: boolean;
|
|
57
|
+
behaviors?: ElementBehavior<T>[];
|
|
58
|
+
component?: ModuleExport;
|
|
59
|
+
props?: ModuleExport;
|
|
60
|
+
omitProps?: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`
|
|
64
|
+
* is loaded.
|
|
65
|
+
*/
|
|
66
|
+
declare const ELEMENTS: Record<string, ElementConfig>;
|
|
67
|
+
/** Props a behavior applies after construction; the constructor is never given them. */
|
|
68
|
+
declare const deferredProps: (behavior: ElementBehavior) => string[];
|
|
69
|
+
/**
|
|
70
|
+
* Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's
|
|
71
|
+
* behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first)
|
|
72
|
+
* and taking the last lazy flag, component, and props seen. Use it to combine an app's element config
|
|
73
|
+
* with its behaviors.
|
|
74
|
+
*/
|
|
75
|
+
declare const mergeElementConfigs: (...maps: Record<string, ElementConfig<never>>[]) => Record<string, ElementConfig>;
|
|
76
|
+
/**
|
|
77
|
+
* Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the
|
|
78
|
+
* registry. Behaviors are appended by default (the framework's built-ins register this way); pass
|
|
79
|
+
* `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the
|
|
80
|
+
* built-ins for the same slot, letting it override them regardless of registration order.
|
|
81
|
+
*/
|
|
82
|
+
declare const registerElements: (map: Record<string, ElementConfig<never>>, options?: {
|
|
83
|
+
prepend?: boolean;
|
|
84
|
+
}) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling
|
|
87
|
+
* editor autocompletion and type checking. Key each entry by GLib type name and write each behavior
|
|
88
|
+
* with {@link defineBehavior} so its hooks receive the concrete GObject class.
|
|
89
|
+
*/
|
|
90
|
+
declare const defineElements: (elements: Record<string, ElementConfig<never>>) => Record<string, ElementConfig<never>>;
|
|
91
|
+
/**
|
|
92
|
+
* Types one behavior against the GObject class it applies to, so every hook's object parameter is
|
|
93
|
+
* inferred rather than annotated by hand. Pass the class as the type argument.
|
|
94
|
+
*
|
|
95
|
+
* ```ts
|
|
96
|
+
* defineElements({
|
|
97
|
+
* GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare const defineBehavior: <T extends GObject.Object>(hooks: ElementBehavior<T>) => ElementBehavior<never>;
|
|
102
|
+
/** Spreads one config across many GLib type names. */
|
|
103
|
+
declare const forTypes: (types: string[], config: ElementConfig<never>) => Record<string, ElementConfig<never>>;
|
|
104
|
+
/** References a base props interface exported from `@gtkx/react/internal`. */
|
|
105
|
+
declare const internal: (name: string) => ModuleExport;
|
|
106
|
+
export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, defineBehavior, forTypes, internal, type Props, type PlaceInfo, type DetachInfo, type ElementBehavior, type ModuleExport, type ElementConfig, };
|
|
107
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/reconciler/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErC,+EAA+E;AAC/E,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,sEAAsE;AACtE,KAAK,UAAU,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,KAAK,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI;IAC9D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;IACvC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IACxE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EA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K,KAAK,EACV,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,GACrB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`
|
|
3
|
+
* is loaded.
|
|
4
|
+
*/
|
|
5
|
+
const ELEMENTS = {};
|
|
6
|
+
/** Props a behavior applies after construction; the constructor is never given them. */
|
|
7
|
+
const deferredProps = (behavior) => behavior.deferred ?? [];
|
|
8
|
+
const mergeBehaviors = (base, added, isPrepended) => {
|
|
9
|
+
const baseBehaviors = base.behaviors ?? [];
|
|
10
|
+
return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];
|
|
11
|
+
};
|
|
12
|
+
const mergeConfigEntry = (base, added, isPrepended = false) => {
|
|
13
|
+
const { behaviors, lazy, omitProps, ...rest } = added;
|
|
14
|
+
const entry = { ...base, ...rest };
|
|
15
|
+
if (behaviors !== undefined) {
|
|
16
|
+
entry.behaviors = mergeBehaviors(base, behaviors, isPrepended);
|
|
17
|
+
}
|
|
18
|
+
if (omitProps !== undefined) {
|
|
19
|
+
entry.omitProps = [...(base.omitProps ?? []), ...omitProps];
|
|
20
|
+
}
|
|
21
|
+
if (lazy === true) {
|
|
22
|
+
entry.lazy = true;
|
|
23
|
+
}
|
|
24
|
+
return entry;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's
|
|
28
|
+
* behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first)
|
|
29
|
+
* and taking the last lazy flag, component, and props seen. Use it to combine an app's element config
|
|
30
|
+
* with its behaviors.
|
|
31
|
+
*/
|
|
32
|
+
const mergeElementConfigs = (...maps) => {
|
|
33
|
+
const merged = {};
|
|
34
|
+
for (const map of maps) {
|
|
35
|
+
for (const [type, config] of Object.entries(map)) {
|
|
36
|
+
merged[type] = mergeConfigEntry(merged[type] ?? {}, config);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return merged;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the
|
|
43
|
+
* registry. Behaviors are appended by default (the framework's built-ins register this way); pass
|
|
44
|
+
* `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the
|
|
45
|
+
* built-ins for the same slot, letting it override them regardless of registration order.
|
|
46
|
+
*/
|
|
47
|
+
const registerElements = (map, options = {}) => {
|
|
48
|
+
for (const [type, config] of Object.entries(map)) {
|
|
49
|
+
ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.prepend === true);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling
|
|
54
|
+
* editor autocompletion and type checking. Key each entry by GLib type name and write each behavior
|
|
55
|
+
* with {@link defineBehavior} so its hooks receive the concrete GObject class.
|
|
56
|
+
*/
|
|
57
|
+
const defineElements = (elements) => elements;
|
|
58
|
+
/**
|
|
59
|
+
* Types one behavior against the GObject class it applies to, so every hook's object parameter is
|
|
60
|
+
* inferred rather than annotated by hand. Pass the class as the type argument.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* defineElements({
|
|
64
|
+
* GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
const defineBehavior = (hooks) => hooks;
|
|
69
|
+
/** Spreads one config across many GLib type names. */
|
|
70
|
+
const forTypes = (types, config) => Object.fromEntries(types.map((type) => [type, config]));
|
|
71
|
+
/** References a base props interface exported from `@gtkx/react/internal`. */
|
|
72
|
+
const internal = (name) => ({ module: "@gtkx/react/internal", export: name });
|
|
73
|
+
export { ELEMENTS, deferredProps, mergeElementConfigs, registerElements, defineElements, defineBehavior, forTypes, internal, };
|
|
74
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/reconciler/registry.ts"],"names":[],"mappings":"AAiEA;;;GAGG;AACH,MAAM,QAAQ,GAAkC,EAAE,CAAC;AAEnD,wFAAwF;AACxF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAY,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;AAEvF,MAAM,cAAc,GAAG,CAAC,IAAmB,EAAE,KAAwB,EAAE,WAAoB,EAAqB,EAAE;IAC9G,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAE3C,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,KAAK,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAE,KAA2B,EAAE,WAAW,GAAG,KAAK,EAAiB,EAAE;IAC9G,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,KAAK,GAAkB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAElD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC,IAAI,EAAE,SAA8B,EAAE,WAAW,CAAC,CAAC;IACxF,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,KAAK,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAChE,CAAC;IA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,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAE5D,8EAA8E;AAC9E,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAEpG,OAAO,EACH,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,GAOX,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\n\n/** The props of a host element or node, as React passes them through the reconciler. */\ntype Props = Record<string, unknown>;\n\n/** Per-child values a slot hook receives while placing or moving one child. */\ntype PlaceInfo = {\n slot: string;\n index: number;\n sibling: GObject.Object | null;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/** Per-child values a slot hook receives while removing one child. */\ntype DetachInfo = {\n slot: string;\n adopted: GObject.Object | null;\n props: Props;\n context: unknown;\n};\n\n/**\n * Customizes how one element type places children and applies props. Every hook receives the\n * GObject instance and a private per-node `context` built once by `createContext`. A slot hook\n * claims a child by returning a non-`undefined` value; that value, or `resolve`, is the object\n * the container adopts for the child. `update` returns the prop names it consumed so those props\n * are not also set as plain GObject properties. `create` builds the GObject for types whose\n * constructor does more than set properties, and is consulted for its own type only, never\n * inherited by subtypes.\n */\ntype ElementBehavior<T extends GObject.Object = GObject.Object> = {\n create?: (props: Props) => GObject.Object;\n createContext?: (object: T) => unknown;\n attach?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n reorder?: (object: T, child: GObject.Object, info: PlaceInfo) => unknown;\n detach?: (object: T, child: GObject.Object, info: DetachInfo) => void;\n resolve?: (object: T, child: GObject.Object) => GObject.Object | null;\n update?: (object: T, prev: Props, next: Props, context: unknown) => Iterable<string> | undefined;\n flush?: (object: T, context: unknown) => void;\n mount?: (object: T, context: unknown) => void;\n unmount?: (object: T, context: unknown) => void;\n deferred?: string[];\n};\n\n/** A named export in a module, referenced as plain data (the module is never imported at runtime). */\ntype ModuleExport = { module: string; export: string };\n\n/**\n * Per-element configuration keyed by GLib type name: whether the element is lazy (its GObject is\n * created by its parent container, as pages and layout children are), the custom behaviors bound to\n * its type, an optional component that wraps the generated element, the base props interface its\n * generated props extend, and the GObject properties to leave out of the generated props (those a\n * behavior already writes from children, such as the `child` and `content` properties). `component`,\n * `props` and `omitProps` are inert at runtime; they are read only by codegen.\n */\ntype ElementConfig<T extends GObject.Object = GObject.Object> = {\n lazy?: boolean;\n behaviors?: ElementBehavior<T>[];\n component?: ModuleExport;\n props?: ModuleExport;\n omitProps?: string[];\n};\n\n/**\n * Every registered element config, keyed by GLib type name. Adwaita entries appear once `@gtkx/react/adw`\n * is loaded.\n */\nconst ELEMENTS: Record<string, ElementConfig> = {};\n\n/** Props a behavior applies after construction; the constructor is never given them. */\nconst deferredProps = (behavior: ElementBehavior): string[] => behavior.deferred ?? [];\n\nconst mergeBehaviors = (base: ElementConfig, added: ElementBehavior[], isPrepended: boolean): ElementBehavior[] => {\n const baseBehaviors = base.behaviors ?? [];\n\n return isPrepended ? [...added, ...baseBehaviors] : [...baseBehaviors, ...added];\n};\n\nconst mergeConfigEntry = (base: ElementConfig, added: ElementConfig<never>, isPrepended = false): ElementConfig => {\n const { behaviors, lazy, omitProps, ...rest } = added;\n const entry: ElementConfig = { ...base, ...rest };\n\n if (behaviors !== undefined) {\n entry.behaviors = mergeBehaviors(base, behaviors as ElementBehavior[], isPrepended);\n }\n\n if (omitProps !== undefined) {\n entry.omitProps = [...(base.omitProps ?? []), ...omitProps];\n }\n\n if (lazy === true) {\n entry.lazy = true;\n }\n\n return entry;\n};\n\n/**\n * Merges maps of {@link ElementConfig} keyed by GLib type name into one, concatenating each type's\n * behaviors and omitted props in the order the maps are given (an earlier map's behaviors come first)\n * and taking the last lazy flag, component, and props seen. Use it to combine an app's element config\n * with its behaviors.\n */\nconst mergeElementConfigs = (...maps: Record<string, ElementConfig<never>>[]): Record<string, ElementConfig> => {\n const merged: Record<string, ElementConfig> = {};\n\n for (const map of maps) {\n for (const [type, config] of Object.entries(map)) {\n merged[type] = mergeConfigEntry(merged[type] ?? {}, config);\n }\n }\n\n return merged;\n};\n\n/**\n * Registers a map of {@link ElementConfig} keyed by GLib type name, merging each entry into the\n * registry. Behaviors are appended by default (the framework's built-ins register this way); pass\n * `{ prepend: true }` for an app's own configuration so its behaviors are consulted before the\n * built-ins for the same slot, letting it override them regardless of registration order.\n */\nconst registerElements = (\n map: Record<string, ElementConfig<never>>,\n options: { prepend?: boolean } = {},\n): void => {\n for (const [type, config] of Object.entries(map)) {\n ELEMENTS[type] = mergeConfigEntry(ELEMENTS[type] ?? {}, config, options.prepend === true);\n }\n};\n\n/**\n * Identity helper that types the module named by the `elements` entry of `gtkx.config.ts`, enabling\n * editor autocompletion and type checking. Key each entry by GLib type name and write each behavior\n * with {@link defineBehavior} so its hooks receive the concrete GObject class.\n */\nconst defineElements = (elements: Record<string, ElementConfig<never>>): Record<string, ElementConfig<never>> =>\n elements;\n\n/**\n * Types one behavior against the GObject class it applies to, so every hook's object parameter is\n * inferred rather than annotated by hand. Pass the class as the type argument.\n *\n * ```ts\n * defineElements({\n * GtkFrame: { behaviors: [defineBehavior<Gtk.Frame>({ attach: (frame, child) => frame.setChild(child) })] },\n * });\n * ```\n */\nconst defineBehavior = <T extends GObject.Object>(hooks: ElementBehavior<T>): ElementBehavior<never> => hooks;\n\n/** Spreads one config across many GLib type names. */\nconst forTypes = (types: string[], config: ElementConfig<never>): Record<string, ElementConfig<never>> =>\n Object.fromEntries(types.map((type) => [type, config]));\n\n/** References a base props interface exported from `@gtkx/react/internal`. */\nconst internal = (name: string): ModuleExport => ({ module: \"@gtkx/react/internal\", export: name });\n\nexport {\n ELEMENTS,\n deferredProps,\n mergeElementConfigs,\n registerElements,\n defineElements,\n defineBehavior,\n forTypes,\n internal,\n type Props,\n type PlaceInfo,\n type DetachInfo,\n type ElementBehavior,\n type ModuleExport,\n type ElementConfig,\n};\n"]}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export type RootElement = {
|
|
6
|
-
[ROOT_ELEMENT]: true;
|
|
1
|
+
/** The type of the shared {@link rootElement} marker used as a default top-level container. */
|
|
2
|
+
type RootElement = {
|
|
3
|
+
[ROOT_ELEMENT_BRAND]: true;
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export {};
|
|
5
|
+
declare const ROOT_ELEMENT_BRAND: unique symbol;
|
|
6
|
+
/** A shared marker value used as the default top-level container for rendering and portals. */
|
|
7
|
+
declare const rootElement: RootElement;
|
|
8
|
+
/** Reports whether an arbitrary value is a {@link rootElement} marker. */
|
|
9
|
+
declare const isRootElement: (value: unknown) => value is RootElement;
|
|
10
|
+
export { rootElement, isRootElement, type RootElement };
|
|
14
11
|
//# sourceMappingURL=root-element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"root-element.d.ts","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,KAAK,WAAW,GAAG;IAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD,QAAA,MAAM,kBAAkB,EAAE,OAAO,MAAwC,CAAC;AAC1E,+FAA+F;AAC/F,QAAA,MAAM,WAAW,EAAE,WAA4C,CAAC;AAEhE,0EAA0E;AAC1E,QAAA,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,WAC0C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
const ROOT_ELEMENT_BRAND = Symbol.for("gtkx:root-element");
|
|
2
|
+
/** A shared marker value used as the default top-level container for rendering and portals. */
|
|
3
|
+
const rootElement = { [ROOT_ELEMENT_BRAND]: true };
|
|
4
|
+
/** Reports whether an arbitrary value is a {@link rootElement} marker. */
|
|
5
|
+
const isRootElement = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);
|
|
6
|
+
export { rootElement, isRootElement };
|
|
7
7
|
//# sourceMappingURL=root-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"root-element.js","sourceRoot":"","sources":["../../src/reconciler/root-element.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GAAkB,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1E,+FAA+F;AAC/F,MAAM,WAAW,GAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC;AAEhE,0EAA0E;AAC1E,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,CAAC","sourcesContent":["/** The type of the shared {@link rootElement} marker used as a default top-level container. */\ntype RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\nconst ROOT_ELEMENT_BRAND: unique symbol = Symbol.for(\"gtkx:root-element\");\n/** A shared marker value used as the default top-level container for rendering and portals. */\nconst rootElement: RootElement = { [ROOT_ELEMENT_BRAND]: true };\n\n/** Reports whether an arbitrary value is a {@link rootElement} marker. */\nconst isRootElement = (value: unknown): value is RootElement =>\n typeof value === \"object\" && value !== null && Object.hasOwn(value, ROOT_ELEMENT_BRAND);\n\nexport { rootElement, isRootElement, type RootElement };\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ErrorInfo, ReactNode, ReactPortal } from "react";
|
|
2
|
+
import * as Gdk from "@gtkx/gi/gdk";
|
|
3
|
+
import { type Container } from "./host-config.js";
|
|
4
|
+
type RootErrorCallbacks = {
|
|
5
|
+
onUncaughtError?: (error: unknown, info: ErrorInfo) => void;
|
|
6
|
+
onCaughtError?: (error: unknown, info: ErrorInfo) => void;
|
|
7
|
+
onRecoverableError?: (error: unknown, info: ErrorInfo) => void;
|
|
8
|
+
};
|
|
9
|
+
type ReconcilerRootOptions = RootErrorCallbacks & {
|
|
10
|
+
containerInfo: Container;
|
|
11
|
+
};
|
|
12
|
+
/** A root that mounts an element tree into an explicit container and reports render errors. */
|
|
13
|
+
type ReconcilerRoot = {
|
|
14
|
+
update: (element: ReactNode) => void;
|
|
15
|
+
unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
/** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */
|
|
18
|
+
type Root = {
|
|
19
|
+
render: (element: ReactNode) => void;
|
|
20
|
+
unmount: () => void;
|
|
21
|
+
};
|
|
22
|
+
type ErrorHandler = (error: unknown) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Installs a process-wide handler for errors thrown while rendering or applying an update.
|
|
25
|
+
*
|
|
26
|
+
* @param handler The handler to install.
|
|
27
|
+
* @returns The previously installed handler, or null.
|
|
28
|
+
*/
|
|
29
|
+
declare const setReconcilerErrorHandler: (handler: ErrorHandler) => ErrorHandler | null;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.
|
|
32
|
+
*
|
|
33
|
+
* @param options The container to render into and the error callbacks to route failures to.
|
|
34
|
+
* @returns A {@link ReconcilerRoot}.
|
|
35
|
+
*/
|
|
36
|
+
declare const createReconcilerRoot: (options: ReconcilerRootOptions) => ReconcilerRoot;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a render root for a GTKX application.
|
|
39
|
+
*
|
|
40
|
+
* @param container The top-level container to render into; defaults to the shared {@link rootElement}.
|
|
41
|
+
* @returns A {@link Root} exposing render and unmount.
|
|
42
|
+
*/
|
|
43
|
+
declare const createRoot: (container?: Container) => Root;
|
|
44
|
+
/** Unmounts every active render root and stops the originating signal from propagating further. */
|
|
45
|
+
declare const quit: () => typeof Gdk.EVENT_STOP;
|
|
46
|
+
/**
|
|
47
|
+
* Renders children into a container other than the surrounding tree.
|
|
48
|
+
*
|
|
49
|
+
* @param children The element tree to render.
|
|
50
|
+
* @param container The GObject, application, or {@link rootElement} to render into.
|
|
51
|
+
* @param key An optional stable key.
|
|
52
|
+
* @returns A React portal.
|
|
53
|
+
*/
|
|
54
|
+
declare const createPortal: (children: ReactNode, container: Container, key?: string) => ReactPortal;
|
|
55
|
+
export { setReconcilerErrorHandler, createReconcilerRoot, createRoot, quit, createPortal, type ReconcilerRoot, type Root, };
|
|
56
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAK9D,KAAK,kBAAkB,GAAG;IACtB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC5D,a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I,EACJ,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,IAAI,GACZ,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as Gdk from "@gtkx/gi/gdk";
|
|
2
|
+
import { createLogger } from "@gtkx/utils";
|
|
3
|
+
import { ConcurrentRoot } from "react-reconciler/constants.js";
|
|
4
|
+
import { reconciler } from "./host-config.js";
|
|
5
|
+
import { rootElement } from "./root-element.js";
|
|
6
|
+
const log = createLogger("react");
|
|
7
|
+
const activeRoots = new Set();
|
|
8
|
+
const errorHandlerSlot = createErrorHandlerSlot();
|
|
9
|
+
function createErrorHandlerSlot() {
|
|
10
|
+
let current = null;
|
|
11
|
+
return {
|
|
12
|
+
get: () => current,
|
|
13
|
+
set: (handler) => {
|
|
14
|
+
const previous = current;
|
|
15
|
+
current = handler;
|
|
16
|
+
return previous;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Installs a process-wide handler for errors thrown while rendering or applying an update.
|
|
22
|
+
*
|
|
23
|
+
* @param handler The handler to install.
|
|
24
|
+
* @returns The previously installed handler, or null.
|
|
25
|
+
*/
|
|
26
|
+
const setReconcilerErrorHandler = (handler) => errorHandlerSlot.set(handler);
|
|
27
|
+
const rethrowUncaughtRenderError = (error) => {
|
|
28
|
+
throw error;
|
|
29
|
+
};
|
|
30
|
+
const logCaughtRenderError = (error) => {
|
|
31
|
+
log.error("caught render error", error);
|
|
32
|
+
};
|
|
33
|
+
const openContainer = (containerInfo, callbacks) => {
|
|
34
|
+
const container = reconciler.createContainer(containerInfo, ConcurrentRoot, null, false, null, "", (error, info) => {
|
|
35
|
+
errorHandlerSlot.get()?.(error);
|
|
36
|
+
callbacks.onUncaughtError?.(error, info);
|
|
37
|
+
}, (error, info) => {
|
|
38
|
+
errorHandlerSlot.get()?.(error);
|
|
39
|
+
callbacks.onCaughtError?.(error, info);
|
|
40
|
+
}, (error, info) => {
|
|
41
|
+
callbacks.onRecoverableError?.(error, info);
|
|
42
|
+
}, () => undefined);
|
|
43
|
+
activeRoots.add(container);
|
|
44
|
+
return container;
|
|
45
|
+
};
|
|
46
|
+
const unmountContainer = (container) => {
|
|
47
|
+
reconciler.updateContainer(null, container, null, null);
|
|
48
|
+
activeRoots.delete(container);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.
|
|
52
|
+
*
|
|
53
|
+
* @param options The container to render into and the error callbacks to route failures to.
|
|
54
|
+
* @returns A {@link ReconcilerRoot}.
|
|
55
|
+
*/
|
|
56
|
+
const createReconcilerRoot = (options) => {
|
|
57
|
+
const container = openContainer(options.containerInfo, options);
|
|
58
|
+
const root = {
|
|
59
|
+
update: (element) => {
|
|
60
|
+
reconciler.updateContainer(element, container, null, null);
|
|
61
|
+
},
|
|
62
|
+
unmount: async (teardown) => {
|
|
63
|
+
await teardown(root);
|
|
64
|
+
activeRoots.delete(container);
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return root;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Creates a render root for a GTKX application.
|
|
71
|
+
*
|
|
72
|
+
* @param container The top-level container to render into; defaults to the shared {@link rootElement}.
|
|
73
|
+
* @returns A {@link Root} exposing render and unmount.
|
|
74
|
+
*/
|
|
75
|
+
const createRoot = (container = rootElement) => {
|
|
76
|
+
const opaque = openContainer(container, {
|
|
77
|
+
onUncaughtError: rethrowUncaughtRenderError,
|
|
78
|
+
onCaughtError: logCaughtRenderError,
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
render: (element) => {
|
|
82
|
+
reconciler.updateContainer(element, opaque, null, null);
|
|
83
|
+
},
|
|
84
|
+
unmount: () => {
|
|
85
|
+
unmountContainer(opaque);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/** Unmounts every active render root and stops the originating signal from propagating further. */
|
|
90
|
+
const quit = () => {
|
|
91
|
+
for (const container of activeRoots) {
|
|
92
|
+
unmountContainer(container);
|
|
93
|
+
}
|
|
94
|
+
return Gdk.EVENT_STOP;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Renders children into a container other than the surrounding tree.
|
|
98
|
+
*
|
|
99
|
+
* @param children The element tree to render.
|
|
100
|
+
* @param container The GObject, application, or {@link rootElement} to render into.
|
|
101
|
+
* @param key An optional stable key.
|
|
102
|
+
* @returns A React portal.
|
|
103
|
+
*/
|
|
104
|
+
const createPortal = (children, container, key) => reconciler.createPortal(children, container, null, key ?? null);
|
|
105
|
+
export { setReconcilerErrorHandler, createReconcilerRoot, createRoot, quit, createPortal, };
|
|
106
|
+
//# sourceMappingURL=root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/reconciler/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA4BhD,MAAM,GAAG,GAAW,YAAY,CAAC,OAAO,CAAC,CAAC;AAC1C,MAAM,WAAW,GAAoB,IAAI,GAAG,EAAE,CAAC;AAC/C,MAAM,gBAAgB,GAAG,sBAAsB,EAAE,CAAC;AAElD,SAAS,sBAAsB;IAC3B,IAAI,OAAO,GAAwB,IAAI,CAAC;IAExC,OAAO;QACH,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO;QAClB,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACb,MAAM,QAAQ,GAAG,OAAO,CAAC;YACzB,OAAO,GAAG,OAAO,CAAC;YAElB,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN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C,CAAC;IAED,OAAO,GAAG,CAAC,UAAU,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,CAAC,QAAmB,EAAE,SAAoB,EAAE,GAAY,EAAe,EAAE,CAC1F,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAA2B,CAAC;AAE9F,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,GAGf,CAAC","sourcesContent":["import type { ErrorInfo, ReactNode, ReactPortal } from \"react\";\nimport * as Gdk from \"@gtkx/gi/gdk\";\nimport { createLogger, type Logger } from \"@gtkx/utils\";\nimport { ConcurrentRoot } from \"react-reconciler/constants.js\";\nimport { type Container, reconciler } from \"./host-config.js\";\nimport { rootElement } from \"./root-element.js\";\n\ntype OpaqueRoot = { [opaqueRoot]: true };\n\ntype RootErrorCallbacks = {\n onUncaughtError?: (error: unknown, info: ErrorInfo) => void;\n onCaughtError?: (error: unknown, info: ErrorInfo) => void;\n onRecoverableError?: (error: unknown, info: ErrorInfo) => void;\n};\n\ntype ReconcilerRootOptions = RootErrorCallbacks & { containerInfo: Container };\n\n/** A root that mounts an element tree into an explicit container and reports render errors. */\ntype ReconcilerRoot = {\n update: (element: ReactNode) => void;\n unmount: (teardown: (root: ReconcilerRoot) => Promise<void>) => Promise<void>;\n};\n\n/** The object {@link createRoot} returns: it renders an element tree into a container and can tear it down. */\ntype Root = {\n render: (element: ReactNode) => void;\n unmount: () => void;\n};\n\ntype ErrorHandler = (error: unknown) => void;\ntype ErrorHandlerSlot = { get: () => ErrorHandler | null; set: (handler: ErrorHandler) => ErrorHandler | null };\n\ndeclare const opaqueRoot: unique symbol;\nconst log: Logger = createLogger(\"react\");\nconst activeRoots: Set<OpaqueRoot> = new Set();\nconst errorHandlerSlot = createErrorHandlerSlot();\n\nfunction createErrorHandlerSlot(): ErrorHandlerSlot {\n let current: ErrorHandler | null = null;\n\n return {\n get: () => current,\n set: (handler) => {\n const previous = current;\n current = handler;\n\n return previous;\n },\n };\n}\n\n/**\n * Installs a process-wide handler for errors thrown while rendering or applying an update.\n *\n * @param handler The handler to install.\n * @returns The previously installed handler, or null.\n */\nconst setReconcilerErrorHandler = (handler: ErrorHandler): ErrorHandler | null => errorHandlerSlot.set(handler);\n\nconst rethrowUncaughtRenderError = (error: unknown): never => {\n throw error;\n};\n\nconst logCaughtRenderError = (error: unknown): void => {\n log.error(\"caught render error\", error);\n};\n\nconst openContainer = (containerInfo: Container, callbacks: RootErrorCallbacks): OpaqueRoot => {\n const container = reconciler.createContainer(\n containerInfo,\n ConcurrentRoot,\n null,\n false,\n null,\n \"\",\n (error, info) => {\n errorHandlerSlot.get()?.(error);\n callbacks.onUncaughtError?.(error, info);\n },\n (error, info) => {\n errorHandlerSlot.get()?.(error);\n callbacks.onCaughtError?.(error, info);\n },\n (error, info) => {\n callbacks.onRecoverableError?.(error, info);\n },\n (): void => undefined,\n ) as OpaqueRoot;\n\n activeRoots.add(container);\n\n return container;\n};\n\nconst unmountContainer = (container: OpaqueRoot): void => {\n reconciler.updateContainer(null, container, null, null);\n activeRoots.delete(container);\n};\n\n/**\n * Creates a root that mounts an element tree into a container, routing render errors to the supplied callbacks.\n *\n * @param options The container to render into and the error callbacks to route failures to.\n * @returns A {@link ReconcilerRoot}.\n */\nconst createReconcilerRoot = (options: ReconcilerRootOptions): ReconcilerRoot => {\n const container = openContainer(options.containerInfo, options);\n\n const root: ReconcilerRoot = {\n update: (element) => {\n reconciler.updateContainer(element, container, null, null);\n },\n unmount: async (teardown) => {\n await teardown(root);\n activeRoots.delete(container);\n },\n };\n\n return root;\n};\n\n/**\n * Creates a render root for a GTKX application.\n *\n * @param container The top-level container to render into; defaults to the shared {@link rootElement}.\n * @returns A {@link Root} exposing render and unmount.\n */\nconst createRoot = (container: Container = rootElement): Root => {\n const opaque = openContainer(container, {\n onUncaughtError: rethrowUncaughtRenderError,\n onCaughtError: logCaughtRenderError,\n });\n\n return {\n render: (element) => {\n reconciler.updateContainer(element, opaque, null, null);\n },\n unmount: () => {\n unmountContainer(opaque);\n },\n };\n};\n\n/** Unmounts every active render root and stops the originating signal from propagating further. */\nconst quit = (): typeof Gdk.EVENT_STOP => {\n for (const container of activeRoots) {\n unmountContainer(container);\n }\n\n return Gdk.EVENT_STOP;\n};\n\n/**\n * Renders children into a container other than the surrounding tree.\n *\n * @param children The element tree to render.\n * @param container The GObject, application, or {@link rootElement} to render into.\n * @param key An optional stable key.\n * @returns A React portal.\n */\nconst createPortal = (children: ReactNode, container: Container, key?: string): ReactPortal =>\n reconciler.createPortal(children, container, null, key ?? null) as unknown as ReactPortal;\n\nexport {\n setReconcilerErrorHandler,\n createReconcilerRoot,\n createRoot,\n quit,\n createPortal,\n type ReconcilerRoot,\n type Root,\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SignalHandler } from "@gtkx/runtime";
|
|
2
|
+
import type { SignalTarget } from "./node.js";
|
|
3
|
+
declare const isApplyingWrite: () => boolean;
|
|
4
|
+
declare const applyWrite: <T>(write: () => T) => T;
|
|
5
|
+
declare const connectHandler: (target: SignalTarget, prop: string, signal: string, handler: SignalHandler) => void;
|
|
6
|
+
declare const disconnectHandler: (target: SignalTarget, prop: string) => void;
|
|
7
|
+
declare const disconnectAllHandlers: (target: SignalTarget) => void;
|
|
8
|
+
export { applyWrite, isApplyingWrite, connectHandler, disconnectHandler, disconnectAllHandlers, };
|
|
9
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/reconciler/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,WAAW,CAAC;AAM7D,QAAA,MAAM,eAAe,QAAO,OAA+B,CAAC;AAE5D,QAAA,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,MAAM,CAAC,KAAG,CAQvC,CAAC;AA2BF,QAAA,MAAM,cAAc,GAAI,QAAQ,YAAY,EAAE,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,aAAa,KAAG,IAmBpG,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,QAAQ,YAAY,EAAE,MAAM,MAAM,KAAG,IAS/D,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,QAAQ,YAAY,KAAG,IAMrD,CAAC;AAEF,OAAO,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,GACxB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getSignalBaseName } from "@gtkx/runtime";
|
|
2
|
+
import { camelCase } from "@gtkx/utils";
|
|
3
|
+
import { typeInfoFor } from "./metadata.js";
|
|
4
|
+
const NOTIFY_DETAIL_PREFIX = "notify::";
|
|
5
|
+
const writeState = { depth: 0 };
|
|
6
|
+
const isApplyingWrite = () => writeState.depth > 0;
|
|
7
|
+
const applyWrite = (write) => {
|
|
8
|
+
writeState.depth += 1;
|
|
9
|
+
try {
|
|
10
|
+
return write();
|
|
11
|
+
}
|
|
12
|
+
finally {
|
|
13
|
+
writeState.depth = Math.max(0, writeState.depth - 1);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const getNotifyProperty = (signal) => signal.startsWith(NOTIFY_DETAIL_PREFIX) ? camelCase(signal.slice(NOTIFY_DETAIL_PREFIX.length)) : null;
|
|
17
|
+
const isBlockableSignal = (info, signal) => info.userEventSignals.has(getSignalBaseName(signal));
|
|
18
|
+
const invokeHandler = (target, record, notifyProperty, args) => notifyProperty === null
|
|
19
|
+
? record.handler(...args, target.object)
|
|
20
|
+
: record.handler(Reflect.get(target.object, notifyProperty), target.object);
|
|
21
|
+
const wrapHandler = (target, record, notifyProperty) => (...args) => {
|
|
22
|
+
if (record.blockable && isApplyingWrite()) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return target.dispatch(() => invokeHandler(target, record, notifyProperty, args));
|
|
26
|
+
};
|
|
27
|
+
const connectHandler = (target, prop, signal, handler) => {
|
|
28
|
+
const existing = target.handlers.get(prop);
|
|
29
|
+
if (existing?.signal === signal) {
|
|
30
|
+
existing.handler = handler;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (existing !== undefined) {
|
|
34
|
+
target.object.off(existing.signal, existing.wrapped);
|
|
35
|
+
}
|
|
36
|
+
const isBlockable = isBlockableSignal(typeInfoFor(target.typeName), signal);
|
|
37
|
+
const notifyProperty = getNotifyProperty(signal);
|
|
38
|
+
const record = { signal, handler, wrapped: () => undefined, blockable: isBlockable };
|
|
39
|
+
record.wrapped = wrapHandler(target, record, notifyProperty);
|
|
40
|
+
target.object.on(signal, record.wrapped);
|
|
41
|
+
target.handlers.set(prop, record);
|
|
42
|
+
};
|
|
43
|
+
const disconnectHandler = (target, prop) => {
|
|
44
|
+
const record = target.handlers.get(prop);
|
|
45
|
+
if (record === undefined) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
target.object.off(record.signal, record.wrapped);
|
|
49
|
+
target.handlers.delete(prop);
|
|
50
|
+
};
|
|
51
|
+
const disconnectAllHandlers = (target) => {
|
|
52
|
+
for (const record of target.handlers.values()) {
|
|
53
|
+
target.object.off(record.signal, record.wrapped);
|
|
54
|
+
}
|
|
55
|
+
target.handlers.clear();
|
|
56
|
+
};
|
|
57
|
+
export { applyWrite, isApplyingWrite, connectHandler, disconnectHandler, disconnectAllHandlers, };
|
|
58
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/reconciler/signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,eAAe,CAAC;AACtE,OAAO,E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AAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,MAAoB,EAAE,IAAY,EAAQ,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO;IACX,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,MAAoB,EAAQ,EAAE;IACzD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,OAAO,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,GACxB,CAAC","sourcesContent":["import { getSignalBaseName, type SignalHandler } from \"@gtkx/runtime\";\nimport { camelCase } from \"@gtkx/utils\";\nimport type { HandlerRecord, SignalTarget } from \"./node.js\";\nimport { type TypeInfo, typeInfoFor } from \"./metadata.js\";\n\nconst NOTIFY_DETAIL_PREFIX = \"notify::\";\nconst writeState: { depth: number } = { depth: 0 };\n\nconst isApplyingWrite = (): boolean => writeState.depth > 0;\n\nconst applyWrite = <T>(write: () => T): T => {\n writeState.depth += 1;\n\n try {\n return write();\n } finally {\n writeState.depth = Math.max(0, writeState.depth - 1);\n }\n};\n\nconst getNotifyProperty = (signal: string): string | null =>\n signal.startsWith(NOTIFY_DETAIL_PREFIX) ? camelCase(signal.slice(NOTIFY_DETAIL_PREFIX.length)) : null;\n\nconst isBlockableSignal = (info: TypeInfo, signal: string): boolean =>\n info.userEventSignals.has(getSignalBaseName(signal));\n\nconst invokeHandler = (\n target: SignalTarget,\n record: HandlerRecord,\n notifyProperty: string | null,\n args: unknown[],\n): unknown =>\n notifyProperty === null\n ? record.handler(...args, target.object)\n : record.handler(Reflect.get(target.object, notifyProperty), target.object);\n\nconst wrapHandler = (target: SignalTarget, record: HandlerRecord, notifyProperty: string | null): SignalHandler =>\n (...args: unknown[]): unknown => {\n if (record.blockable && isApplyingWrite()) {\n return undefined;\n }\n\n return target.dispatch(() => invokeHandler(target, record, notifyProperty, args));\n };\n\nconst connectHandler = (target: SignalTarget, prop: string, signal: string, handler: SignalHandler): void => {\n const existing = target.handlers.get(prop);\n\n if (existing?.signal === signal) {\n existing.handler = handler;\n\n return;\n }\n\n if (existing !== undefined) {\n target.object.off(existing.signal, existing.wrapped);\n }\n\n const isBlockable = isBlockableSignal(typeInfoFor(target.typeName), signal);\n const notifyProperty = getNotifyProperty(signal);\n const record: HandlerRecord = { signal, handler, wrapped: (): undefined => undefined, blockable: isBlockable };\n record.wrapped = wrapHandler(target, record, notifyProperty);\n target.object.on(signal, record.wrapped);\n target.handlers.set(prop, record);\n};\n\nconst disconnectHandler = (target: SignalTarget, prop: string): void => {\n const record = target.handlers.get(prop);\n\n if (record === undefined) {\n return;\n }\n\n target.object.off(record.signal, record.wrapped);\n target.handlers.delete(prop);\n};\n\nconst disconnectAllHandlers = (target: SignalTarget): void => {\n for (const record of target.handlers.values()) {\n target.object.off(record.signal, record.wrapped);\n }\n\n target.handlers.clear();\n};\n\nexport {\n applyWrite,\n isApplyingWrite,\n connectHandler,\n disconnectHandler,\n disconnectAllHandlers,\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
+
import type { ContentChild, ElementNode, TextNode } from "./node.js";
|
|
4
|
+
import type { Props } from "./registry.js";
|
|
5
|
+
declare const TEXT_PROP = "text";
|
|
6
|
+
declare const bufferText: (buffer: Gtk.TextBuffer) => string;
|
|
7
|
+
declare const hasSameText: (object: GObject.Object, prop: string, value: unknown) => boolean;
|
|
8
|
+
declare const textRestrictionError: (text: string) => Error;
|
|
9
|
+
declare const canAcceptText: (host: ElementNode) => boolean;
|
|
10
|
+
declare const markTextDirty: (host: ElementNode) => void;
|
|
11
|
+
declare const enclosingHost: (node: TextNode) => ElementNode | null;
|
|
12
|
+
declare const addContent: (host: ElementNode, child: ContentChild, before: ContentChild | null) => void;
|
|
13
|
+
declare const removeContent: (host: ElementNode, child: ContentChild) => void;
|
|
14
|
+
declare const validateContentMix: (node: ElementNode, props: Props) => void;
|
|
15
|
+
declare const isContentPaintableProp: (node: ElementNode, name: string) => boolean;
|
|
16
|
+
declare const flushTextHosts: () => void;
|
|
17
|
+
declare const didUpdateTextSurgically: (host: ElementNode, node: TextNode, oldText: string, newText: string) => boolean;
|
|
18
|
+
export { TEXT_PROP, textRestrictionError, bufferText, hasSameText, canAcceptText, isContentPaintableProp, markTextDirty, enclosingHost, addContent, removeContent, validateContentMix, flushTextHosts, didUpdateTextSurgically, };
|
|
19
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/reconciler/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,YAAY,EAAe,WAAW,EAAc,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9F,OAA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