@vnejs/plugins.scenario.fastforward 0.1.13 → 0.1.15
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/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/modules/fastforward.d.ts +2 -5
- package/dist/modules/fastforward.js +5 -13
- package/dist/modules/visits.d.ts +4 -4
- package/dist/modules/visits.js +10 -8
- package/dist/types.d.ts +2 -3
- package/package.json +3 -4
- package/src/index.ts +2 -2
- package/src/modules/fastforward.ts +9 -16
- package/src/modules/visits.ts +14 -12
- package/src/types.ts +2 -3
- package/dist/utils/fastforward.d.ts +0 -2
- package/dist/utils/fastforward.js +0 -1
- package/src/utils/fastforward.ts +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "@vnejs/
|
|
1
|
+
import "@vnejs/contracts.scenario.fastforward";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "@vnejs/
|
|
1
|
+
import "@vnejs/contracts.scenario.fastforward";
|
|
2
2
|
import { regPlugin } from "@vnejs/shared";
|
|
3
|
-
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/
|
|
3
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/contracts.scenario.fastforward";
|
|
4
4
|
import { Fastforward } from "./modules/fastforward.js";
|
|
5
5
|
import { FastforwardVisits } from "./modules/visits.js";
|
|
6
6
|
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS, constants: CONSTANTS }, [Fastforward, FastforwardVisits]);
|
|
@@ -3,10 +3,8 @@ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPl
|
|
|
3
3
|
export declare class Fastforward extends ModuleCore<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
|
|
4
4
|
name: string;
|
|
5
5
|
emitStop: () => Promise<unknown[]> | undefined;
|
|
6
|
-
emitFastforwardEmit: () => Promise<unknown[]> | undefined;
|
|
7
|
-
emitFastforwardEmitCheck: () => Promise<unknown[]> | undefined;
|
|
8
6
|
subscribe: () => void;
|
|
9
|
-
init: () => Promise<[unknown[] | undefined, unknown[] | undefined
|
|
7
|
+
init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
|
|
10
8
|
onToggle: () => void;
|
|
11
9
|
onCheck: () => {
|
|
12
10
|
isAllowed: boolean;
|
|
@@ -15,8 +13,7 @@ export declare class Fastforward extends ModuleCore<FastforwardPluginEvents, Fas
|
|
|
15
13
|
onStart: () => void;
|
|
16
14
|
onStop: () => void;
|
|
17
15
|
onFastforwardEmit: () => Promise<void>;
|
|
18
|
-
onFastforwardEmitCheck: () => number
|
|
16
|
+
onFastforwardEmitCheck: () => number;
|
|
19
17
|
setValue: (value: boolean) => void;
|
|
20
|
-
check: () => Promise<void>;
|
|
21
18
|
notFastForward: (s: string) => boolean;
|
|
22
19
|
}
|
|
@@ -2,8 +2,6 @@ import { ModuleCore } from "@vnejs/module.core";
|
|
|
2
2
|
export class Fastforward extends ModuleCore {
|
|
3
3
|
name = "fastforward";
|
|
4
4
|
emitStop = () => this.emit(this.EVENTS.FASTFORWARD.STOP);
|
|
5
|
-
emitFastforwardEmit = () => this.emit(this.EVENTS.FASTFORWARD.EMIT);
|
|
6
|
-
emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
|
|
7
5
|
subscribe = () => {
|
|
8
6
|
this.on(this.EVENTS.FASTFORWARD.STOP, this.onStop);
|
|
9
7
|
this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
|
|
@@ -11,12 +9,10 @@ export class Fastforward extends ModuleCore {
|
|
|
11
9
|
this.on(this.EVENTS.FASTFORWARD.TOGGLE, this.onToggle);
|
|
12
10
|
this.on(this.EVENTS.FASTFORWARD.EMIT, this.onFastforwardEmit);
|
|
13
11
|
this.on(this.EVENTS.FASTFORWARD.EMIT_CHECK, this.onFastforwardEmitCheck);
|
|
14
|
-
this.on(this.EVENTS.INTERACT.ENDED, this.emitFastforwardEmitCheck);
|
|
15
12
|
this.on(this.EVENTS.SYSTEM.STARTED, this.emitStop);
|
|
16
13
|
this.on(this.EVENTS.STATE.CLEAR, this.emitStop);
|
|
17
14
|
};
|
|
18
15
|
init = () => Promise.all([
|
|
19
|
-
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK }),
|
|
20
16
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
|
|
21
17
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
|
|
22
18
|
]);
|
|
@@ -27,12 +23,13 @@ export class Fastforward extends ModuleCore {
|
|
|
27
23
|
onFastforwardEmit = async () => {
|
|
28
24
|
if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED])
|
|
29
25
|
return;
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const checkResults = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []);
|
|
27
|
+
if (!checkResults.every((r) => r.isAllowed))
|
|
28
|
+
this.setValue(false);
|
|
32
29
|
await this.emit(this.EVENTS.INTERACT.EMIT);
|
|
33
30
|
await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
|
|
34
31
|
};
|
|
35
|
-
onFastforwardEmitCheck = () => this.shared.isFastforwardOn &&
|
|
32
|
+
onFastforwardEmitCheck = () => setTimeout(() => this.shared.isFastforwardOn && this.emit(this.EVENTS.FASTFORWARD.EMIT), this.shared.settings[this.SETTINGS.FASTFORWARD.DELAY]);
|
|
36
33
|
setValue = (value) => {
|
|
37
34
|
this.shared.isFastforwardOn = value;
|
|
38
35
|
if (value) {
|
|
@@ -45,12 +42,7 @@ export class Fastforward extends ModuleCore {
|
|
|
45
42
|
}
|
|
46
43
|
this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value });
|
|
47
44
|
if (value)
|
|
48
|
-
this.
|
|
49
|
-
};
|
|
50
|
-
check = async () => {
|
|
51
|
-
const results = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []);
|
|
52
|
-
if (!results.every((r) => r.isAllowed))
|
|
53
|
-
this.setValue(false);
|
|
45
|
+
this.emit(this.EVENTS.FASTFORWARD.EMIT);
|
|
54
46
|
};
|
|
55
47
|
notFastForward = (s) => s !== this.name;
|
|
56
48
|
}
|
package/dist/modules/visits.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import "@vnejs/
|
|
1
|
+
import "@vnejs/contracts.core.scenario";
|
|
2
2
|
import { ModuleCore } from "@vnejs/module.core";
|
|
3
|
-
import type {
|
|
4
|
-
import type { ModuleGlobalStateFastforwardVisits } from "@vnejs/
|
|
3
|
+
import type { ScenarioExecPayload } from "@vnejs/contracts.core.scenario";
|
|
4
|
+
import type { ModuleGlobalStateFastforwardVisits } from "@vnejs/contracts.scenario.fastforward";
|
|
5
5
|
import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
|
|
6
6
|
export declare class FastforwardVisits extends ModuleCore<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams, ModuleGlobalStateFastforwardVisits> {
|
|
7
7
|
name: string;
|
|
8
8
|
visits: Record<string, number>;
|
|
9
9
|
subscribe: () => void;
|
|
10
10
|
init: () => Promise<void>;
|
|
11
|
-
|
|
11
|
+
onExec: ({ module, block, line, args, keywords }?: ScenarioExecPayload) => Promise<void>;
|
|
12
12
|
onVisitCheck: () => Promise<{
|
|
13
13
|
isAllowed: boolean;
|
|
14
14
|
source: string;
|
package/dist/modules/visits.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import "@vnejs/
|
|
1
|
+
import "@vnejs/contracts.core.scenario";
|
|
2
2
|
import { ModuleCore } from "@vnejs/module.core";
|
|
3
3
|
export class FastforwardVisits extends ModuleCore {
|
|
4
4
|
name = "fastforward.visits";
|
|
5
5
|
visits = {};
|
|
6
6
|
subscribe = () => {
|
|
7
|
-
this.on(this.EVENTS.
|
|
7
|
+
this.on(this.EVENTS.SCENARIO.EXEC, this.onExec);
|
|
8
8
|
this.on(this.EVENTS.FASTFORWARD.CHECK, this.onVisitCheck);
|
|
9
9
|
this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
|
|
10
10
|
this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
|
|
11
11
|
this.on(this.EVENTS.STATE.SET, this.onSetStateClone);
|
|
12
12
|
};
|
|
13
13
|
init = async () => {
|
|
14
|
+
await this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK_VISITED, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK_VISITED });
|
|
14
15
|
this.visits = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name }));
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
+
onExec = async ({ module, block, line, args = {}, keywords = [] } = {}) => {
|
|
17
18
|
const key = (await this.emitOne(this.EVENTS.VENDORS.HASH, this.state));
|
|
18
19
|
this.visits[key] = 1;
|
|
19
20
|
this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: 1 });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
this.setState({ module, block, line, args, keywords, label: this.globalState.scenario.label });
|
|
22
|
+
};
|
|
23
|
+
onVisitCheck = async () => {
|
|
24
|
+
const isAllowed = !this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK_VISITED] || Boolean(this.visits[(await this.getHash())]);
|
|
25
|
+
return { isAllowed, source: this.name };
|
|
23
26
|
};
|
|
24
|
-
onVisitCheck = async () => ({ isAllowed: Boolean(this.visits[(await this.getHash())]), source: this.name });
|
|
25
27
|
onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
|
|
26
28
|
getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
|
|
27
|
-
getDefaultState = () => ({
|
|
29
|
+
getDefaultState = () => ({ label: "", args: {}, keywords: [] });
|
|
28
30
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export type FastforwardPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents> & Record<TextPluginName, TextSubscribeEvents>;
|
|
2
|
+
import type { Constants, Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/contracts.scenario.fastforward";
|
|
3
|
+
export type FastforwardPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents>;
|
|
5
4
|
export type FastforwardPluginConstants = ModuleCoreConstants & Record<PluginName, Constants>;
|
|
6
5
|
export type FastforwardPluginSettings = ModuleCoreSettings & Record<PluginName, SettingsKeys>;
|
|
7
6
|
export type FastforwardPluginParams = ModuleCoreParams & Record<PluginName, Params>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.scenario.fastforward",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,12 +30,11 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@vnejs/
|
|
33
|
+
"@vnejs/contracts.scenario.fastforward": "~0.1.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@vnejs/module.core": "~0.1.0",
|
|
37
|
-
"@vnejs/shared": "~0.1.0"
|
|
38
|
-
"@vnejs/plugins.text.contract": "~0.1.0"
|
|
37
|
+
"@vnejs/shared": "~0.1.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"@vnejs/configs.ts-common": "~0.1.0"
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import "@vnejs/
|
|
2
|
+
import "@vnejs/contracts.scenario.fastforward";
|
|
3
3
|
|
|
4
4
|
import { regPlugin } from "@vnejs/shared";
|
|
5
|
-
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/
|
|
5
|
+
import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/contracts.scenario.fastforward";
|
|
6
6
|
|
|
7
7
|
import { Fastforward } from "./modules/fastforward.js";
|
|
8
8
|
import { FastforwardVisits } from "./modules/visits.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
|
|
3
|
-
import type { FastforwardChangedPayload, FastforwardCheckResult } from "@vnejs/
|
|
3
|
+
import type { FastforwardChangedPayload, FastforwardCheckResult } from "@vnejs/contracts.scenario.fastforward";
|
|
4
4
|
|
|
5
5
|
import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
|
|
6
6
|
|
|
@@ -8,8 +8,6 @@ export class Fastforward extends ModuleCore<FastforwardPluginEvents, Fastforward
|
|
|
8
8
|
name = "fastforward";
|
|
9
9
|
|
|
10
10
|
emitStop = () => this.emit(this.EVENTS.FASTFORWARD.STOP);
|
|
11
|
-
emitFastforwardEmit = () => this.emit(this.EVENTS.FASTFORWARD.EMIT);
|
|
12
|
-
emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
|
|
13
11
|
|
|
14
12
|
subscribe = () => {
|
|
15
13
|
this.on(this.EVENTS.FASTFORWARD.STOP, this.onStop);
|
|
@@ -20,34 +18,35 @@ export class Fastforward extends ModuleCore<FastforwardPluginEvents, Fastforward
|
|
|
20
18
|
this.on(this.EVENTS.FASTFORWARD.EMIT, this.onFastforwardEmit);
|
|
21
19
|
this.on(this.EVENTS.FASTFORWARD.EMIT_CHECK, this.onFastforwardEmitCheck);
|
|
22
20
|
|
|
23
|
-
this.on(this.EVENTS.INTERACT.ENDED, this.emitFastforwardEmitCheck);
|
|
24
|
-
|
|
25
21
|
this.on(this.EVENTS.SYSTEM.STARTED, this.emitStop);
|
|
26
22
|
this.on(this.EVENTS.STATE.CLEAR, this.emitStop);
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
init = () =>
|
|
30
26
|
Promise.all([
|
|
31
|
-
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK }),
|
|
32
27
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
|
|
33
28
|
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
|
|
34
29
|
]);
|
|
35
30
|
|
|
36
31
|
onToggle = () => this.setValue(!this.shared.isFastforwardOn);
|
|
37
|
-
onCheck = () => ({ isAllowed: this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED], source: this.name } satisfies FastforwardCheckResult
|
|
32
|
+
onCheck = () => ({ isAllowed: this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED], source: this.name }) satisfies FastforwardCheckResult;
|
|
38
33
|
onStart = () => this.setValue(true);
|
|
39
34
|
onStop = () => this.setValue(false);
|
|
40
35
|
|
|
41
36
|
onFastforwardEmit = async () => {
|
|
42
37
|
if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED]) return;
|
|
43
|
-
|
|
38
|
+
|
|
39
|
+
const checkResults = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []) as FastforwardCheckResult[];
|
|
40
|
+
|
|
41
|
+
if (!checkResults.every((r) => r.isAllowed)) this.setValue(false);
|
|
44
42
|
|
|
45
43
|
await this.emit(this.EVENTS.INTERACT.EMIT);
|
|
46
44
|
|
|
47
45
|
await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
onFastforwardEmitCheck = () =>
|
|
48
|
+
onFastforwardEmitCheck = () =>
|
|
49
|
+
setTimeout(() => this.shared.isFastforwardOn && this.emit(this.EVENTS.FASTFORWARD.EMIT), this.shared.settings[this.SETTINGS.FASTFORWARD.DELAY]);
|
|
51
50
|
|
|
52
51
|
setValue = (value: boolean) => {
|
|
53
52
|
this.shared.isFastforwardOn = value;
|
|
@@ -62,13 +61,7 @@ export class Fastforward extends ModuleCore<FastforwardPluginEvents, Fastforward
|
|
|
62
61
|
|
|
63
62
|
this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value } satisfies FastforwardChangedPayload);
|
|
64
63
|
|
|
65
|
-
if (value) this.
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
check = async () => {
|
|
69
|
-
const results = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []) as FastforwardCheckResult[];
|
|
70
|
-
|
|
71
|
-
if (!results.every((r) => r.isAllowed)) this.setValue(false);
|
|
64
|
+
if (value) this.emit(this.EVENTS.FASTFORWARD.EMIT);
|
|
72
65
|
};
|
|
73
66
|
|
|
74
67
|
notFastForward = (s: string) => s !== this.name;
|
package/src/modules/visits.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "@vnejs/
|
|
1
|
+
import "@vnejs/contracts.core.scenario";
|
|
2
2
|
|
|
3
3
|
import { ModuleCore } from "@vnejs/module.core";
|
|
4
|
-
import type {
|
|
5
|
-
import type { FastforwardCheckResult, ModuleGlobalStateFastforwardVisits } from "@vnejs/
|
|
4
|
+
import type { ScenarioExecPayload } from "@vnejs/contracts.core.scenario";
|
|
5
|
+
import type { FastforwardCheckResult, ModuleGlobalStateFastforwardVisits } from "@vnejs/contracts.scenario.fastforward";
|
|
6
6
|
|
|
7
7
|
import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ export class FastforwardVisits extends ModuleCore<
|
|
|
18
18
|
visits: Record<string, number> = {};
|
|
19
19
|
|
|
20
20
|
subscribe = () => {
|
|
21
|
-
this.on(this.EVENTS.
|
|
21
|
+
this.on(this.EVENTS.SCENARIO.EXEC, this.onExec);
|
|
22
22
|
|
|
23
23
|
this.on(this.EVENTS.FASTFORWARD.CHECK, this.onVisitCheck);
|
|
24
24
|
this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
|
|
@@ -28,27 +28,29 @@ export class FastforwardVisits extends ModuleCore<
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
init = async () => {
|
|
31
|
+
await this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK_VISITED, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK_VISITED });
|
|
32
|
+
|
|
31
33
|
this.visits = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name })) as Record<string, number>;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
onExec = async ({ module, block, line, args = {}, keywords = [] }: ScenarioExecPayload = {}) => {
|
|
35
37
|
const key = (await this.emitOne(this.EVENTS.VENDORS.HASH, this.state)) as string;
|
|
36
38
|
|
|
37
39
|
this.visits[key] = 1;
|
|
38
40
|
this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: 1 });
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
const meet = speaker ? (this.globalState["text.meet"]?.[speaker] ?? 0) : 0;
|
|
42
|
-
|
|
43
|
-
this.setState({ text, label, speaker, meet });
|
|
42
|
+
this.setState({ module, block, line, args, keywords, label: this.globalState.scenario.label });
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
onVisitCheck = async () =>
|
|
47
|
-
|
|
45
|
+
onVisitCheck = async () => {
|
|
46
|
+
const isAllowed = !this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK_VISITED] || Boolean(this.visits[(await this.getHash()) as string]);
|
|
47
|
+
|
|
48
|
+
return { isAllowed, source: this.name } satisfies FastforwardCheckResult;
|
|
49
|
+
};
|
|
48
50
|
|
|
49
51
|
onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
|
|
50
52
|
|
|
51
53
|
getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
|
|
52
54
|
|
|
53
|
-
getDefaultState = (): ModuleGlobalStateFastforwardVisits => ({
|
|
55
|
+
getDefaultState = (): ModuleGlobalStateFastforwardVisits => ({ label: "", args: {}, keywords: [] });
|
|
54
56
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
-
import type {
|
|
3
|
-
import type { Constants, Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
|
|
2
|
+
import type { Constants, Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/contracts.scenario.fastforward";
|
|
4
3
|
|
|
5
|
-
export type FastforwardPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents
|
|
4
|
+
export type FastforwardPluginEvents = ModuleCoreEvents & Record<PluginName, SubscribeEvents>;
|
|
6
5
|
|
|
7
6
|
export type FastforwardPluginConstants = ModuleCoreConstants & Record<PluginName, Constants>;
|
|
8
7
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/utils/fastforward.ts
DELETED