@alipay/ams-checkout 0.0.1748918972-dev.0 → 0.0.1748918972-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 +4 -1
- package/esm/component/popupWindow.style.js +33 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +25 -2
- package/esm/constant/index.js +27 -5
- package/esm/core/component/element/elementController/index.d.ts +1 -1
- package/esm/core/component/element/elementController/index.js +29 -20
- package/esm/core/component/element/index.d.ts +0 -1
- package/esm/core/component/element/index.js +3 -6
- package/esm/core/component/element/type.d.ts +32 -33
- package/esm/core/component/element/type.js +20 -12
- package/esm/core/component/element/util.d.ts +9 -6
- package/esm/core/component/element/util.js +28 -29
- package/esm/core/component/oldElement/type.d.ts +3 -0
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/service/container/index.d.ts +7 -0
- package/esm/foundation/service/container/index.js +124 -20
- package/esm/foundation/service/container/popup.d.ts +9 -6
- package/esm/foundation/service/container/popup.js +3 -1
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/plugin/component/index.js +1 -1
- package/esm/types/index.d.ts +11 -1
- package/esm/types/index.js +2 -1
- package/esm/util/redirect.js +1 -1
- package/package.json +25 -3
@@ -13,17 +13,28 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
13
13
|
import { ERRORMESSAGE } from "../../../constant";
|
14
14
|
import { IElementStatus } from "../../../foundation";
|
15
15
|
import { getIframeUrl } from "../../../plugin/component/cashierApp";
|
16
|
-
import { DisplayTypeEnum, RedirectType, TargetEnum, terminalTypeEnum } from "../../../types";
|
16
|
+
import { DisplayTypeEnum, eventCodeEnum, RedirectType, TargetEnum, terminalTypeEnum } from "../../../types";
|
17
17
|
import { device } from "../../../util/index";
|
18
18
|
import CallApp from "../../../util/intl-callapp/es/main";
|
19
19
|
import { getComponentSign, parseSessionData } from "../index";
|
20
|
-
import { ELEMENT_ENVIRONMENT } from "./type";
|
21
|
-
var formatElementOption = function formatElementOption(options) {
|
20
|
+
import { ELEMENT_ENVIRONMENT, EventCallbackCode } from "./type";
|
21
|
+
export var formatElementOption = function formatElementOption(options) {
|
22
22
|
var environment = options.environment;
|
23
23
|
return _objectSpread(_objectSpread({}, options), {}, {
|
24
24
|
environment: (environment || ELEMENT_ENVIRONMENT.PROD).toLocaleLowerCase()
|
25
25
|
});
|
26
26
|
};
|
27
|
+
export var validateElementOption = function validateElementOption(options) {
|
28
|
+
if (!options.sessionData) {
|
29
|
+
var _options$onEventCallb;
|
30
|
+
options === null || options === void 0 || (_options$onEventCallb = options.onEventCallback) === null || _options$onEventCallb === void 0 || _options$onEventCallb.call(options, {
|
31
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
32
|
+
message: 'sessionData is empty'
|
33
|
+
});
|
34
|
+
return false;
|
35
|
+
}
|
36
|
+
return true;
|
37
|
+
};
|
27
38
|
|
28
39
|
/**
|
29
40
|
* 校验渲染条件
|
@@ -138,6 +149,7 @@ export function generateIframeSrc(_ref3) {
|
|
138
149
|
export function handleRedirect(data) {
|
139
150
|
var _data$isDestroy, _data$isCallApp, _data$callAppDetectSu;
|
140
151
|
var fromFastSdk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
152
|
+
var eventCallback = arguments.length > 2 ? arguments[2] : undefined;
|
141
153
|
console.log('local payment sdk new element redirect arg ----', this);
|
142
154
|
var _data = typeof data === 'string' ? {
|
143
155
|
normalUrl: data
|
@@ -171,10 +183,10 @@ export function handleRedirect(data) {
|
|
171
183
|
// .send();
|
172
184
|
var successCallback = function successCallback(type, url, durationInSeconds) {
|
173
185
|
// TODO
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
186
|
+
eventCallback({
|
187
|
+
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
188
|
+
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
189
|
+
});
|
178
190
|
var extra = {
|
179
191
|
redirectInfo: JSON.stringify(_data),
|
180
192
|
openType: type,
|
@@ -194,10 +206,10 @@ export function handleRedirect(data) {
|
|
194
206
|
// .send();
|
195
207
|
};
|
196
208
|
var failCallback = function failCallback(type, url, durationInSeconds) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
209
|
+
eventCallback({
|
210
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
211
|
+
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
212
|
+
});
|
201
213
|
var extra = {
|
202
214
|
redirectInfo: JSON.stringify(_data),
|
203
215
|
openType: type,
|
@@ -253,21 +265,9 @@ export function handleRedirect(data) {
|
|
253
265
|
return;
|
254
266
|
}
|
255
267
|
redirect({
|
256
|
-
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
257
|
-
|
258
|
-
|
259
|
-
}).catch(function () {
|
260
|
-
if (_data !== null && _data !== void 0 && _data.applinkUrl) failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
261
|
-
return redirect({
|
262
|
-
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
263
|
-
});
|
264
|
-
}).then(function () {
|
265
|
-
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
266
|
-
}).catch(function () {
|
267
|
-
if (_data !== null && _data !== void 0 && _data.schemeUrl) failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
268
|
-
return redirect({
|
269
|
-
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
270
|
-
});
|
268
|
+
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl,
|
269
|
+
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl,
|
270
|
+
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
271
271
|
}).then(function () {
|
272
272
|
successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
|
273
273
|
}).catch(function () {
|
@@ -288,7 +288,7 @@ export function redirect(data) {
|
|
288
288
|
window.location.href = normalUrl;
|
289
289
|
return;
|
290
290
|
}
|
291
|
-
reject(ERRORMESSAGE.
|
291
|
+
reject(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
292
292
|
};
|
293
293
|
var callAppFunc = function callAppFunc() {
|
294
294
|
if (!schemeUrl && !applinkUrl) {
|
@@ -474,5 +474,4 @@ export var isElementPad = function isElementPad() {
|
|
474
474
|
};
|
475
475
|
export var isElementPC = function isElementPC() {
|
476
476
|
return !isElementMobile();
|
477
|
-
};
|
478
|
-
export { formatElementOption };
|
477
|
+
};
|
@@ -10,6 +10,9 @@ export declare enum ElementPaymentEvent {
|
|
10
10
|
SIZE_CHANGE = "onSizeChange",
|
11
11
|
LAUNCH = "onLaunch",
|
12
12
|
CALLBACK = "callback",
|
13
|
+
/**
|
14
|
+
* @deprecated 已废弃 请使用eventCallback
|
15
|
+
*/
|
13
16
|
SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
|
14
17
|
LOG = "log",
|
15
18
|
HANDLE_PAYMENT = "handlePayment"
|
@@ -435,7 +435,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
435
435
|
window.location.href = normalUrl;
|
436
436
|
return;
|
437
437
|
}
|
438
|
-
reject(ERRORMESSAGE.
|
438
|
+
reject(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
439
439
|
};
|
440
440
|
var callAppFunc = function callAppFunc() {
|
441
441
|
if (!schemeUrl && !applinkUrl) {
|
@@ -12,6 +12,8 @@ export declare class ContainerService implements Service {
|
|
12
12
|
private displayInfo;
|
13
13
|
private webApp;
|
14
14
|
private _webAppHeartBeatTimeoutFn;
|
15
|
+
private clientHeight;
|
16
|
+
private boundFocusResizeChange;
|
15
17
|
private customizedLoadingListener;
|
16
18
|
destroy(): void;
|
17
19
|
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
@@ -22,13 +24,18 @@ export declare class ContainerService implements Service {
|
|
22
24
|
dismissLoading(isKeepMockup?: boolean): void;
|
23
25
|
customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
|
24
26
|
startHideAnim(): void;
|
27
|
+
private handleAccountFocus;
|
25
28
|
private addCapabilityToEventCenter;
|
26
29
|
private addCapabilityToApiBusManager;
|
27
30
|
private updateMaskCloseBtn;
|
28
31
|
private handleSizeChanged;
|
32
|
+
private focusResizeChange;
|
33
|
+
private focusScrollFixed;
|
29
34
|
private handleAppHeartBeat;
|
30
35
|
private changeCloseBtnVisibility;
|
31
36
|
private handleMaskCloseBtnShow;
|
32
37
|
private handleCloseButtonTheme;
|
38
|
+
private handlePopupWindow;
|
39
|
+
private handlePopWindow;
|
33
40
|
getWebApp(): HTMLIFrameElement;
|
34
41
|
}
|
@@ -35,6 +35,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
35
35
|
_defineProperty(this, "displayInfo", void 0);
|
36
36
|
_defineProperty(this, "webApp", void 0);
|
37
37
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
38
|
+
_defineProperty(this, "clientHeight", void 0);
|
39
|
+
_defineProperty(this, "boundFocusResizeChange", void 0);
|
38
40
|
// if this variable is true, SDK will invoke listener instead of showing loading
|
39
41
|
_defineProperty(this, "customizedLoadingListener", void 0);
|
40
42
|
}
|
@@ -46,6 +48,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
46
48
|
value: function init(initOptions, instanceId, sdkMetaData) {
|
47
49
|
this.instanceId = instanceId;
|
48
50
|
this.sdkMetaData = sdkMetaData;
|
51
|
+
this.clientHeight = Math.max(window.innerHeight, window.visualViewport.height);
|
49
52
|
this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
|
50
53
|
this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
|
51
54
|
this.popupManager = new PopupManager();
|
@@ -55,6 +58,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
55
58
|
this.addCapabilityToEventCenter();
|
56
59
|
}
|
57
60
|
this.addCapabilityToApiBusManager();
|
61
|
+
// bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
|
62
|
+
this.boundFocusResizeChange = this.focusResizeChange.bind(this);
|
58
63
|
}
|
59
64
|
}, {
|
60
65
|
key: "update",
|
@@ -156,6 +161,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
156
161
|
container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.displayInfo.platform));
|
157
162
|
}
|
158
163
|
}
|
164
|
+
}, {
|
165
|
+
key: "handleAccountFocus",
|
166
|
+
value: function handleAccountFocus(focus) {
|
167
|
+
var _window$visualViewpor, _window;
|
168
|
+
// 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
|
169
|
+
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
|
170
|
+
(_window = window) === null || _window === void 0 || _window.removeEventListener('resize', this.boundFocusResizeChange);
|
171
|
+
// 只有聚焦才监听,失焦后移除,避免影响别的场景
|
172
|
+
if (focus) {
|
173
|
+
var _window$visualViewpor2;
|
174
|
+
// 监听页面visualViewport的高度变化,适用于主流机型更精准获取当前页面高度
|
175
|
+
(_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.boundFocusResizeChange);
|
176
|
+
// 兼容visualViewport处理不到的场景,一般存在于老版本浏览器
|
177
|
+
window.addEventListener('resize', this.boundFocusResizeChange);
|
178
|
+
}
|
179
|
+
}
|
159
180
|
}, {
|
160
181
|
key: "addCapabilityToEventCenter",
|
161
182
|
value: function addCapabilityToEventCenter() {
|
@@ -174,19 +195,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
174
195
|
});
|
175
196
|
});
|
176
197
|
this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
|
177
|
-
|
178
|
-
if (data.paymentElementOldModel) return;
|
179
|
-
insertStyleSheet();
|
180
|
-
_this.popupManager.popup(_objectSpread({
|
181
|
-
platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
|
182
|
-
}, data)).then(function () {
|
183
|
-
_this.eventCenter.addIFrame(_this.popupManager.popupApp);
|
184
|
-
}).catch(function (error) {
|
185
|
-
_this.logService.logError({
|
186
|
-
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
187
|
-
}, error);
|
188
|
-
_this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
189
|
-
});
|
198
|
+
_this.handlePopupWindow(data);
|
190
199
|
});
|
191
200
|
this.eventCenter.listen(EVENT.popWindow.name, function () {
|
192
201
|
_this.popupManager.pop();
|
@@ -195,7 +204,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
195
204
|
_this.handleSizeChanged(_objectSpread({}, data));
|
196
205
|
});
|
197
206
|
this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
|
198
|
-
_this.handleCloseButtonTheme(data.
|
207
|
+
_this.handleCloseButtonTheme(data.style);
|
199
208
|
_this.changeCloseBtnVisibility(true);
|
200
209
|
});
|
201
210
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
@@ -207,6 +216,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
207
216
|
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
208
217
|
_this.handleAppHeartBeat();
|
209
218
|
});
|
219
|
+
/**
|
220
|
+
* 目前仅用于ESP V2的 web sdk
|
221
|
+
* 原因: 在账户输入页和OTP页面的h5场景下键盘弹起页面会有问题,iframe有固定高度,键盘弹起时应用层不会触发大小变化
|
222
|
+
* account账号输入页需要在sdk监听键盘弹起后高度变化并修改iframe及iframe外层容器,account需要按钮置底的放在键盘上面,必须修改高度而不是让容器定位
|
223
|
+
* otp页面需要在聚焦时给iframe及外层容器设置fixed定位,让页面不被弹起
|
224
|
+
* 目的: esp页面输入框聚焦/失焦后给sdk发送消息
|
225
|
+
*/
|
226
|
+
this.eventCenter.listen(EVENT.inputFocus.name, function (data) {
|
227
|
+
// 账号输入页需要修改iframe高度
|
228
|
+
if (data.source === 'ESP_V2' && data.type === 'account') {
|
229
|
+
_this.handleAccountFocus(data.focus);
|
230
|
+
// otp页面需要定位元素
|
231
|
+
} else if (data.source === 'ESP_V2' && data.type === 'otp') {
|
232
|
+
_this.focusScrollFixed(data.focus);
|
233
|
+
}
|
234
|
+
});
|
210
235
|
}
|
211
236
|
}, {
|
212
237
|
key: "addCapabilityToApiBusManager",
|
@@ -229,9 +254,9 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
229
254
|
}, {
|
230
255
|
key: "handleSizeChanged",
|
231
256
|
value: function handleSizeChanged(data) {
|
232
|
-
var _this$
|
233
|
-
appendAliasContainerId = _this$
|
234
|
-
selector = _this$
|
257
|
+
var _this$displayInfo2 = this.displayInfo,
|
258
|
+
appendAliasContainerId = _this$displayInfo2.appendAliasContainerId,
|
259
|
+
selector = _this$displayInfo2.selector;
|
235
260
|
var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
|
236
261
|
if (!this.webApp || !this.displayInfo) {
|
237
262
|
return;
|
@@ -267,6 +292,50 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
267
292
|
this.webApp.style.height = "".concat(data.height, "px");
|
268
293
|
}
|
269
294
|
}
|
295
|
+
|
296
|
+
// 目前仅用于esp账号输入页聚焦
|
297
|
+
}, {
|
298
|
+
key: "focusResizeChange",
|
299
|
+
value: function focusResizeChange() {
|
300
|
+
var _window2;
|
301
|
+
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
302
|
+
var webPageHeightRatio = 0.9;
|
303
|
+
var browserPageHeightFocusRatio = 0.9;
|
304
|
+
// sdk层才能拿到当前键盘弹起后页面的高度
|
305
|
+
var height = ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.visualViewport) === null || _window2 === void 0 ? void 0 : _window2.height) || window.innerHeight;
|
306
|
+
height = height * webPageHeightRatio;
|
307
|
+
height = height * browserPageHeightFocusRatio;
|
308
|
+
// 调用handleSizeChanged修改iframe高度
|
309
|
+
this.handleSizeChanged({
|
310
|
+
width: 0,
|
311
|
+
height: height
|
312
|
+
});
|
313
|
+
}
|
314
|
+
|
315
|
+
// 目前仅用于esp otp页面账号聚焦
|
316
|
+
}, {
|
317
|
+
key: "focusScrollFixed",
|
318
|
+
value: function focusScrollFixed(focus) {
|
319
|
+
// 获取iframe dom元素
|
320
|
+
var _this$displayInfo3 = this.displayInfo,
|
321
|
+
appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
|
322
|
+
selector = _this$displayInfo3.selector;
|
323
|
+
var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
|
324
|
+
if (!this.webApp || !this.displayInfo) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
var cashier = document.getElementById(cashierId);
|
328
|
+
if (!cashier) return;
|
329
|
+
// 输入框聚焦时修改定位信息和top距离
|
330
|
+
if (focus) {
|
331
|
+
cashier.style.setProperty('position', 'fixed', 'important');
|
332
|
+
cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
|
333
|
+
} else {
|
334
|
+
// 失焦时移除定位信息
|
335
|
+
cashier.style.removeProperty('position');
|
336
|
+
cashier.style.removeProperty('top');
|
337
|
+
}
|
338
|
+
}
|
270
339
|
}, {
|
271
340
|
key: "handleAppHeartBeat",
|
272
341
|
value: function handleAppHeartBeat() {
|
@@ -326,12 +395,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
326
395
|
}
|
327
396
|
}, {
|
328
397
|
key: "handleCloseButtonTheme",
|
329
|
-
value: function handleCloseButtonTheme(
|
330
|
-
if (!
|
398
|
+
value: function handleCloseButtonTheme(style) {
|
399
|
+
if (!style) return;
|
331
400
|
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
332
401
|
var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
|
333
402
|
var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
|
334
|
-
if (
|
403
|
+
if (style === 'light') {
|
335
404
|
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
|
336
405
|
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
337
406
|
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
@@ -341,6 +410,41 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
341
410
|
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
342
411
|
}
|
343
412
|
}
|
413
|
+
|
414
|
+
// SDK主动打开弹框
|
415
|
+
}, {
|
416
|
+
key: "handlePopupWindow",
|
417
|
+
value: function handlePopupWindow(data) {
|
418
|
+
var _this$displayInfo4,
|
419
|
+
_this3 = this;
|
420
|
+
if (data.paymentElementOldModel) return;
|
421
|
+
insertStyleSheet();
|
422
|
+
this.popupManager.popup(_objectSpread({
|
423
|
+
platform: (_this$displayInfo4 = this.displayInfo) === null || _this$displayInfo4 === void 0 ? void 0 : _this$displayInfo4.platform,
|
424
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
425
|
+
onCloseOnLoading: function onCloseOnLoading() {
|
426
|
+
return _this3.handlePopWindow(data);
|
427
|
+
}
|
428
|
+
}, data)).then(function () {
|
429
|
+
_this3.eventCenter.addIFrame(_this3.popupManager.popupApp);
|
430
|
+
}).catch(function (error) {
|
431
|
+
_this3.logService.logError({
|
432
|
+
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
433
|
+
}, error);
|
434
|
+
_this3.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
435
|
+
});
|
436
|
+
}
|
437
|
+
|
438
|
+
// SDK主动关闭弹框
|
439
|
+
}, {
|
440
|
+
key: "handlePopWindow",
|
441
|
+
value: function handlePopWindow(data) {
|
442
|
+
this.popupManager.pop();
|
443
|
+
this.eventCenter.dispatchToApp({
|
444
|
+
event: EVENT.popWindow.name,
|
445
|
+
data: data
|
446
|
+
});
|
447
|
+
}
|
344
448
|
}, {
|
345
449
|
key: "getWebApp",
|
346
450
|
value: function getWebApp() {
|
@@ -1,4 +1,12 @@
|
|
1
1
|
import { PlatformEnum } from '../../../types';
|
2
|
+
export type IPopUpParams = {
|
3
|
+
url: string;
|
4
|
+
widthPadding: number;
|
5
|
+
heightPadding: number;
|
6
|
+
platform: PlatformEnum;
|
7
|
+
showCloseOnLoading: boolean;
|
8
|
+
onCloseOnLoading: () => void;
|
9
|
+
};
|
2
10
|
/**
|
3
11
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
4
12
|
* @date 2024/9/22
|
@@ -7,11 +15,6 @@ export declare class PopupManager {
|
|
7
15
|
private popupUrlQuery;
|
8
16
|
popupApp: HTMLIFrameElement;
|
9
17
|
setPopupUrlQuery(queryParams: string): void;
|
10
|
-
popup(data:
|
11
|
-
url: string;
|
12
|
-
widthPadding: number;
|
13
|
-
heightPadding: number;
|
14
|
-
platform: PlatformEnum;
|
15
|
-
}): Promise<void>;
|
18
|
+
popup(data: IPopUpParams): Promise<void>;
|
16
19
|
pop(): void;
|
17
20
|
}
|
@@ -53,7 +53,9 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
53
53
|
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
54
54
|
device: data === null || data === void 0 ? void 0 : data.platform,
|
55
55
|
url: pageUrl,
|
56
|
-
loadingConfig: undefined
|
56
|
+
loadingConfig: undefined,
|
57
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
58
|
+
onCloseOnLoading: data.onCloseOnLoading
|
57
59
|
});
|
58
60
|
case 11:
|
59
61
|
this.popupApp = _context.sent;
|
@@ -69,26 +69,42 @@ export var redirect = function redirect(payload, instanceId) {
|
|
69
69
|
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
70
70
|
}
|
71
71
|
});
|
72
|
+
var callApplinkUrl = function callApplinkUrl() {
|
73
|
+
try {
|
74
|
+
callAppLib.open({
|
75
|
+
link: payload.applinkUrl,
|
76
|
+
fallback: function fallback() {
|
77
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
78
|
+
// Applink evoke failed, try to use scheme url
|
79
|
+
callSchemeUrl();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
} catch (error) {
|
83
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
84
|
+
// Applink evoke failed, try to use scheme url
|
85
|
+
callSchemeUrl();
|
86
|
+
}
|
87
|
+
};
|
72
88
|
var callSchemeUrl = function callSchemeUrl() {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
try {
|
90
|
+
callAppLib.open({
|
91
|
+
scheme: payload.schemeUrl,
|
92
|
+
fallback: function fallback() {
|
93
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
94
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
95
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
96
|
+
window.location.href = payload.url;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
} catch (error) {
|
100
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
101
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
102
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
103
|
+
window.location.href = payload.url;
|
104
|
+
}
|
82
105
|
};
|
83
106
|
if (payload.applinkUrl) {
|
84
|
-
|
85
|
-
link: payload.applinkUrl,
|
86
|
-
fallback: function fallback() {
|
87
|
-
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
88
|
-
// Applink evoke failed, try to use scheme url
|
89
|
-
callSchemeUrl();
|
90
|
-
}
|
91
|
-
});
|
107
|
+
callApplinkUrl();
|
92
108
|
} else if (payload.schemeUrl) {
|
93
109
|
callSchemeUrl();
|
94
110
|
}
|
@@ -116,7 +132,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
116
132
|
};
|
117
133
|
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
118
134
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
119
|
-
code: eventCodeEnum.
|
135
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
120
136
|
message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
|
121
137
|
});
|
122
138
|
serviceProvider.getService('Log').logInfo({
|
@@ -1573,7 +1573,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1573
1573
|
};
|
1574
1574
|
var failCallback = function failCallback(type, url, durationInSeconds) {
|
1575
1575
|
_this8.dispatchToSDK(EVENT.eventCallback.name, {
|
1576
|
-
code: eventCodeEnum.
|
1576
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
1577
1577
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
1578
1578
|
});
|
1579
1579
|
var extra = {
|
package/esm/types/index.d.ts
CHANGED
@@ -641,8 +641,18 @@ export declare enum eventCodeEnum {
|
|
641
641
|
SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
|
642
642
|
SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
|
643
643
|
SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
|
644
|
-
|
644
|
+
/**
|
645
|
+
* 拉取WEB应用&收银台失败
|
646
|
+
*/
|
647
|
+
SDK_LAUNCH_PAYMENT_APP_ERROR = "SDK_LAUNCH_PAYMENT_APP_ERROR",
|
648
|
+
/**
|
649
|
+
* 拉取WEB应用&收银台成功
|
650
|
+
*/
|
645
651
|
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
|
652
|
+
/**
|
653
|
+
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
654
|
+
*/
|
655
|
+
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
|
646
656
|
SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
|
647
657
|
SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
|
648
658
|
SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
|
package/esm/types/index.js
CHANGED
@@ -182,8 +182,9 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
|
182
182
|
eventCodeEnum["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
|
183
183
|
eventCodeEnum["SDK_INIT_PARAMETER_ERROR"] = "SDK_INIT_PARAMETER_ERROR";
|
184
184
|
eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
|
185
|
-
eventCodeEnum["
|
185
|
+
eventCodeEnum["SDK_LAUNCH_PAYMENT_APP_ERROR"] = "SDK_LAUNCH_PAYMENT_APP_ERROR";
|
186
186
|
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
|
187
|
+
eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
|
187
188
|
eventCodeEnum["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
|
188
189
|
eventCodeEnum["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
|
189
190
|
eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
|
package/esm/util/redirect.js
CHANGED
@@ -16,7 +16,7 @@ export function redirect(data) {
|
|
16
16
|
window.location.href = normalUrl;
|
17
17
|
return;
|
18
18
|
}
|
19
|
-
reject(ERRORMESSAGE.
|
19
|
+
reject(ERRORMESSAGE.SDK_LAUNCH_PAYMENT_APP_ERROR.CALL_APP_URL_ERROR);
|
20
20
|
};
|
21
21
|
var callAppFunc = function callAppFunc() {
|
22
22
|
if (!schemeUrl && !applinkUrl) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@alipay/ams-checkout",
|
3
|
-
"version": "0.0.1748918972-dev.
|
3
|
+
"version": "0.0.1748918972-dev.1",
|
4
4
|
"description": "",
|
5
5
|
"author": "",
|
6
6
|
"main": "esm/index.js",
|
@@ -16,14 +16,32 @@
|
|
16
16
|
"scripts": {
|
17
17
|
"build": "father build",
|
18
18
|
"build:w": "father dev",
|
19
|
-
"dev": "father dev",
|
20
19
|
"ci": "npm run lint",
|
21
20
|
"cov": "jest --coverage",
|
21
|
+
"dev": "father dev",
|
22
22
|
"format": "prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"",
|
23
23
|
"lint": "eslint ./src",
|
24
24
|
"test": "jest --silent",
|
25
25
|
"tsc": "tsc --noEmit"
|
26
26
|
},
|
27
|
+
"commitlint": {
|
28
|
+
"extends": [
|
29
|
+
"@commitlint/config-conventional"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
"lint-staged": {
|
33
|
+
"*.{js,jsx}": [
|
34
|
+
"eslint --fix",
|
35
|
+
"prettier --write"
|
36
|
+
],
|
37
|
+
"*.{ts,tsx}": [
|
38
|
+
"eslint --fix",
|
39
|
+
"prettier --parser=typescript --write"
|
40
|
+
],
|
41
|
+
"*.{md,json}": [
|
42
|
+
"prettier --write"
|
43
|
+
]
|
44
|
+
},
|
27
45
|
"dependencies": {
|
28
46
|
"axios": "^1.3.4",
|
29
47
|
"uuid": "^9.0.0"
|
@@ -31,6 +49,8 @@
|
|
31
49
|
"devDependencies": {
|
32
50
|
"@babel/core": "^7.20.7",
|
33
51
|
"@babel/preset-env": "^7.20.2",
|
52
|
+
"@commitlint/cli": "^17.3.0",
|
53
|
+
"@commitlint/config-conventional": "^17.3.0",
|
34
54
|
"@testing-library/jest-dom": "^5.1.1",
|
35
55
|
"@testing-library/react": "^9.5.0",
|
36
56
|
"@types/jest": "^29.2.4",
|
@@ -52,7 +72,9 @@
|
|
52
72
|
"ts-node": "^10.9.1",
|
53
73
|
"typescript": "^4.9.5"
|
54
74
|
},
|
55
|
-
"engines": {
|
75
|
+
"engines": {
|
76
|
+
"install-node": "18"
|
77
|
+
},
|
56
78
|
"publishConfig": {
|
57
79
|
"access": "public"
|
58
80
|
}
|