wtf
This commit is contained in:
+6
-4
@@ -1,7 +1,9 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
*/**/*.js
|
src/**/*.js
|
||||||
*/**/*.d.ts
|
src/**/*.d.ts
|
||||||
|
|
||||||
!lib/Backend.js
|
test/**/*.js
|
||||||
!lib/Frontend.js
|
test/**/*.d.ts
|
||||||
|
|
||||||
|
lib
|
||||||
-167
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rpclib",
|
"name": "rpclibrary",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+8
-7
@@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "rpclib",
|
"name": "rpclibrary",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run clean; npm run tsc; npm run webpack",
|
|
||||||
"tsc": "tsc",
|
"tsc": "tsc",
|
||||||
"webpack": "webpack --config src/webpack.prod.js --progress --colors",
|
"webpack": "webpack",
|
||||||
"clean": "rm -rf lib"
|
"build-lib": "npm run webpack --config ./src/webpack.js",
|
||||||
|
"build-test": "npm run webpack --config ./test/webpack.js",
|
||||||
|
"build": "npm run clean && npm run tsc && npm run build-lib && npm run build-test",
|
||||||
|
"clean": "rm -rf lib ./*.js ./*.d.ts"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
@@ -25,7 +27,6 @@
|
|||||||
"uuid": "^3.3.3"
|
"uuid": "^3.3.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"./lib/Backend.js",
|
"lib/*.js"
|
||||||
"./lib/Frontend.js"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,16 @@ import bsock = require('bsock');
|
|||||||
import * as T from './Types';
|
import * as T from './Types';
|
||||||
import * as U from './Utils';
|
import * as U from './Utils';
|
||||||
import * as I from './Interfaces';
|
import * as I from './Interfaces';
|
||||||
|
import * as R from './Responses';
|
||||||
|
|
||||||
export class Server{
|
export {
|
||||||
|
T as Types,
|
||||||
|
U as Utils,
|
||||||
|
I as Interfaces,
|
||||||
|
R as Responses
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Backend{
|
||||||
private ws = http.createServer()
|
private ws = http.createServer()
|
||||||
private io = bsock.createServer()
|
private io = bsock.createServer()
|
||||||
|
|
||||||
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
var bsock = require('bsock')
|
var bsock = require('bsock')
|
||||||
|
|
||||||
import * as I from './Interfaces';
|
|
||||||
import * as T from './Types';
|
import * as T from './Types';
|
||||||
|
import * as I from './Interfaces';
|
||||||
|
|
||||||
|
export {
|
||||||
|
T as Types,
|
||||||
|
I as Interfaces,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//fix args with defaults like "force = true" -> "force"
|
//fix args with defaults like "force = true" -> "force"
|
||||||
@@ -11,7 +16,7 @@ function stripAfterEquals(str:string){
|
|||||||
return str.split("=")[0]
|
return str.split("=")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Client implements I.Socket{
|
export class Frontend implements I.Socket{
|
||||||
|
|
||||||
private socket: I.Socket
|
private socket: I.Socket
|
||||||
constructor(public port:number, private server: string, private tls: boolean = false){
|
constructor(public port:number, private server: string, private tls: boolean = false){
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
|
||||||
|
|
||||||
const frontendConf = {
|
|
||||||
mode: 'production',
|
|
||||||
target: "web",
|
|
||||||
entry: path.resolve(__dirname, 'Client.ts'),
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, '../lib'),
|
|
||||||
filename: 'Frontend.js',
|
|
||||||
libraryTarget: 'commonjs',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{ test: /\.ts?$/, loader: "ts-loader" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".tsx", ".js"]
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new TerserPlugin({
|
|
||||||
parallel: true,
|
|
||||||
exclude: [
|
|
||||||
/\.\/(.*)\/.ts/,
|
|
||||||
/\.\/(.*).ts/,
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const backendConf = {
|
|
||||||
mode: 'production',
|
|
||||||
target: "node",
|
|
||||||
entry: path.resolve(__dirname, 'Server.ts'),
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, '../lib'),
|
|
||||||
filename: 'Backend.js',
|
|
||||||
libraryTarget: 'commonjs',
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{ test: /\.ts?$/, loader: "ts-loader" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".tsx", ".js"]
|
|
||||||
},
|
|
||||||
optimization: {
|
|
||||||
minimize: true,
|
|
||||||
minimizer: [
|
|
||||||
new TerserPlugin({
|
|
||||||
parallel: true,
|
|
||||||
exclude: [
|
|
||||||
/\.\/(.*)\/.ts/,
|
|
||||||
/\.\/(.*).ts/,
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = [frontendConf, backendConf]
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Backend } from '../src/Backend'
|
||||||
|
|
||||||
|
const testServer = new Backend(20000, [{
|
||||||
|
name: "HelloWorldRPCGroup",
|
||||||
|
publicRPCs: () => [],
|
||||||
|
localRPCs: () => [{
|
||||||
|
type: 'Call',
|
||||||
|
name: 'echo',
|
||||||
|
call: async (s:string) => s,
|
||||||
|
}]
|
||||||
|
}])
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { Frontend } from '../src/Frontend'
|
||||||
|
|
||||||
|
const testClient = new Frontend(20000, 'localhost')
|
||||||
|
testClient.connect().then(_ => {
|
||||||
|
testClient.info().then(console.log)
|
||||||
|
testClient["HelloWorldRPCGroup"].echo("x").then(console.log)
|
||||||
|
})
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { Server } from '../src/Server'
|
|
||||||
import {Client} from '../src/Client'
|
|
||||||
|
|
||||||
new Server(20000, [{
|
|
||||||
name: "HelloWorldRPCGroup",
|
|
||||||
publicRPCs: () => [],
|
|
||||||
localRPCs: () => [{
|
|
||||||
type: 'Call',
|
|
||||||
name: 'echo',
|
|
||||||
call: async (s:string) => s,
|
|
||||||
}]
|
|
||||||
}])
|
|
||||||
|
|
||||||
const caller = new Client(20000, 'localhost')
|
|
||||||
caller.connect().then(_ => {
|
|
||||||
caller.info().then(console.log)
|
|
||||||
caller["HelloWorldRPCGroup"].echo("x").then(console.log)
|
|
||||||
})
|
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"target": "ESnext",
|
"target": "ESnext",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
"outDir": "./lib",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user