@antha/engine 0.5.0 → 0.6.1
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/antha-engine.d.ts +5 -1
- package/dist/antha-engine.js +6 -2
- package/package.json +1 -1
package/dist/antha-engine.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ import { type AnthaLogger } from './logger/antha-logger.js';
|
|
|
9
9
|
* @category Internal
|
|
10
10
|
*/
|
|
11
11
|
export type ModInstanceId = Branded<string, 'antha-mod-instance-id'>;
|
|
12
|
+
/** A timestamp measured from the start of an {@link AnthaEngine}. */
|
|
13
|
+
export type EngineTime = Branded<number, 'antha-engine-time'>;
|
|
14
|
+
/** Creates an {@link EngineTime} from a millisecond offset from an engine's start. */
|
|
15
|
+
export declare function createEngineTime(time: number): EngineTime;
|
|
12
16
|
/**
|
|
13
17
|
* Parameters passed to the execute callback in {@link AnthaMod}.
|
|
14
18
|
*
|
|
@@ -275,7 +279,7 @@ export declare class AnthaEngine<State extends AnyObject = AnyObject> {
|
|
|
275
279
|
*/
|
|
276
280
|
readonly state: Partial<State>;
|
|
277
281
|
/** Total milliseconds elapsed since the engine started. Updated each tick. */
|
|
278
|
-
totalMs:
|
|
282
|
+
totalMs: EngineTime;
|
|
279
283
|
/** When the engine started running its loop. */
|
|
280
284
|
engineStartTime: DOMHighResTimeStamp;
|
|
281
285
|
/**
|
package/dist/antha-engine.js
CHANGED
|
@@ -5,6 +5,10 @@ import { css, html } from 'element-vir';
|
|
|
5
5
|
import { Observable } from 'observavir';
|
|
6
6
|
import { AnthaUi } from './antha-ui.element.js';
|
|
7
7
|
import { browserAnthaLogger } from './logger/browser-antha-logger.js';
|
|
8
|
+
/** Creates an {@link EngineTime} from a millisecond offset from an engine's start. */
|
|
9
|
+
export function createEngineTime(time) {
|
|
10
|
+
return applyBrand(time);
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* Return this from a mod's `execute` callback to instruct {@link AnthaEngine} that the mod's current
|
|
10
14
|
* execution should not count toward the mod's frequency schedule. This is useful when a mod needs a
|
|
@@ -138,7 +142,7 @@ export class AnthaEngine {
|
|
|
138
142
|
*/
|
|
139
143
|
state;
|
|
140
144
|
/** Total milliseconds elapsed since the engine started. Updated each tick. */
|
|
141
|
-
totalMs = 0;
|
|
145
|
+
totalMs = createEngineTime(0);
|
|
142
146
|
/** When the engine started running its loop. */
|
|
143
147
|
engineStartTime = performance.now();
|
|
144
148
|
/**
|
|
@@ -220,7 +224,7 @@ export class AnthaEngine {
|
|
|
220
224
|
/** Clear the array as we're about to populate it. */
|
|
221
225
|
this.currentTemplateArray.length = 0;
|
|
222
226
|
const executionStart = performance.now();
|
|
223
|
-
this.totalMs = executionStart - this.engineStartTime;
|
|
227
|
+
this.totalMs = createEngineTime(executionStart - this.engineStartTime);
|
|
224
228
|
/**
|
|
225
229
|
* Use a plain `for` loop instead of `awaitedForEach` so that synchronous mods execute
|
|
226
230
|
* without microtask boundaries between them. Only yield when a mod actually returns a
|