@antha/engine 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -1,11 +1,38 @@
1
- # Antha
1
+ # @antha/engine
2
2
 
3
- The Antha game engine (for the web), where everything is a mod! The only thing this engine core includes is a framework for flexibly defining and inserting mods with all the tools they need to be successful.
3
+ The Antha game engine (for the web), where everything is a mod! This engine core package only includes a lightweight framework for flexibly defining, inserting, and running the engine mods.
4
4
 
5
5
  - Demo: https://electrovir.github.io/antha/demo
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm i antha
10
+ npm i @antha/engine
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ <!-- example-link: src/readme-examples/creating-engine.example.ts -->
16
+
17
+ ```TypeScript
18
+ import {AnthaEngine, defineAnthaMod} from '@antha/engine';
19
+
20
+ const engine = new AnthaEngine<{
21
+ count: number;
22
+ }>({
23
+ mods: [
24
+ defineAnthaMod<{
25
+ count: number;
26
+ }>({
27
+ modName: 'counter',
28
+ execute({state}) {
29
+ state.count = (state.count ?? 0) + 1;
30
+
31
+ return `Count: ${state.count}`;
32
+ },
33
+ }),
34
+ ],
35
+ });
36
+
37
+ engine.startLoop();
11
38
  ```
@@ -36,10 +36,10 @@ export type ModCleanupParams<State extends AnyObject> = {
36
36
  modInstanceId: ModInstanceId;
37
37
  } & ModOptions;
38
38
  /**
39
- * Return this from a mod's {@link AnthaMod.execute} callback to instruct {@link AnthaEngine} that the
40
- * mod's current execution should not count toward the mod's frequency schedule. This is useful when
41
- * a mod needs a dependency (such as a canvas or external resource) that isn't ready yet so that the
42
- * engine will keep retrying on subsequent ticks, even if the mod has a low execution frequency.
39
+ * Return this from a mod's `execute` callback to instruct {@link AnthaEngine} that the mod's current
40
+ * execution should not count toward the mod's frequency schedule. This is useful when a mod needs a
41
+ * dependency (such as a canvas or external resource) that isn't ready yet so that the engine will
42
+ * keep retrying on subsequent ticks, even if the mod has a low execution frequency.
43
43
  *
44
44
  * @category Mod
45
45
  */
@@ -6,10 +6,10 @@ import { Observable } from 'observavir';
6
6
  import { AnthaUi } from './antha-ui.element.js';
7
7
  import { browserAnthaLogger } from './logger/browser-antha-logger.js';
8
8
  /**
9
- * Return this from a mod's {@link AnthaMod.execute} callback to instruct {@link AnthaEngine} that the
10
- * mod's current execution should not count toward the mod's frequency schedule. This is useful when
11
- * a mod needs a dependency (such as a canvas or external resource) that isn't ready yet so that the
12
- * engine will keep retrying on subsequent ticks, even if the mod has a low execution frequency.
9
+ * Return this from a mod's `execute` callback to instruct {@link AnthaEngine} that the mod's current
10
+ * execution should not count toward the mod's frequency schedule. This is useful when a mod needs a
11
+ * dependency (such as a canvas or external resource) that isn't ready yet so that the engine will
12
+ * keep retrying on subsequent ticks, even if the mod has a low execution frequency.
13
13
  *
14
14
  * @category Mod
15
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/engine",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "The Antha game engine (for the web).",
5
5
  "keywords": [
6
6
  "vir",
@@ -38,7 +38,7 @@
38
38
  "@augment-vir/assert": "^32.2.2",
39
39
  "@augment-vir/common": "^32.2.2",
40
40
  "@paralleldrive/cuid2": "^3.3.0",
41
- "date-vir": "^9.0.0",
41
+ "date-vir": "^9.1.0",
42
42
  "observavir": "^2.3.3",
43
43
  "sentry-vir": "^4.5.1"
44
44
  },