feat: use pnpm & lock core-js shim
This commit is contained in:
parent
5bf4b1c09e
commit
54eaae96bd
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": "0.28.0-beta.3",
|
||||
"npmClient": "yarn",
|
||||
"npmClient": "pnpm",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
|
11
package.json
11
package.json
@ -10,7 +10,7 @@
|
||||
"clean": "lerna run clean",
|
||||
"watch": "lerna run watch --parallel",
|
||||
"build": "lerna run build",
|
||||
"ug": "yarn upgrade-interactive",
|
||||
"ug": "pnpm up -r -i",
|
||||
"np": "./script/push.sh",
|
||||
"lsp": "npm login -scope=@ccms",
|
||||
"lp": "lerna publish --force-publish",
|
||||
@ -23,6 +23,13 @@
|
||||
"packages/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"lerna": "^7.1.4"
|
||||
"lerna": "^7.2.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
"typescript": "^5.2.2",
|
||||
"tslib": "^2.6.2",
|
||||
"@types/node": "^20.8.8",
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"@javatypes/jdk": "^0.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/i18n": "^0.28.0-beta.3",
|
||||
"@ccms/common": "^0.28.0-beta.3",
|
||||
"@ccms/container": "^0.28.0-beta.3",
|
||||
"@ccms/polyfill": "^0.28.0-beta.3",
|
||||
@ -29,9 +30,6 @@
|
||||
"source-map-builder": "^0.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/base64-js": "^1.3.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@types/base64-js": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ export namespace command {
|
||||
* first time script engine need optimize jit code
|
||||
* so ignore first slow exec notify
|
||||
*/
|
||||
private cacheSlowCommandKey = {};
|
||||
private cacheSlowCompleteKey = {};
|
||||
private cacheSlowKeys = {};
|
||||
|
||||
/**
|
||||
* 注册插件命令
|
||||
@ -53,32 +52,13 @@ export namespace command {
|
||||
try {
|
||||
let time = Date.now()
|
||||
let result = executor(sender, command, Java.from(args))
|
||||
let cost = Date.now() - time
|
||||
if (cost > global.ScriptSlowExecuteTime) {
|
||||
let commandKey = `${plugin.description.name}-${command}-${sender.name}`
|
||||
if (!this.cacheSlowCommandKey[commandKey]) { return this.cacheSlowCommandKey[commandKey] = cost }
|
||||
console.i18n("ms.api.command.execute.slow", {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
cost
|
||||
})
|
||||
}
|
||||
this.checkSlow(Date.now() - time,
|
||||
"ms.api.command.execute.slow",
|
||||
plugin, command, sender, args)
|
||||
return result
|
||||
} catch (ex: any) {
|
||||
let message = i18n.translate("ms.api.command.execute.error", {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
ex
|
||||
})
|
||||
console.console(message)
|
||||
console.ex(ex)
|
||||
if (sender.name != 'CONSOLE') {
|
||||
console.sender(sender, [message, ...console.stack(ex)])
|
||||
}
|
||||
this.printError(ex, "ms.api.command.execute.error",
|
||||
plugin, command, sender, args)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -90,36 +70,18 @@ export namespace command {
|
||||
var token = args[args.length - 1]
|
||||
var complete = tabCompleter(sender, command, Java.from(args)) || []
|
||||
let result = this.copyPartialMatches(complete, token)
|
||||
let cost = Date.now() - time
|
||||
if (cost > global.ScriptSlowExecuteTime) {
|
||||
let completerKey = `${plugin.description.name}-${command}-${sender.name}`
|
||||
if (!this.cacheSlowCompleteKey[completerKey]) { return this.cacheSlowCompleteKey[completerKey] = cost }
|
||||
console.i18n("ms.api.command.tab.completer.slow", {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
cost
|
||||
})
|
||||
}
|
||||
this.checkSlow(Date.now() - time,
|
||||
"ms.api.command.tab.completer.slow",
|
||||
plugin, command, sender, args)
|
||||
return result
|
||||
} catch (ex: any) {
|
||||
let message = i18n.translate("ms.api.command.tab.completer.error", {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
ex
|
||||
})
|
||||
console.console(message)
|
||||
console.ex(ex)
|
||||
if (sender.name != 'CONSOLE') {
|
||||
console.sender(sender, [message, ...console.stack(ex)])
|
||||
}
|
||||
this.printError(ex, "ms.api.command.tab.completer.error",
|
||||
plugin, command, sender, args)
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected copyPartialMatches(complete: string[], token: string, array: string[] = []): string[] {
|
||||
if (!token) { return complete }
|
||||
complete.forEach(function (e) {
|
||||
@ -129,5 +91,35 @@ export namespace command {
|
||||
})
|
||||
return array
|
||||
}
|
||||
|
||||
private checkSlow(cost: number, key: string, plugin: plugin.Plugin, command: string, sender: any, args: any[]) {
|
||||
if (cost > global.ScriptSlowExecuteTime) {
|
||||
let completerKey = `${plugin.description.name}-${key}-${command}-${sender.name}`
|
||||
if (!this.cacheSlowKeys[completerKey]) {
|
||||
return this.cacheSlowKeys[completerKey] = cost
|
||||
}
|
||||
console.i18n(key, {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
cost
|
||||
})
|
||||
}
|
||||
}
|
||||
private printError(error: Error, key: string, plugin: plugin.Plugin, command: string, sender: any, args: any[]) {
|
||||
let message = i18n.translate(key, {
|
||||
player: sender.name,
|
||||
plugin: plugin.description.name,
|
||||
command,
|
||||
args: Java.from(args).join(' '),
|
||||
error
|
||||
})
|
||||
console.console(message)
|
||||
console.ex(error)
|
||||
if (sender.name != 'CONSOLE') {
|
||||
console.sender(sender, [message, ...console.stack(error)])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ export namespace task {
|
||||
|
||||
protected pluginDisable(plugin: plugin.Plugin) {
|
||||
if (this.pluginCacheTasks.has(plugin.description.name)) {
|
||||
this.pluginCacheTasks.get(plugin.description.name).forEach((task) => {
|
||||
task.cancel()
|
||||
})
|
||||
this.pluginCacheTasks.get(plugin.description.name).forEach((task) => task.cancel())
|
||||
this.pluginCacheTasks.delete(plugin.description.name)
|
||||
}
|
||||
}
|
||||
@ -151,8 +149,9 @@ export namespace task {
|
||||
this.func(...args)
|
||||
this.emit('after', this)
|
||||
} catch (error: any) {
|
||||
this.emit('error', error)
|
||||
if (!error.processed) {
|
||||
try {
|
||||
this.emit('error', error)
|
||||
} catch (ignore) {
|
||||
console.console('§4插件执行任务时发生错误', error)
|
||||
console.ex(error)
|
||||
this.cancel()
|
||||
@ -181,7 +180,7 @@ export namespace task {
|
||||
* 提交任务
|
||||
* @param args 任务参数
|
||||
*/
|
||||
protected abstract submit0(...args: any[]): any
|
||||
protected abstract submit0(...args: any[]): Cancelable
|
||||
/**
|
||||
* 取消任务
|
||||
*/
|
||||
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@javatypes/spigot-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/spigot-api": "^0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@javatypes/bungee-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/bungee-api": "^0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -18,15 +18,12 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"@javatypes/jdk": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/jdk": "^0.0.3"
|
||||
},
|
||||
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
|
||||
}
|
||||
|
@ -18,12 +18,27 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
"@ccms/bukkit": "^0.28.0-beta.3",
|
||||
"@ccms/bungee": "^0.28.0-beta.3",
|
||||
"@ccms/common": "^0.28.0-beta.3",
|
||||
"@ccms/container": "^0.28.0-beta.3",
|
||||
"@ccms/core": "^0.28.0-beta.3",
|
||||
"@ccms/database": "^0.28.0-beta.3",
|
||||
"@ccms/i18n": "^0.28.0-beta.3",
|
||||
"@ccms/molang": "^0.28.0-beta.3",
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"@ccms/nodejs": "^0.28.0-beta.3",
|
||||
"@ccms/nukkit": "^0.28.0-beta.3",
|
||||
"@ccms/plugin": "^0.28.0-beta.3",
|
||||
"@ccms/polyfill": "^0.28.0-beta.3",
|
||||
"@ccms/protocol": "^0.28.0-beta.3",
|
||||
"@ccms/qrcode": "^0.28.0-beta.3",
|
||||
"@ccms/sponge": "^0.28.0-beta.3",
|
||||
"@ccms/websocket": "^0.28.0-beta.3"
|
||||
}
|
||||
}
|
||||
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@ccms/nashorn": "^0.28.0-beta.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"inversify": "^6.0.1",
|
||||
|
@ -17,18 +17,21 @@
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"watch": "pnpm rollup -c rollup.config.js --watch",
|
||||
"build": "pnpm clean && pnpm rollup -c rollup.config.js",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.1.2",
|
||||
"typescript": "^4.9.5"
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-obfuscator": "^3.0.2",
|
||||
"rollup-plugin-peer-deps-external": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
"@ccms/container": "^0.28.0-beta.3"
|
||||
"@ccms/common": "^0.28.0-beta.3",
|
||||
"@ccms/container": "^0.28.0-beta.3",
|
||||
"js-yaml": "^4.1.0"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
49
packages/core/rollup.config.js
Normal file
49
packages/core/rollup.config.js
Normal file
@ -0,0 +1,49 @@
|
||||
import typescript from '@rollup/plugin-typescript'
|
||||
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
|
||||
import { obfuscator } from 'rollup-obfuscator'
|
||||
|
||||
import pkg from './package.json'
|
||||
|
||||
const external = ['path', 'fs', 'typescript', 'tslib']
|
||||
/**
|
||||
* @type {import('rollup').RollupOptions}
|
||||
*/
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
plugins: [
|
||||
peerDepsExternal(),
|
||||
typescript(),
|
||||
obfuscator({
|
||||
compact: true,
|
||||
deadCodeInjection: true,
|
||||
deadCodeInjectionThreshold: 1,
|
||||
identifierNamesGenerator: 'mangled-shuffled',
|
||||
numbersToExpressions: true,
|
||||
simplify: true,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1,
|
||||
stringArrayEncoding: ['rc4'],
|
||||
stringArrayCallsTransform: true,
|
||||
stringArrayCallsTransformThreshold: 1,
|
||||
stringArrayWrappersChainedCalls: true,
|
||||
stringArrayWrappersParametersMaxCount: 3,
|
||||
sourceMap: true,
|
||||
sourceMapSourcesMode: 'sources',
|
||||
inputFileName: `${pkg.name}.ts`,
|
||||
transformObjectKeys: true,
|
||||
unicodeEscapeSequence: true,
|
||||
target: 'browser-no-eval'
|
||||
}),
|
||||
],
|
||||
external,
|
||||
treeshake: false,
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
interop: "auto",
|
||||
exports: "named",
|
||||
sourcemap: true,
|
||||
file: pkg.main || `dist/${pkg.name}.js`
|
||||
}
|
||||
]
|
||||
}
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@javatypes/spring-jdbc": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/spring-jdbc": "^0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -19,15 +19,12 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@types/js-yaml": "^4.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": "^4.1.0"
|
||||
|
@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
@ -24,9 +24,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/solvedDev/MoLang#readme",
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.17.15",
|
||||
"rimraf": "^4.4.1",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^4.9.5"
|
||||
"@types/node": "^18.17.15"
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,8 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
@ -18,15 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^4.9.5"
|
||||
"@ccms/nashorn": "^0.28.0-beta.3"
|
||||
},
|
||||
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
|
||||
}
|
||||
|
@ -145,8 +145,8 @@ EventEmitter.prototype.emit = function emit(type) {
|
||||
if (er.error instanceof Error || er.error instanceof Throwable) {
|
||||
throw er.error; // Unhandled 'error' event
|
||||
}
|
||||
if (er.cause instanceof Error || er.error instanceof Throwable) {
|
||||
throw er.error; // Unhandled 'error' event
|
||||
if (er.cause instanceof Error || er.cause instanceof Throwable) {
|
||||
throw er.cause; // Unhandled 'error' event
|
||||
}
|
||||
// At least give some kind of context to the user
|
||||
var err = new Error('Unhandled error.' + (er ? ' (' + (er.message || er.error || er.cause || er) + ')' : ''));
|
||||
|
@ -715,6 +715,7 @@ function callbackify(original) {
|
||||
// implications (stack, `uncaughtException`, `async_hooks`)
|
||||
// @ts-ignore
|
||||
original.apply(this, args)
|
||||
// @ts-ignore
|
||||
.then(function (ret) { process.nextTick(cb.bind(null, null, ret)) },
|
||||
function (rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)) });
|
||||
}
|
||||
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@javatypes/nukkit-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/nukkit-api": "^0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -18,15 +18,12 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "^4.1.2",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@types/js-yaml": "^4.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -13,7 +13,7 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -22,9 +22,6 @@
|
||||
"core-js": "^3.32.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@ccms/nashorn": "^0.28.0-beta.3"
|
||||
}
|
||||
}
|
||||
|
239
packages/polyfill/src/core-js.ts
Normal file
239
packages/polyfill/src/core-js.ts
Normal file
@ -0,0 +1,239 @@
|
||||
'use strict';
|
||||
import 'core-js/modules/es.symbol';
|
||||
import 'core-js/modules/es.symbol.description';
|
||||
import 'core-js/modules/es.symbol.async-iterator';
|
||||
import 'core-js/modules/es.symbol.has-instance';
|
||||
import 'core-js/modules/es.symbol.is-concat-spreadable';
|
||||
import 'core-js/modules/es.symbol.iterator';
|
||||
import 'core-js/modules/es.symbol.match';
|
||||
import 'core-js/modules/es.symbol.match-all';
|
||||
import 'core-js/modules/es.symbol.replace';
|
||||
import 'core-js/modules/es.symbol.search';
|
||||
import 'core-js/modules/es.symbol.species';
|
||||
import 'core-js/modules/es.symbol.split';
|
||||
import 'core-js/modules/es.symbol.to-primitive';
|
||||
import 'core-js/modules/es.symbol.to-string-tag';
|
||||
import 'core-js/modules/es.symbol.unscopables';
|
||||
import 'core-js/modules/es.array.at';
|
||||
import 'core-js/modules/es.array.concat';
|
||||
import 'core-js/modules/es.array.copy-within';
|
||||
import 'core-js/modules/es.array.every';
|
||||
import 'core-js/modules/es.array.fill';
|
||||
import 'core-js/modules/es.array.filter';
|
||||
import 'core-js/modules/es.array.find';
|
||||
import 'core-js/modules/es.array.find-index';
|
||||
import 'core-js/modules/es.array.find-last';
|
||||
import 'core-js/modules/es.array.find-last-index';
|
||||
import 'core-js/modules/es.array.flat';
|
||||
import 'core-js/modules/es.array.flat-map';
|
||||
import 'core-js/modules/es.array.for-each';
|
||||
import 'core-js/modules/es.array.from';
|
||||
import 'core-js/modules/es.array.includes';
|
||||
import 'core-js/modules/es.array.index-of';
|
||||
import 'core-js/modules/es.array.is-array';
|
||||
import 'core-js/modules/es.array.iterator';
|
||||
import 'core-js/modules/es.array.join';
|
||||
import 'core-js/modules/es.array.last-index-of';
|
||||
import 'core-js/modules/es.array.map';
|
||||
import 'core-js/modules/es.array.of';
|
||||
import 'core-js/modules/es.array.push';
|
||||
import 'core-js/modules/es.array.reduce';
|
||||
import 'core-js/modules/es.array.reduce-right';
|
||||
import 'core-js/modules/es.array.reverse';
|
||||
import 'core-js/modules/es.array.slice';
|
||||
import 'core-js/modules/es.array.some';
|
||||
import 'core-js/modules/es.array.sort';
|
||||
import 'core-js/modules/es.array.species';
|
||||
import 'core-js/modules/es.array.splice';
|
||||
import 'core-js/modules/es.array.to-reversed';
|
||||
import 'core-js/modules/es.array.to-sorted';
|
||||
import 'core-js/modules/es.array.to-spliced';
|
||||
import 'core-js/modules/es.array.unscopables.flat';
|
||||
import 'core-js/modules/es.array.unscopables.flat-map';
|
||||
import 'core-js/modules/es.array.unshift';
|
||||
import 'core-js/modules/es.array.with';
|
||||
import 'core-js/modules/es.array-buffer.constructor';
|
||||
import 'core-js/modules/es.array-buffer.is-view';
|
||||
import 'core-js/modules/es.array-buffer.slice';
|
||||
import 'core-js/modules/es.data-view';
|
||||
import 'core-js/modules/es.date.get-year';
|
||||
import 'core-js/modules/es.date.now';
|
||||
import 'core-js/modules/es.date.set-year';
|
||||
import 'core-js/modules/es.date.to-gmt-string';
|
||||
import 'core-js/modules/es.date.to-iso-string';
|
||||
import 'core-js/modules/es.date.to-json';
|
||||
import 'core-js/modules/es.date.to-primitive';
|
||||
import 'core-js/modules/es.date.to-string';
|
||||
import 'core-js/modules/es.escape';
|
||||
import 'core-js/modules/es.function.bind';
|
||||
import 'core-js/modules/es.function.has-instance';
|
||||
import 'core-js/modules/es.function.name';
|
||||
import 'core-js/modules/es.global-this';
|
||||
import 'core-js/modules/es.json.stringify';
|
||||
import 'core-js/modules/es.json.to-string-tag';
|
||||
import 'core-js/modules/es.map';
|
||||
import 'core-js/modules/es.math.acosh';
|
||||
import 'core-js/modules/es.math.asinh';
|
||||
import 'core-js/modules/es.math.atanh';
|
||||
import 'core-js/modules/es.math.cbrt';
|
||||
import 'core-js/modules/es.math.clz32';
|
||||
import 'core-js/modules/es.math.cosh';
|
||||
import 'core-js/modules/es.math.expm1';
|
||||
import 'core-js/modules/es.math.fround';
|
||||
import 'core-js/modules/es.math.hypot';
|
||||
import 'core-js/modules/es.math.imul';
|
||||
import 'core-js/modules/es.math.log10';
|
||||
import 'core-js/modules/es.math.log1p';
|
||||
import 'core-js/modules/es.math.log2';
|
||||
import 'core-js/modules/es.math.sign';
|
||||
import 'core-js/modules/es.math.sinh';
|
||||
import 'core-js/modules/es.math.tanh';
|
||||
import 'core-js/modules/es.math.to-string-tag';
|
||||
import 'core-js/modules/es.math.trunc';
|
||||
import 'core-js/modules/es.number.constructor';
|
||||
import 'core-js/modules/es.number.epsilon';
|
||||
import 'core-js/modules/es.number.is-finite';
|
||||
import 'core-js/modules/es.number.is-integer';
|
||||
import 'core-js/modules/es.number.is-nan';
|
||||
import 'core-js/modules/es.number.is-safe-integer';
|
||||
import 'core-js/modules/es.number.max-safe-integer';
|
||||
import 'core-js/modules/es.number.min-safe-integer';
|
||||
import 'core-js/modules/es.number.parse-float';
|
||||
import 'core-js/modules/es.number.parse-int';
|
||||
import 'core-js/modules/es.number.to-exponential';
|
||||
import 'core-js/modules/es.number.to-fixed';
|
||||
import 'core-js/modules/es.number.to-precision';
|
||||
import 'core-js/modules/es.object.assign';
|
||||
import 'core-js/modules/es.object.create';
|
||||
import 'core-js/modules/es.object.define-getter';
|
||||
import 'core-js/modules/es.object.define-properties';
|
||||
import 'core-js/modules/es.object.define-property';
|
||||
import 'core-js/modules/es.object.define-setter';
|
||||
import 'core-js/modules/es.object.entries';
|
||||
import 'core-js/modules/es.object.freeze';
|
||||
import 'core-js/modules/es.object.from-entries';
|
||||
import 'core-js/modules/es.object.get-own-property-descriptor';
|
||||
import 'core-js/modules/es.object.get-own-property-descriptors';
|
||||
import 'core-js/modules/es.object.get-own-property-names';
|
||||
import 'core-js/modules/es.object.get-prototype-of';
|
||||
import 'core-js/modules/es.object.has-own';
|
||||
import 'core-js/modules/es.object.is';
|
||||
import 'core-js/modules/es.object.is-extensible';
|
||||
import 'core-js/modules/es.object.is-frozen';
|
||||
import 'core-js/modules/es.object.is-sealed';
|
||||
import 'core-js/modules/es.object.keys';
|
||||
import 'core-js/modules/es.object.lookup-getter';
|
||||
import 'core-js/modules/es.object.lookup-setter';
|
||||
import 'core-js/modules/es.object.prevent-extensions';
|
||||
import 'core-js/modules/es.object.proto';
|
||||
import 'core-js/modules/es.object.seal';
|
||||
import 'core-js/modules/es.object.values';
|
||||
import 'core-js/modules/es.parse-float';
|
||||
import 'core-js/modules/es.parse-int';
|
||||
import 'core-js/modules/es.promise';
|
||||
import 'core-js/modules/es.promise.all-settled';
|
||||
import 'core-js/modules/es.promise.any';
|
||||
import 'core-js/modules/es.promise.finally';
|
||||
import 'core-js/modules/es.reflect.apply';
|
||||
import 'core-js/modules/es.reflect.construct';
|
||||
import 'core-js/modules/es.reflect.define-property';
|
||||
import 'core-js/modules/es.reflect.delete-property';
|
||||
import 'core-js/modules/es.reflect.get';
|
||||
import 'core-js/modules/es.reflect.get-own-property-descriptor';
|
||||
import 'core-js/modules/es.reflect.get-prototype-of';
|
||||
import 'core-js/modules/es.reflect.has';
|
||||
import 'core-js/modules/es.reflect.is-extensible';
|
||||
import 'core-js/modules/es.reflect.own-keys';
|
||||
import 'core-js/modules/es.reflect.prevent-extensions';
|
||||
import 'core-js/modules/es.reflect.set';
|
||||
import 'core-js/modules/es.reflect.set-prototype-of';
|
||||
import 'core-js/modules/es.reflect.to-string-tag';
|
||||
import 'core-js/modules/es.regexp.constructor';
|
||||
import 'core-js/modules/es.regexp.dot-all';
|
||||
import 'core-js/modules/es.regexp.exec';
|
||||
import 'core-js/modules/es.regexp.flags';
|
||||
import 'core-js/modules/es.regexp.sticky';
|
||||
import 'core-js/modules/es.regexp.test';
|
||||
import 'core-js/modules/es.regexp.to-string';
|
||||
import 'core-js/modules/es.set';
|
||||
import 'core-js/modules/es.string.at-alternative';
|
||||
import 'core-js/modules/es.string.code-point-at';
|
||||
import 'core-js/modules/es.string.ends-with';
|
||||
import 'core-js/modules/es.string.from-code-point';
|
||||
import 'core-js/modules/es.string.includes';
|
||||
import 'core-js/modules/es.string.is-well-formed';
|
||||
import 'core-js/modules/es.string.iterator';
|
||||
import 'core-js/modules/es.string.match';
|
||||
import 'core-js/modules/es.string.match-all';
|
||||
import 'core-js/modules/es.string.pad-end';
|
||||
import 'core-js/modules/es.string.pad-start';
|
||||
import 'core-js/modules/es.string.raw';
|
||||
import 'core-js/modules/es.string.repeat';
|
||||
import 'core-js/modules/es.string.replace';
|
||||
import 'core-js/modules/es.string.replace-all';
|
||||
import 'core-js/modules/es.string.search';
|
||||
import 'core-js/modules/es.string.split';
|
||||
import 'core-js/modules/es.string.starts-with';
|
||||
import 'core-js/modules/es.string.substr';
|
||||
import 'core-js/modules/es.string.to-well-formed';
|
||||
import 'core-js/modules/es.string.trim';
|
||||
import 'core-js/modules/es.string.trim-end';
|
||||
import 'core-js/modules/es.string.trim-start';
|
||||
import 'core-js/modules/es.string.anchor';
|
||||
import 'core-js/modules/es.string.big';
|
||||
import 'core-js/modules/es.string.blink';
|
||||
import 'core-js/modules/es.string.bold';
|
||||
import 'core-js/modules/es.string.fixed';
|
||||
import 'core-js/modules/es.string.fontcolor';
|
||||
import 'core-js/modules/es.string.fontsize';
|
||||
import 'core-js/modules/es.string.italics';
|
||||
import 'core-js/modules/es.string.link';
|
||||
import 'core-js/modules/es.string.small';
|
||||
import 'core-js/modules/es.string.strike';
|
||||
import 'core-js/modules/es.string.sub';
|
||||
import 'core-js/modules/es.string.sup';
|
||||
import 'core-js/modules/es.typed-array.float32-array';
|
||||
import 'core-js/modules/es.typed-array.float64-array';
|
||||
import 'core-js/modules/es.typed-array.int8-array';
|
||||
import 'core-js/modules/es.typed-array.int16-array';
|
||||
import 'core-js/modules/es.typed-array.int32-array';
|
||||
import 'core-js/modules/es.typed-array.uint8-array';
|
||||
import 'core-js/modules/es.typed-array.uint8-clamped-array';
|
||||
import 'core-js/modules/es.typed-array.uint16-array';
|
||||
import 'core-js/modules/es.typed-array.uint32-array';
|
||||
import 'core-js/modules/es.typed-array.at';
|
||||
import 'core-js/modules/es.typed-array.copy-within';
|
||||
import 'core-js/modules/es.typed-array.every';
|
||||
import 'core-js/modules/es.typed-array.fill';
|
||||
import 'core-js/modules/es.typed-array.filter';
|
||||
import 'core-js/modules/es.typed-array.find';
|
||||
import 'core-js/modules/es.typed-array.find-index';
|
||||
import 'core-js/modules/es.typed-array.find-last';
|
||||
import 'core-js/modules/es.typed-array.find-last-index';
|
||||
import 'core-js/modules/es.typed-array.for-each';
|
||||
import 'core-js/modules/es.typed-array.from';
|
||||
import 'core-js/modules/es.typed-array.includes';
|
||||
import 'core-js/modules/es.typed-array.index-of';
|
||||
import 'core-js/modules/es.typed-array.iterator';
|
||||
import 'core-js/modules/es.typed-array.join';
|
||||
import 'core-js/modules/es.typed-array.last-index-of';
|
||||
import 'core-js/modules/es.typed-array.map';
|
||||
import 'core-js/modules/es.typed-array.of';
|
||||
import 'core-js/modules/es.typed-array.reduce';
|
||||
import 'core-js/modules/es.typed-array.reduce-right';
|
||||
import 'core-js/modules/es.typed-array.reverse';
|
||||
import 'core-js/modules/es.typed-array.set';
|
||||
import 'core-js/modules/es.typed-array.slice';
|
||||
import 'core-js/modules/es.typed-array.some';
|
||||
import 'core-js/modules/es.typed-array.sort';
|
||||
import 'core-js/modules/es.typed-array.subarray';
|
||||
import 'core-js/modules/es.typed-array.to-locale-string';
|
||||
import 'core-js/modules/es.typed-array.to-reversed';
|
||||
import 'core-js/modules/es.typed-array.to-sorted';
|
||||
import 'core-js/modules/es.typed-array.to-string';
|
||||
import 'core-js/modules/es.typed-array.with';
|
||||
import 'core-js/modules/es.unescape';
|
||||
import 'core-js/modules/es.weak-map';
|
||||
import 'core-js/modules/es.weak-set';
|
||||
|
||||
module.exports = require('core-js/internals/path');
|
@ -7,7 +7,7 @@ console.i18n("ms.polyfill.initialize")
|
||||
import './openjdk-nashorn-shim'
|
||||
import './es5-ext'
|
||||
import './node-shim'
|
||||
import 'core-js'
|
||||
import './core-js'
|
||||
//@ts-ignore
|
||||
process.on('exit', () => require.disable())
|
||||
global.setGlobal('Proxy', require('./proxy').Proxy)
|
||||
|
@ -45,11 +45,13 @@ class Process extends EventEmitter {
|
||||
execArgv = ''
|
||||
execPath = ''
|
||||
|
||||
private queueMicrotaskExecuteTimeout = 5000
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.on('exit', () => {
|
||||
console.log(`await microTaskPool termination! queueTask: ${microTaskPool.shutdownNow().size()} remainTask: ${threadGroup.activeCount()}`)
|
||||
microTaskPool.awaitTermination(3000, TimeUnit.MILLISECONDS)
|
||||
microTaskPool.awaitTermination(this.queueMicrotaskExecuteTimeout, TimeUnit.MILLISECONDS)
|
||||
})
|
||||
}
|
||||
on(event: string | symbol, listener: (...args: any[]) => void) {
|
||||
@ -67,18 +69,30 @@ class Process extends EventEmitter {
|
||||
})
|
||||
}
|
||||
nextTick(callback: Function, ...args: any[]): void {
|
||||
microTaskPool.execute(() => {
|
||||
try {
|
||||
callback(args)
|
||||
} catch (origin: any) {
|
||||
try {
|
||||
super.emit('error', origin)
|
||||
} catch (error: any) {
|
||||
console.ex(origin)
|
||||
console.ex(error)
|
||||
try {
|
||||
microTaskPool.submit(new Callable({
|
||||
call: () => {
|
||||
try {
|
||||
callback(args)
|
||||
} catch (origin: any) {
|
||||
try {
|
||||
super.emit('error', origin)
|
||||
} catch (error: any) {
|
||||
console.ex(origin)
|
||||
console.ex(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
})).get(this.queueMicrotaskExecuteTimeout, TimeUnit.MILLISECONDS)
|
||||
} catch (error: any) {
|
||||
if (error instanceof InterruptedException) {
|
||||
return console.warn(`FixedThreadPool isInterrupted exit! Task ${callback.name || '<anonymous>'} exec exit!`)
|
||||
}
|
||||
})
|
||||
if (error instanceof TimeoutException) {
|
||||
return console.warn(`Task ${callback.name || '<anonymous>'} => ${callback} exec time greater than ${this.queueMicrotaskExecuteTimeout}ms!`)
|
||||
}
|
||||
throw error.getCause && error.getCause() || error
|
||||
}
|
||||
}
|
||||
exit(code: number) {
|
||||
console.log(`process exit by code ${code}!`)
|
||||
@ -120,9 +134,6 @@ class Process extends EventEmitter {
|
||||
throw new Error('MiaoScript unsupport kill.')
|
||||
return true
|
||||
}
|
||||
toString() {
|
||||
return "[object process]"
|
||||
}
|
||||
}
|
||||
|
||||
class EventLoop {
|
||||
@ -174,7 +185,7 @@ class EventLoop {
|
||||
this.eventLoopMainThread.interrupt()
|
||||
this.fixedThreadPool.shutdownNow()
|
||||
console.log(`await fixedThreadPool termination!`)
|
||||
this.fixedThreadPool.awaitTermination(3000, TimeUnit.MILLISECONDS)
|
||||
this.fixedThreadPool.awaitTermination(this.taskExecuteTimeout, TimeUnit.MILLISECONDS)
|
||||
})
|
||||
}
|
||||
|
||||
@ -261,7 +272,7 @@ class EventLoop {
|
||||
}
|
||||
}
|
||||
global.setGlobal('process', new Process(), {})
|
||||
Object.defineProperty(process, require('core-js/es/symbol/to-string-tag'), { value: '[object process]' })
|
||||
Object.defineProperty(process, require('core-js/es/symbol/to-string-tag'), { value: 'process' })
|
||||
const eventLoop = new EventLoop()
|
||||
Object.defineProperty(process, 'eventLoop', { value: eventLoop })
|
||||
eventLoop.startEventLoop()
|
||||
|
@ -19,12 +19,8 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
@ -18,12 +18,8 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
@ -18,14 +18,11 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@javatypes/sponge-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/sponge-api": "^0.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ccms/api": "^0.28.0-beta.3",
|
||||
|
@ -18,7 +18,7 @@
|
||||
"scripts": {
|
||||
"clean": "rimraf dist",
|
||||
"watch": "tsc --watch",
|
||||
"build": "yarn clean && tsc",
|
||||
"build": "pnpm clean && tsc",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -28,9 +28,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ccms/nashorn": "^0.28.0-beta.3",
|
||||
"@javatypes/tomcat-websocket-api": "^0.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^4.9.5"
|
||||
"@javatypes/tomcat-websocket-api": "^0.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ export class WebSocketManager {
|
||||
constructor() {
|
||||
process.on('exit', () => {
|
||||
for (const client of this.clients.values()) {
|
||||
client.close(0, `client ${client.id} close connect`)
|
||||
client.close(1000, `client ${client.id} close connect due process exit.`)
|
||||
}
|
||||
this.clients.clear()
|
||||
})
|
||||
|
@ -711,6 +711,7 @@ export class Socket extends Emitter<{}, {}, SocketReservedEvents> {
|
||||
* @api private
|
||||
*/
|
||||
private resetPingTimeout() {
|
||||
// @ts-ignore
|
||||
this.clearTimeoutFn(this.pingTimeoutTimer)
|
||||
this.pingTimeoutTimer = this.setTimeoutFn(() => {
|
||||
this.onClose("ping timeout")
|
||||
@ -919,6 +920,7 @@ export class Socket extends Emitter<{}, {}, SocketReservedEvents> {
|
||||
) {
|
||||
debug('socket close with reason: "%s"', reason)
|
||||
|
||||
// @ts-ignore
|
||||
// clear timers
|
||||
this.clearTimeoutFn(this.pingTimeoutTimer)
|
||||
|
||||
|
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
- "packages/*"
|
Loading…
Reference in New Issue
Block a user