mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
24 lines
642 B
JavaScript
24 lines
642 B
JavaScript
/**
|
|
* @typedef {import("./IElement.js").default} IElement
|
|
* @typedef {new (...args) => IElement} ElementConstructor
|
|
*/
|
|
|
|
export default class ElementFactory {
|
|
|
|
/** @type {Map<String, ElementConstructor>} */
|
|
static #elementConstructors = new Map()
|
|
|
|
/**
|
|
* @param {String} tagName
|
|
* @param {ElementConstructor} entityConstructor
|
|
*/
|
|
static registerElement(tagName, entityConstructor) {
|
|
ElementFactory.#elementConstructors.set(tagName, entityConstructor)
|
|
}
|
|
|
|
/** @param {String} tagName */
|
|
static getConstructor(tagName) {
|
|
return ElementFactory.#elementConstructors.get(tagName)
|
|
}
|
|
}
|