mirror of
https://github.com/koush/scrypted.git
synced 2026-03-01 00:42:28 +00:00
core: add script default export support
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
export interface ScriptDevice {
|
||||
/**
|
||||
* @deprecated Use export default instead.
|
||||
* @param handler
|
||||
*/
|
||||
handle<T>(handler?: T & object): void;
|
||||
handleTypes(...interfaces: string[]): void;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export async function scryptedEval(device: ScryptedDeviceBase, script: string, e
|
||||
console: device.console,
|
||||
localStorage: device.storage,
|
||||
device,
|
||||
exports: {},
|
||||
exports: {} as any,
|
||||
ScryptedInterface,
|
||||
ScryptedDeviceType,
|
||||
});
|
||||
@@ -102,7 +102,12 @@ export async function scryptedEval(device: ScryptedDeviceBase, script: string, e
|
||||
}
|
||||
|
||||
try {
|
||||
return await asyncFunction();
|
||||
const value = await asyncFunction();
|
||||
const defaultExport = allParams.exports.default;
|
||||
return {
|
||||
value,
|
||||
defaultExport,
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
device.log.e('Error running script.');
|
||||
|
||||
Reference in New Issue
Block a user