@vnejs/plugins.vars 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.
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ import "@vnejs/plugins.vars.contract";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "@vnejs/plugins.vars.contract";
1
2
  import { regPlugin } from "@vnejs/shared";
2
3
  import { PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.vars.contract";
3
4
  import { VarsGlobal } from "./modules/global.js";
@@ -1,7 +1,7 @@
1
- import { Module } from "@vnejs/module";
1
+ import { Module, type ModuleGlobalStateRegistry } from "@vnejs/module";
2
2
  import type { ModuleGlobalStateVars, VarValue } from "@vnejs/plugins.vars.contract";
3
3
  import type { VarsPluginConstants, VarsPluginEvents, VarsPluginParams, VarsPluginSettings } from "../types.js";
4
- import type { VarsDefaultRegPayload, VarsGetPayload, VarsSetPayload, VarsStateSlicePayload } from "../utils/vars.js";
4
+ import type { VarsDefaultRegPayload, VarsGetPayload, VarsSetPayload } from "../utils/vars.js";
5
5
  export declare class Vars extends Module<VarsPluginEvents, VarsPluginConstants, VarsPluginSettings, VarsPluginParams, ModuleGlobalStateVars> {
6
6
  name: string;
7
7
  defaultVarValues: Record<string, VarValue | undefined>;
@@ -9,7 +9,7 @@ export declare class Vars extends Module<VarsPluginEvents, VarsPluginConstants,
9
9
  onVarSet: ({ name, type, value, isGlobal }?: VarsSetPayload) => void | Promise<unknown[]>;
10
10
  onVarGet: ({ name, type, isGlobal, state }?: VarsGetPayload) => Promise<VarValue | undefined>;
11
11
  onVarDefaultReg: ({ type, value }?: VarsDefaultRegPayload) => void;
12
- onStateSet: (payload?: VarsStateSlicePayload) => Promise<void>;
12
+ onStateSet: (payload: ModuleGlobalStateRegistry) => Promise<void>;
13
13
  getInnerVarName: (name?: string, type?: string) => string;
14
14
  setLocalVar: (name?: string, value?: VarValue) => void;
15
15
  }
@@ -21,10 +21,7 @@ export class Vars extends Module {
21
21
  onVarDefaultReg = ({ type = "", value } = {}) => {
22
22
  this.defaultVarValues[type] = value;
23
23
  };
24
- onStateSet = async (payload = {}) => {
25
- const state = payload[this.name];
26
- return this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, state)));
27
- };
24
+ onStateSet = async (payload) => this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, this.getStateSlice(payload))));
28
25
  getInnerVarName = (name = "", type = "") => `${type}:${name}`;
29
26
  setLocalVar = (name = "", value = "") => {
30
27
  this.state[name] = value;
@@ -1,9 +1,5 @@
1
- import type { ModuleGlobalStateVars } from "@vnejs/plugins.vars.contract";
2
1
  export type ScenarioLine = {
3
2
  line: string;
4
3
  indent?: number;
5
4
  };
6
- export type VarsStateSlicePayload = {
7
- [moduleName: string]: ModuleGlobalStateVars | undefined;
8
- };
9
5
  export type { VarValue, VarsDefaultRegPayload, VarsGetPayload, VarsGlobalGetPayload, VarsGlobalSetPayload, VarsInjectPayload, VarsScenarioPayload, VarsSetPayload } from "@vnejs/plugins.vars.contract";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.vars",
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",
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import "@vnejs/plugins.vars.contract";
2
+
1
3
  import { regPlugin } from "@vnejs/shared";
2
4
  import { PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.vars.contract";
3
5
 
@@ -1,8 +1,8 @@
1
- import { Module } from "@vnejs/module";
1
+ import { Module, type ModuleGlobalStateRegistry } from "@vnejs/module";
2
2
  import type { ModuleGlobalStateVars, VarValue } from "@vnejs/plugins.vars.contract";
3
3
 
4
4
  import type { VarsPluginConstants, VarsPluginEvents, VarsPluginParams, VarsPluginSettings } from "../types.js";
5
- import type { VarsDefaultRegPayload, VarsGetPayload, VarsSetPayload, VarsStateSlicePayload } from "../utils/vars.js";
5
+ import type { VarsDefaultRegPayload, VarsGetPayload, VarsSetPayload } from "../utils/vars.js";
6
6
 
7
7
  export class Vars extends Module<VarsPluginEvents, VarsPluginConstants, VarsPluginSettings, VarsPluginParams, ModuleGlobalStateVars> {
8
8
  name = "vars";
@@ -36,11 +36,8 @@ export class Vars extends Module<VarsPluginEvents, VarsPluginConstants, VarsPlug
36
36
  this.defaultVarValues[type] = value;
37
37
  };
38
38
 
39
- onStateSet = async (payload: VarsStateSlicePayload = {}) => {
40
- const state = payload[this.name];
41
-
42
- return this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, state)) as ModuleGlobalStateVars);
43
- };
39
+ onStateSet = async (payload: ModuleGlobalStateRegistry) =>
40
+ this.setState((await this.emitOne(this.EVENTS.VENDORS.CLONE, this.getStateSlice(payload))) as ModuleGlobalStateVars);
44
41
 
45
42
  getInnerVarName = (name = "", type = "") => `${type}:${name}`;
46
43
 
package/src/utils/vars.ts CHANGED
@@ -1,12 +1,8 @@
1
- import type { ModuleGlobalStateVars, VarValue } from "@vnejs/plugins.vars.contract";
1
+ import type { VarValue } from "@vnejs/plugins.vars.contract";
2
2
 
3
3
  export type ScenarioLine = {
4
4
  line: string;
5
5
  indent?: number;
6
6
  };
7
7
 
8
- export type VarsStateSlicePayload = {
9
- [moduleName: string]: ModuleGlobalStateVars | undefined;
10
- };
11
-
12
8
  export type { VarValue, VarsDefaultRegPayload, VarsGetPayload, VarsGlobalGetPayload, VarsGlobalSetPayload, VarsInjectPayload, VarsScenarioPayload, VarsSetPayload } from "@vnejs/plugins.vars.contract";