@gtkx/react 1.0.0-rc.3 → 1.0.0-rc.4
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/README.md +4 -5
- package/dist/adw/config.d.ts +1 -0
- package/dist/adw/config.d.ts.map +1 -1
- package/dist/adw/config.js +1 -0
- package/dist/adw/config.js.map +1 -1
- package/dist/adw/dialog.d.ts +1 -0
- package/dist/adw/dialog.d.ts.map +1 -1
- package/dist/adw/dialog.js +1 -0
- package/dist/adw/dialog.js.map +1 -1
- package/dist/adw/element-behaviors.js +2 -3
- package/dist/adw/element-behaviors.js.map +1 -1
- package/dist/adw/element-config.d.ts +4 -3
- package/dist/adw/element-config.d.ts.map +1 -1
- package/dist/adw/element-config.js +14 -13
- package/dist/adw/element-config.js.map +1 -1
- package/dist/adw/index.d.ts +1 -0
- package/dist/adw/index.d.ts.map +1 -1
- package/dist/adw/index.js +1 -0
- package/dist/adw/index.js.map +1 -1
- package/dist/adw/prop-types.d.ts +1 -1
- package/dist/adw/prop-types.d.ts.map +1 -1
- package/dist/adw/prop-types.js.map +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/application.d.ts +1 -0
- package/dist/components/application.d.ts.map +1 -1
- package/dist/components/application.js +1 -0
- package/dist/components/application.js.map +1 -1
- package/dist/components/element.d.ts +0 -1
- package/dist/components/element.d.ts.map +1 -1
- package/dist/components/element.js +0 -1
- package/dist/components/element.js.map +1 -1
- package/dist/components/window.d.ts +1 -0
- package/dist/components/window.d.ts.map +1 -1
- package/dist/components/window.js +1 -0
- package/dist/components/window.js.map +1 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/element-behaviors.js +0 -1
- package/dist/element-behaviors.js.map +1 -1
- package/dist/element-config.d.ts +4 -3
- package/dist/element-config.d.ts.map +1 -1
- package/dist/element-config.js +12 -11
- package/dist/element-config.js.map +1 -1
- package/dist/hooks/use-bind-setting.d.ts +8 -7
- package/dist/hooks/use-bind-setting.d.ts.map +1 -1
- package/dist/hooks/use-bind-setting.js +2 -7
- package/dist/hooks/use-bind-setting.js.map +1 -1
- package/dist/hooks/use-parent-window.d.ts +3 -1
- package/dist/hooks/use-parent-window.d.ts.map +1 -1
- package/dist/hooks/use-parent-window.js +3 -1
- package/dist/hooks/use-parent-window.js.map +1 -1
- package/dist/hooks/use-property.d.ts +2 -2
- package/dist/hooks/use-property.d.ts.map +1 -1
- package/dist/hooks/use-property.js +1 -2
- package/dist/hooks/use-property.js.map +1 -1
- package/dist/hooks/use-setting.d.ts +2 -3
- package/dist/hooks/use-setting.d.ts.map +1 -1
- package/dist/hooks/use-setting.js +2 -3
- package/dist/hooks/use-setting.js.map +1 -1
- package/dist/hooks/use-signal.d.ts +13 -7
- package/dist/hooks/use-signal.d.ts.map +1 -1
- package/dist/hooks/use-signal.js +6 -8
- package/dist/hooks/use-signal.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -3
- package/dist/internal.js.map +1 -1
- package/dist/prop-types.d.ts +60 -0
- package/dist/prop-types.d.ts.map +1 -1
- package/dist/prop-types.js.map +1 -1
- package/dist/reconciler/behaviors.d.ts +0 -15
- package/dist/reconciler/behaviors.d.ts.map +1 -1
- package/dist/reconciler/behaviors.js +5 -20
- package/dist/reconciler/behaviors.js.map +1 -1
- package/dist/reconciler/host-config.d.ts +1 -1
- package/dist/reconciler/host-config.d.ts.map +1 -1
- package/dist/reconciler/host-config.js.map +1 -1
- package/dist/reconciler/instance.js +1 -1
- package/dist/reconciler/instance.js.map +1 -1
- package/dist/reconciler/metadata.d.ts +1 -1
- package/dist/reconciler/metadata.d.ts.map +1 -1
- package/dist/reconciler/metadata.js +7 -7
- package/dist/reconciler/metadata.js.map +1 -1
- package/dist/reconciler/node.d.ts +2 -2
- package/dist/reconciler/node.d.ts.map +1 -1
- package/dist/reconciler/node.js +1 -1
- package/dist/reconciler/node.js.map +1 -1
- package/dist/reconciler/placement.js +6 -6
- package/dist/reconciler/placement.js.map +1 -1
- package/dist/reconciler/registry.d.ts +42 -30
- package/dist/reconciler/registry.d.ts.map +1 -1
- package/dist/reconciler/registry.js +10 -19
- package/dist/reconciler/registry.js.map +1 -1
- package/dist/reconciler/root-element.d.ts +0 -1
- package/dist/reconciler/root-element.d.ts.map +1 -1
- package/dist/reconciler/root-element.js +0 -1
- package/dist/reconciler/root-element.js.map +1 -1
- package/dist/reconciler/root.d.ts +6 -20
- package/dist/reconciler/root.d.ts.map +1 -1
- package/dist/reconciler/root.js +4 -19
- package/dist/reconciler/root.js.map +1 -1
- package/dist/reconciler/signals.js +2 -2
- package/dist/reconciler/signals.js.map +1 -1
- package/dist/reconciler/text.js +5 -5
- package/dist/reconciler/text.js.map +1 -1
- package/dist/utils/accessible-metadata.d.ts +0 -7
- package/dist/utils/accessible-metadata.d.ts.map +1 -1
- package/dist/utils/accessible-metadata.js +0 -7
- package/dist/utils/accessible-metadata.js.map +1 -1
- package/dist/utils/accessible-props.d.ts +49 -1
- package/dist/utils/accessible-props.d.ts.map +1 -1
- package/dist/utils/accessible-props.js.map +1 -1
- package/dist/utils/ref-prop.d.ts +0 -6
- package/dist/utils/ref-prop.d.ts.map +1 -1
- package/dist/utils/ref-prop.js +0 -6
- package/dist/utils/ref-prop.js.map +1 -1
- package/dist/utils/settings.d.ts +6 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/settings.js.map +1 -1
- package/env.d.ts +11 -4
- package/package.json +5 -5
- package/src/adw/config.ts +1 -0
- package/src/adw/dialog.tsx +1 -0
- package/src/adw/element-behaviors.ts +2 -3
- package/src/adw/element-config.ts +14 -13
- package/src/adw/index.ts +1 -0
- package/src/adw/prop-types.ts +1 -1
- package/src/bootstrap.ts +1 -1
- package/src/components/application.tsx +1 -0
- package/src/components/element.tsx +0 -1
- package/src/components/window.tsx +1 -0
- package/src/config.ts +5 -9
- package/src/element-behaviors.ts +0 -1
- package/src/element-config.ts +12 -11
- package/src/hooks/use-bind-setting.ts +8 -7
- package/src/hooks/use-parent-window.ts +3 -1
- package/src/hooks/use-property.ts +2 -2
- package/src/hooks/use-setting.ts +2 -3
- package/src/hooks/use-signal.ts +16 -10
- package/src/index.ts +10 -2
- package/src/internal.ts +4 -3
- package/src/prop-types.ts +86 -5
- package/src/reconciler/behaviors.ts +6 -21
- package/src/reconciler/host-config.ts +1 -1
- package/src/reconciler/instance.ts +1 -1
- package/src/reconciler/metadata.ts +8 -8
- package/src/reconciler/node.ts +3 -3
- package/src/reconciler/placement.ts +6 -6
- package/src/reconciler/registry.ts +52 -37
- package/src/reconciler/root-element.ts +0 -1
- package/src/reconciler/root.ts +6 -20
- package/src/reconciler/signals.ts +2 -2
- package/src/reconciler/text.ts +6 -6
- package/src/utils/accessible-metadata.ts +0 -7
- package/src/utils/accessible-props.ts +49 -1
- package/src/utils/ref-prop.ts +0 -6
- package/src/utils/settings.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import "./bootstrap.js";
|
|
2
|
+
/** @public */
|
|
2
3
|
export { useApplication } from "./hooks/use-application.js";
|
|
4
|
+
/** @public */
|
|
3
5
|
export { useBindSetting } from "./hooks/use-bind-setting.js";
|
|
6
|
+
/** @public */
|
|
4
7
|
export { useParentWindow } from "./hooks/use-parent-window.js";
|
|
8
|
+
/** @public */
|
|
5
9
|
export { useProperty } from "./hooks/use-property.js";
|
|
10
|
+
/** @public */
|
|
6
11
|
export { useSetting } from "./hooks/use-setting.js";
|
|
12
|
+
/** @public */
|
|
7
13
|
export { useSignal } from "./hooks/use-signal.js";
|
|
14
|
+
/** @public */
|
|
8
15
|
export { rootElement } from "./reconciler/root-element.js";
|
|
16
|
+
/** @public */
|
|
9
17
|
export { createPortal, createRoot, quit } from "./reconciler/root.js";
|
|
10
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,cAAc;AACd,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,cAAc;AACd,OAAO,EAAoB,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC7E,cAAc;AACd,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAa,MAAM,sBAAsB,CAAC","sourcesContent":["import \"./bootstrap.js\";\n\n/** @public */\nexport { useApplication } from \"./hooks/use-application.js\";\n/** @public */\nexport { useBindSetting } from \"./hooks/use-bind-setting.js\";\n/** @public */\nexport { useParentWindow } from \"./hooks/use-parent-window.js\";\n/** @public */\nexport { useProperty } from \"./hooks/use-property.js\";\n/** @public */\nexport { useSetting } from \"./hooks/use-setting.js\";\n/** @public */\nexport { useSignal } from \"./hooks/use-signal.js\";\n/** @public */\nexport { type RootElement, rootElement } from \"./reconciler/root-element.js\";\n/** @public */\nexport { createPortal, createRoot, quit, type Root } from \"./reconciler/root.js\";\n/** @public */\nexport type { AccessibleProps } from \"./utils/accessible-props.js\";\n/** @public */\nexport type { RefProp } from \"./utils/ref-prop.js\";\n"]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import "./bootstrap.js";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export { createApplicationComponent } from "./components/application.js";
|
|
3
4
|
export { createElementComponent } from "./components/element.js";
|
|
5
|
+
/** @internal */
|
|
4
6
|
export { createWindowComponent } from "./components/window.js";
|
|
5
|
-
export { ApplicationContext } from "./hooks/use-application.js";
|
|
6
7
|
export { useMergedRef } from "./hooks/use-merged-refs.js";
|
|
7
|
-
export { useObjectValue } from "./hooks/use-object-value.js";
|
|
8
8
|
export type * from "./prop-types.js";
|
|
9
|
+
export type { ModuleExport } from "./reconciler/registry.js";
|
|
9
10
|
export { isRootElement } from "./reconciler/root-element.js";
|
|
10
11
|
export { createReconcilerRoot, type ReconcilerRoot, setReconcilerErrorHandler } from "./reconciler/root.js";
|
|
11
12
|
export { applyWrite } from "./reconciler/signals.js";
|
|
12
13
|
export { getAccessibleMetadata } from "./utils/accessible-metadata.js";
|
|
13
|
-
export {
|
|
14
|
+
export type { SettingsSchema, SettingsSchemaKeys, SettingValue } from "./utils/settings.js";
|
|
14
15
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,gBAAgB;AAChB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,mBAAmB,iBAAiB,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "./bootstrap.js";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export { createApplicationComponent } from "./components/application.js";
|
|
3
4
|
export { createElementComponent } from "./components/element.js";
|
|
5
|
+
/** @internal */
|
|
4
6
|
export { createWindowComponent } from "./components/window.js";
|
|
5
|
-
export { ApplicationContext } from "./hooks/use-application.js";
|
|
6
7
|
export { useMergedRef } from "./hooks/use-merged-refs.js";
|
|
7
|
-
export { useObjectValue } from "./hooks/use-object-value.js";
|
|
8
8
|
export { isRootElement } from "./reconciler/root-element.js";
|
|
9
9
|
export { createReconcilerRoot, setReconcilerErrorHandler } from "./reconciler/root.js";
|
|
10
10
|
export { applyWrite } from "./reconciler/signals.js";
|
|
11
11
|
export { getAccessibleMetadata } from "./utils/accessible-metadata.js";
|
|
12
|
-
export { resolveRefProp } from "./utils/ref-prop.js";
|
|
13
12
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,gBAAgB;AAChB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAuB,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["import \"./bootstrap.js\";\n\n/** @internal */\nexport { createApplicationComponent } from \"./components/application.js\";\nexport { createElementComponent } from \"./components/element.js\";\n/** @internal */\nexport { createWindowComponent } from \"./components/window.js\";\nexport { useMergedRef } from \"./hooks/use-merged-refs.js\";\nexport type * from \"./prop-types.js\";\nexport type { ModuleExport } from \"./reconciler/registry.js\";\nexport { isRootElement } from \"./reconciler/root-element.js\";\nexport { createReconcilerRoot, type ReconcilerRoot, setReconcilerErrorHandler } from \"./reconciler/root.js\";\nexport { applyWrite } from \"./reconciler/signals.js\";\nexport { getAccessibleMetadata } from \"./utils/accessible-metadata.js\";\nexport type { SettingsSchema, SettingsSchemaKeys, SettingValue } from \"./utils/settings.js\";\n"]}
|
package/dist/prop-types.d.ts
CHANGED
|
@@ -4,106 +4,166 @@ import type * as Gtk from "@gtkx/gi/gtk";
|
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
5
|
/** One entry of a `GMenu`'s `items` prop; `submenu` and `section` nest further menus. */
|
|
6
6
|
type MenuItem = {
|
|
7
|
+
/** Text shown for the entry, or the heading of the submenu or section it introduces. */
|
|
7
8
|
label?: string | null;
|
|
9
|
+
/** Detailed action name the entry activates, ignored when `submenu` or `section` is given. */
|
|
8
10
|
action?: string | null;
|
|
11
|
+
/** Entries of a separate menu the labelled entry opens. */
|
|
9
12
|
submenu?: MenuItem[];
|
|
13
|
+
/** Entries appended below the label as an inline section, used only when `submenu` is absent. */
|
|
10
14
|
section?: MenuItem[];
|
|
11
15
|
};
|
|
12
16
|
/** One Visual Format Language block applied to a `Gtk.ConstraintLayout`. */
|
|
13
17
|
type VflConstraints = {
|
|
18
|
+
/** Format lines, each describing every constraint on one row or column. */
|
|
14
19
|
lines: string[];
|
|
20
|
+
/** Default horizontal spacing the `-` operator stands for; defaults to 0. */
|
|
15
21
|
hspacing?: number;
|
|
22
|
+
/** Default vertical spacing the `-` operator stands for; defaults to 0. */
|
|
16
23
|
vspacing?: number;
|
|
24
|
+
/** Targets the view names in `lines` refer to; defaults to none. */
|
|
17
25
|
views?: Map<string, Gtk.ConstraintTarget>;
|
|
18
26
|
};
|
|
19
27
|
/** One mark on a `Gtk.Scale`. */
|
|
20
28
|
type ScaleMark = {
|
|
29
|
+
/** Point on the scale the mark is drawn at; defaults to 0. */
|
|
21
30
|
value?: number;
|
|
31
|
+
/** Side of the scale the mark and its label sit on. */
|
|
22
32
|
position: Gtk.PositionType;
|
|
33
|
+
/** Pango markup drawn beside the mark, or `null` for an unlabelled one. */
|
|
23
34
|
markup?: string | null;
|
|
24
35
|
};
|
|
25
36
|
/** One labelled offset on a `Gtk.LevelBar`. */
|
|
26
37
|
type LevelBarOffset = {
|
|
38
|
+
/** Style class applied to the bar's blocks while the value falls in this offset's interval. */
|
|
27
39
|
name: string;
|
|
40
|
+
/** Upper bound of that interval; defaults to 0. */
|
|
28
41
|
value?: number;
|
|
29
42
|
};
|
|
30
43
|
/** One credit section on a `Gtk.AboutDialog`. */
|
|
31
44
|
type CreditSection = {
|
|
45
|
+
/** Heading the names are listed under. */
|
|
32
46
|
sectionName: string;
|
|
47
|
+
/** Names listed in the section. */
|
|
33
48
|
people: string[];
|
|
34
49
|
};
|
|
35
50
|
/** One accelerator binding on a `Gtk.Application`. */
|
|
36
51
|
type ActionAccel = {
|
|
52
|
+
/** Action the accelerators activate, such as `app.quit` or `win.open('file')`. */
|
|
37
53
|
detailedActionName: string;
|
|
54
|
+
/** Accelerators in `Gtk.acceleratorParse` syntax, cleared when the entry goes away. */
|
|
38
55
|
accels: string[];
|
|
39
56
|
};
|
|
40
57
|
/** The drag icon of a `Gtk.DragSource`, with its hotspot. */
|
|
41
58
|
type DragSourceIcon = {
|
|
59
|
+
/** Image shown under the pointer during the drag; defaults to none. */
|
|
42
60
|
paintable?: Gdk.Paintable | null;
|
|
61
|
+
/** Horizontal offset of the pointer within the image; defaults to 0. */
|
|
43
62
|
hotX?: number;
|
|
63
|
+
/** Vertical offset of the pointer within the image; defaults to 0. */
|
|
44
64
|
hotY?: number;
|
|
45
65
|
};
|
|
46
66
|
/** Props of an element that accepts children. */
|
|
47
67
|
type ChildrenProps = {
|
|
68
|
+
/** Elements attached to the element's default child slot, or its text for elements that hold text. */
|
|
48
69
|
children?: ReactNode;
|
|
49
70
|
};
|
|
71
|
+
/** Objects a widget takes through a method call rather than a property. */
|
|
50
72
|
type GtkWidgetProps = {
|
|
73
|
+
/** `Gtk.EventController` elements added to the widget. */
|
|
51
74
|
controllers?: ReactNode | null | undefined;
|
|
75
|
+
/** `Gio.ActionGroup` elements inserted into the widget, each under its own `prefix`. */
|
|
52
76
|
actionGroups?: ReactNode | null | undefined;
|
|
53
77
|
} & ChildrenProps;
|
|
78
|
+
/** Props of an action group placed in a widget's `actionGroups` slot. */
|
|
54
79
|
type GActionGroupProps = {
|
|
80
|
+
/** Prefix the group's actions are addressed by, such as `win`; defaults to the empty string. */
|
|
55
81
|
prefix?: string | null | undefined;
|
|
56
82
|
};
|
|
83
|
+
/** Props of an element implementing `Gio.ActionMap`. */
|
|
57
84
|
type GActionMapProps = {
|
|
85
|
+
/** `Gio.Action` elements added to the map, removed again by their `name`. */
|
|
58
86
|
actions?: ReactNode | null | undefined;
|
|
59
87
|
};
|
|
88
|
+
/** Props of a `Gio.Menu` element. */
|
|
60
89
|
type GMenuProps = {
|
|
90
|
+
/** Entries the menu is rebuilt from whenever they change. */
|
|
61
91
|
items?: MenuItem[] | null | undefined;
|
|
62
92
|
};
|
|
93
|
+
/** Props of a `Gtk.ShortcutController` element. */
|
|
63
94
|
type GtkShortcutControllerProps = {
|
|
95
|
+
/** `Gtk.Shortcut` elements the controller watches for. */
|
|
64
96
|
shortcuts?: ReactNode | null | undefined;
|
|
65
97
|
};
|
|
98
|
+
/** Props of a `Gtk.Overlay` element, whose `children` is the widget the overlays sit above. */
|
|
66
99
|
type GtkOverlayProps = {
|
|
100
|
+
/** Widgets stacked over the main child. */
|
|
67
101
|
overlays?: ReactNode | null | undefined;
|
|
68
102
|
} & ChildrenProps;
|
|
103
|
+
/** Props of a `Gtk.ConstraintLayout` element. */
|
|
69
104
|
type GtkConstraintLayoutProps = {
|
|
105
|
+
/** `Gtk.Constraint` elements added to the layout. */
|
|
70
106
|
constraints?: ReactNode | null | undefined;
|
|
107
|
+
/** `Gtk.ConstraintGuide` elements added to the layout as invisible spacers. */
|
|
71
108
|
guides?: ReactNode | null | undefined;
|
|
109
|
+
/** Visual Format Language blocks whose constraints are added alongside `constraints`. */
|
|
72
110
|
vfl?: VflConstraints[] | null | undefined;
|
|
73
111
|
};
|
|
74
112
|
/** Props of `GtkTextChildAnchor`, which embeds either a child widget or a paintable in a text buffer. */
|
|
75
113
|
type GtkTextChildAnchorProps = {
|
|
114
|
+
/** Image inserted into the buffer instead of an anchored widget; giving both is an error. */
|
|
76
115
|
paintable?: Gdk.Paintable | null | undefined;
|
|
77
116
|
} & ChildrenProps;
|
|
117
|
+
/** Props of a `Gtk.HeaderBar` or `Gtk.ActionBar` element. */
|
|
78
118
|
type GtkHeaderBarProps = {
|
|
119
|
+
/** Widgets packed at the start of the bar. */
|
|
79
120
|
start?: ReactNode | null | undefined;
|
|
121
|
+
/** Widgets packed at the end of the bar. */
|
|
80
122
|
end?: ReactNode | null | undefined;
|
|
81
123
|
};
|
|
124
|
+
/** Props of a `Gtk.Scale` element. */
|
|
82
125
|
type GtkScaleProps = {
|
|
126
|
+
/** Marks drawn along the scale, cleared and re-added whenever the list changes. */
|
|
83
127
|
marks?: ScaleMark[] | null | undefined;
|
|
84
128
|
};
|
|
129
|
+
/** Props of a `Gtk.Calendar` element. */
|
|
85
130
|
type GtkCalendarProps = {
|
|
131
|
+
/** Days of the shown month drawn as marked, cleared and re-marked whenever the list changes. */
|
|
86
132
|
markedDays?: number[] | null | undefined;
|
|
87
133
|
};
|
|
134
|
+
/** Props of a `Gtk.LevelBar` element. */
|
|
88
135
|
type GtkLevelBarProps = {
|
|
136
|
+
/** Offsets that split the bar's range into differently styled intervals. */
|
|
89
137
|
offsets?: LevelBarOffset[] | null | undefined;
|
|
90
138
|
};
|
|
139
|
+
/** Props of a `Gtk.SizeGroup` element. */
|
|
91
140
|
type GtkSizeGroupProps = {
|
|
141
|
+
/** Widgets the group keeps at a common size. */
|
|
92
142
|
widgets?: Gtk.Widget[] | null | undefined;
|
|
93
143
|
};
|
|
144
|
+
/** Props of a `Gtk.AboutDialog` element. */
|
|
94
145
|
type GtkAboutDialogProps = {
|
|
146
|
+
/** Extra sections appended to the dialog's credits, which GTK offers no way to remove. */
|
|
95
147
|
creditSections?: CreditSection[] | null | undefined;
|
|
96
148
|
};
|
|
149
|
+
/** Props of a `Gtk.Application` element, whose `children` are the windows it owns. */
|
|
97
150
|
type GtkApplicationProps = {
|
|
151
|
+
/** Accelerators bound to the application's actions. */
|
|
98
152
|
actionAccels?: ActionAccel[] | null | undefined;
|
|
99
153
|
} & ChildrenProps;
|
|
154
|
+
/** Props of a `Gtk.DropTarget` element. */
|
|
100
155
|
type GtkDropTargetProps = {
|
|
156
|
+
/** GTypes the target accepts a drop of. */
|
|
101
157
|
types?: GObject.Type[] | null | undefined;
|
|
102
158
|
};
|
|
159
|
+
/** Props of a `Gtk.DrawingArea` element. */
|
|
103
160
|
type GtkDrawingAreaProps = {
|
|
161
|
+
/** Callback that draws the area's contents; setting it queues a redraw. */
|
|
104
162
|
drawFunc?: Gtk.DrawingAreaDrawFunc | null | undefined;
|
|
105
163
|
};
|
|
164
|
+
/** Props of a `Gtk.DragSource` element. */
|
|
106
165
|
type GtkDragSourceProps = {
|
|
166
|
+
/** Icon shown under the pointer while a drag started from this source is in flight. */
|
|
107
167
|
icon?: DragSourceIcon | null | undefined;
|
|
108
168
|
};
|
|
109
169
|
export { type MenuItem, type VflConstraints, type ScaleMark, type LevelBarOffset, type CreditSection, type ActionAccel, type DragSourceIcon, type ChildrenProps, type GtkWidgetProps, type GActionGroupProps, type GActionMapProps, type GMenuProps, type GtkShortcutControllerProps, type GtkOverlayProps, type GtkTextChildAnchorProps, type GtkConstraintLayoutProps, type GtkHeaderBarProps, type GtkScaleProps, type GtkCalendarProps, type GtkLevelBarProps, type GtkSizeGroupProps, type GtkAboutDialogProps, type GtkApplicationProps, type GtkDropTargetProps, type GtkDrawingAreaProps, type GtkDragSourceProps, };
|
package/dist/prop-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../src/prop-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,yFAAyF;AACzF,KAAK,QAAQ,GAAG;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,4EAA4E;AAC5E,KAAK,cAAc,GAAG;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF,iCAAiC;AACjC,KAAK,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../src/prop-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,SA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"}
|
package/dist/prop-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-types.js","sourceRoot":"","sources":["../src/prop-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prop-types.js","sourceRoot":"","sources":["../src/prop-types.ts"],"names":[],"mappings":"AAmMA,OAAO,EA2BN,CAAC","sourcesContent":["import type * as Gdk from \"@gtkx/gi/gdk\";\nimport type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ReactNode } from \"react\";\n\n/** One entry of a `GMenu`'s `items` prop; `submenu` and `section` nest further menus. */\ntype MenuItem = {\n /** Text shown for the entry, or the heading of the submenu or section it introduces. */\n label?: string | null;\n /** Detailed action name the entry activates, ignored when `submenu` or `section` is given. */\n action?: string | null;\n /** Entries of a separate menu the labelled entry opens. */\n submenu?: MenuItem[];\n /** Entries appended below the label as an inline section, used only when `submenu` is absent. */\n section?: MenuItem[];\n};\n\n/** One Visual Format Language block applied to a `Gtk.ConstraintLayout`. */\ntype VflConstraints = {\n /** Format lines, each describing every constraint on one row or column. */\n lines: string[];\n /** Default horizontal spacing the `-` operator stands for; defaults to 0. */\n hspacing?: number;\n /** Default vertical spacing the `-` operator stands for; defaults to 0. */\n vspacing?: number;\n /** Targets the view names in `lines` refer to; defaults to none. */\n views?: Map<string, Gtk.ConstraintTarget>;\n};\n\n/** One mark on a `Gtk.Scale`. */\ntype ScaleMark = {\n /** Point on the scale the mark is drawn at; defaults to 0. */\n value?: number;\n /** Side of the scale the mark and its label sit on. */\n position: Gtk.PositionType;\n /** Pango markup drawn beside the mark, or `null` for an unlabelled one. */\n markup?: string | null;\n};\n\n/** One labelled offset on a `Gtk.LevelBar`. */\ntype LevelBarOffset = {\n /** Style class applied to the bar's blocks while the value falls in this offset's interval. */\n name: string;\n /** Upper bound of that interval; defaults to 0. */\n value?: number;\n};\n\n/** One credit section on a `Gtk.AboutDialog`. */\ntype CreditSection = {\n /** Heading the names are listed under. */\n sectionName: string;\n /** Names listed in the section. */\n people: string[];\n};\n\n/** One accelerator binding on a `Gtk.Application`. */\ntype ActionAccel = {\n /** Action the accelerators activate, such as `app.quit` or `win.open('file')`. */\n detailedActionName: string;\n /** Accelerators in `Gtk.acceleratorParse` syntax, cleared when the entry goes away. */\n accels: string[];\n};\n\n/** The drag icon of a `Gtk.DragSource`, with its hotspot. */\ntype DragSourceIcon = {\n /** Image shown under the pointer during the drag; defaults to none. */\n paintable?: Gdk.Paintable | null;\n /** Horizontal offset of the pointer within the image; defaults to 0. */\n hotX?: number;\n /** Vertical offset of the pointer within the image; defaults to 0. */\n hotY?: number;\n};\n\n/** Props of an element that accepts children. */\ntype ChildrenProps = {\n /** Elements attached to the element's default child slot, or its text for elements that hold text. */\n children?: ReactNode;\n};\n\n/** Objects a widget takes through a method call rather than a property. */\ntype GtkWidgetProps = {\n /** `Gtk.EventController` elements added to the widget. */\n controllers?: ReactNode | null | undefined;\n /** `Gio.ActionGroup` elements inserted into the widget, each under its own `prefix`. */\n actionGroups?: ReactNode | null | undefined;\n} & ChildrenProps;\n\n/** Props of an action group placed in a widget's `actionGroups` slot. */\ntype GActionGroupProps = {\n /** Prefix the group's actions are addressed by, such as `win`; defaults to the empty string. */\n prefix?: string | null | undefined;\n};\n\n/** Props of an element implementing `Gio.ActionMap`. */\ntype GActionMapProps = {\n /** `Gio.Action` elements added to the map, removed again by their `name`. */\n actions?: ReactNode | null | undefined;\n};\n\n/** Props of a `Gio.Menu` element. */\ntype GMenuProps = {\n /** Entries the menu is rebuilt from whenever they change. */\n items?: MenuItem[] | null | undefined;\n};\n\n/** Props of a `Gtk.ShortcutController` element. */\ntype GtkShortcutControllerProps = {\n /** `Gtk.Shortcut` elements the controller watches for. */\n shortcuts?: ReactNode | null | undefined;\n};\n\n/** Props of a `Gtk.Overlay` element, whose `children` is the widget the overlays sit above. */\ntype GtkOverlayProps = {\n /** Widgets stacked over the main child. */\n overlays?: ReactNode | null | undefined;\n} & ChildrenProps;\n\n/** Props of a `Gtk.ConstraintLayout` element. */\ntype GtkConstraintLayoutProps = {\n /** `Gtk.Constraint` elements added to the layout. */\n constraints?: ReactNode | null | undefined;\n /** `Gtk.ConstraintGuide` elements added to the layout as invisible spacers. */\n guides?: ReactNode | null | undefined;\n /** Visual Format Language blocks whose constraints are added alongside `constraints`. */\n vfl?: VflConstraints[] | null | undefined;\n};\n\n/** Props of `GtkTextChildAnchor`, which embeds either a child widget or a paintable in a text buffer. */\ntype GtkTextChildAnchorProps = {\n /** Image inserted into the buffer instead of an anchored widget; giving both is an error. */\n paintable?: Gdk.Paintable | null | undefined;\n} & ChildrenProps;\n\n/** Props of a `Gtk.HeaderBar` or `Gtk.ActionBar` element. */\ntype GtkHeaderBarProps = {\n /** Widgets packed at the start of the bar. */\n start?: ReactNode | null | undefined;\n /** Widgets packed at the end of the bar. */\n end?: ReactNode | null | undefined;\n};\n\n/** Props of a `Gtk.Scale` element. */\ntype GtkScaleProps = {\n /** Marks drawn along the scale, cleared and re-added whenever the list changes. */\n marks?: ScaleMark[] | null | undefined;\n};\n\n/** Props of a `Gtk.Calendar` element. */\ntype GtkCalendarProps = {\n /** Days of the shown month drawn as marked, cleared and re-marked whenever the list changes. */\n markedDays?: number[] | null | undefined;\n};\n\n/** Props of a `Gtk.LevelBar` element. */\ntype GtkLevelBarProps = {\n /** Offsets that split the bar's range into differently styled intervals. */\n offsets?: LevelBarOffset[] | null | undefined;\n};\n\n/** Props of a `Gtk.SizeGroup` element. */\ntype GtkSizeGroupProps = {\n /** Widgets the group keeps at a common size. */\n widgets?: Gtk.Widget[] | null | undefined;\n};\n\n/** Props of a `Gtk.AboutDialog` element. */\ntype GtkAboutDialogProps = {\n /** Extra sections appended to the dialog's credits, which GTK offers no way to remove. */\n creditSections?: CreditSection[] | null | undefined;\n};\n\n/** Props of a `Gtk.Application` element, whose `children` are the windows it owns. */\ntype GtkApplicationProps = {\n /** Accelerators bound to the application's actions. */\n actionAccels?: ActionAccel[] | null | undefined;\n} & ChildrenProps;\n\n/** Props of a `Gtk.DropTarget` element. */\ntype GtkDropTargetProps = {\n /** GTypes the target accepts a drop of. */\n types?: GObject.Type[] | null | undefined;\n};\n\n/** Props of a `Gtk.DrawingArea` element. */\ntype GtkDrawingAreaProps = {\n /** Callback that draws the area's contents; setting it queues a redraw. */\n drawFunc?: Gtk.DrawingAreaDrawFunc | null | undefined;\n};\n\n/** Props of a `Gtk.DragSource` element. */\ntype GtkDragSourceProps = {\n /** Icon shown under the pointer while a drag started from this source is in flight. */\n icon?: DragSourceIcon | null | undefined;\n};\n\nexport {\n type MenuItem,\n type VflConstraints,\n type ScaleMark,\n type LevelBarOffset,\n type CreditSection,\n type ActionAccel,\n type DragSourceIcon,\n type ChildrenProps,\n type GtkWidgetProps,\n type GActionGroupProps,\n type GActionMapProps,\n type GMenuProps,\n type GtkShortcutControllerProps,\n type GtkOverlayProps,\n type GtkTextChildAnchorProps,\n type GtkConstraintLayoutProps,\n type GtkHeaderBarProps,\n type GtkScaleProps,\n type GtkCalendarProps,\n type GtkLevelBarProps,\n type GtkSizeGroupProps,\n type GtkAboutDialogProps,\n type GtkApplicationProps,\n type GtkDropTargetProps,\n type GtkDrawingAreaProps,\n type GtkDragSourceProps,\n};\n"]}
|
|
@@ -29,31 +29,16 @@ type IndexedInserter = GObject.Object & {
|
|
|
29
29
|
remove: (child: Gtk.Widget) => void;
|
|
30
30
|
insert: (child: Gtk.Widget, position: number) => unknown;
|
|
31
31
|
};
|
|
32
|
-
/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */
|
|
33
32
|
declare const slot: <P extends GObject.Object, C extends GObject.Object>(slotName: string, childType: string, hooks: SlotHooks<P, C>) => ElementBehavior;
|
|
34
|
-
/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */
|
|
35
33
|
declare const value: <P extends GObject.Object, V>(prop: string, apply: ValueApply<P, V>) => ElementBehavior<P>;
|
|
36
|
-
/**
|
|
37
|
-
* Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural
|
|
38
|
-
* change. `add` may return a handle that the same item's later `remove` receives, for items whose
|
|
39
|
-
* teardown needs what `add` produced (as VFL constraints need the objects the layout created).
|
|
40
|
-
*/
|
|
41
34
|
declare const list: <P extends GObject.Object, I, H = void>(prop: string, hooks: ListHooks<P, I, H>) => ElementBehavior<P>;
|
|
42
|
-
/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */
|
|
43
35
|
declare const deferred: <P extends GObject.Object, V>(prop: string, canApply?: CanApply<P, V>) => ElementBehavior<P>;
|
|
44
|
-
/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */
|
|
45
36
|
declare const controlledText: (prop: string) => ElementBehavior;
|
|
46
|
-
/** Behavior for a container that installs its single child with `setChild`. */
|
|
47
37
|
declare const childSetterSlot: <P extends ChildSetter>() => ElementBehavior<P>;
|
|
48
|
-
/** Behavior for a container that installs its single child with `setContent`. */
|
|
49
38
|
declare const contentSetterSlot: <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(childType?: string) => ElementBehavior<P>;
|
|
50
|
-
/** Behavior for a `GtkBox`-style container that orders children by sibling. */
|
|
51
39
|
declare const boxSlot: <P extends BoxLike>() => ElementBehavior<P>;
|
|
52
|
-
/** Behavior for a container whose children are added and removed by a pair of methods. */
|
|
53
40
|
declare const addRemoveSlot: <C extends GObject.Object, P extends GObject.Object>(slotName: string, childType: string, add: (parent: P, child: C) => unknown, remove: (parent: P, child: C) => void) => ElementBehavior;
|
|
54
|
-
/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */
|
|
55
41
|
declare const adoptedChildrenSlot: <P extends GObject.Object, C extends GObject.Object>(childType: string, add: (parent: P, item: C) => unknown, remove: (parent: P, item: C) => void) => ElementBehavior;
|
|
56
|
-
/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */
|
|
57
42
|
declare const wrappingIndexedSlot: <W extends Gtk.Widget, P extends IndexedInserter>(Wrapper: new (props: Props) => W, setChild: (wrapper: W, inner: Gtk.Widget) => void) => ElementBehavior<P>;
|
|
58
43
|
export { slot, value, list, deferred, controlledText, childSetterSlot, contentSetterSlot, boxSlot, addRemoveSlot, adoptedChildrenSlot, wrappingIndexedSlot, };
|
|
59
44
|
//# sourceMappingURL=behaviors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"behaviors.d.ts","sourceRoot":"","sources":["../../src/reconciler/behaviors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAInF,KAAK,SAAS,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,IAAI;IACjE,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAC1D,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACzD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAC5D,CAAC;AAEF,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAE7E,KAAK,SAAS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AAC,CAQd,CAAC;AAEP,QAAA,MAAM,OAAO,GAAI,CAAC,SAAS,OAAO,OAAK,eAAe,CAAC,CAAC,CASlD,CAAC;AAEP,QAAA,MAAM,aAAa,GAAI,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,EACrE,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,EACrC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,KACtC,eAAmF,CAAC;AAEvF,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,MAAM,EAC3E,WAAW,MAAM,EACjB,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,OAAO,EACpC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,KACrC,eAA0E,CAAC;AAsC9E,QAAA,MAAM,mBAAmB,GAAI,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,SAAS,eAAe,EACxE,SAAS,KAAK,KAAK,EAAE,KAAK,KAAK,CAAC,EAChC,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,KAAK,IAAI,KAClD,eAAe,CAAC,CAAC,CASlB,CAAC;AAEH,OAAO,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACtB,CAAC"}
|
|
@@ -14,7 +14,6 @@ const slotAttach = (slotName, isMatch, attach) => (object, child, info) => {
|
|
|
14
14
|
}
|
|
15
15
|
return attach(object, child, info) ?? true;
|
|
16
16
|
};
|
|
17
|
-
/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */
|
|
18
17
|
const slot = (slotName, childType, hooks) => {
|
|
19
18
|
const matches = childMatcher(childType);
|
|
20
19
|
const { attach, detach, reorder, resolve } = hooks;
|
|
@@ -32,7 +31,6 @@ const slot = (slotName, childType, hooks) => {
|
|
|
32
31
|
}
|
|
33
32
|
return behavior;
|
|
34
33
|
};
|
|
35
|
-
/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */
|
|
36
34
|
const value = (prop, apply) => ({
|
|
37
35
|
update: (object, prev, next) => {
|
|
38
36
|
if (!Object.is(prev[prop], next[prop]) && next[prop] !== undefined) {
|
|
@@ -54,15 +52,10 @@ const teardownList = (object, entries, hooks) => {
|
|
|
54
52
|
remove(object, entry.item, entry.handle);
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural
|
|
59
|
-
* change. `add` may return a handle that the same item's later `remove` receives, for items whose
|
|
60
|
-
* teardown needs what `add` produced (as VFL constraints need the objects the layout created).
|
|
61
|
-
*/
|
|
62
55
|
const list = (prop, hooks) => {
|
|
63
56
|
const { add } = hooks;
|
|
64
57
|
return {
|
|
65
|
-
|
|
58
|
+
initialize: () => ({ snapshot: [], entries: [] }),
|
|
66
59
|
update: (object, _prev, next, context) => {
|
|
67
60
|
const state = context;
|
|
68
61
|
const raw = next[prop];
|
|
@@ -79,7 +72,7 @@ const list = (prop, hooks) => {
|
|
|
79
72
|
};
|
|
80
73
|
const flushDeferred = (object, context, prop, canApply) => {
|
|
81
74
|
const state = context;
|
|
82
|
-
if (!state.
|
|
75
|
+
if (!state.isPresent || Object.is(state.applied, state.desired)) {
|
|
83
76
|
return;
|
|
84
77
|
}
|
|
85
78
|
if (canApply !== undefined && !canApply(object, state.desired)) {
|
|
@@ -90,21 +83,19 @@ const flushDeferred = (object, context, prop, canApply) => {
|
|
|
90
83
|
});
|
|
91
84
|
state.applied = state.desired;
|
|
92
85
|
};
|
|
93
|
-
/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */
|
|
94
86
|
const deferred = (prop, canApply) => ({
|
|
95
87
|
deferred: [prop],
|
|
96
|
-
|
|
88
|
+
initialize: () => ({ desired: undefined, isPresent: false, applied: undefined }),
|
|
97
89
|
update: (_object, _prev, next, context) => {
|
|
98
90
|
const state = context;
|
|
99
91
|
state.desired = next[prop];
|
|
100
|
-
state.
|
|
92
|
+
state.isPresent = next[prop] !== undefined;
|
|
101
93
|
return [prop];
|
|
102
94
|
},
|
|
103
95
|
flush: (object, context) => {
|
|
104
96
|
flushDeferred(object, context, prop, canApply);
|
|
105
97
|
},
|
|
106
98
|
});
|
|
107
|
-
/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */
|
|
108
99
|
const controlledText = (prop) => value(prop, (object, next) => {
|
|
109
100
|
if (!hasSameText(object, prop, next)) {
|
|
110
101
|
applyWrite(() => {
|
|
@@ -112,7 +103,6 @@ const controlledText = (prop) => value(prop, (object, next) => {
|
|
|
112
103
|
});
|
|
113
104
|
}
|
|
114
105
|
});
|
|
115
|
-
/** Behavior for a container that installs its single child with `setChild`. */
|
|
116
106
|
const childSetterSlot = () => slot("children", "GtkWidget", {
|
|
117
107
|
attach: (parent, child) => {
|
|
118
108
|
parent.setChild(child);
|
|
@@ -121,7 +111,6 @@ const childSetterSlot = () => slot("children", "GtkWidget", {
|
|
|
121
111
|
parent.setChild(null);
|
|
122
112
|
},
|
|
123
113
|
});
|
|
124
|
-
/** Behavior for a container that installs its single child with `setContent`. */
|
|
125
114
|
const contentSetterSlot = (childType = "GtkWidget") => slot("children", childType, {
|
|
126
115
|
attach: (parent, child) => {
|
|
127
116
|
parent.setContent(child);
|
|
@@ -130,7 +119,6 @@ const contentSetterSlot = (childType = "GtkWidget") => slot("children", childTyp
|
|
|
130
119
|
parent.setContent(null);
|
|
131
120
|
},
|
|
132
121
|
});
|
|
133
|
-
/** Behavior for a `GtkBox`-style container that orders children by sibling. */
|
|
134
122
|
const boxSlot = () => slot("children", "GtkWidget", {
|
|
135
123
|
attach: (box, child, info) => box.insertChildAfter(child, info.sibling),
|
|
136
124
|
detach: (box, child) => {
|
|
@@ -140,9 +128,7 @@ const boxSlot = () => slot("children", "GtkWidget", {
|
|
|
140
128
|
box.reorderChildAfter(child, info.sibling);
|
|
141
129
|
},
|
|
142
130
|
});
|
|
143
|
-
/** Behavior for a container whose children are added and removed by a pair of methods. */
|
|
144
131
|
const addRemoveSlot = (slotName, childType, add, remove) => slot(slotName, childType, { attach: add, detach: remove });
|
|
145
|
-
/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */
|
|
146
132
|
const adoptedChildrenSlot = (childType, add, remove) => addRemoveSlot("children", childType, add, remove);
|
|
147
133
|
const wrappedRow = (Wrapper, setChild, rows, child) => {
|
|
148
134
|
if (child instanceof Wrapper) {
|
|
@@ -163,7 +149,6 @@ const removeWrappedRow = (Wrapper, parent, child, rows) => {
|
|
|
163
149
|
parent.remove(row);
|
|
164
150
|
}
|
|
165
151
|
};
|
|
166
|
-
/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */
|
|
167
152
|
const wrappingIndexedSlot = (Wrapper, setChild) => ({
|
|
168
153
|
...slot("children", "GtkWidget", {
|
|
169
154
|
attach: (parent, child, info) => parent.insert(wrappedRow(Wrapper, setChild, info.context, child), info.index),
|
|
@@ -171,7 +156,7 @@ const wrappingIndexedSlot = (Wrapper, setChild) => ({
|
|
|
171
156
|
removeWrappedRow(Wrapper, parent, child, info.context);
|
|
172
157
|
},
|
|
173
158
|
}),
|
|
174
|
-
|
|
159
|
+
initialize: () => new WeakMap(),
|
|
175
160
|
});
|
|
176
161
|
export { slot, value, list, deferred, controlledText, childSetterSlot, contentSetterSlot, boxSlot, addRemoveSlot, adoptedChildrenSlot, wrappingIndexedSlot, };
|
|
177
162
|
//# sourceMappingURL=behaviors.js.map
|
|
@@ -1 +1 @@
|
|
|
1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AAC,OAAmB,CAAC,CAAC;QACvE,CAAC;KACJ,CAAC;IACF,aAAa,EAAE,GAAa,EAAE,CAAC,IAAI,OAAO,EAAE;CAC/C,CAAC,CAAC;AAEH,OAAO,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACtB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport { getInstanceType, TYPE_INVALID, typeFromName, typeIsA } from \"@gtkx/runtime\";\nimport { getOrInsert, isDeepEqual, structuredClone } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo, Props } from \"./registry.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { hasSameText } from \"./text.js\";\n\ntype SlotHooks<P extends GObject.Object, C extends GObject.Object> = {\n attach: (parent: P, child: C, info: PlaceInfo) => unknown;\n detach?: (parent: P, child: C, info: DetachInfo) => void;\n reorder?: (parent: P, child: C, info: PlaceInfo) => unknown;\n resolve?: (parent: P, child: C) => GObject.Object | null;\n};\n\ntype ValueApply<P extends GObject.Object, V> = (object: P, value: V) => void;\n\ntype ListHooks<P extends GObject.Object, I, H> = {\n add?: (parent: P, item: I) => H;\n remove?: (parent: P, item: I, handle: H) => void;\n clear?: (parent: P) => void;\n};\n\ntype ListEntry = { item: unknown; handle: unknown };\ntype ListState = { snapshot: unknown[]; entries: ListEntry[] };\ntype DeferredState = { desired: unknown; present: boolean; applied: unknown };\ntype CanApply<P extends GObject.Object, V> = (object: P, value: V) => boolean;\ntype ChildSetter = GObject.Object & { setChild: (child: Gtk.Widget | null) => void };\ntype ContentSetter<C extends Gtk.Widget> = GObject.Object & { setContent: (content: C | null) => void };\n\ntype BoxLike = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insertChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => unknown;\n reorderChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => void;\n};\n\ntype RowCache = WeakMap<GObject.Object, Gtk.Widget>;\n\ntype IndexedInserter = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insert: (child: Gtk.Widget, position: number) => unknown;\n};\n\nconst childTypeCache: Map<string, bigint> = new Map();\n\nconst childTypeFor = (name: string): bigint => getOrInsert(childTypeCache, name, typeFromName);\n\nconst childMatcher =\n (name: string): ((child: GObject.Object) => boolean) =>\n (child) => {\n const type = childTypeFor(name);\n\n return type === TYPE_INVALID || typeIsA(getInstanceType(child), type);\n };\n\nconst slotAttach =\n <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n isMatch: (child: GObject.Object) => boolean,\n attach: SlotHooks<P, C>[\"attach\"],\n ): NonNullable<ElementBehavior[\"attach\"]> =>\n (object, child, info) => {\n if (info.slot !== slotName || !isMatch(child)) {\n return;\n }\n\n return attach(object as P, child as C, info) ?? true;\n };\n\n/** Builds a behavior for a named child slot holding children of `childType`, claiming matches only. */\nconst slot = <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n childType: string,\n hooks: SlotHooks<P, C>,\n): ElementBehavior => {\n const matches = childMatcher(childType);\n const { attach, detach, reorder, resolve } = hooks;\n const behavior: ElementBehavior = { attach: slotAttach(slotName, matches, attach) };\n\n if (reorder !== undefined) {\n behavior.reorder = (object, child, info) => reorder(object as P, child as C, info) ?? true;\n }\n\n if (detach !== undefined) {\n behavior.detach = (object, child, info) => {\n detach(object as P, child as C, info);\n };\n }\n\n if (resolve !== undefined) {\n behavior.resolve = (object, child) => resolve(object as P, child as C);\n }\n\n return behavior;\n};\n\n/** Builds a scalar-prop behavior that invokes `apply` whenever the value changes, and claims the prop. */\nconst value = <P extends GObject.Object, V>(\n prop: string,\n apply: ValueApply<P, V>,\n): ElementBehavior<P> => ({\n update: (object, prev, next) => {\n if (!Object.is(prev[prop], next[prop]) && next[prop] !== undefined) {\n apply(object, next[prop] as V);\n }\n\n return [prop];\n },\n});\n\nconst teardownList = <P extends GObject.Object, I, H>(\n object: P,\n entries: ListEntry[],\n hooks: ListHooks<P, I, H>,\n): void => {\n if (hooks.clear !== undefined) {\n hooks.clear(object);\n\n return;\n }\n\n const remove = hooks.remove;\n\n if (remove === undefined) {\n return;\n }\n\n for (const entry of entries) {\n remove(object, entry.item as I, entry.handle as H);\n }\n};\n\n/**\n * Builds an array-prop behavior that adds, removes, and clears its items, reapplying on structural\n * change. `add` may return a handle that the same item's later `remove` receives, for items whose\n * teardown needs what `add` produced (as VFL constraints need the objects the layout created).\n */\nconst list = <P extends GObject.Object, I, H = void>(\n prop: string,\n hooks: ListHooks<P, I, H>,\n): ElementBehavior<P> => {\n const { add } = hooks;\n\n return {\n createContext: (): ListState => ({ snapshot: [], entries: [] }),\n update: (object, _prev, next, context) => {\n const state = context as ListState;\n const raw = next[prop];\n const items: unknown[] = Array.isArray(raw) ? raw : [];\n\n if (isDeepEqual(state.snapshot, items)) {\n return [prop];\n }\n\n teardownList(object, state.entries, hooks);\n state.entries = items.map((item) => ({ item, handle: add?.(object, item as I) }));\n state.snapshot = structuredClone(items);\n\n return [prop];\n },\n };\n};\n\nconst flushDeferred = <P extends GObject.Object, V>(\n object: GObject.Object,\n context: unknown,\n prop: string,\n canApply: CanApply<P, V> | undefined,\n): void => {\n const state = context as DeferredState;\n\n if (!state.present || Object.is(state.applied, state.desired)) {\n return;\n }\n\n if (canApply !== undefined && !canApply(object as P, state.desired as V)) {\n return;\n }\n\n applyWrite(() => {\n Reflect.set(object, prop, state.desired);\n });\n\n state.applied = state.desired;\n};\n\n/** Builds a behavior for a prop applied after the surrounding commit, deferred until `canApply` returns true. */\nconst deferred = <P extends GObject.Object, V>(\n prop: string,\n canApply?: CanApply<P, V>,\n): ElementBehavior<P> => ({\n deferred: [prop],\n createContext: (): DeferredState => ({ desired: undefined, present: false, applied: undefined }),\n update: (_object, _prev, next, context) => {\n const state = context as DeferredState;\n state.desired = next[prop];\n state.present = next[prop] !== undefined;\n\n return [prop];\n },\n flush: (object, context) => {\n flushDeferred(object, context, prop, canApply);\n },\n});\n\n/** Builds a behavior for a text prop kept in controlled-input sync: set when provided, never reset. */\nconst controlledText = (prop: string): ElementBehavior =>\n value(prop, (object, next) => {\n if (!hasSameText(object, prop, next)) {\n applyWrite(() => {\n Reflect.set(object, prop, next);\n });\n }\n });\n\n/** Behavior for a container that installs its single child with `setChild`. */\nconst childSetterSlot = <P extends ChildSetter>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child) => {\n parent.setChild(child);\n },\n detach: (parent) => {\n parent.setChild(null);\n },\n });\n\n/** Behavior for a container that installs its single child with `setContent`. */\nconst contentSetterSlot = <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(\n childType = \"GtkWidget\",\n): ElementBehavior<P> =>\n slot<P, C>(\"children\", childType, {\n attach: (parent, child) => {\n parent.setContent(child);\n },\n detach: (parent) => {\n parent.setContent(null);\n },\n });\n\n/** Behavior for a `GtkBox`-style container that orders children by sibling. */\nconst boxSlot = <P extends BoxLike>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (box, child, info) => box.insertChildAfter(child, info.sibling as Gtk.Widget | null),\n detach: (box, child) => {\n box.remove(child);\n },\n reorder: (box, child, info) => {\n box.reorderChildAfter(child, info.sibling as Gtk.Widget | null);\n },\n });\n\n/** Behavior for a container whose children are added and removed by a pair of methods. */\nconst addRemoveSlot = <C extends GObject.Object, P extends GObject.Object>(\n slotName: string,\n childType: string,\n add: (parent: P, child: C) => unknown,\n remove: (parent: P, child: C) => void,\n): ElementBehavior => slot<P, C>(slotName, childType, { attach: add, detach: remove });\n\n/** Behavior for a `children` slot whose attach call returns the page object the container adopts. */\nconst adoptedChildrenSlot = <P extends GObject.Object, C extends GObject.Object>(\n childType: string,\n add: (parent: P, item: C) => unknown,\n remove: (parent: P, item: C) => void,\n): ElementBehavior => addRemoveSlot<C, P>(\"children\", childType, add, remove);\n\nconst wrappedRow = <W extends Gtk.Widget>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n rows: RowCache,\n child: Gtk.Widget,\n): Gtk.Widget => {\n if (child instanceof Wrapper) {\n return child;\n }\n\n const existing = rows.get(child);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const wrapper = new Wrapper({});\n setChild(wrapper, child);\n rows.set(child, wrapper);\n\n return wrapper;\n};\n\nconst removeWrappedRow = (\n Wrapper: new (props: Props) => Gtk.Widget,\n parent: IndexedInserter,\n child: Gtk.Widget,\n rows: RowCache,\n): void => {\n const row = child instanceof Wrapper ? child : rows.get(child);\n\n if (row !== undefined) {\n parent.remove(row);\n }\n};\n\n/** Behavior for an index-placed container that wraps each child in `Wrapper` before adding it. */\nconst wrappingIndexedSlot = <W extends Gtk.Widget, P extends IndexedInserter>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n): ElementBehavior<P> => ({\n ...slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child, info) =>\n parent.insert(wrappedRow(Wrapper, setChild, info.context as RowCache, child), info.index),\n detach: (parent, child, info) => {\n removeWrappedRow(Wrapper, parent, child, info.context as RowCache);\n },\n }),\n createContext: (): RowCache => new WeakMap(),\n});\n\nexport {\n slot,\n value,\n list,\n deferred,\n controlledText,\n childSetterSlot,\n contentSetterSlot,\n boxSlot,\n addRemoveSlot,\n adoptedChildrenSlot,\n wrappingIndexedSlot,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"behaviors.js","sourceRoot":"","sources":["../../src/reconciler/behaviors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;A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,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACrB,OAAyC,EACzC,MAAuB,EACvB,KAAiB,EACjB,IAAc,EACV,EAAE;IACN,MAAM,GAAG,GAAG,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAE/D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CACxB,OAAgC,EAChC,QAAiD,EAC/B,EAAE,CAAC,CAAC;IACtB,GAAG,IAAI,CAAgB,UAAU,EAAE,WAAW,EAAE;QAC5C,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC5B,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAmB,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;QAC7F,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC5B,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAmB,CAAC,CAAC;QACvE,CAAC;KACJ,CAAC;IACF,UAAU,EAAE,GAAa,EAAE,CAAC,IAAI,OAAO,EAAE;CAC5C,CAAC,CAAC;AAEH,OAAO,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACtB,CAAC","sourcesContent":["import type * as GObject from \"@gtkx/gi/gobject\";\nimport type * as Gtk from \"@gtkx/gi/gtk\";\nimport { getInstanceType, TYPE_INVALID, typeFromName, typeIsA } from \"@gtkx/runtime\";\nimport { getOrInsert, isDeepEqual, structuredClone } from \"@gtkx/utils\";\nimport type { DetachInfo, ElementBehavior, PlaceInfo, Props } from \"./registry.js\";\nimport { applyWrite } from \"./signals.js\";\nimport { hasSameText } from \"./text.js\";\n\ntype SlotHooks<P extends GObject.Object, C extends GObject.Object> = {\n attach: (parent: P, child: C, info: PlaceInfo) => unknown;\n detach?: (parent: P, child: C, info: DetachInfo) => void;\n reorder?: (parent: P, child: C, info: PlaceInfo) => unknown;\n resolve?: (parent: P, child: C) => GObject.Object | null;\n};\n\ntype ValueApply<P extends GObject.Object, V> = (object: P, value: V) => void;\n\ntype ListHooks<P extends GObject.Object, I, H> = {\n add?: (parent: P, item: I) => H;\n remove?: (parent: P, item: I, handle: H) => void;\n clear?: (parent: P) => void;\n};\n\ntype ListEntry = { item: unknown; handle: unknown };\ntype ListState = { snapshot: unknown[]; entries: ListEntry[] };\ntype DeferredState = { desired: unknown; isPresent: boolean; applied: unknown };\ntype CanApply<P extends GObject.Object, V> = (object: P, value: V) => boolean;\ntype ChildSetter = GObject.Object & { setChild: (child: Gtk.Widget | null) => void };\ntype ContentSetter<C extends Gtk.Widget> = GObject.Object & { setContent: (content: C | null) => void };\n\ntype BoxLike = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insertChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => unknown;\n reorderChildAfter: (child: Gtk.Widget, sibling: Gtk.Widget | null) => void;\n};\n\ntype RowCache = WeakMap<GObject.Object, Gtk.Widget>;\n\ntype IndexedInserter = GObject.Object & {\n remove: (child: Gtk.Widget) => void;\n insert: (child: Gtk.Widget, position: number) => unknown;\n};\n\nconst childTypeCache: Map<string, bigint> = new Map();\n\nconst childTypeFor = (name: string): bigint => getOrInsert(childTypeCache, name, typeFromName);\n\nconst childMatcher =\n (name: string): ((child: GObject.Object) => boolean) =>\n (child) => {\n const type = childTypeFor(name);\n\n return type === TYPE_INVALID || typeIsA(getInstanceType(child), type);\n };\n\nconst slotAttach =\n <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n isMatch: (child: GObject.Object) => boolean,\n attach: SlotHooks<P, C>[\"attach\"],\n ): NonNullable<ElementBehavior[\"attach\"]> =>\n (object, child, info) => {\n if (info.slot !== slotName || !isMatch(child)) {\n return;\n }\n\n return attach(object as P, child as C, info) ?? true;\n };\n\nconst slot = <P extends GObject.Object, C extends GObject.Object>(\n slotName: string,\n childType: string,\n hooks: SlotHooks<P, C>,\n): ElementBehavior => {\n const matches = childMatcher(childType);\n const { attach, detach, reorder, resolve } = hooks;\n const behavior: ElementBehavior = { attach: slotAttach(slotName, matches, attach) };\n\n if (reorder !== undefined) {\n behavior.reorder = (object, child, info) => reorder(object as P, child as C, info) ?? true;\n }\n\n if (detach !== undefined) {\n behavior.detach = (object, child, info) => {\n detach(object as P, child as C, info);\n };\n }\n\n if (resolve !== undefined) {\n behavior.resolve = (object, child) => resolve(object as P, child as C);\n }\n\n return behavior;\n};\n\nconst value = <P extends GObject.Object, V>(\n prop: string,\n apply: ValueApply<P, V>,\n): ElementBehavior<P> => ({\n update: (object, prev, next) => {\n if (!Object.is(prev[prop], next[prop]) && next[prop] !== undefined) {\n apply(object, next[prop] as V);\n }\n\n return [prop];\n },\n});\n\nconst teardownList = <P extends GObject.Object, I, H>(\n object: P,\n entries: ListEntry[],\n hooks: ListHooks<P, I, H>,\n): void => {\n if (hooks.clear !== undefined) {\n hooks.clear(object);\n\n return;\n }\n\n const remove = hooks.remove;\n\n if (remove === undefined) {\n return;\n }\n\n for (const entry of entries) {\n remove(object, entry.item as I, entry.handle as H);\n }\n};\n\nconst list = <P extends GObject.Object, I, H = void>(\n prop: string,\n hooks: ListHooks<P, I, H>,\n): ElementBehavior<P> => {\n const { add } = hooks;\n\n return {\n initialize: (): ListState => ({ snapshot: [], entries: [] }),\n update: (object, _prev, next, context) => {\n const state = context as ListState;\n const raw = next[prop];\n const items: unknown[] = Array.isArray(raw) ? raw : [];\n\n if (isDeepEqual(state.snapshot, items)) {\n return [prop];\n }\n\n teardownList(object, state.entries, hooks);\n state.entries = items.map((item) => ({ item, handle: add?.(object, item as I) }));\n state.snapshot = structuredClone(items);\n\n return [prop];\n },\n };\n};\n\nconst flushDeferred = <P extends GObject.Object, V>(\n object: GObject.Object,\n context: unknown,\n prop: string,\n canApply: CanApply<P, V> | undefined,\n): void => {\n const state = context as DeferredState;\n\n if (!state.isPresent || Object.is(state.applied, state.desired)) {\n return;\n }\n\n if (canApply !== undefined && !canApply(object as P, state.desired as V)) {\n return;\n }\n\n applyWrite(() => {\n Reflect.set(object, prop, state.desired);\n });\n\n state.applied = state.desired;\n};\n\nconst deferred = <P extends GObject.Object, V>(\n prop: string,\n canApply?: CanApply<P, V>,\n): ElementBehavior<P> => ({\n deferred: [prop],\n initialize: (): DeferredState => ({ desired: undefined, isPresent: false, applied: undefined }),\n update: (_object, _prev, next, context) => {\n const state = context as DeferredState;\n state.desired = next[prop];\n state.isPresent = next[prop] !== undefined;\n\n return [prop];\n },\n flush: (object, context) => {\n flushDeferred(object, context, prop, canApply);\n },\n});\n\nconst controlledText = (prop: string): ElementBehavior =>\n value(prop, (object, next) => {\n if (!hasSameText(object, prop, next)) {\n applyWrite(() => {\n Reflect.set(object, prop, next);\n });\n }\n });\n\nconst childSetterSlot = <P extends ChildSetter>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child) => {\n parent.setChild(child);\n },\n detach: (parent) => {\n parent.setChild(null);\n },\n });\n\nconst contentSetterSlot = <P extends ContentSetter<C>, C extends Gtk.Widget = Gtk.Widget>(\n childType = \"GtkWidget\",\n): ElementBehavior<P> =>\n slot<P, C>(\"children\", childType, {\n attach: (parent, child) => {\n parent.setContent(child);\n },\n detach: (parent) => {\n parent.setContent(null);\n },\n });\n\nconst boxSlot = <P extends BoxLike>(): ElementBehavior<P> =>\n slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (box, child, info) => box.insertChildAfter(child, info.sibling as Gtk.Widget | null),\n detach: (box, child) => {\n box.remove(child);\n },\n reorder: (box, child, info) => {\n box.reorderChildAfter(child, info.sibling as Gtk.Widget | null);\n },\n });\n\nconst addRemoveSlot = <C extends GObject.Object, P extends GObject.Object>(\n slotName: string,\n childType: string,\n add: (parent: P, child: C) => unknown,\n remove: (parent: P, child: C) => void,\n): ElementBehavior => slot<P, C>(slotName, childType, { attach: add, detach: remove });\n\nconst adoptedChildrenSlot = <P extends GObject.Object, C extends GObject.Object>(\n childType: string,\n add: (parent: P, item: C) => unknown,\n remove: (parent: P, item: C) => void,\n): ElementBehavior => addRemoveSlot<C, P>(\"children\", childType, add, remove);\n\nconst wrappedRow = <W extends Gtk.Widget>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n rows: RowCache,\n child: Gtk.Widget,\n): Gtk.Widget => {\n if (child instanceof Wrapper) {\n return child;\n }\n\n const existing = rows.get(child);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const wrapper = new Wrapper({});\n setChild(wrapper, child);\n rows.set(child, wrapper);\n\n return wrapper;\n};\n\nconst removeWrappedRow = (\n Wrapper: new (props: Props) => Gtk.Widget,\n parent: IndexedInserter,\n child: Gtk.Widget,\n rows: RowCache,\n): void => {\n const row = child instanceof Wrapper ? child : rows.get(child);\n\n if (row !== undefined) {\n parent.remove(row);\n }\n};\n\nconst wrappingIndexedSlot = <W extends Gtk.Widget, P extends IndexedInserter>(\n Wrapper: new (props: Props) => W,\n setChild: (wrapper: W, inner: Gtk.Widget) => void,\n): ElementBehavior<P> => ({\n ...slot<P, Gtk.Widget>(\"children\", \"GtkWidget\", {\n attach: (parent, child, info) =>\n parent.insert(wrappedRow(Wrapper, setChild, info.context as RowCache, child), info.index),\n detach: (parent, child, info) => {\n removeWrappedRow(Wrapper, parent, child, info.context as RowCache);\n },\n }),\n initialize: (): RowCache => new WeakMap(),\n});\n\nexport {\n slot,\n value,\n list,\n deferred,\n controlledText,\n childSetterSlot,\n contentSetterSlot,\n boxSlot,\n addRemoveSlot,\n adoptedChildrenSlot,\n wrappingIndexedSlot,\n};\n"]}
|
|
@@ -2,7 +2,7 @@ import type * as GObject from "@gtkx/gi/gobject";
|
|
|
2
2
|
import ReactReconciler from "react-reconciler";
|
|
3
3
|
import { type Instance, type TextNode } from "./node.js";
|
|
4
4
|
import { type RootElement } from "./root-element.js";
|
|
5
|
-
/**
|
|
5
|
+
/** What a tree is rendered into: any GObject, or the {@link RootElement} marker to render at the top level. */
|
|
6
6
|
type Container = RootElement | GObject.Object;
|
|
7
7
|
declare const reconciler: ReactReconciler.Reconciler<Container, Instance, TextNode, unknown, unknown, object>;
|
|
8
8
|
export { reconciler, type Container };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-config.d.ts","sourceRoot":"","sources":["../../src/reconciler/host-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAKjD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAe/C,OAAO,EAQH,KAAK,QAAQ,EAGb,KAAK,QAAQ,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAUpE
|
|
1
|
+
{"version":3,"file":"host-config.d.ts","sourceRoot":"","sources":["../../src/reconciler/host-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAKjD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAe/C,OAAO,EAQH,KAAK,QAAQ,EAGb,KAAK,QAAQ,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAUpE,+GAA+G;AAC/G,KAAK,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;AA2H9C,QAAA,MAAM,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CACrE,CAAC;AAwGhC,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,CAAC"}
|