refactor: rename ployfill to polyfill

Signed-off-by: MiaoWoo <admin@yumc.pw>
backup
MiaoWoo 2021-03-26 16:17:13 +08:00
parent 67aa4302e0
commit 93f44e5a00
12 changed files with 18 additions and 13 deletions

View File

@ -21,7 +21,7 @@
"dependencies": {
"@ccms/common": "^0.13.0",
"@ccms/container": "^0.13.0",
"@ccms/ployfill": "^0.13.0",
"@ccms/polyfill": "^0.13.0",
"base64-js": "^1.5.1",
"source-map-builder": "^0.0.7"
},

View File

@ -1,6 +1,6 @@
ms.i18n.completed: "Internationalization component initialization completed. Current Language: English"
ms.ployfill.initialize: "Initialization Java Nashorn ployfill. Please wait..."
ms.ployfill.completed: "Java Nashorn ployfill loading completed... Cost ({time}s)!"
ms.polyfill.initialize: "Initialization Java Nashorn polyfill. Please wait..."
ms.polyfill.completed: "Java Nashorn polyfill loading completed... Cost ({time}s)!"
ms.core.ioc.initialize: "Initialization MiaoScript IOC Container {scope}/container. Please wait..."
ms.core.ioc.completed: "MiaoScript IOC Container {scope}/container loading completed({time}s)!"

View File

@ -1,6 +1,6 @@
ms.i18n.completed: "国际化组件 初始化完成 当前语言: 简体中文"
ms.ployfill.initialize: "加载 Java Nashorn 补丁. 请稍候..."
ms.ployfill.completed: "Java Nashorn 补丁 加载完成... 耗时 ({time}s)!"
ms.polyfill.initialize: "加载 Java Nashorn 补丁. 请稍候..."
ms.polyfill.completed: "Java Nashorn 补丁 加载完成... 耗时 ({time}s)!"
ms.core.ioc.initialize: "初始化 MiaoScript IOC 容器 {scope}/container. 请稍候..."
ms.core.ioc.completed: "MiaoScript IOC 容器 {scope}/container 加载完成 耗时({time}s)"

View File

@ -1,7 +1,7 @@
{
"name": "@ccms/ployfill",
"name": "@ccms/polyfill",
"version": "0.13.0",
"description": "MiaoScript ployfill package",
"description": "MiaoScript polyfill package",
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
@ -16,6 +16,7 @@
"dependencies": {
"@ccms/i18n": "^0.13.0",
"@ccms/nodejs": "^0.13.0",
"@ccms/nashorn": "^0.13.0",
"core-js": "^3.7.0"
},
"devDependencies": {

View File

@ -1,9 +1,9 @@
/// <reference types="@ccms/nashorn" />
import '@ccms/nodejs'
import i18n from '@ccms/i18n'
let ployfillStartTime = new Date().getTime()
let polyfillStartTime = new Date().getTime()
i18n.initialize()
console.i18n("ms.ployfill.initialize")
console.i18n("ms.polyfill.initialize")
import './es5-ext'
import './node-shim'
import 'core-js'
@ -12,4 +12,4 @@ process.on('exit', () => require.disable())
global.setGlobal('Proxy', require('./proxy').Proxy)
global.setGlobal('XMLHttpRequest', require('./xml-http-request').XMLHttpRequest)
global.setGlobal('Blob', require('blob-polyfill').Blob)
console.i18n("ms.ployfill.completed", { time: (new Date().getTime() - ployfillStartTime) / 1000 })
console.i18n("ms.polyfill.completed", { time: (new Date().getTime() - polyfillStartTime) / 1000 })

View File

@ -2,7 +2,6 @@ import { EventEmitter } from 'events'
const System = Java.type('java.lang.System')
const Thread = Java.type('java.lang.Thread')
const Runnable = Java.type('java.lang.Runnable')
const InterruptedException = Java.type('java.lang.InterruptedException')
const ThreadGroup = Java.type("java.lang.ThreadGroup")
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
@ -56,6 +55,10 @@ class Process extends EventEmitter {
console.log(`process exit by code ${code}!`)
this.emit('exit', code)
}
toString() {
return "[object process]"
}
}
class EventLoop {
@ -191,8 +194,9 @@ class EventLoop {
}
}
global.setGlobal('process', new Process(), {})
Object.defineProperty(process, require('core-js/es/symbol/to-string-tag'), { value: '[object process]' })
const eventLoop = new EventLoop()
global.setGlobal('eventLoop', eventLoop, {})
Object.defineProperty(process, 'eventLoop', { value: eventLoop })
eventLoop.startEventLoop()
global.setGlobal('queueMicrotask', (func: any) => microTaskPool.execute(func), {})
global.setGlobal('setTimeout', eventLoop.setTimeout.bind(eventLoop), {})

View File

@ -1,4 +1,4 @@
import { ProxyHandle } from '@ccms/nashorn'
import type { ProxyHandle } from '@ccms/nashorn'
// Nashorn JSAdapter See https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions#Nashornextensions-JSAdapterconstructor
let createProxy = eval(`