@alipay/ams-checkout 0.0.1759909830-dev.1 → 0.0.1760520369-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/popupWindow.style.d.ts +19 -9
- package/esm/component/popupWindow.style.js +26 -13
- package/esm/config/index.d.ts +8 -7
- package/esm/config/index.js +8 -7
- package/esm/constant/index.d.ts +58 -0
- package/esm/constant/index.js +64 -1
- package/esm/core/component/element/EventCenter/index.d.ts +31 -0
- package/esm/core/component/element/EventCenter/index.js +178 -0
- package/esm/core/component/element/elementContainerService/containerService.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/containerService.js +8 -2
- package/esm/core/component/element/elementController/index.d.ts +24 -3
- package/esm/core/component/element/elementController/index.js +533 -189
- package/esm/core/component/element/elementProcessor/addressProcessor.js +5 -6
- package/esm/core/component/element/elementProcessor/authProcessor.js +2 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +2 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +55 -19
- package/esm/core/component/element/index.d.ts +6 -5
- package/esm/core/component/element/index.js +14 -3
- package/esm/core/component/element/mock.js +1 -0
- package/esm/core/component/element/type.d.ts +56 -4
- package/esm/core/component/element/type.js +61 -2
- package/esm/core/component/element/util.d.ts +21 -5
- package/esm/core/component/element/util.js +59 -7
- package/esm/foundation/core/index.js +27 -8
- package/esm/foundation/index.d.ts +1 -0
- package/esm/foundation/product-processor/easysafepay/index.js +4 -2
- package/esm/foundation/product-processor/element/index.js +1 -0
- package/esm/foundation/service/container/popup.d.ts +11 -0
- package/esm/foundation/service/container/popup.js +23 -2
- package/esm/foundation/service/log/keys.js +4 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/foundation/utils/payment_context_utils.js +1 -0
- package/esm/index.js +2 -1
- package/esm/plugin/component/cashierApp.d.ts +2 -0
- package/esm/plugin/component/cashierApp.js +2 -2
- package/esm/plugin/component/channel.js +20 -4
- package/esm/plugin/component/component.popup.style.d.ts +1 -0
- package/esm/plugin/component/component.popup.style.js +1 -1
- package/esm/plugin/component/index.d.ts +1 -0
- package/esm/plugin/component/index.js +9 -5
- package/esm/types/index.d.ts +22 -2
- package/esm/types/index.js +2 -1
- package/esm/util/index.js +4 -1
- package/esm/util/spm-map.d.ts +24 -2
- package/esm/util/spm-map.js +14 -1
- package/package.json +1 -1
- package/esm/core/component/oldElement/components/address.d.ts +0 -19
- package/esm/core/component/oldElement/components/address.js +0 -68
- package/esm/core/component/oldElement/components/auth.d.ts +0 -17
- package/esm/core/component/oldElement/components/auth.js +0 -60
- package/esm/core/component/oldElement/components/payment.d.ts +0 -19
- package/esm/core/component/oldElement/components/payment.js +0 -74
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -354
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/core/component/oldElement/utils.d.ts +0 -13
- package/esm/core/component/oldElement/utils.js +0 -6
@@ -1,14 +1,24 @@
|
|
1
|
+
type CreateModalProps = {
|
2
|
+
device: any;
|
3
|
+
url: string;
|
4
|
+
widthPadding?: number;
|
5
|
+
loadingConfig?: {
|
6
|
+
theme?: string;
|
7
|
+
backgroundPrimary?: string;
|
8
|
+
};
|
9
|
+
showCloseOnLoading: boolean;
|
10
|
+
onCloseOnLoading: () => void;
|
11
|
+
textDirection: 'ltr' | 'rtl';
|
12
|
+
};
|
13
|
+
export declare const getCurrentTheme: (curTheme?: string) => any;
|
1
14
|
export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
|
2
15
|
export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
|
3
16
|
export declare const removePopupLoading: (isShowMockup?: boolean) => void;
|
4
17
|
export declare const insertStyleSheet: () => void;
|
5
|
-
export declare function createCloseIcon(onClose
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
loadingConfig: any;
|
11
|
-
showCloseOnLoading: any;
|
12
|
-
onCloseOnLoading: any;
|
13
|
-
}) => Promise<HTMLIFrameElement>;
|
18
|
+
export declare function createCloseIcon({ onClose, textDirection, }: {
|
19
|
+
onClose: () => void;
|
20
|
+
textDirection: 'ltr' | 'rtl';
|
21
|
+
}): HTMLDivElement;
|
22
|
+
export declare const createModal: ({ device, url, loadingConfig, showCloseOnLoading, onCloseOnLoading, textDirection, }: CreateModalProps) => Promise<HTMLIFrameElement>;
|
14
23
|
export declare const destroyModal: () => void;
|
24
|
+
export {};
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { AMSPOPUP_PREFIX, ANIMATION_TIME, MOCKUP_ID, POPUPLOADING_ID } from "../constant";
|
2
2
|
import { getDesignFontSize } from "../util";
|
3
|
-
|
4
3
|
// CSS样式字符串
|
5
4
|
var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n .").concat(AMSPOPUP_PREFIX, "modal-mobile{\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n bottom: 0;\n left: 0%;\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "-drawer-enter {\n animation: slideIn ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideIn {\n from {\n transform: translateY(100%); /* \u6ED1\u5165\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 0 */\n }\n to {\n transform: translateY(0); /* \u6ED1\u5165\u7ED3\u675F\u65F6\u5728\u539F\u4F4D\u7F6E */\n opacity: 1; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 1 */\n }\n }\n\n /* \u62BD\u5C49\u4ECE\u5E95\u90E8\u6ED1\u51FA */\n .").concat(AMSPOPUP_PREFIX, "-drawer-exit {\n animation: slideOut ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideOut {\n from {\n transform: translateY(0); /* \u6ED1\u51FA\u65F6\u4ECE\u5F53\u524D\u4F4D\u7F6E\u5F00\u59CB */\n opacity: 1; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 1 */\n }\n to {\n transform: translateY(100%); /* \u6ED1\u51FA\u7ED3\u675F\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 0 */\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n\n.ams-component-popup-loading {\n width: 0.8em;\n height:0.8em;\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-popup-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-popup-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-popup-loading .line div:before,\n.ams-component-popup-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: black;\n border-radius: 5.3px;\n}\n.ams-component-popup-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-popup-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.ams-component-popup-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-popup-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n");
|
6
|
-
var getCurrentTheme = function getCurrentTheme() {
|
5
|
+
export var getCurrentTheme = function getCurrentTheme() {
|
7
6
|
var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
8
7
|
var theme = {
|
9
8
|
night: 'dark',
|
@@ -47,10 +46,16 @@ export var insertStyleSheet = function insertStyleSheet() {
|
|
47
46
|
style.innerHTML = modalStyles;
|
48
47
|
document.head.appendChild(style);
|
49
48
|
};
|
50
|
-
export function createCloseIcon(
|
49
|
+
export function createCloseIcon(_ref) {
|
50
|
+
var onClose = _ref.onClose,
|
51
|
+
textDirection = _ref.textDirection;
|
51
52
|
var closeIcon = document.createElement('div');
|
52
53
|
closeIcon.style.position = 'absolute';
|
53
|
-
|
54
|
+
if (textDirection === 'rtl') {
|
55
|
+
closeIcon.style.left = '16px';
|
56
|
+
} else {
|
57
|
+
closeIcon.style.right = '16px';
|
58
|
+
}
|
54
59
|
closeIcon.style.top = '23px';
|
55
60
|
closeIcon.style.cursor = 'pointer';
|
56
61
|
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
@@ -68,16 +73,18 @@ export function createCloseIcon(onClose) {
|
|
68
73
|
closeIcon.onclick = onClose;
|
69
74
|
return closeIcon;
|
70
75
|
}
|
76
|
+
// TODO 这里固定?
|
71
77
|
var modalDevice = 'desktop';
|
72
78
|
// 插入弹窗
|
73
79
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
74
|
-
export var createModal = function createModal(
|
75
|
-
var device =
|
76
|
-
url =
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
export var createModal = function createModal(_ref2) {
|
81
|
+
var device = _ref2.device,
|
82
|
+
url = _ref2.url,
|
83
|
+
loadingConfig = _ref2.loadingConfig,
|
84
|
+
showCloseOnLoading = _ref2.showCloseOnLoading,
|
85
|
+
onCloseOnLoading = _ref2.onCloseOnLoading,
|
86
|
+
_ref2$textDirection = _ref2.textDirection,
|
87
|
+
textDirection = _ref2$textDirection === void 0 ? 'ltr' : _ref2$textDirection;
|
81
88
|
return new Promise(function (resolve, reject) {
|
82
89
|
try {
|
83
90
|
modalDevice = device;
|
@@ -95,6 +102,7 @@ export var createModal = function createModal(_ref) {
|
|
95
102
|
modal.style.height = '80vh';
|
96
103
|
modal.style.borderRadius = '12px 12px 0 0';
|
97
104
|
}
|
105
|
+
modal.setAttribute('dir', textDirection);
|
98
106
|
var iframe = document.createElement('iframe');
|
99
107
|
iframe.src = url; // 替换为实际的 URL 地址
|
100
108
|
iframe.style.border = 'none';
|
@@ -113,7 +121,10 @@ export var createModal = function createModal(_ref) {
|
|
113
121
|
|
114
122
|
// 弹窗渲染loading时关闭按钮逻辑
|
115
123
|
if (showCloseOnLoading) {
|
116
|
-
var closeIcon = createCloseIcon(
|
124
|
+
var closeIcon = createCloseIcon({
|
125
|
+
onClose: onCloseOnLoading,
|
126
|
+
textDirection: textDirection
|
127
|
+
});
|
117
128
|
modal.appendChild(closeIcon);
|
118
129
|
iframe.addEventListener('load', function () {
|
119
130
|
modal.removeChild(closeIcon);
|
@@ -139,7 +150,9 @@ export var destroyModal = function destroyModal() {
|
|
139
150
|
if (!overlay) {
|
140
151
|
return;
|
141
152
|
}
|
142
|
-
var modal =
|
153
|
+
var modal =
|
154
|
+
//TODO modalDevice固定'desktop'?
|
155
|
+
modalDevice === 'desktop' ? document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal")) : document.querySelector(".".concat(AMSPOPUP_PREFIX, "modal-mobile"));
|
143
156
|
overlay.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
144
157
|
overlay.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
|
145
158
|
if (modalDevice === 'desktop') {
|
package/esm/config/index.d.ts
CHANGED
@@ -6,10 +6,11 @@ export declare const sdkVersion: string;
|
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
7
7
|
* TODO 这里考虑直接换成packagejson.version
|
8
8
|
*/
|
9
|
-
export declare const AMSCheckoutAppVersion = "1.
|
10
|
-
export declare const AMSAutoDebitAppVersion = "1.
|
11
|
-
export declare const AMSEasyPayAppVersion = "1.
|
12
|
-
export declare const AMSCashierPaymentAppVersion = "1.
|
13
|
-
export declare const AMSVaultingAppVersion = "1.
|
14
|
-
export declare const AMSPaymentElementAppVersion = "1.
|
15
|
-
export declare const ADDRESSElementAppVersion = "1.
|
9
|
+
export declare const AMSCheckoutAppVersion = "1.46.0";
|
10
|
+
export declare const AMSAutoDebitAppVersion = "1.46.0";
|
11
|
+
export declare const AMSEasyPayAppVersion = "1.46.0";
|
12
|
+
export declare const AMSCashierPaymentAppVersion = "1.46.0";
|
13
|
+
export declare const AMSVaultingAppVersion = "1.46.0";
|
14
|
+
export declare const AMSPaymentElementAppVersion = "1.46.0";
|
15
|
+
export declare const ADDRESSElementAppVersion = "1.46.0";
|
16
|
+
export declare const AUTHElementAppVersion = "1.46.0";
|
package/esm/config/index.js
CHANGED
@@ -36,10 +36,11 @@ export var sdkVersion = json.version;
|
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
37
37
|
* TODO 这里考虑直接换成packagejson.version
|
38
38
|
*/
|
39
|
-
export var AMSCheckoutAppVersion = '1.
|
40
|
-
export var AMSAutoDebitAppVersion = '1.
|
41
|
-
export var AMSEasyPayAppVersion = '1.
|
42
|
-
export var AMSCashierPaymentAppVersion = '1.
|
43
|
-
export var AMSVaultingAppVersion = '1.
|
44
|
-
export var AMSPaymentElementAppVersion = '1.
|
45
|
-
export var ADDRESSElementAppVersion = '1.
|
39
|
+
export var AMSCheckoutAppVersion = '1.46.0'; // 兜底版本号
|
40
|
+
export var AMSAutoDebitAppVersion = '1.46.0'; // 代扣
|
41
|
+
export var AMSEasyPayAppVersion = '1.46.0'; // easypay
|
42
|
+
export var AMSCashierPaymentAppVersion = '1.46.0'; // 收银台(卡、apm)
|
43
|
+
export var AMSVaultingAppVersion = '1.46.0'; // 绑卡
|
44
|
+
export var AMSPaymentElementAppVersion = '1.46.0'; // payment element
|
45
|
+
export var ADDRESSElementAppVersion = '1.46.0'; // address element
|
46
|
+
export var AUTHElementAppVersion = '1.46.0'; // auth element
|
package/esm/constant/index.d.ts
CHANGED
@@ -77,11 +77,42 @@ export declare const ERRORMESSAGE: {
|
|
77
77
|
code: eventCodeEnum;
|
78
78
|
message: string;
|
79
79
|
};
|
80
|
+
LOAD_APP_TIME_OUT: {
|
81
|
+
code: eventCodeEnum;
|
82
|
+
message: string;
|
83
|
+
};
|
84
|
+
CONTAINER_NOT_EXIST: {
|
85
|
+
code: eventCodeEnum;
|
86
|
+
message: string;
|
87
|
+
};
|
80
88
|
};
|
81
89
|
SDK_SUBMIT_ERROR: {
|
82
90
|
code: eventCodeEnum;
|
83
91
|
message: string;
|
84
92
|
};
|
93
|
+
PARAM_INVALID: {
|
94
|
+
code: string;
|
95
|
+
message: string;
|
96
|
+
};
|
97
|
+
UI_STATE_ERROR: {
|
98
|
+
code: string;
|
99
|
+
message: string;
|
100
|
+
};
|
101
|
+
INITALIZE_TIMEOUT: {
|
102
|
+
code: string;
|
103
|
+
API: {
|
104
|
+
code: string;
|
105
|
+
message: string;
|
106
|
+
};
|
107
|
+
WEB: {
|
108
|
+
code: string;
|
109
|
+
message: string;
|
110
|
+
};
|
111
|
+
};
|
112
|
+
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
113
|
+
code: string;
|
114
|
+
message: string;
|
115
|
+
};
|
85
116
|
/**
|
86
117
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
87
118
|
*/
|
@@ -249,6 +280,9 @@ export declare const EVENT: {
|
|
249
280
|
messageForward: {
|
250
281
|
name: string;
|
251
282
|
};
|
283
|
+
submitPromiseCallback: {
|
284
|
+
name: string;
|
285
|
+
};
|
252
286
|
validateFieldsResult: {
|
253
287
|
name: string;
|
254
288
|
forwardName: string;
|
@@ -281,3 +315,27 @@ export declare const TIME_DELAY_SEND_HEART_BEAT = 1000;
|
|
281
315
|
export declare const closeImg = "https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg";
|
282
316
|
export declare const closeImgLight = "https://cdn.marmot-cloud.com/storage/2025/05/24/50891cd3-7a4a-47c0-b550-2e2ce6187c31.svg";
|
283
317
|
export declare const LOADINGIMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACEBAMAAACjap6UAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAAITgAACE4AUWWMWAAAAAqUExURUdwTKe3zKGxyK27z7K/05ytxLbD1bvH2Jaowb/K28DL3JCjvYueucDL2xLcxpgAAAAOdFJOUwCKoHRft0w5zCgY4fYKKSYvdQAABvtJREFUaN6lmt+LG1UUx6fddbcZHOgkpWutBTPbVBEfNp1xS6uF2oQURUGnBBbqw7YdsooV2ipZ06c+uBBZCistDRMU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AgffCLVgv2EchwkuGgGVZWe15bElAL5FeUwSUBR1f5AQUESCQR2mVh1FkjfAkohJgLj1GEVtZIRFACP0fCm/AgmdREnzYqIRhFHkvq+J77MBFQpEPpCQOYPcntwIWeK6Mu0P9D9pzJq4u5hj+AAAAAElFTkSuQmCC";
|
318
|
+
/**
|
319
|
+
* @description Promise回调code映射
|
320
|
+
*/
|
321
|
+
export declare const PROMISE_CALLBACK_CODE: {
|
322
|
+
SUCCESS: {
|
323
|
+
code: string;
|
324
|
+
};
|
325
|
+
UNKNOWN_EXCEPTION: {
|
326
|
+
code: string;
|
327
|
+
message: string;
|
328
|
+
};
|
329
|
+
REPEAT_REQ_REJECT: {
|
330
|
+
code: string;
|
331
|
+
message: string;
|
332
|
+
};
|
333
|
+
PROCESS_FAIL: {
|
334
|
+
code: string;
|
335
|
+
message: string;
|
336
|
+
};
|
337
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
338
|
+
code: string;
|
339
|
+
message: string;
|
340
|
+
};
|
341
|
+
};
|
package/esm/constant/index.js
CHANGED
@@ -76,12 +76,43 @@ export var ERRORMESSAGE = {
|
|
76
76
|
CALL_APP_URL_ERROR: {
|
77
77
|
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
78
78
|
message: 'Failed to launch app'
|
79
|
+
},
|
80
|
+
LOAD_APP_TIME_OUT: {
|
81
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
82
|
+
message: 'Load app time out'
|
83
|
+
},
|
84
|
+
CONTAINER_NOT_EXIST: {
|
85
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
86
|
+
message: 'Container service does not exist'
|
79
87
|
}
|
80
88
|
},
|
81
89
|
SDK_SUBMIT_ERROR: {
|
82
90
|
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
83
91
|
message: 'Component not created or current browser compatibility issue, not supported'
|
84
92
|
},
|
93
|
+
PARAM_INVALID: {
|
94
|
+
code: 'PARAM_INVALID',
|
95
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
96
|
+
},
|
97
|
+
UI_STATE_ERROR: {
|
98
|
+
code: 'UI_STATE_ERROR',
|
99
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
100
|
+
},
|
101
|
+
INITALIZE_TIMEOUT: {
|
102
|
+
code: 'INITALIZE_TIMEOUT',
|
103
|
+
API: {
|
104
|
+
code: 'INITALIZE_API_TIMEOUT',
|
105
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
106
|
+
},
|
107
|
+
WEB: {
|
108
|
+
code: 'INITALIZE_WEB_TIMEOUT',
|
109
|
+
message: 'An error occurred; the transaction cannot be initiated.'
|
110
|
+
}
|
111
|
+
},
|
112
|
+
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
113
|
+
code: 'ERR_DATA_STRUCT_UNRECOGNIZED',
|
114
|
+
message: 'An error occurred. The transaction cannot be initiated.'
|
115
|
+
},
|
85
116
|
/**
|
86
117
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
87
118
|
*/
|
@@ -93,6 +124,9 @@ export var ERRORMESSAGE = {
|
|
93
124
|
}
|
94
125
|
}
|
95
126
|
};
|
127
|
+
|
128
|
+
// as const satisfies Record<string, ErrorMessage>;
|
129
|
+
|
96
130
|
export var BASEPLUGINID = 'CHECKOUT';
|
97
131
|
export var COMPONENTPLUGINID = 'COMPONENT';
|
98
132
|
export var EVENT = {
|
@@ -251,6 +285,10 @@ export var EVENT = {
|
|
251
285
|
messageForward: {
|
252
286
|
name: 'onMessageForward'
|
253
287
|
},
|
288
|
+
// Element支付完成后事件
|
289
|
+
submitPromiseCallback: {
|
290
|
+
name: 'onSubmitPayCallback'
|
291
|
+
},
|
254
292
|
validateFieldsResult: {
|
255
293
|
name: 'validateFieldsResult',
|
256
294
|
forwardName: 'validateFieldsResultForward',
|
@@ -284,4 +322,29 @@ export var TIMEOUT_WEB_APP_HEART_BEAT = 6000;
|
|
284
322
|
export var TIME_DELAY_SEND_HEART_BEAT = 1000;
|
285
323
|
export var closeImg = 'https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg';
|
286
324
|
export var closeImgLight = 'https://cdn.marmot-cloud.com/storage/2025/05/24/50891cd3-7a4a-47c0-b550-2e2ce6187c31.svg';
|
287
|
-
export var LOADINGIMG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACEBAMAAACjap6UAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAAITgAACE4AUWWMWAAAAAqUExURUdwTKe3zKGxyK27z7K/05ytxLbD1bvH2Jaowb/K28DL3JCjvYueucDL2xLcxpgAAAAOdFJOUwCKoHRft0w5zCgY4fYKKSYvdQAABvtJREFUaN6lmt+LG1UUx6fddbcZHOgkpWutBTPbVBEfNp1xS6uF2oQURUGnBBbqw7YdsooV2ipZ06c+uBBZCistDRMUqgV1gnnwJ4HMg2jBh+Qh1bW1A/lfPOfcO9lkNz/m3j3dh2XT+eznfM+dmTvTKsroUovpeGotbyetlXuKTH17vFxeKq9R5fOJG8KAR6+Uy2vlJag8ALDmxSDa2TLWEhos5UPKnEA7sy8yALNYyod1/mpUwiYpQB9MYy1sJZWybwgRgLGGDLRAhg1ftn0qIqHBkijzefBO7HwKRN6cTJguNxoho38gjGHb7y5PTHJpvdyLgsaap3UBSdjISKWMCZlqzzTBosGj4CMJC+LEmh8/20+b62jRM+EGjIAQsLDnxhH+IQduUS7P50p1RQk85zgRwCIPhJTx9pjz6gIev84k1o59tfVJ7HIKw0iRRio5upX3GaGBjPMbg5/FjnOAYRvGC6MIU83mOkGAcHLnx7cxC8O2ETNqsofhcIgT2xja7WOmYRsp4+hwwt9NKErz1xG/ZJYRsE4PXRIX0GAdwxi5AGfjNrYCiGRnyMf/kgRgGmNm9ihl8DoyVAKOxzxfGrdy7vOZGPM7NfaiBDI+G38KXDK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f5AQUESCQR2mVh1FkjfAkohJgLj1GEVtZIRFACP0fCm/AgmdREnzYqIRhFHkvq+J77MBFQpEPpCQOYPcntwIWeK6Mu0P9D9pzJq4u5hj+AAAAAElFTkSuQmCC';
|
326
|
+
|
327
|
+
/**
|
328
|
+
* @description Promise回调code映射
|
329
|
+
*/
|
330
|
+
export var PROMISE_CALLBACK_CODE = {
|
331
|
+
SUCCESS: {
|
332
|
+
code: 'SUCCESS'
|
333
|
+
},
|
334
|
+
UNKNOWN_EXCEPTION: {
|
335
|
+
code: 'UNKNOWN_EXCEPTION',
|
336
|
+
message: 'Unknown exception. Please check the payment status and contact the merchant.'
|
337
|
+
},
|
338
|
+
REPEAT_REQ_REJECT: {
|
339
|
+
code: 'REPEAT_REQ_REJECT',
|
340
|
+
message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
|
341
|
+
},
|
342
|
+
PROCESS_FAIL: {
|
343
|
+
code: 'PROCESS_FAIL',
|
344
|
+
message: 'Unknown exception. Please check the payment status and contact the merchant.'
|
345
|
+
},
|
346
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
347
|
+
code: 'INQUIRY_PAYMENT_SESSION_FAILED',
|
348
|
+
message: 'The order status is abnormal. Please check the payment status and contact the merchant.'
|
349
|
+
}
|
350
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { LogService } from '../../../../foundation/service/log';
|
2
|
+
export declare class EventCenter {
|
3
|
+
private activeEvents;
|
4
|
+
private heartbeatIntervalId;
|
5
|
+
private readonly HEARTBEAT_INTERVAL;
|
6
|
+
private uniqueId;
|
7
|
+
private readonly logger;
|
8
|
+
constructor({ logger }: {
|
9
|
+
logger: LogService;
|
10
|
+
});
|
11
|
+
/**
|
12
|
+
* 注册事件
|
13
|
+
* @param {string} functionName 函数名称
|
14
|
+
* @returns {string} 返回事件起始ID
|
15
|
+
*/
|
16
|
+
registerEvent(functionName: string, sessionData?: string): string;
|
17
|
+
/**
|
18
|
+
* 结束事件
|
19
|
+
* @param startId 事件起始ID
|
20
|
+
* @returns
|
21
|
+
*/
|
22
|
+
endEvent(startId: string, extra?: any): void;
|
23
|
+
private startHeartbeat;
|
24
|
+
private stopHeartbeat;
|
25
|
+
private sendHeartbeat;
|
26
|
+
private sendLog;
|
27
|
+
private buildId;
|
28
|
+
private getEventName;
|
29
|
+
private buildIdFromStart;
|
30
|
+
private getEventNameFromStart;
|
31
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
+
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; }
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
16
|
+
import { getType } from "../../../../util";
|
17
|
+
import { EXPOSURE_API_EVENT } from "../type";
|
18
|
+
import { safeStringify } from "../util";
|
19
|
+
export var EventCenter = /*#__PURE__*/function () {
|
20
|
+
// 日志服务实例
|
21
|
+
|
22
|
+
function EventCenter(_ref) {
|
23
|
+
var logger = _ref.logger;
|
24
|
+
_classCallCheck(this, EventCenter);
|
25
|
+
_defineProperty(this, "activeEvents", new Map());
|
26
|
+
// key: eventId, value: startTime
|
27
|
+
_defineProperty(this, "heartbeatIntervalId", null);
|
28
|
+
// 心跳定时器ID
|
29
|
+
_defineProperty(this, "HEARTBEAT_INTERVAL", 5000);
|
30
|
+
// 心跳间隔时间(毫秒)
|
31
|
+
_defineProperty(this, "uniqueId", 0);
|
32
|
+
// 唯一ID 自增
|
33
|
+
_defineProperty(this, "logger", void 0);
|
34
|
+
this.logger = logger;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* 注册事件
|
39
|
+
* @param {string} functionName 函数名称
|
40
|
+
* @returns {string} 返回事件起始ID
|
41
|
+
*/
|
42
|
+
_createClass(EventCenter, [{
|
43
|
+
key: "registerEvent",
|
44
|
+
value: function registerEvent(functionName, sessionData) {
|
45
|
+
// 构建事件起始ID
|
46
|
+
var startId = this.buildId(functionName, 'start');
|
47
|
+
var type = this.getEventName(functionName, 'start');
|
48
|
+
// 将当前时间戳设置为活动事件的起始时间
|
49
|
+
this.activeEvents.set(startId, Date.now());
|
50
|
+
|
51
|
+
// 启动心跳检测
|
52
|
+
this.startHeartbeat();
|
53
|
+
// 发送日志,记录事件起始信息
|
54
|
+
this.sendLog(type, {
|
55
|
+
eventName: startId,
|
56
|
+
sessionData: sessionData
|
57
|
+
});
|
58
|
+
return startId;
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* 结束事件
|
63
|
+
* @param startId 事件起始ID
|
64
|
+
* @returns
|
65
|
+
*/
|
66
|
+
}, {
|
67
|
+
key: "endEvent",
|
68
|
+
value: function endEvent(startId, extra) {
|
69
|
+
// 如果活动事件中不存在该起始ID,则直接返回
|
70
|
+
if (!this.activeEvents.has(startId)) return;
|
71
|
+
// 获取起始时间
|
72
|
+
var startTime = this.activeEvents.get(startId);
|
73
|
+
// 从活动事件中删除该起始ID
|
74
|
+
this.activeEvents.delete(startId);
|
75
|
+
var type = this.getEventNameFromStart(startId, 'end');
|
76
|
+
|
77
|
+
// 发送日志,记录事件结束信息
|
78
|
+
this.sendLog(type, _objectSpread({
|
79
|
+
eventName: this.buildIdFromStart(startId, 'end'),
|
80
|
+
startTime: startTime,
|
81
|
+
endTime: Date.now()
|
82
|
+
}, extra || {}));
|
83
|
+
if (extra && getType(extra) !== 'object') {
|
84
|
+
this.sendLog('data_error', {
|
85
|
+
msg: safeStringify(extra)
|
86
|
+
});
|
87
|
+
}
|
88
|
+
|
89
|
+
// 如果活动事件数量为0,则停止心跳
|
90
|
+
if (this.activeEvents.size === 0) this.stopHeartbeat();
|
91
|
+
}
|
92
|
+
}, {
|
93
|
+
key: "startHeartbeat",
|
94
|
+
value: function startHeartbeat() {
|
95
|
+
var _this = this;
|
96
|
+
if (this.heartbeatIntervalId) return;
|
97
|
+
this.heartbeatIntervalId = setInterval(function () {
|
98
|
+
if (_this.activeEvents.size === 0) {
|
99
|
+
_this.stopHeartbeat();
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
_this.sendHeartbeat();
|
103
|
+
}, this.HEARTBEAT_INTERVAL);
|
104
|
+
}
|
105
|
+
}, {
|
106
|
+
key: "stopHeartbeat",
|
107
|
+
value: function stopHeartbeat() {
|
108
|
+
if (this.heartbeatIntervalId === null) return;
|
109
|
+
clearInterval(this.heartbeatIntervalId);
|
110
|
+
this.heartbeatIntervalId = null;
|
111
|
+
}
|
112
|
+
}, {
|
113
|
+
key: "sendHeartbeat",
|
114
|
+
value: function sendHeartbeat() {
|
115
|
+
var actionNames = Array.from(this.activeEvents.entries()).map(function (_ref2) {
|
116
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
117
|
+
id = _ref3[0],
|
118
|
+
startTime = _ref3[1];
|
119
|
+
return {
|
120
|
+
eventName: id,
|
121
|
+
startTime: startTime
|
122
|
+
};
|
123
|
+
});
|
124
|
+
this.sendLog('heart_beat', {
|
125
|
+
actionNames: safeStringify(actionNames)
|
126
|
+
});
|
127
|
+
}
|
128
|
+
}, {
|
129
|
+
key: "sendLog",
|
130
|
+
value: function sendLog(type, payload) {
|
131
|
+
/**
|
132
|
+
*当前使用以下事件映射,目前没有遗漏
|
133
|
+
* mount_start
|
134
|
+
* mount_end
|
135
|
+
* submitPayment_start
|
136
|
+
* submitPayment_end
|
137
|
+
* validateFields_start
|
138
|
+
* validateFields_end
|
139
|
+
* destroy_start
|
140
|
+
* destroy_end
|
141
|
+
*/
|
142
|
+
//TODO: 后续需要移除映射,在执行入口埋点
|
143
|
+
var titleMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(EXPOSURE_API_EVENT.MOUNT, "_start"), 'sdk_event_mount'), "".concat(EXPOSURE_API_EVENT.MOUNT, "_end"), 'sdk_event_mount_end'), "".concat(EXPOSURE_API_EVENT.SUBMITPAYMENT, "_start"), 'sdk_event_submitPay'), "".concat(EXPOSURE_API_EVENT.SUBMITPAYMENT, "_end"), 'sdk_event_payment_end'), "".concat(EXPOSURE_API_EVENT.VALIDATAFIELDS, "_start"), 'sdk_event_validateFields'), "".concat(EXPOSURE_API_EVENT.VALIDATAFIELDS, "_end"), 'sdk_event_validateFields_end'), "".concat(EXPOSURE_API_EVENT.DESTORY, "_start"), 'sdk_event_apiOnDestroy'), "".concat(EXPOSURE_API_EVENT.DESTORY, "_end"), 'sdk_event_apiOnDestroy_end'), "heart_beat", 'sdk_element_handleHeartBeat'), "data_error", 'sdk_element_callback_error');
|
144
|
+
var title = titleMap[type];
|
145
|
+
if (!title) return;
|
146
|
+
this.logger.logInfo({
|
147
|
+
title: title
|
148
|
+
}, _objectSpread({
|
149
|
+
actionName: type
|
150
|
+
}, payload));
|
151
|
+
}
|
152
|
+
}, {
|
153
|
+
key: "buildId",
|
154
|
+
value: function buildId(fn, suffix) {
|
155
|
+
return "".concat(fn, "_").concat(++this.uniqueId, "_").concat(suffix);
|
156
|
+
}
|
157
|
+
|
158
|
+
// 通过fn生成埋点事件名,fn=mount,如mount_start
|
159
|
+
}, {
|
160
|
+
key: "getEventName",
|
161
|
+
value: function getEventName(fn, suffix) {
|
162
|
+
return "".concat(fn, "_").concat(suffix);
|
163
|
+
}
|
164
|
+
}, {
|
165
|
+
key: "buildIdFromStart",
|
166
|
+
value: function buildIdFromStart(startId, suffix) {
|
167
|
+
return startId.replace(/_start$/, "_".concat(suffix));
|
168
|
+
}
|
169
|
+
|
170
|
+
// 通过startId生成埋点事件名,如mount_1_start --> mount_end,和生成规则一一对应
|
171
|
+
}, {
|
172
|
+
key: "getEventNameFromStart",
|
173
|
+
value: function getEventNameFromStart(startId, suffix) {
|
174
|
+
return startId.replace(/_.+_/i, '_').replace(/_start$/, "_".concat(suffix));
|
175
|
+
}
|
176
|
+
}]);
|
177
|
+
return EventCenter;
|
178
|
+
}();
|
@@ -19,7 +19,7 @@ export var IContainerStatus = /*#__PURE__*/function (IContainerStatus) {
|
|
19
19
|
}({});
|
20
20
|
export var ContainerController = /*#__PURE__*/function () {
|
21
21
|
function ContainerController(_ref) {
|
22
|
-
var _options$debugProps;
|
22
|
+
var _options$debugProps, _options$debugProps2;
|
23
23
|
var type = _ref.type,
|
24
24
|
instanceId = _ref.instanceId,
|
25
25
|
selector = _ref.selector,
|
@@ -41,6 +41,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
41
41
|
sdkVersion: '',
|
42
42
|
webAppVersion: ''
|
43
43
|
});
|
44
|
+
var iframesSrcLink = options !== null && options !== void 0 && (_options$debugProps = options.debugProps) !== null && _options$debugProps !== void 0 && _options$debugProps.isDebug ? (options === null || options === void 0 || (_options$debugProps2 = options.debugProps) === null || _options$debugProps2 === void 0 ? void 0 : _options$debugProps2.localLink) || '' : '';
|
44
45
|
this.containerElement = this.containerService.load({
|
45
46
|
type: DisplayTypeEnum.inline,
|
46
47
|
platform: isElementPad() ? PlatformEnum.desktop : isElementPC() ? PlatformEnum.desktop : PlatformEnum.mobile,
|
@@ -51,7 +52,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
51
52
|
display: 'block'
|
52
53
|
}
|
53
54
|
}, processor.generateIframeSrc({
|
54
|
-
link:
|
55
|
+
link: iframesSrcLink,
|
55
56
|
instanceId: this.instanceId
|
56
57
|
}));
|
57
58
|
this.eventService = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
@@ -118,6 +119,11 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
118
119
|
value: function getContainerService() {
|
119
120
|
return this.containerService;
|
120
121
|
}
|
122
|
+
}, {
|
123
|
+
key: "getInstanceId",
|
124
|
+
value: function getInstanceId() {
|
125
|
+
return this.instanceId;
|
126
|
+
}
|
121
127
|
}]);
|
122
128
|
return ContainerController;
|
123
129
|
}();
|