Commit Graph

103 Commits

Author SHA1 Message Date
Florian Hotze
7b16ef1de8
[jsscripting] Upgrade openhab-js to 4.7.0 (#16062)
You'll find the changelog at the openhab-js repo: https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#470.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-12-14 20:23:37 +01:00
openhab-bot
62f9f03bbf
New Crowdin updates (#15931)
* New translations openwebnet.properties (Italian)
* New translations jsscripting.properties (Danish)
* New translations hdpowerview.properties (Danish)
2023-11-20 12:30:32 +01:00
Holger Friedrich
f24a4305b8
Improve javadoc for some addons (#15701)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2023-10-08 00:25:04 +02:00
Holger Friedrich
cbf4411034
Improve javadoc for all addons (#15667)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2023-09-30 21:49:12 +02:00
openhab-bot
5012381f08
New Crowdin updates (#15653)
* New translations netatmo.properties (Italian)
* New translations danfossairunit.properties (Danish)
* New translations jsscripting.properties (Italian)
2023-09-29 22:19:03 +02:00
Florian Hotze
99f0512c73
[jsscripting] Rename library injection parameter & Improve docs (#15547)
* [jsscripting] Rename parameter useIncludedLibrary to injectionCachingEnabled (#4)
* [jsscripting] Improve README for cached library injection
* Remove settings image

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-09-26 22:59:20 +02:00
Holger Friedrich
5b42c4b071
Java 17 features (#15493)
- add missing @override
- Java style array syntax
- remove redundant modifiers
- always move String constants to left side in comparisons
- simplify lambda expressions and return statements
- use replace instead of replaceAll w/o regex

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2023-08-26 08:52:11 +02:00
Holger Friedrich
7b90fbe162
[automation] Use Java 17 features (#15484)
* [automation] Code optimization for Java17: instanceof matching and multiline strings

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* [automation] Make use of Java17 features

Use Map/Set/List.of instead of Collections.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

* review comment

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>

---------

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2023-08-23 17:27:40 +02:00
Wouter Born
c71a24f8a1
Link to Java 17 documentation (#15406)
This prevents issues because older documentation may not apply to Java 17.

Signed-off-by: Wouter Born <github@maindrain.net>
2023-08-13 13:44:05 +02:00
voruti
faceef6fd4
Fix missing cast (#15356)
Signed-off-by: Till von Rüden <dev@tillvonrueden.de>
2023-08-06 10:43:06 +02:00
Florian Hotze
bf7f24c099
[jsscripting] Upgrade openhab-js to 4.5.1 to fix cached injection (#15336)
It was found out that a recent change to the webpack config for the library injection bundle heavily affected performance of the evaluation of the cached injection.

openhab-js 4.5.1 fixes that regression and one minor bug, see https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#451.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-30 14:47:03 +02:00
Florian Hotze
e1c9213cfc
[jsscripting] Fix timerId not returned by JS timer methods (#15308)
Regression from #15193.
Reported on the community, see https://community.openhab.org/t/openhab-4-0-release-discussion/147957/53?u=florian-h05.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-26 16:28:46 +02:00
Kai Kreuzer
72607d3bee Apply spotless
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2023-07-24 01:20:31 +02:00
openhab-bot
809fceaff3 [unleash-maven-plugin] Preparation for next development cycle. 2023-07-23 19:19:01 +00:00
Florian Hotze
72c0e1f29f
[jsscripting] Upgrade openhab-js to 4.5.0 (#15219)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-10 23:15:04 +02:00
Florian Hotze
2d75536f48
[jsscripting] Implement NodeJS-like parameter handling for timer polyfills (#15193)
* [jsscripting] Implement NodeJS-like param handling for timer polyfills
* [jsscripting] Clean-Up ThreadsafeTimer methods

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-07 23:10:35 +02:00
Florian Hotze
828c895b54
[jsscripting] Bump openhab-js version to 4.4.0 (#15128)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-06-20 15:40:11 +02:00
Florian Hotze
aa3d6b0dc9
[jsscripting] Add type translation for Instant & Minor improvements (#14984)
* [jsscripting] Minor code improvements
* [jsscripting] Add type mapping for `Instant`
* [jsscripting] Upgrade openhab-js to 4.3.0

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-05-13 12:25:06 +02:00
J-N-K
d9c12ca659
[jsscripting] Allow configuring from add-on page (#14985)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-05-13 12:21:14 +02:00
openhab-bot
4a2c3a35ba
New Crowdin updates (#14957)
* New translations astro.properties (French)

* New translations sonos.properties (French)

* New translations jsscripting.properties (Danish)
2023-05-09 13:09:40 +02:00
Jacob Laursen
e73650366c
Fix automation name/description (#14890)
Declare automation connection

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
2023-04-28 08:30:13 +02:00
Florian Hotze
03b305bde2
[jsscripting] Bump openhab-js to 4.2.1 (#14749)
* [jsscripting] Upgrade openhab-js to 4.2.1
* [jsscripting] Note that it is based on GraalJS

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-04-06 15:50:09 +02:00
openhab-bot
bb626768e4
New Crowdin updates (#14725)
* New translations jsscripting.properties (German)
* New translations jsscripting.properties (Italian)
2023-03-30 23:37:14 +02:00
Richard Koshak
7bddeb4a7f
Standardize on js for SCRIPT (#14652)
This has the add-on docs consistent with the main docs.
Signed-off-by: Richard Koshak <rlkoshak@gmail.com>
2023-03-23 21:53:16 +01:00
Florian Hotze
726858b4f1
[jsscripting] Upgrade openhab-js to 4.1.0 (#14495)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-02-25 10:18:49 +01:00
J-N-K
223deffcfd
[jsscripting] Fix node_modules handling (#14398)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-02-18 19:53:33 +01:00
J-N-K
9a05e9f3b5
[jsscripting] Fix JSScriptFileWatcher not ignoring correct directory (#14393)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-02-15 10:33:00 +01:00
Florian Hotze
ce2e76d6ee
[jsscripting] Bump openhab-js to 4.0.0 & Clean-Ups (#14375)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-02-14 21:19:59 +01:00
J-N-K
d613641bbd
Adapt addons to core watch service changes (#14004)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-02-13 16:37:57 +01:00
Florian Hotze
d2db49ff67
[jsscripting] Extend mapping of openhab-js classes to native openHAB counterparts (#14335)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-02-12 11:53:51 +01:00
J-N-K
5f8214f08a
Adapt to core changes (addon.xml) (#13289)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-01-15 20:31:42 +01:00
J-N-K
6aa0dcbc70
[scripting] Adjust to core changes (#14043)
* [scripting] Adjust to core changes

Signed-off-by: Jan N. Klug <github@klug.nrw>
2023-01-12 22:23:20 +01:00
Jacob Laursen
4dd6d3a8a2
Update license headers to 2023 (#14154)
* Update copyright year in configuration
* Update license headers

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
2023-01-06 09:49:54 +01:00
Florian Hotze
b91fc94bdb
[jsscripting] Update docs for code caching (#14166)
... and fix the table of contents.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-01-05 23:04:07 +01:00
Florian Hotze
f082df923f
[jsscripting] Fix regressions from #14135 & Log stack on IllegalArgumentException (#14142)
* [jsscripting] Fix bundling of global script & regression from #14135

Fixes the regression from https://github.com/openhab/openhab-addons/pull/14135#issuecomment-1369231126.

While working on this, I also noticed that the cache openhab-js does not work because of wrong webpack commandline args in the pom (wrong entrypoint).

* [jsscripting] Enable stack logging for IllegalArgumentExceptions
* [jsscripting] Upgrade openhab-js to 3.2.4
* [jsscripting] Update README for recent PR

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-01-03 20:45:23 +01:00
Florian Hotze
3c669ad77a
[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>
2023-01-02 20:41:35 +01:00
Florian Hotze
23cfec7684
[jsscripting] Improve performance & reduce memory usage (#14113)
* [jsscripting] Share org.graalvm.polyglot.Engine across all OpenhabGraalJSScriptEngine instances

See https://github.com/oracle/graaljs/issues/121#issuecomment-880056648, it is not required to have one engine per GraalJSScriptEngine.

This might improve performance a bit on less powerful systems (Raspberry Pi) and decreases heap usage:
With 5 GraalJS UI scripts, heap usage is now below 100 MB. Before this change, it was over 100 MB.

* [jsscripting] Extend debug logging
* [jsscripting] Cache `@jsscripting-globals.js` across all engines

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-30 23:34:35 +01:00
Florian Hotze
931f004ab8
[jsscripting] Upgrade to ECMAScript 2022 & Dependency improvements (#14093)
* [jsscripting] Remove asm from dependencies in pom

GraalJS >= 20.3.0 doesn't require org.ow2.asm as compile dependency anymore, see https://mvnrepository.com/artifact/org.graalvm.js/js/20.3.0.

* [jsscripting] Remove dependency org.graalvm.js/js-launcher as it is not required

js-launcher is GraalVM's JavaScript command line interpreter and not required in the addon.
See https://www.graalvm.org/22.1/reference-manual/js/RunOnJDK/.

* [jsscripting] Add missing com.ibm.icu dependency

GraalJS changelog says that it is not required for GraalJS >= 22.0.0 (see 685e5873af/CHANGELOG.md (version-2200)).
But GraalJS 22.3.0 attempts to load classes from it during runtime.

* [jsscripting] Update GraalJS engine options

Compat, as its additional functionality is not used by openhab-js and user code is not expected to use it.

* [jsscripting] Remove com.ibm.icu/icu4j dependency
* [jsscripting] Don't disable Nashorn compat mode as openhab-js requires it for accessors

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-30 23:04:43 +01:00
Florian Hotze
895defda8e
[jsscripting] Use application/javascript as MIME type (#14096)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-29 21:01:22 +01:00
Florian Hotze
4d98cca7eb
[jsscripting] Minor fixes & improvements (#13960)
* [jsscripting] Correct wrong `createScriptEngine` implementation
* [jsscripting] Also unlock lock on unexpected exceptions (rethrow them)
* [jsscripting] Call super methods from their overrides
* [jsscripting] Move superclass call of `beforeInvocation`

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-20 09:15:43 +01:00
J-N-K
4d6d6443ef
fix spotless after release (#14014)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-12-19 15:22:17 +01:00
openhab-bot
7993786dc9 [unleash-maven-plugin] Preparation for next development cycle. 2022-12-19 00:55:11 +00:00
openhab-bot
d20b10317c
New Crowdin updates (#13990)
* New translations tr064.properties (German)
* New translations jsscripting.properties (Danish)
* New translations jsscripting.properties (Italian)
2022-12-17 16:51:35 +01:00
Florian Hotze
11e2c4fc31
[jsscripting] Update add-on name in default translation (#13984)
Leftover from #13764.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-17 13:40:12 +01:00
openhab-bot
4a13e1a68f
New Crowdin updates (#13971)
* New translations knx.properties (German)
* New translations yamahamusiccast.properties (German)
* New translations hdpowerview.properties (Danish)
* New translations jsscripting.properties (Danish)
2022-12-17 12:13:24 +01:00
openhab-bot
d6db72774a
New Crowdin updates (#13962)
* New translations chromecast.properties (Italian)
* New translations sonos.properties (Italian)
* New translations exec.properties (Italian)
* New translations knx.properties (German)
* New translations jsscripting.properties (German)
* New translations yamahamusiccast.properties (German)
2022-12-15 23:36:49 +01:00
Wouter Born
6e8b35c4c1
[jsscripting] Fix broken event object table (#13952)
The table is not properly rendered when reading the documentation in Main UI.

Signed-off-by: Wouter Born <github@maindrain.net>
2022-12-15 07:51:22 +01:00
Florian Hotze
d4ec220925
[jsscripting] Extend synchronization to common ScriptEngine methods (#13924)
* [jsscripting] Extend synchronization to common ScriptEngine methods

This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the DelegatingScriptEngineWithInvocableAndAutocloseableAndSynchronization class. Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180.

* Revert "[jsscripting] Extend synchronization to common ScriptEngine methods"

This reverts commit aadd21e45879c10aad29bf279ddbb0afd789b0aa.

* [jsscripting] Extend synchronization to common ScriptEngine methods & Switch to ReentrantLock

This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable class.
The synchronization mechanism changed from using synchronized to using a ReentrantLock together with catch_finally to avoid having deadlocks when an exception is thrown.
Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180.

* [jsscripting] Reduce compiler warnings
* [jsscripting] Replace finally blocks & Wrap returns in afterInvocation
* [jsscripting] Fix deadlock caused by NoSuchMethodException in Invocable interface methods

During testing my latest changes, I noticed that there is a deadlock when invokeFunction or invokeMethod are called on a non-existing method.
This happens because the NoSuchMethodException keeps afterInvocation from running and therefore the lock never gets released.

* [jsscripting] Also rethrow NPE & Fix PMD warnings/errors
* [jsscripting] Wrap and rethrow other exceptions instead of returning them
* [jsscripting] Address review comment from @jpg0

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-14 20:12:54 +01:00
Florian Hotze
438552d485
[jsscripting] Upgrade openhab-js & Remove SharedCache (#13908)
Upgrades the included openhab-js version to 3.1.0, which uses the new
caches from core (introduced in
https://github.com/openhab/openhab-core/pull/2887) and provides many
doc improvements.

Removes the SharedCache from the addon because this functionality is
now provided by core (see
https://github.com/openhab/openhab-core/pull/2887).

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-11 15:25:39 +01:00
Florian Hotze
a9d4244fd8
[jsscripting] Fix "Error removing engine" context already closed (#13855)
In recent PR #13824, I added closing the context when the engine is closed, but core seems to have problems with that.

It logs: "[ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error removing ScriptEngine
java.lang.IllegalStateException: The Context is already closed."

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-06 13:15:47 +01:00