6.7.0 - Alpha13 - 同步并兼容 Rhino 引擎上游代码 (2.0.0-SNAPSHOT)

This commit is contained in:
SuperMonster003
2025-12-25 16:49:18 +08:00
parent 7bb8486447
commit adc27e2c34
16 changed files with 35 additions and 35 deletions

View File

@@ -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",

View File

@@ -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%"
}

View File

@@ -15,7 +15,7 @@
<a href="https://developer.android.com/studio/archive"><img alt="Android Studio" src="https://img.shields.io/badge/Android%20Studio-2023.3+-B64FC8"/></a>
<a href="https://www.jetbrains.com/idea/download/other.html"><img alt="IntelliJ IDEA" src="https://img.shields.io/badge/IntelliJ%20IDEA-2023.3+-EE4677"/></a>
<br>
<a href="https://github.com/mozilla/rhino"><img alt="Rhino" src="https://img.shields.io/badge/Rhino-1.8.1--SNAPSHOT-795548"/></a>
<a href="https://github.com/mozilla/rhino"><img alt="Rhino" src="https://img.shields.io/badge/Rhino-2.0.0--SNAPSHOT-795548"/></a>
<a href="https://www.jetbrains.com/?from=AutoJs6"><img alt="JetBrains supporter" src="https://img.shields.io/badge/Supporter-JetBrains-AA2786"/></a>
<a href="http://project.autojs6.com/blob/master/LICENSE"><img alt="GitHub License" src="https://img.shields.io/github/license/SuperMonster003/AutoJs6?color=534BAE&label=License"/></a>
</p>

View File

@@ -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"))

View File

@@ -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;
})();

View File

@@ -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();
}

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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();
}
}

View File

@@ -107,8 +107,6 @@ class Global(private val scriptRuntime: ScriptRuntime) : Augmentable(scriptRunti
override val selfAssignmentGetters = listOf<Pair<String, Supplier<Any?>>>(
"WIDTH" to Supplier { ScreenMetrics.deviceScreenWidth },
"HEIGHT" to Supplier { ScreenMetrics.deviceScreenHeight },
"Promise" to Supplier { scriptRuntime.js_Promise },
"ResultAdapter" to Supplier { scriptRuntime.js_ResultAdapter },
)
companion object {

View File

@@ -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

View File

@@ -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)

View File

@@ -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);
}

Binary file not shown.

View File

@@ -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