From 9e6c5a5abc14223fd0ba4468cb03cbe3a64a8c6e Mon Sep 17 00:00:00 2001 From: Exelo Date: Sat, 29 Nov 2025 10:41:02 +0100 Subject: [PATCH 1/2] feat: add schematics used types (#102) * feat(ecs): add types for NanoForge Editor * feat(core): add types for init functions in schematics * docs(ecs): add `params` and `dependencies` fields doc * feat(ecs): extend ECElement type with `name`, `description`, `example`, and updated `params` def * feat(ecs): add `name` and `description` fields to Editor manifests --- packages/core/src/index.ts | 3 + packages/ecs/src/editor-manifest.type.ts | 135 +++++++++++++++++++++++ packages/ecs/src/index.ts | 1 + 3 files changed, 139 insertions(+) create mode 100644 packages/ecs/src/editor-manifest.type.ts 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"; From 2c70b310d4458029c73bc19c790690891be5f42c Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Mon, 1 Dec 2025 20:05:09 +0100 Subject: [PATCH 2/2] fix(input): initialized input handler record to prevent undefined --- packages/input/src/input-handler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 {