wapi-client 0.8.4 → 0.8.13
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/dist/api/base-client.browser.cjs +3 -1
- package/dist/api/base-client.browser.js +3 -1
- package/dist/api/base-client.cjs +3 -1
- package/dist/api/base-client.d.ts +2 -1
- package/dist/api/base-client.js +3 -1
- package/dist/api/http-client.browser.cjs +11 -6
- package/dist/api/http-client.browser.js +11 -6
- package/dist/api/http-client.cjs +11 -6
- package/dist/api/http-client.js +11 -6
- package/dist/api/ws-client.browser.cjs +4 -3
- package/dist/api/ws-client.browser.js +4 -3
- package/dist/api/ws-client.cjs +5 -4
- package/dist/api/ws-client.js +5 -4
- package/dist/client.cjs +1 -1
- package/dist/client.js +1 -1
- package/dist/lib/debug.browser.cjs +5 -1
- package/dist/lib/debug.browser.js +5 -1
- package/dist/lib/debug.cjs +5 -1
- package/dist/lib/debug.js +5 -1
- package/dist/lib/isomorphic/web/streams.browser.cjs +3 -0
- package/dist/lib/isomorphic/web/streams.browser.js +3 -0
- package/dist/lib/stream-promise.browser.cjs +11 -1
- package/dist/lib/stream-promise.browser.js +11 -1
- package/dist/lib/stream-promise.cjs +11 -1
- package/dist/lib/stream-promise.js +11 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/wapi-client-web.iife.js +4 -4
- package/dist/wapi-client.iife.js +4 -4
- package/package.json +1 -1
|
@@ -192,7 +192,9 @@ var BaseClient = class {
|
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
stream.push(message);
|
|
195
|
-
stream.
|
|
195
|
+
if (!stream.destroyed) {
|
|
196
|
+
stream.push(null);
|
|
197
|
+
}
|
|
196
198
|
this._requests.delete(message.id);
|
|
197
199
|
if (this.connectionType === import__.WapiClientType.ws) {
|
|
198
200
|
this._send({
|
|
@@ -184,7 +184,9 @@ var BaseClient = class {
|
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
stream.push(message);
|
|
187
|
-
stream.
|
|
187
|
+
if (!stream.destroyed) {
|
|
188
|
+
stream.push(null);
|
|
189
|
+
}
|
|
188
190
|
this._requests.delete(message.id);
|
|
189
191
|
if (this.connectionType === WapiClientType.ws) {
|
|
190
192
|
this._send({
|
package/dist/api/base-client.cjs
CHANGED
|
@@ -192,7 +192,9 @@ var BaseClient = class {
|
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
stream.push(message);
|
|
195
|
-
stream.
|
|
195
|
+
if (!stream.destroyed) {
|
|
196
|
+
stream.push(null);
|
|
197
|
+
}
|
|
196
198
|
this._requests.delete(message.id);
|
|
197
199
|
if (this.connectionType === import__.WapiClientType.ws) {
|
|
198
200
|
this._send({
|
|
@@ -67,7 +67,8 @@ export declare class BaseClient {
|
|
|
67
67
|
_connection: WebSocket | HttpConnectionClient;
|
|
68
68
|
$connect: Promise<ISocketId> | Promise<undefined> | undefined;
|
|
69
69
|
connectionType: WapiClientType;
|
|
70
|
-
|
|
70
|
+
host: string;
|
|
71
|
+
protected jwt: string;
|
|
71
72
|
isConnected: boolean;
|
|
72
73
|
socId: undefined | string;
|
|
73
74
|
hooks: ClientHooks;
|
package/dist/api/base-client.js
CHANGED
|
@@ -184,7 +184,9 @@ var BaseClient = class {
|
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
stream.push(message);
|
|
187
|
-
stream.
|
|
187
|
+
if (!stream.destroyed) {
|
|
188
|
+
stream.push(null);
|
|
189
|
+
}
|
|
188
190
|
this._requests.delete(message.id);
|
|
189
191
|
if (this.connectionType === WapiClientType.ws) {
|
|
190
192
|
this._send({
|
|
@@ -72,19 +72,21 @@ function createHttpClient(opts) {
|
|
|
72
72
|
}
|
|
73
73
|
function createConnection(opts) {
|
|
74
74
|
const url = opts.host.replace(/^wss:/, "https:");
|
|
75
|
+
const REQ_HEADER_ID = "x-wapi-req-id";
|
|
75
76
|
function onmessage(body) {
|
|
76
77
|
return __async(this, null, function* () {
|
|
77
|
-
(0, import_debug.debugLog)(`http_createConnection>message(body:$
|
|
78
|
+
(0, import_debug.debugLog)(`http_createConnection>message(body:$0)`, body);
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
function send(body, jwt) {
|
|
81
82
|
return __async(this, null, function* () {
|
|
82
83
|
const jsonBody = JSON.parse(body);
|
|
83
|
-
const res = yield (0, import_fetch.fetch)(`${
|
|
84
|
+
const res = yield (0, import_fetch.fetch)(`${url}/api`, {
|
|
84
85
|
keepalive: true,
|
|
85
86
|
method: "POST",
|
|
86
87
|
headers: {
|
|
87
|
-
Authorization: `Bearer ${jwt}
|
|
88
|
+
Authorization: `Bearer ${jwt}`,
|
|
89
|
+
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
88
90
|
},
|
|
89
91
|
body
|
|
90
92
|
});
|
|
@@ -92,16 +94,18 @@ function createConnection(opts) {
|
|
|
92
94
|
this.onmessage(__spreadProps(__spreadValues({}, responseBody), { id: jsonBody.id }));
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
const connectId = (0, import_utils.getRandomHex)();
|
|
95
98
|
const $connect = (0, import_fetch.fetch)(`${url}/api`, {
|
|
96
99
|
method: "POST",
|
|
97
100
|
headers: {
|
|
98
|
-
Authorization: `Bearer ${opts.jwt}
|
|
101
|
+
Authorization: `Bearer ${opts.jwt}`,
|
|
102
|
+
[REQ_HEADER_ID]: connectId
|
|
99
103
|
},
|
|
100
104
|
body: JSON.stringify({
|
|
101
105
|
jsonrpc: import_jsonrpc.JSONRPC.version,
|
|
102
106
|
method: "authenticationCheck",
|
|
103
107
|
params: {},
|
|
104
|
-
id:
|
|
108
|
+
id: connectId
|
|
105
109
|
})
|
|
106
110
|
}).then((res) => res.json()).then((res) => {
|
|
107
111
|
if (res.error) {
|
|
@@ -118,6 +122,7 @@ function createConnection(opts) {
|
|
|
118
122
|
var HttpClient = class extends import_base_client.BaseClient {
|
|
119
123
|
constructor(connection, opts) {
|
|
120
124
|
super(connection, import__.WapiClientType.https, connection.$connect);
|
|
125
|
+
this.host = opts.host;
|
|
121
126
|
this.jwt = opts.jwt;
|
|
122
127
|
this.$connect.then(() => {
|
|
123
128
|
this._ready();
|
|
@@ -132,7 +137,7 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
132
137
|
_ready() {
|
|
133
138
|
this._setConnected(true);
|
|
134
139
|
this._connection.onmessage = (body) => __async(this, null, function* () {
|
|
135
|
-
(0, import_debug.debugLog)(`http_message(
|
|
140
|
+
(0, import_debug.debugLog)(`http_message($0)>`, body);
|
|
136
141
|
this._handleMessage(body);
|
|
137
142
|
});
|
|
138
143
|
}
|
|
@@ -53,19 +53,21 @@ function createHttpClient(opts) {
|
|
|
53
53
|
}
|
|
54
54
|
function createConnection(opts) {
|
|
55
55
|
const url = opts.host.replace(/^wss:/, "https:");
|
|
56
|
+
const REQ_HEADER_ID = "x-wapi-req-id";
|
|
56
57
|
function onmessage(body) {
|
|
57
58
|
return __async(this, null, function* () {
|
|
58
|
-
debugLog(`http_createConnection>message(body:$
|
|
59
|
+
debugLog(`http_createConnection>message(body:$0)`, body);
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
function send(body, jwt) {
|
|
62
63
|
return __async(this, null, function* () {
|
|
63
64
|
const jsonBody = JSON.parse(body);
|
|
64
|
-
const res = yield fetch(`${
|
|
65
|
+
const res = yield fetch(`${url}/api`, {
|
|
65
66
|
keepalive: true,
|
|
66
67
|
method: "POST",
|
|
67
68
|
headers: {
|
|
68
|
-
Authorization: `Bearer ${jwt}
|
|
69
|
+
Authorization: `Bearer ${jwt}`,
|
|
70
|
+
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
69
71
|
},
|
|
70
72
|
body
|
|
71
73
|
});
|
|
@@ -73,16 +75,18 @@ function createConnection(opts) {
|
|
|
73
75
|
this.onmessage(__spreadProps(__spreadValues({}, responseBody), { id: jsonBody.id }));
|
|
74
76
|
});
|
|
75
77
|
}
|
|
78
|
+
const connectId = getRandomHex();
|
|
76
79
|
const $connect = fetch(`${url}/api`, {
|
|
77
80
|
method: "POST",
|
|
78
81
|
headers: {
|
|
79
|
-
Authorization: `Bearer ${opts.jwt}
|
|
82
|
+
Authorization: `Bearer ${opts.jwt}`,
|
|
83
|
+
[REQ_HEADER_ID]: connectId
|
|
80
84
|
},
|
|
81
85
|
body: JSON.stringify({
|
|
82
86
|
jsonrpc: JSONRPC.version,
|
|
83
87
|
method: "authenticationCheck",
|
|
84
88
|
params: {},
|
|
85
|
-
id:
|
|
89
|
+
id: connectId
|
|
86
90
|
})
|
|
87
91
|
}).then((res) => res.json()).then((res) => {
|
|
88
92
|
if (res.error) {
|
|
@@ -99,6 +103,7 @@ function createConnection(opts) {
|
|
|
99
103
|
var HttpClient = class extends BaseClient {
|
|
100
104
|
constructor(connection, opts) {
|
|
101
105
|
super(connection, WapiClientType.https, connection.$connect);
|
|
106
|
+
this.host = opts.host;
|
|
102
107
|
this.jwt = opts.jwt;
|
|
103
108
|
this.$connect.then(() => {
|
|
104
109
|
this._ready();
|
|
@@ -113,7 +118,7 @@ var HttpClient = class extends BaseClient {
|
|
|
113
118
|
_ready() {
|
|
114
119
|
this._setConnected(true);
|
|
115
120
|
this._connection.onmessage = (body) => __async(this, null, function* () {
|
|
116
|
-
debugLog(`http_message(
|
|
121
|
+
debugLog(`http_message($0)>`, body);
|
|
117
122
|
this._handleMessage(body);
|
|
118
123
|
});
|
|
119
124
|
}
|
package/dist/api/http-client.cjs
CHANGED
|
@@ -72,19 +72,21 @@ function createHttpClient(opts) {
|
|
|
72
72
|
}
|
|
73
73
|
function createConnection(opts) {
|
|
74
74
|
const url = opts.host.replace(/^wss:/, "https:");
|
|
75
|
+
const REQ_HEADER_ID = "x-wapi-req-id";
|
|
75
76
|
function onmessage(body) {
|
|
76
77
|
return __async(this, null, function* () {
|
|
77
|
-
(0, import_debug.debugLog)(`http_createConnection>message(body:$
|
|
78
|
+
(0, import_debug.debugLog)(`http_createConnection>message(body:$0)`, body);
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
function send(body, jwt) {
|
|
81
82
|
return __async(this, null, function* () {
|
|
82
83
|
const jsonBody = JSON.parse(body);
|
|
83
|
-
const res = yield (0, import_fetch.fetch)(`${
|
|
84
|
+
const res = yield (0, import_fetch.fetch)(`${url}/api`, {
|
|
84
85
|
keepalive: true,
|
|
85
86
|
method: "POST",
|
|
86
87
|
headers: {
|
|
87
|
-
Authorization: `Bearer ${jwt}
|
|
88
|
+
Authorization: `Bearer ${jwt}`,
|
|
89
|
+
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
88
90
|
},
|
|
89
91
|
body
|
|
90
92
|
});
|
|
@@ -92,16 +94,18 @@ function createConnection(opts) {
|
|
|
92
94
|
this.onmessage(__spreadProps(__spreadValues({}, responseBody), { id: jsonBody.id }));
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
const connectId = (0, import_utils.getRandomHex)();
|
|
95
98
|
const $connect = (0, import_fetch.fetch)(`${url}/api`, {
|
|
96
99
|
method: "POST",
|
|
97
100
|
headers: {
|
|
98
|
-
Authorization: `Bearer ${opts.jwt}
|
|
101
|
+
Authorization: `Bearer ${opts.jwt}`,
|
|
102
|
+
[REQ_HEADER_ID]: connectId
|
|
99
103
|
},
|
|
100
104
|
body: JSON.stringify({
|
|
101
105
|
jsonrpc: import_jsonrpc.JSONRPC.version,
|
|
102
106
|
method: "authenticationCheck",
|
|
103
107
|
params: {},
|
|
104
|
-
id:
|
|
108
|
+
id: connectId
|
|
105
109
|
})
|
|
106
110
|
}).then((res) => res.json()).then((res) => {
|
|
107
111
|
if (res.error) {
|
|
@@ -118,6 +122,7 @@ function createConnection(opts) {
|
|
|
118
122
|
var HttpClient = class extends import_base_client.BaseClient {
|
|
119
123
|
constructor(connection, opts) {
|
|
120
124
|
super(connection, import__.WapiClientType.https, connection.$connect);
|
|
125
|
+
this.host = opts.host;
|
|
121
126
|
this.jwt = opts.jwt;
|
|
122
127
|
this.$connect.then(() => {
|
|
123
128
|
this._ready();
|
|
@@ -132,7 +137,7 @@ var HttpClient = class extends import_base_client.BaseClient {
|
|
|
132
137
|
_ready() {
|
|
133
138
|
this._setConnected(true);
|
|
134
139
|
this._connection.onmessage = (body) => __async(this, null, function* () {
|
|
135
|
-
(0, import_debug.debugLog)(`http_message(
|
|
140
|
+
(0, import_debug.debugLog)(`http_message($0)>`, body);
|
|
136
141
|
this._handleMessage(body);
|
|
137
142
|
});
|
|
138
143
|
}
|
package/dist/api/http-client.js
CHANGED
|
@@ -53,19 +53,21 @@ function createHttpClient(opts) {
|
|
|
53
53
|
}
|
|
54
54
|
function createConnection(opts) {
|
|
55
55
|
const url = opts.host.replace(/^wss:/, "https:");
|
|
56
|
+
const REQ_HEADER_ID = "x-wapi-req-id";
|
|
56
57
|
function onmessage(body) {
|
|
57
58
|
return __async(this, null, function* () {
|
|
58
|
-
debugLog(`http_createConnection>message(body:$
|
|
59
|
+
debugLog(`http_createConnection>message(body:$0)`, body);
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
function send(body, jwt) {
|
|
62
63
|
return __async(this, null, function* () {
|
|
63
64
|
const jsonBody = JSON.parse(body);
|
|
64
|
-
const res = yield fetch(`${
|
|
65
|
+
const res = yield fetch(`${url}/api`, {
|
|
65
66
|
keepalive: true,
|
|
66
67
|
method: "POST",
|
|
67
68
|
headers: {
|
|
68
|
-
Authorization: `Bearer ${jwt}
|
|
69
|
+
Authorization: `Bearer ${jwt}`,
|
|
70
|
+
[REQ_HEADER_ID]: jsonBody == null ? void 0 : jsonBody.id
|
|
69
71
|
},
|
|
70
72
|
body
|
|
71
73
|
});
|
|
@@ -73,16 +75,18 @@ function createConnection(opts) {
|
|
|
73
75
|
this.onmessage(__spreadProps(__spreadValues({}, responseBody), { id: jsonBody.id }));
|
|
74
76
|
});
|
|
75
77
|
}
|
|
78
|
+
const connectId = getRandomHex();
|
|
76
79
|
const $connect = fetch(`${url}/api`, {
|
|
77
80
|
method: "POST",
|
|
78
81
|
headers: {
|
|
79
|
-
Authorization: `Bearer ${opts.jwt}
|
|
82
|
+
Authorization: `Bearer ${opts.jwt}`,
|
|
83
|
+
[REQ_HEADER_ID]: connectId
|
|
80
84
|
},
|
|
81
85
|
body: JSON.stringify({
|
|
82
86
|
jsonrpc: JSONRPC.version,
|
|
83
87
|
method: "authenticationCheck",
|
|
84
88
|
params: {},
|
|
85
|
-
id:
|
|
89
|
+
id: connectId
|
|
86
90
|
})
|
|
87
91
|
}).then((res) => res.json()).then((res) => {
|
|
88
92
|
if (res.error) {
|
|
@@ -99,6 +103,7 @@ function createConnection(opts) {
|
|
|
99
103
|
var HttpClient = class extends BaseClient {
|
|
100
104
|
constructor(connection, opts) {
|
|
101
105
|
super(connection, WapiClientType.https, connection.$connect);
|
|
106
|
+
this.host = opts.host;
|
|
102
107
|
this.jwt = opts.jwt;
|
|
103
108
|
this.$connect.then(() => {
|
|
104
109
|
this._ready();
|
|
@@ -113,7 +118,7 @@ var HttpClient = class extends BaseClient {
|
|
|
113
118
|
_ready() {
|
|
114
119
|
this._setConnected(true);
|
|
115
120
|
this._connection.onmessage = (body) => __async(this, null, function* () {
|
|
116
|
-
debugLog(`http_message(
|
|
121
|
+
debugLog(`http_message($0)>`, body);
|
|
117
122
|
this._handleMessage(body);
|
|
118
123
|
});
|
|
119
124
|
}
|
|
@@ -143,6 +143,7 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
143
143
|
super(initial.ws, import__.WapiClientType.ws, initial.$connect);
|
|
144
144
|
this._tryToReconnect = true;
|
|
145
145
|
this._config = config;
|
|
146
|
+
this.host = config.host;
|
|
146
147
|
this.$connect.then((_id) => {
|
|
147
148
|
this.socId = _id;
|
|
148
149
|
return this._ready();
|
|
@@ -166,7 +167,7 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
166
167
|
this._setConnected(true);
|
|
167
168
|
this._connection.onmessage = (event) => {
|
|
168
169
|
const { data, type } = event;
|
|
169
|
-
(0, import_debug.debugLog)(`message(type:${type},data:$
|
|
170
|
+
(0, import_debug.debugLog)(`message(type:${type},data:$0)`, data);
|
|
170
171
|
if (type === "message") {
|
|
171
172
|
const obj = JSON.parse(data.toString());
|
|
172
173
|
this._handleMessage(obj);
|
|
@@ -175,11 +176,11 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
175
176
|
};
|
|
176
177
|
this._connection.onerror = (event) => {
|
|
177
178
|
const { message, error, type } = event;
|
|
178
|
-
(0, import_debug.debugLog)(`error(message:$
|
|
179
|
+
(0, import_debug.debugLog)(`error(message:$0,error:$1,type:${type})`, message, error);
|
|
179
180
|
};
|
|
180
181
|
this._connection.onclose = (event) => {
|
|
181
182
|
const { reason, code, wasClean } = event;
|
|
182
|
-
(0, import_debug.debugLog)(`close(reason:$
|
|
183
|
+
(0, import_debug.debugLog)(`close(reason:$0,code:${code},wasClean:${wasClean})`, reason);
|
|
183
184
|
this._setConnected(false);
|
|
184
185
|
clearTimeout(this._pingTimeout);
|
|
185
186
|
this._connectionLost();
|
|
@@ -125,6 +125,7 @@ var WsClient = class extends BaseClient {
|
|
|
125
125
|
super(initial.ws, WapiClientType.ws, initial.$connect);
|
|
126
126
|
this._tryToReconnect = true;
|
|
127
127
|
this._config = config;
|
|
128
|
+
this.host = config.host;
|
|
128
129
|
this.$connect.then((_id) => {
|
|
129
130
|
this.socId = _id;
|
|
130
131
|
return this._ready();
|
|
@@ -148,7 +149,7 @@ var WsClient = class extends BaseClient {
|
|
|
148
149
|
this._setConnected(true);
|
|
149
150
|
this._connection.onmessage = (event) => {
|
|
150
151
|
const { data, type } = event;
|
|
151
|
-
debugLog(`message(type:${type},data:$
|
|
152
|
+
debugLog(`message(type:${type},data:$0)`, data);
|
|
152
153
|
if (type === "message") {
|
|
153
154
|
const obj = JSON.parse(data.toString());
|
|
154
155
|
this._handleMessage(obj);
|
|
@@ -157,11 +158,11 @@ var WsClient = class extends BaseClient {
|
|
|
157
158
|
};
|
|
158
159
|
this._connection.onerror = (event) => {
|
|
159
160
|
const { message, error, type } = event;
|
|
160
|
-
debugLog(`error(message:$
|
|
161
|
+
debugLog(`error(message:$0,error:$1,type:${type})`, message, error);
|
|
161
162
|
};
|
|
162
163
|
this._connection.onclose = (event) => {
|
|
163
164
|
const { reason, code, wasClean } = event;
|
|
164
|
-
debugLog(`close(reason:$
|
|
165
|
+
debugLog(`close(reason:$0,code:${code},wasClean:${wasClean})`, reason);
|
|
165
166
|
this._setConnected(false);
|
|
166
167
|
clearTimeout(this._pingTimeout);
|
|
167
168
|
this._connectionLost();
|
package/dist/api/ws-client.cjs
CHANGED
|
@@ -61,7 +61,7 @@ var import_base_client = require('./base-client.cjs');
|
|
|
61
61
|
var import_connection = require('./connection/connection.enums.cjs');
|
|
62
62
|
var import__ = require('../index.cjs');
|
|
63
63
|
var _a;
|
|
64
|
-
var CLIENT_VERSION = (_a = '0.8.
|
|
64
|
+
var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
|
|
65
65
|
function createWsClient(opts) {
|
|
66
66
|
const initialConnection = createConnection(opts);
|
|
67
67
|
return new WsClient(initialConnection, opts);
|
|
@@ -149,6 +149,7 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
149
149
|
super(initial.ws, import__.WapiClientType.ws, initial.$connect);
|
|
150
150
|
this._tryToReconnect = true;
|
|
151
151
|
this._config = config;
|
|
152
|
+
this.host = config.host;
|
|
152
153
|
this.$connect.then((_id) => {
|
|
153
154
|
this.socId = _id;
|
|
154
155
|
return this._ready();
|
|
@@ -172,7 +173,7 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
172
173
|
this._setConnected(true);
|
|
173
174
|
this._connection.onmessage = (event) => {
|
|
174
175
|
const { data, type } = event;
|
|
175
|
-
(0, import_debug.debugLog)(`message(type:${type},data:$
|
|
176
|
+
(0, import_debug.debugLog)(`message(type:${type},data:$0)`, data);
|
|
176
177
|
if (type === "message") {
|
|
177
178
|
const obj = JSON.parse(data.toString());
|
|
178
179
|
this._handleMessage(obj);
|
|
@@ -181,11 +182,11 @@ var WsClient = class extends import_base_client.BaseClient {
|
|
|
181
182
|
};
|
|
182
183
|
this._connection.onerror = (event) => {
|
|
183
184
|
const { message, error, type } = event;
|
|
184
|
-
(0, import_debug.debugLog)(`error(message:$
|
|
185
|
+
(0, import_debug.debugLog)(`error(message:$0,error:$1,type:${type})`, message, error);
|
|
185
186
|
};
|
|
186
187
|
this._connection.onclose = (event) => {
|
|
187
188
|
const { reason, code, wasClean } = event;
|
|
188
|
-
(0, import_debug.debugLog)(`close(reason:$
|
|
189
|
+
(0, import_debug.debugLog)(`close(reason:$0,code:${code},wasClean:${wasClean})`, reason);
|
|
189
190
|
this._setConnected(false);
|
|
190
191
|
clearTimeout(this._pingTimeout);
|
|
191
192
|
this._connectionLost();
|
package/dist/api/ws-client.js
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./connection/connection.enums";
|
|
36
36
|
import { WapiClientType } from "../index";
|
|
37
37
|
var _a;
|
|
38
|
-
var CLIENT_VERSION = (_a = '0.8.
|
|
38
|
+
var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
|
|
39
39
|
function createWsClient(opts) {
|
|
40
40
|
const initialConnection = createConnection(opts);
|
|
41
41
|
return new WsClient(initialConnection, opts);
|
|
@@ -123,6 +123,7 @@ var WsClient = class extends BaseClient {
|
|
|
123
123
|
super(initial.ws, WapiClientType.ws, initial.$connect);
|
|
124
124
|
this._tryToReconnect = true;
|
|
125
125
|
this._config = config;
|
|
126
|
+
this.host = config.host;
|
|
126
127
|
this.$connect.then((_id) => {
|
|
127
128
|
this.socId = _id;
|
|
128
129
|
return this._ready();
|
|
@@ -146,7 +147,7 @@ var WsClient = class extends BaseClient {
|
|
|
146
147
|
this._setConnected(true);
|
|
147
148
|
this._connection.onmessage = (event) => {
|
|
148
149
|
const { data, type } = event;
|
|
149
|
-
debugLog(`message(type:${type},data:$
|
|
150
|
+
debugLog(`message(type:${type},data:$0)`, data);
|
|
150
151
|
if (type === "message") {
|
|
151
152
|
const obj = JSON.parse(data.toString());
|
|
152
153
|
this._handleMessage(obj);
|
|
@@ -155,11 +156,11 @@ var WsClient = class extends BaseClient {
|
|
|
155
156
|
};
|
|
156
157
|
this._connection.onerror = (event) => {
|
|
157
158
|
const { message, error, type } = event;
|
|
158
|
-
debugLog(`error(message:$
|
|
159
|
+
debugLog(`error(message:$0,error:$1,type:${type})`, message, error);
|
|
159
160
|
};
|
|
160
161
|
this._connection.onclose = (event) => {
|
|
161
162
|
const { reason, code, wasClean } = event;
|
|
162
|
-
debugLog(`close(reason:$
|
|
163
|
+
debugLog(`close(reason:$0,code:${code},wasClean:${wasClean})`, reason);
|
|
163
164
|
this._setConnected(false);
|
|
164
165
|
clearTimeout(this._pingTimeout);
|
|
165
166
|
this._connectionLost();
|
package/dist/client.cjs
CHANGED
|
@@ -66,7 +66,7 @@ var import_errors = require('./lib/errors.cjs');
|
|
|
66
66
|
var import_fns = require('./fns/index.cjs');
|
|
67
67
|
var import_import_data = require('./fns/import-data/import-data.guards.cjs');
|
|
68
68
|
var _a;
|
|
69
|
-
var CLIENT_VERSION = (_a = '0.8.
|
|
69
|
+
var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
|
|
70
70
|
var Client = class {
|
|
71
71
|
/**
|
|
72
72
|
* @internal
|
package/dist/client.js
CHANGED
|
@@ -24,6 +24,10 @@ __export(debug_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(debug_exports);
|
|
25
25
|
function debugLog(...args) {
|
|
26
26
|
if (window.WAPI_DEBUG) {
|
|
27
|
-
console.log(
|
|
27
|
+
console.log(
|
|
28
|
+
...args.map(
|
|
29
|
+
(arg) => arg && typeof arg === "object" ? JSON.stringify(arg) : arg
|
|
30
|
+
)
|
|
31
|
+
);
|
|
28
32
|
}
|
|
29
33
|
}
|
package/dist/lib/debug.cjs
CHANGED
|
@@ -24,7 +24,11 @@ __export(debug_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(debug_exports);
|
|
25
25
|
function debugLog(...args) {
|
|
26
26
|
if (process.env.WAPI_DEBUG) {
|
|
27
|
-
console.log(
|
|
27
|
+
console.log(
|
|
28
|
+
...args.map(
|
|
29
|
+
(arg) => arg && typeof arg === "object" ? JSON.stringify(arg) : arg
|
|
30
|
+
)
|
|
31
|
+
);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/lib/debug.js
CHANGED
|
@@ -42,6 +42,7 @@ module.exports = __toCommonJS(stream_promise_exports);
|
|
|
42
42
|
var import_errors = require('./errors.cjs');
|
|
43
43
|
var import_jsonrpc = require('../api/jsonrpc/jsonrpc.enums.cjs');
|
|
44
44
|
var import_streams = require('./isomorphic/web/streams.cjs');
|
|
45
|
+
var import_debug = require('./debug.cjs');
|
|
45
46
|
var StreamPromise = class {
|
|
46
47
|
constructor(makeRequest) {
|
|
47
48
|
this.streamObject = new import_streams.ReadStream({
|
|
@@ -54,6 +55,7 @@ var StreamPromise = class {
|
|
|
54
55
|
this.makeRequest = makeRequest;
|
|
55
56
|
}
|
|
56
57
|
start(asMode) {
|
|
58
|
+
(0, import_debug.debugLog)("start request as", asMode);
|
|
57
59
|
if (this.mode && this.mode !== asMode) {
|
|
58
60
|
throw new Error("Already in use as " + this.mode);
|
|
59
61
|
}
|
|
@@ -77,6 +79,7 @@ var StreamPromise = class {
|
|
|
77
79
|
this.streamObject.on(
|
|
78
80
|
"data",
|
|
79
81
|
(chunk) => {
|
|
82
|
+
(0, import_debug.debugLog)("stream data", chunk);
|
|
80
83
|
if (!chunk) {
|
|
81
84
|
this.outStreamObject.push(chunk);
|
|
82
85
|
}
|
|
@@ -102,6 +105,7 @@ var StreamPromise = class {
|
|
|
102
105
|
this.outStreamObject.push(chunk);
|
|
103
106
|
}
|
|
104
107
|
).on("end", () => {
|
|
108
|
+
(0, import_debug.debugLog)("stream ended");
|
|
105
109
|
const lastMessage = internalArr.pop();
|
|
106
110
|
if (!lastMessage) {
|
|
107
111
|
return;
|
|
@@ -123,6 +127,7 @@ var StreamPromise = class {
|
|
|
123
127
|
this.outStreamObject.push(lastMessage);
|
|
124
128
|
this.outStreamObject.push(null);
|
|
125
129
|
}).on("error", (err) => {
|
|
130
|
+
(0, import_debug.debugLog)("stream error", err);
|
|
126
131
|
this.outStreamObject.destroy(err);
|
|
127
132
|
});
|
|
128
133
|
return;
|
|
@@ -133,6 +138,7 @@ var StreamPromise = class {
|
|
|
133
138
|
"data",
|
|
134
139
|
(chunk) => {
|
|
135
140
|
var _a;
|
|
141
|
+
(0, import_debug.debugLog)("streamPromise data", chunk);
|
|
136
142
|
if (chunk === void 0) {
|
|
137
143
|
return;
|
|
138
144
|
}
|
|
@@ -153,6 +159,7 @@ var StreamPromise = class {
|
|
|
153
159
|
internalMap.set(chunk.prop, arr);
|
|
154
160
|
}
|
|
155
161
|
).on("end", () => {
|
|
162
|
+
(0, import_debug.debugLog)("streamPromise end");
|
|
156
163
|
const lastMessage = internalArr.pop();
|
|
157
164
|
if (!lastMessage) {
|
|
158
165
|
return;
|
|
@@ -186,7 +193,10 @@ var StreamPromise = class {
|
|
|
186
193
|
result
|
|
187
194
|
);
|
|
188
195
|
}
|
|
189
|
-
}).on("error",
|
|
196
|
+
}).on("error", (reason) => {
|
|
197
|
+
(0, import_debug.debugLog)("streamPromise error", reason);
|
|
198
|
+
return this.reject(reason);
|
|
199
|
+
});
|
|
190
200
|
}
|
|
191
201
|
}
|
|
192
202
|
then(onfulfilled, onrejected) {
|