request-iframe 0.1.0 → 0.2.0

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.
Files changed (223) hide show
  1. package/QUICKSTART.CN.md +4 -2
  2. package/QUICKSTART.md +4 -2
  3. package/README.CN.md +302 -54
  4. package/README.md +281 -36
  5. package/cdn/request-iframe-react.umd.js +3354 -0
  6. package/cdn/request-iframe-react.umd.js.map +1 -0
  7. package/cdn/request-iframe-react.umd.min.js +2 -0
  8. package/cdn/request-iframe-react.umd.min.js.map +1 -0
  9. package/cdn/request-iframe.umd.js +19735 -0
  10. package/cdn/request-iframe.umd.js.map +1 -0
  11. package/cdn/request-iframe.umd.min.js +4 -0
  12. package/cdn/request-iframe.umd.min.js.map +1 -0
  13. package/esm/api/client.js +31 -22
  14. package/esm/api/endpoint.js +229 -0
  15. package/esm/api/server.js +19 -9
  16. package/esm/constants/debug.js +17 -0
  17. package/esm/constants/index.js +115 -66
  18. package/esm/constants/log.js +11 -0
  19. package/esm/constants/messages.js +6 -1
  20. package/esm/constants/warn-once.js +15 -0
  21. package/esm/endpoint/facade.js +390 -0
  22. package/esm/endpoint/heartbeat/heartbeat.js +60 -0
  23. package/esm/endpoint/heartbeat/ping.js +20 -0
  24. package/esm/endpoint/index.js +13 -0
  25. package/esm/endpoint/infra/hub.js +316 -0
  26. package/esm/endpoint/infra/inbox.js +232 -0
  27. package/esm/endpoint/infra/outbox.js +408 -0
  28. package/esm/endpoint/stream/dispatcher.js +58 -0
  29. package/esm/endpoint/stream/errors.js +27 -0
  30. package/esm/endpoint/stream/factory.js +76 -0
  31. package/esm/endpoint/stream/file-auto-resolve.js +34 -0
  32. package/esm/endpoint/stream/file-writable.js +105 -0
  33. package/esm/endpoint/stream/handler.js +26 -0
  34. package/esm/{core → impl}/client.js +243 -320
  35. package/esm/{core → impl}/response.js +120 -154
  36. package/esm/impl/server.js +568 -0
  37. package/esm/index.js +13 -6
  38. package/esm/message/ack.js +27 -0
  39. package/esm/message/channel-cache.js +108 -0
  40. package/esm/message/channel.js +92 -5
  41. package/esm/message/dispatcher.js +149 -98
  42. package/esm/stream/error.js +22 -0
  43. package/esm/stream/index.js +3 -1
  44. package/esm/stream/readable-stream.js +101 -26
  45. package/esm/stream/stream-core.js +121 -3
  46. package/esm/stream/writable-stream.js +368 -43
  47. package/esm/utils/ack.js +36 -0
  48. package/esm/utils/blob.js +16 -0
  49. package/esm/utils/cache.js +25 -76
  50. package/esm/utils/content-type.js +81 -0
  51. package/esm/utils/debug.js +157 -180
  52. package/esm/utils/hooks.js +130 -0
  53. package/esm/utils/id.js +14 -0
  54. package/esm/utils/iframe.js +20 -0
  55. package/esm/utils/index.js +12 -162
  56. package/esm/utils/is.js +3 -0
  57. package/esm/utils/logger.js +55 -0
  58. package/esm/utils/origin.js +3 -1
  59. package/esm/utils/promise.js +3 -0
  60. package/esm/utils/window.js +31 -0
  61. package/library/api/client.d.ts.map +1 -1
  62. package/library/api/client.js +32 -23
  63. package/library/api/endpoint.d.ts +23 -0
  64. package/library/api/endpoint.d.ts.map +1 -0
  65. package/library/api/endpoint.js +235 -0
  66. package/library/api/server.d.ts +4 -1
  67. package/library/api/server.d.ts.map +1 -1
  68. package/library/api/server.js +19 -9
  69. package/library/constants/debug.d.ts +18 -0
  70. package/library/constants/debug.d.ts.map +1 -0
  71. package/library/constants/debug.js +23 -0
  72. package/library/constants/index.d.ts +58 -7
  73. package/library/constants/index.d.ts.map +1 -1
  74. package/library/constants/index.js +143 -67
  75. package/library/constants/log.d.ts +12 -0
  76. package/library/constants/log.d.ts.map +1 -0
  77. package/library/constants/log.js +17 -0
  78. package/library/constants/messages.d.ts +6 -1
  79. package/library/constants/messages.d.ts.map +1 -1
  80. package/library/constants/messages.js +6 -1
  81. package/library/constants/warn-once.d.ts +12 -0
  82. package/library/constants/warn-once.d.ts.map +1 -0
  83. package/library/constants/warn-once.js +22 -0
  84. package/library/endpoint/facade.d.ts +238 -0
  85. package/library/endpoint/facade.d.ts.map +1 -0
  86. package/library/endpoint/facade.js +398 -0
  87. package/library/endpoint/heartbeat/heartbeat.d.ts +34 -0
  88. package/library/endpoint/heartbeat/heartbeat.d.ts.map +1 -0
  89. package/library/endpoint/heartbeat/heartbeat.js +67 -0
  90. package/library/endpoint/heartbeat/ping.d.ts +18 -0
  91. package/library/endpoint/heartbeat/ping.d.ts.map +1 -0
  92. package/library/endpoint/heartbeat/ping.js +26 -0
  93. package/library/endpoint/index.d.ts +16 -0
  94. package/library/endpoint/index.d.ts.map +1 -0
  95. package/library/endpoint/index.js +114 -0
  96. package/library/endpoint/infra/hub.d.ts +170 -0
  97. package/library/endpoint/infra/hub.d.ts.map +1 -0
  98. package/library/endpoint/infra/hub.js +323 -0
  99. package/library/endpoint/infra/inbox.d.ts +73 -0
  100. package/library/endpoint/infra/inbox.d.ts.map +1 -0
  101. package/library/endpoint/infra/inbox.js +239 -0
  102. package/library/endpoint/infra/outbox.d.ts +149 -0
  103. package/library/endpoint/infra/outbox.d.ts.map +1 -0
  104. package/library/endpoint/infra/outbox.js +415 -0
  105. package/library/endpoint/stream/dispatcher.d.ts +33 -0
  106. package/library/endpoint/stream/dispatcher.d.ts.map +1 -0
  107. package/library/endpoint/stream/dispatcher.js +66 -0
  108. package/library/endpoint/stream/errors.d.ts +20 -0
  109. package/library/endpoint/stream/errors.d.ts.map +1 -0
  110. package/library/endpoint/stream/errors.js +32 -0
  111. package/library/endpoint/stream/factory.d.ts +44 -0
  112. package/library/endpoint/stream/factory.d.ts.map +1 -0
  113. package/library/endpoint/stream/factory.js +82 -0
  114. package/library/endpoint/stream/file-auto-resolve.d.ts +26 -0
  115. package/library/endpoint/stream/file-auto-resolve.d.ts.map +1 -0
  116. package/library/endpoint/stream/file-auto-resolve.js +41 -0
  117. package/library/endpoint/stream/file-writable.d.ts +33 -0
  118. package/library/endpoint/stream/file-writable.d.ts.map +1 -0
  119. package/library/endpoint/stream/file-writable.js +115 -0
  120. package/library/endpoint/stream/handler.d.ts +20 -0
  121. package/library/endpoint/stream/handler.d.ts.map +1 -0
  122. package/library/endpoint/stream/handler.js +32 -0
  123. package/library/{core → impl}/client.d.ts +16 -13
  124. package/library/impl/client.d.ts.map +1 -0
  125. package/library/{core → impl}/client.js +254 -333
  126. package/library/{core → impl}/request.d.ts.map +1 -1
  127. package/library/{core → impl}/response.d.ts +7 -12
  128. package/library/impl/response.d.ts.map +1 -0
  129. package/library/{core → impl}/response.js +120 -154
  130. package/library/{core → impl}/server.d.ts +26 -55
  131. package/library/impl/server.d.ts.map +1 -0
  132. package/library/impl/server.js +575 -0
  133. package/library/index.d.ts +13 -6
  134. package/library/index.d.ts.map +1 -1
  135. package/library/index.js +16 -16
  136. package/library/message/ack.d.ts +15 -0
  137. package/library/message/ack.d.ts.map +1 -0
  138. package/library/message/ack.js +33 -0
  139. package/library/message/channel-cache.d.ts +26 -0
  140. package/library/message/channel-cache.d.ts.map +1 -0
  141. package/library/message/channel-cache.js +115 -0
  142. package/library/message/channel.d.ts +53 -6
  143. package/library/message/channel.d.ts.map +1 -1
  144. package/library/message/channel.js +96 -9
  145. package/library/message/dispatcher.d.ts +17 -0
  146. package/library/message/dispatcher.d.ts.map +1 -1
  147. package/library/message/dispatcher.js +149 -98
  148. package/library/stream/error.d.ts +24 -0
  149. package/library/stream/error.d.ts.map +1 -0
  150. package/library/stream/error.js +29 -0
  151. package/library/stream/index.d.ts +4 -1
  152. package/library/stream/index.d.ts.map +1 -1
  153. package/library/stream/index.js +7 -4
  154. package/library/stream/readable-stream.d.ts.map +1 -1
  155. package/library/stream/readable-stream.js +102 -27
  156. package/library/stream/stream-core.d.ts +22 -1
  157. package/library/stream/stream-core.d.ts.map +1 -1
  158. package/library/stream/stream-core.js +120 -2
  159. package/library/stream/types.d.ts +115 -2
  160. package/library/stream/types.d.ts.map +1 -1
  161. package/library/stream/writable-stream.d.ts +20 -2
  162. package/library/stream/writable-stream.d.ts.map +1 -1
  163. package/library/stream/writable-stream.js +366 -41
  164. package/library/types/index.d.ts +17 -22
  165. package/library/types/index.d.ts.map +1 -1
  166. package/library/utils/ack.d.ts +2 -0
  167. package/library/utils/ack.d.ts.map +1 -0
  168. package/library/utils/ack.js +44 -0
  169. package/library/utils/blob.d.ts +3 -0
  170. package/library/utils/blob.d.ts.map +1 -0
  171. package/library/utils/blob.js +22 -0
  172. package/library/utils/cache.d.ts +10 -20
  173. package/library/utils/cache.d.ts.map +1 -1
  174. package/library/utils/cache.js +25 -79
  175. package/library/utils/content-type.d.ts +13 -0
  176. package/library/utils/content-type.d.ts.map +1 -0
  177. package/library/utils/content-type.js +87 -0
  178. package/library/utils/debug.d.ts.map +1 -1
  179. package/library/utils/debug.js +156 -178
  180. package/library/utils/hooks.d.ts +30 -0
  181. package/library/utils/hooks.d.ts.map +1 -0
  182. package/library/utils/hooks.js +139 -0
  183. package/library/utils/id.d.ts +9 -0
  184. package/library/utils/id.d.ts.map +1 -0
  185. package/library/utils/id.js +21 -0
  186. package/library/utils/iframe.d.ts +5 -0
  187. package/library/utils/iframe.d.ts.map +1 -0
  188. package/library/utils/iframe.js +25 -0
  189. package/library/utils/index.d.ts +7 -34
  190. package/library/utils/index.d.ts.map +1 -1
  191. package/library/utils/index.js +58 -193
  192. package/library/utils/is.d.ts +2 -0
  193. package/library/utils/is.d.ts.map +1 -0
  194. package/library/utils/is.js +9 -0
  195. package/library/utils/logger.d.ts +13 -0
  196. package/library/utils/logger.d.ts.map +1 -0
  197. package/library/utils/logger.js +63 -0
  198. package/library/utils/origin.d.ts.map +1 -1
  199. package/library/utils/origin.js +2 -1
  200. package/library/utils/promise.d.ts +2 -0
  201. package/library/utils/promise.d.ts.map +1 -0
  202. package/library/utils/promise.js +9 -0
  203. package/library/utils/window.d.ts +2 -0
  204. package/library/utils/window.d.ts.map +1 -0
  205. package/library/utils/window.js +38 -0
  206. package/package.json +49 -2
  207. package/react/package.json +2 -1
  208. package/esm/core/client-server.js +0 -329
  209. package/esm/core/server.js +0 -767
  210. package/esm/utils/ack-meta.js +0 -53
  211. package/library/core/client-server.d.ts +0 -106
  212. package/library/core/client-server.d.ts.map +0 -1
  213. package/library/core/client-server.js +0 -336
  214. package/library/core/client.d.ts.map +0 -1
  215. package/library/core/response.d.ts.map +0 -1
  216. package/library/core/server.d.ts.map +0 -1
  217. package/library/core/server.js +0 -772
  218. package/library/utils/ack-meta.d.ts +0 -2
  219. package/library/utils/ack-meta.d.ts.map +0 -1
  220. package/library/utils/ack-meta.js +0 -59
  221. /package/esm/{core → impl}/request.js +0 -0
  222. /package/library/{core → impl}/request.d.ts +0 -0
  223. /package/library/{core → impl}/request.js +0 -0
@@ -12,24 +12,24 @@ import "core-js/modules/es.array.filter.js";
12
12
  import "core-js/modules/es.array.from.js";
13
13
  import "core-js/modules/es.array.iterator.js";
14
14
  import "core-js/modules/es.array.slice.js";
15
- import "core-js/modules/es.map.js";
16
15
  import "core-js/modules/es.object.entries.js";
17
- import "core-js/modules/es.promise.js";
18
16
  import "core-js/modules/es.object.get-own-property-descriptors.js";
17
+ import "core-js/modules/es.promise.js";
19
18
  import "core-js/modules/es.regexp.exec.js";
20
19
  import "core-js/modules/es.regexp.to-string.js";
21
- import "core-js/modules/es.string.match.js";
22
- import "core-js/modules/es.string.replace.js";
23
- import "core-js/modules/es.string.starts-with.js";
24
20
  import "core-js/modules/web.dom-collections.for-each.js";
25
21
  import "core-js/modules/web.dom-collections.iterator.js";
26
- import { RequestIframeError } from '../utils';
27
- import { isAckMetaEqual } from '../utils/ack-meta';
28
- import { detectContentType, blobToBase64, isWindowAvailable, matchOrigin } from '../utils';
29
- import { generateRequestId, generateInstanceId, CookieStore } from '../utils';
22
+ import { RequestIframeError } from '../utils/error';
23
+ import { isExpectedAckMatch } from '../endpoint';
24
+ import { detectContentType } from '../utils/content-type';
25
+ import { isWindowAvailable } from '../utils/window';
26
+ import { generateRequestId, generateInstanceId } from '../utils/id';
27
+ import { CookieStore } from '../utils/cookie';
30
28
  import { RequestInterceptorManager, ResponseInterceptorManager, runRequestInterceptors, runResponseInterceptors } from '../interceptors';
31
- import { DefaultTimeout, ErrorCode, MessageType, HttpStatus, HttpStatusText, HttpHeader, Messages, formatMessage, StreamType as StreamTypeConstant } from '../constants';
32
- import { IframeReadableStream, IframeFileReadableStream, isIframeWritableStream } from '../stream';
29
+ import { RequestIframeEndpointFacade, createReadableStreamFromStart } from '../endpoint';
30
+ import { autoResolveIframeFileReadableStream } from '../endpoint';
31
+ import { DefaultTimeout, ErrorCode, MessageType, MessageRole, HttpStatus, HttpStatusText, HttpHeader, Messages, formatMessage, StreamType as StreamTypeConstant } from '../constants';
32
+ import { isFunction } from '../utils/is';
33
33
 
34
34
  /**
35
35
  * Client configuration options
@@ -44,7 +44,14 @@ export class RequestIframeClientImpl {
44
44
  * When a response is received, we remember the server's creatorId as the targetId for future requests
45
45
  */
46
46
 
47
- constructor(targetWindow, targetOrigin, server, options, instanceId) {
47
+ rememberTargetServerId(serverId) {
48
+ if (!serverId) return;
49
+ if (!this._targetServerId) {
50
+ this._targetServerId = serverId;
51
+ this.outbox.setDefaultTargetId(serverId);
52
+ }
53
+ }
54
+ constructor(targetWindow, targetOrigin, options, instanceId) {
48
55
  var _options$ackTimeout, _options$timeout, _options$asyncTimeout, _options$returnData;
49
56
  /** Unique instance ID */
50
57
  _defineProperty(this, "interceptors", {
@@ -57,28 +64,43 @@ export class RequestIframeClientImpl {
57
64
  * - Automatically parses Set-Cookie and saves when receiving response
58
65
  */
59
66
  _defineProperty(this, "_cookieStore", new CookieStore());
60
- /**
61
- * Stream message handler map
62
- * key: streamId
63
- * value: stream message handler function
64
- */
65
- _defineProperty(this, "streamHandlers", new Map());
66
67
  this.id = instanceId || generateInstanceId();
67
68
  this.targetWindow = targetWindow;
68
69
  this.targetOrigin = targetOrigin;
69
- this.server = server;
70
70
  this.secretKey = options === null || options === void 0 ? void 0 : options.secretKey;
71
+ var endpoint = new RequestIframeEndpointFacade({
72
+ role: MessageRole.CLIENT,
73
+ instanceId: this.id,
74
+ secretKey: options === null || options === void 0 ? void 0 : options.secretKey,
75
+ autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
76
+ autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength,
77
+ inbox: {},
78
+ streamDispatcher: {
79
+ handledBy: this.id
80
+ },
81
+ originValidator: {
82
+ allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
83
+ validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin
84
+ }
85
+ });
86
+ this.endpoint = endpoint;
87
+ /** Core/routers shared composition */
88
+ this.hub = endpoint.hub;
89
+ this.streamDispatcher = endpoint.streamDispatcher;
90
+ this.inbox = endpoint.inbox;
91
+ this.originValidator = endpoint.originValidator;
92
+
93
+ /** Create a fixed-peer sender (built-in client) */
94
+ this.outbox = this.hub.createOutbox(this.targetWindow, this.targetOrigin);
95
+
96
+ /**
97
+ * Register base message infra + response handlers via facade.
98
+ * These hooks will run when client.open() is called.
99
+ */
100
+ this.endpoint.onOpen(() => this.inbox.registerHandlers());
71
101
 
72
102
  // Provide fallback target for auto-ack (useful when MessageEvent.source is missing in tests)
73
- this.server.messageDispatcher.setFallbackTarget(this.targetWindow, this.targetOrigin);
74
-
75
- // Build origin validator (incoming messages)
76
- if (options !== null && options !== void 0 && options.validateOrigin) {
77
- this.originValidator = (origin, data, context) => options.validateOrigin(origin, data, context);
78
- } else if (options !== null && options !== void 0 && options.allowedOrigins) {
79
- var matcher = options.allowedOrigins;
80
- this.originValidator = origin => matchOrigin(origin, matcher);
81
- }
103
+ this.hub.setFallbackTarget(this.outbox.targetWindow, this.outbox.targetOrigin);
82
104
 
83
105
  // Set default timeout configuration
84
106
  this.defaultAckTimeout = (_options$ackTimeout = options === null || options === void 0 ? void 0 : options.ackTimeout) !== null && _options$ackTimeout !== void 0 ? _options$ackTimeout : DefaultTimeout.ACK;
@@ -91,73 +113,58 @@ export class RequestIframeClientImpl {
91
113
  // Save initial headers configuration
92
114
  this.initialHeaders = options === null || options === void 0 ? void 0 : options.headers;
93
115
 
94
- // Register stream message processing callback
95
- this.server.setStreamCallback((data, context) => {
96
- this.dispatchStreamMessage(data, context);
116
+ // Stream dispatching is owned by facade (pluggable stream infra)
117
+ this.endpoint.enableStreamDispatcherCallback({
118
+ isOriginAllowed: (d, ctx) => this.hub.isOriginAllowedBy(ctx.origin, d, ctx, this.targetOrigin, this.originValidator)
97
119
  });
120
+ this.endpoint.registerClientStreamCallbackHandlers({
121
+ handlerOptions: this.hub.createHandlerOptions(() => {
122
+ /** ignore version errors for stream frames */
123
+ })
124
+ });
125
+
126
+ /** Auto-open by default (unless explicitly set to false) */
127
+ if ((options === null || options === void 0 ? void 0 : options.autoOpen) !== false) {
128
+ this.open();
129
+ }
98
130
  }
99
131
 
100
132
  /**
101
133
  * Register stream message handler (StreamMessageHandler interface implementation)
102
134
  */
103
135
  registerStreamHandler(streamId, handler) {
104
- this.streamHandlers.set(streamId, handler);
136
+ this.streamDispatcher.register(streamId, handler);
105
137
  }
106
138
 
107
139
  /**
108
140
  * Unregister stream message handler (StreamMessageHandler interface implementation)
109
141
  */
110
142
  unregisterStreamHandler(streamId) {
111
- this.streamHandlers.delete(streamId);
143
+ this.streamDispatcher.unregister(streamId);
112
144
  }
113
145
 
114
146
  /*
115
147
  Send message (StreamMessageHandler interface implementation)
116
148
  */
117
149
  postMessage(message) {
118
- // Window check is handled in MessageDispatcher
119
- this.server.messageDispatcher.send(this.targetWindow, message, this.targetOrigin);
150
+ this.sendRaw(message);
120
151
  }
121
152
 
122
153
  /**
123
- * Dispatch stream message to corresponding handler
154
+ * Send raw framework message (advanced).
155
+ *
156
+ * Note: streams call `postMessage` via StreamMessageHandler, which delegates here.
124
157
  */
125
- dispatchStreamMessage(data, context) {
126
- // Validate origin for stream messages (stream_data/stream_end/stream_error/stream_cancel)
127
- if (context) {
128
- if (this.originValidator) {
129
- try {
130
- if (!this.originValidator(context.origin, data, context)) {
131
- return;
132
- }
133
- } catch (_unused) {
134
- return;
135
- }
136
- } else if (this.targetOrigin !== '*' && context.origin !== this.targetOrigin) {
137
- return;
138
- }
139
- }
140
- var body = data.body;
141
- if (!body || !body.streamId) return;
142
- var handler = this.streamHandlers.get(body.streamId);
143
- if (handler) {
144
- if (context && !context.handledBy) {
145
- context.accepted = true;
146
- context.handledBy = this.id;
147
- }
148
- // Extract message type (remove stream_ prefix)
149
- var messageType = data.type.replace('stream_', '');
150
- handler(_objectSpread(_objectSpread({}, body), {}, {
151
- type: messageType
152
- }));
153
- }
158
+ sendRaw(message) {
159
+ // Window check is handled in MessageDispatcher
160
+ this.outbox.sendRaw(message);
154
161
  }
155
162
 
156
163
  /**
157
164
  * Resolve header value (handle function type headers)
158
165
  */
159
166
  resolveHeaderValue(value, config) {
160
- if (typeof value === 'function') {
167
+ if (isFunction(value)) {
161
168
  return value(config);
162
169
  }
163
170
  return value;
@@ -222,60 +229,27 @@ export class RequestIframeClientImpl {
222
229
  * Check if server is reachable
223
230
  */
224
231
  isConnect() {
225
- return new Promise((resolve, reject) => {
226
- var requestId = generateRequestId();
227
- var done = false;
228
- var timeoutId = null;
229
- var cleanup = () => {
230
- if (timeoutId) clearTimeout(timeoutId);
231
- this.server._unregisterPendingRequest(requestId);
232
- };
233
-
234
- // Check if target window is still available before sending ping
235
- if (!isWindowAvailable(this.targetWindow)) {
236
- reject(new RequestIframeError({
237
- message: Messages.TARGET_WINDOW_CLOSED,
238
- code: ErrorCode.TARGET_WINDOW_CLOSED,
239
- config: undefined,
240
- requestId
241
- }));
242
- return;
243
- }
244
- this.server._registerPendingRequest(requestId, data => {
245
- if (done) return;
246
- if (data.type === MessageType.ACK || data.type === MessageType.PONG) {
247
- // Remember server's creatorId as target server ID for future requests
248
- if (data.creatorId && !this._targetServerId) {
249
- this._targetServerId = data.creatorId;
250
- }
251
- done = true;
252
- cleanup();
253
- resolve(true);
254
- }
255
- }, () => {
256
- if (done) return;
257
- done = true;
258
- cleanup();
259
- resolve(false);
260
- }, this.targetOrigin, this.originValidator);
261
- timeoutId = setTimeout(() => {
262
- if (done) return;
263
- done = true;
264
- cleanup();
265
- resolve(false);
266
- }, this.defaultAckTimeout);
267
-
268
- // Send ping via MessageDispatcher
269
- this.server.messageDispatcher.sendMessage(this.targetWindow, this.targetOrigin, MessageType.PING, requestId, {
270
- requireAck: true,
271
- targetId: this._targetServerId
272
- });
232
+ // Check if target window is still available before sending ping
233
+ if (!isWindowAvailable(this.targetWindow)) {
234
+ return Promise.reject(new RequestIframeError({
235
+ message: Messages.TARGET_WINDOW_CLOSED,
236
+ code: ErrorCode.TARGET_WINDOW_CLOSED,
237
+ config: undefined,
238
+ requestId: `ping_${Date.now()}`
239
+ }));
240
+ }
241
+ return this.endpoint.pingIsConnect({
242
+ peer: this.outbox,
243
+ timeoutMs: this.defaultAckTimeout,
244
+ targetOrigin: this.targetOrigin,
245
+ targetId: this._targetServerId,
246
+ onPeerId: serverId => this.rememberTargetServerId(serverId)
273
247
  });
274
248
  }
275
249
  send(path, body, options) {
276
250
  var _this = this;
277
251
  return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
278
- var config, processedConfig, processedBody, mergedHeaders, processedPath, processedCookies, userTargetId, _processedConfig$requ, requestId, targetId;
252
+ var config, processedConfig, processedBody;
279
253
  return _regeneratorRuntime.wrap(function (_context) {
280
254
  while (1) switch (_context.prev = _context.next) {
281
255
  case 0:
@@ -287,25 +261,28 @@ export class RequestIframeClientImpl {
287
261
  return runRequestInterceptors(_this.interceptors.request, config);
288
262
  case 1:
289
263
  processedConfig = _context.sent;
290
- processedBody = processedConfig.body; // Universal send: dispatch by type (like response.send)
291
- if (!(typeof File !== 'undefined' && processedBody instanceof File || typeof Blob !== 'undefined' && processedBody instanceof Blob)) {
292
- _context.next = 2;
293
- break;
294
- }
295
- return _context.abrupt("return", _this.sendFile(path, processedBody, options));
264
+ processedBody = processedConfig.body;
265
+ return _context.abrupt("return", _this.outbox.send({
266
+ data: processedBody,
267
+ onFileOrBlob: () => {
268
+ return _this.sendFile(path, processedBody, options);
269
+ },
270
+ onStream: () => {
271
+ return _this.sendStream(path, processedBody, options);
272
+ },
273
+ onOther: () => {
274
+ // Merge and resolve headers (initial headers + request headers)
275
+ var mergedHeaders = _this.mergeHeaders(processedConfig, processedBody);
276
+ var processedPath = processedConfig.path,
277
+ processedCookies = processedConfig.cookies,
278
+ userTargetId = processedConfig.targetId,
279
+ _processedConfig$requ = processedConfig.requestId,
280
+ requestId = _processedConfig$requ === void 0 ? generateRequestId() : _processedConfig$requ;
281
+ var targetId = userTargetId || _this._targetServerId;
282
+ return _this._sendRequest(processedPath, processedBody, mergedHeaders, processedCookies, processedConfig, requestId, targetId);
283
+ }
284
+ }));
296
285
  case 2:
297
- if (!isIframeWritableStream(processedBody)) {
298
- _context.next = 3;
299
- break;
300
- }
301
- return _context.abrupt("return", _this.sendStream(path, processedBody, options));
302
- case 3:
303
- // Merge and resolve headers (initial headers + request headers)
304
- mergedHeaders = _this.mergeHeaders(processedConfig, processedBody);
305
- processedPath = processedConfig.path, processedCookies = processedConfig.cookies, userTargetId = processedConfig.targetId, _processedConfig$requ = processedConfig.requestId, requestId = _processedConfig$requ === void 0 ? generateRequestId() : _processedConfig$requ;
306
- targetId = userTargetId || _this._targetServerId;
307
- return _context.abrupt("return", _this._sendRequest(processedPath, processedBody, mergedHeaders, processedCookies, processedConfig, requestId, targetId));
308
- case 4:
309
286
  case "end":
310
287
  return _context.stop();
311
288
  }
@@ -318,67 +295,61 @@ export class RequestIframeClientImpl {
318
295
  */
319
296
  sendFile(path, content, options) {
320
297
  var _this2 = this;
321
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
322
- var _options$autoResolve;
323
- var streamAutoResolve, mimeType, fileName, _yield$import, IframeFileWritableStream, fileStream;
324
- return _regeneratorRuntime.wrap(function (_context3) {
325
- while (1) switch (_context3.prev = _context3.next) {
298
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
299
+ var _processedConfig$requ2, _processedConfig$targ, _options$autoResolve;
300
+ var config, processedConfig, requestId, targetId, processedPath, mergedHeaders, pathMatchedCookies, mergedCookies, streamConfig;
301
+ return _regeneratorRuntime.wrap(function (_context2) {
302
+ while (1) switch (_context2.prev = _context2.next) {
326
303
  case 0:
327
- streamAutoResolve = (_options$autoResolve = options === null || options === void 0 ? void 0 : options.autoResolve) !== null && _options$autoResolve !== void 0 ? _options$autoResolve : true;
328
- mimeType = options === null || options === void 0 ? void 0 : options.mimeType;
329
- fileName = options === null || options === void 0 ? void 0 : options.fileName;
330
- _context3.next = 1;
331
- return import('../stream');
304
+ config = _objectSpread({
305
+ path,
306
+ body: undefined
307
+ }, options);
308
+ _context2.next = 1;
309
+ return runRequestInterceptors(_this2.interceptors.request, config);
332
310
  case 1:
333
- _yield$import = _context3.sent;
334
- IframeFileWritableStream = _yield$import.IframeFileWritableStream;
335
- fileStream = new IframeFileWritableStream({
336
- filename: fileName || (typeof File !== 'undefined' && content instanceof File ? content.name : 'file'),
337
- mimeType: mimeType || (typeof File !== 'undefined' && content instanceof File ? content.type : content === null || content === void 0 ? void 0 : content.type) || 'application/octet-stream',
311
+ processedConfig = _context2.sent;
312
+ requestId = (_processedConfig$requ2 = processedConfig.requestId) !== null && _processedConfig$requ2 !== void 0 ? _processedConfig$requ2 : generateRequestId();
313
+ targetId = (_processedConfig$targ = processedConfig.targetId) !== null && _processedConfig$targ !== void 0 ? _processedConfig$targ : _this2._targetServerId;
314
+ processedPath = processedConfig.path;
315
+ mergedHeaders = _this2.mergeHeaders(processedConfig, undefined);
316
+ pathMatchedCookies = _this2._cookieStore.getForPath(processedPath);
317
+ mergedCookies = _objectSpread(_objectSpread({}, pathMatchedCookies), processedConfig.cookies);
318
+ streamConfig = _objectSpread(_objectSpread({}, processedConfig), {}, {
319
+ requestId
320
+ });
321
+ return _context2.abrupt("return", _this2.outbox.sendFile({
322
+ content,
323
+ fileName: options === null || options === void 0 ? void 0 : options.fileName,
324
+ mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
338
325
  chunked: false,
339
- autoResolve: streamAutoResolve,
340
- next: function () {
341
- var _next = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
342
- var data, _t;
343
- return _regeneratorRuntime.wrap(function (_context2) {
344
- while (1) switch (_context2.prev = _context2.next) {
345
- case 0:
346
- if (!(typeof content === 'string')) {
347
- _context2.next = 1;
348
- break;
349
- }
350
- _t = btoa(unescape(encodeURIComponent(content)));
351
- _context2.next = 3;
352
- break;
353
- case 1:
354
- _context2.next = 2;
355
- return blobToBase64(content);
356
- case 2:
357
- _t = _context2.sent;
358
- case 3:
359
- data = _t;
360
- return _context2.abrupt("return", {
361
- data,
362
- done: true
363
- });
364
- case 4:
365
- case "end":
366
- return _context2.stop();
367
- }
368
- }, _callee2);
369
- }));
370
- function next() {
371
- return _next.apply(this, arguments);
326
+ autoResolve: (_options$autoResolve = options === null || options === void 0 ? void 0 : options.autoResolve) !== null && _options$autoResolve !== void 0 ? _options$autoResolve : true,
327
+ defaultFileName: typeof File !== 'undefined' && content instanceof File ? content.name : 'file',
328
+ defaultMimeType: 'application/octet-stream',
329
+ stream: {
330
+ bind: {
331
+ requestId,
332
+ registerStreamHandler: _this2.registerStreamHandler.bind(_this2),
333
+ unregisterStreamHandler: _this2.unregisterStreamHandler.bind(_this2),
334
+ heartbeat: () => _this2.isConnect(),
335
+ clientId: _this2.id,
336
+ targetId
337
+ },
338
+ awaitStart: false,
339
+ beforeStart: ({
340
+ stream
341
+ }) => {
342
+ return _this2._sendRequest(processedPath, undefined, mergedHeaders, mergedCookies, streamConfig, requestId, targetId, {
343
+ streamId: stream.streamId
344
+ });
372
345
  }
373
- return next;
374
- }()
375
- });
376
- return _context3.abrupt("return", _this2.sendStream(path, fileStream, options));
346
+ }
347
+ }));
377
348
  case 2:
378
349
  case "end":
379
- return _context3.stop();
350
+ return _context2.stop();
380
351
  }
381
- }, _callee3);
352
+ }, _callee2);
382
353
  }))();
383
354
  }
384
355
 
@@ -388,52 +359,53 @@ export class RequestIframeClientImpl {
388
359
  */
389
360
  sendStream(path, stream, options) {
390
361
  var _this3 = this;
391
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
392
- var _processedConfig$requ2, _processedConfig$targ;
393
- var config, processedConfig, requestId, targetId, processedPath, mergedHeaders, pathMatchedCookies, mergedCookies, streamConfig, promise;
394
- return _regeneratorRuntime.wrap(function (_context4) {
395
- while (1) switch (_context4.prev = _context4.next) {
362
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
363
+ var _processedConfig$requ3, _processedConfig$targ2;
364
+ var config, processedConfig, requestId, targetId, processedPath, mergedHeaders, pathMatchedCookies, mergedCookies, streamConfig;
365
+ return _regeneratorRuntime.wrap(function (_context3) {
366
+ while (1) switch (_context3.prev = _context3.next) {
396
367
  case 0:
397
368
  config = _objectSpread({
398
369
  path,
399
370
  body: undefined
400
371
  }, options);
401
- _context4.next = 1;
372
+ _context3.next = 1;
402
373
  return runRequestInterceptors(_this3.interceptors.request, config);
403
374
  case 1:
404
- processedConfig = _context4.sent;
405
- requestId = (_processedConfig$requ2 = processedConfig.requestId) !== null && _processedConfig$requ2 !== void 0 ? _processedConfig$requ2 : generateRequestId();
406
- targetId = (_processedConfig$targ = processedConfig.targetId) !== null && _processedConfig$targ !== void 0 ? _processedConfig$targ : _this3._targetServerId;
375
+ processedConfig = _context3.sent;
376
+ requestId = (_processedConfig$requ3 = processedConfig.requestId) !== null && _processedConfig$requ3 !== void 0 ? _processedConfig$requ3 : generateRequestId();
377
+ targetId = (_processedConfig$targ2 = processedConfig.targetId) !== null && _processedConfig$targ2 !== void 0 ? _processedConfig$targ2 : _this3._targetServerId;
407
378
  processedPath = processedConfig.path;
408
- stream._bind({
409
- requestId,
410
- targetWindow: _this3.targetWindow,
411
- targetOrigin: _this3.targetOrigin,
412
- secretKey: _this3.secretKey,
413
- channel: _this3.server.messageDispatcher.getChannel(),
414
- registerStreamHandler: _this3.registerStreamHandler.bind(_this3),
415
- unregisterStreamHandler: _this3.unregisterStreamHandler.bind(_this3),
416
- heartbeat: () => _this3.isConnect(),
417
- clientId: _this3.id,
418
- targetId
419
- });
420
379
  mergedHeaders = _this3.mergeHeaders(processedConfig, undefined);
421
380
  pathMatchedCookies = _this3._cookieStore.getForPath(processedPath);
422
381
  mergedCookies = _objectSpread(_objectSpread({}, pathMatchedCookies), processedConfig.cookies);
423
382
  streamConfig = _objectSpread(_objectSpread({}, processedConfig), {}, {
424
383
  requestId
425
384
  });
426
- promise = _this3._sendRequest(processedPath, undefined, mergedHeaders, mergedCookies, streamConfig, requestId, targetId, {
427
- streamId: stream.streamId
428
- });
429
- /** Start stream after REQUEST is sent (_sendRequest sends synchronously in executor) */
430
- void stream.start();
431
- return _context4.abrupt("return", promise);
385
+ return _context3.abrupt("return", _this3.outbox.sendStream({
386
+ stream: stream,
387
+ bind: {
388
+ requestId,
389
+ registerStreamHandler: _this3.registerStreamHandler.bind(_this3),
390
+ unregisterStreamHandler: _this3.unregisterStreamHandler.bind(_this3),
391
+ heartbeat: () => _this3.isConnect(),
392
+ clientId: _this3.id,
393
+ targetId
394
+ },
395
+ awaitStart: false,
396
+ beforeStart: ({
397
+ stream: s
398
+ }) => {
399
+ return _this3._sendRequest(processedPath, undefined, mergedHeaders, mergedCookies, streamConfig, requestId, targetId, {
400
+ streamId: s.streamId
401
+ });
402
+ }
403
+ }));
432
404
  case 2:
433
405
  case "end":
434
- return _context4.stop();
406
+ return _context3.stop();
435
407
  }
436
- }, _callee4);
408
+ }, _callee3);
437
409
  }))();
438
410
  }
439
411
 
@@ -447,10 +419,10 @@ export class RequestIframeClientImpl {
447
419
  timeout = _processedConfig$time === void 0 ? this.defaultTimeout : _processedConfig$time,
448
420
  _processedConfig$asyn = processedConfig.asyncTimeout,
449
421
  asyncTimeout = _processedConfig$asyn === void 0 ? this.defaultAsyncTimeout : _processedConfig$asyn,
450
- _processedConfig$requ3 = processedConfig.requireAck,
451
- requireAck = _processedConfig$requ3 === void 0 ? true : _processedConfig$requ3,
422
+ _processedConfig$requ4 = processedConfig.requireAck,
423
+ requireAck = _processedConfig$requ4 === void 0 ? true : _processedConfig$requ4,
452
424
  streamTimeout = processedConfig.streamTimeout,
453
- ackMeta = processedConfig.ackMeta,
425
+ ack = processedConfig.ack,
454
426
  _processedConfig$retu = processedConfig.returnData,
455
427
  returnData = _processedConfig$retu === void 0 ? this.defaultReturnData : _processedConfig$retu;
456
428
  return new Promise((resolve, reject) => {
@@ -458,7 +430,7 @@ export class RequestIframeClientImpl {
458
430
  var timeoutId = null;
459
431
  var cleanup = () => {
460
432
  if (timeoutId) clearTimeout(timeoutId);
461
- this.server._unregisterPendingRequest(requestId);
433
+ this.inbox.unregisterPendingRequest(requestId);
462
434
  };
463
435
  var fail = error => {
464
436
  if (done) return;
@@ -519,19 +491,17 @@ export class RequestIframeClientImpl {
519
491
  };
520
492
 
521
493
  // Register to server's pending requests
522
- this.server._registerPendingRequest(requestId, data => {
494
+ this.inbox.registerPendingRequest(requestId, data => {
523
495
  if (done) return;
524
496
 
525
497
  // Received ACK: server has received request
526
498
  if (data.type === MessageType.ACK) {
527
- // Optional ackMeta match (ignore mismatched ACK)
528
- if (ackMeta !== undefined && !isAckMetaEqual(ackMeta, data.ackMeta)) {
499
+ // Optional ack match (ignore mismatched ACK)
500
+ if (!isExpectedAckMatch(ack, data.ack)) {
529
501
  return;
530
502
  }
531
503
  // Remember server's creatorId as target server ID for future requests
532
- if (data.creatorId && !this._targetServerId) {
533
- this._targetServerId = data.creatorId;
534
- }
504
+ this.rememberTargetServerId(data.creatorId);
535
505
  // Switch to request timeout
536
506
  setRequestTimeout();
537
507
  return;
@@ -540,9 +510,7 @@ export class RequestIframeClientImpl {
540
510
  // Received ASYNC notification: this is an async task
541
511
  if (data.type === MessageType.ASYNC) {
542
512
  // Remember server's creatorId as target server ID for future requests
543
- if (data.creatorId && !this._targetServerId) {
544
- this._targetServerId = data.creatorId;
545
- }
513
+ this.rememberTargetServerId(data.creatorId);
546
514
  // Switch to async timeout
547
515
  setAsyncTimeout();
548
516
  return;
@@ -550,50 +518,40 @@ export class RequestIframeClientImpl {
550
518
 
551
519
  // Received stream start message
552
520
  if (data.type === MessageType.STREAM_START) {
553
- var _streamBody$chunked, _streamBody$autoResol;
554
521
  done = true;
555
522
  cleanup();
556
- var streamBody = data.body;
557
- var streamId = streamBody.streamId;
558
- var streamType = streamBody.type || StreamTypeConstant.DATA;
559
- var streamMode = streamBody.mode;
560
- var streamChunked = (_streamBody$chunked = streamBody.chunked) !== null && _streamBody$chunked !== void 0 ? _streamBody$chunked : true;
561
- var streamMetadata = streamBody.metadata;
562
- var autoResolve = (_streamBody$autoResol = streamBody.autoResolve) !== null && _streamBody$autoResol !== void 0 ? _streamBody$autoResol : false;
563
-
564
- // Create corresponding readable stream based on stream type
565
- if (streamType === StreamTypeConstant.FILE) {
566
- var _readableStream = new IframeFileReadableStream(streamId, requestId, this, {
567
- chunked: streamChunked,
568
- metadata: streamMetadata,
569
- secretKey: this.secretKey,
570
- idleTimeout: streamTimeout,
571
- heartbeat: () => this.isConnect(),
572
- mode: streamMode,
573
- filename: streamMetadata === null || streamMetadata === void 0 ? void 0 : streamMetadata.filename,
574
- mimeType: streamMetadata === null || streamMetadata === void 0 ? void 0 : streamMetadata.mimeType,
575
- size: streamMetadata === null || streamMetadata === void 0 ? void 0 : streamMetadata.size
576
- });
577
-
578
- // If autoResolve is enabled, automatically read and convert to File/Blob
579
- if (autoResolve) {
580
- var _data$headers;
581
- // Extract fileName from headers if available
582
- var contentDisposition = (_data$headers = data.headers) === null || _data$headers === void 0 ? void 0 : _data$headers[HttpHeader.CONTENT_DISPOSITION];
583
- var fileName;
584
- if (contentDisposition) {
585
- var disposition = typeof contentDisposition === 'string' ? contentDisposition : contentDisposition[0];
586
- var filenameMatch = disposition.match(/filename="?([^"]+)"?/i);
587
- if (filenameMatch) {
588
- fileName = filenameMatch[1];
589
- }
590
- }
591
- // Fallback to stream metadata if not found in headers
592
- fileName = fileName || (streamMetadata === null || streamMetadata === void 0 ? void 0 : streamMetadata.filename) || _readableStream.filename;
593
523
 
594
- // Use stream's readAsFile or readAsBlob method
595
- var fileDataPromise = fileName ? _readableStream.readAsFile(fileName) : _readableStream.readAsBlob();
596
- fileDataPromise.then(fileData => {
524
+ // Remember server's creatorId as target server ID for future requests
525
+ this.rememberTargetServerId(data.creatorId);
526
+ var created = createReadableStreamFromStart({
527
+ requestId,
528
+ data,
529
+ handler: this,
530
+ secretKey: this.secretKey,
531
+ idleTimeout: streamTimeout,
532
+ heartbeat: () => this.isConnect()
533
+ });
534
+ if (!created) {
535
+ fail(new RequestIframeError({
536
+ message: formatMessage(Messages.STREAM_ERROR, 'invalid stream_start'),
537
+ code: ErrorCode.STREAM_ERROR,
538
+ config: processedConfig,
539
+ requestId
540
+ }));
541
+ return;
542
+ }
543
+ var readableStream = created.stream,
544
+ info = created.info;
545
+
546
+ // File stream: optional auto-resolve to File/Blob
547
+ if (info.type === StreamTypeConstant.FILE) {
548
+ var fileStream = readableStream;
549
+ if (info.autoResolve) {
550
+ autoResolveIframeFileReadableStream({
551
+ fileStream,
552
+ info,
553
+ headers: data.headers
554
+ }).then(fileData => {
597
555
  var resp = {
598
556
  data: fileData,
599
557
  status: data.status || HttpStatus.OK,
@@ -607,32 +565,7 @@ export class RequestIframeClientImpl {
607
565
  }).catch(reject);
608
566
  return;
609
567
  }
610
-
611
- // Non-autoResolve: return file stream directly
612
- var _resp = {
613
- data: undefined,
614
- status: data.status || HttpStatus.OK,
615
- statusText: data.statusText || HttpStatusText[HttpStatus.OK],
616
- requestId,
617
- headers: data.headers,
618
- stream: _readableStream
619
- };
620
- runResponseInterceptors(this.interceptors.response, _resp).then(response => {
621
- resolve(returnData ? response.data : response);
622
- }).catch(reject);
623
- return;
624
568
  }
625
-
626
- // Non-file stream: create regular readable stream
627
- var readableStream = new IframeReadableStream(streamId, requestId, this, {
628
- type: streamType,
629
- mode: streamMode,
630
- chunked: streamChunked,
631
- metadata: streamMetadata,
632
- secretKey: this.secretKey,
633
- idleTimeout: streamTimeout,
634
- heartbeat: () => this.isConnect()
635
- });
636
569
  var resp = {
637
570
  data: undefined,
638
571
  status: data.status || HttpStatus.OK,
@@ -647,21 +580,13 @@ export class RequestIframeClientImpl {
647
580
  return;
648
581
  }
649
582
 
650
- // Received stream data/end/error/cancel message - dispatch to stream handler
651
- if (data.type.startsWith('stream_')) {
652
- this.dispatchStreamMessage(data);
653
- return;
654
- }
655
-
656
583
  // Received response
657
584
  if (data.type === MessageType.RESPONSE) {
658
585
  done = true;
659
586
  cleanup();
660
587
 
661
588
  // Remember server's creatorId as target server ID for future requests
662
- if (data.creatorId && !this._targetServerId) {
663
- this._targetServerId = data.creatorId;
664
- }
589
+ this.rememberTargetServerId(data.creatorId);
665
590
 
666
591
  // Parse and save server-set cookies (from Set-Cookie header)
667
592
  if (data.headers && data.headers[HttpHeader.SET_COOKIE]) {
@@ -680,14 +605,14 @@ export class RequestIframeClientImpl {
680
605
  _iterator.f();
681
606
  }
682
607
  }
683
- var _resp2 = {
608
+ var _resp = {
684
609
  data: data.data,
685
610
  status: data.status || HttpStatus.OK,
686
611
  statusText: data.statusText || HttpStatusText[HttpStatus.OK],
687
612
  requestId,
688
613
  headers: data.headers
689
614
  };
690
- runResponseInterceptors(this.interceptors.response, _resp2).then(response => {
615
+ runResponseInterceptors(this.interceptors.response, _resp).then(response => {
691
616
  resolve(returnData ? response.data : response);
692
617
  }).catch(reject);
693
618
  return;
@@ -697,9 +622,7 @@ export class RequestIframeClientImpl {
697
622
  if (data.type === MessageType.ERROR) {
698
623
  var _data$error, _data$error2;
699
624
  // Remember server's creatorId as target server ID for future requests
700
- if (data.creatorId && !this._targetServerId) {
701
- this._targetServerId = data.creatorId;
702
- }
625
+ this.rememberTargetServerId(data.creatorId);
703
626
  fail(new RequestIframeError({
704
627
  message: ((_data$error = data.error) === null || _data$error === void 0 ? void 0 : _data$error.message) || Messages.REQUEST_FAILED,
705
628
  code: ((_data$error2 = data.error) === null || _data$error2 === void 0 ? void 0 : _data$error2.code) || ErrorCode.REQUEST_ERROR,
@@ -740,7 +663,7 @@ export class RequestIframeClientImpl {
740
663
  cookies: mergedCookies,
741
664
  targetId,
742
665
  requireAck,
743
- ackMeta
666
+ ack
744
667
  };
745
668
  if (extraPayload !== null && extraPayload !== void 0 && extraPayload.streamId) {
746
669
  payload.streamId = extraPayload.streamId;
@@ -756,21 +679,21 @@ export class RequestIframeClientImpl {
756
679
  }));
757
680
  return;
758
681
  }
759
- this.server.messageDispatcher.sendMessage(this.targetWindow, this.targetOrigin, MessageType.REQUEST, requestId, payload);
682
+ this.outbox.sendMessage(MessageType.REQUEST, requestId, payload);
760
683
  });
761
684
  }
762
685
  /**
763
- * Get internal server instance (for debugging)
686
+ * Get internal hub instance (for debugging)
764
687
  */
765
- getServer() {
766
- return this.server;
688
+ getHub() {
689
+ return this.hub;
767
690
  }
768
691
 
769
692
  /**
770
693
  * Whether message handling is enabled
771
694
  */
772
695
  get isOpen() {
773
- return this.server.isOpen;
696
+ return this.hub.isOpen;
774
697
  }
775
698
 
776
699
  /**
@@ -785,14 +708,14 @@ export class RequestIframeClientImpl {
785
708
  * Enable message handling (register message handlers)
786
709
  */
787
710
  open() {
788
- this.server.open();
711
+ this.hub.open();
789
712
  }
790
713
 
791
714
  /**
792
715
  * Disable message handling (unregister message handlers, but don't release resources)
793
716
  */
794
717
  close() {
795
- this.server.close();
718
+ this.hub.close();
796
719
  }
797
720
 
798
721
  /**
@@ -803,14 +726,14 @@ export class RequestIframeClientImpl {
803
726
  this._cookieStore.clear();
804
727
 
805
728
  // Clear stream handlers
806
- this.streamHandlers.clear();
729
+ this.streamDispatcher.clear();
807
730
 
808
731
  // Clear interceptors
809
732
  this.interceptors.request.clear();
810
733
  this.interceptors.response.clear();
811
734
 
812
- // Destroy server (this will also release the message channel)
813
- this.server.destroy();
735
+ // Destroy core (this will also release the message channel)
736
+ this.hub.destroy();
814
737
  }
815
738
 
816
739
  /**