@copart/ops-tool-kit 1.13.0-beta.10 → 1.13.0-beta.12
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/dist/ops-tool-kit.js +531 -18
- package/dist/ops-tool-kit.js.map +1 -1
- package/iframe-webpack-facade.js +25 -0
- package/package.json +5 -3
package/dist/ops-tool-kit.js
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var ReactDOM = require('react-dom');
|
|
7
7
|
var frontEndUtils = require('@copart/front-end-utils');
|
|
8
8
|
var coreComponents = require('@copart/core-components');
|
|
9
|
+
var reactRouterDom = require('react-router-dom');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
12
|
|
|
@@ -47,12 +48,13 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
47
48
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
48
49
|
|
|
49
50
|
const name$1 = "@copart/ops-tool-kit";
|
|
50
|
-
const version$3 = "1.13.0-beta.
|
|
51
|
+
const version$3 = "1.13.0-beta.12";
|
|
51
52
|
const main$1 = "dist/ops-tool-kit.js";
|
|
52
53
|
const style = "dist/ops-tool-kit.css";
|
|
53
54
|
const files = [
|
|
54
55
|
"dist",
|
|
55
|
-
"bin"
|
|
56
|
+
"bin",
|
|
57
|
+
"iframe-webpack-facade.js"
|
|
56
58
|
];
|
|
57
59
|
const bin = {
|
|
58
60
|
"generate-build-meta": "./bin/cli.js"
|
|
@@ -106,7 +108,8 @@ const devDependencies$1 = {
|
|
|
106
108
|
};
|
|
107
109
|
const peerDependencies = {
|
|
108
110
|
"@copart/core-components": "2.3.0-alpha.filters.6",
|
|
109
|
-
react: "*"
|
|
111
|
+
react: "*",
|
|
112
|
+
"react-router-dom": "^5.0.0"
|
|
110
113
|
};
|
|
111
114
|
const dependencies$1 = {
|
|
112
115
|
"@reacting/purist": "0.1.0",
|
|
@@ -2862,10 +2865,10 @@ var BreadcrumbsProvider = /*#__PURE__*/function (_React$Component) {
|
|
|
2862
2865
|
}(React__namespace.Component);
|
|
2863
2866
|
|
|
2864
2867
|
var _class;
|
|
2865
|
-
var _excluded$
|
|
2868
|
+
var _excluded$5 = ["breadcrumbs"];
|
|
2866
2869
|
var getCrumbProps = function getCrumbProps(props) {
|
|
2867
2870
|
props.breadcrumbs;
|
|
2868
|
-
var crumbProps = _objectWithoutProperties(props, _excluded$
|
|
2871
|
+
var crumbProps = _objectWithoutProperties(props, _excluded$5);
|
|
2869
2872
|
return crumbProps;
|
|
2870
2873
|
};
|
|
2871
2874
|
var Crumb$1 = withBreadcrumbs(_class = /*#__PURE__*/function (_React$Component) {
|
|
@@ -23483,7 +23486,7 @@ var RoleSelector$2 = function RoleSelector(_ref) {
|
|
|
23483
23486
|
}));
|
|
23484
23487
|
};
|
|
23485
23488
|
|
|
23486
|
-
var _excluded$
|
|
23489
|
+
var _excluded$4 = ["selectedYard", "name", "handleChange", "yardOptions", "label"];
|
|
23487
23490
|
var getDescription = function getDescription(yardOptions) {
|
|
23488
23491
|
return function (code) {
|
|
23489
23492
|
return yardOptions[code].yard_number;
|
|
@@ -23499,7 +23502,7 @@ var YardNumberMenu$2 = function YardNumberMenu(_ref) {
|
|
|
23499
23502
|
handleChange = _ref.handleChange,
|
|
23500
23503
|
yardOptions = _ref.yardOptions,
|
|
23501
23504
|
label = _ref.label,
|
|
23502
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
23505
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$4);
|
|
23503
23506
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
23504
23507
|
className: "utilities_ops-app-frame_AppBarComponent_Settings_SettingsView--col-1-1"
|
|
23505
23508
|
}, /*#__PURE__*/React__default["default"].createElement(coreComponents.AutoSelect, _extends$1({}, otherProps, {
|
|
@@ -24443,14 +24446,14 @@ var HierarchyMenu = function HierarchyMenu(props) {
|
|
|
24443
24446
|
});
|
|
24444
24447
|
};
|
|
24445
24448
|
|
|
24446
|
-
var _excluded$
|
|
24449
|
+
var _excluded$3 = ["value", "handleChange", "yardOptions", "label", "disabled"];
|
|
24447
24450
|
var YardNumberMenu$1 = function YardNumberMenu(_ref) {
|
|
24448
24451
|
var value = _ref.value,
|
|
24449
24452
|
handleChange = _ref.handleChange,
|
|
24450
24453
|
yardOptions = _ref.yardOptions;
|
|
24451
24454
|
_ref.label;
|
|
24452
24455
|
var disabled = _ref.disabled,
|
|
24453
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
24456
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$3);
|
|
24454
24457
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
24455
24458
|
className: "utilities_ops-app-frame_AppBarComponent_Settings_SettingsView--col-1-1"
|
|
24456
24459
|
}, /*#__PURE__*/React__default["default"].createElement(coreComponents.AutoSelect, _extends$1({}, otherProps, {
|
|
@@ -25750,7 +25753,7 @@ var useWindowSize = function useWindowSize() {
|
|
|
25750
25753
|
return windowSize;
|
|
25751
25754
|
};
|
|
25752
25755
|
|
|
25753
|
-
var _excluded$
|
|
25756
|
+
var _excluded$2 = ["count", "current", "showNavButtons", "onLeftButtonClick", "onRightButtonClick", "saveActionComponentState", "ActionComponent", "notificationsTopContainerRef", "mobileNotificationsTopContainerRef", "setNotificationHeightFlag"];
|
|
25754
25757
|
var alertBackgroundColorMapping = {
|
|
25755
25758
|
alert: '#fab9b9',
|
|
25756
25759
|
warning: '#f5f5cb',
|
|
@@ -25819,7 +25822,7 @@ var Banner = function Banner(props) {
|
|
|
25819
25822
|
notificationsTopContainerRef = props.notificationsTopContainerRef,
|
|
25820
25823
|
mobileNotificationsTopContainerRef = props.mobileNotificationsTopContainerRef,
|
|
25821
25824
|
setNotificationHeightFlag = props.setNotificationHeightFlag,
|
|
25822
|
-
notification = _objectWithoutProperties(props, _excluded$
|
|
25825
|
+
notification = _objectWithoutProperties(props, _excluded$2);
|
|
25823
25826
|
var dismissibleFlag = notification.dismissibleFlag,
|
|
25824
25827
|
onDismiss = notification.onDismiss,
|
|
25825
25828
|
startsAt = notification.startsAt,
|
|
@@ -64641,7 +64644,7 @@ AppFrame.defaultProps = {
|
|
|
64641
64644
|
navItems: []
|
|
64642
64645
|
};
|
|
64643
64646
|
|
|
64644
|
-
var _excluded = ["fromPhone", "toPhone", "appCode", "entityType", "lotAttributes"];
|
|
64647
|
+
var _excluded$1 = ["fromPhone", "toPhone", "appCode", "entityType", "lotAttributes"];
|
|
64645
64648
|
var logOutboundCalls = /*#__PURE__*/function () {
|
|
64646
64649
|
var _ref = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee(data) {
|
|
64647
64650
|
var _storage$getLocalItem;
|
|
@@ -64677,7 +64680,7 @@ var CallLogger = React__default["default"].memo(function (_ref2) {
|
|
|
64677
64680
|
entityType = _ref2$entityType === void 0 ? '' : _ref2$entityType,
|
|
64678
64681
|
_ref2$lotAttributes = _ref2.lotAttributes,
|
|
64679
64682
|
lotAttributes = _ref2$lotAttributes === void 0 ? {} : _ref2$lotAttributes,
|
|
64680
|
-
props = _objectWithoutProperties(_ref2, _excluded);
|
|
64683
|
+
props = _objectWithoutProperties(_ref2, _excluded$1);
|
|
64681
64684
|
var _useState = React.useState({
|
|
64682
64685
|
error: null,
|
|
64683
64686
|
success: null
|
|
@@ -68102,6 +68105,7 @@ function ContextualHelp(_ref) {
|
|
|
68102
68105
|
})));
|
|
68103
68106
|
}
|
|
68104
68107
|
|
|
68108
|
+
var _excluded = ["signal"];
|
|
68105
68109
|
var pending = new Map();
|
|
68106
68110
|
function requestId() {
|
|
68107
68111
|
return "bridge-".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 9));
|
|
@@ -68122,7 +68126,8 @@ function handleMessage(event) {
|
|
|
68122
68126
|
if (!id || !pending.has(id)) return;
|
|
68123
68127
|
var _pending$get = pending.get(id),
|
|
68124
68128
|
resolve = _pending$get.resolve,
|
|
68125
|
-
reject = _pending$get.reject
|
|
68129
|
+
reject = _pending$get.reject,
|
|
68130
|
+
pendingResponseType = _pending$get.responseType;
|
|
68126
68131
|
pending.delete(id);
|
|
68127
68132
|
switch (data.eventType) {
|
|
68128
68133
|
case 'FETCH_RESPONSE':
|
|
@@ -68136,6 +68141,25 @@ function handleMessage(event) {
|
|
|
68136
68141
|
} : eventProps.error;
|
|
68137
68142
|
reject(err);
|
|
68138
68143
|
} else {
|
|
68144
|
+
var _eventProps$result;
|
|
68145
|
+
var resultData = (_eventProps$result = eventProps.result) === null || _eventProps$result === void 0 ? void 0 : _eventProps$result.data;
|
|
68146
|
+
if (pendingResponseType === 'arraybuffer') {
|
|
68147
|
+
if (resultData instanceof ArrayBuffer) {
|
|
68148
|
+
console.log('[iframe-bridge/transport] FETCH_RESPONSE binary OK', {
|
|
68149
|
+
requestId: id,
|
|
68150
|
+
byteLength: resultData.byteLength
|
|
68151
|
+
});
|
|
68152
|
+
} else {
|
|
68153
|
+
// Shell returned non-binary for a request that expected arraybuffer.
|
|
68154
|
+
// This means Step 2 (shell) has not been deployed yet, or the shell
|
|
68155
|
+
// is not forwarding responseType to its own axios call.
|
|
68156
|
+
console.warn('[iframe-bridge/transport] FETCH_RESPONSE expected ArrayBuffer but got non-binary — shell may not support responseType yet', {
|
|
68157
|
+
requestId: id,
|
|
68158
|
+
actualType: _typeof$1(resultData),
|
|
68159
|
+
isNull: resultData == null
|
|
68160
|
+
});
|
|
68161
|
+
}
|
|
68162
|
+
}
|
|
68139
68163
|
resolve(eventProps.result);
|
|
68140
68164
|
}
|
|
68141
68165
|
break;
|
|
@@ -68154,13 +68178,57 @@ if (typeof window !== 'undefined') {
|
|
|
68154
68178
|
window.addEventListener('message', handleMessage, false);
|
|
68155
68179
|
}
|
|
68156
68180
|
function sendFetchRequest(payload) {
|
|
68181
|
+
var signal = payload.signal,
|
|
68182
|
+
restPayload = _objectWithoutProperties(payload, _excluded);
|
|
68157
68183
|
return new Promise(function (resolve, reject) {
|
|
68184
|
+
// Reject immediately if the signal is already aborted before we even send
|
|
68185
|
+
if (signal !== null && signal !== void 0 && signal.aborted) {
|
|
68186
|
+
console.log('[iframe-bridge/transport] FETCH_REQUEST aborted before send', {
|
|
68187
|
+
url: payload.url
|
|
68188
|
+
});
|
|
68189
|
+
reject(new DOMException('Request aborted', 'AbortError'));
|
|
68190
|
+
return;
|
|
68191
|
+
}
|
|
68158
68192
|
var id = requestId();
|
|
68193
|
+
// store responseType so the response handler can detect a binary/non-binary mismatch
|
|
68159
68194
|
pending.set(id, {
|
|
68160
68195
|
resolve: resolve,
|
|
68161
|
-
reject: reject
|
|
68196
|
+
reject: reject,
|
|
68197
|
+
responseType: payload.responseType
|
|
68162
68198
|
});
|
|
68163
|
-
|
|
68199
|
+
if (payload.responseType || payload.timeout != null || payload.withCredentials != null) {
|
|
68200
|
+
console.log('[iframe-bridge/transport] sending FETCH_REQUEST with extended options', {
|
|
68201
|
+
requestId: id,
|
|
68202
|
+
url: payload.url,
|
|
68203
|
+
responseType: payload.responseType,
|
|
68204
|
+
timeout: payload.timeout,
|
|
68205
|
+
withCredentials: payload.withCredentials
|
|
68206
|
+
});
|
|
68207
|
+
}
|
|
68208
|
+
|
|
68209
|
+
// signal cannot be transferred through postMessage — handle abort locally
|
|
68210
|
+
if (signal) {
|
|
68211
|
+
var onAbort = function onAbort() {
|
|
68212
|
+
if (pending.has(id)) {
|
|
68213
|
+
pending.delete(id);
|
|
68214
|
+
console.log('[iframe-bridge/transport] FETCH_REQUEST aborted mid-flight', {
|
|
68215
|
+
requestId: id,
|
|
68216
|
+
url: payload.url
|
|
68217
|
+
});
|
|
68218
|
+
// Notify the shell so it can cancel its own request if wired up
|
|
68219
|
+
post('CANCEL_REQUEST', {
|
|
68220
|
+
requestId: id
|
|
68221
|
+
});
|
|
68222
|
+
reject(new DOMException('Request aborted', 'AbortError'));
|
|
68223
|
+
}
|
|
68224
|
+
};
|
|
68225
|
+
signal.addEventListener('abort', onAbort, {
|
|
68226
|
+
once: true
|
|
68227
|
+
});
|
|
68228
|
+
}
|
|
68229
|
+
|
|
68230
|
+
// signal is intentionally excluded from the message — it's a non-serialisable DOM object
|
|
68231
|
+
post('FETCH_REQUEST', _objectSpread2(_objectSpread2({}, restPayload), {}, {
|
|
68164
68232
|
requestId: id
|
|
68165
68233
|
}));
|
|
68166
68234
|
});
|
|
@@ -68662,15 +68730,39 @@ function request(config) {
|
|
|
68662
68730
|
params = finalConfig.params,
|
|
68663
68731
|
data = finalConfig.data,
|
|
68664
68732
|
_finalConfig$headers = finalConfig.headers,
|
|
68665
|
-
headers = _finalConfig$headers === void 0 ? {} : _finalConfig$headers
|
|
68733
|
+
headers = _finalConfig$headers === void 0 ? {} : _finalConfig$headers,
|
|
68734
|
+
responseType = finalConfig.responseType,
|
|
68735
|
+
timeout = finalConfig.timeout,
|
|
68736
|
+
withCredentials = finalConfig.withCredentials,
|
|
68737
|
+
signal = finalConfig.signal;
|
|
68738
|
+
if (responseType || timeout != null || withCredentials != null || signal) {
|
|
68739
|
+
console.log('[iframe-bridge/fetcher] request with extended options', {
|
|
68740
|
+
url: url,
|
|
68741
|
+
responseType: responseType,
|
|
68742
|
+
timeout: timeout,
|
|
68743
|
+
withCredentials: withCredentials,
|
|
68744
|
+
hasSignal: Boolean(signal)
|
|
68745
|
+
});
|
|
68746
|
+
}
|
|
68666
68747
|
return sendFetchRequest({
|
|
68667
68748
|
method: (method || 'get').toLowerCase(),
|
|
68668
68749
|
url: url,
|
|
68669
68750
|
params: params,
|
|
68670
68751
|
data: data,
|
|
68671
|
-
headers: headers
|
|
68752
|
+
headers: headers,
|
|
68753
|
+
responseType: responseType,
|
|
68754
|
+
timeout: timeout,
|
|
68755
|
+
withCredentials: withCredentials,
|
|
68756
|
+
signal: signal
|
|
68672
68757
|
});
|
|
68673
68758
|
}).then(function (result) {
|
|
68759
|
+
if (result.data instanceof ArrayBuffer) {
|
|
68760
|
+
console.log('[iframe-bridge/fetcher] binary response received', {
|
|
68761
|
+
url: config.url,
|
|
68762
|
+
byteLength: result.data.byteLength,
|
|
68763
|
+
type: 'ArrayBuffer'
|
|
68764
|
+
});
|
|
68765
|
+
}
|
|
68674
68766
|
return applyResponseInterceptors({
|
|
68675
68767
|
data: result.data,
|
|
68676
68768
|
status: result.status,
|
|
@@ -69472,6 +69564,419 @@ var iframeFacade = {
|
|
|
69472
69564
|
}
|
|
69473
69565
|
};
|
|
69474
69566
|
|
|
69567
|
+
function normalizeIframePath(uri) {
|
|
69568
|
+
if (uri === '' || uri == null) return '/';
|
|
69569
|
+
return uri.startsWith('/') ? uri : "/".concat(uri);
|
|
69570
|
+
}
|
|
69571
|
+
|
|
69572
|
+
function serializeNavItems(items) {
|
|
69573
|
+
if (!Array.isArray(items)) return [];
|
|
69574
|
+
return items.map(function (item) {
|
|
69575
|
+
var serialized = {
|
|
69576
|
+
name: item.name,
|
|
69577
|
+
route: item.route
|
|
69578
|
+
};
|
|
69579
|
+
if (item.icon && typeof item.icon === 'string') serialized.icon = item.icon;
|
|
69580
|
+
if (typeof item.disabled === 'function') {
|
|
69581
|
+
try {
|
|
69582
|
+
serialized.disabled = item.disabled();
|
|
69583
|
+
} catch (_) {
|
|
69584
|
+
serialized.disabled = false;
|
|
69585
|
+
}
|
|
69586
|
+
} else if (typeof item.disabled === 'boolean') {
|
|
69587
|
+
serialized.disabled = item.disabled;
|
|
69588
|
+
}
|
|
69589
|
+
if (typeof item.hidden === 'function') {
|
|
69590
|
+
try {
|
|
69591
|
+
serialized.hidden = item.hidden();
|
|
69592
|
+
} catch (_) {
|
|
69593
|
+
serialized.hidden = false;
|
|
69594
|
+
}
|
|
69595
|
+
} else if (typeof item.hidden === 'boolean') {
|
|
69596
|
+
serialized.hidden = item.hidden;
|
|
69597
|
+
}
|
|
69598
|
+
if (item.isLandingPage) serialized.isLandingPage = true;
|
|
69599
|
+
if (item.subMenuItems && item.subMenuItems.length > 0) {
|
|
69600
|
+
serialized.subMenuItems = serializeNavItems(item.subMenuItems);
|
|
69601
|
+
}
|
|
69602
|
+
return serialized;
|
|
69603
|
+
});
|
|
69604
|
+
}
|
|
69605
|
+
|
|
69606
|
+
function IframeRouteSync(_ref) {
|
|
69607
|
+
var _ref$updateUriIsPath = _ref.updateUriIsPath,
|
|
69608
|
+
updateUriIsPath = _ref$updateUriIsPath === void 0 ? false : _ref$updateUriIsPath,
|
|
69609
|
+
_ref$suppressEcho = _ref.suppressEcho,
|
|
69610
|
+
suppressEcho = _ref$suppressEcho === void 0 ? true : _ref$suppressEcho;
|
|
69611
|
+
var history = reactRouterDom.useHistory();
|
|
69612
|
+
var location = reactRouterDom.useLocation();
|
|
69613
|
+
var initialRef = React.useRef(true);
|
|
69614
|
+
var suppressUpdateUriRef = React.useRef(false);
|
|
69615
|
+
React.useEffect(function () {
|
|
69616
|
+
var remove = addMessageListener(function (data) {
|
|
69617
|
+
if (data.eventType === 'LOAD_URI' && data.eventProps) {
|
|
69618
|
+
var path = normalizeIframePath(data.eventProps.uri);
|
|
69619
|
+
if (suppressEcho) suppressUpdateUriRef.current = true;
|
|
69620
|
+
history.push(path);
|
|
69621
|
+
}
|
|
69622
|
+
});
|
|
69623
|
+
return remove;
|
|
69624
|
+
}, [history, suppressEcho]);
|
|
69625
|
+
React.useEffect(function () {
|
|
69626
|
+
if (initialRef.current) {
|
|
69627
|
+
initialRef.current = false;
|
|
69628
|
+
return;
|
|
69629
|
+
}
|
|
69630
|
+
if (suppressEcho && suppressUpdateUriRef.current) {
|
|
69631
|
+
suppressUpdateUriRef.current = false;
|
|
69632
|
+
return;
|
|
69633
|
+
}
|
|
69634
|
+
var pathname = location.pathname || '/';
|
|
69635
|
+
postUpdateUri(pathname, updateUriIsPath);
|
|
69636
|
+
}, [location.pathname, updateUriIsPath, suppressEcho]);
|
|
69637
|
+
return null;
|
|
69638
|
+
}
|
|
69639
|
+
|
|
69640
|
+
function defaultToolkitEnv() {
|
|
69641
|
+
return {
|
|
69642
|
+
STACK: process.env.STACK,
|
|
69643
|
+
APP_NAME: process.env.APP_NAME,
|
|
69644
|
+
CORE_CONFIG_URI: process.env.CORE_CONFIG_URI,
|
|
69645
|
+
CONFIG_URI: process.env.CONFIG_URI
|
|
69646
|
+
};
|
|
69647
|
+
}
|
|
69648
|
+
function AppEnvSender(_ref) {
|
|
69649
|
+
var toolkitEnv = _ref.toolkitEnv,
|
|
69650
|
+
_ref$mihelpAgentProps = _ref.mihelpAgentProps,
|
|
69651
|
+
mihelpAgentProps = _ref$mihelpAgentProps === void 0 ? null : _ref$mihelpAgentProps;
|
|
69652
|
+
var sentRef = React.useRef(false);
|
|
69653
|
+
React.useEffect(function () {
|
|
69654
|
+
if (sentRef.current) return;
|
|
69655
|
+
sentRef.current = true;
|
|
69656
|
+
postAppEnv(toolkitEnv || defaultToolkitEnv(), mihelpAgentProps);
|
|
69657
|
+
}, [toolkitEnv, mihelpAgentProps]);
|
|
69658
|
+
return null;
|
|
69659
|
+
}
|
|
69660
|
+
|
|
69661
|
+
function NavConfigSender(_ref) {
|
|
69662
|
+
var navItemsLoader = _ref.navItemsLoader,
|
|
69663
|
+
onError = _ref.onError;
|
|
69664
|
+
var sentRef = React.useRef(false);
|
|
69665
|
+
React.useEffect(function () {
|
|
69666
|
+
if (sentRef.current || !navItemsLoader) return;
|
|
69667
|
+
sentRef.current = true;
|
|
69668
|
+
navItemsLoader().then(function (mod) {
|
|
69669
|
+
var items = mod && (mod.default != null ? mod.default : mod);
|
|
69670
|
+
postNavConfig(serializeNavItems(items));
|
|
69671
|
+
}).catch(function (err) {
|
|
69672
|
+
if (onError) {
|
|
69673
|
+
onError(err);
|
|
69674
|
+
} else {
|
|
69675
|
+
console.warn('[Iframe] Failed to load navItems:', err);
|
|
69676
|
+
}
|
|
69677
|
+
});
|
|
69678
|
+
}, [navItemsLoader, onError]);
|
|
69679
|
+
return null;
|
|
69680
|
+
}
|
|
69681
|
+
|
|
69682
|
+
var defaultContentStyle = {
|
|
69683
|
+
height: '100%',
|
|
69684
|
+
display: 'flex',
|
|
69685
|
+
flexDirection: 'column',
|
|
69686
|
+
overflow: 'hidden'
|
|
69687
|
+
};
|
|
69688
|
+
function IframeAppRootInner(_ref) {
|
|
69689
|
+
var children = _ref.children,
|
|
69690
|
+
contentStyle = _ref.contentStyle,
|
|
69691
|
+
toolkitEnv = _ref.toolkitEnv,
|
|
69692
|
+
mihelpAgentProps = _ref.mihelpAgentProps,
|
|
69693
|
+
navItemsLoader = _ref.navItemsLoader,
|
|
69694
|
+
navConfigOnError = _ref.navConfigOnError,
|
|
69695
|
+
updateUriIsPath = _ref.updateUriIsPath,
|
|
69696
|
+
suppressRouteSyncEcho = _ref.suppressRouteSyncEcho;
|
|
69697
|
+
var history = reactRouterDom.useHistory();
|
|
69698
|
+
return /*#__PURE__*/React__default["default"].createElement(CrumbProvider, {
|
|
69699
|
+
navigate: function navigate(path) {
|
|
69700
|
+
return history.push(path);
|
|
69701
|
+
}
|
|
69702
|
+
}, /*#__PURE__*/React__default["default"].createElement(AppEnvSender, {
|
|
69703
|
+
toolkitEnv: toolkitEnv,
|
|
69704
|
+
mihelpAgentProps: mihelpAgentProps
|
|
69705
|
+
}), /*#__PURE__*/React__default["default"].createElement(IframeRouteSync, {
|
|
69706
|
+
updateUriIsPath: updateUriIsPath,
|
|
69707
|
+
suppressEcho: suppressRouteSyncEcho
|
|
69708
|
+
}), navItemsLoader ? /*#__PURE__*/React__default["default"].createElement(NavConfigSender, {
|
|
69709
|
+
navItemsLoader: navItemsLoader,
|
|
69710
|
+
onError: navConfigOnError
|
|
69711
|
+
}) : null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
69712
|
+
style: contentStyle || defaultContentStyle
|
|
69713
|
+
}, children));
|
|
69714
|
+
}
|
|
69715
|
+
function IframeAppRoot(_ref2) {
|
|
69716
|
+
var _ref2$initialUri = _ref2.initialUri,
|
|
69717
|
+
initialUri = _ref2$initialUri === void 0 ? '/' : _ref2$initialUri,
|
|
69718
|
+
children = _ref2.children,
|
|
69719
|
+
contentStyle = _ref2.contentStyle,
|
|
69720
|
+
toolkitEnv = _ref2.toolkitEnv,
|
|
69721
|
+
_ref2$mihelpAgentProp = _ref2.mihelpAgentProps,
|
|
69722
|
+
mihelpAgentProps = _ref2$mihelpAgentProp === void 0 ? null : _ref2$mihelpAgentProp,
|
|
69723
|
+
navItemsLoader = _ref2.navItemsLoader,
|
|
69724
|
+
navConfigOnError = _ref2.navConfigOnError,
|
|
69725
|
+
_ref2$updateUriIsPath = _ref2.updateUriIsPath,
|
|
69726
|
+
updateUriIsPath = _ref2$updateUriIsPath === void 0 ? false : _ref2$updateUriIsPath,
|
|
69727
|
+
_ref2$suppressRouteSy = _ref2.suppressRouteSyncEcho,
|
|
69728
|
+
suppressRouteSyncEcho = _ref2$suppressRouteSy === void 0 ? true : _ref2$suppressRouteSy;
|
|
69729
|
+
var initialPath = normalizeIframePath(initialUri);
|
|
69730
|
+
return /*#__PURE__*/React__default["default"].createElement(reactRouterDom.MemoryRouter, {
|
|
69731
|
+
initialEntries: [initialPath],
|
|
69732
|
+
initialIndex: 0
|
|
69733
|
+
}, /*#__PURE__*/React__default["default"].createElement(IframeAppRootInner, {
|
|
69734
|
+
contentStyle: contentStyle,
|
|
69735
|
+
toolkitEnv: toolkitEnv,
|
|
69736
|
+
mihelpAgentProps: mihelpAgentProps,
|
|
69737
|
+
navItemsLoader: navItemsLoader,
|
|
69738
|
+
navConfigOnError: navConfigOnError,
|
|
69739
|
+
updateUriIsPath: updateUriIsPath,
|
|
69740
|
+
suppressRouteSyncEcho: suppressRouteSyncEcho
|
|
69741
|
+
}, children));
|
|
69742
|
+
}
|
|
69743
|
+
|
|
69744
|
+
/**
|
|
69745
|
+
* Register a synchronous LOAD_URI listener before async bootstrap loads.
|
|
69746
|
+
* Call this from the app entry (index.js) before dynamic-importing bootstrap.
|
|
69747
|
+
*/
|
|
69748
|
+
function registerEarlyLoadUriListener() {
|
|
69749
|
+
if (typeof window === 'undefined') return;
|
|
69750
|
+
if (window.__IFRAME_EARLY_LOAD_URI_LISTENER_REGISTERED) return;
|
|
69751
|
+
window.__IFRAME_EARLY_LOAD_URI_LISTENER_REGISTERED = true;
|
|
69752
|
+
window.__IFRAME_EARLY_LOAD_URI = null;
|
|
69753
|
+
window.addEventListener('message', function (event) {
|
|
69754
|
+
if (event.data && event.data.eventType === 'LOAD_URI' && event.data.eventProps) {
|
|
69755
|
+
window.__IFRAME_EARLY_LOAD_URI = event.data.eventProps.uri || '/';
|
|
69756
|
+
}
|
|
69757
|
+
});
|
|
69758
|
+
}
|
|
69759
|
+
|
|
69760
|
+
function resolveRootNode(rootSelector) {
|
|
69761
|
+
var selectors = rootSelector ? [rootSelector] : ['#root', '#app'];
|
|
69762
|
+
for (var i = 0; i < selectors.length; i += 1) {
|
|
69763
|
+
var node = document.querySelector(selectors[i]);
|
|
69764
|
+
if (node) return node;
|
|
69765
|
+
}
|
|
69766
|
+
return null;
|
|
69767
|
+
}
|
|
69768
|
+
function isInIframe() {
|
|
69769
|
+
return typeof window !== 'undefined' && window.self !== window.top;
|
|
69770
|
+
}
|
|
69771
|
+
function renderStandaloneError(rootNode, message) {
|
|
69772
|
+
rootNode.innerHTML = "<h1>".concat(message, "</h1>");
|
|
69773
|
+
}
|
|
69774
|
+
function normalizePermissionKeys(permissionKeys) {
|
|
69775
|
+
if (!permissionKeys) return [];
|
|
69776
|
+
return Array.isArray(permissionKeys) ? permissionKeys : [permissionKeys];
|
|
69777
|
+
}
|
|
69778
|
+
function isValidAppConfig(config, validateAppConfig) {
|
|
69779
|
+
if (validateAppConfig) return validateAppConfig(config);
|
|
69780
|
+
return !!config;
|
|
69781
|
+
}
|
|
69782
|
+
function hydrateAppConfig(_x) {
|
|
69783
|
+
return _hydrateAppConfig.apply(this, arguments);
|
|
69784
|
+
}
|
|
69785
|
+
function _hydrateAppConfig() {
|
|
69786
|
+
_hydrateAppConfig = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
69787
|
+
var appName, sendStorageGet, setExtraLocal, fetcher, configFallbackUri, validateAppConfig, appConfig;
|
|
69788
|
+
return _regenerator().w(function (_context) {
|
|
69789
|
+
while (1) switch (_context.n) {
|
|
69790
|
+
case 0:
|
|
69791
|
+
appName = _ref.appName, sendStorageGet = _ref.sendStorageGet, setExtraLocal = _ref.setExtraLocal, fetcher = _ref.fetcher, configFallbackUri = _ref.configFallbackUri, validateAppConfig = _ref.validateAppConfig;
|
|
69792
|
+
_context.n = 1;
|
|
69793
|
+
return sendStorageGet({
|
|
69794
|
+
op: 'getLocalItem',
|
|
69795
|
+
key: "".concat(appName, ":config")
|
|
69796
|
+
});
|
|
69797
|
+
case 1:
|
|
69798
|
+
appConfig = _context.v;
|
|
69799
|
+
if (!(!isValidAppConfig(appConfig, validateAppConfig) && configFallbackUri && fetcher)) {
|
|
69800
|
+
_context.n = 3;
|
|
69801
|
+
break;
|
|
69802
|
+
}
|
|
69803
|
+
_context.n = 2;
|
|
69804
|
+
return fetcher.getConfig(configFallbackUri);
|
|
69805
|
+
case 2:
|
|
69806
|
+
appConfig = _context.v;
|
|
69807
|
+
case 3:
|
|
69808
|
+
if (isValidAppConfig(appConfig, validateAppConfig)) {
|
|
69809
|
+
setExtraLocal("".concat(appName, ":config"), appConfig);
|
|
69810
|
+
}
|
|
69811
|
+
case 4:
|
|
69812
|
+
return _context.a(2);
|
|
69813
|
+
}
|
|
69814
|
+
}, _callee);
|
|
69815
|
+
}));
|
|
69816
|
+
return _hydrateAppConfig.apply(this, arguments);
|
|
69817
|
+
}
|
|
69818
|
+
function hydratePermissions(_x2) {
|
|
69819
|
+
return _hydratePermissions.apply(this, arguments);
|
|
69820
|
+
}
|
|
69821
|
+
/**
|
|
69822
|
+
* Bootstrap an iframe-embedded portal app: init bridge data from shell, then render.
|
|
69823
|
+
*
|
|
69824
|
+
* @param {object} options
|
|
69825
|
+
* @param {string} [options.appName] - Defaults to process.env.APP_NAME
|
|
69826
|
+
* @param {string|string[]} [options.permissionKeys] - Shell localStorage permission key(s)
|
|
69827
|
+
* @param {string} [options.rootSelector] - Root element selector (default: #root then #app)
|
|
69828
|
+
* @param {(initData: *) => void} [options.onInitCache] - Called after setInitCache (e.g. initStoreData)
|
|
69829
|
+
* @param {(initialUri: string, rootNode: HTMLElement) => void} options.render - App render callback
|
|
69830
|
+
* @param {'render'|'error'|'skip'} [options.standaloneMode='render'] - Behavior when not in iframe
|
|
69831
|
+
* @param {(rootNode: HTMLElement) => void} [options.standaloneRender] - Custom standalone UI
|
|
69832
|
+
* @param {string} [options.standaloneErrorMessage] - Message when standaloneMode is 'error'
|
|
69833
|
+
* @param {boolean} [options.fetchConfigFromShell=true] - Fetch app config/permissions from shell
|
|
69834
|
+
* @param {string} [options.configFallbackUri] - Defaults to process.env.CONFIG_URI
|
|
69835
|
+
* @param {(config: *) => boolean} [options.validateAppConfig] - Config validity check before setExtraLocal
|
|
69836
|
+
* @param {boolean} [options.permissionsOnlyIfArray=true] - Only set permissions when shell returns an array
|
|
69837
|
+
*/
|
|
69838
|
+
function _hydratePermissions() {
|
|
69839
|
+
_hydratePermissions = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee3(_ref2) {
|
|
69840
|
+
var permissionKeys, sendStorageGet, setExtraLocal, permissionsOnlyIfArray, keys;
|
|
69841
|
+
return _regenerator().w(function (_context3) {
|
|
69842
|
+
while (1) switch (_context3.n) {
|
|
69843
|
+
case 0:
|
|
69844
|
+
permissionKeys = _ref2.permissionKeys, sendStorageGet = _ref2.sendStorageGet, setExtraLocal = _ref2.setExtraLocal, permissionsOnlyIfArray = _ref2.permissionsOnlyIfArray;
|
|
69845
|
+
keys = normalizePermissionKeys(permissionKeys);
|
|
69846
|
+
_context3.n = 1;
|
|
69847
|
+
return Promise.all(keys.map(/*#__PURE__*/function () {
|
|
69848
|
+
var _ref3 = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee2(key) {
|
|
69849
|
+
var perms;
|
|
69850
|
+
return _regenerator().w(function (_context2) {
|
|
69851
|
+
while (1) switch (_context2.n) {
|
|
69852
|
+
case 0:
|
|
69853
|
+
_context2.n = 1;
|
|
69854
|
+
return sendStorageGet({
|
|
69855
|
+
op: 'getLocalItem',
|
|
69856
|
+
key: key
|
|
69857
|
+
});
|
|
69858
|
+
case 1:
|
|
69859
|
+
perms = _context2.v;
|
|
69860
|
+
if (!(permissionsOnlyIfArray && !Array.isArray(perms))) {
|
|
69861
|
+
_context2.n = 2;
|
|
69862
|
+
break;
|
|
69863
|
+
}
|
|
69864
|
+
return _context2.a(2);
|
|
69865
|
+
case 2:
|
|
69866
|
+
if (perms != null) setExtraLocal(key, perms);
|
|
69867
|
+
case 3:
|
|
69868
|
+
return _context2.a(2);
|
|
69869
|
+
}
|
|
69870
|
+
}, _callee2);
|
|
69871
|
+
}));
|
|
69872
|
+
return function (_x4) {
|
|
69873
|
+
return _ref3.apply(this, arguments);
|
|
69874
|
+
};
|
|
69875
|
+
}()));
|
|
69876
|
+
case 1:
|
|
69877
|
+
return _context3.a(2);
|
|
69878
|
+
}
|
|
69879
|
+
}, _callee3);
|
|
69880
|
+
}));
|
|
69881
|
+
return _hydratePermissions.apply(this, arguments);
|
|
69882
|
+
}
|
|
69883
|
+
function bootstrapIframeApp(_x3) {
|
|
69884
|
+
return _bootstrapIframeApp.apply(this, arguments);
|
|
69885
|
+
}
|
|
69886
|
+
function _bootstrapIframeApp() {
|
|
69887
|
+
_bootstrapIframeApp = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
69888
|
+
var _ref4, _ref4$appName, appName, permissionKeys, rootSelector, onInitCache, render, _ref4$standaloneMode, standaloneMode, standaloneRender, _ref4$standaloneError, standaloneErrorMessage, _ref4$fetchConfigFrom, fetchConfigFromShell, _ref4$configFallbackU, configFallbackUri, validateAppConfig, _ref4$permissionsOnly, permissionsOnlyIfArray, rootNode, bridge, fetcher, getInitialUri, getInitData, setInitCache, setExtraLocal, sendStorageGet, setAppName, _yield$Promise$all, _yield$Promise$all2, initialUri, initData, tasks, _t;
|
|
69889
|
+
return _regenerator().w(function (_context4) {
|
|
69890
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
69891
|
+
case 0:
|
|
69892
|
+
_ref4 = options || {}, _ref4$appName = _ref4.appName, appName = _ref4$appName === void 0 ? process.env.APP_NAME : _ref4$appName, permissionKeys = _ref4.permissionKeys, rootSelector = _ref4.rootSelector, onInitCache = _ref4.onInitCache, render = _ref4.render, _ref4$standaloneMode = _ref4.standaloneMode, standaloneMode = _ref4$standaloneMode === void 0 ? 'render' : _ref4$standaloneMode, standaloneRender = _ref4.standaloneRender, _ref4$standaloneError = _ref4.standaloneErrorMessage, standaloneErrorMessage = _ref4$standaloneError === void 0 ? 'This application must be opened from the parent portal.' : _ref4$standaloneError, _ref4$fetchConfigFrom = _ref4.fetchConfigFromShell, fetchConfigFromShell = _ref4$fetchConfigFrom === void 0 ? true : _ref4$fetchConfigFrom, _ref4$configFallbackU = _ref4.configFallbackUri, configFallbackUri = _ref4$configFallbackU === void 0 ? process.env.CONFIG_URI : _ref4$configFallbackU, validateAppConfig = _ref4.validateAppConfig, _ref4$permissionsOnly = _ref4.permissionsOnlyIfArray, permissionsOnlyIfArray = _ref4$permissionsOnly === void 0 ? true : _ref4$permissionsOnly;
|
|
69893
|
+
if (!(typeof render !== 'function')) {
|
|
69894
|
+
_context4.n = 1;
|
|
69895
|
+
break;
|
|
69896
|
+
}
|
|
69897
|
+
throw new Error('bootstrapIframeApp requires a render(initialUri, rootNode) function');
|
|
69898
|
+
case 1:
|
|
69899
|
+
rootNode = resolveRootNode(rootSelector);
|
|
69900
|
+
if (rootNode) {
|
|
69901
|
+
_context4.n = 2;
|
|
69902
|
+
break;
|
|
69903
|
+
}
|
|
69904
|
+
console.error('[Iframe] No root element found');
|
|
69905
|
+
return _context4.a(2);
|
|
69906
|
+
case 2:
|
|
69907
|
+
if (isInIframe()) {
|
|
69908
|
+
_context4.n = 4;
|
|
69909
|
+
break;
|
|
69910
|
+
}
|
|
69911
|
+
if (!(standaloneMode === 'error')) {
|
|
69912
|
+
_context4.n = 3;
|
|
69913
|
+
break;
|
|
69914
|
+
}
|
|
69915
|
+
if (standaloneRender) standaloneRender(rootNode);else renderStandaloneError(rootNode, standaloneErrorMessage);
|
|
69916
|
+
return _context4.a(2);
|
|
69917
|
+
case 3:
|
|
69918
|
+
if (!(standaloneMode === 'skip')) {
|
|
69919
|
+
_context4.n = 4;
|
|
69920
|
+
break;
|
|
69921
|
+
}
|
|
69922
|
+
return _context4.a(2);
|
|
69923
|
+
case 4:
|
|
69924
|
+
bridge = iframeFacade.bridge, fetcher = iframeFacade.fetcher;
|
|
69925
|
+
getInitialUri = bridge.getInitialUri, getInitData = bridge.getInitData, setInitCache = bridge.setInitCache, setExtraLocal = bridge.setExtraLocal, sendStorageGet = bridge.sendStorageGet, setAppName = bridge.setAppName;
|
|
69926
|
+
_context4.n = 5;
|
|
69927
|
+
return Promise.all([getInitialUri(), getInitData()]);
|
|
69928
|
+
case 5:
|
|
69929
|
+
_yield$Promise$all = _context4.v;
|
|
69930
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
69931
|
+
initialUri = _yield$Promise$all2[0];
|
|
69932
|
+
initData = _yield$Promise$all2[1];
|
|
69933
|
+
if (appName && typeof setAppName === 'function') setAppName(appName);
|
|
69934
|
+
if (!initData) {
|
|
69935
|
+
_context4.n = 9;
|
|
69936
|
+
break;
|
|
69937
|
+
}
|
|
69938
|
+
setInitCache(initData);
|
|
69939
|
+
if (onInitCache) onInitCache(initData);
|
|
69940
|
+
if (!(fetchConfigFromShell && appName)) {
|
|
69941
|
+
_context4.n = 9;
|
|
69942
|
+
break;
|
|
69943
|
+
}
|
|
69944
|
+
_context4.p = 6;
|
|
69945
|
+
tasks = [hydrateAppConfig({
|
|
69946
|
+
appName: appName,
|
|
69947
|
+
sendStorageGet: sendStorageGet,
|
|
69948
|
+
setExtraLocal: setExtraLocal,
|
|
69949
|
+
fetcher: fetcher,
|
|
69950
|
+
configFallbackUri: configFallbackUri,
|
|
69951
|
+
validateAppConfig: validateAppConfig
|
|
69952
|
+
})];
|
|
69953
|
+
if (permissionKeys) {
|
|
69954
|
+
tasks.push(hydratePermissions({
|
|
69955
|
+
permissionKeys: permissionKeys,
|
|
69956
|
+
sendStorageGet: sendStorageGet,
|
|
69957
|
+
setExtraLocal: setExtraLocal,
|
|
69958
|
+
permissionsOnlyIfArray: permissionsOnlyIfArray
|
|
69959
|
+
}));
|
|
69960
|
+
}
|
|
69961
|
+
_context4.n = 7;
|
|
69962
|
+
return Promise.all(tasks);
|
|
69963
|
+
case 7:
|
|
69964
|
+
_context4.n = 9;
|
|
69965
|
+
break;
|
|
69966
|
+
case 8:
|
|
69967
|
+
_context4.p = 8;
|
|
69968
|
+
_t = _context4.v;
|
|
69969
|
+
console.warn('[Iframe] failed to fetch app config/permissions from shell:', _t);
|
|
69970
|
+
case 9:
|
|
69971
|
+
render(initialUri, rootNode);
|
|
69972
|
+
case 10:
|
|
69973
|
+
return _context4.a(2);
|
|
69974
|
+
}
|
|
69975
|
+
}, _callee4, null, [[6, 8]]);
|
|
69976
|
+
}));
|
|
69977
|
+
return _bootstrapIframeApp.apply(this, arguments);
|
|
69978
|
+
}
|
|
69979
|
+
|
|
69475
69980
|
setup({
|
|
69476
69981
|
pkg: pkg
|
|
69477
69982
|
});
|
|
@@ -81050,13 +81555,21 @@ var index_es = /*#__PURE__*/Object.freeze({
|
|
|
81050
81555
|
vectorsRatio: vectorsRatio
|
|
81051
81556
|
});
|
|
81052
81557
|
|
|
81558
|
+
exports.AppEnvSender = AppEnvSender;
|
|
81053
81559
|
exports.AppFrame = AppFrame;
|
|
81054
81560
|
exports.AutoRefresh = AutoRefresh;
|
|
81055
81561
|
exports.CallLogger = CallLogger;
|
|
81056
81562
|
exports.ContextualHelp = ContextualHelp;
|
|
81057
81563
|
exports.Crumb = Crumb$1;
|
|
81564
|
+
exports.IframeAppRoot = IframeAppRoot;
|
|
81565
|
+
exports.IframeRouteSync = IframeRouteSync;
|
|
81566
|
+
exports.NavConfigSender = NavConfigSender;
|
|
81058
81567
|
exports.accessHelpers = accessHelpers$1;
|
|
81568
|
+
exports.bootstrapIframeApp = bootstrapIframeApp;
|
|
81059
81569
|
exports.fetcher = fetcher$1;
|
|
81060
81570
|
exports.iframeFacade = iframeFacade;
|
|
81571
|
+
exports.normalizeIframePath = normalizeIframePath;
|
|
81572
|
+
exports.registerEarlyLoadUriListener = registerEarlyLoadUriListener;
|
|
81573
|
+
exports.serializeNavItems = serializeNavItems;
|
|
81061
81574
|
exports.storage = storage$2;
|
|
81062
81575
|
//# sourceMappingURL=ops-tool-kit.js.map
|