Browse Source

fix

master
peter 5 years ago
parent
commit
a2887fc4a6
11 changed files with 54 additions and 39 deletions
  1. 22
    0
      .drone.yml
  2. 2
    3
      .gitignore
  3. 9
    1
      Index.ts
  4. 1
    1
      package.json
  5. 1
    9
      src/Backend.ts
  6. 2
    11
      src/Frontend.ts
  7. 0
    1
      src/Responses.ts
  8. 10
    5
      src/webpack.js
  9. 3
    3
      test/TestBackend.ts
  10. 3
    4
      test/TestFrontend.ts
  11. 1
    1
      test/index.html

+ 22
- 0
.drone.yml View File

1
+kind: pipeline
2
+name: default
3
+
4
+steps:
5
+- name: npm install
6
+  image: node:12
7
+  commands:
8
+  - npm install
9
+
10
+- name: npm run build
11
+  image: node:12
12
+  commands:
13
+  - npm run build
14
+
15
+- name: npm publish
16
+  image: plugins/npm
17
+  settings:
18
+    username: frontwork
19
+    password:
20
+      from_secret: npm_password
21
+    email: frontwork.me@gmail.com
22
+  

+ 2
- 3
.gitignore View File

1
 node_modules
1
 node_modules
2
+js
2
 
3
 
3
 src/**/*.js
4
 src/**/*.js
4
 src/**/*.d.ts
5
 src/**/*.d.ts
7
 test/**/*.d.ts
8
 test/**/*.d.ts
8
 
9
 
9
 *.d.ts
10
 *.d.ts
10
-*.js
11
-
12
-lib
11
+*.js

+ 9
- 1
Index.ts View File

1
 import * as Back from './src/Backend';
1
 import * as Back from './src/Backend';
2
 import * as Front from './src/Frontend';
2
 import * as Front from './src/Frontend';
3
+import * as Types from './src/Types'; 
4
+import * as Utils from './src/Utils'; 
5
+import * as Interfaces from './src/Interfaces';
6
+import * as Responses from './src/Responses';
3
 
7
 
4
 export {
8
 export {
5
     Back as Backend,
9
     Back as Backend,
6
-    Front as Frontend
10
+    Front as Frontend,
11
+    Types, 
12
+    Utils, 
13
+    Interfaces,
14
+    Responses
7
 }
15
 }

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "rpclibrary",
2
   "name": "rpclibrary",
3
-  "version": "1.0.3",
3
+  "version": "1.0.4",
4
   "description": "",
4
   "description": "",
5
   "main": "./js/Index.js",
5
   "main": "./js/Index.js",
6
   "scripts": {
6
   "scripts": {

+ 1
- 9
src/Backend.ts View File

6
 import * as T from './Types'; 
6
 import * as T from './Types'; 
7
 import * as U from './Utils'; 
7
 import * as U from './Utils'; 
8
 import * as I from './Interfaces';
8
 import * as I from './Interfaces';
9
-import * as R from './Responses';
10
 
9
 
11
-export { 
12
-    T as Types, 
13
-    U as Utils, 
14
-    I as Interfaces,
15
-    R as Responses
16
-}
17
-
18
-export class Server{
10
+export class RPCServer{
19
     private ws = http.createServer()
11
     private ws = http.createServer()
20
     private io = bsock.createServer()
12
     private io = bsock.createServer()
21
     private visibility:T.Visibility
13
     private visibility:T.Visibility

+ 2
- 11
src/Frontend.ts View File

3
 import bsock = require('bsock');
3
 import bsock = require('bsock');
4
 
4
 
5
 import * as T from './Types'; 
5
 import * as T from './Types'; 
6
-import * as U from './Utils'; 
7
 import * as I from './Interfaces';
6
 import * as I from './Interfaces';
8
-import * as R from './Responses';
9
-
10
-export { 
11
-    T as Types, 
12
-    U as Utils, 
13
-    I as Interfaces,
14
-    R as Responses
15
-}
16
-
17
 
7
 
18
 //fix args with defaults like "force = true" -> "force"
8
 //fix args with defaults like "force = true" -> "force"
19
 function stripAfterEquals(str:string){
9
 function stripAfterEquals(str:string){
20
     return str.split("=")[0]
10
     return str.split("=")[0]
21
 }
11
 }
22
 
12
 
23
-export class Client implements I.Socket{
13
+export class RPCSocket implements I.Socket{
24
 
14
 
25
     private socket: I.Socket
15
     private socket: I.Socket
26
     constructor(public port:number, private server: string, private tls: boolean = false){
16
     constructor(public port:number, private server: string, private tls: boolean = false){
17
+        Object.defineProperty(this, 'socket', {value: undefined, writable: true})
27
     }
18
     }
28
 
19
 
29
     public hook(name: T.Name, args: T.Arg){
20
     public hook(name: T.Name, args: T.Arg){

+ 0
- 1
src/Responses.ts View File

1
 
1
 
2
 export type Outcome = "Success" | "Error"
2
 export type Outcome = "Success" | "Error"
3
 
3
 
4
-/* Responses */
5
 export class Response{
4
 export class Response{
6
     constructor(
5
     constructor(
7
         public message?:string
6
         public message?:string

+ 10
- 5
src/webpack.js View File

1
 const path = require('path');
1
 const path = require('path');
2
 
2
 
3
-const frontendConf = {
3
+module.exports = {
4
   mode: 'production',
4
   mode: 'production',
5
   target: "web",
5
   target: "web",
6
-  entry: path.resolve(__dirname, '..', 'js', 'src', 'Frontend.js'),
6
+  entry: path.resolve(__dirname, 'Frontend.ts'),
7
   output: {
7
   output: {
8
       path: path.resolve(__dirname, '..', 'js', 'rpclibrary.browser.js'),
8
       path: path.resolve(__dirname, '..', 'js', 'rpclibrary.browser.js'),
9
       filename: "Frontend.js",
9
       filename: "Frontend.js",
12
   resolve: {
12
   resolve: {
13
     extensions: [".ts", ".tsx", ".js"]
13
     extensions: [".ts", ".tsx", ".js"]
14
   },
14
   },
15
+  module: {
16
+    rules: [
17
+      { test: /\.ts?$/, loader: "ts-loader" }
18
+    ]
19
+  },
15
   optimization: {
20
   optimization: {
16
     minimize: false,
21
     minimize: false,
17
   },
22
   },
18
-}
19
-
20
-module.exports =  [frontendConf]
23
+  externals: {
24
+  }
25
+}

+ 3
- 3
test/TestBackend.ts View File

1
-import { Server } from '../src/Backend'
1
+import { RPCServer } from '../src/Backend'
2
 import { SubscriptionResponse } from '../src/Responses'
2
 import { SubscriptionResponse } from '../src/Responses'
3
 
3
 
4
 let subcallback
4
 let subcallback
5
 
5
 
6
-new Server(20000, [{
6
+new RPCServer(20000, [{
7
     name: "HelloWorldRPCGroup",
7
     name: "HelloWorldRPCGroup",
8
     exportRPCs: () => [{
8
     exportRPCs: () => [{
9
         type: 'Call',
9
         type: 'Call',
25
 }])
25
 }])
26
 
26
 
27
 try{
27
 try{
28
-    new Server(20001, [{
28
+    new RPCServer(20001, [{
29
         name: "bad",
29
         name: "bad",
30
         exportRPCs: ()  => [
30
         exportRPCs: ()  => [
31
             (aaa,bbb,ccc) => { return aaa+bbb+ccc }
31
             (aaa,bbb,ccc) => { return aaa+bbb+ccc }

+ 3
- 4
test/TestFrontend.ts View File

1
-import { Client } from '../src/Frontend'
2
-console.log(Client)
3
-const client = new Client(20000, 'localhost')
1
+import { RPCSocket } from '../src/Frontend'
2
+const client = new RPCSocket(20000, 'localhost')
4
 client.connect().then(async _ => {
3
 client.connect().then(async _ => {
5
     await client.info().then(console.log)
4
     await client.info().then(console.log)
6
     
5
     
21
     client["HelloWorldRPCGroup"].triggerCallback("test1")
20
     client["HelloWorldRPCGroup"].triggerCallback("test1")
22
     client["HelloWorldRPCGroup"].triggerCallback("test2")
21
     client["HelloWorldRPCGroup"].triggerCallback("test2")
23
     client["HelloWorldRPCGroup"].triggerCallback("test3")
22
     client["HelloWorldRPCGroup"].triggerCallback("test3")
24
-})
23
+})

+ 1
- 1
test/index.html View File

1
-<script src="../lib/RPCaller.min.js"></script>
1
+<script src="../js/Frontend.min.js"></script>

Loading…
Cancel
Save