@momo2555/koppeliajs 0.0.105 → 0.0.107

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.
@@ -7,6 +7,7 @@ export declare class State {
7
7
  private _globalState;
8
8
  private _console;
9
9
  private _access;
10
+ private _previousStateValue;
10
11
  constructor(console: Console, defaultState?: AnyState);
11
12
  get state(): Writable<AnyState>;
12
13
  /**
@@ -5,6 +5,7 @@ export class State {
5
5
  _globalState;
6
6
  _console;
7
7
  _access = true;
8
+ _previousStateValue = {};
8
9
  constructor(console, defaultState = {}) {
9
10
  this._access = false;
10
11
  this._globalState = writable(defaultState);
@@ -61,18 +62,17 @@ export class State {
61
62
  // Send a change state request when detect a state change
62
63
  this._globalState.subscribe((newState) => {
63
64
  if (this._access) {
64
- let currentState = get(this._globalState);
65
65
  let update = {};
66
66
  for (let entry in newState) {
67
- if (!Object.hasOwn(currentState, entry)) {
67
+ if (!Object.hasOwn(this._previousStateValue, entry)) {
68
68
  update[entry] = newState[entry];
69
69
  }
70
- else if (currentState[entry] != newState[entry]) {
70
+ else if (this._previousStateValue[entry] != newState[entry]) {
71
71
  update[entry] = newState[entry];
72
72
  }
73
73
  }
74
74
  this._console.onReady(() => {
75
- console.log("change state new state", newState);
75
+ console.log("change state NewState=", newState, "; update=", update, " currentState=", this._previousStateValue);
76
76
  let req = new Message();
77
77
  req.setRequest("changeState");
78
78
  req.addParam("state", update);
@@ -80,6 +80,8 @@ export class State {
80
80
  this._console.sendMessage(req);
81
81
  });
82
82
  }
83
+ }, () => {
84
+ this._previousStateValue = get(this._globalState);
83
85
  });
84
86
  }
85
87
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo2555/koppeliajs",
3
- "version": "0.0.105",
3
+ "version": "0.0.107",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",