server: add exports to plugin scope

This commit is contained in:
Koushik Dutta
2021-10-22 00:54:29 -07:00
parent ecc3535efe
commit 2563ec4453
6 changed files with 17 additions and 15 deletions

2
.gitmodules vendored
View File

@@ -1,5 +1,5 @@
[submodule "plugins/homekit/HAP-NodeJS"]
path = plugins/homekit/HAP-NodeJS
path = external/HAP-NodeJS
url = git@github.com:koush/HAP-NodeJS
[submodule "plugins/unifi-protect/src/unifi-protect"]
path = plugins/unifi-protect/src/unifi-protect

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/server",
"version": "0.0.41",
"version": "0.0.43",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/server",
"version": "0.0.41",
"version": "0.0.43",
"license": "ISC",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/server",
"version": "0.0.41",
"version": "0.0.43",
"description": "",
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.5",
@@ -30,14 +30,19 @@
},
"optionalDependencies": {
"ffmpeg-for-homebridge": "^0.0.9",
"mdns": "^2.7.2"
},
"devDependencies": {
"mdns": "^2.7.2",
"canvas": "^2.8.0",
"serialport": "^9.2.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.3",
"zwave-js": "^8.1.1",
"@koush/opencv4nodejs": "^5.6.7",
"@tensorflow-models/coco-ssd": "^2.2.2",
"@tensorflow/tfjs": "^3.9.0",
"@tensorflow/tfjs-core": "^3.9.0",
"@tensorflow/tfjs-node-gpu": "^3.9.0",
"@tensorflow/tfjs-node-gpu": "^3.9.0"
},
"devDependencies": {
"@types/adm-zip": "^0.4.33",
"@types/cookie-parser": "^1.4.2",
"@types/debug": "^4.1.5",
@@ -54,12 +59,7 @@
"@types/tar": "^4.0.5",
"@types/tmp": "^0.2.0",
"@types/whatwg-mimetype": "^2.1.0",
"@types/ws": "^7.4.7",
"canvas": "^2.8.0",
"serialport": "^9.2.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.3",
"zwave-js": "^8.1.1"
"@types/ws": "^7.4.7"
},
"scripts": {
"preserve": "npm run build",

View File

@@ -81,7 +81,7 @@ export class PluginDeviceProxyHandler implements ProxyHandler<any>, ScryptedDevi
const wrappedProxy = new Proxy(wrappedHandler, wrappedHandler);
try {
const interfaces = await (mixinProvider.canMixin(type, allInterfaces) as any) as ScryptedInterface[];
const interfaces = await mixinProvider.canMixin(type, allInterfaces) as any as ScryptedInterface[];
if (!interfaces) {
console.warn(`mixin provider ${mixinId} can no longer mixin ${this.id}`);
const mixins: string[] = getState(pluginDevice, ScryptedInterfaceProperty.mixins) || [];
@@ -173,6 +173,7 @@ export class PluginDeviceProxyHandler implements ProxyHandler<any>, ScryptedDevi
const mixinTable = await this.mixinTable;
for (const mixin of mixinTable) {
// this could be null?
if (mixin.interfaces.includes(iface))
return (await mixin.proxy)[method](...argArray);
}

View File

@@ -422,6 +422,7 @@ export function attachPluginRemote(peer: RpcPeer, options?: PluginRemoteAttachOp
}
const params: any = {
exports,
window,
require: (name: string) => {
if (name === 'fs' && !packageJson.scrypted.realfs) {