Library work
Some checks failed
Lint / lint (push) Failing after 10s

This commit is contained in:
Julien Valverdé
2025-12-28 22:04:37 +01:00
parent 446dbc1cc7
commit 0c642b655e
4 changed files with 114 additions and 2 deletions

View File

@@ -5,7 +5,6 @@ import { camelToSnake, hasProperty, snakeToPascal } from "./utils.js"
const DefaultEventPriority = 32
export const make = () => {
let eventTime = 0
let currentPriority = DefaultEventPriority
@@ -85,7 +84,7 @@ export const make = () => {
resetAfterCommit() {},
getRootHostContext() {
return {};
return {}
},
getChildHostContext(parentHostContext, _type, _rootContainer) {
@@ -141,6 +140,58 @@ export const make = () => {
noTimeout: -1,
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.")
},
})
}

View 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,
)
}

View File

@@ -0,0 +1,3 @@
export * from "./jsx.js"
export * as Reconciler from "./Reconciler.js"
export * as Renderer from "./Renderer.js"

View 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 {}
}
}
// }