@alipay/ams-checkout 1.9.0 → 1.10.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/core/component/index.d.ts +5 -0
- package/esm/core/component/index.js +101 -11
- package/esm/index.d.ts +10 -2
- package/esm/index.js +53 -8
- package/esm/plugin/component/cashierApp.d.ts +3 -0
- package/esm/plugin/component/cashierApp.js +23 -2
- package/esm/plugin/component/index.d.ts +4 -0
- package/esm/plugin/component/index.js +120 -38
- package/esm/types/index.d.ts +3 -0
- package/esm/util/createIframeNode.d.ts +1 -0
- package/esm/util/createIframeNode.js +6 -0
- package/esm/util/index.d.ts +2 -1
- package/esm/util/index.js +14 -1
- package/esm/util/versionCompare.d.ts +1 -5
- package/esm/util/versionCompare.js +0 -5
- package/package.json +1 -1
@@ -5,14 +5,19 @@ export declare const getComponentSign: (params: IpaymentSessionMetaData) => comp
|
|
5
5
|
export declare const parseSessionData: (sessionData: string) => [IpaymentSessionMetaData, string];
|
6
6
|
export declare class AMSComponent extends CoreInstance {
|
7
7
|
_componentApp: ComponentApp;
|
8
|
+
channelType: componentSignEnum[];
|
9
|
+
productSceneVersion: string;
|
8
10
|
constructor(options: IoptionsParams);
|
9
11
|
private parameterInitAndCheck;
|
10
12
|
private pluginAppendIframe;
|
13
|
+
private savePreviousChannel;
|
11
14
|
/**
|
12
15
|
* @description Create component application
|
13
16
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
14
17
|
*/
|
15
18
|
createComponent(params: IcreateComponent): Promise<void>;
|
19
|
+
preloadComponent(channelType: any, productSceneVersion: any): void;
|
20
|
+
clearPreloadIframe(isTimeOut?: boolean): void;
|
16
21
|
/**
|
17
22
|
* @description Create and render components in the specified element area
|
18
23
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
@@ -29,8 +29,8 @@ import { v4 as uuid } from 'uuid';
|
|
29
29
|
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
30
30
|
import ComponentApp from "../../plugin/component";
|
31
31
|
import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
32
|
-
import { getOrSetStorageId, isPC } from "../../util";
|
33
|
-
import { createIframeNode } from "../../util/createIframeNode";
|
32
|
+
import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
|
33
|
+
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
34
34
|
import { getSecurityConfigStorageKey } from "../../util/security";
|
35
35
|
import CoreInstance from "../instance/index";
|
36
36
|
export var getComponentSign = function getComponentSign(params) {
|
@@ -44,7 +44,7 @@ export var getComponentSign = function getComponentSign(params) {
|
|
44
44
|
};
|
45
45
|
export var parseSessionData = function parseSessionData(sessionData) {
|
46
46
|
try {
|
47
|
-
return [JSON.parse(
|
47
|
+
return [JSON.parse(parseBase64ToString(sessionData.split('&&')[3])), sessionData.split('&&').slice(0, 3).join('&&')];
|
48
48
|
} catch (error) {
|
49
49
|
console.error('Parsing sessionData is abnormal and may affect the payment link. Please ensure to use the new version of SDK.');
|
50
50
|
return [{}, sessionData];
|
@@ -106,8 +106,11 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
106
106
|
_this = _super.call(this, options);
|
107
107
|
// Instantiate the plug-in and set render
|
108
108
|
_defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
|
109
|
+
_defineProperty(_assertThisInitialized(_this), "channelType", void 0);
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
|
109
111
|
var ComponentPlugin = new ComponentApp();
|
110
112
|
ComponentPlugin.setRender(createIframeNode);
|
113
|
+
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
|
111
114
|
// Register Cashier Application Plug in
|
112
115
|
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
113
116
|
_this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
|
@@ -146,6 +149,45 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
146
149
|
return Promise.reject(error);
|
147
150
|
}
|
148
151
|
}
|
152
|
+
}, {
|
153
|
+
key: "savePreviousChannel",
|
154
|
+
value: function savePreviousChannel(iframeNodesParams) {
|
155
|
+
var _ref2 = iframeNodesParams || {},
|
156
|
+
_ref2$paymentSessionM = _ref2.paymentSessionMetaData.paymentSessionConfig,
|
157
|
+
_ref2$paymentSessionM2 = _ref2$paymentSessionM.productScene,
|
158
|
+
productScene = _ref2$paymentSessionM2 === void 0 ? '' : _ref2$paymentSessionM2,
|
159
|
+
_ref2$paymentSessionM3 = _ref2$paymentSessionM.paymentMethodCategoryType,
|
160
|
+
paymentMethodCategoryType = _ref2$paymentSessionM3 === void 0 ? '' : _ref2$paymentSessionM3,
|
161
|
+
_ref2$paymentSessionM4 = _ref2$paymentSessionM.productSceneVersion,
|
162
|
+
productSceneVersion = _ref2$paymentSessionM4 === void 0 ? '' : _ref2$paymentSessionM4;
|
163
|
+
var channelType = "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
164
|
+
if (productScene && paymentMethodCategoryType && productSceneVersion) {
|
165
|
+
if (Array.isArray(this.channelType) && this.channelType.includes(channelType) && this.productSceneVersion === productSceneVersion) {
|
166
|
+
this.logger.logInfo({
|
167
|
+
title: 'preload_match'
|
168
|
+
}, {
|
169
|
+
preloadChannel: this.channelType,
|
170
|
+
preloadVersion: this.productSceneVersion,
|
171
|
+
sessionDataChannel: channelType,
|
172
|
+
sessionDataVersion: productSceneVersion
|
173
|
+
});
|
174
|
+
} else {
|
175
|
+
this.logger.logInfo({
|
176
|
+
title: 'preload_no_match'
|
177
|
+
}, {
|
178
|
+
preloadChannel: this.channelType,
|
179
|
+
preloadVersion: this.productSceneVersion,
|
180
|
+
sessionDataChannel: channelType,
|
181
|
+
sessionDataVersion: productSceneVersion
|
182
|
+
});
|
183
|
+
}
|
184
|
+
var previousChannel = {
|
185
|
+
channelType: channelType === componentSignEnum.VAULTING_CARD ? componentSignEnum.CASHIER_PAYMENT_CARD : channelType,
|
186
|
+
productSceneVersion: productSceneVersion
|
187
|
+
};
|
188
|
+
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
189
|
+
}
|
190
|
+
}
|
149
191
|
/**
|
150
192
|
* @description Create component application
|
151
193
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
@@ -154,6 +196,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
154
196
|
key: "createComponent",
|
155
197
|
value: function createComponent(params) {
|
156
198
|
var _this2 = this;
|
199
|
+
this.clearPreloadIframe();
|
157
200
|
return this.parameterInitAndCheck({
|
158
201
|
params: params,
|
159
202
|
renderDisplayType: renderDisplayTypeEnum.popup
|
@@ -168,9 +211,53 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
168
211
|
_this2._eventCenter.emit(EVENT.error.name, error);
|
169
212
|
return Promise.reject(error);
|
170
213
|
}).then(function (appendParams) {
|
214
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
215
|
+
_this2.savePreviousChannel(iframeNodesParams);
|
171
216
|
return _this2.pluginAppendIframe(appendParams);
|
172
217
|
});
|
173
218
|
}
|
219
|
+
}, {
|
220
|
+
key: "preloadComponent",
|
221
|
+
value: function preloadComponent(channelType, productSceneVersion) {
|
222
|
+
var _this3 = this;
|
223
|
+
this.channelType = channelType;
|
224
|
+
this.productSceneVersion = productSceneVersion;
|
225
|
+
var MAX_CLEAR_TIME = 10000;
|
226
|
+
if (Array.isArray(channelType)) {
|
227
|
+
for (var i = 0; i < channelType.length; i++) {
|
228
|
+
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
229
|
+
}
|
230
|
+
} else {
|
231
|
+
this.logger.logError({
|
232
|
+
title: 'performance_optimization_channelType_error'
|
233
|
+
}, {
|
234
|
+
channelType: channelType
|
235
|
+
});
|
236
|
+
}
|
237
|
+
setTimeout(function () {
|
238
|
+
_this3.clearPreloadIframe(true);
|
239
|
+
}, MAX_CLEAR_TIME);
|
240
|
+
}
|
241
|
+
}, {
|
242
|
+
key: "clearPreloadIframe",
|
243
|
+
value: function clearPreloadIframe() {
|
244
|
+
var isTimeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
245
|
+
if (Array.isArray(this.channelType)) {
|
246
|
+
for (var i = 0; i < this.channelType.length; i++) {
|
247
|
+
var iframe = document.getElementById("ams-checkout-component-".concat(this.channelType[i], "-").concat(this.productSceneVersion));
|
248
|
+
iframe && document.body.removeChild(iframe);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
if (!isTimeOut) {
|
252
|
+
this.logger.logInfo({
|
253
|
+
title: 'performance_optimization_clearPreloadIframe'
|
254
|
+
});
|
255
|
+
} else {
|
256
|
+
this.logger.logInfo({
|
257
|
+
title: 'performance_optimization_clearPreloadIframe_timeout'
|
258
|
+
});
|
259
|
+
}
|
260
|
+
}
|
174
261
|
/**
|
175
262
|
* @description Create and render components in the specified element area
|
176
263
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
@@ -179,7 +266,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
179
266
|
}, {
|
180
267
|
key: "mountComponent",
|
181
268
|
value: function mountComponent(params, selector) {
|
182
|
-
var
|
269
|
+
var _this4 = this;
|
270
|
+
this.clearPreloadIframe();
|
183
271
|
return this.parameterInitAndCheck({
|
184
272
|
params: params,
|
185
273
|
renderDisplayType: renderDisplayTypeEnum.inline,
|
@@ -187,15 +275,17 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
187
275
|
}).then(function (_params) {
|
188
276
|
return handleParams(_params);
|
189
277
|
}).catch(function (error) {
|
190
|
-
|
278
|
+
_this4.logger.logError({
|
191
279
|
title: 'sdk_error_parameter'
|
192
280
|
}, {
|
193
281
|
params: JSON.stringify(params)
|
194
282
|
}).send();
|
195
|
-
|
283
|
+
_this4._eventCenter.emit(EVENT.error.name, error);
|
196
284
|
return Promise.reject(error);
|
197
285
|
}).then(function (appendParams) {
|
198
|
-
|
286
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
287
|
+
_this4.savePreviousChannel(iframeNodesParams);
|
288
|
+
return _this4.pluginAppendIframe(appendParams);
|
199
289
|
});
|
200
290
|
}
|
201
291
|
/**
|
@@ -206,22 +296,22 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
206
296
|
}, {
|
207
297
|
key: "submit",
|
208
298
|
value: function submit(data) {
|
209
|
-
var
|
299
|
+
var _this5 = this;
|
210
300
|
return new Promise(function (resolve, reject) {
|
211
301
|
try {
|
212
302
|
var eventCallbackId = uuid();
|
213
303
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
214
|
-
|
304
|
+
_this5._eventCenter.once(eventCallbackId, function (_data) {
|
215
305
|
resolve(_data);
|
216
306
|
});
|
217
|
-
|
307
|
+
_this5._componentApp.dispatchToApp({
|
218
308
|
context: {
|
219
309
|
event: 'submitPay',
|
220
310
|
eventCallbackId: eventCallbackId,
|
221
311
|
data: data
|
222
312
|
}
|
223
313
|
});
|
224
|
-
|
314
|
+
_this5.logger.logInfo({
|
225
315
|
title: 'sdk_event_apiSubmit'
|
226
316
|
});
|
227
317
|
} catch (error) {
|
package/esm/index.d.ts
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
+
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
|
+
*/
|
3
8
|
import ApplePayComponent from './core/applepay';
|
9
|
+
import { AMSComponent } from './core/component/index';
|
10
|
+
import { IoptionsParams, componentSignEnum } from './types';
|
4
11
|
export * from './types';
|
5
12
|
export declare class AMSCheckout extends AMSComponent {
|
13
|
+
constructor(_options: any, channelType?: componentSignEnum[], productSceneVersion?: string);
|
6
14
|
}
|
7
15
|
export declare class AMSApplePay extends ApplePayComponent {
|
8
16
|
}
|
package/esm/index.js
CHANGED
@@ -18,16 +18,23 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
18
18
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
19
19
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
20
20
|
*/
|
21
|
-
import { productSceneEnum } from "./types/index";
|
22
|
-
import { AMSComponent } from "./core/component/index";
|
23
21
|
import ApplePayComponent from "./core/applepay";
|
22
|
+
import { AMSComponent } from "./core/component/index";
|
23
|
+
import { componentSignEnum } from "./types";
|
24
|
+
import { productSceneEnum } from "./types/index";
|
25
|
+
import { Logger, LogConfig } from "./util/logger";
|
26
|
+
var logger = new Logger(LogConfig, true);
|
24
27
|
export * from "./types";
|
25
28
|
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
26
29
|
_inherits(AMSCheckout, _AMSComponent);
|
27
30
|
var _super = _createSuper(AMSCheckout);
|
28
|
-
function AMSCheckout() {
|
31
|
+
function AMSCheckout(_options, channelType) {
|
32
|
+
var _this;
|
33
|
+
var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
|
29
34
|
_classCallCheck(this, AMSCheckout);
|
30
|
-
|
35
|
+
_this = _super.call(this, _options);
|
36
|
+
_this.preloadComponent(channelType, productSceneVersion);
|
37
|
+
return _this;
|
31
38
|
}
|
32
39
|
return _createClass(AMSCheckout);
|
33
40
|
}(AMSComponent);
|
@@ -48,7 +55,7 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
|
48
55
|
var _options = Object.assign({}, options, {
|
49
56
|
product: productSceneEnum.AUTO_DEBIT
|
50
57
|
});
|
51
|
-
return _super3.call(this, _options);
|
58
|
+
return _super3.call(this, _options, [componentSignEnum.AUTO_DEBIT_WALLET]);
|
52
59
|
}
|
53
60
|
return _createClass(AMSAutoDebit);
|
54
61
|
}(AMSCheckout);
|
@@ -60,7 +67,26 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
|
|
60
67
|
var _options = Object.assign({}, options, {
|
61
68
|
product: productSceneEnum.EASY_PAY
|
62
69
|
});
|
63
|
-
|
70
|
+
var currentProductSceneVersion = '1.0';
|
71
|
+
try {
|
72
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
73
|
+
var previousChannel = JSON.parse(previousChannelStr) || {};
|
74
|
+
var _ref = previousChannel || {},
|
75
|
+
_ref$channelType = _ref.channelType,
|
76
|
+
channelType = _ref$channelType === void 0 ? '' : _ref$channelType,
|
77
|
+
_ref$productSceneVers = _ref.productSceneVersion,
|
78
|
+
productSceneVersion = _ref$productSceneVers === void 0 ? '1.0' : _ref$productSceneVers;
|
79
|
+
if (channelType === componentSignEnum.EASY_PAY_WALLET) {
|
80
|
+
currentProductSceneVersion = productSceneVersion;
|
81
|
+
}
|
82
|
+
} catch (error) {
|
83
|
+
logger.logError({
|
84
|
+
title: 'performance_optimization_get_previousChannel_error'
|
85
|
+
}, {
|
86
|
+
error: error
|
87
|
+
});
|
88
|
+
}
|
89
|
+
return _super4.call(this, _options, [componentSignEnum.EASY_PAY_WALLET], currentProductSceneVersion);
|
64
90
|
}
|
65
91
|
return _createClass(AMSEasyPay);
|
66
92
|
}(AMSCheckout);
|
@@ -72,7 +98,26 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
72
98
|
var _options = Object.assign({}, options, {
|
73
99
|
product: productSceneEnum.CASHIER_PAYMENT
|
74
100
|
});
|
75
|
-
|
101
|
+
var currentChannelType;
|
102
|
+
try {
|
103
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
104
|
+
var previousChannel = JSON.parse(previousChannelStr) || {};
|
105
|
+
var _ref2 = previousChannel || {},
|
106
|
+
_ref2$channelType = _ref2.channelType,
|
107
|
+
channelType = _ref2$channelType === void 0 ? '' : _ref2$channelType;
|
108
|
+
if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.CASHIER_PAYMENT_APM, componentSignEnum.CASHIER_PAYMENT_BANK].includes(channelType)) {
|
109
|
+
currentChannelType = [channelType];
|
110
|
+
} else {
|
111
|
+
currentChannelType = [componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.CASHIER_PAYMENT_APM];
|
112
|
+
}
|
113
|
+
} catch (error) {
|
114
|
+
logger.logError({
|
115
|
+
title: 'performance_optimization_get_previousChannel_error'
|
116
|
+
}, {
|
117
|
+
error: error
|
118
|
+
});
|
119
|
+
}
|
120
|
+
return _super5.call(this, _options, currentChannelType);
|
76
121
|
}
|
77
122
|
return _createClass(AMSCashierPayment);
|
78
123
|
}(AMSCheckout);
|
@@ -84,7 +129,7 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
|
|
84
129
|
var _options = Object.assign({}, options, {
|
85
130
|
product: productSceneEnum.VAULTING
|
86
131
|
});
|
87
|
-
return _super6.call(this, _options);
|
132
|
+
return _super6.call(this, _options, [componentSignEnum.CASHIER_PAYMENT_CARD]);
|
88
133
|
}
|
89
134
|
return _createClass(AMSVaulting);
|
90
135
|
}(AMSCheckout);
|
@@ -17,6 +17,8 @@ export declare const getIframeUrl: (iframeParams: {
|
|
17
17
|
locale: string;
|
18
18
|
instanceId: string;
|
19
19
|
renderDisplayType: renderDisplayTypeEnum;
|
20
|
+
isPreload?: string;
|
21
|
+
hostSign?: string;
|
20
22
|
}) => {
|
21
23
|
path: string;
|
22
24
|
locationSearch: string;
|
@@ -25,3 +27,4 @@ export declare const getIframeUrl: (iframeParams: {
|
|
25
27
|
* @description Create iframe
|
26
28
|
*/
|
27
29
|
export declare const createIframe: (mode: string, platform: 'mobile' | 'desktop') => HTMLIFrameElement;
|
30
|
+
export declare const createPreloadIframe: (channelType: any, version: any) => HTMLIFrameElement;
|
@@ -69,7 +69,11 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
69
69
|
extendInfo = iframeParams.extendInfo,
|
70
70
|
locale = iframeParams.locale,
|
71
71
|
instanceId = iframeParams.instanceId,
|
72
|
-
renderDisplayType = iframeParams.renderDisplayType
|
72
|
+
renderDisplayType = iframeParams.renderDisplayType,
|
73
|
+
_iframeParams$isPrelo = iframeParams.isPreload,
|
74
|
+
isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
|
75
|
+
_iframeParams$hostSig = iframeParams.hostSign,
|
76
|
+
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig;
|
73
77
|
var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
|
74
78
|
var initialScale = 1;
|
75
79
|
var scale = getViewPort('initial-scale') || initialScale;
|
@@ -90,7 +94,9 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
90
94
|
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
91
95
|
sdkVersion: sdkVersion,
|
92
96
|
refUrl: window.location.href,
|
93
|
-
_componentStartTime: "".concat(Date.now())
|
97
|
+
_componentStartTime: "".concat(Date.now()),
|
98
|
+
isPreload: isPreload || '',
|
99
|
+
hostSign: hostSign || ''
|
94
100
|
});
|
95
101
|
if (LOCAL_MOCK) urlParams.LOCAL_MOCK = LOCAL_MOCK;
|
96
102
|
if (requestHost) urlParams.requestHost = requestHost;
|
@@ -98,6 +104,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
98
104
|
if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
|
99
105
|
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
|
100
106
|
if (_displayType) urlParams.displayType = _displayType;
|
107
|
+
if (isPreload) urlParams.isPreload = isPreload;
|
101
108
|
var locationSearch = serialize(urlParams);
|
102
109
|
return {
|
103
110
|
path: path,
|
@@ -127,4 +134,18 @@ export var createIframe = function createIframe(mode, platform) {
|
|
127
134
|
iframe.style.opacity = none;
|
128
135
|
iframe.style.overflow = 'hidden';
|
129
136
|
return iframe;
|
137
|
+
};
|
138
|
+
export var createPreloadIframe = function createPreloadIframe(channelType, version) {
|
139
|
+
var id = "ams-checkout-component-".concat(channelType, "-").concat(version);
|
140
|
+
var iframe = document.createElement('iframe');
|
141
|
+
var iframeId = id;
|
142
|
+
var none = '1px';
|
143
|
+
var width = '1px';
|
144
|
+
iframe.id = iframeId;
|
145
|
+
iframe.style.height = none;
|
146
|
+
iframe.style.width = width;
|
147
|
+
iframe.style.border = none;
|
148
|
+
iframe.style.opacity = '0';
|
149
|
+
iframe.style.overflow = 'hidden';
|
150
|
+
return iframe;
|
130
151
|
};
|
@@ -13,6 +13,7 @@ export default class ComponentApp {
|
|
13
13
|
private popupApp?;
|
14
14
|
private appDomain;
|
15
15
|
private createIframeNode;
|
16
|
+
private createPreloadIframeNode;
|
16
17
|
private _selector;
|
17
18
|
private _appVersion;
|
18
19
|
private _isRetention;
|
@@ -40,6 +41,7 @@ export default class ComponentApp {
|
|
40
41
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
41
42
|
*/
|
42
43
|
setRender(renderFunc: IrenderFuncParams): void;
|
44
|
+
setPreloadRender(renderFunc: any): void;
|
43
45
|
private initSecurity;
|
44
46
|
private logDeviceId;
|
45
47
|
private getDeviceIdAndLog;
|
@@ -47,6 +49,7 @@ export default class ComponentApp {
|
|
47
49
|
* @description render iframe content
|
48
50
|
*/
|
49
51
|
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void>;
|
52
|
+
appendPreloadIframeNodes(componentSign: any, productSceneVersion: any): void;
|
50
53
|
private setParameterDefaultValues;
|
51
54
|
private renderInlineLoading;
|
52
55
|
private renderPopupLoading;
|
@@ -57,6 +60,7 @@ export default class ComponentApp {
|
|
57
60
|
private createActionQueryPromise;
|
58
61
|
private createSubmitPromise;
|
59
62
|
private cleanElement;
|
63
|
+
private createPreloadApp;
|
60
64
|
/**
|
61
65
|
* @description Create app
|
62
66
|
*/
|