@twin.org/engine-models 0.0.1-next.1 → 0.0.1-next.2

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.
@@ -3,4 +3,4 @@ import type { IEngineCore } from "../models/IEngineCore";
3
3
  /**
4
4
  * Factory for creating engine cores.
5
5
  */
6
- export declare const EngineCoreFactory: Factory<IEngineCore>;
6
+ export declare const EngineCoreFactory: Factory<IEngineCore<import("..").IEngineState>>;
@@ -7,7 +7,7 @@ import type { IEngineState } from "./IEngineState";
7
7
  /**
8
8
  * Interface describing the engine core methods.
9
9
  */
10
- export interface IEngineCore {
10
+ export interface IEngineCore<S extends IEngineState = IEngineState> {
11
11
  /**
12
12
  * Add a type initialiser.
13
13
  * @param type The type to add the initialiser for.
@@ -44,7 +44,7 @@ export interface IEngineCore {
44
44
  * Get the state of the engine.
45
45
  * @returns The state of the engine.
46
46
  */
47
- getState(): IEngineState;
47
+ getState(): S;
48
48
  /**
49
49
  * Get the types for the component.
50
50
  * @returns The default types.
@@ -4,7 +4,7 @@ import type { IEngineState } from "./IEngineState";
4
4
  /**
5
5
  * The context for the engine core.
6
6
  */
7
- export interface IEngineCoreContext {
7
+ export interface IEngineCoreContext<S extends IEngineState = IEngineState> {
8
8
  /**
9
9
  * The engine core config.
10
10
  */
@@ -12,7 +12,7 @@ export interface IEngineCoreContext {
12
12
  /**
13
13
  * The engine core state.
14
14
  */
15
- state: IEngineState;
15
+ state: S;
16
16
  /**
17
17
  * The state dirty flag, which flags that the state needs saving.
18
18
  */
@@ -3,18 +3,18 @@ import type { IEngineState } from "./IEngineState";
3
3
  /**
4
4
  * Definition of state storage for engine.
5
5
  */
6
- export interface IEngineStateStorage {
6
+ export interface IEngineStateStorage<S extends IEngineState = IEngineState> {
7
7
  /**
8
8
  * Method for loading the state.
9
9
  * @param engineCore The engine core to load the state for.
10
10
  * @returns The state of the engine or undefined if it doesn't exist.
11
11
  */
12
- load(engineCore: IEngineCore): Promise<IEngineState | undefined>;
12
+ load(engineCore: IEngineCore): Promise<S | undefined>;
13
13
  /**
14
14
  * Method for saving the state.
15
15
  * @param engineCore The engine core to save the state for.
16
16
  * @param state The state of the engine to save.
17
17
  * @returns Nothing.
18
18
  */
19
- save(engineCore: IEngineCore, state: IEngineState): Promise<void>;
19
+ save(engineCore: IEngineCore, state: S): Promise<void>;
20
20
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/engine-models - Changelog
2
2
 
3
- ## v0.0.1-next.1
3
+ ## v0.0.1-next.2
4
4
 
5
5
  - Initial Release
@@ -1,7 +1,11 @@
1
- # Interface: IEngineCore
1
+ # Interface: IEngineCore\<S\>
2
2
 
3
3
  Interface describing the engine core methods.
4
4
 
5
+ ## Type Parameters
6
+
7
+ • **S** *extends* [`IEngineState`](IEngineState.md) = [`IEngineState`](IEngineState.md)
8
+
5
9
  ## Methods
6
10
 
7
11
  ### addTypeInitialiser()
@@ -114,13 +118,13 @@ The config for the engine.
114
118
 
115
119
  ### getState()
116
120
 
117
- > **getState**(): [`IEngineState`](IEngineState.md)
121
+ > **getState**(): `S`
118
122
 
119
123
  Get the state of the engine.
120
124
 
121
125
  #### Returns
122
126
 
123
- [`IEngineState`](IEngineState.md)
127
+ `S`
124
128
 
125
129
  The state of the engine.
126
130
 
@@ -1,7 +1,11 @@
1
- # Interface: IEngineCoreContext
1
+ # Interface: IEngineCoreContext\<S\>
2
2
 
3
3
  The context for the engine core.
4
4
 
5
+ ## Type Parameters
6
+
7
+ • **S** *extends* [`IEngineState`](IEngineState.md) = [`IEngineState`](IEngineState.md)
8
+
5
9
  ## Properties
6
10
 
7
11
  ### config
@@ -14,7 +18,7 @@ The engine core config.
14
18
 
15
19
  ### state
16
20
 
17
- > **state**: [`IEngineState`](IEngineState.md)
21
+ > **state**: `S`
18
22
 
19
23
  The engine core state.
20
24
 
@@ -1,24 +1,28 @@
1
- # Interface: IEngineStateStorage
1
+ # Interface: IEngineStateStorage\<S\>
2
2
 
3
3
  Definition of state storage for engine.
4
4
 
5
+ ## Type Parameters
6
+
7
+ • **S** *extends* [`IEngineState`](IEngineState.md) = [`IEngineState`](IEngineState.md)
8
+
5
9
  ## Methods
6
10
 
7
11
  ### load()
8
12
 
9
- > **load**(`engineCore`): `Promise`\<`undefined` \| [`IEngineState`](IEngineState.md)\>
13
+ > **load**(`engineCore`): `Promise`\<`undefined` \| `S`\>
10
14
 
11
15
  Method for loading the state.
12
16
 
13
17
  #### Parameters
14
18
 
15
- • **engineCore**: [`IEngineCore`](IEngineCore.md)
19
+ • **engineCore**: [`IEngineCore`](IEngineCore.md)\<[`IEngineState`](IEngineState.md)\>
16
20
 
17
21
  The engine core to load the state for.
18
22
 
19
23
  #### Returns
20
24
 
21
- `Promise`\<`undefined` \| [`IEngineState`](IEngineState.md)\>
25
+ `Promise`\<`undefined` \| `S`\>
22
26
 
23
27
  The state of the engine or undefined if it doesn't exist.
24
28
 
@@ -32,11 +36,11 @@ Method for saving the state.
32
36
 
33
37
  #### Parameters
34
38
 
35
- • **engineCore**: [`IEngineCore`](IEngineCore.md)
39
+ • **engineCore**: [`IEngineCore`](IEngineCore.md)\<[`IEngineState`](IEngineState.md)\>
36
40
 
37
41
  The engine core to save the state for.
38
42
 
39
- • **state**: [`IEngineState`](IEngineState.md)
43
+ • **state**: `S`
40
44
 
41
45
  The state of the engine to save.
42
46
 
@@ -1,5 +1,5 @@
1
1
  # Variable: EngineCoreFactory
2
2
 
3
- > `const` **EngineCoreFactory**: `Factory`\<[`IEngineCore`](../interfaces/IEngineCore.md)\>
3
+ > `const` **EngineCoreFactory**: `Factory`\<[`IEngineCore`](../interfaces/IEngineCore.md)\<[`IEngineState`](../interfaces/IEngineState.md)\>\>
4
4
 
5
5
  Factory for creating engine cores.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-models",
3
- "version": "0.0.1-next.1",
3
+ "version": "0.0.1-next.2",
4
4
  "description": "Models which define the structure of the engine.",
5
5
  "repository": {
6
6
  "type": "git",