Skip to content

Commit 0e7c26e

Browse files
authored
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
1 parent b21eb45 commit 0e7c26e

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

packages/core/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
export * from "./application/nanoforge-factory";
2+
3+
export type { NanoforgeClient } from "./application/nanoforge-client";
4+
export type { NanoforgeServer } from "./application/nanoforge-server";
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/**
2+
* * Editor Component Element Defaults
3+
* Basic fields for Editor Component Element
4+
* @param Type - Type of the element
5+
* @param Default - Type of the element's default value
6+
*/
7+
type ECElementDefaults<Type, Default> = {
8+
/**
9+
* Type of the element
10+
*/
11+
type: Type;
12+
13+
/**
14+
* Name of the element
15+
*/
16+
name: string;
17+
18+
/**
19+
* Description of the element
20+
*/
21+
description?: string;
22+
23+
/**
24+
* Example of the element
25+
*/
26+
example?: Default;
27+
28+
/**
29+
* Is the element optional
30+
* @default false
31+
*/
32+
optional?: boolean;
33+
34+
/**
35+
* Default value of the element
36+
* Force optional to true if set
37+
*/
38+
default?: Default;
39+
};
40+
41+
/**
42+
* * Editor Component String Element
43+
* Type for string element
44+
*/
45+
type ECStringElement = {
46+
/**
47+
* Values allowed for the element
48+
*/
49+
enum?: string[];
50+
} & ECElementDefaults<"string", string>;
51+
52+
/**
53+
* * Editor Component Number Element
54+
* Type for number element
55+
*/
56+
type ECNumberElement = ECElementDefaults<"number", number>;
57+
58+
/**
59+
* * Editor Component Boolean Element
60+
* Type for boolean element
61+
*/
62+
type ECBooleanElement = ECElementDefaults<"boolean", boolean>;
63+
64+
/**
65+
* * Editor Component Array Element
66+
* Type for array element
67+
*/
68+
type ECArrayElement = {
69+
/**
70+
* Items of the array
71+
*/
72+
items: ECElement;
73+
} & ECElementDefaults<"array", any[]>;
74+
75+
/**
76+
* * Editor Component Object Element
77+
* Type for object element
78+
*/
79+
type ECObjectElement = {
80+
/**
81+
* Properties of the object
82+
*/
83+
properties: Record<string, ECElement>;
84+
} & ECElementDefaults<"object", object>;
85+
86+
/**
87+
* * Editor Component Element
88+
* Type for component element
89+
*/
90+
type ECElement =
91+
| ECStringElement
92+
| ECNumberElement
93+
| ECBooleanElement
94+
| ECArrayElement
95+
| ECObjectElement;
96+
97+
/**
98+
* Manifest for a component to be used in the NanoForge Editor
99+
*/
100+
export type EditorComponentManifest = {
101+
/**
102+
* Displayed name of the component
103+
*/
104+
name: string;
105+
106+
/**
107+
* Description of the component
108+
*/
109+
description?: string;
110+
111+
/**
112+
* Parameters of the component
113+
*/
114+
params: Record<string, ECElement>;
115+
};
116+
117+
/**
118+
* Manifest for a system to be used in the NanoForge Editor
119+
*/
120+
export type EditorSystemManifest = {
121+
/**
122+
* Displayed name of the system
123+
*/
124+
name: string;
125+
126+
/**
127+
* Description of the system
128+
*/
129+
description?: string;
130+
131+
/**
132+
* Component names needed by the system
133+
*/
134+
dependencies: string[];
135+
};

packages/ecs/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ import "../lib/libecs.wasm";
22

33
export { ECSLibrary } from "./ecs-library";
44
export type { Component, System, Registry } from "../lib";
5+
export type * from "./editor-manifest.type";

0 commit comments

Comments
 (0)