@@ -1,10 +1,17 @@
|
||||
import type * as Godot from "godot"
|
||||
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 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>(
|
||||
class_: new (...args: any[]) => T
|
||||
|
||||
@@ -1,34 +1,25 @@
|
||||
import type * as Godot from "godot"
|
||||
import type { PascalToCamel } from "./utils.js"
|
||||
import type * as Component from "./Component.js"
|
||||
|
||||
|
||||
export type NodeClass = {
|
||||
[K in keyof typeof Godot]: typeof Godot[K] extends new (...args: any[]) => Godot.Node
|
||||
? K
|
||||
: never
|
||||
}[keyof typeof Godot]
|
||||
// export type NodeClass = {
|
||||
// [K in keyof typeof Godot]: typeof Godot[K] extends new (...args: any[]) => Godot.Node
|
||||
// ? K
|
||||
// : never
|
||||
// }[keyof typeof Godot]
|
||||
|
||||
export type GodotIntrinsicElements = {
|
||||
[K in NodeClass as PascalToCamel<K>]: React.JSX.IntrinsicAttributes & PropsFromInstance<InstanceType<(typeof Godot)[K]>>
|
||||
} & {
|
||||
element: {
|
||||
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]
|
||||
}
|
||||
// export type GodotIntrinsicElements = {
|
||||
// [K in NodeClass as PascalToCamel<K>]: Component.Props<InstanceType<(typeof Godot)[K]>>
|
||||
// } & {
|
||||
// element: {
|
||||
// class: new (...args: any[]) => Godot.Node
|
||||
// }
|
||||
// }
|
||||
|
||||
declare global {
|
||||
namespace React {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements extends GodotIntrinsicElements {}
|
||||
interface IntrinsicAttributes {
|
||||
children?: React.ReactNode
|
||||
name?: string
|
||||
}
|
||||
// interface IntrinsicElements extends GodotIntrinsicElements {}
|
||||
interface IntrinsicAttributes extends Component.InstrinsicAttributes {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user