From 6b8c6b2339814c9ee5b121d572bf20ad92db35c3 Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Wed, 10 Sep 2025 11:26:15 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha4=20-=20=E4=BF=AE=E5=A4=8D=20i?= =?UTF-8?q?sJavaClass/isJavaPackage=20=E7=AD=89=E5=85=A8=E5=B1=80=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 4 +- .../autojs/autojs/runtime/ScriptRuntime.kt | 48 +++++++++---------- .../autojs/runtime/api/augment/Augmentable.kt | 24 +++++++--- version.properties | 6 +-- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index ed001e56..33aed6cc 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -27,7 +27,8 @@ "内置模块相关方法实参类型的异常消息增加类型摘要信息", "文件管理器浮动按钮展开后点击菜单项时优化菜单收起时机", "崩溃报告页面支持双指缩放调整字体大小并添加常用功能按钮", - "应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_" + "应用启动器图标支持自适应图标特性 _[`issue #405`](http://issues.autojs6.com/405)_", + "Gradle 构建脚本提升 7z 格式文件的解压效率" ], "dependency": [ "附加 Androidx Core (KTX) 版本 1.15.0", @@ -57,6 +58,7 @@ "util.dpToPx/spToPx/pxToDp/pxToSp 方法, 用于像素单位转换" ], "fix": [ + "isJavaClass/isJavaPackage 等全局方法无效的问题", "屏幕旋转至横向时子标题可能显示不完整的问题", "屏幕旋转至横向时部分页面内容被侧边导航栏遮挡的问题", "Android 15 部分页面状态栏背景着色区域不完整的问题 _[`issue #398`](http://issues.autojs6.com/398)_", diff --git a/app/src/main/java/org/autojs/autojs/runtime/ScriptRuntime.kt b/app/src/main/java/org/autojs/autojs/runtime/ScriptRuntime.kt index 85d1ade9..cea1e074 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/ScriptRuntime.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/ScriptRuntime.kt @@ -704,20 +704,20 @@ class ScriptRuntime private constructor(builder: Builder) { private fun augment(target: ScriptableObject) { - Global(this).assign(target, GlobalClasses) - GlobalLegacy(this).assign(target) - IsNullish.augment(target, false) - Util.augment(target, true).apply { - UtilJava.augment(this, false) - UtilVersion.augment(this, false) - UtilVersionCodes.augment(this, VersionCodesInfo.obj, false) - UtilInspect.augment(this, false) - UtilMorseCode.augment(this, false) + Global(this).assignWithGlobal(target, topLevelScope, GlobalClasses) + GlobalLegacy(this).assignWithGlobal(target, topLevelScope) + IsNullish.augmentWithGlobal(target, topLevelScope, false) + Util.augmentWithGlobal(target, topLevelScope, true).apply { + UtilJava.augmentWithGlobal(this, topLevelScope, false) + UtilVersion.augmentWithGlobal(this, topLevelScope, false) + UtilVersionCodes.augmentWithGlobal(this, topLevelScope, VersionCodesInfo.obj, false) + UtilInspect.augmentWithGlobal(this, topLevelScope, false) + UtilMorseCode.augmentWithGlobal(this, topLevelScope, false) } - Species.augment(target, true) + Species.augmentWithGlobal(target, topLevelScope, true) App(this).augment(target, app, true).also { augmentedApp = it } Autojs(this).augment(target, true).also { augmentedAutojs = it }.apply { - AutojsVersion.augment(this, false) + AutojsVersion.augmentWithGlobal(this, topLevelScope, false) } Shell(this).augment(target, true) Timers(this).augment(target, timers, true) @@ -725,7 +725,7 @@ class ScriptRuntime private constructor(builder: Builder) { Automator(this).augment(target, true) Selector(this).augment(target, true, READONLY) Events(this).augment(target, events, true) - Keys.augment(target, true) + Keys.augmentWithGlobal(target, topLevelScope, true) Images(this).augment(target, true) Ocr(this).augment(target, true).apply { OcrMLKit(this@ScriptRuntime).augment(this, false).also { augmentedOcrMLKit = it } @@ -736,15 +736,15 @@ class ScriptRuntime private constructor(builder: Builder) { QrCode(this).augment(target, true) Threads(this).augment(target, threads, true) UI(this).proxying(target, ui, true) - Colors.augment(target, listOf(colors, Colors), true) - Color.augment(target, false) + Colors.augmentWithGlobal(target, topLevelScope, listOf(colors, Colors), true) + Color.augmentWithGlobal(target, topLevelScope, false) Tasks(this).augment(target, true) Dialogs(this).augment(target, true) Continuation(this).augment(target, js_mod_continuation, true, READONLY) Http(this).augment(target, http, true) Web(this).augment(target, true) WebSocket(this).augment(target, WebSocketFields, false) - S13n.augment(target, true) + S13n.augmentWithGlobal(target, topLevelScope, true) Console(this).proxying(target, console, true).also { consoleProxyObject = it } Plugins(this).augment(target, true) Arrayx(this).augment(target, false) @@ -752,29 +752,29 @@ class ScriptRuntime private constructor(builder: Builder) { Mathx(this).augment(target, false) Jsox(this).augment(target, true) Files(this).augment(target, files, true) - Crypto.augment(target, CoreCrypto, true) + Crypto.augmentWithGlobal(target, topLevelScope, CoreCrypto, true) RootAutomator(this).augment(target, false) Engines(this).augment(target, true) Floaty(this).augment(target, true) - Storages.augment(target, true) + Storages.augmentWithGlobal(target, topLevelScope, true) Device(this).augment(target, device, true) Recorder(this).augment(target, recorder, true) Toast(this).augment(target, true) - Media.augment(target, media, true) - Sensors.augment(target, sensors, true) - Base64.augment(target, true) + Media.augmentWithGlobal(target, topLevelScope, media, true) + Sensors.augmentWithGlobal(target, topLevelScope, sensors, true) + Base64.augmentWithGlobal(target, topLevelScope, true) Notice(this).augment(target, true).apply { NoticeChannel(this@ScriptRuntime).augment(this, false) } Shizuku(this).augment(target, shizuku, true) - OpenCC.augment(target, true) + OpenCC.augmentWithGlobal(target, topLevelScope, true) Mime(this).augment(target, mime, true) SysProps(this).augment(target, true) SQLite(this).augment(target, true) Zip(this).augment(target, true) - NanoID.augment(target, true) - Pinyin.augment(target, true) - Pinyin4j.augment(target, true) + NanoID.augmentWithGlobal(target, topLevelScope, true) + Pinyin.augmentWithGlobal(target, topLevelScope, true) + Pinyin4j.augmentWithGlobal(target, topLevelScope, true) Mediainfo(this).augment(target, true) augmentedApp.defineProp(Autojs::class.java.simpleName.lowercase(), augmentedAutojs) diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/Augmentable.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/Augmentable.kt index 5dc3f086..d77e350c 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/Augmentable.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/Augmentable.kt @@ -135,11 +135,19 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F fun originateKeyName() = also { mIsOriginalKeyName = true } - fun augment(target: Scriptable, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject { - return augment(target, emptyList(), withDollarPrefix, additionalAttributes) + fun augmentWithGlobal(target: Scriptable, specifiedGlobal: ScriptableObject, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0): ScriptableObject { + 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(), withDollarPrefix, additionalAttributes, specifiedGlobal) + } + + fun augment(target: Scriptable, proto: Any, withDollarPrefix: Boolean = true, additionalAttributes: Int = 0, specifiedGlobal: ScriptableObject? = null): ScriptableObject { val callFunc: (args: Array) -> Any? = { args -> try { (this as Invokable).invoke(*args) @@ -180,7 +188,7 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F else -> RhinoUtils.newObject(target) } - assign(newObj, proto) + assign(newObj, proto, specifiedGlobal) val keys = mutableListOf(key) if (withDollarPrefix) keys += "\$$key" @@ -192,13 +200,17 @@ abstract class Augmentable(private val scriptRuntime: ScriptRuntime? = null) : F 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. * 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) { null -> emptyList() diff --git a/version.properties b/version.properties index bec3cdd1..3798b8e7 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Fri Sep 05 15:31:16 CST 2025 -BUILD_TIME=1757057476985 +#Wed Sep 10 11:24:53 CST 2025 +BUILD_TIME=1757474693346 COMPILE_SDK_VERSION=35 IMAGE_QUANT_CMAKE_VERSION=3.22.1 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 TARGET_SDK_VERSION=35 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3355 +VERSION_BUILD=3359 VERSION_NAME=6.7.0 Alpha4 VSCODE_EXT_REQUIRED_VERSION=1.0.8