diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 2931fb74..4273d62e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1 +1,4 @@ export * from "./application/nanoforge-factory"; + +export type { NanoforgeClient } from "./application/nanoforge-client"; +export type { NanoforgeServer } from "./application/nanoforge-server"; diff --git a/packages/ecs/src/editor-manifest.type.ts b/packages/ecs/src/editor-manifest.type.ts new file mode 100644 index 00000000..73cf0e60 --- /dev/null +++ b/packages/ecs/src/editor-manifest.type.ts @@ -0,0 +1,135 @@ +/** + * * Editor Component Element Defaults + * Basic fields for Editor Component Element + * @param Type - Type of the element + * @param Default - Type of the element's default value + */ +type ECElementDefaults = { + /** + * Type of the element + */ + type: Type; + + /** + * Name of the element + */ + name: string; + + /** + * Description of the element + */ + description?: string; + + /** + * Example of the element + */ + example?: Default; + + /** + * Is the element optional + * @default false + */ + optional?: boolean; + + /** + * Default value of the element + * Force optional to true if set + */ + default?: Default; +}; + +/** + * * Editor Component String Element + * Type for string element + */ +type ECStringElement = { + /** + * Values allowed for the element + */ + enum?: string[]; +} & ECElementDefaults<"string", string>; + +/** + * * Editor Component Number Element + * Type for number element + */ +type ECNumberElement = ECElementDefaults<"number", number>; + +/** + * * Editor Component Boolean Element + * Type for boolean element + */ +type ECBooleanElement = ECElementDefaults<"boolean", boolean>; + +/** + * * Editor Component Array Element + * Type for array element + */ +type ECArrayElement = { + /** + * Items of the array + */ + items: ECElement; +} & ECElementDefaults<"array", any[]>; + +/** + * * Editor Component Object Element + * Type for object element + */ +type ECObjectElement = { + /** + * Properties of the object + */ + properties: Record; +} & ECElementDefaults<"object", object>; + +/** + * * Editor Component Element + * Type for component element + */ +type ECElement = + | ECStringElement + | ECNumberElement + | ECBooleanElement + | ECArrayElement + | ECObjectElement; + +/** + * Manifest for a component to be used in the NanoForge Editor + */ +export type EditorComponentManifest = { + /** + * Displayed name of the component + */ + name: string; + + /** + * Description of the component + */ + description?: string; + + /** + * Parameters of the component + */ + params: Record; +}; + +/** + * Manifest for a system to be used in the NanoForge Editor + */ +export type EditorSystemManifest = { + /** + * Displayed name of the system + */ + name: string; + + /** + * Description of the system + */ + description?: string; + + /** + * Component names needed by the system + */ + dependencies: string[]; +}; diff --git a/packages/ecs/src/index.ts b/packages/ecs/src/index.ts index dc434f7f..8bc56f55 100644 --- a/packages/ecs/src/index.ts +++ b/packages/ecs/src/index.ts @@ -2,3 +2,4 @@ import "../lib/libecs.wasm"; export { ECSLibrary } from "./ecs-library"; export type { Component, System, Registry } from "../lib"; +export type * from "./editor-manifest.type"; diff --git a/packages/input/src/input-handler.ts b/packages/input/src/input-handler.ts index 56416b01..8002b642 100644 --- a/packages/input/src/input-handler.ts +++ b/packages/input/src/input-handler.ts @@ -1,4 +1,4 @@ -import { type InputEnum } from "./input.enum"; +import { InputEnum } from "./input.enum"; export class InputHandler { public inputs: Record = {}; @@ -11,6 +11,10 @@ export class InputHandler { window.addEventListener("keyup", (e: KeyboardEvent) => { this.inputs[e.code] = false; }); + + for (const key in InputEnum) { + this.inputs[key] = false; + } } getKeyStatus(key: InputEnum): boolean {