This commit is contained in:
@@ -7,6 +7,7 @@ const VFlowContainer = Component.make(Godot.VFlowContainer)
|
||||
const Label = Component.make(Godot.Label)
|
||||
const TextEdit = Component.make(Godot.TextEdit)
|
||||
const Button = Component.make(Godot.Button)
|
||||
const Test = Component.
|
||||
|
||||
export function TestUi1Component() {
|
||||
const [text, setText] = useState("Default text")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"src/TestUi1.tscn": {};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import TestUi1 from "../../../src/TestUi1";
|
||||
declare module "godot" {
|
||||
interface ResourceTypes {
|
||||
"res://src/TestUi1.tscn": PackedScene<TestUi1>;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
declare module "godot" {
|
||||
interface SceneNodes {
|
||||
"src/TestUi2.tscn": {};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import TestUi2 from "../../../src/TestUi2";
|
||||
declare module "godot" {
|
||||
interface ResourceTypes {
|
||||
"res://src/TestUi2.tscn": PackedScene<TestUi2>;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,22 @@ export const make = <T extends Godot.Node<Godot.NodePathMap>>(
|
||||
Prototype,
|
||||
)
|
||||
|
||||
export declare namespace fromScene {
|
||||
export type SceneNames = {
|
||||
[K in keyof Godot.ResourceTypes]: Godot.ResourceTypes[K] extends Godot.PackedScene ? K : never
|
||||
}[keyof Godot.ResourceTypes]
|
||||
}
|
||||
|
||||
export const fromScene = <A extends fromScene.SceneNames>(
|
||||
name: A
|
||||
): Component<Godot.ResourceTypes[A]> => Object.setPrototypeOf(
|
||||
Object.assign(
|
||||
(props: Props<Godot.ResourceTypes[A]>) => React.createElement("element", { ...props }),
|
||||
{ displayName: name },
|
||||
),
|
||||
Prototype,
|
||||
)
|
||||
|
||||
export declare namespace useSignal {
|
||||
export type SignalNames<T extends Godot.Node<Godot.NodePathMap>> = {
|
||||
[K in keyof T & string]: T[K] extends Godot.Signal ? K : never
|
||||
@@ -49,10 +65,10 @@ export declare namespace useSignal {
|
||||
)
|
||||
}
|
||||
|
||||
export const useSignal = <T extends Godot.Node<Godot.NodePathMap>, N extends useSignal.SignalNames<T>>(
|
||||
export const useSignal = <T extends Godot.Node<Godot.NodePathMap>, A extends useSignal.SignalNames<T>>(
|
||||
ref: React.RefObject<T | null>,
|
||||
name: N,
|
||||
f: useSignal.Function<T, N>,
|
||||
name: A,
|
||||
f: useSignal.Function<T, A>,
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: "f" is non-reactive
|
||||
): void => React.useEffect(() => {
|
||||
if (!ref.current) return
|
||||
|
||||
@@ -31,5 +31,5 @@
|
||||
"sourceMap": true
|
||||
},
|
||||
|
||||
"include": ["./src", "./typings"]
|
||||
"include": ["./src", "./typings", "./gen"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user