Skip to content

Commit

Permalink
core: fix init order
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed May 13, 2023
1 parent 90c9efc commit d8f3ede
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plugins/core/.vscode/settings.json
@@ -1,3 +1,3 @@
{
"scrypted.debugHost": "192.168.2.53",
"scrypted.debugHost": "127.0.0.1",
}
4 changes: 2 additions & 2 deletions plugins/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@scrypted/core",
"version": "0.1.127",
"version": "0.1.128",
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
"author": "Scrypted",
"license": "Apache-2.0",
Expand Down
17 changes: 6 additions & 11 deletions plugins/core/src/main.ts
Expand Up @@ -35,7 +35,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
router: any = Router();
publicRouter: any = Router();
mediaCore: MediaCore;
launcher: LauncherMixin;
scriptCore: ScriptCore;
aggregateCore: AggregateCore;
automationCore: AutomationCore;
Expand Down Expand Up @@ -73,7 +72,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
type: ScryptedDeviceType.Builtin,
},
);
this.mediaCore = new MediaCore('mediacore');
})();
(async () => {
await deviceManager.onDeviceDiscovered(
Expand All @@ -84,7 +82,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
type: ScryptedDeviceType.Builtin,
},
);
this.scriptCore = new ScriptCore();
})();

(async () => {
Expand All @@ -96,7 +93,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
type: ScryptedDeviceType.Builtin,
},
);
this.automationCore = new AutomationCore();
})();

deviceManager.onDeviceDiscovered({
Expand All @@ -119,7 +115,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
type: ScryptedDeviceType.Builtin,
},
);
this.aggregateCore = new AggregateCore();
})();


Expand All @@ -132,7 +127,6 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
type: ScryptedDeviceType.Builtin,
},
);
this.users = new UsersCore();
})();
}

Expand All @@ -145,6 +139,7 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
}
return this.storageSettings.getSettings();
}

async putSetting(key: string, value: SettingValue): Promise<void> {
await this.storageSettings.putSetting(key, value);
}
Expand All @@ -153,15 +148,15 @@ class ScryptedCore extends ScryptedDeviceBase implements HttpRequestHandler, Eng
if (nativeId === 'launcher')
return new LauncherMixin('launcher');
if (nativeId === 'mediacore')
return this.mediaCore;
return this.mediaCore ||= new MediaCore();
if (nativeId === ScriptCoreNativeId)
return this.scriptCore;
return this.scriptCore ||= new ScriptCore();
if (nativeId === AutomationCoreNativeId)
return this.automationCore;
return this.automationCore ||= new AutomationCore()
if (nativeId === AggregateCoreNativeId)
return this.aggregateCore;
return this.aggregateCore ||= new AggregateCore();
if (nativeId === UsersNativeId)
return this.users;
return this.users ||= new UsersCore();
}

async releaseDevice(id: string, nativeId: string): Promise<void> {
Expand Down
5 changes: 3 additions & 2 deletions plugins/core/src/media-core.ts
Expand Up @@ -5,15 +5,16 @@ const { systemManager, deviceManager, mediaManager, endpointManager } = sdk;
import { RequestMediaObjectHost, FileHost, BufferHost } from './converters';
import url from 'url';

export const MediaCoreNativeId = 'mediacore';
export class MediaCore extends ScryptedDeviceBase implements DeviceProvider, BufferConverter, HttpRequestHandler {
httpHost: BufferHost;
httpsHost: BufferHost;
rmoHost: RequestMediaObjectHost;
fileHost: FileHost;
filesHost: FileHost;

constructor(nativeId: string) {
super(nativeId);
constructor() {
super(MediaCoreNativeId);

this.fromMimeType = ScryptedMimeTypes.SchemePrefix + 'scrypted-media';
this.toMimeType = ScryptedMimeTypes.MediaObject;
Expand Down

0 comments on commit d8f3ede

Please sign in to comment.