@@ -19,7 +19,7 @@ export function TestUi1Component() {
|
|||||||
text="This is a label"
|
text="This is a label"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<node2D name="Issou" />
|
<GodotControl name="Issou" />
|
||||||
</GodotControl>
|
</GodotControl>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
import type * as Godot from "godot"
|
import type * as Godot from "godot"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import type * as JSX from "./JSX.js"
|
|
||||||
|
|
||||||
|
|
||||||
export type Props<T extends Godot.Node> = JSX.PropsFromInstance<T>
|
|
||||||
export type Component<T extends Godot.Node> = React.FunctionComponent<Props<T>>
|
export type Component<T extends Godot.Node> = React.FunctionComponent<Props<T>>
|
||||||
|
export type Props<T extends Godot.Node> = {
|
||||||
|
// biome-ignore lint/complexity/noBannedTypes: using Function here is completely fine
|
||||||
|
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InstrinsicAttributes {
|
||||||
|
readonly children?: React.ReactNode
|
||||||
|
readonly name?: string
|
||||||
|
}
|
||||||
|
|
||||||
export const make = <T extends Godot.Node>(
|
export const make = <T extends Godot.Node>(
|
||||||
class_: new (...args: any[]) => T
|
class_: new (...args: any[]) => T
|
||||||
|
|||||||
@@ -1,34 +1,25 @@
|
|||||||
import type * as Godot from "godot"
|
import type * as Component from "./Component.js"
|
||||||
import type { PascalToCamel } from "./utils.js"
|
|
||||||
|
|
||||||
|
|
||||||
export type NodeClass = {
|
// export type NodeClass = {
|
||||||
[K in keyof typeof Godot]: typeof Godot[K] extends new (...args: any[]) => Godot.Node
|
// [K in keyof typeof Godot]: typeof Godot[K] extends new (...args: any[]) => Godot.Node
|
||||||
? K
|
// ? K
|
||||||
: never
|
// : never
|
||||||
}[keyof typeof Godot]
|
// }[keyof typeof Godot]
|
||||||
|
|
||||||
export type GodotIntrinsicElements = {
|
// export type GodotIntrinsicElements = {
|
||||||
[K in NodeClass as PascalToCamel<K>]: React.JSX.IntrinsicAttributes & PropsFromInstance<InstanceType<(typeof Godot)[K]>>
|
// [K in NodeClass as PascalToCamel<K>]: Component.Props<InstanceType<(typeof Godot)[K]>>
|
||||||
} & {
|
// } & {
|
||||||
element: {
|
// element: {
|
||||||
class: new (...args: any[]) => Godot.Node
|
// class: new (...args: any[]) => Godot.Node
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
export type PropsFromInstance<T> = {
|
|
||||||
// biome-ignore lint/complexity/noBannedTypes: using Function here is completely fine
|
|
||||||
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
|
|
||||||
}
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace React {
|
namespace React {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
interface IntrinsicElements extends GodotIntrinsicElements {}
|
// interface IntrinsicElements extends GodotIntrinsicElements {}
|
||||||
interface IntrinsicAttributes {
|
interface IntrinsicAttributes extends Component.InstrinsicAttributes {}
|
||||||
children?: React.ReactNode
|
|
||||||
name?: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user