remove remote; add ws & types@ws
This commit is contained in:
parent
9861cd60a6
commit
186b0dfb80
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import * as doric from './src/runtime/sandbox'
|
import * as doric from './src/runtime/sandbox'
|
||||||
|
import * as WebSocket from "ws"
|
||||||
|
|
||||||
let global = new Function('return this')()
|
let global = new Function('return this')()
|
||||||
global.doric = doric
|
global.doric = doric
|
||||||
const contextId = "DoricDebug"
|
const contextId = "DoricDebug"
|
||||||
@ -21,6 +23,21 @@ global.context = doric.jsObtainContext(contextId)
|
|||||||
global.Entry = doric.jsObtainEntry(contextId)
|
global.Entry = doric.jsObtainEntry(contextId)
|
||||||
console.log('Start Server')
|
console.log('Start Server')
|
||||||
|
|
||||||
|
const wss = new WebSocket.Server({ port: 2080 })
|
||||||
|
var sandbox = {}
|
||||||
|
|
||||||
|
wss.on('connection', function connection(ws) {
|
||||||
|
ws.on('message', function incoming(message: string) {
|
||||||
|
let messageObject = JSON.parse(message)
|
||||||
|
switch (messageObject.cmd) {
|
||||||
|
case "loadJS":
|
||||||
|
break
|
||||||
|
case "evaluateJS":
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
global.injectGlobal = (objName: string, obj: string) => {
|
global.injectGlobal = (objName: string, obj: string) => {
|
||||||
Reflect.set(global, objName, JSON.parse(obj))
|
Reflect.set(global, objName, JSON.parse(obj))
|
||||||
}
|
}
|
||||||
|
21
js-framework/package-lock.json
generated
21
js-framework/package-lock.json
generated
@ -22,6 +22,14 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/ws": {
|
||||||
|
"version": "6.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-6.0.3.tgz",
|
||||||
|
"integrity": "sha512-yBTM0P05Tx9iXGq00BbJPo37ox68R5vaGTXivs6RGh/BQ6QP5zqZDGWdAO6JbRE/iR1l80xeGAwCQS2nMV9S/w==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "7.1.0",
|
"version": "7.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
|
||||||
@ -69,6 +77,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz",
|
||||||
"integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ=="
|
"integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ=="
|
||||||
},
|
},
|
||||||
|
"async-limiter": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||||
|
},
|
||||||
"atob": {
|
"atob": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
|
||||||
@ -2072,6 +2085,14 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||||
|
},
|
||||||
|
"ws": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-+SqNqFbwTm/0DC18KYzIsMTnEWpLwJsiasW/O17la4iDRRIO9uaHbvKiAS3AHgTiuuWerK/brj4O6MYZkei9xg==",
|
||||||
|
"requires": {
|
||||||
|
"async-limiter": "^1.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/doric-pub/doric#readme",
|
"homepage": "https://github.com/doric-pub/doric#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/ws": "^6.0.3",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rollup": "^1.17.0",
|
"rollup": "^1.17.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-watch": "^4.3.1",
|
"rollup-watch": "^4.3.1",
|
||||||
"tslib": "^1.10.0",
|
"tslib": "^1.10.0",
|
||||||
"typescript": "^3.5.3"
|
"typescript": "^3.5.3",
|
||||||
|
"ws": "^7.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
1
remote/.gitignore
vendored
1
remote/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
node_modules/
|
|
21
remote/.vscode/launch.json
vendored
21
remote/.vscode/launch.json
vendored
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Launch Program",
|
|
||||||
"program": "${workspaceFolder}/index.ts",
|
|
||||||
"preLaunchTask": "tsc: build - tsconfig.json",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"request": "attach",
|
|
||||||
"name": "Attach",
|
|
||||||
"port": 9229
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
const WebSocket = require('ws')
|
|
||||||
const vm = require("vm")
|
|
||||||
|
|
||||||
const wss = new WebSocket.Server({ port: 2080 })
|
|
||||||
var sandbox = {}
|
|
||||||
var context = vm.createContext(sandbox)
|
|
||||||
|
|
||||||
wss.on('connection', function connection(ws) {
|
|
||||||
ws.on('message', function incoming(message) {
|
|
||||||
let messageObject = JSON.parse(message)
|
|
||||||
switch (messageObject.cmd) {
|
|
||||||
case "loadJS":
|
|
||||||
let result = vm.runInContext(messageObject.script, sandbox)
|
|
||||||
ws.send(JSON.stringify({ cmd: 'loadJS', result: String(result) }))
|
|
||||||
break
|
|
||||||
case "evaluateJS":
|
|
||||||
break
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
21
remote/package-lock.json
generated
21
remote/package-lock.json
generated
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "remote",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"lockfileVersion": 1,
|
|
||||||
"requires": true,
|
|
||||||
"dependencies": {
|
|
||||||
"async-limiter": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
|
||||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
|
||||||
},
|
|
||||||
"ws": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-+SqNqFbwTm/0DC18KYzIsMTnEWpLwJsiasW/O17la4iDRRIO9uaHbvKiAS3AHgTiuuWerK/brj4O6MYZkei9xg==",
|
|
||||||
"requires": {
|
|
||||||
"async-limiter": "^1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "remote",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ws": "^7.2.0"
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user