@vnejs/plugins.vars.counters 0.1.9 → 0.1.11

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.
@@ -1,9 +1,9 @@
1
1
  import { Module } from "@vnejs/module";
2
+ import type { LineExecHandlerArg } from "@vnejs/plugins.core.scenario.contract";
2
3
  import type { CountersPluginConstants, CountersPluginEvents, CountersPluginParams, CountersPluginSettings } from "../types.js";
3
- import type { ScenarioLineExecPayload } from "../utils/counters.js";
4
4
  export declare class CountersExec extends Module<CountersPluginEvents, CountersPluginConstants, CountersPluginSettings, CountersPluginParams> {
5
5
  name: string;
6
6
  init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
7
- onLineExecModule: ({ line, keywords }?: ScenarioLineExecPayload) => Promise<void>;
8
- onLineExecBlock: ({ line, keywords }?: ScenarioLineExecPayload) => Promise<void>;
7
+ onLineExecModule: ({ line, keywords }?: LineExecHandlerArg) => Promise<void>;
8
+ onLineExecBlock: ({ line, keywords }?: LineExecHandlerArg) => Promise<void>;
9
9
  }
@@ -6,7 +6,8 @@ export class CountersExec extends Module {
6
6
  this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.CONST.VARS_COUNTERS.EXEC_NAME, handler: this.onLineExecModule }),
7
7
  ]);
8
8
  onLineExecModule = async ({ line = "", keywords = [] } = {}) => {
9
- const { name = "", action = "", execValue = 0, value = 0, isGlobal = false } = (await this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_INFO, { line, keywords }));
9
+ const execInfo = (await this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_INFO, { line, keywords }));
10
+ const { name = "", action = "", execValue = 0, value = 0, isGlobal = false } = execInfo;
10
11
  const newValue = Number(await this.emitOne(this.EVENTS.VARS_COUNTERS.CHANGE, { value, execValue, action }));
11
12
  await this.emit(this.EVENTS.VARS_COUNTERS.SET, { name, isGlobal, value: newValue });
12
13
  this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
@@ -38,10 +38,6 @@ export type CountersExecCheckPayload = {
38
38
  keywords?: string[];
39
39
  state?: ModuleGlobalStateRegistry | null;
40
40
  };
41
- export type ScenarioLineExecPayload = {
42
- line?: string;
43
- keywords?: string[];
44
- };
45
41
  export type VarsSetPayload = {
46
42
  name?: string;
47
43
  type?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.vars.counters",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,9 @@
1
1
  import { Module } from "@vnejs/module";
2
2
 
3
+ import type { LineExecHandlerArg } from "@vnejs/plugins.core.scenario.contract";
4
+
3
5
  import type { CountersPluginConstants, CountersPluginEvents, CountersPluginParams, CountersPluginSettings } from "../types.js";
4
- import type { CountersExecInfoResult, CountersSetPayload, ScenarioLineExecPayload } from "../utils/counters.js";
6
+ import type { CountersExecInfoResult, CountersSetPayload } from "../utils/counters.js";
5
7
 
6
8
  export class CountersExec extends Module<CountersPluginEvents, CountersPluginConstants, CountersPluginSettings, CountersPluginParams> {
7
9
  name = "vars.counters.exec";
@@ -12,8 +14,9 @@ export class CountersExec extends Module<CountersPluginEvents, CountersPluginCon
12
14
  this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.CONST.VARS_COUNTERS.EXEC_NAME, handler: this.onLineExecModule }),
13
15
  ]);
14
16
 
15
- onLineExecModule = async ({ line = "", keywords = [] }: ScenarioLineExecPayload = {}) => {
16
- const { name = "", action = "", execValue = 0, value = 0, isGlobal = false } = (await this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_INFO, { line, keywords })) as CountersExecInfoResult;
17
+ onLineExecModule = async ({ line = "", keywords = [] }: LineExecHandlerArg = {}) => {
18
+ const execInfo = (await this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_INFO, { line, keywords })) as CountersExecInfoResult;
19
+ const { name = "", action = "", execValue = 0, value = 0, isGlobal = false } = execInfo;
17
20
 
18
21
  const newValue = Number(await this.emitOne(this.EVENTS.VARS_COUNTERS.CHANGE, { value, execValue, action }));
19
22
 
@@ -22,7 +25,7 @@ export class CountersExec extends Module<CountersPluginEvents, CountersPluginCon
22
25
  this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
23
26
  };
24
27
 
25
- onLineExecBlock = async ({ line = "", keywords = [] }: ScenarioLineExecPayload = {}) => {
28
+ onLineExecBlock = async ({ line = "", keywords = [] }: LineExecHandlerArg = {}) => {
26
29
  const { action = "", execValue = 0, value = 0 } = (await this.emitOne(this.EVENTS.VARS_COUNTERS.EXEC_INFO, { line, keywords })) as CountersExecInfoResult;
27
30
 
28
31
  const shouldGoInside = Boolean(await this.emitOne(this.EVENTS.VARS_COUNTERS.COMPARE, { value, execValue, action }));
@@ -46,11 +46,6 @@ export type CountersExecCheckPayload = {
46
46
  state?: ModuleGlobalStateRegistry | null;
47
47
  };
48
48
 
49
- export type ScenarioLineExecPayload = {
50
- line?: string;
51
- keywords?: string[];
52
- };
53
-
54
49
  export type VarsSetPayload = {
55
50
  name?: string;
56
51
  type?: string;