@nanoforge-dev/schematics 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collection.json +14 -4
- package/dist/libs/application/files/js/package.json +9 -1
- package/dist/libs/application/files/ts/package.json +9 -1
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/client.save.json +69 -0
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/server.save.json +41 -0
- package/dist/libs/part-base/files/js/__part__/components/example.component.js +72 -0
- package/dist/libs/part-base/files/js/__part__/init/after-init.js +12 -0
- package/dist/libs/part-base/files/js/__part__/init/after-registry-init.js +14 -0
- package/dist/libs/part-base/files/js/__part__/init/after-run.js +12 -0
- package/dist/libs/part-base/files/js/__part__/init/before-init.js +13 -0
- package/dist/libs/part-base/files/js/__part__/init/before-registry-init.js +14 -0
- package/dist/libs/part-base/files/js/__part__/init/before-run.js +12 -0
- package/dist/libs/part-base/files/js/__part__/systems/example.system.js +44 -0
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/client.save.json +69 -0
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/server.save.json +41 -0
- package/dist/libs/part-base/files/ts/__part__/components/example.component.ts +55 -0
- package/dist/libs/part-base/files/ts/__part__/init/after-init.ts +5 -0
- package/dist/libs/part-base/files/ts/__part__/init/after-registry-init.ts +6 -0
- package/dist/libs/part-base/files/ts/__part__/init/after-run.ts +5 -0
- package/dist/libs/part-base/files/ts/__part__/init/before-init.ts +5 -0
- package/dist/libs/part-base/files/ts/__part__/init/before-registry-init.ts +6 -0
- package/dist/libs/part-base/files/ts/__part__/init/before-run.ts +5 -0
- package/dist/libs/part-base/files/ts/__part__/systems/example.system.ts +31 -0
- package/dist/libs/part-base/part-base.factory.d.ts +32 -0
- package/dist/libs/part-base/part-base.factory.js +71 -0
- package/dist/libs/part-base/part-base.factory.js.map +1 -0
- package/dist/libs/part-base/schema.json +38 -0
- package/dist/libs/part-main/part-main.factory.d.ts +37 -0
- package/dist/libs/part-main/part-main.factory.js +224 -0
- package/dist/libs/part-main/part-main.factory.js.map +1 -0
- package/dist/libs/part-main/schema.json +42 -0
- package/package.json +12 -10
package/dist/collection.json
CHANGED
|
@@ -2,14 +2,24 @@
|
|
|
2
2
|
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
3
|
"schematics": {
|
|
4
4
|
"application": {
|
|
5
|
-
"factory": "./
|
|
5
|
+
"factory": "./libs/application/application.factory#main",
|
|
6
6
|
"description": "Create a NanoForge Base application.",
|
|
7
|
-
"schema": "./
|
|
7
|
+
"schema": "./libs/application/schema.json"
|
|
8
8
|
},
|
|
9
9
|
"configuration": {
|
|
10
|
-
"factory": "./
|
|
10
|
+
"factory": "./libs/configuration/configuration.factory#main",
|
|
11
11
|
"description": "Create a NanoForge Configuration.",
|
|
12
|
-
"schema": "./
|
|
12
|
+
"schema": "./libs/configuration/schema.json"
|
|
13
|
+
},
|
|
14
|
+
"part-base": {
|
|
15
|
+
"factory": "./libs/part-base/part-base.factory#main",
|
|
16
|
+
"description": "Create a NanoForge Base for client or server.",
|
|
17
|
+
"schema": "./libs/part-base/schema.json"
|
|
18
|
+
},
|
|
19
|
+
"part-main": {
|
|
20
|
+
"factory": "./libs/part-main/part-main.factory#main",
|
|
21
|
+
"description": "Create a Main file for client or server.",
|
|
22
|
+
"schema": "./libs/part-main/schema.json"
|
|
13
23
|
}
|
|
14
24
|
}
|
|
15
25
|
}
|
|
@@ -9,10 +9,18 @@
|
|
|
9
9
|
"lint": "prettier --check . && eslint --format=pretty \"{client,server}/**/*.js\"",
|
|
10
10
|
"format": "prettier --write . && eslint --fix --format=pretty \"{client,server}/**/*.js\""
|
|
11
11
|
},
|
|
12
|
-
"dependencies": {},
|
|
13
12
|
"devDependencies": {
|
|
14
13
|
"@eslint/js": "^9.39.0",
|
|
14
|
+
"@nanoforge-dev/asset-manager": "^0.0.1",
|
|
15
15
|
"@nanoforge-dev/cli": "^0.0.1",
|
|
16
|
+
"@nanoforge-dev/common": "^0.0.1",
|
|
17
|
+
"@nanoforge-dev/config": "^0.0.1",
|
|
18
|
+
"@nanoforge-dev/core": "^0.0.1",
|
|
19
|
+
"@nanoforge-dev/ecs": "^0.0.1",
|
|
20
|
+
"@nanoforge-dev/graphics-2d": "^0.0.1",
|
|
21
|
+
"@nanoforge-dev/input": "^0.0.1",
|
|
22
|
+
"@nanoforge-dev/music": "^0.0.1",
|
|
23
|
+
"@nanoforge-dev/sound": "^0.0.1",
|
|
16
24
|
"eslint": "^9.39.0",
|
|
17
25
|
"eslint-config-prettier": "^10.1.8",
|
|
18
26
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -9,10 +9,18 @@
|
|
|
9
9
|
"lint": "prettier --check . && eslint --format=pretty \"{client,server}/**/*.ts\"",
|
|
10
10
|
"format": "prettier --write . && eslint --fix --format=pretty \"{client,server}/**/*.ts\""
|
|
11
11
|
},
|
|
12
|
-
"dependencies": {},
|
|
13
12
|
"devDependencies": {
|
|
14
13
|
"@eslint/js": "^9.39.0",
|
|
14
|
+
"@nanoforge-dev/asset-manager": "^0.0.1",
|
|
15
15
|
"@nanoforge-dev/cli": "^0.0.1",
|
|
16
|
+
"@nanoforge-dev/common": "^0.0.1",
|
|
17
|
+
"@nanoforge-dev/config": "^0.0.1",
|
|
18
|
+
"@nanoforge-dev/core": "^0.0.1",
|
|
19
|
+
"@nanoforge-dev/ecs": "^0.0.1",
|
|
20
|
+
"@nanoforge-dev/graphics-2d": "^0.0.1",
|
|
21
|
+
"@nanoforge-dev/input": "^0.0.1",
|
|
22
|
+
"@nanoforge-dev/music": "^0.0.1",
|
|
23
|
+
"@nanoforge-dev/sound": "^0.0.1",
|
|
16
24
|
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
17
25
|
"@typescript-eslint/parser": "^8.46.2",
|
|
18
26
|
"eslint": "^9.39.0",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"libraries": [
|
|
3
|
+
{
|
|
4
|
+
"id": "assetManagerLibrary",
|
|
5
|
+
"type": "asset-manager",
|
|
6
|
+
"name": "AssetManagerLibrary",
|
|
7
|
+
"path": "@nanoforge-dev/asset-manager",
|
|
8
|
+
"params": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "ecsLibrary",
|
|
12
|
+
"type": "component-system",
|
|
13
|
+
"name": "ECSLibrary",
|
|
14
|
+
"path": "@nanoforge-dev/ecs",
|
|
15
|
+
"params": ["\"client\""]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "graphicsLibrary",
|
|
19
|
+
"type": "graphics",
|
|
20
|
+
"name": "Graphics2DLibrary",
|
|
21
|
+
"path": "@nanoforge-dev/graphics-2d",
|
|
22
|
+
"params": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "inputLibrary",
|
|
26
|
+
"type": "input",
|
|
27
|
+
"name": "InputLibrary",
|
|
28
|
+
"path": "@nanoforge-dev/input",
|
|
29
|
+
"params": []
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "musicLibrary",
|
|
33
|
+
"type": "music",
|
|
34
|
+
"name": "MusicLibrary",
|
|
35
|
+
"path": "@nanoforge-dev/music",
|
|
36
|
+
"params": []
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "soundLibrary",
|
|
40
|
+
"type": "sound",
|
|
41
|
+
"name": "SoundLibrary",
|
|
42
|
+
"path": "@nanoforge-dev/sound",
|
|
43
|
+
"params": []
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"components": [
|
|
47
|
+
{
|
|
48
|
+
"name": "ExampleComponent",
|
|
49
|
+
"path": "./components/example.component"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"systems": [
|
|
53
|
+
{
|
|
54
|
+
"name": "exampleSystem",
|
|
55
|
+
"path": "./systems/example.system"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"entities": [
|
|
59
|
+
{
|
|
60
|
+
"id": "exampleEntity",
|
|
61
|
+
"components": [
|
|
62
|
+
{
|
|
63
|
+
"name": "ExampleComponent",
|
|
64
|
+
"params": ["\"example\"", "10"]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"libraries": [
|
|
3
|
+
{
|
|
4
|
+
"id": "assetManagerLibrary",
|
|
5
|
+
"type": "asset-manager",
|
|
6
|
+
"name": "AssetManagerLibrary",
|
|
7
|
+
"path": "@nanoforge-dev/asset-manager",
|
|
8
|
+
"params": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "ecsLibrary",
|
|
12
|
+
"type": "component-system",
|
|
13
|
+
"name": "ECSLibrary",
|
|
14
|
+
"path": "@nanoforge-dev/ecs",
|
|
15
|
+
"params": ["\"server\""]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"components": [
|
|
19
|
+
{
|
|
20
|
+
"name": "ExampleComponent",
|
|
21
|
+
"path": "./components/example.component"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"systems": [
|
|
25
|
+
{
|
|
26
|
+
"name": "exampleSystem",
|
|
27
|
+
"path": "./systems/example.system"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"entities": [
|
|
31
|
+
{
|
|
32
|
+
"id": "exampleEntity",
|
|
33
|
+
"components": [
|
|
34
|
+
{
|
|
35
|
+
"name": "ExampleComponent",
|
|
36
|
+
"params": ["\"example\"", "10"]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/ecs").EditorComponentManifest} EditorComponentManifest
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export class ExampleComponent {
|
|
6
|
+
static name = "ExampleComponent";
|
|
7
|
+
name = this.constructor.name;
|
|
8
|
+
|
|
9
|
+
paramA;
|
|
10
|
+
paramB;
|
|
11
|
+
paramC;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Example component constructor
|
|
15
|
+
* @param {string} paramA
|
|
16
|
+
* @param {number} paramB
|
|
17
|
+
* @param {boolean} [paramC = false]
|
|
18
|
+
*/
|
|
19
|
+
constructor(paramA, paramB, paramC = false) {
|
|
20
|
+
this.paramA = paramA;
|
|
21
|
+
this.paramB = paramB;
|
|
22
|
+
this.paramC = paramC;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get foo() {
|
|
26
|
+
return "bar";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get paramAOrDefault() {
|
|
30
|
+
return this.paramC ? this.paramA : "default";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addOne() {
|
|
34
|
+
this.paramB += 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// * Required to generate code
|
|
39
|
+
export default ExampleComponent.name;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Editor component manifest
|
|
43
|
+
* * Required for the editor to display the component and generate code
|
|
44
|
+
* @type {EditorComponentManifest}
|
|
45
|
+
*/
|
|
46
|
+
export const EDITOR_COMPONENT_MANIFEST = {
|
|
47
|
+
name: "Example",
|
|
48
|
+
description: "Example component description",
|
|
49
|
+
params: {
|
|
50
|
+
paramA: {
|
|
51
|
+
type: "string",
|
|
52
|
+
name: "Param A",
|
|
53
|
+
description: "Param A description",
|
|
54
|
+
example: "Example value",
|
|
55
|
+
},
|
|
56
|
+
paramB: {
|
|
57
|
+
type: "number",
|
|
58
|
+
name: "Param B",
|
|
59
|
+
description: "Param B description",
|
|
60
|
+
example: 3,
|
|
61
|
+
},
|
|
62
|
+
paramC: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
name: "Param C",
|
|
65
|
+
description: "Param C description",
|
|
66
|
+
example: true,
|
|
67
|
+
default: false,
|
|
68
|
+
// Not required because it has a default value
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Actions that are executed after the application initialization
|
|
7
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export async function afterInit(app) {
|
|
11
|
+
// Actions after app initialization
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
* @typedef {import("@nanoforge-dev/ecs").Registry} Registry
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Actions that are executed after the registry components, entities and systems initialization
|
|
8
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
9
|
+
* @param {Registry} registry - ECS registry instance
|
|
10
|
+
* @returns {Promise<void>}
|
|
11
|
+
*/
|
|
12
|
+
export async function afterRegistryInit(app, registry) {
|
|
13
|
+
// Actions after registry components, entities and systems initialization
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Actions that are executed when the application ended
|
|
7
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export async function afterRun(app) {
|
|
11
|
+
// Actions after app ended
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Actions that are executed before the application initialization
|
|
7
|
+
* But are executed after base libraries addition
|
|
8
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
export async function beforeInit(app) {
|
|
12
|
+
// Actions before app initialization
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
* @typedef {import("@nanoforge-dev/ecs").Registry} Registry
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Actions that are executed before the registry components, entities and systems initialization
|
|
8
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
9
|
+
* @param {Registry} registry - ECS registry instance
|
|
10
|
+
* @returns {Promise<void>}
|
|
11
|
+
*/
|
|
12
|
+
export async function beforeRegistryInit(app, registry) {
|
|
13
|
+
// Actions before registry components, entities and systems initialization
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/core").<%= appClass %>} <%= appClass %>
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Actions that are executed before the application started
|
|
7
|
+
* @param {<%= appClass %>} app - Nanoforge <%= part %> instance
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export async function beforeRun(app) {
|
|
11
|
+
// Actions before app started
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("@nanoforge-dev/common").Context} Context
|
|
3
|
+
* @typedef {import("@nanoforge-dev/ecs").EditorSystemManifest} EditorSystemManifest
|
|
4
|
+
* @typedef {import("@nanoforge-dev/ecs").Registry} Registry
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ExampleComponent } from "../components/example.component";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Example system
|
|
11
|
+
* This system end the game when paramB reaches 0 for any entity with ExampleComponent
|
|
12
|
+
* @param {Registry} registry - ECS registry instance
|
|
13
|
+
* @param {Context} ctx - Nanoforge <%= part %> instance
|
|
14
|
+
*/
|
|
15
|
+
export const exampleSystem = (registry: Registry, ctx: Context) => {
|
|
16
|
+
const entities = registry.getZipper([ExampleComponent]);
|
|
17
|
+
|
|
18
|
+
entities.forEach((entity) => {
|
|
19
|
+
if (entity.ExampleComponent.paramA === "end") {
|
|
20
|
+
ctx.app.setIsRunning(false);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (entity.ExampleComponent.paramB === 0) entity.ExampleComponent.paramA = "end";
|
|
25
|
+
|
|
26
|
+
if (entity.ExampleComponent.paramB >= 0)
|
|
27
|
+
entity.ExampleComponent.paramB = entity.ExampleComponent.paramB - 1;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// * Required to generate code
|
|
32
|
+
export default exampleSystem.name;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Editor component manifest
|
|
36
|
+
* * Required for the editor to display the system and generate code
|
|
37
|
+
* @type {EditorSystemManifest}
|
|
38
|
+
*/
|
|
39
|
+
export const EDITOR_SYSTEM_MANIFEST = {
|
|
40
|
+
name: "Example",
|
|
41
|
+
description:
|
|
42
|
+
"This system end the game when paramB reaches 0 for any entity with ExampleComponent",
|
|
43
|
+
dependencies: ["ExampleComponent"],
|
|
44
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"libraries": [
|
|
3
|
+
{
|
|
4
|
+
"id": "assetManagerLibrary",
|
|
5
|
+
"type": "asset-manager",
|
|
6
|
+
"name": "AssetManagerLibrary",
|
|
7
|
+
"path": "@nanoforge-dev/asset-manager",
|
|
8
|
+
"params": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "ecsLibrary",
|
|
12
|
+
"type": "component-system",
|
|
13
|
+
"name": "ECSLibrary",
|
|
14
|
+
"path": "@nanoforge-dev/ecs",
|
|
15
|
+
"params": ["\"client\""]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "graphicsLibrary",
|
|
19
|
+
"type": "graphics",
|
|
20
|
+
"name": "Graphics2DLibrary",
|
|
21
|
+
"path": "@nanoforge-dev/graphics-2d",
|
|
22
|
+
"params": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "inputLibrary",
|
|
26
|
+
"type": "input",
|
|
27
|
+
"name": "InputLibrary",
|
|
28
|
+
"path": "@nanoforge-dev/input",
|
|
29
|
+
"params": []
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "musicLibrary",
|
|
33
|
+
"type": "music",
|
|
34
|
+
"name": "MusicLibrary",
|
|
35
|
+
"path": "@nanoforge-dev/music",
|
|
36
|
+
"params": []
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "soundLibrary",
|
|
40
|
+
"type": "sound",
|
|
41
|
+
"name": "SoundLibrary",
|
|
42
|
+
"path": "@nanoforge-dev/sound",
|
|
43
|
+
"params": []
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"components": [
|
|
47
|
+
{
|
|
48
|
+
"name": "ExampleComponent",
|
|
49
|
+
"path": "./components/example.component"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"systems": [
|
|
53
|
+
{
|
|
54
|
+
"name": "exampleSystem",
|
|
55
|
+
"path": "./systems/example.system"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"entities": [
|
|
59
|
+
{
|
|
60
|
+
"id": "exampleEntity",
|
|
61
|
+
"components": [
|
|
62
|
+
{
|
|
63
|
+
"name": "ExampleComponent",
|
|
64
|
+
"params": ["\"example\"", "10"]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"libraries": [
|
|
3
|
+
{
|
|
4
|
+
"id": "assetManagerLibrary",
|
|
5
|
+
"type": "asset-manager",
|
|
6
|
+
"name": "AssetManagerLibrary",
|
|
7
|
+
"path": "@nanoforge-dev/asset-manager",
|
|
8
|
+
"params": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "ecsLibrary",
|
|
12
|
+
"type": "component-system",
|
|
13
|
+
"name": "ECSLibrary",
|
|
14
|
+
"path": "@nanoforge-dev/ecs",
|
|
15
|
+
"params": ["\"server\""]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"components": [
|
|
19
|
+
{
|
|
20
|
+
"name": "ExampleComponent",
|
|
21
|
+
"path": "./components/example.component"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"systems": [
|
|
25
|
+
{
|
|
26
|
+
"name": "exampleSystem",
|
|
27
|
+
"path": "./systems/example.system"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"entities": [
|
|
31
|
+
{
|
|
32
|
+
"id": "exampleEntity",
|
|
33
|
+
"components": [
|
|
34
|
+
{
|
|
35
|
+
"name": "ExampleComponent",
|
|
36
|
+
"params": ["\"example\"", "10"]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type EditorComponentManifest } from "@nanoforge-dev/ecs";
|
|
2
|
+
|
|
3
|
+
export class ExampleComponent {
|
|
4
|
+
name = this.constructor.name;
|
|
5
|
+
|
|
6
|
+
constructor(
|
|
7
|
+
public paramA: string,
|
|
8
|
+
public paramB: number,
|
|
9
|
+
public paramC: boolean = false,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
get foo() {
|
|
13
|
+
return "bar";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get paramAOrDefault() {
|
|
17
|
+
return this.paramC ? this.paramA : "default";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
addOne() {
|
|
21
|
+
this.paramB += 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// * Required to generate code
|
|
26
|
+
export default ExampleComponent.name;
|
|
27
|
+
|
|
28
|
+
// * Required for the editor to display the component and generate code
|
|
29
|
+
export const EDITOR_COMPONENT_MANIFEST: EditorComponentManifest = {
|
|
30
|
+
name: "Example",
|
|
31
|
+
description: "Example component description",
|
|
32
|
+
params: {
|
|
33
|
+
paramA: {
|
|
34
|
+
type: "string",
|
|
35
|
+
name: "Param A",
|
|
36
|
+
description: "Param A description",
|
|
37
|
+
example: "Example value",
|
|
38
|
+
},
|
|
39
|
+
paramB: {
|
|
40
|
+
type: "number",
|
|
41
|
+
name: "Param B",
|
|
42
|
+
description: "Param B description",
|
|
43
|
+
example: 3,
|
|
44
|
+
},
|
|
45
|
+
paramC: {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
name: "Param C",
|
|
48
|
+
description: "Param C description",
|
|
49
|
+
example: true,
|
|
50
|
+
default: false,
|
|
51
|
+
// Not required because it has a default value
|
|
52
|
+
optional: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type <%= appClass %> } from "@nanoforge-dev/core";
|
|
2
|
+
import { type Registry } from "@nanoforge-dev/ecs";
|
|
3
|
+
|
|
4
|
+
export async function afterRegistryInit(app: <%= appClass %>, registry: Registry) {
|
|
5
|
+
// Actions after registry components, entities and systems initialization
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type <%= appClass %> } from "@nanoforge-dev/core";
|
|
2
|
+
import { type Registry } from "@nanoforge-dev/ecs";
|
|
3
|
+
|
|
4
|
+
export async function beforeRegistryInit(app: <%= appClass %>, registry: Registry) {
|
|
5
|
+
// Actions before registry components, entities and systems initialization
|
|
6
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Context } from "@nanoforge-dev/common";
|
|
2
|
+
import { type EditorSystemManifest, type Registry } from "@nanoforge-dev/ecs";
|
|
3
|
+
|
|
4
|
+
import { ExampleComponent } from "../components/example.component";
|
|
5
|
+
|
|
6
|
+
export const exampleSystem = (registry: Registry, ctx: Context) => {
|
|
7
|
+
const entities = registry.getZipper([ExampleComponent]);
|
|
8
|
+
|
|
9
|
+
entities.forEach((entity) => {
|
|
10
|
+
if (entity.ExampleComponent.paramA === "end") {
|
|
11
|
+
ctx.app.setIsRunning(false);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (entity.ExampleComponent.paramB === 0) entity.ExampleComponent.paramA = "end";
|
|
16
|
+
|
|
17
|
+
if (entity.ExampleComponent.paramB >= 0)
|
|
18
|
+
entity.ExampleComponent.paramB = entity.ExampleComponent.paramB - 1;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// * Required to generate code
|
|
23
|
+
export default exampleSystem.name;
|
|
24
|
+
|
|
25
|
+
// * Required for the editor to display the system and generate code
|
|
26
|
+
export const EDITOR_SYSTEM_MANIFEST: EditorSystemManifest = {
|
|
27
|
+
name: "Example",
|
|
28
|
+
description:
|
|
29
|
+
"This system end the game when paramB reaches 0 for any entity with ExampleComponent",
|
|
30
|
+
dependencies: ["ExampleComponent"],
|
|
31
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
|
|
3
|
+
interface PartBaseSchema {
|
|
4
|
+
/**
|
|
5
|
+
* NanoForge application name
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The part of the application to generate
|
|
11
|
+
*/
|
|
12
|
+
part: "client" | "server";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* NanoForge application destination directory
|
|
16
|
+
*/
|
|
17
|
+
directory?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* NanoForge Application language
|
|
21
|
+
*/
|
|
22
|
+
language?: "js" | "ts";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Add init functions to the application
|
|
26
|
+
*/
|
|
27
|
+
initFunctions?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare const main: (schema: PartBaseSchema) => Rule;
|
|
31
|
+
|
|
32
|
+
export { main };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/libs/part-base/part-base.factory.ts
|
|
5
|
+
import { join, strings } from "@angular-devkit/core";
|
|
6
|
+
import {
|
|
7
|
+
apply,
|
|
8
|
+
filter,
|
|
9
|
+
mergeWith,
|
|
10
|
+
move,
|
|
11
|
+
template,
|
|
12
|
+
url
|
|
13
|
+
} from "@angular-devkit/schematics";
|
|
14
|
+
|
|
15
|
+
// src/utils/formatting.ts
|
|
16
|
+
var toKebabCase = /* @__PURE__ */ __name((str) => {
|
|
17
|
+
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
18
|
+
}, "toKebabCase");
|
|
19
|
+
|
|
20
|
+
// src/utils/name.ts
|
|
21
|
+
import { basename, parse } from "path";
|
|
22
|
+
var resolvePackageName = /* @__PURE__ */ __name((path) => {
|
|
23
|
+
const { base: baseFilename, dir: dirname } = parse(path);
|
|
24
|
+
if (baseFilename === ".") {
|
|
25
|
+
return basename(process.cwd());
|
|
26
|
+
}
|
|
27
|
+
if (dirname.match(/^@[^\s]/)) {
|
|
28
|
+
return `${dirname}/${baseFilename}`;
|
|
29
|
+
}
|
|
30
|
+
return baseFilename;
|
|
31
|
+
}, "resolvePackageName");
|
|
32
|
+
|
|
33
|
+
// src/defaults.ts
|
|
34
|
+
var DEFAULT_APP_NAME = "nanoforge-app";
|
|
35
|
+
var DEFAULT_LANGUAGE = "ts";
|
|
36
|
+
|
|
37
|
+
// src/libs/part-base/part-base.factory.ts
|
|
38
|
+
var transform = /* @__PURE__ */ __name((schema) => {
|
|
39
|
+
const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
part: schema.part,
|
|
43
|
+
appClass: schema.part === "client" ? "NanoforgeClient" : "NanoforgeServer",
|
|
44
|
+
language: schema.language ?? DEFAULT_LANGUAGE,
|
|
45
|
+
initFunctions: schema.initFunctions ?? false
|
|
46
|
+
};
|
|
47
|
+
}, "transform");
|
|
48
|
+
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
49
|
+
const rules = [
|
|
50
|
+
template({
|
|
51
|
+
...strings,
|
|
52
|
+
...options,
|
|
53
|
+
nanoforgeFolder: ".nanoforge"
|
|
54
|
+
}),
|
|
55
|
+
move(path),
|
|
56
|
+
filter((path2) => {
|
|
57
|
+
const splited = path2.split("/");
|
|
58
|
+
return splited.at(-2) !== ".nanoforge" || splited.at(-1) === `${options.part}.save.json`;
|
|
59
|
+
})
|
|
60
|
+
];
|
|
61
|
+
if (!options.initFunctions) rules.push(filter((path2) => path2.split("/").at(-2) !== "init"));
|
|
62
|
+
return apply(url(join("./files", options.language)), rules);
|
|
63
|
+
}, "generate");
|
|
64
|
+
var main = /* @__PURE__ */ __name((schema) => {
|
|
65
|
+
const options = transform(schema);
|
|
66
|
+
return mergeWith(generate(options, schema.directory ?? options.name));
|
|
67
|
+
}, "main");
|
|
68
|
+
export {
|
|
69
|
+
main
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=part-base.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/libs/part-base/part-base.factory.ts","../../../src/utils/formatting.ts","../../../src/utils/name.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, join, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n filter,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { toKebabCase } from \"@utils/formatting\";\nimport { resolvePackageName } from \"@utils/name\";\n\nimport { DEFAULT_APP_NAME, DEFAULT_LANGUAGE } from \"~/defaults\";\n\nimport { type PartBaseOptions } from \"./part-base.options\";\nimport { type PartBaseSchema } from \"./part-base.schema\";\n\nconst transform = (schema: PartBaseSchema): PartBaseOptions => {\n const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));\n\n return {\n name,\n part: schema.part,\n appClass: schema.part === \"client\" ? \"NanoforgeClient\" : \"NanoforgeServer\",\n language: schema.language ?? DEFAULT_LANGUAGE,\n initFunctions: schema.initFunctions ?? false,\n };\n};\n\nconst generate = (options: PartBaseOptions, path: string): Source => {\n const rules = [\n template({\n ...strings,\n ...options,\n nanoforgeFolder: \".nanoforge\",\n }),\n move(path),\n filter((path) => {\n const splited = path.split(\"/\");\n return splited.at(-2) !== \".nanoforge\" || splited.at(-1) === `${options.part}.save.json`;\n }),\n ];\n if (!options.initFunctions) rules.push(filter((path) => path.split(\"/\").at(-2) !== \"init\"));\n\n return apply(url(join(\"./files\" as Path, options.language)), rules);\n};\n\nexport const main = (schema: PartBaseSchema): Rule => {\n const options = transform(schema);\n\n return mergeWith(generate(options, schema.directory ?? options.name));\n};\n","export const toKebabCase = (str: string): string => {\n return str\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n};\n","import { basename, parse } from \"path\";\n\nexport const resolvePackageName = (path: string): string => {\n const { base: baseFilename, dir: dirname } = parse(path);\n if (baseFilename === \".\") {\n return basename(process.cwd());\n }\n if (dirname.match(/^@[^\\s]/)) {\n return `${dirname}/${baseFilename}`;\n }\n return baseFilename;\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";;;;AAAA,SAAoB,MAAM,eAAe;AACzC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACVA,IAAM,cAAc,wBAAC,QAAwB;AAClD,SAAO,IACJ,QAAQ,gCAAgC,OAAO,EAC/C,QAAQ,WAAW,GAAG,EACtB,YAAY;AACjB,GAL2B;;;ACA3B,SAAS,UAAU,aAAa;AAEzB,IAAM,qBAAqB,wBAAC,SAAyB;AAC1D,QAAM,EAAE,MAAM,cAAc,KAAK,QAAQ,IAAI,MAAM,IAAI;AACvD,MAAI,iBAAiB,KAAK;AACxB,WAAO,SAAS,QAAQ,IAAI,CAAC;AAAA,EAC/B;AACA,MAAI,QAAQ,MAAM,SAAS,GAAG;AAC5B,WAAO,GAAG,OAAO,IAAI,YAAY;AAAA,EACnC;AACA,SAAO;AACT,GATkC;;;ACF3B,IAAM,mBAAmB;AAIzB,IAAM,mBAAmB;;;AHgBhC,IAAM,YAAY,wBAAC,WAA4C;AAC7D,QAAM,OAAO,mBAAmB,YAAY,OAAO,MAAM,SAAS,KAAK,gBAAgB,CAAC;AAExF,SAAO;AAAA,IACL;AAAA,IACA,MAAM,OAAO;AAAA,IACb,UAAU,OAAO,SAAS,WAAW,oBAAoB;AAAA,IACzD,UAAU,OAAO,YAAY;AAAA,IAC7B,eAAe,OAAO,iBAAiB;AAAA,EACzC;AACF,GAVkB;AAYlB,IAAM,WAAW,wBAAC,SAA0B,SAAyB;AACnE,QAAM,QAAQ;AAAA,IACZ,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,iBAAiB;AAAA,IACnB,CAAC;AAAA,IACD,KAAK,IAAI;AAAA,IACT,OAAO,CAACA,UAAS;AACf,YAAM,UAAUA,MAAK,MAAM,GAAG;AAC9B,aAAO,QAAQ,GAAG,EAAE,MAAM,gBAAgB,QAAQ,GAAG,EAAE,MAAM,GAAG,QAAQ,IAAI;AAAA,IAC9E,CAAC;AAAA,EACH;AACA,MAAI,CAAC,QAAQ,cAAe,OAAM,KAAK,OAAO,CAACA,UAASA,MAAK,MAAM,GAAG,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1F,SAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,QAAQ,CAAC,GAAG,KAAK;AACpE,GAhBiB;AAkBV,IAAM,OAAO,wBAAC,WAAiC;AACpD,QAAM,UAAU,UAAU,MAAM;AAEhC,SAAO,UAAU,SAAS,SAAS,OAAO,aAAa,QAAQ,IAAI,CAAC;AACtE,GAJoB;","names":["path"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "SchematicsNanoForgePartBase",
|
|
4
|
+
"title": "NanoForge Part Base Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the application",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use for the new project ?"
|
|
15
|
+
},
|
|
16
|
+
"part": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["client", "server"],
|
|
19
|
+
"description": "The part of the application to generate"
|
|
20
|
+
},
|
|
21
|
+
"directory": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "NanoForge application destination directory"
|
|
24
|
+
},
|
|
25
|
+
"language": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["ts", "js"],
|
|
28
|
+
"description": "NanoForge application language",
|
|
29
|
+
"default": "ts"
|
|
30
|
+
},
|
|
31
|
+
"initFunctions": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Add init functions to the application",
|
|
34
|
+
"default": false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": ["name", "part"]
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
|
|
3
|
+
interface PartMainSchema {
|
|
4
|
+
/**
|
|
5
|
+
* NanoForge application name
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The part of the application to generate
|
|
11
|
+
*/
|
|
12
|
+
part: "client" | "server";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* NanoForge application destination directory
|
|
16
|
+
*/
|
|
17
|
+
directory?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* NanoForge Application language
|
|
21
|
+
*/
|
|
22
|
+
language?: "js" | "ts";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Add init functions to the application
|
|
26
|
+
*/
|
|
27
|
+
initFunctions?: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Save file path with components and systems in JSON format
|
|
31
|
+
*/
|
|
32
|
+
saveFile?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare const main: (schema: PartMainSchema) => Rule;
|
|
36
|
+
|
|
37
|
+
export { main };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/libs/part-main/part-main.factory.ts
|
|
5
|
+
import { join, strings } from "@angular-devkit/core";
|
|
6
|
+
import {
|
|
7
|
+
apply,
|
|
8
|
+
asSource,
|
|
9
|
+
mergeWith,
|
|
10
|
+
move,
|
|
11
|
+
template
|
|
12
|
+
} from "@angular-devkit/schematics";
|
|
13
|
+
import * as fs from "fs";
|
|
14
|
+
|
|
15
|
+
// src/utils/formatting.ts
|
|
16
|
+
var toKebabCase = /* @__PURE__ */ __name((str) => {
|
|
17
|
+
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
18
|
+
}, "toKebabCase");
|
|
19
|
+
|
|
20
|
+
// src/utils/main/conts.ts
|
|
21
|
+
var LIBS_FUNCTIONS_NAME = {
|
|
22
|
+
["asset-manager" /* ASSET_MANAGER */]: "useAssetManager",
|
|
23
|
+
["component-system" /* COMPONENT_SYSTEM */]: "useComponentSystem",
|
|
24
|
+
["graphics" /* GRAPHICS */]: "useGraphics",
|
|
25
|
+
["input" /* INPUT */]: "useInput",
|
|
26
|
+
["network" /* NETWORK */]: "useNetwork",
|
|
27
|
+
["sound" /* SOUND */]: "useSound"
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/utils/main/main.generator.ts
|
|
31
|
+
var MainGenerator = class {
|
|
32
|
+
static {
|
|
33
|
+
__name(this, "MainGenerator");
|
|
34
|
+
}
|
|
35
|
+
buffer = "";
|
|
36
|
+
indentation = 0;
|
|
37
|
+
toString() {
|
|
38
|
+
return this.buffer;
|
|
39
|
+
}
|
|
40
|
+
generateBaseImports(hasTypes) {
|
|
41
|
+
if (hasTypes) this.writeLine(`import { type IRunOptions } from "@nanoforge-dev/common";`);
|
|
42
|
+
this.writeLine(`import { NanoforgeFactory } from "@nanoforge-dev/core";`);
|
|
43
|
+
this.endSection();
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
generateLibsImports(libs) {
|
|
47
|
+
return this.generateImports(libs);
|
|
48
|
+
}
|
|
49
|
+
generateComponentsImports(libs) {
|
|
50
|
+
return this.generateImports(libs);
|
|
51
|
+
}
|
|
52
|
+
generateSystemsImports(libs) {
|
|
53
|
+
return this.generateImports(libs);
|
|
54
|
+
}
|
|
55
|
+
generateMainFunction(hasTypes, cb) {
|
|
56
|
+
this.writeLine(`export async function main(options${hasTypes ? ": IRunOptions" : ""}) {`);
|
|
57
|
+
this.indentation += 1;
|
|
58
|
+
cb(this);
|
|
59
|
+
this.indentation -= 1;
|
|
60
|
+
this.writeLine("}");
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
generateApp(isServer) {
|
|
64
|
+
this.writeLine(`const app = NanoforgeFactory.create${isServer ? "Server" : "Client"}();`);
|
|
65
|
+
this.endSection();
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
generateAppInit() {
|
|
69
|
+
this.writeLine(`await app.init(options);`);
|
|
70
|
+
this.endSection();
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
generateAppRun(hasInitFunctions) {
|
|
74
|
+
this.writeLine(`await app.run();`);
|
|
75
|
+
if (hasInitFunctions) this.endSection();
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
generateLibsInstances(libs) {
|
|
79
|
+
libs.forEach(({ id, name }) => this.writeLine(`const ${id} = new ${name}();`));
|
|
80
|
+
this.endSection();
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
generateLibsInit(libs) {
|
|
84
|
+
libs.forEach(({ id, type }) => this.writeLine(this.getInitFunction(id, type)));
|
|
85
|
+
this.endSection();
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
generateRegistry(libs) {
|
|
89
|
+
const libName = libs.find((lib) => lib.type === "component-system" /* COMPONENT_SYSTEM */)?.id ?? "ecsLibrary";
|
|
90
|
+
this.writeLine(`const registry = ${libName}.registry;`);
|
|
91
|
+
this.endSection();
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
generateEntities(entities) {
|
|
95
|
+
entities.forEach((entity) => this.generateEntity(entity));
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
generateSystems(systems) {
|
|
99
|
+
systems.forEach(({ name }) => this.writeLine(`registry.addSystem(${name});`));
|
|
100
|
+
this.endSection();
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
generateInitFunctionIfNeeded(needed, func) {
|
|
104
|
+
if (needed) return this.generateInitFunction(func);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
generateInitFunctionsImportsIfNeeded(needed) {
|
|
108
|
+
if (!needed) return this;
|
|
109
|
+
return this.generateImports([
|
|
110
|
+
{ name: "afterInit", path: "./init/after-init" },
|
|
111
|
+
{ name: "afterRegistryInit", path: "./init/after-registry-init" },
|
|
112
|
+
{ name: "afterRun", path: "./init/after-run" },
|
|
113
|
+
{ name: "beforeInit", path: "./init/before-init" },
|
|
114
|
+
{ name: "beforeRegistryInit", path: "./init/before-registry-init" },
|
|
115
|
+
{ name: "beforeRun", path: "./init/before-run" }
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
generateInitFunction(func) {
|
|
119
|
+
const params = ["app"];
|
|
120
|
+
if (["beforeRegistryInit" /* BEFORE_REGISTRY_INIT */, "afterRegistryInit" /* AFTER_REGISTRY_INIT */].includes(func))
|
|
121
|
+
params.push("registry");
|
|
122
|
+
this.writeLine(`await ${func}(${params.join(", ")});`);
|
|
123
|
+
if (func !== "afterRun" /* AFTER_RUN */) this.endSection();
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
generateImports(els) {
|
|
127
|
+
els.sort((a, b) => a.path.localeCompare(b.path)).forEach(({ name, path }) => this.writeLine(`import { ${name} } from "${path}";`));
|
|
128
|
+
this.endSection();
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
generateEntity(entity) {
|
|
132
|
+
this.writeLine(`const ${entity.id} = registry.spawnEntity();`);
|
|
133
|
+
entity.components.forEach(
|
|
134
|
+
({ name, params }) => this.writeLine(`registry.addComponent(${entity.id}, new ${name}(${params.join(", ")}));`)
|
|
135
|
+
);
|
|
136
|
+
this.endSection();
|
|
137
|
+
}
|
|
138
|
+
getInitFunction(name, type) {
|
|
139
|
+
const baseName = LIBS_FUNCTIONS_NAME[type];
|
|
140
|
+
if (baseName) return `app.${baseName}(${name});`;
|
|
141
|
+
return `app.use("${type}", ${name});`;
|
|
142
|
+
}
|
|
143
|
+
writeLine(text, indentation = true) {
|
|
144
|
+
const line = `${" ".repeat(indentation ? this.indentation * 2 : 0)}${text}
|
|
145
|
+
`;
|
|
146
|
+
this.buffer += line;
|
|
147
|
+
}
|
|
148
|
+
endSection() {
|
|
149
|
+
this.writeLine("");
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/utils/main/main-functions.ts
|
|
154
|
+
var generateMain = /* @__PURE__ */ __name((options, save) => {
|
|
155
|
+
const isServer = options.part === "server";
|
|
156
|
+
const hasTypes = options.language === "ts";
|
|
157
|
+
const initFunctions = options.initFunctions;
|
|
158
|
+
return new MainGenerator().generateBaseImports(hasTypes).generateLibsImports(save.libraries).generateInitFunctionsImportsIfNeeded(initFunctions).generateComponentsImports(save.components).generateSystemsImports(save.systems).generateMainFunction(hasTypes, (generator) => {
|
|
159
|
+
generator.generateApp(isServer).generateLibsInstances(save.libraries).generateLibsInit(save.libraries).generateInitFunctionIfNeeded(initFunctions, "beforeInit" /* BEFORE_INIT */).generateAppInit().generateInitFunctionIfNeeded(initFunctions, "afterInit" /* AFTER_INIT */).generateRegistry(save.libraries).generateInitFunctionIfNeeded(initFunctions, "beforeRegistryInit" /* BEFORE_REGISTRY_INIT */).generateEntities(save.entities).generateSystems(save.systems).generateInitFunctionIfNeeded(initFunctions, "afterRegistryInit" /* AFTER_REGISTRY_INIT */).generateInitFunctionIfNeeded(initFunctions, "beforeRun" /* BEFORE_RUN */).generateAppRun(initFunctions).generateInitFunctionIfNeeded(initFunctions, "afterRun" /* AFTER_RUN */);
|
|
160
|
+
}).toString();
|
|
161
|
+
}, "generateMain");
|
|
162
|
+
|
|
163
|
+
// src/utils/name.ts
|
|
164
|
+
import { basename, parse } from "path";
|
|
165
|
+
var resolvePackageName = /* @__PURE__ */ __name((path) => {
|
|
166
|
+
const { base: baseFilename, dir: dirname } = parse(path);
|
|
167
|
+
if (baseFilename === ".") {
|
|
168
|
+
return basename(process.cwd());
|
|
169
|
+
}
|
|
170
|
+
if (dirname.match(/^@[^\s]/)) {
|
|
171
|
+
return `${dirname}/${baseFilename}`;
|
|
172
|
+
}
|
|
173
|
+
return baseFilename;
|
|
174
|
+
}, "resolvePackageName");
|
|
175
|
+
|
|
176
|
+
// src/defaults.ts
|
|
177
|
+
var DEFAULT_APP_NAME = "nanoforge-app";
|
|
178
|
+
var DEFAULT_LANGUAGE = "ts";
|
|
179
|
+
|
|
180
|
+
// src/libs/part-main/part-main.factory.ts
|
|
181
|
+
var transform = /* @__PURE__ */ __name((schema) => {
|
|
182
|
+
const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
|
|
183
|
+
return {
|
|
184
|
+
name,
|
|
185
|
+
part: schema.part,
|
|
186
|
+
language: schema.language ?? DEFAULT_LANGUAGE,
|
|
187
|
+
initFunctions: schema.initFunctions ?? false,
|
|
188
|
+
saveFile: schema.saveFile
|
|
189
|
+
};
|
|
190
|
+
}, "transform");
|
|
191
|
+
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
192
|
+
const rules = [
|
|
193
|
+
template({
|
|
194
|
+
...strings,
|
|
195
|
+
...options
|
|
196
|
+
}),
|
|
197
|
+
move(path)
|
|
198
|
+
];
|
|
199
|
+
return apply(asSource(writeMain(options, path)), rules);
|
|
200
|
+
}, "generate");
|
|
201
|
+
var writeMain = /* @__PURE__ */ __name((options, path) => {
|
|
202
|
+
return (tree) => {
|
|
203
|
+
const save = getSave(path, options.part, options.saveFile);
|
|
204
|
+
const resPath = join(options.part, `main.${options.language}`);
|
|
205
|
+
const content = generateMain(options, save);
|
|
206
|
+
fs.rmSync(join(path, resPath), { force: true });
|
|
207
|
+
tree.create(resPath, content);
|
|
208
|
+
return tree;
|
|
209
|
+
};
|
|
210
|
+
}, "writeMain");
|
|
211
|
+
var getSave = /* @__PURE__ */ __name((path, part, saveFile) => {
|
|
212
|
+
return JSON.parse(
|
|
213
|
+
fs.readFileSync(saveFile ?? join(path, `.nanoforge/${part}.save.json`), "utf-8")
|
|
214
|
+
);
|
|
215
|
+
}, "getSave");
|
|
216
|
+
var main = /* @__PURE__ */ __name((schema) => {
|
|
217
|
+
console.error(schema);
|
|
218
|
+
const options = transform(schema);
|
|
219
|
+
return mergeWith(generate(options, schema.directory ?? options.name));
|
|
220
|
+
}, "main");
|
|
221
|
+
export {
|
|
222
|
+
main
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=part-main.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/libs/part-main/part-main.factory.ts","../../../src/utils/formatting.ts","../../../src/utils/main/conts.ts","../../../src/utils/main/main.generator.ts","../../../src/utils/main/main-functions.ts","../../../src/utils/name.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, join, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n type Tree,\n apply,\n asSource,\n mergeWith,\n move,\n template,\n} from \"@angular-devkit/schematics\";\nimport * as fs from \"node:fs\";\n\nimport { toKebabCase } from \"@utils/formatting\";\nimport { generateMain } from \"@utils/main/main-functions\";\nimport { type Save } from \"@utils/main/save.type\";\nimport { resolvePackageName } from \"@utils/name\";\n\nimport { DEFAULT_APP_NAME, DEFAULT_LANGUAGE } from \"~/defaults\";\n\nimport { type PartMainOptions } from \"./part-main.options\";\nimport { type PartMainSchema } from \"./part-main.schema\";\n\nconst transform = (schema: PartMainSchema): PartMainOptions => {\n const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));\n\n return {\n name,\n part: schema.part,\n language: schema.language ?? DEFAULT_LANGUAGE,\n initFunctions: schema.initFunctions ?? false,\n saveFile: schema.saveFile,\n };\n};\n\nconst generate = (options: PartMainOptions, path: string): Source => {\n const rules = [\n template({\n ...strings,\n ...options,\n }),\n move(path),\n ];\n\n return apply(asSource(writeMain(options, path)), rules);\n};\n\nconst writeMain = (options: PartMainOptions, path: string) => {\n return (tree: Tree) => {\n const save = getSave(path, options.part, options.saveFile);\n const resPath = join(options.part as Path, `main.${options.language}`);\n const content = generateMain(options, save);\n fs.rmSync(join(path as Path, resPath), { force: true });\n tree.create(resPath, content);\n return tree;\n };\n};\n\nconst getSave = (path: string, part: \"client\" | \"server\", saveFile?: string): Save => {\n return JSON.parse(\n fs.readFileSync(saveFile ?? join(path as Path, `.nanoforge/${part}.save.json`), \"utf-8\"),\n ) as Save;\n};\n\nexport const main = (schema: PartMainSchema): Rule => {\n console.error(schema);\n const options = transform(schema);\n\n return mergeWith(generate(options, schema.directory ?? options.name));\n};\n","export const toKebabCase = (str: string): string => {\n return str\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n};\n","import { SaveLibraryTypeEnum } from \"@utils/main/save.type\";\n\nexport const LIBS_FUNCTIONS_NAME: Record<SaveLibraryTypeEnum | string, string> = {\n [SaveLibraryTypeEnum.ASSET_MANAGER]: \"useAssetManager\",\n [SaveLibraryTypeEnum.COMPONENT_SYSTEM]: \"useComponentSystem\",\n [SaveLibraryTypeEnum.GRAPHICS]: \"useGraphics\",\n [SaveLibraryTypeEnum.INPUT]: \"useInput\",\n [SaveLibraryTypeEnum.NETWORK]: \"useNetwork\",\n [SaveLibraryTypeEnum.SOUND]: \"useSound\",\n};\n","import { InitFunctionEnum } from \"@utils/main/enums\";\n\nimport { LIBS_FUNCTIONS_NAME } from \"./conts\";\nimport {\n type SaveComponent,\n type SaveEntity,\n type SaveLibrary,\n SaveLibraryTypeEnum,\n type SaveSystem,\n} from \"./save.type\";\n\nexport class MainGenerator {\n private buffer = \"\";\n private indentation = 0;\n\n toString(): string {\n return this.buffer;\n }\n\n generateBaseImports(hasTypes: boolean): MainGenerator {\n if (hasTypes) this.writeLine(`import { type IRunOptions } from \"@nanoforge-dev/common\";`);\n this.writeLine(`import { NanoforgeFactory } from \"@nanoforge-dev/core\";`);\n this.endSection();\n return this;\n }\n\n generateLibsImports(libs: SaveLibrary[]): MainGenerator {\n return this.generateImports(libs);\n }\n\n generateComponentsImports(libs: SaveComponent[]): MainGenerator {\n return this.generateImports(libs);\n }\n\n generateSystemsImports(libs: SaveSystem[]): MainGenerator {\n return this.generateImports(libs);\n }\n\n generateMainFunction(hasTypes: boolean, cb: (generator: MainGenerator) => void): MainGenerator {\n this.writeLine(`export async function main(options${hasTypes ? \": IRunOptions\" : \"\"}) {`);\n this.indentation += 1;\n cb(this);\n this.indentation -= 1;\n this.writeLine(\"}\");\n return this;\n }\n\n generateApp(isServer: boolean): MainGenerator {\n this.writeLine(`const app = NanoforgeFactory.create${isServer ? \"Server\" : \"Client\"}();`);\n this.endSection();\n return this;\n }\n\n generateAppInit(): MainGenerator {\n this.writeLine(`await app.init(options);`);\n this.endSection();\n return this;\n }\n\n generateAppRun(hasInitFunctions: boolean): MainGenerator {\n this.writeLine(`await app.run();`);\n if (hasInitFunctions) this.endSection();\n return this;\n }\n\n generateLibsInstances(libs: SaveLibrary[]): MainGenerator {\n libs.forEach(({ id, name }) => this.writeLine(`const ${id} = new ${name}();`));\n this.endSection();\n return this;\n }\n\n generateLibsInit(libs: SaveLibrary[]): MainGenerator {\n libs.forEach(({ id, type }) => this.writeLine(this.getInitFunction(id, type)));\n this.endSection();\n return this;\n }\n\n generateRegistry(libs: SaveLibrary[]): MainGenerator {\n const libName =\n libs.find((lib) => lib.type === SaveLibraryTypeEnum.COMPONENT_SYSTEM)?.id ?? \"ecsLibrary\";\n this.writeLine(`const registry = ${libName}.registry;`);\n this.endSection();\n return this;\n }\n\n generateEntities(entities: SaveEntity[]): MainGenerator {\n entities.forEach((entity) => this.generateEntity(entity));\n return this;\n }\n\n generateSystems(systems: SaveSystem[]): MainGenerator {\n systems.forEach(({ name }) => this.writeLine(`registry.addSystem(${name});`));\n this.endSection();\n return this;\n }\n\n generateInitFunctionIfNeeded(needed: boolean, func: InitFunctionEnum): MainGenerator {\n if (needed) return this.generateInitFunction(func);\n return this;\n }\n\n generateInitFunctionsImportsIfNeeded(needed: boolean): MainGenerator {\n if (!needed) return this;\n return this.generateImports([\n { name: \"afterInit\", path: \"./init/after-init\" },\n { name: \"afterRegistryInit\", path: \"./init/after-registry-init\" },\n { name: \"afterRun\", path: \"./init/after-run\" },\n { name: \"beforeInit\", path: \"./init/before-init\" },\n { name: \"beforeRegistryInit\", path: \"./init/before-registry-init\" },\n { name: \"beforeRun\", path: \"./init/before-run\" },\n ]);\n }\n\n private generateInitFunction(func: InitFunctionEnum): MainGenerator {\n const params = [\"app\"];\n if (\n [InitFunctionEnum.BEFORE_REGISTRY_INIT, InitFunctionEnum.AFTER_REGISTRY_INIT].includes(func)\n )\n params.push(\"registry\");\n this.writeLine(`await ${func}(${params.join(\", \")});`);\n if (func !== InitFunctionEnum.AFTER_RUN) this.endSection();\n return this;\n }\n\n private generateImports(els: { name: string; path: string }[]): MainGenerator {\n els\n .sort((a, b) => a.path.localeCompare(b.path))\n .forEach(({ name, path }) => this.writeLine(`import { ${name} } from \"${path}\";`));\n this.endSection();\n return this;\n }\n\n private generateEntity(entity: SaveEntity): void {\n this.writeLine(`const ${entity.id} = registry.spawnEntity();`);\n entity.components.forEach(({ name, params }) =>\n this.writeLine(`registry.addComponent(${entity.id}, new ${name}(${params.join(\", \")}));`),\n );\n this.endSection();\n }\n\n private getInitFunction(name: string, type: SaveLibraryTypeEnum | string): string {\n const baseName = LIBS_FUNCTIONS_NAME[type];\n if (baseName) return `app.${baseName}(${name});`;\n return `app.use(\"${type}\", ${name});`;\n }\n\n private writeLine(text: string, indentation = true): void {\n const line = `${\" \".repeat(indentation ? this.indentation * 2 : 0)}${text}\\n`;\n this.buffer += line;\n }\n\n private endSection(): void {\n this.writeLine(\"\");\n }\n}\n","import { InitFunctionEnum } from \"@utils/main/enums\";\n\nimport { MainGenerator } from \"./main.generator\";\nimport { type Save } from \"./save.type\";\n\nexport interface MainOptions {\n part: \"client\" | \"server\";\n language: \"js\" | \"ts\";\n initFunctions: boolean;\n}\n\nexport const generateMain = (options: MainOptions, save: Save) => {\n const isServer = options.part === \"server\";\n const hasTypes = options.language === \"ts\";\n const initFunctions = options.initFunctions;\n\n return new MainGenerator()\n .generateBaseImports(hasTypes)\n .generateLibsImports(save.libraries)\n .generateInitFunctionsImportsIfNeeded(initFunctions)\n .generateComponentsImports(save.components)\n .generateSystemsImports(save.systems)\n\n .generateMainFunction(hasTypes, (generator) => {\n generator\n .generateApp(isServer)\n\n .generateLibsInstances(save.libraries)\n .generateLibsInit(save.libraries)\n\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.BEFORE_INIT)\n .generateAppInit()\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.AFTER_INIT)\n\n .generateRegistry(save.libraries)\n\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.BEFORE_REGISTRY_INIT)\n .generateEntities(save.entities)\n .generateSystems(save.systems)\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.AFTER_REGISTRY_INIT)\n\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.BEFORE_RUN)\n .generateAppRun(initFunctions)\n .generateInitFunctionIfNeeded(initFunctions, InitFunctionEnum.AFTER_RUN);\n })\n .toString();\n};\n","import { basename, parse } from \"path\";\n\nexport const resolvePackageName = (path: string): string => {\n const { base: baseFilename, dir: dirname } = parse(path);\n if (baseFilename === \".\") {\n return basename(process.cwd());\n }\n if (dirname.match(/^@[^\\s]/)) {\n return `${dirname}/${baseFilename}`;\n }\n return baseFilename;\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";;;;AAAA,SAAoB,MAAM,eAAe;AACzC;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,QAAQ;;;ACXb,IAAM,cAAc,wBAAC,QAAwB;AAClD,SAAO,IACJ,QAAQ,gCAAgC,OAAO,EAC/C,QAAQ,WAAW,GAAG,EACtB,YAAY;AACjB,GAL2B;;;ACEpB,IAAM,sBAAoE;AAAA,EAC/E,oCAAkC,GAAG;AAAA,EACrC,0CAAqC,GAAG;AAAA,EACxC,0BAA6B,GAAG;AAAA,EAChC,oBAA0B,GAAG;AAAA,EAC7B,wBAA4B,GAAG;AAAA,EAC/B,oBAA0B,GAAG;AAC/B;;;ACEO,IAAM,gBAAN,MAAoB;AAAA,EAX3B,OAW2B;AAAA;AAAA;AAAA,EACjB,SAAS;AAAA,EACT,cAAc;AA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AAQ,MAAM,QAAQ,MAAM,QAAQ,QAAQ;AACzD,UAAM,UAAU,KAAK,QAAQ,MAAc,QAAQ,QAAQ,QAAQ,EAAE;AACrE,UAAM,UAAU,aAAa,SAAS,IAAI;AAC1C,IAAG,UAAO,KAAK,MAAc,OAAO,GAAG,EAAE,OAAO,KAAK,CAAC;AACtD,SAAK,OAAO,SAAS,OAAO;AAC5B,WAAO;AAAA,EACT;AACF,GATkB;AAWlB,IAAM,UAAU,wBAAC,MAAc,MAA2B,aAA4B;AACpF,SAAO,KAAK;AAAA,IACP,gBAAa,YAAY,KAAK,MAAc,cAAc,IAAI,YAAY,GAAG,OAAO;AAAA,EACzF;AACF,GAJgB;AAMT,IAAM,OAAO,wBAAC,WAAiC;AACpD,UAAQ,MAAM,MAAM;AACpB,QAAM,UAAU,UAAU,MAAM;AAEhC,SAAO,UAAU,SAAS,SAAS,OAAO,aAAa,QAAQ,IAAI,CAAC;AACtE,GALoB;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "SchematicsNanoForgePartMain",
|
|
4
|
+
"title": "NanoForge Part Main Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the application",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use for the new project ?"
|
|
15
|
+
},
|
|
16
|
+
"part": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["client", "server"],
|
|
19
|
+
"description": "The part of the application to generate"
|
|
20
|
+
},
|
|
21
|
+
"directory": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "NanoForge application destination directory"
|
|
24
|
+
},
|
|
25
|
+
"language": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["ts", "js"],
|
|
28
|
+
"description": "NanoForge application language",
|
|
29
|
+
"default": "ts"
|
|
30
|
+
},
|
|
31
|
+
"initFunctions": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Add init functions to the main application",
|
|
34
|
+
"default": false
|
|
35
|
+
},
|
|
36
|
+
"saveFile": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "Save file path with components and systems in JSON format"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": ["name", "part"]
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@nanoforge-dev/schematics",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "NanoForge Schematics",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"nanoforge",
|
|
@@ -20,20 +20,21 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
|
-
"main": "./dist/index.
|
|
24
|
-
"module": "./dist/index.
|
|
25
|
-
"types": "./dist/index.d.
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.cts",
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"require": {
|
|
29
|
-
"types": "./dist/index.d.
|
|
30
|
-
"default": "./dist/index.
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
31
|
},
|
|
32
32
|
"import": {
|
|
33
|
-
"types": "./dist/index.d.
|
|
34
|
-
"default": "./dist/index.
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
37
38
|
},
|
|
38
39
|
"type": "module",
|
|
39
40
|
"directories": {
|
|
@@ -72,11 +73,12 @@
|
|
|
72
73
|
"typescript-eslint": "^8.46.2"
|
|
73
74
|
},
|
|
74
75
|
"engines": {
|
|
75
|
-
"node": "24.11.
|
|
76
|
+
"node": "24.11.1"
|
|
76
77
|
},
|
|
77
78
|
"publishConfig": {
|
|
78
79
|
"access": "public"
|
|
79
80
|
},
|
|
81
|
+
"schematics": "./dist/collection.json",
|
|
80
82
|
"lint-staged": {
|
|
81
83
|
"**/*.ts": [
|
|
82
84
|
"prettier --write"
|