@ringozz/react-godot 4.7.2-570 → 4.7.2-579

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/react-types.ts +27 -9
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ringozz/react-godot",
3
3
  "author": "Vladimir Davidovich",
4
- "version": "4.7.2-570",
4
+ "version": "4.7.2-579",
5
5
  "description": "A React renderer for Godot Engine via @ringozz/godot",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -23,7 +23,7 @@
23
23
  "*.md"
24
24
  ],
25
25
  "dependencies": {
26
- "@ringozz/godot": "^4.7.2-570",
26
+ "@ringozz/godot": "^4.7.2-579",
27
27
  "@types/react-reconciler": "^0.33.0",
28
28
  "react-reconciler": "^0.33.0"
29
29
  },
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type React from 'react';
6
6
  import type { Object } from '@ringozz/godot/Object';
7
- import type { Signal, ValueTypes } from '@ringozz/godot';
7
+ import type { Signal, ValueTypes, GodotDictionary } from '@ringozz/godot';
8
8
  import type { PackedScene } from '@ringozz/godot/PackedScene';
9
9
 
10
10
  // Identity check sensitive to readonly (deferred-conditional trick; the
@@ -37,15 +37,33 @@ type SettableKey<T, K extends keyof T> =
37
37
  ? (T[K] extends Function ? never : K)
38
38
  : never;
39
39
 
40
- // JSX props are settable instance members, typed as the setter accepts them:
41
- // ValueTypes also accept JSX arrays, and signals (getter `Signal<CB>`, setter
42
- // `CB | null`) take the callback directly. Maps over `keyof T` (homomorphic)
43
- // so optional/readonly modifiers survive.
40
+ // Container props accept plain JS forms: JSX values flow through
41
+ // `Instance.assign` (`napi_to_variant_typed`), which builds packed arrays,
42
+ // Godot `Array`s, and `Dictionary`s from JS arrays/objects. Only gen heap
43
+ // containers (10 packed + `GodotArray` + `GodotDictionary`) implement
44
+ // `Iterable`, so that is the gate; `get(index: number)` recovers the concrete
45
+ // element type (packed class getters return it even though the class generic
46
+ // defaults to `any`). Scalar-packed -> `number[]`/`string[]`; element-packed
47
+ // -> `(E | number[])[]` (instances or value-type tuples); `GodotArray<E>` ->
48
+ // `(E | number[])[]`; `GodotDictionary<K,V>` -> `Record<string, V>`.
49
+ type ContainerForm<T> =
50
+ T extends GodotDictionary<any, infer V> ? Record<string, V>
51
+ : T extends { get(index: number): infer E } ? (E extends number | string ? E[] : (E | number[])[])
52
+ : T extends Iterable<infer E> ? E[]
53
+ : never;
54
+
55
+ // JSX props are settable instance members, typed as the reconciler's
56
+ // `Instance.assign` accepts them: ValueTypes also accept JSX arrays, signals
57
+ // (getter `Signal<CB>`, setter `CB | null`) take the callback directly, and
58
+ // containers accept plain JS arrays/objects. Maps over `keyof T`
59
+ // (homomorphic) so optional/readonly modifiers survive.
44
60
  type Properties<T> = {
45
- [K in keyof T as SettableKey<T, K>]:
46
- T[K] extends ValueTypes ? T[K] | number[]
47
- : T[K] extends Signal<infer CB> ? CB | null
48
- : T[K];
61
+ [K in keyof T as SettableKey<T, K>]:
62
+ T[K] extends ValueTypes ? T[K] | number[]
63
+ : T[K] extends Signal<infer CB> ? CB | null
64
+ : T[K] extends GodotDictionary<any, any> ? T[K] | ContainerForm<T[K]>
65
+ : T[K] extends Iterable<unknown> ? T[K] | ContainerForm<T[K]>
66
+ : T[K];
49
67
  };
50
68
 
51
69
  export type ComponentProps<T extends GodotConstructor, P extends Instance = InstanceType<T>> =