@vnejs/plugins.scenario.fastforward 0.1.1 → 0.1.2

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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+ import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
3
+ import { Fastforward } from "./modules/fastforward.js";
4
+ import { FastforwardVisits } from "./modules/visits.js";
5
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [Fastforward, FastforwardVisits]);
@@ -0,0 +1,23 @@
1
+ import "@vnejs/plugins.audio.contract";
2
+ import "@vnejs/plugins.core.components.contract";
3
+ import "@vnejs/plugins.core.media.contract";
4
+ import "@vnejs/plugins.scenario.fastforward.contract";
5
+ import "@vnejs/plugins.text.contract";
6
+ import { Module } from "@vnejs/module";
7
+ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
8
+ export declare class Fastforward extends Module<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
9
+ name: string;
10
+ emitStop: () => Promise<unknown[]> | undefined;
11
+ emitFastforwardEmit: () => Promise<unknown[]> | undefined;
12
+ emitFastforwardEmitCheck: () => Promise<unknown[]> | undefined;
13
+ subscribe: () => void;
14
+ init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
15
+ onToggle: () => void;
16
+ onStart: () => void;
17
+ onStop: () => void;
18
+ onFastforwardEmit: () => Promise<void>;
19
+ onFastforwardEmitCheck: () => number | false;
20
+ setValue: (value: boolean) => void;
21
+ checkVisited: () => Promise<void>;
22
+ notFastForward: (s: string) => boolean;
23
+ }
@@ -0,0 +1,59 @@
1
+ import "@vnejs/plugins.audio.contract";
2
+ import "@vnejs/plugins.core.components.contract";
3
+ import "@vnejs/plugins.core.media.contract";
4
+ import "@vnejs/plugins.scenario.fastforward.contract";
5
+ import "@vnejs/plugins.text.contract";
6
+ import { Module } from "@vnejs/module";
7
+ export class Fastforward extends Module {
8
+ name = "fastforward";
9
+ emitStop = () => this.emit(this.EVENTS.FASTFORWARD.STOP);
10
+ emitFastforwardEmit = () => this.emit(this.EVENTS.FASTFORWARD.EMIT);
11
+ emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
12
+ subscribe = () => {
13
+ this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
14
+ this.on(this.EVENTS.FASTFORWARD.STOP, this.onStop);
15
+ this.on(this.EVENTS.FASTFORWARD.TOGGLE, this.onToggle);
16
+ this.on(this.EVENTS.FASTFORWARD.EMIT, this.onFastforwardEmit);
17
+ this.on(this.EVENTS.FASTFORWARD.EMIT_CHECK, this.onFastforwardEmitCheck);
18
+ this.on(this.EVENTS.INTERACT.ENDED, this.emitFastforwardEmitCheck);
19
+ this.on(this.EVENTS.SYSTEM.STARTED, this.emitStop);
20
+ this.on(this.EVENTS.STATE.CLEAR, this.emitStop);
21
+ };
22
+ init = () => Promise.all([
23
+ this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK }),
24
+ this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
25
+ ]);
26
+ onToggle = () => this.setValue(!this.shared.isFastforwardOn);
27
+ onStart = () => this.setValue(true);
28
+ onStop = () => this.setValue(false);
29
+ onFastforwardEmit = async () => {
30
+ if (this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK])
31
+ await this.checkVisited();
32
+ await this.emit(this.EVENTS.INTERACT.EMIT);
33
+ await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
34
+ };
35
+ onFastforwardEmitCheck = () => this.shared.isFastforwardOn && setTimeout(this.emitFastforwardEmit, this.shared.settings[this.SETTINGS.FASTFORWARD.DELAY]);
36
+ setValue = (value) => {
37
+ this.shared.isFastforwardOn = value;
38
+ if (value) {
39
+ this.shared.audioNoSmoothSources.push(this.name);
40
+ this.shared.mediaNoTimeoutSources.push(this.name);
41
+ this.shared.textNoAnimationSources.push(this.name);
42
+ this.shared.viewForceAnimationSources.push(this.name);
43
+ }
44
+ else {
45
+ this.shared.audioNoSmoothSources = this.shared.audioNoSmoothSources.filter(this.notFastForward);
46
+ this.shared.mediaNoTimeoutSources = this.shared.mediaNoTimeoutSources.filter(this.notFastForward);
47
+ this.shared.textNoAnimationSources = this.shared.textNoAnimationSources.filter(this.notFastForward);
48
+ this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notFastForward);
49
+ }
50
+ this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value });
51
+ if (value)
52
+ this.emitFastforwardEmit();
53
+ };
54
+ checkVisited = async () => {
55
+ if (!(await this.emitOne(this.EVENTS.FASTFORWARD.CHECK)))
56
+ this.setValue(false);
57
+ };
58
+ notFastForward = (s) => s !== this.name;
59
+ }
@@ -0,0 +1,18 @@
1
+ import "@vnejs/plugins.core.scenario.contract";
2
+ import "@vnejs/plugins.text.contract";
3
+ import { Module } from "@vnejs/module";
4
+ import type { FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
5
+ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
6
+ import type { FastforwardVisitsStateSlicePayload } from "../utils/fastforward.js";
7
+ export declare class FastforwardVisits extends Module<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams, ModuleGlobalStateFastforwardVisits> {
8
+ name: string;
9
+ visits: Record<string, number>;
10
+ subscribe: () => void;
11
+ init: () => Promise<void>;
12
+ onText: ({ text, speaker }?: FastforwardTextPayload) => Promise<void>;
13
+ onVisitCheck: () => Promise<boolean>;
14
+ onClear: () => Promise<unknown[]> | undefined;
15
+ onStateSet: (payload?: FastforwardVisitsStateSlicePayload) => Promise<void>;
16
+ getHash: () => Promise<unknown> | undefined;
17
+ getDefaultState: () => ModuleGlobalStateFastforwardVisits;
18
+ }
@@ -0,0 +1,33 @@
1
+ import "@vnejs/plugins.core.scenario.contract";
2
+ import "@vnejs/plugins.text.contract";
3
+ import { Module } from "@vnejs/module";
4
+ export class FastforwardVisits extends Module {
5
+ name = "fastforward.visits";
6
+ visits = {};
7
+ subscribe = () => {
8
+ this.on(this.EVENTS.TEXT.EMIT, this.onText);
9
+ this.on(this.EVENTS.FASTFORWARD.CHECK, this.onVisitCheck);
10
+ this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
11
+ this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
12
+ this.on(this.EVENTS.STATE.SET, this.onStateSet);
13
+ };
14
+ init = async () => {
15
+ this.visits = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name }));
16
+ };
17
+ onText = async ({ text = "", speaker = "" } = {}) => {
18
+ const key = (await this.emitOne(this.EVENTS.VENDORS.HASH, this.state));
19
+ this.visits[key] = 1;
20
+ this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: 1 });
21
+ const { label } = this.globalState.scenario;
22
+ const meet = speaker ? (this.globalState["text.meet"]?.[speaker] ?? 0) : 0;
23
+ this.setState({ text, label, speaker, meet });
24
+ };
25
+ onVisitCheck = async () => Boolean(this.visits[(await this.getHash())]);
26
+ onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
27
+ onStateSet = async (payload = {}) => {
28
+ const state = payload[this.name];
29
+ return this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, state)));
30
+ };
31
+ getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
32
+ getDefaultState = () => ({ text: "", label: "", speaker: "", meet: 0 });
33
+ }
@@ -0,0 +1,13 @@
1
+ import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
2
+ import type { PluginName as InteractPluginName, SubscribeEvents as InteractSubscribeEvents } from "@vnejs/plugins.core.interact.contract";
3
+ import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
4
+ import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/plugins.core.state.contract";
5
+ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/plugins.core.storage.contract";
6
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
7
+ import type { PluginName as VendorsPluginName, SubscribeEvents as VendorsSubscribeEvents } from "@vnejs/plugins.core.vendors.contract";
8
+ import type { PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/plugins.text.contract";
9
+ import type { Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
10
+ export type FastforwardPluginEvents = VnePluginEventsMapRegistry & Record<PluginName, SubscribeEvents> & Record<InteractPluginName, InteractSubscribeEvents> & Record<SettingsPluginName, SettingsSubscribeEvents> & Record<StatePluginName, StateSubscribeEvents> & Record<StoragePluginName, StorageSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<TextPluginName, TextSubscribeEvents> & Record<VendorsPluginName, VendorsSubscribeEvents>;
11
+ export type FastforwardPluginConstants = VnePluginConstantsMapRegistry;
12
+ export type FastforwardPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
13
+ export type FastforwardPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { FastforwardChangedPayload, FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
2
+ export type FastforwardVisitsStateSlicePayload = {
3
+ [moduleName: string]: ModuleGlobalStateFastforwardVisits | undefined;
4
+ };
5
+ export type { FastforwardChangedPayload, FastforwardTextPayload, ModuleGlobalStateFastforwardVisits };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,17 +1,53 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.scenario.fastforward",
3
- "version": "0.1.1",
4
- "main": "index.js",
3
+ "version": "0.1.2",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "tsconfig.json"
19
+ ],
5
20
  "scripts": {
6
21
  "test": "echo \"Error: no test specified\" && exit 1",
22
+ "build": "npx @vnejs/monorepo package",
7
23
  "publish:major:plugin": "npm run publish:major",
8
24
  "publish:minor:plugin": "npm run publish:minor",
9
25
  "publish:patch:plugin": "npm run publish:patch",
10
- "publish:major": "npm version major && npm publish --access public",
11
- "publish:minor": "npm version minor && npm publish --access public",
12
- "publish:patch": "npm version patch && npm publish --access public"
26
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
27
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
28
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
13
29
  },
14
30
  "author": "",
15
31
  "license": "ISC",
16
- "description": ""
32
+ "dependencies": {
33
+ "@vnejs/plugins.scenario.fastforward.contract": "~0.0.1"
34
+ },
35
+ "peerDependencies": {
36
+ "@vnejs/plugins.audio.contract": "~0.0.1",
37
+ "@vnejs/plugins.core.components.contract": "~0.0.1",
38
+ "@vnejs/plugins.core.media.contract": "~0.0.1",
39
+ "@vnejs/module": "~0.0.1",
40
+ "@vnejs/plugins.core.interact.contract": "~0.0.1",
41
+ "@vnejs/plugins.core.scenario.contract": "~0.0.1",
42
+ "@vnejs/plugins.core.settings.contract": "~0.0.1",
43
+ "@vnejs/plugins.core.state.contract": "~0.0.1",
44
+ "@vnejs/plugins.core.storage.contract": "~0.0.1",
45
+ "@vnejs/plugins.core.system.contract": "~0.0.1",
46
+ "@vnejs/plugins.core.vendors.contract": "~0.0.1",
47
+ "@vnejs/plugins.text.contract": "~0.0.1",
48
+ "@vnejs/shared": "~0.0.9"
49
+ },
50
+ "devDependencies": {
51
+ "@vnejs/configs.ts-common": "~0.0.1"
52
+ }
17
53
  }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { regPlugin } from "@vnejs/shared";
2
+ import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
3
+
4
+ import { Fastforward } from "./modules/fastforward.js";
5
+ import { FastforwardVisits } from "./modules/visits.js";
6
+
7
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [Fastforward, FastforwardVisits]);
@@ -1,11 +1,20 @@
1
+ import "@vnejs/plugins.audio.contract";
2
+ import "@vnejs/plugins.core.components.contract";
3
+ import "@vnejs/plugins.core.media.contract";
4
+ import "@vnejs/plugins.scenario.fastforward.contract";
5
+ import "@vnejs/plugins.text.contract";
6
+
1
7
  import { Module } from "@vnejs/module";
8
+ import type { FastforwardChangedPayload } from "@vnejs/plugins.scenario.fastforward.contract";
9
+
10
+ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
2
11
 
3
- export class Fastforward extends Module {
12
+ export class Fastforward extends Module<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
4
13
  name = "fastforward";
5
14
 
6
15
  emitStop = () => this.emit(this.EVENTS.FASTFORWARD.STOP);
7
16
  emitFastforwardEmit = () => this.emit(this.EVENTS.FASTFORWARD.EMIT);
8
- emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.CHECK);
17
+ emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
9
18
 
10
19
  subscribe = () => {
11
20
  this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
@@ -33,12 +42,14 @@ export class Fastforward extends Module {
33
42
 
34
43
  onFastforwardEmit = async () => {
35
44
  if (this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK]) await this.checkVisited();
45
+
36
46
  await this.emit(this.EVENTS.INTERACT.EMIT);
37
47
  await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
38
48
  };
49
+
39
50
  onFastforwardEmitCheck = () => this.shared.isFastforwardOn && setTimeout(this.emitFastforwardEmit, this.shared.settings[this.SETTINGS.FASTFORWARD.DELAY]);
40
51
 
41
- setValue = (value) => {
52
+ setValue = (value: boolean) => {
42
53
  this.shared.isFastforwardOn = value;
43
54
 
44
55
  if (value) {
@@ -53,10 +64,14 @@ export class Fastforward extends Module {
53
64
  this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notFastForward);
54
65
  }
55
66
 
56
- this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value });
67
+ this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value } satisfies FastforwardChangedPayload);
57
68
 
58
- value && this.emitFastforwardEmit();
69
+ if (value) this.emitFastforwardEmit();
59
70
  };
60
- checkVisited = async () => !(await this.emitOne(this.EVENTS.FASTFORWARD.CHECK)) && this.setValue(false);
61
- notFastForward = (s) => s !== this.name;
71
+
72
+ checkVisited = async () => {
73
+ if (!(await this.emitOne(this.EVENTS.FASTFORWARD.CHECK))) this.setValue(false);
74
+ };
75
+
76
+ notFastForward = (s: string) => s !== this.name;
62
77
  }
@@ -0,0 +1,60 @@
1
+ import "@vnejs/plugins.core.scenario.contract";
2
+ import "@vnejs/plugins.text.contract";
3
+
4
+ import { Module } from "@vnejs/module";
5
+ import type { FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
6
+
7
+ import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
8
+ import type { FastforwardVisitsStateSlicePayload } from "../utils/fastforward.js";
9
+
10
+ export class FastforwardVisits extends Module<
11
+ FastforwardPluginEvents,
12
+ FastforwardPluginConstants,
13
+ FastforwardPluginSettings,
14
+ FastforwardPluginParams,
15
+ ModuleGlobalStateFastforwardVisits
16
+ > {
17
+ name = "fastforward.visits";
18
+
19
+ visits: Record<string, number> = {};
20
+
21
+ subscribe = () => {
22
+ this.on(this.EVENTS.TEXT.EMIT, this.onText);
23
+
24
+ this.on(this.EVENTS.FASTFORWARD.CHECK, this.onVisitCheck);
25
+ this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
26
+
27
+ this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
28
+ this.on(this.EVENTS.STATE.SET, this.onStateSet);
29
+ };
30
+
31
+ init = async () => {
32
+ this.visits = (await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name })) as Record<string, number>;
33
+ };
34
+
35
+ onText = async ({ text = "", speaker = "" }: FastforwardTextPayload = {}) => {
36
+ const key = (await this.emitOne(this.EVENTS.VENDORS.HASH, this.state)) as string;
37
+
38
+ this.visits[key] = 1;
39
+ this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: 1 });
40
+
41
+ const { label } = this.globalState.scenario;
42
+ const meet = speaker ? (this.globalState["text.meet"]?.[speaker] ?? 0) : 0;
43
+
44
+ this.setState({ text, label, speaker, meet });
45
+ };
46
+
47
+ onVisitCheck = async () => Boolean(this.visits[(await this.getHash()) as string]);
48
+
49
+ onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
50
+
51
+ onStateSet = async (payload: FastforwardVisitsStateSlicePayload = {}) => {
52
+ const state = payload[this.name];
53
+
54
+ return this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, state)) as ModuleGlobalStateFastforwardVisits);
55
+ };
56
+
57
+ getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
58
+
59
+ getDefaultState = (): ModuleGlobalStateFastforwardVisits => ({ text: "", label: "", speaker: "", meet: 0 });
60
+ }
package/src/types.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
2
+ import type { PluginName as InteractPluginName, SubscribeEvents as InteractSubscribeEvents } from "@vnejs/plugins.core.interact.contract";
3
+ import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
4
+ import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/plugins.core.state.contract";
5
+ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/plugins.core.storage.contract";
6
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
7
+ import type { PluginName as VendorsPluginName, SubscribeEvents as VendorsSubscribeEvents } from "@vnejs/plugins.core.vendors.contract";
8
+ import type { PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/plugins.text.contract";
9
+ import type { Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
10
+
11
+ export type FastforwardPluginEvents = VnePluginEventsMapRegistry &
12
+ Record<PluginName, SubscribeEvents> &
13
+ Record<InteractPluginName, InteractSubscribeEvents> &
14
+ Record<SettingsPluginName, SettingsSubscribeEvents> &
15
+ Record<StatePluginName, StateSubscribeEvents> &
16
+ Record<StoragePluginName, StorageSubscribeEvents> &
17
+ Record<SystemPluginName, SystemSubscribeEvents> &
18
+ Record<TextPluginName, TextSubscribeEvents> &
19
+ Record<VendorsPluginName, VendorsSubscribeEvents>;
20
+
21
+ export type FastforwardPluginConstants = VnePluginConstantsMapRegistry;
22
+
23
+ export type FastforwardPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
24
+
25
+ export type FastforwardPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params>;
@@ -0,0 +1,7 @@
1
+ import type { FastforwardChangedPayload, FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
2
+
3
+ export type FastforwardVisitsStateSlicePayload = {
4
+ [moduleName: string]: ModuleGlobalStateFastforwardVisits | undefined;
5
+ };
6
+
7
+ export type { FastforwardChangedPayload, FastforwardTextPayload, ModuleGlobalStateFastforwardVisits };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["dist", "node_modules"]
9
+ }
package/const/const.js DELETED
File without changes
package/const/events.js DELETED
@@ -1,14 +0,0 @@
1
- export const SUBSCRIBE_EVENTS = {
2
- STOP: "vne:fastforward:stop",
3
- START: "vne:fastforward:start",
4
- TOGGLE: "vne:fastforward:toggle",
5
-
6
- EMIT: "vne:fastforward:emit",
7
- EMIT_CHECK: "vne:fastforward:emit_check",
8
-
9
- CHECK: "vne:fastforward:check",
10
-
11
- CHANGED: "vne:fastforward:changed",
12
-
13
- CLEAR: "vne:fastforward:clear",
14
- };
package/const/params.js DELETED
@@ -1,2 +0,0 @@
1
- export const DEFAULT_CHECK = true;
2
- export const DEFAULT_DELAY = 50;
package/const/settings.js DELETED
@@ -1,4 +0,0 @@
1
- export const SETTINGS_KEYS = {
2
- CHECK: "vne:fastforward:check",
3
- DELAY: "vne:fastforward:delay",
4
- };
package/index.js DELETED
@@ -1,10 +0,0 @@
1
- import { regPlugin } from "@vnejs/shared";
2
-
3
- import { SUBSCRIBE_EVENTS } from "./const/events";
4
- import { SETTINGS_KEYS } from "./const/settings";
5
- import * as params from "./const/params";
6
-
7
- import { Fastforward } from "./modules/fastforward";
8
- import { FastforwardVisits } from "./modules/visits";
9
-
10
- regPlugin("FASTFORWARD", { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params }, [Fastforward, FastforwardVisits]);
package/modules/visits.js DELETED
@@ -1,40 +0,0 @@
1
- import { Module } from "@vnejs/module";
2
-
3
- export class FastforwardVisits extends Module {
4
- name = "fastforward.visits";
5
-
6
- visits = {};
7
-
8
- subscribe = () => {
9
- this.on(this.EVENTS.TEXT.EMIT, this.onText);
10
-
11
- this.on(this.EVENTS.FASTFORWARD.CHECK, this.onVisitCheck);
12
- this.on(this.EVENTS.FASTFORWARD.CLEAR, this.onClear);
13
-
14
- this.on(this.EVENTS.STATE.CLEAR, this.setDefaultState);
15
- this.on(this.EVENTS.STATE.SET, this.onStateSet);
16
- };
17
-
18
- init = async () => {
19
- this.visits = await this.emitOne(this.EVENTS.STORAGE.GET_ALL, { module: this.name });
20
- };
21
-
22
- onText = async ({ text, speaker } = {}) => {
23
- const key = await this.getHash();
24
-
25
- this.visits[key] = 1;
26
- this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key, value: 1 });
27
-
28
- const { label } = this.globalState.scenario;
29
- const meet = speaker ? this.globalState?.["text.meet"]?.[speaker] : 0;
30
-
31
- this.setState({ text, label, speaker, meet });
32
- };
33
- onVisitCheck = async () => Boolean(this.visits[await this.getHash()]);
34
- onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
35
- onStateSet = async ({ [this.name]: state } = {}) => this.setState(await this.emitOne(this.EVENTS.VENDORS.CLONE, state));
36
-
37
- getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
38
-
39
- getDefaultState = () => ({ text: "", label: "", speaker: "", meet: 0 });
40
- }