@rc-ex/ws 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src → lib/esm}/exceptions/ClosedException.js +1 -1
- package/lib/esm/exceptions/ClosedException.js.map +1 -0
- package/{src → lib/esm}/exceptions/ConnectionException.d.ts +1 -1
- package/{src → lib/esm}/exceptions/ConnectionException.js +4 -2
- package/lib/esm/exceptions/ConnectionException.js.map +1 -0
- package/{src → lib/esm}/exceptions/TimeoutException.js +1 -1
- package/lib/esm/exceptions/TimeoutException.js.map +1 -0
- package/{src → lib/esm}/index.d.ts +5 -5
- package/{src → lib/esm}/index.js +52 -47
- package/lib/esm/index.js.map +1 -0
- package/{src → lib/esm}/rest.d.ts +2 -2
- package/{src → lib/esm}/rest.js +5 -6
- package/lib/esm/rest.js.map +1 -0
- package/{src → lib/esm}/subscription.d.ts +3 -3
- package/{src → lib/esm}/subscription.js +8 -3
- package/lib/esm/subscription.js.map +1 -0
- package/{src → lib/esm}/types.d.ts +1 -1
- package/lib/esm/types.js.map +1 -0
- package/{src → lib/esm}/utils.d.ts +1 -1
- package/{src → lib/esm}/utils.js +4 -4
- package/lib/esm/utils.js.map +1 -0
- package/lib/exceptions/ClosedException.js +21 -4
- package/lib/exceptions/ClosedException.js.map +1 -1
- package/lib/exceptions/ConnectionException.d.ts +1 -1
- package/lib/exceptions/ConnectionException.js +27 -8
- package/lib/exceptions/ConnectionException.js.map +1 -1
- package/lib/exceptions/TimeoutException.js +21 -4
- package/lib/exceptions/TimeoutException.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +478 -292
- package/lib/index.js.map +1 -1
- package/lib/rest.d.ts +2 -2
- package/lib/rest.js +96 -47
- package/lib/rest.js.map +1 -1
- package/lib/subscription.d.ts +3 -3
- package/lib/subscription.js +150 -63
- package/lib/subscription.js.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +79 -35
- package/lib/utils.js.map +1 -1
- package/package.json +10 -6
- package/src/exceptions/ConnectionException.ts +2 -2
- package/src/index.ts +15 -12
- package/src/rest.ts +4 -4
- package/src/subscription.ts +9 -5
- package/src/types.ts +1 -1
- package/src/utils.ts +3 -3
- package/lib/exceptions/ClosedException.ts +0 -7
- package/lib/exceptions/ConnectionException.ts +0 -17
- package/lib/exceptions/TimeoutException.ts +0 -7
- package/lib/index.ts +0 -418
- package/lib/rest.ts +0 -71
- package/lib/subscription.ts +0 -131
- package/lib/types.ts +0 -85
- package/lib/utils.ts +0 -82
- package/src/exceptions/ClosedException.js.map +0 -1
- package/src/exceptions/ConnectionException.js.map +0 -1
- package/src/exceptions/TimeoutException.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/rest.js.map +0 -1
- package/src/subscription.js.map +0 -1
- package/src/types.js.map +0 -1
- package/src/utils.js.map +0 -1
- /package/{src → lib/esm}/exceptions/ClosedException.d.ts +0 -0
- /package/{src → lib/esm}/exceptions/TimeoutException.d.ts +0 -0
- /package/{src → lib/esm}/types.js +0 -0
package/lib/utils.js
CHANGED
|
@@ -1,62 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
42
|
+
var ClosedException_js_1 = __importDefault(require("./exceptions/ClosedException.js"));
|
|
43
|
+
var TimeoutException_js_1 = __importDefault(require("./exceptions/TimeoutException.js"));
|
|
44
|
+
var Utils = /** @class */ (function () {
|
|
45
|
+
function Utils() {
|
|
46
|
+
}
|
|
47
|
+
Utils.splitWsgData = function (wsgData) {
|
|
10
48
|
if (wsgData.includes(",--Boundary")) {
|
|
11
|
-
|
|
49
|
+
var index = wsgData.indexOf(",--Boundary");
|
|
12
50
|
return [
|
|
13
51
|
JSON.parse(wsgData.substring(1, index)),
|
|
14
52
|
wsgData.substring(index + 1, wsgData.length - 1),
|
|
15
53
|
];
|
|
16
54
|
}
|
|
17
55
|
return JSON.parse(wsgData);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
};
|
|
57
|
+
Utils.debugWebSocket = function (_ws) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
var ws = _ws;
|
|
60
|
+
var send = ws.send.bind(ws);
|
|
61
|
+
ws.send = function (str) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, send(str)];
|
|
65
|
+
case 1:
|
|
66
|
+
_a.sent();
|
|
67
|
+
console.debug("*** WebSocket outgoing message: ***\n".concat(JSON.stringify(JSON.parse(str), null, 2), "\n******"));
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); };
|
|
72
|
+
ws.addEventListener("message", function (mEvent) {
|
|
73
|
+
var event = mEvent;
|
|
74
|
+
console.debug("*** WebSocket incoming message: ***\n".concat(JSON.stringify(JSON.parse(event.data), null, 2), "\n******"));
|
|
33
75
|
});
|
|
34
|
-
ws.addEventListener("open", (event)
|
|
76
|
+
ws.addEventListener("open", function (event) {
|
|
35
77
|
console.debug("WebSocket open event:", event);
|
|
36
78
|
});
|
|
37
|
-
ws.addEventListener("error", (event)
|
|
79
|
+
ws.addEventListener("error", function (event) {
|
|
38
80
|
console.debug("WebSocket error event:", event);
|
|
39
81
|
});
|
|
40
|
-
ws.addEventListener("close", (event)
|
|
82
|
+
ws.addEventListener("close", function (event) {
|
|
41
83
|
console.debug("WebSocket close event:", event);
|
|
42
84
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
85
|
+
};
|
|
86
|
+
Utils.waitForWebSocketMessage = function (ws, matchCondition, timeout) {
|
|
87
|
+
if (timeout === void 0) { timeout = 60000; }
|
|
88
|
+
return new Promise(function (resolve, reject) {
|
|
89
|
+
var checkHandle = setInterval(function () {
|
|
47
90
|
if (ws.readyState === ws.CLOSED) {
|
|
48
91
|
clearInterval(checkHandle);
|
|
49
|
-
reject(new
|
|
92
|
+
reject(new ClosedException_js_1.default());
|
|
50
93
|
}
|
|
51
94
|
}, 1000);
|
|
52
|
-
|
|
95
|
+
var timeoutHandle = setTimeout(function () {
|
|
53
96
|
ws.removeEventListener("message", handler);
|
|
54
97
|
clearInterval(checkHandle);
|
|
55
|
-
reject(new
|
|
98
|
+
reject(new TimeoutException_js_1.default());
|
|
56
99
|
}, timeout);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
100
|
+
var handler = function (mEvent) {
|
|
101
|
+
var event = mEvent;
|
|
102
|
+
var _a = Utils.splitWsgData(event.data), meta = _a[0], body = _a[1];
|
|
60
103
|
if (matchCondition(meta)) {
|
|
61
104
|
ws.removeEventListener("message", handler);
|
|
62
105
|
clearInterval(checkHandle);
|
|
@@ -66,7 +109,8 @@ ${JSON.stringify(JSON.parse(event.data), null, 2)}
|
|
|
66
109
|
};
|
|
67
110
|
ws.addEventListener("message", handler);
|
|
68
111
|
});
|
|
69
|
-
}
|
|
70
|
-
|
|
112
|
+
};
|
|
113
|
+
return Utils;
|
|
114
|
+
}());
|
|
71
115
|
exports.default = Utils;
|
|
72
116
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-ex/ws",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "WebSocket extension for ringcentral-extensible project",
|
|
5
5
|
"author": "Tyler Liu <tyler.liu@ringcentral.com>",
|
|
6
6
|
"homepage": "https://github.com/ringcentral/ringcentral-extensible/tree/master/packages/extensions/ws",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"types": "./lib/esm/index.d.ts",
|
|
9
|
+
"main": "./lib/index.js",
|
|
10
|
+
"module": "./lib/esm/index.js",
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "git+https://github.com/ringcentral/ringcentral-extensible.git"
|
|
@@ -22,11 +23,14 @@
|
|
|
22
23
|
"http-status-codes": "^2.3.0",
|
|
23
24
|
"hyperid": "^3.3.0",
|
|
24
25
|
"isomorphic-ws": "^5.0.0",
|
|
25
|
-
"wait-for-async": "^0.7.
|
|
26
|
+
"wait-for-async": "^0.7.10",
|
|
26
27
|
"ws": "^8.18.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@rc-ex/core": "^1.
|
|
30
|
+
"@rc-ex/core": "^1.6.1"
|
|
30
31
|
},
|
|
31
|
-
"
|
|
32
|
+
"scripts": {
|
|
33
|
+
"rename-to-cjs": "find lib -type f -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "f87265ce907e6f36534ae49fadbe3e67f8d14340"
|
|
32
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WsgError, WsgEvent, WsgMeta } from "../types";
|
|
2
|
-
import Utils from "../utils";
|
|
1
|
+
import type { WsgError, WsgEvent, WsgMeta } from "../types.js";
|
|
2
|
+
import Utils from "../utils.js";
|
|
3
3
|
|
|
4
4
|
class ConnectionException extends Error {
|
|
5
5
|
public wsgEvent: WsgEvent;
|
package/src/index.ts
CHANGED
|
@@ -3,17 +3,17 @@ import type {
|
|
|
3
3
|
RestMethod,
|
|
4
4
|
RestRequestConfig,
|
|
5
5
|
RestResponse,
|
|
6
|
-
} from "@rc-ex/core/
|
|
7
|
-
import SdkExtension from "@rc-ex/core/
|
|
6
|
+
} from "@rc-ex/core/lib/esm/types.js";
|
|
7
|
+
import SdkExtension from "@rc-ex/core/lib/esm/SdkExtension.js";
|
|
8
8
|
import type { MessageEvent } from "isomorphic-ws";
|
|
9
9
|
import WS from "isomorphic-ws";
|
|
10
10
|
import hyperid from "hyperid";
|
|
11
11
|
import { EventEmitter } from "events";
|
|
12
12
|
import waitFor from "wait-for-async";
|
|
13
|
-
import RestException from "@rc-ex/core/
|
|
14
|
-
import type SubscriptionInfo from "@rc-ex/core/
|
|
13
|
+
import RestException from "@rc-ex/core/lib/esm/RestException.js";
|
|
14
|
+
import type SubscriptionInfo from "@rc-ex/core/lib/esm/definitions/SubscriptionInfo.js";
|
|
15
15
|
|
|
16
|
-
import { request } from "./rest";
|
|
16
|
+
import { request } from "./rest.js";
|
|
17
17
|
import type {
|
|
18
18
|
ConnectionDetails,
|
|
19
19
|
WebSocketExtensionInterface,
|
|
@@ -21,10 +21,10 @@ import type {
|
|
|
21
21
|
Wsc,
|
|
22
22
|
WsgEvent,
|
|
23
23
|
WsToken,
|
|
24
|
-
} from "./types";
|
|
25
|
-
import Subscription from "./subscription";
|
|
26
|
-
import ConnectionException from "./exceptions/ConnectionException";
|
|
27
|
-
import Utils from "./utils";
|
|
24
|
+
} from "./types.js";
|
|
25
|
+
import Subscription from "./subscription.js";
|
|
26
|
+
import ConnectionException from "./exceptions/ConnectionException.js";
|
|
27
|
+
import Utils from "./utils.js";
|
|
28
28
|
|
|
29
29
|
const CONNECTING = 0;
|
|
30
30
|
const OPEN = 1;
|
|
@@ -200,14 +200,17 @@ class WebSocketExtension extends SdkExtension {
|
|
|
200
200
|
);
|
|
201
201
|
|
|
202
202
|
// browser only code start
|
|
203
|
-
if (
|
|
204
|
-
window
|
|
203
|
+
if (
|
|
204
|
+
typeof globalThis.window !== "undefined" &&
|
|
205
|
+
globalThis.window.addEventListener
|
|
206
|
+
) {
|
|
207
|
+
globalThis.window.addEventListener("offline", () => {
|
|
205
208
|
if (this.pingServerHandle) {
|
|
206
209
|
clearTimeout(this.pingServerHandle);
|
|
207
210
|
}
|
|
208
211
|
this.ws?.close();
|
|
209
212
|
});
|
|
210
|
-
window.addEventListener("online", () => {
|
|
213
|
+
globalThis.window.addEventListener("online", () => {
|
|
211
214
|
check();
|
|
212
215
|
});
|
|
213
216
|
}
|
package/src/rest.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type {
|
|
|
2
2
|
RestMethod,
|
|
3
3
|
RestRequestConfig,
|
|
4
4
|
RestResponse,
|
|
5
|
-
} from "@rc-ex/core/
|
|
6
|
-
import RestException from "@rc-ex/core/
|
|
5
|
+
} from "@rc-ex/core/lib/esm/types.js";
|
|
6
|
+
import RestException from "@rc-ex/core/lib/esm/RestException.js";
|
|
7
7
|
import hyperid from "hyperid";
|
|
8
8
|
import { getReasonPhrase } from "http-status-codes";
|
|
9
9
|
|
|
10
|
-
import Utils from "./utils";
|
|
11
|
-
import type { WebSocketExtensionInterface } from "./types";
|
|
10
|
+
import Utils from "./utils.js";
|
|
11
|
+
import type { WebSocketExtensionInterface } from "./types.js";
|
|
12
12
|
|
|
13
13
|
const version = "0.16";
|
|
14
14
|
|
package/src/subscription.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type CreateSubscriptionRequest from "@rc-ex/core/
|
|
2
|
-
import type SubscriptionInfo from "@rc-ex/core/
|
|
3
|
-
import type { RestResponse } from "@rc-ex/core/
|
|
1
|
+
import type CreateSubscriptionRequest from "@rc-ex/core/lib/esm/definitions/CreateSubscriptionRequest.js";
|
|
2
|
+
import type SubscriptionInfo from "@rc-ex/core/lib/esm/definitions/SubscriptionInfo.js";
|
|
3
|
+
import type { RestResponse } from "@rc-ex/core/lib/esm/types.js";
|
|
4
4
|
import type { MessageEvent } from "ws";
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
WebSocketExtensionInterface,
|
|
8
|
+
WsgEvent,
|
|
9
|
+
WsgMeta,
|
|
10
|
+
} from "./types.js";
|
|
11
|
+
import Utils from "./utils.js";
|
|
8
12
|
|
|
9
13
|
class Subscription {
|
|
10
14
|
public subscriptionInfo?: SubscriptionInfo;
|
package/src/types.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MessageEvent } from "isomorphic-ws";
|
|
2
2
|
import type WS from "isomorphic-ws";
|
|
3
3
|
|
|
4
|
-
import type { WsgEvent, WsgMeta } from "./types";
|
|
5
|
-
import ClosedException from "./exceptions/ClosedException";
|
|
6
|
-
import TimeoutException from "./exceptions/TimeoutException";
|
|
4
|
+
import type { WsgEvent, WsgMeta } from "./types.js";
|
|
5
|
+
import ClosedException from "./exceptions/ClosedException.js";
|
|
6
|
+
import TimeoutException from "./exceptions/TimeoutException.js";
|
|
7
7
|
|
|
8
8
|
class Utils {
|
|
9
9
|
public static splitWsgData(wsgData: string): [WsgMeta, any] {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { WsgError, WsgEvent, WsgMeta } from "../types";
|
|
2
|
-
import Utils from "../utils";
|
|
3
|
-
|
|
4
|
-
class ConnectionException extends Error {
|
|
5
|
-
public wsgEvent: WsgEvent;
|
|
6
|
-
|
|
7
|
-
public wsgError: WsgError;
|
|
8
|
-
|
|
9
|
-
public constructor(wsgEvent: WsgEvent) {
|
|
10
|
-
const [, wsgError]: [WsgMeta, WsgError] = Utils.splitWsgData(wsgEvent.data);
|
|
11
|
-
super(JSON.stringify(wsgError, null, 2));
|
|
12
|
-
this.wsgEvent = wsgEvent;
|
|
13
|
-
this.wsgError = wsgError;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default ConnectionException;
|