@@ -5,7 +5,6 @@ import { camelToSnake, hasProperty, snakeToPascal } from "./utils.js"
|
|||||||
|
|
||||||
const DefaultEventPriority = 32
|
const DefaultEventPriority = 32
|
||||||
|
|
||||||
|
|
||||||
export const make = () => {
|
export const make = () => {
|
||||||
let eventTime = 0
|
let eventTime = 0
|
||||||
let currentPriority = DefaultEventPriority
|
let currentPriority = DefaultEventPriority
|
||||||
@@ -85,7 +84,7 @@ export const make = () => {
|
|||||||
resetAfterCommit() {},
|
resetAfterCommit() {},
|
||||||
|
|
||||||
getRootHostContext() {
|
getRootHostContext() {
|
||||||
return {};
|
return {}
|
||||||
},
|
},
|
||||||
|
|
||||||
getChildHostContext(parentHostContext, _type, _rootContainer) {
|
getChildHostContext(parentHostContext, _type, _rootContainer) {
|
||||||
@@ -141,6 +140,58 @@ export const make = () => {
|
|||||||
noTimeout: -1,
|
noTimeout: -1,
|
||||||
|
|
||||||
isPrimaryRenderer: true,
|
isPrimaryRenderer: true,
|
||||||
|
supportsPersistence: false,
|
||||||
|
|
||||||
|
preparePortalMount(_containerInfo) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
getInstanceFromNode(_node) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
beforeActiveInstanceBlur() {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
afterActiveInstanceBlur() {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
prepareScopeUpdate(_scopeInstance, _instance) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
getInstanceFromScope(_scopeInstance) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
detachDeletedInstance(_node) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
|
||||||
|
supportsHydration: false,
|
||||||
|
NotPendingTransition: undefined,
|
||||||
|
HostTransitionContext: undefined as any,
|
||||||
|
|
||||||
|
resetFormInstance(_form) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
requestPostPaintCallback(_callback: (time: number) => void) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
shouldAttemptEagerTransition: (): boolean => {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
maySuspendCommit(_type, _props) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
preloadInstance(_type, _props) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
startSuspendingCommit() {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
suspendInstance(_type, _props) {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
|
waitForCommitToBeReady() {
|
||||||
|
throw new Error("Function not implemented.")
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
packages/react-godot-renderer/src/Renderer.ts
Normal file
27
packages/react-godot-renderer/src/Renderer.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import type { Node, NodePathMap } from "godot"
|
||||||
|
import * as Reconciler from "./Reconciler.js"
|
||||||
|
|
||||||
|
|
||||||
|
const ConcurrentRoot = 1
|
||||||
|
|
||||||
|
export const render = (element: React.ReactNode, container: Node<NodePathMap>, callback?: () => void): number => {
|
||||||
|
const reconciler = Reconciler.make()
|
||||||
|
|
||||||
|
if (!(container as any)._rootContainer)
|
||||||
|
(container as any)._rootContainer = (reconciler as any).createContainer(
|
||||||
|
container,
|
||||||
|
ConcurrentRoot,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
console.error,
|
||||||
|
)
|
||||||
|
|
||||||
|
return reconciler.updateContainer(
|
||||||
|
element,
|
||||||
|
(container as any)._rootContainer,
|
||||||
|
null,
|
||||||
|
callback,
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export * from "./jsx.js"
|
||||||
|
export * as Reconciler from "./Reconciler.js"
|
||||||
|
export * as Renderer from "./Renderer.js"
|
||||||
|
|||||||
31
packages/react-godot-renderer/src/jsx.ts
Normal file
31
packages/react-godot-renderer/src/jsx.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import type * as Godot from "godot"
|
||||||
|
|
||||||
|
|
||||||
|
type NodeClass = {
|
||||||
|
[K in keyof typeof Godot]: typeof Godot[K] extends new (...args: any[]) => Godot.Node
|
||||||
|
? K
|
||||||
|
: never
|
||||||
|
}[keyof typeof Godot]
|
||||||
|
|
||||||
|
type DecapitalizeString<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S
|
||||||
|
|
||||||
|
type PropsFromInstance<T> = {
|
||||||
|
// biome-ignore lint/complexity/noBannedTypes: it's completely fine
|
||||||
|
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
|
||||||
|
}
|
||||||
|
|
||||||
|
type GodotIntrinsicElements = {
|
||||||
|
[K in NodeClass as DecapitalizeString<K>]: PropsFromInstance<InstanceType<(typeof Godot)[K]>>
|
||||||
|
} & {
|
||||||
|
custom: {
|
||||||
|
class: new (...args: any[]) => Godot.Node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// declare global {
|
||||||
|
declare namespace React {
|
||||||
|
namespace JSX {
|
||||||
|
interface IntrinsicElements extends GodotIntrinsicElements {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }
|
||||||
Reference in New Issue
Block a user