diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 6c5428bf..8681bd79 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -99,6 +99,7 @@ "附加 Androidx Work Runtime 版本 2.11.0", "升级 Android SDK 版本 35 -> 36", "升级 Gradle 版本 8.14 -> 8.14.3", + "升级 Rhino 版本 1.8.1-SNAPSHOT -> 2.0.0-SNAPSHOT", "升级 Desugar JDK Libs 版本 2.0.4 -> 2.1.5", "升级 Android Material 版本 1.12.0 -> 1.13.0", "升级 Androidx AppCompat 版本 1.7.0 -> 1.7.1", diff --git a/.readme/common.json b/.readme/common.json index 0b6e4de9..6f843d18 100644 --- a/.readme/common.json +++ b/.readme/common.json @@ -11,8 +11,8 @@ "android_studio_latest_recommended_download_address_of_tar": "https://edgedl.me.gvt1.com/edgedl/android/studio/ide-zips/2025.2.2.7/android-studio-2025.2.2.7-linux.tar.gz", "android_studio_latest_recommended_file_size_of_tar": "1.38 GiB", "var_date_contribution_table_data_updated": "2025/09/06", - "latest_rhino_engine_name_with_github_lineno_address": "[v1.8.1-SNAPSHOT](http://rhino.autojs6.com/blob/master/gradle.properties#L3)", - "var_date_rhino_engine_latest_committed": "2025/10/05", + "latest_rhino_engine_name_with_github_lineno_address": "[v2.0.0-SNAPSHOT](http://rhino.autojs6.com/blob/master/gradle.properties#L3)", + "var_date_rhino_engine_latest_committed": "2025/12/25", "var_date_jdk_max_supported": "%CURRENT_DATE%", "var_date_active_maintenance_phase_statistics_since_when": "%CURRENT_DATE%" } \ No newline at end of file diff --git a/.readme/template_readme.md b/.readme/template_readme.md index e2a45cbd..d0b7b6d2 100644 --- a/.readme/template_readme.md +++ b/.readme/template_readme.md @@ -15,7 +15,7 @@ Android Studio IntelliJ IDEA
- Rhino + Rhino JetBrains supporter GitHub License

diff --git a/app/build.gradle.kts b/app/build.gradle.kts index aa7dcb72..395acd52 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -190,7 +190,7 @@ dependencies /* Unclassified */ { implementation(project(":libs:markwon-syntax-highlight-4_6_2")) // Rhino - implementation(files("$rootDir/libs/org-mozilla-rhino-1_8_1-SNAPSHOT.jar")) + implementation(files("$rootDir/libs/org-mozilla-rhino-2_0_0-SNAPSHOT.jar")) // Tasker Plugin implementation(project(":libs:android-spackle-9_0_0")) diff --git a/app/src/main/assets/modules/promise.js b/app/src/main/assets/modules/promise.js index 3fd2ec92..8aed0ac0 100644 --- a/app/src/main/assets/modules/promise.js +++ b/app/src/main/assets/modules/promise.js @@ -5,10 +5,7 @@ * @see https://raw.githubusercontent.com/taylorhakes/promise-polyfill/master/dist/polyfill.js */ -/** - * @type {PromiseConstructorLike} - */ -module.exports = (/* @IIFE */ () => { +( /* @ModuleIIFE */ () => { let _ = { isArray(x) { return Boolean(x && typeof x.length !== 'undefined'); @@ -314,5 +311,8 @@ module.exports = (/* @IIFE */ () => { }, }); - return Promise; + /** + * @type {PromiseConstructorLike} + */ + module.exports = Promise; })(); \ No newline at end of file diff --git a/app/src/main/java/com/stardust/autojs/rhino/BindingNativeJavaObject.java b/app/src/main/java/com/stardust/autojs/rhino/BindingNativeJavaObject.java index 82fcb541..90793591 100644 --- a/app/src/main/java/com/stardust/autojs/rhino/BindingNativeJavaObject.java +++ b/app/src/main/java/com/stardust/autojs/rhino/BindingNativeJavaObject.java @@ -22,7 +22,7 @@ public class BindingNativeJavaObject extends NativeJavaObject { if (this.javaObject != null) { dynamicType = this.javaObject.getClass(); } else { - dynamicType = this.staticType; + dynamicType = this.staticType.asClass(); } diff --git a/app/src/main/java/org/autojs/autojs/engine/RhinoJavaScriptEngine.kt b/app/src/main/java/org/autojs/autojs/engine/RhinoJavaScriptEngine.kt index cba2b74c..a3f4667f 100644 --- a/app/src/main/java/org/autojs/autojs/engine/RhinoJavaScriptEngine.kt +++ b/app/src/main/java/org/autojs/autojs/engine/RhinoJavaScriptEngine.kt @@ -35,6 +35,7 @@ import org.mozilla.javascript.ScriptableObject.PERMANENT import org.mozilla.javascript.ScriptableObject.READONLY import org.mozilla.javascript.commonjs.module.RequireBuilder import org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider +import org.mozilla.javascript.lc.type.TypeInfo import java.io.File import java.io.IOException import java.io.InputStreamReader @@ -106,14 +107,18 @@ open class RhinoJavaScriptEngine(private val androidContext: android.content.Con override fun init() { thread = Thread.currentThread() - scriptable.defineProp("global", scriptable, PERMANENT) - scriptable.defineProp("__engine__", this, READONLY or DONTENUM or PERMANENT) + initRequireBuilder(context, scriptable) runtime.withTimeConsuming("runtime-init-prologue") { it.initPrologue() } + scriptable.defineProp("global", scriptable, PERMANENT) + scriptable.defineProp("__engine__", this, READONLY or DONTENUM or PERMANENT) + scriptable.defineProp("Promise", runtime.js_Promise, READONLY or PERMANENT) + scriptable.defineProp("ResultAdapter", runtime.js_ResultAdapter, READONLY or PERMANENT) + mInitScript.withTimeConsuming("script-init") { initScript -> runCatching { context.executeScriptWithContinuations(initScript, scriptable) @@ -200,8 +205,7 @@ open class RhinoJavaScriptEngine(private val androidContext: android.content.Con if (this is AutoJsContext) { rhinoJavaScriptEngine = this@RhinoJavaScriptEngine } - @Suppress("DEPRECATION") - optimizationLevel = -1 + isInterpretedMode = true languageVersion = Context.VERSION_ES6 locale = Locale.getDefault() wrapFactory = mWrapFactory @@ -209,9 +213,9 @@ open class RhinoJavaScriptEngine(private val androidContext: android.content.Con private inner class WrapFactory : AndroidContextFactory.WrapFactory() { - override fun wrapAsJavaObject(cx: Context?, scope: Scriptable, javaObject: Any?, staticType: Class<*>?): Scriptable? { + override fun wrapAsJavaObject(cx: Context?, scope: Scriptable, javaObject: Any?, staticType: TypeInfo): Scriptable? { return when (javaObject) { - is View -> ViewExtras.getNativeView(scope, /* view = */ javaObject, staticType, runtime) + is View -> ViewExtras.getNativeView(scope, /* view = */ javaObject, staticType.asClass(), runtime) is Paint -> super.wrapAsJavaObject(cx, scope, RhinoPaint(javaObject), staticType) else -> super.wrapAsJavaObject(cx, scope, javaObject, staticType) } diff --git a/app/src/main/java/org/autojs/autojs/rhino/AndroidContextFactory.kt b/app/src/main/java/org/autojs/autojs/rhino/AndroidContextFactory.kt index 44deb03a..993e7e2b 100644 --- a/app/src/main/java/org/autojs/autojs/rhino/AndroidContextFactory.kt +++ b/app/src/main/java/org/autojs/autojs/rhino/AndroidContextFactory.kt @@ -10,6 +10,7 @@ import org.autojs.autojs6.R import org.mozilla.javascript.Context import org.mozilla.javascript.ContextFactory import org.mozilla.javascript.Scriptable +import org.mozilla.javascript.lc.type.TypeInfo import java.io.File import java.util.* import java.util.concurrent.atomic.AtomicInteger @@ -51,8 +52,7 @@ open class AndroidContextFactory(private val cacheDirectory: File) : ContextFact private fun setupContext(context: Context) { context.apply { instructionObserverThreshold = 10000 - @Suppress("DEPRECATION") - optimizationLevel = -1 + isInterpretedMode = true languageVersion = Context.VERSION_ES6 locale = Locale.getDefault() wrapFactory = this@AndroidContextFactory.wrapFactory @@ -77,9 +77,9 @@ open class AndroidContextFactory(private val cacheDirectory: File) : ContextFact isJavaPrimitiveWrap = Pref.getBoolean(R.string.key_rhino_java_primitive_wrap, R.bool.pref_rhino_java_primitive_wrap) } - override fun wrap(cx: Context, scope: Scriptable, obj: Any?, staticType: Class<*>?): Any? = when { - obj is String -> bridges.toString(obj.toString()) - staticType == UiObjectCollection::class.java -> (obj as? UiObjectCollection)?.let { bridges.asArray(it) } ?: UiObjectCollection.EMPTY + override fun wrap(cx: Context, scope: Scriptable, obj: Any?, staticType: TypeInfo): Any? = when { + obj is String -> bridges.toString(obj) + staticType.asClass() == UiObjectCollection::class.java -> (obj as? UiObjectCollection)?.let { bridges.asArray(it) } ?: UiObjectCollection.EMPTY else -> super.wrap(cx, scope, obj, staticType) } diff --git a/app/src/main/java/org/autojs/autojs/rhino/BindingNativeJavaObject.java b/app/src/main/java/org/autojs/autojs/rhino/BindingNativeJavaObject.java index c4509b1b..b79fe3a1 100644 --- a/app/src/main/java/org/autojs/autojs/rhino/BindingNativeJavaObject.java +++ b/app/src/main/java/org/autojs/autojs/rhino/BindingNativeJavaObject.java @@ -23,7 +23,7 @@ public class BindingNativeJavaObject extends NativeJavaObject { if (this.javaObject != null) { dynamicType = this.javaObject.getClass(); } else { - dynamicType = this.staticType; + dynamicType = this.staticType.asClass(); } } diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/global/Global.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/global/Global.kt index 4ff510f7..12723aaa 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/global/Global.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/global/Global.kt @@ -107,8 +107,6 @@ class Global(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRunti override val selfAssignmentGetters = listOf>>( "WIDTH" to Supplier { ScreenMetrics.deviceScreenWidth }, "HEIGHT" to Supplier { ScreenMetrics.deviceScreenHeight }, - "Promise" to Supplier { scriptRuntime.js_Promise }, - "ResultAdapter" to Supplier { scriptRuntime.js_ResultAdapter }, ) companion object { diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/ui/UI.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/ui/UI.kt index 0096359a..7040e9e4 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/ui/UI.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/ui/UI.kt @@ -54,7 +54,6 @@ import org.autojs.autojs6.R import org.mozilla.javascript.BaseFunction import org.mozilla.javascript.Context import org.mozilla.javascript.NativeArray -import org.mozilla.javascript.NativeFunction import org.mozilla.javascript.NativeObject import org.mozilla.javascript.NativeWith import org.mozilla.javascript.Scriptable @@ -206,7 +205,7 @@ class UI(private val scriptRuntime: ScriptRuntime) : AugmentableProxy(scriptRunt override fun beforeCreateView(inflateContext: InflateContext, node: Node?, viewName: String, parent: ViewGroup?): View? { val widgets = scriptRuntime.ui.widgets if (widgets.contains(viewName)) { - val ctor = widgets.prop(viewName) as NativeFunction + val ctor = widgets.prop(viewName) as BaseFunction val widget = withRhinoContext { cx -> ctor.construct(cx, scriptRuntime.topLevelScope, arrayOf()) } as ScriptableObject diff --git a/app/src/main/java/org/autojs/autojs/util/RhinoUtils.kt b/app/src/main/java/org/autojs/autojs/util/RhinoUtils.kt index 22cf0e1a..c0c63604 100644 --- a/app/src/main/java/org/autojs/autojs/util/RhinoUtils.kt +++ b/app/src/main/java/org/autojs/autojs/util/RhinoUtils.kt @@ -728,10 +728,10 @@ object RhinoUtils { } @JvmStatic - fun js_object_getOwnPropertyDescriptor(value: ScriptableObject, key: Any): ScriptableObject? = withRhinoContext { cx -> + fun js_object_getOwnPropertyDescriptor(value: ScriptableObject, key: Any): ScriptableObject = withRhinoContext { cx -> val topLevel = ImporterTopLevel(cx) val obj = ensureScriptableObject(toObject(cx, topLevel, value)) - obj.getOwnPropertyDescriptor(cx, key) + obj.getOwnPropertyDescriptor(cx, key).toScriptableObject(topLevel) } @JvmStatic @@ -794,8 +794,6 @@ object RhinoUtils { it.initStandardObjects() cxRhino = it } - @Suppress("DEPRECATION") - cx.optimizationLevel = -1 cx.languageVersion = Context.VERSION_ES6 cx.isInterpretedMode = true function.invoke(cx) diff --git a/app/src/main/java/org/mozilla/javascript/ContextWrapper.java b/app/src/main/java/org/mozilla/javascript/ContextWrapper.java index 4d5ffbb9..3fea01ac 100644 --- a/app/src/main/java/org/mozilla/javascript/ContextWrapper.java +++ b/app/src/main/java/org/mozilla/javascript/ContextWrapper.java @@ -198,7 +198,7 @@ public class ContextWrapper extends Context { Context.setCachingEnabled(cachingEnabled); } - public static DebuggableScript getDebuggableView(Script script) { + public static DebuggableScript getDebuggableView(ScriptOrFn script) { return Context.getDebuggableView(script); } diff --git a/libs/org-mozilla-rhino-1_8_1-SNAPSHOT.jar b/libs/org-mozilla-rhino-1_8_1-SNAPSHOT.jar deleted file mode 100644 index 4b3c272c..00000000 Binary files a/libs/org-mozilla-rhino-1_8_1-SNAPSHOT.jar and /dev/null differ diff --git a/libs/org-mozilla-rhino-2_0_0-SNAPSHOT.jar b/libs/org-mozilla-rhino-2_0_0-SNAPSHOT.jar new file mode 100644 index 00000000..43e3648f Binary files /dev/null and b/libs/org-mozilla-rhino-2_0_0-SNAPSHOT.jar differ diff --git a/version.properties b/version.properties index d07d6e1e..b87babb3 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Wed Dec 24 16:10:20 CST 2025 -BUILD_TIME=1766563820979 +#Thu Dec 25 16:35:57 CST 2025 +BUILD_TIME=1766651757534 COMPILE_SDK_VERSION=36 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125 @@ -27,6 +27,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=36 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3546 -VERSION_NAME=6.7.0 Alpha12 +VERSION_BUILD=3548 +VERSION_NAME=6.7.0 Alpha13 VSCODE_EXT_REQUIRED_VERSION=1.0.8