Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c4f512c89 | |||
| a8ae60625b | |||
| e7bc14294e | |||
| 4750f31b6e | |||
| 18df821049 | |||
| ef98c49e1d |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"stream": true
|
"stream": true
|
||||||
},
|
},
|
||||||
"publish": {
|
"publish": {
|
||||||
|
"access": "public",
|
||||||
"registry": "https://repo.yumc.pw/repository/npm-hosted/"
|
"registry": "https://repo.yumc.pw/repository/npm-hosted/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
"build": "lerna run build --scope=\"@ccms/!(plugins)\"",
|
"build": "lerna run build --scope=\"@ccms/!(plugins)\"",
|
||||||
"build:plugins": "lerna run build --scope=\"@ccms/plugins\"",
|
"build:plugins": "lerna run build --scope=\"@ccms/plugins\"",
|
||||||
"ug": "yarn upgrade-interactive --latest",
|
"ug": "yarn upgrade-interactive --latest",
|
||||||
"np": "lerna exec \"npm publish --registry https://registry.npmjs.org\" --scope=\"@ccms/!(client|plugins)\"",
|
"np": "lerna exec \"npm publish --access=public --registry https://registry.npmjs.org\" --scope=\"@ccms/!(client|plugins)\"",
|
||||||
"lsp": "npm login --registry=https://registry.npmjs.org --scope=@ccms",
|
"lsp": "npm login --registry=https://registry.npmjs.org --scope=@ccms",
|
||||||
"lp": "lerna publish"
|
"lp": "lerna publish --registry https://registry.npmjs.org"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/amqp",
|
"name": "@ccms/amqp",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript amqp package",
|
"description": "MiaoScript amqp package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/nashorn": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/container": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/nashorn": "^0.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { ConnectionFactoryAdapter } from "./connection"
|
import { ConnectionFactoryAdapter } from "./connection"
|
||||||
import { RabbitTemplateAdapter } from "./template"
|
import { RabbitTemplateAdapter } from "./template"
|
||||||
|
import { JSClass } from "@ccms/container"
|
||||||
|
|
||||||
export const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
|
export const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
|
||||||
|
|
||||||
export class RabbitAdminAdapter {
|
export class RabbitAdminAdapter {
|
||||||
|
@JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
|
||||||
|
private RabbitAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
|
||||||
private _Handler: org.springframework.amqp.rabbit.core.RabbitAdmin
|
private _Handler: org.springframework.amqp.rabbit.core.RabbitAdmin
|
||||||
constructor(config: RabbitTemplateAdapter | org.springframework.amqp.rabbit.core.RabbitTemplate | ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory) {
|
constructor(config: RabbitTemplateAdapter | org.springframework.amqp.rabbit.core.RabbitTemplate | ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory) {
|
||||||
this._Handler = new RabbitAdmin((config instanceof RabbitTemplateAdapter || config instanceof ConnectionFactoryAdapter) ? config.getHandler() : config)
|
this._Handler = new RabbitAdmin((config instanceof RabbitTemplateAdapter || config instanceof ConnectionFactoryAdapter) ? config.getHandler() : config)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ConnectionFactoryAdapter, ConnectionFactory } from "./connection"
|
|||||||
import { ChannelAwareMessageListenerAdapter, ChannelAwareMessageListener } from "./listener"
|
import { ChannelAwareMessageListenerAdapter, ChannelAwareMessageListener } from "./listener"
|
||||||
|
|
||||||
export const SimpleMessageListenerContainer = org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
|
export const SimpleMessageListenerContainer = org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
|
||||||
export const AcknowledgeMode = org.springframework.amqp.core.AcknowledgeMode
|
export const AcknowledgeMode: org.springframework.amqp.core.AcknowledgeMode = Java.type('org.springframework.amqp.core.AcknowledgeMode')
|
||||||
interface ContainerConfig {
|
interface ContainerConfig {
|
||||||
connectionFactory: ConnectionFactoryAdapter | typeof ConnectionFactory
|
connectionFactory: ConnectionFactoryAdapter | typeof ConnectionFactory
|
||||||
queueNames: string[]
|
queueNames: string[]
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { JSClass } from "@ccms/container"
|
import { JSClass } from "@ccms/container"
|
||||||
import { RabbitAdminAdapter, MessageListenerContainerAdapter, AcknowledgeMode, MessageHandler, ChannelAwareMessageListenerAdapter } from "./adapter"
|
import { RabbitAdminAdapter, MessageListenerContainerAdapter, AcknowledgeMode, MessageHandler, ChannelAwareMessageListenerAdapter } from "./adapter"
|
||||||
|
|
||||||
const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
|
|
||||||
|
|
||||||
export class AmqpAdmin {
|
export class AmqpAdmin {
|
||||||
@JSClass('org.springframework.amqp.core.TopicExchange')
|
@JSClass('org.springframework.amqp.core.TopicExchange')
|
||||||
private TopicExchange: typeof org.springframework.amqp.core.TopicExchange
|
private TopicExchange: typeof org.springframework.amqp.core.TopicExchange
|
||||||
@@ -10,14 +8,15 @@ export class AmqpAdmin {
|
|||||||
private Queue: typeof org.springframework.amqp.core.Queue
|
private Queue: typeof org.springframework.amqp.core.Queue
|
||||||
@JSClass('org.springframework.amqp.core.Binding')
|
@JSClass('org.springframework.amqp.core.Binding')
|
||||||
private Binding: typeof org.springframework.amqp.core.Binding
|
private Binding: typeof org.springframework.amqp.core.Binding
|
||||||
|
@JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
|
||||||
|
private RabbitAdmin: typeof org.springframework.amqp.rabbit.core.RabbitAdmin
|
||||||
@JSClass('org.springframework.amqp.core.Binding.DestinationType')
|
@JSClass('org.springframework.amqp.core.Binding.DestinationType')
|
||||||
private DestinationType: typeof org.springframework.amqp.core.Binding.DestinationType
|
private DestinationType: org.springframework.amqp.core.Binding.DestinationType
|
||||||
|
|
||||||
private amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
|
private amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
|
||||||
|
|
||||||
constructor(amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin | any) {
|
constructor(amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin | any) {
|
||||||
if (amqpAdmin instanceof RabbitAdmin) {
|
if (amqpAdmin instanceof this.RabbitAdmin) {
|
||||||
this.amqpAdmin = amqpAdmin
|
this.amqpAdmin = amqpAdmin
|
||||||
} else if (amqpAdmin instanceof RabbitAdminAdapter) {
|
} else if (amqpAdmin instanceof RabbitAdminAdapter) {
|
||||||
this.amqpAdmin = amqpAdmin.getHandler()
|
this.amqpAdmin = amqpAdmin.getHandler()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/// <reference types="@ccms/nashorn" />
|
/// <reference types="@ccms/nashorn" />
|
||||||
/// <reference types="@ccms/types/dist/typings/jdk" />
|
/// <reference types="@javatypes/jdk" />
|
||||||
/// <reference types="@ccms/types/dist/typings/spring" />
|
/// <reference types="@javatypes/spring-amqp" />
|
||||||
/// <reference types="@ccms/types/dist/typings/spring/amqp" />
|
/// <reference types="@javatypes/spring-rabbit" />
|
||||||
/// <reference types="@ccms/types/dist/typings/rabbitmq" />
|
/// <reference types="@javatypes/amqp-client" />
|
||||||
|
|
||||||
import { amqp } from '@ccms/api'
|
import { amqp } from '@ccms/api'
|
||||||
import { getContainer, reduceMetadata } from '@ccms/container'
|
import { getContainer, reduceMetadata } from '@ccms/container'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/api",
|
"name": "@ccms/api",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/container": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/ployfill": "^0.7.0",
|
"@ccms/container": "^0.8.0",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/ployfill": "^0.8.1",
|
||||||
"base64-js": "^1.3.1",
|
"base64-js": "^1.3.1",
|
||||||
"source-map-builder": "^0.0.7"
|
"source-map-builder": "^0.0.7"
|
||||||
},
|
},
|
||||||
@@ -31,4 +31,4 @@
|
|||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,44 @@ export namespace plugin {
|
|||||||
getPlugins(): Map<string, plugin.Plugin>
|
getPlugins(): Map<string, plugin.Plugin>
|
||||||
}
|
}
|
||||||
export const PluginScanner = Symbol("PluginScanner")
|
export const PluginScanner = Symbol("PluginScanner")
|
||||||
|
/**
|
||||||
|
* 插件加载元信息
|
||||||
|
*/
|
||||||
|
export interface PluginLoadMetadata {
|
||||||
|
/**
|
||||||
|
* 插件加载类型
|
||||||
|
*/
|
||||||
|
type: string
|
||||||
|
/**
|
||||||
|
* 插件名称
|
||||||
|
*/
|
||||||
|
name?: string
|
||||||
|
/**
|
||||||
|
* 插件文件
|
||||||
|
*/
|
||||||
|
file?: string
|
||||||
|
/**
|
||||||
|
* 插件实例
|
||||||
|
*/
|
||||||
|
instance?: any
|
||||||
|
/**
|
||||||
|
* 插件元信息
|
||||||
|
*/
|
||||||
|
metadata?: PluginMetadata
|
||||||
|
/**
|
||||||
|
* 插件扫描器
|
||||||
|
*/
|
||||||
|
scanner: PluginScanner
|
||||||
|
/**
|
||||||
|
* 插件加载器
|
||||||
|
*/
|
||||||
|
loader?: PluginLoader
|
||||||
|
/**
|
||||||
|
* 是否已加载
|
||||||
|
*/
|
||||||
|
loaded?: boolean
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 插件扫描器
|
* 插件扫描器
|
||||||
*/
|
*/
|
||||||
@@ -39,15 +77,20 @@ export namespace plugin {
|
|||||||
*/
|
*/
|
||||||
type: string
|
type: string
|
||||||
/**
|
/**
|
||||||
* 扫描插件 返回插件加载列表
|
* 扫描插件目录 返回插件加载元信息列表
|
||||||
* @param target 扫描目标
|
* @param target 扫描目标
|
||||||
*/
|
*/
|
||||||
scan(target: any): string[]
|
scan(target: any): PluginLoadMetadata[]
|
||||||
|
/**
|
||||||
|
* 读取插件 返回插件加载元信息
|
||||||
|
* @param target
|
||||||
|
*/
|
||||||
|
read(target: any): PluginLoadMetadata
|
||||||
/**
|
/**
|
||||||
* 加载扫描到的目标
|
* 加载扫描到的目标
|
||||||
* @param target 加载目标
|
* @param target 加载目标
|
||||||
*/
|
*/
|
||||||
load(target: any): any
|
load(target: PluginLoadMetadata): PluginLoadMetadata
|
||||||
}
|
}
|
||||||
export const PluginLoader = Symbol("PluginLoader")
|
export const PluginLoader = Symbol("PluginLoader")
|
||||||
/**
|
/**
|
||||||
@@ -63,12 +106,12 @@ export namespace plugin {
|
|||||||
* @param target 加载目标
|
* @param target 加载目标
|
||||||
* @param result 扫描器加载的结果
|
* @param result 扫描器加载的结果
|
||||||
*/
|
*/
|
||||||
require(target: any, result: any): PluginMetadata
|
require(loadMetadata: PluginLoadMetadata): PluginLoadMetadata
|
||||||
/**
|
/**
|
||||||
* 构建插件
|
* 构建插件
|
||||||
* @param metadata 插件元信息
|
* @param metadata 插件元信息
|
||||||
*/
|
*/
|
||||||
build(metadata: any): Plugin
|
build(metadata: PluginMetadata): Plugin
|
||||||
/**
|
/**
|
||||||
* Load 阶段
|
* Load 阶段
|
||||||
* @param plugin 插件
|
* @param plugin 插件
|
||||||
@@ -133,13 +176,9 @@ export namespace plugin {
|
|||||||
*/
|
*/
|
||||||
type?: string
|
type?: string
|
||||||
/**
|
/**
|
||||||
* 插件扫描器
|
* 插件加载信息
|
||||||
*/
|
*/
|
||||||
scanner?: PluginScanner
|
loadMetadata?: PluginLoadMetadata
|
||||||
/**
|
|
||||||
* 插件加载器
|
|
||||||
*/
|
|
||||||
loader?: PluginLoader
|
|
||||||
/**
|
/**
|
||||||
* 插件本体
|
* 插件本体
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/bukkit",
|
"name": "@ccms/bukkit",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript bukkit package",
|
"description": "MiaoScript bukkit package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/bukkit" />
|
/// <reference types="@javatypes/spigot-api" />
|
||||||
|
|
||||||
import { server } from '@ccms/api'
|
import { server } from '@ccms/api'
|
||||||
import { Container } from '@ccms/container'
|
import { Container } from '@ccms/container'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/bungee",
|
"name": "@ccms/bungee",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript bungee package",
|
"description": "MiaoScript bungee package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/bungee" />
|
/// <reference types="@javatypes/bungee-api" />
|
||||||
|
|
||||||
import { server } from '@ccms/api'
|
import { server } from '@ccms/api'
|
||||||
import { Container } from '@ccms/container'
|
import { Container } from '@ccms/container'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "@ccms/client",
|
"name": "@ccms/client",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript client package",
|
"description": "MiaoScript client package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/common",
|
"name": "@ccms/common",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/nashorn": "^0.7.0"
|
"@ccms/nashorn": "^0.8.0",
|
||||||
|
"@javatypes/jdk": "^1.14.0"
|
||||||
},
|
},
|
||||||
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/jdk" />
|
/// <reference types="@javatypes/jdk" />
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 反射工具类
|
* 反射工具类
|
||||||
@@ -11,7 +11,7 @@ const methodCache = []
|
|||||||
|
|
||||||
class Reflect {
|
class Reflect {
|
||||||
private obj: java.lang.Object
|
private obj: java.lang.Object
|
||||||
private class: java.lang.Class
|
private class: java.lang.Class<any>
|
||||||
|
|
||||||
constructor(obj: any) {
|
constructor(obj: any) {
|
||||||
// if (obj === undefined || obj === null) { throw Error(`reflect object can't be ${obj}!`) }
|
// if (obj === undefined || obj === null) { throw Error(`reflect object can't be ${obj}!`) }
|
||||||
@@ -26,8 +26,8 @@ class Reflect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
method(name: string, ...args: any[]) {
|
method(name: string, ...args: java.lang.Class<any>[]) {
|
||||||
return declaredMethod(this.class, name, args)
|
return declaredMethod(this.class, name, ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
methods() {
|
methods() {
|
||||||
@@ -90,7 +90,7 @@ function types(values: any[], def?: any) {
|
|||||||
if (values === null) {
|
if (values === null) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
let result: java.lang.Class[] = []
|
let result: java.lang.Class<any>[] = []
|
||||||
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class))
|
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class))
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ function declaredConstructor(clazz, param) {
|
|||||||
return accessible(constructor)
|
return accessible(constructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
function declaredField(clazz: java.lang.Class, name: string | java.lang.String) {
|
function declaredField(clazz: java.lang.Class<any>, name: string | java.lang.String) {
|
||||||
if (!clazz) { throw Error(`target class can't be ${clazz}!`) }
|
if (!clazz) { throw Error(`target class can't be ${clazz}!`) }
|
||||||
let target = clazz
|
let target = clazz
|
||||||
let field = null
|
let field = null
|
||||||
@@ -139,17 +139,17 @@ function declaredField(clazz: java.lang.Class, name: string | java.lang.String)
|
|||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
|
||||||
function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: any[]): java.lang.reflect.Method {
|
function declaredMethod(clazz: java.lang.Class<any>, name: string, ...clazzs: java.lang.Class<any>[]): java.lang.reflect.Method {
|
||||||
let key = clazz.getName() + '.' + name + ':' + (clazzs || []).join(':')
|
let key = clazz.getName() + '.' + name + ':' + (clazzs || []).join(':')
|
||||||
if (!methodCache[key]) {
|
if (!methodCache[key]) {
|
||||||
try {
|
try {
|
||||||
methodCache[key] = clazz.getMethod(name, clazzs as any)
|
methodCache[key] = clazz.getMethod(name, ...clazzs)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
try {
|
try {
|
||||||
methodCache[key] = clazz.getDeclaredMethod(name, clazzs as any)
|
methodCache[key] = clazz.getDeclaredMethod(name, clazzs as any)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
for (const m of Java.from(declaredMethods(clazz))) {
|
for (const m of Java.from(declaredMethods(clazz))) {
|
||||||
if (m.name == name) {
|
if (m.getName() == name) {
|
||||||
methodCache[key] = m
|
methodCache[key] = m
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -160,8 +160,8 @@ function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: any[]):
|
|||||||
return methodCache[key]
|
return methodCache[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
function declaredMethods(clazz) {
|
function declaredMethods(clazz: java.lang.Class<any>) {
|
||||||
return clazz.declaredMethods
|
return clazz.getDeclaredMethods()
|
||||||
}
|
}
|
||||||
|
|
||||||
let classMethodsCache: any[] = []
|
let classMethodsCache: any[] = []
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/compile",
|
"name": "@ccms/compile",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript compile package",
|
"description": "MiaoScript compile package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/container",
|
"name": "@ccms/container",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript container package",
|
"description": "MiaoScript container package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ccms/nashorn": "^0.8.0",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"inversify-binding-decorators": "^4.0.0",
|
"inversify-binding-decorators": "^4.0.0"
|
||||||
"@ccms/nashorn": "^0.7.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/core",
|
"name": "@ccms/core",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
},
|
},
|
||||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/database",
|
"name": "@ccms/database",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript database package",
|
"description": "MiaoScript database package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/spring" />
|
|
||||||
|
|
||||||
import { Model } from './model'
|
import { Model } from './model'
|
||||||
|
|
||||||
const HikariDataSource = Java.type('com.zaxxer.hikari.HikariDataSource')
|
const HikariDataSource = Java.type('com.zaxxer.hikari.HikariDataSource')
|
||||||
@@ -69,7 +67,7 @@ export class DataBase {
|
|||||||
*/
|
*/
|
||||||
query<T>(sql: string, ...args: any[]): Array<T> {
|
query<T>(sql: string, ...args: any[]): Array<T> {
|
||||||
let startTime = Date.now()
|
let startTime = Date.now()
|
||||||
let result = Java.from(this.jdbcTemplate.queryForList(sql, args))
|
let result = Java.from<any>(this.jdbcTemplate.queryForList(sql, args))
|
||||||
console.debug(java.lang.String.format(`\n[DB] query \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
|
console.debug(java.lang.String.format(`\n[DB] query \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/// <reference types="@ccms/nashorn" />
|
/// <reference types="@ccms/nashorn" />
|
||||||
/// <reference types="@ccms/types/dist/typings/jdk/index" />
|
/// <reference types="@javatypes/jdk" />
|
||||||
|
/// <reference types="@javatypes/spring-jdbc" />
|
||||||
|
|
||||||
export * from './database'
|
export * from './database'
|
||||||
export * from './manager'
|
export * from './manager'
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/i18n",
|
"name": "@ccms/i18n",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript i18n package",
|
"description": "MiaoScript i18n package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/nashorn": "^0.7.0",
|
"@ccms/nashorn": "^0.8.0",
|
||||||
"js-yaml": "^3.13.1"
|
"js-yaml": "^3.13.1"
|
||||||
},
|
},
|
||||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/nashorn",
|
"name": "@ccms/nashorn",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ declare global {
|
|||||||
|
|
||||||
namespace Java {
|
namespace Java {
|
||||||
function type<T = any>(clazz: string): T
|
function type<T = any>(clazz: string): T
|
||||||
function from<T>(javaObj: T[]): T[]
|
function from<T = any>(javaObj: T[]): T[]
|
||||||
function to<T>(array: T[], type?: T): T[]
|
function to<T = any>(array: T[], type?: T): T[]
|
||||||
function extend(...parentTypes: any[]): any
|
function extend(...parentTypes: any[]): any
|
||||||
function synchronized(func: () => void, lock: any): Function
|
function synchronized(func: () => void, lock: any): Function
|
||||||
function asJSONCompatible<T = any>(obj: T): T
|
function asJSONCompatible<T = any>(obj: T): T
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/nodejs",
|
"name": "@ccms/nodejs",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript nodejs package",
|
"description": "MiaoScript nodejs package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/nashorn": "^0.7.0"
|
"@ccms/nashorn": "^0.8.0"
|
||||||
},
|
},
|
||||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/nukkit",
|
"name": "@ccms/nukkit",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript nukkit package",
|
"description": "MiaoScript nukkit package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/nukkit" />
|
/// <reference types="@javatypes/nukkit-api" />
|
||||||
|
|
||||||
import { server } from '@ccms/api'
|
import { server } from '@ccms/api'
|
||||||
import { Container } from '@ccms/container'
|
import { Container } from '@ccms/container'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/ployfill",
|
"name": "@ccms/ployfill",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript ployfill package",
|
"description": "MiaoScript ployfill package",
|
||||||
"author": "MiaoWoo <admin@yumc.pw>",
|
"author": "MiaoWoo <admin@yumc.pw>",
|
||||||
"homepage": "https://github.com/circlecloud/ms.git",
|
"homepage": "https://github.com/circlecloud/ms.git",
|
||||||
@@ -14,8 +14,9 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/i18n": "^0.7.0",
|
"@ccms/i18n": "^0.8.0",
|
||||||
"@ccms/nashorn": "^0.7.0",
|
"@ccms/nashorn": "^0.8.0",
|
||||||
|
"@ccms/nodejs": "^0.8.0",
|
||||||
"core-js": "^3.6.5"
|
"core-js": "^3.6.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/// <reference types="@ccms/nashorn" />
|
/// <reference types="@ccms/nashorn" />
|
||||||
|
import '@ccms/nodejs'
|
||||||
import i18n from '@ccms/i18n'
|
import i18n from '@ccms/i18n'
|
||||||
let ployfillStartTime = new Date().getTime()
|
let ployfillStartTime = new Date().getTime()
|
||||||
i18n.initialize()
|
i18n.initialize()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/plugin",
|
"name": "@ccms/plugin",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -25,10 +25,10 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0",
|
"@ccms/container": "^0.8.0",
|
||||||
"@ccms/i18n": "^0.7.0",
|
"@ccms/i18n": "^0.8.0",
|
||||||
"js-yaml": "^3.13.1"
|
"js-yaml": "^3.13.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ export class BasicLoader implements plugin.PluginLoader {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.pluginRequireMap = new Map()
|
this.pluginRequireMap = new Map()
|
||||||
}
|
}
|
||||||
require(target: any, result: any) {
|
require(loadMetadata: plugin.PluginLoadMetadata) {
|
||||||
this.pluginRequireMap.set(target.toString(), result)
|
let metadata = loadMetadata.instance.description
|
||||||
return result
|
if (metadata && metadata.type == this.type) {
|
||||||
|
loadMetadata.metadata = metadata
|
||||||
|
loadMetadata.loaded = true
|
||||||
|
this.pluginRequireMap.set(metadata.source.toString(), loadMetadata.instance)
|
||||||
|
}
|
||||||
|
return loadMetadata
|
||||||
}
|
}
|
||||||
build(metadata: plugin.PluginMetadata) {
|
build(metadata: plugin.PluginMetadata) {
|
||||||
return this.pluginRequireMap.get(metadata.source.toString())
|
return this.pluginRequireMap.get(metadata.source.toString())
|
||||||
|
|||||||
@@ -18,8 +18,13 @@ export class IocLoader implements plugin.PluginLoader {
|
|||||||
this.pluginMetadataMap = getPluginSources()
|
this.pluginMetadataMap = getPluginSources()
|
||||||
}
|
}
|
||||||
|
|
||||||
require(target: any, result: any) {
|
require(loadMetadata: plugin.PluginLoadMetadata) {
|
||||||
return this.pluginMetadataMap.get(target.toString())
|
let metadata = this.pluginMetadataMap.get(loadMetadata.file.toString())
|
||||||
|
if (metadata && metadata.type == this.type) {
|
||||||
|
loadMetadata.metadata = metadata
|
||||||
|
loadMetadata.loaded = true
|
||||||
|
}
|
||||||
|
return loadMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
build(metadata: plugin.PluginMetadata) {
|
build(metadata: plugin.PluginMetadata) {
|
||||||
|
|||||||
@@ -64,8 +64,13 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
this.initialize()
|
this.initialize()
|
||||||
for (const [, scanner] of this.sacnnerMap) {
|
for (const [, scanner] of this.sacnnerMap) {
|
||||||
try {
|
try {
|
||||||
scanner.scan(folder).forEach(file => {
|
scanner.scan(folder).forEach(loadMetadata => {
|
||||||
this.loadPlugin(file, scanner)
|
try {
|
||||||
|
this.loadPlugin(scanner.load(loadMetadata))
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`plugin scanner ${scanner.type} load ${loadMetadata.name} occurred error ${error}`)
|
||||||
|
console.ex(error)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`plugin scanner ${scanner.type} occurred error ${error}`)
|
console.error(`plugin scanner ${scanner.type} occurred error ${error}`)
|
||||||
@@ -89,28 +94,28 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
ext()
|
ext()
|
||||||
this.runCatch(plugin, stage)
|
this.runCatch(plugin, stage)
|
||||||
this.runCatch(plugin, `${this.serverType}${stage}`)
|
this.runCatch(plugin, `${this.serverType}${stage}`)
|
||||||
plugin.description.loader[stage](plugin)
|
plugin.description.loadMetadata.loader[stage](plugin)
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
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 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadPlugin(file: string, scanner: plugin.PluginScanner) {
|
private loadPlugin(loadMetadata: plugin.PluginLoadMetadata) {
|
||||||
try {
|
try {
|
||||||
let requireInstance = scanner.load(file)
|
|
||||||
for (const [, loader] of this.loaderMap) {
|
for (const [, loader] of this.loaderMap) {
|
||||||
let metadata = loader.require(file, requireInstance)
|
if (loader.require(loadMetadata).loaded) {
|
||||||
if (metadata && metadata.source && metadata.name) {
|
loadMetadata.loader = loader
|
||||||
metadata.loader = loader
|
let metadata = loadMetadata.metadata
|
||||||
this.metadataMap.set(metadata.name, metadata)
|
this.metadataMap.set(metadata.name, metadata)
|
||||||
|
metadata.loadMetadata = loadMetadata
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.i18n("ms.plugin.manager.initialize.error", { name: file, ex: error })
|
console.i18n("ms.plugin.manager.initialize.error", { name: loadMetadata.file, ex: error })
|
||||||
console.ex(error)
|
console.ex(error)
|
||||||
}
|
}
|
||||||
console.console(`§efile §b${file} §ccan't load metadata. §eskip load!`)
|
console.console(`§6scanner: §b${loadMetadata.scanner.type} §ccan\'t load §6file §b${loadMetadata.file}. §eskip!`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,8 +125,8 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
loadFromFile(file: string, scanner = this.sacnnerMap.get('file')): plugin.Plugin {
|
loadFromFile(file: string, scanner = this.sacnnerMap.get('file')): plugin.Plugin {
|
||||||
if (!file) { throw new Error('plugin file can\'t be null!') }
|
if (!file) { throw new Error('plugin file can\'t be null!') }
|
||||||
if (!scanner) { throw new Error('plugin scanner can\'t be null!') }
|
if (!scanner) { throw new Error('plugin scanner can\'t be null!') }
|
||||||
let metadata = this.loadPlugin(file, scanner)
|
let metadata = this.loadPlugin(scanner.read(file))
|
||||||
let plugin = metadata.loader.build(metadata)
|
let plugin = metadata.loadMetadata.loader.build(metadata)
|
||||||
this.load(plugin)
|
this.load(plugin)
|
||||||
this.enable(plugin)
|
this.enable(plugin)
|
||||||
return plugin
|
return plugin
|
||||||
@@ -157,7 +162,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
reload(...args: any[]): void {
|
reload(...args: any[]): void {
|
||||||
this.checkAndGet(args[0]).forEach((pl: plugin.Plugin) => {
|
this.checkAndGet(args[0]).forEach((pl: plugin.Plugin) => {
|
||||||
this.disable(pl)
|
this.disable(pl)
|
||||||
this.loadFromFile(pl.description.source, pl.description.scanner)
|
this.loadFromFile(pl.description.source, pl.description.loadMetadata.scanner)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +211,9 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
|||||||
console.error(`§4无法加载插件 §c${metadata.name} §4请检查 §c${metadata.type} §4加载器是否正常启用!`)
|
console.error(`§4无法加载插件 §c${metadata.name} §4请检查 §c${metadata.type} §4加载器是否正常启用!`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
(pluginInstance = this.loaderMap.get(metadata.type).build(metadata)) && this.instanceMap.set(metadata.name, pluginInstance)
|
pluginInstance = this.loaderMap.get(metadata.type).build(metadata)
|
||||||
|
if (!pluginInstance) { console.error(`§4加载器 §c${metadata.type} §4加载插件 §c${metadata.name} §4失败!`); continue }
|
||||||
|
this.instanceMap.set(metadata.name, pluginInstance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,20 @@ import { provideSingletonNamed } from "@ccms/container"
|
|||||||
export class JSFileScanner implements plugin.PluginScanner {
|
export class JSFileScanner implements plugin.PluginScanner {
|
||||||
type: string = 'file'
|
type: string = 'file'
|
||||||
|
|
||||||
scan(target: any): string[] {
|
scan(target: any): plugin.PluginLoadMetadata[] {
|
||||||
return this.scanFolder(fs.concat(root, target))
|
return this.scanFolder(fs.concat(root, target)).map((file) => this.read(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
load(file: string) {
|
read(file: any): plugin.PluginLoadMetadata {
|
||||||
if (typeof file === "string") { return }
|
return { file, type: this.type, scanner: this, loaded: false }
|
||||||
this.updatePlugin(file)
|
}
|
||||||
|
|
||||||
|
load(metadata: plugin.PluginLoadMetadata): plugin.PluginLoadMetadata {
|
||||||
|
if (metadata.type !== this.type) { return }
|
||||||
|
this.updatePlugin(metadata.file)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return require(file.toString(), { cache: false })
|
metadata.instance = require(metadata.file.toString(), { cache: false })
|
||||||
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
private scanFolder(folder: any): string[] {
|
private scanFolder(folder: any): string[] {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "@ccms/plugins",
|
"name": "@ccms/plugins",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript plugins package",
|
"description": "MiaoScript plugins package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/container": "^0.7.0",
|
"@ccms/container": "^0.8.0",
|
||||||
"@ccms/plugin": "^0.7.0"
|
"@ccms/plugin": "^0.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/bukkit" />
|
/// <reference types="@javatypes/bungee-api" />
|
||||||
/// <reference types="@ccms/types/dist/typings/sponge" />
|
/// <reference types="@javatypes/spigot-api" />
|
||||||
/// <reference types="@ccms/types/dist/typings/bungee" />
|
/// <reference types="@javatypes/sponge-api" />
|
||||||
/// <reference types="@ccms/types/dist/typings/nukkit" />
|
|
||||||
|
|
||||||
import { server } from '@ccms/api';
|
import { server } from '@ccms/api';
|
||||||
import { inject } from '@ccms/container';
|
import { inject } from '@ccms/container';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/bukkit" />
|
/// <reference types="@javatypes/bungee-api" />
|
||||||
/// <reference types="@ccms/types/dist/typings/sponge" />
|
/// <reference types="@javatypes/spigot-api" />
|
||||||
/// <reference types="@ccms/types/dist/typings/bungee" />
|
/// <reference types="@javatypes/sponge-api" />
|
||||||
|
|
||||||
import { server, plugin as pluginApi, channel, constants } from '@ccms/api'
|
import { server, plugin as pluginApi, channel, constants } from '@ccms/api'
|
||||||
import { inject, optional } from '@ccms/container';
|
import { inject, optional } from '@ccms/container';
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
/// <reference types="@ccms/nashorn" />
|
/// <reference types="@ccms/nashorn" />
|
||||||
/// <reference types="@ccms/types/dist/typings/bukkit" />
|
|
||||||
/// <reference types="@ccms/types/dist/typings/sponge" />
|
|
||||||
/// <reference types="@ccms/types/dist/typings/bungee" />
|
|
||||||
|
|
||||||
import { plugin as pluginApi, server, task, constants } from '@ccms/api'
|
import { plugin as pluginApi, server, task, constants } from '@ccms/api'
|
||||||
import { plugin, interfaces, cmd, tab, enable, config, disable } from '@ccms/plugin'
|
import { plugin, interfaces, cmd, tab, enable, config, disable } from '@ccms/plugin'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types" />
|
/// <reference types="@javatypes/jdk" />
|
||||||
|
|
||||||
import { task, server } from "@ccms/api";
|
import { task, server } from "@ccms/api";
|
||||||
import { inject } from "@ccms/container";
|
import { inject } from "@ccms/container";
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
/// <reference types="@ccms/types" />
|
|
||||||
|
|
||||||
import { task, server, constants } from "@ccms/api";
|
import { task, server, constants } from "@ccms/api";
|
||||||
import { inject } from "@ccms/container";
|
import { inject } from "@ccms/container";
|
||||||
import { plugin, interfaces, cmd } from "@ccms/plugin";
|
import { plugin, interfaces, cmd } from "@ccms/plugin";
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
/// <reference types="@ccms/types" />
|
/// <reference types="@javatypes/tomcat" />
|
||||||
/// <reference types="@ccms/types/dist/typings/tomcat/index" />
|
/// <reference types="@javatypes/spring-web" />
|
||||||
/// <reference types="@ccms/types/dist/typings/spring/index" />
|
|
||||||
|
|
||||||
import { constants, database, plugin, web } from "@ccms/api"
|
import { constants, database, plugin, web } from "@ccms/api"
|
||||||
import { inject, ContainerInstance, Container } from "@ccms/container"
|
import { inject, ContainerInstance, Container, JSClass } from "@ccms/container"
|
||||||
import { JSPlugin, interfaces, cmd } from "@ccms/plugin"
|
import { JSPlugin, interfaces, cmd } from "@ccms/plugin"
|
||||||
import { DataBase, DataBaseManager } from '@ccms/database'
|
import { DataBase, DataBaseManager } from '@ccms/database'
|
||||||
import { Server, Context, RequestHandler } from '@ccms/web'
|
import { Server, Context, RequestHandler } from '@ccms/web'
|
||||||
@@ -22,6 +21,9 @@ export class MiaoSpring extends interfaces.Plugin {
|
|||||||
@inject(web.Server)
|
@inject(web.Server)
|
||||||
private webServer: Server
|
private webServer: Server
|
||||||
|
|
||||||
|
@JSClass('org.springframework.http.HttpStatus')
|
||||||
|
private HttpStatus: org.springframework.http.HttpStatus
|
||||||
|
|
||||||
private ResponseEntity = org.springframework.http.ResponseEntity
|
private ResponseEntity = org.springframework.http.ResponseEntity
|
||||||
|
|
||||||
private mainDatabase: DataBase
|
private mainDatabase: DataBase
|
||||||
@@ -56,7 +58,7 @@ export class MiaoSpring extends interfaces.Plugin {
|
|||||||
preHandle: (ctx: Context) => {
|
preHandle: (ctx: Context) => {
|
||||||
const index = foundMap.indexOf(ctx.request.getRequestURI())
|
const index = foundMap.indexOf(ctx.request.getRequestURI())
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
return this.ResponseEntity.status(org.springframework.http.HttpStatus.FOUND).header('Location', foundMap[index + 1]).build()
|
return this.ResponseEntity.status(this.HttpStatus.FOUND).header('Location', foundMap[index + 1]).build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/rabbitmq" />
|
|
||||||
/// <reference types="@ccms/types/dist/typings/spring/amqp" />
|
|
||||||
|
|
||||||
import { constants, plugin as pluginApi, amqp, server, web } from '@ccms/api'
|
import { constants, plugin as pluginApi, amqp, server, web } from '@ccms/api'
|
||||||
import { plugin, interfaces, cmd } from '@ccms/plugin'
|
import { plugin, interfaces, cmd } from '@ccms/plugin'
|
||||||
import { AmqpAdmin, ConnectionFactoryAdapter, AmqpManager } from '@ccms/amqp'
|
import { AmqpAdmin, ConnectionFactoryAdapter, AmqpManager } from '@ccms/amqp'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/sponge",
|
"name": "@ccms/sponge",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript api package",
|
"description": "MiaoScript api package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/sponge" />
|
/// <reference types="@javatypes/sponge-api" />
|
||||||
|
|
||||||
import { server } from '@ccms/api'
|
import { server } from '@ccms/api'
|
||||||
import { Container } from '@ccms/container'
|
import { Container } from '@ccms/container'
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { server, constants } from '@ccms/api'
|
import { server, constants } from '@ccms/api'
|
||||||
import { provideSingleton } from '@ccms/container';
|
import { provideSingleton } from '@ccms/container'
|
||||||
|
|
||||||
import * as reflect from '@ccms/common/dist/reflect'
|
import * as reflect from '@ccms/common/dist/reflect'
|
||||||
|
|
||||||
const Sponge = org.spongepowered.api.Sponge;
|
const Sponge = org.spongepowered.api.Sponge
|
||||||
const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers;
|
const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers
|
||||||
const File = Java.type("java.io.File");
|
const File = Java.type("java.io.File")
|
||||||
|
|
||||||
@provideSingleton(server.Server)
|
@provideSingleton(server.Server)
|
||||||
export class SpongeServer extends server.ReflectServer {
|
export class SpongeServer extends server.ReflectServer {
|
||||||
private pluginsFolder: string;
|
private pluginsFolder: string
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super()
|
||||||
this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath()
|
this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,25 +35,25 @@ export class SpongeServer extends server.ReflectServer {
|
|||||||
if (typeof sender === 'string') {
|
if (typeof sender === 'string') {
|
||||||
sender = this.getPlayer(sender)
|
sender = this.getPlayer(sender)
|
||||||
}
|
}
|
||||||
return Sponge.getCommandManager().process(sender, command).getQueryResult().get()
|
return Sponge.getCommandManager().process(sender, command).getQueryResult().get() != 0
|
||||||
}
|
}
|
||||||
dispatchConsoleCommand(command: string): boolean {
|
dispatchConsoleCommand(command: string): boolean {
|
||||||
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get()
|
return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get() != 0
|
||||||
}
|
}
|
||||||
getPluginsFolder(): string {
|
getPluginsFolder(): string {
|
||||||
return this.pluginsFolder;
|
return this.pluginsFolder
|
||||||
}
|
}
|
||||||
getNativePluginManager() {
|
getNativePluginManager() {
|
||||||
return Sponge.getPluginManager() as any;
|
return Sponge.getPluginManager() as any
|
||||||
}
|
}
|
||||||
getDedicatedServer() {
|
getDedicatedServer() {
|
||||||
return reflect.on(Sponge.getServer()).get()
|
return reflect.on(Sponge.getServer()).get()
|
||||||
}
|
}
|
||||||
getNettyPipeline() {
|
getNettyPipeline() {
|
||||||
return this.pipeline;
|
return this.pipeline
|
||||||
}
|
}
|
||||||
getRootLogger() {
|
getRootLogger() {
|
||||||
return this.rootLogger;
|
return this.rootLogger
|
||||||
}
|
}
|
||||||
sendJson(sender: string | any, json: string): void {
|
sendJson(sender: string | any, json: string): void {
|
||||||
if (typeof sender === "string") {
|
if (typeof sender === "string") {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/spring",
|
"name": "@ccms/spring",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript spring package",
|
"description": "MiaoScript spring package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/api": "^0.7.0",
|
"@ccms/api": "^0.8.1",
|
||||||
"@ccms/common": "^0.7.0",
|
"@ccms/common": "^0.8.0",
|
||||||
"@ccms/container": "^0.7.0",
|
"@ccms/container": "^0.8.0",
|
||||||
"@ccms/database": "^0.7.0"
|
"@ccms/database": "^0.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,37 @@ import { provideSingleton, inject } from '@ccms/container'
|
|||||||
|
|
||||||
import * as fs from '@ccms/common/dist/fs'
|
import * as fs from '@ccms/common/dist/fs'
|
||||||
|
|
||||||
|
interface MySQLPlugin {
|
||||||
|
name: string
|
||||||
|
source: string
|
||||||
|
}
|
||||||
|
|
||||||
@provideSingleton(plugin.PluginScanner)
|
@provideSingleton(plugin.PluginScanner)
|
||||||
export class MySQLScanner implements plugin.PluginScanner {
|
export class MySQLScanner implements plugin.PluginScanner {
|
||||||
type: string = "mysql"
|
type: string = "mysql"
|
||||||
|
|
||||||
|
private cacheDir = 'mysql-plugin-cache'
|
||||||
private target: string
|
private target: string
|
||||||
|
|
||||||
@inject(database.DataBaseManager)
|
@inject(database.DataBaseManager)
|
||||||
private databaseManager: DataBaseManager
|
private databaseManager: DataBaseManager
|
||||||
|
|
||||||
scan(target: any): string[] {
|
scan(target: any): plugin.PluginLoadMetadata[] {
|
||||||
this.target = target
|
this.target = target
|
||||||
let plugins = this.databaseManager.getMainDatabase().query<{ name: string }>(`SELECT name FROM ${this.target} WHERE LENGTH(source) != 0 AND deleted = 0`)
|
let plugins = this.databaseManager.getMainDatabase().query<MySQLPlugin>(`SELECT name FROM ${this.target} WHERE LENGTH(source) != 0 AND deleted = 0`)
|
||||||
return plugins.map(p => `mysql:${p.name}`)
|
return plugins.map(p => this.read(p))
|
||||||
}
|
}
|
||||||
load(target: any) {
|
read(mysqlPlugin: MySQLPlugin): plugin.PluginLoadMetadata {
|
||||||
if (typeof target !== "string" || !target.startsWith('mysql:')) { return }
|
return { name: mysqlPlugin.name, file: fs.concat(root, this.cacheDir, `${mysqlPlugin.name}.js`), type: this.type, mysqlPlugin, scanner: this }
|
||||||
let name = target.split("mysql:")[1]
|
}
|
||||||
if (!name) { console.warn(`[PluginScanner][mysql] plugin name can't be null!`); return }
|
load(metadata: plugin.PluginLoadMetadata) {
|
||||||
var plugin: any = this.databaseManager.getMainDatabase().query<{ source: string }>(`SELECT source FROM ${this.target} WHERE name = ? AND deleted = 0`, name)
|
if (metadata.type !== this.type) { return }
|
||||||
if (plugin.length == 0) { console.warn(`[PluginScanner][mysql] plugin ${target} not found at mysql database...`); return }
|
var plugin: any = this.databaseManager.getMainDatabase().query<MySQLPlugin>(`SELECT source FROM ${this.target} WHERE name = ? AND deleted = 0`, metadata.name)
|
||||||
let temp = fs.concat(root, 'mysql-plugin-cache', target, `${plugin[0]}.js`)
|
if (plugin.length == 0) { throw new Error(`[MySQLScanner] plugin ${metadata.name} not found at mysql database...`) }; plugin = plugin[0]
|
||||||
base.save(temp, plugin[0].source)
|
if (!plugin.source) { throw new Error(`[MySQLScanner] plugin ${metadata.name} source can\'t be undefiend or empty...`) }
|
||||||
|
base.save(metadata.file, plugin.source)
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return require(temp, { cache: false })
|
metadata.instance = require(metadata.file, { cache: false })
|
||||||
|
return metadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/web",
|
"name": "@ccms/web",
|
||||||
"version": "0.7.0",
|
"version": "0.8.1",
|
||||||
"description": "MiaoScript web package",
|
"description": "MiaoScript web package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/container": "^0.7.0"
|
"@ccms/api": "^0.8.1",
|
||||||
|
"@ccms/container": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
/// <reference types="@ccms/types/dist/typings/jdk/index" />
|
/// <reference types="@ccms/nashorn" />
|
||||||
/// <reference types="@ccms/types/dist/typings/tomcat/index" />
|
/// <reference types="@javatypes/jdk" />
|
||||||
/// <reference types="@ccms/types/dist/typings/spring/index" />
|
/// <reference types="@javatypes/tomcat" />
|
||||||
/// <reference types="@ccms/types/dist/typings/spring/beans/index" />
|
/// <reference types="@javatypes/spring-web" />
|
||||||
|
/// <reference types="@javatypes/spring-core" />
|
||||||
|
/// <reference types="@javatypes/spring-beans" />
|
||||||
|
|
||||||
export * from './server'
|
export * from './server'
|
||||||
export * from './decorators'
|
export * from './decorators'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ccms/websocket",
|
"name": "@ccms/websocket",
|
||||||
"version": "0.7.0",
|
"version": "0.8.0",
|
||||||
"description": "MiaoScript websocket package",
|
"description": "MiaoScript websocket package",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"miaoscript",
|
"miaoscript",
|
||||||
@@ -24,6 +24,6 @@
|
|||||||
"typescript": "^3.9.2"
|
"typescript": "^3.9.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ccms/nashorn": "^0.7.0"
|
"@ccms/nashorn": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user