@alipay/ams-checkout 0.0.1766457560-dev.0 → 0.0.1766664288-dev.0
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/ams-checkout.js +3 -3
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/element/config.d.ts +10 -0
- package/esm/core/component/element/config.js +17 -0
- package/esm/core/component/element/elementController/index.d.ts +4 -2
- package/esm/core/component/element/elementController/index.js +45 -21
- package/esm/core/component/element/index.d.ts +3 -2
- package/esm/core/component/element/index.js +7 -2
- package/esm/core/component/element/type.d.ts +14 -0
- package/esm/core/component/element/type.js +7 -1
- package/esm/core/component/element/util.d.ts +1 -0
- package/esm/core/component/element/util.js +13 -12
- package/esm/foundation/service/log/index.d.ts +0 -1
- package/esm/foundation/service/log/index.js +3 -40
- package/esm/main.js +1 -2
- package/esm/util/logger.d.ts +0 -1
- package/esm/util/logger.js +3 -40
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum ProductScene {
|
|
2
|
+
EXPRESS_CHECKOUT = "EXPRESS_CHECKOUT",
|
|
3
|
+
ELEMENT_PAYMENT = "ELEMENT_PAYMENT"
|
|
4
|
+
}
|
|
5
|
+
interface EventScenario {
|
|
6
|
+
eventName: ProductScene;
|
|
7
|
+
supportedEvents: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const productEventScenarios: EventScenario[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// 定义产品场景的枚举
|
|
2
|
+
export var ProductScene = /*#__PURE__*/function (ProductScene) {
|
|
3
|
+
ProductScene["EXPRESS_CHECKOUT"] = "EXPRESS_CHECKOUT";
|
|
4
|
+
ProductScene["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT";
|
|
5
|
+
return ProductScene;
|
|
6
|
+
}({});
|
|
7
|
+
|
|
8
|
+
// 定义一个事件场景的接口
|
|
9
|
+
|
|
10
|
+
// 存储产品场景及支持的事件名
|
|
11
|
+
export var productEventScenarios = [{
|
|
12
|
+
eventName: ProductScene.EXPRESS_CHECKOUT,
|
|
13
|
+
supportedEvents: [] // 没有支持的事件
|
|
14
|
+
}, {
|
|
15
|
+
eventName: ProductScene.ELEMENT_PAYMENT,
|
|
16
|
+
supportedEvents: ['paymentMethodChanged'] // 支持的事件
|
|
17
|
+
}];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressMountOptions, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
|
1
|
+
import { AddressMountOptions, EventDataMap, EVENTNAME, ICommonApiResponse, IElementOptions, IPaymentApiResponse, LinkAuthMountOptions, PaymentMountOptions, SubmitFuncParams } from '../type';
|
|
2
2
|
declare class ElementController {
|
|
3
3
|
private options;
|
|
4
4
|
private elementContainer;
|
|
@@ -33,7 +33,7 @@ declare class ElementController {
|
|
|
33
33
|
validateFields(): Promise<{
|
|
34
34
|
isValid: boolean;
|
|
35
35
|
}>;
|
|
36
|
-
submitPayment(): Promise<IPaymentApiResponse>;
|
|
36
|
+
submitPayment(submitParams: SubmitFuncParams): Promise<IPaymentApiResponse>;
|
|
37
37
|
private changeLoading;
|
|
38
38
|
private addEventListener;
|
|
39
39
|
private sendRequestAndWaitWebLaunch;
|
|
@@ -44,5 +44,7 @@ declare class ElementController {
|
|
|
44
44
|
private destroyHandle;
|
|
45
45
|
destroy(): void;
|
|
46
46
|
private setControllerStatusOrView;
|
|
47
|
+
on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
|
|
48
|
+
private isEventAllowed;
|
|
47
49
|
}
|
|
48
50
|
export default ElementController;
|
|
@@ -40,8 +40,9 @@ import { IContainerStatus } from "../elementContainerService/containerService";
|
|
|
40
40
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
41
41
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
42
42
|
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
43
|
-
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeStringify, showToast } from "../util";
|
|
43
|
+
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeParse, safeStringify, showToast } from "../util";
|
|
44
44
|
import { convertPaymentSession } from "../../../../foundation/utils/payment_context_utils";
|
|
45
|
+
import { productEventScenarios, ProductScene } from "../config";
|
|
45
46
|
var TIMEOUT_DURATION = 10000;
|
|
46
47
|
var ElementController = /*#__PURE__*/function () {
|
|
47
48
|
function ElementController(options) {
|
|
@@ -337,7 +338,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
337
338
|
}, {
|
|
338
339
|
key: "submitPayment",
|
|
339
340
|
value: function () {
|
|
340
|
-
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
341
|
+
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
|
|
341
342
|
var _this3 = this;
|
|
342
343
|
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
343
344
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -369,7 +370,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
369
370
|
_context4.next = 11;
|
|
370
371
|
return new Promise( /*#__PURE__*/function () {
|
|
371
372
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
372
|
-
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2,
|
|
373
|
+
var that, recordResultCallback, params, processStep, _yield$_this3$onValid2, _data, errorResult;
|
|
373
374
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
374
375
|
while (1) switch (_context3.prev = _context3.next) {
|
|
375
376
|
case 0:
|
|
@@ -422,7 +423,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
422
423
|
}
|
|
423
424
|
}, _callee2);
|
|
424
425
|
}));
|
|
425
|
-
return function processStep(
|
|
426
|
+
return function processStep(_x3, _x4) {
|
|
426
427
|
return _ref4.apply(this, arguments);
|
|
427
428
|
};
|
|
428
429
|
}(); // 按顺序处理步骤
|
|
@@ -445,29 +446,28 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
445
446
|
return _context3.abrupt("return");
|
|
446
447
|
case 14:
|
|
447
448
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
448
|
-
_context3.next =
|
|
449
|
+
_context3.next = 22;
|
|
449
450
|
break;
|
|
450
451
|
}
|
|
451
|
-
|
|
452
|
+
params.handleAction = (submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleAction) || false;
|
|
453
|
+
_context3.next = 18;
|
|
452
454
|
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
|
453
|
-
case
|
|
455
|
+
case 18:
|
|
454
456
|
_yield$_this3$onValid2 = _context3.sent;
|
|
455
|
-
|
|
457
|
+
_data = _yield$_this3$onValid2.data;
|
|
456
458
|
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
457
459
|
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
458
|
-
recordResult =
|
|
460
|
+
recordResult = _data;
|
|
459
461
|
recordResultCallback(recordResult);
|
|
460
|
-
case
|
|
462
|
+
case 22:
|
|
461
463
|
_context3.next = 30;
|
|
462
464
|
break;
|
|
463
|
-
case
|
|
464
|
-
_context3.prev =
|
|
465
|
+
case 24:
|
|
466
|
+
_context3.prev = 24;
|
|
465
467
|
_context3.t0 = _context3["catch"](2);
|
|
466
|
-
// 修复error为{}空对象的问题,上报stack&message
|
|
467
|
-
errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
|
|
468
468
|
errorResult = {
|
|
469
469
|
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.ERR_DATA_STRUCT_UNRECOGNIZED), {}, {
|
|
470
|
-
context:
|
|
470
|
+
context: JSON.stringify(_context3.t0)
|
|
471
471
|
}),
|
|
472
472
|
status: PaymentStatus.FAIL
|
|
473
473
|
};
|
|
@@ -482,9 +482,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
482
482
|
case "end":
|
|
483
483
|
return _context3.stop();
|
|
484
484
|
}
|
|
485
|
-
}, _callee3, null, [[2,
|
|
485
|
+
}, _callee3, null, [[2, 24]]);
|
|
486
486
|
}));
|
|
487
|
-
return function (
|
|
487
|
+
return function (_x2) {
|
|
488
488
|
return _ref3.apply(this, arguments);
|
|
489
489
|
};
|
|
490
490
|
}());
|
|
@@ -509,7 +509,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
509
509
|
}
|
|
510
510
|
}, _callee4, this, [[8,, 12, 17]]);
|
|
511
511
|
}));
|
|
512
|
-
function submitPayment() {
|
|
512
|
+
function submitPayment(_x) {
|
|
513
513
|
return _submitPayment.apply(this, arguments);
|
|
514
514
|
}
|
|
515
515
|
return submitPayment;
|
|
@@ -654,7 +654,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
654
654
|
}
|
|
655
655
|
}, _callee5, this, [[1, 20]]);
|
|
656
656
|
}));
|
|
657
|
-
function sendRequestAndWaitWebLaunch(
|
|
657
|
+
function sendRequestAndWaitWebLaunch(_x5, _x6) {
|
|
658
658
|
return _sendRequestAndWaitWebLaunch.apply(this, arguments);
|
|
659
659
|
}
|
|
660
660
|
return sendRequestAndWaitWebLaunch;
|
|
@@ -787,7 +787,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
787
787
|
}
|
|
788
788
|
}, _callee6);
|
|
789
789
|
}));
|
|
790
|
-
return function (
|
|
790
|
+
return function (_x8) {
|
|
791
791
|
return _ref5.apply(this, arguments);
|
|
792
792
|
};
|
|
793
793
|
}()));
|
|
@@ -797,7 +797,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
797
797
|
}
|
|
798
798
|
}, _callee7);
|
|
799
799
|
}));
|
|
800
|
-
function updatePayment(
|
|
800
|
+
function updatePayment(_x7) {
|
|
801
801
|
return _updatePayment.apply(this, arguments);
|
|
802
802
|
}
|
|
803
803
|
return updatePayment;
|
|
@@ -834,6 +834,30 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
834
834
|
(_this$onStatusChangeC = this.onStatusChangeCallback) === null || _this$onStatusChangeC === void 0 || _this$onStatusChangeC.call(this, "\u72B6\u6001\u7531 ".concat(_status, " \u53D8\u66F4\u4E3A ").concat(status));
|
|
835
835
|
this.elementContainer.setStatus(status);
|
|
836
836
|
}
|
|
837
|
+
}, {
|
|
838
|
+
key: "on",
|
|
839
|
+
value: function on(event, callback) {
|
|
840
|
+
if (!this.isEventAllowed(event)) {
|
|
841
|
+
return console.error("Event \"".concat(event, "\" is not allowed."));
|
|
842
|
+
}
|
|
843
|
+
this.serviceMap.EventCenter.listen(event, function (data) {
|
|
844
|
+
callback === null || callback === void 0 || callback(data);
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
}, {
|
|
848
|
+
key: "isEventAllowed",
|
|
849
|
+
value: function isEventAllowed(event) {
|
|
850
|
+
var _safeParse, _this$elementContaine;
|
|
851
|
+
// 获取当前场景
|
|
852
|
+
var isExpressCheckout = (_safeParse = safeParse((_this$elementContaine = this.elementContainer.getPaymentContext()) === null || _this$elementContaine === void 0 || (_this$elementContaine = _this$elementContaine.paymentSessionObj) === null || _this$elementContaine === void 0 ? void 0 : _this$elementContaine.extendInfo)) === null || _safeParse === void 0 ? void 0 : _safeParse.expressCheckout;
|
|
853
|
+
var productScene = isExpressCheckout ? ProductScene.EXPRESS_CHECKOUT : ProductScene.ELEMENT_PAYMENT;
|
|
854
|
+
// 查找对应的产品场景
|
|
855
|
+
var scenario = productEventScenarios.find(function (s) {
|
|
856
|
+
return s.eventName === productScene;
|
|
857
|
+
});
|
|
858
|
+
// 检查场景存在且事件名称在支持的事件列表中
|
|
859
|
+
return scenario !== undefined && scenario.supportedEvents.includes(event);
|
|
860
|
+
}
|
|
837
861
|
}]);
|
|
838
862
|
return ElementController;
|
|
839
863
|
}();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IElementOptions, PaymentMountOptions } from './type';
|
|
1
|
+
import { EventDataMap, EVENTNAME, IElementOptions, PaymentMountOptions, SubmitFuncParams } from './type';
|
|
2
2
|
export declare class ElementComponent {
|
|
3
3
|
private options;
|
|
4
4
|
private controller;
|
|
@@ -8,6 +8,7 @@ export declare class ElementComponent {
|
|
|
8
8
|
validateFields(): Promise<{
|
|
9
9
|
isValid: boolean;
|
|
10
10
|
}>;
|
|
11
|
-
submitPayment(): Promise<import("./type").IPaymentApiResponse>;
|
|
11
|
+
submitPayment(params: SubmitFuncParams): Promise<import("./type").IPaymentApiResponse>;
|
|
12
12
|
destroy(): void;
|
|
13
|
+
on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
|
|
13
14
|
}
|
|
@@ -62,14 +62,19 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
|
62
62
|
}
|
|
63
63
|
}, {
|
|
64
64
|
key: "submitPayment",
|
|
65
|
-
value: function submitPayment() {
|
|
66
|
-
return this.controller.submitPayment();
|
|
65
|
+
value: function submitPayment(params) {
|
|
66
|
+
return this.controller.submitPayment(params);
|
|
67
67
|
}
|
|
68
68
|
}, {
|
|
69
69
|
key: "destroy",
|
|
70
70
|
value: function destroy() {
|
|
71
71
|
this.controller.destroy();
|
|
72
72
|
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "on",
|
|
75
|
+
value: function on(event, callback) {
|
|
76
|
+
this.controller.on(event, callback);
|
|
77
|
+
}
|
|
73
78
|
}]);
|
|
74
79
|
return ElementComponent;
|
|
75
80
|
}();
|
|
@@ -261,9 +261,13 @@ export interface AddressSubmitData {
|
|
|
261
261
|
shippingId: string;
|
|
262
262
|
actionFlag?: 'I' | 'U' | 'D';
|
|
263
263
|
}
|
|
264
|
+
export interface SubmitFuncParams {
|
|
265
|
+
handleAction?: boolean;
|
|
266
|
+
}
|
|
264
267
|
export interface SubmitServiceParams extends PaymentSubmitData {
|
|
265
268
|
accountInfo: AuthSubmitData['accountInfo'];
|
|
266
269
|
shipping?: AddressSubmitData;
|
|
270
|
+
handleAction?: boolean;
|
|
267
271
|
}
|
|
268
272
|
interface SubmitResultActionForm extends ActionForm {
|
|
269
273
|
paymentCodeExpireTime: string;
|
|
@@ -443,4 +447,14 @@ export declare enum EXPOSURE_API_EVENT {
|
|
|
443
447
|
VALIDATAFIELDS = "validateFields",
|
|
444
448
|
UPDATEPAYMENT = "updatePayment"
|
|
445
449
|
}
|
|
450
|
+
export declare enum EVENTNAME {
|
|
451
|
+
PAYMENTMETHODCHANGED = "paymentMethodChanged"
|
|
452
|
+
}
|
|
453
|
+
interface PaymentMethodChangedData {
|
|
454
|
+
type: string;
|
|
455
|
+
name: string;
|
|
456
|
+
}
|
|
457
|
+
export interface EventDataMap {
|
|
458
|
+
[EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
|
|
459
|
+
}
|
|
446
460
|
export {};
|
|
@@ -147,4 +147,10 @@ export var EXPOSURE_API_EVENT = /*#__PURE__*/function (EXPOSURE_API_EVENT) {
|
|
|
147
147
|
EXPOSURE_API_EVENT["VALIDATAFIELDS"] = "validateFields";
|
|
148
148
|
EXPOSURE_API_EVENT["UPDATEPAYMENT"] = "updatePayment";
|
|
149
149
|
return EXPOSURE_API_EVENT;
|
|
150
|
-
}({});
|
|
150
|
+
}({});
|
|
151
|
+
export var EVENTNAME = /*#__PURE__*/function (EVENTNAME) {
|
|
152
|
+
EVENTNAME["PAYMENTMETHODCHANGED"] = "paymentMethodChanged";
|
|
153
|
+
return EVENTNAME;
|
|
154
|
+
}({});
|
|
155
|
+
|
|
156
|
+
// 支付方式改变的回调函数的数据结构
|
|
@@ -83,3 +83,4 @@ export declare const isElementPC: () => boolean;
|
|
|
83
83
|
*/
|
|
84
84
|
export declare const isLoadErrorPage: (params: CashierSdkActionQueryResult) => boolean;
|
|
85
85
|
export declare const safeStringify: (payload: any, defaultValue?: string) => string;
|
|
86
|
+
export declare const safeParse: (payload: any, defaultValue?: Record<string, any>) => Record<string, any>;
|
|
@@ -63,20 +63,14 @@ export function checkCanMount(_ref) {
|
|
|
63
63
|
return {
|
|
64
64
|
success: false,
|
|
65
65
|
errorMsg: "Element with selector ".concat(sdkSelector, " not found."),
|
|
66
|
-
error:
|
|
67
|
-
code: ERRORMESSAGE.PARAM_INVALID.code,
|
|
68
|
-
message: "Element with selector ".concat(sdkSelector, " not found.")
|
|
69
|
-
}
|
|
66
|
+
error: ERRORMESSAGE.PARAM_INVALID
|
|
70
67
|
};
|
|
71
68
|
}
|
|
72
69
|
if (status === IElementStatus.DESTROYED) {
|
|
73
70
|
return {
|
|
74
71
|
success: false,
|
|
75
72
|
errorMsg: "Creating components in the destroyed state is forbidden.",
|
|
76
|
-
error:
|
|
77
|
-
code: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
78
|
-
message: "Creating components in the destroyed state is forbidden."
|
|
79
|
-
}
|
|
73
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
80
74
|
};
|
|
81
75
|
}
|
|
82
76
|
if (status === IElementStatus.READY) {
|
|
@@ -88,10 +82,7 @@ export function checkCanMount(_ref) {
|
|
|
88
82
|
return {
|
|
89
83
|
success: false,
|
|
90
84
|
errorMsg: "SDK status error.",
|
|
91
|
-
error:
|
|
92
|
-
code: ERRORMESSAGE.UI_STATE_ERROR.code,
|
|
93
|
-
message: "SDK status error."
|
|
94
|
-
}
|
|
85
|
+
error: ERRORMESSAGE.UI_STATE_ERROR
|
|
95
86
|
};
|
|
96
87
|
}
|
|
97
88
|
return {
|
|
@@ -535,4 +526,14 @@ export var safeStringify = function safeStringify(payload) {
|
|
|
535
526
|
console.error('JSON.stringify failed:', e);
|
|
536
527
|
return defaultValue;
|
|
537
528
|
}
|
|
529
|
+
};
|
|
530
|
+
export var safeParse = function safeParse(payload) {
|
|
531
|
+
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
532
|
+
if (!payload) return defaultValue;
|
|
533
|
+
try {
|
|
534
|
+
return JSON.parse(payload) || defaultValue;
|
|
535
|
+
} catch (e) {
|
|
536
|
+
console.error('JSON.parse failed:', e);
|
|
537
|
+
return defaultValue;
|
|
538
|
+
}
|
|
538
539
|
};
|
|
@@ -35,7 +35,6 @@ export declare class LogService implements Service {
|
|
|
35
35
|
log(type: string, payload: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
|
|
36
36
|
private reportLogs;
|
|
37
37
|
private loadScript;
|
|
38
|
-
private fallbackLoadScript;
|
|
39
38
|
private initTracker;
|
|
40
39
|
send(): void;
|
|
41
40
|
setComponentStartTime(val: number): void;
|
|
@@ -183,43 +183,6 @@ export var LogService = /*#__PURE__*/function () {
|
|
|
183
183
|
}, {
|
|
184
184
|
key: "loadScript",
|
|
185
185
|
value: function loadScript(url, callback) {
|
|
186
|
-
var _this3 = this;
|
|
187
|
-
/*
|
|
188
|
-
* 如果宿主环境存在AMD加载器,通过直接创建script标签的方式加载会造成宿主环境报错:
|
|
189
|
-
* Message: Mismatched anonymous define() module
|
|
190
|
-
* 原因是直接通过script标签加载的模块如果没有定义模块名,会被AMD加载器认为是匿名模块,
|
|
191
|
-
* 而宿主环境中已经存在匿名模块,导致报错。
|
|
192
|
-
*
|
|
193
|
-
* TODO: 所有通过window.iTracker调用的方法都需要判断
|
|
194
|
-
* 是否是AMD环境,如果是,需要通过require加载获取iTracker实例
|
|
195
|
-
* */
|
|
196
|
-
if (typeof window.define === 'function' && window.define.amd && typeof window.require === 'function') {
|
|
197
|
-
var moduleId = 'antom_iTracker';
|
|
198
|
-
try {
|
|
199
|
-
var _specified, _ref;
|
|
200
|
-
// 避免重复 config
|
|
201
|
-
if (!((_specified = (_ref = window.require).specified) !== null && _specified !== void 0 && _specified.call(_ref, moduleId))) {
|
|
202
|
-
// @ts-expect-error amd
|
|
203
|
-
window.require.config({
|
|
204
|
-
paths: _defineProperty({}, moduleId, url.replace(/\.js$/, ''))
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// @ts-expect-error amd
|
|
209
|
-
window.require([moduleId], callback, function (err) {
|
|
210
|
-
console.error('AMD load failed, falling back to script tag', err);
|
|
211
|
-
_this3.fallbackLoadScript(url, callback);
|
|
212
|
-
});
|
|
213
|
-
return;
|
|
214
|
-
} catch (e) {
|
|
215
|
-
console.warn('require not available, using script tag', e);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
this.fallbackLoadScript(url, callback);
|
|
219
|
-
}
|
|
220
|
-
}, {
|
|
221
|
-
key: "fallbackLoadScript",
|
|
222
|
-
value: function fallbackLoadScript(url, callback) {
|
|
223
186
|
var script = document.createElement('script');
|
|
224
187
|
script.type = 'text/javascript';
|
|
225
188
|
script.src = url;
|
|
@@ -232,16 +195,16 @@ export var LogService = /*#__PURE__*/function () {
|
|
|
232
195
|
}, {
|
|
233
196
|
key: "initTracker",
|
|
234
197
|
value: function initTracker() {
|
|
235
|
-
var
|
|
198
|
+
var _this3 = this;
|
|
236
199
|
if (this.isLoaded) return;
|
|
237
200
|
this.isLoaded = true;
|
|
238
201
|
try {
|
|
239
202
|
if (typeof localStorage !== 'undefined') {
|
|
240
203
|
this.loadScript(this.config.scriptUrl, function () {
|
|
241
204
|
var _window4;
|
|
242
|
-
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(
|
|
205
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this3.config);
|
|
243
206
|
setTimeout(function () {
|
|
244
|
-
|
|
207
|
+
_this3.reportLogs();
|
|
245
208
|
}, 80);
|
|
246
209
|
});
|
|
247
210
|
}
|
package/esm/main.js
CHANGED
|
@@ -238,8 +238,7 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
|
238
238
|
displayInfo: {
|
|
239
239
|
type: DisplayTypeEnum.popup
|
|
240
240
|
},
|
|
241
|
-
isAppWebview: params.isAppWebview
|
|
242
|
-
isNativeAppWebview: params.isNativeAppWebview
|
|
241
|
+
isAppWebview: params.isAppWebview
|
|
243
242
|
});
|
|
244
243
|
}
|
|
245
244
|
}, {
|
package/esm/util/logger.d.ts
CHANGED
|
@@ -56,7 +56,6 @@ export declare class Logger {
|
|
|
56
56
|
reportRPC(rpcData: LogPayload, extra?: Extra): Logger;
|
|
57
57
|
reportLogs(): void;
|
|
58
58
|
loadScript(url: string, callback: () => void): void;
|
|
59
|
-
private fallbackLoadScript;
|
|
60
59
|
initTracker(): void;
|
|
61
60
|
send(): void;
|
|
62
61
|
setComponentStartTime(val: number): void;
|
package/esm/util/logger.js
CHANGED
|
@@ -176,43 +176,6 @@ export var Logger = /*#__PURE__*/function () {
|
|
|
176
176
|
}, {
|
|
177
177
|
key: "loadScript",
|
|
178
178
|
value: function loadScript(url, callback) {
|
|
179
|
-
var _this5 = this;
|
|
180
|
-
/*
|
|
181
|
-
* 如果宿主环境存在AMD加载器,通过直接创建script标签的方式加载会造成宿主环境报错:
|
|
182
|
-
* Message: Mismatched anonymous define() module
|
|
183
|
-
* 原因是直接通过script标签加载的模块如果没有定义模块名,会被AMD加载器认为是匿名模块,
|
|
184
|
-
* 而宿主环境中已经存在匿名模块,导致报错。
|
|
185
|
-
*
|
|
186
|
-
* TODO: 所有通过window.iTracker调用的方法都需要判断
|
|
187
|
-
* 是否是AMD环境,如果是,需要通过require加载获取iTracker实例
|
|
188
|
-
* */
|
|
189
|
-
if (typeof window.define === 'function' && window.define.amd && typeof window.require === 'function') {
|
|
190
|
-
var moduleId = 'antom_iTracker';
|
|
191
|
-
try {
|
|
192
|
-
var _specified, _ref;
|
|
193
|
-
// 避免重复 config
|
|
194
|
-
if (!((_specified = (_ref = window.require).specified) !== null && _specified !== void 0 && _specified.call(_ref, moduleId))) {
|
|
195
|
-
// @ts-expect-error amd
|
|
196
|
-
window.require.config({
|
|
197
|
-
paths: _defineProperty({}, moduleId, url.replace(/\.js$/, ''))
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// @ts-expect-error amd
|
|
202
|
-
window.require([moduleId], callback, function (err) {
|
|
203
|
-
console.error('AMD load failed, falling back to script tag', err);
|
|
204
|
-
_this5.fallbackLoadScript(url, callback);
|
|
205
|
-
});
|
|
206
|
-
return;
|
|
207
|
-
} catch (e) {
|
|
208
|
-
console.warn('require not available, using script tag', e);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
this.fallbackLoadScript(url, callback);
|
|
212
|
-
}
|
|
213
|
-
}, {
|
|
214
|
-
key: "fallbackLoadScript",
|
|
215
|
-
value: function fallbackLoadScript(url, callback) {
|
|
216
179
|
var script = document.createElement('script');
|
|
217
180
|
script.type = 'text/javascript';
|
|
218
181
|
script.src = url;
|
|
@@ -225,16 +188,16 @@ export var Logger = /*#__PURE__*/function () {
|
|
|
225
188
|
}, {
|
|
226
189
|
key: "initTracker",
|
|
227
190
|
value: function initTracker() {
|
|
228
|
-
var
|
|
191
|
+
var _this5 = this;
|
|
229
192
|
if (this.isLoaded) return;
|
|
230
193
|
this.isLoaded = true;
|
|
231
194
|
try {
|
|
232
195
|
if (typeof localStorage !== 'undefined') {
|
|
233
196
|
this.loadScript(this.config.scriptUrl, function () {
|
|
234
197
|
var _window4;
|
|
235
|
-
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(
|
|
198
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this5.config);
|
|
236
199
|
setTimeout(function () {
|
|
237
|
-
|
|
200
|
+
_this5.reportLogs();
|
|
238
201
|
}, 80);
|
|
239
202
|
});
|
|
240
203
|
}
|