Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| edf8410cd1 | |||
| b0b4bbcc2b | |||
| e68689c560 | |||
| 58353cb5b8 | |||
| 8c6b75ff10 | |||
| d53287fc51 | |||
| 13a3611ebd | |||
| 6d90980726 | |||
| 42de3700ba | |||
| 5991662764 | |||
| 1c98c19e37 | |||
| c596280d8d | |||
| 77301e0130 | |||
| 90878fc7df | |||
| a0a4c13e7b | |||
| 0e92a9c795 |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"useWorkspaces": true,
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/api",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,11 +22,13 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/container": "^0.4.0",
|
||||
"@ms/ployfill": "^0.4.1",
|
||||
"@ms/container": "^0.5.0",
|
||||
"@ms/ployfill": "^0.5.0",
|
||||
"base64-js": "^1.3.1",
|
||||
"source-map-builder": "^0.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/base64-js": "^1.2.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.3"
|
||||
|
||||
@@ -41,9 +41,11 @@ export namespace command {
|
||||
try {
|
||||
return executor(sender, command, Java.from(args));
|
||||
} catch (ex) {
|
||||
console.i18n("ms.api.command.execute.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
|
||||
console.i18n("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
|
||||
console.ex(ex);
|
||||
console.sender(sender, [i18n.translate("ms.api.command.execute.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
|
||||
if (sender.name != 'CONSOLE') {
|
||||
console.sender(sender, [i18n.translate("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import i18m from '@ms/i18n'
|
||||
import { SourceMapBuilder } from 'source-map-builder'
|
||||
import * as base64 from 'base64-js'
|
||||
|
||||
const Arrays = Java.type('java.util.Arrays');
|
||||
const Level = Java.type('java.util.logging.Level');
|
||||
const JavaString = Java.type('java.lang.String');
|
||||
const Files = Java.type('java.nio.file.Files');
|
||||
const Paths = Java.type('java.nio.file.Paths');
|
||||
const ignoreLogPrefix = ['java.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.', 'io.netty.', 'org.spongepowered.'];
|
||||
|
||||
@@ -23,6 +22,7 @@ export class MiaoScriptConsole implements Console {
|
||||
Console: NodeJS.ConsoleConstructor;
|
||||
|
||||
private sourceMaps: { [key: string]: SourceMapBuilder } = {};
|
||||
private sourceFileMaps: { [key: string]: string } = {};
|
||||
private _name: string = '';
|
||||
private _level: LogLevel = LogLevel.INFO;
|
||||
|
||||
@@ -83,7 +83,7 @@ export class MiaoScriptConsole implements Console {
|
||||
this.console(i18m.translate(name, param))
|
||||
}
|
||||
object(obj) {
|
||||
for (var i in obj) {
|
||||
for (const i in obj) {
|
||||
this.info(i, '=>', obj[i])
|
||||
}
|
||||
}
|
||||
@@ -93,23 +93,31 @@ export class MiaoScriptConsole implements Console {
|
||||
readSourceMap(fileName: string, lineNumber: number) {
|
||||
try {
|
||||
if (fileName.endsWith('js')) {
|
||||
var file = Paths.get(fileName + '.map');
|
||||
if (this.sourceMaps[fileName] === undefined) {
|
||||
if (file.toFile().exists()) {
|
||||
var sourceMapObj = JSON.parse(new JavaString(Files.readAllBytes(file), "UTF-8"))
|
||||
this.sourceMaps[fileName] = new SourceMapBuilder(sourceMapObj)
|
||||
} else {
|
||||
this.sourceMaps[fileName] = null;
|
||||
this.sourceMaps[fileName] = null
|
||||
let sourceLine = base.read(fileName).split('\n');
|
||||
let lastLine = sourceLine[sourceLine.length - 1]
|
||||
if (lastLine.startsWith('//# sourceMappingURL=')) {
|
||||
let sourceContent = null;
|
||||
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1];
|
||||
if (sourceMappingURL.startsWith('data:application/json;base64,')) {
|
||||
sourceContent = String.fromCharCode(...Array.from(base64.toByteArray(sourceMappingURL.split(',', 2)[1])))
|
||||
} else if (sourceMappingURL.startsWith('http')) {
|
||||
// TODO
|
||||
} else {
|
||||
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile();
|
||||
if (file.exists()) { sourceContent = base.read(file) }
|
||||
}
|
||||
if (sourceContent) {
|
||||
this.sourceMaps[fileName] = new SourceMapBuilder(JSON.parse(sourceContent))
|
||||
this.sourceFileMaps[fileName] = Paths.get(fileName, '..', this.sourceMaps[fileName].sources[0]).toFile().getCanonicalPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.sourceMaps[fileName]) {
|
||||
var sourceMapping = this.sourceMaps[fileName].getSource(lineNumber, 25, true);
|
||||
if (sourceMapping) {
|
||||
if (lineNumber != sourceMapping.mapping.sourceLine) {
|
||||
fileName = fileName.replace(".js", ".ts");
|
||||
lineNumber = sourceMapping.mapping.sourceLine;
|
||||
}
|
||||
}
|
||||
let sourceMapping = this.sourceMaps[fileName].getSource(lineNumber, 25, true, true);
|
||||
fileName = this.sourceFileMaps[fileName]
|
||||
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine; }
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -121,26 +129,26 @@ export class MiaoScriptConsole implements Console {
|
||||
}
|
||||
}
|
||||
stack(ex: Error): string[] {
|
||||
var stack = ex.getStackTrace();
|
||||
var cache = ['§c' + ex];
|
||||
let stack = ex.getStackTrace();
|
||||
let cache = ['§c' + ex];
|
||||
//@ts-ignore
|
||||
if (stack.class) {
|
||||
stack = Arrays.asList(stack)
|
||||
}
|
||||
stack.forEach(trace => {
|
||||
if (trace.className.startsWith('<')) {
|
||||
var { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
|
||||
let { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
|
||||
if (fileName.startsWith(root)) { fileName = fileName.split(root)[1] }
|
||||
cache.push(` §e->§c ${fileName} => §4${trace.methodName}:${lineNumber}`)
|
||||
} else {
|
||||
var className = trace.className;
|
||||
let className = trace.className;
|
||||
var fileName = trace.fileName as string;
|
||||
if (className.startsWith('jdk.nashorn.internal.scripts')) {
|
||||
className = className.substr(className.lastIndexOf('$') + 1)
|
||||
var { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
|
||||
if (fileName.startsWith(root)) { fileName = fileName.split(root)[1] }
|
||||
} else {
|
||||
for (var prefix in ignoreLogPrefix) {
|
||||
for (let prefix in ignoreLogPrefix) {
|
||||
if (className.startsWith(ignoreLogPrefix[prefix])) {
|
||||
return;
|
||||
}
|
||||
|
||||
16
packages/api/src/constants.ts
Normal file
16
packages/api/src/constants.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export namespace constants {
|
||||
export namespace Reflect {
|
||||
export const Method = {
|
||||
getServerConnection: [/*spigot 1.8.8*/'aq',/*spigot 1.12.2*/ 'an', /*spigot 1.14.4+*/'getServerConnection', /*catserver 1.12.2*/'func_147137_ag']
|
||||
}
|
||||
export const Field = {
|
||||
listeningChannels: [/*spigot 1.8.8-1.12.2*/'g', /*spigot 1.14.4*/'f', /*spigot 1.15.2+*/'listeningChannels', /*catserver 1.12.2*/'field_151274_e']
|
||||
}
|
||||
}
|
||||
export enum ServerType {
|
||||
Bukkit = 'bukkit',
|
||||
Sponge = 'sponge',
|
||||
Nukkit = 'nukkit',
|
||||
Bungee = 'bungee'
|
||||
}
|
||||
}
|
||||
@@ -62,8 +62,8 @@ export namespace event {
|
||||
return count;
|
||||
}
|
||||
|
||||
getJarFile(resource: string) {
|
||||
let dirs = Thread.currentThread().getContextClassLoader().getResources(resource);
|
||||
getJarFile(resource: string, loader?: any) {
|
||||
let dirs = (loader || Thread.currentThread().getContextClassLoader()).getResources(resource);
|
||||
if (dirs.hasMoreElements()) {
|
||||
let url = dirs.nextElement();
|
||||
if (url.protocol === "jar") { return url.openConnection().jarFile; }
|
||||
|
||||
@@ -4,4 +4,5 @@ export * from './event'
|
||||
export * from './console'
|
||||
export * from './channel'
|
||||
export * from './command'
|
||||
export * from './constants'
|
||||
export * from './interfaces'
|
||||
|
||||
@@ -30,6 +30,7 @@ export namespace server {
|
||||
dispatchConsoleCommand(command: string): boolean;
|
||||
getPluginsFolder(): string;
|
||||
getNativePluginManager(): NativePluginManager;
|
||||
getNettyPipeline(): any;
|
||||
sendJson(sender: string | any, json: object | string): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ export namespace task {
|
||||
* @param func 执行内容
|
||||
*/
|
||||
callSyncMethod(func: Function): any;
|
||||
/**
|
||||
* 关闭任务管理器
|
||||
*/
|
||||
disable();
|
||||
}
|
||||
/**
|
||||
* 任务抽象
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/bukkit",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript bukkit package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,8 +27,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/common": "^0.4.0",
|
||||
"@ms/container": "^0.4.0"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/common": "^0.5.0",
|
||||
"@ms/container": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class BukkitEvent extends event.Event {
|
||||
}
|
||||
|
||||
getJarFile(resource: string) {
|
||||
return super.getJarFile('org/bukkit/Bukkit.class')
|
||||
return super.getJarFile('org/bukkit/Bukkit.class', Bukkit.class.classLoader)
|
||||
}
|
||||
isValidEvent(clazz: any): boolean {
|
||||
// 继承于 org.bukkit.event.Event
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { server } from '@ms/api'
|
||||
import { server, constants } from '@ms/api'
|
||||
import { provideSingleton } from '@ms/container';
|
||||
|
||||
import * as reflect from '@ms/common/dist/reflect'
|
||||
import chat from './enhance/chat'
|
||||
|
||||
let Bukkit = org.bukkit.Bukkit;
|
||||
@@ -8,9 +9,11 @@ let Bukkit = org.bukkit.Bukkit;
|
||||
@provideSingleton(server.Server)
|
||||
export class BukkitServer implements server.Server {
|
||||
private pluginsFolder: string;
|
||||
private pipeline: any;
|
||||
|
||||
constructor() {
|
||||
this.pluginsFolder = Bukkit.getUpdateFolderFile().getParentFile().getCanonicalPath();
|
||||
this.reflectPipeline()
|
||||
}
|
||||
|
||||
getPlayer(name: string) {
|
||||
@@ -43,6 +46,9 @@ export class BukkitServer implements server.Server {
|
||||
getNativePluginManager() {
|
||||
return Bukkit.getPluginManager() as any;
|
||||
}
|
||||
getNettyPipeline() {
|
||||
return this.pipeline;
|
||||
}
|
||||
sendJson(sender: string | any, json: object | string): void {
|
||||
if (typeof sender === "string") {
|
||||
sender = this.getPlayer(sender)
|
||||
@@ -52,4 +58,27 @@ export class BukkitServer implements server.Server {
|
||||
this.dispatchConsoleCommand(result)
|
||||
}
|
||||
}
|
||||
|
||||
private reflectPipeline() {
|
||||
let consoleServer = reflect.on(Bukkit.getServer()).get('console').get()
|
||||
let connection: any;
|
||||
let promise: any;
|
||||
for (const method of constants.Reflect.Method.getServerConnection) {
|
||||
try {
|
||||
connection = reflect.on(consoleServer).call(method).get()
|
||||
if (connection.class.name.indexOf('ServerConnection') !== -1) { break; }
|
||||
connection = undefined;
|
||||
} catch (error) { }
|
||||
}
|
||||
if (!connection) { console.error("Can't found ServerConnection!"); return }
|
||||
for (const field of constants.Reflect.Field.listeningChannels) {
|
||||
try {
|
||||
promise = reflect.on(connection).get(field).get().get(0);
|
||||
if (promise.class.name.indexOf('Promise') !== -1) { break; }
|
||||
promise = undefined;
|
||||
} catch (error) { }
|
||||
}
|
||||
if (!promise) { console.error("Can't found listeningChannels!"); return }
|
||||
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ export class BukkitTaskManager implements task.TaskManager {
|
||||
callSyncMethod(func: Function): any {
|
||||
return Bukkit.getScheduler().callSyncMethod(this.pluginInstance, new Callable({ call: () => func() })).get()
|
||||
}
|
||||
disable() {
|
||||
Bukkit.getScheduler().cancelTasks(this.pluginInstance);
|
||||
}
|
||||
}
|
||||
|
||||
export class BukkitTask extends task.Task {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/bungee",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript bungee package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,8 +27,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/common": "^0.4.0",
|
||||
"@ms/container": "^0.4.0"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/common": "^0.5.0",
|
||||
"@ms/container": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,42 @@
|
||||
import { server } from '@ms/api'
|
||||
import { provideSingleton } from '@ms/container';
|
||||
import { server, task } from '@ms/api'
|
||||
import { provideSingleton, inject, postConstruct } from '@ms/container'
|
||||
|
||||
import * as reflect from '@ms/common/dist/reflect'
|
||||
|
||||
let Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy();
|
||||
|
||||
@provideSingleton(server.Server)
|
||||
export class BungeeServer implements server.Server {
|
||||
private pluginsFolder: string;
|
||||
private pipeline: any;
|
||||
|
||||
@inject(task.TaskManager)
|
||||
private task: task.TaskManager
|
||||
|
||||
constructor() {
|
||||
this.pluginsFolder = Bungee.getPluginsFolder().getCanonicalPath();
|
||||
}
|
||||
|
||||
@postConstruct()
|
||||
initialize() {
|
||||
let count = 0;
|
||||
let wait = this.task.create(() => {
|
||||
try {
|
||||
// @ts-ignore
|
||||
this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline()
|
||||
wait.cancel();
|
||||
} catch (ex) {
|
||||
count++
|
||||
if (count > 50) {
|
||||
console.error('Reflect BungeeCord netty channel pipeline error time > 50times. Err: ' + ex)
|
||||
wait.cancel()
|
||||
} else {
|
||||
console.warn('Wait BungeeCord start ready to get netty channel pipeline. Err: ' + ex)
|
||||
}
|
||||
}
|
||||
}).later(10).timer(20).submit()
|
||||
}
|
||||
|
||||
getPlayer(name: string) {
|
||||
return Bungee.getPlayer(name);
|
||||
}
|
||||
@@ -41,6 +67,9 @@ export class BungeeServer implements server.Server {
|
||||
getNativePluginManager() {
|
||||
return Bungee.getPluginManager() as any
|
||||
}
|
||||
getNettyPipeline() {
|
||||
return this.pipeline;
|
||||
}
|
||||
sendJson(sender: string | any, json: string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ export class BungeeTaskManager implements task.TaskManager {
|
||||
callSyncMethod(func: Function): any {
|
||||
return func();
|
||||
}
|
||||
disable() {
|
||||
this.pluginInstance.getProxy().getScheduler().cancel(this.pluginInstance)
|
||||
}
|
||||
}
|
||||
|
||||
export class BungeeTask extends task.Task {
|
||||
@@ -25,9 +28,9 @@ export class BungeeTask extends task.Task {
|
||||
return this.plugin.getProxy().getScheduler().runAsync(this.plugin, run)
|
||||
}
|
||||
if (this.interval) {
|
||||
return this.plugin.getProxy().getScheduler().schedule(this.plugin, run, this.laterTime, this.interval, TimeUnit.MILLISECONDS)
|
||||
return this.plugin.getProxy().getScheduler().schedule(this.plugin, run, this.laterTime * 50, this.interval * 50, TimeUnit.MILLISECONDS)
|
||||
} else {
|
||||
return this.plugin.getProxy().getScheduler().schedule(this.plugin, run, this.laterTime, TimeUnit.MILLISECONDS)
|
||||
return this.plugin.getProxy().getScheduler().schedule(this.plugin, run, this.laterTime * 50, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@ms/client",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript client package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -28,7 +28,6 @@
|
||||
"minecraft-protocol": "^1.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^6.14.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import { attachForge } from './forge'
|
||||
import { attachEvents } from './event'
|
||||
|
||||
let username = process.argv[2] || 'Mr_jtb'
|
||||
let version = process.argv[3] || '1.12.2'
|
||||
let client = createConnection('192.168.2.5', 25577, username)
|
||||
|
||||
function createConnection(host: string, port: number, username: string) {
|
||||
let client = createClient({
|
||||
version: '1.12.2',
|
||||
version,
|
||||
host,
|
||||
port,
|
||||
username,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/common",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,7 +27,7 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/nashorn": "^0.4.0"
|
||||
"@ms/nashorn": "^0.5.0"
|
||||
},
|
||||
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
||||
}
|
||||
|
||||
@@ -198,4 +198,4 @@ export = {
|
||||
accessible,
|
||||
declaredMethods,
|
||||
mapToObject
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/compile",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript compile package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/container",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript container package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/core",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,8 +27,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/container": "^0.4.0"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/container": "^0.5.0"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
let containerStartTime = Date.now();
|
||||
console.i18n("ms.core.ioc.initialize");
|
||||
import { plugin, server, task } from '@ms/api'
|
||||
import { plugin, server, task, constants } from '@ms/api'
|
||||
import { DefaultContainer as container, inject, provideSingleton, ContainerInstance, buildProviderModule } from '@ms/container'
|
||||
console.i18n("ms.core.ioc.completed", { time: (Date.now() - containerStartTime) / 1000 })
|
||||
|
||||
@@ -24,15 +24,13 @@ class MiaoScriptCore {
|
||||
}
|
||||
|
||||
loadServerConsole() {
|
||||
// @ts-ignore
|
||||
console = new this.Console();
|
||||
//@ts-ignore
|
||||
global.setGlobal('console', new this.Console())
|
||||
}
|
||||
|
||||
loadTaskFunction() {
|
||||
//@ts-ignore
|
||||
global.setTimeout = (func: Function, tick: number, async: boolean = false) => this.taskManager.create(func).later(tick).async(async).submit()
|
||||
//@ts-ignore
|
||||
global.setInterval = (func: Function, tick: number, async: boolean = false) => this.taskManager.create(func).timer(tick).async(async).submit()
|
||||
global.setGlobal('setTimeout', (func: Function, tick: number, async: boolean = false) => this.taskManager.create(func).later(tick).async(async).submit())
|
||||
global.setGlobal('setInterval', (func: Function, tick: number, async: boolean = false) => this.taskManager.create(func).timer(tick).async(async).submit())
|
||||
}
|
||||
|
||||
loadPlugins() {
|
||||
@@ -48,49 +46,58 @@ class MiaoScriptCore {
|
||||
disable() {
|
||||
console.i18n("ms.core.engine.disable")
|
||||
this.pluginManager.disable();
|
||||
this.taskManager.disable();
|
||||
//@ts-ignore
|
||||
require.disable()
|
||||
}
|
||||
}
|
||||
|
||||
function detectServer() {
|
||||
function detectServer(): constants.ServerType {
|
||||
try {
|
||||
Java.type("org.bukkit.Bukkit");
|
||||
return 'bukkit'
|
||||
return constants.ServerType.Bukkit
|
||||
} catch (ex) {
|
||||
}
|
||||
try {
|
||||
Java.type("org.spongepowered.api.Sponge");
|
||||
return 'sponge'
|
||||
return constants.ServerType.Sponge
|
||||
} catch (ex) {
|
||||
}
|
||||
try {
|
||||
Java.type("cn.nukkit.Nukkit");
|
||||
return 'nukkit'
|
||||
return constants.ServerType.Nukkit
|
||||
} catch (ex) {
|
||||
}
|
||||
try {
|
||||
Java.type("net.md_5.bungee.api.ProxyServer");
|
||||
return 'bungee'
|
||||
return constants.ServerType.Bungee
|
||||
} catch (ex) {
|
||||
}
|
||||
throw Error('Unknow Server Type...')
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
let corePackageStartTime = new Date().getTime()
|
||||
container.bind(ContainerInstance).toConstantValue(container);
|
||||
container.bind(plugin.PluginInstance).toConstantValue(base.getInstance());
|
||||
container.bind(plugin.PluginFolder).toConstantValue('plugins');
|
||||
let type = detectServer();
|
||||
console.i18n("ms.core.initialize.detect", { type });
|
||||
container.bind(server.ServerType).toConstantValue(type);
|
||||
console.i18n("ms.core.package.initialize", { type });
|
||||
require(`@ms/${type}`).default(container);
|
||||
require('@ms/plugin')
|
||||
container.load(buildProviderModule());
|
||||
console.i18n("ms.core.package.completed", { type, time: (Date.now() - corePackageStartTime) / 1000 });
|
||||
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
|
||||
console.i18n("ms.core.engine.completed", { time: (Date.now() - global.NashornEngineStartTime) / 1000 });
|
||||
return disable;
|
||||
try {
|
||||
let corePackageStartTime = new Date().getTime()
|
||||
container.bind(ContainerInstance).toConstantValue(container);
|
||||
container.bind(plugin.PluginInstance).toConstantValue(base.getInstance());
|
||||
container.bind(plugin.PluginFolder).toConstantValue('plugins');
|
||||
let type = detectServer();
|
||||
console.i18n("ms.core.initialize.detect", { type });
|
||||
container.bind(server.ServerType).toConstantValue(type);
|
||||
console.i18n("ms.core.package.initialize", { type });
|
||||
require(`@ms/${type}`).default(container);
|
||||
require('@ms/plugin')
|
||||
container.load(buildProviderModule());
|
||||
console.i18n("ms.core.package.completed", { type, time: (Date.now() - corePackageStartTime) / 1000 });
|
||||
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
|
||||
console.i18n("ms.core.engine.completed", { time: (Date.now() - global.NashornEngineStartTime) / 1000 });
|
||||
return disable;
|
||||
} catch (error) {
|
||||
console.i18n("ms.core.initialize.error", { error });
|
||||
console.ex(error)
|
||||
return () => console.i18n('ms.core.engine.disable.abnormal')
|
||||
}
|
||||
}
|
||||
|
||||
export default initialize();
|
||||
|
||||
@@ -4,12 +4,14 @@ ms.ployfill.completed: "Java Nashorn ployfill loading completed... Cost ({time}s
|
||||
ms.core.ioc.initialize: "Initialization MiaoScript IOC Container @ms/container. Please wait..."
|
||||
ms.core.ioc.completed: "MiaoScript IOC Container @ms/container loading completed({time}s)!"
|
||||
ms.core.initialize.detect: "Detect Compatible Server set ServerType to {type} ..."
|
||||
ms.core.initialize.error: "MiaoScript Engine Initialization Error: {error} ..."
|
||||
ms.core.package.initialize: "Initialization MiaoScript Package @ms/core @ms/{type} @ms/plugin. Please wait..."
|
||||
ms.core.package.completed: "MiaoScript Package @ms/core @ms/{type} @ms/plugin loading completed({time}s)!"
|
||||
ms.core.plugin.initialize: "Initialization MiaoScript Plugin System. Please wait..."
|
||||
ms.core.plugin.completed: "MiaoScript Plugin System loading completed({time}s)!"
|
||||
ms.core.engine.completed: "MiaoScript ScriptEngine loading completed... Done({time}s)!"
|
||||
ms.core.engine.disable: "Disable MiaoScript Engine..."
|
||||
ms.core.engine.disable.abnormal: "abnormal Initialization MiaoScript Engine. Skip disable step..."
|
||||
|
||||
ms.api.event.resource.not.found: "Can't Mapping Event Because not found Resources {resource}!"
|
||||
ms.api.event.empty.event.dir: "base event dir is empty, can't map event name !"
|
||||
@@ -26,11 +28,13 @@ ms.api.command.unregister: "[{plugin}] unregister command {name}..."
|
||||
ms.api.command.execute.error: "§6Player {player} §6exec §b{plugin} §6Plugin Command §d{command} {args} §6error §4{ex}"
|
||||
ms.api.command.tab.completer.error: "§6Player {player} §6exec §b{plugin} §6Plugin TabComplete §d{command} {args} §6error §4{ex}"
|
||||
|
||||
ms.plugin.initialize: "Initialization MiaoScript Plugin System: {plugin} ..."
|
||||
ms.plugin.initialize: "Initialization MiaoScript Plugin System: Plugin: {plugin} Loader: {loader}..."
|
||||
ms.plugin.event.map: "Total {count} {type} Event Mapping Complate..."
|
||||
ms.plugin.manager.scan: "Scanning Plugins in {folder} ..."
|
||||
ms.plugin.manager.initialize.error: "§6Plugin §b{name} §6initialize error §4{ex}"
|
||||
ms.plugin.manager.stage: "{stage} {plugin} version {version} by {author}"
|
||||
ms.plugin.manager.stage.exec: "[{plugin}] Exec {name} Stage {stage} When servers is {servers}..."
|
||||
ms.plugin.manager.stage.exec.error: "§6Plugin §b{plugin} §6exec §d{executor} §6function error §4{error}"
|
||||
ms.plugin.manager.stage.load: "Loading"
|
||||
ms.plugin.manager.stage.enable: "Enabling"
|
||||
ms.plugin.manager.stage.disable: "Disabling"
|
||||
|
||||
@@ -4,12 +4,14 @@ ms.ployfill.completed: "Java Nashorn 补丁 加载完成... 耗时 ({time}s)!"
|
||||
ms.core.ioc.initialize: "初始化 MiaoScript IOC 容器 @ms/container. 请稍候..."
|
||||
ms.core.ioc.completed: "MiaoScript IOC 容器 @ms/container 加载完成 耗时({time}s)"
|
||||
ms.core.initialize.detect: "检测到兼容的服务器类型. 设置 ServerType 值 {type} ..."
|
||||
ms.core.initialize.error: "§4MiaoScript 系统初始化失败 §c{error} ..."
|
||||
ms.core.package.initialize: "初始化 MiaoScript 扩展 @ms/core @ms/{type} @ms/plugin. 请稍候..."
|
||||
ms.core.package.completed: "MiaoScript 扩展 @ms/core @ms/{type} @ms/plugin 加载完成 耗时({time}s)"
|
||||
ms.core.plugin.initialize: "MiaoScript 开始引导插件系统. 请稍候..."
|
||||
ms.core.plugin.completed: "MiaoScript 插件加载完毕 耗时({time}s)!"
|
||||
ms.core.engine.completed: "MiaoScript 脚本引擎 加载完毕... 耗时({time}s)!"
|
||||
ms.core.engine.disable: "关闭 MiaoScript 引擎..."
|
||||
ms.core.engine.disable.abnormal: "引擎异常启动或初始化未完成 跳过关闭流程..."
|
||||
|
||||
ms.api.event.resource.not.found: "无法映射事件 未找到资源文件 {resource}!"
|
||||
ms.api.event.empty.event.dir: "事件基础目录为空, 无法映射事件!"
|
||||
@@ -26,11 +28,13 @@ ms.api.command.unregister: "[{plugin}] 注销命令 {name}..."
|
||||
ms.api.command.execute.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6命令时发生异常 §4{ex}"
|
||||
ms.api.command.tab.completer.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6补全时发生异常 §4{ex}"
|
||||
|
||||
ms.plugin.initialize: "初始化 MiaoScript 插件系统: {plugin} ..."
|
||||
ms.plugin.initialize: "初始化 MiaoScript 插件系统: 实例: {plugin} 加载器: {loader}..."
|
||||
ms.plugin.event.map: "总计 {count} 个 {type} 事件 映射完成..."
|
||||
ms.plugin.manager.scan: "扫描 {folder} 文件夹中插件..."
|
||||
ms.plugin.manager.initialize.error: "§6插件 §b{name} §6初始化错误 §4{ex}"
|
||||
ms.plugin.manager.stage: "{stage} {plugin} 版本 {version} 作者 {author}"
|
||||
ms.plugin.manager.stage.exec: "[{plugin}] 执行 {stage} 阶段函数 {name} 匹配类型 {servers}..."
|
||||
ms.plugin.manager.stage.exec.error: "§6插件 §b{plugin} §6执行 §d{executor} §6函数发生异常 错误: §4{error}"
|
||||
ms.plugin.manager.stage.load: "加载"
|
||||
ms.plugin.manager.stage.enable: "启用"
|
||||
ms.plugin.manager.stage.disable: "关闭"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/i18n",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript i18n package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,13 +22,13 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.2",
|
||||
"@types/js-yaml": "^3.12.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/nashorn": "^0.4.0",
|
||||
"@ms/nashorn": "^0.5.0",
|
||||
"js-yaml": "^3.13.1"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/nashorn",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/nodejs",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript nodejs package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,7 +27,7 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/nashorn": "^0.4.0"
|
||||
"@ms/nashorn": "^0.5.0"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
||||
442
packages/nodejs/src/punycode/index.ts
Normal file
442
packages/nodejs/src/punycode/index.ts
Normal file
@@ -0,0 +1,442 @@
|
||||
'use strict';
|
||||
|
||||
/** Highest positive signed 32-bit float value */
|
||||
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
||||
|
||||
/** Bootstring parameters */
|
||||
const base = 36;
|
||||
const tMin = 1;
|
||||
const tMax = 26;
|
||||
const skew = 38;
|
||||
const damp = 700;
|
||||
const initialBias = 72;
|
||||
const initialN = 128; // 0x80
|
||||
const delimiter = '-'; // '\x2D'
|
||||
|
||||
/** Regular expressions */
|
||||
const regexPunycode = /^xn--/;
|
||||
const regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
|
||||
const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
|
||||
|
||||
/** Error messages */
|
||||
const errors = {
|
||||
'overflow': 'Overflow: input needs wider integers to process',
|
||||
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
||||
'invalid-input': 'Invalid input'
|
||||
};
|
||||
|
||||
/** Convenience shortcuts */
|
||||
const baseMinusTMin = base - tMin;
|
||||
const floor = Math.floor;
|
||||
const stringFromCharCode = String.fromCharCode;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* A generic error utility function.
|
||||
* @private
|
||||
* @param {String} type The error type.
|
||||
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
||||
*/
|
||||
function error(type) {
|
||||
throw new RangeError(errors[type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic `Array#map` utility function.
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} callback The function that gets called for every array
|
||||
* item.
|
||||
* @returns {Array} A new array of values returned by the callback function.
|
||||
*/
|
||||
function map(array, fn) {
|
||||
const result = [];
|
||||
let length = array.length;
|
||||
while (length--) {
|
||||
result[length] = fn(array[length]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
||||
* addresses.
|
||||
* @private
|
||||
* @param {String} domain The domain name or email address.
|
||||
* @param {Function} callback The function that gets called for every
|
||||
* character.
|
||||
* @returns {Array} A new string of characters returned by the callback
|
||||
* function.
|
||||
*/
|
||||
function mapDomain(string, fn) {
|
||||
const parts = string.split('@');
|
||||
let result = '';
|
||||
if (parts.length > 1) {
|
||||
// In email addresses, only the domain name should be punycoded. Leave
|
||||
// the local part (i.e. everything up to `@`) intact.
|
||||
result = parts[0] + '@';
|
||||
string = parts[1];
|
||||
}
|
||||
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
||||
string = string.replace(regexSeparators, '\x2E');
|
||||
const labels = string.split('.');
|
||||
const encoded = map(labels, fn).join('.');
|
||||
return result + encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array containing the numeric code points of each Unicode
|
||||
* character in the string. While JavaScript uses UCS-2 internally,
|
||||
* this function will convert a pair of surrogate halves (each of which
|
||||
* UCS-2 exposes as separate characters) into a single code point,
|
||||
* matching UTF-16.
|
||||
* @see `punycode.ucs2.encode`
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode.ucs2
|
||||
* @name decode
|
||||
* @param {String} string The Unicode input string (UCS-2).
|
||||
* @returns {Array} The new array of code points.
|
||||
*/
|
||||
function ucs2decode(string) {
|
||||
const output = [];
|
||||
let counter = 0;
|
||||
const length = string.length;
|
||||
while (counter < length) {
|
||||
const value = string.charCodeAt(counter++);
|
||||
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
||||
// It's a high surrogate, and there is a next character.
|
||||
const extra = string.charCodeAt(counter++);
|
||||
if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
|
||||
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
||||
} else {
|
||||
// It's an unmatched surrogate; only append this code unit, in case the
|
||||
// next code unit is the high surrogate of a surrogate pair.
|
||||
output.push(value);
|
||||
counter--;
|
||||
}
|
||||
} else {
|
||||
output.push(value);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string based on an array of numeric code points.
|
||||
* @see `punycode.ucs2.decode`
|
||||
* @memberOf punycode.ucs2
|
||||
* @name encode
|
||||
* @param {Array} codePoints The array of numeric code points.
|
||||
* @returns {String} The new Unicode string (UCS-2).
|
||||
*/
|
||||
const ucs2encode = array => String.fromCodePoint(...array);
|
||||
|
||||
/**
|
||||
* Converts a basic code point into a digit/integer.
|
||||
* @see `digitToBasic()`
|
||||
* @private
|
||||
* @param {Number} codePoint The basic numeric code point value.
|
||||
* @returns {Number} The numeric value of a basic code point (for use in
|
||||
* representing integers) in the range `0` to `base - 1`, or `base` if
|
||||
* the code point does not represent a value.
|
||||
*/
|
||||
const basicToDigit = function (codePoint) {
|
||||
if (codePoint - 0x30 < 0x0A) {
|
||||
return codePoint - 0x16;
|
||||
}
|
||||
if (codePoint - 0x41 < 0x1A) {
|
||||
return codePoint - 0x41;
|
||||
}
|
||||
if (codePoint - 0x61 < 0x1A) {
|
||||
return codePoint - 0x61;
|
||||
}
|
||||
return base;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a digit/integer into a basic code point.
|
||||
* @see `basicToDigit()`
|
||||
* @private
|
||||
* @param {Number} digit The numeric value of a basic code point.
|
||||
* @returns {Number} The basic code point whose value (when used for
|
||||
* representing integers) is `digit`, which needs to be in the range
|
||||
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
||||
* used; else, the lowercase form is used. The behavior is undefined
|
||||
* if `flag` is non-zero and `digit` has no uppercase form.
|
||||
*/
|
||||
const digitToBasic = function (digit: number, flag: number) {
|
||||
// 0..25 map to ASCII a..z or A..Z
|
||||
// 26..35 map to ASCII 0..9
|
||||
//@ts-ignore
|
||||
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Bias adaptation function as per section 3.4 of RFC 3492.
|
||||
* https://tools.ietf.org/html/rfc3492#section-3.4
|
||||
* @private
|
||||
*/
|
||||
const adapt = function (delta, numPoints, firstTime) {
|
||||
let k = 0;
|
||||
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
||||
delta += floor(delta / numPoints);
|
||||
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
||||
delta = floor(delta / baseMinusTMin);
|
||||
}
|
||||
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
||||
* symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycode string of ASCII-only symbols.
|
||||
* @returns {String} The resulting string of Unicode symbols.
|
||||
*/
|
||||
const decode = function (input) {
|
||||
// Don't use UCS-2.
|
||||
const output = [];
|
||||
const inputLength = input.length;
|
||||
let i = 0;
|
||||
let n = initialN;
|
||||
let bias = initialBias;
|
||||
|
||||
// Handle the basic code points: let `basic` be the number of input code
|
||||
// points before the last delimiter, or `0` if there is none, then copy
|
||||
// the first basic code points to the output.
|
||||
|
||||
let basic = input.lastIndexOf(delimiter);
|
||||
if (basic < 0) {
|
||||
basic = 0;
|
||||
}
|
||||
|
||||
for (let j = 0; j < basic; ++j) {
|
||||
// if it's not a basic code point
|
||||
if (input.charCodeAt(j) >= 0x80) {
|
||||
error('not-basic');
|
||||
}
|
||||
output.push(input.charCodeAt(j));
|
||||
}
|
||||
|
||||
// Main decoding loop: start just after the last delimiter if any basic code
|
||||
// points were copied; start at the beginning otherwise.
|
||||
|
||||
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
||||
|
||||
// `index` is the index of the next character to be consumed.
|
||||
// Decode a generalized variable-length integer into `delta`,
|
||||
// which gets added to `i`. The overflow checking is easier
|
||||
// if we increase `i` as we go, then subtract off its starting
|
||||
// value at the end to obtain `delta`.
|
||||
let oldi = i;
|
||||
for (let w = 1, k = base; /* no condition */; k += base) {
|
||||
|
||||
if (index >= inputLength) {
|
||||
error('invalid-input');
|
||||
}
|
||||
|
||||
const digit = basicToDigit(input.charCodeAt(index++));
|
||||
|
||||
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
i += digit * w;
|
||||
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
|
||||
if (digit < t) {
|
||||
break;
|
||||
}
|
||||
|
||||
const baseMinusT = base - t;
|
||||
if (w > floor(maxInt / baseMinusT)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
w *= baseMinusT;
|
||||
|
||||
}
|
||||
|
||||
const out = output.length + 1;
|
||||
bias = adapt(i - oldi, out, oldi == 0);
|
||||
|
||||
// `i` was supposed to wrap around from `out` to `0`,
|
||||
// incrementing `n` each time, so we'll fix that now:
|
||||
if (floor(i / out) > maxInt - n) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
n += floor(i / out);
|
||||
i %= out;
|
||||
|
||||
// Insert `n` at position `i` of the output.
|
||||
output.splice(i++, 0, n);
|
||||
|
||||
}
|
||||
|
||||
return String.fromCodePoint(...output);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
||||
* Punycode string of ASCII-only symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The string of Unicode symbols.
|
||||
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
||||
*/
|
||||
const encode = function (input) {
|
||||
const output = [];
|
||||
|
||||
// Convert the input in UCS-2 to an array of Unicode code points.
|
||||
input = ucs2decode(input);
|
||||
|
||||
// Cache the length.
|
||||
let inputLength = input.length;
|
||||
|
||||
// Initialize the state.
|
||||
let n = initialN;
|
||||
let delta = 0;
|
||||
let bias = initialBias;
|
||||
|
||||
// Handle the basic code points.
|
||||
for (const currentValue of input) {
|
||||
if (currentValue < 0x80) {
|
||||
output.push(stringFromCharCode(currentValue));
|
||||
}
|
||||
}
|
||||
|
||||
let basicLength = output.length;
|
||||
let handledCPCount = basicLength;
|
||||
|
||||
// `handledCPCount` is the number of code points that have been handled;
|
||||
// `basicLength` is the number of basic code points.
|
||||
|
||||
// Finish the basic string with a delimiter unless it's empty.
|
||||
if (basicLength) {
|
||||
output.push(delimiter);
|
||||
}
|
||||
|
||||
// Main encoding loop:
|
||||
while (handledCPCount < inputLength) {
|
||||
|
||||
// All non-basic code points < n have been handled already. Find the next
|
||||
// larger one:
|
||||
let m = maxInt;
|
||||
for (const currentValue of input) {
|
||||
if (currentValue >= n && currentValue < m) {
|
||||
m = currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
||||
// but guard against overflow.
|
||||
const handledCPCountPlusOne = handledCPCount + 1;
|
||||
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
delta += (m - n) * handledCPCountPlusOne;
|
||||
n = m;
|
||||
|
||||
for (const currentValue of input) {
|
||||
if (currentValue < n && ++delta > maxInt) {
|
||||
error('overflow');
|
||||
}
|
||||
if (currentValue == n) {
|
||||
// Represent delta as a generalized variable-length integer.
|
||||
let q = delta;
|
||||
for (let k = base; /* no condition */; k += base) {
|
||||
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
if (q < t) {
|
||||
break;
|
||||
}
|
||||
const qMinusT = q - t;
|
||||
const baseMinusT = base - t;
|
||||
output.push(
|
||||
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
||||
);
|
||||
q = floor(qMinusT / baseMinusT);
|
||||
}
|
||||
|
||||
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
||||
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
||||
delta = 0;
|
||||
++handledCPCount;
|
||||
}
|
||||
}
|
||||
|
||||
++delta;
|
||||
++n;
|
||||
|
||||
}
|
||||
return output.join('');
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Punycode string representing a domain name or an email address
|
||||
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
||||
* it doesn't matter if you call it on a string that has already been
|
||||
* converted to Unicode.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycoded domain name or email address to
|
||||
* convert to Unicode.
|
||||
* @returns {String} The Unicode representation of the given Punycode
|
||||
* string.
|
||||
*/
|
||||
const toUnicode = function (input) {
|
||||
return mapDomain(input, function (string) {
|
||||
return regexPunycode.test(string)
|
||||
? decode(string.slice(4).toLowerCase())
|
||||
: string;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Unicode string representing a domain name or an email address to
|
||||
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
||||
* i.e. it doesn't matter if you call it with a domain that's already in
|
||||
* ASCII.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The domain name or email address to convert, as a
|
||||
* Unicode string.
|
||||
* @returns {String} The Punycode representation of the given domain name or
|
||||
* email address.
|
||||
*/
|
||||
const toASCII = function (input) {
|
||||
return mapDomain(input, function (string) {
|
||||
return regexNonASCII.test(string)
|
||||
? 'xn--' + encode(string)
|
||||
: string;
|
||||
});
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/** Define the public API */
|
||||
//@ts-ignore
|
||||
const punycode = {
|
||||
/**
|
||||
* A string representing the current Punycode.js version number.
|
||||
* @memberOf punycode
|
||||
* @type String
|
||||
*/
|
||||
'version': '2.1.0',
|
||||
/**
|
||||
* An object of methods to convert from JavaScript's internal character
|
||||
* representation (UCS-2) to Unicode code points, and back.
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode
|
||||
* @type Object
|
||||
*/
|
||||
'ucs2': {
|
||||
'decode': ucs2decode,
|
||||
'encode': ucs2encode
|
||||
},
|
||||
'decode': decode,
|
||||
'encode': encode,
|
||||
'toASCII': toASCII,
|
||||
'toUnicode': toUnicode
|
||||
};
|
||||
|
||||
export = punycode;
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var punycode = require('punycode');
|
||||
// @ts-ignore
|
||||
import * as punycode from 'punycode'
|
||||
|
||||
var util = {
|
||||
isString: function (arg) {
|
||||
return typeof (arg) === 'string';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/nukkit",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript nukkit package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,8 +27,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/common": "^0.4.0",
|
||||
"@ms/container": "^0.4.0"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/common": "^0.5.0",
|
||||
"@ms/container": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ export class NukkitServer implements server.Server {
|
||||
getNativePluginManager() {
|
||||
return Nukkit.getPluginManager() as any;
|
||||
}
|
||||
getNettyPipeline() {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
sendJson(sender: string | any, json: object | string): void {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ export class NukkitTaskManager implements task.TaskManager {
|
||||
callSyncMethod(func: Function): any {
|
||||
return func()
|
||||
}
|
||||
disable() {
|
||||
base.getInstance().getServer().getScheduler().cancelTask(this.pluginInstance)
|
||||
}
|
||||
}
|
||||
|
||||
export class NukkitTask extends task.Task {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/ployfill",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript ployfill package",
|
||||
"author": "MiaoWoo <admin@yumc.pw>",
|
||||
"homepage": "https://github.com/circlecloud/ms.git",
|
||||
@@ -17,8 +17,8 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/i18n": "^0.4.1",
|
||||
"@ms/nashorn": "^0.4.0",
|
||||
"@ms/i18n": "^0.5.0",
|
||||
"@ms/nashorn": "^0.5.0",
|
||||
"core-js": "^3.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/plugin",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -22,16 +22,16 @@
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.2",
|
||||
"@types/js-yaml": "^3.12.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/common": "^0.4.0",
|
||||
"@ms/container": "^0.4.0",
|
||||
"@ms/i18n": "^0.4.1",
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/common": "^0.5.0",
|
||||
"@ms/container": "^0.5.0",
|
||||
"@ms/i18n": "^0.5.0",
|
||||
"js-yaml": "^3.13.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,9 @@ export const METADATA_KEY = {
|
||||
tab: "@ms/plugin:tab",
|
||||
listener: "@ms/plugin:listener",
|
||||
config: "@ms/plugin:config",
|
||||
stage: {
|
||||
load: "@ms/plugin:stage:load",
|
||||
enable: "@ms/plugin:stage:enable",
|
||||
disable: "@ms/plugin:stage:disable"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { injectable, decorate } from "@ms/container";
|
||||
import { interfaces } from './interfaces'
|
||||
import { METADATA_KEY } from './constants'
|
||||
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPluginTabCompleterMetadata, getPluginConfigMetadata } from './utils'
|
||||
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPluginTabCompleterMetadata, getPluginConfigMetadata, getPluginStageMetadata } from './utils'
|
||||
|
||||
/**
|
||||
* MiaoScript plugin
|
||||
* @param metadata PluginMetadata
|
||||
*/
|
||||
export function plugin(metadata: interfaces.PluginMetadata) {
|
||||
return function(target: any) {
|
||||
return function (target: any) {
|
||||
metadata.target = target;
|
||||
decorate(injectable(), target);
|
||||
Reflect.defineMetadata(METADATA_KEY.plugin, metadata, target);
|
||||
@@ -23,7 +23,7 @@ export function plugin(metadata: interfaces.PluginMetadata) {
|
||||
* @param metadata CommandMetadata
|
||||
*/
|
||||
export function cmd(metadata: interfaces.CommandMetadata = {}) {
|
||||
return function(target: any, key: string, value: any) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || key;
|
||||
metadata.executor = key;
|
||||
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
|
||||
@@ -37,13 +37,13 @@ export function cmd(metadata: interfaces.CommandMetadata = {}) {
|
||||
* MiaoScript TabComplete
|
||||
* @param metadata TabCompleterMetadata
|
||||
*/
|
||||
export function tab(metadata: interfaces.TabCompleterMetadata = {}) {
|
||||
return function(target: any, key: string, value: any) {
|
||||
export function tab(metadata: interfaces.CommandMetadata = {}) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || (key.startsWith('tab') ? key.split('tab', 2)[1] : key);
|
||||
if (!metadata.name) { return; }
|
||||
metadata.executor = key;
|
||||
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
|
||||
const previousMetadata: Map<string, interfaces.TabCompleterMetadata> = getPluginTabCompleterMetadata(target)
|
||||
const previousMetadata: Map<string, interfaces.CommandMetadata> = getPluginTabCompleterMetadata(target)
|
||||
previousMetadata.set(metadata.name, metadata)
|
||||
Reflect.defineMetadata(METADATA_KEY.tab, previousMetadata, target.constructor);
|
||||
};
|
||||
@@ -54,7 +54,7 @@ export function tab(metadata: interfaces.TabCompleterMetadata = {}) {
|
||||
* @param metadata ListenerMetadata
|
||||
*/
|
||||
export function listener(metadata: interfaces.ListenerMetadata = {}) {
|
||||
return function(target: any, key: string, value: any) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || key;
|
||||
metadata.executor = key;
|
||||
const previousMetadata: interfaces.ListenerMetadata[] = getPluginListenerMetadata(target)
|
||||
@@ -63,7 +63,7 @@ export function listener(metadata: interfaces.ListenerMetadata = {}) {
|
||||
}
|
||||
|
||||
export function config(metadata: interfaces.ConfigMetadata = { version: 1, format: 'yml' }) {
|
||||
return function(target: any, key: string) {
|
||||
return function (target: any, key: string) {
|
||||
metadata.name = metadata.name || key;
|
||||
metadata.variable = key;
|
||||
const previousMetadata: Map<string, interfaces.ConfigMetadata> = getPluginConfigMetadata(target)
|
||||
@@ -71,3 +71,24 @@ export function config(metadata: interfaces.ConfigMetadata = { version: 1, forma
|
||||
Reflect.defineMetadata(METADATA_KEY.config, previousMetadata, target.constructor);
|
||||
}
|
||||
}
|
||||
|
||||
function stage(metadata: interfaces.ExecMetadata = {}, stage: string) {
|
||||
return function (target: any, key: string, value: any) {
|
||||
metadata.name = metadata.name || key;
|
||||
metadata.executor = key;
|
||||
const previousMetadata: interfaces.ExecMetadata[] = getPluginStageMetadata(target, stage)
|
||||
Reflect.defineMetadata(METADATA_KEY.stage[stage], [metadata, ...previousMetadata], target.constructor);
|
||||
};
|
||||
}
|
||||
|
||||
export function load(metadata: interfaces.ExecMetadata = {}) {
|
||||
return stage(metadata, 'load')
|
||||
}
|
||||
|
||||
export function enable(metadata: interfaces.ExecMetadata = {}) {
|
||||
return stage(metadata, 'enable')
|
||||
}
|
||||
|
||||
export function disable(metadata: interfaces.ExecMetadata = {}) {
|
||||
return stage(metadata, 'disable')
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { server, MiaoScriptConsole } from "@ms/api";
|
||||
import { server, MiaoScriptConsole, event } from "@ms/api";
|
||||
import { METADATA_KEY } from './constants'
|
||||
import { injectable, inject, postConstruct } from "@ms/container";
|
||||
import { getPluginMetadata } from "./utils";
|
||||
@@ -55,7 +55,7 @@ export namespace interfaces {
|
||||
*/
|
||||
target?: any;
|
||||
}
|
||||
interface ExecMetadata extends BaseMetadata {
|
||||
export interface ExecMetadata extends BaseMetadata {
|
||||
/**
|
||||
* 执行器
|
||||
*/
|
||||
@@ -67,13 +67,16 @@ export namespace interfaces {
|
||||
*/
|
||||
paramtypes?: string[];
|
||||
}
|
||||
export interface TabCompleterMetadata extends ExecMetadata {
|
||||
/**
|
||||
* 参数列表
|
||||
*/
|
||||
paramtypes?: string[];
|
||||
}
|
||||
export interface ListenerMetadata extends ExecMetadata {
|
||||
/**
|
||||
* 监听优先级
|
||||
*/
|
||||
priority?: event.EventPriority;
|
||||
/**
|
||||
* 是否忽略已取消的事件
|
||||
*/
|
||||
ignoreCancel?: boolean;
|
||||
|
||||
}
|
||||
export interface ConfigMetadata extends BaseMetadata {
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import i18n from '@ms/i18n'
|
||||
import { plugin, server, command, event } from '@ms/api'
|
||||
import { inject, provideSingleton, postConstruct, Container, ContainerInstance } from '@ms/container'
|
||||
import { inject, provideSingleton, Container, ContainerInstance } from '@ms/container'
|
||||
import * as fs from '@ms/common/dist/fs'
|
||||
|
||||
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPlugin, getPluginTabCompleterMetadata, getPluginConfigMetadata } from './utils'
|
||||
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPlugin, getPluginTabCompleterMetadata, getPluginConfigMetadata, getPluginStageMetadata } from './utils'
|
||||
import { interfaces } from './interfaces'
|
||||
import { getConfigLoader } from './config'
|
||||
|
||||
const Thread = Java.type('java.lang.Thread')
|
||||
|
||||
@provideSingleton(plugin.PluginManager)
|
||||
export class PluginManagerImpl implements plugin.PluginManager {
|
||||
@inject(ContainerInstance)
|
||||
@@ -22,25 +24,23 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
@inject(event.Event)
|
||||
private EventManager: event.Event
|
||||
|
||||
private initialized: boolean = false
|
||||
private pluginMap: Map<string, interfaces.Plugin>
|
||||
|
||||
@postConstruct()
|
||||
initialize() {
|
||||
if (this.pluginInstance !== null) {
|
||||
if (this.pluginInstance !== null && this.initialized !== true) {
|
||||
// 如果plugin不等于null 则代表是正式环境
|
||||
console.i18n('ms.plugin.initialize', { plugin: this.pluginInstance })
|
||||
console.i18n('ms.plugin.initialize', { plugin: this.pluginInstance, loader: Thread.currentThread().contextClassLoader })
|
||||
this.pluginMap = new Map()
|
||||
console.i18n('ms.plugin.event.map', { count: this.EventManager.mapEventName().toFixed(0), type: this.serverType });
|
||||
this.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
scan(folder: string): void {
|
||||
this.initialize()
|
||||
var plugin = fs.file(root, folder)
|
||||
var files = []
|
||||
// load common plugin
|
||||
.concat(this.scanFolder(plugin))
|
||||
// load space plugin
|
||||
.concat(this.scanFolder(fs.file(plugin, this.serverType)))
|
||||
var files = this.scanFolder(plugin)
|
||||
this.loadPlugins(files)
|
||||
}
|
||||
|
||||
@@ -52,32 +52,36 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
console.i18n("ms.plugin.manager.stage", { stage, plugin: plugin.description.name, version: plugin.description.version, author: plugin.description.author })
|
||||
}
|
||||
|
||||
private runPluginStage(plugin: interfaces.Plugin, stage: string, ext: Function) {
|
||||
this.logStage(plugin, i18n.translate(`ms.plugin.manager.stage.${stage}`))
|
||||
this.runCatch(plugin, stage)
|
||||
this.runCatch(plugin, `${this.serverType}${stage}`)
|
||||
this.execPluginStage(plugin, stage)
|
||||
}
|
||||
|
||||
load(...args: any[]): void {
|
||||
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
|
||||
this.logStage(plugin, i18n.translate("ms.plugin.manager.stage.load"))
|
||||
this.loadConfig(plugin)
|
||||
this.runCatch(plugin, 'load')
|
||||
this.runCatch(plugin, `${this.serverType}load`)
|
||||
this.runPluginStage(plugin, 'load', () => {
|
||||
this.loadConfig(plugin)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
enable(...args: any[]): void {
|
||||
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
|
||||
this.logStage(plugin, i18n.translate("ms.plugin.manager.stage.enable"))
|
||||
this.registryCommand(plugin)
|
||||
this.registryListener(plugin)
|
||||
this.runCatch(plugin, 'enable')
|
||||
this.runCatch(plugin, `${this.serverType}enable`)
|
||||
this.runPluginStage(plugin, 'enable', () => {
|
||||
this.registryCommand(plugin)
|
||||
this.registryListener(plugin)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
disable(...args: any[]): void {
|
||||
this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => {
|
||||
this.logStage(plugin, i18n.translate("ms.plugin.manager.stage.disable"))
|
||||
this.unregistryCommand(plugin)
|
||||
this.unregistryListener(plugin)
|
||||
this.runCatch(plugin, 'disable')
|
||||
this.runCatch(plugin, `${this.serverType}disable`)
|
||||
this.runPluginStage(plugin, 'disable', () => {
|
||||
this.unregistryCommand(plugin)
|
||||
this.unregistryListener(plugin)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -99,7 +103,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
try {
|
||||
if (pl[func]) pl[func].call(pl)
|
||||
} catch (ex) {
|
||||
console.console(`§6Plugin §b${pl.description.name} §6exec §d${func} §6function error §4${ex}`)
|
||||
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pl.description.name, executor: func, error: ex })
|
||||
console.ex(ex)
|
||||
}
|
||||
}
|
||||
@@ -162,7 +166,7 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
|
||||
private allowProcess(servers: string[]) {
|
||||
// Not set servers allow
|
||||
if (!servers) return true
|
||||
if (!servers || !servers.length) return true
|
||||
// include !type deny
|
||||
let denyServers = servers.filter(svr => svr.startsWith("!"))
|
||||
if (denyServers.length !== 0) {
|
||||
@@ -260,4 +264,18 @@ export class PluginManagerImpl implements plugin.PluginManager {
|
||||
private unregistryListener(pluginInstance: interfaces.Plugin) {
|
||||
this.EventManager.disable(pluginInstance)
|
||||
}
|
||||
|
||||
private execPluginStage(pluginInstance: interfaces.Plugin, stageName: string) {
|
||||
let stages = getPluginStageMetadata(pluginInstance, stageName);
|
||||
for (const stage of stages) {
|
||||
if (!this.allowProcess(stage.servers)) { continue }
|
||||
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) {
|
||||
console.i18n("ms.plugin.manager.stage.exec.error", { plugin: pluginInstance.description.name, executor: stage.executor, error })
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ function getPluginCommandMetadata(target: any) {
|
||||
}
|
||||
|
||||
function getPluginTabCompleterMetadata(target: any) {
|
||||
let tabcompleterMetadata: Map<string, interfaces.TabCompleterMetadata> = Reflect.getMetadata(
|
||||
let tabcompleterMetadata: Map<string, interfaces.CommandMetadata> = Reflect.getMetadata(
|
||||
METADATA_KEY.tab,
|
||||
target.constructor
|
||||
) || new Map<string, interfaces.TabCompleterMetadata>();
|
||||
) || new Map<string, interfaces.CommandMetadata>();
|
||||
return tabcompleterMetadata;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,14 @@ function getPluginConfigMetadata(target: any) {
|
||||
return configMetadata;
|
||||
}
|
||||
|
||||
function getPluginStageMetadata(target: any, stage: string) {
|
||||
let stageMetadata: interfaces.ExecMetadata[] = Reflect.getMetadata(
|
||||
METADATA_KEY.stage[stage],
|
||||
target.constructor
|
||||
) || [];
|
||||
return stageMetadata;
|
||||
}
|
||||
|
||||
export {
|
||||
getPlugin,
|
||||
getPlugins,
|
||||
@@ -65,5 +73,6 @@ export {
|
||||
getPluginCommandMetadata,
|
||||
getPluginTabCompleterMetadata,
|
||||
getPluginListenerMetadata,
|
||||
getPluginConfigMetadata
|
||||
getPluginConfigMetadata,
|
||||
getPluginStageMetadata
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@ms/plugins",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript plugins package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -28,8 +28,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/container": "^0.4.0",
|
||||
"@ms/plugin": "^0.4.1"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/container": "^0.5.0",
|
||||
"@ms/plugin": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/// <reference types="@ms/types/dist/typings/sponge" />
|
||||
/// <reference types="@ms/types/dist/typings/bungee" />
|
||||
|
||||
import { server, plugin as pluginApi, channel } from '@ms/api'
|
||||
import { server, plugin as pluginApi, channel, constants } from '@ms/api'
|
||||
import { inject, optional } from '@ms/container';
|
||||
import { plugin, interfaces, cmd, listener, tab, config } from '@ms/plugin'
|
||||
import { plugin, interfaces, cmd, listener, tab, config, enable } from '@ms/plugin'
|
||||
import Tellraw from '@ms/common/dist/tellraw'
|
||||
|
||||
const ByteArrayInputStream = Java.type("java.io.ByteArrayInputStream");
|
||||
@@ -12,10 +12,8 @@ const ByteArrayOutputStream = Java.type("java.io.ByteArrayOutputStream");
|
||||
const StandardCharsets = Java.type("java.nio.charset.StandardCharsets");
|
||||
const GZIPInputStream = Java.type("java.util.zip.GZIPInputStream");
|
||||
const GZIPOutputStream = Java.type("java.util.zip.GZIPOutputStream");
|
||||
const Consumer = Java.type("java.util.function.Consumer");
|
||||
const ByteArray = Java.type("byte[]")
|
||||
|
||||
const BiConsumer = Java.type('java.util.function.BiConsumer')
|
||||
const ByteArray = Java.type("byte[]")
|
||||
|
||||
class MiaoMessage {
|
||||
// public static final String CHANNEL = "MiaoChat:Default".toLowerCase();
|
||||
@@ -146,7 +144,7 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
}
|
||||
|
||||
private compare(prop: string) {
|
||||
return function(obj1: { [x: string]: any; }, obj2: { [x: string]: any; }) {
|
||||
return function (obj1: { [x: string]: any; }, obj2: { [x: string]: any; }) {
|
||||
var val1 = obj1[prop];
|
||||
var val2 = obj2[prop];
|
||||
if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
|
||||
@@ -184,9 +182,6 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
} catch (ex) {
|
||||
this.logger.console("§cCan't found me.clip.placeholderapi.PlaceholderAPI variable will not be replaced! Err: " + ex)
|
||||
}
|
||||
this.channelOff = this.Channel?.listen(this, MiaoMessage.CHANNEL, (data) => {
|
||||
this.sendChatAll(MiaoMessage.decode(data).json)
|
||||
})
|
||||
}
|
||||
|
||||
spongeenable() {
|
||||
@@ -205,6 +200,10 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
} catch (ex) {
|
||||
this.logger.console("§cCan't found me.rojo8399.placeholderapi.PlaceholderService variable will not be replaced! Err: " + ex)
|
||||
}
|
||||
}
|
||||
|
||||
@enable({ servers: [constants.ServerType.Bukkit, constants.ServerType.Sponge] })
|
||||
serverEnbale() {
|
||||
this.channelOff = this.Channel?.listen(this, MiaoMessage.CHANNEL, (data) => {
|
||||
this.sendChatAll(MiaoMessage.decode(data).json)
|
||||
})
|
||||
@@ -244,7 +243,7 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
|
||||
@listener({ servers: ['bukkit'] })
|
||||
AsyncPlayerChatEvent(event: org.bukkit.event.player.AsyncPlayerChatEvent) {
|
||||
this.sendChat(event.getPlayer(), event.getMessage(), function() {
|
||||
this.sendChat(event.getPlayer(), event.getMessage(), function () {
|
||||
event.setCancelled(true);
|
||||
});
|
||||
}
|
||||
@@ -260,7 +259,7 @@ export class MiaoChat extends interfaces.Plugin {
|
||||
if (plain.startsWith(Tellraw.duplicateChar)) {
|
||||
return;
|
||||
}
|
||||
this.sendChat(player, plain, function() {
|
||||
this.sendChat(player, plain, function () {
|
||||
event.setMessageCancelled(true)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,101 +4,111 @@
|
||||
|
||||
import { plugin as pluginApi, server, task } from '@ms/api'
|
||||
import { plugin, interfaces, cmd } from '@ms/plugin'
|
||||
import { inject, Container } from '@ms/container'
|
||||
import * as reflect from '@ms/common/dist/reflect'
|
||||
import { Server as SocketIOServer, Socket as SocketIOSocket } from '@ms/websocket'
|
||||
import { inject, ContainerInstance, Container } from '@ms/container'
|
||||
import io, { Server as SocketIOServer, Socket as SocketIOSocket } from '@ms/websocket'
|
||||
|
||||
const refList: Array<{ server: string, future: string }> = [
|
||||
{ server: 'an', future: 'g' },//spigot 1.12.2
|
||||
{ server: 'getServerConnection', future: 'f' },//after spigot 1.14.4
|
||||
{ server: 'func_147137_ag', future: 'field_151274_e' }//catserver 1.12.2
|
||||
]
|
||||
const suffixMap = {
|
||||
ts: 'typescript',
|
||||
js: 'javascript',
|
||||
yml: 'yaml'
|
||||
}
|
||||
|
||||
@plugin({ name: 'MiaoConsole', version: '1.0.0', author: 'MiaoWoo', servers: ['!nukkit'], source: __filename })
|
||||
export class MiaoConsole extends interfaces.Plugin {
|
||||
@inject(ContainerInstance)
|
||||
private container: Container
|
||||
@inject(server.ServerType)
|
||||
private ServerType: string
|
||||
private serverType: string
|
||||
@inject(server.Server)
|
||||
private Server: server.Server
|
||||
private server: server.Server
|
||||
@inject(task.TaskManager)
|
||||
private Task: task.TaskManager
|
||||
private task: task.TaskManager
|
||||
@inject(pluginApi.PluginManager)
|
||||
private pluginManager: pluginApi.PluginManager
|
||||
|
||||
private pipeline: any;
|
||||
private socketIOServer: SocketIOServer;
|
||||
|
||||
@cmd()
|
||||
mconsole(sender: any, command: string, args: string[]) {
|
||||
if (args[0] == 'reload') {
|
||||
// @ts-ignore
|
||||
require.clear('websocket');
|
||||
this.pluginManager.reload(this);
|
||||
return
|
||||
}
|
||||
let tfunc = new Function('pipeline', args.join(' '))
|
||||
tfunc.apply(this, [this.pipeline])
|
||||
}
|
||||
|
||||
enable() {
|
||||
let count = 0;
|
||||
let wait = this.task.create(() => {
|
||||
this.pipeline = this.server.getNettyPipeline()
|
||||
if (this.pipeline) {
|
||||
wait.cancel()
|
||||
this.createSocketIOServer()
|
||||
this.startSocketIOServer()
|
||||
}
|
||||
if (count > 30) { wait.cancel() }
|
||||
count++
|
||||
}).later(20).timer(40).submit()
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.socketIOServer?.close()
|
||||
}
|
||||
|
||||
bukkitenable() {
|
||||
let Bukkit = Java.type('org.bukkit.Bukkit')
|
||||
let consoleServer = reflect.on(Bukkit.getServer()).get('console').get()
|
||||
this.reflectChannel(this.reflectPromise(consoleServer))
|
||||
this.injectMiaoDetect()
|
||||
}
|
||||
|
||||
spongeenable() {
|
||||
let Sponge = Java.type('org.spongepowered.api.Sponge')
|
||||
let consoleServer = reflect.on(Sponge.getServer()).get()
|
||||
this.reflectChannel(this.reflectPromise(consoleServer))
|
||||
this.injectMiaoDetect()
|
||||
}
|
||||
|
||||
bungeeenable() {
|
||||
let wait = this.Task.create(() => {
|
||||
try {
|
||||
// @ts-ignore
|
||||
this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline()
|
||||
this.injectMiaoDetect()
|
||||
wait.cancel();
|
||||
} catch (ex) {
|
||||
this.logger.warn('Wait BungeeCord start ready to get netty channel pipeline. Err: ' + ex)
|
||||
}
|
||||
}).later(300).timer(500).submit()
|
||||
}
|
||||
|
||||
reflectPromise(consoleServer: any) {
|
||||
for (const ref of refList) {
|
||||
try { return reflect.on(consoleServer).call(ref.server).get(ref.future).get().get(0) } catch (error) { }
|
||||
if (this.container.isBound(io.Instance)) {
|
||||
this.container.unbind(io.Instance)
|
||||
}
|
||||
}
|
||||
|
||||
reflectChannel(promise: any) {
|
||||
if (!promise) { throw Error(`Can't found ServerConnection or ChannelFuture !`) }
|
||||
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
|
||||
createSocketIOServer() {
|
||||
this.socketIOServer = io(this.pipeline, {
|
||||
path: '/ws',
|
||||
root: '/home/project/TSWorkSpace/ms/packages/plugins/public'
|
||||
});
|
||||
this.container.bind(io.Instance).toConstantValue(this.socketIOServer)
|
||||
}
|
||||
|
||||
injectMiaoDetect() {
|
||||
this.socketIOServer = new SocketIOServer(this.pipeline, {
|
||||
path: '/ws'
|
||||
});
|
||||
startSocketIOServer() {
|
||||
let namespace = this.socketIOServer.of('/MiaoConsole')
|
||||
namespace.on('connect', (client: SocketIOSocket) => {
|
||||
global.setGlobal('client', client);
|
||||
this.logger.console(`§6客户端 §b${client.id} §a新建连接...`)
|
||||
client.on('type', (fn) => {
|
||||
this.logger.console(`§6客户端 §b${client.id} §a新建连接...`)
|
||||
fn && fn(this.ServerType)
|
||||
client.emit('log', `Currect Server Version is ${this.Server.getVersion()}`)
|
||||
fn && fn(this.serverType)
|
||||
client.emit('log', `Currect Server Version is ${this.server.getVersion()}`)
|
||||
})
|
||||
client.on('command', (cmd) => {
|
||||
setTimeout(() => this.Server.dispatchConsoleCommand(cmd), 0)
|
||||
setTimeout(() => this.server.dispatchConsoleCommand(cmd), 0)
|
||||
client.emit('log', `§6命令: §b${cmd} §a执行成功!`)
|
||||
})
|
||||
client.on('exec', (code) => {
|
||||
try {
|
||||
client.emit('log', this.Task.callSyncMethod(() => eval(code)) + '')
|
||||
client.emit('log', this.runCode(code, namespace, client))
|
||||
} catch (ex) {
|
||||
client.emit('log', '§4代码执行异常\n' + console.stack(ex).join('\n'))
|
||||
}
|
||||
})
|
||||
client.on('edit', (file: string, fn) => {
|
||||
fn && fn(base.read(file), suffixMap[file.split('.', 2)[1]])
|
||||
})
|
||||
client.on('disconnect', () => {
|
||||
this.logger.console(`§6客户端 §b${client.id} §c断开连接...`)
|
||||
})
|
||||
})
|
||||
this.logger.info('Netty Channel Pipeline Inject MiaoDetectHandler Successful!')
|
||||
}
|
||||
|
||||
private runCode(code: string, namespace: any, client: any) {
|
||||
let tfunc = new Function('namespace', 'client', `
|
||||
var reflect = require('@ms/common/dist/reflect');
|
||||
var tempconcent = '';
|
||||
function print(text) {
|
||||
tempconcent += text + "\\n"
|
||||
}
|
||||
var result = eval(${JSON.stringify(code)});
|
||||
return tempconcent + result
|
||||
`)
|
||||
return this.task.callSyncMethod(() => tfunc.apply(this, [namespace, client])) + ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"outDir": "dist",
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": false,
|
||||
"inlineSourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/sponge",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript api package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,8 +27,8 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/api": "^0.4.1",
|
||||
"@ms/common": "^0.4.0",
|
||||
"@ms/container": "^0.4.0"
|
||||
"@ms/api": "^0.5.0",
|
||||
"@ms/common": "^0.5.0",
|
||||
"@ms/container": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { server } from '@ms/api'
|
||||
import { server, constants } from '@ms/api'
|
||||
import { provideSingleton } from '@ms/container';
|
||||
|
||||
import * as fs from '@ms/common/dist/fs'
|
||||
import * as reflect from '@ms/common/dist/reflect'
|
||||
|
||||
const Sponge = org.spongepowered.api.Sponge;
|
||||
const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers;
|
||||
const URL = Java.type("java.net.URL");
|
||||
const File = Java.type("java.io.File");
|
||||
|
||||
@provideSingleton(server.Server)
|
||||
export class SpongeServer implements server.Server {
|
||||
private pluginsFolder: string;
|
||||
private pipeline: any;
|
||||
|
||||
constructor() {
|
||||
this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath()
|
||||
this.reflectPipeline()
|
||||
}
|
||||
|
||||
getPlayer(name: string) {
|
||||
@@ -46,10 +47,35 @@ export class SpongeServer implements server.Server {
|
||||
getNativePluginManager() {
|
||||
return Sponge.getPluginManager() as any;
|
||||
}
|
||||
getNettyPipeline() {
|
||||
return this.pipeline;
|
||||
}
|
||||
sendJson(sender: string | any, json: string): void {
|
||||
if (typeof sender === "string") {
|
||||
sender = this.getPlayer(sender)
|
||||
}
|
||||
sender.sendMessage(TextSerializers.JSON.deserialize(json))
|
||||
}
|
||||
private reflectPipeline() {
|
||||
let consoleServer = reflect.on(Sponge.getServer()).get()
|
||||
let connection: any;
|
||||
let promise: any;
|
||||
for (const method of constants.Reflect.Method.getServerConnection) {
|
||||
try {
|
||||
connection = reflect.on(consoleServer).call(method).get()
|
||||
if (connection.class.name.indexOf('ServerConnection') !== -1) { break; }
|
||||
connection = undefined;
|
||||
} catch (error) { }
|
||||
}
|
||||
if (!connection) { console.error("Can't found ServerConnection!"); return }
|
||||
for (const field of constants.Reflect.Field.listeningChannels) {
|
||||
try {
|
||||
promise = reflect.on(connection).get(field).get().get(0);
|
||||
if (promise.class.name.indexOf('Promise') !== -1) { break; }
|
||||
promise = undefined;
|
||||
} catch (error) { }
|
||||
}
|
||||
if (!promise) { console.error("Can't found listeningChannels!"); return }
|
||||
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task, plugin } from '@ms/api'
|
||||
import { inject, provideSingleton } from '@ms/container';
|
||||
import { inject, provideSingleton, postConstruct } from '@ms/container';
|
||||
|
||||
const Sponge = Java.type("org.spongepowered.api.Sponge");
|
||||
const Task = Java.type("org.spongepowered.api.scheduler.Task");
|
||||
@@ -11,16 +11,23 @@ const TimeUnit = Java.type('java.util.concurrent.TimeUnit');
|
||||
export class SpongeTaskManager implements task.TaskManager {
|
||||
@inject(plugin.PluginInstance)
|
||||
private pluginInstance: any;
|
||||
private syncExecutor: any;
|
||||
|
||||
@postConstruct()
|
||||
initialize() {
|
||||
this.syncExecutor = Sponge.getScheduler().createSyncExecutor(this.pluginInstance)
|
||||
}
|
||||
|
||||
create(func: Function): task.Task {
|
||||
if (Object.prototype.toString.call(func) !== "[object Function]") { throw TypeError('第一个参数 Task 必须为 function !'); };
|
||||
return new SpongeTask(this.pluginInstance, func);
|
||||
}
|
||||
callSyncMethod(func: Function): any {
|
||||
return Sponge.getScheduler()
|
||||
.createSyncExecutor(this.pluginInstance)
|
||||
// @ts-ignore
|
||||
.schedule(new Callable({ call: () => func() }), java.lang.Long.valueOf(0), TimeUnit.NANOSECONDS).get()
|
||||
// @ts-ignore
|
||||
return this.syncExecutor.schedule(new Callable({ call: () => func() }), java.lang.Long.valueOf(0), TimeUnit.NANOSECONDS).get()
|
||||
}
|
||||
disable() {
|
||||
Sponge.getScheduler().getScheduledTasks(this.pluginInstance).forEach((task: task.Cancelable) => task.cancel())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/types",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript types package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ms/websocket",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "MiaoScript websocket package",
|
||||
"keywords": [
|
||||
"miaoscript",
|
||||
@@ -27,6 +27,6 @@
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ms/nashorn": "^0.4.0"
|
||||
"@ms/nashorn": "^0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,46 @@
|
||||
/// <reference types="@ms/nashorn" />
|
||||
|
||||
export * from './socket-io'
|
||||
import { Server, ServerOptions } from './socket-io'
|
||||
|
||||
interface SocketIOStatic {
|
||||
/**
|
||||
* Default Server constructor
|
||||
*/
|
||||
(): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param srv The HTTP server that we're going to bind to
|
||||
* @param opts An optional parameters object
|
||||
*/
|
||||
(srv: any, opts?: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param port A port to bind to, as a number, or a string
|
||||
* @param An optional parameters object
|
||||
*/
|
||||
(port: string | number, opts?: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param A parameters object
|
||||
*/
|
||||
(opts: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Backwards compatibility
|
||||
* @see io().listen()
|
||||
*/
|
||||
listen?: SocketIOStatic;
|
||||
}
|
||||
|
||||
type SocketStatic = SocketIOStatic & { Instance?: symbol }
|
||||
|
||||
// @ts-ignore
|
||||
let io: SocketStatic = function (pipeline: any, options: ServerOptions) {
|
||||
return new Server(pipeline, options)
|
||||
}
|
||||
io.Instance = Symbol("@ms/websocket")
|
||||
export default io
|
||||
export * from './socket-io'
|
||||
|
||||
@@ -15,6 +15,8 @@ export enum Keys {
|
||||
Default = "DefaultChannelPipeline"
|
||||
}
|
||||
|
||||
let RequestAttributeKey: any
|
||||
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error) { }
|
||||
export enum AttributeKeys {
|
||||
Request = AttributeKey.valueOf('request')
|
||||
}
|
||||
Request = RequestAttributeKey
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { EventEmitter } from 'events'
|
||||
|
||||
import { NettyClient } from './client'
|
||||
import { ServerOptions } from '../socket-io'
|
||||
import { ServerEvent, Keys } from './constants'
|
||||
import { WebSocketDetect } from './websocket_detect'
|
||||
import { WebSocketHandler } from './websocket_handler'
|
||||
import { NettyClient } from './client'
|
||||
import { ServerOptions } from '../socket-io'
|
||||
|
||||
class NettyWebSocketServer extends EventEmitter {
|
||||
private pipeline: any;
|
||||
@@ -22,9 +22,9 @@ class NettyWebSocketServer extends EventEmitter {
|
||||
ctx.fireChannelRead(channel)
|
||||
})
|
||||
connectEvent.on(ServerEvent.connect, (ctx) => {
|
||||
let nettyClient = new NettyClient(this, ctx.channel());
|
||||
this.allClients[nettyClient.id] = nettyClient;
|
||||
this.emit(ServerEvent.connect, nettyClient);
|
||||
let nettyClient = new NettyClient(this, ctx.channel())
|
||||
this.allClients[nettyClient.id] = nettyClient
|
||||
this.emit(ServerEvent.connect, nettyClient)
|
||||
})
|
||||
connectEvent.on(ServerEvent.message, (ctx, msg) => {
|
||||
this.emit(ServerEvent.message, this.allClients[ctx.channel().id()], msg.text())
|
||||
@@ -45,4 +45,4 @@ export {
|
||||
NettyWebSocketServer,
|
||||
ServerEvent,
|
||||
NettyClient
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TextWebSocketFrameHandlerAdapter } from '../netty'
|
||||
import { EventEmitter } from 'events'
|
||||
import { ServerEvent } from './constants'
|
||||
import { ServerOptions } from '../socket-io';
|
||||
import { TextWebSocketFrameHandlerAdapter } from '../netty'
|
||||
|
||||
export class TextWebSocketFrameHandler extends TextWebSocketFrameHandlerAdapter {
|
||||
private event: EventEmitter;
|
||||
|
||||
Reference in New Issue
Block a user