diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..5f7726e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,22 @@ +kind: pipeline +name: default + +steps: +- name: npm install + image: node:12 + commands: + - npm install + +- name: npm run build + image: node:12 + commands: + - npm run build + +- name: npm publish + image: plugins/npm + settings: + username: frontwork + password: + from_secret: npm_password + email: frontwork.me@gmail.com + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ed8763..35162d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules +js src/**/*.js src/**/*.d.ts @@ -7,6 +8,4 @@ test/**/*.js test/**/*.d.ts *.d.ts -*.js - -lib \ No newline at end of file +*.js \ No newline at end of file diff --git a/Index.ts b/Index.ts index f307de2..5db6b50 100644 --- a/Index.ts +++ b/Index.ts @@ -1,7 +1,15 @@ import * as Back from './src/Backend'; import * as Front from './src/Frontend'; +import * as Types from './src/Types'; +import * as Utils from './src/Utils'; +import * as Interfaces from './src/Interfaces'; +import * as Responses from './src/Responses'; export { Back as Backend, - Front as Frontend + Front as Frontend, + Types, + Utils, + Interfaces, + Responses } \ No newline at end of file diff --git a/package.json b/package.json index d52c6fa..78e6790 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rpclibrary", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "./js/Index.js", "scripts": { diff --git a/src/Backend.ts b/src/Backend.ts index 6d01b58..36a4d04 100644 --- a/src/Backend.ts +++ b/src/Backend.ts @@ -6,16 +6,8 @@ import bsock = require('bsock'); import * as T from './Types'; import * as U from './Utils'; import * as I from './Interfaces'; -import * as R from './Responses'; -export { - T as Types, - U as Utils, - I as Interfaces, - R as Responses -} - -export class Server{ +export class RPCServer{ private ws = http.createServer() private io = bsock.createServer() private visibility:T.Visibility diff --git a/src/Frontend.ts b/src/Frontend.ts index 891af91..3b0e834 100644 --- a/src/Frontend.ts +++ b/src/Frontend.ts @@ -3,27 +3,18 @@ import bsock = require('bsock'); import * as T from './Types'; -import * as U from './Utils'; import * as I from './Interfaces'; -import * as R from './Responses'; - -export { - T as Types, - U as Utils, - I as Interfaces, - R as Responses -} - //fix args with defaults like "force = true" -> "force" function stripAfterEquals(str:string){ return str.split("=")[0] } -export class Client implements I.Socket{ +export class RPCSocket implements I.Socket{ private socket: I.Socket constructor(public port:number, private server: string, private tls: boolean = false){ + Object.defineProperty(this, 'socket', {value: undefined, writable: true}) } public hook(name: T.Name, args: T.Arg){ diff --git a/src/Responses.ts b/src/Responses.ts index 7f470bf..2b44c45 100644 --- a/src/Responses.ts +++ b/src/Responses.ts @@ -1,7 +1,6 @@ export type Outcome = "Success" | "Error" -/* Responses */ export class Response{ constructor( public message?:string diff --git a/src/webpack.js b/src/webpack.js index ae46e31..02cf839 100644 --- a/src/webpack.js +++ b/src/webpack.js @@ -1,9 +1,9 @@ const path = require('path'); -const frontendConf = { +module.exports = { mode: 'production', target: "web", - entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'), + entry: path.resolve(__dirname, 'Frontend.ts'), output: { path: path.resolve(__dirname, '..', 'js', 'rpclibrary.browser.js'), filename: "Frontend.js", @@ -12,9 +12,14 @@ const frontendConf = { resolve: { extensions: [".ts", ".tsx", ".js"] }, + module: { + rules: [ + { test: /\.ts?$/, loader: "ts-loader" } + ] + }, optimization: { minimize: false, }, -} - -module.exports = [frontendConf] + externals: { + } +} \ No newline at end of file diff --git a/test/TestBackend.ts b/test/TestBackend.ts index 1e32d3d..c61218b 100644 --- a/test/TestBackend.ts +++ b/test/TestBackend.ts @@ -1,9 +1,9 @@ -import { Server } from '../src/Backend' +import { RPCServer } from '../src/Backend' import { SubscriptionResponse } from '../src/Responses' let subcallback -new Server(20000, [{ +new RPCServer(20000, [{ name: "HelloWorldRPCGroup", exportRPCs: () => [{ type: 'Call', @@ -25,7 +25,7 @@ new Server(20000, [{ }]) try{ - new Server(20001, [{ + new RPCServer(20001, [{ name: "bad", exportRPCs: () => [ (aaa,bbb,ccc) => { return aaa+bbb+ccc } diff --git a/test/TestFrontend.ts b/test/TestFrontend.ts index 48c8fee..d91d310 100644 --- a/test/TestFrontend.ts +++ b/test/TestFrontend.ts @@ -1,6 +1,5 @@ -import { Client } from '../src/Frontend' -console.log(Client) -const client = new Client(20000, 'localhost') +import { RPCSocket } from '../src/Frontend' +const client = new RPCSocket(20000, 'localhost') client.connect().then(async _ => { await client.info().then(console.log) @@ -21,4 +20,4 @@ client.connect().then(async _ => { client["HelloWorldRPCGroup"].triggerCallback("test1") client["HelloWorldRPCGroup"].triggerCallback("test2") client["HelloWorldRPCGroup"].triggerCallback("test3") -}) \ No newline at end of file +}) diff --git a/test/index.html b/test/index.html index 32395da..4159903 100644 --- a/test/index.html +++ b/test/index.html @@ -1 +1 @@ - \ No newline at end of file +