@scrypted/server 0.7.63 → 0.7.64

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.

Potentially problematic release.


This version of @scrypted/server might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@scrypted/server",
3
- "version": "0.7.63",
3
+ "version": "0.7.64",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@mapbox/node-pre-gyp": "^1.0.10",
7
- "@scrypted/types": "^0.2.79",
7
+ "@scrypted/types": "^0.2.80",
8
8
  "adm-zip": "^0.5.10",
9
9
  "axios": "^0.21.4",
10
10
  "body-parser": "^1.20.2",
@@ -1,4 +1,4 @@
1
- import { EventListener, EventListenerOptions, EventListenerRegister, Logger, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedInterfaceDescriptor, ScryptedInterfaceDescriptors, ScryptedInterfaceProperty, SystemDeviceState, SystemManager } from "@scrypted/types";
1
+ import { EventListener, EventListenerOptions, EventListenerRegister, Logger, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedInterfaceDescriptor, ScryptedInterfaceDescriptors, ScryptedInterfaceProperty, ScryptedNativeId, SystemDeviceState, SystemManager } from "@scrypted/types";
2
2
  import { EventRegistry } from "../event-registry";
3
3
  import { PrimitiveProxyHandler, RpcPeer } from '../rpc';
4
4
  // import type { PluginComponent } from "../services/plugin";
@@ -175,8 +175,24 @@ export class SystemManagerImpl implements SystemManager {
175
175
  return this.state;
176
176
  }
177
177
 
178
- getDeviceById(id: string): any {
179
- if (!this.state[id])
178
+ getDeviceById(idOrPluginId: string, nativeId?: ScryptedNativeId): any {
179
+ let id: string;
180
+ if (this.state[idOrPluginId]) {
181
+ id = idOrPluginId;
182
+ }
183
+ else {
184
+ for (const check of Object.keys(this.state)) {
185
+ const state = this.state[check];
186
+ if (state[ScryptedInterfaceProperty.pluginId] === idOrPluginId) {
187
+ // null and undefined should match here.
188
+ if (nativeId == state[ScryptedInterfaceProperty.nativeId]) {
189
+ id = check;
190
+ break;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ if (!id)
180
196
  return;
181
197
  let proxy = this.deviceProxies[id];
182
198
  if (!proxy)