Paul il y a 5 ans
Parent
révision
7f7a86c58b
7 fichiers modifiés avec 1372 ajouts et 85 suppressions
  1. 11
    0
      .babelrc
  2. 13
    1
      package.json
  3. 2
    14
      src/client.ts
  4. 14
    0
      src/types/callback.ts
  5. 1
    1
      tsconfig.json
  6. 7
    11
      webpack.config.js
  7. 1324
    58
      yarn.lock

+ 11
- 0
.babelrc Voir le fichier

@@ -0,0 +1,11 @@
1
+{
2
+  "presets": [
3
+    "@babel/env",
4
+    "@babel/typescript"
5
+  ],
6
+  "plugins": [
7
+    "@babel/plugin-transform-runtime",
8
+    "@babel/proposal-class-properties",
9
+    "@babel/proposal-object-rest-spread"
10
+  ]
11
+}

+ 13
- 1
package.json Voir le fichier

@@ -4,6 +4,8 @@
4 4
   "description": "linker's ts sdk",
5 5
   "main": "lib/src/client.js",
6 6
   "scripts": {
7
+    "type-check": "tsc --noEmit",
8
+    "type-check:watch": "npm run type-check -- --watch",
7 9
     "start": "webpack-dev-server  --mode development",
8 10
     "test": "jest",
9 11
     "build": "webpack --config webpack.config.js"
@@ -19,13 +21,23 @@
19 21
     "node-int64": "^0.4.0"
20 22
   },
21 23
   "devDependencies": {
24
+    "@babel/cli": "^7.4.4",
25
+    "@babel/core": "^7.4.4",
26
+    "@babel/plugin-proposal-class-properties": "^7.4.4",
27
+    "@babel/plugin-proposal-object-rest-spread": "^7.4.4",
28
+    "@babel/plugin-transform-runtime": "^7.4.4",
29
+    "@babel/preset-env": "^7.4.4",
30
+    "@babel/preset-typescript": "^7.3.3",
31
+    "@babel/runtime": "^7.4.4",
22 32
     "@types/crypto-js": "^3.1.43",
23 33
     "@types/jest": "^24.0.11",
24 34
     "@types/node-int64": "^0.4.29",
35
+    "babel-core": "^6.26.3",
36
+    "babel-loader": "^8.0.5",
37
+    "babel-preset-env": "^1.7.0",
25 38
     "html-webpack-plugin": "^3.2.0",
26 39
     "jest": "^24.5.0",
27 40
     "ts-jest": "^24.0.0",
28
-    "ts-loader": "^6.0.0",
29 41
     "typescript": "^3.3.4000",
30 42
     "webpack": "^4.30.0",
31 43
     "webpack-cli": "^3.3.2",

+ 2
- 14
src/client.ts Voir le fichier

@@ -1,18 +1,6 @@
1 1
 import { Packet } from './packet';
2 2
 import { Utils } from './utils';
3
-
4
-interface ReadyStateCallback {
5
-  onOpen(ev: Event): void;
6
-  onError(ev: Event): void;
7
-  onClose(ev: Event): void;
8
-}
9
-
10
-interface RequestCallback {
11
-  onStart(): void;
12
-  onSuccess(data: string): void;
13
-  onError(code: number, message: string): void;
14
-  onEnd(): void;
15
-}
3
+import { ReadyStateCallback, RequestCallback } from './types/callback';
16 4
 
17 5
 /**
18 6
  * 初始化链接以及收发数据
@@ -336,4 +324,4 @@ class Client {
336 324
   }
337 325
 }
338 326
 
339
-export { Client, ReadyStateCallback, RequestCallback };
327
+export { Client };

+ 14
- 0
src/types/callback.ts Voir le fichier

@@ -0,0 +1,14 @@
1
+interface ReadyStateCallback {
2
+  onOpen(ev: Event): void;
3
+  onError(ev: Event): void;
4
+  onClose(ev: Event): void;
5
+}
6
+
7
+interface RequestCallback {
8
+  onStart(): void;
9
+  onSuccess(data: string): void;
10
+  onError(code: number, message: string): void;
11
+  onEnd(): void;
12
+}
13
+
14
+export { ReadyStateCallback, RequestCallback };

+ 1
- 1
tsconfig.json Voir le fichier

@@ -2,7 +2,7 @@
2 2
   "compileOnSave": true,
3 3
   "compilerOptions": {
4 4
     // Target latest version of ECMAScript.
5
-    "target": "es5",
5
+    "target": "es6",
6 6
     // Search under node_modules for non-relative imports.
7 7
     "moduleResolution": "node",
8 8
     // Process & infer types from .js files.

+ 7
- 11
webpack.config.js Voir le fichier

@@ -19,17 +19,13 @@ module.exports = {
19 19
         filename: 'main.js',
20 20
         path: path.resolve(__dirname, 'dist')
21 21
     },
22
+    resolve: { extensions: ['.js', '.jsx', '.tsx', '.ts', '.json'] },
22 23
     module: {
23
-        rules: [{
24
-            test: /\.ts$/,
25
-            use: "ts-loader"
26
-        }]
27
-    },
28
-    resolve: {
29
-        extensions: [
30
-            '.ts',
31
-            '.js',
32
-            '.tsx'
33
-        ]
24
+      rules: [{
25
+          // Include ts, tsx, js, and jsx files.
26
+          test: /\.(ts|js)x?$/,
27
+          exclude: /node_modules/,
28
+          loader: 'babel-loader',
29
+      }],
34 30
     }
35 31
 };

+ 1324
- 58
yarn.lock
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier