@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.
- package/dist/director.js +131 -21
- package/dist/driver.d.ts +1 -0
- package/dist/driver.js +1225 -107
- package/dist/platform-storage.js +14 -3
- package/dist/testing.js +9 -1
- package/package.json +1 -1
package/dist/platform-storage.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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