request-iframe 0.0.2 → 0.0.4
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/QUICKSTART.CN.md +35 -8
- package/QUICKSTART.md +35 -8
- package/README.CN.md +439 -36
- package/README.md +496 -30
- package/library/__tests__/channel.test.ts +420 -0
- package/library/__tests__/coverage-branches.test.ts +356 -0
- package/library/__tests__/debug.test.ts +588 -0
- package/library/__tests__/dispatcher.test.ts +481 -0
- package/library/__tests__/requestIframe.test.ts +3163 -185
- package/library/__tests__/server.test.ts +738 -0
- package/library/__tests__/stream.test.ts +46 -15
- package/library/api/client.d.ts.map +1 -1
- package/library/api/client.js +12 -6
- package/library/api/server.d.ts +4 -3
- package/library/api/server.d.ts.map +1 -1
- package/library/api/server.js +25 -7
- package/library/constants/index.d.ts +14 -4
- package/library/constants/index.d.ts.map +1 -1
- package/library/constants/index.js +15 -7
- package/library/constants/messages.d.ts +37 -0
- package/library/constants/messages.d.ts.map +1 -1
- package/library/constants/messages.js +38 -1
- package/library/core/client-server.d.ts +105 -0
- package/library/core/client-server.d.ts.map +1 -0
- package/library/core/client-server.js +289 -0
- package/library/core/client.d.ts +53 -10
- package/library/core/client.d.ts.map +1 -1
- package/library/core/client.js +529 -207
- package/library/core/request.d.ts +3 -1
- package/library/core/request.d.ts.map +1 -1
- package/library/core/request.js +2 -1
- package/library/core/response.d.ts +30 -4
- package/library/core/response.d.ts.map +1 -1
- package/library/core/response.js +176 -100
- package/library/core/server-client.d.ts +3 -1
- package/library/core/server-client.d.ts.map +1 -1
- package/library/core/server-client.js +19 -9
- package/library/core/server.d.ts +22 -1
- package/library/core/server.d.ts.map +1 -1
- package/library/core/server.js +304 -55
- package/library/index.d.ts +3 -2
- package/library/index.d.ts.map +1 -1
- package/library/index.js +34 -5
- package/library/interceptors/index.d.ts.map +1 -1
- package/library/message/channel.d.ts +3 -1
- package/library/message/channel.d.ts.map +1 -1
- package/library/message/dispatcher.d.ts +7 -2
- package/library/message/dispatcher.d.ts.map +1 -1
- package/library/message/dispatcher.js +48 -2
- package/library/message/index.d.ts.map +1 -1
- package/library/stream/file-stream.d.ts +5 -0
- package/library/stream/file-stream.d.ts.map +1 -1
- package/library/stream/file-stream.js +41 -12
- package/library/stream/index.d.ts +11 -1
- package/library/stream/index.d.ts.map +1 -1
- package/library/stream/index.js +21 -3
- package/library/stream/readable-stream.d.ts.map +1 -1
- package/library/stream/readable-stream.js +32 -30
- package/library/stream/types.d.ts +20 -2
- package/library/stream/types.d.ts.map +1 -1
- package/library/stream/writable-stream.d.ts +2 -1
- package/library/stream/writable-stream.d.ts.map +1 -1
- package/library/stream/writable-stream.js +13 -10
- package/library/types/index.d.ts +106 -32
- package/library/types/index.d.ts.map +1 -1
- package/library/utils/cache.d.ts +24 -0
- package/library/utils/cache.d.ts.map +1 -1
- package/library/utils/cache.js +76 -0
- package/library/utils/cookie.d.ts.map +1 -1
- package/library/utils/debug.d.ts.map +1 -1
- package/library/utils/debug.js +382 -20
- package/library/utils/index.d.ts +19 -0
- package/library/utils/index.d.ts.map +1 -1
- package/library/utils/index.js +113 -2
- package/library/utils/path-match.d.ts +16 -0
- package/library/utils/path-match.d.ts.map +1 -1
- package/library/utils/path-match.js +65 -0
- package/library/utils/protocol.d.ts.map +1 -1
- package/package.json +4 -1
- package/react/library/__tests__/index.test.tsx +274 -281
- package/react/library/index.d.ts +4 -3
- package/react/library/index.d.ts.map +1 -1
- package/react/library/index.js +225 -158
- package/react/package.json +7 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.RequestIframeClientServer = void 0;
|
|
8
|
+
require("core-js/modules/es.array.iterator.js");
|
|
9
|
+
require("core-js/modules/es.map.js");
|
|
10
|
+
require("core-js/modules/es.set.js");
|
|
11
|
+
require("core-js/modules/es.string.starts-with.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _message = require("../message");
|
|
16
|
+
var _cache = require("../utils/cache");
|
|
17
|
+
var _utils = require("../utils");
|
|
18
|
+
var _constants = require("../constants");
|
|
19
|
+
/**
|
|
20
|
+
* Stream message handler callback
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Pending acknowledgment response
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Pending request awaiting response
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ClientServer configuration options
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* RequestIframeClientServer - Client-side message server
|
|
37
|
+
* Only handles responses, not requests
|
|
38
|
+
* Uses shared MessageDispatcher (backed by MessageChannel) to listen for and send messages
|
|
39
|
+
*/
|
|
40
|
+
class RequestIframeClientServer {
|
|
41
|
+
constructor(options, instanceId) {
|
|
42
|
+
var _options$ackTimeout, _options$versionValid;
|
|
43
|
+
/** Pending responses awaiting client acknowledgment */
|
|
44
|
+
(0, _defineProperty2.default)(this, "pendingAcks", new Map());
|
|
45
|
+
/** Pending requests awaiting response */
|
|
46
|
+
(0, _defineProperty2.default)(this, "pendingRequests", new Map());
|
|
47
|
+
/**
|
|
48
|
+
* Avoid spamming logs for the same requestId when closed/destroyed
|
|
49
|
+
*/
|
|
50
|
+
(0, _defineProperty2.default)(this, "warnedMissingPendingWhenClosed", new Set());
|
|
51
|
+
/** List of unregister handler functions */
|
|
52
|
+
(0, _defineProperty2.default)(this, "unregisterFns", []);
|
|
53
|
+
/** Whether opened */
|
|
54
|
+
(0, _defineProperty2.default)(this, "_isOpen", false);
|
|
55
|
+
this.ackTimeout = (_options$ackTimeout = options === null || options === void 0 ? void 0 : options.ackTimeout) !== null && _options$ackTimeout !== void 0 ? _options$ackTimeout : _constants.DefaultTimeout.ACK;
|
|
56
|
+
this.versionValidator = (_options$versionValid = options === null || options === void 0 ? void 0 : options.versionValidator) !== null && _options$versionValid !== void 0 ? _options$versionValid : _utils.isCompatibleVersion;
|
|
57
|
+
|
|
58
|
+
// Get or create shared channel and create dispatcher
|
|
59
|
+
var channel = (0, _cache.getOrCreateMessageChannel)(options === null || options === void 0 ? void 0 : options.secretKey);
|
|
60
|
+
this.dispatcher = new _message.MessageDispatcher(channel, _constants.MessageRole.CLIENT, instanceId);
|
|
61
|
+
|
|
62
|
+
// Auto-open by default (unless explicitly set to false)
|
|
63
|
+
if ((options === null || options === void 0 ? void 0 : options.autoOpen) !== false) {
|
|
64
|
+
this.open();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Open message handling (register message handlers)
|
|
70
|
+
*/
|
|
71
|
+
open() {
|
|
72
|
+
if (this._isOpen) return;
|
|
73
|
+
this._isOpen = true;
|
|
74
|
+
this.registerHandlers();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Close message handling (unregister message handlers, but don't release channel)
|
|
79
|
+
*/
|
|
80
|
+
close() {
|
|
81
|
+
if (!this._isOpen) return;
|
|
82
|
+
this._isOpen = false;
|
|
83
|
+
|
|
84
|
+
// Unregister all handlers
|
|
85
|
+
this.unregisterFns.forEach(fn => fn());
|
|
86
|
+
this.unregisterFns.length = 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether opened
|
|
91
|
+
*/
|
|
92
|
+
get isOpen() {
|
|
93
|
+
return this._isOpen;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Register message handlers
|
|
98
|
+
*/
|
|
99
|
+
registerHandlers() {
|
|
100
|
+
var handlerOptions = {
|
|
101
|
+
versionValidator: this.versionValidator,
|
|
102
|
+
onVersionError: this.handleVersionError.bind(this)
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Bind handleClientResponse to ensure correct 'this' context
|
|
106
|
+
var boundHandleClientResponse = this.handleClientResponse.bind(this);
|
|
107
|
+
|
|
108
|
+
// Handle ACK messages
|
|
109
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.ACK, boundHandleClientResponse, handlerOptions));
|
|
110
|
+
|
|
111
|
+
// Handle ASYNC messages
|
|
112
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.ASYNC, boundHandleClientResponse, handlerOptions));
|
|
113
|
+
|
|
114
|
+
// Handle RESPONSE messages
|
|
115
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.RESPONSE, boundHandleClientResponse, handlerOptions));
|
|
116
|
+
|
|
117
|
+
// Handle ERROR messages
|
|
118
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.ERROR, boundHandleClientResponse, handlerOptions));
|
|
119
|
+
|
|
120
|
+
// Handle RECEIVED messages
|
|
121
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.RECEIVED, this.handleReceived.bind(this), handlerOptions));
|
|
122
|
+
|
|
123
|
+
// Handle PONG messages
|
|
124
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.PONG, this.handlePong.bind(this), handlerOptions));
|
|
125
|
+
|
|
126
|
+
// Handle stream_start messages (route to handleClientResponse so it reaches send callback)
|
|
127
|
+
// Note: stream_start is handled in send callback, not through streamCallback
|
|
128
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(_constants.MessageType.STREAM_START, boundHandleClientResponse, handlerOptions));
|
|
129
|
+
|
|
130
|
+
// Handle other stream messages (stream_data, stream_end, etc.)
|
|
131
|
+
this.unregisterFns.push(this.dispatcher.registerHandler(type => type.startsWith('stream_') && type !== _constants.MessageType.STREAM_START, (data, context) => {
|
|
132
|
+
var _this$streamCallback;
|
|
133
|
+
return (_this$streamCallback = this.streamCallback) === null || _this$streamCallback === void 0 ? void 0 : _this$streamCallback.call(this, data, context);
|
|
134
|
+
}, handlerOptions));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handle protocol version error
|
|
139
|
+
*/
|
|
140
|
+
handleVersionError(data, context, version) {
|
|
141
|
+
// For response messages, we need to notify the waiting request
|
|
142
|
+
var pending = this.pendingRequests.get(data.requestId);
|
|
143
|
+
if (pending) {
|
|
144
|
+
this.pendingRequests.delete(data.requestId);
|
|
145
|
+
pending.reject(new Error((0, _constants.formatMessage)(_constants.Messages.PROTOCOL_VERSION_TOO_LOW, version, _constants.ProtocolVersion.MIN_SUPPORTED)));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Handle client response
|
|
151
|
+
*/
|
|
152
|
+
handleClientResponse(data, context) {
|
|
153
|
+
var pending = this.pendingRequests.get(data.requestId);
|
|
154
|
+
if (!pending) {
|
|
155
|
+
/**
|
|
156
|
+
* Pending request not found - ignore by default.
|
|
157
|
+
*
|
|
158
|
+
* If client server is already closed/destroyed, emit a warning to help debugging:
|
|
159
|
+
* this usually means the client was recreated/unmounted before the response arrived.
|
|
160
|
+
*/
|
|
161
|
+
if (!this._isOpen) {
|
|
162
|
+
var key = data.requestId;
|
|
163
|
+
if (!this.warnedMissingPendingWhenClosed.has(key)) {
|
|
164
|
+
this.warnedMissingPendingWhenClosed.add(key);
|
|
165
|
+
// eslint-disable-next-line no-console
|
|
166
|
+
console.warn((0, _constants.formatMessage)(_constants.Messages.CLIENT_SERVER_IGNORED_MESSAGE_WHEN_CLOSED, data.type, data.requestId));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Validate origin
|
|
173
|
+
if (pending.origin && pending.origin !== '*' && context.origin !== pending.origin) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ack, async, and stream_start don't delete pending (stream_start needs to keep pending for stream_data/stream_end)
|
|
178
|
+
if (data.type === _constants.MessageType.ACK || data.type === _constants.MessageType.ASYNC || data.type === _constants.MessageType.STREAM_START) {
|
|
179
|
+
pending.resolve(data);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// response and error delete pending
|
|
184
|
+
this.pendingRequests.delete(data.requestId);
|
|
185
|
+
pending.resolve(data);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Handle received acknowledgment
|
|
190
|
+
*/
|
|
191
|
+
handleReceived(data) {
|
|
192
|
+
var pending = this.pendingAcks.get(data.requestId);
|
|
193
|
+
if (pending) {
|
|
194
|
+
clearTimeout(pending.timeoutId);
|
|
195
|
+
this.pendingAcks.delete(data.requestId);
|
|
196
|
+
pending.resolve(true);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Handle pong
|
|
202
|
+
*/
|
|
203
|
+
handlePong(data, context) {
|
|
204
|
+
var pending = this.pendingRequests.get(data.requestId);
|
|
205
|
+
if (pending) {
|
|
206
|
+
if (pending.origin && pending.origin !== '*' && context.origin !== pending.origin) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
this.pendingRequests.delete(data.requestId);
|
|
210
|
+
pending.resolve(data);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Set stream message handler callback
|
|
216
|
+
*/
|
|
217
|
+
setStreamCallback(callback) {
|
|
218
|
+
this.streamCallback = callback;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Get secretKey */
|
|
222
|
+
get secretKey() {
|
|
223
|
+
return this.dispatcher.secretKey;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Get the underlying MessageDispatcher */
|
|
227
|
+
get messageDispatcher() {
|
|
228
|
+
return this.dispatcher;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Register pending acknowledgment response
|
|
233
|
+
*/
|
|
234
|
+
_registerPendingAck(requestId, resolve, reject) {
|
|
235
|
+
var timeoutId = setTimeout(() => {
|
|
236
|
+
this.pendingAcks.delete(requestId);
|
|
237
|
+
resolve(false);
|
|
238
|
+
}, this.ackTimeout);
|
|
239
|
+
this.pendingAcks.set(requestId, {
|
|
240
|
+
resolve,
|
|
241
|
+
reject,
|
|
242
|
+
timeoutId
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Register pending request awaiting response
|
|
248
|
+
*/
|
|
249
|
+
_registerPendingRequest(requestId, resolve, reject, origin) {
|
|
250
|
+
this.pendingRequests.set(requestId, {
|
|
251
|
+
resolve,
|
|
252
|
+
reject,
|
|
253
|
+
origin
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Cancel pending response
|
|
259
|
+
*/
|
|
260
|
+
_unregisterPendingRequest(requestId) {
|
|
261
|
+
this.pendingRequests.delete(requestId);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Send ping message
|
|
266
|
+
*/
|
|
267
|
+
sendPing(targetWindow, targetOrigin, requestId) {
|
|
268
|
+
this.dispatcher.sendMessage(targetWindow, targetOrigin, _constants.MessageType.PING, requestId);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Destroy (close and release channel reference)
|
|
273
|
+
*/
|
|
274
|
+
destroy() {
|
|
275
|
+
// Close first
|
|
276
|
+
this.close();
|
|
277
|
+
|
|
278
|
+
// Clear pending
|
|
279
|
+
this.pendingRequests.clear();
|
|
280
|
+
this.pendingAcks.forEach(pending => clearTimeout(pending.timeoutId));
|
|
281
|
+
this.pendingAcks.clear();
|
|
282
|
+
this.warnedMissingPendingWhenClosed.clear();
|
|
283
|
+
|
|
284
|
+
// Destroy dispatcher and release channel reference
|
|
285
|
+
this.dispatcher.destroy();
|
|
286
|
+
(0, _cache.releaseMessageChannel)(this.dispatcher.getChannel());
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.RequestIframeClientServer = RequestIframeClientServer;
|
package/library/core/client.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { RequestOptions, Response, RequestIframeClient, RequestDefaults } from '../types';
|
|
1
|
+
import { RequestOptions, Response, RequestIframeClient, RequestDefaults, HeadersConfig } from '../types';
|
|
2
2
|
import { RequestInterceptorManager, ResponseInterceptorManager } from '../interceptors';
|
|
3
|
-
import { RequestIframeClientServer } from './server
|
|
4
|
-
import { StreamMessageHandler, StreamMessageData } from '../stream';
|
|
3
|
+
import { RequestIframeClientServer } from './client-server';
|
|
4
|
+
import { IframeWritableStream, StreamMessageHandler, StreamMessageData } from '../stream';
|
|
5
5
|
/**
|
|
6
6
|
* Client configuration options
|
|
7
7
|
*/
|
|
8
8
|
export interface ClientOptions extends RequestDefaults {
|
|
9
9
|
secretKey?: string;
|
|
10
|
+
headers?: HeadersConfig;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* RequestIframeClient implementation (only responsible for initiating requests, reuses server's listener)
|
|
13
14
|
*/
|
|
14
15
|
export declare class RequestIframeClientImpl implements RequestIframeClient, StreamMessageHandler {
|
|
16
|
+
/** Unique instance ID */
|
|
17
|
+
readonly id: string;
|
|
15
18
|
interceptors: {
|
|
16
19
|
request: RequestInterceptorManager;
|
|
17
20
|
response: ResponseInterceptorManager;
|
|
18
21
|
};
|
|
19
|
-
|
|
22
|
+
readonly targetWindow: Window;
|
|
20
23
|
private readonly targetOrigin;
|
|
21
24
|
private readonly server;
|
|
22
25
|
private readonly secretKey?;
|
|
@@ -24,6 +27,10 @@ export declare class RequestIframeClientImpl implements RequestIframeClient, Str
|
|
|
24
27
|
private readonly defaultAckTimeout;
|
|
25
28
|
private readonly defaultTimeout;
|
|
26
29
|
private readonly defaultAsyncTimeout;
|
|
30
|
+
/** Default returnData configuration */
|
|
31
|
+
private readonly defaultReturnData;
|
|
32
|
+
/** Initial headers configuration */
|
|
33
|
+
private readonly initialHeaders?;
|
|
27
34
|
/**
|
|
28
35
|
* Internal cookies storage
|
|
29
36
|
* - Automatically includes cookies matching the path when sending requests
|
|
@@ -36,7 +43,12 @@ export declare class RequestIframeClientImpl implements RequestIframeClient, Str
|
|
|
36
43
|
* value: stream message handler function
|
|
37
44
|
*/
|
|
38
45
|
private readonly streamHandlers;
|
|
39
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Target server ID (remembered from responses)
|
|
48
|
+
* When a response is received, we remember the server's creatorId as the targetId for future requests
|
|
49
|
+
*/
|
|
50
|
+
private _targetServerId?;
|
|
51
|
+
constructor(targetWindow: Window, targetOrigin: string, server: RequestIframeClientServer, options?: ClientOptions, instanceId?: string);
|
|
40
52
|
/**
|
|
41
53
|
* Register stream message handler (StreamMessageHandler interface implementation)
|
|
42
54
|
*/
|
|
@@ -45,20 +57,51 @@ export declare class RequestIframeClientImpl implements RequestIframeClient, Str
|
|
|
45
57
|
* Unregister stream message handler (StreamMessageHandler interface implementation)
|
|
46
58
|
*/
|
|
47
59
|
unregisterStreamHandler(streamId: string): void;
|
|
48
|
-
/**
|
|
49
|
-
* Send message (StreamMessageHandler interface implementation)
|
|
50
|
-
*/
|
|
51
60
|
postMessage(message: any): void;
|
|
52
61
|
/**
|
|
53
62
|
* Dispatch stream message to corresponding handler
|
|
54
63
|
*/
|
|
55
64
|
private dispatchStreamMessage;
|
|
65
|
+
/**
|
|
66
|
+
* Resolve header value (handle function type headers)
|
|
67
|
+
*/
|
|
68
|
+
private resolveHeaderValue;
|
|
69
|
+
/**
|
|
70
|
+
* Detect Content-Type for request body
|
|
71
|
+
*/
|
|
72
|
+
private detectContentTypeForBody;
|
|
73
|
+
/**
|
|
74
|
+
* Check if header exists (case-insensitive)
|
|
75
|
+
*/
|
|
76
|
+
private hasHeader;
|
|
77
|
+
/**
|
|
78
|
+
* Merge and resolve headers (initial headers + request headers)
|
|
79
|
+
* Request headers take precedence over initial headers
|
|
80
|
+
* Also auto-detects and sets Content-Type if not already set
|
|
81
|
+
*/
|
|
82
|
+
private mergeHeaders;
|
|
56
83
|
/**
|
|
57
84
|
* Check if server is reachable
|
|
58
85
|
*/
|
|
59
86
|
isConnect(): Promise<boolean>;
|
|
60
|
-
send<T = any>(path: string, body?:
|
|
61
|
-
|
|
87
|
+
send<T = any>(path: string, body?: any, options?: RequestOptions): Promise<Response<T> | T>;
|
|
88
|
+
/**
|
|
89
|
+
* Send file as request body (stream only; server receives stream or auto-resolved File/Blob via autoResolve).
|
|
90
|
+
*/
|
|
91
|
+
sendFile<T = any>(path: string, content: string | Blob | File, options?: RequestOptions & {
|
|
92
|
+
mimeType?: string;
|
|
93
|
+
fileName?: string;
|
|
94
|
+
autoResolve?: boolean;
|
|
95
|
+
}): Promise<Response<T> | T>;
|
|
96
|
+
/**
|
|
97
|
+
* Send stream as request body (server receives readable stream).
|
|
98
|
+
* Sends REQUEST with streamId and stream: true, then starts the writable stream.
|
|
99
|
+
*/
|
|
100
|
+
sendStream<T = any>(path: string, stream: IframeWritableStream, options?: RequestOptions): Promise<Response<T> | T>;
|
|
101
|
+
/**
|
|
102
|
+
* Internal: send REQUEST and wait for response (used by send, sendFile, sendStream).
|
|
103
|
+
*/
|
|
104
|
+
private _sendRequest;
|
|
62
105
|
/**
|
|
63
106
|
* Get internal server instance (for debugging)
|
|
64
107
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EAGR,mBAAmB,EACnB,eAAe,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["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