mirror of
https://github.com/koush/scrypted.git
synced 2026-09-17 17:20:39 +01:00
Merge branch 'main' of github.com:koush/scrypted
This commit is contained in:
40
.github/workflows/build-plugins-changed.yml
vendored
Normal file
40
.github/workflows/build-plugins-changed.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: Build changed plugins
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths: ["plugins/**"]
|
||||
pull_request:
|
||||
paths: ["plugins/**"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Set up base packages
|
||||
run: ./npm-install.sh
|
||||
|
||||
- name: Build changed plugins
|
||||
run: |
|
||||
# Get the list of changed directories in /plugins
|
||||
changed_dirs=$(git diff --name-only HEAD^ HEAD ./plugins | awk -F/ '{print $2}' | uniq)
|
||||
|
||||
# Loop through each changed directory
|
||||
for dir in $changed_dirs; do
|
||||
pushd "./plugins/$dir"
|
||||
echo "plugins/$dir > npm install"
|
||||
npm install
|
||||
echo "plugins/$dir > npm run build"
|
||||
npm run build
|
||||
popd
|
||||
done
|
||||
2
.github/workflows/build-sdk.yml
vendored
2
.github/workflows/build-sdk.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
- run: npm ci
|
||||
|
||||
@@ -73,5 +73,5 @@ export abstract class AutoenableMixinProvider extends ScryptedDeviceBase {
|
||||
this.storage.setItem('hasEnabledMixin', JSON.stringify(this.hasEnabledMixin));
|
||||
}
|
||||
|
||||
abstract canMixin(type: ScryptedDeviceType, interfaces: string[]): Promise<string[]>;
|
||||
abstract canMixin(type: ScryptedDeviceType, interfaces: string[]): Promise<string[] | null | undefined | void>;
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ export class Scheduler {
|
||||
schedule.saturday,
|
||||
];
|
||||
|
||||
const date = new Date();
|
||||
date.setHours(schedule.hour);
|
||||
date.setMinutes(schedule.minute);
|
||||
|
||||
const ret: ScryptedDevice = {
|
||||
async setName() { },
|
||||
async setType() { },
|
||||
async setRoom() { },
|
||||
async setMixins() { },
|
||||
async probe() { return true },
|
||||
async probe() { return true; },
|
||||
listen(event: EventListenerOptions, callback, source?: ScryptedDeviceBase) {
|
||||
function reschedule(): Date {
|
||||
const date = new Date();
|
||||
date.setHours(schedule.hour);
|
||||
date.setMinutes(schedule.minute);
|
||||
|
||||
const now = Date.now();
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const future = new Date(date.getTime() + i * 24 * 60 * 60 * 1000);
|
||||
@@ -65,7 +65,7 @@ export class Scheduler {
|
||||
eventId: undefined,
|
||||
eventInterface: 'Scheduler',
|
||||
eventTime: Date.now(),
|
||||
}, prevWhen)
|
||||
}, prevWhen);
|
||||
}
|
||||
|
||||
function setupTimer() {
|
||||
@@ -87,8 +87,13 @@ export class Scheduler {
|
||||
timeout = null;
|
||||
when = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
id: "",
|
||||
pluginId: "",
|
||||
interfaces: [],
|
||||
mixins: [],
|
||||
providedInterfaces: []
|
||||
}
|
||||
|
||||
ret.name = 'Scheduler';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { writeFileSync } from "fs";
|
||||
import { ffmpegFilterImage } from "../src/ffmpeg-image-filter";
|
||||
import { sharpFilterImage } from "../src/sharp-image-filter";
|
||||
import path from 'path';
|
||||
|
||||
async function main1() {
|
||||
@@ -27,29 +26,4 @@ async function main1() {
|
||||
console.log('test1 done');
|
||||
}
|
||||
|
||||
async function main2() {
|
||||
const ret = await sharpFilterImage('/Users/koush/Downloads/151-1678381127261.jpg',
|
||||
{
|
||||
blur: true,
|
||||
// crop: {
|
||||
// // fractional: true,
|
||||
// left: 100,
|
||||
// top: 100,
|
||||
// width: 1000,
|
||||
// height: 500,
|
||||
// },
|
||||
brightness: -.2,
|
||||
text: {
|
||||
fontFile: path.join(__dirname, '../fs/Lato-Bold.ttf'),
|
||||
text: 'Hello World',
|
||||
}
|
||||
// }
|
||||
// { "crop": { "left": 0.216796875, "top": 0.2552083333333333, "width": 0.318359375, "height": 0.17907714843749994, "fractional": true }
|
||||
}
|
||||
);
|
||||
writeFileSync('test2.jpg', ret);
|
||||
console.log('test2 done');
|
||||
}
|
||||
|
||||
main1();
|
||||
main2();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
"src/**/*",
|
||||
"test/**/*",
|
||||
]
|
||||
}
|
||||
@@ -159,24 +159,22 @@ export class MixinDeviceBase<T> extends DeviceBase implements DeviceState {
|
||||
|
||||
(function () {
|
||||
function _createGetState(state: ScryptedInterfaceProperty) {
|
||||
return function () {
|
||||
// @ts-ignore: this as any
|
||||
return function <T>(this: ScryptedDeviceBase | MixinDeviceBase<T>) {
|
||||
this._lazyLoadDeviceState();
|
||||
// @ts-ignore: this as any
|
||||
// @ts-ignore: accessing private property
|
||||
return this._deviceState?.[state];
|
||||
};
|
||||
}
|
||||
|
||||
function _createSetState(state: ScryptedInterfaceProperty) {
|
||||
return function (value: any) {
|
||||
// @ts-ignore: this as any
|
||||
return function <T>(this: ScryptedDeviceBase | MixinDeviceBase<T>, value: any) {
|
||||
this._lazyLoadDeviceState();
|
||||
// @ts-ignore: this as any
|
||||
// @ts-ignore: accessing private property
|
||||
if (!this._deviceState) {
|
||||
console.warn('device state is unavailable. the device must be discovered with deviceManager.onDeviceDiscovered or deviceManager.onDevicesChanged before the state can be set.');
|
||||
}
|
||||
else {
|
||||
// @ts-ignore: this as any
|
||||
// @ts-ignore: accessing private property
|
||||
this._deviceState[state] = value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1097,7 +1097,7 @@ class Microphone:
|
||||
class MixinProvider:
|
||||
"""MixinProviders can add and intercept interfaces to other devices to add or augment their behavior."""
|
||||
|
||||
async def canMixin(self, type: ScryptedDeviceType, interfaces: list[str]) -> list[str]:
|
||||
async def canMixin(self, type: ScryptedDeviceType, interfaces: list[str]) -> None | list[str]:
|
||||
pass
|
||||
|
||||
async def getMixin(self, mixinDevice: Any, mixinDeviceInterfaces: list[ScryptedInterface], mixinDeviceState: WritableDeviceState) -> Any:
|
||||
|
||||
@@ -1862,7 +1862,7 @@ export interface MixinProvider {
|
||||
/**
|
||||
* Called by the system to determine if this provider can create a mixin for the supplied device. Returns null if a mixin can not be created, otherwise returns a list of new interfaces (which may be an empty list) that are provided by the mixin.
|
||||
*/
|
||||
canMixin(type: ScryptedDeviceType, interfaces: string[]): Promise<string[]>;
|
||||
canMixin(type: ScryptedDeviceType, interfaces: string[]): Promise<string[] | null | undefined | void>;
|
||||
|
||||
/**
|
||||
* Create a mixin that can be applied to the supplied device.
|
||||
|
||||
Reference in New Issue
Block a user