ecspresso 0.8.0 → 0.9.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.
@@ -1,6 +1,6 @@
1
1
  import Bundle from "./bundle";
2
2
  import ECSpresso from "./ecspresso";
3
- import type { FilteredEntity, System } from "./types";
3
+ import type { FilteredEntity, System, SystemPhase } from "./types";
4
4
  /**
5
5
  * Builder class for creating type-safe ECS Systems with proper query inference
6
6
  */
@@ -14,6 +14,7 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
14
14
  private initializeFunction?;
15
15
  private eventHandlers?;
16
16
  private _priority;
17
+ private _phase;
17
18
  private _isRegistered;
18
19
  private _groups;
19
20
  private _inScreens?;
@@ -52,6 +53,14 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
52
53
  * @returns This SystemBuilder instance for method chaining
53
54
  */
54
55
  setPriority(priority: number): this;
56
+ /**
57
+ * Set the execution phase for this system.
58
+ * Systems are grouped by phase and executed in order:
59
+ * preUpdate -> fixedUpdate -> update -> postUpdate -> render
60
+ * @param phase The phase to assign this system to (default: 'update')
61
+ * @returns This SystemBuilder instance for method chaining
62
+ */
63
+ inPhase(phase: SystemPhase): this;
55
64
  /**
56
65
  * Add this system to a group. Systems can belong to multiple groups.
57
66
  * When any group a system belongs to is disabled, the system will be skipped.
@@ -89,6 +98,7 @@ export declare class SystemBuilder<ComponentTypes extends Record<string, any> =
89
98
  addQuery<QueryName extends string, WithComponents extends keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes = never, NewQueries extends Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>> = Queries & Record<QueryName, QueryDefinition<ComponentTypes, WithComponents, WithoutComponents>>>(name: QueryName, definition: {
90
99
  with: ReadonlyArray<WithComponents>;
91
100
  without?: ReadonlyArray<WithoutComponents>;
101
+ changed?: ReadonlyArray<WithComponents>;
92
102
  }): this extends SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, Queries> ? SystemBuilderWithEcspresso<ComponentTypes, EventTypes, ResourceTypes, NewQueries> : this extends SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, Queries> ? SystemBuilderWithBundle<ComponentTypes, EventTypes, ResourceTypes, NewQueries> : SystemBuilder<ComponentTypes, EventTypes, ResourceTypes, NewQueries>;
93
103
  /**
94
104
  * Set the system's process function that runs each update
@@ -148,6 +158,7 @@ export declare function registerSystemWithEcspresso<ComponentTypes extends Recor
148
158
  type QueryDefinition<ComponentTypes, WithComponents extends keyof ComponentTypes = any, WithoutComponents extends keyof ComponentTypes = any> = {
149
159
  with: ReadonlyArray<WithComponents>;
150
160
  without?: ReadonlyArray<WithoutComponents>;
161
+ changed?: ReadonlyArray<WithComponents>;
151
162
  };
152
163
  type QueryResults<ComponentTypes, Queries extends Record<string, QueryDefinition<ComponentTypes>>> = {
153
164
  [QueryName in keyof Queries]: QueryName extends string ? FilteredEntity<ComponentTypes, Queries[QueryName] extends QueryDefinition<ComponentTypes, infer W, any> ? W : never, Queries[QueryName] extends QueryDefinition<ComponentTypes, any, infer WO> ? WO : never>[] : never;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import ECSpresso from "./ecspresso";
2
+ /**
3
+ * Execution phase for systems. Systems are grouped by phase and executed
4
+ * in this fixed order: preUpdate -> fixedUpdate -> update -> postUpdate -> render.
5
+ * Within each phase, systems are sorted by priority (higher first).
6
+ */
7
+ export type SystemPhase = 'preUpdate' | 'fixedUpdate' | 'update' | 'postUpdate' | 'render';
2
8
  export interface Entity<ComponentTypes> {
3
9
  id: number;
4
10
  components: Partial<ComponentTypes>;
@@ -54,6 +60,7 @@ export interface FilteredEntity<ComponentTypes, WithComponents extends keyof Com
54
60
  export interface QueryConfig<ComponentTypes, WithComponents extends keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes> {
55
61
  with: ReadonlyArray<WithComponents>;
56
62
  without?: ReadonlyArray<WithoutComponents>;
63
+ changed?: ReadonlyArray<WithComponents>;
57
64
  }
58
65
  /**
59
66
  * Utility type to derive the entity type that would result from a query definition.
@@ -79,6 +86,7 @@ export interface QueryConfig<ComponentTypes, WithComponents extends keyof Compon
79
86
  export type QueryResultEntity<ComponentTypes extends Record<string, any>, QueryDef extends {
80
87
  with: ReadonlyArray<keyof ComponentTypes>;
81
88
  without?: ReadonlyArray<keyof ComponentTypes>;
89
+ changed?: ReadonlyArray<keyof ComponentTypes>;
82
90
  }> = FilteredEntity<ComponentTypes, QueryDef['with'][number], QueryDef['without'] extends ReadonlyArray<any> ? QueryDef['without'][number] : never>;
83
91
  /**
84
92
  * Simplified query definition type for creating reusable queries
@@ -86,6 +94,7 @@ export type QueryResultEntity<ComponentTypes extends Record<string, any>, QueryD
86
94
  export type QueryDefinition<ComponentTypes extends Record<string, any>, WithComponents extends keyof ComponentTypes = keyof ComponentTypes, WithoutComponents extends keyof ComponentTypes = keyof ComponentTypes> = {
87
95
  with: ReadonlyArray<WithComponents>;
88
96
  without?: ReadonlyArray<WithoutComponents>;
97
+ changed?: ReadonlyArray<WithComponents>;
89
98
  };
90
99
  /**
91
100
  * Helper function to create a query definition with proper type inference.
@@ -117,6 +126,7 @@ export type QueryDefinition<ComponentTypes extends Record<string, any>, WithComp
117
126
  export declare function createQueryDefinition<ComponentTypes extends Record<string, any>, const QueryDef extends {
118
127
  with: ReadonlyArray<keyof ComponentTypes>;
119
128
  without?: ReadonlyArray<keyof ComponentTypes>;
129
+ changed?: ReadonlyArray<keyof ComponentTypes>;
120
130
  }>(queryDef: QueryDef): QueryDef;
121
131
  export interface System<ComponentTypes extends Record<string, any> = {}, WithComponents extends keyof ComponentTypes = never, WithoutComponents extends keyof ComponentTypes = never, EventTypes extends Record<string, any> = {}, ResourceTypes extends Record<string, any> = {}, AssetTypes extends Record<string, unknown> = {}, ScreenStates extends Record<string, any> = {}> {
122
132
  label: string;
@@ -125,6 +135,12 @@ export interface System<ComponentTypes extends Record<string, any> = {}, WithCom
125
135
  * When systems have the same priority, they execute in registration order
126
136
  */
127
137
  priority?: number;
138
+ /**
139
+ * Execution phase for this system (default: 'update')
140
+ * Systems are grouped by phase and executed in order:
141
+ * preUpdate -> fixedUpdate -> update -> postUpdate -> render
142
+ */
143
+ phase?: SystemPhase;
128
144
  /**
129
145
  * Groups this system belongs to. If any group is disabled, the system will be skipped.
130
146
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecspresso",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",