Skip to content

Commit 45ec899

Browse files
committed
fix(ecs/zipper): zipper typing was not conform to how array are written in ts
[type] instead of type[]
1 parent 36b4e53 commit 45ec899

File tree

7 files changed

+11
-85
lines changed

7 files changed

+11
-85
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,5 @@ dist
227227
.nx/
228228
.cursor/rules/nx-rules.mdc
229229
.github/instructions/nx.instructions.md
230+
231+
compile_commands.json

packages/ecs/lib/libecs.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface Registry extends ClassHandle {
6060
getEntityComponent(_0: Entity, _1: Component): any | undefined;
6161
addComponent(_0: Entity, _1: Component): any | undefined;
6262
runSystems(_0: any): void;
63-
getZipper(_0: [Component]): any;
63+
getZipper(_0: Component[]): any;
6464
}
6565

6666
interface EmbindModule {

packages/ecs/src/ecs-library.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import {
77
type InitContext,
88
} from "@nanoforge/common";
99

10-
import type { MainModule } from "../lib";
10+
import type { MainModule, Registry } from "../lib";
1111
import { Module } from "../lib";
12-
import { ECSRegistry } from "./ecs-registry";
1312

1413
export class ECSLibrary extends BaseComponentSystemLibrary {
1514
private module: MainModule;
16-
private _registry: ECSRegistry;
15+
private _registry: Registry;
1716

1817
private readonly path: string = "libecs.wasm";
1918

@@ -33,14 +32,14 @@ export class ECSLibrary extends BaseComponentSystemLibrary {
3332
.getAssetManager<AssetManagerLibrary>()
3433
.library.getWasm(this.path);
3534
this.module = await Module({ locateFile: () => wasmFile.path });
36-
this._registry = new ECSRegistry(new this.module.Registry());
35+
this._registry = new this.module.Registry();
3736
}
3837

3938
async __run(ctx: Context): Promise<void> {
4039
this._registry.runSystems(ctx);
4140
}
4241

43-
get registry(): ECSRegistry {
42+
get registry(): Registry {
4443
return this._registry;
4544
}
4645
}

packages/ecs/src/ecs-registry.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

packages/ecs/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "../lib/libecs.wasm";
22

33
export { ECSLibrary } from "./ecs-library";
4-
export type { ECSRegistry } from "./ecs-registry";
54
export type { Component, System, Registry } from "../lib";

packages/ecs/test/ecs-library.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import {
66
InitContext,
77
} from "@nanoforge/common";
88
import { EditableLibraryManager } from "@nanoforge/core/src/common/library/manager/library.manager";
9-
import { type ECSRegistry } from "@nanoforge/ecs";
109
import { ECSLibrary } from "@nanoforge/ecs/src/ecs-library";
1110

11+
import { type Registry } from "../lib";
12+
1213
class Position {
1314
name: string = "Position";
1415
constructor(
@@ -22,7 +23,7 @@ class Position {
2223

2324
describe("ECSLibrary", () => {
2425
let ecs: ECSLibrary;
25-
let registry: ECSRegistry;
26+
let registry: Registry;
2627
const assetManager = new AssetManagerLibrary();
2728
const appContext = new ApplicationContext();
2829
const libraryManager = new EditableLibraryManager();

packages/ecs/wasm/Registry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace nfo {
2424
{
2525
emscripten::register_type<Component>("Component", "{name: string, [key: string]: any}");
2626
emscripten::register_type<System>("System", "(registry: Registry, ctx: any) => void");
27-
emscripten::register_type<ZipperInput>("[Component]");
27+
emscripten::register_type<ZipperInput>("Component[]");
2828

2929
emscripten::class_<Registry>("Registry")
3030
.constructor()

0 commit comments

Comments
 (0)