beginnings of new api

This commit is contained in:
MapleLeaf
2021-12-25 00:52:21 -06:00
parent fa95b42be6
commit e799e71f1a
9 changed files with 177 additions and 45 deletions

33
src.new/main.ts Normal file
View File

@@ -0,0 +1,33 @@
import type { CommandInteraction } from "discord.js"
import type { ReactNode } from "react"
import type { OpaqueRoot } from "react-reconciler"
import { reconciler } from "./reconciler.js"
import { RootNode } from "./root-node.js"
export class InstanceManager {
private instances = new Set<Instance>()
create(interaction: CommandInteraction) {
const instance = new Instance(interaction)
this.instances.add(instance)
return instance
}
destroy(instance: Instance) {
this.instances.delete(instance)
}
}
class Instance {
private rootNode: RootNode
private container: OpaqueRoot
constructor(interaction: CommandInteraction) {
this.rootNode = new RootNode(interaction)
this.container = reconciler.createContainer(this.rootNode, 0, false, {})
}
render(content: ReactNode) {
reconciler.updateContainer(content, this.container)
}
}