@momo2555/koppeliajs 0.0.98 → 0.0.100

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.
@@ -58,7 +58,7 @@ export declare class Console {
58
58
  * @param callback
59
59
  */
60
60
  onReady(callback: () => void): void;
61
- onDeviceEvent(callback: () => void): void;
61
+ onDeviceEvent(callback: DeviceEventCallback): void;
62
62
  onRequest(callback: AnyRequestCallback): void;
63
63
  /**
64
64
  * Get if the connection with the console is ready
@@ -19,7 +19,10 @@ export class Console {
19
19
  _ready = false;
20
20
  _onReadyCallback;
21
21
  constructor() {
22
- this.consoleHostname = get(page).url.hostname;
22
+ this.consoleHostname = "";
23
+ if (!import.meta.env.SSR) {
24
+ this.consoleHostname = window.location.hostname;
25
+ }
23
26
  let consoleUrl = "ws://" + this.consoleHostname + ":" + PORT;
24
27
  this.consoleSocket = new KoppeliaWebsocket(consoleUrl);
25
28
  this._ready = false;
@@ -31,7 +31,11 @@ export class Device {
31
31
  }
32
32
  onEvent(eventName, callback) {
33
33
  this._attachEvent(eventName);
34
- this._console.onDeviceEvent(callback);
34
+ let consoleEvent = (device, from_addr, event) => {
35
+ if (event == eventName && from_addr == this._address)
36
+ callback();
37
+ };
38
+ this._console.onDeviceEvent(consoleEvent);
35
39
  }
36
40
  onZPosition(callback) {
37
41
  this._enableModule("zPos");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo2555/koppeliajs",
3
- "version": "0.0.98",
3
+ "version": "0.0.100",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",