@vnejs/module.components 0.0.3 → 0.0.4

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/index.d.ts CHANGED
@@ -52,8 +52,7 @@ export class ModuleView extends Module {
52
52
  regCanvas: () => Promise<void>;
53
53
  regComponent: () => Promise<void>;
54
54
 
55
- onUpdateReactComponent: (state: any) => Promise<void>;
55
+ onUpdateStoreComponent: (state: any) => Promise<void>;
56
56
 
57
- setIsForceReact: (isForce: Boolean) => Promise<void>;
58
57
  insertExtraDataToState: (state: any) => Promise<any>;
59
58
  }
package/modules/view.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Module } from "@vnejs/module";
2
2
 
3
+ import { createStore } from "zustand/vanilla";
4
+
3
5
  export class ModuleView extends Module {
4
6
  animationTime = 0;
5
7
  renderFunc = null;
@@ -8,6 +10,8 @@ export class ModuleView extends Module {
8
10
  canvasInfo = null;
9
11
  locLabel = null;
10
12
 
13
+ store = createStore(() => ({}));
14
+
11
15
  subscribe = () => {
12
16
  if (this.updateEvent && this.updateHandler) this.on(this.updateEvent, this.updateHandler);
13
17
  };
@@ -22,34 +26,28 @@ export class ModuleView extends Module {
22
26
  };
23
27
 
24
28
  regComponent = async () => {
25
- this.component = await this.emitOne(this.EVENTS.COMPONENTS.REG, { name: this.name, renderFunc: this.renderFunc });
29
+ this.component = await this.emitOne(this.EVENTS.COMPONENTS.REG, { name: this.name, renderFunc: this.renderFunc, store: this.store });
26
30
  };
27
31
 
28
- onUpdateReactComponent = async (state = {}) => {
32
+ onUpdateStoreComponent = async (state = {}) => {
29
33
  if (!this.isReady) await this.waitIsReady();
30
34
 
31
35
  await this.insertExtraDataToState(state);
32
36
 
33
37
  return new Promise(async (resolve) => {
34
38
  if (state.isForce) {
35
- this.component.setState(state);
39
+ this.store.setState(state);
36
40
  await this.waitRerender();
37
- this.component.setState({ ...state, isForce: false });
41
+ this.store.setState({ ...state, isForce: false });
38
42
  await this.waitRerender();
39
43
  return resolve();
40
44
  }
41
- this.component.setState(state);
45
+ this.store.setState(state);
42
46
 
43
47
  return state.isFast ? resolve() : setTimeout(resolve, this.animationTime);
44
48
  });
45
49
  };
46
50
 
47
- setIsForceReact = async (isForce) => {
48
- this.component.setState({ ...this.state, isForce });
49
-
50
- await this.waitRerender();
51
- };
52
-
53
51
  insertExtraDataToState = async (state) => {
54
52
  if (this.locLabel) state.locs = await this.emitOne(this.EVENTS.LOCS.GET, { label: this.locLabel, isConstant: true });
55
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/module.components",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  "author": "",
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
- "@vnejs/module": "~0.0.1"
15
+ "@vnejs/module": "~0.0.1",
16
+ "zustand": "5.0.10"
16
17
  }
17
18
  }