request-iframe 0.0.5 → 0.1.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 (142) hide show
  1. package/README.CN.md +54 -7
  2. package/README.md +64 -11
  3. package/esm/api/client.js +79 -0
  4. package/esm/api/server.js +59 -0
  5. package/esm/constants/index.js +257 -0
  6. package/esm/constants/messages.js +155 -0
  7. package/esm/core/client-server.js +329 -0
  8. package/esm/core/client.js +873 -0
  9. package/esm/core/request.js +27 -0
  10. package/esm/core/response.js +451 -0
  11. package/esm/core/server.js +767 -0
  12. package/esm/index.js +21 -0
  13. package/esm/interceptors/index.js +122 -0
  14. package/esm/message/channel.js +181 -0
  15. package/esm/message/dispatcher.js +380 -0
  16. package/esm/message/index.js +2 -0
  17. package/esm/stream/file-stream.js +289 -0
  18. package/esm/stream/index.js +44 -0
  19. package/esm/stream/readable-stream.js +500 -0
  20. package/esm/stream/stream-core.js +91 -0
  21. package/esm/stream/types.js +1 -0
  22. package/esm/stream/writable-stream.js +582 -0
  23. package/esm/types/index.js +1 -0
  24. package/esm/utils/ack-meta.js +53 -0
  25. package/esm/utils/cache.js +147 -0
  26. package/esm/utils/cookie.js +352 -0
  27. package/esm/utils/debug.js +521 -0
  28. package/esm/utils/error.js +27 -0
  29. package/esm/utils/index.js +178 -0
  30. package/esm/utils/origin.js +28 -0
  31. package/esm/utils/path-match.js +148 -0
  32. package/esm/utils/protocol.js +157 -0
  33. package/library/api/client.d.ts.map +1 -1
  34. package/library/api/client.js +8 -1
  35. package/library/api/server.d.ts.map +1 -1
  36. package/library/api/server.js +4 -1
  37. package/library/constants/index.d.ts +25 -1
  38. package/library/constants/index.d.ts.map +1 -1
  39. package/library/constants/index.js +30 -5
  40. package/library/constants/messages.d.ts +5 -0
  41. package/library/constants/messages.d.ts.map +1 -1
  42. package/library/constants/messages.js +5 -0
  43. package/library/core/client-server.d.ts +3 -2
  44. package/library/core/client-server.d.ts.map +1 -1
  45. package/library/core/client-server.js +51 -4
  46. package/library/core/client.d.ts +4 -1
  47. package/library/core/client.d.ts.map +1 -1
  48. package/library/core/client.js +74 -31
  49. package/library/core/response.d.ts +21 -3
  50. package/library/core/response.d.ts.map +1 -1
  51. package/library/core/response.js +46 -6
  52. package/library/core/server.d.ts +28 -1
  53. package/library/core/server.d.ts.map +1 -1
  54. package/library/core/server.js +180 -19
  55. package/library/message/channel.d.ts +6 -0
  56. package/library/message/channel.d.ts.map +1 -1
  57. package/library/message/dispatcher.d.ts +22 -0
  58. package/library/message/dispatcher.d.ts.map +1 -1
  59. package/library/message/dispatcher.js +92 -0
  60. package/library/stream/file-stream.d.ts +4 -0
  61. package/library/stream/file-stream.d.ts.map +1 -1
  62. package/library/stream/file-stream.js +61 -33
  63. package/library/stream/index.d.ts.map +1 -1
  64. package/library/stream/index.js +2 -0
  65. package/library/stream/readable-stream.d.ts +30 -11
  66. package/library/stream/readable-stream.d.ts.map +1 -1
  67. package/library/stream/readable-stream.js +329 -73
  68. package/library/stream/stream-core.d.ts +44 -0
  69. package/library/stream/stream-core.d.ts.map +1 -0
  70. package/library/stream/stream-core.js +98 -0
  71. package/library/stream/types.d.ts +90 -3
  72. package/library/stream/types.d.ts.map +1 -1
  73. package/library/stream/writable-stream.d.ts +40 -12
  74. package/library/stream/writable-stream.d.ts.map +1 -1
  75. package/library/stream/writable-stream.js +391 -195
  76. package/library/types/index.d.ts +70 -3
  77. package/library/types/index.d.ts.map +1 -1
  78. package/library/utils/ack-meta.d.ts +2 -0
  79. package/library/utils/ack-meta.d.ts.map +1 -0
  80. package/library/utils/ack-meta.js +59 -0
  81. package/library/utils/index.d.ts +1 -0
  82. package/library/utils/index.d.ts.map +1 -1
  83. package/library/utils/index.js +16 -0
  84. package/library/utils/origin.d.ts +14 -0
  85. package/library/utils/origin.d.ts.map +1 -0
  86. package/library/utils/origin.js +34 -0
  87. package/package.json +31 -7
  88. package/react/README.md +16 -0
  89. package/react/esm/index.js +284 -0
  90. package/react/library/index.d.ts +1 -1
  91. package/react/library/index.d.ts.map +1 -1
  92. package/react/library/index.js +7 -4
  93. package/react/package.json +24 -2
  94. package/library/__tests__/channel.test.ts +0 -432
  95. package/library/__tests__/coverage-branches.test.ts +0 -356
  96. package/library/__tests__/debug.test.ts +0 -610
  97. package/library/__tests__/dispatcher.test.ts +0 -485
  98. package/library/__tests__/interceptors.test.ts +0 -146
  99. package/library/__tests__/requestIframe.test.ts +0 -5590
  100. package/library/__tests__/server.test.ts +0 -738
  101. package/library/__tests__/stream.test.ts +0 -726
  102. package/library/__tests__/utils.test.ts +0 -473
  103. package/library/api/client.d.js +0 -5
  104. package/library/api/server.d.js +0 -5
  105. package/library/constants/index.d.js +0 -36
  106. package/library/constants/messages.d.js +0 -5
  107. package/library/core/client.d.js +0 -5
  108. package/library/core/message-handler.d.ts +0 -110
  109. package/library/core/message-handler.d.ts.map +0 -1
  110. package/library/core/message-handler.js +0 -320
  111. package/library/core/request-response.d.ts +0 -59
  112. package/library/core/request-response.d.ts.map +0 -1
  113. package/library/core/request-response.js +0 -337
  114. package/library/core/request.d.js +0 -5
  115. package/library/core/response.d.js +0 -5
  116. package/library/core/server-base.d.ts +0 -86
  117. package/library/core/server-base.d.ts.map +0 -1
  118. package/library/core/server-base.js +0 -257
  119. package/library/core/server-client.d.js +0 -5
  120. package/library/core/server-client.d.ts +0 -101
  121. package/library/core/server-client.d.ts.map +0 -1
  122. package/library/core/server-client.js +0 -266
  123. package/library/core/server.d.js +0 -5
  124. package/library/interceptors/index.d.js +0 -5
  125. package/library/message/channel.d.js +0 -5
  126. package/library/message/dispatcher.d.js +0 -5
  127. package/library/message/index.d.js +0 -25
  128. package/library/stream/file-stream.d.js +0 -4
  129. package/library/stream/index.d.js +0 -58
  130. package/library/stream/readable-stream.d.js +0 -5
  131. package/library/stream/types.d.js +0 -5
  132. package/library/stream/writable-stream.d.js +0 -5
  133. package/library/types/index.d.js +0 -5
  134. package/library/utils/cache.d.js +0 -5
  135. package/library/utils/cookie.d.js +0 -5
  136. package/library/utils/debug.d.js +0 -5
  137. package/library/utils/index.d.js +0 -94
  138. package/library/utils/path-match.d.js +0 -5
  139. package/library/utils/protocol.d.js +0 -5
  140. package/react/library/__tests__/index.test.d.ts +0 -2
  141. package/react/library/__tests__/index.test.d.ts.map +0 -1
  142. package/react/library/__tests__/index.test.tsx +0 -792
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Protocol version constants
3
+ * Used to identify the protocol version of messages, for compatibility handling in future version upgrades
4
+ *
5
+ * Version compatibility strategy:
6
+ * - Only check minimum supported version, reject deprecated old versions
7
+ * - Don't check maximum version, as new versions usually maintain backward compatibility with old message formats
8
+ * - This way new version servers can be compatible with old version clients, without forcing client upgrades
9
+ */
10
+ export var ProtocolVersion = {
11
+ /** Current protocol version */
12
+ CURRENT: 2,
13
+ /** Minimum supported protocol version (messages below this version will be rejected) */
14
+ MIN_SUPPORTED: 1
15
+ };
16
+
17
+ /**
18
+ * Protocol version type
19
+ */
20
+
21
+ /**
22
+ * Protocol validation result
23
+ */
24
+
25
+ /**
26
+ * HTTP status code constants
27
+ */
28
+ export var HttpStatus = {
29
+ OK: 200,
30
+ CREATED: 201,
31
+ NO_CONTENT: 204,
32
+ BAD_REQUEST: 400,
33
+ UNAUTHORIZED: 401,
34
+ FORBIDDEN: 403,
35
+ NOT_FOUND: 404,
36
+ REQUEST_TIMEOUT: 408,
37
+ TOO_MANY_REQUESTS: 429,
38
+ INTERNAL_SERVER_ERROR: 500,
39
+ BAD_GATEWAY: 502,
40
+ SERVICE_UNAVAILABLE: 503
41
+ };
42
+
43
+ /**
44
+ * HTTP status text constants
45
+ */
46
+ export var HttpStatusText = {
47
+ [HttpStatus.OK]: 'OK',
48
+ [HttpStatus.CREATED]: 'Created',
49
+ [HttpStatus.NO_CONTENT]: 'No Content',
50
+ [HttpStatus.BAD_REQUEST]: 'Bad Request',
51
+ [HttpStatus.UNAUTHORIZED]: 'Unauthorized',
52
+ [HttpStatus.FORBIDDEN]: 'Forbidden',
53
+ [HttpStatus.NOT_FOUND]: 'Not Found',
54
+ [HttpStatus.REQUEST_TIMEOUT]: 'Request Timeout',
55
+ [HttpStatus.TOO_MANY_REQUESTS]: 'Too Many Requests',
56
+ [HttpStatus.INTERNAL_SERVER_ERROR]: 'Internal Server Error',
57
+ [HttpStatus.BAD_GATEWAY]: 'Bad Gateway',
58
+ [HttpStatus.SERVICE_UNAVAILABLE]: 'Service Unavailable'
59
+ };
60
+
61
+ /**
62
+ * Get status text
63
+ */
64
+ export function getStatusText(code) {
65
+ return HttpStatusText[code] || 'Unknown';
66
+ }
67
+
68
+ /**
69
+ * Error code constants
70
+ */
71
+ export var ErrorCode = {
72
+ /** ACK confirmation timeout */
73
+ ACK_TIMEOUT: 'ACK_TIMEOUT',
74
+ /** Request timeout (synchronous) */
75
+ TIMEOUT: 'TIMEOUT',
76
+ /** Async request timeout */
77
+ ASYNC_TIMEOUT: 'ASYNC_TIMEOUT',
78
+ /** Request error */
79
+ REQUEST_ERROR: 'REQUEST_ERROR',
80
+ /** Method not found */
81
+ METHOD_NOT_FOUND: 'METHOD_NOT_FOUND',
82
+ /** No response */
83
+ NO_RESPONSE: 'NO_RESPONSE',
84
+ /** Protocol version not supported */
85
+ PROTOCOL_UNSUPPORTED: 'PROTOCOL_UNSUPPORTED',
86
+ /** iframe not ready */
87
+ IFRAME_NOT_READY: 'IFRAME_NOT_READY',
88
+ /** Stream error */
89
+ STREAM_ERROR: 'STREAM_ERROR',
90
+ /** Stream cancelled */
91
+ STREAM_CANCELLED: 'STREAM_CANCELLED',
92
+ /** Stream not bound */
93
+ STREAM_NOT_BOUND: 'STREAM_NOT_BOUND',
94
+ /** Target window closed */
95
+ TARGET_WINDOW_CLOSED: 'TARGET_WINDOW_CLOSED',
96
+ /** Too many concurrent requests (rate limiting) */
97
+ TOO_MANY_REQUESTS: 'TOO_MANY_REQUESTS',
98
+ /** Stream start not received in time */
99
+ STREAM_START_TIMEOUT: 'STREAM_START_TIMEOUT'
100
+ };
101
+
102
+ /**
103
+ * Message type constants
104
+ */
105
+ export var MessageType = {
106
+ /** Request message */
107
+ REQUEST: 'request',
108
+ /** Acknowledge request received */
109
+ ACK: 'ack',
110
+ /** Async task notification */
111
+ ASYNC: 'async',
112
+ /** Response message */
113
+ RESPONSE: 'response',
114
+ /** Error message */
115
+ ERROR: 'error',
116
+ /** Client confirms response received */
117
+ RECEIVED: 'received',
118
+ /** Ping message (for connection detection) */
119
+ PING: 'ping',
120
+ /** Pong message (for connection detection) */
121
+ PONG: 'pong',
122
+ /** Stream start */
123
+ STREAM_START: 'stream_start',
124
+ /** Stream data chunk */
125
+ STREAM_DATA: 'stream_data',
126
+ /** Stream end */
127
+ STREAM_END: 'stream_end',
128
+ /** Stream error */
129
+ STREAM_ERROR: 'stream_error',
130
+ /** Stream cancel */
131
+ STREAM_CANCEL: 'stream_cancel',
132
+ /** Stream pull (receiver requests next chunks) */
133
+ STREAM_PULL: 'stream_pull',
134
+ /** Stream ack (receiver acknowledges a chunk) */
135
+ STREAM_ACK: 'stream_ack'
136
+ };
137
+ export var MessageRole = {
138
+ /** Server role */
139
+ SERVER: 'server',
140
+ /** Client role */
141
+ CLIENT: 'client'
142
+ };
143
+ /**
144
+ * Default timeout configuration (milliseconds)
145
+ */
146
+ export var DefaultTimeout = {
147
+ /**
148
+ * ACK confirmation timeout: 1000ms (1s)
149
+ * Used for both client waiting for server ACK and server waiting for client RECEIVED.
150
+ * Increased from 500ms to accommodate slower environments or busy browsers where postMessage
151
+ * serialization/deserialization may take longer.
152
+ */
153
+ ACK: 1000,
154
+ /** Request timeout: 5s */
155
+ REQUEST: 5000,
156
+ /** Async request timeout: 120s */
157
+ ASYNC: 120000
158
+ };
159
+
160
+ /**
161
+ * HTTP Header name constants
162
+ */
163
+ export var HttpHeader = {
164
+ /** Set-Cookie (server sets cookie) */
165
+ SET_COOKIE: 'Set-Cookie',
166
+ /** Content-Type */
167
+ CONTENT_TYPE: 'Content-Type',
168
+ /** Content-Disposition (for file downloads) */
169
+ CONTENT_DISPOSITION: 'Content-Disposition',
170
+ /** Authorization */
171
+ AUTHORIZATION: 'Authorization',
172
+ /** Cookie (cookies carried in request) */
173
+ COOKIE: 'Cookie'
174
+ };
175
+
176
+ /**
177
+ * HTTP Header name type
178
+ */
179
+
180
+ /**
181
+ * Message type union type
182
+ */
183
+
184
+ /**
185
+ * Error code union type
186
+ */
187
+
188
+ /**
189
+ * Stream type constants
190
+ */
191
+ export var StreamType = {
192
+ /** Normal data stream */
193
+ DATA: 'data',
194
+ /** File stream */
195
+ FILE: 'file'
196
+ };
197
+
198
+ /**
199
+ * Stream mode constants
200
+ * - PULL: receiver pulls next chunks (backpressure)
201
+ * - PUSH: producer pushes via write()
202
+ */
203
+ export var StreamMode = {
204
+ PULL: 'pull',
205
+ PUSH: 'push'
206
+ };
207
+ /**
208
+ * Stream internal message type constants (for stream internal message handling)
209
+ * Note: These are MessageType.STREAM_* values with the stream_ prefix removed
210
+ */
211
+ export var StreamInternalMessageType = {
212
+ /** Data message */
213
+ DATA: 'data',
214
+ /** End message */
215
+ END: 'end',
216
+ /** Error message */
217
+ ERROR: 'error',
218
+ /** Cancel message */
219
+ CANCEL: 'cancel',
220
+ /** Pull message */
221
+ PULL: 'pull',
222
+ /** Ack message */
223
+ ACK: 'ack'
224
+ };
225
+
226
+ /**
227
+ * Stream internal message type value type
228
+ */
229
+
230
+ /**
231
+ * Stream type value type
232
+ */
233
+
234
+ /**
235
+ * Stream state constants
236
+ */
237
+ export var StreamState = {
238
+ /** Pending */
239
+ PENDING: 'pending',
240
+ /** Streaming */
241
+ STREAMING: 'streaming',
242
+ /** Ended */
243
+ ENDED: 'ended',
244
+ /** Error */
245
+ ERROR: 'error',
246
+ /** Cancelled */
247
+ CANCELLED: 'cancelled'
248
+ };
249
+
250
+ /**
251
+ * Stream state value type
252
+ */
253
+
254
+ /**
255
+ * Message constants (for multi-language support)
256
+ */
257
+ export { Messages, formatMessage, setMessages, resetMessages, getMessages } from './messages';
@@ -0,0 +1,155 @@
1
+ import "core-js/modules/es.array.filter.js";
2
+ import "core-js/modules/es.object.get-own-property-descriptors.js";
3
+ import "core-js/modules/web.dom-collections.for-each.js";
4
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
+ import "core-js/modules/es.regexp.exec.js";
6
+ import "core-js/modules/es.string.replace.js";
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ /**
10
+ * Message constants (for multi-language support)
11
+ *
12
+ * Usage:
13
+ * 1. Direct use: Messages.REQUEST_FAILED
14
+ * 2. Messages with parameters: Messages.formatMessage(Messages.CONNECT_TIMEOUT, timeout)
15
+ *
16
+ * Multi-language extension:
17
+ * You can use the setMessages() method to replace message content for multi-language support
18
+ */
19
+
20
+ /**
21
+ * Default message definitions
22
+ */
23
+ var defaultMessages = {
24
+ /** Protocol related errors */
25
+ INVALID_PROTOCOL_VERSION_FORMAT: 'Invalid protocol version format',
26
+ PROTOCOL_VERSION_TOO_LOW: 'Protocol version {0} is too low, minimum supported version is {1}',
27
+ PROTOCOL_VERSION_UNSUPPORTED: 'Protocol Version Unsupported',
28
+ /** Message format errors */
29
+ INVALID_MESSAGE_FORMAT_NOT_OBJECT: 'Invalid message format: not an object',
30
+ INVALID_MESSAGE_FORMAT_MISSING_PROTOCOL: 'Invalid message format: missing __requestIframe__ field',
31
+ INVALID_MESSAGE_FORMAT_MISSING_TYPE: 'Invalid message format: missing or invalid type field',
32
+ INVALID_MESSAGE_FORMAT_MISSING_REQUEST_ID: 'Invalid message format: missing or invalid requestId field',
33
+ /** Timeout errors */
34
+ ACK_TIMEOUT: 'ACK timeout after {0}ms',
35
+ REQUEST_TIMEOUT: 'Request timeout after {0}ms',
36
+ ASYNC_REQUEST_TIMEOUT: 'Async request timeout after {0}ms',
37
+ /** Request/response errors */
38
+ REQUEST_FAILED: 'Request failed',
39
+ METHOD_NOT_FOUND: 'Method not found',
40
+ NO_RESPONSE_SENT: 'Handler completed but no response sent',
41
+ MIDDLEWARE_ERROR: 'Middleware error',
42
+ ERROR: 'Error',
43
+ TOO_MANY_REQUESTS: 'Too many concurrent requests (limit: {0})',
44
+ /** Client errors */
45
+ IFRAME_NOT_READY: 'iframe.contentWindow is not available',
46
+ TARGET_WINDOW_CLOSED: 'Target window is closed or no longer available',
47
+ /** ClientServer warnings */
48
+ CLIENT_SERVER_IGNORED_MESSAGE_WHEN_CLOSED: 'Ignored message because client server is closed/destroyed (type: {0}, requestId: {1})',
49
+ /** Stream related messages */
50
+ STREAM_NOT_BOUND: 'Stream is not bound to a request context',
51
+ STREAM_ALREADY_STARTED: 'Stream has already started',
52
+ STREAM_CANCELLED: 'Stream was cancelled: {0}',
53
+ STREAM_ERROR: 'Stream error: {0}',
54
+ STREAM_TIMEOUT: 'Stream idle timeout after {0}ms',
55
+ STREAM_EXPIRED: 'Stream expired after {0}ms',
56
+ STREAM_START_TIMEOUT: 'Stream start timeout after {0}ms',
57
+ STREAM_ENDED: 'Stream has ended',
58
+ STREAM_READ_ERROR: 'Failed to read stream data',
59
+ STREAM_WRITE_ONLY_IN_PUSH_MODE: 'Stream write() is only available when mode is "push"',
60
+ /** Debug messages - Client */
61
+ DEBUG_CLIENT_REQUEST_START: '📤 [Client] Request Start',
62
+ DEBUG_CLIENT_REQUEST_SUCCESS: '✅ [Client] Request Success',
63
+ DEBUG_CLIENT_REQUEST_SUCCESS_FILE: '✅ [Client] Request Success (File)',
64
+ DEBUG_CLIENT_REQUEST_SUCCESS_STREAM: '✅ [Client] Request Success (Stream)',
65
+ DEBUG_CLIENT_REQUEST_FAILED: '❌ [Client] Request Failed',
66
+ DEBUG_CLIENT_RECEIVED_ACK: '📥 [Client] Received ACK',
67
+ DEBUG_CLIENT_RECEIVED_ASYNC: '⏳ [Client] Received ASYNC Notification',
68
+ DEBUG_CLIENT_RECEIVED_STREAM_START: '🌊 [Client] Received Stream Start',
69
+ DEBUG_CLIENT_RECEIVED_STREAM_DATA: '🌊 [Client] Received Stream Data',
70
+ DEBUG_CLIENT_RECEIVED_STREAM_END: '🌊 [Client] Received Stream End',
71
+ DEBUG_CLIENT_RECEIVED_RESPONSE: '📥 [Client] Received Response',
72
+ DEBUG_CLIENT_RECEIVED_ERROR: '📥 [Client] Received Error',
73
+ DEBUG_CLIENT_REQUEST_TIMEOUT: '⏱️ [Client] Request Timeout',
74
+ DEBUG_CLIENT_SENDING_REQUEST: '📤 [Client] Sending Request',
75
+ DEBUG_CLIENT_SENDING_PING: '📤 [Client] Sending Ping',
76
+ DEBUG_CLIENT_SENDING_RECEIVED_ACK: '📤 [Client] Sending Received ACK',
77
+ /** Debug messages - Server */
78
+ DEBUG_SERVER_RECEIVED_REQUEST: '📥 [Server] Received Request',
79
+ DEBUG_SERVER_SETTING_STATUS_CODE: '📝 [Server] Setting Status Code',
80
+ DEBUG_SERVER_SETTING_HEADER: '📝 [Server] Setting Header',
81
+ DEBUG_SERVER_SENDING_RESPONSE: '📤 [Server] Sending Response',
82
+ DEBUG_SERVER_SENDING_JSON_RESPONSE: '📤 [Server] Sending JSON Response',
83
+ DEBUG_SERVER_SENDING_FILE: '📤 [Server] Sending File',
84
+ DEBUG_SERVER_SENDING_STREAM: '📤 [Server] Sending Stream',
85
+ DEBUG_SERVER_SENDING_ACK: '📤 [Server] Sending ACK',
86
+ DEBUG_SERVER_SENDING_ASYNC: '📤 [Server] Sending ASYNC Notification',
87
+ DEBUG_SERVER_SENDING_STREAM_START: '🌊 [Server] Sending Stream Start',
88
+ DEBUG_SERVER_SENDING_STREAM_DATA: '🌊 [Server] Sending Stream Data',
89
+ DEBUG_SERVER_SENDING_STREAM_END: '🌊 [Server] Sending Stream End',
90
+ DEBUG_SERVER_SENDING_ERROR: '📤 [Server] Sending Error',
91
+ DEBUG_SERVER_SENDING_RESPONSE_VIA_DISPATCHER: '📤 [Server] Sending Response (via dispatcher)',
92
+ DEBUG_SERVER_HANDLING_REQUEST: '📥 [Server] Handling Request',
93
+ DEBUG_SERVER_EXECUTING_MIDDLEWARE_CHAIN: '⚙️ [Server] Executing Middleware Chain',
94
+ DEBUG_SERVER_MIDDLEWARE_CHAIN_COMPLETED: '✅ [Server] Middleware Chain Completed'
95
+ };
96
+
97
+ /**
98
+ * Message type
99
+ */
100
+
101
+ /**
102
+ * Current message configuration
103
+ */
104
+ var currentMessages = _objectSpread({}, defaultMessages);
105
+
106
+ /**
107
+ * Message constants object
108
+ */
109
+ export var Messages = new Proxy(currentMessages, {
110
+ get(target, prop) {
111
+ return target[prop] || prop;
112
+ }
113
+ });
114
+
115
+ /**
116
+ * Set message content (for multi-language support)
117
+ * @param messages Custom message content (partial or full)
118
+ */
119
+ export function setMessages(messages) {
120
+ currentMessages = _objectSpread(_objectSpread({}, defaultMessages), messages);
121
+ }
122
+
123
+ /**
124
+ * Reset to default messages
125
+ */
126
+ export function resetMessages() {
127
+ currentMessages = _objectSpread({}, defaultMessages);
128
+ }
129
+
130
+ /**
131
+ * Format message (replace placeholders)
132
+ * @param template Message template, using {0}, {1}, etc. as placeholders
133
+ * @param args Replacement parameters
134
+ * @returns Formatted message
135
+ *
136
+ * @example
137
+ * formatMessage('Connect timeout after {0}ms', 5000)
138
+ * // => 'Connect timeout after 5000ms'
139
+ *
140
+ * formatMessage('Protocol version {0} is too low, minimum supported version is {1}', 0, 1)
141
+ * // => 'Protocol version 0 is too low, minimum supported version is 1'
142
+ */
143
+ export function formatMessage(template, ...args) {
144
+ return template.replace(/\{(\d+)\}/g, (match, index) => {
145
+ var argIndex = parseInt(index, 10);
146
+ return argIndex < args.length ? String(args[argIndex]) : match;
147
+ });
148
+ }
149
+
150
+ /**
151
+ * Get current message configuration
152
+ */
153
+ export function getMessages() {
154
+ return _objectSpread({}, currentMessages);
155
+ }