From db903f560841009358e464ae00f754cd3fca9dfd Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 7 Jan 2022 11:30:37 -0800 Subject: [PATCH] core: reduce memory pressure on startup from typescript import --- common/src/scrypted-eval.ts | 7 +++++-- plugins/core/package-lock.json | 4 ++-- plugins/core/package.json | 2 +- plugins/core/src/aggregate.ts | 4 +++- plugins/core/src/builtins/scheduler.ts | 1 + 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/src/scrypted-eval.ts b/common/src/scrypted-eval.ts index 9a7638c55..142383320 100644 --- a/common/src/scrypted-eval.ts +++ b/common/src/scrypted-eval.ts @@ -1,10 +1,13 @@ -import ts, { ScriptTarget } from "typescript"; +import type { TranspileOptions } from "typescript"; import sdk, { ScryptedDeviceBase, ScryptedInterface, ScryptedDeviceType } from "@scrypted/sdk"; import vm from "vm"; const { systemManager, deviceManager, mediaManager, endpointManager } = sdk; -function tsCompile(source: string, options: ts.TranspileOptions = null): string { +function tsCompile(source: string, options: TranspileOptions = null): string { + const ts = require("typescript"); + const { ScriptTarget } = ts; + // Default options -- you could also perform a merge, or use the project tsconfig.json if (null === options) { options = { diff --git a/plugins/core/package-lock.json b/plugins/core/package-lock.json index 13a1fa3a0..7ce0d51f8 100644 --- a/plugins/core/package-lock.json +++ b/plugins/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/core", - "version": "0.0.167", + "version": "0.0.168", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/core", - "version": "0.0.167", + "version": "0.0.168", "license": "Apache-2.0", "dependencies": { "@koush/wrtc": "^0.5.0", diff --git a/plugins/core/package.json b/plugins/core/package.json index df9c1953a..a743ec351 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/core", - "version": "0.0.167", + "version": "0.0.168", "description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/core/src/aggregate.ts b/plugins/core/src/aggregate.ts index c62bc5bdf..a19d1e026 100644 --- a/plugins/core/src/aggregate.ts +++ b/plugins/core/src/aggregate.ts @@ -39,8 +39,10 @@ aggregators.set(ScryptedInterface.Lock, values => values.reduce((prev, cur) => cur === LockState.Unlocked ? cur : prev, LockState.Locked)); +type AggregateCameraParsers = "mpegts"; + function createVideoCamera(devices: VideoCamera[], console: Console): VideoCamera { - let sessionPromise: Promise + let sessionPromise: Promise> async function getVideoStreamWrapped(options: MediaStreamOptions) { if (sessionPromise) { diff --git a/plugins/core/src/builtins/scheduler.ts b/plugins/core/src/builtins/scheduler.ts index a0b172ac2..685b74203 100644 --- a/plugins/core/src/builtins/scheduler.ts +++ b/plugins/core/src/builtins/scheduler.ts @@ -53,6 +53,7 @@ export class Scheduler { async setName() { }, async setType() { }, async setRoom() { }, + async probe() { return true }, listen(event: EventListenerOptions, callback, source?: ScryptedDeviceBase) { function reschedule(): Date { const now = Date.now();