[jsscripting] Cache openhab-js injection to improve performance (#14135)

* [jsscripting] Extend comments for wraprequire
* [jsscripting] Enable openhab-js caching to improve performance

On my dev system (which I guess is much more powerful than most openHAB servers), cached openhab-js injection takes 100-200 ms.
openhab-js injection from file system takes about 1000 ms.

* [jsscripting] Update configuration language
* [jsscripting] Upgrade openhab-js version to 3.2.1 for required webpack changes

Documentation updates will follow in another PR to keep this one clean.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze
2023-01-02 20:41:35 +01:00
committed by GitHub
parent 12bd7c99c3
commit 3c669ad77a
6 changed files with 64 additions and 19 deletions

View File

@@ -7,8 +7,9 @@
<config-description uri="automation:jsscripting">
<parameter name="injectionEnabled" type="boolean" required="true">
<label>Use Built-in Global Variables</label>
<description><![CDATA[ Import all variables from the OH scripting library into all rules for common services like items, things, actions, log, etc... <br>
If disabled, the OH scripting library can be imported manually using "<i>require('openhab')</i>"
<description><![CDATA[
Import all variables from the openHAB JavaScript library into all rules for common services like items, things, actions, log, etc... <br>
If disabled, the openHAB JavaScript library can be imported manually using "<i>require('openhab')</i>"
]]></description>
<options>
<option value="true">Use Built-in Variables</option>
@@ -16,5 +17,17 @@
</options>
<default>true</default>
</parameter>
<parameter name="useIncludedLibrary" type="boolean" required="true">
<label>Use Included openHAB JavaScript Library</label>
<description><![CDATA[
Use the included openHAB JavaScript library for optimal performance.<br>
Disable this option to allow loading the library from the local user configuration directory "automation/js/node_modules". Using a user provided version of the library may increase script loading times, especially on less powerful systems.
]]></description>
<options>
<option value="true">Use Included Library</option>
<option value="false">Do Not Use Included Library</option>
</options>
<default>true</default>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@@ -1,7 +1,11 @@
automation.config.jsscripting.injectionEnabled.label = Use Built-in Global Variables
automation.config.jsscripting.injectionEnabled.description = Import all variables from the OH scripting library into all rules for common services like items, things, actions, log, etc... <br> If disabled, the OH scripting library can be imported manually using "<i>require('openhab')</i>"
automation.config.jsscripting.injectionEnabled.description = Import all variables from the openHAB JavaScript library into all rules for common services like items, things, actions, log, etc... <br> If disabled, the openHAB JavaScript library can be imported manually using "<i>require('openhab')</i>"
automation.config.jsscripting.injectionEnabled.option.true = Use Built-in Variables
automation.config.jsscripting.injectionEnabled.option.false = Do Not Use Built-in Variables
automation.config.jsscripting.useIncludedLibrary.label = Use Included openHAB JavaScript Library
automation.config.jsscripting.useIncludedLibrary.description = Use the included openHAB JavaScript library for optimal performance.<br> Disable this option to allow loading the library from the local user configuration directory "automation/js/node_modules". Using a user provided version of the library may increase script loading times, especially on less powerful systems.
automation.config.jsscripting.useIncludedLibrary.option.true = Use Included Library
automation.config.jsscripting.useIncludedLibrary.option.false = Do Not Use Included Library
# service