@vnejs/plugins.scenario.random 0.2.5 → 0.2.6

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,5 +1,5 @@
1
1
  import "@vnejs/contracts.scenario.random";
2
2
  import { regPlugin } from "@vnejs/shared";
3
- import { PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
3
+ import { CONSTANTS, PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
4
4
  import { Random } from "./modules/random.js";
5
- regPlugin(PLUGIN_NAME, {}, [Random]);
5
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS }, [Random]);
@@ -12,7 +12,7 @@ export class Random extends ModuleCore {
12
12
  const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) ?? [];
13
13
  const options = getBlockOptions(lines, curLine, this.optionPrefix).map(({ index }) => index);
14
14
  const index = Math.floor(Math.random() * options.length);
15
- this.emitLog({ type: "option", index, curLine: options[index] + 1 });
15
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.RANDOM.LOGS_ACTIONS.OPTION, index, curLine: options[index] + 1 });
16
16
  this.globalState.scenario.curLine = options[index] + 1;
17
17
  this.emit(this.EVENTS.SCENARIO.NEXT);
18
18
  };
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { Constants, PluginName } from "@vnejs/contracts.scenario.random";
2
3
  export type RandomPluginEvents = ModuleCoreEvents;
3
- export type RandomPluginConstants = ModuleCoreConstants;
4
+ export type RandomPluginConstants = ModuleCoreConstants & Record<PluginName, Constants>;
4
5
  export type RandomPluginSettings = ModuleCoreSettings;
5
6
  export type RandomPluginParams = ModuleCoreParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.scenario.random",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import "@vnejs/contracts.scenario.random";
2
2
 
3
3
  import { regPlugin } from "@vnejs/shared";
4
- import { PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
4
+ import { CONSTANTS, PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
5
5
 
6
6
  import { Random } from "./modules/random.js";
7
7
 
8
- regPlugin(PLUGIN_NAME, {}, [Random]);
8
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS }, [Random]);
@@ -20,7 +20,7 @@ export class Random extends ModuleCore<RandomPluginEvents, RandomPluginConstants
20
20
 
21
21
  const index = Math.floor(Math.random() * options.length);
22
22
 
23
- this.emitLog({ type: "option", index, curLine: options[index] + 1 });
23
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.RANDOM.LOGS_ACTIONS.OPTION, index, curLine: options[index] + 1 });
24
24
 
25
25
  this.globalState.scenario.curLine = options[index] + 1;
26
26
 
@@ -1,8 +1,9 @@
1
- import { PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
2
- import { createCoreGlobalState, createTestModule, registerCoreVne } from "@vnejs/test-utils";
1
+ import { CONSTANTS, PLUGIN_NAME } from "@vnejs/contracts.scenario.random";
2
+ import { createCoreGlobalState, createTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
3
3
 
4
4
  export const registerRandomPluginVne = () => {
5
5
  registerCoreVne();
6
+ registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS });
6
7
  };
7
8
 
8
9
  export const createRandomTestModule = <T extends Parameters<typeof createTestModule>[0]>(
@@ -14,4 +15,4 @@ export const createRandomTestModule = <T extends Parameters<typeof createTestMod
14
15
  ...options,
15
16
  });
16
17
 
17
- export { PLUGIN_NAME };
18
+ export { PLUGIN_NAME, CONSTANTS };
package/src/types.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
+ import type { Constants, PluginName } from "@vnejs/contracts.scenario.random";
2
3
 
3
4
  export type RandomPluginEvents = ModuleCoreEvents;
4
5
 
5
- export type RandomPluginConstants = ModuleCoreConstants;
6
+ export type RandomPluginConstants = ModuleCoreConstants & Record<PluginName, Constants>;
6
7
 
7
8
  export type RandomPluginSettings = ModuleCoreSettings;
8
9