diff --git a/CHANGELOG.md b/CHANGELOG.md index 54e9133..eafb9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.5] - 2024-01-07 +### Changed +- Replaced usage of deprecated synchronous version of `evaluateJSONataExpression` by asynchronous version as synchronous version will not work anymore starting with Node-RED 4.0. +- Updated versions of some dependencies. + ## [2.0.4] - 2023-06-15 ### Fixed - Removed port input for video sources in configuration UI. diff --git a/LICENSE b/LICENSE index 19252a0..c945f01 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Jens-Uwe Rossbach +Copyright (c) 2024 Jens-Uwe Rossbach Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 84ccde5..6ef9042 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you encountered a bug, would like to propose a new feature or simply want to To see what has changed in recent versions of the software, please have a look at the project's [change log](https://github.com/jensrossbach/node-red-sony-audio/blob/master/CHANGELOG.md). ## License -Copyright (c) 2023 Jens-Uwe Rossbach +Copyright (c) 2024 Jens-Uwe Rossbach This code is licensed under the MIT License. @@ -59,7 +59,7 @@ THIS SOFTWARE AND ITS AUTHOR ARE NOT AFFILIATED WITH SONY CORPORATION. The trademark "SONY" and any other product names, service names or logos of SONY used, quoted and/or referenced in this Web Site are trademarks or registered trademarks of Sony Corporation or any of its affiliates. ### License Audio Control API -Copyright (c) 2023 Sony Corporation. All rights reserved. +Copyright (c) 2024 Sony Corporation. All rights reserved. The 'Audio Control API' is licensed to the user by Sony Video & Sound products Inc. under the license terms of the [Creative Commons Attribution-NoDerivatives 4.0 International Public License](https://creativecommons.org/licenses/by-nd/4.0/legalcode). diff --git a/nodes/common/event_constants.js b/nodes/common/event_constants.js index 668bde0..26b9284 100644 --- a/nodes/common/event_constants.js +++ b/nodes/common/event_constants.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Jens-Uwe Rossbach + * Copyright (c) 2024 Jens-Uwe Rossbach * * This code is licensed under the MIT License. * diff --git a/nodes/common/event_recv.js b/nodes/common/event_recv.js index 5903419..da992a4 100644 --- a/nodes/common/event_recv.js +++ b/nodes/common/event_recv.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Jens-Uwe Rossbach + * Copyright (c) 2024 Jens-Uwe Rossbach * * This code is licensed under the MIT License. * diff --git a/nodes/common/utils.js b/nodes/common/utils.js index 49b89e0..a60babc 100644 --- a/nodes/common/utils.js +++ b/nodes/common/utils.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Jens-Uwe Rossbach + * Copyright (c) 2024 Jens-Uwe Rossbach * * This code is licensed under the MIT License. * @@ -27,6 +27,8 @@ const Nunjucks = require("nunjucks"); module.exports = { + evaluateJSONataExpression: evaluateJSONataExpression, + validateOutputProperties: function(RED, node, source, target, allowEmpty) { for (let prop of source) @@ -112,8 +114,9 @@ module.exports = } catch (e) { - node.error(RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidExpression", - {error: e.code + ": " + e.message + " [POS: " + e.position + ", TOK: '" + e.token + ", VAL: '" + e.value + "']"})); + node.error( + RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidExpression", + {error: e.code + ": " + e.message + " [POS: " + e.position + ", TOK: '" + e.token + ", VAL: '" + e.value + "']"})); return false; } } @@ -142,7 +145,7 @@ module.exports = return true; }, - prepareOutput: function(RED, node, properties, msg, data, sendIfPayload) + prepareOutput: async function(RED, node, properties, msg, data, sendIfPayload) { let out = msg ? msg : {}; let numMsgProps = 0; @@ -154,7 +157,7 @@ module.exports = { if (prop.type == "msg") { - RED.util.setMessageProperty(out, prop.name, getProperty(prop), true); + RED.util.setMessageProperty(out, prop.name, await getProperty(prop), true); ++numMsgProps; if (prop.name == "payload") @@ -165,7 +168,7 @@ module.exports = else { let ctx = RED.util.parseContextStore(prop.name); - node.context()[prop.type].set(ctx.key, getProperty(prop), ctx.store); + node.context()[prop.type].set(ctx.key, await getProperty(prop), ctx.store); } } catch (e) @@ -192,7 +195,7 @@ module.exports = return out; - function getProperty(prop) + async function getProperty(prop) { let value = null; @@ -226,7 +229,9 @@ module.exports = } catch (e) { - throw new Error(RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidTemplate", {error: e.message})); + throw new Error( + RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidTemplate", + {error: e.message})); } } else @@ -240,12 +245,13 @@ module.exports = { try { - value = RED.util.evaluateJSONataExpression(prop.value.expression, data); + value = await evaluateJSONataExpression(RED, prop.value.expression, data); } catch (e) { - throw new Error(RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidExpression", - {error: e.code + ": " + e.message + " [POS: " + e.position + ", TOK: '" + e.token + "']"})); + throw new Error( + RED._("@jens_rossbach/node-red-sony-audio/sonyaudio-device:common.error.invalidExpression", + {error: e.code + ": " + e.message + " [POS: " + e.position + ", TOK: '" + e.token + "']"})); } if (typeof value == "undefined") @@ -662,3 +668,21 @@ module.exports = } } }; + +function evaluateJSONataExpression(RED, expr, msg) +{ + return new Promise((resolve, reject) => + { + RED.util.evaluateJSONataExpression(expr, msg, (error, result) => + { + if (error) + { + reject(error); + } + else + { + resolve(result); + } + }); + }); +} diff --git a/nodes/control.html b/nodes/control.html index 419f79e..083cc17 100644 --- a/nodes/control.html +++ b/nodes/control.html @@ -1,5 +1,5 @@