@gtkx/animated 1.5.0 → 2.0.0-beta.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 CHANGED
@@ -13,7 +13,7 @@
13
13
  <p align="center">
14
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
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" />
16
+ <img src="https://img.shields.io/badge/node-%E2%89%A526.7-339933?logo=node.js&logoColor=white" alt="Node >= 26.7" />
17
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
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
19
  <img src="https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white" alt="TypeScript" />
@@ -116,7 +116,7 @@ At runtime, the native Rust core calls straight into the system GTK4, Adwaita, a
116
116
 
117
117
  ## Quick start
118
118
 
119
- GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requirements).
119
+ GTKX is Linux-only and needs Node.js 26.7 or later. See [Requirements](#requirements).
120
120
 
121
121
  Scaffold a new app with the `create-gtkx` initializer:
122
122
 
@@ -145,8 +145,8 @@ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tu
145
145
 
146
146
  GTKX is Linux-only. You need:
147
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
148
+ - Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later), and GLib development libraries
149
+ - Node.js 26.7 or later
150
150
 
151
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
152
 
@@ -167,7 +167,7 @@ GTKX is stable and ready for production use.
167
167
 
168
168
  ## Contributing
169
169
 
170
- 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.
170
+ 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 26.7 or later, pnpm, and a Rust toolchain.
171
171
 
172
172
  ## License
173
173
 
@@ -1,19 +1,12 @@
1
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;
2
+ import type { AnimatedComponent } from "./types.js";
3
+ /** Callable entrypoint that wraps a component with animated props. */
4
+ type Animated = <T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>;
8
5
  /**
9
6
  * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is
10
7
  * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are
11
8
  * 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.
9
+ * created once and reused.
17
10
  */
18
11
  declare const animated: Animated;
19
12
  export { animated, type Animated };
@@ -1 +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"}
1
+ {"version":3,"file":"animated.d.ts","sourceRoot":"","sources":["../src/animated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpD,sEAAsE;AACtE,KAAK,QAAQ,GAAG,CAAC,CAAC,SAAS,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,EAAE,QAAuB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,CAAC"}
package/dist/animated.js CHANGED
@@ -1,44 +1,10 @@
1
- import * as elements from "@gtkx/jsx";
2
1
  import { withAnimated } from "./with-animated.js";
3
2
  /**
4
3
  * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is
5
4
  * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are
6
5
  * 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.
6
+ * created once and reused.
12
7
  */
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
- }
8
+ const animated = withAnimated;
43
9
  export { animated };
44
10
  //# sourceMappingURL=animated.js.map
@@ -1 +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,MA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C3C,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEvD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;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"]}
1
+ {"version":3,"file":"animated.js","sourceRoot":"","sources":["../src/animated.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD;;;;;GAKG;AACH,MAAM,QAAQ,GAAa,YAAY,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAiB,CAAC","sourcesContent":["import type { ElementType } from \"react\";\nimport type { AnimatedComponent } from \"./types.js\";\nimport { withAnimated } from \"./with-animated.js\";\n\n/** Callable entrypoint that wraps a component with animated props. */\ntype Animated = <T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>;\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.\n */\nconst animated: Animated = withAnimated;\n\nexport { animated, type Animated };\n"]}
@@ -1 +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;AAwGlD,QAAA,MAAM,sBAAsB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAUlE,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
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;AAmGlD,QAAA,MAAM,sBAAsB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,OAUlE,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -17,11 +17,8 @@ const hasSetter = (instance, name) => {
17
17
  if (prototype === null) {
18
18
  return false;
19
19
  }
20
- let known = setterCache.get(prototype);
21
- if (known === undefined) {
22
- known = new Map();
23
- setterCache.set(prototype, known);
24
- }
20
+ const known = setterCache.get(prototype) ?? new Map();
21
+ setterCache.set(prototype, known);
25
22
  let isWritable = known.get(name);
26
23
  if (isWritable === undefined) {
27
24
  isWritable = hasSetterInChain(prototype, name);
@@ -1 +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,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,WAAW,GAA0C,IAAI,OAAO,EAAE,CAAC;AAEzE,MAAM,gBAAgB,GAAG,CAAC,SAAwB,EAAE,IAAY,EAAW,EAAE;IACzE,KAAK,IAAI,OAAO,GAAG,SAAS,EAAE,OAAO,KAAK,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAkB,EAAE,CAAC;QACxG,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAElE,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,UAAU,CAAC,GAA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C,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE;QAClB,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 LABEL_PROP = \"label\";\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(LABEL_PROP, () => {\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(name, () => {\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"]}
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,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,WAAW,GAA0C,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,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,IAAI,EAAE,GAAG,EAAE;QAClB,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 LABEL_PROP = \"label\";\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 const known = setterCache.get(prototype) ?? new Map<string, boolean>();\n setterCache.set(prototype, known);\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(LABEL_PROP, () => {\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(name, () => {\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"]}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./bootstrap.js";
2
2
  export { animated, type Animated } from "./animated.js";
3
3
  export { useReducedMotion } from "./reduced-motion.js";
4
- export type { AnimatedComponent, AnimatedElements, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle, } from "./types.js";
4
+ export type { AnimatedComponent, AnimatedElementMap, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle, } from "./types.js";
5
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
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
7
  export type { FluidValue } from "@react-spring/shared";
@@ -1 +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,aA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AM,EACN,SAAS,EACT,YAAY,GACf,MAAM,qBAAqB,CAAC"}
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,kBAAkB,EAClB,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.map CHANGED
@@ -1 +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"]}
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 AnimatedElementMap,\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"]}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
- import type * as elements from "@gtkx/jsx";
3
2
  import type { FluidValue } from "@react-spring/shared";
4
- import type { ComponentPropsWithRef, ElementType, FunctionComponent, Ref } from "react";
3
+ import type { ComponentPropsWithRef, ElementType, FunctionComponent, JSX, Ref } from "react";
5
4
  /** An array-valued prop whose items may each be a spring or an interpolation, such as mixed text children. */
6
5
  type AnimatedItems<T> = [Exclude<Extract<T, Iterable<unknown>>, string>] extends [never] ? never : Exclude<Extract<T, Iterable<unknown>>, string> extends Iterable<infer Item> ? Iterable<AnimatedProp<Item>> : never;
7
6
  /** A prop value that an animated component also accepts as a spring or an interpolation. */
@@ -24,15 +23,13 @@ type AnimatedProps<Props extends object> = {
24
23
  /** A component returned by {@link animated}: the wrapped component with animated props. */
25
24
  type AnimatedComponent<T extends Exclude<ElementType, string>> = FunctionComponent<AnimatedProps<ComponentPropsWithRef<T>>>;
26
25
  /**
27
- * The widget components of the generated `@gtkx/jsx` store, keyed by element name, each wrapped as
28
- * an {@link AnimatedComponent}. Only components whose `ref` exposes a `Gtk.Widget` subclass are
29
- * included, so `animated.GtkLabel` is available while non-widget elements such as `GtkAdjustment`
30
- * are wrapped explicitly through the `animated(...)` call instead.
26
+ * The generated JSX intrinsic elements, keyed by element name, as components accepting animated props.
27
+ * Only elements whose `ref` exposes a `Gtk.Widget` subclass are included.
31
28
  */
32
- type AnimatedElements = {
33
- readonly [K in keyof typeof elements as (typeof elements)[K] extends Exclude<ElementType, string> ? ComponentPropsWithRef<(typeof elements)[K]> extends {
29
+ type AnimatedElementMap = {
30
+ readonly [K in keyof JSX.IntrinsicElements as JSX.IntrinsicElements[K] extends {
34
31
  ref?: Ref<infer Instance> | undefined;
35
- } ? [NonNullable<Instance>] extends [never] ? never : NonNullable<Instance> extends Gtk.Widget ? K : never : never : never]: (typeof elements)[K] extends Exclude<ElementType, string> ? AnimatedComponent<(typeof elements)[K]> : never;
32
+ } ? [NonNullable<Instance>] extends [never] ? never : NonNullable<Instance> extends Gtk.Widget ? K : never : never]: JSX.IntrinsicElements[K] extends object ? FunctionComponent<AnimatedProps<JSX.IntrinsicElements[K]>> : never;
36
33
  };
37
- export type { AnimatedComponent, AnimatedElements, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle };
34
+ export type { AnimatedComponent, AnimatedElementMap, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle, };
38
35
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,KAAK,QAAQ,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAExF,8GAA8G;AAC9G,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAClF,KAAK,GACL,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,QAAQ,CAAC,MAAM,IAAI,CAAC,GACvE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAC5B,KAAK,CAAC;AAEhB,4FAA4F;AAC5F,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAA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AAC,GAAG,SAAS,CAAC;KACzC,GACK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC/B,KAAK,GACL,WAAW,CAAC,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,GACpC,CAAC,GACD,KAAK,GACjB,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,MAAM,GAC/C,iBAAiB,CAAC,aAAa,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,GAC1D,KAAK;CACd,CAAC;AAEF,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,GAChB,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type * as elements from \"@gtkx/jsx\";\nimport type { FluidValue } from \"@react-spring/shared\";\nimport type { ComponentPropsWithRef, ElementType, FunctionComponent, Ref } from \"react\";\n\n/** An array-valued prop whose items may each be a spring or an interpolation, such as mixed text children. */\ntype AnimatedItems<T> = [Exclude<Extract<T, Iterable<unknown>>, string>] extends [never]\n ? never\n : Exclude<Extract<T, Iterable<unknown>>, string> extends Iterable<infer Item>\n ? Iterable<AnimatedProp<Item>>\n : never;\n\n/** A prop value that an animated component also accepts as a spring or an interpolation. */\ntype AnimatedProp<T> = T | FluidValue<Exclude<T, undefined>> | AnimatedItems<Exclude<T, undefined>>;\n\n/**\n * A `style` object whose declarations may each be a spring or an interpolation, nested blocks\n * included, so the object a spring hook returns can be handed to `style` as it is.\n */\ntype AnimatedStyle<T> = {\n [K in keyof T]: T[K] extends string | number | undefined | null\n ? AnimatedProp<T[K]>\n : AnimatedProp<T[K]> | AnimatedStyle<NonNullable<T[K]>>;\n};\n\n/**\n * The props of an animated component: every prop of the wrapped component, each also accepting a\n * {@link FluidValue} such as a `SpringValue` or an `Interpolation`, while `ref` and `key` keep\n * their original types.\n */\ntype AnimatedProps<Props extends object> = {\n [P in keyof Props]: P extends \"key\" | \"ref\"\n ? Props[P]\n : P extends \"style\"\n ? AnimatedProp<Props[P]> | AnimatedStyle<NonNullable<Props[P]>>\n : AnimatedProp<Props[P]>;\n};\n\n/** A component returned by {@link animated}: the wrapped component with animated props. */\ntype AnimatedComponent<T extends Exclude<ElementType, string>> = FunctionComponent<\n AnimatedProps<ComponentPropsWithRef<T>>\n>;\n\n/**\n * The widget components of the generated `@gtkx/jsx` store, keyed by element name, each wrapped as\n * an {@link AnimatedComponent}. Only components whose `ref` exposes a `Gtk.Widget` subclass are\n * included, so `animated.GtkLabel` is available while non-widget elements such as `GtkAdjustment`\n * are wrapped explicitly through the `animated(...)` call instead.\n */\ntype AnimatedElements = {\n readonly [K in keyof typeof elements as (typeof elements)[K] extends Exclude<ElementType, string>\n ? ComponentPropsWithRef<(typeof elements)[K]> extends { ref?: Ref<infer Instance> | undefined }\n ? [NonNullable<Instance>] extends [never]\n ? never\n : NonNullable<Instance> extends Gtk.Widget\n ? K\n : never\n : never\n : never]: (typeof elements)[K] extends Exclude<ElementType, string>\n ? AnimatedComponent<(typeof elements)[K]>\n : never;\n};\n\nexport type { AnimatedComponent, AnimatedElements, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { FluidValue } from \"@react-spring/shared\";\nimport type { ComponentPropsWithRef, ElementType, FunctionComponent, JSX, Ref } from \"react\";\n\n/** An array-valued prop whose items may each be a spring or an interpolation, such as mixed text children. */\ntype AnimatedItems<T> = [Exclude<Extract<T, Iterable<unknown>>, string>] extends [never]\n ? never\n : Exclude<Extract<T, Iterable<unknown>>, string> extends Iterable<infer Item>\n ? Iterable<AnimatedProp<Item>>\n : never;\n\n/** A prop value that an animated component also accepts as a spring or an interpolation. */\ntype AnimatedProp<T> = T | FluidValue<Exclude<T, undefined>> | AnimatedItems<Exclude<T, undefined>>;\n\n/**\n * A `style` object whose declarations may each be a spring or an interpolation, nested blocks\n * included, so the object a spring hook returns can be handed to `style` as it is.\n */\ntype AnimatedStyle<T> = {\n [K in keyof T]: T[K] extends string | number | undefined | null\n ? AnimatedProp<T[K]>\n : AnimatedProp<T[K]> | AnimatedStyle<NonNullable<T[K]>>;\n};\n\n/**\n * The props of an animated component: every prop of the wrapped component, each also accepting a\n * {@link FluidValue} such as a `SpringValue` or an `Interpolation`, while `ref` and `key` keep\n * their original types.\n */\ntype AnimatedProps<Props extends object> = {\n [P in keyof Props]: P extends \"key\" | \"ref\"\n ? Props[P]\n : P extends \"style\"\n ? AnimatedProp<Props[P]> | AnimatedStyle<NonNullable<Props[P]>>\n : AnimatedProp<Props[P]>;\n};\n\n/** A component returned by {@link animated}: the wrapped component with animated props. */\ntype AnimatedComponent<T extends Exclude<ElementType, string>> = FunctionComponent<\n AnimatedProps<ComponentPropsWithRef<T>>\n>;\n\n/**\n * The generated JSX intrinsic elements, keyed by element name, as components accepting animated props.\n * Only elements whose `ref` exposes a `Gtk.Widget` subclass are included.\n */\ntype AnimatedElementMap = {\n readonly [K in keyof JSX.IntrinsicElements as JSX.IntrinsicElements[K] extends {\n ref?: Ref<infer Instance> | undefined;\n }\n ? [NonNullable<Instance>] extends [never]\n ? never\n : NonNullable<Instance> extends Gtk.Widget\n ? K\n : never\n : never]: JSX.IntrinsicElements[K] extends object\n ? FunctionComponent<AnimatedProps<JSX.IntrinsicElements[K]>>\n : never;\n};\n\nexport type {\n AnimatedComponent,\n AnimatedElementMap,\n AnimatedItems,\n AnimatedProp,\n AnimatedProps,\n AnimatedStyle,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"with-animated.d.ts","sourceRoot":"","sources":["../src/with-animated.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,WAAW,EAAqE,MAAM,OAAO,CAAC;AAC5G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKpD,KAAK,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AA+M9C,iBAAS,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAS7E;AAmBD,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"with-animated.d.ts","sourceRoot":"","sources":["../src/with-animated.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,WAAW,EAAqE,MAAM,OAAO,CAAC;AAC5G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAKpD,KAAK,SAAS,GAAG,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAsM9C,iBAAS,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,SAAS,EAAE,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAS7E;AAmBD,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -97,16 +97,10 @@ const unobserve = (observer) => {
97
97
  raf.cancel(observer.update);
98
98
  };
99
99
  const useObserver = (observer) => {
100
- const observerRef = useRef(null);
101
100
  useLayoutEffect(() => {
102
- observerRef.current = observer;
103
101
  observe(observer);
104
102
  return () => {
105
- if (observerRef.current === null) {
106
- return;
107
- }
108
- unobserve(observerRef.current);
109
- observerRef.current = null;
103
+ unobserve(observer);
110
104
  };
111
105
  });
112
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"with-animated.js","sourceRoot":"","sources":["../src/with-animated.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACH,gBAAgB,EAGhB,aAAa,EACb,aAAa,EACb,GAAG,EACH,mBAAmB,EACnB,cAAc,GACjB,M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Y,CAAsB,SAAY;IACnD,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAElC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;QAC5C,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,MAA8B,CAAC;AAC1C,CAAC;AAED,MAAM,aAAa;IACN,MAAM,CAAa;IAEnB,YAAY,CAAkB;IAEvC,YAAY,MAAkB,EAAE,YAA6B;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,aAAa,CAAC,KAAiB;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { Lookup } from \"@react-spring/types\";\nimport { useMergedRef } from \"@gtkx/react/internal\";\nimport {\n addFluidObserver,\n type FluidEvent,\n type FluidValue,\n getFluidValue,\n hasFluidValue,\n raf,\n removeFluidObserver,\n useForceUpdate,\n} from \"@react-spring/shared\";\nimport { type ElementType, type ReactNode, type Ref, type RefObject, useLayoutEffect, useRef } from \"react\";\nimport type { AnimatedComponent } from \"./types.js\";\nimport { didApplyAnimatedValues } from \"./apply-animated-values.js\";\nimport { trackReducedMotion } from \"./reduced-motion.js\";\n\ntype AnimatedInput = { ref?: Ref<object> | undefined; [key: string]: unknown };\ntype Wrappable = Exclude<ElementType, string>;\ntype ObserverRef = { current: PropsObserver | null };\n\nconst STYLE_PROP = \"style\";\nconst cache: WeakMap<object, AnimatedComponent<Wrappable>> = new WeakMap();\n\nconst getDisplayName = (component: Wrappable): string => {\n const { displayName, name } = component as { displayName?: unknown; name?: unknown };\n\n if (typeof displayName === \"string\" && displayName !== \"\") {\n return displayName;\n }\n\n return typeof name === \"string\" && name !== \"\" ? name : \"Anonymous\";\n};\n\nconst isFluidProp = (value: unknown): boolean => hasFluidValue(value) || isFluidArray(value);\n\nconst isBlock = (value: unknown): value is Lookup =>\n typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype;\n\nfunction isFluidArray(value: unknown): value is unknown[] {\n return Array.isArray(value) && value.some((item) => isFluidProp(item));\n}\n\nfunction isFluidStyle(value: unknown): value is Lookup {\n return isBlock(value) && Object.values(value).some((item) => hasFluidValue(item) || isFluidStyle(item));\n}\n\nfunction resolveStyle(style: Lookup): Lookup {\n const resolved: Lookup = {};\n\n for (const name in style) {\n const value: unknown = style[name];\n const next: unknown = isFluidStyle(value) ? resolveStyle(value) : getFluidValue(value);\n resolved[name] = next;\n }\n\n return resolved;\n}\n\nfunction resolveValue(value: unknown): unknown {\n return isFluidArray(value) ? value.map((item) => resolveValue(item)) : getFluidValue(value);\n}\n\nconst isFluidNamed = (name: string, value: unknown): boolean =>\n isFluidProp(value) || (name === STYLE_PROP && isFluidStyle(value));\n\nconst resolveNamed = (name: string, value: unknown): unknown =>\n name === STYLE_PROP && isFluidStyle(value) ? resolveStyle(value) : resolveValue(value);\n\nconst resolveProps = (props: Lookup, isAnimatedOnly: boolean): Lookup => {\n const resolved: Lookup = {};\n\n for (const name in props) {\n const value: unknown = props[name];\n\n if (isFluidNamed(name, value)) {\n resolved[name] = resolveNamed(name, value);\n } else if (!isAnimatedOnly) {\n resolved[name] = value;\n }\n }\n\n return resolved;\n};\n\nfunction collectEach(items: unknown[], dependencies: Set<FluidValue>): void {\n for (const item of items) {\n collectDependencies(item, dependencies);\n }\n}\n\nfunction collectDependencies(value: unknown, dependencies: Set<FluidValue>): void {\n if (hasFluidValue(value)) {\n dependencies.add(value);\n } else if (isFluidArray(value)) {\n collectEach(value, dependencies);\n } else if (isFluidStyle(value)) {\n collectEach(Object.values(value), dependencies);\n }\n}\n\nconst collectNamed = (name: string, value: unknown, dependencies: Set<FluidValue>): void => {\n if (isFluidNamed(name, value)) {\n collectDependencies(value, dependencies);\n }\n};\n\nconst getDependencies = (props: Lookup): Set<FluidValue> => {\n const dependencies: Set<FluidValue> = new Set();\n\n for (const name in props) {\n collectNamed(name, props[name], dependencies);\n }\n\n return dependencies;\n};\n\nconst getFluidNames = (props: Lookup): Set<string> => {\n const names: Set<string> = new Set();\n\n for (const name in props) {\n if (isFluidNamed(name, props[name])) {\n names.add(name);\n }\n }\n\n return names;\n};\n\nconst observe = (observer: PropsObserver): void => {\n for (const dependency of observer.dependencies) {\n addFluidObserver(dependency, observer);\n }\n};\n\nconst unobserve = (observer: PropsObserver): void => {\n for (const dependency of observer.dependencies) {\n removeFluidObserver(dependency, observer);\n }\n\n raf.cancel(observer.update);\n};\n\nconst useObserver = (observer: PropsObserver): void => {\n const observerRef: ObserverRef = useRef<PropsObserver | null>(null);\n\n useLayoutEffect(() => {\n observerRef.current = observer;\n observe(observer);\n\n return () => {\n if (observerRef.current === null) {\n return;\n }\n\n unobserve(observerRef.current);\n observerRef.current = null;\n };\n });\n};\n\nconst collectStaticReplacements = (\n props: Lookup,\n previous: Set<string>,\n current: Set<string>,\n values: Lookup,\n): void => {\n for (const name of previous) {\n const value: unknown = props[name];\n\n if (value !== undefined && !current.has(name)) {\n values[name] = value;\n }\n }\n};\n\nconst useCommitSync = (instanceRef: RefObject<object | null>, props: Lookup): void => {\n const fluidNamesRef = useRef<Set<string>>(new Set());\n\n useLayoutEffect(() => {\n const previous = fluidNamesRef.current;\n const current = getFluidNames(props);\n fluidNamesRef.current = current;\n trackReducedMotion();\n const instance = instanceRef.current;\n\n if (instance === null) {\n return;\n }\n\n const values = resolveProps(props, true);\n collectStaticReplacements(props, previous, current, values);\n didApplyAnimatedValues(instance, values);\n });\n};\n\nconst useAnimatedUpdate = (instanceRef: RefObject<object | null>, props: Lookup): (() => void) => {\n const forceUpdate = useForceUpdate();\n\n return () => {\n const instance = instanceRef.current;\n const isApplied = instance !== null && didApplyAnimatedValues(instance, resolveProps(props, true));\n\n if (!isApplied) {\n forceUpdate();\n }\n };\n};\n\nconst createAnimatedComponent = (Component: Wrappable): AnimatedComponent<Wrappable> => {\n const Animated = ({ ref: givenRef, ...props }: AnimatedInput): ReactNode => {\n const instanceRef = useRef<object | null>(null);\n const ref = useMergedRef(givenRef, instanceRef);\n const update = useAnimatedUpdate(instanceRef, props);\n useObserver(new PropsObserver(update, getDependencies(props)));\n useCommitSync(instanceRef, props);\n\n return <Component {...resolveProps(props, false)} ref={ref} />;\n };\n\n Animated.displayName = `Animated(${getDisplayName(Component)})`;\n\n return Animated as AnimatedComponent<Wrappable>;\n};\n\nfunction withAnimated<T extends Wrappable>(component: T): AnimatedComponent<T> {\n let cached = cache.get(component);\n\n if (cached === undefined) {\n cached = createAnimatedComponent(component);\n cache.set(component, cached);\n }\n\n return cached as AnimatedComponent<T>;\n}\n\nclass PropsObserver {\n readonly update: () => void;\n\n readonly dependencies: Set<FluidValue>;\n\n constructor(update: () => void, dependencies: Set<FluidValue>) {\n this.update = update;\n this.dependencies = dependencies;\n }\n\n eventObserved(event: FluidEvent): void {\n if (event.type === \"change\") {\n raf.write(this.update);\n }\n }\n}\n\nexport { withAnimated };\n"]}
1
+ {"version":3,"file":"with-animated.js","sourceRoot":"","sources":["../src/with-animated.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACH,gBAAgB,EAGhB,aAAa,EACb,aAAa,EACb,GAAG,EACH,mBAAmB,EACnB,cAAc,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA8D,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKzD,MA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AAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,aAAa,CAAC,KAAiB;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { Lookup } from \"@react-spring/types\";\nimport { useMergedRef } from \"@gtkx/react/internal\";\nimport {\n addFluidObserver,\n type FluidEvent,\n type FluidValue,\n getFluidValue,\n hasFluidValue,\n raf,\n removeFluidObserver,\n useForceUpdate,\n} from \"@react-spring/shared\";\nimport { type ElementType, type ReactNode, type Ref, type RefObject, useLayoutEffect, useRef } from \"react\";\nimport type { AnimatedComponent } from \"./types.js\";\nimport { didApplyAnimatedValues } from \"./apply-animated-values.js\";\nimport { trackReducedMotion } from \"./reduced-motion.js\";\n\ntype AnimatedInput = { ref?: Ref<object> | undefined; [key: string]: unknown };\ntype Wrappable = Exclude<ElementType, string>;\n\nconst STYLE_PROP = \"style\";\nconst cache: WeakMap<object, AnimatedComponent<Wrappable>> = new WeakMap();\n\nconst getDisplayName = (component: Wrappable): string => {\n const { displayName, name } = component as { displayName?: unknown; name?: unknown };\n\n if (typeof displayName === \"string\" && displayName !== \"\") {\n return displayName;\n }\n\n return typeof name === \"string\" && name !== \"\" ? name : \"Anonymous\";\n};\n\nconst isFluidProp = (value: unknown): boolean => hasFluidValue(value) || isFluidArray(value);\n\nconst isBlock = (value: unknown): value is Lookup =>\n typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype;\n\nfunction isFluidArray(value: unknown): value is unknown[] {\n return Array.isArray(value) && value.some((item) => isFluidProp(item));\n}\n\nfunction isFluidStyle(value: unknown): value is Lookup {\n return isBlock(value) && Object.values(value).some((item) => hasFluidValue(item) || isFluidStyle(item));\n}\n\nfunction resolveStyle(style: Lookup): Lookup {\n const resolved: Lookup = {};\n\n for (const name in style) {\n const value: unknown = style[name];\n const next: unknown = isFluidStyle(value) ? resolveStyle(value) : getFluidValue(value);\n resolved[name] = next;\n }\n\n return resolved;\n}\n\nfunction resolveValue(value: unknown): unknown {\n return isFluidArray(value) ? value.map((item) => resolveValue(item)) : getFluidValue(value);\n}\n\nconst isFluidNamed = (name: string, value: unknown): boolean =>\n isFluidProp(value) || (name === STYLE_PROP && isFluidStyle(value));\n\nconst resolveNamed = (name: string, value: unknown): unknown =>\n name === STYLE_PROP && isFluidStyle(value) ? resolveStyle(value) : resolveValue(value);\n\nconst resolveProps = (props: Lookup, isAnimatedOnly: boolean): Lookup => {\n const resolved: Lookup = {};\n\n for (const name in props) {\n const value: unknown = props[name];\n\n if (isFluidNamed(name, value)) {\n resolved[name] = resolveNamed(name, value);\n } else if (!isAnimatedOnly) {\n resolved[name] = value;\n }\n }\n\n return resolved;\n};\n\nfunction collectEach(items: unknown[], dependencies: Set<FluidValue>): void {\n for (const item of items) {\n collectDependencies(item, dependencies);\n }\n}\n\nfunction collectDependencies(value: unknown, dependencies: Set<FluidValue>): void {\n if (hasFluidValue(value)) {\n dependencies.add(value);\n } else if (isFluidArray(value)) {\n collectEach(value, dependencies);\n } else if (isFluidStyle(value)) {\n collectEach(Object.values(value), dependencies);\n }\n}\n\nconst collectNamed = (name: string, value: unknown, dependencies: Set<FluidValue>): void => {\n if (isFluidNamed(name, value)) {\n collectDependencies(value, dependencies);\n }\n};\n\nconst getDependencies = (props: Lookup): Set<FluidValue> => {\n const dependencies: Set<FluidValue> = new Set();\n\n for (const name in props) {\n collectNamed(name, props[name], dependencies);\n }\n\n return dependencies;\n};\n\nconst getFluidNames = (props: Lookup): Set<string> => {\n const names: Set<string> = new Set();\n\n for (const name in props) {\n if (isFluidNamed(name, props[name])) {\n names.add(name);\n }\n }\n\n return names;\n};\n\nconst observe = (observer: PropsObserver): void => {\n for (const dependency of observer.dependencies) {\n addFluidObserver(dependency, observer);\n }\n};\n\nconst unobserve = (observer: PropsObserver): void => {\n for (const dependency of observer.dependencies) {\n removeFluidObserver(dependency, observer);\n }\n\n raf.cancel(observer.update);\n};\n\nconst useObserver = (observer: PropsObserver): void => {\n useLayoutEffect(() => {\n observe(observer);\n\n return () => {\n unobserve(observer);\n };\n });\n};\n\nconst collectStaticReplacements = (\n props: Lookup,\n previous: Set<string>,\n current: Set<string>,\n values: Lookup,\n): void => {\n for (const name of previous) {\n const value: unknown = props[name];\n\n if (value !== undefined && !current.has(name)) {\n values[name] = value;\n }\n }\n};\n\nconst useCommitSync = (instanceRef: RefObject<object | null>, props: Lookup): void => {\n const fluidNamesRef = useRef<Set<string>>(new Set());\n\n useLayoutEffect(() => {\n const previous = fluidNamesRef.current;\n const current = getFluidNames(props);\n fluidNamesRef.current = current;\n trackReducedMotion();\n const instance = instanceRef.current;\n\n if (instance === null) {\n return;\n }\n\n const values = resolveProps(props, true);\n collectStaticReplacements(props, previous, current, values);\n didApplyAnimatedValues(instance, values);\n });\n};\n\nconst useAnimatedUpdate = (instanceRef: RefObject<object | null>, props: Lookup): (() => void) => {\n const forceUpdate = useForceUpdate();\n\n return () => {\n const instance = instanceRef.current;\n const isApplied = instance !== null && didApplyAnimatedValues(instance, resolveProps(props, true));\n\n if (!isApplied) {\n forceUpdate();\n }\n };\n};\n\nconst createAnimatedComponent = (Component: Wrappable): AnimatedComponent<Wrappable> => {\n const Animated = ({ ref: givenRef, ...props }: AnimatedInput): ReactNode => {\n const instanceRef = useRef<object | null>(null);\n const ref = useMergedRef(givenRef, instanceRef);\n const update = useAnimatedUpdate(instanceRef, props);\n useObserver(new PropsObserver(update, getDependencies(props)));\n useCommitSync(instanceRef, props);\n\n return <Component {...resolveProps(props, false)} ref={ref} />;\n };\n\n Animated.displayName = `Animated(${getDisplayName(Component)})`;\n\n return Animated as AnimatedComponent<Wrappable>;\n};\n\nfunction withAnimated<T extends Wrappable>(component: T): AnimatedComponent<T> {\n let cached = cache.get(component);\n\n if (cached === undefined) {\n cached = createAnimatedComponent(component);\n cache.set(component, cached);\n }\n\n return cached as AnimatedComponent<T>;\n}\n\nclass PropsObserver {\n readonly update: () => void;\n\n readonly dependencies: Set<FluidValue>;\n\n constructor(update: () => void, dependencies: Set<FluidValue>) {\n this.update = update;\n this.dependencies = dependencies;\n }\n\n eventObserved(event: FluidEvent): void {\n if (event.type === \"change\") {\n raf.write(this.update);\n }\n }\n}\n\nexport { withAnimated };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/animated",
3
- "version": "1.5.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Spring animations for GTK widgets, driven by the GTK4 frame clock.",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -29,6 +29,8 @@
29
29
  "./package.json": "./package.json",
30
30
  ".": {
31
31
  "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": null,
32
34
  "default": "./dist/index.js"
33
35
  }
34
36
  },
@@ -53,23 +55,23 @@
53
55
  }
54
56
  },
55
57
  "engines": {
56
- "node": ">=24"
58
+ "node": ">=26.7.0"
57
59
  },
58
60
  "dependencies": {
61
+ "@gtkx/react": "2.0.0-beta.1",
62
+ "@gtkx/runtime": "2.0.0-beta.1",
59
63
  "@react-spring/core": "^10.1.2",
60
64
  "@react-spring/shared": "^10.1.2",
61
- "@react-spring/types": "^10.1.2",
62
- "@gtkx/runtime": "1.5.0",
63
- "@gtkx/react": "1.5.0"
65
+ "@react-spring/types": "^10.1.2"
64
66
  },
65
67
  "peerDependencies": {
66
68
  "react": "^19.2"
67
69
  },
68
70
  "devDependencies": {
69
- "vitest": "^4.1.11",
70
- "@gtkx/config": "1.5.0",
71
- "@gtkx/testing": "1.5.0",
72
- "@gtkx/vitest": "1.5.0"
71
+ "@gtkx/config": "2.0.0-beta.1",
72
+ "@gtkx/testing": "2.0.0-beta.1",
73
+ "@gtkx/vitest": "2.0.0-beta.1",
74
+ "vitest": "^4.1.11"
73
75
  },
74
76
  "scripts": {
75
77
  "release": "tsx ../../scripts/release-package.ts"
package/src/animated.ts CHANGED
@@ -1,62 +1,16 @@
1
1
  import type { ElementType } from "react";
2
- import * as elements from "@gtkx/jsx";
3
- import type { AnimatedComponent, AnimatedElements } from "./types.js";
2
+ import type { AnimatedComponent } from "./types.js";
4
3
  import { withAnimated } from "./with-animated.js";
5
4
 
6
- type Wrappable = Exclude<ElementType, string>;
7
- /**
8
- * The `animated` entrypoint: callable to wrap any component, and exposing every generated widget
9
- * component as a property, so `animated.GtkLabel` is the animated form of `GtkLabel`.
10
- */
11
- type Animated = (<T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>) & AnimatedElements;
5
+ /** Callable entrypoint that wraps a component with animated props. */
6
+ type Animated = <T extends Exclude<ElementType, string>>(component: T) => AnimatedComponent<T>;
12
7
 
13
8
  /**
14
9
  * Wraps a component so that its props accept springs and interpolations: `animated(GtkLabel)` is
15
10
  * `GtkLabel` with every prop also taking a `SpringValue` or an `Interpolation`. Animated values are
16
11
  * written to the widget on each frame without a React render. The wrapper of a given component is
17
- * created once and reused, so repeated lookups render the same component.
18
- *
19
- * Every widget component of the generated `@gtkx/jsx` store is also available as a property:
20
- * `animated.GtkLabel` is `animated(GtkLabel)` without the import. Elements whose `ref` does not
21
- * expose a `Gtk.Widget` subclass, such as `GtkAdjustment`, are wrapped through the call form.
12
+ * created once and reused.
22
13
  */
23
- const animated: Animated = new Proxy(wrapComponent, {
24
- get(target, property, receiver): unknown {
25
- const component = componentFor(property);
26
-
27
- return component === null ? Reflect.get(target, property, receiver) : withAnimated(component);
28
- },
29
- getOwnPropertyDescriptor(target, property): PropertyDescriptor | undefined {
30
- const component = componentFor(property);
31
-
32
- if (component === null) {
33
- return Reflect.getOwnPropertyDescriptor(target, property);
34
- }
35
-
36
- return { configurable: true, enumerable: true, writable: false, value: withAnimated(component) };
37
- },
38
- has(target, property): boolean {
39
- return componentFor(property) !== null || Reflect.has(target, property);
40
- },
41
- ownKeys(target): (string | symbol)[] {
42
- const names = Object.keys(elements).filter((name) => componentFor(name) !== null);
43
-
44
- return [...new Set([...Reflect.ownKeys(target), ...names])];
45
- },
46
- }) as Animated;
47
-
48
- function componentFor(property: string | symbol): Wrappable | null {
49
- const value: unknown = Reflect.get(elements, property);
50
-
51
- return isComponent(value) ? value : null;
52
- }
53
-
54
- function isComponent(value: unknown): value is Wrappable {
55
- return typeof value === "function";
56
- }
57
-
58
- function wrapComponent<T extends Wrappable>(component: T): AnimatedComponent<T> {
59
- return withAnimated(component);
60
- }
14
+ const animated: Animated = withAnimated;
61
15
 
62
16
  export { animated, type Animated };
@@ -25,13 +25,8 @@ const hasSetter = (instance: object, name: string): boolean => {
25
25
  return false;
26
26
  }
27
27
 
28
- let known = setterCache.get(prototype);
29
-
30
- if (known === undefined) {
31
- known = new Map();
32
- setterCache.set(prototype, known);
33
- }
34
-
28
+ const known = setterCache.get(prototype) ?? new Map<string, boolean>();
29
+ setterCache.set(prototype, known);
35
30
  let isWritable = known.get(name);
36
31
 
37
32
  if (isWritable === undefined) {
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ export { animated, type Animated } from "./animated.js";
4
4
  export { useReducedMotion } from "./reduced-motion.js";
5
5
  export type {
6
6
  AnimatedComponent,
7
- AnimatedElements,
7
+ AnimatedElementMap,
8
8
  AnimatedItems,
9
9
  AnimatedProp,
10
10
  AnimatedProps,
package/src/types.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type * as Gtk from "@gtkx/gi/gtk";
2
- import type * as elements from "@gtkx/jsx";
3
2
  import type { FluidValue } from "@react-spring/shared";
4
- import type { ComponentPropsWithRef, ElementType, FunctionComponent, Ref } from "react";
3
+ import type { ComponentPropsWithRef, ElementType, FunctionComponent, JSX, Ref } from "react";
5
4
 
6
5
  /** An array-valued prop whose items may each be a spring or an interpolation, such as mixed text children. */
7
6
  type AnimatedItems<T> = [Exclude<Extract<T, Iterable<unknown>>, string>] extends [never]
@@ -42,23 +41,28 @@ type AnimatedComponent<T extends Exclude<ElementType, string>> = FunctionCompone
42
41
  >;
43
42
 
44
43
  /**
45
- * The widget components of the generated `@gtkx/jsx` store, keyed by element name, each wrapped as
46
- * an {@link AnimatedComponent}. Only components whose `ref` exposes a `Gtk.Widget` subclass are
47
- * included, so `animated.GtkLabel` is available while non-widget elements such as `GtkAdjustment`
48
- * are wrapped explicitly through the `animated(...)` call instead.
44
+ * The generated JSX intrinsic elements, keyed by element name, as components accepting animated props.
45
+ * Only elements whose `ref` exposes a `Gtk.Widget` subclass are included.
49
46
  */
50
- type AnimatedElements = {
51
- readonly [K in keyof typeof elements as (typeof elements)[K] extends Exclude<ElementType, string>
52
- ? ComponentPropsWithRef<(typeof elements)[K]> extends { ref?: Ref<infer Instance> | undefined }
53
- ? [NonNullable<Instance>] extends [never]
54
- ? never
55
- : NonNullable<Instance> extends Gtk.Widget
56
- ? K
57
- : never
58
- : never
59
- : never]: (typeof elements)[K] extends Exclude<ElementType, string>
60
- ? AnimatedComponent<(typeof elements)[K]>
47
+ type AnimatedElementMap = {
48
+ readonly [K in keyof JSX.IntrinsicElements as JSX.IntrinsicElements[K] extends {
49
+ ref?: Ref<infer Instance> | undefined;
50
+ }
51
+ ? [NonNullable<Instance>] extends [never]
52
+ ? never
53
+ : NonNullable<Instance> extends Gtk.Widget
54
+ ? K
55
+ : never
56
+ : never]: JSX.IntrinsicElements[K] extends object
57
+ ? FunctionComponent<AnimatedProps<JSX.IntrinsicElements[K]>>
61
58
  : never;
62
59
  };
63
60
 
64
- export type { AnimatedComponent, AnimatedElements, AnimatedItems, AnimatedProp, AnimatedProps, AnimatedStyle };
61
+ export type {
62
+ AnimatedComponent,
63
+ AnimatedElementMap,
64
+ AnimatedItems,
65
+ AnimatedProp,
66
+ AnimatedProps,
67
+ AnimatedStyle,
68
+ };
@@ -17,7 +17,6 @@ import { trackReducedMotion } from "./reduced-motion.js";
17
17
 
18
18
  type AnimatedInput = { ref?: Ref<object> | undefined; [key: string]: unknown };
19
19
  type Wrappable = Exclude<ElementType, string>;
20
- type ObserverRef = { current: PropsObserver | null };
21
20
 
22
21
  const STYLE_PROP = "style";
23
22
  const cache: WeakMap<object, AnimatedComponent<Wrappable>> = new WeakMap();
@@ -142,19 +141,11 @@ const unobserve = (observer: PropsObserver): void => {
142
141
  };
143
142
 
144
143
  const useObserver = (observer: PropsObserver): void => {
145
- const observerRef: ObserverRef = useRef<PropsObserver | null>(null);
146
-
147
144
  useLayoutEffect(() => {
148
- observerRef.current = observer;
149
145
  observe(observer);
150
146
 
151
147
  return () => {
152
- if (observerRef.current === null) {
153
- return;
154
- }
155
-
156
- unobserve(observerRef.current);
157
- observerRef.current = null;
148
+ unobserve(observer);
158
149
  };
159
150
  });
160
151
  };