@vnejs/plugins.scenario.fastforward 0.1.4 → 0.1.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "@vnejs/plugins.scenario.fastforward.contract";
2
2
  import { regPlugin } from "@vnejs/shared";
3
- import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
3
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
4
4
  import { Fastforward } from "./modules/fastforward.js";
5
5
  import { FastforwardVisits } from "./modules/visits.js";
6
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [Fastforward, FastforwardVisits]);
6
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS, constants: CONSTANTS }, [Fastforward, FastforwardVisits]);
@@ -1,8 +1,5 @@
1
- import "@vnejs/plugins.audio.contract";
2
1
  import "@vnejs/plugins.core.components.contract";
3
2
  import "@vnejs/plugins.core.media.contract";
4
- import "@vnejs/plugins.scenario.fastforward.contract";
5
- import "@vnejs/plugins.text.contract";
6
3
  import { Module } from "@vnejs/module";
7
4
  import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
8
5
  export declare class Fastforward extends Module<FastforwardPluginEvents, FastforwardPluginConstants, FastforwardPluginSettings, FastforwardPluginParams> {
@@ -11,13 +8,17 @@ export declare class Fastforward extends Module<FastforwardPluginEvents, Fastfor
11
8
  emitFastforwardEmit: () => Promise<unknown[]> | undefined;
12
9
  emitFastforwardEmitCheck: () => Promise<unknown[]> | undefined;
13
10
  subscribe: () => void;
14
- init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
11
+ init: () => Promise<[unknown[] | undefined, unknown[] | undefined, unknown[] | undefined]>;
15
12
  onToggle: () => void;
13
+ onCheck: () => {
14
+ isAllowed: boolean;
15
+ source: string;
16
+ };
16
17
  onStart: () => void;
17
18
  onStop: () => void;
18
19
  onFastforwardEmit: () => Promise<void>;
19
20
  onFastforwardEmitCheck: () => number | false;
20
21
  setValue: (value: boolean) => void;
21
- checkVisited: () => Promise<void>;
22
+ check: () => Promise<void>;
22
23
  notFastForward: (s: string) => boolean;
23
24
  }
@@ -1,8 +1,5 @@
1
- import "@vnejs/plugins.audio.contract";
2
1
  import "@vnejs/plugins.core.components.contract";
3
2
  import "@vnejs/plugins.core.media.contract";
4
- import "@vnejs/plugins.scenario.fastforward.contract";
5
- import "@vnejs/plugins.text.contract";
6
3
  import { Module } from "@vnejs/module";
7
4
  export class Fastforward extends Module {
8
5
  name = "fastforward";
@@ -10,8 +7,9 @@ export class Fastforward extends Module {
10
7
  emitFastforwardEmit = () => this.emit(this.EVENTS.FASTFORWARD.EMIT);
11
8
  emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
12
9
  subscribe = () => {
13
- this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
14
10
  this.on(this.EVENTS.FASTFORWARD.STOP, this.onStop);
11
+ this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
12
+ this.on(this.EVENTS.FASTFORWARD.CHECK, this.onCheck);
15
13
  this.on(this.EVENTS.FASTFORWARD.TOGGLE, this.onToggle);
16
14
  this.on(this.EVENTS.FASTFORWARD.EMIT, this.onFastforwardEmit);
17
15
  this.on(this.EVENTS.FASTFORWARD.EMIT_CHECK, this.onFastforwardEmitCheck);
@@ -22,13 +20,17 @@ export class Fastforward extends Module {
22
20
  init = () => Promise.all([
23
21
  this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK }),
24
22
  this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
23
+ this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
25
24
  ]);
26
25
  onToggle = () => this.setValue(!this.shared.isFastforwardOn);
26
+ onCheck = () => ({ isAllowed: this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED], source: this.name });
27
27
  onStart = () => this.setValue(true);
28
28
  onStop = () => this.setValue(false);
29
29
  onFastforwardEmit = async () => {
30
+ if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED])
31
+ return;
30
32
  if (this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK])
31
- await this.checkVisited();
33
+ await this.check();
32
34
  await this.emit(this.EVENTS.INTERACT.EMIT);
33
35
  await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
34
36
  };
@@ -36,23 +38,20 @@ export class Fastforward extends Module {
36
38
  setValue = (value) => {
37
39
  this.shared.isFastforwardOn = value;
38
40
  if (value) {
39
- this.shared.audioNoSmoothSources.push(this.name);
40
41
  this.shared.mediaNoTimeoutSources.push(this.name);
41
- this.shared.textNoAnimationSources.push(this.name);
42
42
  this.shared.viewForceAnimationSources.push(this.name);
43
43
  }
44
44
  else {
45
- this.shared.audioNoSmoothSources = this.shared.audioNoSmoothSources.filter(this.notFastForward);
46
45
  this.shared.mediaNoTimeoutSources = this.shared.mediaNoTimeoutSources.filter(this.notFastForward);
47
- this.shared.textNoAnimationSources = this.shared.textNoAnimationSources.filter(this.notFastForward);
48
46
  this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notFastForward);
49
47
  }
50
48
  this.emit(this.EVENTS.FASTFORWARD.CHANGED, { value });
51
49
  if (value)
52
50
  this.emitFastforwardEmit();
53
51
  };
54
- checkVisited = async () => {
55
- if (!(await this.emitOne(this.EVENTS.FASTFORWARD.CHECK)))
52
+ check = async () => {
53
+ const results = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []);
54
+ if (!results.every((r) => r.isAllowed))
56
55
  this.setValue(false);
57
56
  };
58
57
  notFastForward = (s) => s !== this.name;
@@ -9,7 +9,10 @@ export declare class FastforwardVisits extends Module<FastforwardPluginEvents, F
9
9
  subscribe: () => void;
10
10
  init: () => Promise<void>;
11
11
  onText: ({ text, speaker }?: FastforwardTextPayload) => Promise<void>;
12
- onVisitCheck: () => Promise<boolean>;
12
+ onVisitCheck: () => Promise<{
13
+ isAllowed: boolean;
14
+ source: string;
15
+ }>;
13
16
  onClear: () => Promise<unknown[]> | undefined;
14
17
  onStateSet: (payload: ModuleGlobalStateRegistry) => Promise<void>;
15
18
  getHash: () => Promise<unknown> | undefined;
@@ -22,7 +22,7 @@ export class FastforwardVisits extends Module {
22
22
  const meet = speaker ? (this.globalState["text.meet"]?.[speaker] ?? 0) : 0;
23
23
  this.setState({ text, label, speaker, meet });
24
24
  };
25
- onVisitCheck = async () => Boolean(this.visits[(await this.getHash())]);
25
+ onVisitCheck = async () => ({ isAllowed: Boolean(this.visits[(await this.getHash())]), source: this.name });
26
26
  onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
27
27
  onStateSet = async (payload) => this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, this.getStateSlice(payload))));
28
28
  getHash = () => this.emitOne(this.EVENTS.VENDORS.HASH, this.state);
package/dist/types.d.ts CHANGED
@@ -6,8 +6,8 @@ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscri
6
6
  import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
7
7
  import type { PluginName as VendorsPluginName, SubscribeEvents as VendorsSubscribeEvents } from "@vnejs/plugins.core.vendors.contract";
8
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";
9
+ import type { Constants, Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
10
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;
11
+ export type FastforwardPluginConstants = VnePluginConstantsMapRegistry & Record<PluginName, Constants>;
12
12
  export type FastforwardPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
13
13
  export type FastforwardPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.scenario.fastforward",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,10 +33,10 @@
33
33
  "@vnejs/plugins.scenario.fastforward.contract": "~0.0.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@vnejs/plugins.audio.contract": "~0.0.1",
36
+ "@vnejs/module": "~0.0.1",
37
+ "@vnejs/shared": "~0.0.9",
37
38
  "@vnejs/plugins.core.components.contract": "~0.0.1",
38
39
  "@vnejs/plugins.core.media.contract": "~0.0.1",
39
- "@vnejs/module": "~0.0.1",
40
40
  "@vnejs/plugins.core.interact.contract": "~0.0.1",
41
41
  "@vnejs/plugins.core.scenario.contract": "~0.0.1",
42
42
  "@vnejs/plugins.core.settings.contract": "~0.0.1",
@@ -44,8 +44,7 @@
44
44
  "@vnejs/plugins.core.storage.contract": "~0.0.1",
45
45
  "@vnejs/plugins.core.system.contract": "~0.0.1",
46
46
  "@vnejs/plugins.core.vendors.contract": "~0.0.1",
47
- "@vnejs/plugins.text.contract": "~0.0.1",
48
- "@vnejs/shared": "~0.0.9"
47
+ "@vnejs/plugins.text.contract": "~0.0.1"
49
48
  },
50
49
  "devDependencies": {
51
50
  "@vnejs/configs.ts-common": "~0.0.1"
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "@vnejs/plugins.scenario.fastforward.contract";
2
2
 
3
3
  import { regPlugin } from "@vnejs/shared";
4
- import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
4
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.scenario.fastforward.contract";
5
5
 
6
6
  import { Fastforward } from "./modules/fastforward.js";
7
7
  import { FastforwardVisits } from "./modules/visits.js";
8
8
 
9
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [Fastforward, FastforwardVisits]);
9
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS, constants: CONSTANTS }, [Fastforward, FastforwardVisits]);
@@ -1,11 +1,8 @@
1
- import "@vnejs/plugins.audio.contract";
2
1
  import "@vnejs/plugins.core.components.contract";
3
2
  import "@vnejs/plugins.core.media.contract";
4
- import "@vnejs/plugins.scenario.fastforward.contract";
5
- import "@vnejs/plugins.text.contract";
6
3
 
7
4
  import { Module } from "@vnejs/module";
8
- import type { FastforwardChangedPayload } from "@vnejs/plugins.scenario.fastforward.contract";
5
+ import type { FastforwardChangedPayload, FastforwardCheckResult } from "@vnejs/plugins.scenario.fastforward.contract";
9
6
 
10
7
  import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
11
8
 
@@ -17,8 +14,9 @@ export class Fastforward extends Module<FastforwardPluginEvents, FastforwardPlug
17
14
  emitFastforwardEmitCheck = () => this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
18
15
 
19
16
  subscribe = () => {
20
- this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
21
17
  this.on(this.EVENTS.FASTFORWARD.STOP, this.onStop);
18
+ this.on(this.EVENTS.FASTFORWARD.START, this.onStart);
19
+ this.on(this.EVENTS.FASTFORWARD.CHECK, this.onCheck);
22
20
  this.on(this.EVENTS.FASTFORWARD.TOGGLE, this.onToggle);
23
21
 
24
22
  this.on(this.EVENTS.FASTFORWARD.EMIT, this.onFastforwardEmit);
@@ -34,16 +32,20 @@ export class Fastforward extends Module<FastforwardPluginEvents, FastforwardPlug
34
32
  Promise.all([
35
33
  this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.CHECK, value: this.PARAMS.FASTFORWARD.DEFAULT_CHECK }),
36
34
  this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.DELAY, value: this.PARAMS.FASTFORWARD.DEFAULT_DELAY }),
35
+ this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.FASTFORWARD.ENABLED, value: this.PARAMS.FASTFORWARD.DEFAULT_ENABLED }),
37
36
  ]);
38
37
 
39
38
  onToggle = () => this.setValue(!this.shared.isFastforwardOn);
39
+ onCheck = () => ({ isAllowed: this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED], source: this.name } satisfies FastforwardCheckResult);
40
40
  onStart = () => this.setValue(true);
41
41
  onStop = () => this.setValue(false);
42
42
 
43
43
  onFastforwardEmit = async () => {
44
- if (this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK]) await this.checkVisited();
44
+ if (!this.shared.settings[this.SETTINGS.FASTFORWARD.ENABLED]) return;
45
+ if (this.shared.settings[this.SETTINGS.FASTFORWARD.CHECK]) await this.check();
45
46
 
46
47
  await this.emit(this.EVENTS.INTERACT.EMIT);
48
+
47
49
  await this.emit(this.EVENTS.FASTFORWARD.EMIT_CHECK);
48
50
  };
49
51
 
@@ -53,14 +55,10 @@ export class Fastforward extends Module<FastforwardPluginEvents, FastforwardPlug
53
55
  this.shared.isFastforwardOn = value;
54
56
 
55
57
  if (value) {
56
- this.shared.audioNoSmoothSources.push(this.name);
57
58
  this.shared.mediaNoTimeoutSources.push(this.name);
58
- this.shared.textNoAnimationSources.push(this.name);
59
59
  this.shared.viewForceAnimationSources.push(this.name);
60
60
  } else {
61
- this.shared.audioNoSmoothSources = this.shared.audioNoSmoothSources.filter(this.notFastForward);
62
61
  this.shared.mediaNoTimeoutSources = this.shared.mediaNoTimeoutSources.filter(this.notFastForward);
63
- this.shared.textNoAnimationSources = this.shared.textNoAnimationSources.filter(this.notFastForward);
64
62
  this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notFastForward);
65
63
  }
66
64
 
@@ -69,8 +67,10 @@ export class Fastforward extends Module<FastforwardPluginEvents, FastforwardPlug
69
67
  if (value) this.emitFastforwardEmit();
70
68
  };
71
69
 
72
- checkVisited = async () => {
73
- if (!(await this.emitOne(this.EVENTS.FASTFORWARD.CHECK))) this.setValue(false);
70
+ check = async () => {
71
+ const results = ((await this.emit(this.EVENTS.FASTFORWARD.CHECK)) ?? []) as FastforwardCheckResult[];
72
+
73
+ if (!results.every((r) => r.isAllowed)) this.setValue(false);
74
74
  };
75
75
 
76
76
  notFastForward = (s: string) => s !== this.name;
@@ -2,7 +2,7 @@ import "@vnejs/plugins.core.scenario.contract";
2
2
  import "@vnejs/plugins.text.contract";
3
3
 
4
4
  import { Module, type ModuleGlobalStateRegistry } from "@vnejs/module";
5
- import type { FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
5
+ import type { FastforwardCheckResult, FastforwardTextPayload, ModuleGlobalStateFastforwardVisits } from "@vnejs/plugins.scenario.fastforward.contract";
6
6
 
7
7
  import type { FastforwardPluginConstants, FastforwardPluginEvents, FastforwardPluginParams, FastforwardPluginSettings } from "../types.js";
8
8
 
@@ -43,7 +43,8 @@ export class FastforwardVisits extends Module<
43
43
  this.setState({ text, label, speaker, meet });
44
44
  };
45
45
 
46
- onVisitCheck = async () => Boolean(this.visits[(await this.getHash()) as string]);
46
+ onVisitCheck = async () =>
47
+ ({ isAllowed: Boolean(this.visits[(await this.getHash()) as string]), source: this.name } satisfies FastforwardCheckResult);
47
48
 
48
49
  onClear = () => this.emit(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
49
50
 
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscri
6
6
  import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
7
7
  import type { PluginName as VendorsPluginName, SubscribeEvents as VendorsSubscribeEvents } from "@vnejs/plugins.core.vendors.contract";
8
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";
9
+ import type { Constants, Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.scenario.fastforward.contract";
10
10
 
11
11
  export type FastforwardPluginEvents = VnePluginEventsMapRegistry &
12
12
  Record<PluginName, SubscribeEvents> &
@@ -18,7 +18,7 @@ export type FastforwardPluginEvents = VnePluginEventsMapRegistry &
18
18
  Record<TextPluginName, TextSubscribeEvents> &
19
19
  Record<VendorsPluginName, VendorsSubscribeEvents>;
20
20
 
21
- export type FastforwardPluginConstants = VnePluginConstantsMapRegistry;
21
+ export type FastforwardPluginConstants = VnePluginConstantsMapRegistry & Record<PluginName, Constants>;
22
22
 
23
23
  export type FastforwardPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
24
24