Browse Source

chore: update

wxyyxc1992 5 years ago
parent
commit
d3f54d1c53

+ 3
- 3
packages/cts-api/dist/cjs/packet.js View File

@@ -1,7 +1,7 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3 3
 var utils_1 = require("./utils");
4
-var node_int64_1 = require("node-int64");
4
+var Int64 = require("node-int64");
5 5
 var Packet = (function () {
6 6
     function Packet() {
7 7
         this.key = 'b8ca9aa66def05ff3f24919274bb4a66';
@@ -13,7 +13,7 @@ var Packet = (function () {
13 13
         var bodyLength = body.length;
14 14
         var buf = new ArrayBuffer(20 + headerLength + bodyLength);
15 15
         var dataView = new DataView(buf);
16
-        var nsBuf = new node_int64_1.default(sequence).toBuffer();
16
+        var nsBuf = new Int64(sequence).toBuffer();
17 17
         dataView.setUint32(0, operator);
18 18
         dataView.setUint32(12, headerLength);
19 19
         dataView.setUint32(16, bodyLength);
@@ -32,7 +32,7 @@ var Packet = (function () {
32 32
     Packet.prototype.unPack = function (data) {
33 33
         var dataView = new DataView(data);
34 34
         this.operator = dataView.getUint32(0, false);
35
-        this.sequence = new node_int64_1.default(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
35
+        this.sequence = new Int64(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
36 36
         this.headerLength = dataView.getUint32(12, false);
37 37
         this.bodyLength = dataView.getUint32(16, false);
38 38
         var header = utils_1.Utils.ab2str(dataView.buffer.slice(20, 20 + this.headerLength));

+ 1
- 1
packages/cts-api/dist/index.js
File diff suppressed because it is too large
View File


+ 4
- 13
packages/cts-api/src/packet.ts View File

@@ -1,5 +1,5 @@
1 1
 import { Utils } from './utils';
2
-import Int64 from 'node-int64';
2
+import * as Int64 from 'node-int64';
3 3
 
4 4
 export class Packet {
5 5
   private key: string = 'b8ca9aa66def05ff3f24919274bb4a66';
@@ -10,12 +10,7 @@ export class Packet {
10 10
   public header: string;
11 11
   public body: string;
12 12
 
13
-  public pack(
14
-    operator: number,
15
-    sequence: number,
16
-    header: string,
17
-    body: string,
18
-  ): ArrayBuffer {
13
+  public pack(operator: number, sequence: number, header: string, body: string): ArrayBuffer {
19 14
     header = Utils.encrypt(header, this.key, this.key);
20 15
     body = Utils.encrypt(body, this.key, this.key);
21 16
 
@@ -49,15 +44,11 @@ export class Packet {
49 44
     const dataView = new DataView(data);
50 45
 
51 46
     this.operator = dataView.getUint32(0, false);
52
-    this.sequence = new Int64(
53
-      new Uint8Array(dataView.buffer.slice(4, 12)),
54
-    ).toNumber();
47
+    this.sequence = new Int64(new Uint8Array(dataView.buffer.slice(4, 12))).toNumber();
55 48
     this.headerLength = dataView.getUint32(12, false);
56 49
     this.bodyLength = dataView.getUint32(16, false);
57 50
 
58
-    const header = Utils.ab2str(
59
-      dataView.buffer.slice(20, 20 + this.headerLength),
60
-    );
51
+    const header = Utils.ab2str(dataView.buffer.slice(20, 20 + this.headerLength));
61 52
     const body = Utils.ab2str(dataView.buffer.slice(20 + this.headerLength));
62 53
 
63 54
     this.header = Utils.decrypt(header, this.key, this.key);

+ 1
- 0
packages/cts-api/src/types/node-int64.d.ts View File

@@ -0,0 +1 @@
1
+declare module 'node-int64';

+ 2
- 0
packages/cts-api/types.d.ts View File

@@ -12,3 +12,5 @@ declare module '*.svg' {
12 12
   const content: string;
13 13
   export default content;
14 14
 }
15
+
16
+declare module 'node-int64';