@remvst/game-navigation-core 1.8.3 → 1.9.0
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/lib/navigation/resolver.js +1 -1
- package/lib/ui/screen.d.ts +0 -1
- package/lib/ui/screen.js +2 -1
- package/lib/util/navigation-flow.d.ts +2 -1
- package/lib/util/navigation-flow.js +13 -2
- package/package.json +2 -2
- package/src/navigation/resolver.ts +3 -1
- package/src/storage/get-client-storage.ts +4 -1
- package/src/ui/screen.ts +2 -5
- package/src/util/navigation-flow.ts +16 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Resolver = exports.UserCancelledError = void 0;
|
|
4
4
|
class UserCancelledError extends Error {
|
|
5
|
-
constructor(message =
|
|
5
|
+
constructor(message = "User backed out and cancelled navigation flow") {
|
|
6
6
|
super(message);
|
|
7
7
|
}
|
|
8
8
|
}
|
package/lib/ui/screen.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export declare abstract class Screen {
|
|
|
11
11
|
interpolationPool: InterpolationPool;
|
|
12
12
|
delegate: ScreenDelegate | null;
|
|
13
13
|
protected readonly subscreens: Screen[];
|
|
14
|
-
constructor();
|
|
15
14
|
addSubscreen(screen: Screen): void;
|
|
16
15
|
bind(game: Game): void;
|
|
17
16
|
abstract get id(): string;
|
package/lib/ui/screen.js
CHANGED
|
@@ -5,12 +5,12 @@ const animate_js_1 = require("@remvst/animate.js");
|
|
|
5
5
|
const inputs_1 = require("../interaction/inputs");
|
|
6
6
|
class Screen {
|
|
7
7
|
constructor() {
|
|
8
|
+
this.game = null;
|
|
8
9
|
this.cursorType = "default";
|
|
9
10
|
this.age = 0;
|
|
10
11
|
this.frameCount = 0;
|
|
11
12
|
this.delegate = null;
|
|
12
13
|
this.subscreens = [];
|
|
13
|
-
this.game = null;
|
|
14
14
|
}
|
|
15
15
|
addSubscreen(screen) {
|
|
16
16
|
this.subscreens.push(screen);
|
|
@@ -40,6 +40,7 @@ class Screen {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
destroy() {
|
|
43
|
+
this.interpolationPool.clear();
|
|
43
44
|
this.delegate?.onDestroy();
|
|
44
45
|
for (const sub of this.subscreens) {
|
|
45
46
|
sub.destroy();
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function navigationFlow<T>(flow: Promise<T>): void;
|
|
1
|
+
export declare function navigationFlow<T>(flow: Promise<T> | (() => Promise<T>)): void;
|
|
2
|
+
export declare function navigationClickHandler<T>(flow: () => Promise<T>): () => void;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.navigationFlow = void 0;
|
|
3
|
+
exports.navigationClickHandler = exports.navigationFlow = void 0;
|
|
4
4
|
const resolver_1 = require("../navigation/resolver");
|
|
5
5
|
function navigationFlow(flow) {
|
|
6
|
-
|
|
6
|
+
let promise;
|
|
7
|
+
if (flow instanceof Function) {
|
|
8
|
+
promise = flow();
|
|
9
|
+
}
|
|
10
|
+
if (flow instanceof Promise) {
|
|
11
|
+
promise = flow;
|
|
12
|
+
}
|
|
13
|
+
promise.catch((err) => {
|
|
7
14
|
if (err instanceof resolver_1.UserCancelledError)
|
|
8
15
|
return;
|
|
9
16
|
console.error(err);
|
|
10
17
|
});
|
|
11
18
|
}
|
|
12
19
|
exports.navigationFlow = navigationFlow;
|
|
20
|
+
function navigationClickHandler(flow) {
|
|
21
|
+
return () => navigationFlow(flow);
|
|
22
|
+
}
|
|
23
|
+
exports.navigationClickHandler = navigationClickHandler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remvst/game-navigation-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Rémi Vansteelandt",
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@remvst/animate.js": "^3.
|
|
13
|
+
"@remvst/animate.js": "^3.1.0",
|
|
14
14
|
"@remvst/client-inputs": "^1.0.4",
|
|
15
15
|
"@remvst/optimization": "^1.0.1"
|
|
16
16
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Screen } from "../ui/screen";
|
|
2
2
|
|
|
3
3
|
export class UserCancelledError extends Error {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(
|
|
5
|
+
message: string = "User backed out and cancelled navigation flow",
|
|
6
|
+
) {
|
|
5
7
|
super(message);
|
|
6
8
|
}
|
|
7
9
|
}
|
|
@@ -15,7 +15,10 @@ export function getClientStorage(): Storage {
|
|
|
15
15
|
}
|
|
16
16
|
return storage;
|
|
17
17
|
} catch (err) {
|
|
18
|
-
console.error(
|
|
18
|
+
console.error(
|
|
19
|
+
`Failed to get ${label} (${err.message}), falling back`,
|
|
20
|
+
err,
|
|
21
|
+
);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
}
|
package/src/ui/screen.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ScreenInputs } from "../interaction/inputs";
|
|
|
4
4
|
import { ScreenDelegate } from "./screen-delegate";
|
|
5
5
|
|
|
6
6
|
export abstract class Screen {
|
|
7
|
-
game: Game;
|
|
7
|
+
game: Game = null;
|
|
8
8
|
cursorType: string = "default";
|
|
9
9
|
|
|
10
10
|
inputs: ScreenInputs;
|
|
@@ -15,10 +15,6 @@ export abstract class Screen {
|
|
|
15
15
|
|
|
16
16
|
protected readonly subscreens: Screen[] = [];
|
|
17
17
|
|
|
18
|
-
constructor() {
|
|
19
|
-
this.game = null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
addSubscreen(screen: Screen) {
|
|
23
19
|
this.subscreens.push(screen);
|
|
24
20
|
}
|
|
@@ -72,6 +68,7 @@ export abstract class Screen {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
destroy() {
|
|
71
|
+
this.interpolationPool.clear();
|
|
75
72
|
this.delegate?.onDestroy();
|
|
76
73
|
|
|
77
74
|
for (const sub of this.subscreens) {
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { UserCancelledError } from "../navigation/resolver";
|
|
2
2
|
|
|
3
|
-
export function navigationFlow<T>(flow: Promise<T>) {
|
|
4
|
-
|
|
3
|
+
export function navigationFlow<T>(flow: Promise<T> | (() => Promise<T>)): void {
|
|
4
|
+
let promise: Promise<T>;
|
|
5
|
+
|
|
6
|
+
if (flow instanceof Function) {
|
|
7
|
+
promise = flow();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (flow instanceof Promise) {
|
|
11
|
+
promise = flow;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
promise.catch((err) => {
|
|
5
15
|
if (err instanceof UserCancelledError) return;
|
|
6
16
|
console.error(err);
|
|
7
17
|
});
|
|
8
18
|
}
|
|
19
|
+
|
|
20
|
+
export function navigationClickHandler<T>(flow: () => Promise<T>): () => void {
|
|
21
|
+
return () => navigationFlow(flow);
|
|
22
|
+
}
|