@gtkx/react 1.0.0-rc.1 → 1.0.0-rc.2
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 +299 -0
- package/dist/adw/element-behaviors.js.map +1 -0
- package/dist/adw/element-config.d.ts +9 -0
- package/dist/adw/element-config.d.ts.map +1 -0
- package/dist/adw/element-config.js +137 -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 +10 -11
- 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 +146 -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 +10 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +29 -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 +6 -7
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -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 +182 -84
- 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 +172 -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 +175 -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 +175 -0
- package/dist/reconciler/placement.js.map +1 -0
- package/dist/reconciler/registry.d.ts +92 -0
- package/dist/reconciler/registry.d.ts.map +1 -0
- package/dist/reconciler/registry.js +64 -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 +109 -0
- package/dist/reconciler/root.js.map +1 -0
- package/dist/reconciler/signals.d.ts +10 -0
- package/dist/reconciler/signals.d.ts.map +1 -0
- package/dist/reconciler/signals.js +70 -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 +276 -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 +379 -0
- package/src/adw/element-config.ts +140 -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 +12 -13
- package/src/config.ts +3 -0
- package/src/element-behaviors.ts +424 -0
- package/src/element-config.ts +148 -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 +37 -48
- package/src/index.ts +7 -8
- package/src/internal.ts +7 -18
- package/src/prop-types.ts +142 -0
- package/src/reconciler/apply-props.ts +233 -85
- package/src/reconciler/behaviors.ts +324 -0
- package/src/reconciler/child-routing.ts +202 -0
- package/src/reconciler/host-config.ts +239 -366
- 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 +255 -0
- package/src/reconciler/registry.ts +161 -0
- package/src/reconciler/root-element.ts +9 -11
- package/src/reconciler/root.ts +175 -0
- package/src/reconciler/signals.ts +113 -0
- package/src/reconciler/text.ts +407 -0
- package/src/utils/accessible-metadata.ts +23 -18
- package/src/utils/accessible-props.ts +279 -0
- package/src/utils/ref-prop.ts +30 -0
- package/src/utils/settings.ts +69 -0
- package/src/utils/variant.ts +368 -0
- package/dist/hooks/use-merge-refs.d.ts +0 -3
- package/dist/hooks/use-merge-refs.d.ts.map +0 -1
- package/dist/hooks/use-merge-refs.js +0 -48
- package/dist/hooks/use-merge-refs.js.map +0 -1
- package/dist/hooks/use-object-attachment.d.ts +0 -10
- package/dist/hooks/use-object-attachment.d.ts.map +0 -1
- package/dist/hooks/use-object-attachment.js +0 -24
- package/dist/hooks/use-object-attachment.js.map +0 -1
- package/dist/libraries/adw/dialog.d.ts.map +0 -1
- package/dist/libraries/adw/dialog.js +0 -25
- package/dist/libraries/adw/dialog.js.map +0 -1
- package/dist/libraries/adw/index.d.ts +0 -2
- package/dist/libraries/adw/index.d.ts.map +0 -1
- package/dist/libraries/adw/index.js +0 -2
- package/dist/libraries/adw/index.js.map +0 -1
- package/dist/reconciler/accessible.d.ts.map +0 -1
- package/dist/reconciler/accessible.js +0 -143
- package/dist/reconciler/accessible.js.map +0 -1
- package/dist/reconciler/commit-flush.d.ts +0 -3
- package/dist/reconciler/commit-flush.d.ts.map +0 -1
- package/dist/reconciler/commit-flush.js +0 -13
- package/dist/reconciler/commit-flush.js.map +0 -1
- package/dist/reconciler/container-attach.d.ts +0 -10
- package/dist/reconciler/container-attach.d.ts.map +0 -1
- package/dist/reconciler/container-attach.js +0 -216
- package/dist/reconciler/container-attach.js.map +0 -1
- package/dist/reconciler/content-rebuild.d.ts +0 -3
- package/dist/reconciler/content-rebuild.d.ts.map +0 -1
- package/dist/reconciler/content-rebuild.js +0 -15
- package/dist/reconciler/content-rebuild.js.map +0 -1
- package/dist/reconciler/dispatch.d.ts +0 -6
- package/dist/reconciler/dispatch.d.ts.map +0 -1
- package/dist/reconciler/dispatch.js +0 -61
- package/dist/reconciler/dispatch.js.map +0 -1
- package/dist/reconciler/element-prop-appliers.d.ts +0 -5
- package/dist/reconciler/element-prop-appliers.d.ts.map +0 -1
- package/dist/reconciler/element-prop-appliers.js +0 -104
- package/dist/reconciler/element-prop-appliers.js.map +0 -1
- package/dist/reconciler/element-props.d.ts +0 -25
- package/dist/reconciler/element-props.d.ts.map +0 -1
- package/dist/reconciler/element-props.js +0 -157
- package/dist/reconciler/element-props.js.map +0 -1
- package/dist/reconciler/label-text-rebuild.d.ts +0 -3
- package/dist/reconciler/label-text-rebuild.d.ts.map +0 -1
- package/dist/reconciler/label-text-rebuild.js +0 -22
- package/dist/reconciler/label-text-rebuild.js.map +0 -1
- package/dist/reconciler/portal.d.ts +0 -11
- package/dist/reconciler/portal.d.ts.map +0 -1
- package/dist/reconciler/portal.js +0 -20
- package/dist/reconciler/portal.js.map +0 -1
- package/dist/reconciler/reconciler-error-handler.d.ts +0 -7
- package/dist/reconciler/reconciler-error-handler.d.ts.map +0 -1
- package/dist/reconciler/reconciler-error-handler.js +0 -24
- package/dist/reconciler/reconciler-error-handler.js.map +0 -1
- package/dist/reconciler/reconciler-root.d.ts +0 -19
- package/dist/reconciler/reconciler-root.d.ts.map +0 -1
- package/dist/reconciler/reconciler-root.js +0 -24
- package/dist/reconciler/reconciler-root.js.map +0 -1
- package/dist/reconciler/reconciler.d.ts +0 -3
- package/dist/reconciler/reconciler.d.ts.map +0 -1
- package/dist/reconciler/reconciler.js +0 -12
- package/dist/reconciler/reconciler.js.map +0 -1
- package/dist/reconciler/render.d.ts +0 -23
- package/dist/reconciler/render.d.ts.map +0 -1
- package/dist/reconciler/render.js +0 -46
- package/dist/reconciler/render.js.map +0 -1
- package/dist/reconciler/signal-store.d.ts +0 -22
- package/dist/reconciler/signal-store.d.ts.map +0 -1
- package/dist/reconciler/signal-store.js +0 -84
- package/dist/reconciler/signal-store.js.map +0 -1
- package/dist/reconciler/state.d.ts +0 -36
- package/dist/reconciler/state.d.ts.map +0 -1
- package/dist/reconciler/state.js +0 -38
- package/dist/reconciler/state.js.map +0 -1
- package/dist/reconciler/text-buffer-controller.d.ts +0 -17
- package/dist/reconciler/text-buffer-controller.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-controller.js +0 -102
- package/dist/reconciler/text-buffer-controller.js.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.d.ts +0 -3
- package/dist/reconciler/text-buffer-rebuild.d.ts.map +0 -1
- package/dist/reconciler/text-buffer-rebuild.js +0 -7
- package/dist/reconciler/text-buffer-rebuild.js.map +0 -1
- package/dist/reconciler/text-node.d.ts +0 -7
- package/dist/reconciler/text-node.d.ts.map +0 -1
- package/dist/reconciler/text-node.js +0 -8
- package/dist/reconciler/text-node.js.map +0 -1
- package/dist/reconciler/types.d.ts +0 -5
- package/dist/reconciler/types.d.ts.map +0 -1
- package/dist/reconciler/types.js +0 -2
- package/dist/reconciler/types.js.map +0 -1
- package/dist/reconciler/visibility.d.ts +0 -6
- package/dist/reconciler/visibility.d.ts.map +0 -1
- package/dist/reconciler/visibility.js +0 -57
- package/dist/reconciler/visibility.js.map +0 -1
- package/dist/reconciler/wrapper-apply.d.ts +0 -6
- package/dist/reconciler/wrapper-apply.d.ts.map +0 -1
- package/dist/reconciler/wrapper-apply.js +0 -287
- package/dist/reconciler/wrapper-apply.js.map +0 -1
- package/dist/reconciler/wrapper-content.d.ts +0 -8
- package/dist/reconciler/wrapper-content.d.ts.map +0 -1
- package/dist/reconciler/wrapper-content.js +0 -19
- package/dist/reconciler/wrapper-content.js.map +0 -1
- package/dist/reconciler/wrapper-node.d.ts +0 -8
- package/dist/reconciler/wrapper-node.d.ts.map +0 -1
- package/dist/reconciler/wrapper-node.js +0 -4
- package/dist/reconciler/wrapper-node.js.map +0 -1
- package/dist/reconciler/wrapper-protocol.d.ts +0 -13
- package/dist/reconciler/wrapper-protocol.d.ts.map +0 -1
- package/dist/reconciler/wrapper-protocol.js +0 -20
- package/dist/reconciler/wrapper-protocol.js.map +0 -1
- package/dist/utils/create-element-component.d.ts +0 -4
- package/dist/utils/create-element-component.d.ts.map +0 -1
- package/dist/utils/create-element-component.js +0 -54
- package/dist/utils/create-element-component.js.map +0 -1
- package/dist/utils/gtype.d.ts +0 -16
- package/dist/utils/gtype.d.ts.map +0 -1
- package/dist/utils/gtype.js +0 -127
- package/dist/utils/gtype.js.map +0 -1
- package/dist/utils/notify-name.d.ts +0 -5
- package/dist/utils/notify-name.d.ts.map +0 -1
- package/dist/utils/notify-name.js +0 -6
- package/dist/utils/notify-name.js.map +0 -1
- package/dist/utils/object-prop.d.ts +0 -8
- package/dist/utils/object-prop.d.ts.map +0 -1
- package/dist/utils/object-prop.js +0 -9
- package/dist/utils/object-prop.js.map +0 -1
- package/dist/utils/settings-accessor.d.ts +0 -8
- package/dist/utils/settings-accessor.d.ts.map +0 -1
- package/dist/utils/settings-accessor.js +0 -69
- package/dist/utils/settings-accessor.js.map +0 -1
- package/dist/utils/wrapper-node-jsx.d.ts +0 -32
- package/dist/utils/wrapper-node-jsx.d.ts.map +0 -1
- package/dist/utils/wrapper-node-jsx.js +0 -2
- package/dist/utils/wrapper-node-jsx.js.map +0 -1
- package/src/hooks/use-merge-refs.ts +0 -53
- package/src/hooks/use-object-attachment.ts +0 -35
- package/src/libraries/adw/dialog.tsx +0 -34
- package/src/libraries/adw/index.ts +0 -1
- package/src/reconciler/accessible.ts +0 -232
- package/src/reconciler/commit-flush.ts +0 -13
- package/src/reconciler/container-attach.ts +0 -219
- package/src/reconciler/content-rebuild.ts +0 -19
- package/src/reconciler/dispatch.ts +0 -58
- package/src/reconciler/element-prop-appliers.ts +0 -110
- package/src/reconciler/element-props.ts +0 -192
- package/src/reconciler/label-text-rebuild.ts +0 -26
- package/src/reconciler/portal.ts +0 -28
- package/src/reconciler/reconciler-error-handler.ts +0 -29
- package/src/reconciler/reconciler-root.ts +0 -57
- package/src/reconciler/reconciler.ts +0 -13
- package/src/reconciler/render.ts +0 -61
- package/src/reconciler/signal-store.ts +0 -103
- package/src/reconciler/state.ts +0 -72
- package/src/reconciler/text-buffer-controller.ts +0 -107
- package/src/reconciler/text-buffer-rebuild.ts +0 -12
- package/src/reconciler/text-node.ts +0 -13
- package/src/reconciler/types.ts +0 -6
- package/src/reconciler/visibility.ts +0 -52
- package/src/reconciler/wrapper-apply.ts +0 -308
- package/src/reconciler/wrapper-content.ts +0 -24
- package/src/reconciler/wrapper-node.ts +0 -8
- package/src/reconciler/wrapper-protocol.ts +0 -32
- package/src/utils/create-element-component.ts +0 -77
- package/src/utils/gtype.ts +0 -166
- package/src/utils/notify-name.ts +0 -10
- package/src/utils/object-prop.ts +0 -13
- package/src/utils/settings-accessor.ts +0 -89
- package/src/utils/wrapper-node-jsx.ts +0 -34
|
@@ -1,27 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { getWrapperClass, TYPE_INVALID, typeFromName, typeIsA } from "@gtkx/runtime";
|
|
2
|
+
import { pickBy } from "@gtkx/utils";
|
|
3
|
+
import { typeInfoFor } from "./metadata.js";
|
|
4
|
+
import { createElementNode, createLazyNode, } from "./node.js";
|
|
5
|
+
import { ELEMENTS } from "./registry.js";
|
|
6
|
+
const CONTENT_TYPE_NAMES = [
|
|
7
|
+
{ kind: "label", name: "GtkLabel" },
|
|
8
|
+
{ kind: "buffer", name: "GtkTextBuffer" },
|
|
9
|
+
{ kind: "tag", name: "GtkTextTag" },
|
|
10
|
+
{ kind: "anchor", name: "GtkTextChildAnchor" },
|
|
11
|
+
];
|
|
12
|
+
const getContentTypes = createContentTypeCache();
|
|
13
|
+
function createContentTypeCache() {
|
|
14
|
+
let cached = null;
|
|
15
|
+
return () => {
|
|
16
|
+
cached ??= CONTENT_TYPE_NAMES.map((entry) => ({ kind: entry.kind, type: typeFromName(entry.name) }));
|
|
17
|
+
return cached;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const resolveContentKind = (type) => {
|
|
21
|
+
for (const entry of getContentTypes()) {
|
|
22
|
+
if (entry.type !== TYPE_INVALID && typeIsA(type, entry.type)) {
|
|
23
|
+
return entry.kind;
|
|
24
|
+
}
|
|
13
25
|
}
|
|
14
|
-
return
|
|
26
|
+
return null;
|
|
15
27
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
const constructInput = (info, props) => pickBy(props, (value, name) => value !== undefined &&
|
|
29
|
+
!info.deferred.has(name) &&
|
|
30
|
+
(info.constructOnly.has(name) || info.construct.has(name)));
|
|
31
|
+
const instantiate = (type, input) => {
|
|
32
|
+
const cls = getWrapperClass(type);
|
|
33
|
+
return new cls(input);
|
|
21
34
|
};
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
return node;
|
|
35
|
+
const createObject = (typeName, type, input) => {
|
|
36
|
+
const create = ELEMENTS[typeName]?.behaviors?.find((behavior) => behavior.create !== undefined)?.create;
|
|
37
|
+
return create === undefined ? instantiate(type, input) : create(input);
|
|
26
38
|
};
|
|
39
|
+
const resolveElementNode = (typeName, props, dispatch) => {
|
|
40
|
+
const info = typeInfoFor(typeName);
|
|
41
|
+
if (info.lazy) {
|
|
42
|
+
return createLazyNode(typeName, props, dispatch);
|
|
43
|
+
}
|
|
44
|
+
const type = typeFromName(typeName);
|
|
45
|
+
const object = createObject(typeName, type, constructInput(info, props));
|
|
46
|
+
return createElementNode(typeName, object, dispatch, resolveContentKind(type));
|
|
47
|
+
};
|
|
48
|
+
export { resolveElementNode };
|
|
27
49
|
//# sourceMappingURL=instance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/reconciler/instance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/reconciler/instance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAEH,iBAAiB,EACjB,cAAc,GAIjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,MAAM,kBAAkB,GAA0C;IAC9D,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;IACnC,EAAE,IAAI,EAAE,QAAQ,EAAE,IA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\"@gtkx/utils\";\nimport type { Props } from \"./registry.js\";\nimport { type TypeInfo, typeInfoFor } from \"./metadata.js\";\nimport {\n type ContentKind,\n createElementNode,\n createLazyNode,\n type Dispatch,\n type ElementNode,\n type LazyNode,\n} from \"./node.js\";\nimport { ELEMENTS } from \"./registry.js\";\n\ntype WidgetConstructor = new (props: Props) => GObject.Object;\ntype ContentType = { kind: ContentKind; type: bigint };\n\nconst CONTENT_TYPE_NAMES: { kind: ContentKind; name: string }[] = [\n { kind: \"label\", name: \"GtkLabel\" },\n { kind: \"buffer\", name: \"GtkTextBuffer\" },\n { kind: \"tag\", name: \"GtkTextTag\" },\n { kind: \"anchor\", name: \"GtkTextChildAnchor\" },\n];\n\nconst getContentTypes = createContentTypeCache();\n\nfunction createContentTypeCache(): () => ContentType[] {\n let cached: ContentType[] | null = null;\n\n return () => {\n cached ??= CONTENT_TYPE_NAMES.map((entry) => ({ kind: entry.kind, type: typeFromName(entry.name) }));\n\n return cached;\n };\n}\n\nconst resolveContentKind = (type: bigint): ContentKind | null => {\n for (const entry of getContentTypes()) {\n if (entry.type !== TYPE_INVALID && typeIsA(type, entry.type)) {\n return entry.kind;\n }\n }\n\n return null;\n};\n\nconst constructInput = (info: TypeInfo, props: Props): Props =>\n pickBy(\n props,\n (value, name) =>\n value !== undefined &&\n !info.deferred.has(name) &&\n (info.constructOnly.has(name) || info.construct.has(name)),\n );\n\nconst instantiate = (type: bigint, input: Props): GObject.Object => {\n const cls = getWrapperClass(type) as WidgetConstructor;\n\n return new cls(input);\n};\n\nconst createObject = (typeName: string, type: bigint, input: Props): GObject.Object => {\n const create = ELEMENTS[typeName]?.behaviors?.find((behavior) => behavior.create !== undefined)?.create;\n\n return create === undefined ? instantiate(type, input) : create(input);\n};\n\nconst resolveElementNode = (typeName: string, props: Props, dispatch: Dispatch): ElementNode | LazyNode => {\n const info = typeInfoFor(typeName);\n\n if (info.lazy) {\n return createLazyNode(typeName, props, dispatch);\n }\n\n const type = typeFromName(typeName);\n const object = createObject(typeName, type, constructInput(info, props));\n\n return createElementNode(typeName, object, dispatch, resolveContentKind(type));\n};\n\nexport { resolveElementNode };\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ElementBehavior } from "./registry.js";
|
|
2
|
+
type TypeInfo = {
|
|
3
|
+
typeName: string;
|
|
4
|
+
signals: Record<string, string>;
|
|
5
|
+
userEventSignals: Set<string>;
|
|
6
|
+
behaviors: ElementBehavior[];
|
|
7
|
+
deferred: Set<string>;
|
|
8
|
+
lazy: boolean;
|
|
9
|
+
hasFlush: boolean;
|
|
10
|
+
hasMount: boolean;
|
|
11
|
+
constructOnly: Set<string>;
|
|
12
|
+
construct: Set<string>;
|
|
13
|
+
defaults: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
declare const typeInfoFor: (name: string) => TypeInfo;
|
|
16
|
+
export { typeInfoFor, type TypeInfo };
|
|
17
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/reconciler/metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,eAAe,EAAY,MAAM,eAAe,CAAC;AAE9E,KAAK,QAAQ,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAmGF,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,QAA2D,CAAC;AAEhG,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { TYPE_INVALID, typeFromName, typeInterfaces, typeName, typeParent } from "@gtkx/runtime";
|
|
2
|
+
import { getOrInsert } from "@gtkx/utils";
|
|
3
|
+
import { CONSTRUCT_ONLY_PROPS, CONSTRUCT_PROPS, DEFAULT_PROPS, SIGNALS, userEventSignals } from "virtual:gtkx-config";
|
|
4
|
+
import { deferredProps, ELEMENTS } from "./registry.js";
|
|
5
|
+
const ancestryCache = new Map();
|
|
6
|
+
const typeInfoCache = new Map();
|
|
7
|
+
const addAncestor = (names, seen, name) => {
|
|
8
|
+
if (name === null || seen.has(name)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
seen.add(name);
|
|
12
|
+
names.push(name);
|
|
13
|
+
};
|
|
14
|
+
const buildAncestry = (name) => {
|
|
15
|
+
const names = [];
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
let type = typeFromName(name);
|
|
18
|
+
while (type !== TYPE_INVALID) {
|
|
19
|
+
addAncestor(names, seen, typeName(type));
|
|
20
|
+
for (const iface of typeInterfaces(type)) {
|
|
21
|
+
addAncestor(names, seen, typeName(iface));
|
|
22
|
+
}
|
|
23
|
+
type = typeParent(type);
|
|
24
|
+
}
|
|
25
|
+
return names;
|
|
26
|
+
};
|
|
27
|
+
const ancestryFor = (name) => getOrInsert(ancestryCache, name, buildAncestry);
|
|
28
|
+
const addAll = (target, source) => {
|
|
29
|
+
const items = source ?? [];
|
|
30
|
+
for (const item of items) {
|
|
31
|
+
target.add(item);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const accumulateAncestor = (info, ancestor) => {
|
|
35
|
+
Object.assign(info.signals, SIGNALS[ancestor] ?? {});
|
|
36
|
+
addAll(info.userEventSignals, userEventSignals[ancestor]);
|
|
37
|
+
addAll(info.constructOnly, CONSTRUCT_ONLY_PROPS[ancestor]);
|
|
38
|
+
addAll(info.construct, CONSTRUCT_PROPS[ancestor]);
|
|
39
|
+
info.behaviors.push(...(ELEMENTS[ancestor]?.behaviors ?? []));
|
|
40
|
+
};
|
|
41
|
+
const applyBehaviorFlags = (info, behavior) => {
|
|
42
|
+
if (behavior.flush !== undefined) {
|
|
43
|
+
info.hasFlush = true;
|
|
44
|
+
}
|
|
45
|
+
if (behavior.mount !== undefined) {
|
|
46
|
+
info.hasMount = true;
|
|
47
|
+
}
|
|
48
|
+
addAll(info.deferred, deferredProps(behavior));
|
|
49
|
+
};
|
|
50
|
+
const resolveBehaviorFlags = (info) => {
|
|
51
|
+
for (const behavior of info.behaviors) {
|
|
52
|
+
applyBehaviorFlags(info, behavior);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const buildTypeInfo = (name) => {
|
|
56
|
+
const chain = ancestryFor(name);
|
|
57
|
+
const info = {
|
|
58
|
+
typeName: name,
|
|
59
|
+
signals: {},
|
|
60
|
+
userEventSignals: new Set(),
|
|
61
|
+
behaviors: [],
|
|
62
|
+
deferred: new Set(),
|
|
63
|
+
lazy: false,
|
|
64
|
+
hasFlush: false,
|
|
65
|
+
hasMount: false,
|
|
66
|
+
constructOnly: new Set(),
|
|
67
|
+
construct: new Set(),
|
|
68
|
+
defaults: {},
|
|
69
|
+
};
|
|
70
|
+
for (const ancestor of chain) {
|
|
71
|
+
accumulateAncestor(info, ancestor);
|
|
72
|
+
}
|
|
73
|
+
resolveBehaviorFlags(info);
|
|
74
|
+
info.lazy = chain.some((ancestor) => ELEMENTS[ancestor]?.lazy === true);
|
|
75
|
+
for (const ancestor of chain.toReversed()) {
|
|
76
|
+
Object.assign(info.defaults, DEFAULT_PROPS[ancestor] ?? {});
|
|
77
|
+
}
|
|
78
|
+
return info;
|
|
79
|
+
};
|
|
80
|
+
const typeInfoFor = (name) => getOrInsert(typeInfoCache, name, buildTypeInfo);
|
|
81
|
+
export { typeInfoFor };
|
|
82
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/reconciler/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAwB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgB9E,MAAM,aAAa,GAA0B,IAAI,GAAG,EAAE,CAAC;AACvD,MAAM,aAAa,GAA0B,IAAI,GAAG,EAAE,CAAC;AAEvD,MAAM,WAAW,GAAG,CAAC,KAAe,EAAE,IAAiB,EAAE,IAAmB,EAAQ,EAAE;IAClF,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO;IACX,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,IAAY,EAAY,EAAE;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAgB,IAAI,GAAG,EAAE,CAAC;IACpC,IAAI,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAE9B,OAAO,IAAI,KAAK,YAAY,EAAE,CAAC;QAC3B,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,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CAAC,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC;IAExE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEhG,OAAO,EAAE,WAAW,EAAiB,CAAC","sourcesContent":["import { TYPE_INVALID, typeFromName, typeInterfaces, typeName, typeParent } from \"@gtkx/runtime\";\nimport { getOrInsert } from \"@gtkx/utils\";\nimport { CONSTRUCT_ONLY_PROPS, CONSTRUCT_PROPS, DEFAULT_PROPS, SIGNALS, userEventSignals } from \"virtual:gtkx-config\";\nimport { deferredProps, type ElementBehavior, ELEMENTS } from \"./registry.js\";\n\ntype TypeInfo = {\n typeName: string;\n signals: Record<string, string>;\n userEventSignals: Set<string>;\n behaviors: ElementBehavior[];\n deferred: Set<string>;\n lazy: boolean;\n hasFlush: boolean;\n hasMount: boolean;\n constructOnly: Set<string>;\n construct: Set<string>;\n defaults: Record<string, unknown>;\n};\n\nconst ancestryCache: Map<string, string[]> = new Map();\nconst typeInfoCache: Map<string, TypeInfo> = new Map();\n\nconst addAncestor = (names: string[], seen: Set<string>, name: string | null): void => {\n if (name === null || seen.has(name)) {\n return;\n }\n\n seen.add(name);\n names.push(name);\n};\n\nconst buildAncestry = (name: string): string[] => {\n const names: string[] = [];\n const seen: Set<string> = new Set();\n let type = typeFromName(name);\n\n while (type !== TYPE_INVALID) {\n addAncestor(names, seen, typeName(type));\n\n for (const iface of typeInterfaces(type)) {\n addAncestor(names, seen, typeName(iface));\n }\n\n type = typeParent(type);\n }\n\n return names;\n};\n\nconst ancestryFor = (name: string): string[] => getOrInsert(ancestryCache, name, buildAncestry);\n\nconst addAll = <T>(target: Set<T>, source: Iterable<T> | undefined): void => {\n const items = source ?? [];\n\n for (const item of items) {\n target.add(item);\n }\n};\n\nconst accumulateAncestor = (info: TypeInfo, ancestor: string): void => {\n Object.assign(info.signals, SIGNALS[ancestor] ?? {});\n addAll(info.userEventSignals, userEventSignals[ancestor]);\n addAll(info.constructOnly, CONSTRUCT_ONLY_PROPS[ancestor]);\n addAll(info.construct, CONSTRUCT_PROPS[ancestor]);\n info.behaviors.push(...(ELEMENTS[ancestor]?.behaviors ?? []));\n};\n\nconst applyBehaviorFlags = (info: TypeInfo, behavior: ElementBehavior): void => {\n if (behavior.flush !== undefined) {\n info.hasFlush = true;\n }\n\n if (behavior.mount !== undefined) {\n info.hasMount = true;\n }\n\n addAll(info.deferred, deferredProps(behavior));\n};\n\nconst resolveBehaviorFlags = (info: TypeInfo): void => {\n for (const behavior of info.behaviors) {\n applyBehaviorFlags(info, behavior);\n }\n};\n\nconst buildTypeInfo = (name: string): TypeInfo => {\n const chain = ancestryFor(name);\n\n const info: TypeInfo = {\n typeName: name,\n signals: {},\n userEventSignals: new Set(),\n behaviors: [],\n deferred: new Set(),\n lazy: false,\n hasFlush: false,\n hasMount: false,\n constructOnly: new Set(),\n construct: new Set(),\n defaults: {},\n };\n\n for (const ancestor of chain) {\n accumulateAncestor(info, ancestor);\n }\n\n resolveBehaviorFlags(info);\n info.lazy = chain.some((ancestor) => ELEMENTS[ancestor]?.lazy === true);\n\n for (const ancestor of chain.toReversed()) {\n Object.assign(info.defaults, DEFAULT_PROPS[ancestor] ?? {});\n }\n\n return info;\n};\n\nconst typeInfoFor = (name: string): TypeInfo => getOrInsert(typeInfoCache, name, buildTypeInfo);\n\nexport { typeInfoFor, type TypeInfo };\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import type * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
+
import type { SignalHandler } from "@gtkx/runtime";
|
|
4
|
+
import type { ElementBehavior, Props } from "./registry.js";
|
|
5
|
+
type ContentKind = "label" | "buffer" | "tag" | "anchor";
|
|
6
|
+
type HandlerRecord = {
|
|
7
|
+
signal: string;
|
|
8
|
+
handler: SignalHandler;
|
|
9
|
+
wrapped: SignalHandler;
|
|
10
|
+
blockable: boolean;
|
|
11
|
+
};
|
|
12
|
+
type Dispatch = (fn: () => unknown) => unknown;
|
|
13
|
+
type SignalTarget = {
|
|
14
|
+
object: GObject.Object;
|
|
15
|
+
handlers: Map<string, HandlerRecord>;
|
|
16
|
+
typeName: string;
|
|
17
|
+
dispatch: Dispatch;
|
|
18
|
+
};
|
|
19
|
+
type PlacedChild = {
|
|
20
|
+
node: PlaceableNode;
|
|
21
|
+
object: GObject.Object;
|
|
22
|
+
adopted: GObject.Object | null;
|
|
23
|
+
slot: string;
|
|
24
|
+
behavior: ElementBehavior | null;
|
|
25
|
+
attached: boolean;
|
|
26
|
+
};
|
|
27
|
+
type ElementNode = SignalTarget & {
|
|
28
|
+
kind: typeof ELEMENT_KIND;
|
|
29
|
+
props: Props;
|
|
30
|
+
placements: Map<string, PlacedChild[]>;
|
|
31
|
+
contexts: Map<ElementBehavior, unknown>;
|
|
32
|
+
parent: ParentNode | null;
|
|
33
|
+
content: ContentChild[];
|
|
34
|
+
contentKind: ContentKind | null;
|
|
35
|
+
bufferView: Gtk.TextView | null;
|
|
36
|
+
};
|
|
37
|
+
type PropNode = {
|
|
38
|
+
kind: typeof PROP_KIND;
|
|
39
|
+
slot: string;
|
|
40
|
+
children: PlaceableNode[];
|
|
41
|
+
parent: ElementNode | null;
|
|
42
|
+
};
|
|
43
|
+
type LazyNode = {
|
|
44
|
+
kind: typeof LAZY_KIND;
|
|
45
|
+
typeName: string;
|
|
46
|
+
props: Props;
|
|
47
|
+
children: PlaceableNode[];
|
|
48
|
+
parent: ElementNode | null;
|
|
49
|
+
adopted: GObject.Object | null;
|
|
50
|
+
handlers: Map<string, HandlerRecord>;
|
|
51
|
+
dispatch: Dispatch;
|
|
52
|
+
};
|
|
53
|
+
type TextNode = {
|
|
54
|
+
kind: typeof TEXT_KIND;
|
|
55
|
+
text: string;
|
|
56
|
+
parent: ParentNode | null;
|
|
57
|
+
};
|
|
58
|
+
type PlaceableNode = ElementNode | LazyNode;
|
|
59
|
+
type ParentNode = ElementNode | PropNode | LazyNode;
|
|
60
|
+
type ContentChild = TextNode | ElementNode;
|
|
61
|
+
type Instance = ElementNode | PropNode | LazyNode;
|
|
62
|
+
type AnyNode = Instance | TextNode;
|
|
63
|
+
declare const ELEMENT_KIND = "element";
|
|
64
|
+
declare const PROP_KIND = "prop";
|
|
65
|
+
declare const TEXT_KIND = "text";
|
|
66
|
+
declare const LAZY_KIND = "lazy";
|
|
67
|
+
declare const DEFAULT_SLOT = "children";
|
|
68
|
+
declare const createPropNode: (slot: string) => PropNode;
|
|
69
|
+
declare const createLazyNode: (typeName: string, props: Props, dispatch: Dispatch) => LazyNode;
|
|
70
|
+
declare const createElementNode: (typeName: string, object: GObject.Object, dispatch: Dispatch, contentKind: ContentKind | null) => ElementNode;
|
|
71
|
+
declare const createTextNode: (text: string) => TextNode;
|
|
72
|
+
declare const nodeObject: (node: PlaceableNode) => GObject.Object | null;
|
|
73
|
+
declare const lazyTarget: (node: LazyNode, adopted: GObject.Object) => SignalTarget;
|
|
74
|
+
declare const getOrCreateContext: (node: ElementNode, behavior: ElementBehavior) => unknown;
|
|
75
|
+
export { ELEMENT_KIND, PROP_KIND, TEXT_KIND, LAZY_KIND, DEFAULT_SLOT, createPropNode, createLazyNode, createElementNode, createTextNode, nodeObject, lazyTarget, getOrCreateContext, type ContentKind, type HandlerRecord, type Dispatch, type SignalTarget, type PlacedChild, type ElementNode, type PropNode, type LazyNode, type TextNode, type PlaceableNode, type ParentNode, type ContentChild, type Instance, type AnyNode, };
|
|
76
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getOrInsert } from "@gtkx/utils";
|
|
2
|
+
const ELEMENT_KIND = "element";
|
|
3
|
+
const PROP_KIND = "prop";
|
|
4
|
+
const TEXT_KIND = "text";
|
|
5
|
+
const LAZY_KIND = "lazy";
|
|
6
|
+
const DEFAULT_SLOT = "children";
|
|
7
|
+
const createPropNode = (slot) => ({
|
|
8
|
+
kind: PROP_KIND,
|
|
9
|
+
slot,
|
|
10
|
+
children: [],
|
|
11
|
+
parent: null,
|
|
12
|
+
});
|
|
13
|
+
const createLazyNode = (typeName, props, dispatch) => ({
|
|
14
|
+
kind: LAZY_KIND,
|
|
15
|
+
typeName,
|
|
16
|
+
props,
|
|
17
|
+
children: [],
|
|
18
|
+
parent: null,
|
|
19
|
+
adopted: null,
|
|
20
|
+
handlers: new Map(),
|
|
21
|
+
dispatch,
|
|
22
|
+
});
|
|
23
|
+
const createElementNode = (typeName, object, dispatch, contentKind) => ({
|
|
24
|
+
kind: ELEMENT_KIND,
|
|
25
|
+
typeName,
|
|
26
|
+
object,
|
|
27
|
+
props: {},
|
|
28
|
+
handlers: new Map(),
|
|
29
|
+
placements: new Map(),
|
|
30
|
+
contexts: new Map(),
|
|
31
|
+
parent: null,
|
|
32
|
+
content: [],
|
|
33
|
+
contentKind,
|
|
34
|
+
bufferView: null,
|
|
35
|
+
dispatch,
|
|
36
|
+
});
|
|
37
|
+
const createTextNode = (text) => ({ kind: TEXT_KIND, text, parent: null });
|
|
38
|
+
const nodeObject = (node) => {
|
|
39
|
+
if (node.kind === LAZY_KIND) {
|
|
40
|
+
const [child] = node.children;
|
|
41
|
+
return child === undefined ? null : nodeObject(child);
|
|
42
|
+
}
|
|
43
|
+
return node.object;
|
|
44
|
+
};
|
|
45
|
+
const lazyTarget = (node, adopted) => ({
|
|
46
|
+
object: adopted,
|
|
47
|
+
handlers: node.handlers,
|
|
48
|
+
typeName: node.typeName,
|
|
49
|
+
dispatch: node.dispatch,
|
|
50
|
+
});
|
|
51
|
+
const getOrCreateContext = (node, behavior) => getOrInsert(node.contexts, behavior, () => behavior.createContext?.(node.object));
|
|
52
|
+
export { ELEMENT_KIND, PROP_KIND, TEXT_KIND, LAZY_KIND, DEFAULT_SLOT, createPropNode, createLazyNode, createElementNode, createTextNode, nodeObject, lazyTarget, getOrCreateContext, };
|
|
53
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/reconciler/node.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgE1C,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,YAAY,GAAG,UAAU,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,CAAC;IAChD,IAAI,EAAE,SAAS;IACf,IAAI;IACJ,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,KAAY,EAAE,QAAkB,EAAY,EAAE,CAAC,CAAC;IACtF,IAAI,EAAE,SAAS;IACf,QAAQ;IACR,KAAK;IACL,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,QAAQ;CACX,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CACtB,QAAgB,EAChB,MAAsB,EACtB,QAAkB,EAClB,WAA+B,EACpB,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,YAAY;IAClB,QAAQ;IACR,MAAM;IACN,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,IAAI,GAAG,EAAE;IACnB,UAAU,EA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kBAAkB,GAerB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { SignalHandler } from \"@gtkx/runtime\";\nimport { getOrInsert } from \"@gtkx/utils\";\nimport type { ElementBehavior, Props } from \"./registry.js\";\n\ntype ContentKind = \"label\" | \"buffer\" | \"tag\" | \"anchor\";\ntype HandlerRecord = { signal: string; handler: SignalHandler; wrapped: SignalHandler; blockable: boolean };\ntype Dispatch = (fn: () => unknown) => unknown;\n\ntype SignalTarget = {\n object: GObject.Object;\n handlers: Map<string, HandlerRecord>;\n typeName: string;\n dispatch: Dispatch;\n};\n\ntype PlacedChild = {\n node: PlaceableNode;\n object: GObject.Object;\n adopted: GObject.Object | null;\n slot: string;\n behavior: ElementBehavior | null;\n attached: boolean;\n};\n\ntype ElementNode = SignalTarget & {\n kind: typeof ELEMENT_KIND;\n props: Props;\n placements: Map<string, PlacedChild[]>;\n contexts: Map<ElementBehavior, unknown>;\n parent: ParentNode | null;\n content: ContentChild[];\n contentKind: ContentKind | null;\n bufferView: Gtk.TextView | null;\n};\n\ntype PropNode = {\n kind: typeof PROP_KIND;\n slot: string;\n children: PlaceableNode[];\n parent: ElementNode | null;\n};\n\ntype LazyNode = {\n kind: typeof LAZY_KIND;\n typeName: string;\n props: Props;\n children: PlaceableNode[];\n parent: ElementNode | null;\n adopted: GObject.Object | null;\n handlers: Map<string, HandlerRecord>;\n dispatch: Dispatch;\n};\n\ntype TextNode = {\n kind: typeof TEXT_KIND;\n text: string;\n parent: ParentNode | null;\n};\n\ntype PlaceableNode = ElementNode | LazyNode;\ntype ParentNode = ElementNode | PropNode | LazyNode;\ntype ContentChild = TextNode | ElementNode;\ntype Instance = ElementNode | PropNode | LazyNode;\ntype AnyNode = Instance | TextNode;\n\nconst ELEMENT_KIND = \"element\";\nconst PROP_KIND = \"prop\";\nconst TEXT_KIND = \"text\";\nconst LAZY_KIND = \"lazy\";\nconst DEFAULT_SLOT = \"children\";\n\nconst createPropNode = (slot: string): PropNode => ({\n kind: PROP_KIND,\n slot,\n children: [],\n parent: null,\n});\n\nconst createLazyNode = (typeName: string, props: Props, dispatch: Dispatch): LazyNode => ({\n kind: LAZY_KIND,\n typeName,\n props,\n children: [],\n parent: null,\n adopted: null,\n handlers: new Map(),\n dispatch,\n});\n\nconst createElementNode = (\n typeName: string,\n object: GObject.Object,\n dispatch: Dispatch,\n contentKind: ContentKind | null,\n): ElementNode => ({\n kind: ELEMENT_KIND,\n typeName,\n object,\n props: {},\n handlers: new Map(),\n placements: new Map(),\n contexts: new Map(),\n parent: null,\n content: [],\n contentKind,\n bufferView: null,\n dispatch,\n});\n\nconst createTextNode = (text: string): TextNode => ({ kind: TEXT_KIND, text, parent: null });\n\nconst nodeObject = (node: PlaceableNode): GObject.Object | null => {\n if (node.kind === LAZY_KIND) {\n const [child] = node.children;\n\n return child === undefined ? null : nodeObject(child);\n }\n\n return node.object;\n};\n\nconst lazyTarget = (node: LazyNode, adopted: GObject.Object): SignalTarget => ({\n object: adopted,\n handlers: node.handlers,\n typeName: node.typeName,\n dispatch: node.dispatch,\n});\n\nconst getOrCreateContext = (node: ElementNode, behavior: ElementBehavior): unknown =>\n getOrInsert(node.contexts, behavior, () => behavior.createContext?.(node.object));\n\nexport {\n ELEMENT_KIND,\n PROP_KIND,\n TEXT_KIND,\n LAZY_KIND,\n DEFAULT_SLOT,\n createPropNode,\n createLazyNode,\n createElementNode,\n createTextNode,\n nodeObject,\n lazyTarget,\n getOrCreateContext,\n type ContentKind,\n type HandlerRecord,\n type Dispatch,\n type SignalTarget,\n type PlacedChild,\n type ElementNode,\n type PropNode,\n type LazyNode,\n type TextNode,\n type PlaceableNode,\n type ParentNode,\n type ContentChild,\n type Instance,\n type AnyNode,\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ElementNode, type PlaceableNode } from "./node.js";
|
|
2
|
+
declare const placeChild: (parent: ElementNode, slot: string, node: PlaceableNode, before: PlaceableNode | null) => void;
|
|
3
|
+
declare const unplaceChild: (parent: ElementNode, slot: string, node: PlaceableNode) => void;
|
|
4
|
+
export { placeChild, unplaceChild };
|
|
5
|
+
//# sourceMappingURL=placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAMA,OAAO,EAGH,KAAK,WAAW,EAKhB,KAAK,aAAa,EAErB,MAAM,WAAW,CAAC;AAwLnB,QAAA,MAAM,UAAU,GACZ,QAAQ,WAAW,EACnB,MAAM,MAAM,EACZ,MAAM,aAAa,EACnB,QAAQ,aAAa,GAAG,IAAI,KAC7B,IAyBF,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,QAAQ,WAAW,EAAE,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,IAoB9E,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as GObject from "@gtkx/gi/gobject";
|
|
2
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
3
|
+
import { getOrInsert, indexBeforeOrEnd, remove } from "@gtkx/utils";
|
|
4
|
+
import { applyAdoptedProps, markFlush } from "./apply-props.js";
|
|
5
|
+
import { typeInfoFor } from "./metadata.js";
|
|
6
|
+
import { DEFAULT_SLOT, ELEMENT_KIND, getOrCreateContext, LAZY_KIND, lazyTarget, nodeObject, } from "./node.js";
|
|
7
|
+
import { markTextDirty } from "./text.js";
|
|
8
|
+
const createEntry = (slot, node) => {
|
|
9
|
+
const object = nodeObject(node);
|
|
10
|
+
if (object === null) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return { node, object, adopted: null, slot, behavior: null, attached: false };
|
|
14
|
+
};
|
|
15
|
+
const siblingAt = (entries, index) => index > 0 ? (entries[index - 1]?.object ?? null) : null;
|
|
16
|
+
const placeInfo = (entry, index, sibling, context) => ({
|
|
17
|
+
slot: entry.slot,
|
|
18
|
+
index,
|
|
19
|
+
sibling,
|
|
20
|
+
adopted: entry.adopted,
|
|
21
|
+
props: entry.node.props,
|
|
22
|
+
context,
|
|
23
|
+
});
|
|
24
|
+
const adoptedFrom = (parent, entry, behavior, claim) => {
|
|
25
|
+
if (behavior.resolve !== undefined) {
|
|
26
|
+
entry.adopted = behavior.resolve(parent.object, entry.object);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
entry.adopted = claim instanceof GObject.Object ? claim : null;
|
|
30
|
+
};
|
|
31
|
+
const applyLazyProps = (entry) => {
|
|
32
|
+
if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);
|
|
36
|
+
entry.node.adopted = entry.adopted;
|
|
37
|
+
};
|
|
38
|
+
const wireBufferView = (node, parent) => {
|
|
39
|
+
if (!(node.kind === ELEMENT_KIND && node.contentKind === "buffer" && parent.object instanceof Gtk.TextView)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
node.bufferView = parent.object;
|
|
43
|
+
markTextDirty(node);
|
|
44
|
+
};
|
|
45
|
+
const setObjectSlot = (parent, entry) => {
|
|
46
|
+
Reflect.set(parent.object, entry.slot, entry.object);
|
|
47
|
+
wireBufferView(entry.node, parent);
|
|
48
|
+
entry.behavior = null;
|
|
49
|
+
entry.attached = true;
|
|
50
|
+
};
|
|
51
|
+
const didAttach = (ctx, behavior) => {
|
|
52
|
+
const attach = behavior.attach;
|
|
53
|
+
if (attach === undefined) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const context = getOrCreateContext(ctx.parent, behavior);
|
|
57
|
+
const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));
|
|
58
|
+
if (claim === undefined) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
ctx.entry.behavior = behavior;
|
|
62
|
+
adoptedFrom(ctx.parent, ctx.entry, behavior, claim);
|
|
63
|
+
ctx.entry.attached = true;
|
|
64
|
+
applyLazyProps(ctx.entry);
|
|
65
|
+
return true;
|
|
66
|
+
};
|
|
67
|
+
const attachEntry = (parent, entry, index, sibling) => {
|
|
68
|
+
const ctx = { parent, entry, index, sibling };
|
|
69
|
+
for (const behavior of typeInfoFor(parent.typeName).behaviors) {
|
|
70
|
+
if (didAttach(ctx, behavior)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (entry.slot !== DEFAULT_SLOT) {
|
|
75
|
+
setObjectSlot(parent, entry);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const detachInfo = (entry, context) => ({
|
|
79
|
+
slot: entry.slot,
|
|
80
|
+
adopted: entry.adopted,
|
|
81
|
+
props: entry.node.props,
|
|
82
|
+
context,
|
|
83
|
+
});
|
|
84
|
+
const detachEntry = (parent, entry) => {
|
|
85
|
+
if (!entry.attached) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
entry.attached = false;
|
|
89
|
+
const behavior = entry.behavior;
|
|
90
|
+
if (behavior === null) {
|
|
91
|
+
if (entry.slot !== DEFAULT_SLOT) {
|
|
92
|
+
Reflect.set(parent.object, entry.slot, null);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));
|
|
97
|
+
};
|
|
98
|
+
const rebuild = (parent, entries) => {
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
detachEntry(parent, entry);
|
|
101
|
+
}
|
|
102
|
+
for (const [index, entry] of entries.entries()) {
|
|
103
|
+
entry.behavior = null;
|
|
104
|
+
attachEntry(parent, entry, index, siblingAt(entries, index));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const getPosition = (entries, before) => indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);
|
|
108
|
+
const placeNew = (parent, entry, entries, index) => {
|
|
109
|
+
attachEntry(parent, entry, index, siblingAt(entries, index));
|
|
110
|
+
if (!entry.attached) {
|
|
111
|
+
remove(entries, entry);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const isInsertedBeforeEnd = index < entries.length - 1;
|
|
115
|
+
const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;
|
|
116
|
+
if (isInsertedBeforeEnd && isCannotReorderInPlace) {
|
|
117
|
+
rebuild(parent, entries);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const moveEntry = (parent, entry, entries, index) => {
|
|
121
|
+
const behavior = entry.behavior;
|
|
122
|
+
const reorder = behavior?.reorder;
|
|
123
|
+
if (behavior === null || reorder === undefined) {
|
|
124
|
+
rebuild(parent, entries);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const context = getOrCreateContext(parent, behavior);
|
|
128
|
+
const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));
|
|
129
|
+
adoptedFrom(parent, entry, behavior, claim);
|
|
130
|
+
applyLazyProps(entry);
|
|
131
|
+
};
|
|
132
|
+
const resolveEntry = (entries, existing, slot, node) => {
|
|
133
|
+
if (existing >= 0) {
|
|
134
|
+
return entries[existing] ?? null;
|
|
135
|
+
}
|
|
136
|
+
return createEntry(slot, node);
|
|
137
|
+
};
|
|
138
|
+
const placeChild = (parent, slot, node, before) => {
|
|
139
|
+
const entries = getOrInsert(parent.placements, slot, () => []);
|
|
140
|
+
const existing = entries.findIndex((entry) => entry.node === node);
|
|
141
|
+
const entry = resolveEntry(entries, existing, slot, node);
|
|
142
|
+
if (entry === null) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const isMove = existing !== -1;
|
|
146
|
+
if (isMove) {
|
|
147
|
+
entries.splice(existing, 1);
|
|
148
|
+
}
|
|
149
|
+
const index = getPosition(entries, before);
|
|
150
|
+
entries.splice(index, 0, entry);
|
|
151
|
+
if (isMove) {
|
|
152
|
+
moveEntry(parent, entry, entries, index);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
placeNew(parent, entry, entries, index);
|
|
156
|
+
}
|
|
157
|
+
markFlush(parent);
|
|
158
|
+
};
|
|
159
|
+
const unplaceChild = (parent, slot, node) => {
|
|
160
|
+
const entries = parent.placements.get(slot);
|
|
161
|
+
if (entries === undefined) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const index = entries.findIndex((entry) => entry.node === node);
|
|
165
|
+
if (index === -1) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const [entry] = entries.splice(index, 1);
|
|
169
|
+
if (entry !== undefined) {
|
|
170
|
+
detachEntry(parent, entry);
|
|
171
|
+
}
|
|
172
|
+
markFlush(parent);
|
|
173
|
+
};
|
|
174
|
+
export { placeChild, unplaceChild };
|
|
175
|
+
//# sourceMappingURL=placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.js","sourceRoot":"","sources":["../../src/reconciler/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,UAAU,GAGb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,IAAmB,EAAsB,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AM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAEhC,IAAI,MAAM,EAAE,CAAC;QACT,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,MAAmB,EAAE,IAAY,EAAE,IAAmB,EAAQ,EAAE;IAClF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO;IACX,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAEhE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrInsert, indexBeforeOrEnd, remove } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo } from \"./registry.js\";\nimport { applyAdoptedProps, markFlush } from \"./apply-props.js\";\nimport { typeInfoFor } from \"./metadata.js\";\nimport {\n DEFAULT_SLOT,\n ELEMENT_KIND,\n type ElementNode,\n getOrCreateContext,\n LAZY_KIND,\n lazyTarget,\n nodeObject,\n type PlaceableNode,\n type PlacedChild,\n} from \"./node.js\";\nimport { markTextDirty } from \"./text.js\";\n\ntype AttachContext = { parent: ElementNode; entry: PlacedChild; index: number; sibling: GObject.Object | null };\n\nconst createEntry = (slot: string, node: PlaceableNode): PlacedChild | null => {\n const object = nodeObject(node);\n\n if (object === null) {\n return null;\n }\n\n return { node, object, adopted: null, slot, behavior: null, attached: false };\n};\n\nconst siblingAt = (entries: PlacedChild[], index: number): GObject.Object | null =>\n index > 0 ? (entries[index - 1]?.object ?? null) : null;\n\nconst placeInfo = (entry: PlacedChild, index: number, sibling: GObject.Object | null, context: unknown): PlaceInfo => ({\n slot: entry.slot,\n index,\n sibling,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst adoptedFrom = (parent: ElementNode, entry: PlacedChild, behavior: ElementBehavior, claim: unknown): void => {\n if (behavior.resolve !== undefined) {\n entry.adopted = behavior.resolve(parent.object, entry.object);\n\n return;\n }\n\n entry.adopted = claim instanceof GObject.Object ? claim : null;\n};\n\nconst applyLazyProps = (entry: PlacedChild): void => {\n if (entry.node.kind !== LAZY_KIND || entry.adopted === null) {\n return;\n }\n\n applyAdoptedProps(lazyTarget(entry.node, entry.adopted), {}, entry.node.props);\n entry.node.adopted = entry.adopted;\n};\n\nconst wireBufferView = (node: PlaceableNode, parent: ElementNode): void => {\n if (!(node.kind === ELEMENT_KIND && node.contentKind === \"buffer\" && parent.object instanceof Gtk.TextView)) {\n return;\n }\n\n node.bufferView = parent.object;\n markTextDirty(node);\n};\n\nconst setObjectSlot = (parent: ElementNode, entry: PlacedChild): void => {\n Reflect.set(parent.object, entry.slot, entry.object);\n wireBufferView(entry.node, parent);\n entry.behavior = null;\n entry.attached = true;\n};\n\nconst didAttach = (ctx: AttachContext, behavior: ElementBehavior): boolean => {\n const attach = behavior.attach;\n\n if (attach === undefined) {\n return false;\n }\n\n const context = getOrCreateContext(ctx.parent, behavior);\n const claim = attach(ctx.parent.object, ctx.entry.object, placeInfo(ctx.entry, ctx.index, ctx.sibling, context));\n\n if (claim === undefined) {\n return false;\n }\n\n ctx.entry.behavior = behavior;\n adoptedFrom(ctx.parent, ctx.entry, behavior, claim);\n ctx.entry.attached = true;\n applyLazyProps(ctx.entry);\n\n return true;\n};\n\nconst attachEntry = (parent: ElementNode, entry: PlacedChild, index: number, sibling: GObject.Object | null): void => {\n const ctx: AttachContext = { parent, entry, index, sibling };\n\n for (const behavior of typeInfoFor(parent.typeName).behaviors) {\n if (didAttach(ctx, behavior)) {\n return;\n }\n }\n\n if (entry.slot !== DEFAULT_SLOT) {\n setObjectSlot(parent, entry);\n }\n};\n\nconst detachInfo = (entry: PlacedChild, context: unknown): DetachInfo => ({\n slot: entry.slot,\n adopted: entry.adopted,\n props: entry.node.props,\n context,\n});\n\nconst detachEntry = (parent: ElementNode, entry: PlacedChild): void => {\n if (!entry.attached) {\n return;\n }\n\n entry.attached = false;\n const behavior = entry.behavior;\n\n if (behavior === null) {\n if (entry.slot !== DEFAULT_SLOT) {\n Reflect.set(parent.object, entry.slot, null);\n }\n\n return;\n }\n\n behavior.detach?.(parent.object, entry.object, detachInfo(entry, getOrCreateContext(parent, behavior)));\n};\n\nconst rebuild = (parent: ElementNode, entries: PlacedChild[]): void => {\n for (const entry of entries) {\n detachEntry(parent, entry);\n }\n\n for (const [index, entry] of entries.entries()) {\n entry.behavior = null;\n attachEntry(parent, entry, index, siblingAt(entries, index));\n }\n};\n\nconst getPosition = (entries: PlacedChild[], before: PlaceableNode | null): number =>\n indexBeforeOrEnd(entries, before, (entry, target) => entry.node === target);\n\nconst placeNew = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n attachEntry(parent, entry, index, siblingAt(entries, index));\n\n if (!entry.attached) {\n remove(entries, entry);\n\n return;\n }\n\n const isInsertedBeforeEnd = index < entries.length - 1;\n const isCannotReorderInPlace = entry.behavior !== null && entry.behavior.reorder === undefined;\n\n if (isInsertedBeforeEnd && isCannotReorderInPlace) {\n rebuild(parent, entries);\n }\n};\n\nconst moveEntry = (parent: ElementNode, entry: PlacedChild, entries: PlacedChild[], index: number): void => {\n const behavior = entry.behavior;\n const reorder = behavior?.reorder;\n\n if (behavior === null || reorder === undefined) {\n rebuild(parent, entries);\n\n return;\n }\n\n const context = getOrCreateContext(parent, behavior);\n const claim = reorder(parent.object, entry.object, placeInfo(entry, index, siblingAt(entries, index), context));\n adoptedFrom(parent, entry, behavior, claim);\n applyLazyProps(entry);\n};\n\nconst resolveEntry = (\n entries: PlacedChild[],\n existing: number,\n slot: string,\n node: PlaceableNode,\n): PlacedChild | null => {\n if (existing >= 0) {\n return entries[existing] ?? null;\n }\n\n return createEntry(slot, node);\n};\n\nconst placeChild = (\n parent: ElementNode,\n slot: string,\n node: PlaceableNode,\n before: PlaceableNode | null,\n): void => {\n const entries = getOrInsert(parent.placements, slot, () => []);\n const existing = entries.findIndex((entry) => entry.node === node);\n const entry = resolveEntry(entries, existing, slot, node);\n\n if (entry === null) {\n return;\n }\n\n const isMove = existing !== -1;\n\n if (isMove) {\n entries.splice(existing, 1);\n }\n\n const index = getPosition(entries, before);\n entries.splice(index, 0, entry);\n\n if (isMove) {\n moveEntry(parent, entry, entries, index);\n } else {\n placeNew(parent, entry, entries, index);\n }\n\n markFlush(parent);\n};\n\nconst unplaceChild = (parent: ElementNode, slot: string, node: PlaceableNode): void => {\n const entries = parent.placements.get(slot);\n\n if (entries === undefined) {\n return;\n }\n\n const index = entries.findIndex((entry) => entry.node === node);\n\n if (index === -1) {\n return;\n }\n\n const [entry] = entries.splice(index, 1);\n\n if (entry !== undefined) {\n detachEntry(parent, entry);\n }\n\n markFlush(parent);\n};\n\nexport { placeChild, unplaceChild };\n"]}
|