From dd5d3e3c772c19c729fe1b64739be2bb44bfb43e Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 17 Sep 2021 13:04:37 -0700 Subject: [PATCH] sdk: mixin events --- sdk/index.d.ts | 3 ++- sdk/index.generated.js | 6 +++--- sdk/types.d.ts | 7 ++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk/index.d.ts b/sdk/index.d.ts index ffbe0bee1..abf581502 100644 --- a/sdk/index.d.ts +++ b/sdk/index.d.ts @@ -65,7 +65,8 @@ export class ScryptedDeviceBase implements DeviceState { export class MixinDeviceBase implements DeviceState { - constructor(mixinDevice: T, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: { [key: string]: any }, providerNativeId: string); + constructor(mixinDevice: T, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: { [key: string]: any }, mixinProviderNativeId: string); + mixinProviderNativeId: string; mixinDevice: ScryptedDevice & T; mixinDeviceInterfaces: ScryptedInterface[]; console: Console; diff --git a/sdk/index.generated.js b/sdk/index.generated.js index 0e0a58984..131c0d1df 100644 --- a/sdk/index.generated.js +++ b/sdk/index.generated.js @@ -40,17 +40,17 @@ class ScryptedDeviceBase { } class MixinDeviceBase { - constructor(mixinDevice, mixinDeviceInterfaces, mixinDeviceState, providerNativeId) { + constructor(mixinDevice, mixinDeviceInterfaces, mixinDeviceState, mixinProviderNativeId) { this.mixinDevice = mixinDevice; this.mixinDevice = mixinDevice; this.mixinDeviceInterfaces = mixinDeviceInterfaces; this._deviceState = mixinDeviceState; - this.providerNativeId = providerNativeId; + this.mixinProviderNativeId = mixinProviderNativeId; } get storage() { if (!this._storage) { - this._storage = deviceManager.getMixinStorage(this.id, this.providerNativeId); + this._storage = deviceManager.getMixinStorage(this.id, this.mixinProviderNativeId); } return this._storage; } diff --git a/sdk/types.d.ts b/sdk/types.d.ts index 5d156ab57..73e4d7d62 100644 --- a/sdk/types.d.ts +++ b/sdk/types.d.ts @@ -709,9 +709,14 @@ export interface DeviceManager { * @param id The id of the device being mixined. * @param nativeId The nativeId of the MixinProvider. */ - getMixinStorage(id: string, nativeId?: string): Storage; + getMixinStorage(id: string, nativeId: string): Storage; /** + * Fire an event for a mixin provided by this plugin. + */ + onMixinEvent(id: string, nativeId: string, eventInterface: string, eventData: any): Promise; + + /** * Get the per device Storage object. */ getDeviceStorage(nativeId: string): Storage;