@scrypted/server 0.0.7 → 0.0.8

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.

@@ -0,0 +1,144 @@
1
+ export * from './types';
2
+ import type { ScryptedNativeId } from './types';
3
+ import type { DeviceInformation, ScryptedInterface, ScryptedStatic, ScryptedDeviceType, Logger, ColorRgb, ColorHsv, DeviceState, TemperatureUnit, LockState, ThermostatMode, Position } from './types';
4
+ export declare class ScryptedDeviceBase implements DeviceState {
5
+ nativeId?: string;
6
+ id?: string;
7
+ interfaces?: string[];
8
+ mixins?: string[];
9
+ info?: DeviceInformation;
10
+ name?: string;
11
+ providedInterfaces?: string[];
12
+ providedName?: ScryptedDeviceType;
13
+ providedRoom?: string;
14
+ providedType?: ScryptedDeviceType;
15
+ providerId?: string;
16
+ room?: string;
17
+ type?: ScryptedDeviceType;
18
+ on?: boolean;
19
+ brightness?: number;
20
+ colorTemperature?: number;
21
+ rgb?: ColorRgb;
22
+ hsv?: ColorHsv;
23
+ running?: boolean;
24
+ paused?: boolean;
25
+ docked?: boolean;
26
+ /**
27
+ * Get the ambient temperature in Celsius.
28
+ */
29
+ temperature?: number;
30
+ /**
31
+ * Get the user facing unit of measurement for this thermometer. Note that while this may be Fahrenheit, getTemperatureAmbient will return the temperature in Celsius.
32
+ */
33
+ temperatureUnit?: TemperatureUnit;
34
+ humidity?: number;
35
+ thermostatAvailableModes?: ThermostatMode[];
36
+ thermostatMode?: ThermostatMode;
37
+ thermostatSetpoint?: number;
38
+ thermostatSetpointHigh?: number;
39
+ thermostatSetpointLow?: number;
40
+ lockState?: LockState;
41
+ entryOpen?: boolean;
42
+ batteryLevel?: number;
43
+ online?: boolean;
44
+ updateAvailable?: boolean;
45
+ fromMimeType?: string;
46
+ toMimeType?: string;
47
+ binaryState?: boolean;
48
+ intrusionDetected?: boolean;
49
+ powerDetected?: boolean;
50
+ motionDetected?: boolean;
51
+ audioDetected?: boolean;
52
+ occupied?: boolean;
53
+ flooded?: boolean;
54
+ ultraviolet?: number;
55
+ luminance?: number;
56
+ position?: Position;
57
+ private _storage;
58
+ private _log;
59
+ private _console;
60
+ private _deviceState;
61
+ constructor(nativeId?: string);
62
+ get storage(): Storage;
63
+ /**
64
+ * @deprecated
65
+ */
66
+ get log(): Logger;
67
+ get console(): Console;
68
+ _lazyLoadDeviceState(): void;
69
+ /**
70
+ * Fire an event for this device.
71
+ */
72
+ onDeviceEvent(eventInterface: string, eventData: any): Promise<void>;
73
+ }
74
+ export declare class MixinDeviceBase<T> implements DeviceState {
75
+ mixinDevice: T;
76
+ mixinDeviceInterfaces: ScryptedInterface[];
77
+ mixinProviderNativeId: ScryptedNativeId;
78
+ id?: string;
79
+ interfaces?: string[];
80
+ mixins?: string[];
81
+ info?: DeviceInformation;
82
+ name?: string;
83
+ providedInterfaces?: string[];
84
+ providedName?: ScryptedDeviceType;
85
+ providedRoom?: string;
86
+ providedType?: ScryptedDeviceType;
87
+ providerId?: string;
88
+ room?: string;
89
+ type?: ScryptedDeviceType;
90
+ on?: boolean;
91
+ brightness?: number;
92
+ colorTemperature?: number;
93
+ rgb?: ColorRgb;
94
+ hsv?: ColorHsv;
95
+ running?: boolean;
96
+ paused?: boolean;
97
+ docked?: boolean;
98
+ /**
99
+ * Get the ambient temperature in Celsius.
100
+ */
101
+ temperature?: number;
102
+ /**
103
+ * Get the user facing unit of measurement for this thermometer. Note that while this may be Fahrenheit, getTemperatureAmbient will return the temperature in Celsius.
104
+ */
105
+ temperatureUnit?: TemperatureUnit;
106
+ humidity?: number;
107
+ thermostatAvailableModes?: ThermostatMode[];
108
+ thermostatMode?: ThermostatMode;
109
+ thermostatSetpoint?: number;
110
+ thermostatSetpointHigh?: number;
111
+ thermostatSetpointLow?: number;
112
+ lockState?: LockState;
113
+ entryOpen?: boolean;
114
+ batteryLevel?: number;
115
+ online?: boolean;
116
+ updateAvailable?: boolean;
117
+ fromMimeType?: string;
118
+ toMimeType?: string;
119
+ binaryState?: boolean;
120
+ intrusionDetected?: boolean;
121
+ powerDetected?: boolean;
122
+ motionDetected?: boolean;
123
+ audioDetected?: boolean;
124
+ occupied?: boolean;
125
+ flooded?: boolean;
126
+ ultraviolet?: number;
127
+ luminance?: number;
128
+ position?: Position;
129
+ private _storage;
130
+ private _log;
131
+ private _console;
132
+ private _deviceState;
133
+ constructor(mixinDevice: T, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: DeviceState, mixinProviderNativeId: ScryptedNativeId);
134
+ get storage(): Storage;
135
+ get console(): Console;
136
+ /**
137
+ * Fire an event for this device.
138
+ */
139
+ onDeviceEvent(eventInterface: string, eventData: any): Promise<void>;
140
+ _lazyLoadDeviceState(): void;
141
+ release(): void;
142
+ }
143
+ declare let sdk: ScryptedStatic;
144
+ export default sdk;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.MixinDeviceBase = exports.ScryptedDeviceBase = void 0;
14
+ __exportStar(require("./types"), exports);
15
+ const types_1 = require("./types");
16
+ class ScryptedDeviceBase {
17
+ constructor(nativeId) {
18
+ this.nativeId = nativeId;
19
+ }
20
+ get storage() {
21
+ if (!this._storage) {
22
+ this._storage = deviceManager.getDeviceStorage(this.nativeId);
23
+ }
24
+ return this._storage;
25
+ }
26
+ /**
27
+ * @deprecated
28
+ */
29
+ get log() {
30
+ if (!this._log) {
31
+ this._log = deviceManager.getDeviceLogger(this.nativeId);
32
+ }
33
+ return this._log;
34
+ }
35
+ get console() {
36
+ if (!this._console) {
37
+ this._console = deviceManager.getDeviceConsole(this.nativeId);
38
+ }
39
+ return this._console;
40
+ }
41
+ _lazyLoadDeviceState() {
42
+ if (!this._deviceState) {
43
+ if (this.nativeId) {
44
+ this._deviceState = deviceManager.getDeviceState(this.nativeId);
45
+ }
46
+ else {
47
+ this._deviceState = deviceManager.getDeviceState();
48
+ }
49
+ }
50
+ }
51
+ /**
52
+ * Fire an event for this device.
53
+ */
54
+ onDeviceEvent(eventInterface, eventData) {
55
+ return deviceManager.onDeviceEvent(this.nativeId, eventInterface, eventData);
56
+ }
57
+ }
58
+ exports.ScryptedDeviceBase = ScryptedDeviceBase;
59
+ class MixinDeviceBase {
60
+ constructor(mixinDevice, mixinDeviceInterfaces, mixinDeviceState, mixinProviderNativeId) {
61
+ this.mixinDevice = mixinDevice;
62
+ this.mixinDeviceInterfaces = mixinDeviceInterfaces;
63
+ this.mixinProviderNativeId = mixinProviderNativeId;
64
+ this._deviceState = mixinDeviceState;
65
+ }
66
+ get storage() {
67
+ if (!this._storage) {
68
+ this._storage = deviceManager.getMixinStorage(this.id, this.mixinProviderNativeId);
69
+ }
70
+ return this._storage;
71
+ }
72
+ get console() {
73
+ if (!this._console) {
74
+ if (deviceManager.getMixinConsole)
75
+ this._console = deviceManager.getMixinConsole(this.id, this.mixinProviderNativeId);
76
+ else
77
+ this._console = deviceManager.getDeviceConsole(this.mixinProviderNativeId);
78
+ }
79
+ return this._console;
80
+ }
81
+ /**
82
+ * Fire an event for this device.
83
+ */
84
+ onDeviceEvent(eventInterface, eventData) {
85
+ return deviceManager.onMixinEvent(this.id, this.mixinProviderNativeId, eventInterface, eventData);
86
+ }
87
+ _lazyLoadDeviceState() {
88
+ }
89
+ release() {
90
+ }
91
+ }
92
+ exports.MixinDeviceBase = MixinDeviceBase;
93
+ (function () {
94
+ function _createGetState(state) {
95
+ return function () {
96
+ this._lazyLoadDeviceState();
97
+ return this._deviceState[state];
98
+ };
99
+ }
100
+ function _createSetState(state) {
101
+ return function (value) {
102
+ this._lazyLoadDeviceState();
103
+ this._deviceState[state] = value;
104
+ };
105
+ }
106
+ for (var field of Object.values(types_1.ScryptedInterfaceProperty)) {
107
+ Object.defineProperty(ScryptedDeviceBase.prototype, field, {
108
+ set: _createSetState(field),
109
+ get: _createGetState(field),
110
+ });
111
+ Object.defineProperty(MixinDeviceBase.prototype, field, {
112
+ set: _createSetState(field),
113
+ get: _createGetState(field),
114
+ });
115
+ }
116
+ })();
117
+ let sdk = {};
118
+ try {
119
+ sdk = Object.assign(sdk, {
120
+ log: deviceManager.getDeviceLogger(undefined),
121
+ deviceManager,
122
+ endpointManager,
123
+ mediaManager,
124
+ systemManager,
125
+ pluginHostAPI,
126
+ });
127
+ }
128
+ catch (e) {
129
+ console.error('sdk initialization error, import @scrypted/sdk/types instead', e);
130
+ }
131
+ exports.default = sdk;
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAuB;AACvB,mCAAoD;AAIpD,MAAa,kBAAkB;IA2D7B,YAAmB,QAAiB;QAAjB,aAAQ,GAAR,QAAQ,CAAS;IACpC,CAAC;IAED,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC/D;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1D;QACD,OAAO,IAAI,CAAC,IAAI,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