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.
Files changed (84) hide show
  1. package/QUICKSTART.CN.md +35 -8
  2. package/QUICKSTART.md +35 -8
  3. package/README.CN.md +439 -36
  4. package/README.md +496 -30
  5. package/library/__tests__/channel.test.ts +420 -0
  6. package/library/__tests__/coverage-branches.test.ts +356 -0
  7. package/library/__tests__/debug.test.ts +588 -0
  8. package/library/__tests__/dispatcher.test.ts +481 -0
  9. package/library/__tests__/requestIframe.test.ts +3163 -185
  10. package/library/__tests__/server.test.ts +738 -0
  11. package/library/__tests__/stream.test.ts +46 -15
  12. package/library/api/client.d.ts.map +1 -1
  13. package/library/api/client.js +12 -6
  14. package/library/api/server.d.ts +4 -3
  15. package/library/api/server.d.ts.map +1 -1
  16. package/library/api/server.js +25 -7
  17. package/library/constants/index.d.ts +14 -4
  18. package/library/constants/index.d.ts.map +1 -1
  19. package/library/constants/index.js +15 -7
  20. package/library/constants/messages.d.ts +37 -0
  21. package/library/constants/messages.d.ts.map +1 -1
  22. package/library/constants/messages.js +38 -1
  23. package/library/core/client-server.d.ts +105 -0
  24. package/library/core/client-server.d.ts.map +1 -0
  25. package/library/core/client-server.js +289 -0
  26. package/library/core/client.d.ts +53 -10
  27. package/library/core/client.d.ts.map +1 -1
  28. package/library/core/client.js +529 -207
  29. package/library/core/request.d.ts +3 -1
  30. package/library/core/request.d.ts.map +1 -1
  31. package/library/core/request.js +2 -1
  32. package/library/core/response.d.ts +30 -4
  33. package/library/core/response.d.ts.map +1 -1
  34. package/library/core/response.js +176 -100
  35. package/library/core/server-client.d.ts +3 -1
  36. package/library/core/server-client.d.ts.map +1 -1
  37. package/library/core/server-client.js +19 -9
  38. package/library/core/server.d.ts +22 -1
  39. package/library/core/server.d.ts.map +1 -1
  40. package/library/core/server.js +304 -55
  41. package/library/index.d.ts +3 -2
  42. package/library/index.d.ts.map +1 -1
  43. package/library/index.js +34 -5
  44. package/library/interceptors/index.d.ts.map +1 -1
  45. package/library/message/channel.d.ts +3 -1
  46. package/library/message/channel.d.ts.map +1 -1
  47. package/library/message/dispatcher.d.ts +7 -2
  48. package/library/message/dispatcher.d.ts.map +1 -1
  49. package/library/message/dispatcher.js +48 -2
  50. package/library/message/index.d.ts.map +1 -1
  51. package/library/stream/file-stream.d.ts +5 -0
  52. package/library/stream/file-stream.d.ts.map +1 -1
  53. package/library/stream/file-stream.js +41 -12
  54. package/library/stream/index.d.ts +11 -1
  55. package/library/stream/index.d.ts.map +1 -1
  56. package/library/stream/index.js +21 -3
  57. package/library/stream/readable-stream.d.ts.map +1 -1
  58. package/library/stream/readable-stream.js +32 -30
  59. package/library/stream/types.d.ts +20 -2
  60. package/library/stream/types.d.ts.map +1 -1
  61. package/library/stream/writable-stream.d.ts +2 -1
  62. package/library/stream/writable-stream.d.ts.map +1 -1
  63. package/library/stream/writable-stream.js +13 -10
  64. package/library/types/index.d.ts +106 -32
  65. package/library/types/index.d.ts.map +1 -1
  66. package/library/utils/cache.d.ts +24 -0
  67. package/library/utils/cache.d.ts.map +1 -1
  68. package/library/utils/cache.js +76 -0
  69. package/library/utils/cookie.d.ts.map +1 -1
  70. package/library/utils/debug.d.ts.map +1 -1
  71. package/library/utils/debug.js +382 -20
  72. package/library/utils/index.d.ts +19 -0
  73. package/library/utils/index.d.ts.map +1 -1
  74. package/library/utils/index.js +113 -2
  75. package/library/utils/path-match.d.ts +16 -0
  76. package/library/utils/path-match.d.ts.map +1 -1
  77. package/library/utils/path-match.js +65 -0
  78. package/library/utils/protocol.d.ts.map +1 -1
  79. package/package.json +4 -1
  80. package/react/library/__tests__/index.test.tsx +274 -281
  81. package/react/library/index.d.ts +4 -3
  82. package/react/library/index.d.ts.map +1 -1
  83. package/react/library/index.js +225 -158
  84. package/react/package.json +7 -0
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * Stream functionality tests
3
3
  */
4
+ import type { MessageChannel } from '../message';
4
5
  import {
5
6
  IframeWritableStream,
6
7
  IframeReadableStream,
7
8
  IframeFileWritableStream,
8
9
  IframeFileReadableStream,
9
10
  isIframeReadableStream,
10
- isIframeFileStream,
11
+ isIframeFileReadableStream,
12
+ isIframeFileWritableStream,
11
13
  StreamMessageHandler
12
14
  } from '../stream';
13
15
 
@@ -15,12 +17,17 @@ describe('Stream', () => {
15
17
  describe('IframeWritableStream', () => {
16
18
  let mockTargetWindow: Window;
17
19
  let mockPostMessage: jest.Mock;
20
+ /** Mock channel: only send() is used by WritableStream */
21
+ let mockChannel: MessageChannel;
18
22
 
19
23
  beforeEach(() => {
20
24
  mockPostMessage = jest.fn();
21
25
  mockTargetWindow = {
22
26
  postMessage: mockPostMessage
23
27
  } as any;
28
+ mockChannel = {
29
+ send: (target: Window, message: any, origin: string) => target.postMessage(message, origin)
30
+ } as unknown as MessageChannel;
24
31
  });
25
32
 
26
33
  it('should create stream with default options', () => {
@@ -69,7 +76,8 @@ describe('Stream', () => {
69
76
  requestId: 'req-123',
70
77
  targetWindow: mockTargetWindow,
71
78
  targetOrigin: 'https://example.com',
72
- secretKey: 'test'
79
+ secretKey: 'test',
80
+ channel: mockChannel
73
81
  });
74
82
 
75
83
  await stream.start();
@@ -98,7 +106,8 @@ describe('Stream', () => {
98
106
  requestId: 'req-123',
99
107
  targetWindow: mockTargetWindow,
100
108
  targetOrigin: 'https://example.com',
101
- secretKey: 'test'
109
+ secretKey: 'test',
110
+ channel: mockChannel
102
111
  });
103
112
 
104
113
  await stream.start();
@@ -115,7 +124,8 @@ describe('Stream', () => {
115
124
  requestId: 'req-123',
116
125
  targetWindow: mockTargetWindow,
117
126
  targetOrigin: 'https://example.com',
118
- secretKey: 'test'
127
+ secretKey: 'test',
128
+ channel: mockChannel
119
129
  });
120
130
 
121
131
  await stream.start();
@@ -136,7 +146,8 @@ describe('Stream', () => {
136
146
  requestId: 'req-123',
137
147
  targetWindow: mockTargetWindow,
138
148
  targetOrigin: 'https://example.com',
139
- secretKey: 'test'
149
+ secretKey: 'test',
150
+ channel: mockChannel
140
151
  });
141
152
 
142
153
  await stream.start();
@@ -159,7 +170,8 @@ describe('Stream', () => {
159
170
  requestId: 'req-123',
160
171
  targetWindow: mockTargetWindow,
161
172
  targetOrigin: 'https://example.com',
162
- secretKey: 'test'
173
+ secretKey: 'test',
174
+ channel: mockChannel
163
175
  });
164
176
 
165
177
  await stream.start();
@@ -174,7 +186,8 @@ describe('Stream', () => {
174
186
  requestId: 'req-123',
175
187
  targetWindow: mockTargetWindow,
176
188
  targetOrigin: 'https://example.com',
177
- secretKey: 'test'
189
+ secretKey: 'test',
190
+ channel: mockChannel
178
191
  });
179
192
 
180
193
  stream.cancel('User cancelled');
@@ -192,7 +205,8 @@ describe('Stream', () => {
192
205
  requestId: 'req-123',
193
206
  targetWindow: mockTargetWindow,
194
207
  targetOrigin: 'https://example.com',
195
- secretKey: 'test'
208
+ secretKey: 'test',
209
+ channel: mockChannel
196
210
  });
197
211
 
198
212
  // Manually set state to ended (simulating already ended)
@@ -237,7 +251,8 @@ describe('Stream', () => {
237
251
  requestId: 'req-123',
238
252
  targetWindow: mockTargetWindow,
239
253
  targetOrigin: 'https://example.com',
240
- secretKey: 'test'
254
+ secretKey: 'test',
255
+ channel: mockChannel
241
256
  });
242
257
 
243
258
  stream.cancel('User cancelled');
@@ -261,7 +276,8 @@ describe('Stream', () => {
261
276
  requestId: 'req-123',
262
277
  targetWindow: mockTargetWindow,
263
278
  targetOrigin: 'https://example.com',
264
- secretKey: 'test'
279
+ secretKey: 'test',
280
+ channel: mockChannel
265
281
  });
266
282
 
267
283
  await stream.start();
@@ -284,7 +300,8 @@ describe('Stream', () => {
284
300
  requestId: 'req-123',
285
301
  targetWindow: mockTargetWindow,
286
302
  targetOrigin: 'https://example.com',
287
- secretKey: 'test'
303
+ secretKey: 'test',
304
+ channel: mockChannel
288
305
  });
289
306
 
290
307
  const startPromise = stream.start();
@@ -637,14 +654,28 @@ describe('Stream', () => {
637
654
  expect(isIframeReadableStream('string')).toBe(false);
638
655
  });
639
656
 
640
- it('isIframeFileStream should return true for IframeFileReadableStream', () => {
657
+ it('isIframeFileReadableStream should return true for IframeFileReadableStream', () => {
641
658
  const stream = new IframeFileReadableStream('id', 'reqId', mockHandler);
642
- expect(isIframeFileStream(stream)).toBe(true);
659
+ expect(isIframeFileReadableStream(stream)).toBe(true);
643
660
  });
644
661
 
645
- it('isIframeFileStream should return false for regular IframeReadableStream', () => {
662
+ it('isIframeFileReadableStream should return false for regular IframeReadableStream', () => {
646
663
  const stream = new IframeReadableStream('id', 'reqId', mockHandler);
647
- expect(isIframeFileStream(stream)).toBe(false);
664
+ expect(isIframeFileReadableStream(stream)).toBe(false);
665
+ });
666
+
667
+ it('isIframeFileWritableStream should return true for IframeFileWritableStream', () => {
668
+ const stream = new IframeFileWritableStream({
669
+ filename: 'test.txt',
670
+ mimeType: 'text/plain',
671
+ next: async () => ({ data: btoa('test'), done: true })
672
+ });
673
+ expect(isIframeFileWritableStream(stream)).toBe(true);
674
+ });
675
+
676
+ it('isIframeFileWritableStream should return false for regular IframeWritableStream', () => {
677
+ const stream = new IframeWritableStream();
678
+ expect(isIframeFileWritableStream(stream)).toBe(false);
648
679
  });
649
680
  });
650
681
  });
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAO1F;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,GAAG,MAAM,EAClC,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CA0CrB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAKtE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAO1F;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,GAAG,MAAM,EAClC,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CAgDrB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAKtE"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.clearRequestIframeClientCache = clearRequestIframeClientCache;
7
7
  exports.requestIframeClient = requestIframeClient;
8
8
  var _utils = require("../utils");
9
- var _serverClient = require("../core/server-client");
9
+ var _clientServer = require("../core/client-server");
10
10
  var _client = require("../core/client");
11
11
  var _debug = require("../utils/debug");
12
12
  var _constants = require("../constants");
@@ -39,19 +39,25 @@ function requestIframeClient(target, options) {
39
39
  // Determine secretKey
40
40
  var secretKey = options === null || options === void 0 ? void 0 : options.secretKey;
41
41
 
42
+ // Generate instance ID first (will be used by both client and server)
43
+ var instanceId = (0, _utils.generateInstanceId)();
44
+
42
45
  // Create ClientServer (internally obtains or creates a shared MessageChannel)
43
- var server = new _serverClient.RequestIframeClientServer({
46
+ var server = new _clientServer.RequestIframeClientServer({
44
47
  secretKey,
45
- ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout
46
- });
48
+ ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
49
+ autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen
50
+ }, instanceId);
47
51
 
48
52
  // Create client instance
49
53
  var client = new _client.RequestIframeClientImpl(targetWindow, targetOrigin, server, {
50
54
  secretKey,
51
55
  ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
52
56
  timeout: options === null || options === void 0 ? void 0 : options.timeout,
53
- asyncTimeout: options === null || options === void 0 ? void 0 : options.asyncTimeout
54
- });
57
+ asyncTimeout: options === null || options === void 0 ? void 0 : options.asyncTimeout,
58
+ returnData: options === null || options === void 0 ? void 0 : options.returnData,
59
+ headers: options === null || options === void 0 ? void 0 : options.headers
60
+ }, instanceId);
55
61
 
56
62
  // If trace mode is enabled, register debug interceptors
57
63
  if (options !== null && options !== void 0 && options.trace) {
@@ -4,13 +4,14 @@ import { RequestIframeServer, RequestIframeServerOptions } from '../types';
4
4
  *
5
5
  * Note:
6
6
  * - MessageChannel is cached at the window level by secretKey (ensures unique message listener)
7
- * - Server instances are not cached, a new instance is created on each call
7
+ * - If options.id is specified, the server will be cached and reused (singleton pattern)
8
+ * - If options.id is not specified, a new instance is created on each call
8
9
  * - This allows different versions of the library to coexist
9
10
  */
10
11
  export declare function requestIframeServer(options?: RequestIframeServerOptions): RequestIframeServer;
11
12
  /**
12
- * Clear MessageChannel cache (for testing or reset)
13
- * Note: This clears the shared message channel for the specified secretKey
13
+ * Clear server cache (for testing or reset)
14
+ * Note: This clears the cached server instances
14
15
  */
15
16
  export declare function clearRequestIframeServerCache(secretKey?: string): void;
16
17
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAI3E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CAgBrB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAKtE"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAK3E;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CAgCrB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAKtE"}
@@ -7,38 +7,56 @@ exports.clearRequestIframeServerCache = clearRequestIframeServerCache;
7
7
  exports.requestIframeServer = requestIframeServer;
8
8
  var _server = require("../core/server");
9
9
  var _debug = require("../utils/debug");
10
+ var _cache = require("../utils/cache");
10
11
  /**
11
12
  * Create a server (for receiving and handling requests)
12
13
  *
13
14
  * Note:
14
15
  * - MessageChannel is cached at the window level by secretKey (ensures unique message listener)
15
- * - Server instances are not cached, a new instance is created on each call
16
+ * - If options.id is specified, the server will be cached and reused (singleton pattern)
17
+ * - If options.id is not specified, a new instance is created on each call
16
18
  * - This allows different versions of the library to coexist
17
19
  */
18
20
  function requestIframeServer(options) {
19
- // Determine secretKey
21
+ // Determine secretKey and id
20
22
  var secretKey = options === null || options === void 0 ? void 0 : options.secretKey;
23
+ var id = options === null || options === void 0 ? void 0 : options.id;
24
+
25
+ // If id is specified, check cache first
26
+ if (id) {
27
+ var cached = (0, _cache.getCachedServer)(secretKey, id);
28
+ if (cached) {
29
+ return cached;
30
+ }
31
+ }
21
32
 
22
33
  // Create server (internally obtains or creates a shared MessageChannel)
23
34
  var server = new _server.RequestIframeServerImpl({
24
35
  secretKey,
25
- ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout
36
+ id,
37
+ ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
38
+ autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen
26
39
  });
27
40
 
28
41
  // If trace mode is enabled, register debug listeners
29
42
  if (options !== null && options !== void 0 && options.trace) {
30
43
  (0, _debug.setupServerDebugListeners)(server);
31
44
  }
45
+
46
+ // Cache server if id is specified
47
+ if (id) {
48
+ (0, _cache.cacheServer)(server, secretKey, id);
49
+ }
32
50
  return server;
33
51
  }
34
52
 
35
53
  /**
36
- * Clear MessageChannel cache (for testing or reset)
37
- * Note: This clears the shared message channel for the specified secretKey
54
+ * Clear server cache (for testing or reset)
55
+ * Note: This clears the cached server instances
38
56
  */
39
57
  function clearRequestIframeServerCache(secretKey) {
40
- // Now server is no longer cached, only need to clear MessageChannel cache
58
+ // Clear server cache
59
+ (0, _cache.clearServerCache)();
41
60
  // MessageChannel cleanup is handled by clearMessageChannelCache in cache.ts
42
- // Empty implementation kept here to maintain API compatibility
43
61
  void secretKey;
44
62
  }
@@ -111,18 +111,28 @@ export declare const MessageType: {
111
111
  /** Stream cancel */
112
112
  readonly STREAM_CANCEL: "stream_cancel";
113
113
  };
114
+ export declare const MessageRole: {
115
+ /** Server role */
116
+ readonly SERVER: "server";
117
+ /** Client role */
118
+ readonly CLIENT: "client";
119
+ };
120
+ export type MessageRoleValue = typeof MessageRole[keyof typeof MessageRole];
114
121
  /**
115
122
  * Default timeout configuration (milliseconds)
116
123
  */
117
124
  export declare const DefaultTimeout: {
118
- /** ACK confirmation timeout: 500ms (client waiting for server confirmation) */
119
- readonly ACK: 500;
125
+ /**
126
+ * ACK confirmation timeout: 1000ms (1s)
127
+ * Used for both client waiting for server ACK and server waiting for client RECEIVED.
128
+ * Increased from 500ms to accommodate slower environments or busy browsers where postMessage
129
+ * serialization/deserialization may take longer.
130
+ */
131
+ readonly ACK: 1000;
120
132
  /** Request timeout: 5s */
121
133
  readonly REQUEST: 5000;
122
134
  /** Async request timeout: 120s */
123
135
  readonly ASYNC: 120000;
124
- /** Server waiting for client confirmation timeout: 5s (server waiting for client to confirm response received) */
125
- readonly SERVER_ACK: 5000;
126
136
  };
127
137
  /**
128
138
  * HTTP Header name constants
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;IAC1B,+BAA+B;;IAE/B,wFAAwF;;CAEhF,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,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MessageType = exports.HttpStatusText = exports.HttpStatus = exports.HttpHeader = exports.ErrorCode = exports.DefaultTimeout = void 0;
6
+ exports.MessageType = exports.MessageRole = exports.HttpStatusText = exports.HttpStatus = exports.HttpHeader = exports.ErrorCode = exports.DefaultTimeout = void 0;
7
7
  Object.defineProperty(exports, "Messages", {
8
8
  enumerable: true,
9
9
  get: function get() {
@@ -159,19 +159,27 @@ var MessageType = exports.MessageType = {
159
159
  /** Stream cancel */
160
160
  STREAM_CANCEL: 'stream_cancel'
161
161
  };
162
-
162
+ var MessageRole = exports.MessageRole = {
163
+ /** Server role */
164
+ SERVER: 'server',
165
+ /** Client role */
166
+ CLIENT: 'client'
167
+ };
163
168
  /**
164
169
  * Default timeout configuration (milliseconds)
165
170
  */
166
171
  var DefaultTimeout = exports.DefaultTimeout = {
167
- /** ACK confirmation timeout: 500ms (client waiting for server confirmation) */
168
- ACK: 500,
172
+ /**
173
+ * ACK confirmation timeout: 1000ms (1s)
174
+ * Used for both client waiting for server ACK and server waiting for client RECEIVED.
175
+ * Increased from 500ms to accommodate slower environments or busy browsers where postMessage
176
+ * serialization/deserialization may take longer.
177
+ */
178
+ ACK: 1000,
169
179
  /** Request timeout: 5s */
170
180
  REQUEST: 5000,
171
181
  /** Async request timeout: 120s */
172
- ASYNC: 120000,
173
- /** Server waiting for client confirmation timeout: 5s (server waiting for client to confirm response received) */
174
- SERVER_ACK: 5000
182
+ ASYNC: 120000
175
183
  };
176
184
 
177
185
  /**
@@ -33,6 +33,8 @@ declare const defaultMessages: {
33
33
  readonly ERROR: "Error";
34
34
  /** Client errors */
35
35
  readonly IFRAME_NOT_READY: "iframe.contentWindow is not available";
36
+ /** ClientServer warnings */
37
+ readonly CLIENT_SERVER_IGNORED_MESSAGE_WHEN_CLOSED: "Ignored message because client server is closed/destroyed (type: {0}, requestId: {1})";
36
38
  /** Stream related messages */
37
39
  readonly STREAM_NOT_BOUND: "Stream is not bound to a request context";
38
40
  readonly STREAM_ALREADY_STARTED: "Stream has already started";
@@ -40,6 +42,41 @@ declare const defaultMessages: {
40
42
  readonly STREAM_ERROR: "Stream error: {0}";
41
43
  readonly STREAM_ENDED: "Stream has ended";
42
44
  readonly STREAM_READ_ERROR: "Failed to read stream data";
45
+ /** Debug messages - Client */
46
+ readonly DEBUG_CLIENT_REQUEST_START: "📤 [Client] Request Start";
47
+ readonly DEBUG_CLIENT_REQUEST_SUCCESS: "✅ [Client] Request Success";
48
+ readonly DEBUG_CLIENT_REQUEST_SUCCESS_FILE: "✅ [Client] Request Success (File)";
49
+ readonly DEBUG_CLIENT_REQUEST_SUCCESS_STREAM: "✅ [Client] Request Success (Stream)";
50
+ readonly DEBUG_CLIENT_REQUEST_FAILED: "❌ [Client] Request Failed";
51
+ readonly DEBUG_CLIENT_RECEIVED_ACK: "📥 [Client] Received ACK";
52
+ readonly DEBUG_CLIENT_RECEIVED_ASYNC: "⏳ [Client] Received ASYNC Notification";
53
+ readonly DEBUG_CLIENT_RECEIVED_STREAM_START: "🌊 [Client] Received Stream Start";
54
+ readonly DEBUG_CLIENT_RECEIVED_STREAM_DATA: "🌊 [Client] Received Stream Data";
55
+ readonly DEBUG_CLIENT_RECEIVED_STREAM_END: "🌊 [Client] Received Stream End";
56
+ readonly DEBUG_CLIENT_RECEIVED_RESPONSE: "📥 [Client] Received Response";
57
+ readonly DEBUG_CLIENT_RECEIVED_ERROR: "📥 [Client] Received Error";
58
+ readonly DEBUG_CLIENT_REQUEST_TIMEOUT: "⏱️ [Client] Request Timeout";
59
+ readonly DEBUG_CLIENT_SENDING_REQUEST: "📤 [Client] Sending Request";
60
+ readonly DEBUG_CLIENT_SENDING_PING: "📤 [Client] Sending Ping";
61
+ readonly DEBUG_CLIENT_SENDING_RECEIVED_ACK: "📤 [Client] Sending Received ACK";
62
+ /** Debug messages - Server */
63
+ readonly DEBUG_SERVER_RECEIVED_REQUEST: "📥 [Server] Received Request";
64
+ readonly DEBUG_SERVER_SETTING_STATUS_CODE: "📝 [Server] Setting Status Code";
65
+ readonly DEBUG_SERVER_SETTING_HEADER: "📝 [Server] Setting Header";
66
+ readonly DEBUG_SERVER_SENDING_RESPONSE: "📤 [Server] Sending Response";
67
+ readonly DEBUG_SERVER_SENDING_JSON_RESPONSE: "📤 [Server] Sending JSON Response";
68
+ readonly DEBUG_SERVER_SENDING_FILE: "📤 [Server] Sending File";
69
+ readonly DEBUG_SERVER_SENDING_STREAM: "📤 [Server] Sending Stream";
70
+ readonly DEBUG_SERVER_SENDING_ACK: "📤 [Server] Sending ACK";
71
+ readonly DEBUG_SERVER_SENDING_ASYNC: "📤 [Server] Sending ASYNC Notification";
72
+ readonly DEBUG_SERVER_SENDING_STREAM_START: "🌊 [Server] Sending Stream Start";
73
+ readonly DEBUG_SERVER_SENDING_STREAM_DATA: "🌊 [Server] Sending Stream Data";
74
+ readonly DEBUG_SERVER_SENDING_STREAM_END: "🌊 [Server] Sending Stream End";
75
+ readonly DEBUG_SERVER_SENDING_ERROR: "📤 [Server] Sending Error";
76
+ readonly DEBUG_SERVER_SENDING_RESPONSE_VIA_DISPATCHER: "📤 [Server] Sending Response (via dispatcher)";
77
+ readonly DEBUG_SERVER_HANDLING_REQUEST: "📥 [Server] Handling Request";
78
+ readonly DEBUG_SERVER_EXECUTING_MIDDLEWARE_CHAIN: "⚙️ [Server] Executing Middleware Chain";
79
+ readonly DEBUG_SERVER_MIDDLEWARE_CHAIN_COMPLETED: "✅ [Server] Middleware Chain Completed";
43
80
  };
44
81
  /**
45
82
  * Message type
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,QAAA,MAAM,eAAe;IACnB,8BAA8B;;;;IAK9B,4BAA4B;;;;;IAM5B,qBAAqB;;;;IAKrB,8BAA8B;;;;;;IAO9B,oBAAoB;;IAGpB,8BAA8B;;;;;;;CAOtB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG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gB,aAAa,IAAI,IAAI,CAEpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAKpF;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAElE"}
@@ -53,13 +53,50 @@ var defaultMessages = {
53
53
  ERROR: 'Error',
54
54
  /** Client errors */
55
55
  IFRAME_NOT_READY: 'iframe.contentWindow is not available',
56
+ /** ClientServer warnings */
57
+ CLIENT_SERVER_IGNORED_MESSAGE_WHEN_CLOSED: 'Ignored message because client server is closed/destroyed (type: {0}, requestId: {1})',
56
58
  /** Stream related messages */
57
59
  STREAM_NOT_BOUND: 'Stream is not bound to a request context',
58
60
  STREAM_ALREADY_STARTED: 'Stream has already started',
59
61
  STREAM_CANCELLED: 'Stream was cancelled: {0}',
60
62
  STREAM_ERROR: 'Stream error: {0}',
61
63
  STREAM_ENDED: 'Stream has ended',
62
- STREAM_READ_ERROR: 'Failed to read stream data'
64
+ STREAM_READ_ERROR: 'Failed to read stream data',
65
+ /** Debug messages - Client */
66
+ DEBUG_CLIENT_REQUEST_START: '📤 [Client] Request Start',
67
+ DEBUG_CLIENT_REQUEST_SUCCESS: '✅ [Client] Request Success',
68
+ DEBUG_CLIENT_REQUEST_SUCCESS_FILE: '✅ [Client] Request Success (File)',
69
+ DEBUG_CLIENT_REQUEST_SUCCESS_STREAM: '✅ [Client] Request Success (Stream)',
70
+ DEBUG_CLIENT_REQUEST_FAILED: '❌ [Client] Request Failed',
71
+ DEBUG_CLIENT_RECEIVED_ACK: '📥 [Client] Received ACK',
72
+ DEBUG_CLIENT_RECEIVED_ASYNC: '⏳ [Client] Received ASYNC Notification',
73
+ DEBUG_CLIENT_RECEIVED_STREAM_START: '🌊 [Client] Received Stream Start',
74
+ DEBUG_CLIENT_RECEIVED_STREAM_DATA: '🌊 [Client] Received Stream Data',
75
+ DEBUG_CLIENT_RECEIVED_STREAM_END: '🌊 [Client] Received Stream End',
76
+ DEBUG_CLIENT_RECEIVED_RESPONSE: '📥 [Client] Received Response',
77
+ DEBUG_CLIENT_RECEIVED_ERROR: '📥 [Client] Received Error',
78
+ DEBUG_CLIENT_REQUEST_TIMEOUT: '⏱️ [Client] Request Timeout',
79
+ DEBUG_CLIENT_SENDING_REQUEST: '📤 [Client] Sending Request',
80
+ DEBUG_CLIENT_SENDING_PING: '📤 [Client] Sending Ping',
81
+ DEBUG_CLIENT_SENDING_RECEIVED_ACK: '📤 [Client] Sending Received ACK',
82
+ /** Debug messages - Server */
83
+ DEBUG_SERVER_RECEIVED_REQUEST: '📥 [Server] Received Request',
84
+ DEBUG_SERVER_SETTING_STATUS_CODE: '📝 [Server] Setting Status Code',
85
+ DEBUG_SERVER_SETTING_HEADER: '📝 [Server] Setting Header',
86
+ DEBUG_SERVER_SENDING_RESPONSE: '📤 [Server] Sending Response',
87
+ DEBUG_SERVER_SENDING_JSON_RESPONSE: '📤 [Server] Sending JSON Response',
88
+ DEBUG_SERVER_SENDING_FILE: '📤 [Server] Sending File',
89
+ DEBUG_SERVER_SENDING_STREAM: '📤 [Server] Sending Stream',
90
+ DEBUG_SERVER_SENDING_ACK: '📤 [Server] Sending ACK',
91
+ DEBUG_SERVER_SENDING_ASYNC: '📤 [Server] Sending ASYNC Notification',
92
+ DEBUG_SERVER_SENDING_STREAM_START: '🌊 [Server] Sending Stream Start',
93
+ DEBUG_SERVER_SENDING_STREAM_DATA: '🌊 [Server] Sending Stream Data',
94
+ DEBUG_SERVER_SENDING_STREAM_END: '🌊 [Server] Sending Stream End',
95
+ DEBUG_SERVER_SENDING_ERROR: '📤 [Server] Sending Error',
96
+ DEBUG_SERVER_SENDING_RESPONSE_VIA_DISPATCHER: '📤 [Server] Sending Response (via dispatcher)',
97
+ DEBUG_SERVER_HANDLING_REQUEST: '📥 [Server] Handling Request',
98
+ DEBUG_SERVER_EXECUTING_MIDDLEWARE_CHAIN: '⚙️ [Server] Executing Middleware Chain',
99
+ DEBUG_SERVER_MIDDLEWARE_CHAIN_COMPLETED: '✅ [Server] Middleware Chain Completed'
63
100
  };
64
101
 
65
102
  /**
@@ -0,0 +1,105 @@
1
+ import { PostMessageData } from '../types';
2
+ import { MessageDispatcher, VersionValidator, MessageContext } from '../message';
3
+ /**
4
+ * Stream message handler callback
5
+ */
6
+ export type StreamMessageCallback = (data: PostMessageData, context: MessageContext) => void;
7
+ /**
8
+ * ClientServer configuration options
9
+ */
10
+ export interface ClientServerOptions {
11
+ /** Message isolation key */
12
+ secretKey?: string;
13
+ /** ACK timeout */
14
+ ackTimeout?: number;
15
+ /** Protocol version validator (optional, uses built-in validation by default) */
16
+ versionValidator?: VersionValidator;
17
+ /** Whether to automatically open when creating the client server. Default is true. */
18
+ autoOpen?: boolean;
19
+ }
20
+ /**
21
+ * RequestIframeClientServer - Client-side message server
22
+ * Only handles responses, not requests
23
+ * Uses shared MessageDispatcher (backed by MessageChannel) to listen for and send messages
24
+ */
25
+ export declare class RequestIframeClientServer {
26
+ private readonly dispatcher;
27
+ private readonly ackTimeout;
28
+ private readonly versionValidator;
29
+ /** Pending responses awaiting client acknowledgment */
30
+ private readonly pendingAcks;
31
+ /** Pending requests awaiting response */
32
+ private readonly pendingRequests;
33
+ /**
34
+ * Avoid spamming logs for the same requestId when closed/destroyed
35
+ */
36
+ private readonly warnedMissingPendingWhenClosed;
37
+ /** Stream message callback */
38
+ private streamCallback?;
39
+ /** List of unregister handler functions */
40
+ private readonly unregisterFns;
41
+ /** Whether opened */
42
+ private _isOpen;
43
+ constructor(options?: ClientServerOptions, instanceId?: string);
44
+ /**
45
+ * Open message handling (register message handlers)
46
+ */
47
+ open(): void;
48
+ /**
49
+ * Close message handling (unregister message handlers, but don't release channel)
50
+ */
51
+ close(): void;
52
+ /**
53
+ * Whether opened
54
+ */
55
+ get isOpen(): boolean;
56
+ /**
57
+ * Register message handlers
58
+ */
59
+ private registerHandlers;
60
+ /**
61
+ * Handle protocol version error
62
+ */
63
+ private handleVersionError;
64
+ /**
65
+ * Handle client response
66
+ */
67
+ private handleClientResponse;
68
+ /**
69
+ * Handle received acknowledgment
70
+ */
71
+ private handleReceived;
72
+ /**
73
+ * Handle pong
74
+ */
75
+ private handlePong;
76
+ /**
77
+ * Set stream message handler callback
78
+ */
79
+ setStreamCallback(callback: StreamMessageCallback): void;
80
+ /** Get secretKey */
81
+ get secretKey(): string | undefined;
82
+ /** Get the underlying MessageDispatcher */
83
+ get messageDispatcher(): MessageDispatcher;
84
+ /**
85
+ * Register pending acknowledgment response
86
+ */
87
+ _registerPendingAck(requestId: string, resolve: (received: boolean) => void, reject: (error: Error) => void): void;
88
+ /**
89
+ * Register pending request awaiting response
90
+ */
91
+ _registerPendingRequest(requestId: string, resolve: (data: PostMessageData) => void, reject: (error: Error) => void, origin?: string): void;
92
+ /**
93
+ * Cancel pending response
94
+ */
95
+ _unregisterPendingRequest(requestId: string): void;
96
+ /**
97
+ * Send ping message
98
+ */
99
+ sendPing(targetWindow: Window, targetOrigin: string, requestId: string): void;
100
+ /**
101
+ * Destroy (close and release channel reference)
102
+ */
103
+ destroy(): void;
104
+ }
105
+ //# sourceMappingURL=client-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-server.d.ts","sourceRoot":"","sources":["../../src/core/client-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;AAoB7F;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM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