@vnejs/plugins.scenario.fastforward 0.2.3 → 0.2.5
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/modules/emit.js +1 -1
- package/dist/modules/fastforward.d.ts +3 -2
- package/dist/modules/fastforward.js +6 -6
- package/dist/modules/storage.d.ts +2 -2
- package/dist/modules/storage.js +1 -1
- package/dist/modules/visits.d.ts +1 -1
- package/dist/modules/visits.js +1 -1
- package/package.json +1 -1
- package/src/modules/emit.ts +1 -3
- package/src/modules/fastforward.ts +7 -6
- package/src/modules/storage.ts +1 -1
- package/src/modules/visits.ts +1 -1
- package/src/tests/visits.test.ts +2 -2
package/dist/modules/emit.js
CHANGED
|
@@ -8,7 +8,7 @@ export class FastforwardEmit extends ModuleCore {
|
|
|
8
8
|
onFastforwardEmit = async () => {
|
|
9
9
|
if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED])
|
|
10
10
|
return;
|
|
11
|
-
const checkResults = (
|
|
11
|
+
const checkResults = (await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? [];
|
|
12
12
|
if (!checkResults.every((r) => r.isAllowed))
|
|
13
13
|
await this.emit(this.EVENTS.FASTFORWARD.STOP);
|
|
14
14
|
await this.emit(this.EVENTS.INTERACT.EMIT);
|
|
@@ -2,9 +2,10 @@ import { ModuleCore } from "@vnejs/module.core";
|
|
|
2
2
|
import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
|
|
3
3
|
export declare class Fastforward extends ModuleCore<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
|
|
4
4
|
name: string;
|
|
5
|
-
emitStop: () => Promise<
|
|
5
|
+
emitStop: () => Promise<import("@vnejs/shared").EmitResults<"vne:fastforward:stop">> | undefined;
|
|
6
6
|
subscribe: () => void;
|
|
7
|
-
|
|
7
|
+
setup: () => Promise<[import("@vnejs/shared").EmitResults<"vne:settings:init"> | undefined, import("@vnejs/shared").EmitResults<"vne:settings:init"> | undefined]>;
|
|
8
|
+
init: () => void;
|
|
8
9
|
onToggle: () => void;
|
|
9
10
|
onCheck: () => {
|
|
10
11
|
isAllowed: boolean;
|
|
@@ -9,12 +9,12 @@ export class Fastforward extends ModuleCore {
|
|
|
9
9
|
this.on(this.EVENTS.FASTFORWARD.TOGGLE, this.onToggle);
|
|
10
10
|
this.on(this.EVENTS.STATE.CLEAR, this.emitStop);
|
|
11
11
|
};
|
|
12
|
+
setup = () => Promise.all([
|
|
13
|
+
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
|
|
14
|
+
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
|
|
15
|
+
]);
|
|
12
16
|
init = () => {
|
|
13
17
|
this.setValue(false);
|
|
14
|
-
return Promise.all([
|
|
15
|
-
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
|
|
16
|
-
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
|
|
17
|
-
]);
|
|
18
18
|
};
|
|
19
19
|
onToggle = () => this.setValue(!this.shared.isFastforwardOn);
|
|
20
20
|
onCheck = () => ({ isAllowed: this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED], source: this.name });
|
|
@@ -22,8 +22,8 @@ export class Fastforward extends ModuleCore {
|
|
|
22
22
|
onStop = () => this.setValue(false);
|
|
23
23
|
setValue = (value) => {
|
|
24
24
|
this.shared.isFastforwardOn = value;
|
|
25
|
-
this.shared.mediaNoTimeoutSources
|
|
26
|
-
this.shared.viewForceAnimationSources
|
|
25
|
+
this.shared.mediaNoTimeoutSources.set(this.name, value);
|
|
26
|
+
this.shared.viewForceAnimationSources.set(this.name, value);
|
|
27
27
|
this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value });
|
|
28
28
|
if (value)
|
|
29
29
|
this.emit(this.EVENTS.FASTFORWARD.EMIT);
|
|
@@ -5,6 +5,6 @@ export declare class FastforwardStorage extends ModuleCore<FastforwardPluginEven
|
|
|
5
5
|
name: string;
|
|
6
6
|
subscribe: () => void;
|
|
7
7
|
init: () => Promise<void>;
|
|
8
|
-
onVisitAdd: ({ key, group }?: FastforwardVisitAddPayload) => Promise<
|
|
9
|
-
onClear: () => Promise<
|
|
8
|
+
onVisitAdd: ({ key, group }?: FastforwardVisitAddPayload) => Promise<import("@vnejs/shared").EmitResults<"vne:storage:set">> | undefined;
|
|
9
|
+
onClear: () => Promise<import("@vnejs/shared").EmitResults<"vne:storage:rm_all">> | undefined;
|
|
10
10
|
}
|
package/dist/modules/storage.js
CHANGED
|
@@ -11,7 +11,7 @@ export class FastforwardStorage extends ModuleCore {
|
|
|
11
11
|
this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
|
|
12
12
|
};
|
|
13
13
|
init = async () => {
|
|
14
|
-
const stored = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name }));
|
|
14
|
+
const stored = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name })) ?? {};
|
|
15
15
|
this.shared.fastforwardStorage = new Set(Object.keys(stored).map(toVisitKey));
|
|
16
16
|
};
|
|
17
17
|
onVisitAdd = ({ key = "", group = "" } = {}) => this.emit(this.EVENTS.STORAGE.SET, { module: this.name, group, key, value: STORAGE_VALUE });
|
package/dist/modules/visits.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPl
|
|
|
4
4
|
export declare class FastforwardVisits extends ModuleCore<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams, ModuleGlobalStateFastforwardVisits> {
|
|
5
5
|
name: string;
|
|
6
6
|
subscribe: () => void;
|
|
7
|
-
|
|
7
|
+
setup: () => Promise<import("@vnejs/shared").EmitResults<"vne:settings:init">> | undefined;
|
|
8
8
|
onVisitCheck: () => Promise<{
|
|
9
9
|
isAllowed: boolean;
|
|
10
10
|
source: string;
|
package/dist/modules/visits.js
CHANGED
|
@@ -8,7 +8,7 @@ export class FastforwardVisits extends ModuleCore {
|
|
|
8
8
|
this.on(this.EVENTS.STATE.SET, this.onSetStateClone);
|
|
9
9
|
this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
setup = () => this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK_VISITED, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK_VISITED });
|
|
12
12
|
onVisitCheck = async () => {
|
|
13
13
|
const isAllowed = !this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK_VISITED] || this.shared.fastforwardStorage.has((await hashSha256(this.state)));
|
|
14
14
|
return { isAllowed, source: this.name };
|
package/package.json
CHANGED
package/src/modules/emit.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
|
|
3
|
-
import type { FastforwardCheckResult } from "@vnejs/contracts.scenario.fastforward";
|
|
4
|
-
|
|
5
3
|
import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
|
|
6
4
|
|
|
7
5
|
export class FastforwardEmit extends ModuleCore<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
|
|
@@ -15,7 +13,7 @@ export class FastforwardEmit extends ModuleCore<FastforwardPluginEvents, Fastfor
|
|
|
15
13
|
onFastforwardEmit = async () => {
|
|
16
14
|
if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED]) return;
|
|
17
15
|
|
|
18
|
-
const checkResults = (
|
|
16
|
+
const checkResults = (await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? [];
|
|
19
17
|
|
|
20
18
|
if (!checkResults.every((r) => r.isAllowed)) await this.emit(this.EVENTS.FASTFORWARD.STOP);
|
|
21
19
|
|
|
@@ -18,13 +18,14 @@ export class Fastforward extends ModuleCore<FastforwardPluginEvents, Fastforward
|
|
|
18
18
|
this.on(this.EVENTS.STATE.CLEAR, this.emitStop);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return Promise.all([
|
|
21
|
+
setup = () =>
|
|
22
|
+
Promise.all([
|
|
25
23
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
|
|
26
24
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
|
|
27
25
|
]);
|
|
26
|
+
|
|
27
|
+
init = () => {
|
|
28
|
+
this.setValue(false);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
onToggle = () => this.setValue(!this.shared.isFastforwardOn);
|
|
@@ -35,8 +36,8 @@ export class Fastforward extends ModuleCore<FastforwardPluginEvents, Fastforward
|
|
|
35
36
|
setValue = (value: boolean) => {
|
|
36
37
|
this.shared.isFastforwardOn = value;
|
|
37
38
|
|
|
38
|
-
this.shared.mediaNoTimeoutSources
|
|
39
|
-
this.shared.viewForceAnimationSources
|
|
39
|
+
this.shared.mediaNoTimeoutSources.set(this.name, value);
|
|
40
|
+
this.shared.viewForceAnimationSources.set(this.name, value);
|
|
40
41
|
|
|
41
42
|
this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value } satisfies FastforwardChangedPayload);
|
|
42
43
|
|
package/src/modules/storage.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class FastforwardStorage extends ModuleCore<FastforwardPluginEvents, Fast
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
init = async () => {
|
|
23
|
-
const stored = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name }))
|
|
23
|
+
const stored = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name })) ?? {};
|
|
24
24
|
|
|
25
25
|
this.shared.fastforwardStorage = new Set(Object.keys(stored).map(toVisitKey));
|
|
26
26
|
};
|
package/src/modules/visits.ts
CHANGED
|
@@ -21,7 +21,7 @@ export class FastforwardVisits extends ModuleCore<
|
|
|
21
21
|
this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
setup = () => this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK_VISITED, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK_VISITED });
|
|
25
25
|
|
|
26
26
|
onVisitCheck = async () => {
|
|
27
27
|
const isAllowed =
|
package/src/tests/visits.test.ts
CHANGED
|
@@ -17,11 +17,11 @@ describe("FastforwardVisits", () => {
|
|
|
17
17
|
registerFastforwardPluginVne();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
it("
|
|
20
|
+
it("setup registers CHECK_VISITED setting", async () => {
|
|
21
21
|
const { module, observer } = createFastforwardTestModule(FastforwardVisits, { subscribe: false });
|
|
22
22
|
const settingsInit = spyEvent(observer, SETTINGS_EVENTS.INIT);
|
|
23
23
|
|
|
24
|
-
await (module as FastforwardVisits).
|
|
24
|
+
await (module as FastforwardVisits).setup();
|
|
25
25
|
|
|
26
26
|
expect(settingsInit).toHaveBeenCalledExactlyOnceWith({
|
|
27
27
|
name: SETTINGS_KEYS.CHECK_VISITED,
|