6.7.0 - Alpha4 - 修复 isJavaClass/isJavaPackage 等全局方法无效的问题

This commit is contained in:
SuperMonster003
2025-09-10 11:26:15 +08:00
parent c2aab17618
commit 6b8c6b2339
4 changed files with 48 additions and 34 deletions

View File

@@ -27,7 +27,8 @@
"内置模块相关方法实参类型的异常消息增加类型摘要信息", "内置模块相关方法实参类型的异常消息增加类型摘要信息",
"文件管理器浮动按钮展开后点击菜单项时优化菜单收起时机", "文件管理器浮动按钮展开后点击菜单项时优化菜单收起时机",
"崩溃报告页面支持双指缩放调整字体大小并添加常用功能按钮", "崩溃报告页面支持双指缩放调整字体大小并添加常用功能按钮",
"应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_" "应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_",
"Gradle 构建脚本提升 7z 格式文件的解压效率"
], ],
"dependency": [ "dependency": [
"附加 Androidx Core (KTX) 版本 1.15.0", "附加 Androidx Core (KTX) 版本 1.15.0",
@@ -57,6 +58,7 @@
"util.dpToPx/spToPx/pxToDp/pxToSp 方法, 用于像素单位转换" "util.dpToPx/spToPx/pxToDp/pxToSp 方法, 用于像素单位转换"
], ],
"fix": [ "fix": [
"isJavaClass/isJavaPackage 等全局方法无效的问题",
"屏幕旋转至横向时子标题可能显示不完整的问题", "屏幕旋转至横向时子标题可能显示不完整的问题",
"屏幕旋转至横向时部分页面内容被侧边导航栏遮挡的问题", "屏幕旋转至横向时部分页面内容被侧边导航栏遮挡的问题",
"Android 15 部分页面状态栏背景着色区域不完整的问题 _[`issue #398`](http://issues.autojs6.com/398)_", "Android 15 部分页面状态栏背景着色区域不完整的问题 _[`issue #398`](http://issues.autojs6.com/398)_",

View File

@@ -704,20 +704,20 @@ class ScriptRuntime private constructor(builder: Builder) {
private fun augment(target: ScriptableObject) { private fun augment(target: ScriptableObject) {
Global(this).assign(target, GlobalClasses) Global(this).assignWithGlobal(target, topLevelScope, GlobalClasses)
GlobalLegacy(this).assign(target) GlobalLegacy(this).assignWithGlobal(target, topLevelScope)
IsNullish.augment(target, false) IsNullish.augmentWithGlobal(target, topLevelScope, false)
Util.augment(target, true).apply { Util.augmentWithGlobal(target, topLevelScope, true).apply {
UtilJava.augment(this, false) UtilJava.augmentWithGlobal(this, topLevelScope, false)
UtilVersion.augment(this, false) UtilVersion.augmentWithGlobal(this, topLevelScope, false)
UtilVersionCodes.augment(this, VersionCodesInfo.obj, false) UtilVersionCodes.augmentWithGlobal(this, topLevelScope, VersionCodesInfo.obj, false)
UtilInspect.augment(this, false) UtilInspect.augmentWithGlobal(this, topLevelScope, false)
UtilMorseCode.augment(this, false) UtilMorseCode.augmentWithGlobal(this, topLevelScope, false)
} }
Species.augment(target, true) Species.augmentWithGlobal(target, topLevelScope, true)
App(this).augment(target, app, true).also { augmentedApp = it } App(this).augment(target, app, true).also { augmentedApp = it }
Autojs(this).augment(target, true).also { augmentedAutojs = it }.apply { Autojs(this).augment(target, true).also { augmentedAutojs = it }.apply {
AutojsVersion.augment(this, false) AutojsVersion.augmentWithGlobal(this, topLevelScope, false)
} }
Shell(this).augment(target, true) Shell(this).augment(target, true)
Timers(this).augment(target, timers, true) Timers(this).augment(target, timers, true)
@@ -725,7 +725,7 @@ class ScriptRuntime private constructor(builder: Builder) {
Automator(this).augment(target, true) Automator(this).augment(target, true)
Selector(this).augment(target, true, READONLY) Selector(this).augment(target, true, READONLY)
Events(this).augment(target, events, true) Events(this).augment(target, events, true)
Keys.augment(target, true) Keys.augmentWithGlobal(target, topLevelScope, true)
Images(this).augment(target, true) Images(this).augment(target, true)
Ocr(this).augment(target, true).apply { Ocr(this).augment(target, true).apply {
OcrMLKit(this@ScriptRuntime).augment(this, false).also { augmentedOcrMLKit = it } OcrMLKit(this@ScriptRuntime).augment(this, false).also { augmentedOcrMLKit = it }
@@ -736,15 +736,15 @@ class ScriptRuntime private constructor(builder: Builder) {
QrCode(this).augment(target, true) QrCode(this).augment(target, true)
Threads(this).augment(target, threads, true) Threads(this).augment(target, threads, true)
UI(this).proxying(target, ui, true) UI(this).proxying(target, ui, true)
Colors.augment(target, listOf(colors, Colors), true) Colors.augmentWithGlobal(target, topLevelScope, listOf(colors, Colors), true)
Color.augment(target, false) Color.augmentWithGlobal(target, topLevelScope, false)
Tasks(this).augment(target, true) Tasks(this).augment(target, true)
Dialogs(this).augment(target, true) Dialogs(this).augment(target, true)
Continuation(this).augment(target, js_mod_continuation, true, READONLY) Continuation(this).augment(target, js_mod_continuation, true, READONLY)
Http(this).augment(target, http, true) Http(this).augment(target, http, true)
Web(this).augment(target, true) Web(this).augment(target, true)
WebSocket(this).augment(target, WebSocketFields, false) WebSocket(this).augment(target, WebSocketFields, false)
S13n.augment(target, true) S13n.augmentWithGlobal(target, topLevelScope, true)
Console(this).proxying(target, console, true).also { consoleProxyObject = it } Console(this).proxying(target, console, true).also { consoleProxyObject = it }
Plugins(this).augment(target, true) Plugins(this).augment(target, true)
Arrayx(this).augment(target, false) Arrayx(this).augment(target, false)
@@ -752,29 +752,29 @@ class ScriptRuntime private constructor(builder: Builder) {
Mathx(this).augment(target, false) Mathx(this).augment(target, false)
Jsox(this).augment(target, true) Jsox(this).augment(target, true)
Files(this).augment(target, files, true) Files(this).augment(target, files, true)
Crypto.augment(target, CoreCrypto, true) Crypto.augmentWithGlobal(target, topLevelScope, CoreCrypto, true)
RootAutomator(this).augment(target, false) RootAutomator(this).augment(target, false)
Engines(this).augment(target, true) Engines(this).augment(target, true)
Floaty(this).augment(target, true) Floaty(this).augment(target, true)
Storages.augment(target, true) Storages.augmentWithGlobal(target, topLevelScope, true)
Device(this).augment(target, device, true) Device(this).augment(target, device, true)
Recorder(this).augment(target, recorder, true) Recorder(this).augment(target, recorder, true)
Toast(this).augment(target, true) Toast(this).augment(target, true)
Media.augment(target, media, true) Media.augmentWithGlobal(target, topLevelScope, media, true)
Sensors.augment(target, sensors, true) Sensors.augmentWithGlobal(target, topLevelScope, sensors, true)
Base64.augment(target, true) Base64.augmentWithGlobal(target, topLevelScope, true)
Notice(this).augment(target, true).apply { Notice(this).augment(target, true).apply {
NoticeChannel(this@ScriptRuntime).augment(this, false) NoticeChannel(this@ScriptRuntime).augment(this, false)
} }
Shizuku(this).augment(target, shizuku, true) Shizuku(this).augment(target, shizuku, true)
OpenCC.augment(target, true) OpenCC.augmentWithGlobal(target, topLevelScope, true)
Mime(this).augment(target, mime, true) Mime(this).augment(target, mime, true)
SysProps(this).augment(target, true) SysProps(this).augment(target, true)
SQLite(this).augment(target, true) SQLite(this).augment(target, true)
Zip(this).augment(target, true) Zip(this).augment(target, true)
NanoID.augment(target, true) NanoID.augmentWithGlobal(target, topLevelScope, true)
Pinyin.augment(target, true) Pinyin.augmentWithGlobal(target, topLevelScope, true)
Pinyin4j.augment(target, true) Pinyin4j.augmentWithGlobal(target, topLevelScope, true)
Mediainfo(this).augment(target, true) Mediainfo(this).augment(target, true)
augmentedApp.defineProp(Autojs::class.java.simpleName.lowercase(), augmentedAutojs) augmentedApp.defineProp(Autojs::class.java.simpleName.lowercase(), augmentedAutojs)

View File

@@ -135,11 +135,19 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
fun originateKeyName() = also { mIsOriginalKeyName = true } fun originateKeyName() = also { mIsOriginalKeyName = true }
fun augment(target: Scriptable, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject { fun augmentWithGlobal(target: Scriptable, specifiedGlobal: ScriptableObject, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
return augment(target, emptyList<Any>(), withDollarPrefix, additionalAttributes) return augment(target, withDollarPrefix, additionalAttributes, specifiedGlobal)
} }
fun augment(target: Scriptable, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject { fun augmentWithGlobal(target: Scriptable, specifiedGlobal: ScriptableObject, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject {
return augment(target, proto, withDollarPrefix, additionalAttributes, specifiedGlobal)
}
fun augment(target: Scriptable, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0, specifiedGlobal: ScriptableObject? = null): ScriptableObject {
return augment(target, emptyList<Any>(), withDollarPrefix, additionalAttributes, specifiedGlobal)
}
fun augment(target: Scriptable, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0, specifiedGlobal: ScriptableObject? = null): ScriptableObject {
val callFunc: (args: Array<out Any?>) -> Any? = { args -> val callFunc: (args: Array<out Any?>) -> Any? = { args ->
try { try {
(this as Invokable).invoke(*args) (this as Invokable).invoke(*args)
@@ -180,7 +188,7 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
else -> RhinoUtils.newObject(target) else -> RhinoUtils.newObject(target)
} }
assign(newObj, proto) assign(newObj, proto, specifiedGlobal)
val keys = mutableListOf(key) val keys = mutableListOf(key)
if (withDollarPrefix) keys += "\$$key" if (withDollarPrefix) keys += "\$$key"
@@ -192,13 +200,17 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F
return newObj return newObj
} }
fun assignWithGlobal(target: ScriptableObject, specifiedGlobal: ScriptableObject, proto: Any? = null) {
assign(target, proto, specifiedGlobal)
}
/** /**
* When the subclass calls assign, the value of key will be ignored. * When the subclass calls assign, the value of key will be ignored.
* zh-CN: 子类调用 assign 时将忽略 key 的值. * zh-CN: 子类调用 assign 时将忽略 key 的值.
*/ */
fun assign(target: ScriptableObject, proto: Any? = null) { fun assign(target: ScriptableObject, proto: Any? = null, specifiedGlobal: ScriptableObject? = null) {
val global: ScriptableObject = scriptRuntime?.topLevelScope ?: ScriptableObject.getTopLevelScope(target) as ScriptableObject val global: ScriptableObject = specifiedGlobal ?: scriptRuntime?.topLevelScope ?: ScriptableObject.getTopLevelScope(target) as ScriptableObject
val protos = when (proto) { val protos = when (proto) {
null -> emptyList() null -> emptyList()

View File

@@ -1,5 +1,5 @@
#Fri Sep 05 15:31:16 CST 2025 #Wed Sep 10 11:24:53 CST 2025
BUILD_TIME=1757057476985 BUILD_TIME=1757474693346
COMPILE_SDK_VERSION=35 COMPILE_SDK_VERSION=35
IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_CMAKE_VERSION=3.22.1
IMAGE_QUANT_NDK_VERSION=26.1.10909125 IMAGE_QUANT_NDK_VERSION=26.1.10909125
@@ -24,6 +24,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
TARGET_SDK_VERSION=35 TARGET_SDK_VERSION=35
TARGET_SDK_VERSION_INRT=29 TARGET_SDK_VERSION_INRT=29
VERSION_BUILD=3355 VERSION_BUILD=3359
VERSION_NAME=6.7.0 Alpha4 VERSION_NAME=6.7.0 Alpha4
VSCODE_EXT_REQUIRED_VERSION=1.0.8 VSCODE_EXT_REQUIRED_VERSION=1.0.8