@gtkx/animated 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +172 -0
  2. package/dist/animated.d.ts +20 -0
  3. package/dist/animated.d.ts.map +1 -0
  4. package/dist/animated.js +44 -0
  5. package/dist/animated.js.map +1 -0
  6. package/dist/apply-animated-values.d.ts +4 -0
  7. package/dist/apply-animated-values.d.ts.map +1 -0
  8. package/dist/apply-animated-values.js +84 -0
  9. package/dist/apply-animated-values.js.map +1 -0
  10. package/dist/bootstrap.d.ts +2 -0
  11. package/dist/bootstrap.d.ts.map +1 -0
  12. package/dist/bootstrap.js +11 -0
  13. package/dist/bootstrap.js.map +1 -0
  14. package/dist/index.d.ts +9 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +5 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/reduced-motion.d.ts +13 -0
  19. package/dist/reduced-motion.d.ts.map +1 -0
  20. package/dist/reduced-motion.js +59 -0
  21. package/dist/reduced-motion.js.map +1 -0
  22. package/dist/request-frame.d.ts +4 -0
  23. package/dist/request-frame.d.ts.map +1 -0
  24. package/dist/request-frame.js +155 -0
  25. package/dist/request-frame.js.map +1 -0
  26. package/dist/types.d.ts +38 -0
  27. package/dist/types.d.ts.map +1 -0
  28. package/dist/types.js +2 -0
  29. package/dist/types.js.map +1 -0
  30. package/dist/with-animated.d.ts +6 -0
  31. package/dist/with-animated.d.ts.map +1 -0
  32. package/dist/with-animated.js +181 -0
  33. package/dist/with-animated.js.map +1 -0
  34. package/package.json +78 -0
  35. package/src/animated.ts +62 -0
  36. package/src/apply-animated-values.ts +116 -0
  37. package/src/bootstrap.ts +12 -0
  38. package/src/index.ts +110 -0
  39. package/src/reduced-motion.ts +82 -0
  40. package/src/request-frame.ts +214 -0
  41. package/src/types.ts +64 -0
  42. package/src/with-animated.tsx +254 -0
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/logo.svg" alt="GTKX" width="100" />
3
+ </p>
4
+
5
+ <h1 align="center">GTKX</h1>
6
+
7
+ <p align="center">
8
+ The React framework for Linux.<br />
9
+ Write native Linux applications with React and TypeScript.
10
+ Built on the GNOME stack and standard web tooling.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/v/create-gtkx?color=cb3837&logo=npm&label=create-gtkx" alt="npm version" /></a>
15
+ <a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/dm/create-gtkx?color=cb3837&logo=npm&label=downloads" alt="npm downloads" /></a>
16
+ <img src="https://img.shields.io/badge/node-%E2%89%A524-339933?logo=node.js&logoColor=white" alt="Node >= 24" />
17
+ <a href="https://github.com/gtkx-org/gtkx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MPL--2.0-blue.svg" alt="License: MPL-2.0" /></a>
18
+ <a href="https://github.com/gtkx-org/gtkx/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gtkx-org/gtkx/ci.yml?branch=main&logo=github&label=CI" alt="CI status" /></a>
19
+ <img src="https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white" alt="TypeScript" />
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a href="https://gtkx.dev">Homepage</a> &middot;
24
+ <a href="https://gtkx.dev/guide/getting-started">Documentation</a> &middot;
25
+ <a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> &middot;
26
+ <a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ <p align="center">
32
+ <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
33
+ </p>
34
+
35
+ <p align="center">
36
+ <em>The Tasks app you build in the <a href="https://gtkx.dev/tutorial/">tutorial</a>.</em>
37
+ </p>
38
+
39
+ ## Demo
40
+
41
+ The intrinsic elements in this snippet render GTK4 widgets, and ordinary React hooks and events drive them:
42
+
43
+ ```tsx
44
+ import * as Gtk from "@gtkx/gi/gtk";
45
+ import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
46
+ import { createRoot, quit } from "@gtkx/react";
47
+ import { useState } from "react";
48
+
49
+ const Counter = () => {
50
+ const [count, setCount] = useState(0);
51
+
52
+ return (
53
+ <GtkApplicationWindow
54
+ title="Hello GTKX"
55
+ defaultWidth={400}
56
+ defaultHeight={300}
57
+ onCloseRequest={quit}
58
+ >
59
+ <GtkBox
60
+ orientation={Gtk.Orientation.VERTICAL}
61
+ spacing={20}
62
+ marginTop={40}
63
+ marginBottom={40}
64
+ marginStart={40}
65
+ marginEnd={40}
66
+ valign={Gtk.Align.CENTER}
67
+ halign={Gtk.Align.CENTER}
68
+ >
69
+ <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
70
+ <GtkLabel cssClasses={["title-2"]}>{`Count: ${count}`}</GtkLabel>
71
+ <GtkButton
72
+ label="Increment"
73
+ onClicked={() => setCount((c) => c + 1)}
74
+ cssClasses={["suggested-action", "pill"]}
75
+ />
76
+ </GtkBox>
77
+ </GtkApplicationWindow>
78
+ );
79
+ };
80
+
81
+ const App = () => (
82
+ <GtkApplication>
83
+ <Counter />
84
+ </GtkApplication>
85
+ );
86
+
87
+ createRoot().render(<App />);
88
+ ```
89
+
90
+ This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world) example, with `app.tsx` and `index.tsx` combined into a single snippet. `@gtkx/gi` and `@gtkx/jsx` are per-project bindings generated by the CLI, not packages you install from npm.
91
+
92
+ ## Why GTKX
93
+
94
+ ### A declarative layer for the GNOME stack
95
+
96
+ GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing re-renders that interface when your application state changes, and nothing hot-reloads it as you work. GTKX adds that missing layer, and the tooling around it, on top of the stack you already know:
97
+
98
+ - a React reconciler that exposes every GObject as a JSX element,
99
+ - a CLI for scaffolding, development, and production builds,
100
+ - a dev server with Fast Refresh that patches your running UI in place,
101
+ - CSS-in-JS styling, React Spring animations, and high-level list, grid, and dialog components,
102
+ - a Testing Library-style API for querying and driving your widgets in tests,
103
+ - and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
104
+
105
+ ### The full GNOME API surface
106
+
107
+ React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX exposes it: GTK4, Adwaita, and any other GObject-Introspection library on your system. Linux-only by design.
108
+
109
+ ### Why Node.js, and why generated bindings
110
+
111
+ GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers what running on Node.js means day to day.
112
+
113
+ GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
114
+
115
+ At runtime, the native Rust core calls straight into the system GTK4, Adwaita, and GLib libraries through libffi, without loading libgirepository at all.
116
+
117
+ ## Quick start
118
+
119
+ GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requirements).
120
+
121
+ Scaffold a new app with the `create-gtkx` initializer:
122
+
123
+ ```sh
124
+ npm create gtkx
125
+ ```
126
+
127
+ The same command works with other package managers: `pnpm create gtkx` or `yarn create gtkx`.
128
+
129
+ Then run your new app:
130
+
131
+ ```sh
132
+ cd my-app
133
+ npm run dev
134
+ ```
135
+
136
+ To go further, follow the [tutorial](https://gtkx.dev/tutorial/).
137
+
138
+ ## Documentation
139
+
140
+ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tutorial that builds a complete GNOME app, from scaffolding to packaging and shipping, plus guides and a full API reference.
141
+
142
+ **[Read the docs &rarr;](https://gtkx.dev/guide/why-gtkx)**
143
+
144
+ ## Requirements
145
+
146
+ GTKX is Linux-only. You need:
147
+
148
+ - Linux with the GTK4 (4.20 or later) and GLib development libraries, plus Adwaita (1.8 or later) once your project binds `Adw-1`
149
+ - Node.js 24 or later
150
+
151
+ The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
152
+
153
+ ## Examples
154
+
155
+ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
156
+
157
+ - [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
158
+ - [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
159
+ - [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
160
+ - [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
161
+
162
+ ## Status
163
+
164
+ GTKX is stable and ready for production use.
165
+
166
+ ## Contributing
167
+
168
+ Contributions are welcome. See [CONTRIBUTING.md](https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/gtkx-org/gtkx/blob/main/CODE_OF_CONDUCT.md), and the [security policy](https://github.com/gtkx-org/gtkx/blob/main/SECURITY.md). Building the repo needs Node.js 24 or later, pnpm, and a Rust toolchain.
169
+
170
+ ## License
171
+
172
+ GTKX is licensed under [MPL-2.0](https://github.com/gtkx-org/gtkx/blob/main/LICENSE).
@@ -0,0 +1,20 @@
1
+ import type { ElementType } from "react";
2
+ import type { AnimatedComponent, AnimatedElements } from "./types.js";
3
+ /**
4
+ * The `animated` entrypoint: callable to wrap any component, and exposing every generated widget
5
+ * component as a property, so `animated.GtkLabel` is the animated form of `GtkLabel`.
6
+ */
7
+ type Animated = (<T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>) & AnimatedElements;
8
+ /**
9
+ * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is
10
+ * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are
11
+ * written to the widget on each frame without a React render. The wrapper of a given component is
12
+ * created once and reused, so repeated lookups render the same component.
13
+ *
14
+ * Every widget component of the generated `@gtkx/jsx` store is also available as a property:
15
+ * `animated.GtkLabel` is `animated(GtkLabel)` without the import. Elements whose `ref` does not
16
+ * expose a `Gtk.Widget` subclass, such as `GtkAdjustment`, are wrapped through the call form.
17
+ */
18
+ declare const animated: Animated;
19
+ export { animated, type Animated };
20
+ //# sourceMappingURL=animated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animated.d.ts","sourceRoot":"","sources":["../src/animated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAItE;;;GAGG;AACH,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC;AAEpH;;;;;;;;;GASG;AACH,QAAA,MAAM,QAAQ,EAAE,QAuBF,CAAC;AAgBf,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import * as elements from "@gtkx/jsx";
2
+ import { withAnimated } from "./with-animated.js";
3
+ /**
4
+ * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is
5
+ * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are
6
+ * written to the widget on each frame without a React render. The wrapper of a given component is
7
+ * created once and reused, so repeated lookups render the same component.
8
+ *
9
+ * Every widget component of the generated `@gtkx/jsx` store is also available as a property:
10
+ * `animated.GtkLabel` is `animated(GtkLabel)` without the import. Elements whose `ref` does not
11
+ * expose a `Gtk.Widget` subclass, such as `GtkAdjustment`, are wrapped through the call form.
12
+ */
13
+ const animated = new Proxy(wrapComponent, {
14
+ get(target, property, receiver) {
15
+ const component = componentFor(property);
16
+ return component === null ? Reflect.get(target, property, receiver) : withAnimated(component);
17
+ },
18
+ getOwnPropertyDescriptor(target, property) {
19
+ const component = componentFor(property);
20
+ if (component === null) {
21
+ return Reflect.getOwnPropertyDescriptor(target, property);
22
+ }
23
+ return { configurable: true, enumerable: true, writable: false, value: withAnimated(component) };
24
+ },
25
+ has(target, property) {
26
+ return componentFor(property) !== null || Reflect.has(target, property);
27
+ },
28
+ ownKeys(target) {
29
+ const names = Object.keys(elements).filter((name) => componentFor(name) !== null);
30
+ return [...new Set([...Reflect.ownKeys(target), ...names])];
31
+ },
32
+ });
33
+ function componentFor(property) {
34
+ const value = Reflect.get(elements, property);
35
+ return isComponent(value) ? value : null;
36
+ }
37
+ function isComponent(value) {
38
+ return typeof value === "function";
39
+ }
40
+ function wrapComponent(component) {
41
+ return withAnimated(component);
42
+ }
43
+ export { animated };
44
+ //# sourceMappingURL=animated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animated.js","sourceRoot":"","sources":["../src/animated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASlD;;;;;;;;;GASG;AACH,MAAM,QAAQ,GAAa,IAAI,KAAK,CAAC,aAAa,EAAE;IAChD,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ;QAC1B,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEzC,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CA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;IAC/B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC;AAED,SAAS,aAAa,CAAsB,SAAY;IACpD,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,OAAO,EAAE,QAAQ,EAAiB,CAAC","sourcesContent":["import type { ElementType } from \"react\";\nimport * as elements from \"@gtkx/jsx\";\nimport type { AnimatedComponent, AnimatedElements } from \"./types.js\";\nimport { withAnimated } from \"./with-animated.js\";\n\ntype Wrappable = Exclude<ElementType, string>;\n/**\n * The `animated` entrypoint: callable to wrap any component, and exposing every generated widget\n * component as a property, so `animated.GtkLabel` is the animated form of `GtkLabel`.\n */\ntype Animated = (<T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>) & AnimatedElements;\n\n/**\n * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is\n * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are\n * written to the widget on each frame without a React render. The wrapper of a given component is\n * created once and reused, so repeated lookups render the same component.\n *\n * Every widget component of the generated `@gtkx/jsx` store is also available as a property:\n * `animated.GtkLabel` is `animated(GtkLabel)` without the import. Elements whose `ref` does not\n * expose a `Gtk.Widget` subclass, such as `GtkAdjustment`, are wrapped through the call form.\n */\nconst animated: Animated = new Proxy(wrapComponent, {\n get(target, property, receiver): unknown {\n const component = componentFor(property);\n\n return component === null ? Reflect.get(target, property, receiver) : withAnimated(component);\n },\n getOwnPropertyDescriptor(target, property): PropertyDescriptor | undefined {\n const component = componentFor(property);\n\n if (component === null) {\n return Reflect.getOwnPropertyDescriptor(target, property);\n }\n\n return { configurable: true, enumerable: true, writable: false, value: withAnimated(component) };\n },\n has(target, property): boolean {\n return componentFor(property) !== null || Reflect.has(target, property);\n },\n ownKeys(target): (string | symbol)[] {\n const names = Object.keys(elements).filter((name) => componentFor(name) !== null);\n\n return [...new Set([...Reflect.ownKeys(target), ...names])];\n },\n}) as Animated;\n\nfunction componentFor(property: string | symbol): Wrappable | null {\n const value: unknown = Reflect.get(elements, property);\n\n return isComponent(value) ? value : null;\n}\n\nfunction isComponent(value: unknown): value is Wrappable {\n return typeof value === \"function\";\n}\n\nfunction wrapComponent<T extends Wrappable>(component: T): AnimatedComponent<T> {\n return withAnimated(component);\n}\n\nexport { animated, type Animated };\n"]}
@@ -0,0 +1,4 @@
1
+ import type { Lookup } from "@react-spring/types";
2
+ declare const didApplyAnimatedValues: (instance: object, values: Lookup) => boolean;
3
+ export { didApplyAnimatedValues };
4
+ //# sourceMappingURL=apply-animated-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-animated-values.d.ts","sourceRoot":"","sources":["../src/apply-animated-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAuGlD,QAAA,MAAM,sBAAsB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAUlE,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,84 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ import { applyStyle, applyWrite } from "@gtkx/react/internal";
3
+ import { coerceObjectProperty } from "@gtkx/runtime";
4
+ const setterCache = new WeakMap();
5
+ const hasSetterInChain = (prototype, name) => {
6
+ for (let current = prototype; current !== null; current = Object.getPrototypeOf(current)) {
7
+ const descriptor = Object.getOwnPropertyDescriptor(current, name);
8
+ if (descriptor !== undefined) {
9
+ return descriptor.set !== undefined;
10
+ }
11
+ }
12
+ return false;
13
+ };
14
+ const hasSetter = (instance, name) => {
15
+ const prototype = Object.getPrototypeOf(instance);
16
+ if (prototype === null) {
17
+ return false;
18
+ }
19
+ let known = setterCache.get(prototype);
20
+ if (known === undefined) {
21
+ known = new Map();
22
+ setterCache.set(prototype, known);
23
+ }
24
+ let isWritable = known.get(name);
25
+ if (isWritable === undefined) {
26
+ isWritable = hasSetterInChain(prototype, name);
27
+ known.set(name, isWritable);
28
+ }
29
+ return isWritable;
30
+ };
31
+ const isText = (value) => typeof value === "string" || typeof value === "number";
32
+ const getText = (value) => {
33
+ if (isText(value)) {
34
+ return String(value);
35
+ }
36
+ if (!Array.isArray(value)) {
37
+ return null;
38
+ }
39
+ const texts = value.map((item) => getText(item));
40
+ return texts.every((item) => item !== null) ? texts.join("") : null;
41
+ };
42
+ const didApplyText = (instance, value) => {
43
+ const text = getText(value);
44
+ if (text === null || !(instance instanceof Gtk.Label)) {
45
+ return false;
46
+ }
47
+ applyWrite(() => {
48
+ instance.setLabel(text);
49
+ });
50
+ return true;
51
+ };
52
+ const didApplyStyle = (instance, value) => {
53
+ if (!(instance instanceof Gtk.Widget)) {
54
+ return false;
55
+ }
56
+ applyStyle(instance, value);
57
+ return true;
58
+ };
59
+ const didApplyValue = (instance, name, value) => {
60
+ if (name === "children") {
61
+ return didApplyText(instance, value);
62
+ }
63
+ if (name === "style") {
64
+ return didApplyStyle(instance, value);
65
+ }
66
+ if (!hasSetter(instance, name)) {
67
+ return false;
68
+ }
69
+ applyWrite(() => {
70
+ Reflect.set(instance, name, coerceObjectProperty(instance, name, value));
71
+ });
72
+ return true;
73
+ };
74
+ const didApplyAnimatedValues = (instance, values) => {
75
+ let isApplied = true;
76
+ for (const name in values) {
77
+ if (!didApplyValue(instance, name, values[name])) {
78
+ isApplied = false;
79
+ }
80
+ }
81
+ return isApplied;
82
+ };
83
+ export { didApplyAnimatedValues };
84
+ //# sourceMappingURL=apply-animated-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-animated-values.js","sourceRoot":"","sources":["../src/apply-animated-values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,GAA0C,IAAI,OAAO,EAAE,CAAC;AAEzE,MAAM,gBAAgB,G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;AAEF,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAE,KAAc,EAAW,EAAE;IAC9E,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACtB,OAAO,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACnB,OAAO,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,oBAAoB,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAW,EAAE;IACzE,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC/C,SAAS,GAAG,KAAK,CAAC;QACtB,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import type { Lookup } from \"@react-spring/types\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { applyStyle, applyWrite } from \"@gtkx/react/internal\";\nimport { coerceObjectProperty } from \"@gtkx/runtime\";\n\nconst setterCache: WeakMap<object, Map<string, boolean>> = new WeakMap();\n\nconst hasSetterInChain = (prototype: object | null, name: string): boolean => {\n for (let current = prototype; current !== null; current = Object.getPrototypeOf(current) as object | null) {\n const descriptor = Object.getOwnPropertyDescriptor(current, name);\n\n if (descriptor !== undefined) {\n return descriptor.set !== undefined;\n }\n }\n\n return false;\n};\n\nconst hasSetter = (instance: object, name: string): boolean => {\n const prototype = Object.getPrototypeOf(instance) as object | null;\n\n if (prototype === null) {\n return false;\n }\n\n let known = setterCache.get(prototype);\n\n if (known === undefined) {\n known = new Map();\n setterCache.set(prototype, known);\n }\n\n let isWritable = known.get(name);\n\n if (isWritable === undefined) {\n isWritable = hasSetterInChain(prototype, name);\n known.set(name, isWritable);\n }\n\n return isWritable;\n};\n\nconst isText = (value: unknown): value is string | number => typeof value === \"string\" || typeof value === \"number\";\n\nconst getText = (value: unknown): string | null => {\n if (isText(value)) {\n return String(value);\n }\n\n if (!Array.isArray(value)) {\n return null;\n }\n\n const texts = value.map((item) => getText(item));\n\n return texts.every((item) => item !== null) ? texts.join(\"\") : null;\n};\n\nconst didApplyText = (instance: object, value: unknown): boolean => {\n const text = getText(value);\n\n if (text === null || !(instance instanceof Gtk.Label)) {\n return false;\n }\n\n applyWrite(() => {\n instance.setLabel(text);\n });\n\n return true;\n};\n\nconst didApplyStyle = (instance: object, value: unknown): boolean => {\n if (!(instance instanceof Gtk.Widget)) {\n return false;\n }\n\n applyStyle(instance, value);\n\n return true;\n};\n\nconst didApplyValue = (instance: object, name: string, value: unknown): boolean => {\n if (name === \"children\") {\n return didApplyText(instance, value);\n }\n\n if (name === \"style\") {\n return didApplyStyle(instance, value);\n }\n\n if (!hasSetter(instance, name)) {\n return false;\n }\n\n applyWrite(() => {\n Reflect.set(instance, name, coerceObjectProperty(instance, name, value));\n });\n\n return true;\n};\n\nconst didApplyAnimatedValues = (instance: object, values: Lookup): boolean => {\n let isApplied = true;\n\n for (const name in values) {\n if (!didApplyValue(instance, name, values[name])) {\n isApplied = false;\n }\n }\n\n return isApplied;\n};\n\nexport { didApplyAnimatedValues };\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { Globals } from "@react-spring/core";
2
+ import { colors, createStringInterpolator } from "@react-spring/shared";
3
+ import { trackReducedMotion } from "./reduced-motion.js";
4
+ import { requestFrame } from "./request-frame.js";
5
+ Globals.assign({
6
+ colors,
7
+ createStringInterpolator,
8
+ requestAnimationFrame: requestFrame,
9
+ });
10
+ trackReducedMotion();
11
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,CAAC,MAAM,CAAC;IACX,MAAM;IACN,wBAAwB;IACxB,qBAAqB,EAAE,YAAY;CACtC,CAAC,CAAC;AAEH,kBAAkB,EAAE,CAAC","sourcesContent":["import { Globals } from \"@react-spring/core\";\nimport { colors, createStringInterpolator } from \"@react-spring/shared\";\nimport { trackReducedMotion } from \"./reduced-motion.js\";\nimport { requestFrame } from \"./request-frame.js\";\n\nGlobals.assign({\n colors,\n createStringInterpolator,\n requestAnimationFrame: requestFrame,\n});\n\ntrackReducedMotion();\n"]}
@@ -0,0 +1,9 @@
1
+ import "./bootstrap.js";
2
+ export { animated, type Animated } from "./animated.js";
3
+ export { useReducedMotion } from "./reduced-motion.js";
4
+ export type { AnimatedComponent, AnimatedElements, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle, } from "./types.js";
5
+ export { BailSignal, config, Controller, createInterpolator, easings, FrameValue, Globals, inferTo, Interpolation, Spring, SpringContext, SpringRef, SpringValue, to, Trail, Transition, update, useChain, useSpring, useSpringRef, useSprings, useSpringValue, useTrail, useTransition, } from "@react-spring/core";
6
+ export type { AnimationConfig, AnimationProps, AnimationResult, AsyncResult, Change, ControllerFlushFn, ControllerProps, ControllerUpdate, EventProp, ForwardProps, GoalProp, GoalValue, GoalValues, InferTo, InlineToProps, Interpolated, Interpolator, ItemKeys, LoopProp, MatchProp, OnChange, OnPause, OnProps, OnResolve, OnRest, OnResume, OnStart, PickAnimated, ReservedEventProps, ReservedProps, SpringChain, SpringComponentProps, SpringConfig, SpringProps, SpringsUpdate, SpringTo, SpringToFn, SpringUpdate, SpringUpdateFn, SpringValues, Springify, ToProps, ToValues, TrailComponentProps, TransitionComponentProps, TransitionFn, TransitionFrom, TransitionKey, TransitionRenderFn, TransitionState, TransitionTo, TransitionValues, UseSpringProps, UseSpringsProps, UseTrailProps, UseTransitionProps, VelocityProp, } from "@react-spring/core";
7
+ export type { FluidValue } from "@react-spring/shared";
8
+ export type { Animatable, EasingFunction, ExtrapolateType, InterpolatorArgs, InterpolatorConfig, InterpolatorFactory, InterpolatorFn, Lookup, OneOrMore, UnknownProps, } from "@react-spring/types";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACR,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,UAAU,EACV,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EACV,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,EACN,aAAa,EACb,SAAS,EACT,WAAW,EACX,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACR,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,EACV,OAAO,EACP,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,SAAS,EACT,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,YAAY,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,MAAM,EACN,SAAS,EACT,YAAY,GACf,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import "./bootstrap.js";
2
+ export { animated } from "./animated.js";
3
+ export { useReducedMotion } from "./reduced-motion.js";
4
+ export { BailSignal, config, Controller, createInterpolator, easings, FrameValue, Globals, inferTo, Interpolation, Spring, SpringContext, SpringRef, SpringValue, to, Trail, Transition, update, useChain, useSpring, useSpringRef, useSprings, useSpringValue, useTrail, useTransition, } from "@react-spring/core";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAiB,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AASvD,OAAO,EACH,UAAU,EACV,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EACV,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,EACN,aAAa,EACb,SAAS,EACT,WAAW,EACX,EAAE,EACF,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,GAChB,MAAM,oBAAoB,CAAC","sourcesContent":["import \"./bootstrap.js\";\n\nexport { animated, type Animated } from \"./animated.js\";\nexport { useReducedMotion } from \"./reduced-motion.js\";\nexport type {\n AnimatedComponent,\n AnimatedElements,\n AnimatedItems,\n AnimatedProp,\n AnimatedProps,\n AnimatedStyle,\n} from \"./types.js\";\nexport {\n BailSignal,\n config,\n Controller,\n createInterpolator,\n easings,\n FrameValue,\n Globals,\n inferTo,\n Interpolation,\n Spring,\n SpringContext,\n SpringRef,\n SpringValue,\n to,\n Trail,\n Transition,\n update,\n useChain,\n useSpring,\n useSpringRef,\n useSprings,\n useSpringValue,\n useTrail,\n useTransition,\n} from \"@react-spring/core\";\nexport type {\n AnimationConfig,\n AnimationProps,\n AnimationResult,\n AsyncResult,\n Change,\n ControllerFlushFn,\n ControllerProps,\n ControllerUpdate,\n EventProp,\n ForwardProps,\n GoalProp,\n GoalValue,\n GoalValues,\n InferTo,\n InlineToProps,\n Interpolated,\n Interpolator,\n ItemKeys,\n LoopProp,\n MatchProp,\n OnChange,\n OnPause,\n OnProps,\n OnResolve,\n OnRest,\n OnResume,\n OnStart,\n PickAnimated,\n ReservedEventProps,\n ReservedProps,\n SpringChain,\n SpringComponentProps,\n SpringConfig,\n SpringProps,\n SpringsUpdate,\n SpringTo,\n SpringToFn,\n SpringUpdate,\n SpringUpdateFn,\n SpringValues,\n Springify,\n ToProps,\n ToValues,\n TrailComponentProps,\n TransitionComponentProps,\n TransitionFn,\n TransitionFrom,\n TransitionKey,\n TransitionRenderFn,\n TransitionState,\n TransitionTo,\n TransitionValues,\n UseSpringProps,\n UseSpringsProps,\n UseTrailProps,\n UseTransitionProps,\n VelocityProp,\n} from \"@react-spring/core\";\nexport type { FluidValue } from \"@react-spring/shared\";\nexport type {\n Animatable,\n EasingFunction,\n ExtrapolateType,\n InterpolatorArgs,\n InterpolatorConfig,\n InterpolatorFactory,\n InterpolatorFn,\n Lookup,\n OneOrMore,\n UnknownProps,\n} from \"@react-spring/types\";\n"]}
@@ -0,0 +1,13 @@
1
+ declare const trackReducedMotion: () => boolean | null;
2
+ /**
3
+ * Reports whether the desktop asks for less motion: `true` while GTK's `gtk-enable-animations`
4
+ * setting is off, which is when every spring already jumps straight to its target, and also while
5
+ * the `gtk-interface-reduced-motion` setting of GTK 4.22 asks to reduce motion, the preference
6
+ * behind the `prefers-reduced-motion` media query, which leaves springs running so that components
7
+ * can trade a slide for a fade themselves. Returns `null` until a display is open.
8
+ *
9
+ * @returns `true` when motion should be reduced, `false` when it should not, `null` when unknown.
10
+ */
11
+ declare const useReducedMotion: () => boolean | null;
12
+ export { trackReducedMotion, useReducedMotion };
13
+ //# sourceMappingURL=reduced-motion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reduced-motion.d.ts","sourceRoot":"","sources":["../src/reduced-motion.ts"],"names":[],"mappings":"AAgDA,QAAA,MAAM,kBAAkB,QAAO,OAAO,GAAG,IAYxC,CAAC;AAUF;;;;;;;;GAQG;AACH,QAAA,MAAM,gBAAgB,QAAO,OAAO,GAAG,IAA2D,CAAC;AAEnG,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,59 @@
1
+ import * as Gtk from "@gtkx/gi/gtk";
2
+ import { Globals } from "@react-spring/core";
3
+ import { useSyncExternalStore } from "react";
4
+ const REDUCED_MOTION_MINOR = 22;
5
+ const tracker = { settings: null, isReduced: null };
6
+ const listeners = new Set();
7
+ const hasReducedMotionSetting = () => Gtk.checkVersion(4, REDUCED_MOTION_MINOR, 0) === null;
8
+ const isReduceMotionPreferred = (settings) => hasReducedMotionSetting() && settings.gtkInterfaceReducedMotion === Gtk.ReducedMotion.REDUCE;
9
+ const sync = () => {
10
+ const { settings } = tracker;
11
+ if (settings === null) {
12
+ return;
13
+ }
14
+ const isReduced = !settings.gtkEnableAnimations || isReduceMotionPreferred(settings);
15
+ Globals.assign({ skipAnimation: !settings.gtkEnableAnimations });
16
+ if (isReduced === tracker.isReduced) {
17
+ return;
18
+ }
19
+ tracker.isReduced = isReduced;
20
+ for (const listener of listeners) {
21
+ listener();
22
+ }
23
+ };
24
+ const watch = (settings) => {
25
+ tracker.settings = settings;
26
+ settings.on("notify::gtk-enable-animations", sync);
27
+ if (hasReducedMotionSetting()) {
28
+ settings.on("notify::gtk-interface-reduced-motion", sync);
29
+ }
30
+ sync();
31
+ };
32
+ const trackReducedMotion = () => {
33
+ if (tracker.settings === null) {
34
+ const settings = Gtk.Settings.getDefault();
35
+ if (settings === null) {
36
+ return null;
37
+ }
38
+ watch(settings);
39
+ }
40
+ return tracker.isReduced;
41
+ };
42
+ const subscribe = (listener) => {
43
+ listeners.add(listener);
44
+ return () => {
45
+ listeners.delete(listener);
46
+ };
47
+ };
48
+ /**
49
+ * Reports whether the desktop asks for less motion: `true` while GTK's `gtk-enable-animations`
50
+ * setting is off, which is when every spring already jumps straight to its target, and also while
51
+ * the `gtk-interface-reduced-motion` setting of GTK 4.22 asks to reduce motion, the preference
52
+ * behind the `prefers-reduced-motion` media query, which leaves springs running so that components
53
+ * can trade a slide for a fade themselves. Returns `null` until a display is open.
54
+ *
55
+ * @returns `true` when motion should be reduced, `false` when it should not, `null` when unknown.
56
+ */
57
+ const useReducedMotion = () => useSyncExternalStore(subscribe, trackReducedMotion);
58
+ export { trackReducedMotion, useReducedMotion };
59
+ //# sourceMappingURL=reduced-motion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reduced-motion.js","sourceRoot":"","sources":["../src/reduced-motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAK7C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,OAAO,GAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC7D,MAAM,SAAS,GAAkB,IAAI,GAAG,EAAE,CAAC;AAE3C,MAAM,uBAAuB,GAAG,GAAY,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;AAErG,MAAM,uBAAuB,GAAG,CAAC,QAAsB,EAAW,EAAE,CAChE,uBAAuB,EAAE,IAAI,QAAQ,CAAC,yBAAyB,KAAK,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC;AAEjG,MAAM,IAAI,GAAG,GAAS,EAAE;IACpB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE7B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO;IACX,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,mBAAmB,IAAI,uBAAuB,CAAC,QAAQ,C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AM,gBAAgB,GAAG,GAAmB,EAAE,CAAC,oBAAoB,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAEnG,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { Globals } from \"@react-spring/core\";\nimport { useSyncExternalStore } from \"react\";\n\ntype Listener = () => void;\ntype Tracker = { settings: Gtk.Settings | null; isReduced: boolean | null };\n\nconst REDUCED_MOTION_MINOR = 22;\nconst tracker: Tracker = { settings: null, isReduced: null };\nconst listeners: Set<Listener> = new Set();\n\nconst hasReducedMotionSetting = (): boolean => Gtk.checkVersion(4, REDUCED_MOTION_MINOR, 0) === null;\n\nconst isReduceMotionPreferred = (settings: Gtk.Settings): boolean =>\n hasReducedMotionSetting() && settings.gtkInterfaceReducedMotion === Gtk.ReducedMotion.REDUCE;\n\nconst sync = (): void => {\n const { settings } = tracker;\n\n if (settings === null) {\n return;\n }\n\n const isReduced = !settings.gtkEnableAnimations || isReduceMotionPreferred(settings);\n Globals.assign({ skipAnimation: !settings.gtkEnableAnimations });\n\n if (isReduced === tracker.isReduced) {\n return;\n }\n\n tracker.isReduced = isReduced;\n\n for (const listener of listeners) {\n listener();\n }\n};\n\nconst watch = (settings: Gtk.Settings): void => {\n tracker.settings = settings;\n settings.on(\"notify::gtk-enable-animations\", sync);\n\n if (hasReducedMotionSetting()) {\n settings.on(\"notify::gtk-interface-reduced-motion\", sync);\n }\n\n sync();\n};\n\nconst trackReducedMotion = (): boolean | null => {\n if (tracker.settings === null) {\n const settings = Gtk.Settings.getDefault();\n\n if (settings === null) {\n return null;\n }\n\n watch(settings);\n }\n\n return tracker.isReduced;\n};\n\nconst subscribe = (listener: Listener): (() => void) => {\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n};\n\n/**\n * Reports whether the desktop asks for less motion: `true` while GTK's `gtk-enable-animations`\n * setting is off, which is when every spring already jumps straight to its target, and also while\n * the `gtk-interface-reduced-motion` setting of GTK 4.22 asks to reduce motion, the preference\n * behind the `prefers-reduced-motion` media query, which leaves springs running so that components\n * can trade a slide for a fade themselves. Returns `null` until a display is open.\n *\n * @returns `true` when motion should be reduced, `false` when it should not, `null` when unknown.\n */\nconst useReducedMotion = (): boolean | null => useSyncExternalStore(subscribe, trackReducedMotion);\n\nexport { trackReducedMotion, useReducedMotion };\n"]}
@@ -0,0 +1,4 @@
1
+ type FrameCallback = () => void;
2
+ declare const requestFrame: (callback: FrameCallback) => void;
3
+ export { requestFrame };
4
+ //# sourceMappingURL=request-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-frame.d.ts","sourceRoot":"","sources":["../src/request-frame.ts"],"names":[],"mappings":"AAGA,KAAK,aAAa,GAAG,MAAM,IAAI,CAAC;AA0MhC,QAAA,MAAM,YAAY,GAAI,UAAU,aAAa,KAAG,IAM/C,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}