peter 5 yıl önce
ebeveyn
işleme
a2887fc4a6
11 değiştirilmiş dosya ile 54 ekleme ve 39 silme
  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 Dosyayı Görüntüle

@@ -0,0 +1,22 @@
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 Dosyayı Görüntüle

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

+ 9
- 1
Index.ts Dosyayı Görüntüle

@@ -1,7 +1,15 @@
1 1
 import * as Back from './src/Backend';
2 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 8
 export {
5 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 Dosyayı Görüntüle

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

+ 1
- 9
src/Backend.ts Dosyayı Görüntüle

@@ -6,16 +6,8 @@ import bsock = require('bsock');
6 6
 import * as T from './Types'; 
7 7
 import * as U from './Utils'; 
8 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 11
     private ws = http.createServer()
20 12
     private io = bsock.createServer()
21 13
     private visibility:T.Visibility

+ 2
- 11
src/Frontend.ts Dosyayı Görüntüle

@@ -3,27 +3,18 @@
3 3
 import bsock = require('bsock');
4 4
 
5 5
 import * as T from './Types'; 
6
-import * as U from './Utils'; 
7 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 8
 //fix args with defaults like "force = true" -> "force"
19 9
 function stripAfterEquals(str:string){
20 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 15
     private socket: I.Socket
26 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 20
     public hook(name: T.Name, args: T.Arg){

+ 0
- 1
src/Responses.ts Dosyayı Görüntüle

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

+ 10
- 5
src/webpack.js Dosyayı Görüntüle

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

+ 3
- 3
test/TestBackend.ts Dosyayı Görüntüle

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

+ 3
- 4
test/TestFrontend.ts Dosyayı Görüntüle

@@ -1,6 +1,5 @@
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 3
 client.connect().then(async _ => {
5 4
     await client.info().then(console.log)
6 5
     
@@ -21,4 +20,4 @@ client.connect().then(async _ => {
21 20
     client["HelloWorldRPCGroup"].triggerCallback("test1")
22 21
     client["HelloWorldRPCGroup"].triggerCallback("test2")
23 22
     client["HelloWorldRPCGroup"].triggerCallback("test3")
24
-})
23
+})

+ 1
- 1
test/index.html Dosyayı Görüntüle

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

Loading…
İptal
Kaydet