@mpgd/tutorial 0.1.0 → 0.1.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.
@@ -5,6 +5,14 @@ export async function createPlatformTutorialProgressStore(input) {
5
5
  let current = null;
6
6
  let available = true;
7
7
  let queue = Promise.resolve();
8
+ function reportError(error) {
9
+ try {
10
+ input.onError?.(error);
11
+ }
12
+ catch {
13
+ // Error reporting must not interrupt storage lifecycle handling.
14
+ }
15
+ }
8
16
  try {
9
17
  const stored = await loadWithTimeout(input.storage.load({ key: input.key }), loadTimeoutMs);
10
18
  if (stored !== null) {
@@ -12,13 +20,16 @@ export async function createPlatformTutorialProgressStore(input) {
12
20
  current = parseTutorialProgress(input.definition, migrated);
13
21
  if (current === null && (input.invalidRecord ?? 'disable') === 'disable') {
14
22
  available = false;
15
- input.onError?.(new Error(`Invalid tutorial progress: ${input.key}`));
23
+ reportError(new Error(`Invalid tutorial progress: ${input.key}`));
24
+ }
25
+ else if (current !== null && input.migrate !== undefined) {
26
+ await input.storage.save({ key: input.key, value: current });
16
27
  }
17
28
  }
18
29
  }
19
30
  catch (error) {
20
31
  available = false;
21
- input.onError?.(error);
32
+ reportError(error);
22
33
  }
23
34
  return {
24
35
  get available() {
@@ -41,7 +52,7 @@ export async function createPlatformTutorialProgressStore(input) {
41
52
  });
42
53
  void (queue = operation.catch((error) => {
43
54
  available = false;
44
- input.onError?.(error);
55
+ reportError(error);
45
56
  }));
46
57
  return operation;
47
58
  },
package/dist/testing.js CHANGED
@@ -144,8 +144,16 @@ function createFloatingReplayTrigger(input, bridge) {
144
144
  button.style.insetBlockStart = '12px';
145
145
  button.style.insetInlineEnd = '12px';
146
146
  button.style.zIndex = '2147483647';
147
+ const reportError = (error) => {
148
+ try {
149
+ input.onError?.(error);
150
+ }
151
+ catch {
152
+ // Error reporting must not interrupt floating replay trigger handling.
153
+ }
154
+ };
147
155
  const handleClick = () => {
148
- void bridge.replay().catch((error) => input.onError?.(error));
156
+ void bridge.replay().catch(reportError);
149
157
  };
150
158
  button.addEventListener('click', handleClick);
151
159
  (options.parent ?? document.body).appendChild(button);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/tutorial",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Headless tutorial progression, optional Driver.js presentation, and local reproduction helpers for mpgd games.",
5
5
  "license": "MIT",
6
6
  "repository": {