@vnejs/plugins.scenario.random 0.2.1 → 0.2.3

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.
@@ -9,7 +9,7 @@ export class Random extends ModuleCore {
9
9
  };
10
10
  onLineExec = async () => {
11
11
  const { label, curLine } = this.globalState.scenario;
12
- const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label }));
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
15
  this.emitLog({ type: "option", index, curLine: options[index] + 1 });
@@ -18,7 +18,7 @@ export class Random extends ModuleCore {
18
18
  };
19
19
  onOptionLineExec = async () => {
20
20
  const { label, curLine } = this.globalState.scenario;
21
- const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label }));
21
+ const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) ?? [];
22
22
  this.globalState.scenario.curLine = curLine + getOptionExecShift(lines, curLine);
23
23
  this.emitNext();
24
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.scenario.random",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,7 +2,6 @@ import { getBlockOptions, getOptionExecShift } from "@vnejs/helpers";
2
2
  import { ModuleCore } from "@vnejs/module.core";
3
3
 
4
4
  import type { RandomPluginConstants, RandomPluginEvents, RandomPluginParams, RandomPluginSettings } from "../types.js";
5
- import type { ScenarioLine } from "../utils/random.js";
6
5
 
7
6
  export class Random extends ModuleCore<RandomPluginEvents, RandomPluginConstants, RandomPluginSettings, RandomPluginParams> {
8
7
  name = "random";
@@ -16,7 +15,7 @@ export class Random extends ModuleCore<RandomPluginEvents, RandomPluginConstants
16
15
 
17
16
  onLineExec = async () => {
18
17
  const { label, curLine } = this.globalState.scenario;
19
- const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) as ScenarioLine[];
18
+ const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) ?? [];
20
19
  const options = getBlockOptions(lines, curLine, this.optionPrefix).map(({ index }) => index);
21
20
 
22
21
  const index = Math.floor(Math.random() * options.length);
@@ -30,7 +29,7 @@ export class Random extends ModuleCore<RandomPluginEvents, RandomPluginConstants
30
29
 
31
30
  onOptionLineExec = async () => {
32
31
  const { label, curLine } = this.globalState.scenario;
33
- const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) as ScenarioLine[];
32
+ const lines = (await this.emitOne(this.EVENTS.SCENARIO.LINES_GET, { label })) ?? [];
34
33
 
35
34
  this.globalState.scenario.curLine = curLine + getOptionExecShift(lines, curLine);
36
35
 
@@ -1,4 +0,0 @@
1
- export type ScenarioLine = {
2
- line: string;
3
- indent?: number;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export type ScenarioLine = {
2
- line: string;
3
- indent?: number;
4
- };