6.2.0 - 重新设计及编写项目文档; 新增多语言适配; 丰富控件选择器功能; 优化夜间模式适配等

This commit is contained in:
SuperMonster003
2023-01-21 22:17:16 +08:00
parent 069932c8d3
commit 10960ddbee
2139 changed files with 66316 additions and 41795 deletions

View File

@@ -0,0 +1,86 @@
/**
* @param {org.autojs.autojs.runtime.ScriptRuntime} scriptRuntime
* @param {org.mozilla.javascript.Scriptable | global} scope
* @return {Internal.Timers}
*/
module.exports = function (scriptRuntime, scope) {
let _ = {
Timers: (() => {
/**
* @implements Internal.Timers
*/
const Timers = function () {
// Empty interface body.
};
Timers.prototype = {
constructor: Timers,
setIntervalExt(listener, interval, timeout, callback) {
let $ = {
initTimestamp: Date.now(),
interval: interval > 0 ? interval : 200,
timeout: timeout > 0 ? timeout : Infinity,
setIntervalExt() {
return setTimeout(this.run.bind(this), this.interval);
},
run() {
listener();
this.relayIFN();
},
relayIFN() {
if (!this.isTimedOut()) {
this.setIntervalExt();
} else if (typeof callback === 'function') {
callback.call(this, this.timeoutResult);
}
},
isTimedOut() {
if (typeof this.isTimedOutCache !== 'function') {
this.isTimedOutCache = typeof timeout === 'function'
? timeout.bind(this)
: () => Date.now() - this.initTimestamp > this.timeout;
}
this.timeoutResult = this.isTimedOutCache();
return this.timeoutResult !== false && !isNullish(this.timeoutResult);
},
};
return $.setIntervalExt();
},
};
Object.setPrototypeOf(Timers.prototype, scriptRuntime.timers);
return Timers;
})(),
scopeAugment() {
/**
* @type {(keyof Internal.Timers)[]}
*/
let methods = [
'setTimeout', 'clearTimeout',
'setInterval', 'clearInterval',
'setImmediate', 'clearImmediate',
];
__asGlobal__(scriptRuntime.timers, methods);
Object.assign(scope, {
/**
* @global
*/
loop() {
return scriptRuntime.console.warn('Method loop() is deprecated and has no effect.');
},
});
},
};
/**
* @type {Internal.Timers}
*/
const timers = new _.Timers();
_.scopeAugment();
return timers;
};