@scrypted/server 0.7.22 → 0.7.24
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/dist/asynciterable-utils.d.ts +2 -0
- package/dist/cert.d.ts +6 -0
- package/dist/collection.d.ts +1 -0
- package/dist/db-types.d.ts +38 -0
- package/dist/event-registry.d.ts +19 -0
- package/dist/http-interfaces.d.ts +3 -0
- package/dist/infer-defaults.d.ts +11 -0
- package/dist/io.d.ts +22 -0
- package/dist/level.d.ts +110 -0
- package/dist/listen-zero.d.ts +10 -0
- package/dist/logger.d.ts +29 -0
- package/dist/media-helpers.d.ts +5 -0
- package/dist/mixin/mixin-cycle.d.ts +3 -0
- package/dist/plugin/acl.d.ts +16 -0
- package/dist/plugin/descriptor.d.ts +22 -0
- package/dist/plugin/media.d.ts +71 -0
- package/dist/plugin/plugin-api.d.ts +106 -0
- package/dist/plugin/plugin-console.d.ts +28 -0
- package/dist/plugin/plugin-debug.d.ts +4 -0
- package/dist/plugin/plugin-device.d.ts +54 -0
- package/dist/plugin/plugin-error.d.ts +2 -0
- package/dist/plugin/plugin-host-api.d.ts +43 -0
- package/dist/plugin/plugin-host.d.ts +45 -0
- package/dist/plugin/plugin-host.js +8 -25
- package/dist/plugin/plugin-host.js.map +1 -1
- package/dist/plugin/plugin-http.d.ts +18 -0
- package/dist/plugin/plugin-lazy-remote.d.ts +31 -0
- package/dist/plugin/plugin-npm-dependencies.d.ts +2 -0
- package/dist/plugin/plugin-remote-stats.d.ts +8 -0
- package/dist/plugin/plugin-remote-websocket.d.ts +29 -0
- package/dist/plugin/plugin-remote-worker.d.ts +2 -0
- package/dist/plugin/plugin-remote-worker.js +4 -4
- package/dist/plugin/plugin-remote-worker.js.map +1 -1
- package/dist/plugin/plugin-remote.d.ts +75 -0
- package/dist/plugin/plugin-repl.d.ts +2 -0
- package/dist/plugin/plugin-state-check.d.ts +1 -0
- package/dist/plugin/plugin-volume.d.ts +3 -0
- package/dist/plugin/runtime/child-process-worker.d.ts +20 -0
- package/dist/plugin/runtime/node-fork-worker.d.ts +9 -0
- package/dist/plugin/runtime/node-fork-worker.js.map +1 -1
- package/dist/plugin/runtime/node-thread-worker.d.ts +20 -0
- package/dist/plugin/runtime/python-worker.d.ts +10 -0
- package/dist/plugin/runtime/runtime-worker.d.ts +26 -0
- package/dist/plugin/socket-serializer.d.ts +5 -0
- package/dist/plugin/system.d.ts +39 -0
- package/dist/rpc-buffer-serializer.d.ts +11 -0
- package/dist/rpc-serializer.d.ts +24 -0
- package/dist/rpc.d.ts +132 -0
- package/dist/runtime.d.ts +103 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -1
- package/dist/scrypted-main-exports.d.ts +6 -0
- package/dist/scrypted-main-exports.js +7 -2
- package/dist/scrypted-main-exports.js.map +1 -1
- package/dist/scrypted-main.d.ts +1 -0
- package/dist/scrypted-plugin-main.d.ts +2 -0
- package/dist/scrypted-server-main.d.ts +6 -0
- package/dist/scrypted-server-main.js +2 -1
- package/dist/scrypted-server-main.js.map +1 -1
- package/dist/server-settings.d.ts +5 -0
- package/dist/services/addresses.d.ts +7 -0
- package/dist/services/alerts.d.ts +9 -0
- package/dist/services/cors.d.ts +18 -0
- package/dist/services/info.d.ts +5 -0
- package/dist/services/plugin.d.ts +46 -0
- package/dist/services/service-control.d.ts +8 -0
- package/dist/services/users.d.ts +14 -0
- package/dist/sleep.d.ts +1 -0
- package/dist/state.d.ts +39 -0
- package/dist/threading.d.ts +3 -0
- package/dist/usertoken.d.ts +11 -0
- package/package.json +2 -1
- package/python/rpc-iterator-test.py +7 -3
- package/python/rpc.py +8 -0
- package/src/plugin/plugin-host.ts +10 -25
- package/src/plugin/plugin-remote-worker.ts +4 -4
- package/src/plugin/runtime/node-fork-worker.ts +3 -3
- package/src/plugin/runtime/runtime-worker.ts +1 -1
- package/src/runtime.ts +9 -0
- package/src/scrypted-main-exports.ts +9 -2
- package/src/scrypted-plugin-main.ts +1 -1
- package/src/scrypted-server-main.ts +6 -1
- package/test/rpc-python-test.ts +10 -6
- package/tsconfig.json +1 -0
package/dist/cert.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare function hasSameElements<T>(a: T[], b: T[]): boolean;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { LevelDocument } from "./level";
|
2
|
+
import { ScryptedNativeId, SystemDeviceState } from "@scrypted/types";
|
3
|
+
export declare class ScryptedDocument implements LevelDocument {
|
4
|
+
_id?: string;
|
5
|
+
_documentType?: string;
|
6
|
+
}
|
7
|
+
export declare class Settings extends ScryptedDocument {
|
8
|
+
value?: any;
|
9
|
+
}
|
10
|
+
export declare class Plugin extends ScryptedDocument {
|
11
|
+
packageJson?: any;
|
12
|
+
zip?: string;
|
13
|
+
}
|
14
|
+
export declare class ScryptedUser extends ScryptedDocument {
|
15
|
+
passwordDate: number;
|
16
|
+
passwordHash: string;
|
17
|
+
token: string;
|
18
|
+
salt: string;
|
19
|
+
aclId: string;
|
20
|
+
}
|
21
|
+
export declare class ScryptedAlert extends ScryptedDocument {
|
22
|
+
timestamp: number;
|
23
|
+
title: string;
|
24
|
+
path: string;
|
25
|
+
message: string;
|
26
|
+
}
|
27
|
+
export declare class PluginDevice extends ScryptedDocument {
|
28
|
+
constructor(id?: string);
|
29
|
+
nativeId: ScryptedNativeId;
|
30
|
+
pluginId: string;
|
31
|
+
state: {
|
32
|
+
[property: string]: SystemDeviceState;
|
33
|
+
};
|
34
|
+
stateVersion: number;
|
35
|
+
storage: {
|
36
|
+
[key: string]: string;
|
37
|
+
};
|
38
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { EventDetails, EventListenerOptions, EventListenerRegister } from "@scrypted/types";
|
2
|
+
export declare class EventListenerRegisterImpl implements EventListenerRegister {
|
3
|
+
removeListener: () => void;
|
4
|
+
constructor(removeListener: () => void);
|
5
|
+
}
|
6
|
+
export declare function getMixinEventName(options: string | EventListenerOptions): string;
|
7
|
+
export declare class EventRegistry {
|
8
|
+
systemListeners: Set<(id: string, eventDetails: EventDetails, eventData: any) => void>;
|
9
|
+
listeners: {
|
10
|
+
[token: string]: Set<(eventDetails: EventDetails, eventData: any) => void>;
|
11
|
+
};
|
12
|
+
listen(callback: (id: string, eventDetails: EventDetails, eventData: any) => void): EventListenerRegister;
|
13
|
+
listenDevice(id: string, options: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): EventListenerRegister;
|
14
|
+
notify(id: string | undefined, eventTime: number, eventInterface: string, property: string | undefined, value: any, options?: {
|
15
|
+
changed?: boolean;
|
16
|
+
mixinId?: string;
|
17
|
+
}): boolean;
|
18
|
+
notifyEventDetails(id: string | undefined, eventDetails: EventDetails, value: any, eventInterface?: string): boolean;
|
19
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ScryptedDeviceType, ScryptedInterface } from "@scrypted/types";
|
2
|
+
import { PluginDevice } from "./db-types";
|
3
|
+
export declare function inferTypeFromInterfaces(interfaces: ScryptedInterface[]): ScryptedDeviceType;
|
4
|
+
export declare function inferTypesFromInterfaces(interfaces: ScryptedInterface[]): ScryptedDeviceType[];
|
5
|
+
export declare function getProvidedNameOrDefault(pluginDevice: PluginDevice): string;
|
6
|
+
export declare function getDisplayName(pluginDevice: PluginDevice): string;
|
7
|
+
export declare function getProvidedTypeOrDefault(pluginDevice: PluginDevice): ScryptedDeviceType;
|
8
|
+
export declare function getDisplayType(pluginDevice: PluginDevice): ScryptedDeviceType;
|
9
|
+
export declare function inferRoomFromName(name: string): string;
|
10
|
+
export declare function getProvidedRoomOrDefault(pluginDevice: PluginDevice): string;
|
11
|
+
export declare function getDisplayRoom(pluginDevice: PluginDevice): string;
|
package/dist/io.d.ts
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import type { Server, Socket as ServerSocket } from "engine.io";
|
3
|
+
export declare type IOServer = {
|
4
|
+
on(ev: 'connection' | 'drain', fn: (socket: IOServerSocket & IOServerSocket) => void): IOServer;
|
5
|
+
} & Server;
|
6
|
+
export declare type IOServerSocket = ServerSocket & IOSocket;
|
7
|
+
export interface IOSocket {
|
8
|
+
send(data: any, options?: any, callback?: any): this;
|
9
|
+
on(ev: "close", fn: (reason: string, description?: Error) => void): this;
|
10
|
+
/**
|
11
|
+
* Fired when the client sends a message.
|
12
|
+
*/
|
13
|
+
on(ev: "message", fn: (data: string | Buffer) => void): this;
|
14
|
+
/**
|
15
|
+
* Fired when an error occurs.
|
16
|
+
*/
|
17
|
+
on(ev: "error", fn: (err: Error) => void): this;
|
18
|
+
/**
|
19
|
+
* Called when the write buffer is drained
|
20
|
+
*/
|
21
|
+
on(ev: "drain", fn: () => void): this;
|
22
|
+
}
|
package/dist/level.d.ts
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
export interface AbstractOptions {
|
2
|
+
readonly [k: string]: any;
|
3
|
+
}
|
4
|
+
export declare type ErrorCallback = (err: Error | undefined) => void;
|
5
|
+
export declare type ErrorValueCallback<V> = (err: Error | undefined, value: V) => void;
|
6
|
+
export declare type ErrorKeyValueCallback<K, V> = (err: Error | undefined, key: K, value: V) => void;
|
7
|
+
export interface AbstractOpenOptions extends AbstractOptions {
|
8
|
+
createIfMissing?: boolean;
|
9
|
+
errorIfExists?: boolean;
|
10
|
+
}
|
11
|
+
export interface AbstractGetOptions extends AbstractOptions {
|
12
|
+
asBuffer?: boolean;
|
13
|
+
}
|
14
|
+
export interface LevelDocument {
|
15
|
+
_id?: any;
|
16
|
+
_documentType?: string;
|
17
|
+
}
|
18
|
+
export interface LevelDocumentConstructor<T extends LevelDocument> {
|
19
|
+
new (): T;
|
20
|
+
}
|
21
|
+
export interface AbstractLevelDOWN<K = any, V = any> {
|
22
|
+
open(cb?: ErrorCallback): Promise<void>;
|
23
|
+
open(options: AbstractOpenOptions, cb?: ErrorCallback): Promise<void>;
|
24
|
+
close(cb?: ErrorCallback): void;
|
25
|
+
get(key: K, cb?: ErrorValueCallback<V>): Promise<V>;
|
26
|
+
get(key: K, options: AbstractGetOptions, cb?: ErrorValueCallback<V>): Promise<V>;
|
27
|
+
put(key: K, value: V, cb?: ErrorCallback): Promise<void>;
|
28
|
+
put(key: K, value: V, options: AbstractOptions, cb?: ErrorCallback): Promise<void>;
|
29
|
+
del(key: K, cb?: ErrorCallback): Promise<void>;
|
30
|
+
del(key: K, options: AbstractOptions, cb?: ErrorCallback): Promise<void>;
|
31
|
+
batch(): AbstractChainedBatch<K, V>;
|
32
|
+
batch(array: ReadonlyArray<AbstractBatch<K, V>>, cb?: ErrorCallback): AbstractChainedBatch<K, V>;
|
33
|
+
batch(array: ReadonlyArray<AbstractBatch<K, V>>, options: AbstractOptions, cb?: ErrorCallback): AbstractChainedBatch<K, V>;
|
34
|
+
iterator(options?: AbstractIteratorOptions<K>): AbstractIterator<K, V>;
|
35
|
+
[Symbol.asyncIterator](): AsyncIterator<{
|
36
|
+
key: K;
|
37
|
+
value: V;
|
38
|
+
}>;
|
39
|
+
nextId(): number;
|
40
|
+
tryGet<T extends LevelDocument>(documentConstructor: LevelDocumentConstructor<T>, _id: any, options?: AbstractGetOptions): Promise<T | undefined>;
|
41
|
+
getAll<T extends LevelDocument>(documentConstructor: LevelDocumentConstructor<T>, options?: AbstractGetOptions): AsyncIterable<T>;
|
42
|
+
upsert<T extends LevelDocument>(value: T, options?: AbstractOptions): Promise<T>;
|
43
|
+
remove<T extends LevelDocument>(value: T): Promise<void>;
|
44
|
+
removeId<T extends LevelDocument>(documentConstructor: LevelDocumentConstructor<T>, _id: any): Promise<void>;
|
45
|
+
removeAll<T extends LevelDocument>(documentConstructor: LevelDocumentConstructor<T>): Promise<void>;
|
46
|
+
getCount<T extends LevelDocument>(documentConstructor: LevelDocumentConstructor<T>, options?: AbstractGetOptions): Promise<number>;
|
47
|
+
}
|
48
|
+
export interface AbstractLevelDOWNConstructor {
|
49
|
+
new <K = any, V = any>(location: string): AbstractLevelDOWN<K, V>;
|
50
|
+
<K = any, V = any>(location: string): AbstractLevelDOWN<K, V>;
|
51
|
+
}
|
52
|
+
export interface AbstractIteratorOptions<K = any> extends AbstractOptions {
|
53
|
+
gt?: K;
|
54
|
+
gte?: K;
|
55
|
+
lt?: K;
|
56
|
+
lte?: K;
|
57
|
+
reverse?: boolean;
|
58
|
+
limit?: number;
|
59
|
+
keys?: boolean;
|
60
|
+
values?: boolean;
|
61
|
+
keyAsBuffer?: boolean;
|
62
|
+
valueAsBuffer?: boolean;
|
63
|
+
}
|
64
|
+
export declare type AbstractBatch<K = any, V = any> = PutBatch<K, V> | DelBatch<K, V>;
|
65
|
+
export interface PutBatch<K = any, V = any> {
|
66
|
+
readonly type: 'put';
|
67
|
+
readonly key: K;
|
68
|
+
readonly value: V;
|
69
|
+
}
|
70
|
+
export interface DelBatch<K = any, V = any> {
|
71
|
+
readonly type: 'del';
|
72
|
+
readonly key: K;
|
73
|
+
}
|
74
|
+
export interface AbstractChainedBatch<K = any, V = any> extends AbstractOptions {
|
75
|
+
put: (key: K, value: V) => this;
|
76
|
+
del: (key: K) => this;
|
77
|
+
clear: () => this;
|
78
|
+
write(cb?: ErrorCallback): any;
|
79
|
+
write(options: any, cb?: ErrorCallback): any;
|
80
|
+
}
|
81
|
+
export interface AbstractChainedBatchConstructor {
|
82
|
+
new <K = any, V = any>(db: any): AbstractChainedBatch<K, V>;
|
83
|
+
<K = any, V = any>(db: any): AbstractChainedBatch<K, V>;
|
84
|
+
}
|
85
|
+
export interface AbstractIterator<K, V> extends AbstractOptions {
|
86
|
+
db: AbstractLevelDOWN<K, V>;
|
87
|
+
next(cb?: ErrorKeyValueCallback<K, V>): this;
|
88
|
+
end(cb?: ErrorCallback): void;
|
89
|
+
}
|
90
|
+
export interface AbstractIteratorConstructor {
|
91
|
+
new <K = any, V = any>(db: any): AbstractIterator<K, V>;
|
92
|
+
<K = any, V = any>(db: any): AbstractIterator<K, V>;
|
93
|
+
}
|
94
|
+
export interface Level extends AbstractLevelDOWN {
|
95
|
+
readonly location: string;
|
96
|
+
readonly prefix: string;
|
97
|
+
readonly version: string | number;
|
98
|
+
destroy(location: string, cb?: (err: Error | undefined) => void): void;
|
99
|
+
destroy(location: string, prefix: string, cb?: (err: Error | undefined) => void): void;
|
100
|
+
}
|
101
|
+
interface LevelOptions {
|
102
|
+
readonly prefix?: string;
|
103
|
+
readonly version?: string | number;
|
104
|
+
}
|
105
|
+
interface LevelConstructor {
|
106
|
+
new (location: string, options?: LevelOptions): Level;
|
107
|
+
(location: string, options?: LevelOptions): Level;
|
108
|
+
}
|
109
|
+
declare const _default: LevelConstructor;
|
110
|
+
export default _default;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import net from 'net';
|
3
|
+
export declare function listenZero(server: net.Server, hostname?: string): Promise<number>;
|
4
|
+
export declare function listenZeroSingleClient(hostname?: string): Promise<{
|
5
|
+
server: net.Server;
|
6
|
+
url: string;
|
7
|
+
host: string;
|
8
|
+
port: number;
|
9
|
+
clientPromise: Promise<net.Socket>;
|
10
|
+
}>;
|
package/dist/logger.d.ts
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { EventEmitter } from 'events';
|
3
|
+
import { ScryptedRuntime } from './runtime';
|
4
|
+
import { PluginLogger } from './plugin/plugin-api';
|
5
|
+
export declare function makeAlertId(path: string, msg: string): string;
|
6
|
+
export interface LogEntry {
|
7
|
+
title: string;
|
8
|
+
timestamp: number;
|
9
|
+
level: string;
|
10
|
+
message: string;
|
11
|
+
path: string;
|
12
|
+
}
|
13
|
+
export declare class Logger extends EventEmitter implements PluginLogger {
|
14
|
+
logs: LogEntry[];
|
15
|
+
children: {
|
16
|
+
[id: string]: Logger;
|
17
|
+
};
|
18
|
+
path: string;
|
19
|
+
title: string;
|
20
|
+
scrypted: ScryptedRuntime;
|
21
|
+
constructor(scrypted: ScryptedRuntime, path: string, title: string);
|
22
|
+
log(level: string, message: string): Promise<void>;
|
23
|
+
purge(before: number): void;
|
24
|
+
clear(): Promise<void>;
|
25
|
+
clearAlert(message: string): Promise<void>;
|
26
|
+
clearAlerts(): Promise<void>;
|
27
|
+
getLogger(id: string, title: string): Logger;
|
28
|
+
getLogs(): LogEntry[];
|
29
|
+
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { ChildProcess } from "child_process";
|
3
|
+
export declare function safeKillFFmpeg(cp: ChildProcess): void;
|
4
|
+
export declare function ffmpegLogInitialOutput(console: Console, cp: ChildProcess, forever?: boolean, storage?: Storage): void;
|
5
|
+
export declare function safePrintFFmpegArguments(console: Console, args: string[]): void;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { EventDetails, ScryptedInterface, ScryptedUserAccessControl } from "@scrypted/types";
|
2
|
+
/**
|
3
|
+
* Scrypted Access Controls allow selective reading of state, subscription to evemts,
|
4
|
+
* and invocation of methods.
|
5
|
+
* Everything else should be rejected.
|
6
|
+
*/
|
7
|
+
export declare class AccessControls {
|
8
|
+
acl: ScryptedUserAccessControl;
|
9
|
+
constructor(acl: ScryptedUserAccessControl);
|
10
|
+
deny(reason?: string): void;
|
11
|
+
shouldRejectDevice(id: string): boolean;
|
12
|
+
shouldRejectProperty(id: string, property: string): boolean;
|
13
|
+
shouldRejectEvent(id: string, eventDetails: EventDetails): boolean;
|
14
|
+
shouldRejectInterface(id: string, scryptedInterface: ScryptedInterface): boolean;
|
15
|
+
shouldRejectMethod(id: string, method: string): boolean;
|
16
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { ScryptedInterface, ScryptedInterfaceDescriptor } from "@scrypted/types";
|
2
|
+
export declare const allInterfaceProperties: string[];
|
3
|
+
export declare function getPropertyInterfaces(descriptors: {
|
4
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
5
|
+
}): {
|
6
|
+
[property: string]: ScryptedInterface;
|
7
|
+
};
|
8
|
+
export declare const propertyInterfaces: {
|
9
|
+
[property: string]: ScryptedInterface;
|
10
|
+
};
|
11
|
+
export declare function getInterfaceMethods(descriptors: {
|
12
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
13
|
+
}, interfaces: Set<string>): string[];
|
14
|
+
export declare function getInterfaceProperties(descriptors: {
|
15
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
16
|
+
}, interfaces: Set<string>): string[];
|
17
|
+
export declare function isValidInterfaceMethod(descriptors: {
|
18
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
19
|
+
}, interfaces: Set<string>, method: string): boolean;
|
20
|
+
export declare function isValidInterfaceProperty(descriptors: {
|
21
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
22
|
+
}, interfaces: string[], property: string): boolean;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { BufferConverter, DeviceManager, FFmpegInput, MediaManager, MediaObject as MediaObjectInterface, MediaObjectOptions, ScryptedDevice, ScryptedNativeId, SystemDeviceState, SystemManager } from "@scrypted/types";
|
3
|
+
import { MediaObjectRemote } from "./plugin-api";
|
4
|
+
declare type IdBufferConverter = BufferConverter & {
|
5
|
+
id: string;
|
6
|
+
name: string;
|
7
|
+
};
|
8
|
+
export declare abstract class MediaManagerBase implements MediaManager {
|
9
|
+
builtinConverters: IdBufferConverter[];
|
10
|
+
extraConverters: IdBufferConverter[];
|
11
|
+
constructor();
|
12
|
+
addConverter(converter: IdBufferConverter): Promise<void>;
|
13
|
+
clearConverters(): Promise<void>;
|
14
|
+
convertMediaObjectToJSON<T>(mediaObject: MediaObjectInterface, toMimeType: string): Promise<T>;
|
15
|
+
abstract getSystemState(): {
|
16
|
+
[id: string]: {
|
17
|
+
[property: string]: SystemDeviceState;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
abstract getDeviceById<T>(id: string): T & ScryptedDevice;
|
21
|
+
abstract getPluginDeviceId(): string;
|
22
|
+
abstract getMixinConsole(mixinId: string, nativeId: ScryptedNativeId): Console;
|
23
|
+
getFFmpegPath(): Promise<string>;
|
24
|
+
getFilesPath(): Promise<string>;
|
25
|
+
getConverters(): IdBufferConverter[];
|
26
|
+
ensureMediaObjectRemote(mediaObject: string | MediaObjectInterface): MediaObjectRemote;
|
27
|
+
convertMediaObject<T>(mediaObject: MediaObjectInterface, toMimeType: string): Promise<T>;
|
28
|
+
convertMediaObjectToInsecureLocalUrl(mediaObject: string | MediaObjectInterface, toMimeType: string): Promise<string>;
|
29
|
+
convertMediaObjectToBuffer(mediaObject: MediaObjectInterface, toMimeType: string): Promise<Buffer>;
|
30
|
+
convertMediaObjectToLocalUrl(mediaObject: string | MediaObjectInterface, toMimeType: string): Promise<string>;
|
31
|
+
convertMediaObjectToUrl(mediaObject: string | MediaObjectInterface, toMimeType: string): Promise<string>;
|
32
|
+
createMediaObjectRemote<T extends MediaObjectOptions>(data: any | Buffer | Promise<string | Buffer>, mimeType: string, options?: T): MediaObjectRemote & T;
|
33
|
+
createFFmpegMediaObject(ffMpegInput: FFmpegInput, options?: MediaObjectOptions): Promise<MediaObjectInterface>;
|
34
|
+
createMediaObjectFromUrl(data: string, options?: MediaObjectOptions): Promise<MediaObjectInterface>;
|
35
|
+
createMediaObject<T extends MediaObjectOptions>(data: any, mimeType: string, options?: T): Promise<MediaObjectInterface & T>;
|
36
|
+
convert(converters: IdBufferConverter[], mediaObject: MediaObjectRemote, toMimeType: string): Promise<{
|
37
|
+
data: Buffer | string | any;
|
38
|
+
mimeType: string;
|
39
|
+
}>;
|
40
|
+
}
|
41
|
+
export declare class MediaManagerImpl extends MediaManagerBase {
|
42
|
+
systemManager: SystemManager;
|
43
|
+
deviceManager: DeviceManager;
|
44
|
+
constructor(systemManager: SystemManager, deviceManager: DeviceManager);
|
45
|
+
getSystemState(): {
|
46
|
+
[id: string]: {
|
47
|
+
[property: string]: SystemDeviceState;
|
48
|
+
};
|
49
|
+
};
|
50
|
+
getDeviceById<T>(id: string): T;
|
51
|
+
getPluginDeviceId(): string;
|
52
|
+
getMixinConsole(mixinId: string, nativeId: string): Console;
|
53
|
+
}
|
54
|
+
export declare class MediaManagerHostImpl extends MediaManagerBase {
|
55
|
+
pluginDeviceId: string;
|
56
|
+
getSystemState: () => {
|
57
|
+
[id: string]: {
|
58
|
+
[property: string]: SystemDeviceState;
|
59
|
+
};
|
60
|
+
};
|
61
|
+
console: Console;
|
62
|
+
getDeviceById: (id: string) => any;
|
63
|
+
constructor(pluginDeviceId: string, getSystemState: () => {
|
64
|
+
[id: string]: {
|
65
|
+
[property: string]: SystemDeviceState;
|
66
|
+
};
|
67
|
+
}, console: Console, getDeviceById: (id: string) => any);
|
68
|
+
getPluginDeviceId(): string;
|
69
|
+
getMixinConsole(mixinId: string, nativeId: string): Console;
|
70
|
+
}
|
71
|
+
export {};
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import type { Device, DeviceManifest, EventDetails, EventListenerOptions, EventListenerRegister, MediaManager, MediaObject, ScryptedDevice, ScryptedInterfaceDescriptor, ScryptedInterfaceProperty, ScryptedNativeId, SystemDeviceState } from '@scrypted/types';
|
3
|
+
import { AccessControls } from './acl';
|
4
|
+
export interface PluginLogger {
|
5
|
+
log(level: string, message: string): Promise<void>;
|
6
|
+
clear(): Promise<void>;
|
7
|
+
clearAlert(message: string): Promise<void>;
|
8
|
+
clearAlerts(): Promise<void>;
|
9
|
+
}
|
10
|
+
export interface PluginHostInfo {
|
11
|
+
serverVersion: string;
|
12
|
+
}
|
13
|
+
export interface PluginAPI {
|
14
|
+
setState(nativeId: ScryptedNativeId, key: string, value: any): Promise<void>;
|
15
|
+
onDevicesChanged(deviceManifest: DeviceManifest): Promise<void>;
|
16
|
+
onDeviceDiscovered(device: Device): Promise<string>;
|
17
|
+
onDeviceEvent(nativeId: ScryptedNativeId, eventInterface: string, eventData?: any): Promise<void>;
|
18
|
+
onMixinEvent(id: string, nativeId: ScryptedNativeId, eventInterface: string, eventData?: any): Promise<void>;
|
19
|
+
onDeviceRemoved(nativeId: string): Promise<void>;
|
20
|
+
setStorage(nativeId: string, storage: {
|
21
|
+
[key: string]: any;
|
22
|
+
}): Promise<void>;
|
23
|
+
getDeviceById(id: string): Promise<ScryptedDevice>;
|
24
|
+
setDeviceProperty(id: string, property: ScryptedInterfaceProperty, value: any): Promise<void>;
|
25
|
+
removeDevice(id: string): Promise<void>;
|
26
|
+
listen(EventListener: (id: string, eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
27
|
+
listenDevice(id: string, event: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
28
|
+
getLogger(nativeId: ScryptedNativeId): Promise<PluginLogger>;
|
29
|
+
getComponent(id: string): Promise<any>;
|
30
|
+
getMediaManager(): Promise<MediaManager>;
|
31
|
+
requestRestart(): Promise<void>;
|
32
|
+
setScryptedInterfaceDescriptors(typesVersion: string, descriptors: {
|
33
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
34
|
+
}): Promise<void>;
|
35
|
+
}
|
36
|
+
export declare class PluginAPIManagedListeners {
|
37
|
+
listeners: Set<EventListenerRegister>;
|
38
|
+
manageListener(listener: EventListenerRegister): EventListenerRegister;
|
39
|
+
removeListeners(): void;
|
40
|
+
}
|
41
|
+
export declare class PluginAPIProxy extends PluginAPIManagedListeners implements PluginAPI {
|
42
|
+
api: PluginAPI;
|
43
|
+
mediaManager?: MediaManager;
|
44
|
+
acl: AccessControls;
|
45
|
+
constructor(api: PluginAPI, mediaManager?: MediaManager);
|
46
|
+
setScryptedInterfaceDescriptors(typesVersion: string, descriptors: {
|
47
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
48
|
+
}): Promise<void>;
|
49
|
+
setState(nativeId: ScryptedNativeId, key: string, value: any): Promise<void>;
|
50
|
+
onDevicesChanged(deviceManifest: DeviceManifest): Promise<void>;
|
51
|
+
onDeviceDiscovered(device: Device): Promise<string>;
|
52
|
+
onDeviceEvent(nativeId: ScryptedNativeId, eventInterface: any, eventData?: any): Promise<void>;
|
53
|
+
onMixinEvent(id: string, nativeId: ScryptedNativeId, eventInterface: string, eventData?: any): Promise<void>;
|
54
|
+
onDeviceRemoved(nativeId: string): Promise<void>;
|
55
|
+
setStorage(nativeId: ScryptedNativeId, storage: {
|
56
|
+
[key: string]: any;
|
57
|
+
}): Promise<void>;
|
58
|
+
getDeviceById(id: string): Promise<ScryptedDevice>;
|
59
|
+
setDeviceProperty(id: string, property: ScryptedInterfaceProperty, value: any): Promise<void>;
|
60
|
+
removeDevice(id: string): Promise<void>;
|
61
|
+
listen(callback: (id: string, eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
62
|
+
listenDevice(id: string, event: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
63
|
+
getLogger(nativeId: ScryptedNativeId): Promise<PluginLogger>;
|
64
|
+
getComponent(id: string): Promise<any>;
|
65
|
+
getMediaManager(): Promise<MediaManager>;
|
66
|
+
requestRestart(): Promise<void>;
|
67
|
+
}
|
68
|
+
export interface PluginRemoteLoadZipOptions {
|
69
|
+
/**
|
70
|
+
* The filename to load the script as. Use for debugger source mapping.
|
71
|
+
*/
|
72
|
+
filename?: string;
|
73
|
+
/**
|
74
|
+
* The path that the zip is currently unzipped at on the server. May not
|
75
|
+
* exist on the "remote", if it is not the same machine.
|
76
|
+
*/
|
77
|
+
unzippedPath?: string;
|
78
|
+
fork?: boolean;
|
79
|
+
clusterId: string;
|
80
|
+
clusterSecret: string;
|
81
|
+
}
|
82
|
+
export interface PluginRemote {
|
83
|
+
loadZip(packageJson: any, zipData: Buffer | string, options: PluginRemoteLoadZipOptions): Promise<any>;
|
84
|
+
setSystemState(state: {
|
85
|
+
[id: string]: {
|
86
|
+
[property: string]: SystemDeviceState;
|
87
|
+
};
|
88
|
+
}): Promise<void>;
|
89
|
+
setNativeId(nativeId: ScryptedNativeId, id: string, storage: {
|
90
|
+
[key: string]: any;
|
91
|
+
}): Promise<void>;
|
92
|
+
updateDeviceState(id: string, state: {
|
93
|
+
[property: string]: SystemDeviceState;
|
94
|
+
}): Promise<void>;
|
95
|
+
/**
|
96
|
+
* @deprecated
|
97
|
+
*/
|
98
|
+
notify(id: string, eventTime: number, eventInterface: string, property: string | undefined, value: SystemDeviceState | any, changed?: boolean): Promise<void>;
|
99
|
+
notify(id: string, eventDetails: EventDetails, eventData: SystemDeviceState | any): Promise<void>;
|
100
|
+
ioEvent(id: string, event: string, message?: any): Promise<void>;
|
101
|
+
createDeviceState(id: string, setState: (property: string, value: any) => Promise<any>): Promise<any>;
|
102
|
+
getServicePort(name: string, ...args: any[]): Promise<number>;
|
103
|
+
}
|
104
|
+
export interface MediaObjectRemote extends MediaObject {
|
105
|
+
getData(): Promise<Buffer | string>;
|
106
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
import { DeviceManager, ScryptedNativeId, SystemManager } from '@scrypted/types';
|
4
|
+
import { PassThrough, Readable } from 'stream';
|
5
|
+
export interface ConsoleServer {
|
6
|
+
pluginConsole: Console;
|
7
|
+
readPort: number;
|
8
|
+
writePort: number;
|
9
|
+
destroy(): void;
|
10
|
+
clear(nativeId: ScryptedNativeId): void;
|
11
|
+
}
|
12
|
+
export interface StdPassThroughs {
|
13
|
+
stdout: PassThrough;
|
14
|
+
stderr: PassThrough;
|
15
|
+
buffers: Buffer[];
|
16
|
+
}
|
17
|
+
export declare function getConsole(hook: (stdout: PassThrough, stderr: PassThrough) => Promise<void>, also?: Console, alsoPrefix?: string): Console;
|
18
|
+
export declare function prepareConsoles(getConsoleName: () => string, systemManager: () => SystemManager, deviceManager: () => DeviceManager, getPlugins: () => Promise<any>): {
|
19
|
+
getDeviceConsole: (nativeId?: ScryptedNativeId) => Console;
|
20
|
+
getMixinConsole: (mixinId: string, nativeId: ScryptedNativeId) => Console;
|
21
|
+
};
|
22
|
+
export declare function createConsoleServer(remoteStdout: Readable, remoteStderr: Readable, header: string): Promise<{
|
23
|
+
clear(nativeId: ScryptedNativeId): void;
|
24
|
+
destroy(): void;
|
25
|
+
pluginConsole: Console;
|
26
|
+
readPort: number;
|
27
|
+
writePort: number;
|
28
|
+
}>;
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import { EventListener, EventListenerOptions, EventListenerRegister, ScryptedDevice, ScryptedDeviceType } from "@scrypted/types";
|
2
|
+
import { PluginDevice } from "../db-types";
|
3
|
+
import { PrimitiveProxyHandler } from "../rpc";
|
4
|
+
import { ScryptedRuntime } from "../runtime";
|
5
|
+
interface MixinTable {
|
6
|
+
mixinProviderId: string;
|
7
|
+
entry: Promise<MixinTableEntry>;
|
8
|
+
}
|
9
|
+
interface MixinTableEntry {
|
10
|
+
interfaces: Set<string>;
|
11
|
+
methods?: Set<string>;
|
12
|
+
allInterfaces: string[];
|
13
|
+
proxy: any;
|
14
|
+
error?: Error;
|
15
|
+
passthrough: boolean;
|
16
|
+
}
|
17
|
+
export declare const RefreshSymbol: unique symbol;
|
18
|
+
export declare const QueryInterfaceSymbol: unique symbol;
|
19
|
+
export declare class PluginDeviceProxyHandler implements PrimitiveProxyHandler<any>, ScryptedDevice {
|
20
|
+
scrypted: ScryptedRuntime;
|
21
|
+
id: string;
|
22
|
+
mixinTable: MixinTable[];
|
23
|
+
releasing: Set<any>;
|
24
|
+
static sortInterfaces(interfaces: string[]): string[];
|
25
|
+
constructor(scrypted: ScryptedRuntime, id: string);
|
26
|
+
toPrimitive(): string;
|
27
|
+
invalidateEntry(mixinEntry: MixinTable): void;
|
28
|
+
getMixinProviderId(id: string, mixinDevice: any): Promise<string | true>;
|
29
|
+
invalidate(): void;
|
30
|
+
/**
|
31
|
+
* Rebuild the mixin table with any currently missing mixins.
|
32
|
+
*/
|
33
|
+
rebuildMixinTable(): void;
|
34
|
+
ensureProxy(lastValidMixinId?: string): Promise<PluginDevice>;
|
35
|
+
rebuildEntry(pluginDevice: PluginDevice, mixinId: string, wrappedMixinTablePromise: Promise<MixinTable[]>): Promise<MixinTableEntry>;
|
36
|
+
get(target: any, p: PropertyKey, receiver: any): any;
|
37
|
+
listen(event: string | EventListenerOptions, callback: EventListener): EventListenerRegister;
|
38
|
+
setName(name: string): Promise<void>;
|
39
|
+
setRoom(room: string): Promise<void>;
|
40
|
+
setType(type: ScryptedDeviceType): Promise<void>;
|
41
|
+
setMixins(mixins: string[]): Promise<void>;
|
42
|
+
probe(): Promise<boolean>;
|
43
|
+
applyMixin(method: string, argArray?: any): Promise<any>;
|
44
|
+
findMethod(method: string): Promise<{
|
45
|
+
mixin: MixinTable;
|
46
|
+
entry: MixinTableEntry;
|
47
|
+
}>;
|
48
|
+
findMixin(iface: string): Promise<{
|
49
|
+
mixin: MixinTable;
|
50
|
+
entry: MixinTableEntry;
|
51
|
+
}>;
|
52
|
+
apply(target: any, thisArg: any, argArray?: any): Promise<any>;
|
53
|
+
}
|
54
|
+
export {};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/// <reference types="lodash" />
|
2
|
+
import { Device, DeviceManifest, EventDetails, EventListenerOptions, EventListenerRegister, MediaManager, ScryptedDevice, ScryptedInterfaceDescriptor, ScryptedInterfaceProperty, ScryptedNativeId } from '@scrypted/types';
|
3
|
+
import { Logger } from '../logger';
|
4
|
+
import { RpcPeer } from '../rpc';
|
5
|
+
import { ScryptedRuntime } from '../runtime';
|
6
|
+
import { getPropertyInterfaces } from './descriptor';
|
7
|
+
import { PluginAPI, PluginAPIManagedListeners } from './plugin-api';
|
8
|
+
import { PluginHost } from './plugin-host';
|
9
|
+
export declare class PluginHostAPI extends PluginAPIManagedListeners implements PluginAPI {
|
10
|
+
scrypted: ScryptedRuntime;
|
11
|
+
pluginHost: PluginHost;
|
12
|
+
mediaManager: MediaManager;
|
13
|
+
pluginId: string;
|
14
|
+
typesVersion: string;
|
15
|
+
descriptors: {
|
16
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
17
|
+
};
|
18
|
+
propertyInterfaces: ReturnType<typeof getPropertyInterfaces>;
|
19
|
+
[RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS]: string[];
|
20
|
+
restartDebounced: import("lodash").DebouncedFunc<() => Promise<void>>;
|
21
|
+
constructor(scrypted: ScryptedRuntime, pluginId: string, pluginHost: PluginHost, mediaManager: MediaManager);
|
22
|
+
onMixinEvent(id: string, nativeIdOrMixinDevice: ScryptedNativeId | any, eventInterface: string, eventData?: any): Promise<void>;
|
23
|
+
getMediaManager(): Promise<MediaManager>;
|
24
|
+
getLogger(nativeId: ScryptedNativeId): Promise<Logger>;
|
25
|
+
getComponent(id: string): Promise<any>;
|
26
|
+
setDeviceProperty(id: string, property: ScryptedInterfaceProperty, value: any): Promise<void>;
|
27
|
+
setState(nativeId: ScryptedNativeId, key: string, value: any): Promise<void>;
|
28
|
+
setStorage(nativeId: ScryptedNativeId, storage: {
|
29
|
+
[key: string]: string;
|
30
|
+
}): Promise<void>;
|
31
|
+
onDevicesChanged(deviceManifest: DeviceManifest): Promise<void>;
|
32
|
+
onDeviceDiscovered(device: Device): Promise<string>;
|
33
|
+
onDeviceRemoved(nativeId: string): Promise<void>;
|
34
|
+
onDeviceEvent(nativeId: any, eventInterface: any, eventData?: any): Promise<void>;
|
35
|
+
getDeviceById<T>(id: string): Promise<T & ScryptedDevice>;
|
36
|
+
listen(callback: (id: string, eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
37
|
+
listenDevice(id: string, event: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
|
38
|
+
removeDevice(id: string): Promise<void>;
|
39
|
+
requestRestart(): Promise<void>;
|
40
|
+
setScryptedInterfaceDescriptors(typesVersion: string, descriptors: {
|
41
|
+
[scryptedInterface: string]: ScryptedInterfaceDescriptor;
|
42
|
+
}): Promise<void>;
|
43
|
+
}
|