@twin.org/engine-core 0.0.3-next.4 → 0.0.3-next.40
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/README.md +1 -1
- package/dist/es/engineCore.js +112 -70
- package/dist/es/engineCore.js.map +1 -1
- package/dist/es/storage/fileStateStorage.js.map +1 -1
- package/dist/es/storage/memoryStateStorage.js.map +1 -1
- package/dist/types/engineCore.d.ts +26 -4
- package/docs/changelog.md +687 -109
- package/docs/examples.md +156 -1
- package/docs/reference/classes/EngineCore.md +117 -37
- package/docs/reference/classes/EngineModuleHelper.md +2 -2
- package/docs/reference/classes/FileStateStorage.md +7 -7
- package/docs/reference/classes/MemoryStateStorage.md +7 -7
- package/docs/reference/interfaces/IEngineCoreOptions.md +10 -10
- package/locales/en.json +2 -1
- package/package.json +5 -5
package/docs/examples.md
CHANGED
|
@@ -1 +1,156 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Engine Core Examples
|
|
2
|
+
|
|
3
|
+
These examples focus on common runtime patterns such as lifecycle control, cloning, state storage, and module loading.
|
|
4
|
+
|
|
5
|
+
## EngineCore
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { EngineCore, MemoryStateStorage } from '@twin.org/engine-core';
|
|
9
|
+
import type { IEngineCoreConfig, IEngineState } from '@twin.org/engine-models';
|
|
10
|
+
|
|
11
|
+
interface AppState extends IEngineState {
|
|
12
|
+
runCount?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const config: IEngineCoreConfig = {
|
|
16
|
+
debug: true,
|
|
17
|
+
silent: false,
|
|
18
|
+
types: {}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const stateStorage = new MemoryStateStorage<AppState>();
|
|
22
|
+
const engineCore = new EngineCore<IEngineCoreConfig, AppState>({
|
|
23
|
+
config,
|
|
24
|
+
stateStorage,
|
|
25
|
+
skipBootstrap: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
engineCore.addTypeInitialiser('loggingConnector', '@twin.org/engine-types', 'initLoggingConnector');
|
|
29
|
+
console.log(engineCore.getTypeConfig('loggingConnector')?.length ?? 0); // 0
|
|
30
|
+
|
|
31
|
+
engineCore.addContextIdKey('tenant', ['tenant']);
|
|
32
|
+
engineCore.addContextId('tenant', 'tenant-a');
|
|
33
|
+
|
|
34
|
+
console.log(engineCore.getContextIdKeys()); // ["tenant"]
|
|
35
|
+
console.log(engineCore.getContextIds()); // { tenant: "tenant-a" }
|
|
36
|
+
console.log(engineCore.isPrimary()); // true
|
|
37
|
+
console.log(engineCore.isClone()); // false
|
|
38
|
+
console.log(engineCore.isStarted()); // false
|
|
39
|
+
|
|
40
|
+
await engineCore.start(true);
|
|
41
|
+
console.log(engineCore.isStarted()); // true
|
|
42
|
+
|
|
43
|
+
await engineCore.logInfo('Engine started for tenant-a');
|
|
44
|
+
|
|
45
|
+
const state = engineCore.getState();
|
|
46
|
+
state.runCount = (state.runCount ?? 0) + 1;
|
|
47
|
+
engineCore.setStateDirty();
|
|
48
|
+
|
|
49
|
+
console.log(engineCore.getConfig().debug); // true
|
|
50
|
+
console.log(engineCore.getRegisteredInstances()); // { loggingConnector: [...], loggingComponent: [...] }
|
|
51
|
+
console.log(engineCore.getRegisteredInstanceType('loggingComponent')); // "engine-logging-service"
|
|
52
|
+
console.log(engineCore.getRegisteredInstanceTypeOptional('hostingComponent')); // undefined
|
|
53
|
+
|
|
54
|
+
await engineCore.stop();
|
|
55
|
+
console.log(engineCore.isStarted()); // false
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { BaseError, GeneralError } from '@twin.org/core';
|
|
60
|
+
import { EngineCore } from '@twin.org/engine-core';
|
|
61
|
+
|
|
62
|
+
const engineCore = new EngineCore({
|
|
63
|
+
config: { debug: false, silent: true, types: {} },
|
|
64
|
+
skipBootstrap: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const wrapped = new GeneralError(
|
|
68
|
+
EngineCore.CLASS_NAME,
|
|
69
|
+
'sampleFailure',
|
|
70
|
+
{ area: 'examples' },
|
|
71
|
+
BaseError.fromError(new Error('Sample failure'))
|
|
72
|
+
);
|
|
73
|
+
await engineCore.logError(wrapped);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { EngineCore } from '@twin.org/engine-core';
|
|
78
|
+
|
|
79
|
+
const primary = new EngineCore({
|
|
80
|
+
config: { debug: false, silent: true, types: {} },
|
|
81
|
+
skipBootstrap: true
|
|
82
|
+
});
|
|
83
|
+
primary.addContextIdKey('node', ['node']);
|
|
84
|
+
|
|
85
|
+
const cloneData = primary.getCloneData();
|
|
86
|
+
|
|
87
|
+
const clone = new EngineCore({ config: { debug: false, silent: true, types: {} } });
|
|
88
|
+
clone.populateClone(cloneData, { node: 'node-1', tenant: 'tenant-a' }, true);
|
|
89
|
+
|
|
90
|
+
console.log(clone.isClone()); // true
|
|
91
|
+
console.log(clone.getContextIds()); // { node: "node-1", tenant: "tenant-a" }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## FileStateStorage
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { EngineCore, FileStateStorage } from '@twin.org/engine-core';
|
|
98
|
+
|
|
99
|
+
const engineCore = new EngineCore({
|
|
100
|
+
config: { debug: false, silent: true, types: {} },
|
|
101
|
+
skipBootstrap: true
|
|
102
|
+
});
|
|
103
|
+
const fileStorage = new FileStateStorage('./data/engine-state.json');
|
|
104
|
+
|
|
105
|
+
await fileStorage.save(engineCore, { ready: true });
|
|
106
|
+
|
|
107
|
+
const loaded = await fileStorage.load(engineCore);
|
|
108
|
+
console.log(loaded); // { ready: true }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## MemoryStateStorage
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { EngineCore, MemoryStateStorage } from '@twin.org/engine-core';
|
|
115
|
+
|
|
116
|
+
const engineCore = new EngineCore({
|
|
117
|
+
config: { debug: false, silent: true, types: {} },
|
|
118
|
+
skipBootstrap: true
|
|
119
|
+
});
|
|
120
|
+
const memoryStorage = new MemoryStateStorage(false, { retries: 1 });
|
|
121
|
+
|
|
122
|
+
console.log(await memoryStorage.load(engineCore)); // { retries: 1 }
|
|
123
|
+
|
|
124
|
+
await memoryStorage.save(engineCore, { retries: 2 });
|
|
125
|
+
console.log(await memoryStorage.load(engineCore)); // { retries: 2 }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## EngineModuleHelper
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { EngineCore, EngineModuleHelper } from '@twin.org/engine-core';
|
|
132
|
+
import type { IEngineModuleConfig } from '@twin.org/engine-models';
|
|
133
|
+
|
|
134
|
+
const engineCore = new EngineCore({
|
|
135
|
+
config: { debug: false, silent: true, types: {} },
|
|
136
|
+
skipBootstrap: true
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const moduleConfig: IEngineModuleConfig = {
|
|
140
|
+
moduleName: '@twin.org/logging-service',
|
|
141
|
+
className: 'LoggingService',
|
|
142
|
+
dependencies: [
|
|
143
|
+
{
|
|
144
|
+
propertyName: 'loggingConnectorType',
|
|
145
|
+
componentName: 'loggingConnector',
|
|
146
|
+
isOptional: false
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
config: {
|
|
150
|
+
level: 'info'
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const component = await EngineModuleHelper.loadComponent<unknown>(engineCore, moduleConfig);
|
|
155
|
+
console.log(component !== undefined); // true
|
|
156
|
+
```
|
|
@@ -38,7 +38,7 @@ The options for the engine.
|
|
|
38
38
|
|
|
39
39
|
## Properties
|
|
40
40
|
|
|
41
|
-
### LOGGING\_COMPONENT\_TYPE\_NAME
|
|
41
|
+
### LOGGING\_COMPONENT\_TYPE\_NAME {#logging_component_type_name}
|
|
42
42
|
|
|
43
43
|
> `readonly` `static` **LOGGING\_COMPONENT\_TYPE\_NAME**: `string` = `"engine-logging-service"`
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ Name for the engine logger component, used for direct console logging.
|
|
|
46
46
|
|
|
47
47
|
***
|
|
48
48
|
|
|
49
|
-
### LOGGING\_CONNECTOR\_TYPE\_NAME
|
|
49
|
+
### LOGGING\_CONNECTOR\_TYPE\_NAME {#logging_connector_type_name}
|
|
50
50
|
|
|
51
51
|
> `readonly` `static` **LOGGING\_CONNECTOR\_TYPE\_NAME**: `string` = `"engine-logging-connector"`
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ Name for the engine logger connector, used for direct console logging.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
-
### CLASS\_NAME
|
|
57
|
+
### CLASS\_NAME {#class_name}
|
|
58
58
|
|
|
59
59
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ Runtime name for the class.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### \_context
|
|
65
|
+
### \_context {#_context}
|
|
66
66
|
|
|
67
67
|
> `protected` **\_context**: `IEngineCoreContext`\<`C`, `S`\>
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ The core context.
|
|
|
70
70
|
|
|
71
71
|
***
|
|
72
72
|
|
|
73
|
-
### \_contextIdKeys
|
|
73
|
+
### \_contextIdKeys {#_contextidkeys}
|
|
74
74
|
|
|
75
75
|
> `protected` `readonly` **\_contextIdKeys**: `object`[]
|
|
76
76
|
|
|
@@ -86,15 +86,15 @@ The context ID keys.
|
|
|
86
86
|
|
|
87
87
|
***
|
|
88
88
|
|
|
89
|
-
### \_contextIds?
|
|
89
|
+
### \_contextIds? {#_contextids}
|
|
90
90
|
|
|
91
|
-
> `protected` `optional` **\_contextIds
|
|
91
|
+
> `protected` `optional` **\_contextIds?**: `IContextIds`
|
|
92
92
|
|
|
93
93
|
The context IDs.
|
|
94
94
|
|
|
95
95
|
## Methods
|
|
96
96
|
|
|
97
|
-
### addTypeInitialiser()
|
|
97
|
+
### addTypeInitialiser() {#addtypeinitialiser}
|
|
98
98
|
|
|
99
99
|
> **addTypeInitialiser**(`type`, `module`, `method`): `void`
|
|
100
100
|
|
|
@@ -130,9 +130,9 @@ The name of the method to call.
|
|
|
130
130
|
|
|
131
131
|
***
|
|
132
132
|
|
|
133
|
-
### getTypeConfig()
|
|
133
|
+
### getTypeConfig() {#gettypeconfig}
|
|
134
134
|
|
|
135
|
-
> **getTypeConfig**(`type`): `
|
|
135
|
+
> **getTypeConfig**(`type`): `IEngineCoreTypeConfig`[] \| `undefined`
|
|
136
136
|
|
|
137
137
|
Get the type config for a specific type.
|
|
138
138
|
|
|
@@ -146,7 +146,7 @@ The type to get the config for.
|
|
|
146
146
|
|
|
147
147
|
#### Returns
|
|
148
148
|
|
|
149
|
-
`
|
|
149
|
+
`IEngineCoreTypeConfig`[] \| `undefined`
|
|
150
150
|
|
|
151
151
|
The type config or undefined if not found.
|
|
152
152
|
|
|
@@ -156,7 +156,7 @@ The type config or undefined if not found.
|
|
|
156
156
|
|
|
157
157
|
***
|
|
158
158
|
|
|
159
|
-
### addContextIdKey()
|
|
159
|
+
### addContextIdKey() {#addcontextidkey}
|
|
160
160
|
|
|
161
161
|
> **addContextIdKey**(`key`, `componentFeatures`): `void`
|
|
162
162
|
|
|
@@ -186,7 +186,7 @@ The component features for the context ID handler.
|
|
|
186
186
|
|
|
187
187
|
***
|
|
188
188
|
|
|
189
|
-
### getContextIdKeys()
|
|
189
|
+
### getContextIdKeys() {#getcontextidkeys}
|
|
190
190
|
|
|
191
191
|
> **getContextIdKeys**(): `string`[]
|
|
192
192
|
|
|
@@ -204,7 +204,7 @@ The context IDs keys.
|
|
|
204
204
|
|
|
205
205
|
***
|
|
206
206
|
|
|
207
|
-
### addContextId()
|
|
207
|
+
### addContextId() {#addcontextid}
|
|
208
208
|
|
|
209
209
|
> **addContextId**(`key`, `value`): `void`
|
|
210
210
|
|
|
@@ -234,15 +234,15 @@ The context ID value.
|
|
|
234
234
|
|
|
235
235
|
***
|
|
236
236
|
|
|
237
|
-
### getContextIds()
|
|
237
|
+
### getContextIds() {#getcontextids}
|
|
238
238
|
|
|
239
|
-
> **getContextIds**(): `
|
|
239
|
+
> **getContextIds**(): `IContextIds` \| `undefined`
|
|
240
240
|
|
|
241
241
|
Get the context IDs for the engine.
|
|
242
242
|
|
|
243
243
|
#### Returns
|
|
244
244
|
|
|
245
|
-
`
|
|
245
|
+
`IContextIds` \| `undefined`
|
|
246
246
|
|
|
247
247
|
The context IDs or undefined if none are set.
|
|
248
248
|
|
|
@@ -252,17 +252,25 @@ The context IDs or undefined if none are set.
|
|
|
252
252
|
|
|
253
253
|
***
|
|
254
254
|
|
|
255
|
-
### start()
|
|
255
|
+
### start() {#start}
|
|
256
256
|
|
|
257
|
-
> **start**(): `Promise`\<`
|
|
257
|
+
> **start**(`skipComponentStart?`): `Promise`\<`void`\>
|
|
258
258
|
|
|
259
259
|
Start the engine core.
|
|
260
260
|
|
|
261
|
+
#### Parameters
|
|
262
|
+
|
|
263
|
+
##### skipComponentStart?
|
|
264
|
+
|
|
265
|
+
`boolean`
|
|
266
|
+
|
|
267
|
+
Should the component start be skipped.
|
|
268
|
+
|
|
261
269
|
#### Returns
|
|
262
270
|
|
|
263
|
-
`Promise`\<`
|
|
271
|
+
`Promise`\<`void`\>
|
|
264
272
|
|
|
265
|
-
|
|
273
|
+
Nothing.
|
|
266
274
|
|
|
267
275
|
#### Implementation of
|
|
268
276
|
|
|
@@ -270,7 +278,7 @@ True if the start was successful.
|
|
|
270
278
|
|
|
271
279
|
***
|
|
272
280
|
|
|
273
|
-
### stop()
|
|
281
|
+
### stop() {#stop}
|
|
274
282
|
|
|
275
283
|
> **stop**(): `Promise`\<`void`\>
|
|
276
284
|
|
|
@@ -288,7 +296,7 @@ Nothing.
|
|
|
288
296
|
|
|
289
297
|
***
|
|
290
298
|
|
|
291
|
-
### isStarted()
|
|
299
|
+
### isStarted() {#isstarted}
|
|
292
300
|
|
|
293
301
|
> **isStarted**(): `boolean`
|
|
294
302
|
|
|
@@ -306,7 +314,7 @@ True if the engine is started.
|
|
|
306
314
|
|
|
307
315
|
***
|
|
308
316
|
|
|
309
|
-
### isPrimary()
|
|
317
|
+
### isPrimary() {#isprimary}
|
|
310
318
|
|
|
311
319
|
> **isPrimary**(): `boolean`
|
|
312
320
|
|
|
@@ -324,7 +332,7 @@ True if the engine is the primary instance.
|
|
|
324
332
|
|
|
325
333
|
***
|
|
326
334
|
|
|
327
|
-
### isClone()
|
|
335
|
+
### isClone() {#isclone}
|
|
328
336
|
|
|
329
337
|
> **isClone**(): `boolean`
|
|
330
338
|
|
|
@@ -342,7 +350,7 @@ True if the engine instance is a clone.
|
|
|
342
350
|
|
|
343
351
|
***
|
|
344
352
|
|
|
345
|
-
### logInfo()
|
|
353
|
+
### logInfo() {#loginfo}
|
|
346
354
|
|
|
347
355
|
> **logInfo**(`message`): `Promise`\<`void`\>
|
|
348
356
|
|
|
@@ -366,7 +374,7 @@ The message to log.
|
|
|
366
374
|
|
|
367
375
|
***
|
|
368
376
|
|
|
369
|
-
### logError()
|
|
377
|
+
### logError() {#logerror}
|
|
370
378
|
|
|
371
379
|
> **logError**(`error`): `Promise`\<`void`\>
|
|
372
380
|
|
|
@@ -390,7 +398,7 @@ The error to log.
|
|
|
390
398
|
|
|
391
399
|
***
|
|
392
400
|
|
|
393
|
-
### getConfig()
|
|
401
|
+
### getConfig() {#getconfig}
|
|
394
402
|
|
|
395
403
|
> **getConfig**(): `C`
|
|
396
404
|
|
|
@@ -408,7 +416,7 @@ The config for the engine.
|
|
|
408
416
|
|
|
409
417
|
***
|
|
410
418
|
|
|
411
|
-
### getState()
|
|
419
|
+
### getState() {#getstate}
|
|
412
420
|
|
|
413
421
|
> **getState**(): `S`
|
|
414
422
|
|
|
@@ -426,7 +434,23 @@ The state of the engine.
|
|
|
426
434
|
|
|
427
435
|
***
|
|
428
436
|
|
|
429
|
-
###
|
|
437
|
+
### setStateDirty() {#setstatedirty}
|
|
438
|
+
|
|
439
|
+
> **setStateDirty**(): `void`
|
|
440
|
+
|
|
441
|
+
Set the state to dirty so it gets saved.
|
|
442
|
+
|
|
443
|
+
#### Returns
|
|
444
|
+
|
|
445
|
+
`void`
|
|
446
|
+
|
|
447
|
+
#### Implementation of
|
|
448
|
+
|
|
449
|
+
`IEngineCore.setStateDirty`
|
|
450
|
+
|
|
451
|
+
***
|
|
452
|
+
|
|
453
|
+
### getRegisteredInstances() {#getregisteredinstances}
|
|
430
454
|
|
|
431
455
|
> **getRegisteredInstances**(): `object`
|
|
432
456
|
|
|
@@ -444,7 +468,7 @@ The registered instances.
|
|
|
444
468
|
|
|
445
469
|
***
|
|
446
470
|
|
|
447
|
-
### getRegisteredInstanceType()
|
|
471
|
+
### getRegisteredInstanceType() {#getregisteredinstancetype}
|
|
448
472
|
|
|
449
473
|
> **getRegisteredInstanceType**(`componentConnectorType`, `features?`): `string`
|
|
450
474
|
|
|
@@ -480,9 +504,9 @@ If a matching instance was not found.
|
|
|
480
504
|
|
|
481
505
|
***
|
|
482
506
|
|
|
483
|
-
### getRegisteredInstanceTypeOptional()
|
|
507
|
+
### getRegisteredInstanceTypeOptional() {#getregisteredinstancetypeoptional}
|
|
484
508
|
|
|
485
|
-
> **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `
|
|
509
|
+
> **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `string` \| `undefined`
|
|
486
510
|
|
|
487
511
|
Get the registered instance type for the component/connector if it exists.
|
|
488
512
|
|
|
@@ -502,7 +526,7 @@ The requested features of the component, if not specified the default entry will
|
|
|
502
526
|
|
|
503
527
|
#### Returns
|
|
504
528
|
|
|
505
|
-
`
|
|
529
|
+
`string` \| `undefined`
|
|
506
530
|
|
|
507
531
|
The instance type matching the criteria if one is registered.
|
|
508
532
|
|
|
@@ -512,7 +536,57 @@ The instance type matching the criteria if one is registered.
|
|
|
512
536
|
|
|
513
537
|
***
|
|
514
538
|
|
|
515
|
-
###
|
|
539
|
+
### getRegisteredComponents() {#getregisteredcomponents}
|
|
540
|
+
|
|
541
|
+
> **getRegisteredComponents**(): `Promise`\<`object`[]\>
|
|
542
|
+
|
|
543
|
+
Get the registered components.
|
|
544
|
+
|
|
545
|
+
#### Returns
|
|
546
|
+
|
|
547
|
+
`Promise`\<`object`[]\>
|
|
548
|
+
|
|
549
|
+
The registered components.
|
|
550
|
+
|
|
551
|
+
#### Implementation of
|
|
552
|
+
|
|
553
|
+
`IEngineCore.getRegisteredComponents`
|
|
554
|
+
|
|
555
|
+
***
|
|
556
|
+
|
|
557
|
+
### addRegisteredComponent() {#addregisteredcomponent}
|
|
558
|
+
|
|
559
|
+
> **addRegisteredComponent**(`instanceType`, `component`): `Promise`\<`void`\>
|
|
560
|
+
|
|
561
|
+
Add a registered component to the engine.
|
|
562
|
+
|
|
563
|
+
#### Parameters
|
|
564
|
+
|
|
565
|
+
##### instanceType
|
|
566
|
+
|
|
567
|
+
`string`
|
|
568
|
+
|
|
569
|
+
The instance type to register the component under.
|
|
570
|
+
|
|
571
|
+
##### component
|
|
572
|
+
|
|
573
|
+
`IComponent`
|
|
574
|
+
|
|
575
|
+
The component to register.
|
|
576
|
+
|
|
577
|
+
#### Returns
|
|
578
|
+
|
|
579
|
+
`Promise`\<`void`\>
|
|
580
|
+
|
|
581
|
+
Nothing.
|
|
582
|
+
|
|
583
|
+
#### Implementation of
|
|
584
|
+
|
|
585
|
+
`IEngineCore.addRegisteredComponent`
|
|
586
|
+
|
|
587
|
+
***
|
|
588
|
+
|
|
589
|
+
### getCloneData() {#getclonedata}
|
|
516
590
|
|
|
517
591
|
> **getCloneData**(): `IEngineCoreClone`\<`C`, `S`\>
|
|
518
592
|
|
|
@@ -530,9 +604,9 @@ The clone data.
|
|
|
530
604
|
|
|
531
605
|
***
|
|
532
606
|
|
|
533
|
-
### populateClone()
|
|
607
|
+
### populateClone() {#populateclone}
|
|
534
608
|
|
|
535
|
-
> **populateClone**(`cloneData`, `silent?`): `void`
|
|
609
|
+
> **populateClone**(`cloneData`, `contextIds?`, `silent?`): `void`
|
|
536
610
|
|
|
537
611
|
Populate the engine from the clone data.
|
|
538
612
|
|
|
@@ -544,6 +618,12 @@ Populate the engine from the clone data.
|
|
|
544
618
|
|
|
545
619
|
The clone data to populate from.
|
|
546
620
|
|
|
621
|
+
##### contextIds?
|
|
622
|
+
|
|
623
|
+
`IContextIds`
|
|
624
|
+
|
|
625
|
+
The context IDs to use for the clone.
|
|
626
|
+
|
|
547
627
|
##### silent?
|
|
548
628
|
|
|
549
629
|
`boolean`
|
|
@@ -14,7 +14,7 @@ Helper class for engine modules.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### loadComponent()
|
|
25
|
+
### loadComponent() {#loadcomponent}
|
|
26
26
|
|
|
27
27
|
> `static` **loadComponent**\<`T`\>(`engineCore`, `engineModuleConfig`): `Promise`\<`T`\>
|
|
28
28
|
|
|
@@ -16,7 +16,7 @@ Store state in a file.
|
|
|
16
16
|
|
|
17
17
|
### Constructor
|
|
18
18
|
|
|
19
|
-
> **new FileStateStorage**\<`S`\>(`filename`, `readonlyMode
|
|
19
|
+
> **new FileStateStorage**\<`S`\>(`filename`, `readonlyMode?`): `FileStateStorage`\<`S`\>
|
|
20
20
|
|
|
21
21
|
Create a new instance of FileStateStorage.
|
|
22
22
|
|
|
@@ -28,7 +28,7 @@ Create a new instance of FileStateStorage.
|
|
|
28
28
|
|
|
29
29
|
The filename to store the state.
|
|
30
30
|
|
|
31
|
-
##### readonlyMode
|
|
31
|
+
##### readonlyMode?
|
|
32
32
|
|
|
33
33
|
`boolean` = `false`
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ Whether the file is in read-only mode.
|
|
|
40
40
|
|
|
41
41
|
## Properties
|
|
42
42
|
|
|
43
|
-
### CLASS\_NAME
|
|
43
|
+
### CLASS\_NAME {#class_name}
|
|
44
44
|
|
|
45
45
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
46
46
|
|
|
@@ -48,9 +48,9 @@ Runtime name for the class.
|
|
|
48
48
|
|
|
49
49
|
## Methods
|
|
50
50
|
|
|
51
|
-
### load()
|
|
51
|
+
### load() {#load}
|
|
52
52
|
|
|
53
|
-
> **load**(`engineCore`): `Promise`\<`
|
|
53
|
+
> **load**(`engineCore`): `Promise`\<`S` \| `undefined`\>
|
|
54
54
|
|
|
55
55
|
Method for loading the state.
|
|
56
56
|
|
|
@@ -64,7 +64,7 @@ The engine core to load the state for.
|
|
|
64
64
|
|
|
65
65
|
#### Returns
|
|
66
66
|
|
|
67
|
-
`Promise`\<`
|
|
67
|
+
`Promise`\<`S` \| `undefined`\>
|
|
68
68
|
|
|
69
69
|
The state of the engine or undefined if it doesn't exist.
|
|
70
70
|
|
|
@@ -74,7 +74,7 @@ The state of the engine or undefined if it doesn't exist.
|
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
77
|
-
### save()
|
|
77
|
+
### save() {#save}
|
|
78
78
|
|
|
79
79
|
> **save**(`engineCore`, `state`): `Promise`\<`void`\>
|
|
80
80
|
|
|
@@ -16,13 +16,13 @@ Store state in memory.
|
|
|
16
16
|
|
|
17
17
|
### Constructor
|
|
18
18
|
|
|
19
|
-
> **new MemoryStateStorage**\<`S`\>(`readonlyMode
|
|
19
|
+
> **new MemoryStateStorage**\<`S`\>(`readonlyMode?`, `state?`): `MemoryStateStorage`\<`S`\>
|
|
20
20
|
|
|
21
21
|
Create a new instance of MemoryStateStorage.
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
##### readonlyMode
|
|
25
|
+
##### readonlyMode?
|
|
26
26
|
|
|
27
27
|
`boolean` = `false`
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ The initial state.
|
|
|
40
40
|
|
|
41
41
|
## Properties
|
|
42
42
|
|
|
43
|
-
### CLASS\_NAME
|
|
43
|
+
### CLASS\_NAME {#class_name}
|
|
44
44
|
|
|
45
45
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
46
46
|
|
|
@@ -48,9 +48,9 @@ Runtime name for the class.
|
|
|
48
48
|
|
|
49
49
|
## Methods
|
|
50
50
|
|
|
51
|
-
### load()
|
|
51
|
+
### load() {#load}
|
|
52
52
|
|
|
53
|
-
> **load**(`engineCore`): `Promise`\<`
|
|
53
|
+
> **load**(`engineCore`): `Promise`\<`S` \| `undefined`\>
|
|
54
54
|
|
|
55
55
|
Method for loading the state.
|
|
56
56
|
|
|
@@ -64,7 +64,7 @@ The engine core to load the state for.
|
|
|
64
64
|
|
|
65
65
|
#### Returns
|
|
66
66
|
|
|
67
|
-
`Promise`\<`
|
|
67
|
+
`Promise`\<`S` \| `undefined`\>
|
|
68
68
|
|
|
69
69
|
The state of the engine or undefined if it doesn't exist.
|
|
70
70
|
|
|
@@ -74,7 +74,7 @@ The state of the engine or undefined if it doesn't exist.
|
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
77
|
-
### save()
|
|
77
|
+
### save() {#save}
|
|
78
78
|
|
|
79
79
|
> **save**(`engineCore`, `state`): `Promise`\<`void`\>
|
|
80
80
|
|
|
@@ -14,33 +14,33 @@ The options for creating engine core.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### config?
|
|
17
|
+
### config? {#config}
|
|
18
18
|
|
|
19
|
-
> `optional` **config
|
|
19
|
+
> `optional` **config?**: `C`
|
|
20
20
|
|
|
21
21
|
The engine core config.
|
|
22
22
|
|
|
23
23
|
***
|
|
24
24
|
|
|
25
|
-
### stateStorage?
|
|
25
|
+
### stateStorage? {#statestorage}
|
|
26
26
|
|
|
27
|
-
> `optional` **stateStorage
|
|
27
|
+
> `optional` **stateStorage?**: `IEngineStateStorage`\<`S`\>
|
|
28
28
|
|
|
29
29
|
The state storage component.
|
|
30
30
|
|
|
31
31
|
***
|
|
32
32
|
|
|
33
|
-
### skipBootstrap?
|
|
33
|
+
### skipBootstrap? {#skipbootstrap}
|
|
34
34
|
|
|
35
|
-
> `optional` **skipBootstrap
|
|
35
|
+
> `optional` **skipBootstrap?**: `boolean`
|
|
36
36
|
|
|
37
37
|
Skip the bootstrap process, useful for additional engine instances.
|
|
38
38
|
|
|
39
39
|
***
|
|
40
40
|
|
|
41
|
-
### populateTypeInitialisers
|
|
41
|
+
### populateTypeInitialisers? {#populatetypeinitialisers}
|
|
42
42
|
|
|
43
|
-
> `optional` **populateTypeInitialisers
|
|
43
|
+
> `optional` **populateTypeInitialisers?**: (`engineCore`, `context`) => `void`
|
|
44
44
|
|
|
45
45
|
Populate the type initialisers for the engine.
|
|
46
46
|
|
|
@@ -60,9 +60,9 @@ Populate the type initialisers for the engine.
|
|
|
60
60
|
|
|
61
61
|
***
|
|
62
62
|
|
|
63
|
-
### customBootstrap
|
|
63
|
+
### customBootstrap? {#custombootstrap}
|
|
64
64
|
|
|
65
|
-
> `optional` **customBootstrap
|
|
65
|
+
> `optional` **customBootstrap?**: (`engineCore`, `context`) => `Promise`\<`void`\>
|
|
66
66
|
|
|
67
67
|
Custom bootstrap method for the engine.
|
|
68
68
|
|
package/locales/en.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
"bootstrapFailed": "Failed to bootstrap component type \"{className}\" with instance type \"{instanceType}\"",
|
|
6
6
|
"componentStartFailed": "Failed to start component type \"{className}\" with instance type \"{instanceType}\"",
|
|
7
7
|
"componentStopFailed": "Failed to stop component type \"{className}\" with instance type \"{instanceType}\"",
|
|
8
|
-
"instanceTypeNotFound": "Instance type not found for \"{type}\"
|
|
8
|
+
"instanceTypeNotFound": "Instance type not found for \"{type}\"",
|
|
9
|
+
"instanceTypeNotFoundWithFeatures": "Instance type not found for \"{type}\" with features \"{features}\""
|
|
9
10
|
},
|
|
10
11
|
"fileStateStorage": {
|
|
11
12
|
"failedLoading": "Failed to load file state storage from \"{filename}\"",
|