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.
- package/QUICKSTART.CN.md +4 -2
- package/QUICKSTART.md +4 -2
- package/README.CN.md +302 -54
- package/README.md +281 -36
- package/cdn/request-iframe-react.umd.js +3354 -0
- package/cdn/request-iframe-react.umd.js.map +1 -0
- package/cdn/request-iframe-react.umd.min.js +2 -0
- package/cdn/request-iframe-react.umd.min.js.map +1 -0
- package/cdn/request-iframe.umd.js +19735 -0
- package/cdn/request-iframe.umd.js.map +1 -0
- package/cdn/request-iframe.umd.min.js +4 -0
- package/cdn/request-iframe.umd.min.js.map +1 -0
- package/esm/api/client.js +31 -22
- package/esm/api/endpoint.js +229 -0
- package/esm/api/server.js +19 -9
- package/esm/constants/debug.js +17 -0
- package/esm/constants/index.js +115 -66
- package/esm/constants/log.js +11 -0
- package/esm/constants/messages.js +6 -1
- package/esm/constants/warn-once.js +15 -0
- package/esm/endpoint/facade.js +390 -0
- package/esm/endpoint/heartbeat/heartbeat.js +60 -0
- package/esm/endpoint/heartbeat/ping.js +20 -0
- package/esm/endpoint/index.js +13 -0
- package/esm/endpoint/infra/hub.js +316 -0
- package/esm/endpoint/infra/inbox.js +232 -0
- package/esm/endpoint/infra/outbox.js +408 -0
- package/esm/endpoint/stream/dispatcher.js +58 -0
- package/esm/endpoint/stream/errors.js +27 -0
- package/esm/endpoint/stream/factory.js +76 -0
- package/esm/endpoint/stream/file-auto-resolve.js +34 -0
- package/esm/endpoint/stream/file-writable.js +105 -0
- package/esm/endpoint/stream/handler.js +26 -0
- package/esm/{core → impl}/client.js +243 -320
- package/esm/{core → impl}/response.js +120 -154
- package/esm/impl/server.js +568 -0
- package/esm/index.js +13 -6
- package/esm/message/ack.js +27 -0
- package/esm/message/channel-cache.js +108 -0
- package/esm/message/channel.js +92 -5
- package/esm/message/dispatcher.js +149 -98
- package/esm/stream/error.js +22 -0
- package/esm/stream/index.js +3 -1
- package/esm/stream/readable-stream.js +101 -26
- package/esm/stream/stream-core.js +121 -3
- package/esm/stream/writable-stream.js +368 -43
- package/esm/utils/ack.js +36 -0
- package/esm/utils/blob.js +16 -0
- package/esm/utils/cache.js +25 -76
- package/esm/utils/content-type.js +81 -0
- package/esm/utils/debug.js +157 -180
- package/esm/utils/hooks.js +130 -0
- package/esm/utils/id.js +14 -0
- package/esm/utils/iframe.js +20 -0
- package/esm/utils/index.js +12 -162
- package/esm/utils/is.js +3 -0
- package/esm/utils/logger.js +55 -0
- package/esm/utils/origin.js +3 -1
- package/esm/utils/promise.js +3 -0
- package/esm/utils/window.js +31 -0
- package/library/api/client.d.ts.map +1 -1
- package/library/api/client.js +32 -23
- package/library/api/endpoint.d.ts +23 -0
- package/library/api/endpoint.d.ts.map +1 -0
- package/library/api/endpoint.js +235 -0
- package/library/api/server.d.ts +4 -1
- package/library/api/server.d.ts.map +1 -1
- package/library/api/server.js +19 -9
- package/library/constants/debug.d.ts +18 -0
- package/library/constants/debug.d.ts.map +1 -0
- package/library/constants/debug.js +23 -0
- package/library/constants/index.d.ts +58 -7
- package/library/constants/index.d.ts.map +1 -1
- package/library/constants/index.js +143 -67
- package/library/constants/log.d.ts +12 -0
- package/library/constants/log.d.ts.map +1 -0
- package/library/constants/log.js +17 -0
- package/library/constants/messages.d.ts +6 -1
- package/library/constants/messages.d.ts.map +1 -1
- package/library/constants/messages.js +6 -1
- package/library/constants/warn-once.d.ts +12 -0
- package/library/constants/warn-once.d.ts.map +1 -0
- package/library/constants/warn-once.js +22 -0
- package/library/endpoint/facade.d.ts +238 -0
- package/library/endpoint/facade.d.ts.map +1 -0
- package/library/endpoint/facade.js +398 -0
- package/library/endpoint/heartbeat/heartbeat.d.ts +34 -0
- package/library/endpoint/heartbeat/heartbeat.d.ts.map +1 -0
- package/library/endpoint/heartbeat/heartbeat.js +67 -0
- package/library/endpoint/heartbeat/ping.d.ts +18 -0
- package/library/endpoint/heartbeat/ping.d.ts.map +1 -0
- package/library/endpoint/heartbeat/ping.js +26 -0
- package/library/endpoint/index.d.ts +16 -0
- package/library/endpoint/index.d.ts.map +1 -0
- package/library/endpoint/index.js +114 -0
- package/library/endpoint/infra/hub.d.ts +170 -0
- package/library/endpoint/infra/hub.d.ts.map +1 -0
- package/library/endpoint/infra/hub.js +323 -0
- package/library/endpoint/infra/inbox.d.ts +73 -0
- package/library/endpoint/infra/inbox.d.ts.map +1 -0
- package/library/endpoint/infra/inbox.js +239 -0
- package/library/endpoint/infra/outbox.d.ts +149 -0
- package/library/endpoint/infra/outbox.d.ts.map +1 -0
- package/library/endpoint/infra/outbox.js +415 -0
- package/library/endpoint/stream/dispatcher.d.ts +33 -0
- package/library/endpoint/stream/dispatcher.d.ts.map +1 -0
- package/library/endpoint/stream/dispatcher.js +66 -0
- package/library/endpoint/stream/errors.d.ts +20 -0
- package/library/endpoint/stream/errors.d.ts.map +1 -0
- package/library/endpoint/stream/errors.js +32 -0
- package/library/endpoint/stream/factory.d.ts +44 -0
- package/library/endpoint/stream/factory.d.ts.map +1 -0
- package/library/endpoint/stream/factory.js +82 -0
- package/library/endpoint/stream/file-auto-resolve.d.ts +26 -0
- package/library/endpoint/stream/file-auto-resolve.d.ts.map +1 -0
- package/library/endpoint/stream/file-auto-resolve.js +41 -0
- package/library/endpoint/stream/file-writable.d.ts +33 -0
- package/library/endpoint/stream/file-writable.d.ts.map +1 -0
- package/library/endpoint/stream/file-writable.js +115 -0
- package/library/endpoint/stream/handler.d.ts +20 -0
- package/library/endpoint/stream/handler.d.ts.map +1 -0
- package/library/endpoint/stream/handler.js +32 -0
- package/library/{core → impl}/client.d.ts +16 -13
- package/library/impl/client.d.ts.map +1 -0
- package/library/{core → impl}/client.js +254 -333
- package/library/{core → impl}/request.d.ts.map +1 -1
- package/library/{core → impl}/response.d.ts +7 -12
- package/library/impl/response.d.ts.map +1 -0
- package/library/{core → impl}/response.js +120 -154
- package/library/{core → impl}/server.d.ts +26 -55
- package/library/impl/server.d.ts.map +1 -0
- package/library/impl/server.js +575 -0
- package/library/index.d.ts +13 -6
- package/library/index.d.ts.map +1 -1
- package/library/index.js +16 -16
- package/library/message/ack.d.ts +15 -0
- package/library/message/ack.d.ts.map +1 -0
- package/library/message/ack.js +33 -0
- package/library/message/channel-cache.d.ts +26 -0
- package/library/message/channel-cache.d.ts.map +1 -0
- package/library/message/channel-cache.js +115 -0
- package/library/message/channel.d.ts +53 -6
- package/library/message/channel.d.ts.map +1 -1
- package/library/message/channel.js +96 -9
- package/library/message/dispatcher.d.ts +17 -0
- package/library/message/dispatcher.d.ts.map +1 -1
- package/library/message/dispatcher.js +149 -98
- package/library/stream/error.d.ts +24 -0
- package/library/stream/error.d.ts.map +1 -0
- package/library/stream/error.js +29 -0
- package/library/stream/index.d.ts +4 -1
- package/library/stream/index.d.ts.map +1 -1
- package/library/stream/index.js +7 -4
- package/library/stream/readable-stream.d.ts.map +1 -1
- package/library/stream/readable-stream.js +102 -27
- package/library/stream/stream-core.d.ts +22 -1
- package/library/stream/stream-core.d.ts.map +1 -1
- package/library/stream/stream-core.js +120 -2
- package/library/stream/types.d.ts +115 -2
- package/library/stream/types.d.ts.map +1 -1
- package/library/stream/writable-stream.d.ts +20 -2
- package/library/stream/writable-stream.d.ts.map +1 -1
- package/library/stream/writable-stream.js +366 -41
- package/library/types/index.d.ts +17 -22
- package/library/types/index.d.ts.map +1 -1
- package/library/utils/ack.d.ts +2 -0
- package/library/utils/ack.d.ts.map +1 -0
- package/library/utils/ack.js +44 -0
- package/library/utils/blob.d.ts +3 -0
- package/library/utils/blob.d.ts.map +1 -0
- package/library/utils/blob.js +22 -0
- package/library/utils/cache.d.ts +10 -20
- package/library/utils/cache.d.ts.map +1 -1
- package/library/utils/cache.js +25 -79
- package/library/utils/content-type.d.ts +13 -0
- package/library/utils/content-type.d.ts.map +1 -0
- package/library/utils/content-type.js +87 -0
- package/library/utils/debug.d.ts.map +1 -1
- package/library/utils/debug.js +156 -178
- package/library/utils/hooks.d.ts +30 -0
- package/library/utils/hooks.d.ts.map +1 -0
- package/library/utils/hooks.js +139 -0
- package/library/utils/id.d.ts +9 -0
- package/library/utils/id.d.ts.map +1 -0
- package/library/utils/id.js +21 -0
- package/library/utils/iframe.d.ts +5 -0
- package/library/utils/iframe.d.ts.map +1 -0
- package/library/utils/iframe.js +25 -0
- package/library/utils/index.d.ts +7 -34
- package/library/utils/index.d.ts.map +1 -1
- package/library/utils/index.js +58 -193
- package/library/utils/is.d.ts +2 -0
- package/library/utils/is.d.ts.map +1 -0
- package/library/utils/is.js +9 -0
- package/library/utils/logger.d.ts +13 -0
- package/library/utils/logger.d.ts.map +1 -0
- package/library/utils/logger.js +63 -0
- package/library/utils/origin.d.ts.map +1 -1
- package/library/utils/origin.js +2 -1
- package/library/utils/promise.d.ts +2 -0
- package/library/utils/promise.d.ts.map +1 -0
- package/library/utils/promise.js +9 -0
- package/library/utils/window.d.ts +2 -0
- package/library/utils/window.d.ts.map +1 -0
- package/library/utils/window.js +38 -0
- package/package.json +49 -2
- package/react/package.json +2 -1
- package/esm/core/client-server.js +0 -329
- package/esm/core/server.js +0 -767
- package/esm/utils/ack-meta.js +0 -53
- package/library/core/client-server.d.ts +0 -106
- package/library/core/client-server.d.ts.map +0 -1
- package/library/core/client-server.js +0 -336
- package/library/core/client.d.ts.map +0 -1
- package/library/core/response.d.ts.map +0 -1
- package/library/core/server.d.ts.map +0 -1
- package/library/core/server.js +0 -772
- package/library/utils/ack-meta.d.ts +0 -2
- package/library/utils/ack-meta.d.ts.map +0 -1
- package/library/utils/ack-meta.js +0 -59
- /package/esm/{core → impl}/request.js +0 -0
- /package/library/{core → impl}/request.d.ts +0 -0
- /package/library/{core → impl}/request.js +0 -0
package/esm/api/client.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { getIframeTargetOrigin
|
|
2
|
-
import {
|
|
3
|
-
import { RequestIframeClientImpl } from '../
|
|
1
|
+
import { getIframeTargetOrigin } from '../utils/iframe';
|
|
2
|
+
import { generateInstanceId } from '../utils/id';
|
|
3
|
+
import { RequestIframeClientImpl } from '../impl/client';
|
|
4
4
|
import { setupClientDebugInterceptors } from '../utils/debug';
|
|
5
|
-
import {
|
|
5
|
+
import { setRequestIframeLogLevel } from '../utils/logger';
|
|
6
|
+
import { Messages, ErrorCode, OriginConstant, LogLevel } from '../constants';
|
|
7
|
+
import { clearMessageChannelCache } from '../message/channel-cache';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Create a client (for sending requests)
|
|
@@ -14,7 +16,7 @@ import { Messages, ErrorCode } from '../constants';
|
|
|
14
16
|
*/
|
|
15
17
|
export function requestIframeClient(target, options) {
|
|
16
18
|
var targetWindow = null;
|
|
17
|
-
var targetOrigin =
|
|
19
|
+
var targetOrigin = OriginConstant.ANY;
|
|
18
20
|
if (target.tagName === 'IFRAME') {
|
|
19
21
|
var iframe = target;
|
|
20
22
|
targetWindow = iframe.contentWindow;
|
|
@@ -27,7 +29,7 @@ export function requestIframeClient(target, options) {
|
|
|
27
29
|
}
|
|
28
30
|
} else {
|
|
29
31
|
targetWindow = target;
|
|
30
|
-
targetOrigin =
|
|
32
|
+
targetOrigin = OriginConstant.ANY;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
// Allow user to override targetOrigin explicitly
|
|
@@ -41,15 +43,8 @@ export function requestIframeClient(target, options) {
|
|
|
41
43
|
// Generate instance ID first (will be used by both client and server)
|
|
42
44
|
var instanceId = generateInstanceId();
|
|
43
45
|
|
|
44
|
-
// Create
|
|
45
|
-
var
|
|
46
|
-
secretKey,
|
|
47
|
-
ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
|
|
48
|
-
autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen
|
|
49
|
-
}, instanceId);
|
|
50
|
-
|
|
51
|
-
// Create client instance
|
|
52
|
-
var client = new RequestIframeClientImpl(targetWindow, targetOrigin, server, {
|
|
46
|
+
// Create client instance (internally creates its core message server)
|
|
47
|
+
var client = new RequestIframeClientImpl(targetWindow, targetOrigin, {
|
|
53
48
|
secretKey,
|
|
54
49
|
ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
|
|
55
50
|
timeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
@@ -57,12 +52,23 @@ export function requestIframeClient(target, options) {
|
|
|
57
52
|
returnData: options === null || options === void 0 ? void 0 : options.returnData,
|
|
58
53
|
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
59
54
|
allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
|
|
60
|
-
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin
|
|
55
|
+
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin,
|
|
56
|
+
autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen,
|
|
57
|
+
autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
58
|
+
autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
61
59
|
}, instanceId);
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Trace/log level:
|
|
63
|
+
* - default: only warn/error will be printed (logger default)
|
|
64
|
+
* - if trace enabled: raise log level and (optionally) enable detailed debug interceptors
|
|
65
|
+
*/
|
|
64
66
|
if (options !== null && options !== void 0 && options.trace) {
|
|
65
|
-
|
|
67
|
+
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
68
|
+
setRequestIframeLogLevel(level);
|
|
69
|
+
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
70
|
+
setupClientDebugInterceptors(client);
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
return client;
|
|
68
74
|
}
|
|
@@ -72,8 +78,11 @@ export function requestIframeClient(target, options) {
|
|
|
72
78
|
* Note: This clears the shared message channel for the specified secretKey
|
|
73
79
|
*/
|
|
74
80
|
export function clearRequestIframeClientCache(secretKey) {
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
// Client is not cached; this helper only clears shared MessageChannel cache.
|
|
82
|
+
// If secretKey is provided, only clear channels under that secretKey.
|
|
83
|
+
if (typeof secretKey === 'string') {
|
|
84
|
+
clearMessageChannelCache(secretKey);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
clearMessageChannelCache();
|
|
79
88
|
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import "core-js/modules/es.array.map.js";
|
|
3
|
+
import { getIframeTargetOrigin } from '../utils/iframe';
|
|
4
|
+
import { generateInstanceId } from '../utils/id';
|
|
5
|
+
import { isWindowAvailable } from '../utils/window';
|
|
6
|
+
import { RequestIframeClientImpl } from '../impl/client';
|
|
7
|
+
import { RequestIframeServerImpl } from '../impl/server';
|
|
8
|
+
import { setupClientDebugInterceptors, setupServerDebugListeners } from '../utils/debug';
|
|
9
|
+
import { setRequestIframeLogLevel } from '../utils/logger';
|
|
10
|
+
import { Messages, ErrorCode, OriginConstant, LogLevel } from '../constants';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Endpoint facade type (client + server).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Endpoint facade options (client + server).
|
|
18
|
+
*
|
|
19
|
+
* - For client-side sending: uses RequestIframeClientOptions fields (targetOrigin, headers, etc.)
|
|
20
|
+
* - For server-side handling: uses RequestIframeServerOptions fields (middlewares, allowedOrigins, etc.)
|
|
21
|
+
*
|
|
22
|
+
* Note: overlapping fields (autoOpen/trace/allowedOrigins/validateOrigin/ackTimeout/autoAckMax*) apply to both sides.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
class RequestIframeEndpointApiFacade {
|
|
26
|
+
constructor(params) {
|
|
27
|
+
var _params$options;
|
|
28
|
+
_defineProperty(this, "desiredOpen_", true);
|
|
29
|
+
/** Client send APIs */
|
|
30
|
+
_defineProperty(this, "send", (path, body, options) => this.getClient().send(path, body, options));
|
|
31
|
+
_defineProperty(this, "sendFile", (path, content, options) => this.getClient().sendFile(path, content, options));
|
|
32
|
+
_defineProperty(this, "sendStream", (path, stream, options) => this.getClient().sendStream(path, stream, options));
|
|
33
|
+
_defineProperty(this, "isConnect", () => this.getClient().isConnect());
|
|
34
|
+
_defineProperty(this, "getCookies", path => this.getClient().getCookies(path));
|
|
35
|
+
_defineProperty(this, "getCookie", (name, path) => this.getClient().getCookie(name, path));
|
|
36
|
+
_defineProperty(this, "setCookie", (name, value, options) => this.getClient().setCookie(name, value, options));
|
|
37
|
+
_defineProperty(this, "removeCookie", (name, path) => this.getClient().removeCookie(name, path));
|
|
38
|
+
_defineProperty(this, "clearCookies", () => this.getClient().clearCookies());
|
|
39
|
+
/** Server routing/middleware APIs */
|
|
40
|
+
_defineProperty(this, "use", (pathOrMiddleware, middleware) => this.getServer().use(pathOrMiddleware, middleware));
|
|
41
|
+
_defineProperty(this, "on", (path, handler) => this.getServer().on(path, handler));
|
|
42
|
+
_defineProperty(this, "off", path => this.getServer().off(path));
|
|
43
|
+
_defineProperty(this, "map", handlers => this.getServer().map(handlers));
|
|
44
|
+
this.targetWindow_ = params.targetWindow;
|
|
45
|
+
this.targetOrigin_ = params.targetOrigin;
|
|
46
|
+
this.options_ = params.options;
|
|
47
|
+
this.endpointId_ = params.endpointId;
|
|
48
|
+
this.desiredOpen_ = ((_params$options = params.options) === null || _params$options === void 0 ? void 0 : _params$options.autoOpen) !== false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Lazy create client.
|
|
53
|
+
*/
|
|
54
|
+
getClient() {
|
|
55
|
+
if (!this.client_) {
|
|
56
|
+
var options = this.options_;
|
|
57
|
+
var client = new RequestIframeClientImpl(this.targetWindow_, this.targetOrigin_, {
|
|
58
|
+
secretKey: options === null || options === void 0 ? void 0 : options.secretKey,
|
|
59
|
+
ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
|
|
60
|
+
timeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
61
|
+
asyncTimeout: options === null || options === void 0 ? void 0 : options.asyncTimeout,
|
|
62
|
+
returnData: options === null || options === void 0 ? void 0 : options.returnData,
|
|
63
|
+
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
64
|
+
allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
|
|
65
|
+
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin,
|
|
66
|
+
autoOpen: false,
|
|
67
|
+
autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
68
|
+
autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
69
|
+
}, this.endpointId_);
|
|
70
|
+
if (options !== null && options !== void 0 && options.trace) {
|
|
71
|
+
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
72
|
+
setRequestIframeLogLevel(level);
|
|
73
|
+
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
74
|
+
setupClientDebugInterceptors(client);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.client_ = client;
|
|
78
|
+
}
|
|
79
|
+
if (this.desiredOpen_ && !this.client_.isOpen) {
|
|
80
|
+
this.client_.open();
|
|
81
|
+
}
|
|
82
|
+
if (!this.desiredOpen_ && this.client_.isOpen) {
|
|
83
|
+
this.client_.close();
|
|
84
|
+
}
|
|
85
|
+
return this.client_;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Lazy create server.
|
|
90
|
+
*/
|
|
91
|
+
getServer() {
|
|
92
|
+
if (!this.server_) {
|
|
93
|
+
var options = this.options_;
|
|
94
|
+
var server = new RequestIframeServerImpl({
|
|
95
|
+
secretKey: options === null || options === void 0 ? void 0 : options.secretKey,
|
|
96
|
+
id: this.endpointId_,
|
|
97
|
+
ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
|
|
98
|
+
autoOpen: false,
|
|
99
|
+
allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
|
|
100
|
+
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin,
|
|
101
|
+
maxConcurrentRequestsPerClient: options === null || options === void 0 ? void 0 : options.maxConcurrentRequestsPerClient,
|
|
102
|
+
autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
103
|
+
autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
104
|
+
});
|
|
105
|
+
if (options !== null && options !== void 0 && options.trace) {
|
|
106
|
+
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
107
|
+
setRequestIframeLogLevel(level);
|
|
108
|
+
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
109
|
+
setupServerDebugListeners(server);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.server_ = server;
|
|
113
|
+
}
|
|
114
|
+
if (this.desiredOpen_ && !this.server_.isOpen) {
|
|
115
|
+
this.server_.open();
|
|
116
|
+
}
|
|
117
|
+
if (!this.desiredOpen_ && this.server_.isOpen) {
|
|
118
|
+
this.server_.close();
|
|
119
|
+
}
|
|
120
|
+
return this.server_;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Optional accessors for debugging.
|
|
125
|
+
* Note: accessing will trigger lazy creation.
|
|
126
|
+
*/
|
|
127
|
+
get client() {
|
|
128
|
+
return this.getClient();
|
|
129
|
+
}
|
|
130
|
+
get server() {
|
|
131
|
+
return this.getServer();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Client fields */
|
|
135
|
+
get targetWindow() {
|
|
136
|
+
return this.targetWindow_;
|
|
137
|
+
}
|
|
138
|
+
get id() {
|
|
139
|
+
return this.endpointId_;
|
|
140
|
+
}
|
|
141
|
+
get isOpen() {
|
|
142
|
+
/**
|
|
143
|
+
* Facade-level open state.
|
|
144
|
+
* - When client/server is lazily created later, it will follow this state.
|
|
145
|
+
*/
|
|
146
|
+
return this.desiredOpen_;
|
|
147
|
+
}
|
|
148
|
+
get interceptors() {
|
|
149
|
+
return this.getClient().interceptors;
|
|
150
|
+
}
|
|
151
|
+
set interceptors(value) {
|
|
152
|
+
this.getClient().interceptors = value;
|
|
153
|
+
}
|
|
154
|
+
isAvailable() {
|
|
155
|
+
return isWindowAvailable(this.targetWindow_);
|
|
156
|
+
}
|
|
157
|
+
open() {
|
|
158
|
+
var _this$client_, _this$server_;
|
|
159
|
+
this.desiredOpen_ = true;
|
|
160
|
+
(_this$client_ = this.client_) === null || _this$client_ === void 0 || _this$client_.open();
|
|
161
|
+
(_this$server_ = this.server_) === null || _this$server_ === void 0 || _this$server_.open();
|
|
162
|
+
}
|
|
163
|
+
close() {
|
|
164
|
+
var _this$client_2, _this$server_2;
|
|
165
|
+
this.desiredOpen_ = false;
|
|
166
|
+
(_this$client_2 = this.client_) === null || _this$client_2 === void 0 || _this$client_2.close();
|
|
167
|
+
(_this$server_2 = this.server_) === null || _this$server_2 === void 0 || _this$server_2.close();
|
|
168
|
+
}
|
|
169
|
+
destroy() {
|
|
170
|
+
var _this$client_3, _this$server_3;
|
|
171
|
+
/**
|
|
172
|
+
* Destroy created sides only.
|
|
173
|
+
* They share the underlying MessageChannel via cache ref-counting, so partial creation is safe.
|
|
174
|
+
*/
|
|
175
|
+
(_this$client_3 = this.client_) === null || _this$client_3 === void 0 || _this$client_3.destroy();
|
|
176
|
+
(_this$server_3 = this.server_) === null || _this$server_3 === void 0 || _this$server_3.destroy();
|
|
177
|
+
this.client_ = undefined;
|
|
178
|
+
this.server_ = undefined;
|
|
179
|
+
}
|
|
180
|
+
/** Server fields */
|
|
181
|
+
get secretKey() {
|
|
182
|
+
var _this$options_;
|
|
183
|
+
return (_this$options_ = this.options_) === null || _this$options_ === void 0 ? void 0 : _this$options_.secretKey;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Create an endpoint facade (client + server) for a peer window/iframe.
|
|
189
|
+
*
|
|
190
|
+
* It can:
|
|
191
|
+
* - send requests to the peer (client)
|
|
192
|
+
* - handle requests from the peer (server)
|
|
193
|
+
*/
|
|
194
|
+
export function requestIframeEndpoint(target, options) {
|
|
195
|
+
var _options$id;
|
|
196
|
+
var targetWindow = null;
|
|
197
|
+
var targetOrigin = OriginConstant.ANY;
|
|
198
|
+
if (target.tagName === 'IFRAME') {
|
|
199
|
+
var iframe = target;
|
|
200
|
+
targetWindow = iframe.contentWindow;
|
|
201
|
+
targetOrigin = getIframeTargetOrigin(iframe);
|
|
202
|
+
if (!targetWindow) {
|
|
203
|
+
throw {
|
|
204
|
+
message: Messages.IFRAME_NOT_READY,
|
|
205
|
+
code: ErrorCode.IFRAME_NOT_READY
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
targetWindow = target;
|
|
210
|
+
targetOrigin = OriginConstant.ANY;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Allow user to override targetOrigin explicitly */
|
|
214
|
+
if (options !== null && options !== void 0 && options.targetOrigin) {
|
|
215
|
+
targetOrigin = options.targetOrigin;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Endpoint uses ONE shared id by default, so it behaves like a single endpoint.
|
|
220
|
+
* If options.id is provided, it becomes the shared id for both client+server.
|
|
221
|
+
*/
|
|
222
|
+
var endpointId = (_options$id = options === null || options === void 0 ? void 0 : options.id) !== null && _options$id !== void 0 ? _options$id : generateInstanceId();
|
|
223
|
+
return new RequestIframeEndpointApiFacade({
|
|
224
|
+
targetWindow,
|
|
225
|
+
targetOrigin,
|
|
226
|
+
options,
|
|
227
|
+
endpointId
|
|
228
|
+
});
|
|
229
|
+
}
|
package/esm/api/server.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { RequestIframeServerImpl } from '../
|
|
1
|
+
import { RequestIframeServerImpl } from '../impl/server';
|
|
2
2
|
import { setupServerDebugListeners } from '../utils/debug';
|
|
3
|
+
import { setRequestIframeLogLevel } from '../utils/logger';
|
|
3
4
|
import { getCachedServer, cacheServer, clearServerCache } from '../utils/cache';
|
|
5
|
+
import { LogLevel } from '../constants';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Create a server (for receiving and handling requests)
|
|
@@ -32,12 +34,22 @@ export function requestIframeServer(options) {
|
|
|
32
34
|
autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen,
|
|
33
35
|
allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
|
|
34
36
|
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin,
|
|
35
|
-
maxConcurrentRequestsPerClient: options === null || options === void 0 ? void 0 : options.maxConcurrentRequestsPerClient
|
|
37
|
+
maxConcurrentRequestsPerClient: options === null || options === void 0 ? void 0 : options.maxConcurrentRequestsPerClient,
|
|
38
|
+
autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
39
|
+
autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
36
40
|
});
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Trace/log level:
|
|
44
|
+
* - default: only warn/error will be printed (logger default)
|
|
45
|
+
* - if trace enabled: raise log level and (optionally) enable detailed debug listeners
|
|
46
|
+
*/
|
|
39
47
|
if (options !== null && options !== void 0 && options.trace) {
|
|
40
|
-
|
|
48
|
+
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
49
|
+
setRequestIframeLogLevel(level);
|
|
50
|
+
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
51
|
+
setupServerDebugListeners(server);
|
|
52
|
+
}
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
// Cache server if id is specified
|
|
@@ -51,9 +63,7 @@ export function requestIframeServer(options) {
|
|
|
51
63
|
* Clear server cache (for testing or reset)
|
|
52
64
|
* Note: This clears the cached server instances
|
|
53
65
|
*/
|
|
54
|
-
export function clearRequestIframeServerCache(
|
|
55
|
-
|
|
56
|
-
clearServerCache();
|
|
57
|
-
// MessageChannel cleanup is handled by clearMessageChannelCache in cache.ts
|
|
58
|
-
void secretKey;
|
|
66
|
+
export function clearRequestIframeServerCache(arg) {
|
|
67
|
+
/** Clear server cache */
|
|
68
|
+
clearServerCache(arg);
|
|
59
69
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug constants (event names for structured logs).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export var DebugEvent = {
|
|
6
|
+
CLIENT_REQUEST_START: 'client.request.start',
|
|
7
|
+
CLIENT_REQUEST_SUCCESS: 'client.request.success',
|
|
8
|
+
CLIENT_REQUEST_SUCCESS_FILE: 'client.request.success.file',
|
|
9
|
+
CLIENT_REQUEST_SUCCESS_STREAM: 'client.request.success.stream',
|
|
10
|
+
CLIENT_REQUEST_FAILED: 'client.request.failed',
|
|
11
|
+
CLIENT_MESSAGE_INBOUND: 'client.message.inbound',
|
|
12
|
+
CLIENT_MESSAGE_OUTBOUND: 'client.message.outbound',
|
|
13
|
+
SERVER_REQUEST_RECEIVED: 'server.request.received',
|
|
14
|
+
SERVER_RESPONSE_SEND: 'server.response.send',
|
|
15
|
+
SERVER_MESSAGE_INBOUND: 'server.message.inbound',
|
|
16
|
+
SERVER_MESSAGE_OUTBOUND: 'server.message.outbound'
|
|
17
|
+
};
|
package/esm/constants/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
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
9
|
*/
|
|
10
10
|
export var ProtocolVersion = {
|
|
11
11
|
/** Current protocol version */
|
|
@@ -14,16 +14,34 @@ export var ProtocolVersion = {
|
|
|
14
14
|
MIN_SUPPORTED: 1
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
17
|
+
/**
|
|
18
|
+
* Special origin values
|
|
19
19
|
*/
|
|
20
|
+
export var OriginConstant = {
|
|
21
|
+
/** Wildcard origin (postMessage targetOrigin = '*') */
|
|
22
|
+
ANY: '*'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Auto-ack (ACK-only) limits.
|
|
27
|
+
*/
|
|
28
|
+
export var AutoAckConstant = {
|
|
29
|
+
/** Max length of ack.id to be echoed back in auto-ack */
|
|
30
|
+
MAX_ID_LENGTH: 1024,
|
|
31
|
+
/** Max length of ack.meta to be echoed back in auto-ack */
|
|
32
|
+
MAX_META_LENGTH: 5120
|
|
33
|
+
};
|
|
20
34
|
|
|
21
|
-
/**
|
|
22
|
-
* Protocol
|
|
35
|
+
/**
|
|
36
|
+
* Protocol version type
|
|
23
37
|
*/
|
|
24
38
|
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
39
|
+
/**
|
|
40
|
+
* Protocol validation result
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* HTTP status code constants
|
|
27
45
|
*/
|
|
28
46
|
export var HttpStatus = {
|
|
29
47
|
OK: 200,
|
|
@@ -40,8 +58,8 @@ export var HttpStatus = {
|
|
|
40
58
|
SERVICE_UNAVAILABLE: 503
|
|
41
59
|
};
|
|
42
60
|
|
|
43
|
-
/**
|
|
44
|
-
* HTTP status text constants
|
|
61
|
+
/**
|
|
62
|
+
* HTTP status text constants
|
|
45
63
|
*/
|
|
46
64
|
export var HttpStatusText = {
|
|
47
65
|
[HttpStatus.OK]: 'OK',
|
|
@@ -58,15 +76,15 @@ export var HttpStatusText = {
|
|
|
58
76
|
[HttpStatus.SERVICE_UNAVAILABLE]: 'Service Unavailable'
|
|
59
77
|
};
|
|
60
78
|
|
|
61
|
-
/**
|
|
62
|
-
* Get status text
|
|
79
|
+
/**
|
|
80
|
+
* Get status text
|
|
63
81
|
*/
|
|
64
82
|
export function getStatusText(code) {
|
|
65
83
|
return HttpStatusText[code] || 'Unknown';
|
|
66
84
|
}
|
|
67
85
|
|
|
68
|
-
/**
|
|
69
|
-
* Error code constants
|
|
86
|
+
/**
|
|
87
|
+
* Error code constants
|
|
70
88
|
*/
|
|
71
89
|
export var ErrorCode = {
|
|
72
90
|
/** ACK confirmation timeout */
|
|
@@ -96,11 +114,27 @@ export var ErrorCode = {
|
|
|
96
114
|
/** Too many concurrent requests (rate limiting) */
|
|
97
115
|
TOO_MANY_REQUESTS: 'TOO_MANY_REQUESTS',
|
|
98
116
|
/** Stream start not received in time */
|
|
99
|
-
STREAM_START_TIMEOUT: 'STREAM_START_TIMEOUT'
|
|
117
|
+
STREAM_START_TIMEOUT: 'STREAM_START_TIMEOUT',
|
|
118
|
+
/** Stream has already started */
|
|
119
|
+
STREAM_ALREADY_STARTED: 'STREAM_ALREADY_STARTED',
|
|
120
|
+
/** Stream has ended */
|
|
121
|
+
STREAM_ENDED: 'STREAM_ENDED',
|
|
122
|
+
/** Stream idle timeout */
|
|
123
|
+
STREAM_TIMEOUT: 'STREAM_TIMEOUT',
|
|
124
|
+
/** Stream expired */
|
|
125
|
+
STREAM_EXPIRED: 'STREAM_EXPIRED',
|
|
126
|
+
/** Stream read error */
|
|
127
|
+
STREAM_READ_ERROR: 'STREAM_READ_ERROR',
|
|
128
|
+
/** Stream write() is only available when mode is push */
|
|
129
|
+
STREAM_WRITE_ONLY_IN_PUSH_MODE: 'STREAM_WRITE_ONLY_IN_PUSH_MODE',
|
|
130
|
+
/** Stream pending queue overflow */
|
|
131
|
+
STREAM_PENDING_QUEUE_OVERFLOW: 'STREAM_PENDING_QUEUE_OVERFLOW',
|
|
132
|
+
/** Stream pending bytes overflow */
|
|
133
|
+
STREAM_PENDING_BYTES_OVERFLOW: 'STREAM_PENDING_BYTES_OVERFLOW'
|
|
100
134
|
};
|
|
101
135
|
|
|
102
|
-
/**
|
|
103
|
-
* Message type constants
|
|
136
|
+
/**
|
|
137
|
+
* Message type constants
|
|
104
138
|
*/
|
|
105
139
|
export var MessageType = {
|
|
106
140
|
/** Request message */
|
|
@@ -113,8 +147,6 @@ export var MessageType = {
|
|
|
113
147
|
RESPONSE: 'response',
|
|
114
148
|
/** Error message */
|
|
115
149
|
ERROR: 'error',
|
|
116
|
-
/** Client confirms response received */
|
|
117
|
-
RECEIVED: 'received',
|
|
118
150
|
/** Ping message (for connection detection) */
|
|
119
151
|
PING: 'ping',
|
|
120
152
|
/** Pong message (for connection detection) */
|
|
@@ -130,9 +162,7 @@ export var MessageType = {
|
|
|
130
162
|
/** Stream cancel */
|
|
131
163
|
STREAM_CANCEL: 'stream_cancel',
|
|
132
164
|
/** Stream pull (receiver requests next chunks) */
|
|
133
|
-
STREAM_PULL: 'stream_pull'
|
|
134
|
-
/** Stream ack (receiver acknowledges a chunk) */
|
|
135
|
-
STREAM_ACK: 'stream_ack'
|
|
165
|
+
STREAM_PULL: 'stream_pull'
|
|
136
166
|
};
|
|
137
167
|
export var MessageRole = {
|
|
138
168
|
/** Server role */
|
|
@@ -140,15 +170,15 @@ export var MessageRole = {
|
|
|
140
170
|
/** Client role */
|
|
141
171
|
CLIENT: 'client'
|
|
142
172
|
};
|
|
143
|
-
/**
|
|
144
|
-
* Default timeout configuration (milliseconds)
|
|
173
|
+
/**
|
|
174
|
+
* Default timeout configuration (milliseconds)
|
|
145
175
|
*/
|
|
146
176
|
export var DefaultTimeout = {
|
|
147
|
-
/**
|
|
148
|
-
* ACK confirmation timeout: 1000ms (1s)
|
|
149
|
-
* Used for
|
|
150
|
-
* Increased from 500ms to accommodate slower environments or busy browsers where postMessage
|
|
151
|
-
* serialization/deserialization may take longer.
|
|
177
|
+
/**
|
|
178
|
+
* ACK confirmation timeout: 1000ms (1s)
|
|
179
|
+
* Used for requireAck confirmation (ACK-only).
|
|
180
|
+
* Increased from 500ms to accommodate slower environments or busy browsers where postMessage
|
|
181
|
+
* serialization/deserialization may take longer.
|
|
152
182
|
*/
|
|
153
183
|
ACK: 1000,
|
|
154
184
|
/** Request timeout: 5s */
|
|
@@ -157,8 +187,8 @@ export var DefaultTimeout = {
|
|
|
157
187
|
ASYNC: 120000
|
|
158
188
|
};
|
|
159
189
|
|
|
160
|
-
/**
|
|
161
|
-
* HTTP Header name constants
|
|
190
|
+
/**
|
|
191
|
+
* HTTP Header name constants
|
|
162
192
|
*/
|
|
163
193
|
export var HttpHeader = {
|
|
164
194
|
/** Set-Cookie (server sets cookie) */
|
|
@@ -173,20 +203,20 @@ export var HttpHeader = {
|
|
|
173
203
|
COOKIE: 'Cookie'
|
|
174
204
|
};
|
|
175
205
|
|
|
176
|
-
/**
|
|
177
|
-
* HTTP Header name type
|
|
206
|
+
/**
|
|
207
|
+
* HTTP Header name type
|
|
178
208
|
*/
|
|
179
209
|
|
|
180
|
-
/**
|
|
181
|
-
* Message type union type
|
|
210
|
+
/**
|
|
211
|
+
* Message type union type
|
|
182
212
|
*/
|
|
183
213
|
|
|
184
|
-
/**
|
|
185
|
-
* Error code union type
|
|
214
|
+
/**
|
|
215
|
+
* Error code union type
|
|
186
216
|
*/
|
|
187
217
|
|
|
188
|
-
/**
|
|
189
|
-
* Stream type constants
|
|
218
|
+
/**
|
|
219
|
+
* Stream type constants
|
|
190
220
|
*/
|
|
191
221
|
export var StreamType = {
|
|
192
222
|
/** Normal data stream */
|
|
@@ -195,18 +225,18 @@ export var StreamType = {
|
|
|
195
225
|
FILE: 'file'
|
|
196
226
|
};
|
|
197
227
|
|
|
198
|
-
/**
|
|
199
|
-
* Stream mode constants
|
|
200
|
-
* - PULL: receiver pulls next chunks (backpressure)
|
|
201
|
-
* - PUSH: producer pushes via write()
|
|
228
|
+
/**
|
|
229
|
+
* Stream mode constants
|
|
230
|
+
* - PULL: receiver pulls next chunks (backpressure)
|
|
231
|
+
* - PUSH: producer pushes via write()
|
|
202
232
|
*/
|
|
203
233
|
export var StreamMode = {
|
|
204
234
|
PULL: 'pull',
|
|
205
235
|
PUSH: 'push'
|
|
206
236
|
};
|
|
207
|
-
/**
|
|
208
|
-
* Stream internal message type constants (for stream internal message handling)
|
|
209
|
-
* Note: These are MessageType.STREAM_* values with the stream_ prefix removed
|
|
237
|
+
/**
|
|
238
|
+
* Stream internal message type constants (for stream internal message handling)
|
|
239
|
+
* Note: These are MessageType.STREAM_* values with the stream_ prefix removed
|
|
210
240
|
*/
|
|
211
241
|
export var StreamInternalMessageType = {
|
|
212
242
|
/** Data message */
|
|
@@ -218,21 +248,19 @@ export var StreamInternalMessageType = {
|
|
|
218
248
|
/** Cancel message */
|
|
219
249
|
CANCEL: 'cancel',
|
|
220
250
|
/** Pull message */
|
|
221
|
-
PULL: 'pull'
|
|
222
|
-
/** Ack message */
|
|
223
|
-
ACK: 'ack'
|
|
251
|
+
PULL: 'pull'
|
|
224
252
|
};
|
|
225
253
|
|
|
226
|
-
/**
|
|
227
|
-
* Stream internal message type value type
|
|
254
|
+
/**
|
|
255
|
+
* Stream internal message type value type
|
|
228
256
|
*/
|
|
229
257
|
|
|
230
|
-
/**
|
|
231
|
-
* Stream type value type
|
|
258
|
+
/**
|
|
259
|
+
* Stream type value type
|
|
232
260
|
*/
|
|
233
261
|
|
|
234
|
-
/**
|
|
235
|
-
* Stream state constants
|
|
262
|
+
/**
|
|
263
|
+
* Stream state constants
|
|
236
264
|
*/
|
|
237
265
|
export var StreamState = {
|
|
238
266
|
/** Pending */
|
|
@@ -247,11 +275,32 @@ export var StreamState = {
|
|
|
247
275
|
CANCELLED: 'cancelled'
|
|
248
276
|
};
|
|
249
277
|
|
|
250
|
-
/**
|
|
251
|
-
* Stream state value type
|
|
278
|
+
/**
|
|
279
|
+
* Stream state value type
|
|
252
280
|
*/
|
|
253
281
|
|
|
254
|
-
/**
|
|
255
|
-
*
|
|
282
|
+
/**
|
|
283
|
+
* Stream event name constants (for stream.on / observability)
|
|
284
|
+
*/
|
|
285
|
+
export var StreamEvent = {
|
|
286
|
+
START: 'start',
|
|
287
|
+
DATA: 'data',
|
|
288
|
+
READ: 'read',
|
|
289
|
+
WRITE: 'write',
|
|
290
|
+
SEND: 'send',
|
|
291
|
+
PULL: 'pull',
|
|
292
|
+
ACK: 'ack',
|
|
293
|
+
END: 'end',
|
|
294
|
+
CANCEL: 'cancel',
|
|
295
|
+
ERROR: 'error',
|
|
296
|
+
TIMEOUT: 'timeout',
|
|
297
|
+
EXPIRED: 'expired',
|
|
298
|
+
STATE: 'state'
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Message constants (for multi-language support)
|
|
256
302
|
*/
|
|
257
|
-
export { Messages, formatMessage, setMessages, resetMessages, getMessages } from './messages';
|
|
303
|
+
export { Messages, formatMessage, setMessages, resetMessages, getMessages } from './messages';
|
|
304
|
+
export { WarnOnceKey, buildWarnOnceKey } from './warn-once';
|
|
305
|
+
export { LogLevel } from './log';
|
|
306
|
+
export { DebugEvent } from './debug';
|