request-iframe 0.0.1

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 (96) hide show
  1. package/QUICKSTART.CN.md +269 -0
  2. package/QUICKSTART.md +269 -0
  3. package/README.CN.md +1369 -0
  4. package/README.md +1016 -0
  5. package/library/__tests__/interceptors.test.ts +124 -0
  6. package/library/__tests__/requestIframe.test.ts +2216 -0
  7. package/library/__tests__/stream.test.ts +650 -0
  8. package/library/__tests__/utils.test.ts +433 -0
  9. package/library/api/client.d.ts +16 -0
  10. package/library/api/client.d.ts.map +1 -0
  11. package/library/api/client.js +72 -0
  12. package/library/api/server.d.ts +16 -0
  13. package/library/api/server.d.ts.map +1 -0
  14. package/library/api/server.js +44 -0
  15. package/library/constants/index.d.ts +209 -0
  16. package/library/constants/index.d.ts.map +1 -0
  17. package/library/constants/index.js +260 -0
  18. package/library/constants/messages.d.ts +80 -0
  19. package/library/constants/messages.d.ts.map +1 -0
  20. package/library/constants/messages.js +123 -0
  21. package/library/core/client.d.ts +99 -0
  22. package/library/core/client.d.ts.map +1 -0
  23. package/library/core/client.js +440 -0
  24. package/library/core/message-handler.d.ts +110 -0
  25. package/library/core/message-handler.d.ts.map +1 -0
  26. package/library/core/message-handler.js +320 -0
  27. package/library/core/request-response.d.ts +59 -0
  28. package/library/core/request-response.d.ts.map +1 -0
  29. package/library/core/request-response.js +337 -0
  30. package/library/core/request.d.ts +17 -0
  31. package/library/core/request.d.ts.map +1 -0
  32. package/library/core/request.js +34 -0
  33. package/library/core/response.d.ts +51 -0
  34. package/library/core/response.d.ts.map +1 -0
  35. package/library/core/response.js +323 -0
  36. package/library/core/server-base.d.ts +86 -0
  37. package/library/core/server-base.d.ts.map +1 -0
  38. package/library/core/server-base.js +257 -0
  39. package/library/core/server-client.d.ts +99 -0
  40. package/library/core/server-client.d.ts.map +1 -0
  41. package/library/core/server-client.js +256 -0
  42. package/library/core/server.d.ts +82 -0
  43. package/library/core/server.d.ts.map +1 -0
  44. package/library/core/server.js +338 -0
  45. package/library/index.d.ts +16 -0
  46. package/library/index.d.ts.map +1 -0
  47. package/library/index.js +211 -0
  48. package/library/interceptors/index.d.ts +41 -0
  49. package/library/interceptors/index.d.ts.map +1 -0
  50. package/library/interceptors/index.js +126 -0
  51. package/library/message/channel.d.ts +107 -0
  52. package/library/message/channel.d.ts.map +1 -0
  53. package/library/message/channel.js +184 -0
  54. package/library/message/dispatcher.d.ts +119 -0
  55. package/library/message/dispatcher.d.ts.map +1 -0
  56. package/library/message/dispatcher.js +249 -0
  57. package/library/message/index.d.ts +5 -0
  58. package/library/message/index.d.ts.map +1 -0
  59. package/library/message/index.js +25 -0
  60. package/library/stream/file-stream.d.ts +48 -0
  61. package/library/stream/file-stream.d.ts.map +1 -0
  62. package/library/stream/file-stream.js +240 -0
  63. package/library/stream/index.d.ts +15 -0
  64. package/library/stream/index.d.ts.map +1 -0
  65. package/library/stream/index.js +83 -0
  66. package/library/stream/readable-stream.d.ts +83 -0
  67. package/library/stream/readable-stream.d.ts.map +1 -0
  68. package/library/stream/readable-stream.js +249 -0
  69. package/library/stream/types.d.ts +165 -0
  70. package/library/stream/types.d.ts.map +1 -0
  71. package/library/stream/types.js +5 -0
  72. package/library/stream/writable-stream.d.ts +60 -0
  73. package/library/stream/writable-stream.d.ts.map +1 -0
  74. package/library/stream/writable-stream.js +348 -0
  75. package/library/types/index.d.ts +408 -0
  76. package/library/types/index.d.ts.map +1 -0
  77. package/library/types/index.js +5 -0
  78. package/library/utils/cache.d.ts +19 -0
  79. package/library/utils/cache.d.ts.map +1 -0
  80. package/library/utils/cache.js +83 -0
  81. package/library/utils/cookie.d.ts +117 -0
  82. package/library/utils/cookie.d.ts.map +1 -0
  83. package/library/utils/cookie.js +365 -0
  84. package/library/utils/debug.d.ts +11 -0
  85. package/library/utils/debug.d.ts.map +1 -0
  86. package/library/utils/debug.js +162 -0
  87. package/library/utils/index.d.ts +13 -0
  88. package/library/utils/index.d.ts.map +1 -0
  89. package/library/utils/index.js +132 -0
  90. package/library/utils/path-match.d.ts +17 -0
  91. package/library/utils/path-match.d.ts.map +1 -0
  92. package/library/utils/path-match.js +90 -0
  93. package/library/utils/protocol.d.ts +61 -0
  94. package/library/utils/protocol.d.ts.map +1 -0
  95. package/library/utils/protocol.js +169 -0
  96. package/package.json +58 -0
@@ -0,0 +1,209 @@
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 declare const ProtocolVersion: {
11
+ /** Current protocol version */
12
+ readonly CURRENT: 1;
13
+ /** Minimum supported protocol version (messages below this version will be rejected) */
14
+ readonly MIN_SUPPORTED: 1;
15
+ };
16
+ /**
17
+ * Protocol version type
18
+ */
19
+ export type ProtocolVersionValue = typeof ProtocolVersion[keyof typeof ProtocolVersion];
20
+ /**
21
+ * Protocol validation result
22
+ */
23
+ export interface ProtocolValidationResult {
24
+ /** Whether valid */
25
+ valid: boolean;
26
+ /** Protocol version (if valid) */
27
+ version?: number;
28
+ /** Error message (if invalid) */
29
+ error?: string;
30
+ /** Error code (if invalid) */
31
+ errorCode?: 'INVALID_FORMAT' | 'VERSION_TOO_LOW';
32
+ }
33
+ /**
34
+ * HTTP status code constants
35
+ */
36
+ export declare const HttpStatus: {
37
+ readonly OK: 200;
38
+ readonly CREATED: 201;
39
+ readonly NO_CONTENT: 204;
40
+ readonly BAD_REQUEST: 400;
41
+ readonly UNAUTHORIZED: 401;
42
+ readonly FORBIDDEN: 403;
43
+ readonly NOT_FOUND: 404;
44
+ readonly INTERNAL_SERVER_ERROR: 500;
45
+ readonly BAD_GATEWAY: 502;
46
+ readonly SERVICE_UNAVAILABLE: 503;
47
+ };
48
+ /**
49
+ * HTTP status text constants
50
+ */
51
+ export declare const HttpStatusText: Record<number, string>;
52
+ /**
53
+ * Get status text
54
+ */
55
+ export declare function getStatusText(code: number): string;
56
+ /**
57
+ * Error code constants
58
+ */
59
+ export declare const ErrorCode: {
60
+ /** ACK confirmation timeout */
61
+ readonly ACK_TIMEOUT: "ACK_TIMEOUT";
62
+ /** Request timeout (synchronous) */
63
+ readonly TIMEOUT: "TIMEOUT";
64
+ /** Async request timeout */
65
+ readonly ASYNC_TIMEOUT: "ASYNC_TIMEOUT";
66
+ /** Request error */
67
+ readonly REQUEST_ERROR: "REQUEST_ERROR";
68
+ /** Method not found */
69
+ readonly METHOD_NOT_FOUND: "METHOD_NOT_FOUND";
70
+ /** No response */
71
+ readonly NO_RESPONSE: "NO_RESPONSE";
72
+ /** Protocol version not supported */
73
+ readonly PROTOCOL_UNSUPPORTED: "PROTOCOL_UNSUPPORTED";
74
+ /** iframe not ready */
75
+ readonly IFRAME_NOT_READY: "IFRAME_NOT_READY";
76
+ /** Stream error */
77
+ readonly STREAM_ERROR: "STREAM_ERROR";
78
+ /** Stream cancelled */
79
+ readonly STREAM_CANCELLED: "STREAM_CANCELLED";
80
+ /** Stream not bound */
81
+ readonly STREAM_NOT_BOUND: "STREAM_NOT_BOUND";
82
+ };
83
+ /**
84
+ * Message type constants
85
+ */
86
+ export declare const MessageType: {
87
+ /** Request message */
88
+ readonly REQUEST: "request";
89
+ /** Acknowledge request received */
90
+ readonly ACK: "ack";
91
+ /** Async task notification */
92
+ readonly ASYNC: "async";
93
+ /** Response message */
94
+ readonly RESPONSE: "response";
95
+ /** Error message */
96
+ readonly ERROR: "error";
97
+ /** Client confirms response received */
98
+ readonly RECEIVED: "received";
99
+ /** Ping message (for connection detection) */
100
+ readonly PING: "ping";
101
+ /** Pong message (for connection detection) */
102
+ readonly PONG: "pong";
103
+ /** Stream start */
104
+ readonly STREAM_START: "stream_start";
105
+ /** Stream data chunk */
106
+ readonly STREAM_DATA: "stream_data";
107
+ /** Stream end */
108
+ readonly STREAM_END: "stream_end";
109
+ /** Stream error */
110
+ readonly STREAM_ERROR: "stream_error";
111
+ /** Stream cancel */
112
+ readonly STREAM_CANCEL: "stream_cancel";
113
+ };
114
+ /**
115
+ * Default timeout configuration (milliseconds)
116
+ */
117
+ export declare const DefaultTimeout: {
118
+ /** ACK confirmation timeout: 500ms (client waiting for server confirmation) */
119
+ readonly ACK: 500;
120
+ /** Request timeout: 5s */
121
+ readonly REQUEST: 5000;
122
+ /** Async request timeout: 120s */
123
+ 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
+ };
127
+ /**
128
+ * HTTP Header name constants
129
+ */
130
+ export declare const HttpHeader: {
131
+ /** Set-Cookie (server sets cookie) */
132
+ readonly SET_COOKIE: "Set-Cookie";
133
+ /** Content-Type */
134
+ readonly CONTENT_TYPE: "Content-Type";
135
+ /** Content-Disposition (for file downloads) */
136
+ readonly CONTENT_DISPOSITION: "Content-Disposition";
137
+ /** Authorization */
138
+ readonly AUTHORIZATION: "Authorization";
139
+ /** Cookie (cookies carried in request) */
140
+ readonly COOKIE: "Cookie";
141
+ };
142
+ /**
143
+ * HTTP Header name type
144
+ */
145
+ export type HttpHeaderValue = typeof HttpHeader[keyof typeof HttpHeader];
146
+ /**
147
+ * Message type union type
148
+ */
149
+ export type MessageTypeValue = typeof MessageType[keyof typeof MessageType];
150
+ /**
151
+ * Error code union type
152
+ */
153
+ export type ErrorCodeValue = typeof ErrorCode[keyof typeof ErrorCode];
154
+ /**
155
+ * Stream type constants
156
+ */
157
+ export declare const StreamType: {
158
+ /** Normal data stream */
159
+ readonly DATA: "data";
160
+ /** File stream */
161
+ readonly FILE: "file";
162
+ };
163
+ /**
164
+ * Stream internal message type constants (for stream internal message handling)
165
+ * Note: These are MessageType.STREAM_* values with the stream_ prefix removed
166
+ */
167
+ export declare const StreamInternalMessageType: {
168
+ /** Data message */
169
+ readonly DATA: "data";
170
+ /** End message */
171
+ readonly END: "end";
172
+ /** Error message */
173
+ readonly ERROR: "error";
174
+ /** Cancel message */
175
+ readonly CANCEL: "cancel";
176
+ };
177
+ /**
178
+ * Stream internal message type value type
179
+ */
180
+ export type StreamInternalMessageTypeValue = typeof StreamInternalMessageType[keyof typeof StreamInternalMessageType];
181
+ /**
182
+ * Stream type value type
183
+ */
184
+ export type StreamTypeValue = typeof StreamType[keyof typeof StreamType];
185
+ /**
186
+ * Stream state constants
187
+ */
188
+ export declare const StreamState: {
189
+ /** Pending */
190
+ readonly PENDING: "pending";
191
+ /** Streaming */
192
+ readonly STREAMING: "streaming";
193
+ /** Ended */
194
+ readonly ENDED: "ended";
195
+ /** Error */
196
+ readonly ERROR: "error";
197
+ /** Cancelled */
198
+ readonly CANCELLED: "cancelled";
199
+ };
200
+ /**
201
+ * Stream state value type
202
+ */
203
+ export type StreamStateValue = typeof StreamState[keyof typeof StreamState];
204
+ /**
205
+ * Message constants (for multi-language support)
206
+ */
207
+ export { Messages, formatMessage, setMessages, resetMessages, getMessages } from './messages';
208
+ export type { MessageKey } from './messages';
209
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MessageType = exports.HttpStatusText = exports.HttpStatus = exports.HttpHeader = exports.ErrorCode = exports.DefaultTimeout = void 0;
7
+ Object.defineProperty(exports, "Messages", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _messages.Messages;
11
+ }
12
+ });
13
+ exports.StreamType = exports.StreamState = exports.StreamInternalMessageType = exports.ProtocolVersion = void 0;
14
+ Object.defineProperty(exports, "formatMessage", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _messages.formatMessage;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "getMessages", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _messages.getMessages;
24
+ }
25
+ });
26
+ exports.getStatusText = getStatusText;
27
+ Object.defineProperty(exports, "resetMessages", {
28
+ enumerable: true,
29
+ get: function get() {
30
+ return _messages.resetMessages;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "setMessages", {
34
+ enumerable: true,
35
+ get: function get() {
36
+ return _messages.setMessages;
37
+ }
38
+ });
39
+ var _messages = require("./messages");
40
+ /**
41
+ * Protocol version constants
42
+ * Used to identify the protocol version of messages, for compatibility handling in future version upgrades
43
+ *
44
+ * Version compatibility strategy:
45
+ * - Only check minimum supported version, reject deprecated old versions
46
+ * - Don't check maximum version, as new versions usually maintain backward compatibility with old message formats
47
+ * - This way new version servers can be compatible with old version clients, without forcing client upgrades
48
+ */
49
+ var ProtocolVersion = exports.ProtocolVersion = {
50
+ /** Current protocol version */
51
+ CURRENT: 1,
52
+ /** Minimum supported protocol version (messages below this version will be rejected) */
53
+ MIN_SUPPORTED: 1
54
+ };
55
+
56
+ /**
57
+ * Protocol version type
58
+ */
59
+
60
+ /**
61
+ * Protocol validation result
62
+ */
63
+
64
+ /**
65
+ * HTTP status code constants
66
+ */
67
+ var HttpStatus = exports.HttpStatus = {
68
+ OK: 200,
69
+ CREATED: 201,
70
+ NO_CONTENT: 204,
71
+ BAD_REQUEST: 400,
72
+ UNAUTHORIZED: 401,
73
+ FORBIDDEN: 403,
74
+ NOT_FOUND: 404,
75
+ INTERNAL_SERVER_ERROR: 500,
76
+ BAD_GATEWAY: 502,
77
+ SERVICE_UNAVAILABLE: 503
78
+ };
79
+
80
+ /**
81
+ * HTTP status text constants
82
+ */
83
+ var HttpStatusText = exports.HttpStatusText = {
84
+ [HttpStatus.OK]: 'OK',
85
+ [HttpStatus.CREATED]: 'Created',
86
+ [HttpStatus.NO_CONTENT]: 'No Content',
87
+ [HttpStatus.BAD_REQUEST]: 'Bad Request',
88
+ [HttpStatus.UNAUTHORIZED]: 'Unauthorized',
89
+ [HttpStatus.FORBIDDEN]: 'Forbidden',
90
+ [HttpStatus.NOT_FOUND]: 'Not Found',
91
+ [HttpStatus.INTERNAL_SERVER_ERROR]: 'Internal Server Error',
92
+ [HttpStatus.BAD_GATEWAY]: 'Bad Gateway',
93
+ [HttpStatus.SERVICE_UNAVAILABLE]: 'Service Unavailable'
94
+ };
95
+
96
+ /**
97
+ * Get status text
98
+ */
99
+ function getStatusText(code) {
100
+ return HttpStatusText[code] || 'Unknown';
101
+ }
102
+
103
+ /**
104
+ * Error code constants
105
+ */
106
+ var ErrorCode = exports.ErrorCode = {
107
+ /** ACK confirmation timeout */
108
+ ACK_TIMEOUT: 'ACK_TIMEOUT',
109
+ /** Request timeout (synchronous) */
110
+ TIMEOUT: 'TIMEOUT',
111
+ /** Async request timeout */
112
+ ASYNC_TIMEOUT: 'ASYNC_TIMEOUT',
113
+ /** Request error */
114
+ REQUEST_ERROR: 'REQUEST_ERROR',
115
+ /** Method not found */
116
+ METHOD_NOT_FOUND: 'METHOD_NOT_FOUND',
117
+ /** No response */
118
+ NO_RESPONSE: 'NO_RESPONSE',
119
+ /** Protocol version not supported */
120
+ PROTOCOL_UNSUPPORTED: 'PROTOCOL_UNSUPPORTED',
121
+ /** iframe not ready */
122
+ IFRAME_NOT_READY: 'IFRAME_NOT_READY',
123
+ /** Stream error */
124
+ STREAM_ERROR: 'STREAM_ERROR',
125
+ /** Stream cancelled */
126
+ STREAM_CANCELLED: 'STREAM_CANCELLED',
127
+ /** Stream not bound */
128
+ STREAM_NOT_BOUND: 'STREAM_NOT_BOUND'
129
+ };
130
+
131
+ /**
132
+ * Message type constants
133
+ */
134
+ var MessageType = exports.MessageType = {
135
+ /** Request message */
136
+ REQUEST: 'request',
137
+ /** Acknowledge request received */
138
+ ACK: 'ack',
139
+ /** Async task notification */
140
+ ASYNC: 'async',
141
+ /** Response message */
142
+ RESPONSE: 'response',
143
+ /** Error message */
144
+ ERROR: 'error',
145
+ /** Client confirms response received */
146
+ RECEIVED: 'received',
147
+ /** Ping message (for connection detection) */
148
+ PING: 'ping',
149
+ /** Pong message (for connection detection) */
150
+ PONG: 'pong',
151
+ /** Stream start */
152
+ STREAM_START: 'stream_start',
153
+ /** Stream data chunk */
154
+ STREAM_DATA: 'stream_data',
155
+ /** Stream end */
156
+ STREAM_END: 'stream_end',
157
+ /** Stream error */
158
+ STREAM_ERROR: 'stream_error',
159
+ /** Stream cancel */
160
+ STREAM_CANCEL: 'stream_cancel'
161
+ };
162
+
163
+ /**
164
+ * Default timeout configuration (milliseconds)
165
+ */
166
+ var DefaultTimeout = exports.DefaultTimeout = {
167
+ /** ACK confirmation timeout: 500ms (client waiting for server confirmation) */
168
+ ACK: 500,
169
+ /** Request timeout: 5s */
170
+ REQUEST: 5000,
171
+ /** 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
175
+ };
176
+
177
+ /**
178
+ * HTTP Header name constants
179
+ */
180
+ var HttpHeader = exports.HttpHeader = {
181
+ /** Set-Cookie (server sets cookie) */
182
+ SET_COOKIE: 'Set-Cookie',
183
+ /** Content-Type */
184
+ CONTENT_TYPE: 'Content-Type',
185
+ /** Content-Disposition (for file downloads) */
186
+ CONTENT_DISPOSITION: 'Content-Disposition',
187
+ /** Authorization */
188
+ AUTHORIZATION: 'Authorization',
189
+ /** Cookie (cookies carried in request) */
190
+ COOKIE: 'Cookie'
191
+ };
192
+
193
+ /**
194
+ * HTTP Header name type
195
+ */
196
+
197
+ /**
198
+ * Message type union type
199
+ */
200
+
201
+ /**
202
+ * Error code union type
203
+ */
204
+
205
+ /**
206
+ * Stream type constants
207
+ */
208
+ var StreamType = exports.StreamType = {
209
+ /** Normal data stream */
210
+ DATA: 'data',
211
+ /** File stream */
212
+ FILE: 'file'
213
+ };
214
+
215
+ /**
216
+ * Stream internal message type constants (for stream internal message handling)
217
+ * Note: These are MessageType.STREAM_* values with the stream_ prefix removed
218
+ */
219
+ var StreamInternalMessageType = exports.StreamInternalMessageType = {
220
+ /** Data message */
221
+ DATA: 'data',
222
+ /** End message */
223
+ END: 'end',
224
+ /** Error message */
225
+ ERROR: 'error',
226
+ /** Cancel message */
227
+ CANCEL: 'cancel'
228
+ };
229
+
230
+ /**
231
+ * Stream internal message type value type
232
+ */
233
+
234
+ /**
235
+ * Stream type value type
236
+ */
237
+
238
+ /**
239
+ * Stream state constants
240
+ */
241
+ var StreamState = exports.StreamState = {
242
+ /** Pending */
243
+ PENDING: 'pending',
244
+ /** Streaming */
245
+ STREAMING: 'streaming',
246
+ /** Ended */
247
+ ENDED: 'ended',
248
+ /** Error */
249
+ ERROR: 'error',
250
+ /** Cancelled */
251
+ CANCELLED: 'cancelled'
252
+ };
253
+
254
+ /**
255
+ * Stream state value type
256
+ */
257
+
258
+ /**
259
+ * Message constants (for multi-language support)
260
+ */
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Message constants (for multi-language support)
3
+ *
4
+ * Usage:
5
+ * 1. Direct use: Messages.REQUEST_FAILED
6
+ * 2. Messages with parameters: Messages.formatMessage(Messages.CONNECT_TIMEOUT, timeout)
7
+ *
8
+ * Multi-language extension:
9
+ * You can use the setMessages() method to replace message content for multi-language support
10
+ */
11
+ /**
12
+ * Default message definitions
13
+ */
14
+ declare const defaultMessages: {
15
+ /** Protocol related errors */
16
+ readonly INVALID_PROTOCOL_VERSION_FORMAT: "Invalid protocol version format";
17
+ readonly PROTOCOL_VERSION_TOO_LOW: "Protocol version {0} is too low, minimum supported version is {1}";
18
+ readonly PROTOCOL_VERSION_UNSUPPORTED: "Protocol Version Unsupported";
19
+ /** Message format errors */
20
+ readonly INVALID_MESSAGE_FORMAT_NOT_OBJECT: "Invalid message format: not an object";
21
+ readonly INVALID_MESSAGE_FORMAT_MISSING_PROTOCOL: "Invalid message format: missing __requestIframe__ field";
22
+ readonly INVALID_MESSAGE_FORMAT_MISSING_TYPE: "Invalid message format: missing or invalid type field";
23
+ readonly INVALID_MESSAGE_FORMAT_MISSING_REQUEST_ID: "Invalid message format: missing or invalid requestId field";
24
+ /** Timeout errors */
25
+ readonly ACK_TIMEOUT: "ACK timeout after {0}ms";
26
+ readonly REQUEST_TIMEOUT: "Request timeout after {0}ms";
27
+ readonly ASYNC_REQUEST_TIMEOUT: "Async request timeout after {0}ms";
28
+ /** Request/response errors */
29
+ readonly REQUEST_FAILED: "Request failed";
30
+ readonly METHOD_NOT_FOUND: "Method not found";
31
+ readonly NO_RESPONSE_SENT: "Handler completed but no response sent";
32
+ readonly MIDDLEWARE_ERROR: "Middleware error";
33
+ readonly ERROR: "Error";
34
+ /** Client errors */
35
+ readonly IFRAME_NOT_READY: "iframe.contentWindow is not available";
36
+ /** Stream related messages */
37
+ readonly STREAM_NOT_BOUND: "Stream is not bound to a request context";
38
+ readonly STREAM_ALREADY_STARTED: "Stream has already started";
39
+ readonly STREAM_CANCELLED: "Stream was cancelled: {0}";
40
+ readonly STREAM_ERROR: "Stream error: {0}";
41
+ readonly STREAM_ENDED: "Stream has ended";
42
+ readonly STREAM_READ_ERROR: "Failed to read stream data";
43
+ };
44
+ /**
45
+ * Message type
46
+ */
47
+ export type MessageKey = keyof typeof defaultMessages;
48
+ /**
49
+ * Message constants object
50
+ */
51
+ export declare const Messages: Readonly<Record<MessageKey, string>>;
52
+ /**
53
+ * Set message content (for multi-language support)
54
+ * @param messages Custom message content (partial or full)
55
+ */
56
+ export declare function setMessages(messages: Partial<Record<MessageKey, string>>): void;
57
+ /**
58
+ * Reset to default messages
59
+ */
60
+ export declare function resetMessages(): void;
61
+ /**
62
+ * Format message (replace placeholders)
63
+ * @param template Message template, using {0}, {1}, etc. as placeholders
64
+ * @param args Replacement parameters
65
+ * @returns Formatted message
66
+ *
67
+ * @example
68
+ * formatMessage('Connect timeout after {0}ms', 5000)
69
+ * // => 'Connect timeout after 5000ms'
70
+ *
71
+ * formatMessage('Protocol version {0} is too low, minimum supported version is {1}', 0, 1)
72
+ * // => 'Protocol version 0 is too low, minimum supported version is 1'
73
+ */
74
+ export declare function formatMessage(template: string, ...args: (string | number)[]): string;
75
+ /**
76
+ * Get current message configuration
77
+ */
78
+ export declare function getMessages(): Readonly<Record<MessageKey, string>>;
79
+ export {};
80
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/constants/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,MAAM,OAAO,eAAe,CAAC;AAOtD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAIxD,CAAC;AAEH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAE/E;AAED;;GAEG;AACH,wBAAgB,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"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.array.filter.js");
4
+ require("core-js/modules/es.object.get-own-property-descriptors.js");
5
+ require("core-js/modules/web.dom-collections.for-each.js");
6
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.Messages = void 0;
11
+ exports.formatMessage = formatMessage;
12
+ exports.getMessages = getMessages;
13
+ exports.resetMessages = resetMessages;
14
+ exports.setMessages = setMessages;
15
+ require("core-js/modules/es.regexp.exec.js");
16
+ require("core-js/modules/es.string.replace.js");
17
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
+ 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; }
19
+ 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) { (0, _defineProperty2.default)(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; }
20
+ /**
21
+ * Message constants (for multi-language support)
22
+ *
23
+ * Usage:
24
+ * 1. Direct use: Messages.REQUEST_FAILED
25
+ * 2. Messages with parameters: Messages.formatMessage(Messages.CONNECT_TIMEOUT, timeout)
26
+ *
27
+ * Multi-language extension:
28
+ * You can use the setMessages() method to replace message content for multi-language support
29
+ */
30
+
31
+ /**
32
+ * Default message definitions
33
+ */
34
+ var defaultMessages = {
35
+ /** Protocol related errors */
36
+ INVALID_PROTOCOL_VERSION_FORMAT: 'Invalid protocol version format',
37
+ PROTOCOL_VERSION_TOO_LOW: 'Protocol version {0} is too low, minimum supported version is {1}',
38
+ PROTOCOL_VERSION_UNSUPPORTED: 'Protocol Version Unsupported',
39
+ /** Message format errors */
40
+ INVALID_MESSAGE_FORMAT_NOT_OBJECT: 'Invalid message format: not an object',
41
+ INVALID_MESSAGE_FORMAT_MISSING_PROTOCOL: 'Invalid message format: missing __requestIframe__ field',
42
+ INVALID_MESSAGE_FORMAT_MISSING_TYPE: 'Invalid message format: missing or invalid type field',
43
+ INVALID_MESSAGE_FORMAT_MISSING_REQUEST_ID: 'Invalid message format: missing or invalid requestId field',
44
+ /** Timeout errors */
45
+ ACK_TIMEOUT: 'ACK timeout after {0}ms',
46
+ REQUEST_TIMEOUT: 'Request timeout after {0}ms',
47
+ ASYNC_REQUEST_TIMEOUT: 'Async request timeout after {0}ms',
48
+ /** Request/response errors */
49
+ REQUEST_FAILED: 'Request failed',
50
+ METHOD_NOT_FOUND: 'Method not found',
51
+ NO_RESPONSE_SENT: 'Handler completed but no response sent',
52
+ MIDDLEWARE_ERROR: 'Middleware error',
53
+ ERROR: 'Error',
54
+ /** Client errors */
55
+ IFRAME_NOT_READY: 'iframe.contentWindow is not available',
56
+ /** Stream related messages */
57
+ STREAM_NOT_BOUND: 'Stream is not bound to a request context',
58
+ STREAM_ALREADY_STARTED: 'Stream has already started',
59
+ STREAM_CANCELLED: 'Stream was cancelled: {0}',
60
+ STREAM_ERROR: 'Stream error: {0}',
61
+ STREAM_ENDED: 'Stream has ended',
62
+ STREAM_READ_ERROR: 'Failed to read stream data'
63
+ };
64
+
65
+ /**
66
+ * Message type
67
+ */
68
+
69
+ /**
70
+ * Current message configuration
71
+ */
72
+ var currentMessages = _objectSpread({}, defaultMessages);
73
+
74
+ /**
75
+ * Message constants object
76
+ */
77
+ var Messages = exports.Messages = new Proxy(currentMessages, {
78
+ get(target, prop) {
79
+ return target[prop] || prop;
80
+ }
81
+ });
82
+
83
+ /**
84
+ * Set message content (for multi-language support)
85
+ * @param messages Custom message content (partial or full)
86
+ */
87
+ function setMessages(messages) {
88
+ currentMessages = _objectSpread(_objectSpread({}, defaultMessages), messages);
89
+ }
90
+
91
+ /**
92
+ * Reset to default messages
93
+ */
94
+ function resetMessages() {
95
+ currentMessages = _objectSpread({}, defaultMessages);
96
+ }
97
+
98
+ /**
99
+ * Format message (replace placeholders)
100
+ * @param template Message template, using {0}, {1}, etc. as placeholders
101
+ * @param args Replacement parameters
102
+ * @returns Formatted message
103
+ *
104
+ * @example
105
+ * formatMessage('Connect timeout after {0}ms', 5000)
106
+ * // => 'Connect timeout after 5000ms'
107
+ *
108
+ * formatMessage('Protocol version {0} is too low, minimum supported version is {1}', 0, 1)
109
+ * // => 'Protocol version 0 is too low, minimum supported version is 1'
110
+ */
111
+ function formatMessage(template, ...args) {
112
+ return template.replace(/\{(\d+)\}/g, (match, index) => {
113
+ var argIndex = parseInt(index, 10);
114
+ return argIndex < args.length ? String(args[argIndex]) : match;
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Get current message configuration
120
+ */
121
+ function getMessages() {
122
+ return _objectSpread({}, currentMessages);
123
+ }