react-native-gtkx 0.1.0-alpha.4 → 0.2.0-alpha.1
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 +12 -8
- package/dist/adw/index.d.ts +3 -0
- package/dist/adw/index.js +41 -0
- package/dist/adw/index.js.map +1 -0
- package/dist/adw/widgets.generated.d.ts +63 -0
- package/dist/adw/widgets.generated.js +125 -0
- package/dist/adw/widgets.generated.js.map +1 -0
- package/dist/common/content.d.ts +69 -0
- package/dist/common/content.js +84 -0
- package/dist/common/content.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.js +19 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/navigation-stack.d.ts +84 -0
- package/dist/common/navigation-stack.js +313 -0
- package/dist/common/navigation-stack.js.map +1 -0
- package/dist/common/widget.d.ts +83 -0
- package/dist/common/widget.js +142 -0
- package/dist/common/widget.js.map +1 -0
- package/dist/components/animated.d.ts +3 -2
- package/dist/components/animated.js +85 -66
- package/dist/components/animated.js.map +1 -1
- package/dist/components/app-registry.d.ts +10 -1
- package/dist/components/app-registry.js +8 -3
- package/dist/components/app-registry.js.map +1 -1
- package/dist/components/pressable.js +105 -12
- package/dist/components/pressable.js.map +1 -1
- package/dist/components/rect-store.d.ts +11 -1
- package/dist/components/rect-store.js +27 -3
- package/dist/components/rect-store.js.map +1 -1
- package/dist/components/svg/animated-support.d.ts +19 -0
- package/dist/components/svg/animated-support.js +64 -0
- package/dist/components/svg/animated-support.js.map +1 -0
- package/dist/components/svg/context.d.ts +8 -0
- package/dist/components/svg/context.js +15 -0
- package/dist/components/svg/context.js.map +1 -0
- package/dist/components/svg/gradients.d.ts +31 -0
- package/dist/components/svg/gradients.js +93 -0
- package/dist/components/svg/gradients.js.map +1 -0
- package/dist/components/svg/group.d.ts +8 -0
- package/dist/components/svg/group.js +30 -0
- package/dist/components/svg/group.js.map +1 -0
- package/dist/components/svg/index.d.ts +6 -0
- package/dist/components/svg/index.js +5 -0
- package/dist/components/svg/index.js.map +1 -0
- package/dist/components/svg/node.d.ts +7 -0
- package/dist/components/svg/node.js +7 -0
- package/dist/components/svg/node.js.map +1 -0
- package/dist/components/svg/paint.d.ts +24 -0
- package/dist/components/svg/paint.js +57 -0
- package/dist/components/svg/paint.js.map +1 -0
- package/dist/components/svg/shapes.d.ts +47 -0
- package/dist/components/svg/shapes.js +51 -0
- package/dist/components/svg/shapes.js.map +1 -0
- package/dist/components/svg/svg.d.ts +14 -0
- package/dist/components/svg/svg.js +48 -0
- package/dist/components/svg/svg.js.map +1 -0
- package/dist/components/svg/use-shape-node.d.ts +12 -0
- package/dist/components/svg/use-shape-node.js +52 -0
- package/dist/components/svg/use-shape-node.js.map +1 -0
- package/dist/components/text.js +11 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/use-layout-child.js +47 -4
- package/dist/components/use-layout-child.js.map +1 -1
- package/dist/contracts.d.ts +12 -1
- package/dist/contracts.js.map +1 -1
- package/dist/gtk/index.d.ts +6 -0
- package/dist/gtk/index.js +39 -0
- package/dist/gtk/index.js.map +1 -0
- package/dist/gtk/widgets.generated.d.ts +103 -0
- package/dist/gtk/widgets.generated.js +206 -0
- package/dist/gtk/widgets.generated.js.map +1 -0
- package/dist/gtkx/bridge/index.d.ts +9 -4
- package/dist/gtkx/bridge/index.js +40 -4
- package/dist/gtkx/bridge/index.js.map +1 -1
- package/dist/gtkx/bridge/layout-manager.d.ts +2 -1
- package/dist/gtkx/bridge/layout-manager.js +31 -9
- package/dist/gtkx/bridge/layout-manager.js.map +1 -1
- package/dist/gtkx/bridge/svg-node.d.ts +79 -0
- package/dist/gtkx/bridge/svg-node.js +367 -0
- package/dist/gtkx/bridge/svg-node.js.map +1 -0
- package/dist/gtkx/bridge/use-signal.js +18 -8
- package/dist/gtkx/bridge/use-signal.js.map +1 -1
- package/dist/gtkx/bridge/widgets.generated.d.ts +2 -0
- package/dist/gtkx/bridge/widgets.generated.js +14 -0
- package/dist/gtkx/bridge/widgets.generated.js.map +1 -0
- package/dist/mcp/bin.d.ts +2 -0
- package/dist/mcp/bin.js +17 -0
- package/dist/mcp/bin.js.map +1 -0
- package/dist/mcp/data/generated.d.ts +1282 -0
- package/dist/mcp/data/generated.js +1148 -0
- package/dist/mcp/data/generated.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/list.d.ts +4 -0
- package/dist/mcp/list.js +56 -0
- package/dist/mcp/list.js.map +1 -0
- package/dist/mcp/resolve.d.ts +55 -0
- package/dist/mcp/resolve.js +151 -0
- package/dist/mcp/resolve.js.map +1 -0
- package/dist/mcp/search.d.ts +13 -0
- package/dist/mcp/search.js +48 -0
- package/dist/mcp/search.js.map +1 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.js +135 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool.d.ts +21 -0
- package/dist/mcp/tool.js +36 -0
- package/dist/mcp/tool.js.map +1 -0
- package/dist/metro/index.js +10 -0
- package/dist/metro/index.js.map +1 -1
- package/dist/navigation/index.d.ts +50 -13
- package/dist/navigation/index.js +183 -148
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/option-warnings.js +9 -1
- package/dist/navigation/option-warnings.js.map +1 -1
- package/dist/navigation/sidebar.d.ts +177 -9
- package/dist/navigation/sidebar.js +284 -10
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/runner/index.d.ts +22 -2
- package/dist/runner/index.js +163 -13
- package/dist/runner/index.js.map +1 -1
- package/dist/sea/assemble.d.ts +29 -0
- package/dist/sea/assemble.js +129 -0
- package/dist/sea/assemble.js.map +1 -0
- package/dist/sea/bundle.d.ts +61 -0
- package/dist/sea/bundle.js +202 -0
- package/dist/sea/bundle.js.map +1 -0
- package/dist/sea/gtkx-config-module.d.ts +18 -0
- package/dist/sea/gtkx-config-module.js +67 -0
- package/dist/sea/gtkx-config-module.js.map +1 -0
- package/dist/sea/native-shim.d.ts +40 -0
- package/dist/sea/native-shim.js +121 -0
- package/dist/sea/native-shim.js.map +1 -0
- package/dist/sea/react-anchor-plugin.d.ts +2 -0
- package/dist/sea/react-anchor-plugin.js +30 -0
- package/dist/sea/react-anchor-plugin.js.map +1 -0
- package/dist/style/index.d.ts +1 -0
- package/dist/style/index.js +1 -0
- package/dist/style/index.js.map +1 -1
- package/dist/style/split-style.js +2 -2
- package/dist/style/split-style.js.map +1 -1
- package/dist/style/transform.d.ts +22 -0
- package/dist/style/transform.js +137 -0
- package/dist/style/transform.js.map +1 -0
- package/dist/style/visual-css.js +3 -2
- package/dist/style/visual-css.js.map +1 -1
- package/dist/svg/geometry.d.ts +19 -0
- package/dist/svg/geometry.js +80 -0
- package/dist/svg/geometry.js.map +1 -0
- package/dist/svg/gradient-geometry.d.ts +15 -0
- package/dist/svg/gradient-geometry.js +18 -0
- package/dist/svg/gradient-geometry.js.map +1 -0
- package/dist/svg/transform.d.ts +22 -0
- package/dist/svg/transform.js +74 -0
- package/dist/svg/transform.js.map +1 -0
- package/dist/svg/view-box.d.ts +34 -0
- package/dist/svg/view-box.js +108 -0
- package/dist/svg/view-box.js.map +1 -0
- package/dist/svg-compat/index.d.ts +1 -0
- package/dist/svg-compat/index.js +16 -0
- package/dist/svg-compat/index.js.map +1 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.js +14 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/vite/index.d.ts +7 -3
- package/dist/vite/index.js +15 -3
- package/dist/vite/index.js.map +1 -1
- package/dist/vitest/index.d.ts +52 -0
- package/dist/vitest/index.js +58 -0
- package/dist/vitest/index.js.map +1 -0
- package/dist/vitest/setup.d.ts +4 -0
- package/dist/vitest/setup.js +22 -0
- package/dist/vitest/setup.js.map +1 -0
- package/package.json +47 -8
|
@@ -2,17 +2,22 @@ import * as Adw from "@gtkx/gi/adw";
|
|
|
2
2
|
import * as Gdk from "@gtkx/gi/gdk";
|
|
3
3
|
import * as Gio from "@gtkx/gi/gio";
|
|
4
4
|
import * as GLib from "@gtkx/gi/glib";
|
|
5
|
+
import * as GObject from "@gtkx/gi/gobject";
|
|
5
6
|
import * as Graphene from "@gtkx/gi/graphene";
|
|
6
7
|
import * as Gsk from "@gtkx/gi/gsk";
|
|
7
8
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
8
9
|
import * as Pango from "@gtkx/gi/pango";
|
|
9
|
-
export { Adw, Gdk, Gio, GLib, Graphene, Gsk, Gtk, Pango };
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
10
|
+
export { Adw, Gdk, Gio, GLib, GObject, Graphene, Gsk, Gtk, Pango };
|
|
11
|
+
export { GtkApplication, GtkGestureClick } from "@gtkx/jsx/gtk";
|
|
12
|
+
export { GMenu, GSimpleAction } from "@gtkx/jsx/gio";
|
|
13
|
+
export { AdwBreakpoint, AdwShortcutsItem, AdwShortcutsSection, AdwToggle, } from "@gtkx/jsx/adw";
|
|
14
|
+
export { GtkAdjustment, GtkDragSource, GtkDropTarget, GtkShortcut, GtkShortcutController, GtkTextBuffer, } from "@gtkx/jsx/gtk";
|
|
15
|
+
export * from "./widgets.generated";
|
|
16
|
+
export { createPortal, createRoot, quit, rootElement, useApplication, useBindSetting, useParentWindow, useProperty, useSetting, type Root, type RootElement, type SettingsSchema, type SettingsSchemaKeys, type SettingValue, } from "@gtkx/react";
|
|
13
17
|
export { useSignal } from "./use-signal";
|
|
14
18
|
export { css, cx, injectGlobal } from "@gtkx/css";
|
|
15
19
|
export { createTextProbe, measureWidget, toNumber } from "./measure";
|
|
16
20
|
export { getViewBoxComponent, setBoxPassthrough } from "./view-box";
|
|
21
|
+
export { getSvgNodeComponent, getSvgNodeDescriptor, queueSvgRedraw, resolveSvgColor, resolveSvgPaint, setSvgNodeDescriptor, type SvgDefsDescriptor, type SvgGradientUnits, type SvgGroupDescriptor, type SvgLinearGradientDescriptor, type SvgNodeDescriptor, type SvgPaintSpec, type SvgRadialGradientDescriptor, type SvgShapeDescriptor, type SvgStopDescriptor, type SvgSvgDescriptor, } from "./svg-node";
|
|
17
22
|
export { allocateChild, attachRnLayout, detachRnLayout, queueAllocate, queueResize, type RnLayoutHooks, type RnLayoutOrientation, } from "./layout-manager";
|
|
18
23
|
export { colorScheme, styleManager } from "./theme";
|
|
@@ -10,20 +10,56 @@ import * as Adw from "@gtkx/gi/adw";
|
|
|
10
10
|
import * as Gdk from "@gtkx/gi/gdk";
|
|
11
11
|
import * as Gio from "@gtkx/gi/gio";
|
|
12
12
|
import * as GLib from "@gtkx/gi/glib";
|
|
13
|
+
import * as GObject from "@gtkx/gi/gobject";
|
|
13
14
|
import * as Graphene from "@gtkx/gi/graphene";
|
|
14
15
|
import * as Gsk from "@gtkx/gi/gsk";
|
|
15
16
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
16
17
|
import * as Pango from "@gtkx/gi/pango";
|
|
17
|
-
export { Adw, Gdk, Gio, GLib, Graphene, Gsk, Gtk, Pango };
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export { Adw, Gdk, Gio, GLib, GObject, Graphene, Gsk, Gtk, Pango };
|
|
19
|
+
// GtkApplication and GtkGestureClick are not Gtk.Widget subclasses (an
|
|
20
|
+
// application object and an event controller, respectively), so the widget
|
|
21
|
+
// surface generator never sees them — kept here by hand, same as before it
|
|
22
|
+
// existed.
|
|
23
|
+
export { GtkApplication, GtkGestureClick } from "@gtkx/jsx/gtk";
|
|
24
|
+
// Auxiliary gtkx JSX elements that are not Gtk.Widget/Adw.Widget subclasses
|
|
25
|
+
// either, same reason as the pair above — scripts/generate-widget-surface.ts
|
|
26
|
+
// only classifies widgets, so these fall into its "notAWidget" bucket
|
|
27
|
+
// (see scripts/widget-surface/classification.json) and are otherwise
|
|
28
|
+
// unreachable through react-native-gtkx/gtk or /adw. Every one of these is a
|
|
29
|
+
// real, necessary building block for a real app: actions and menus (Gio),
|
|
30
|
+
// a responsive breakpoint (Adw), a text buffer and an adjustment (the model
|
|
31
|
+
// objects GtkTextView/GtkSpinRow etc. bind to), keyboard shortcuts, and the
|
|
32
|
+
// two drag-and-drop controllers.
|
|
33
|
+
//
|
|
34
|
+
// Adw.Breakpoint specifically: independently verified
|
|
35
|
+
// (`Adw.Breakpoint.prototype instanceof Gtk.Widget === false`, prototype
|
|
36
|
+
// chain bottoms out at plain GObject.Object) — it draws nothing and has no
|
|
37
|
+
// size, it is a declaration (a condition plus a set of property setters)
|
|
38
|
+
// attached to a Window/ApplicationWindow/Dialog/BreakpointBin. Running it
|
|
39
|
+
// through wrapReactNative would give it a Yoga node for a widget that
|
|
40
|
+
// occupies no space: a layout bug, not a convenience. Adw.BreakpointBin (a
|
|
41
|
+
// real widget, the container that scopes breakpoints to a subtree) is
|
|
42
|
+
// wrapped normally in ./widgets.generated instead, and is what
|
|
43
|
+
// createSidebarNavigator's own collapse pairs AdwBreakpoint with (see
|
|
44
|
+
// docs/platform-layer.md, "Two ways to react to size").
|
|
45
|
+
export { GMenu, GSimpleAction } from "@gtkx/jsx/gio";
|
|
46
|
+
export { AdwBreakpoint, AdwShortcutsItem, AdwShortcutsSection, AdwToggle, } from "@gtkx/jsx/adw";
|
|
47
|
+
export { GtkAdjustment, GtkDragSource, GtkDropTarget, GtkShortcut, GtkShortcutController, GtkTextBuffer, } from "@gtkx/jsx/gtk";
|
|
48
|
+
// The full widget surface — every GTK/Adwaita class gtkx binds that derives
|
|
49
|
+
// Gtk.Widget, raw. src/gtk/widgets.generated and src/adw/widgets.generated
|
|
50
|
+
// wrap most of them with wrapReactNative; this file is where @gtkx/jsx is
|
|
51
|
+
// still allowed to be imported directly (see the eslint carve-out for
|
|
52
|
+
// src/gtkx/bridge/**), so they pull the raw widgets from here rather than
|
|
53
|
+
// from @gtkx/jsx themselves.
|
|
54
|
+
export * from "./widgets.generated";
|
|
55
|
+
export { createPortal, createRoot, quit, rootElement, useApplication, useBindSetting, useParentWindow, useProperty, useSetting, } from "@gtkx/react";
|
|
21
56
|
// useSignal comes from ./use-signal, not @gtkx/react — see the workaround note
|
|
22
57
|
// there (rc.2 delivers a stale handler).
|
|
23
58
|
export { useSignal } from "./use-signal";
|
|
24
59
|
export { css, cx, injectGlobal } from "@gtkx/css";
|
|
25
60
|
export { createTextProbe, measureWidget, toNumber } from "./measure";
|
|
26
61
|
export { getViewBoxComponent, setBoxPassthrough } from "./view-box";
|
|
62
|
+
export { getSvgNodeComponent, getSvgNodeDescriptor, queueSvgRedraw, resolveSvgColor, resolveSvgPaint, setSvgNodeDescriptor, } from "./svg-node";
|
|
27
63
|
export { allocateChild, attachRnLayout, detachRnLayout, queueAllocate, queueResize, } from "./layout-manager";
|
|
28
64
|
export { colorScheme, styleManager } from "./theme";
|
|
29
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gtkx/bridge/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,gFAAgF;AAChF,EAAE;AACF,0EAA0E;AAC1E,oFAAoF;AAEpF,2EAA2E;AAC3E,sEAAsE;AACtE,qDAAqD;AACrD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAA;AAEtB,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,sEAAsE;AACtE,0EAA0E;AAC1E,6BAA6B;AAC7B,cAAc,qBAAqB,CAAA;AAEnC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,WAAW,EACX,cAAc,EACd,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,GAMX,MAAM,aAAa,CAAA;AAEpB,+EAA+E;AAC/E,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,GAWrB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,aAAa,EACb,WAAW,GAGZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA","sourcesContent":["// The ONLY module allowed to import @gtkx/* (enforced by eslint no-restricted-imports).\n// gtkx is an RC dependency: when its API moves, this bridge absorbs the change.\n//\n// Caveats baked into this surface (catalogued in docs/gtkx-rc2-notes.md):\n// - 64-bit FFI values arrive as BigInt → normalize with toNumber() at this boundary\n\n// import-then-export (not `export * as`): the latter is the one syntax the\n// stock @react-native/babel-preset cannot transform — this form keeps\n// consumer apps on their unmodified RN Babel config.\nimport * as Adw from \"@gtkx/gi/adw\"\nimport * as Gdk from \"@gtkx/gi/gdk\"\nimport * as Gio from \"@gtkx/gi/gio\"\nimport * as GLib from \"@gtkx/gi/glib\"\nimport * as GObject from \"@gtkx/gi/gobject\"\nimport * as Graphene from \"@gtkx/gi/graphene\"\nimport * as Gsk from \"@gtkx/gi/gsk\"\nimport * as Gtk from \"@gtkx/gi/gtk\"\nimport * as Pango from \"@gtkx/gi/pango\"\n\nexport { Adw, Gdk, Gio, GLib, GObject, Graphene, Gsk, Gtk, Pango }\n\n// GtkApplication and GtkGestureClick are not Gtk.Widget subclasses (an\n// application object and an event controller, respectively), so the widget\n// surface generator never sees them — kept here by hand, same as before it\n// existed.\nexport { GtkApplication, GtkGestureClick } from \"@gtkx/jsx/gtk\"\n\n// Auxiliary gtkx JSX elements that are not Gtk.Widget/Adw.Widget subclasses\n// either, same reason as the pair above — scripts/generate-widget-surface.ts\n// only classifies widgets, so these fall into its \"notAWidget\" bucket\n// (see scripts/widget-surface/classification.json) and are otherwise\n// unreachable through react-native-gtkx/gtk or /adw. Every one of these is a\n// real, necessary building block for a real app: actions and menus (Gio),\n// a responsive breakpoint (Adw), a text buffer and an adjustment (the model\n// objects GtkTextView/GtkSpinRow etc. bind to), keyboard shortcuts, and the\n// two drag-and-drop controllers.\n//\n// Adw.Breakpoint specifically: independently verified\n// (`Adw.Breakpoint.prototype instanceof Gtk.Widget === false`, prototype\n// chain bottoms out at plain GObject.Object) — it draws nothing and has no\n// size, it is a declaration (a condition plus a set of property setters)\n// attached to a Window/ApplicationWindow/Dialog/BreakpointBin. Running it\n// through wrapReactNative would give it a Yoga node for a widget that\n// occupies no space: a layout bug, not a convenience. Adw.BreakpointBin (a\n// real widget, the container that scopes breakpoints to a subtree) is\n// wrapped normally in ./widgets.generated instead, and is what\n// createSidebarNavigator's own collapse pairs AdwBreakpoint with (see\n// docs/platform-layer.md, \"Two ways to react to size\").\nexport { GMenu, GSimpleAction } from \"@gtkx/jsx/gio\"\nexport {\n AdwBreakpoint,\n AdwShortcutsItem,\n AdwShortcutsSection,\n AdwToggle,\n} from \"@gtkx/jsx/adw\"\nexport {\n GtkAdjustment,\n GtkDragSource,\n GtkDropTarget,\n GtkShortcut,\n GtkShortcutController,\n GtkTextBuffer,\n} from \"@gtkx/jsx/gtk\"\n\n// The full widget surface — every GTK/Adwaita class gtkx binds that derives\n// Gtk.Widget, raw. src/gtk/widgets.generated and src/adw/widgets.generated\n// wrap most of them with wrapReactNative; this file is where @gtkx/jsx is\n// still allowed to be imported directly (see the eslint carve-out for\n// src/gtkx/bridge/**), so they pull the raw widgets from here rather than\n// from @gtkx/jsx themselves.\nexport * from \"./widgets.generated\"\n\nexport {\n createPortal,\n createRoot,\n quit,\n rootElement,\n useApplication,\n useBindSetting,\n useParentWindow,\n useProperty,\n useSetting,\n type Root,\n type RootElement,\n type SettingsSchema,\n type SettingsSchemaKeys,\n type SettingValue,\n} from \"@gtkx/react\"\n\n// useSignal comes from ./use-signal, not @gtkx/react — see the workaround note\n// there (rc.2 delivers a stale handler).\nexport { useSignal } from \"./use-signal\"\n\nexport { css, cx, injectGlobal } from \"@gtkx/css\"\n\nexport { createTextProbe, measureWidget, toNumber } from \"./measure\"\nexport { getViewBoxComponent, setBoxPassthrough } from \"./view-box\"\nexport {\n getSvgNodeComponent,\n getSvgNodeDescriptor,\n queueSvgRedraw,\n resolveSvgColor,\n resolveSvgPaint,\n setSvgNodeDescriptor,\n type SvgDefsDescriptor,\n type SvgGradientUnits,\n type SvgGroupDescriptor,\n type SvgLinearGradientDescriptor,\n type SvgNodeDescriptor,\n type SvgPaintSpec,\n type SvgRadialGradientDescriptor,\n type SvgShapeDescriptor,\n type SvgStopDescriptor,\n type SvgSvgDescriptor,\n} from \"./svg-node\"\nexport {\n allocateChild,\n attachRnLayout,\n detachRnLayout,\n queueAllocate,\n queueResize,\n type RnLayoutHooks,\n type RnLayoutOrientation,\n} from \"./layout-manager\"\nexport { colorScheme, styleManager } from \"./theme\"\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import type { Transform2D } from "../../contracts";
|
|
2
3
|
export type RnLayoutOrientation = "horizontal" | "vertical";
|
|
3
4
|
export type RnLayoutHooks = {
|
|
4
5
|
measure(orientation: RnLayoutOrientation, forSize: number): number;
|
|
@@ -6,6 +7,6 @@ export type RnLayoutHooks = {
|
|
|
6
7
|
};
|
|
7
8
|
export declare const attachRnLayout: (widget: Gtk.Widget, hooks: RnLayoutHooks) => void;
|
|
8
9
|
export declare const detachRnLayout: (widget: Gtk.Widget) => void;
|
|
9
|
-
export declare const allocateChild: (child: Gtk.Widget, x: number, y: number, width: number, height: number) => void;
|
|
10
|
+
export declare const allocateChild: (child: Gtk.Widget, x: number, y: number, width: number, height: number, matrix?: Transform2D | null) => void;
|
|
10
11
|
export declare const queueAllocate: (widget: Gtk.Widget) => void;
|
|
11
12
|
export declare const queueResize: (widget: Gtk.Widget) => void;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// minimum ratchet, overflow children inflating ancestors, and widget minimums
|
|
8
8
|
// pushing rects.
|
|
9
9
|
import * as Gdk from "@gtkx/gi/gdk";
|
|
10
|
+
import * as Gsk from "@gtkx/gi/gsk";
|
|
10
11
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
11
12
|
import { registerClass } from "@gtkx/runtime";
|
|
12
13
|
// The class must exist before any instance is created, but registration needs
|
|
@@ -66,15 +67,36 @@ export const detachRnLayout = (widget) => {
|
|
|
66
67
|
hooksByManager.delete(manager);
|
|
67
68
|
widget.setLayoutManager(null);
|
|
68
69
|
};
|
|
69
|
-
// Places one child at an exact rect
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
// Places one child at an exact rect, optionally under a visual transform.
|
|
71
|
+
// Only meaningful from inside an allocate() hook — GTK forbids
|
|
72
|
+
// size-allocating outside the layout phase.
|
|
73
|
+
//
|
|
74
|
+
// The transform path is gtk_widget_allocate(), which is what
|
|
75
|
+
// gtk_widget_size_allocate() itself calls with a plain translate — the child
|
|
76
|
+
// keeps the width/height Yoga gave it and only its placement matrix changes,
|
|
77
|
+
// which is exactly RN's "transforms are visual only". GTK4 inverts that
|
|
78
|
+
// matrix in gtk_widget_pick(), so input follows the rotated/scaled shape for
|
|
79
|
+
// free (measured: docs/research/transforms.md).
|
|
80
|
+
export const allocateChild = (child, x, y, width, height, matrix = null) => {
|
|
81
|
+
const left = Math.round(x);
|
|
82
|
+
const top = Math.round(y);
|
|
83
|
+
const w = Math.max(0, Math.round(width));
|
|
84
|
+
const h = Math.max(0, Math.round(height));
|
|
85
|
+
if (!matrix) {
|
|
86
|
+
child.sizeAllocate(new Gdk.Rectangle({ x: left, y: top, width: w, height: h }), -1);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// RN's transform origin is the centre of the view, so the matrix GTK gets
|
|
90
|
+
// is T(left + cx, top + cy) · matrix · T(-cx, -cy) — folded into the six
|
|
91
|
+
// components here rather than chained through GskTransform, which would
|
|
92
|
+
// cost five FFI hops instead of one.
|
|
93
|
+
const cx = w / 2;
|
|
94
|
+
const cy = h / 2;
|
|
95
|
+
const transform = Gsk.Transform.new().matrix2d(matrix.xx, matrix.yx, matrix.xy, matrix.yy, left + cx - (matrix.xx * cx + matrix.xy * cy) + matrix.dx, top + cy - (matrix.yx * cx + matrix.yy * cy) + matrix.dy);
|
|
96
|
+
// gtk_widget_allocate consumes the transform (transfer full) and gtkx
|
|
97
|
+
// hands ownership over with it — never unref it here (that aborts on
|
|
98
|
+
// GLib's rc-box magic assertion).
|
|
99
|
+
child.allocate(w, h, -1, transform);
|
|
78
100
|
};
|
|
79
101
|
// Engine flush → new rects for the same container size: schedule allocation
|
|
80
102
|
// only. A measure-affecting change must use queueResize instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-manager.js","sourceRoot":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/D,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAiB,EACjB,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACR,EAAE;IACR,KAAK,CAAC,YAAY,CAChB,IAAI,GAAG,CAAC,SAAS,CAAC;QAChB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAChB,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAChB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KACxC,CAAC,EACF,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA;AAED,4EAA4E;AAC5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACxD,MAAM,CAAC,aAAa,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACtD,MAAM,CAAC,WAAW,EAAE,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// RnGtkxLayout — a GObject subclass of GtkLayoutManager registered entirely\n// from JS (docs/research/layout-manager.md, \"B0\"). The manager obeys ONLY the\n// layout engine: measure() reports the engine-provided size (minimum ==\n// natural, children are never queried) and allocate() delegates to the engine,\n// which places every child at exactly its computed rect via allocateChild().\n// This is what removes the GTK-vs-RN layout conflicts at the root: window\n// minimum ratchet, overflow children inflating ancestors, and widget minimums\n// pushing rects.\nimport * as Gdk from \"@gtkx/gi/gdk\"\nimport * as Gtk from \"@gtkx/gi/gtk\"\nimport { registerClass } from \"@gtkx/runtime\"\n\nexport type RnLayoutOrientation = \"horizontal\" | \"vertical\"\n\nexport type RnLayoutHooks = {\n // Engine-provided size for the given axis; minimum == natural == this value.\n measure(orientation: RnLayoutOrientation, forSize: number): number\n // Called during GTK's allocation phase with the container's final size.\n // The engine must size-allocate every child (allocateChild) synchronously.\n allocate(width: number, height: number): void\n}\n\n// The class must exist before any instance is created, but registration needs\n// GObject to be initialized — both hold after the bridge is imported, so the\n// class is registered lazily on first attach (also keeps the module safe to\n// import in environments without a display).\nlet RnGtkxLayoutClass: (new () => Gtk.LayoutManager) | null = null\n\nconst hooksByManager = new WeakMap<Gtk.LayoutManager, RnLayoutHooks>()\n\nconst ensureRegistered = (): new () => Gtk.LayoutManager => {\n if (RnGtkxLayoutClass) {\n return RnGtkxLayoutClass\n }\n\n class RnGtkxLayout extends Gtk.LayoutManager {\n override measure(\n _widget: Gtk.Widget,\n orientation: Gtk.Orientation,\n forSize: number,\n ): [number, number, number, number] {\n const hooks = hooksByManager.get(this)\n if (!hooks) {\n return [0, 0, -1, -1]\n }\n const size = hooks.measure(\n orientation === Gtk.Orientation.HORIZONTAL ? \"horizontal\" : \"vertical\",\n forSize,\n )\n return [size, size, -1, -1]\n }\n\n // Trailing vfunc params (baseline; widget) are dropped — JS tolerates the\n // arity mismatch and the linter rejects unused trailing args.\n override allocate(\n _widget: Gtk.Widget,\n width: number,\n height: number,\n ): void {\n hooksByManager.get(this)?.allocate(width, height)\n }\n\n override getRequestMode(): Gtk.SizeRequestMode {\n return Gtk.SizeRequestMode.CONSTANT_SIZE\n }\n }\n\n // Explicit typeName: bundlers minify class names and registerClass derives\n // the GType name from klass.name by default (FINDINGS §1).\n registerClass(RnGtkxLayout, { typeName: \"RnGtkxLayout\" })\n RnGtkxLayoutClass = RnGtkxLayout\n return RnGtkxLayout\n}\n\n// Replaces the widget's layout manager with an RnGtkxLayout driven by `hooks`.\n// The container must attach its children in a layout-child-free way (GtkBox\n// append / set_parent) — GtkFixed.put demands a GtkFixedLayoutChild from the\n// current manager and is incompatible (FINDINGS §2).\nexport const attachRnLayout = (\n widget: Gtk.Widget,\n hooks: RnLayoutHooks,\n): void => {\n const Klass = ensureRegistered()\n if (hooksByManager.has(widget.getLayoutManager() as Gtk.LayoutManager)) {\n throw new Error(\"attachRnLayout: widget already has an RnGtkxLayout\")\n }\n const manager = new Klass()\n hooksByManager.set(manager, hooks)\n widget.setLayoutManager(manager)\n}\n\n// Drops the hooks and hands layout back to a fresh manager of the widget's\n// own class default. Safe to call on widgets that were never attached.\nexport const detachRnLayout = (widget: Gtk.Widget): void => {\n const manager = widget.getLayoutManager() as Gtk.LayoutManager | null\n if (!manager || !hooksByManager.has(manager)) {\n return\n }\n hooksByManager.delete(manager)\n widget.setLayoutManager(null as unknown as Gtk.LayoutManager)\n}\n\n// Places one child at an exact rect. Only meaningful from inside an allocate()\n// hook — GTK forbids size-allocating outside the layout phase.\nexport const allocateChild = (\n child: Gtk.Widget,\n x: number,\n y: number,\n width: number,\n height: number,\n): void => {\n child.sizeAllocate(\n new Gdk.Rectangle({\n x: Math.round(x),\n y: Math.round(y),\n width: Math.max(0, Math.round(width)),\n height: Math.max(0, Math.round(height)),\n }),\n -1,\n )\n}\n\n// Engine flush → new rects for the same container size: schedule allocation\n// only. A measure-affecting change must use queueResize instead.\nexport const queueAllocate = (widget: Gtk.Widget): void => {\n widget.queueAllocate()\n}\n\nexport const queueResize = (widget: Gtk.Widget): void => {\n widget.queueResize()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"layout-manager.js","sourceRoot":"","sources":["../../../src/gtkx/bridge/layout-manager.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,6EAA6E;AAC7E,0EAA0E;AAC1E,8EAA8E;AAC9E,iBAAiB;AACjB,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAa7C,8EAA8E;AAC9E,6EAA6E;AA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C,CAAA;AACrC,CAAC,CAAA;AAED,4EAA4E;AAC5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACxD,MAAM,CAAC,aAAa,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACtD,MAAM,CAAC,WAAW,EAAE,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// RnGtkxLayout — a GObject subclass of GtkLayoutManager registered entirely\n// from JS (docs/research/layout-manager.md, \"B0\"). The manager obeys ONLY the\n// layout engine: measure() reports the engine-provided size (minimum ==\n// natural, children are never queried) and allocate() delegates to the engine,\n// which places every child at exactly its computed rect via allocateChild().\n// This is what removes the GTK-vs-RN layout conflicts at the root: window\n// minimum ratchet, overflow children inflating ancestors, and widget minimums\n// pushing rects.\nimport * as Gdk from \"@gtkx/gi/gdk\"\nimport * as Gsk from \"@gtkx/gi/gsk\"\nimport * as Gtk from \"@gtkx/gi/gtk\"\nimport { registerClass } from \"@gtkx/runtime\"\nimport type { Transform2D } from \"../../contracts\"\n\nexport type RnLayoutOrientation = \"horizontal\" | \"vertical\"\n\nexport type RnLayoutHooks = {\n // Engine-provided size for the given axis; minimum == natural == this value.\n measure(orientation: RnLayoutOrientation, forSize: number): number\n // Called during GTK's allocation phase with the container's final size.\n // The engine must size-allocate every child (allocateChild) synchronously.\n allocate(width: number, height: number): void\n}\n\n// The class must exist before any instance is created, but registration needs\n// GObject to be initialized — both hold after the bridge is imported, so the\n// class is registered lazily on first attach (also keeps the module safe to\n// import in environments without a display).\nlet RnGtkxLayoutClass: (new () => Gtk.LayoutManager) | null = null\n\nconst hooksByManager = new WeakMap<Gtk.LayoutManager, RnLayoutHooks>()\n\nconst ensureRegistered = (): new () => Gtk.LayoutManager => {\n if (RnGtkxLayoutClass) {\n return RnGtkxLayoutClass\n }\n\n class RnGtkxLayout extends Gtk.LayoutManager {\n override measure(\n _widget: Gtk.Widget,\n orientation: Gtk.Orientation,\n forSize: number,\n ): [number, number, number, number] {\n const hooks = hooksByManager.get(this)\n if (!hooks) {\n return [0, 0, -1, -1]\n }\n const size = hooks.measure(\n orientation === Gtk.Orientation.HORIZONTAL ? \"horizontal\" : \"vertical\",\n forSize,\n )\n return [size, size, -1, -1]\n }\n\n // Trailing vfunc params (baseline; widget) are dropped — JS tolerates the\n // arity mismatch and the linter rejects unused trailing args.\n override allocate(\n _widget: Gtk.Widget,\n width: number,\n height: number,\n ): void {\n hooksByManager.get(this)?.allocate(width, height)\n }\n\n override getRequestMode(): Gtk.SizeRequestMode {\n return Gtk.SizeRequestMode.CONSTANT_SIZE\n }\n }\n\n // Explicit typeName: bundlers minify class names and registerClass derives\n // the GType name from klass.name by default (FINDINGS §1).\n registerClass(RnGtkxLayout, { typeName: \"RnGtkxLayout\" })\n RnGtkxLayoutClass = RnGtkxLayout\n return RnGtkxLayout\n}\n\n// Replaces the widget's layout manager with an RnGtkxLayout driven by `hooks`.\n// The container must attach its children in a layout-child-free way (GtkBox\n// append / set_parent) — GtkFixed.put demands a GtkFixedLayoutChild from the\n// current manager and is incompatible (FINDINGS §2).\nexport const attachRnLayout = (\n widget: Gtk.Widget,\n hooks: RnLayoutHooks,\n): void => {\n const Klass = ensureRegistered()\n if (hooksByManager.has(widget.getLayoutManager() as Gtk.LayoutManager)) {\n throw new Error(\"attachRnLayout: widget already has an RnGtkxLayout\")\n }\n const manager = new Klass()\n hooksByManager.set(manager, hooks)\n widget.setLayoutManager(manager)\n}\n\n// Drops the hooks and hands layout back to a fresh manager of the widget's\n// own class default. Safe to call on widgets that were never attached.\nexport const detachRnLayout = (widget: Gtk.Widget): void => {\n const manager = widget.getLayoutManager() as Gtk.LayoutManager | null\n if (!manager || !hooksByManager.has(manager)) {\n return\n }\n hooksByManager.delete(manager)\n widget.setLayoutManager(null as unknown as Gtk.LayoutManager)\n}\n\n// Places one child at an exact rect, optionally under a visual transform.\n// Only meaningful from inside an allocate() hook — GTK forbids\n// size-allocating outside the layout phase.\n//\n// The transform path is gtk_widget_allocate(), which is what\n// gtk_widget_size_allocate() itself calls with a plain translate — the child\n// keeps the width/height Yoga gave it and only its placement matrix changes,\n// which is exactly RN's \"transforms are visual only\". GTK4 inverts that\n// matrix in gtk_widget_pick(), so input follows the rotated/scaled shape for\n// free (measured: docs/research/transforms.md).\nexport const allocateChild = (\n child: Gtk.Widget,\n x: number,\n y: number,\n width: number,\n height: number,\n matrix: Transform2D | null = null,\n): void => {\n const left = Math.round(x)\n const top = Math.round(y)\n const w = Math.max(0, Math.round(width))\n const h = Math.max(0, Math.round(height))\n\n if (!matrix) {\n child.sizeAllocate(\n new Gdk.Rectangle({ x: left, y: top, width: w, height: h }),\n -1,\n )\n return\n }\n\n // RN's transform origin is the centre of the view, so the matrix GTK gets\n // is T(left + cx, top + cy) · matrix · T(-cx, -cy) — folded into the six\n // components here rather than chained through GskTransform, which would\n // cost five FFI hops instead of one.\n const cx = w / 2\n const cy = h / 2\n const transform = Gsk.Transform.new().matrix2d(\n matrix.xx,\n matrix.yx,\n matrix.xy,\n matrix.yy,\n left + cx - (matrix.xx * cx + matrix.xy * cy) + matrix.dx,\n top + cy - (matrix.yx * cx + matrix.yy * cy) + matrix.dy,\n )\n // gtk_widget_allocate consumes the transform (transfer full) and gtkx\n // hands ownership over with it — never unref it here (that aborts on\n // GLib's rc-box magic assertion).\n child.allocate(w, h, -1, transform)\n}\n\n// Engine flush → new rects for the same container size: schedule allocation\n// only. A measure-affecting change must use queueResize instead.\nexport const queueAllocate = (widget: Gtk.Widget): void => {\n widget.queueAllocate()\n}\n\nexport const queueResize = (widget: Gtk.Widget): void => {\n widget.queueResize()\n}\n"]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as Gdk from "@gtkx/gi/gdk";
|
|
2
|
+
import * as Gsk from "@gtkx/gi/gsk";
|
|
3
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
+
import { createElementComponent } from "@gtkx/react/internal";
|
|
5
|
+
import type { SvgTransformOp } from "../../svg/transform";
|
|
6
|
+
import { type PreserveAspectRatio, type ViewBox } from "../../svg/view-box";
|
|
7
|
+
export type SvgPaintSpec = {
|
|
8
|
+
kind: "color";
|
|
9
|
+
rgba: Gdk.RGBA;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "ref";
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
export type SvgGradientUnits = "objectBoundingBox" | "userSpaceOnUse";
|
|
15
|
+
export type SvgSvgDescriptor = {
|
|
16
|
+
kind: "svg";
|
|
17
|
+
viewBox: ViewBox | null;
|
|
18
|
+
preserveAspectRatio: PreserveAspectRatio;
|
|
19
|
+
};
|
|
20
|
+
export type SvgGroupDescriptor = {
|
|
21
|
+
kind: "g";
|
|
22
|
+
transformOps: SvgTransformOp[];
|
|
23
|
+
opacity: number;
|
|
24
|
+
};
|
|
25
|
+
export type SvgShapeDescriptor = {
|
|
26
|
+
kind: "shape";
|
|
27
|
+
path: Gsk.Path | null;
|
|
28
|
+
fill: SvgPaintSpec | null;
|
|
29
|
+
fillOpacity: number;
|
|
30
|
+
fillRule: Gsk.FillRule;
|
|
31
|
+
stroke: SvgPaintSpec | null;
|
|
32
|
+
strokeOpacity: number;
|
|
33
|
+
strokeWidth: number;
|
|
34
|
+
strokeLinecap: Gsk.LineCap;
|
|
35
|
+
strokeLinejoin: Gsk.LineJoin;
|
|
36
|
+
strokeMiterlimit: number;
|
|
37
|
+
strokeDasharray: number[] | null;
|
|
38
|
+
strokeDashoffset: number;
|
|
39
|
+
opacity: number;
|
|
40
|
+
};
|
|
41
|
+
export type SvgDefsDescriptor = {
|
|
42
|
+
kind: "defs";
|
|
43
|
+
};
|
|
44
|
+
export type SvgLinearGradientDescriptor = {
|
|
45
|
+
kind: "gradient";
|
|
46
|
+
type: "linear";
|
|
47
|
+
id: string;
|
|
48
|
+
units: SvgGradientUnits;
|
|
49
|
+
x1: number;
|
|
50
|
+
y1: number;
|
|
51
|
+
x2: number;
|
|
52
|
+
y2: number;
|
|
53
|
+
};
|
|
54
|
+
export type SvgRadialGradientDescriptor = {
|
|
55
|
+
kind: "gradient";
|
|
56
|
+
type: "radial";
|
|
57
|
+
id: string;
|
|
58
|
+
units: SvgGradientUnits;
|
|
59
|
+
cx: number;
|
|
60
|
+
cy: number;
|
|
61
|
+
r: number;
|
|
62
|
+
};
|
|
63
|
+
export type SvgStopDescriptor = {
|
|
64
|
+
kind: "stop";
|
|
65
|
+
offset: number;
|
|
66
|
+
color: Gdk.RGBA;
|
|
67
|
+
};
|
|
68
|
+
export type SvgNodeDescriptor = SvgSvgDescriptor | SvgGroupDescriptor | SvgShapeDescriptor | SvgDefsDescriptor | SvgLinearGradientDescriptor | SvgRadialGradientDescriptor | SvgStopDescriptor;
|
|
69
|
+
export declare const setSvgNodeDescriptor: (widget: Gtk.Widget, descriptor: SvgNodeDescriptor) => void;
|
|
70
|
+
export declare const getSvgNodeDescriptor: (widget: Gtk.Widget) => SvgNodeDescriptor | undefined;
|
|
71
|
+
export declare const resolveSvgColor: (spec: string | undefined) => Gdk.RGBA | null;
|
|
72
|
+
export declare const resolveSvgPaint: (spec: string | undefined) => SvgPaintSpec | null;
|
|
73
|
+
type SvgNodeComponent = ReturnType<typeof createElementComponent>;
|
|
74
|
+
export declare const getSvgNodeComponent: () => SvgNodeComponent;
|
|
75
|
+
/** Imperative invalidation channel for SVG: paint-only changes (including
|
|
76
|
+
* Animated-driven ones) call this instead of queueAllocate/queueResize —
|
|
77
|
+
* nothing here ever touches Yoga. */
|
|
78
|
+
export declare const queueSvgRedraw: (rootWidget: Gtk.Widget) => void;
|
|
79
|
+
export {};
|