request-iframe 0.2.1 → 0.2.2
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 +33 -11
- package/QUICKSTART.md +33 -11
- package/README.CN.md +157 -44
- package/README.md +159 -41
- package/cdn/request-iframe.umd.js +2471 -1709
- package/cdn/request-iframe.umd.js.map +1 -1
- package/cdn/request-iframe.umd.min.js +2 -2
- package/cdn/request-iframe.umd.min.js.map +1 -1
- package/esm/api/client.js +45 -22
- package/esm/api/endpoint.js +30 -13
- package/esm/api/server.js +22 -13
- package/esm/constants/warn-once.js +7 -1
- package/esm/endpoint/index.js +1 -2
- package/esm/endpoint/infra/inbox.js +5 -4
- package/esm/endpoint/infra/outbox.js +8 -8
- package/esm/endpoint/stream/file-auto-resolve.js +9 -8
- package/esm/impl/client.js +3 -2
- package/esm/impl/response.js +4 -2
- package/esm/impl/server.js +8 -6
- package/esm/message/channel.js +15 -3
- package/esm/stream/file-stream.js +311 -72
- package/esm/stream/writable-stream.js +21 -4
- package/esm/utils/blob.js +17 -0
- package/esm/utils/debug-lazy.js +76 -0
- package/esm/utils/logger.js +33 -1
- package/esm/utils/strict-mode.js +85 -0
- package/esm/utils/warn-once.js +30 -0
- package/esm/utils/warnings.js +47 -0
- package/library/api/client.d.ts.map +1 -1
- package/library/api/client.js +45 -22
- package/library/api/endpoint.d.ts.map +1 -1
- package/library/api/endpoint.js +30 -13
- package/library/api/server.d.ts.map +1 -1
- package/library/api/server.js +22 -13
- package/library/constants/warn-once.d.ts +6 -0
- package/library/constants/warn-once.d.ts.map +1 -1
- package/library/constants/warn-once.js +7 -1
- package/library/endpoint/index.d.ts +0 -1
- package/library/endpoint/index.d.ts.map +1 -1
- package/library/endpoint/index.js +1 -8
- package/library/endpoint/infra/inbox.d.ts.map +1 -1
- package/library/endpoint/infra/inbox.js +4 -3
- package/library/endpoint/infra/outbox.d.ts +2 -0
- package/library/endpoint/infra/outbox.d.ts.map +1 -1
- package/library/endpoint/infra/outbox.js +7 -7
- package/library/endpoint/stream/file-auto-resolve.d.ts +1 -1
- package/library/endpoint/stream/file-auto-resolve.d.ts.map +1 -1
- package/library/endpoint/stream/file-auto-resolve.js +8 -8
- package/library/impl/client.d.ts +2 -0
- package/library/impl/client.d.ts.map +1 -1
- package/library/impl/client.js +3 -2
- package/library/impl/response.d.ts.map +1 -1
- package/library/impl/response.js +4 -2
- package/library/impl/server.d.ts.map +1 -1
- package/library/impl/server.js +7 -5
- package/library/message/channel.d.ts +2 -2
- package/library/message/channel.d.ts.map +1 -1
- package/library/message/channel.js +15 -3
- package/library/stream/file-stream.d.ts +70 -5
- package/library/stream/file-stream.d.ts.map +1 -1
- package/library/stream/file-stream.js +310 -70
- package/library/stream/types.d.ts +2 -0
- package/library/stream/types.d.ts.map +1 -1
- package/library/stream/writable-stream.d.ts.map +1 -1
- package/library/stream/writable-stream.js +21 -4
- package/library/types/index.d.ts +38 -0
- package/library/types/index.d.ts.map +1 -1
- package/library/utils/blob.d.ts +7 -0
- package/library/utils/blob.d.ts.map +1 -1
- package/library/utils/blob.js +18 -0
- package/library/utils/debug-lazy.d.ts +26 -0
- package/library/utils/debug-lazy.d.ts.map +1 -0
- package/library/utils/debug-lazy.js +85 -0
- package/library/utils/logger.d.ts +20 -0
- package/library/utils/logger.d.ts.map +1 -1
- package/library/utils/logger.js +34 -1
- package/library/utils/strict-mode.d.ts +37 -0
- package/library/utils/strict-mode.d.ts.map +1 -0
- package/library/utils/strict-mode.js +94 -0
- package/library/utils/warn-once.d.ts +9 -0
- package/library/utils/warn-once.d.ts.map +1 -0
- package/library/utils/warn-once.js +36 -0
- package/library/utils/warnings.d.ts +48 -0
- package/library/utils/warnings.d.ts.map +1 -0
- package/library/utils/warnings.js +54 -0
- package/package.json +1 -1
- package/esm/endpoint/stream/file-writable.js +0 -105
- package/library/endpoint/stream/file-writable.d.ts +0 -33
- package/library/endpoint/stream/file-writable.d.ts.map +0 -1
- package/library/endpoint/stream/file-writable.js +0 -115
|
@@ -1574,11 +1574,11 @@
|
|
|
1574
1574
|
return objectGetOwnPropertySymbols;
|
|
1575
1575
|
}
|
|
1576
1576
|
|
|
1577
|
-
var ownKeys$
|
|
1577
|
+
var ownKeys$e;
|
|
1578
1578
|
var hasRequiredOwnKeys;
|
|
1579
1579
|
|
|
1580
1580
|
function requireOwnKeys () {
|
|
1581
|
-
if (hasRequiredOwnKeys) return ownKeys$
|
|
1581
|
+
if (hasRequiredOwnKeys) return ownKeys$e;
|
|
1582
1582
|
hasRequiredOwnKeys = 1;
|
|
1583
1583
|
var getBuiltIn = requireGetBuiltIn();
|
|
1584
1584
|
var uncurryThis = requireFunctionUncurryThis();
|
|
@@ -1589,12 +1589,12 @@
|
|
|
1589
1589
|
var concat = uncurryThis([].concat);
|
|
1590
1590
|
|
|
1591
1591
|
// all object keys, includes non-enumerable and symbols
|
|
1592
|
-
ownKeys$
|
|
1592
|
+
ownKeys$e = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
1593
1593
|
var keys = getOwnPropertyNamesModule.f(anObject(it));
|
|
1594
1594
|
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
1595
1595
|
return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
|
|
1596
1596
|
};
|
|
1597
|
-
return ownKeys$
|
|
1597
|
+
return ownKeys$e;
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
1600
|
var copyConstructorProperties;
|
|
@@ -5885,8 +5885,8 @@
|
|
|
5885
5885
|
|
|
5886
5886
|
requireEs_string_replace();
|
|
5887
5887
|
|
|
5888
|
-
function ownKeys$
|
|
5889
|
-
function _objectSpread$
|
|
5888
|
+
function ownKeys$d(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; }
|
|
5889
|
+
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5890
5890
|
/**
|
|
5891
5891
|
* Message constants (for multi-language support)
|
|
5892
5892
|
*
|
|
@@ -5987,7 +5987,7 @@
|
|
|
5987
5987
|
/**
|
|
5988
5988
|
* Current message configuration
|
|
5989
5989
|
*/
|
|
5990
|
-
var currentMessages = _objectSpread$
|
|
5990
|
+
var currentMessages = _objectSpread$d({}, defaultMessages);
|
|
5991
5991
|
|
|
5992
5992
|
/**
|
|
5993
5993
|
* Message constants object
|
|
@@ -6003,14 +6003,14 @@
|
|
|
6003
6003
|
* @param messages Custom message content (partial or full)
|
|
6004
6004
|
*/
|
|
6005
6005
|
function setMessages(messages) {
|
|
6006
|
-
currentMessages = _objectSpread$
|
|
6006
|
+
currentMessages = _objectSpread$d(_objectSpread$d({}, defaultMessages), messages);
|
|
6007
6007
|
}
|
|
6008
6008
|
|
|
6009
6009
|
/**
|
|
6010
6010
|
* Reset to default messages
|
|
6011
6011
|
*/
|
|
6012
6012
|
function resetMessages() {
|
|
6013
|
-
currentMessages = _objectSpread$
|
|
6013
|
+
currentMessages = _objectSpread$d({}, defaultMessages);
|
|
6014
6014
|
}
|
|
6015
6015
|
|
|
6016
6016
|
/**
|
|
@@ -6037,7 +6037,7 @@
|
|
|
6037
6037
|
* Get current message configuration
|
|
6038
6038
|
*/
|
|
6039
6039
|
function getMessages() {
|
|
6040
|
-
return _objectSpread$
|
|
6040
|
+
return _objectSpread$d({}, currentMessages);
|
|
6041
6041
|
}
|
|
6042
6042
|
|
|
6043
6043
|
var es_array_map = {};
|
|
@@ -6074,7 +6074,13 @@
|
|
|
6074
6074
|
|
|
6075
6075
|
var WarnOnceKey = {
|
|
6076
6076
|
INBOX_MISSING_PENDING_WHEN_CLOSED: 'inbox:missingPendingWhenClosed',
|
|
6077
|
-
SERVER_MISSING_PENDING_WHEN_CLOSED: 'server:missingPendingWhenClosed'
|
|
6077
|
+
SERVER_MISSING_PENDING_WHEN_CLOSED: 'server:missingPendingWhenClosed',
|
|
6078
|
+
/**
|
|
6079
|
+
* Security warning:
|
|
6080
|
+
* - targetOrigin is '*'
|
|
6081
|
+
* - and no allowedOrigins/validateOrigin is configured
|
|
6082
|
+
*/
|
|
6083
|
+
TARGET_ORIGIN_ANY_WITHOUT_ORIGIN_VALIDATION: 'targetOrigin:anyWithoutOriginValidation'
|
|
6078
6084
|
};
|
|
6079
6085
|
function buildWarnOnceKey(prefix, ...parts) {
|
|
6080
6086
|
if (!parts.length) return prefix;
|
|
@@ -9037,8 +9043,8 @@
|
|
|
9037
9043
|
|
|
9038
9044
|
requireEs_set();
|
|
9039
9045
|
|
|
9040
|
-
function ownKeys$
|
|
9041
|
-
function _objectSpread$
|
|
9046
|
+
function ownKeys$c(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; }
|
|
9047
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9042
9048
|
|
|
9043
9049
|
/**
|
|
9044
9050
|
* Create PostMessage data
|
|
@@ -9048,7 +9054,7 @@
|
|
|
9048
9054
|
* @returns PostMessageData
|
|
9049
9055
|
*/
|
|
9050
9056
|
function createPostMessage(type, requestId, data) {
|
|
9051
|
-
return _objectSpread$
|
|
9057
|
+
return _objectSpread$c({
|
|
9052
9058
|
__requestIframe__: ProtocolVersion.CURRENT,
|
|
9053
9059
|
timestamp: Date.now(),
|
|
9054
9060
|
type,
|
|
@@ -9129,6 +9135,65 @@
|
|
|
9129
9135
|
}
|
|
9130
9136
|
}
|
|
9131
9137
|
|
|
9138
|
+
var esnext_globalThis = {};
|
|
9139
|
+
|
|
9140
|
+
var es_globalThis = {};
|
|
9141
|
+
|
|
9142
|
+
var hasRequiredEs_globalThis;
|
|
9143
|
+
|
|
9144
|
+
function requireEs_globalThis () {
|
|
9145
|
+
if (hasRequiredEs_globalThis) return es_globalThis;
|
|
9146
|
+
hasRequiredEs_globalThis = 1;
|
|
9147
|
+
var $ = require_export();
|
|
9148
|
+
var globalThis = requireGlobalThis();
|
|
9149
|
+
|
|
9150
|
+
// `globalThis` object
|
|
9151
|
+
// https://tc39.es/ecma262/#sec-globalthis
|
|
9152
|
+
$({ global: true, forced: globalThis.globalThis !== globalThis }, {
|
|
9153
|
+
globalThis: globalThis
|
|
9154
|
+
});
|
|
9155
|
+
return es_globalThis;
|
|
9156
|
+
}
|
|
9157
|
+
|
|
9158
|
+
var hasRequiredEsnext_globalThis;
|
|
9159
|
+
|
|
9160
|
+
function requireEsnext_globalThis () {
|
|
9161
|
+
if (hasRequiredEsnext_globalThis) return esnext_globalThis;
|
|
9162
|
+
hasRequiredEsnext_globalThis = 1;
|
|
9163
|
+
// TODO: Remove from `core-js@4`
|
|
9164
|
+
requireEs_globalThis();
|
|
9165
|
+
return esnext_globalThis;
|
|
9166
|
+
}
|
|
9167
|
+
|
|
9168
|
+
requireEsnext_globalThis();
|
|
9169
|
+
|
|
9170
|
+
/**
|
|
9171
|
+
* A simple global warn-once helper.
|
|
9172
|
+
*
|
|
9173
|
+
* Why:
|
|
9174
|
+
* - Some warnings need to fire before a hub/client/server instance exists (e.g. api factory functions).
|
|
9175
|
+
* - We use Symbol.for() so multiple bundles/versions can share the same dedupe storage.
|
|
9176
|
+
*/
|
|
9177
|
+
|
|
9178
|
+
var WARN_ONCE_SYMBOL = Symbol.for('__requestIframeWarnOnce__');
|
|
9179
|
+
function getHost() {
|
|
9180
|
+
if (typeof window !== 'undefined') return window;
|
|
9181
|
+
return globalThis;
|
|
9182
|
+
}
|
|
9183
|
+
function getWarnOnceSet() {
|
|
9184
|
+
var host = getHost();
|
|
9185
|
+
if (!(WARN_ONCE_SYMBOL in host)) {
|
|
9186
|
+
host[WARN_ONCE_SYMBOL] = new Set();
|
|
9187
|
+
}
|
|
9188
|
+
return host[WARN_ONCE_SYMBOL];
|
|
9189
|
+
}
|
|
9190
|
+
function warnOnce(key, fn) {
|
|
9191
|
+
var set = getWarnOnceSet();
|
|
9192
|
+
if (set.has(key)) return;
|
|
9193
|
+
set.add(key);
|
|
9194
|
+
fn();
|
|
9195
|
+
}
|
|
9196
|
+
|
|
9132
9197
|
/**
|
|
9133
9198
|
* Built-in leveled logger for request-iframe.
|
|
9134
9199
|
*
|
|
@@ -9145,6 +9210,9 @@
|
|
|
9145
9210
|
[LogLevel.SILENT]: 100
|
|
9146
9211
|
};
|
|
9147
9212
|
var currentLevel = LogLevel.WARN;
|
|
9213
|
+
function getRequestIframeLogLevel() {
|
|
9214
|
+
return currentLevel;
|
|
9215
|
+
}
|
|
9148
9216
|
function setRequestIframeLogLevel(level) {
|
|
9149
9217
|
currentLevel = level;
|
|
9150
9218
|
}
|
|
@@ -9180,6 +9248,37 @@
|
|
|
9180
9248
|
}
|
|
9181
9249
|
}
|
|
9182
9250
|
|
|
9251
|
+
/**
|
|
9252
|
+
* Unified logger facade.
|
|
9253
|
+
*
|
|
9254
|
+
* Notes:
|
|
9255
|
+
* - This is a thin wrapper around existing functions (kept for backward compatibility).
|
|
9256
|
+
* - `once()` is useful for configuration/security hints to avoid noisy logs.
|
|
9257
|
+
*/
|
|
9258
|
+
var logger = {
|
|
9259
|
+
getLevel: getRequestIframeLogLevel,
|
|
9260
|
+
setLevel: setRequestIframeLogLevel,
|
|
9261
|
+
ensureLevel: ensureRequestIframeLogLevel,
|
|
9262
|
+
trace(message, data) {
|
|
9263
|
+
requestIframeLog(LogLevel.TRACE, message, data);
|
|
9264
|
+
},
|
|
9265
|
+
info(message, data) {
|
|
9266
|
+
requestIframeLog(LogLevel.INFO, message, data);
|
|
9267
|
+
},
|
|
9268
|
+
warn(message, data) {
|
|
9269
|
+
requestIframeLog(LogLevel.WARN, message, data);
|
|
9270
|
+
},
|
|
9271
|
+
error(message, data) {
|
|
9272
|
+
requestIframeLog(LogLevel.ERROR, message, data);
|
|
9273
|
+
},
|
|
9274
|
+
/**
|
|
9275
|
+
* Log once by key (deduped across bundles/versions).
|
|
9276
|
+
*/
|
|
9277
|
+
once(level, key, message, data) {
|
|
9278
|
+
warnOnce(key, () => requestIframeLog(level, message, data));
|
|
9279
|
+
}
|
|
9280
|
+
};
|
|
9281
|
+
|
|
9183
9282
|
var es_array_indexOf = {};
|
|
9184
9283
|
|
|
9185
9284
|
var hasRequiredEs_array_indexOf;
|
|
@@ -9370,8 +9469,8 @@
|
|
|
9370
9469
|
}
|
|
9371
9470
|
}
|
|
9372
9471
|
|
|
9373
|
-
function ownKeys$
|
|
9374
|
-
function _objectSpread$
|
|
9472
|
+
function ownKeys$b(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; }
|
|
9473
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9375
9474
|
|
|
9376
9475
|
/**
|
|
9377
9476
|
* Message context (extracted from MessageEvent, transport-agnostic)
|
|
@@ -9588,10 +9687,22 @@
|
|
|
9588
9687
|
* @param message message data (already formatted as PostMessageData)
|
|
9589
9688
|
* @param targetOrigin target origin (defaults to '*')
|
|
9590
9689
|
*/
|
|
9591
|
-
send(target, message, targetOrigin = OriginConstant.ANY) {
|
|
9690
|
+
send(target, message, targetOrigin = OriginConstant.ANY, transfer) {
|
|
9592
9691
|
if (!isWindowAvailable(target)) {
|
|
9593
9692
|
return false;
|
|
9594
9693
|
}
|
|
9694
|
+
/**
|
|
9695
|
+
* Prefer transferable objects when provided.
|
|
9696
|
+
* Use a try/catch fallback for environments that don't support the 3rd arg signature.
|
|
9697
|
+
*/
|
|
9698
|
+
if (transfer && transfer.length) {
|
|
9699
|
+
try {
|
|
9700
|
+
target.postMessage(message, targetOrigin, transfer);
|
|
9701
|
+
return true;
|
|
9702
|
+
} catch (_unused) {
|
|
9703
|
+
/** fall through to 2-arg postMessage */
|
|
9704
|
+
}
|
|
9705
|
+
}
|
|
9595
9706
|
target.postMessage(message, targetOrigin);
|
|
9596
9707
|
return true;
|
|
9597
9708
|
}
|
|
@@ -9604,11 +9715,11 @@
|
|
|
9604
9715
|
* @param requestId request ID
|
|
9605
9716
|
* @param data additional data
|
|
9606
9717
|
*/
|
|
9607
|
-
sendMessage(target, targetOrigin, type, requestId, data) {
|
|
9608
|
-
var message = createPostMessage(type, requestId, _objectSpread$
|
|
9718
|
+
sendMessage(target, targetOrigin, type, requestId, data, transfer) {
|
|
9719
|
+
var message = createPostMessage(type, requestId, _objectSpread$b(_objectSpread$b({}, data), {}, {
|
|
9609
9720
|
secretKey: this.secretKey
|
|
9610
9721
|
}));
|
|
9611
|
-
return this.send(target, message, targetOrigin);
|
|
9722
|
+
return this.send(target, message, targetOrigin, transfer);
|
|
9612
9723
|
}
|
|
9613
9724
|
|
|
9614
9725
|
/**
|
|
@@ -10068,8 +10179,8 @@
|
|
|
10068
10179
|
return expectedId === receivedId;
|
|
10069
10180
|
}
|
|
10070
10181
|
|
|
10071
|
-
function ownKeys$
|
|
10072
|
-
function _objectSpread$
|
|
10182
|
+
function ownKeys$a(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; }
|
|
10183
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10073
10184
|
function _createForOfIteratorHelper$4(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$4(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10074
10185
|
function _unsupportedIterableToArray$4(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$4(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$4(r, a) : void 0; } }
|
|
10075
10186
|
function _arrayLikeToArray$4(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -10472,7 +10583,7 @@
|
|
|
10472
10583
|
sendMessage(target, targetOrigin, type, requestId, data) {
|
|
10473
10584
|
// Automatically set role, creatorId, and secretKey based on dispatcher's properties
|
|
10474
10585
|
// Create message with role, creatorId, and secretKey using createPostMessage directly
|
|
10475
|
-
var message = createPostMessage(type, requestId, _objectSpread$
|
|
10586
|
+
var message = createPostMessage(type, requestId, _objectSpread$a(_objectSpread$a({}, data), {}, {
|
|
10476
10587
|
role: this.role,
|
|
10477
10588
|
creatorId: this.instanceId,
|
|
10478
10589
|
secretKey: this.secretKey
|
|
@@ -10505,38 +10616,6 @@
|
|
|
10505
10616
|
}
|
|
10506
10617
|
}
|
|
10507
10618
|
|
|
10508
|
-
var esnext_globalThis = {};
|
|
10509
|
-
|
|
10510
|
-
var es_globalThis = {};
|
|
10511
|
-
|
|
10512
|
-
var hasRequiredEs_globalThis;
|
|
10513
|
-
|
|
10514
|
-
function requireEs_globalThis () {
|
|
10515
|
-
if (hasRequiredEs_globalThis) return es_globalThis;
|
|
10516
|
-
hasRequiredEs_globalThis = 1;
|
|
10517
|
-
var $ = require_export();
|
|
10518
|
-
var globalThis = requireGlobalThis();
|
|
10519
|
-
|
|
10520
|
-
// `globalThis` object
|
|
10521
|
-
// https://tc39.es/ecma262/#sec-globalthis
|
|
10522
|
-
$({ global: true, forced: globalThis.globalThis !== globalThis }, {
|
|
10523
|
-
globalThis: globalThis
|
|
10524
|
-
});
|
|
10525
|
-
return es_globalThis;
|
|
10526
|
-
}
|
|
10527
|
-
|
|
10528
|
-
var hasRequiredEsnext_globalThis;
|
|
10529
|
-
|
|
10530
|
-
function requireEsnext_globalThis () {
|
|
10531
|
-
if (hasRequiredEsnext_globalThis) return esnext_globalThis;
|
|
10532
|
-
hasRequiredEsnext_globalThis = 1;
|
|
10533
|
-
// TODO: Remove from `core-js@4`
|
|
10534
|
-
requireEs_globalThis();
|
|
10535
|
-
return esnext_globalThis;
|
|
10536
|
-
}
|
|
10537
|
-
|
|
10538
|
-
requireEsnext_globalThis();
|
|
10539
|
-
|
|
10540
10619
|
/**
|
|
10541
10620
|
* Global cache Symbol (used to store MessageChannel instance cache on window/globalThis).
|
|
10542
10621
|
*
|
|
@@ -10915,8 +10994,8 @@
|
|
|
10915
10994
|
}
|
|
10916
10995
|
}
|
|
10917
10996
|
|
|
10918
|
-
function ownKeys$
|
|
10919
|
-
function _objectSpread$
|
|
10997
|
+
function ownKeys$9(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; }
|
|
10998
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10920
10999
|
|
|
10921
11000
|
/**
|
|
10922
11001
|
* Generate a unique stream ID
|
|
@@ -10991,7 +11070,7 @@
|
|
|
10991
11070
|
});
|
|
10992
11071
|
}
|
|
10993
11072
|
}
|
|
10994
|
-
this.pendingQueue.push(_objectSpread$
|
|
11073
|
+
this.pendingQueue.push(_objectSpread$9(_objectSpread$9({}, item), {}, {
|
|
10995
11074
|
bytes
|
|
10996
11075
|
}));
|
|
10997
11076
|
this.pendingBytes += bytes;
|
|
@@ -11190,14 +11269,31 @@
|
|
|
11190
11269
|
var creatorId = (_this$context$serverI = this.context.serverId) !== null && _this$context$serverI !== void 0 ? _this$context$serverI : this.context.clientId;
|
|
11191
11270
|
var message = createPostMessage(type, this.context.requestId, {
|
|
11192
11271
|
secretKey: this.context.secretKey,
|
|
11193
|
-
body: _objectSpread$
|
|
11272
|
+
body: _objectSpread$9({
|
|
11194
11273
|
streamId: this.streamId
|
|
11195
11274
|
}, data),
|
|
11196
11275
|
role,
|
|
11197
11276
|
creatorId,
|
|
11198
11277
|
targetId: this.context.targetId
|
|
11199
11278
|
});
|
|
11200
|
-
|
|
11279
|
+
|
|
11280
|
+
/**
|
|
11281
|
+
* Transferable optimization:
|
|
11282
|
+
* - If payload contains ArrayBuffer/TypedArray, transfer its underlying buffer to avoid copy.
|
|
11283
|
+
* - This helps large chunks (e.g. file streams) significantly.
|
|
11284
|
+
*/
|
|
11285
|
+
var payloadData = data === null || data === void 0 ? void 0 : data.data;
|
|
11286
|
+
var transfer;
|
|
11287
|
+
try {
|
|
11288
|
+
if (typeof ArrayBuffer !== 'undefined' && payloadData instanceof ArrayBuffer) {
|
|
11289
|
+
transfer = [payloadData];
|
|
11290
|
+
} else if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && payloadData && ArrayBuffer.isView(payloadData) && payloadData.buffer instanceof ArrayBuffer) {
|
|
11291
|
+
transfer = [payloadData.buffer];
|
|
11292
|
+
}
|
|
11293
|
+
} catch (_unused6) {
|
|
11294
|
+
/** ignore */
|
|
11295
|
+
}
|
|
11296
|
+
var ok = this.context.channel.send(this.context.targetWindow, message, this.context.targetOrigin, transfer);
|
|
11201
11297
|
if (!ok) {
|
|
11202
11298
|
this._state = StreamState.CANCELLED;
|
|
11203
11299
|
this.clearExpireTimer();
|
|
@@ -11242,7 +11338,7 @@
|
|
|
11242
11338
|
if (isFunction(ch.removeReceiver)) {
|
|
11243
11339
|
try {
|
|
11244
11340
|
ch.removeReceiver(this.ackReceiver);
|
|
11245
|
-
} catch (
|
|
11341
|
+
} catch (_unused7) {
|
|
11246
11342
|
/** ignore */
|
|
11247
11343
|
}
|
|
11248
11344
|
}
|
|
@@ -11277,7 +11373,7 @@
|
|
|
11277
11373
|
timeout: expireTimeout
|
|
11278
11374
|
});
|
|
11279
11375
|
this.error(formatMessage(Messages.STREAM_EXPIRED, expireTimeout));
|
|
11280
|
-
} catch (
|
|
11376
|
+
} catch (_unused8) {
|
|
11281
11377
|
/** ignore timer-triggered send failures */
|
|
11282
11378
|
}
|
|
11283
11379
|
}, expireTimeout);
|
|
@@ -11792,7 +11888,7 @@
|
|
|
11792
11888
|
this.sendMessage(MessageType.STREAM_CANCEL, {
|
|
11793
11889
|
reason
|
|
11794
11890
|
});
|
|
11795
|
-
} catch (
|
|
11891
|
+
} catch (_unused9) {
|
|
11796
11892
|
// ignore send failures on cancel
|
|
11797
11893
|
}
|
|
11798
11894
|
}
|
|
@@ -11887,6 +11983,71 @@
|
|
|
11887
11983
|
|
|
11888
11984
|
requireEs_array_reduce();
|
|
11889
11985
|
|
|
11986
|
+
var es_string_match = {};
|
|
11987
|
+
|
|
11988
|
+
var hasRequiredEs_string_match;
|
|
11989
|
+
|
|
11990
|
+
function requireEs_string_match () {
|
|
11991
|
+
if (hasRequiredEs_string_match) return es_string_match;
|
|
11992
|
+
hasRequiredEs_string_match = 1;
|
|
11993
|
+
var call = requireFunctionCall();
|
|
11994
|
+
var uncurryThis = requireFunctionUncurryThis();
|
|
11995
|
+
var fixRegExpWellKnownSymbolLogic = requireFixRegexpWellKnownSymbolLogic();
|
|
11996
|
+
var anObject = requireAnObject();
|
|
11997
|
+
var isObject = requireIsObject();
|
|
11998
|
+
var toLength = requireToLength();
|
|
11999
|
+
var toString = requireToString();
|
|
12000
|
+
var requireObjectCoercible = requireRequireObjectCoercible();
|
|
12001
|
+
var getMethod = requireGetMethod();
|
|
12002
|
+
var advanceStringIndex = requireAdvanceStringIndex();
|
|
12003
|
+
var getRegExpFlags = requireRegexpGetFlags();
|
|
12004
|
+
var regExpExec = requireRegexpExecAbstract();
|
|
12005
|
+
|
|
12006
|
+
var stringIndexOf = uncurryThis(''.indexOf);
|
|
12007
|
+
|
|
12008
|
+
// @@match logic
|
|
12009
|
+
fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
|
|
12010
|
+
return [
|
|
12011
|
+
// `String.prototype.match` method
|
|
12012
|
+
// https://tc39.es/ecma262/#sec-string.prototype.match
|
|
12013
|
+
function match(regexp) {
|
|
12014
|
+
var O = requireObjectCoercible(this);
|
|
12015
|
+
var matcher = isObject(regexp) ? getMethod(regexp, MATCH) : undefined;
|
|
12016
|
+
return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
|
|
12017
|
+
},
|
|
12018
|
+
// `RegExp.prototype[@@match]` method
|
|
12019
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
|
12020
|
+
function (string) {
|
|
12021
|
+
var rx = anObject(this);
|
|
12022
|
+
var S = toString(string);
|
|
12023
|
+
var res = maybeCallNative(nativeMatch, rx, S);
|
|
12024
|
+
|
|
12025
|
+
if (res.done) return res.value;
|
|
12026
|
+
|
|
12027
|
+
var flags = toString(getRegExpFlags(rx));
|
|
12028
|
+
|
|
12029
|
+
if (stringIndexOf(flags, 'g') === -1) return regExpExec(rx, S);
|
|
12030
|
+
|
|
12031
|
+
var fullUnicode = stringIndexOf(flags, 'u') !== -1;
|
|
12032
|
+
rx.lastIndex = 0;
|
|
12033
|
+
var A = [];
|
|
12034
|
+
var n = 0;
|
|
12035
|
+
var result;
|
|
12036
|
+
while ((result = regExpExec(rx, S)) !== null) {
|
|
12037
|
+
var matchStr = toString(result[0]);
|
|
12038
|
+
A[n] = matchStr;
|
|
12039
|
+
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
|
12040
|
+
n++;
|
|
12041
|
+
}
|
|
12042
|
+
return n === 0 ? null : A;
|
|
12043
|
+
}
|
|
12044
|
+
];
|
|
12045
|
+
});
|
|
12046
|
+
return es_string_match;
|
|
12047
|
+
}
|
|
12048
|
+
|
|
12049
|
+
requireEs_string_match();
|
|
12050
|
+
|
|
11890
12051
|
var es_typedArray_uint8Array = {};
|
|
11891
12052
|
|
|
11892
12053
|
var typedArrayConstructor = {exports: {}};
|
|
@@ -13393,8 +13554,8 @@
|
|
|
13393
13554
|
|
|
13394
13555
|
requireEs_symbol_asyncIterator();
|
|
13395
13556
|
|
|
13396
|
-
function ownKeys$
|
|
13397
|
-
function _objectSpread$
|
|
13557
|
+
function ownKeys$8(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; }
|
|
13558
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13398
13559
|
|
|
13399
13560
|
/**
|
|
13400
13561
|
* Stream message handler interface
|
|
@@ -13436,7 +13597,7 @@
|
|
|
13436
13597
|
postControl(type, body) {
|
|
13437
13598
|
var message = createPostMessage(type, this.requestId, {
|
|
13438
13599
|
secretKey: this.secretKey,
|
|
13439
|
-
body: _objectSpread$
|
|
13600
|
+
body: _objectSpread$8({
|
|
13440
13601
|
streamId: this.streamId
|
|
13441
13602
|
}, body)
|
|
13442
13603
|
});
|
|
@@ -13953,332 +14114,23 @@
|
|
|
13953
14114
|
}
|
|
13954
14115
|
}
|
|
13955
14116
|
|
|
13956
|
-
|
|
13957
|
-
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
|
|
13958
|
-
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13959
|
-
function ownKeys$6(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; }
|
|
13960
|
-
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14117
|
+
var es_array_includes = {};
|
|
13961
14118
|
|
|
13962
|
-
|
|
13963
|
-
* Convert Uint8Array to Base64 string
|
|
13964
|
-
*/
|
|
13965
|
-
function uint8ArrayToBase64(uint8Array) {
|
|
13966
|
-
/**
|
|
13967
|
-
* Avoid O(n^2) string concatenation for large buffers.
|
|
13968
|
-
* Note: btoa still needs a single binary string, so this mainly improves conversion cost.
|
|
13969
|
-
*/
|
|
13970
|
-
var chunkSize = 0x8000; // 32KB per chunk (safe for fromCharCode/apply limits)
|
|
13971
|
-
var parts = [];
|
|
13972
|
-
for (var i = 0; i < uint8Array.length; i += chunkSize) {
|
|
13973
|
-
var chunk = uint8Array.subarray(i, i + chunkSize);
|
|
13974
|
-
parts.push(String.fromCharCode.apply(null, chunk));
|
|
13975
|
-
}
|
|
13976
|
-
return btoa(parts.join(''));
|
|
13977
|
-
}
|
|
14119
|
+
var hasRequiredEs_array_includes;
|
|
13978
14120
|
|
|
13979
|
-
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
uint8Array[i] = binary.charCodeAt(i);
|
|
13987
|
-
}
|
|
13988
|
-
return uint8Array;
|
|
13989
|
-
}
|
|
14121
|
+
function requireEs_array_includes () {
|
|
14122
|
+
if (hasRequiredEs_array_includes) return es_array_includes;
|
|
14123
|
+
hasRequiredEs_array_includes = 1;
|
|
14124
|
+
var $ = require_export();
|
|
14125
|
+
var $includes = requireArrayIncludes().includes;
|
|
14126
|
+
var fails = requireFails();
|
|
14127
|
+
var addToUnscopables = requireAddToUnscopables();
|
|
13990
14128
|
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
constructor(options) {
|
|
13997
|
-
super(_objectSpread$6(_objectSpread$6({}, options), {}, {
|
|
13998
|
-
type: StreamType.FILE,
|
|
13999
|
-
metadata: _objectSpread$6(_objectSpread$6({}, options.metadata), {}, {
|
|
14000
|
-
filename: options.filename,
|
|
14001
|
-
mimeType: options.mimeType || 'application/octet-stream',
|
|
14002
|
-
size: options.size
|
|
14003
|
-
})
|
|
14004
|
-
}));
|
|
14005
|
-
this.filename = options.filename;
|
|
14006
|
-
this.mimeType = options.mimeType || 'application/octet-stream';
|
|
14007
|
-
this.size = options.size;
|
|
14008
|
-
}
|
|
14009
|
-
|
|
14010
|
-
/**
|
|
14011
|
-
* Override encode method to convert Uint8Array to Base64
|
|
14012
|
-
*/
|
|
14013
|
-
encodeData(data) {
|
|
14014
|
-
if (data instanceof Uint8Array) {
|
|
14015
|
-
return uint8ArrayToBase64(data);
|
|
14016
|
-
}
|
|
14017
|
-
if (data instanceof ArrayBuffer) {
|
|
14018
|
-
return uint8ArrayToBase64(new Uint8Array(data));
|
|
14019
|
-
}
|
|
14020
|
-
if (typeof data === 'string') {
|
|
14021
|
-
// Already a base64 string
|
|
14022
|
-
return data;
|
|
14023
|
-
}
|
|
14024
|
-
// Try to convert other types
|
|
14025
|
-
return String(data);
|
|
14026
|
-
}
|
|
14027
|
-
}
|
|
14028
|
-
|
|
14029
|
-
/**
|
|
14030
|
-
* IframeFileReadableStream - Client-side file readable stream
|
|
14031
|
-
* Automatically handles Base64 decoding of file content
|
|
14032
|
-
*/
|
|
14033
|
-
class IframeFileReadableStream extends IframeReadableStream {
|
|
14034
|
-
constructor(streamId, requestId, messageHandler, options = {}) {
|
|
14035
|
-
var _options$metadata, _options$metadata2, _options$metadata3;
|
|
14036
|
-
super(streamId, requestId, messageHandler, _objectSpread$6(_objectSpread$6({}, options), {}, {
|
|
14037
|
-
type: StreamType.FILE
|
|
14038
|
-
}));
|
|
14039
|
-
this.filename = options.filename || ((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.filename);
|
|
14040
|
-
this.mimeType = options.mimeType || ((_options$metadata2 = options.metadata) === null || _options$metadata2 === void 0 ? void 0 : _options$metadata2.mimeType);
|
|
14041
|
-
this.size = options.size || ((_options$metadata3 = options.metadata) === null || _options$metadata3 === void 0 ? void 0 : _options$metadata3.size);
|
|
14042
|
-
}
|
|
14043
|
-
|
|
14044
|
-
/**
|
|
14045
|
-
* Override decode method to convert Base64 to Uint8Array
|
|
14046
|
-
*/
|
|
14047
|
-
decodeData(data) {
|
|
14048
|
-
if (typeof data === 'string') {
|
|
14049
|
-
return base64ToUint8Array(data);
|
|
14050
|
-
}
|
|
14051
|
-
if (data instanceof Uint8Array) {
|
|
14052
|
-
return data;
|
|
14053
|
-
}
|
|
14054
|
-
if (data instanceof ArrayBuffer) {
|
|
14055
|
-
return new Uint8Array(data);
|
|
14056
|
-
}
|
|
14057
|
-
return new Uint8Array();
|
|
14058
|
-
}
|
|
14059
|
-
|
|
14060
|
-
/**
|
|
14061
|
-
* Override merge method to merge all Uint8Array chunks
|
|
14062
|
-
*/
|
|
14063
|
-
mergeChunks() {
|
|
14064
|
-
var chunks = this.chunks;
|
|
14065
|
-
if (chunks.length === 0) {
|
|
14066
|
-
return new Uint8Array();
|
|
14067
|
-
}
|
|
14068
|
-
if (chunks.length === 1) {
|
|
14069
|
-
return chunks[0];
|
|
14070
|
-
}
|
|
14071
|
-
|
|
14072
|
-
// Calculate total length
|
|
14073
|
-
var totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
14074
|
-
var result = new Uint8Array(totalLength);
|
|
14075
|
-
|
|
14076
|
-
// Merge all chunks
|
|
14077
|
-
var offset = 0;
|
|
14078
|
-
var _iterator = _createForOfIteratorHelper$3(chunks),
|
|
14079
|
-
_step;
|
|
14080
|
-
try {
|
|
14081
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14082
|
-
var chunk = _step.value;
|
|
14083
|
-
result.set(chunk, offset);
|
|
14084
|
-
offset += chunk.length;
|
|
14085
|
-
}
|
|
14086
|
-
} catch (err) {
|
|
14087
|
-
_iterator.e(err);
|
|
14088
|
-
} finally {
|
|
14089
|
-
_iterator.f();
|
|
14090
|
-
}
|
|
14091
|
-
return result;
|
|
14092
|
-
}
|
|
14093
|
-
|
|
14094
|
-
/**
|
|
14095
|
-
* Read all data as a merged Uint8Array (file stream default behavior)
|
|
14096
|
-
*/
|
|
14097
|
-
read() {
|
|
14098
|
-
var _superprop_getRead = () => super.read,
|
|
14099
|
-
_this = this;
|
|
14100
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14101
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
14102
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14103
|
-
case 0:
|
|
14104
|
-
_context.next = 1;
|
|
14105
|
-
return _superprop_getRead().call(_this);
|
|
14106
|
-
case 1:
|
|
14107
|
-
return _context.abrupt("return", _context.sent);
|
|
14108
|
-
case 2:
|
|
14109
|
-
case "end":
|
|
14110
|
-
return _context.stop();
|
|
14111
|
-
}
|
|
14112
|
-
}, _callee);
|
|
14113
|
-
}))();
|
|
14114
|
-
}
|
|
14115
|
-
|
|
14116
|
-
/**
|
|
14117
|
-
* Read as Blob
|
|
14118
|
-
*/
|
|
14119
|
-
readAsBlob() {
|
|
14120
|
-
var _this2 = this;
|
|
14121
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
14122
|
-
var data, buffer;
|
|
14123
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
14124
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
14125
|
-
case 0:
|
|
14126
|
-
_context2.next = 1;
|
|
14127
|
-
return _this2.read();
|
|
14128
|
-
case 1:
|
|
14129
|
-
data = _context2.sent;
|
|
14130
|
-
// Use slice to create a pure ArrayBuffer copy to avoid type issues
|
|
14131
|
-
buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
14132
|
-
return _context2.abrupt("return", new Blob([buffer], {
|
|
14133
|
-
type: _this2.mimeType || 'application/octet-stream'
|
|
14134
|
-
}));
|
|
14135
|
-
case 2:
|
|
14136
|
-
case "end":
|
|
14137
|
-
return _context2.stop();
|
|
14138
|
-
}
|
|
14139
|
-
}, _callee2);
|
|
14140
|
-
}))();
|
|
14141
|
-
}
|
|
14142
|
-
|
|
14143
|
-
/**
|
|
14144
|
-
* Read as File
|
|
14145
|
-
* @param fileName Optional file name (if not provided, uses stream's filename)
|
|
14146
|
-
*/
|
|
14147
|
-
readAsFile(fileName) {
|
|
14148
|
-
var _this3 = this;
|
|
14149
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
14150
|
-
var data, buffer, name;
|
|
14151
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
14152
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
14153
|
-
case 0:
|
|
14154
|
-
_context3.next = 1;
|
|
14155
|
-
return _this3.read();
|
|
14156
|
-
case 1:
|
|
14157
|
-
data = _context3.sent;
|
|
14158
|
-
// Use slice to create a pure ArrayBuffer copy to avoid type issues
|
|
14159
|
-
buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
14160
|
-
name = fileName || _this3.filename || 'file';
|
|
14161
|
-
return _context3.abrupt("return", new File([buffer], name, {
|
|
14162
|
-
type: _this3.mimeType || 'application/octet-stream'
|
|
14163
|
-
}));
|
|
14164
|
-
case 2:
|
|
14165
|
-
case "end":
|
|
14166
|
-
return _context3.stop();
|
|
14167
|
-
}
|
|
14168
|
-
}, _callee3);
|
|
14169
|
-
}))();
|
|
14170
|
-
}
|
|
14171
|
-
|
|
14172
|
-
/**
|
|
14173
|
-
* Read as ArrayBuffer
|
|
14174
|
-
*/
|
|
14175
|
-
readAsArrayBuffer() {
|
|
14176
|
-
var _this4 = this;
|
|
14177
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
14178
|
-
var data, buffer;
|
|
14179
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
14180
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
14181
|
-
case 0:
|
|
14182
|
-
_context4.next = 1;
|
|
14183
|
-
return _this4.read();
|
|
14184
|
-
case 1:
|
|
14185
|
-
data = _context4.sent;
|
|
14186
|
-
// Create a new ArrayBuffer copy
|
|
14187
|
-
buffer = new ArrayBuffer(data.byteLength);
|
|
14188
|
-
new Uint8Array(buffer).set(data);
|
|
14189
|
-
return _context4.abrupt("return", buffer);
|
|
14190
|
-
case 2:
|
|
14191
|
-
case "end":
|
|
14192
|
-
return _context4.stop();
|
|
14193
|
-
}
|
|
14194
|
-
}, _callee4);
|
|
14195
|
-
}))();
|
|
14196
|
-
}
|
|
14197
|
-
|
|
14198
|
-
/**
|
|
14199
|
-
* Read as Data URL
|
|
14200
|
-
*/
|
|
14201
|
-
readAsDataURL() {
|
|
14202
|
-
var _this5 = this;
|
|
14203
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
14204
|
-
var data, base64;
|
|
14205
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
14206
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
14207
|
-
case 0:
|
|
14208
|
-
_context5.next = 1;
|
|
14209
|
-
return _this5.read();
|
|
14210
|
-
case 1:
|
|
14211
|
-
data = _context5.sent;
|
|
14212
|
-
base64 = uint8ArrayToBase64(data);
|
|
14213
|
-
return _context5.abrupt("return", `data:${_this5.mimeType || 'application/octet-stream'};base64,${base64}`);
|
|
14214
|
-
case 2:
|
|
14215
|
-
case "end":
|
|
14216
|
-
return _context5.stop();
|
|
14217
|
-
}
|
|
14218
|
-
}, _callee5);
|
|
14219
|
-
}))();
|
|
14220
|
-
}
|
|
14221
|
-
}
|
|
14222
|
-
|
|
14223
|
-
// Type exports
|
|
14224
|
-
/**
|
|
14225
|
-
* Check if value is an IframeReadableStream
|
|
14226
|
-
*/
|
|
14227
|
-
function isIframeReadableStream(value) {
|
|
14228
|
-
return value instanceof IframeReadableStream;
|
|
14229
|
-
}
|
|
14230
|
-
|
|
14231
|
-
/**
|
|
14232
|
-
* Check if value is an IframeFileReadableStream (file stream)
|
|
14233
|
-
*/
|
|
14234
|
-
function isIframeFileReadableStream(value) {
|
|
14235
|
-
return value instanceof IframeFileReadableStream;
|
|
14236
|
-
}
|
|
14237
|
-
|
|
14238
|
-
/**
|
|
14239
|
-
* Check if value is an IframeWritableStream (includes IframeFileWritableStream)
|
|
14240
|
-
*/
|
|
14241
|
-
function isIframeWritableStream(value) {
|
|
14242
|
-
return value instanceof IframeWritableStream || value instanceof IframeFileWritableStream;
|
|
14243
|
-
}
|
|
14244
|
-
|
|
14245
|
-
/**
|
|
14246
|
-
* Check if value is an IframeFileWritableStream (file writable stream)
|
|
14247
|
-
*/
|
|
14248
|
-
function isIframeFileWritableStream(value) {
|
|
14249
|
-
return value instanceof IframeFileWritableStream;
|
|
14250
|
-
}
|
|
14251
|
-
|
|
14252
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
14253
|
-
__proto__: null,
|
|
14254
|
-
IframeFileReadableStream: IframeFileReadableStream,
|
|
14255
|
-
IframeFileWritableStream: IframeFileWritableStream,
|
|
14256
|
-
IframeReadableStream: IframeReadableStream,
|
|
14257
|
-
IframeWritableStream: IframeWritableStream,
|
|
14258
|
-
RequestIframeStreamError: RequestIframeStreamError,
|
|
14259
|
-
isIframeFileReadableStream: isIframeFileReadableStream,
|
|
14260
|
-
isIframeFileWritableStream: isIframeFileWritableStream,
|
|
14261
|
-
isIframeReadableStream: isIframeReadableStream,
|
|
14262
|
-
isIframeWritableStream: isIframeWritableStream
|
|
14263
|
-
});
|
|
14264
|
-
|
|
14265
|
-
var es_array_includes = {};
|
|
14266
|
-
|
|
14267
|
-
var hasRequiredEs_array_includes;
|
|
14268
|
-
|
|
14269
|
-
function requireEs_array_includes () {
|
|
14270
|
-
if (hasRequiredEs_array_includes) return es_array_includes;
|
|
14271
|
-
hasRequiredEs_array_includes = 1;
|
|
14272
|
-
var $ = require_export();
|
|
14273
|
-
var $includes = requireArrayIncludes().includes;
|
|
14274
|
-
var fails = requireFails();
|
|
14275
|
-
var addToUnscopables = requireAddToUnscopables();
|
|
14276
|
-
|
|
14277
|
-
// FF99+ bug
|
|
14278
|
-
var BROKEN_ON_SPARSE = fails(function () {
|
|
14279
|
-
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
14280
|
-
return !Array(1).includes();
|
|
14281
|
-
});
|
|
14129
|
+
// FF99+ bug
|
|
14130
|
+
var BROKEN_ON_SPARSE = fails(function () {
|
|
14131
|
+
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
14132
|
+
return !Array(1).includes();
|
|
14133
|
+
});
|
|
14282
14134
|
|
|
14283
14135
|
// `Array.prototype.includes` method
|
|
14284
14136
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
@@ -14384,378 +14236,412 @@
|
|
|
14384
14236
|
}
|
|
14385
14237
|
|
|
14386
14238
|
/**
|
|
14387
|
-
*
|
|
14388
|
-
*
|
|
14389
|
-
* This directory integrates postMessage `stream_*` messages with the stream object system in `src/stream`:
|
|
14390
|
-
* - Endpoint-side File/Blob -> IframeFileWritableStream adaptation (for sendFile / res.sendFile)
|
|
14391
|
-
* - Does NOT implement the stream protocol itself (protocol lives in `src/stream`)
|
|
14239
|
+
* Convert Blob to ArrayBuffer.
|
|
14392
14240
|
*
|
|
14393
|
-
*
|
|
14394
|
-
*
|
|
14395
|
-
* Shared by:
|
|
14396
|
-
* - client: sendFile(...) -> sendStream(...)
|
|
14397
|
-
* - server response: res.sendFile(...) -> sendStream(...)
|
|
14241
|
+
* Notes:
|
|
14242
|
+
* - Use FileReader for legacy browser support (e.g. Chrome 49).
|
|
14398
14243
|
*/
|
|
14399
|
-
function
|
|
14400
|
-
return
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
case 0:
|
|
14409
|
-
_context2.next = 1;
|
|
14410
|
-
return Promise.resolve().then(function () { return index; });
|
|
14411
|
-
case 1:
|
|
14412
|
-
_yield$import = _context2.sent;
|
|
14413
|
-
IframeFileWritableStream = _yield$import.IframeFileWritableStream;
|
|
14414
|
-
mimeType = params.mimeType || params.defaultMimeType || 'application/octet-stream';
|
|
14415
|
-
fileName = params.fileName;
|
|
14416
|
-
try {
|
|
14417
|
-
if (typeof File !== 'undefined' && params.content instanceof File) {
|
|
14418
|
-
mimeType = params.content.type || mimeType;
|
|
14419
|
-
fileName = fileName || params.content.name;
|
|
14420
|
-
}
|
|
14421
|
-
} catch (_unused) {
|
|
14422
|
-
/** ignore */
|
|
14423
|
-
}
|
|
14424
|
-
try {
|
|
14425
|
-
if (!fileName && typeof Blob !== 'undefined' && params.content instanceof Blob) {
|
|
14426
|
-
t = params.content.type;
|
|
14427
|
-
if (t) mimeType = t;
|
|
14428
|
-
}
|
|
14429
|
-
} catch (_unused2) {
|
|
14430
|
-
/** ignore */
|
|
14431
|
-
}
|
|
14432
|
-
if (!(typeof params.content === 'string')) {
|
|
14433
|
-
_context2.next = 2;
|
|
14434
|
-
break;
|
|
14435
|
-
}
|
|
14436
|
-
_t = btoa(unescape(encodeURIComponent(params.content)));
|
|
14437
|
-
_context2.next = 4;
|
|
14438
|
-
break;
|
|
14439
|
-
case 2:
|
|
14440
|
-
_context2.next = 3;
|
|
14441
|
-
return blobToBase64(params.content);
|
|
14442
|
-
case 3:
|
|
14443
|
-
_t = _context2.sent;
|
|
14444
|
-
case 4:
|
|
14445
|
-
fileContent = _t;
|
|
14446
|
-
streamFileName = fileName || params.defaultFileName || 'file';
|
|
14447
|
-
stream = new IframeFileWritableStream({
|
|
14448
|
-
filename: streamFileName,
|
|
14449
|
-
mimeType,
|
|
14450
|
-
chunked: (_params$chunked = params.chunked) !== null && _params$chunked !== void 0 ? _params$chunked : false,
|
|
14451
|
-
autoResolve: (_params$autoResolve = params.autoResolve) !== null && _params$autoResolve !== void 0 ? _params$autoResolve : true,
|
|
14452
|
-
next: function () {
|
|
14453
|
-
var _next = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14454
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
14455
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14456
|
-
case 0:
|
|
14457
|
-
return _context.abrupt("return", {
|
|
14458
|
-
data: fileContent,
|
|
14459
|
-
done: true
|
|
14460
|
-
});
|
|
14461
|
-
case 1:
|
|
14462
|
-
case "end":
|
|
14463
|
-
return _context.stop();
|
|
14464
|
-
}
|
|
14465
|
-
}, _callee);
|
|
14466
|
-
}));
|
|
14467
|
-
function next() {
|
|
14468
|
-
return _next.apply(this, arguments);
|
|
14469
|
-
}
|
|
14470
|
-
return next;
|
|
14471
|
-
}()
|
|
14472
|
-
});
|
|
14473
|
-
return _context2.abrupt("return", {
|
|
14474
|
-
stream,
|
|
14475
|
-
fileName,
|
|
14476
|
-
mimeType
|
|
14477
|
-
});
|
|
14478
|
-
case 5:
|
|
14479
|
-
case "end":
|
|
14480
|
-
return _context2.stop();
|
|
14481
|
-
}
|
|
14482
|
-
}, _callee2);
|
|
14483
|
-
}));
|
|
14484
|
-
return _createIframeFileWritableStreamFromContent.apply(this, arguments);
|
|
14244
|
+
function blobToArrayBuffer(blob) {
|
|
14245
|
+
return new Promise((resolve, reject) => {
|
|
14246
|
+
var reader = new FileReader();
|
|
14247
|
+
reader.onloadend = () => {
|
|
14248
|
+
resolve(reader.result);
|
|
14249
|
+
};
|
|
14250
|
+
reader.onerror = reject;
|
|
14251
|
+
reader.readAsArrayBuffer(blob);
|
|
14252
|
+
});
|
|
14485
14253
|
}
|
|
14486
14254
|
|
|
14487
|
-
function
|
|
14488
|
-
function
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
/**
|
|
14495
|
-
* Stream send pipeline params.
|
|
14496
|
-
*/
|
|
14255
|
+
function _createForOfIteratorHelper$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
14256
|
+
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
|
|
14257
|
+
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14258
|
+
function ownKeys$7(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; }
|
|
14259
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14260
|
+
var DEFAULT_FILE_CHUNK_SIZE = 256 * 1024; // 256KB
|
|
14497
14261
|
|
|
14498
|
-
/**
|
|
14499
|
-
*
|
|
14262
|
+
/**
|
|
14263
|
+
* Convert Uint8Array to Base64 string
|
|
14500
14264
|
*/
|
|
14265
|
+
function uint8ArrayToBase64(uint8Array) {
|
|
14266
|
+
/**
|
|
14267
|
+
* Avoid O(n^2) string concatenation for large buffers.
|
|
14268
|
+
* Note: btoa still needs a single binary string, so this mainly improves conversion cost.
|
|
14269
|
+
*/
|
|
14270
|
+
var chunkSize = 0x8000; // 32KB per chunk (safe for fromCharCode/apply limits)
|
|
14271
|
+
var parts = [];
|
|
14272
|
+
for (var i = 0; i < uint8Array.length; i += chunkSize) {
|
|
14273
|
+
var chunk = uint8Array.subarray(i, i + chunkSize);
|
|
14274
|
+
parts.push(String.fromCharCode.apply(null, chunk));
|
|
14275
|
+
}
|
|
14276
|
+
return btoa(parts.join(''));
|
|
14277
|
+
}
|
|
14501
14278
|
|
|
14502
|
-
/**
|
|
14503
|
-
*
|
|
14279
|
+
/**
|
|
14280
|
+
* Convert string to UTF-8 bytes.
|
|
14281
|
+
*
|
|
14282
|
+
* Notes:
|
|
14283
|
+
* - We prefer TextEncoder when available.
|
|
14284
|
+
* - Fallback uses `unescape(encodeURIComponent(...))` for broad browser compatibility.
|
|
14504
14285
|
*/
|
|
14505
|
-
|
|
14506
|
-
function safeIsFile(data) {
|
|
14286
|
+
function stringToUtf8Uint8Array(value) {
|
|
14507
14287
|
try {
|
|
14508
|
-
|
|
14288
|
+
if (typeof TextEncoder !== 'undefined') {
|
|
14289
|
+
return new TextEncoder().encode(value);
|
|
14290
|
+
}
|
|
14509
14291
|
} catch (_unused) {
|
|
14510
|
-
|
|
14292
|
+
/** ignore */
|
|
14511
14293
|
}
|
|
14294
|
+
var latin1 = unescape(encodeURIComponent(value));
|
|
14295
|
+
var arr = new Uint8Array(latin1.length);
|
|
14296
|
+
for (var i = 0; i < latin1.length; i++) {
|
|
14297
|
+
arr[i] = latin1.charCodeAt(i);
|
|
14298
|
+
}
|
|
14299
|
+
return arr;
|
|
14512
14300
|
}
|
|
14513
|
-
|
|
14301
|
+
|
|
14302
|
+
/**
|
|
14303
|
+
* Convert UTF-8 bytes to string.
|
|
14304
|
+
*
|
|
14305
|
+
* Notes:
|
|
14306
|
+
* - We prefer TextDecoder when available.
|
|
14307
|
+
* - Fallback uses `escape/decodeURIComponent` for broad browser compatibility.
|
|
14308
|
+
*/
|
|
14309
|
+
function utf8Uint8ArrayToString(bytes) {
|
|
14514
14310
|
try {
|
|
14515
|
-
|
|
14311
|
+
if (typeof TextDecoder !== 'undefined') {
|
|
14312
|
+
return new TextDecoder('utf-8').decode(bytes);
|
|
14313
|
+
}
|
|
14516
14314
|
} catch (_unused2) {
|
|
14517
|
-
|
|
14315
|
+
/** ignore */
|
|
14518
14316
|
}
|
|
14317
|
+
/**
|
|
14318
|
+
* Fallback:
|
|
14319
|
+
* - Build a latin1 string from bytes, then decode as UTF-8.
|
|
14320
|
+
* - We chunk to avoid call stack / argument limits.
|
|
14321
|
+
*/
|
|
14322
|
+
var chunkSize = 0x8000;
|
|
14323
|
+
var parts = [];
|
|
14324
|
+
for (var i = 0; i < bytes.length; i += chunkSize) {
|
|
14325
|
+
var chunk = bytes.subarray(i, i + chunkSize);
|
|
14326
|
+
parts.push(String.fromCharCode.apply(null, chunk));
|
|
14327
|
+
}
|
|
14328
|
+
return decodeURIComponent(escape(parts.join('')));
|
|
14519
14329
|
}
|
|
14520
14330
|
|
|
14521
|
-
/**
|
|
14522
|
-
*
|
|
14523
|
-
*
|
|
14524
|
-
*
|
|
14525
|
-
*
|
|
14526
|
-
*
|
|
14331
|
+
/**
|
|
14332
|
+
* IframeFileWritableStream - Server-side file writable stream
|
|
14333
|
+
*
|
|
14334
|
+
* Notes:
|
|
14335
|
+
* - This stream supports binary chunks (ArrayBuffer / Uint8Array), which can be transferred
|
|
14336
|
+
* via postMessage transfer list for better performance.
|
|
14527
14337
|
*/
|
|
14528
|
-
class
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
}
|
|
14543
|
-
setDefaultTargetId(targetId) {
|
|
14544
|
-
this.defaultTargetId = targetId;
|
|
14545
|
-
}
|
|
14546
|
-
get secretKey() {
|
|
14547
|
-
return this.dispatcher.secretKey;
|
|
14548
|
-
}
|
|
14549
|
-
get channel() {
|
|
14550
|
-
return this.dispatcher.getChannel();
|
|
14551
|
-
}
|
|
14552
|
-
runWithHooks(hooks, fn) {
|
|
14553
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14554
|
-
var result, _t;
|
|
14555
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
14556
|
-
while (1) switch (_context.prev = _context.next) {
|
|
14338
|
+
class IframeFileWritableStream extends IframeWritableStream {
|
|
14339
|
+
/**
|
|
14340
|
+
* Create a file writable stream from string/Blob/File.
|
|
14341
|
+
*
|
|
14342
|
+
* This is a stream-layer utility:
|
|
14343
|
+
* - It does NOT depend on headers.
|
|
14344
|
+
* - It produces binary chunks (ArrayBuffer) for better performance.
|
|
14345
|
+
*/
|
|
14346
|
+
static from(params) {
|
|
14347
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
14348
|
+
var _params$chunked, _params$autoResolve;
|
|
14349
|
+
var mimeType, fileName, size, t, blob, streamFileName, chunked, chunkSize, offset, stream;
|
|
14350
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
14351
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
14557
14352
|
case 0:
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
case 2:
|
|
14569
|
-
result = _context.sent;
|
|
14570
|
-
if (!hooks.end) {
|
|
14571
|
-
_context.next = 3;
|
|
14572
|
-
break;
|
|
14573
|
-
}
|
|
14574
|
-
_context.next = 3;
|
|
14575
|
-
return hooks.end(result);
|
|
14576
|
-
case 3:
|
|
14577
|
-
return _context.abrupt("return", result);
|
|
14578
|
-
case 4:
|
|
14579
|
-
_context.prev = 4;
|
|
14580
|
-
_t = _context["catch"](0);
|
|
14581
|
-
if (!hooks.error) {
|
|
14582
|
-
_context.next = 6;
|
|
14583
|
-
break;
|
|
14353
|
+
mimeType = params.mimeType || params.defaultMimeType || 'application/octet-stream';
|
|
14354
|
+
fileName = params.fileName;
|
|
14355
|
+
try {
|
|
14356
|
+
if (typeof File !== 'undefined' && params.content instanceof File) {
|
|
14357
|
+
mimeType = params.content.type || mimeType;
|
|
14358
|
+
fileName = fileName || params.content.name;
|
|
14359
|
+
size = params.content.size;
|
|
14360
|
+
}
|
|
14361
|
+
} catch (_unused3) {
|
|
14362
|
+
/** ignore */
|
|
14584
14363
|
}
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
if (!hooks.finally) {
|
|
14594
|
-
_context.next = 8;
|
|
14595
|
-
break;
|
|
14364
|
+
try {
|
|
14365
|
+
if (!fileName && typeof Blob !== 'undefined' && params.content instanceof Blob) {
|
|
14366
|
+
t = params.content.type;
|
|
14367
|
+
if (t) mimeType = t;
|
|
14368
|
+
size = params.content.size;
|
|
14369
|
+
}
|
|
14370
|
+
} catch (_unused4) {
|
|
14371
|
+
/** ignore */
|
|
14596
14372
|
}
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14373
|
+
blob = typeof params.content === 'string' ? new Blob([params.content], {
|
|
14374
|
+
type: mimeType
|
|
14375
|
+
}) : params.content;
|
|
14376
|
+
size = size !== null && size !== void 0 ? size : blob === null || blob === void 0 ? void 0 : blob.size;
|
|
14377
|
+
streamFileName = fileName || params.defaultFileName || 'file';
|
|
14378
|
+
chunked = (_params$chunked = params.chunked) !== null && _params$chunked !== void 0 ? _params$chunked : false;
|
|
14379
|
+
chunkSize = typeof params.chunkSize === 'number' && Number.isFinite(params.chunkSize) && params.chunkSize > 0 ? Math.floor(params.chunkSize) : DEFAULT_FILE_CHUNK_SIZE;
|
|
14380
|
+
offset = 0;
|
|
14381
|
+
stream = new IframeFileWritableStream({
|
|
14382
|
+
filename: streamFileName,
|
|
14383
|
+
mimeType,
|
|
14384
|
+
size,
|
|
14385
|
+
chunked,
|
|
14386
|
+
autoResolve: (_params$autoResolve = params.autoResolve) !== null && _params$autoResolve !== void 0 ? _params$autoResolve : true,
|
|
14387
|
+
next: function () {
|
|
14388
|
+
var _next = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14389
|
+
var _size;
|
|
14390
|
+
var all, total, end, slice, buf;
|
|
14391
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
14392
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14393
|
+
case 0:
|
|
14394
|
+
if (chunked) {
|
|
14395
|
+
_context.next = 2;
|
|
14396
|
+
break;
|
|
14397
|
+
}
|
|
14398
|
+
_context.next = 1;
|
|
14399
|
+
return blobToArrayBuffer(blob);
|
|
14400
|
+
case 1:
|
|
14401
|
+
all = _context.sent;
|
|
14402
|
+
return _context.abrupt("return", {
|
|
14403
|
+
data: all,
|
|
14404
|
+
done: true
|
|
14405
|
+
});
|
|
14406
|
+
case 2:
|
|
14407
|
+
total = (_size = blob.size) !== null && _size !== void 0 ? _size : 0;
|
|
14408
|
+
if (!(offset >= total)) {
|
|
14409
|
+
_context.next = 3;
|
|
14410
|
+
break;
|
|
14411
|
+
}
|
|
14412
|
+
return _context.abrupt("return", {
|
|
14413
|
+
data: new ArrayBuffer(0),
|
|
14414
|
+
done: true
|
|
14415
|
+
});
|
|
14416
|
+
case 3:
|
|
14417
|
+
end = Math.min(total, offset + chunkSize);
|
|
14418
|
+
slice = blob.slice(offset, end);
|
|
14419
|
+
_context.next = 4;
|
|
14420
|
+
return blobToArrayBuffer(slice);
|
|
14421
|
+
case 4:
|
|
14422
|
+
buf = _context.sent;
|
|
14423
|
+
offset = end;
|
|
14424
|
+
return _context.abrupt("return", {
|
|
14425
|
+
data: buf,
|
|
14426
|
+
done: offset >= total
|
|
14427
|
+
});
|
|
14428
|
+
case 5:
|
|
14429
|
+
case "end":
|
|
14430
|
+
return _context.stop();
|
|
14431
|
+
}
|
|
14432
|
+
}, _callee);
|
|
14433
|
+
}));
|
|
14434
|
+
function next() {
|
|
14435
|
+
return _next.apply(this, arguments);
|
|
14436
|
+
}
|
|
14437
|
+
return next;
|
|
14438
|
+
}()
|
|
14439
|
+
});
|
|
14440
|
+
return _context2.abrupt("return", stream);
|
|
14441
|
+
case 1:
|
|
14602
14442
|
case "end":
|
|
14603
|
-
return
|
|
14443
|
+
return _context2.stop();
|
|
14604
14444
|
}
|
|
14605
|
-
},
|
|
14445
|
+
}, _callee2);
|
|
14606
14446
|
}))();
|
|
14607
14447
|
}
|
|
14608
14448
|
|
|
14609
|
-
/**
|
|
14610
|
-
* Create a
|
|
14611
|
-
*
|
|
14612
|
-
* This
|
|
14613
|
-
*
|
|
14614
|
-
|
|
14615
|
-
createStreamBindContext(params) {
|
|
14616
|
-
var _params$targetId;
|
|
14617
|
-
return {
|
|
14618
|
-
requestId: params.requestId,
|
|
14619
|
-
targetWindow: this.targetWindow,
|
|
14620
|
-
targetOrigin: this.targetOrigin,
|
|
14621
|
-
secretKey: this.secretKey,
|
|
14622
|
-
channel: this.channel,
|
|
14623
|
-
registerStreamHandler: params.registerStreamHandler,
|
|
14624
|
-
unregisterStreamHandler: params.unregisterStreamHandler,
|
|
14625
|
-
heartbeat: params.heartbeat,
|
|
14626
|
-
serverId: params.serverId,
|
|
14627
|
-
clientId: params.clientId,
|
|
14628
|
-
targetId: (_params$targetId = params.targetId) !== null && _params$targetId !== void 0 ? _params$targetId : this.defaultTargetId
|
|
14629
|
-
};
|
|
14630
|
-
}
|
|
14631
|
-
|
|
14632
|
-
/**
|
|
14633
|
-
* Bind and start a writable stream to this peer.
|
|
14634
|
-
*
|
|
14635
|
-
* Note:
|
|
14636
|
-
* - Client-side request-body streams may need to delay `start()` until after REQUEST is sent.
|
|
14637
|
-
* For that case, prefer `createStreamBindContext()` + manual `stream.start()`.
|
|
14449
|
+
/**
|
|
14450
|
+
* Create a UTF-8 text file stream.
|
|
14451
|
+
*
|
|
14452
|
+
* This is a convenience wrapper around from({ content: string, ... }):
|
|
14453
|
+
* - Makes "string -> UTF-8 bytes -> file stream" intent explicit.
|
|
14454
|
+
* - Sets a more appropriate default mimeType for text files.
|
|
14638
14455
|
*/
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
return _regeneratorRuntime.wrap(function (
|
|
14643
|
-
while (1) switch (
|
|
14456
|
+
static fromText(params) {
|
|
14457
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
14458
|
+
var _params$mimeType, _params$defaultFileNa;
|
|
14459
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
14460
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
14644
14461
|
case 0:
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14462
|
+
_context3.next = 1;
|
|
14463
|
+
return IframeFileWritableStream.from({
|
|
14464
|
+
content: params.text,
|
|
14465
|
+
fileName: params.fileName,
|
|
14466
|
+
mimeType: (_params$mimeType = params.mimeType) !== null && _params$mimeType !== void 0 ? _params$mimeType : 'text/plain; charset=utf-8',
|
|
14467
|
+
chunked: params.chunked,
|
|
14468
|
+
chunkSize: params.chunkSize,
|
|
14469
|
+
autoResolve: params.autoResolve,
|
|
14470
|
+
defaultFileName: (_params$defaultFileNa = params.defaultFileName) !== null && _params$defaultFileNa !== void 0 ? _params$defaultFileNa : 'file.txt',
|
|
14471
|
+
defaultMimeType: 'text/plain; charset=utf-8'
|
|
14472
|
+
});
|
|
14648
14473
|
case 1:
|
|
14474
|
+
return _context3.abrupt("return", _context3.sent);
|
|
14475
|
+
case 2:
|
|
14649
14476
|
case "end":
|
|
14650
|
-
return
|
|
14477
|
+
return _context3.stop();
|
|
14651
14478
|
}
|
|
14652
|
-
},
|
|
14479
|
+
}, _callee3);
|
|
14653
14480
|
}))();
|
|
14654
14481
|
}
|
|
14482
|
+
constructor(options) {
|
|
14483
|
+
super(_objectSpread$7(_objectSpread$7({}, options), {}, {
|
|
14484
|
+
type: StreamType.FILE,
|
|
14485
|
+
metadata: _objectSpread$7(_objectSpread$7({}, options.metadata), {}, {
|
|
14486
|
+
filename: options.filename,
|
|
14487
|
+
mimeType: options.mimeType || 'application/octet-stream',
|
|
14488
|
+
size: options.size
|
|
14489
|
+
})
|
|
14490
|
+
}));
|
|
14491
|
+
this.filename = options.filename;
|
|
14492
|
+
this.mimeType = options.mimeType || 'application/octet-stream';
|
|
14493
|
+
this.size = options.size;
|
|
14494
|
+
}
|
|
14655
14495
|
|
|
14656
|
-
/**
|
|
14657
|
-
*
|
|
14496
|
+
/**
|
|
14497
|
+
* Encode outbound chunk.
|
|
14498
|
+
*
|
|
14499
|
+
* - ArrayBuffer / TypedArray: keep as-is (binary chunks)
|
|
14500
|
+
* - string: encoded as UTF-8 bytes
|
|
14658
14501
|
*/
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14666
|
-
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
|
|
14680
|
-
|
|
14681
|
-
|
|
14682
|
-
|
|
14683
|
-
|
|
14684
|
-
|
|
14685
|
-
|
|
14686
|
-
|
|
14687
|
-
|
|
14688
|
-
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
|
|
14703
|
-
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14502
|
+
encodeData(data) {
|
|
14503
|
+
try {
|
|
14504
|
+
if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer) {
|
|
14505
|
+
return data;
|
|
14506
|
+
}
|
|
14507
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView && ArrayBuffer.isView(data)) {
|
|
14508
|
+
return data;
|
|
14509
|
+
}
|
|
14510
|
+
} catch (_unused5) {
|
|
14511
|
+
/** ignore */
|
|
14512
|
+
}
|
|
14513
|
+
if (typeof data === 'string') {
|
|
14514
|
+
return stringToUtf8Uint8Array(data);
|
|
14515
|
+
}
|
|
14516
|
+
return stringToUtf8Uint8Array(String(data));
|
|
14517
|
+
}
|
|
14518
|
+
}
|
|
14519
|
+
|
|
14520
|
+
/**
|
|
14521
|
+
* IframeFileReadableStream - Client-side file readable stream
|
|
14522
|
+
* Automatically normalizes inbound chunks to Uint8Array.
|
|
14523
|
+
*/
|
|
14524
|
+
class IframeFileReadableStream extends IframeReadableStream {
|
|
14525
|
+
constructor(streamId, requestId, messageHandler, options = {}) {
|
|
14526
|
+
var _options$metadata, _options$metadata2, _options$metadata3;
|
|
14527
|
+
super(streamId, requestId, messageHandler, _objectSpread$7(_objectSpread$7({}, options), {}, {
|
|
14528
|
+
type: StreamType.FILE
|
|
14529
|
+
}));
|
|
14530
|
+
this.filename = options.filename || ((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.filename);
|
|
14531
|
+
this.mimeType = options.mimeType || ((_options$metadata2 = options.metadata) === null || _options$metadata2 === void 0 ? void 0 : _options$metadata2.mimeType);
|
|
14532
|
+
this.size = options.size || ((_options$metadata3 = options.metadata) === null || _options$metadata3 === void 0 ? void 0 : _options$metadata3.size);
|
|
14533
|
+
}
|
|
14534
|
+
|
|
14535
|
+
/**
|
|
14536
|
+
* Override decode method to normalize chunk to Uint8Array.
|
|
14537
|
+
*/
|
|
14538
|
+
decodeData(data) {
|
|
14539
|
+
if (typeof data === 'string') {
|
|
14540
|
+
return stringToUtf8Uint8Array(data);
|
|
14541
|
+
}
|
|
14542
|
+
if (data instanceof Uint8Array) {
|
|
14543
|
+
return data;
|
|
14544
|
+
}
|
|
14545
|
+
if (data instanceof ArrayBuffer) {
|
|
14546
|
+
return new Uint8Array(data);
|
|
14547
|
+
}
|
|
14548
|
+
return new Uint8Array();
|
|
14549
|
+
}
|
|
14550
|
+
|
|
14551
|
+
/**
|
|
14552
|
+
* Parse filename from Content-Disposition header value.
|
|
14553
|
+
*/
|
|
14554
|
+
static parseFilenameFromContentDisposition(value) {
|
|
14555
|
+
if (!value) return undefined;
|
|
14556
|
+
var disposition = typeof value === 'string' ? value : value[0];
|
|
14557
|
+
if (!disposition) return undefined;
|
|
14558
|
+
var match = disposition.match(/filename="?([^"]+)"?/i);
|
|
14559
|
+
return match ? match[1] : undefined;
|
|
14560
|
+
}
|
|
14561
|
+
|
|
14562
|
+
/**
|
|
14563
|
+
* Resolve this file stream to File or Blob, depending on whether fileName is provided.
|
|
14564
|
+
*/
|
|
14565
|
+
readAsFileOrBlob(fileName) {
|
|
14566
|
+
return fileName ? this.readAsFile(fileName) : this.readAsBlob();
|
|
14567
|
+
}
|
|
14568
|
+
|
|
14569
|
+
/**
|
|
14570
|
+
* Override merge method to merge all Uint8Array chunks
|
|
14571
|
+
*/
|
|
14572
|
+
mergeChunks() {
|
|
14573
|
+
var chunks = this.chunks;
|
|
14574
|
+
if (chunks.length === 0) {
|
|
14575
|
+
return new Uint8Array();
|
|
14576
|
+
}
|
|
14577
|
+
if (chunks.length === 1) {
|
|
14578
|
+
return chunks[0];
|
|
14579
|
+
}
|
|
14580
|
+
|
|
14581
|
+
// Calculate total length
|
|
14582
|
+
var totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
14583
|
+
var result = new Uint8Array(totalLength);
|
|
14584
|
+
|
|
14585
|
+
// Merge all chunks
|
|
14586
|
+
var offset = 0;
|
|
14587
|
+
var _iterator = _createForOfIteratorHelper$3(chunks),
|
|
14588
|
+
_step;
|
|
14589
|
+
try {
|
|
14590
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14591
|
+
var chunk = _step.value;
|
|
14592
|
+
result.set(chunk, offset);
|
|
14593
|
+
offset += chunk.length;
|
|
14594
|
+
}
|
|
14595
|
+
} catch (err) {
|
|
14596
|
+
_iterator.e(err);
|
|
14597
|
+
} finally {
|
|
14598
|
+
_iterator.f();
|
|
14599
|
+
}
|
|
14600
|
+
return result;
|
|
14601
|
+
}
|
|
14602
|
+
|
|
14603
|
+
/**
|
|
14604
|
+
* Read all data as a merged Uint8Array (file stream default behavior)
|
|
14605
|
+
*/
|
|
14606
|
+
read() {
|
|
14607
|
+
var _superprop_getRead = () => super.read,
|
|
14608
|
+
_this = this;
|
|
14609
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
14610
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
14611
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
14612
|
+
case 0:
|
|
14613
|
+
_context4.next = 1;
|
|
14614
|
+
return _superprop_getRead().call(_this);
|
|
14717
14615
|
case 1:
|
|
14616
|
+
return _context4.abrupt("return", _context4.sent);
|
|
14617
|
+
case 2:
|
|
14718
14618
|
case "end":
|
|
14719
14619
|
return _context4.stop();
|
|
14720
14620
|
}
|
|
14721
14621
|
}, _callee4);
|
|
14722
14622
|
}))();
|
|
14723
14623
|
}
|
|
14724
|
-
|
|
14725
|
-
|
|
14624
|
+
|
|
14625
|
+
/**
|
|
14626
|
+
* Read as Blob
|
|
14627
|
+
*/
|
|
14628
|
+
readAsBlob() {
|
|
14629
|
+
var _this2 = this;
|
|
14726
14630
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
14727
|
-
var
|
|
14631
|
+
var data, buffer;
|
|
14728
14632
|
return _regeneratorRuntime.wrap(function (_context5) {
|
|
14729
14633
|
while (1) switch (_context5.prev = _context5.next) {
|
|
14730
14634
|
case 0:
|
|
14731
|
-
params.stream._bind(_this3.createStreamBindContext(params.bind));
|
|
14732
|
-
resultPromise = params.beforeStart ? params.beforeStart({
|
|
14733
|
-
stream: params.stream
|
|
14734
|
-
}) : undefined;
|
|
14735
|
-
if (!(params.awaitStart === false)) {
|
|
14736
|
-
_context5.next = 2;
|
|
14737
|
-
break;
|
|
14738
|
-
}
|
|
14739
|
-
/**
|
|
14740
|
-
* Fire-and-forget:
|
|
14741
|
-
* - request-body stream must start after REQUEST is sent (beforeStart is expected to send REQUEST synchronously)
|
|
14742
|
-
* - we must NOT await the response promise before starting stream, otherwise server will time out waiting stream_start
|
|
14743
|
-
*/
|
|
14744
|
-
void params.stream.start();
|
|
14745
14635
|
_context5.next = 1;
|
|
14746
|
-
return
|
|
14636
|
+
return _this2.read();
|
|
14747
14637
|
case 1:
|
|
14748
|
-
|
|
14638
|
+
data = _context5.sent;
|
|
14639
|
+
// Use slice to create a pure ArrayBuffer copy to avoid type issues
|
|
14640
|
+
buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
14641
|
+
return _context5.abrupt("return", new Blob([buffer], {
|
|
14642
|
+
type: _this2.mimeType || 'application/octet-stream'
|
|
14643
|
+
}));
|
|
14749
14644
|
case 2:
|
|
14750
|
-
_context5.next = 3;
|
|
14751
|
-
return resultPromise;
|
|
14752
|
-
case 3:
|
|
14753
|
-
result = _context5.sent;
|
|
14754
|
-
_context5.next = 4;
|
|
14755
|
-
return params.stream.start();
|
|
14756
|
-
case 4:
|
|
14757
|
-
return _context5.abrupt("return", result);
|
|
14758
|
-
case 5:
|
|
14759
14645
|
case "end":
|
|
14760
14646
|
return _context5.stop();
|
|
14761
14647
|
}
|
|
@@ -14763,30 +14649,55 @@
|
|
|
14763
14649
|
}))();
|
|
14764
14650
|
}
|
|
14765
14651
|
|
|
14766
|
-
/**
|
|
14767
|
-
*
|
|
14652
|
+
/**
|
|
14653
|
+
* Read as UTF-8 text.
|
|
14654
|
+
*
|
|
14655
|
+
* Notes:
|
|
14656
|
+
* - This is intended for "text file" use cases where file stream chunks represent UTF-8 bytes.
|
|
14657
|
+
* - For non-UTF-8 binary files, use readAsBlob()/readAsArrayBuffer().
|
|
14768
14658
|
*/
|
|
14769
|
-
|
|
14659
|
+
readAsText() {
|
|
14660
|
+
var _this3 = this;
|
|
14661
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
14662
|
+
var data;
|
|
14663
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
14664
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
14665
|
+
case 0:
|
|
14666
|
+
_context6.next = 1;
|
|
14667
|
+
return _this3.read();
|
|
14668
|
+
case 1:
|
|
14669
|
+
data = _context6.sent;
|
|
14670
|
+
return _context6.abrupt("return", utf8Uint8ArrayToString(data));
|
|
14671
|
+
case 2:
|
|
14672
|
+
case "end":
|
|
14673
|
+
return _context6.stop();
|
|
14674
|
+
}
|
|
14675
|
+
}, _callee6);
|
|
14676
|
+
}))();
|
|
14677
|
+
}
|
|
14678
|
+
|
|
14679
|
+
/**
|
|
14680
|
+
* Read as File
|
|
14681
|
+
* @param fileName Optional file name (if not provided, uses stream's filename)
|
|
14682
|
+
*/
|
|
14683
|
+
readAsFile(fileName) {
|
|
14770
14684
|
var _this4 = this;
|
|
14771
14685
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
14686
|
+
var data, buffer, name;
|
|
14772
14687
|
return _regeneratorRuntime.wrap(function (_context7) {
|
|
14773
14688
|
while (1) switch (_context7.prev = _context7.next) {
|
|
14774
14689
|
case 0:
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
14778
|
-
case 0:
|
|
14779
|
-
_context6.next = 1;
|
|
14780
|
-
return _this4.runStreamSend(params);
|
|
14781
|
-
case 1:
|
|
14782
|
-
return _context6.abrupt("return", _context6.sent);
|
|
14783
|
-
case 2:
|
|
14784
|
-
case "end":
|
|
14785
|
-
return _context6.stop();
|
|
14786
|
-
}
|
|
14787
|
-
}, _callee6);
|
|
14788
|
-
}))));
|
|
14690
|
+
_context7.next = 1;
|
|
14691
|
+
return _this4.read();
|
|
14789
14692
|
case 1:
|
|
14693
|
+
data = _context7.sent;
|
|
14694
|
+
// Use slice to create a pure ArrayBuffer copy to avoid type issues
|
|
14695
|
+
buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
14696
|
+
name = fileName || _this4.filename || 'file';
|
|
14697
|
+
return _context7.abrupt("return", new File([buffer], name, {
|
|
14698
|
+
type: _this4.mimeType || 'application/octet-stream'
|
|
14699
|
+
}));
|
|
14700
|
+
case 2:
|
|
14790
14701
|
case "end":
|
|
14791
14702
|
return _context7.stop();
|
|
14792
14703
|
}
|
|
@@ -14794,426 +14705,862 @@
|
|
|
14794
14705
|
}))();
|
|
14795
14706
|
}
|
|
14796
14707
|
|
|
14797
|
-
/**
|
|
14798
|
-
*
|
|
14708
|
+
/**
|
|
14709
|
+
* Read as ArrayBuffer
|
|
14799
14710
|
*/
|
|
14800
|
-
|
|
14711
|
+
readAsArrayBuffer() {
|
|
14801
14712
|
var _this5 = this;
|
|
14713
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
14714
|
+
var data, buffer;
|
|
14715
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
14716
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
14717
|
+
case 0:
|
|
14718
|
+
_context8.next = 1;
|
|
14719
|
+
return _this5.read();
|
|
14720
|
+
case 1:
|
|
14721
|
+
data = _context8.sent;
|
|
14722
|
+
// Create a new ArrayBuffer copy
|
|
14723
|
+
buffer = new ArrayBuffer(data.byteLength);
|
|
14724
|
+
new Uint8Array(buffer).set(data);
|
|
14725
|
+
return _context8.abrupt("return", buffer);
|
|
14726
|
+
case 2:
|
|
14727
|
+
case "end":
|
|
14728
|
+
return _context8.stop();
|
|
14729
|
+
}
|
|
14730
|
+
}, _callee8);
|
|
14731
|
+
}))();
|
|
14732
|
+
}
|
|
14733
|
+
|
|
14734
|
+
/**
|
|
14735
|
+
* Read as Data URL
|
|
14736
|
+
*/
|
|
14737
|
+
readAsDataURL() {
|
|
14738
|
+
var _this6 = this;
|
|
14802
14739
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
14740
|
+
var data, base64;
|
|
14803
14741
|
return _regeneratorRuntime.wrap(function (_context9) {
|
|
14804
14742
|
while (1) switch (_context9.prev = _context9.next) {
|
|
14805
14743
|
case 0:
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
var created;
|
|
14809
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
14810
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
14811
|
-
case 0:
|
|
14812
|
-
_context8.next = 1;
|
|
14813
|
-
return createIframeFileWritableStreamFromContent({
|
|
14814
|
-
content: params.content,
|
|
14815
|
-
fileName: params.fileName,
|
|
14816
|
-
mimeType: params.mimeType,
|
|
14817
|
-
chunked: params.chunked,
|
|
14818
|
-
autoResolve: params.autoResolve,
|
|
14819
|
-
defaultFileName: params.defaultFileName,
|
|
14820
|
-
defaultMimeType: params.defaultMimeType
|
|
14821
|
-
});
|
|
14822
|
-
case 1:
|
|
14823
|
-
created = _context8.sent;
|
|
14824
|
-
_context8.next = 2;
|
|
14825
|
-
return (_params$onFileInfo = params.onFileInfo) === null || _params$onFileInfo === void 0 ? void 0 : _params$onFileInfo.call(params, {
|
|
14826
|
-
fileName: created.fileName,
|
|
14827
|
-
mimeType: created.mimeType
|
|
14828
|
-
});
|
|
14829
|
-
case 2:
|
|
14830
|
-
_context8.next = 3;
|
|
14831
|
-
return _this5.runStreamSend(_objectSpread$5(_objectSpread$5({}, params.stream), {}, {
|
|
14832
|
-
stream: created.stream
|
|
14833
|
-
}));
|
|
14834
|
-
case 3:
|
|
14835
|
-
return _context8.abrupt("return", _context8.sent);
|
|
14836
|
-
case 4:
|
|
14837
|
-
case "end":
|
|
14838
|
-
return _context8.stop();
|
|
14839
|
-
}
|
|
14840
|
-
}, _callee8);
|
|
14841
|
-
}))));
|
|
14744
|
+
_context9.next = 1;
|
|
14745
|
+
return _this6.read();
|
|
14842
14746
|
case 1:
|
|
14747
|
+
data = _context9.sent;
|
|
14748
|
+
base64 = uint8ArrayToBase64(data);
|
|
14749
|
+
return _context9.abrupt("return", `data:${_this6.mimeType || 'application/octet-stream'};base64,${base64}`);
|
|
14750
|
+
case 2:
|
|
14843
14751
|
case "end":
|
|
14844
14752
|
return _context9.stop();
|
|
14845
14753
|
}
|
|
14846
14754
|
}, _callee9);
|
|
14847
14755
|
}))();
|
|
14848
14756
|
}
|
|
14849
|
-
|
|
14850
|
-
/**
|
|
14851
|
-
* Send typed message with peer pre-bound.
|
|
14852
|
-
*/
|
|
14853
|
-
sendMessage(type, requestId, data) {
|
|
14854
|
-
var payload = _objectSpread$5({}, data || {});
|
|
14855
|
-
if (payload.targetId === undefined && this.defaultTargetId !== undefined) {
|
|
14856
|
-
payload.targetId = this.defaultTargetId;
|
|
14857
|
-
}
|
|
14858
|
-
this.hooks.beforeSendMessage.call(type, requestId, payload);
|
|
14859
|
-
try {
|
|
14860
|
-
var _ok = this.dispatcher.sendMessage(this.targetWindow, this.targetOrigin, type, requestId, payload);
|
|
14861
|
-
this.hooks.afterSendMessage.call(type, requestId, payload, _ok);
|
|
14862
|
-
return _ok;
|
|
14863
|
-
} catch (e) {
|
|
14864
|
-
this.hooks.sendMessageError.call(type, requestId, payload, e);
|
|
14865
|
-
throw e;
|
|
14866
|
-
}
|
|
14867
|
-
}
|
|
14868
|
-
|
|
14869
|
-
/**
|
|
14870
|
-
* Send raw message with peer pre-bound.
|
|
14871
|
-
*/
|
|
14872
|
-
sendRaw(message) {
|
|
14873
|
-
this.hooks.beforeSendRaw.call(message);
|
|
14874
|
-
try {
|
|
14875
|
-
var _ok2 = this.dispatcher.send(this.targetWindow, message, this.targetOrigin);
|
|
14876
|
-
this.hooks.afterSendRaw.call(message, _ok2);
|
|
14877
|
-
return _ok2;
|
|
14878
|
-
} catch (e) {
|
|
14879
|
-
this.hooks.sendRawError.call(message, e);
|
|
14880
|
-
throw e;
|
|
14881
|
-
}
|
|
14882
|
-
}
|
|
14883
14757
|
}
|
|
14884
14758
|
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
*
|
|
14888
|
-
* - Track all pending maps created by hub
|
|
14889
|
-
* - Track all timeouts created by hub
|
|
14890
|
-
* - Provide a unified cleanup when destroying
|
|
14759
|
+
// Type exports
|
|
14760
|
+
/**
|
|
14761
|
+
* Check if value is an IframeReadableStream
|
|
14891
14762
|
*/
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
_defineProperty(this, "timeouts", new Set());
|
|
14896
|
-
}
|
|
14897
|
-
/**
|
|
14898
|
-
* Get or create a named pending map that will be auto-cleared on destroy.
|
|
14899
|
-
*/
|
|
14900
|
-
map(name) {
|
|
14901
|
-
var existing = this.maps.get(name);
|
|
14902
|
-
if (existing) return existing;
|
|
14903
|
-
var m = new Map();
|
|
14904
|
-
this.maps.set(name, m);
|
|
14905
|
-
return m;
|
|
14906
|
-
}
|
|
14907
|
-
get(name, key) {
|
|
14908
|
-
return this.map(name).get(key);
|
|
14909
|
-
}
|
|
14910
|
-
set(name, key, value) {
|
|
14911
|
-
this.map(name).set(key, value);
|
|
14912
|
-
}
|
|
14913
|
-
has(name, key) {
|
|
14914
|
-
return this.map(name).has(key);
|
|
14915
|
-
}
|
|
14916
|
-
delete(name, key) {
|
|
14917
|
-
return this.map(name).delete(key);
|
|
14918
|
-
}
|
|
14763
|
+
function isIframeReadableStream(value) {
|
|
14764
|
+
return value instanceof IframeReadableStream;
|
|
14765
|
+
}
|
|
14919
14766
|
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
fn();
|
|
14927
|
-
}, ms);
|
|
14928
|
-
this.timeouts.add(id);
|
|
14929
|
-
return id;
|
|
14930
|
-
}
|
|
14767
|
+
/**
|
|
14768
|
+
* Check if value is an IframeFileReadableStream (file stream)
|
|
14769
|
+
*/
|
|
14770
|
+
function isIframeFileReadableStream(value) {
|
|
14771
|
+
return value instanceof IframeFileReadableStream;
|
|
14772
|
+
}
|
|
14931
14773
|
|
|
14932
|
-
|
|
14933
|
-
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
}
|
|
14774
|
+
/**
|
|
14775
|
+
* Check if value is an IframeWritableStream (includes IframeFileWritableStream)
|
|
14776
|
+
*/
|
|
14777
|
+
function isIframeWritableStream(value) {
|
|
14778
|
+
return value instanceof IframeWritableStream || value instanceof IframeFileWritableStream;
|
|
14779
|
+
}
|
|
14939
14780
|
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
this.timeouts.clear();
|
|
14946
|
-
this.maps.forEach(m => m.clear());
|
|
14947
|
-
}
|
|
14781
|
+
/**
|
|
14782
|
+
* Check if value is an IframeFileWritableStream (file writable stream)
|
|
14783
|
+
*/
|
|
14784
|
+
function isIframeFileWritableStream(value) {
|
|
14785
|
+
return value instanceof IframeFileWritableStream;
|
|
14948
14786
|
}
|
|
14949
14787
|
|
|
14788
|
+
function ownKeys$6(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; }
|
|
14789
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14790
|
+
|
|
14950
14791
|
/**
|
|
14951
|
-
*
|
|
14952
|
-
*
|
|
14953
|
-
* This is intended as a shared infrastructure for both client/server:
|
|
14954
|
-
* - server can limit max concurrent in-flight requests per client
|
|
14955
|
-
* - client can limit max concurrent streams / in-flight sends in future
|
|
14792
|
+
* Outbox hooks for send pipelines.
|
|
14956
14793
|
*/
|
|
14957
|
-
class RequestIframeLimiter {
|
|
14958
|
-
constructor(pending) {
|
|
14959
|
-
this.pending = pending;
|
|
14960
|
-
}
|
|
14961
|
-
get(bucket, key) {
|
|
14962
|
-
var _this$pending$get;
|
|
14963
|
-
return (_this$pending$get = this.pending.get(bucket, key)) !== null && _this$pending$get !== void 0 ? _this$pending$get : 0;
|
|
14964
|
-
}
|
|
14965
|
-
|
|
14966
|
-
/**
|
|
14967
|
-
* Try acquire one permit for the given key.
|
|
14968
|
-
* Returns true if acquired, false if limit reached.
|
|
14969
|
-
*/
|
|
14970
|
-
tryAcquire(bucket, key, limit) {
|
|
14971
|
-
if (!Number.isFinite(limit)) {
|
|
14972
|
-
/** Treat Infinity as always allowed but still count for symmetry */
|
|
14973
|
-
var next = this.get(bucket, key) + 1;
|
|
14974
|
-
this.pending.set(bucket, key, next);
|
|
14975
|
-
return true;
|
|
14976
|
-
}
|
|
14977
|
-
var current = this.get(bucket, key);
|
|
14978
|
-
if (current >= limit) return false;
|
|
14979
|
-
this.pending.set(bucket, key, current + 1);
|
|
14980
|
-
return true;
|
|
14981
|
-
}
|
|
14982
14794
|
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
release(bucket, key) {
|
|
14987
|
-
var current = this.get(bucket, key);
|
|
14988
|
-
var next = current - 1;
|
|
14989
|
-
if (next <= 0) {
|
|
14990
|
-
this.pending.delete(bucket, key);
|
|
14991
|
-
return;
|
|
14992
|
-
}
|
|
14993
|
-
this.pending.set(bucket, key, next);
|
|
14994
|
-
}
|
|
14995
|
-
}
|
|
14795
|
+
/**
|
|
14796
|
+
* Stream send pipeline params.
|
|
14797
|
+
*/
|
|
14996
14798
|
|
|
14997
14799
|
/**
|
|
14998
|
-
*
|
|
14800
|
+
* File send pipeline params.
|
|
14999
14801
|
*/
|
|
15000
14802
|
|
|
15001
14803
|
/**
|
|
15002
|
-
*
|
|
15003
|
-
*
|
|
15004
|
-
* Endpoint "hub" responsible for:
|
|
15005
|
-
* - MessageDispatcher lifecycle
|
|
15006
|
-
* - handler registration/unregistration
|
|
15007
|
-
* - pending + timeout management
|
|
15008
|
-
* - limiter counters
|
|
14804
|
+
* Universal send pipeline params.
|
|
15009
14805
|
*/
|
|
15010
|
-
class RequestIframeEndpointHub {
|
|
15011
|
-
constructor(role, instanceId, options) {
|
|
15012
|
-
var _options$versionValid;
|
|
15013
|
-
_defineProperty(this, "hooks", {
|
|
15014
|
-
beforeOpen: new SyncHook(),
|
|
15015
|
-
afterOpen: new SyncHook(),
|
|
15016
|
-
beforeClose: new SyncHook(),
|
|
15017
|
-
afterClose: new SyncHook(),
|
|
15018
|
-
beforeDestroy: new SyncHook(),
|
|
15019
|
-
afterDestroy: new SyncHook(),
|
|
15020
|
-
registerHandler: new SyncHook(),
|
|
15021
|
-
unregisterHandler: new SyncHook()
|
|
15022
|
-
});
|
|
15023
|
-
_defineProperty(this, "pending", new RequestIframePendingManager());
|
|
15024
|
-
_defineProperty(this, "limiter", new RequestIframeLimiter(this.pending));
|
|
15025
|
-
_defineProperty(this, "unregisterFns", []);
|
|
15026
|
-
_defineProperty(this, "warnOnceKeys", new Set());
|
|
15027
|
-
/** Whether it is open */
|
|
15028
|
-
_defineProperty(this, "_isOpen", false);
|
|
15029
|
-
this.instanceId = instanceId;
|
|
15030
|
-
this.versionValidator = (_options$versionValid = options === null || options === void 0 ? void 0 : options.versionValidator) !== null && _options$versionValid !== void 0 ? _options$versionValid : isCompatibleVersion;
|
|
15031
14806
|
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
maxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
15038
|
-
});
|
|
14807
|
+
function safeIsFile(data) {
|
|
14808
|
+
try {
|
|
14809
|
+
return typeof File !== 'undefined' && data instanceof File;
|
|
14810
|
+
} catch (_unused) {
|
|
14811
|
+
return false;
|
|
15039
14812
|
}
|
|
15040
|
-
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
setRegisterHandlers(fn) {
|
|
15047
|
-
this.registerHandlersFn = fn;
|
|
14813
|
+
}
|
|
14814
|
+
function safeIsBlob(data) {
|
|
14815
|
+
try {
|
|
14816
|
+
return typeof Blob !== 'undefined' && data instanceof Blob;
|
|
14817
|
+
} catch (_unused2) {
|
|
14818
|
+
return false;
|
|
15048
14819
|
}
|
|
14820
|
+
}
|
|
15049
14821
|
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
14822
|
+
/**
|
|
14823
|
+
* RequestIframeEndpointOutbox
|
|
14824
|
+
*
|
|
14825
|
+
* A lightweight "built-in sender" bound to a fixed peer (targetWindow/targetOrigin).
|
|
14826
|
+
* Used by request/response-side objects to send messages without repeatedly passing
|
|
14827
|
+
* targetWindow/targetOrigin.
|
|
14828
|
+
*/
|
|
14829
|
+
class RequestIframeEndpointOutbox {
|
|
14830
|
+
constructor(dispatcher, targetWindow, targetOrigin, defaultTargetId) {
|
|
14831
|
+
_defineProperty(this, "hooks", {
|
|
14832
|
+
beforeSendRaw: new SyncHook(),
|
|
14833
|
+
afterSendRaw: new SyncHook(),
|
|
14834
|
+
sendRawError: new SyncHook(),
|
|
14835
|
+
beforeSendMessage: new SyncHook(),
|
|
14836
|
+
afterSendMessage: new SyncHook(),
|
|
14837
|
+
sendMessageError: new SyncHook()
|
|
14838
|
+
});
|
|
14839
|
+
this.dispatcher = dispatcher;
|
|
14840
|
+
this.targetWindow = targetWindow;
|
|
14841
|
+
this.targetOrigin = targetOrigin;
|
|
14842
|
+
this.defaultTargetId = defaultTargetId;
|
|
14843
|
+
}
|
|
14844
|
+
setDefaultTargetId(targetId) {
|
|
14845
|
+
this.defaultTargetId = targetId;
|
|
14846
|
+
}
|
|
14847
|
+
get secretKey() {
|
|
14848
|
+
return this.dispatcher.secretKey;
|
|
14849
|
+
}
|
|
14850
|
+
get channel() {
|
|
14851
|
+
return this.dispatcher.getChannel();
|
|
14852
|
+
}
|
|
14853
|
+
runWithHooks(hooks, fn) {
|
|
14854
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14855
|
+
var result, _t;
|
|
14856
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
14857
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14858
|
+
case 0:
|
|
14859
|
+
_context.prev = 0;
|
|
14860
|
+
if (!hooks.before) {
|
|
14861
|
+
_context.next = 1;
|
|
14862
|
+
break;
|
|
14863
|
+
}
|
|
14864
|
+
_context.next = 1;
|
|
14865
|
+
return hooks.before();
|
|
14866
|
+
case 1:
|
|
14867
|
+
_context.next = 2;
|
|
14868
|
+
return fn();
|
|
14869
|
+
case 2:
|
|
14870
|
+
result = _context.sent;
|
|
14871
|
+
if (!hooks.end) {
|
|
14872
|
+
_context.next = 3;
|
|
14873
|
+
break;
|
|
14874
|
+
}
|
|
14875
|
+
_context.next = 3;
|
|
14876
|
+
return hooks.end(result);
|
|
14877
|
+
case 3:
|
|
14878
|
+
return _context.abrupt("return", result);
|
|
14879
|
+
case 4:
|
|
14880
|
+
_context.prev = 4;
|
|
14881
|
+
_t = _context["catch"](0);
|
|
14882
|
+
if (!hooks.error) {
|
|
14883
|
+
_context.next = 6;
|
|
14884
|
+
break;
|
|
14885
|
+
}
|
|
14886
|
+
_context.next = 5;
|
|
14887
|
+
return hooks.error(_t);
|
|
14888
|
+
case 5:
|
|
14889
|
+
return _context.abrupt("return", _context.sent);
|
|
14890
|
+
case 6:
|
|
14891
|
+
throw _t;
|
|
14892
|
+
case 7:
|
|
14893
|
+
_context.prev = 7;
|
|
14894
|
+
if (!hooks.finally) {
|
|
14895
|
+
_context.next = 8;
|
|
14896
|
+
break;
|
|
14897
|
+
}
|
|
14898
|
+
_context.next = 8;
|
|
14899
|
+
return hooks.finally();
|
|
14900
|
+
case 8:
|
|
14901
|
+
return _context.finish(7);
|
|
14902
|
+
case 9:
|
|
14903
|
+
case "end":
|
|
14904
|
+
return _context.stop();
|
|
14905
|
+
}
|
|
14906
|
+
}, _callee, null, [[0, 4, 7, 9]]);
|
|
14907
|
+
}))();
|
|
15058
14908
|
}
|
|
15059
14909
|
|
|
15060
14910
|
/**
|
|
15061
|
-
* Create
|
|
14911
|
+
* Create a stream bind context using this peer's fixed target info.
|
|
14912
|
+
*
|
|
14913
|
+
* This helps unify the duplicated `_bind({ targetWindow, targetOrigin, secretKey, channel, ... })` logic
|
|
14914
|
+
* across client/server response implementations.
|
|
15062
14915
|
*/
|
|
15063
|
-
|
|
14916
|
+
createStreamBindContext(params) {
|
|
14917
|
+
var _params$targetId;
|
|
15064
14918
|
return {
|
|
15065
|
-
|
|
15066
|
-
|
|
14919
|
+
requestId: params.requestId,
|
|
14920
|
+
targetWindow: this.targetWindow,
|
|
14921
|
+
targetOrigin: this.targetOrigin,
|
|
14922
|
+
secretKey: this.secretKey,
|
|
14923
|
+
channel: this.channel,
|
|
14924
|
+
registerStreamHandler: params.registerStreamHandler,
|
|
14925
|
+
unregisterStreamHandler: params.unregisterStreamHandler,
|
|
14926
|
+
heartbeat: params.heartbeat,
|
|
14927
|
+
serverId: params.serverId,
|
|
14928
|
+
clientId: params.clientId,
|
|
14929
|
+
targetId: (_params$targetId = params.targetId) !== null && _params$targetId !== void 0 ? _params$targetId : this.defaultTargetId
|
|
15067
14930
|
};
|
|
15068
14931
|
}
|
|
15069
14932
|
|
|
15070
14933
|
/**
|
|
15071
|
-
*
|
|
14934
|
+
* Bind and start a writable stream to this peer.
|
|
14935
|
+
*
|
|
14936
|
+
* Note:
|
|
14937
|
+
* - Client-side request-body streams may need to delay `start()` until after REQUEST is sent.
|
|
14938
|
+
* For that case, prefer `createStreamBindContext()` + manual `stream.start()`.
|
|
15072
14939
|
*/
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
14940
|
+
sendWritableStream(stream, params) {
|
|
14941
|
+
var _this = this;
|
|
14942
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
14943
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
14944
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
14945
|
+
case 0:
|
|
14946
|
+
stream._bind(_this.createStreamBindContext(params));
|
|
14947
|
+
_context2.next = 1;
|
|
14948
|
+
return stream.start();
|
|
14949
|
+
case 1:
|
|
14950
|
+
case "end":
|
|
14951
|
+
return _context2.stop();
|
|
14952
|
+
}
|
|
14953
|
+
}, _callee2);
|
|
14954
|
+
}))();
|
|
15077
14955
|
}
|
|
15078
14956
|
|
|
15079
14957
|
/**
|
|
15080
|
-
*
|
|
14958
|
+
* Universal send - dispatch by data type, then call hooks to implement differences.
|
|
15081
14959
|
*/
|
|
15082
|
-
|
|
15083
|
-
|
|
14960
|
+
send(params) {
|
|
14961
|
+
var _this2 = this;
|
|
14962
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
14963
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
14964
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
14965
|
+
case 0:
|
|
14966
|
+
return _context4.abrupt("return", _this2.runWithHooks(params, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
14967
|
+
var data;
|
|
14968
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
14969
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
14970
|
+
case 0:
|
|
14971
|
+
data = params.data;
|
|
14972
|
+
if (!isIframeWritableStream(data)) {
|
|
14973
|
+
_context3.next = 4;
|
|
14974
|
+
break;
|
|
14975
|
+
}
|
|
14976
|
+
if (!params.onStream) {
|
|
14977
|
+
_context3.next = 2;
|
|
14978
|
+
break;
|
|
14979
|
+
}
|
|
14980
|
+
_context3.next = 1;
|
|
14981
|
+
return params.onStream(data);
|
|
14982
|
+
case 1:
|
|
14983
|
+
return _context3.abrupt("return", _context3.sent);
|
|
14984
|
+
case 2:
|
|
14985
|
+
_context3.next = 3;
|
|
14986
|
+
return params.onOther(data);
|
|
14987
|
+
case 3:
|
|
14988
|
+
return _context3.abrupt("return", _context3.sent);
|
|
14989
|
+
case 4:
|
|
14990
|
+
if (!(safeIsFile(data) || safeIsBlob(data))) {
|
|
14991
|
+
_context3.next = 8;
|
|
14992
|
+
break;
|
|
14993
|
+
}
|
|
14994
|
+
if (!params.onFileOrBlob) {
|
|
14995
|
+
_context3.next = 6;
|
|
14996
|
+
break;
|
|
14997
|
+
}
|
|
14998
|
+
_context3.next = 5;
|
|
14999
|
+
return params.onFileOrBlob(data);
|
|
15000
|
+
case 5:
|
|
15001
|
+
return _context3.abrupt("return", _context3.sent);
|
|
15002
|
+
case 6:
|
|
15003
|
+
_context3.next = 7;
|
|
15004
|
+
return params.onOther(data);
|
|
15005
|
+
case 7:
|
|
15006
|
+
return _context3.abrupt("return", _context3.sent);
|
|
15007
|
+
case 8:
|
|
15008
|
+
_context3.next = 9;
|
|
15009
|
+
return params.onOther(data);
|
|
15010
|
+
case 9:
|
|
15011
|
+
return _context3.abrupt("return", _context3.sent);
|
|
15012
|
+
case 10:
|
|
15013
|
+
case "end":
|
|
15014
|
+
return _context3.stop();
|
|
15015
|
+
}
|
|
15016
|
+
}, _callee3);
|
|
15017
|
+
}))));
|
|
15018
|
+
case 1:
|
|
15019
|
+
case "end":
|
|
15020
|
+
return _context4.stop();
|
|
15021
|
+
}
|
|
15022
|
+
}, _callee4);
|
|
15023
|
+
}))();
|
|
15084
15024
|
}
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15025
|
+
runStreamSend(params) {
|
|
15026
|
+
var _this3 = this;
|
|
15027
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
15028
|
+
var resultPromise, result;
|
|
15029
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
15030
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
15031
|
+
case 0:
|
|
15032
|
+
params.stream._bind(_this3.createStreamBindContext(params.bind));
|
|
15033
|
+
resultPromise = params.beforeStart ? params.beforeStart({
|
|
15034
|
+
stream: params.stream
|
|
15035
|
+
}) : undefined;
|
|
15036
|
+
if (!(params.awaitStart === false)) {
|
|
15037
|
+
_context5.next = 2;
|
|
15038
|
+
break;
|
|
15039
|
+
}
|
|
15040
|
+
/**
|
|
15041
|
+
* Fire-and-forget:
|
|
15042
|
+
* - request-body stream must start after REQUEST is sent (beforeStart is expected to send REQUEST synchronously)
|
|
15043
|
+
* - we must NOT await the response promise before starting stream, otherwise server will time out waiting stream_start
|
|
15044
|
+
*/
|
|
15045
|
+
void params.stream.start();
|
|
15046
|
+
_context5.next = 1;
|
|
15047
|
+
return resultPromise;
|
|
15048
|
+
case 1:
|
|
15049
|
+
return _context5.abrupt("return", _context5.sent);
|
|
15050
|
+
case 2:
|
|
15051
|
+
_context5.next = 3;
|
|
15052
|
+
return resultPromise;
|
|
15053
|
+
case 3:
|
|
15054
|
+
result = _context5.sent;
|
|
15055
|
+
_context5.next = 4;
|
|
15056
|
+
return params.stream.start();
|
|
15057
|
+
case 4:
|
|
15058
|
+
return _context5.abrupt("return", result);
|
|
15059
|
+
case 5:
|
|
15060
|
+
case "end":
|
|
15061
|
+
return _context5.stop();
|
|
15062
|
+
}
|
|
15063
|
+
}, _callee5);
|
|
15064
|
+
}))();
|
|
15091
15065
|
}
|
|
15092
15066
|
|
|
15093
15067
|
/**
|
|
15094
|
-
*
|
|
15068
|
+
* Send writable stream via peer.
|
|
15095
15069
|
*/
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15070
|
+
sendStream(params) {
|
|
15071
|
+
var _this4 = this;
|
|
15072
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
15073
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
15074
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
15075
|
+
case 0:
|
|
15076
|
+
return _context7.abrupt("return", _this4.runWithHooks(params, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
15077
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
15078
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
15079
|
+
case 0:
|
|
15080
|
+
_context6.next = 1;
|
|
15081
|
+
return _this4.runStreamSend(params);
|
|
15082
|
+
case 1:
|
|
15083
|
+
return _context6.abrupt("return", _context6.sent);
|
|
15084
|
+
case 2:
|
|
15085
|
+
case "end":
|
|
15086
|
+
return _context6.stop();
|
|
15087
|
+
}
|
|
15088
|
+
}, _callee6);
|
|
15089
|
+
}))));
|
|
15090
|
+
case 1:
|
|
15091
|
+
case "end":
|
|
15092
|
+
return _context7.stop();
|
|
15093
|
+
}
|
|
15094
|
+
}, _callee7);
|
|
15095
|
+
}))();
|
|
15106
15096
|
}
|
|
15107
15097
|
|
|
15108
15098
|
/**
|
|
15109
|
-
*
|
|
15110
|
-
*
|
|
15111
|
-
* This is useful for "response endpoint" style usage where the peer is already known
|
|
15112
|
-
* (e.g. a client bound to an iframe window).
|
|
15099
|
+
* Send File/Blob/string as a file stream via peer.
|
|
15113
15100
|
*/
|
|
15114
|
-
|
|
15115
|
-
this
|
|
15101
|
+
sendFile(params) {
|
|
15102
|
+
var _this5 = this;
|
|
15103
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
15104
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
15105
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
15106
|
+
case 0:
|
|
15107
|
+
return _context9.abrupt("return", _this5.runWithHooks(params, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
15108
|
+
var _params$onFileInfo;
|
|
15109
|
+
var stream;
|
|
15110
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
15111
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
15112
|
+
case 0:
|
|
15113
|
+
_context8.next = 1;
|
|
15114
|
+
return IframeFileWritableStream.from({
|
|
15115
|
+
content: params.content,
|
|
15116
|
+
fileName: params.fileName,
|
|
15117
|
+
mimeType: params.mimeType,
|
|
15118
|
+
chunked: params.chunked,
|
|
15119
|
+
chunkSize: params.chunkSize,
|
|
15120
|
+
autoResolve: params.autoResolve,
|
|
15121
|
+
defaultFileName: params.defaultFileName,
|
|
15122
|
+
defaultMimeType: params.defaultMimeType
|
|
15123
|
+
});
|
|
15124
|
+
case 1:
|
|
15125
|
+
stream = _context8.sent;
|
|
15126
|
+
_context8.next = 2;
|
|
15127
|
+
return (_params$onFileInfo = params.onFileInfo) === null || _params$onFileInfo === void 0 ? void 0 : _params$onFileInfo.call(params, {
|
|
15128
|
+
fileName: stream.filename,
|
|
15129
|
+
mimeType: stream.mimeType
|
|
15130
|
+
});
|
|
15131
|
+
case 2:
|
|
15132
|
+
_context8.next = 3;
|
|
15133
|
+
return _this5.runStreamSend(_objectSpread$6(_objectSpread$6({}, params.stream), {}, {
|
|
15134
|
+
stream: stream
|
|
15135
|
+
}));
|
|
15136
|
+
case 3:
|
|
15137
|
+
return _context8.abrupt("return", _context8.sent);
|
|
15138
|
+
case 4:
|
|
15139
|
+
case "end":
|
|
15140
|
+
return _context8.stop();
|
|
15141
|
+
}
|
|
15142
|
+
}, _callee8);
|
|
15143
|
+
}))));
|
|
15144
|
+
case 1:
|
|
15145
|
+
case "end":
|
|
15146
|
+
return _context9.stop();
|
|
15147
|
+
}
|
|
15148
|
+
}, _callee9);
|
|
15149
|
+
}))();
|
|
15116
15150
|
}
|
|
15117
15151
|
|
|
15118
15152
|
/**
|
|
15119
|
-
*
|
|
15153
|
+
* Send typed message with peer pre-bound.
|
|
15120
15154
|
*/
|
|
15121
|
-
|
|
15122
|
-
|
|
15155
|
+
sendMessage(type, requestId, data) {
|
|
15156
|
+
var payload = _objectSpread$6({}, data || {});
|
|
15157
|
+
if (payload.targetId === undefined && this.defaultTargetId !== undefined) {
|
|
15158
|
+
payload.targetId = this.defaultTargetId;
|
|
15159
|
+
}
|
|
15160
|
+
this.hooks.beforeSendMessage.call(type, requestId, payload);
|
|
15161
|
+
try {
|
|
15162
|
+
var _ok = this.dispatcher.sendMessage(this.targetWindow, this.targetOrigin, type, requestId, payload);
|
|
15163
|
+
this.hooks.afterSendMessage.call(type, requestId, payload, _ok);
|
|
15164
|
+
return _ok;
|
|
15165
|
+
} catch (e) {
|
|
15166
|
+
this.hooks.sendMessageError.call(type, requestId, payload, e);
|
|
15167
|
+
throw e;
|
|
15168
|
+
}
|
|
15123
15169
|
}
|
|
15124
15170
|
|
|
15125
15171
|
/**
|
|
15126
|
-
*
|
|
15172
|
+
* Send raw message with peer pre-bound.
|
|
15127
15173
|
*/
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15174
|
+
sendRaw(message) {
|
|
15175
|
+
this.hooks.beforeSendRaw.call(message);
|
|
15176
|
+
try {
|
|
15177
|
+
var _ok2 = this.dispatcher.send(this.targetWindow, message, this.targetOrigin);
|
|
15178
|
+
this.hooks.afterSendRaw.call(message, _ok2);
|
|
15179
|
+
return _ok2;
|
|
15180
|
+
} catch (e) {
|
|
15181
|
+
this.hooks.sendRawError.call(message, e);
|
|
15182
|
+
throw e;
|
|
15134
15183
|
}
|
|
15135
|
-
this.registerHandlersFn();
|
|
15136
|
-
this.hooks.afterOpen.call();
|
|
15137
15184
|
}
|
|
15185
|
+
}
|
|
15138
15186
|
|
|
15187
|
+
/**
|
|
15188
|
+
* Pending manager for maps and timers.
|
|
15189
|
+
*
|
|
15190
|
+
* - Track all pending maps created by hub
|
|
15191
|
+
* - Track all timeouts created by hub
|
|
15192
|
+
* - Provide a unified cleanup when destroying
|
|
15193
|
+
*/
|
|
15194
|
+
class RequestIframePendingManager {
|
|
15195
|
+
constructor() {
|
|
15196
|
+
_defineProperty(this, "maps", new Map());
|
|
15197
|
+
_defineProperty(this, "timeouts", new Set());
|
|
15198
|
+
}
|
|
15139
15199
|
/**
|
|
15140
|
-
*
|
|
15200
|
+
* Get or create a named pending map that will be auto-cleared on destroy.
|
|
15141
15201
|
*/
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
this.
|
|
15151
|
-
|
|
15202
|
+
map(name) {
|
|
15203
|
+
var existing = this.maps.get(name);
|
|
15204
|
+
if (existing) return existing;
|
|
15205
|
+
var m = new Map();
|
|
15206
|
+
this.maps.set(name, m);
|
|
15207
|
+
return m;
|
|
15208
|
+
}
|
|
15209
|
+
get(name, key) {
|
|
15210
|
+
return this.map(name).get(key);
|
|
15211
|
+
}
|
|
15212
|
+
set(name, key, value) {
|
|
15213
|
+
this.map(name).set(key, value);
|
|
15214
|
+
}
|
|
15215
|
+
has(name, key) {
|
|
15216
|
+
return this.map(name).has(key);
|
|
15217
|
+
}
|
|
15218
|
+
delete(name, key) {
|
|
15219
|
+
return this.map(name).delete(key);
|
|
15152
15220
|
}
|
|
15153
15221
|
|
|
15154
15222
|
/**
|
|
15155
|
-
*
|
|
15223
|
+
* Create a timeout that will be auto-cleared on destroy.
|
|
15156
15224
|
*/
|
|
15157
|
-
|
|
15158
|
-
|
|
15225
|
+
setTimeout(fn, ms) {
|
|
15226
|
+
var id = setTimeout(() => {
|
|
15227
|
+
this.timeouts.delete(id);
|
|
15228
|
+
fn();
|
|
15229
|
+
}, ms);
|
|
15230
|
+
this.timeouts.add(id);
|
|
15231
|
+
return id;
|
|
15159
15232
|
}
|
|
15160
15233
|
|
|
15161
15234
|
/**
|
|
15162
|
-
*
|
|
15235
|
+
* Clear a tracked timeout.
|
|
15163
15236
|
*/
|
|
15164
|
-
|
|
15165
|
-
|
|
15237
|
+
clearTimeout(id) {
|
|
15238
|
+
clearTimeout(id);
|
|
15239
|
+
this.timeouts.delete(id);
|
|
15166
15240
|
}
|
|
15167
15241
|
|
|
15168
15242
|
/**
|
|
15169
|
-
*
|
|
15243
|
+
* Clear all tracked pending maps and timeouts.
|
|
15170
15244
|
*/
|
|
15171
|
-
|
|
15172
|
-
this.
|
|
15173
|
-
|
|
15174
|
-
this.
|
|
15175
|
-
|
|
15176
|
-
/** Clear all pending maps and timeouts */
|
|
15177
|
-
this.pending.clearAll();
|
|
15178
|
-
this.warnOnceKeys.clear();
|
|
15179
|
-
this.streamCallback = undefined;
|
|
15180
|
-
|
|
15181
|
-
/** Destroy dispatcher and release channel reference */
|
|
15182
|
-
this.messageDispatcher.destroy();
|
|
15183
|
-
releaseMessageChannel(this.messageDispatcher.getChannel());
|
|
15184
|
-
this.hooks.afterDestroy.call();
|
|
15245
|
+
clearAll() {
|
|
15246
|
+
this.timeouts.forEach(id => clearTimeout(id));
|
|
15247
|
+
this.timeouts.clear();
|
|
15248
|
+
this.maps.forEach(m => m.clear());
|
|
15185
15249
|
}
|
|
15186
15250
|
}
|
|
15187
15251
|
|
|
15188
15252
|
/**
|
|
15189
|
-
*
|
|
15253
|
+
* Generic counter/limiter utilities (built on hub.pending maps).
|
|
15190
15254
|
*
|
|
15191
|
-
* This is a shared
|
|
15255
|
+
* This is intended as a shared infrastructure for both client/server:
|
|
15256
|
+
* - server can limit max concurrent in-flight requests per client
|
|
15257
|
+
* - client can limit max concurrent streams / in-flight sends in future
|
|
15192
15258
|
*/
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15259
|
+
class RequestIframeLimiter {
|
|
15260
|
+
constructor(pending) {
|
|
15261
|
+
this.pending = pending;
|
|
15262
|
+
}
|
|
15263
|
+
get(bucket, key) {
|
|
15264
|
+
var _this$pending$get;
|
|
15265
|
+
return (_this$pending$get = this.pending.get(bucket, key)) !== null && _this$pending$get !== void 0 ? _this$pending$get : 0;
|
|
15266
|
+
}
|
|
15267
|
+
|
|
15268
|
+
/**
|
|
15269
|
+
* Try acquire one permit for the given key.
|
|
15270
|
+
* Returns true if acquired, false if limit reached.
|
|
15271
|
+
*/
|
|
15272
|
+
tryAcquire(bucket, key, limit) {
|
|
15273
|
+
if (!Number.isFinite(limit)) {
|
|
15274
|
+
/** Treat Infinity as always allowed but still count for symmetry */
|
|
15275
|
+
var next = this.get(bucket, key) + 1;
|
|
15276
|
+
this.pending.set(bucket, key, next);
|
|
15277
|
+
return true;
|
|
15278
|
+
}
|
|
15279
|
+
var current = this.get(bucket, key);
|
|
15280
|
+
if (current >= limit) return false;
|
|
15281
|
+
this.pending.set(bucket, key, current + 1);
|
|
15282
|
+
return true;
|
|
15283
|
+
}
|
|
15284
|
+
|
|
15285
|
+
/**
|
|
15286
|
+
* Release one permit for the given key.
|
|
15287
|
+
*/
|
|
15288
|
+
release(bucket, key) {
|
|
15289
|
+
var current = this.get(bucket, key);
|
|
15290
|
+
var next = current - 1;
|
|
15291
|
+
if (next <= 0) {
|
|
15292
|
+
this.pending.delete(bucket, key);
|
|
15293
|
+
return;
|
|
15294
|
+
}
|
|
15295
|
+
this.pending.set(bucket, key, next);
|
|
15296
|
+
}
|
|
15206
15297
|
}
|
|
15207
15298
|
|
|
15208
15299
|
/**
|
|
15209
|
-
*
|
|
15300
|
+
* Shared options for endpoint hub.
|
|
15210
15301
|
*/
|
|
15211
15302
|
|
|
15212
15303
|
/**
|
|
15213
|
-
*
|
|
15304
|
+
* RequestIframeEndpointHub
|
|
15214
15305
|
*
|
|
15215
|
-
*
|
|
15216
|
-
*
|
|
15306
|
+
* Endpoint "hub" responsible for:
|
|
15307
|
+
* - MessageDispatcher lifecycle
|
|
15308
|
+
* - handler registration/unregistration
|
|
15309
|
+
* - pending + timeout management
|
|
15310
|
+
* - limiter counters
|
|
15311
|
+
*/
|
|
15312
|
+
class RequestIframeEndpointHub {
|
|
15313
|
+
constructor(role, instanceId, options) {
|
|
15314
|
+
var _options$versionValid;
|
|
15315
|
+
_defineProperty(this, "hooks", {
|
|
15316
|
+
beforeOpen: new SyncHook(),
|
|
15317
|
+
afterOpen: new SyncHook(),
|
|
15318
|
+
beforeClose: new SyncHook(),
|
|
15319
|
+
afterClose: new SyncHook(),
|
|
15320
|
+
beforeDestroy: new SyncHook(),
|
|
15321
|
+
afterDestroy: new SyncHook(),
|
|
15322
|
+
registerHandler: new SyncHook(),
|
|
15323
|
+
unregisterHandler: new SyncHook()
|
|
15324
|
+
});
|
|
15325
|
+
_defineProperty(this, "pending", new RequestIframePendingManager());
|
|
15326
|
+
_defineProperty(this, "limiter", new RequestIframeLimiter(this.pending));
|
|
15327
|
+
_defineProperty(this, "unregisterFns", []);
|
|
15328
|
+
_defineProperty(this, "warnOnceKeys", new Set());
|
|
15329
|
+
/** Whether it is open */
|
|
15330
|
+
_defineProperty(this, "_isOpen", false);
|
|
15331
|
+
this.instanceId = instanceId;
|
|
15332
|
+
this.versionValidator = (_options$versionValid = options === null || options === void 0 ? void 0 : options.versionValidator) !== null && _options$versionValid !== void 0 ? _options$versionValid : isCompatibleVersion;
|
|
15333
|
+
|
|
15334
|
+
/** Get or create shared channel and create dispatcher */
|
|
15335
|
+
var channel = getOrCreateMessageChannel(options === null || options === void 0 ? void 0 : options.secretKey);
|
|
15336
|
+
this.messageDispatcher = new MessageDispatcher(channel, role, instanceId);
|
|
15337
|
+
this.messageDispatcher.setAutoAckLimits({
|
|
15338
|
+
maxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
15339
|
+
maxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
15340
|
+
});
|
|
15341
|
+
}
|
|
15342
|
+
|
|
15343
|
+
/**
|
|
15344
|
+
* Set registerHandlers callback.
|
|
15345
|
+
*
|
|
15346
|
+
* This is used by composition-based implementations to define handler bindings.
|
|
15347
|
+
*/
|
|
15348
|
+
setRegisterHandlers(fn) {
|
|
15349
|
+
this.registerHandlersFn = fn;
|
|
15350
|
+
}
|
|
15351
|
+
|
|
15352
|
+
/**
|
|
15353
|
+
* Register a dispatcher handler and track its unregister function.
|
|
15354
|
+
*/
|
|
15355
|
+
registerHandler(matcher, handler, options) {
|
|
15356
|
+
this.hooks.registerHandler.call(matcher);
|
|
15357
|
+
var unreg = this.messageDispatcher.registerHandler(matcher, handler, options);
|
|
15358
|
+
this.unregisterFns.push(unreg);
|
|
15359
|
+
return unreg;
|
|
15360
|
+
}
|
|
15361
|
+
|
|
15362
|
+
/**
|
|
15363
|
+
* Create common handler options object.
|
|
15364
|
+
*/
|
|
15365
|
+
createHandlerOptions(onVersionError) {
|
|
15366
|
+
return {
|
|
15367
|
+
versionValidator: this.versionValidator,
|
|
15368
|
+
onVersionError
|
|
15369
|
+
};
|
|
15370
|
+
}
|
|
15371
|
+
|
|
15372
|
+
/**
|
|
15373
|
+
* Warn once per key.
|
|
15374
|
+
*/
|
|
15375
|
+
warnOnce(key, fn) {
|
|
15376
|
+
if (this.warnOnceKeys.has(key)) return;
|
|
15377
|
+
this.warnOnceKeys.add(key);
|
|
15378
|
+
fn();
|
|
15379
|
+
}
|
|
15380
|
+
|
|
15381
|
+
/**
|
|
15382
|
+
* Set stream callback (used by client-side stream routing).
|
|
15383
|
+
*/
|
|
15384
|
+
setStreamCallback(callback) {
|
|
15385
|
+
this.streamCallback = callback;
|
|
15386
|
+
}
|
|
15387
|
+
|
|
15388
|
+
/**
|
|
15389
|
+
* Get stream callback (used by handler registration side).
|
|
15390
|
+
*/
|
|
15391
|
+
getStreamCallback() {
|
|
15392
|
+
return this.streamCallback;
|
|
15393
|
+
}
|
|
15394
|
+
|
|
15395
|
+
/**
|
|
15396
|
+
* Validate origin safely (originValidator wins over origin string).
|
|
15397
|
+
*/
|
|
15398
|
+
isOriginAllowedBy(contextOrigin, data, context, origin, originValidator) {
|
|
15399
|
+
if (originValidator) {
|
|
15400
|
+
try {
|
|
15401
|
+
return originValidator(contextOrigin, data, context);
|
|
15402
|
+
} catch (_unused) {
|
|
15403
|
+
return false;
|
|
15404
|
+
}
|
|
15405
|
+
}
|
|
15406
|
+
if (!origin || origin === OriginConstant.ANY) return true;
|
|
15407
|
+
return contextOrigin === origin;
|
|
15408
|
+
}
|
|
15409
|
+
|
|
15410
|
+
/**
|
|
15411
|
+
* Set a fixed peer (fallback target) for cases where MessageEvent.source is missing.
|
|
15412
|
+
*
|
|
15413
|
+
* This is useful for "response endpoint" style usage where the peer is already known
|
|
15414
|
+
* (e.g. a client bound to an iframe window).
|
|
15415
|
+
*/
|
|
15416
|
+
setFallbackTarget(targetWindow, targetOrigin) {
|
|
15417
|
+
this.messageDispatcher.setFallbackTarget(targetWindow, targetOrigin);
|
|
15418
|
+
}
|
|
15419
|
+
|
|
15420
|
+
/**
|
|
15421
|
+
* Create a peer-bound outbox using this hub's dispatcher.
|
|
15422
|
+
*/
|
|
15423
|
+
createOutbox(targetWindow, targetOrigin, defaultTargetId) {
|
|
15424
|
+
return new RequestIframeEndpointOutbox(this.messageDispatcher, targetWindow, targetOrigin, defaultTargetId);
|
|
15425
|
+
}
|
|
15426
|
+
|
|
15427
|
+
/**
|
|
15428
|
+
* Open message processing (register message handlers)
|
|
15429
|
+
*/
|
|
15430
|
+
open() {
|
|
15431
|
+
if (this._isOpen) return;
|
|
15432
|
+
this.hooks.beforeOpen.call();
|
|
15433
|
+
this._isOpen = true;
|
|
15434
|
+
if (!this.registerHandlersFn) {
|
|
15435
|
+
throw new Error(Messages.HUB_REGISTER_HANDLERS_NOT_SET);
|
|
15436
|
+
}
|
|
15437
|
+
this.registerHandlersFn();
|
|
15438
|
+
this.hooks.afterOpen.call();
|
|
15439
|
+
}
|
|
15440
|
+
|
|
15441
|
+
/**
|
|
15442
|
+
* Close message processing (unregister message handlers, but don't release channel)
|
|
15443
|
+
*/
|
|
15444
|
+
close() {
|
|
15445
|
+
if (!this._isOpen) return;
|
|
15446
|
+
this.hooks.beforeClose.call();
|
|
15447
|
+
this._isOpen = false;
|
|
15448
|
+
|
|
15449
|
+
/** Unregister all handlers */
|
|
15450
|
+
this.unregisterFns.forEach(fn => fn());
|
|
15451
|
+
this.unregisterFns.length = 0;
|
|
15452
|
+
this.hooks.unregisterHandler.call();
|
|
15453
|
+
this.hooks.afterClose.call();
|
|
15454
|
+
}
|
|
15455
|
+
|
|
15456
|
+
/**
|
|
15457
|
+
* Whether it is open
|
|
15458
|
+
*/
|
|
15459
|
+
get isOpen() {
|
|
15460
|
+
return this._isOpen;
|
|
15461
|
+
}
|
|
15462
|
+
|
|
15463
|
+
/**
|
|
15464
|
+
* Get secretKey
|
|
15465
|
+
*/
|
|
15466
|
+
get secretKey() {
|
|
15467
|
+
return this.messageDispatcher.secretKey;
|
|
15468
|
+
}
|
|
15469
|
+
|
|
15470
|
+
/**
|
|
15471
|
+
* Destroy (close and release channel reference)
|
|
15472
|
+
*/
|
|
15473
|
+
destroy() {
|
|
15474
|
+
this.hooks.beforeDestroy.call();
|
|
15475
|
+
/** Close first */
|
|
15476
|
+
this.close();
|
|
15477
|
+
|
|
15478
|
+
/** Clear all pending maps and timeouts */
|
|
15479
|
+
this.pending.clearAll();
|
|
15480
|
+
this.warnOnceKeys.clear();
|
|
15481
|
+
this.streamCallback = undefined;
|
|
15482
|
+
|
|
15483
|
+
/** Destroy dispatcher and release channel reference */
|
|
15484
|
+
this.messageDispatcher.destroy();
|
|
15485
|
+
releaseMessageChannel(this.messageDispatcher.getChannel());
|
|
15486
|
+
this.hooks.afterDestroy.call();
|
|
15487
|
+
}
|
|
15488
|
+
}
|
|
15489
|
+
|
|
15490
|
+
/**
|
|
15491
|
+
* Create a PING responder handler (reply PONG).
|
|
15492
|
+
*
|
|
15493
|
+
* This is a shared building block for both client/server endpoints.
|
|
15494
|
+
*/
|
|
15495
|
+
function createPingResponder(params) {
|
|
15496
|
+
var hub = params.hub,
|
|
15497
|
+
handledBy = params.handledBy,
|
|
15498
|
+
includeTargetId = params.includeTargetId;
|
|
15499
|
+
return (data, context) => {
|
|
15500
|
+
if (!context.source) return;
|
|
15501
|
+
/** Mark accepted so MessageDispatcher can auto-send ACK when requireAck === true */
|
|
15502
|
+
context.markAcceptedBy(handledBy);
|
|
15503
|
+
/** Reply PONG */
|
|
15504
|
+
hub.messageDispatcher.sendMessage(context.source, context.origin, MessageType.PONG, data.requestId, includeTargetId ? {
|
|
15505
|
+
targetId: data.creatorId
|
|
15506
|
+
} : undefined);
|
|
15507
|
+
};
|
|
15508
|
+
}
|
|
15509
|
+
|
|
15510
|
+
/**
|
|
15511
|
+
* Minimal "warnOnce host" interface.
|
|
15512
|
+
*
|
|
15513
|
+
* Why:
|
|
15514
|
+
* - We want to reuse the hub-level warnOnce mechanism without importing endpoint internals here.
|
|
15515
|
+
*/
|
|
15516
|
+
|
|
15517
|
+
/**
|
|
15518
|
+
* Warn when using `targetOrigin="*"` for Window targets without any incoming origin validation.
|
|
15519
|
+
*
|
|
15520
|
+
* Why:
|
|
15521
|
+
* - For `Window` targets, default `targetOrigin` is '*'.
|
|
15522
|
+
* - If user does not configure `allowedOrigins` / `validateOrigin`, origin validation is effectively disabled.
|
|
15523
|
+
* - This is a best-practice/security warning and is logged once (INFO level) to avoid noise.
|
|
15524
|
+
*/
|
|
15525
|
+
function warnUnsafeTargetOriginForWindow(params) {
|
|
15526
|
+
if (params.isIframeTarget) return;
|
|
15527
|
+
if (params.targetOrigin !== OriginConstant.ANY) return;
|
|
15528
|
+
if (params.allowedOrigins || params.validateOrigin) return;
|
|
15529
|
+
logger.once(LogLevel.INFO, buildWarnOnceKey(WarnOnceKey.TARGET_ORIGIN_ANY_WITHOUT_ORIGIN_VALIDATION), '[Security] targetOrigin is "*" for Window targets and no allowedOrigins/validateOrigin is configured. ' + 'Consider setting a strict targetOrigin and allowedOrigins/validateOrigin.');
|
|
15530
|
+
}
|
|
15531
|
+
|
|
15532
|
+
/**
|
|
15533
|
+
* Warn once when a client-side endpoint is already closed/destroyed and an inbound message arrives
|
|
15534
|
+
* without a matching pending request.
|
|
15535
|
+
*
|
|
15536
|
+
* This is a debugging hint (warn level) because it often indicates lifecycle issues:
|
|
15537
|
+
* - the client/server instance was recreated/unmounted before the response arrived
|
|
15538
|
+
*/
|
|
15539
|
+
function warnClientServerIgnoredMessageWhenClosedOnce(host, params) {
|
|
15540
|
+
host.warnOnce(buildWarnOnceKey(WarnOnceKey.INBOX_MISSING_PENDING_WHEN_CLOSED, params.requestId), () => {
|
|
15541
|
+
logger.warn(formatMessage(Messages.CLIENT_SERVER_IGNORED_MESSAGE_WHEN_CLOSED, params.type, params.requestId));
|
|
15542
|
+
});
|
|
15543
|
+
}
|
|
15544
|
+
|
|
15545
|
+
/**
|
|
15546
|
+
* Warn once when a server-side endpoint is already closed/destroyed and it receives a message
|
|
15547
|
+
* that cannot be matched to a pending waiter (e.g. ack/pong/stream control frames).
|
|
15548
|
+
*/
|
|
15549
|
+
function warnServerIgnoredMessageWhenClosedOnce(host, params) {
|
|
15550
|
+
host.warnOnce(buildWarnOnceKey(WarnOnceKey.SERVER_MISSING_PENDING_WHEN_CLOSED, params.type, params.requestId), () => {
|
|
15551
|
+
logger.warn(formatMessage(Messages.SERVER_IGNORED_MESSAGE_WHEN_CLOSED, params.type, params.requestId));
|
|
15552
|
+
});
|
|
15553
|
+
}
|
|
15554
|
+
|
|
15555
|
+
/**
|
|
15556
|
+
* Pending request awaiting response
|
|
15557
|
+
*/
|
|
15558
|
+
|
|
15559
|
+
/**
|
|
15560
|
+
* RequestIframeEndpointInbox
|
|
15561
|
+
*
|
|
15562
|
+
* The endpoint "inbox" is responsible for handling inbound framework messages and
|
|
15563
|
+
* driving pending request resolution by requestId.
|
|
15217
15564
|
*
|
|
15218
15565
|
* - Registers dispatcher handlers for ACK/ASYNC/RESPONSE/ERROR/STREAM_START + PING/PONG
|
|
15219
15566
|
* - Manages pending requests via hub.pending
|
|
@@ -15359,8 +15706,9 @@
|
|
|
15359
15706
|
*/
|
|
15360
15707
|
if (!this.hub.isOpen) {
|
|
15361
15708
|
this.hooks.missingPending.call(data, context);
|
|
15362
|
-
this.hub
|
|
15363
|
-
|
|
15709
|
+
warnClientServerIgnoredMessageWhenClosedOnce(this.hub, {
|
|
15710
|
+
type: data.type,
|
|
15711
|
+
requestId: data.requestId
|
|
15364
15712
|
});
|
|
15365
15713
|
}
|
|
15366
15714
|
return;
|
|
@@ -15453,8 +15801,8 @@
|
|
|
15453
15801
|
return isAckMatch(expectedAck, receivedAck);
|
|
15454
15802
|
}
|
|
15455
15803
|
|
|
15456
|
-
function ownKeys$
|
|
15457
|
-
function _objectSpread$
|
|
15804
|
+
function ownKeys$5(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; }
|
|
15805
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15458
15806
|
/**
|
|
15459
15807
|
* Endpoint Stream integration layer (`src/endpoint/stream`)
|
|
15460
15808
|
*
|
|
@@ -15497,7 +15845,7 @@
|
|
|
15497
15845
|
context.markAcceptedBy(this.handledBy);
|
|
15498
15846
|
}
|
|
15499
15847
|
var messageType = data.type.replace('stream_', '');
|
|
15500
|
-
handler(_objectSpread$
|
|
15848
|
+
handler(_objectSpread$5(_objectSpread$5({}, body), {}, {
|
|
15501
15849
|
type: messageType
|
|
15502
15850
|
}));
|
|
15503
15851
|
}
|
|
@@ -16134,87 +16482,18 @@
|
|
|
16134
16482
|
};
|
|
16135
16483
|
}
|
|
16136
16484
|
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
var toLength = requireToLength();
|
|
16150
|
-
var toString = requireToString();
|
|
16151
|
-
var requireObjectCoercible = requireRequireObjectCoercible();
|
|
16152
|
-
var getMethod = requireGetMethod();
|
|
16153
|
-
var advanceStringIndex = requireAdvanceStringIndex();
|
|
16154
|
-
var getRegExpFlags = requireRegexpGetFlags();
|
|
16155
|
-
var regExpExec = requireRegexpExecAbstract();
|
|
16156
|
-
|
|
16157
|
-
var stringIndexOf = uncurryThis(''.indexOf);
|
|
16158
|
-
|
|
16159
|
-
// @@match logic
|
|
16160
|
-
fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
|
|
16161
|
-
return [
|
|
16162
|
-
// `String.prototype.match` method
|
|
16163
|
-
// https://tc39.es/ecma262/#sec-string.prototype.match
|
|
16164
|
-
function match(regexp) {
|
|
16165
|
-
var O = requireObjectCoercible(this);
|
|
16166
|
-
var matcher = isObject(regexp) ? getMethod(regexp, MATCH) : undefined;
|
|
16167
|
-
return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
|
|
16168
|
-
},
|
|
16169
|
-
// `RegExp.prototype[@@match]` method
|
|
16170
|
-
// https://tc39.es/ecma262/#sec-regexp.prototype-@@match
|
|
16171
|
-
function (string) {
|
|
16172
|
-
var rx = anObject(this);
|
|
16173
|
-
var S = toString(string);
|
|
16174
|
-
var res = maybeCallNative(nativeMatch, rx, S);
|
|
16175
|
-
|
|
16176
|
-
if (res.done) return res.value;
|
|
16177
|
-
|
|
16178
|
-
var flags = toString(getRegExpFlags(rx));
|
|
16179
|
-
|
|
16180
|
-
if (stringIndexOf(flags, 'g') === -1) return regExpExec(rx, S);
|
|
16181
|
-
|
|
16182
|
-
var fullUnicode = stringIndexOf(flags, 'u') !== -1;
|
|
16183
|
-
rx.lastIndex = 0;
|
|
16184
|
-
var A = [];
|
|
16185
|
-
var n = 0;
|
|
16186
|
-
var result;
|
|
16187
|
-
while ((result = regExpExec(rx, S)) !== null) {
|
|
16188
|
-
var matchStr = toString(result[0]);
|
|
16189
|
-
A[n] = matchStr;
|
|
16190
|
-
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
|
|
16191
|
-
n++;
|
|
16192
|
-
}
|
|
16193
|
-
return n === 0 ? null : A;
|
|
16194
|
-
}
|
|
16195
|
-
];
|
|
16196
|
-
});
|
|
16197
|
-
return es_string_match;
|
|
16198
|
-
}
|
|
16199
|
-
|
|
16200
|
-
requireEs_string_match();
|
|
16201
|
-
|
|
16202
|
-
/**
|
|
16203
|
-
* Endpoint Stream integration layer (`src/endpoint/stream`)
|
|
16204
|
-
*
|
|
16205
|
-
* This directory integrates postMessage `stream_*` messages with the stream object system in `src/stream`:
|
|
16206
|
-
* - Endpoint-side file stream utilities (e.g. choose filename from header/metadata and auto-resolve)
|
|
16207
|
-
* - Does NOT implement the stream protocol itself (protocol lives in `src/stream`)
|
|
16208
|
-
*
|
|
16209
|
-
* Parse filename from Content-Disposition header.
|
|
16210
|
-
*/
|
|
16211
|
-
function parseFilenameFromContentDisposition(value) {
|
|
16212
|
-
if (!value) return undefined;
|
|
16213
|
-
var disposition = typeof value === 'string' ? value : value[0];
|
|
16214
|
-
if (!disposition) return undefined;
|
|
16215
|
-
var match = disposition.match(/filename="?([^"]+)"?/i);
|
|
16216
|
-
return match ? match[1] : undefined;
|
|
16217
|
-
}
|
|
16485
|
+
/**
|
|
16486
|
+
* Endpoint Stream integration layer (`src/endpoint/stream`)
|
|
16487
|
+
*
|
|
16488
|
+
* This directory integrates postMessage `stream_*` messages with the stream object system in `src/stream`:
|
|
16489
|
+
* - Endpoint-side file stream utilities (e.g. choose filename from header/metadata and auto-resolve)
|
|
16490
|
+
* - Does NOT implement the stream protocol itself (protocol lives in `src/stream`)
|
|
16491
|
+
*
|
|
16492
|
+
* Parse filename from Content-Disposition header.
|
|
16493
|
+
*/
|
|
16494
|
+
function parseFilenameFromContentDisposition(value) {
|
|
16495
|
+
return IframeFileReadableStream.parseFilenameFromContentDisposition(value);
|
|
16496
|
+
}
|
|
16218
16497
|
|
|
16219
16498
|
/**
|
|
16220
16499
|
* Auto resolve a file readable stream to File/Blob.
|
|
@@ -16228,7 +16507,12 @@
|
|
|
16228
16507
|
var _params$headers, _params$info;
|
|
16229
16508
|
var headerFilename = parseFilenameFromContentDisposition((_params$headers = params.headers) === null || _params$headers === void 0 ? void 0 : _params$headers[HttpHeader.CONTENT_DISPOSITION]);
|
|
16230
16509
|
var fileName = headerFilename || ((_params$info = params.info) === null || _params$info === void 0 || (_params$info = _params$info.metadata) === null || _params$info === void 0 ? void 0 : _params$info.filename) || params.fileStream.filename;
|
|
16231
|
-
|
|
16510
|
+
var anyStream = params.fileStream;
|
|
16511
|
+
if (typeof anyStream.readAsFileOrBlob === 'function') {
|
|
16512
|
+
return anyStream.readAsFileOrBlob(fileName);
|
|
16513
|
+
}
|
|
16514
|
+
// Backward-compatible fallback for mocks/older stream objects
|
|
16515
|
+
return fileName ? anyStream.readAsFile(fileName) : anyStream.readAsBlob();
|
|
16232
16516
|
}
|
|
16233
16517
|
|
|
16234
16518
|
/**
|
|
@@ -16453,8 +16737,8 @@
|
|
|
16453
16737
|
|
|
16454
16738
|
requireEs_string_trim();
|
|
16455
16739
|
|
|
16456
|
-
function ownKeys$
|
|
16457
|
-
function _objectSpread$
|
|
16740
|
+
function ownKeys$4(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; }
|
|
16741
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16458
16742
|
function _createForOfIteratorHelper$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
16459
16743
|
function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } }
|
|
16460
16744
|
function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -16724,7 +17008,7 @@
|
|
|
16724
17008
|
var result = [];
|
|
16725
17009
|
this.cookies.forEach(cookie => {
|
|
16726
17010
|
if (!cookie.expires || cookie.expires > now) {
|
|
16727
|
-
result.push(_objectSpread$
|
|
17011
|
+
result.push(_objectSpread$4({}, cookie));
|
|
16728
17012
|
}
|
|
16729
17013
|
});
|
|
16730
17014
|
return result;
|
|
@@ -16887,8 +17171,8 @@
|
|
|
16887
17171
|
function _createForOfIteratorHelper$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
16888
17172
|
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
16889
17173
|
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16890
|
-
function ownKeys$
|
|
16891
|
-
function _objectSpread$
|
|
17174
|
+
function ownKeys$3(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; }
|
|
17175
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16892
17176
|
|
|
16893
17177
|
/**
|
|
16894
17178
|
* Client configuration options
|
|
@@ -17112,7 +17396,7 @@
|
|
|
17112
17396
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
17113
17397
|
while (1) switch (_context.prev = _context.next) {
|
|
17114
17398
|
case 0:
|
|
17115
|
-
config = _objectSpread$
|
|
17399
|
+
config = _objectSpread$3({
|
|
17116
17400
|
path,
|
|
17117
17401
|
body
|
|
17118
17402
|
}, options);
|
|
@@ -17155,12 +17439,12 @@
|
|
|
17155
17439
|
sendFile(path, content, options) {
|
|
17156
17440
|
var _this2 = this;
|
|
17157
17441
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
17158
|
-
var _processedConfig$requ2, _processedConfig$targ, _options$autoResolve;
|
|
17442
|
+
var _processedConfig$requ2, _processedConfig$targ, _options$chunked, _options$autoResolve;
|
|
17159
17443
|
var config, processedConfig, requestId, targetId, processedPath, mergedHeaders, pathMatchedCookies, mergedCookies, streamConfig;
|
|
17160
17444
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
17161
17445
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17162
17446
|
case 0:
|
|
17163
|
-
config = _objectSpread$
|
|
17447
|
+
config = _objectSpread$3({
|
|
17164
17448
|
path,
|
|
17165
17449
|
body: undefined
|
|
17166
17450
|
}, options);
|
|
@@ -17173,15 +17457,16 @@
|
|
|
17173
17457
|
processedPath = processedConfig.path;
|
|
17174
17458
|
mergedHeaders = _this2.mergeHeaders(processedConfig, undefined);
|
|
17175
17459
|
pathMatchedCookies = _this2._cookieStore.getForPath(processedPath);
|
|
17176
|
-
mergedCookies = _objectSpread$
|
|
17177
|
-
streamConfig = _objectSpread$
|
|
17460
|
+
mergedCookies = _objectSpread$3(_objectSpread$3({}, pathMatchedCookies), processedConfig.cookies);
|
|
17461
|
+
streamConfig = _objectSpread$3(_objectSpread$3({}, processedConfig), {}, {
|
|
17178
17462
|
requestId
|
|
17179
17463
|
});
|
|
17180
17464
|
return _context2.abrupt("return", _this2.outbox.sendFile({
|
|
17181
17465
|
content,
|
|
17182
17466
|
fileName: options === null || options === void 0 ? void 0 : options.fileName,
|
|
17183
17467
|
mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
|
|
17184
|
-
chunked: false,
|
|
17468
|
+
chunked: (_options$chunked = options === null || options === void 0 ? void 0 : options.chunked) !== null && _options$chunked !== void 0 ? _options$chunked : false,
|
|
17469
|
+
chunkSize: options === null || options === void 0 ? void 0 : options.chunkSize,
|
|
17185
17470
|
autoResolve: (_options$autoResolve = options === null || options === void 0 ? void 0 : options.autoResolve) !== null && _options$autoResolve !== void 0 ? _options$autoResolve : true,
|
|
17186
17471
|
defaultFileName: typeof File !== 'undefined' && content instanceof File ? content.name : 'file',
|
|
17187
17472
|
defaultMimeType: 'application/octet-stream',
|
|
@@ -17224,7 +17509,7 @@
|
|
|
17224
17509
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
17225
17510
|
while (1) switch (_context3.prev = _context3.next) {
|
|
17226
17511
|
case 0:
|
|
17227
|
-
config = _objectSpread$
|
|
17512
|
+
config = _objectSpread$3({
|
|
17228
17513
|
path,
|
|
17229
17514
|
body: undefined
|
|
17230
17515
|
}, options);
|
|
@@ -17237,8 +17522,8 @@
|
|
|
17237
17522
|
processedPath = processedConfig.path;
|
|
17238
17523
|
mergedHeaders = _this3.mergeHeaders(processedConfig, undefined);
|
|
17239
17524
|
pathMatchedCookies = _this3._cookieStore.getForPath(processedPath);
|
|
17240
|
-
mergedCookies = _objectSpread$
|
|
17241
|
-
streamConfig = _objectSpread$
|
|
17525
|
+
mergedCookies = _objectSpread$3(_objectSpread$3({}, pathMatchedCookies), processedConfig.cookies);
|
|
17526
|
+
streamConfig = _objectSpread$3(_objectSpread$3({}, processedConfig), {}, {
|
|
17242
17527
|
requestId
|
|
17243
17528
|
});
|
|
17244
17529
|
return _context3.abrupt("return", _this3.outbox.sendStream({
|
|
@@ -17512,7 +17797,7 @@
|
|
|
17512
17797
|
|
|
17513
17798
|
// Get cookies matching request path and merge with user-provided cookies (user-provided takes precedence)
|
|
17514
17799
|
var pathMatchedCookies = this._cookieStore.getForPath(requestPath);
|
|
17515
|
-
var mergedCookies = _objectSpread$
|
|
17800
|
+
var mergedCookies = _objectSpread$3(_objectSpread$3({}, pathMatchedCookies), processedCookies);
|
|
17516
17801
|
|
|
17517
17802
|
// Send request via MessageDispatcher
|
|
17518
17803
|
var payload = {
|
|
@@ -17654,555 +17939,512 @@
|
|
|
17654
17939
|
}
|
|
17655
17940
|
}
|
|
17656
17941
|
|
|
17657
|
-
|
|
17658
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17659
|
-
function logEvent(level, event, message, data) {
|
|
17660
|
-
if (data !== undefined && data !== null && typeof data === 'object') {
|
|
17661
|
-
requestIframeLog(level, message, _objectSpread$1({
|
|
17662
|
-
event
|
|
17663
|
-
}, data));
|
|
17664
|
-
return;
|
|
17665
|
-
}
|
|
17666
|
-
requestIframeLog(level, message, data === undefined ? {
|
|
17667
|
-
event
|
|
17668
|
-
} : {
|
|
17669
|
-
event,
|
|
17670
|
-
data
|
|
17671
|
-
});
|
|
17672
|
-
}
|
|
17942
|
+
var es_weakMap = {};
|
|
17673
17943
|
|
|
17674
|
-
|
|
17675
|
-
* Format message data for logging (remove sensitive data if needed)
|
|
17676
|
-
*/
|
|
17677
|
-
function formatMessageData(data) {
|
|
17678
|
-
if (!data) return data;
|
|
17679
|
-
var formatted = _objectSpread$1({}, data);
|
|
17944
|
+
var es_weakMap_constructor = {};
|
|
17680
17945
|
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
var bodyStr = JSON.stringify(formatted.body);
|
|
17684
|
-
if (bodyStr.length > 500) {
|
|
17685
|
-
formatted.body = bodyStr.substring(0, 500) + '... (truncated)';
|
|
17686
|
-
}
|
|
17687
|
-
}
|
|
17946
|
+
var collectionWeak;
|
|
17947
|
+
var hasRequiredCollectionWeak;
|
|
17688
17948
|
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17949
|
+
function requireCollectionWeak () {
|
|
17950
|
+
if (hasRequiredCollectionWeak) return collectionWeak;
|
|
17951
|
+
hasRequiredCollectionWeak = 1;
|
|
17952
|
+
var uncurryThis = requireFunctionUncurryThis();
|
|
17953
|
+
var defineBuiltIns = requireDefineBuiltIns();
|
|
17954
|
+
var getWeakData = requireInternalMetadata().getWeakData;
|
|
17955
|
+
var anInstance = requireAnInstance();
|
|
17956
|
+
var anObject = requireAnObject();
|
|
17957
|
+
var isNullOrUndefined = requireIsNullOrUndefined();
|
|
17958
|
+
var isObject = requireIsObject();
|
|
17959
|
+
var iterate = requireIterate();
|
|
17960
|
+
var ArrayIterationModule = requireArrayIteration();
|
|
17961
|
+
var hasOwn = requireHasOwnProperty();
|
|
17962
|
+
var InternalStateModule = requireInternalState();
|
|
17698
17963
|
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17964
|
+
var setInternalState = InternalStateModule.set;
|
|
17965
|
+
var internalStateGetterFor = InternalStateModule.getterFor;
|
|
17966
|
+
var find = ArrayIterationModule.find;
|
|
17967
|
+
var findIndex = ArrayIterationModule.findIndex;
|
|
17968
|
+
var splice = uncurryThis([].splice);
|
|
17969
|
+
var id = 0;
|
|
17704
17970
|
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
body: config.body,
|
|
17710
|
-
headers: config.headers,
|
|
17711
|
-
cookies: config.cookies,
|
|
17712
|
-
ackTimeout: config.ackTimeout,
|
|
17713
|
-
timeout: config.timeout,
|
|
17714
|
-
asyncTimeout: config.asyncTimeout,
|
|
17715
|
-
requestId: config.requestId
|
|
17716
|
-
}));
|
|
17717
|
-
return config;
|
|
17718
|
-
});
|
|
17971
|
+
// fallback for uncaught frozen keys
|
|
17972
|
+
var uncaughtFrozenStore = function (state) {
|
|
17973
|
+
return state.frozen || (state.frozen = new UncaughtFrozenStore());
|
|
17974
|
+
};
|
|
17719
17975
|
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
requestId: response.requestId,
|
|
17724
|
-
status: response.status,
|
|
17725
|
-
statusText: response.statusText,
|
|
17726
|
-
headers: response.headers
|
|
17727
|
-
};
|
|
17976
|
+
var UncaughtFrozenStore = function () {
|
|
17977
|
+
this.entries = [];
|
|
17978
|
+
};
|
|
17728
17979
|
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
var contentLength = file.size;
|
|
17735
|
-
logData.fileData = {
|
|
17736
|
-
fileName,
|
|
17737
|
-
mimeType,
|
|
17738
|
-
contentLength
|
|
17739
|
-
};
|
|
17740
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS_FILE, Messages.DEBUG_CLIENT_REQUEST_SUCCESS_FILE, formatMessageData(logData));
|
|
17741
|
-
} else if (response.stream) {
|
|
17742
|
-
logData.stream = {
|
|
17743
|
-
streamId: response.stream.streamId,
|
|
17744
|
-
type: response.stream.type
|
|
17745
|
-
};
|
|
17746
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS_STREAM, Messages.DEBUG_CLIENT_REQUEST_SUCCESS_STREAM, formatMessageData(logData));
|
|
17747
|
-
} else {
|
|
17748
|
-
logData.data = response.data;
|
|
17749
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS, Messages.DEBUG_CLIENT_REQUEST_SUCCESS, formatMessageData(logData));
|
|
17750
|
-
}
|
|
17751
|
-
return response;
|
|
17752
|
-
}, error => {
|
|
17753
|
-
logEvent(LogLevel.ERROR, DebugEvent.CLIENT_REQUEST_FAILED, Messages.DEBUG_CLIENT_REQUEST_FAILED, formatMessageData({
|
|
17754
|
-
requestId: error.requestId,
|
|
17755
|
-
code: error.code,
|
|
17756
|
-
message: error.message,
|
|
17757
|
-
config: error.config,
|
|
17758
|
-
response: error.response
|
|
17759
|
-
}));
|
|
17760
|
-
return Promise.reject(error);
|
|
17761
|
-
});
|
|
17980
|
+
var findUncaughtFrozen = function (store, key) {
|
|
17981
|
+
return find(store.entries, function (it) {
|
|
17982
|
+
return it[0] === key;
|
|
17983
|
+
});
|
|
17984
|
+
};
|
|
17762
17985
|
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17986
|
+
UncaughtFrozenStore.prototype = {
|
|
17987
|
+
get: function (key) {
|
|
17988
|
+
var entry = findUncaughtFrozen(this, key);
|
|
17989
|
+
if (entry) return entry[1];
|
|
17990
|
+
},
|
|
17991
|
+
has: function (key) {
|
|
17992
|
+
return !!findUncaughtFrozen(this, key);
|
|
17993
|
+
},
|
|
17994
|
+
set: function (key, value) {
|
|
17995
|
+
var entry = findUncaughtFrozen(this, key);
|
|
17996
|
+
if (entry) entry[1] = value;
|
|
17997
|
+
else this.entries.push([key, value]);
|
|
17998
|
+
},
|
|
17999
|
+
'delete': function (key) {
|
|
18000
|
+
var index = findIndex(this.entries, function (it) {
|
|
18001
|
+
return it[0] === key;
|
|
18002
|
+
});
|
|
18003
|
+
if (~index) splice(this.entries, index, 1);
|
|
18004
|
+
return !!~index;
|
|
18005
|
+
}
|
|
18006
|
+
};
|
|
17767
18007
|
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
18008
|
+
collectionWeak = {
|
|
18009
|
+
getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
|
|
18010
|
+
var Constructor = wrapper(function (that, iterable) {
|
|
18011
|
+
anInstance(that, Prototype);
|
|
18012
|
+
setInternalState(that, {
|
|
18013
|
+
type: CONSTRUCTOR_NAME,
|
|
18014
|
+
id: id++,
|
|
18015
|
+
frozen: null
|
|
18016
|
+
});
|
|
18017
|
+
if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
|
|
18018
|
+
});
|
|
17776
18019
|
|
|
17777
|
-
|
|
17778
|
-
if (outbox !== null && outbox !== void 0 && (_outbox$hooks = outbox.hooks) !== null && _outbox$hooks !== void 0 && (_outbox$hooks = _outbox$hooks.afterSendMessage) !== null && _outbox$hooks !== void 0 && _outbox$hooks.tap) {
|
|
17779
|
-
outbox.hooks.afterSendMessage.tap('debug', (type, requestId, data) => {
|
|
17780
|
-
if (type === MessageType.REQUEST) {
|
|
17781
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_REQUEST, formatMessageData({
|
|
17782
|
-
requestId,
|
|
17783
|
-
path: data === null || data === void 0 ? void 0 : data.path,
|
|
17784
|
-
body: data === null || data === void 0 ? void 0 : data.body,
|
|
17785
|
-
headers: data === null || data === void 0 ? void 0 : data.headers
|
|
17786
|
-
}));
|
|
17787
|
-
} else if (type === MessageType.PING) {
|
|
17788
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_PING, {
|
|
17789
|
-
requestId
|
|
17790
|
-
});
|
|
17791
|
-
} else if (type === MessageType.ACK) {
|
|
17792
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_RECEIVED_ACK, {
|
|
17793
|
-
requestId
|
|
17794
|
-
});
|
|
17795
|
-
}
|
|
17796
|
-
});
|
|
17797
|
-
} else if (dispatcher !== null && dispatcher !== void 0 && (_dispatcher$hooks = dispatcher.hooks) !== null && _dispatcher$hooks !== void 0 && (_dispatcher$hooks = _dispatcher$hooks.afterSend) !== null && _dispatcher$hooks !== void 0 && _dispatcher$hooks.tap) {
|
|
17798
|
-
dispatcher.hooks.afterSend.tap('debug', (_target, _origin, message) => {
|
|
17799
|
-
if (message.type === MessageType.REQUEST) {
|
|
17800
|
-
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_REQUEST, formatMessageData({
|
|
17801
|
-
requestId: message.requestId,
|
|
17802
|
-
path: message.path,
|
|
17803
|
-
body: message.body,
|
|
17804
|
-
headers: message.headers
|
|
17805
|
-
}));
|
|
17806
|
-
}
|
|
17807
|
-
});
|
|
17808
|
-
}
|
|
18020
|
+
var Prototype = Constructor.prototype;
|
|
17809
18021
|
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
17832
|
-
|
|
17833
|
-
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
17840
|
-
|
|
17841
|
-
|
|
17842
|
-
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
18022
|
+
var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
|
|
18023
|
+
|
|
18024
|
+
var define = function (that, key, value) {
|
|
18025
|
+
var state = getInternalState(that);
|
|
18026
|
+
var data = getWeakData(anObject(key), true);
|
|
18027
|
+
if (data === true) uncaughtFrozenStore(state).set(key, value);
|
|
18028
|
+
else data[state.id] = value;
|
|
18029
|
+
return that;
|
|
18030
|
+
};
|
|
18031
|
+
|
|
18032
|
+
defineBuiltIns(Prototype, {
|
|
18033
|
+
// `{ WeakMap, WeakSet }.prototype.delete(key)` methods
|
|
18034
|
+
// https://tc39.es/ecma262/#sec-weakmap.prototype.delete
|
|
18035
|
+
// https://tc39.es/ecma262/#sec-weakset.prototype.delete
|
|
18036
|
+
'delete': function (key) {
|
|
18037
|
+
var state = getInternalState(this);
|
|
18038
|
+
if (!isObject(key)) return false;
|
|
18039
|
+
var data = getWeakData(key);
|
|
18040
|
+
if (data === true) return uncaughtFrozenStore(state)['delete'](key);
|
|
18041
|
+
return data && hasOwn(data, state.id) && delete data[state.id];
|
|
18042
|
+
},
|
|
18043
|
+
// `{ WeakMap, WeakSet }.prototype.has(key)` methods
|
|
18044
|
+
// https://tc39.es/ecma262/#sec-weakmap.prototype.has
|
|
18045
|
+
// https://tc39.es/ecma262/#sec-weakset.prototype.has
|
|
18046
|
+
has: function has(key) {
|
|
18047
|
+
var state = getInternalState(this);
|
|
18048
|
+
if (!isObject(key)) return false;
|
|
18049
|
+
var data = getWeakData(key);
|
|
18050
|
+
if (data === true) return uncaughtFrozenStore(state).has(key);
|
|
18051
|
+
return data && hasOwn(data, state.id);
|
|
18052
|
+
}
|
|
18053
|
+
});
|
|
18054
|
+
|
|
18055
|
+
defineBuiltIns(Prototype, IS_MAP ? {
|
|
18056
|
+
// `WeakMap.prototype.get(key)` method
|
|
18057
|
+
// https://tc39.es/ecma262/#sec-weakmap.prototype.get
|
|
18058
|
+
get: function get(key) {
|
|
18059
|
+
var state = getInternalState(this);
|
|
18060
|
+
if (isObject(key)) {
|
|
18061
|
+
var data = getWeakData(key);
|
|
18062
|
+
if (data === true) return uncaughtFrozenStore(state).get(key);
|
|
18063
|
+
if (data) return data[state.id];
|
|
18064
|
+
}
|
|
18065
|
+
},
|
|
18066
|
+
// `WeakMap.prototype.set(key, value)` method
|
|
18067
|
+
// https://tc39.es/ecma262/#sec-weakmap.prototype.set
|
|
18068
|
+
set: function set(key, value) {
|
|
18069
|
+
return define(this, key, value);
|
|
18070
|
+
}
|
|
18071
|
+
} : {
|
|
18072
|
+
// `WeakSet.prototype.add(value)` method
|
|
18073
|
+
// https://tc39.es/ecma262/#sec-weakset.prototype.add
|
|
18074
|
+
add: function add(value) {
|
|
18075
|
+
return define(this, value, true);
|
|
18076
|
+
}
|
|
18077
|
+
});
|
|
18078
|
+
|
|
18079
|
+
return Constructor;
|
|
18080
|
+
}
|
|
18081
|
+
};
|
|
18082
|
+
return collectionWeak;
|
|
18083
|
+
}
|
|
18084
|
+
|
|
18085
|
+
var hasRequiredEs_weakMap_constructor;
|
|
18086
|
+
|
|
18087
|
+
function requireEs_weakMap_constructor () {
|
|
18088
|
+
if (hasRequiredEs_weakMap_constructor) return es_weakMap_constructor;
|
|
18089
|
+
hasRequiredEs_weakMap_constructor = 1;
|
|
18090
|
+
var FREEZING = requireFreezing();
|
|
18091
|
+
var globalThis = requireGlobalThis();
|
|
18092
|
+
var uncurryThis = requireFunctionUncurryThis();
|
|
18093
|
+
var defineBuiltIns = requireDefineBuiltIns();
|
|
18094
|
+
var InternalMetadataModule = requireInternalMetadata();
|
|
18095
|
+
var collection = requireCollection();
|
|
18096
|
+
var collectionWeak = requireCollectionWeak();
|
|
18097
|
+
var isObject = requireIsObject();
|
|
18098
|
+
var enforceInternalState = requireInternalState().enforce;
|
|
18099
|
+
var fails = requireFails();
|
|
18100
|
+
var NATIVE_WEAK_MAP = requireWeakMapBasicDetection();
|
|
18101
|
+
|
|
18102
|
+
var $Object = Object;
|
|
18103
|
+
// eslint-disable-next-line es/no-array-isarray -- safe
|
|
18104
|
+
var isArray = Array.isArray;
|
|
18105
|
+
// eslint-disable-next-line es/no-object-isextensible -- safe
|
|
18106
|
+
var isExtensible = $Object.isExtensible;
|
|
18107
|
+
// eslint-disable-next-line es/no-object-isfrozen -- safe
|
|
18108
|
+
var isFrozen = $Object.isFrozen;
|
|
18109
|
+
// eslint-disable-next-line es/no-object-issealed -- safe
|
|
18110
|
+
var isSealed = $Object.isSealed;
|
|
18111
|
+
// eslint-disable-next-line es/no-object-freeze -- safe
|
|
18112
|
+
var freeze = $Object.freeze;
|
|
18113
|
+
// eslint-disable-next-line es/no-object-seal -- safe
|
|
18114
|
+
var seal = $Object.seal;
|
|
18115
|
+
|
|
18116
|
+
var IS_IE11 = !globalThis.ActiveXObject && 'ActiveXObject' in globalThis;
|
|
18117
|
+
var InternalWeakMap;
|
|
18118
|
+
|
|
18119
|
+
var wrapper = function (init) {
|
|
18120
|
+
return function WeakMap() {
|
|
18121
|
+
return init(this, arguments.length ? arguments[0] : undefined);
|
|
18122
|
+
};
|
|
18123
|
+
};
|
|
18124
|
+
|
|
18125
|
+
// `WeakMap` constructor
|
|
18126
|
+
// https://tc39.es/ecma262/#sec-weakmap-constructor
|
|
18127
|
+
var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
|
|
18128
|
+
var WeakMapPrototype = $WeakMap.prototype;
|
|
18129
|
+
var nativeSet = uncurryThis(WeakMapPrototype.set);
|
|
18130
|
+
|
|
18131
|
+
// Chakra Edge bug: adding frozen arrays to WeakMap unfreeze them
|
|
18132
|
+
var hasMSEdgeFreezingBug = function () {
|
|
18133
|
+
return FREEZING && fails(function () {
|
|
18134
|
+
var frozenArray = freeze([]);
|
|
18135
|
+
nativeSet(new $WeakMap(), frozenArray, 1);
|
|
18136
|
+
return !isFrozen(frozenArray);
|
|
18137
|
+
});
|
|
18138
|
+
};
|
|
18139
|
+
|
|
18140
|
+
// IE11 WeakMap frozen keys fix
|
|
18141
|
+
// We can't use feature detection because it crash some old IE builds
|
|
18142
|
+
// https://github.com/zloirock/core-js/issues/485
|
|
18143
|
+
if (NATIVE_WEAK_MAP) if (IS_IE11) {
|
|
18144
|
+
InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
|
|
18145
|
+
InternalMetadataModule.enable();
|
|
18146
|
+
var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
|
|
18147
|
+
var nativeHas = uncurryThis(WeakMapPrototype.has);
|
|
18148
|
+
var nativeGet = uncurryThis(WeakMapPrototype.get);
|
|
18149
|
+
defineBuiltIns(WeakMapPrototype, {
|
|
18150
|
+
'delete': function (key) {
|
|
18151
|
+
if (isObject(key) && !isExtensible(key)) {
|
|
18152
|
+
var state = enforceInternalState(this);
|
|
18153
|
+
if (!state.frozen) state.frozen = new InternalWeakMap();
|
|
18154
|
+
return nativeDelete(this, key) || state.frozen['delete'](key);
|
|
18155
|
+
} return nativeDelete(this, key);
|
|
18156
|
+
},
|
|
18157
|
+
has: function has(key) {
|
|
18158
|
+
if (isObject(key) && !isExtensible(key)) {
|
|
18159
|
+
var state = enforceInternalState(this);
|
|
18160
|
+
if (!state.frozen) state.frozen = new InternalWeakMap();
|
|
18161
|
+
return nativeHas(this, key) || state.frozen.has(key);
|
|
18162
|
+
} return nativeHas(this, key);
|
|
18163
|
+
},
|
|
18164
|
+
get: function get(key) {
|
|
18165
|
+
if (isObject(key) && !isExtensible(key)) {
|
|
18166
|
+
var state = enforceInternalState(this);
|
|
18167
|
+
if (!state.frozen) state.frozen = new InternalWeakMap();
|
|
18168
|
+
return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
|
|
18169
|
+
} return nativeGet(this, key);
|
|
18170
|
+
},
|
|
18171
|
+
set: function set(key, value) {
|
|
18172
|
+
if (isObject(key) && !isExtensible(key)) {
|
|
18173
|
+
var state = enforceInternalState(this);
|
|
18174
|
+
if (!state.frozen) state.frozen = new InternalWeakMap();
|
|
18175
|
+
nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
|
|
18176
|
+
} else nativeSet(this, key, value);
|
|
18177
|
+
return this;
|
|
18178
|
+
}
|
|
18179
|
+
});
|
|
18180
|
+
// Chakra Edge frozen keys fix
|
|
18181
|
+
} else if (hasMSEdgeFreezingBug()) {
|
|
18182
|
+
defineBuiltIns(WeakMapPrototype, {
|
|
18183
|
+
set: function set(key, value) {
|
|
18184
|
+
var arrayIntegrityLevel;
|
|
18185
|
+
if (isArray(key)) {
|
|
18186
|
+
if (isFrozen(key)) arrayIntegrityLevel = freeze;
|
|
18187
|
+
else if (isSealed(key)) arrayIntegrityLevel = seal;
|
|
18188
|
+
}
|
|
18189
|
+
nativeSet(this, key, value);
|
|
18190
|
+
if (arrayIntegrityLevel) arrayIntegrityLevel(key);
|
|
18191
|
+
return this;
|
|
18192
|
+
}
|
|
18193
|
+
});
|
|
18194
|
+
}
|
|
18195
|
+
return es_weakMap_constructor;
|
|
18196
|
+
}
|
|
18197
|
+
|
|
18198
|
+
var hasRequiredEs_weakMap;
|
|
18199
|
+
|
|
18200
|
+
function requireEs_weakMap () {
|
|
18201
|
+
if (hasRequiredEs_weakMap) return es_weakMap;
|
|
18202
|
+
hasRequiredEs_weakMap = 1;
|
|
18203
|
+
// TODO: Remove this module from `core-js@4` since it's replaced to module below
|
|
18204
|
+
requireEs_weakMap_constructor();
|
|
18205
|
+
return es_weakMap;
|
|
18206
|
+
}
|
|
18207
|
+
|
|
18208
|
+
requireEs_weakMap();
|
|
18209
|
+
|
|
18210
|
+
/**
|
|
18211
|
+
* Lazy-load debug helpers (dynamic import) with shared caching.
|
|
18212
|
+
*
|
|
18213
|
+
* Why:
|
|
18214
|
+
* - Avoid eagerly bundling debug wiring into the main bundle.
|
|
18215
|
+
* - Keep one shared Promise so multiple entry points don't trigger multiple imports.
|
|
18216
|
+
*/
|
|
18217
|
+
|
|
18218
|
+
var debugModulePromise = null;
|
|
18219
|
+
function loadDebugModule() {
|
|
18220
|
+
if (!debugModulePromise) {
|
|
18221
|
+
debugModulePromise = Promise.resolve().then(function () { return debug; });
|
|
18222
|
+
}
|
|
18223
|
+
return debugModulePromise;
|
|
18224
|
+
}
|
|
18225
|
+
var CLIENT_DEBUG_STATE = new WeakMap();
|
|
18226
|
+
var CLIENT_DEBUG_WRAPPED = Symbol.for('__requestIframeClientDebugWrapped__');
|
|
18227
|
+
|
|
18228
|
+
/**
|
|
18229
|
+
* Ensure debug interceptors/listeners are attached to a client instance.
|
|
18230
|
+
*
|
|
18231
|
+
* Notes:
|
|
18232
|
+
* - This returns a Promise that never rejects (best-effort).
|
|
18233
|
+
* - It is safe to call multiple times; only attaches once per client instance.
|
|
18234
|
+
*/
|
|
18235
|
+
function ensureClientDebugInterceptors(client) {
|
|
18236
|
+
var key = client;
|
|
18237
|
+
var state = CLIENT_DEBUG_STATE.get(key);
|
|
18238
|
+
if (!state) {
|
|
18239
|
+
state = {
|
|
18240
|
+
promise: null,
|
|
18241
|
+
attached: false
|
|
18242
|
+
};
|
|
18243
|
+
CLIENT_DEBUG_STATE.set(key, state);
|
|
18244
|
+
}
|
|
18245
|
+
if (state.attached) return Promise.resolve();
|
|
18246
|
+
if (!state.promise) {
|
|
18247
|
+
state.promise = loadDebugModule().then(m => {
|
|
18248
|
+
if (state.attached) return;
|
|
18249
|
+
m.setupClientDebugInterceptors(client);
|
|
18250
|
+
state.attached = true;
|
|
18251
|
+
}).catch(() => {
|
|
18252
|
+
/** ignore */
|
|
17863
18253
|
});
|
|
17864
|
-
}
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
18254
|
+
}
|
|
18255
|
+
return state.promise;
|
|
18256
|
+
}
|
|
18257
|
+
|
|
18258
|
+
/**
|
|
18259
|
+
* Wrap client send methods so the first request in trace mode won't miss debug hooks.
|
|
18260
|
+
*
|
|
18261
|
+
* Why:
|
|
18262
|
+
* - debug module is lazy-loaded via dynamic import, so it may not be ready immediately.
|
|
18263
|
+
* - In trace mode, it's acceptable to delay the first send by a microtask or module-load time.
|
|
18264
|
+
*/
|
|
18265
|
+
function wrapClientMethodsForDebug(client) {
|
|
18266
|
+
var c = client;
|
|
18267
|
+
if (c[CLIENT_DEBUG_WRAPPED]) return;
|
|
18268
|
+
c[CLIENT_DEBUG_WRAPPED] = true;
|
|
18269
|
+
var wrapAsyncMethod = name => {
|
|
18270
|
+
var original = c[name];
|
|
18271
|
+
if (typeof original !== 'function') return;
|
|
18272
|
+
var bound = original.bind(c);
|
|
18273
|
+
c[name] = (...args) => {
|
|
18274
|
+
return ensureClientDebugInterceptors(client).then(() => bound(...args));
|
|
18275
|
+
};
|
|
18276
|
+
};
|
|
18277
|
+
wrapAsyncMethod('send');
|
|
18278
|
+
wrapAsyncMethod('sendFile');
|
|
18279
|
+
wrapAsyncMethod('sendStream');
|
|
18280
|
+
wrapAsyncMethod('isConnect');
|
|
18281
|
+
}
|
|
18282
|
+
|
|
18283
|
+
function ownKeys$2(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; }
|
|
18284
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18285
|
+
/**
|
|
18286
|
+
* Security defaults helper for "strict mode".
|
|
18287
|
+
*
|
|
18288
|
+
* Goal:
|
|
18289
|
+
* - Reduce boilerplate in common same-origin usage.
|
|
18290
|
+
* - Provide safer defaults when user does NOT configure origin constraints explicitly.
|
|
18291
|
+
*
|
|
18292
|
+
* Behavior (when strict === true):
|
|
18293
|
+
* - Client-like options:
|
|
18294
|
+
* - If targetOrigin is not provided, default to window.location.origin (same-origin only).
|
|
18295
|
+
* - If neither allowedOrigins nor validateOrigin is provided, default allowedOrigins to [window.location.origin].
|
|
18296
|
+
* - Server-like options:
|
|
18297
|
+
* - If neither allowedOrigins nor validateOrigin is provided, default allowedOrigins to [window.location.origin].
|
|
18298
|
+
*
|
|
18299
|
+
* Notes:
|
|
18300
|
+
* - This intentionally makes cross-origin setups fail fast unless user explicitly configures
|
|
18301
|
+
* targetOrigin and allowedOrigins/validateOrigin.
|
|
18302
|
+
*/
|
|
18303
|
+
|
|
18304
|
+
function getCurrentWindowOrigin() {
|
|
18305
|
+
try {
|
|
18306
|
+
var _window$location;
|
|
18307
|
+
if (typeof window === 'undefined') return undefined;
|
|
18308
|
+
var origin = (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.origin;
|
|
18309
|
+
if (typeof origin === 'string' && origin) return origin;
|
|
18310
|
+
} catch (_unused) {
|
|
18311
|
+
/** ignore */
|
|
18312
|
+
}
|
|
18313
|
+
return undefined;
|
|
18314
|
+
}
|
|
18315
|
+
function applyStrictClientSecurityDefaults(defaultTargetOrigin, options) {
|
|
18316
|
+
var _options$targetOrigin;
|
|
18317
|
+
var strict = (options === null || options === void 0 ? void 0 : options.strict) === true;
|
|
18318
|
+
var targetOrigin = (_options$targetOrigin = options === null || options === void 0 ? void 0 : options.targetOrigin) !== null && _options$targetOrigin !== void 0 ? _options$targetOrigin : defaultTargetOrigin;
|
|
18319
|
+
var allowedOrigins = options === null || options === void 0 ? void 0 : options.allowedOrigins;
|
|
18320
|
+
if (strict) {
|
|
18321
|
+
var currentOrigin = getCurrentWindowOrigin();
|
|
18322
|
+
if (currentOrigin) {
|
|
18323
|
+
if (!(options !== null && options !== void 0 && options.targetOrigin)) {
|
|
18324
|
+
targetOrigin = currentOrigin;
|
|
17871
18325
|
}
|
|
17872
|
-
|
|
18326
|
+
if (!(options !== null && options !== void 0 && options.allowedOrigins) && !(options !== null && options !== void 0 && options.validateOrigin)) {
|
|
18327
|
+
allowedOrigins = [currentOrigin];
|
|
18328
|
+
}
|
|
18329
|
+
}
|
|
18330
|
+
}
|
|
18331
|
+
if (!options) {
|
|
18332
|
+
return {
|
|
18333
|
+
targetOrigin,
|
|
18334
|
+
options: options
|
|
18335
|
+
};
|
|
18336
|
+
}
|
|
18337
|
+
if (targetOrigin === options.targetOrigin && allowedOrigins === options.allowedOrigins) {
|
|
18338
|
+
return {
|
|
18339
|
+
targetOrigin,
|
|
18340
|
+
options
|
|
18341
|
+
};
|
|
18342
|
+
}
|
|
18343
|
+
return {
|
|
18344
|
+
targetOrigin,
|
|
18345
|
+
options: _objectSpread$2(_objectSpread$2(_objectSpread$2({}, options), targetOrigin !== options.targetOrigin ? {
|
|
18346
|
+
targetOrigin
|
|
18347
|
+
} : null), allowedOrigins !== options.allowedOrigins ? {
|
|
18348
|
+
allowedOrigins
|
|
18349
|
+
} : null)
|
|
18350
|
+
};
|
|
18351
|
+
}
|
|
18352
|
+
function applyStrictServerSecurityDefaults(options) {
|
|
18353
|
+
var strict = (options === null || options === void 0 ? void 0 : options.strict) === true;
|
|
18354
|
+
if (!strict) return options;
|
|
18355
|
+
if (options !== null && options !== void 0 && options.allowedOrigins || options !== null && options !== void 0 && options.validateOrigin) {
|
|
18356
|
+
return options;
|
|
17873
18357
|
}
|
|
18358
|
+
var currentOrigin = getCurrentWindowOrigin();
|
|
18359
|
+
if (!currentOrigin) return options;
|
|
18360
|
+
return _objectSpread$2(_objectSpread$2({}, options), {}, {
|
|
18361
|
+
allowedOrigins: [currentOrigin]
|
|
18362
|
+
});
|
|
17874
18363
|
}
|
|
17875
18364
|
|
|
17876
|
-
/**
|
|
17877
|
-
*
|
|
17878
|
-
*
|
|
18365
|
+
/**
|
|
18366
|
+
* Create a client (for sending requests)
|
|
18367
|
+
*
|
|
18368
|
+
* Note:
|
|
18369
|
+
* - MessageChannel is cached at the window level by secretKey (ensures unique message listener)
|
|
18370
|
+
* - Client instances are not cached, a new instance is created on each call
|
|
18371
|
+
* - This allows different versions of the library to coexist
|
|
17879
18372
|
*/
|
|
17880
|
-
function
|
|
17881
|
-
|
|
17882
|
-
var
|
|
17883
|
-
var
|
|
18373
|
+
function requestIframeClient(target, options) {
|
|
18374
|
+
var _resolved$options;
|
|
18375
|
+
var targetWindow = null;
|
|
18376
|
+
var defaultTargetOrigin = OriginConstant.ANY;
|
|
18377
|
+
if (target.tagName === 'IFRAME') {
|
|
18378
|
+
var iframe = target;
|
|
18379
|
+
targetWindow = iframe.contentWindow;
|
|
18380
|
+
defaultTargetOrigin = getIframeTargetOrigin(iframe);
|
|
18381
|
+
if (!targetWindow) {
|
|
18382
|
+
throw {
|
|
18383
|
+
message: Messages.IFRAME_NOT_READY,
|
|
18384
|
+
code: ErrorCode.IFRAME_NOT_READY
|
|
18385
|
+
};
|
|
18386
|
+
}
|
|
18387
|
+
} else {
|
|
18388
|
+
targetWindow = target;
|
|
18389
|
+
defaultTargetOrigin = OriginConstant.ANY;
|
|
18390
|
+
}
|
|
18391
|
+
var resolved = applyStrictClientSecurityDefaults(defaultTargetOrigin, options);
|
|
18392
|
+
var targetOrigin = resolved.targetOrigin;
|
|
18393
|
+
var resolvedOptions = (_resolved$options = resolved.options) !== null && _resolved$options !== void 0 ? _resolved$options : options;
|
|
17884
18394
|
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
cookies: req.cookies,
|
|
17897
|
-
method: 'POST' // iframe requests are always POST-like
|
|
17898
|
-
}));
|
|
18395
|
+
/**
|
|
18396
|
+
* P1: warn on unsafe default targetOrigin for Window targets.
|
|
18397
|
+
* - If targetOrigin is '*' and user did not configure allowedOrigins/validateOrigin,
|
|
18398
|
+
* incoming message origin validation is effectively disabled.
|
|
18399
|
+
*/
|
|
18400
|
+
warnUnsafeTargetOriginForWindow({
|
|
18401
|
+
isIframeTarget: target.tagName === 'IFRAME',
|
|
18402
|
+
targetOrigin,
|
|
18403
|
+
allowedOrigins: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.allowedOrigins,
|
|
18404
|
+
validateOrigin: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.validateOrigin
|
|
18405
|
+
});
|
|
17899
18406
|
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
var originalJson = res.json.bind(res);
|
|
17903
|
-
var originalSendFile = res.sendFile.bind(res);
|
|
17904
|
-
var originalSendStream = (_res$sendStream = res.sendStream) === null || _res$sendStream === void 0 ? void 0 : _res$sendStream.bind(res);
|
|
17905
|
-
var originalStatus = res.status.bind(res);
|
|
17906
|
-
var originalSetHeader = res.setHeader.bind(res);
|
|
18407
|
+
// Determine secretKey
|
|
18408
|
+
var secretKey = resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.secretKey;
|
|
17907
18409
|
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SETTING_STATUS_CODE, {
|
|
17911
|
-
requestId: req.requestId,
|
|
17912
|
-
path: req.path,
|
|
17913
|
-
statusCode: code
|
|
17914
|
-
});
|
|
17915
|
-
return originalStatus(code);
|
|
17916
|
-
};
|
|
18410
|
+
// Generate instance ID first (will be used by both client and server)
|
|
18411
|
+
var instanceId = generateInstanceId();
|
|
17917
18412
|
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
var duration;
|
|
17933
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
17934
|
-
while (1) switch (_context.prev = _context.next) {
|
|
17935
|
-
case 0:
|
|
17936
|
-
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
17937
|
-
startTimes.delete(req.requestId);
|
|
17938
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_RESPONSE, formatMessageData({
|
|
17939
|
-
requestId: req.requestId,
|
|
17940
|
-
path: req.path,
|
|
17941
|
-
status: res.statusCode,
|
|
17942
|
-
statusText: getStatusText(res.statusCode),
|
|
17943
|
-
requireAck: options === null || options === void 0 ? void 0 : options.requireAck,
|
|
17944
|
-
headers: res.headers,
|
|
17945
|
-
data,
|
|
17946
|
-
duration: `${duration}ms`
|
|
17947
|
-
}));
|
|
17948
|
-
return _context.abrupt("return", originalSend(data, options));
|
|
17949
|
-
case 1:
|
|
17950
|
-
case "end":
|
|
17951
|
-
return _context.stop();
|
|
17952
|
-
}
|
|
17953
|
-
}, _callee);
|
|
17954
|
-
}));
|
|
17955
|
-
return function (_x, _x2) {
|
|
17956
|
-
return _ref.apply(this, arguments);
|
|
17957
|
-
};
|
|
17958
|
-
}();
|
|
17959
|
-
|
|
17960
|
-
// Override json method
|
|
17961
|
-
res.json = /*#__PURE__*/function () {
|
|
17962
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, options) {
|
|
17963
|
-
var duration;
|
|
17964
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
17965
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
17966
|
-
case 0:
|
|
17967
|
-
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
17968
|
-
startTimes.delete(req.requestId);
|
|
17969
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_JSON_RESPONSE, formatMessageData({
|
|
17970
|
-
requestId: req.requestId,
|
|
17971
|
-
path: req.path,
|
|
17972
|
-
status: res.statusCode,
|
|
17973
|
-
statusText: getStatusText(res.statusCode),
|
|
17974
|
-
requireAck: options === null || options === void 0 ? void 0 : options.requireAck,
|
|
17975
|
-
headers: res.headers,
|
|
17976
|
-
data,
|
|
17977
|
-
duration: `${duration}ms`
|
|
17978
|
-
}));
|
|
17979
|
-
return _context2.abrupt("return", originalJson(data, options));
|
|
17980
|
-
case 1:
|
|
17981
|
-
case "end":
|
|
17982
|
-
return _context2.stop();
|
|
17983
|
-
}
|
|
17984
|
-
}, _callee2);
|
|
17985
|
-
}));
|
|
17986
|
-
return function (_x3, _x4) {
|
|
17987
|
-
return _ref2.apply(this, arguments);
|
|
17988
|
-
};
|
|
17989
|
-
}();
|
|
17990
|
-
|
|
17991
|
-
// Override sendFile method
|
|
17992
|
-
res.sendFile = /*#__PURE__*/function () {
|
|
17993
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(content, options) {
|
|
17994
|
-
var duration;
|
|
17995
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
17996
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
17997
|
-
case 0:
|
|
17998
|
-
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
17999
|
-
startTimes.delete(req.requestId);
|
|
18000
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_FILE, formatMessageData({
|
|
18001
|
-
requestId: req.requestId,
|
|
18002
|
-
path: req.path,
|
|
18003
|
-
status: res.statusCode,
|
|
18004
|
-
statusText: getStatusText(res.statusCode),
|
|
18005
|
-
fileName: options === null || options === void 0 ? void 0 : options.fileName,
|
|
18006
|
-
mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
|
|
18007
|
-
contentLength: typeof content === 'string' ? content.length : (content === null || content === void 0 ? void 0 : content.size) || 0,
|
|
18008
|
-
duration: `${duration}ms`
|
|
18009
|
-
}));
|
|
18010
|
-
return _context3.abrupt("return", originalSendFile(content, options));
|
|
18011
|
-
case 1:
|
|
18012
|
-
case "end":
|
|
18013
|
-
return _context3.stop();
|
|
18014
|
-
}
|
|
18015
|
-
}, _callee3);
|
|
18016
|
-
}));
|
|
18017
|
-
return function (_x5, _x6) {
|
|
18018
|
-
return _ref3.apply(this, arguments);
|
|
18019
|
-
};
|
|
18020
|
-
}();
|
|
18021
|
-
|
|
18022
|
-
// Override sendStream method if exists
|
|
18023
|
-
if (originalSendStream) {
|
|
18024
|
-
res.sendStream = /*#__PURE__*/function () {
|
|
18025
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(stream) {
|
|
18026
|
-
var duration;
|
|
18027
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
18028
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
18029
|
-
case 0:
|
|
18030
|
-
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
18031
|
-
startTimes.delete(req.requestId);
|
|
18032
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_STREAM, formatMessageData({
|
|
18033
|
-
requestId: req.requestId,
|
|
18034
|
-
path: req.path,
|
|
18035
|
-
status: res.statusCode,
|
|
18036
|
-
statusText: getStatusText(res.statusCode),
|
|
18037
|
-
streamId: stream === null || stream === void 0 ? void 0 : stream.streamId,
|
|
18038
|
-
duration: `${duration}ms`
|
|
18039
|
-
}));
|
|
18040
|
-
return _context4.abrupt("return", originalSendStream(stream));
|
|
18041
|
-
case 1:
|
|
18042
|
-
case "end":
|
|
18043
|
-
return _context4.stop();
|
|
18044
|
-
}
|
|
18045
|
-
}, _callee4);
|
|
18046
|
-
}));
|
|
18047
|
-
return function (_x7) {
|
|
18048
|
-
return _ref4.apply(this, arguments);
|
|
18049
|
-
};
|
|
18050
|
-
}();
|
|
18051
|
-
}
|
|
18052
|
-
next();
|
|
18053
|
-
});
|
|
18054
|
-
|
|
18055
|
-
/** Hook into MessageDispatcher hooks (no monkey patch). */
|
|
18056
|
-
setupServerMessageDebuggingViaHooks(serverImpl);
|
|
18057
|
-
}
|
|
18058
|
-
|
|
18059
|
-
/**
|
|
18060
|
-
* Setup message-level debugging for server (hook-based, no monkey patch).
|
|
18061
|
-
*/
|
|
18062
|
-
function setupServerMessageDebuggingViaHooks(serverImpl) {
|
|
18063
|
-
var _dispatcher$hooks$aft, _dispatcher$hooks$inb;
|
|
18064
|
-
var dispatcher = serverImpl.messageDispatcher || serverImpl.dispatcher;
|
|
18065
|
-
if (!(dispatcher !== null && dispatcher !== void 0 && dispatcher.hooks)) return;
|
|
18066
|
-
|
|
18067
|
-
/** Outbound messages */
|
|
18068
|
-
if ((_dispatcher$hooks$aft = dispatcher.hooks.afterSend) !== null && _dispatcher$hooks$aft !== void 0 && _dispatcher$hooks$aft.tap) {
|
|
18069
|
-
dispatcher.hooks.afterSend.tap('debug', (_target, _targetOrigin, message) => {
|
|
18070
|
-
var type = message.type;
|
|
18071
|
-
var requestId = message.requestId;
|
|
18072
|
-
var data = message;
|
|
18073
|
-
if (type === MessageType.ACK) {
|
|
18074
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ACK, formatMessageData({
|
|
18075
|
-
requestId,
|
|
18076
|
-
path: data.path
|
|
18077
|
-
}));
|
|
18078
|
-
} else if (type === MessageType.ASYNC) {
|
|
18079
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ASYNC, formatMessageData({
|
|
18080
|
-
requestId,
|
|
18081
|
-
path: data.path
|
|
18082
|
-
}));
|
|
18083
|
-
} else if (type === MessageType.STREAM_START) {
|
|
18084
|
-
var streamBody = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
18085
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_START, formatMessageData({
|
|
18086
|
-
requestId,
|
|
18087
|
-
streamId: streamBody.streamId,
|
|
18088
|
-
streamType: streamBody.type,
|
|
18089
|
-
chunked: streamBody.chunked,
|
|
18090
|
-
autoResolve: streamBody.autoResolve,
|
|
18091
|
-
metadata: streamBody.metadata
|
|
18092
|
-
}));
|
|
18093
|
-
} else if (type === MessageType.STREAM_DATA) {
|
|
18094
|
-
var _streamBody3$data;
|
|
18095
|
-
var _streamBody3 = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
18096
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_DATA, formatMessageData({
|
|
18097
|
-
requestId,
|
|
18098
|
-
streamId: _streamBody3.streamId,
|
|
18099
|
-
done: _streamBody3.done,
|
|
18100
|
-
dataLength: ((_streamBody3$data = _streamBody3.data) === null || _streamBody3$data === void 0 ? void 0 : _streamBody3$data.length) || 0
|
|
18101
|
-
}));
|
|
18102
|
-
} else if (type === MessageType.STREAM_END) {
|
|
18103
|
-
var _streamBody4 = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
18104
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_END, formatMessageData({
|
|
18105
|
-
requestId,
|
|
18106
|
-
streamId: _streamBody4.streamId
|
|
18107
|
-
}));
|
|
18108
|
-
} else if (type === MessageType.ERROR) {
|
|
18109
|
-
logEvent(LogLevel.ERROR, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ERROR, formatMessageData({
|
|
18110
|
-
requestId,
|
|
18111
|
-
status: data === null || data === void 0 ? void 0 : data.status,
|
|
18112
|
-
statusText: data === null || data === void 0 ? void 0 : data.statusText,
|
|
18113
|
-
error: data === null || data === void 0 ? void 0 : data.error,
|
|
18114
|
-
path: data === null || data === void 0 ? void 0 : data.path
|
|
18115
|
-
}));
|
|
18116
|
-
} else if (type === MessageType.RESPONSE) {
|
|
18117
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_RESPONSE_VIA_DISPATCHER, formatMessageData({
|
|
18118
|
-
requestId,
|
|
18119
|
-
status: data === null || data === void 0 ? void 0 : data.status,
|
|
18120
|
-
statusText: data === null || data === void 0 ? void 0 : data.statusText,
|
|
18121
|
-
requireAck: data === null || data === void 0 ? void 0 : data.requireAck,
|
|
18122
|
-
path: data === null || data === void 0 ? void 0 : data.path
|
|
18123
|
-
}));
|
|
18124
|
-
}
|
|
18125
|
-
});
|
|
18126
|
-
}
|
|
18127
|
-
|
|
18128
|
-
/** Inbound messages */
|
|
18129
|
-
if ((_dispatcher$hooks$inb = dispatcher.hooks.inbound) !== null && _dispatcher$hooks$inb !== void 0 && _dispatcher$hooks$inb.tap) {
|
|
18130
|
-
dispatcher.hooks.inbound.tap('debug', (data, context) => {
|
|
18131
|
-
if (data.type === MessageType.REQUEST) {
|
|
18132
|
-
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_INBOUND, Messages.DEBUG_SERVER_HANDLING_REQUEST, formatMessageData({
|
|
18133
|
-
requestId: data.requestId,
|
|
18134
|
-
path: data.path,
|
|
18135
|
-
origin: context === null || context === void 0 ? void 0 : context.origin,
|
|
18136
|
-
role: data.role,
|
|
18137
|
-
creatorId: data.creatorId
|
|
18138
|
-
}));
|
|
18139
|
-
}
|
|
18140
|
-
});
|
|
18141
|
-
}
|
|
18142
|
-
}
|
|
18143
|
-
|
|
18144
|
-
/**
|
|
18145
|
-
* Create a client (for sending requests)
|
|
18146
|
-
*
|
|
18147
|
-
* Note:
|
|
18148
|
-
* - MessageChannel is cached at the window level by secretKey (ensures unique message listener)
|
|
18149
|
-
* - Client instances are not cached, a new instance is created on each call
|
|
18150
|
-
* - This allows different versions of the library to coexist
|
|
18151
|
-
*/
|
|
18152
|
-
function requestIframeClient(target, options) {
|
|
18153
|
-
var targetWindow = null;
|
|
18154
|
-
var targetOrigin = OriginConstant.ANY;
|
|
18155
|
-
if (target.tagName === 'IFRAME') {
|
|
18156
|
-
var iframe = target;
|
|
18157
|
-
targetWindow = iframe.contentWindow;
|
|
18158
|
-
targetOrigin = getIframeTargetOrigin(iframe);
|
|
18159
|
-
if (!targetWindow) {
|
|
18160
|
-
throw {
|
|
18161
|
-
message: Messages.IFRAME_NOT_READY,
|
|
18162
|
-
code: ErrorCode.IFRAME_NOT_READY
|
|
18163
|
-
};
|
|
18164
|
-
}
|
|
18165
|
-
} else {
|
|
18166
|
-
targetWindow = target;
|
|
18167
|
-
targetOrigin = OriginConstant.ANY;
|
|
18168
|
-
}
|
|
18169
|
-
|
|
18170
|
-
// Allow user to override targetOrigin explicitly
|
|
18171
|
-
if (options !== null && options !== void 0 && options.targetOrigin) {
|
|
18172
|
-
targetOrigin = options.targetOrigin;
|
|
18173
|
-
}
|
|
18174
|
-
|
|
18175
|
-
// Determine secretKey
|
|
18176
|
-
var secretKey = options === null || options === void 0 ? void 0 : options.secretKey;
|
|
18177
|
-
|
|
18178
|
-
// Generate instance ID first (will be used by both client and server)
|
|
18179
|
-
var instanceId = generateInstanceId();
|
|
18180
|
-
|
|
18181
|
-
// Create client instance (internally creates its core message server)
|
|
18182
|
-
var client = new RequestIframeClientImpl(targetWindow, targetOrigin, {
|
|
18183
|
-
secretKey,
|
|
18184
|
-
ackTimeout: options === null || options === void 0 ? void 0 : options.ackTimeout,
|
|
18185
|
-
timeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
18186
|
-
asyncTimeout: options === null || options === void 0 ? void 0 : options.asyncTimeout,
|
|
18187
|
-
returnData: options === null || options === void 0 ? void 0 : options.returnData,
|
|
18188
|
-
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
18189
|
-
allowedOrigins: options === null || options === void 0 ? void 0 : options.allowedOrigins,
|
|
18190
|
-
validateOrigin: options === null || options === void 0 ? void 0 : options.validateOrigin,
|
|
18191
|
-
autoOpen: options === null || options === void 0 ? void 0 : options.autoOpen,
|
|
18192
|
-
autoAckMaxMetaLength: options === null || options === void 0 ? void 0 : options.autoAckMaxMetaLength,
|
|
18193
|
-
autoAckMaxIdLength: options === null || options === void 0 ? void 0 : options.autoAckMaxIdLength
|
|
18194
|
-
}, instanceId);
|
|
18413
|
+
// Create client instance (internally creates its core message server)
|
|
18414
|
+
var client = new RequestIframeClientImpl(targetWindow, targetOrigin, {
|
|
18415
|
+
secretKey,
|
|
18416
|
+
ackTimeout: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.ackTimeout,
|
|
18417
|
+
timeout: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.timeout,
|
|
18418
|
+
asyncTimeout: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.asyncTimeout,
|
|
18419
|
+
returnData: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.returnData,
|
|
18420
|
+
headers: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.headers,
|
|
18421
|
+
allowedOrigins: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.allowedOrigins,
|
|
18422
|
+
validateOrigin: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.validateOrigin,
|
|
18423
|
+
autoOpen: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoOpen,
|
|
18424
|
+
autoAckMaxMetaLength: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoAckMaxMetaLength,
|
|
18425
|
+
autoAckMaxIdLength: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoAckMaxIdLength
|
|
18426
|
+
}, instanceId);
|
|
18195
18427
|
|
|
18196
18428
|
/**
|
|
18197
18429
|
* Trace/log level:
|
|
18198
18430
|
* - default: only warn/error will be printed (logger default)
|
|
18199
18431
|
* - if trace enabled: raise log level and (optionally) enable detailed debug interceptors
|
|
18200
18432
|
*/
|
|
18201
|
-
if (
|
|
18202
|
-
var level =
|
|
18433
|
+
if (resolvedOptions !== null && resolvedOptions !== void 0 && resolvedOptions.trace) {
|
|
18434
|
+
var level = resolvedOptions.trace === true ? LogLevel.TRACE : resolvedOptions.trace;
|
|
18203
18435
|
setRequestIframeLogLevel(level);
|
|
18204
18436
|
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
18205
|
-
|
|
18437
|
+
/**
|
|
18438
|
+
* Lazy-load debug hooks to keep main bundle smaller, but still ensure
|
|
18439
|
+
* the first request in trace mode won't miss debug interceptors.
|
|
18440
|
+
*/
|
|
18441
|
+
wrapClientMethodsForDebug(client);
|
|
18442
|
+
// Preheat import early (best-effort)
|
|
18443
|
+
void loadDebugModule().catch(() => {
|
|
18444
|
+
/** ignore */
|
|
18445
|
+
});
|
|
18446
|
+
// Attach ASAP (best-effort)
|
|
18447
|
+
void ensureClientDebugInterceptors(client);
|
|
18206
18448
|
}
|
|
18207
18449
|
}
|
|
18208
18450
|
return client;
|
|
@@ -18388,8 +18630,8 @@
|
|
|
18388
18630
|
}
|
|
18389
18631
|
}
|
|
18390
18632
|
|
|
18391
|
-
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; }
|
|
18392
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).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; }
|
|
18633
|
+
function ownKeys$1(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; }
|
|
18634
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18393
18635
|
|
|
18394
18636
|
/**
|
|
18395
18637
|
* Callback waiting for client acknowledgment
|
|
@@ -18599,7 +18841,7 @@
|
|
|
18599
18841
|
}(),
|
|
18600
18842
|
onFileOrBlob: () => {
|
|
18601
18843
|
// Extract options for sendFile
|
|
18602
|
-
var fileOptions = _objectSpread({
|
|
18844
|
+
var fileOptions = _objectSpread$1({
|
|
18603
18845
|
requireAck: options === null || options === void 0 ? void 0 : options.requireAck
|
|
18604
18846
|
}, typeof File !== 'undefined' && data instanceof File ? {
|
|
18605
18847
|
mimeType: data.type,
|
|
@@ -18626,6 +18868,7 @@
|
|
|
18626
18868
|
sendFile(content, options) {
|
|
18627
18869
|
var _this2 = this;
|
|
18628
18870
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
18871
|
+
var _options$chunked, _options$autoResolve;
|
|
18629
18872
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
18630
18873
|
while (1) switch (_context3.prev = _context3.next) {
|
|
18631
18874
|
case 0:
|
|
@@ -18640,8 +18883,9 @@
|
|
|
18640
18883
|
content,
|
|
18641
18884
|
fileName: options === null || options === void 0 ? void 0 : options.fileName,
|
|
18642
18885
|
mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
|
|
18643
|
-
chunked: false,
|
|
18644
|
-
|
|
18886
|
+
chunked: (_options$chunked = options === null || options === void 0 ? void 0 : options.chunked) !== null && _options$chunked !== void 0 ? _options$chunked : false,
|
|
18887
|
+
chunkSize: options === null || options === void 0 ? void 0 : options.chunkSize,
|
|
18888
|
+
autoResolve: (_options$autoResolve = options === null || options === void 0 ? void 0 : options.autoResolve) !== null && _options$autoResolve !== void 0 ? _options$autoResolve : true,
|
|
18645
18889
|
defaultFileName: 'file',
|
|
18646
18890
|
defaultMimeType: 'application/octet-stream',
|
|
18647
18891
|
onFileInfo: ({
|
|
@@ -18834,8 +19078,9 @@
|
|
|
18834
19078
|
handledBy: this.id,
|
|
18835
19079
|
isOriginAllowed: (d, ctx) => this.isOriginAllowed(d, ctx),
|
|
18836
19080
|
warnMissingPendingWhenClosed: d => {
|
|
18837
|
-
this.hub
|
|
18838
|
-
|
|
19081
|
+
warnServerIgnoredMessageWhenClosedOnce(this.hub, {
|
|
19082
|
+
type: d.type,
|
|
19083
|
+
requestId: d.requestId
|
|
18839
19084
|
});
|
|
18840
19085
|
}
|
|
18841
19086
|
},
|
|
@@ -18850,8 +19095,9 @@
|
|
|
18850
19095
|
this.ackTimeout = (_options$ackTimeout = options === null || options === void 0 ? void 0 : options.ackTimeout) !== null && _options$ackTimeout !== void 0 ? _options$ackTimeout : DefaultTimeout.ACK;
|
|
18851
19096
|
this.maxConcurrentRequestsPerClient = (_options$maxConcurren = options === null || options === void 0 ? void 0 : options.maxConcurrentRequestsPerClient) !== null && _options$maxConcurren !== void 0 ? _options$maxConcurren : Number.POSITIVE_INFINITY;
|
|
18852
19097
|
var warnMissingPendingWhenClosed = d => {
|
|
18853
|
-
this.hub
|
|
18854
|
-
|
|
19098
|
+
warnServerIgnoredMessageWhenClosedOnce(this.hub, {
|
|
19099
|
+
type: d.type,
|
|
19100
|
+
requestId: d.requestId
|
|
18855
19101
|
});
|
|
18856
19102
|
};
|
|
18857
19103
|
var handlerOptions = this.hub.createHandlerOptions(this.handleVersionError.bind(this));
|
|
@@ -19429,9 +19675,11 @@
|
|
|
19429
19675
|
* - This allows different versions of the library to coexist
|
|
19430
19676
|
*/
|
|
19431
19677
|
function requestIframeServer(options) {
|
|
19678
|
+
var _applyStrictServerSec;
|
|
19679
|
+
var resolvedOptions = (_applyStrictServerSec = applyStrictServerSecurityDefaults(options)) !== null && _applyStrictServerSec !== void 0 ? _applyStrictServerSec : options;
|
|
19432
19680
|
// Determine secretKey and id
|
|
19433
|
-
var secretKey =
|
|
19434
|
-
var id =
|
|
19681
|
+
var secretKey = resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.secretKey;
|
|
19682
|
+
var id = resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.id;
|
|
19435
19683
|
|
|
19436
19684
|
// If id is specified, check cache first
|
|
19437
19685
|
if (id) {
|
|
@@ -19445,13 +19693,13 @@
|
|
|
19445
19693
|
var server = new RequestIframeServerImpl({
|
|
19446
19694
|
secretKey,
|
|
19447
19695
|
id,
|
|
19448
|
-
ackTimeout:
|
|
19449
|
-
autoOpen:
|
|
19450
|
-
allowedOrigins:
|
|
19451
|
-
validateOrigin:
|
|
19452
|
-
maxConcurrentRequestsPerClient:
|
|
19453
|
-
autoAckMaxMetaLength:
|
|
19454
|
-
autoAckMaxIdLength:
|
|
19696
|
+
ackTimeout: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.ackTimeout,
|
|
19697
|
+
autoOpen: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoOpen,
|
|
19698
|
+
allowedOrigins: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.allowedOrigins,
|
|
19699
|
+
validateOrigin: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.validateOrigin,
|
|
19700
|
+
maxConcurrentRequestsPerClient: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.maxConcurrentRequestsPerClient,
|
|
19701
|
+
autoAckMaxMetaLength: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoAckMaxMetaLength,
|
|
19702
|
+
autoAckMaxIdLength: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.autoAckMaxIdLength
|
|
19455
19703
|
});
|
|
19456
19704
|
|
|
19457
19705
|
/**
|
|
@@ -19459,11 +19707,17 @@
|
|
|
19459
19707
|
* - default: only warn/error will be printed (logger default)
|
|
19460
19708
|
* - if trace enabled: raise log level and (optionally) enable detailed debug listeners
|
|
19461
19709
|
*/
|
|
19462
|
-
if (
|
|
19463
|
-
var level =
|
|
19710
|
+
if (resolvedOptions !== null && resolvedOptions !== void 0 && resolvedOptions.trace) {
|
|
19711
|
+
var level = resolvedOptions.trace === true ? LogLevel.TRACE : resolvedOptions.trace;
|
|
19464
19712
|
setRequestIframeLogLevel(level);
|
|
19465
19713
|
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
19466
|
-
|
|
19714
|
+
/**
|
|
19715
|
+
* Lazy-load debug hooks to keep main bundle smaller.
|
|
19716
|
+
* Best-effort: ignore dynamic import errors.
|
|
19717
|
+
*/
|
|
19718
|
+
void loadDebugModule().then(m => m.setupServerDebugListeners(server)).catch(() => {
|
|
19719
|
+
/** ignore */
|
|
19720
|
+
});
|
|
19467
19721
|
}
|
|
19468
19722
|
}
|
|
19469
19723
|
|
|
@@ -19545,7 +19799,11 @@
|
|
|
19545
19799
|
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
19546
19800
|
setRequestIframeLogLevel(level);
|
|
19547
19801
|
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
19548
|
-
|
|
19802
|
+
wrapClientMethodsForDebug(client);
|
|
19803
|
+
void loadDebugModule().catch(() => {
|
|
19804
|
+
/** ignore */
|
|
19805
|
+
});
|
|
19806
|
+
void ensureClientDebugInterceptors(client);
|
|
19549
19807
|
}
|
|
19550
19808
|
}
|
|
19551
19809
|
this.client_ = client;
|
|
@@ -19580,7 +19838,9 @@
|
|
|
19580
19838
|
var level = options.trace === true ? LogLevel.TRACE : options.trace;
|
|
19581
19839
|
setRequestIframeLogLevel(level);
|
|
19582
19840
|
if (level === LogLevel.TRACE || level === LogLevel.INFO) {
|
|
19583
|
-
setupServerDebugListeners(server)
|
|
19841
|
+
void loadDebugModule().then(m => m.setupServerDebugListeners(server)).catch(() => {
|
|
19842
|
+
/** ignore */
|
|
19843
|
+
});
|
|
19584
19844
|
}
|
|
19585
19845
|
}
|
|
19586
19846
|
this.server_ = server;
|
|
@@ -19666,13 +19926,13 @@
|
|
|
19666
19926
|
* - handle requests from the peer (server)
|
|
19667
19927
|
*/
|
|
19668
19928
|
function requestIframeEndpoint(target, options) {
|
|
19669
|
-
var
|
|
19929
|
+
var _applyStrictServerSec, _resolvedClient$optio, _resolvedClient$optio2, _resolvedOptions$id;
|
|
19670
19930
|
var targetWindow = null;
|
|
19671
|
-
var
|
|
19931
|
+
var defaultTargetOrigin = OriginConstant.ANY;
|
|
19672
19932
|
if (target.tagName === 'IFRAME') {
|
|
19673
19933
|
var iframe = target;
|
|
19674
19934
|
targetWindow = iframe.contentWindow;
|
|
19675
|
-
|
|
19935
|
+
defaultTargetOrigin = getIframeTargetOrigin(iframe);
|
|
19676
19936
|
if (!targetWindow) {
|
|
19677
19937
|
throw {
|
|
19678
19938
|
message: Messages.IFRAME_NOT_READY,
|
|
@@ -19681,27 +19941,529 @@
|
|
|
19681
19941
|
}
|
|
19682
19942
|
} else {
|
|
19683
19943
|
targetWindow = target;
|
|
19684
|
-
|
|
19944
|
+
defaultTargetOrigin = OriginConstant.ANY;
|
|
19685
19945
|
}
|
|
19946
|
+
var resolvedClient = applyStrictClientSecurityDefaults(defaultTargetOrigin, options);
|
|
19947
|
+
var targetOrigin = resolvedClient.targetOrigin;
|
|
19948
|
+
var resolvedOptions = (_applyStrictServerSec = applyStrictServerSecurityDefaults((_resolvedClient$optio = resolvedClient.options) !== null && _resolvedClient$optio !== void 0 ? _resolvedClient$optio : options)) !== null && _applyStrictServerSec !== void 0 ? _applyStrictServerSec : (_resolvedClient$optio2 = resolvedClient.options) !== null && _resolvedClient$optio2 !== void 0 ? _resolvedClient$optio2 : options;
|
|
19686
19949
|
|
|
19687
|
-
/**
|
|
19688
|
-
|
|
19689
|
-
|
|
19690
|
-
|
|
19950
|
+
/**
|
|
19951
|
+
* P1: warn on unsafe default targetOrigin for Window targets.
|
|
19952
|
+
* Endpoint facade is lazy (client/server created later), so warn here.
|
|
19953
|
+
*/
|
|
19954
|
+
warnUnsafeTargetOriginForWindow({
|
|
19955
|
+
isIframeTarget: target.tagName === 'IFRAME',
|
|
19956
|
+
targetOrigin,
|
|
19957
|
+
allowedOrigins: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.allowedOrigins,
|
|
19958
|
+
validateOrigin: resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.validateOrigin
|
|
19959
|
+
});
|
|
19691
19960
|
|
|
19692
19961
|
/**
|
|
19693
19962
|
* Endpoint uses ONE shared id by default, so it behaves like a single endpoint.
|
|
19694
19963
|
* If options.id is provided, it becomes the shared id for both client+server.
|
|
19695
19964
|
*/
|
|
19696
|
-
var endpointId = (
|
|
19965
|
+
var endpointId = (_resolvedOptions$id = resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.id) !== null && _resolvedOptions$id !== void 0 ? _resolvedOptions$id : generateInstanceId();
|
|
19697
19966
|
return new RequestIframeEndpointApiFacade({
|
|
19698
19967
|
targetWindow,
|
|
19699
19968
|
targetOrigin,
|
|
19700
|
-
options,
|
|
19969
|
+
options: resolvedOptions,
|
|
19701
19970
|
endpointId
|
|
19702
19971
|
});
|
|
19703
19972
|
}
|
|
19704
19973
|
|
|
19974
|
+
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; }
|
|
19975
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).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; }
|
|
19976
|
+
function logEvent(level, event, message, data) {
|
|
19977
|
+
if (data !== undefined && data !== null && typeof data === 'object') {
|
|
19978
|
+
requestIframeLog(level, message, _objectSpread({
|
|
19979
|
+
event
|
|
19980
|
+
}, data));
|
|
19981
|
+
return;
|
|
19982
|
+
}
|
|
19983
|
+
requestIframeLog(level, message, data === undefined ? {
|
|
19984
|
+
event
|
|
19985
|
+
} : {
|
|
19986
|
+
event,
|
|
19987
|
+
data
|
|
19988
|
+
});
|
|
19989
|
+
}
|
|
19990
|
+
|
|
19991
|
+
/**
|
|
19992
|
+
* Format message data for logging (remove sensitive data if needed)
|
|
19993
|
+
*/
|
|
19994
|
+
function formatMessageData(data) {
|
|
19995
|
+
if (!data) return data;
|
|
19996
|
+
var formatted = _objectSpread({}, data);
|
|
19997
|
+
|
|
19998
|
+
// Limit body size in logs
|
|
19999
|
+
if (formatted.body && typeof formatted.body === 'object') {
|
|
20000
|
+
var bodyStr = JSON.stringify(formatted.body);
|
|
20001
|
+
if (bodyStr.length > 500) {
|
|
20002
|
+
formatted.body = bodyStr.substring(0, 500) + '... (truncated)';
|
|
20003
|
+
}
|
|
20004
|
+
}
|
|
20005
|
+
|
|
20006
|
+
// Limit data size in logs
|
|
20007
|
+
if (formatted.data && typeof formatted.data === 'object') {
|
|
20008
|
+
var dataStr = JSON.stringify(formatted.data);
|
|
20009
|
+
if (dataStr.length > 500) {
|
|
20010
|
+
formatted.data = dataStr.substring(0, 500) + '... (truncated)';
|
|
20011
|
+
}
|
|
20012
|
+
}
|
|
20013
|
+
return formatted;
|
|
20014
|
+
}
|
|
20015
|
+
|
|
20016
|
+
/**
|
|
20017
|
+
* Register debug interceptors for client
|
|
20018
|
+
*/
|
|
20019
|
+
function setupClientDebugInterceptors(client) {
|
|
20020
|
+
ensureRequestIframeLogLevel(LogLevel.INFO);
|
|
20021
|
+
|
|
20022
|
+
// Request interceptor: log request start
|
|
20023
|
+
client.interceptors.request.use(config => {
|
|
20024
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_START, Messages.DEBUG_CLIENT_REQUEST_START, formatMessageData({
|
|
20025
|
+
path: config.path,
|
|
20026
|
+
body: config.body,
|
|
20027
|
+
headers: config.headers,
|
|
20028
|
+
cookies: config.cookies,
|
|
20029
|
+
ackTimeout: config.ackTimeout,
|
|
20030
|
+
timeout: config.timeout,
|
|
20031
|
+
asyncTimeout: config.asyncTimeout,
|
|
20032
|
+
requestId: config.requestId
|
|
20033
|
+
}));
|
|
20034
|
+
return config;
|
|
20035
|
+
});
|
|
20036
|
+
|
|
20037
|
+
// Response interceptor: log response success
|
|
20038
|
+
client.interceptors.response.use(response => {
|
|
20039
|
+
var logData = {
|
|
20040
|
+
requestId: response.requestId,
|
|
20041
|
+
status: response.status,
|
|
20042
|
+
statusText: response.statusText,
|
|
20043
|
+
headers: response.headers
|
|
20044
|
+
};
|
|
20045
|
+
|
|
20046
|
+
// Check if response.data is a File or Blob
|
|
20047
|
+
if (response.data instanceof File || response.data instanceof Blob) {
|
|
20048
|
+
var file = response.data;
|
|
20049
|
+
var fileName = file instanceof File ? file.name : undefined;
|
|
20050
|
+
var mimeType = file.type || undefined;
|
|
20051
|
+
var contentLength = file.size;
|
|
20052
|
+
logData.fileData = {
|
|
20053
|
+
fileName,
|
|
20054
|
+
mimeType,
|
|
20055
|
+
contentLength
|
|
20056
|
+
};
|
|
20057
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS_FILE, Messages.DEBUG_CLIENT_REQUEST_SUCCESS_FILE, formatMessageData(logData));
|
|
20058
|
+
} else if (response.stream) {
|
|
20059
|
+
logData.stream = {
|
|
20060
|
+
streamId: response.stream.streamId,
|
|
20061
|
+
type: response.stream.type
|
|
20062
|
+
};
|
|
20063
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS_STREAM, Messages.DEBUG_CLIENT_REQUEST_SUCCESS_STREAM, formatMessageData(logData));
|
|
20064
|
+
} else {
|
|
20065
|
+
logData.data = response.data;
|
|
20066
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_REQUEST_SUCCESS, Messages.DEBUG_CLIENT_REQUEST_SUCCESS, formatMessageData(logData));
|
|
20067
|
+
}
|
|
20068
|
+
return response;
|
|
20069
|
+
}, error => {
|
|
20070
|
+
logEvent(LogLevel.ERROR, DebugEvent.CLIENT_REQUEST_FAILED, Messages.DEBUG_CLIENT_REQUEST_FAILED, formatMessageData({
|
|
20071
|
+
requestId: error.requestId,
|
|
20072
|
+
code: error.code,
|
|
20073
|
+
message: error.message,
|
|
20074
|
+
config: error.config,
|
|
20075
|
+
response: error.response
|
|
20076
|
+
}));
|
|
20077
|
+
return Promise.reject(error);
|
|
20078
|
+
});
|
|
20079
|
+
|
|
20080
|
+
/** Attach hook-based message debugging (no monkey patch). */
|
|
20081
|
+
var clientImpl = client;
|
|
20082
|
+
setupClientMessageDebuggingViaHooks(clientImpl);
|
|
20083
|
+
}
|
|
20084
|
+
|
|
20085
|
+
/**
|
|
20086
|
+
* Setup message-level debugging for client (hook-based, no monkey patch).
|
|
20087
|
+
*/
|
|
20088
|
+
function setupClientMessageDebuggingViaHooks(clientImpl) {
|
|
20089
|
+
var _clientImpl$hub, _clientImpl$getHub, _outbox$hooks, _dispatcher$hooks, _inbox$hooks, _dispatcher$hooks2;
|
|
20090
|
+
var inbox = clientImpl.inbox;
|
|
20091
|
+
var outbox = clientImpl.outbox;
|
|
20092
|
+
var dispatcher = ((_clientImpl$hub = clientImpl.hub) === null || _clientImpl$hub === void 0 ? void 0 : _clientImpl$hub.messageDispatcher) || ((_clientImpl$getHub = clientImpl.getHub) === null || _clientImpl$getHub === void 0 || (_clientImpl$getHub = _clientImpl$getHub.call(clientImpl)) === null || _clientImpl$getHub === void 0 ? void 0 : _clientImpl$getHub.messageDispatcher);
|
|
20093
|
+
|
|
20094
|
+
/** Outbound */
|
|
20095
|
+
if (outbox !== null && outbox !== void 0 && (_outbox$hooks = outbox.hooks) !== null && _outbox$hooks !== void 0 && (_outbox$hooks = _outbox$hooks.afterSendMessage) !== null && _outbox$hooks !== void 0 && _outbox$hooks.tap) {
|
|
20096
|
+
outbox.hooks.afterSendMessage.tap('debug', (type, requestId, data) => {
|
|
20097
|
+
if (type === MessageType.REQUEST) {
|
|
20098
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_REQUEST, formatMessageData({
|
|
20099
|
+
requestId,
|
|
20100
|
+
path: data === null || data === void 0 ? void 0 : data.path,
|
|
20101
|
+
body: data === null || data === void 0 ? void 0 : data.body,
|
|
20102
|
+
headers: data === null || data === void 0 ? void 0 : data.headers
|
|
20103
|
+
}));
|
|
20104
|
+
} else if (type === MessageType.PING) {
|
|
20105
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_PING, {
|
|
20106
|
+
requestId
|
|
20107
|
+
});
|
|
20108
|
+
} else if (type === MessageType.ACK) {
|
|
20109
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_RECEIVED_ACK, {
|
|
20110
|
+
requestId
|
|
20111
|
+
});
|
|
20112
|
+
}
|
|
20113
|
+
});
|
|
20114
|
+
} else if (dispatcher !== null && dispatcher !== void 0 && (_dispatcher$hooks = dispatcher.hooks) !== null && _dispatcher$hooks !== void 0 && (_dispatcher$hooks = _dispatcher$hooks.afterSend) !== null && _dispatcher$hooks !== void 0 && _dispatcher$hooks.tap) {
|
|
20115
|
+
dispatcher.hooks.afterSend.tap('debug', (_target, _origin, message) => {
|
|
20116
|
+
if (message.type === MessageType.REQUEST) {
|
|
20117
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_OUTBOUND, Messages.DEBUG_CLIENT_SENDING_REQUEST, formatMessageData({
|
|
20118
|
+
requestId: message.requestId,
|
|
20119
|
+
path: message.path,
|
|
20120
|
+
body: message.body,
|
|
20121
|
+
headers: message.headers
|
|
20122
|
+
}));
|
|
20123
|
+
}
|
|
20124
|
+
});
|
|
20125
|
+
}
|
|
20126
|
+
|
|
20127
|
+
/** Inbound */
|
|
20128
|
+
if (inbox !== null && inbox !== void 0 && (_inbox$hooks = inbox.hooks) !== null && _inbox$hooks !== void 0 && (_inbox$hooks = _inbox$hooks.inbound) !== null && _inbox$hooks !== void 0 && _inbox$hooks.tap) {
|
|
20129
|
+
inbox.hooks.inbound.tap('debug', data => {
|
|
20130
|
+
if (data.type === MessageType.ACK) {
|
|
20131
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_ACK, formatMessageData({
|
|
20132
|
+
requestId: data.requestId,
|
|
20133
|
+
path: data.path
|
|
20134
|
+
}));
|
|
20135
|
+
} else if (data.type === MessageType.ASYNC) {
|
|
20136
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_ASYNC, formatMessageData({
|
|
20137
|
+
requestId: data.requestId,
|
|
20138
|
+
path: data.path
|
|
20139
|
+
}));
|
|
20140
|
+
} else if (data.type === MessageType.STREAM_START) {
|
|
20141
|
+
var streamBody = data.body;
|
|
20142
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_STREAM_START, formatMessageData({
|
|
20143
|
+
requestId: data.requestId,
|
|
20144
|
+
streamId: streamBody === null || streamBody === void 0 ? void 0 : streamBody.streamId,
|
|
20145
|
+
streamType: streamBody === null || streamBody === void 0 ? void 0 : streamBody.type,
|
|
20146
|
+
chunked: streamBody === null || streamBody === void 0 ? void 0 : streamBody.chunked,
|
|
20147
|
+
autoResolve: streamBody === null || streamBody === void 0 ? void 0 : streamBody.autoResolve,
|
|
20148
|
+
metadata: streamBody === null || streamBody === void 0 ? void 0 : streamBody.metadata
|
|
20149
|
+
}));
|
|
20150
|
+
} else if (data.type === MessageType.STREAM_DATA) {
|
|
20151
|
+
var _streamBody$data;
|
|
20152
|
+
var _streamBody = data.body;
|
|
20153
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_STREAM_DATA, formatMessageData({
|
|
20154
|
+
requestId: data.requestId,
|
|
20155
|
+
streamId: _streamBody === null || _streamBody === void 0 ? void 0 : _streamBody.streamId,
|
|
20156
|
+
done: _streamBody === null || _streamBody === void 0 ? void 0 : _streamBody.done,
|
|
20157
|
+
dataLength: (_streamBody === null || _streamBody === void 0 || (_streamBody$data = _streamBody.data) === null || _streamBody$data === void 0 ? void 0 : _streamBody$data.length) || 0
|
|
20158
|
+
}));
|
|
20159
|
+
} else if (data.type === MessageType.STREAM_END) {
|
|
20160
|
+
var _streamBody2 = data.body;
|
|
20161
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_STREAM_END, formatMessageData({
|
|
20162
|
+
requestId: data.requestId,
|
|
20163
|
+
streamId: _streamBody2 === null || _streamBody2 === void 0 ? void 0 : _streamBody2.streamId
|
|
20164
|
+
}));
|
|
20165
|
+
} else if (data.type === MessageType.RESPONSE) {
|
|
20166
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_RESPONSE, formatMessageData({
|
|
20167
|
+
requestId: data.requestId,
|
|
20168
|
+
status: data.status,
|
|
20169
|
+
statusText: data.statusText,
|
|
20170
|
+
requireAck: data.requireAck
|
|
20171
|
+
}));
|
|
20172
|
+
} else if (data.type === MessageType.ERROR) {
|
|
20173
|
+
logEvent(LogLevel.ERROR, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_ERROR, formatMessageData({
|
|
20174
|
+
requestId: data.requestId,
|
|
20175
|
+
status: data.status,
|
|
20176
|
+
statusText: data.statusText,
|
|
20177
|
+
error: data.error
|
|
20178
|
+
}));
|
|
20179
|
+
}
|
|
20180
|
+
});
|
|
20181
|
+
} else if (dispatcher !== null && dispatcher !== void 0 && (_dispatcher$hooks2 = dispatcher.hooks) !== null && _dispatcher$hooks2 !== void 0 && (_dispatcher$hooks2 = _dispatcher$hooks2.inbound) !== null && _dispatcher$hooks2 !== void 0 && _dispatcher$hooks2.tap) {
|
|
20182
|
+
dispatcher.hooks.inbound.tap('debug', data => {
|
|
20183
|
+
if (data.type === MessageType.ACK) {
|
|
20184
|
+
logEvent(LogLevel.INFO, DebugEvent.CLIENT_MESSAGE_INBOUND, Messages.DEBUG_CLIENT_RECEIVED_ACK, formatMessageData({
|
|
20185
|
+
requestId: data.requestId,
|
|
20186
|
+
path: data.path
|
|
20187
|
+
}));
|
|
20188
|
+
}
|
|
20189
|
+
});
|
|
20190
|
+
}
|
|
20191
|
+
}
|
|
20192
|
+
|
|
20193
|
+
/**
|
|
20194
|
+
* Register debug listeners for server
|
|
20195
|
+
* Use middleware to log requests and responses
|
|
20196
|
+
*/
|
|
20197
|
+
function setupServerDebugListeners(server) {
|
|
20198
|
+
ensureRequestIframeLogLevel(LogLevel.INFO);
|
|
20199
|
+
var serverImpl = server;
|
|
20200
|
+
var startTimes = new Map();
|
|
20201
|
+
|
|
20202
|
+
// Use global middleware to log requests
|
|
20203
|
+
server.use((req, res, next) => {
|
|
20204
|
+
var _res$sendStream;
|
|
20205
|
+
var startTime = Date.now();
|
|
20206
|
+
startTimes.set(req.requestId, startTime);
|
|
20207
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_REQUEST_RECEIVED, Messages.DEBUG_SERVER_RECEIVED_REQUEST, formatMessageData({
|
|
20208
|
+
requestId: req.requestId,
|
|
20209
|
+
path: req.path,
|
|
20210
|
+
body: req.body,
|
|
20211
|
+
origin: req.origin,
|
|
20212
|
+
headers: req.headers,
|
|
20213
|
+
cookies: req.cookies,
|
|
20214
|
+
method: 'POST' // iframe requests are always POST-like
|
|
20215
|
+
}));
|
|
20216
|
+
|
|
20217
|
+
// Store original send methods
|
|
20218
|
+
var originalSend = res.send.bind(res);
|
|
20219
|
+
var originalJson = res.json.bind(res);
|
|
20220
|
+
var originalSendFile = res.sendFile.bind(res);
|
|
20221
|
+
var originalSendStream = (_res$sendStream = res.sendStream) === null || _res$sendStream === void 0 ? void 0 : _res$sendStream.bind(res);
|
|
20222
|
+
var originalStatus = res.status.bind(res);
|
|
20223
|
+
var originalSetHeader = res.setHeader.bind(res);
|
|
20224
|
+
|
|
20225
|
+
// Track status code changes
|
|
20226
|
+
res.status = function (code) {
|
|
20227
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SETTING_STATUS_CODE, {
|
|
20228
|
+
requestId: req.requestId,
|
|
20229
|
+
path: req.path,
|
|
20230
|
+
statusCode: code
|
|
20231
|
+
});
|
|
20232
|
+
return originalStatus(code);
|
|
20233
|
+
};
|
|
20234
|
+
|
|
20235
|
+
// Track header changes
|
|
20236
|
+
res.setHeader = function (name, value) {
|
|
20237
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SETTING_HEADER, {
|
|
20238
|
+
requestId: req.requestId,
|
|
20239
|
+
path: req.path,
|
|
20240
|
+
header: name,
|
|
20241
|
+
value: Array.isArray(value) ? value.join(', ') : String(value)
|
|
20242
|
+
});
|
|
20243
|
+
return originalSetHeader(name, value);
|
|
20244
|
+
};
|
|
20245
|
+
|
|
20246
|
+
// Override send method
|
|
20247
|
+
res.send = /*#__PURE__*/function () {
|
|
20248
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, options) {
|
|
20249
|
+
var duration;
|
|
20250
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
20251
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20252
|
+
case 0:
|
|
20253
|
+
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
20254
|
+
startTimes.delete(req.requestId);
|
|
20255
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_RESPONSE, formatMessageData({
|
|
20256
|
+
requestId: req.requestId,
|
|
20257
|
+
path: req.path,
|
|
20258
|
+
status: res.statusCode,
|
|
20259
|
+
statusText: getStatusText(res.statusCode),
|
|
20260
|
+
requireAck: options === null || options === void 0 ? void 0 : options.requireAck,
|
|
20261
|
+
headers: res.headers,
|
|
20262
|
+
data,
|
|
20263
|
+
duration: `${duration}ms`
|
|
20264
|
+
}));
|
|
20265
|
+
return _context.abrupt("return", originalSend(data, options));
|
|
20266
|
+
case 1:
|
|
20267
|
+
case "end":
|
|
20268
|
+
return _context.stop();
|
|
20269
|
+
}
|
|
20270
|
+
}, _callee);
|
|
20271
|
+
}));
|
|
20272
|
+
return function (_x, _x2) {
|
|
20273
|
+
return _ref.apply(this, arguments);
|
|
20274
|
+
};
|
|
20275
|
+
}();
|
|
20276
|
+
|
|
20277
|
+
// Override json method
|
|
20278
|
+
res.json = /*#__PURE__*/function () {
|
|
20279
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, options) {
|
|
20280
|
+
var duration;
|
|
20281
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
20282
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
20283
|
+
case 0:
|
|
20284
|
+
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
20285
|
+
startTimes.delete(req.requestId);
|
|
20286
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_JSON_RESPONSE, formatMessageData({
|
|
20287
|
+
requestId: req.requestId,
|
|
20288
|
+
path: req.path,
|
|
20289
|
+
status: res.statusCode,
|
|
20290
|
+
statusText: getStatusText(res.statusCode),
|
|
20291
|
+
requireAck: options === null || options === void 0 ? void 0 : options.requireAck,
|
|
20292
|
+
headers: res.headers,
|
|
20293
|
+
data,
|
|
20294
|
+
duration: `${duration}ms`
|
|
20295
|
+
}));
|
|
20296
|
+
return _context2.abrupt("return", originalJson(data, options));
|
|
20297
|
+
case 1:
|
|
20298
|
+
case "end":
|
|
20299
|
+
return _context2.stop();
|
|
20300
|
+
}
|
|
20301
|
+
}, _callee2);
|
|
20302
|
+
}));
|
|
20303
|
+
return function (_x3, _x4) {
|
|
20304
|
+
return _ref2.apply(this, arguments);
|
|
20305
|
+
};
|
|
20306
|
+
}();
|
|
20307
|
+
|
|
20308
|
+
// Override sendFile method
|
|
20309
|
+
res.sendFile = /*#__PURE__*/function () {
|
|
20310
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(content, options) {
|
|
20311
|
+
var duration;
|
|
20312
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
20313
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
20314
|
+
case 0:
|
|
20315
|
+
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
20316
|
+
startTimes.delete(req.requestId);
|
|
20317
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_FILE, formatMessageData({
|
|
20318
|
+
requestId: req.requestId,
|
|
20319
|
+
path: req.path,
|
|
20320
|
+
status: res.statusCode,
|
|
20321
|
+
statusText: getStatusText(res.statusCode),
|
|
20322
|
+
fileName: options === null || options === void 0 ? void 0 : options.fileName,
|
|
20323
|
+
mimeType: options === null || options === void 0 ? void 0 : options.mimeType,
|
|
20324
|
+
contentLength: typeof content === 'string' ? content.length : (content === null || content === void 0 ? void 0 : content.size) || 0,
|
|
20325
|
+
duration: `${duration}ms`
|
|
20326
|
+
}));
|
|
20327
|
+
return _context3.abrupt("return", originalSendFile(content, options));
|
|
20328
|
+
case 1:
|
|
20329
|
+
case "end":
|
|
20330
|
+
return _context3.stop();
|
|
20331
|
+
}
|
|
20332
|
+
}, _callee3);
|
|
20333
|
+
}));
|
|
20334
|
+
return function (_x5, _x6) {
|
|
20335
|
+
return _ref3.apply(this, arguments);
|
|
20336
|
+
};
|
|
20337
|
+
}();
|
|
20338
|
+
|
|
20339
|
+
// Override sendStream method if exists
|
|
20340
|
+
if (originalSendStream) {
|
|
20341
|
+
res.sendStream = /*#__PURE__*/function () {
|
|
20342
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(stream) {
|
|
20343
|
+
var duration;
|
|
20344
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
20345
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
20346
|
+
case 0:
|
|
20347
|
+
duration = Date.now() - (startTimes.get(req.requestId) || startTime);
|
|
20348
|
+
startTimes.delete(req.requestId);
|
|
20349
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_RESPONSE_SEND, Messages.DEBUG_SERVER_SENDING_STREAM, formatMessageData({
|
|
20350
|
+
requestId: req.requestId,
|
|
20351
|
+
path: req.path,
|
|
20352
|
+
status: res.statusCode,
|
|
20353
|
+
statusText: getStatusText(res.statusCode),
|
|
20354
|
+
streamId: stream === null || stream === void 0 ? void 0 : stream.streamId,
|
|
20355
|
+
duration: `${duration}ms`
|
|
20356
|
+
}));
|
|
20357
|
+
return _context4.abrupt("return", originalSendStream(stream));
|
|
20358
|
+
case 1:
|
|
20359
|
+
case "end":
|
|
20360
|
+
return _context4.stop();
|
|
20361
|
+
}
|
|
20362
|
+
}, _callee4);
|
|
20363
|
+
}));
|
|
20364
|
+
return function (_x7) {
|
|
20365
|
+
return _ref4.apply(this, arguments);
|
|
20366
|
+
};
|
|
20367
|
+
}();
|
|
20368
|
+
}
|
|
20369
|
+
next();
|
|
20370
|
+
});
|
|
20371
|
+
|
|
20372
|
+
/** Hook into MessageDispatcher hooks (no monkey patch). */
|
|
20373
|
+
setupServerMessageDebuggingViaHooks(serverImpl);
|
|
20374
|
+
}
|
|
20375
|
+
|
|
20376
|
+
/**
|
|
20377
|
+
* Setup message-level debugging for server (hook-based, no monkey patch).
|
|
20378
|
+
*/
|
|
20379
|
+
function setupServerMessageDebuggingViaHooks(serverImpl) {
|
|
20380
|
+
var _dispatcher$hooks$aft, _dispatcher$hooks$inb;
|
|
20381
|
+
var dispatcher = serverImpl.messageDispatcher || serverImpl.dispatcher;
|
|
20382
|
+
if (!(dispatcher !== null && dispatcher !== void 0 && dispatcher.hooks)) return;
|
|
20383
|
+
|
|
20384
|
+
/** Outbound messages */
|
|
20385
|
+
if ((_dispatcher$hooks$aft = dispatcher.hooks.afterSend) !== null && _dispatcher$hooks$aft !== void 0 && _dispatcher$hooks$aft.tap) {
|
|
20386
|
+
dispatcher.hooks.afterSend.tap('debug', (_target, _targetOrigin, message) => {
|
|
20387
|
+
var type = message.type;
|
|
20388
|
+
var requestId = message.requestId;
|
|
20389
|
+
var data = message;
|
|
20390
|
+
if (type === MessageType.ACK) {
|
|
20391
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ACK, formatMessageData({
|
|
20392
|
+
requestId,
|
|
20393
|
+
path: data.path
|
|
20394
|
+
}));
|
|
20395
|
+
} else if (type === MessageType.ASYNC) {
|
|
20396
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ASYNC, formatMessageData({
|
|
20397
|
+
requestId,
|
|
20398
|
+
path: data.path
|
|
20399
|
+
}));
|
|
20400
|
+
} else if (type === MessageType.STREAM_START) {
|
|
20401
|
+
var streamBody = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
20402
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_START, formatMessageData({
|
|
20403
|
+
requestId,
|
|
20404
|
+
streamId: streamBody.streamId,
|
|
20405
|
+
streamType: streamBody.type,
|
|
20406
|
+
chunked: streamBody.chunked,
|
|
20407
|
+
autoResolve: streamBody.autoResolve,
|
|
20408
|
+
metadata: streamBody.metadata
|
|
20409
|
+
}));
|
|
20410
|
+
} else if (type === MessageType.STREAM_DATA) {
|
|
20411
|
+
var _streamBody3$data;
|
|
20412
|
+
var _streamBody3 = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
20413
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_DATA, formatMessageData({
|
|
20414
|
+
requestId,
|
|
20415
|
+
streamId: _streamBody3.streamId,
|
|
20416
|
+
done: _streamBody3.done,
|
|
20417
|
+
dataLength: ((_streamBody3$data = _streamBody3.data) === null || _streamBody3$data === void 0 ? void 0 : _streamBody3$data.length) || 0
|
|
20418
|
+
}));
|
|
20419
|
+
} else if (type === MessageType.STREAM_END) {
|
|
20420
|
+
var _streamBody4 = (data === null || data === void 0 ? void 0 : data.body) || {};
|
|
20421
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_STREAM_END, formatMessageData({
|
|
20422
|
+
requestId,
|
|
20423
|
+
streamId: _streamBody4.streamId
|
|
20424
|
+
}));
|
|
20425
|
+
} else if (type === MessageType.ERROR) {
|
|
20426
|
+
logEvent(LogLevel.ERROR, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_ERROR, formatMessageData({
|
|
20427
|
+
requestId,
|
|
20428
|
+
status: data === null || data === void 0 ? void 0 : data.status,
|
|
20429
|
+
statusText: data === null || data === void 0 ? void 0 : data.statusText,
|
|
20430
|
+
error: data === null || data === void 0 ? void 0 : data.error,
|
|
20431
|
+
path: data === null || data === void 0 ? void 0 : data.path
|
|
20432
|
+
}));
|
|
20433
|
+
} else if (type === MessageType.RESPONSE) {
|
|
20434
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_OUTBOUND, Messages.DEBUG_SERVER_SENDING_RESPONSE_VIA_DISPATCHER, formatMessageData({
|
|
20435
|
+
requestId,
|
|
20436
|
+
status: data === null || data === void 0 ? void 0 : data.status,
|
|
20437
|
+
statusText: data === null || data === void 0 ? void 0 : data.statusText,
|
|
20438
|
+
requireAck: data === null || data === void 0 ? void 0 : data.requireAck,
|
|
20439
|
+
path: data === null || data === void 0 ? void 0 : data.path
|
|
20440
|
+
}));
|
|
20441
|
+
}
|
|
20442
|
+
});
|
|
20443
|
+
}
|
|
20444
|
+
|
|
20445
|
+
/** Inbound messages */
|
|
20446
|
+
if ((_dispatcher$hooks$inb = dispatcher.hooks.inbound) !== null && _dispatcher$hooks$inb !== void 0 && _dispatcher$hooks$inb.tap) {
|
|
20447
|
+
dispatcher.hooks.inbound.tap('debug', (data, context) => {
|
|
20448
|
+
if (data.type === MessageType.REQUEST) {
|
|
20449
|
+
logEvent(LogLevel.INFO, DebugEvent.SERVER_MESSAGE_INBOUND, Messages.DEBUG_SERVER_HANDLING_REQUEST, formatMessageData({
|
|
20450
|
+
requestId: data.requestId,
|
|
20451
|
+
path: data.path,
|
|
20452
|
+
origin: context === null || context === void 0 ? void 0 : context.origin,
|
|
20453
|
+
role: data.role,
|
|
20454
|
+
creatorId: data.creatorId
|
|
20455
|
+
}));
|
|
20456
|
+
}
|
|
20457
|
+
});
|
|
20458
|
+
}
|
|
20459
|
+
}
|
|
20460
|
+
|
|
20461
|
+
var debug = /*#__PURE__*/Object.freeze({
|
|
20462
|
+
__proto__: null,
|
|
20463
|
+
setupClientDebugInterceptors: setupClientDebugInterceptors,
|
|
20464
|
+
setupServerDebugListeners: setupServerDebugListeners
|
|
20465
|
+
});
|
|
20466
|
+
|
|
19705
20467
|
exports.AutoAckConstant = AutoAckConstant;
|
|
19706
20468
|
exports.ChannelType = ChannelType;
|
|
19707
20469
|
exports.DebugEvent = DebugEvent;
|