@alipay/ams-checkout 0.0.1763724075-dev.3 → 0.0.1763966842-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.
Files changed (45) hide show
  1. package/README.md +10 -1
  2. package/dist/umd/ams-checkout.min.js +1 -1
  3. package/esm/constant/index.d.ts +0 -3
  4. package/esm/constant/index.js +0 -3
  5. package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -2
  6. package/esm/core/component/element/elementProcessor/authProcessor.js +3 -2
  7. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +1 -1
  8. package/esm/core/component/element/elementProcessor/paymentProcessor.js +28 -30
  9. package/esm/foundation/core/index.js +0 -27
  10. package/esm/foundation/service/container/index.d.ts +0 -1
  11. package/esm/foundation/service/container/index.js +2 -33
  12. package/esm/foundation/utils/web_app_url_utils.d.ts +2 -0
  13. package/esm/foundation/utils/web_app_url_utils.js +15 -10
  14. package/esm/index.d.ts +52 -3
  15. package/esm/index.js +341 -5
  16. package/esm/plugin/component/cashierApp.js +4 -7
  17. package/esm/util/logger.d.ts +0 -2
  18. package/esm/util/logger.js +1 -1
  19. package/esm/util/versionCompare.d.ts +1 -1
  20. package/package.json +6 -16
  21. package/ams-checkout.js +0 -1
  22. package/esm/constant/auto-debit.d.ts +0 -12
  23. package/esm/constant/auto-debit.js +0 -15
  24. package/esm/constant/element.d.ts +0 -26
  25. package/esm/constant/element.js +0 -30
  26. package/esm/loader/Proxy.d.ts +0 -5
  27. package/esm/loader/Proxy.js +0 -364
  28. package/esm/loader/constant.d.ts +0 -36
  29. package/esm/loader/constant.js +0 -36
  30. package/esm/loader/index.d.ts +0 -20
  31. package/esm/loader/index.js +0 -23
  32. package/esm/loader/utils/common.d.ts +0 -13
  33. package/esm/loader/utils/common.js +0 -63
  34. package/esm/loader/utils/debugger.d.ts +0 -7
  35. package/esm/loader/utils/debugger.js +0 -15
  36. package/esm/loader/utils/loadSDK.d.ts +0 -8
  37. package/esm/loader/utils/loadSDK.js +0 -92
  38. package/esm/loader/utils/logger.d.ts +0 -10
  39. package/esm/loader/utils/logger.js +0 -59
  40. package/esm/loader/utils/proxyPerformance.d.ts +0 -20
  41. package/esm/loader/utils/proxyPerformance.js +0 -66
  42. package/esm/main.d.ts +0 -45
  43. package/esm/main.js +0 -329
  44. package/esm/util/integrationType.d.ts +0 -21
  45. package/esm/util/integrationType.js +0 -48
@@ -1,15 +0,0 @@
1
- /**
2
- * 全局debug上下文
3
- * */
4
- import { SDK_URL } from "../constant";
5
- var debugContext = {
6
- debugMode: false,
7
- showLogger: true,
8
- sdkUrl: SDK_URL.PROD // 默认为prod url
9
- };
10
- export var setDebugContext = function setDebugContext(props) {
11
- Object.assign(debugContext, props || {});
12
- };
13
- export var getDebugContext = function getDebugContext() {
14
- return debugContext;
15
- };
@@ -1,8 +0,0 @@
1
- import { EConstructorName, ProductType } from '../constant';
2
- type SdkLoadResult = {
3
- success: boolean;
4
- loadType?: 'cached' | 'network';
5
- };
6
- export declare function loadSdk(): Promise<SdkLoadResult>;
7
- export declare function newActualInstance<T extends ProductType>(constructorName: EConstructorName, newProps: any): T | null;
8
- export {};
@@ -1,92 +0,0 @@
1
- import { SDK_URL } from "../constant";
2
- import { getDebugContext } from "./debugger";
3
- import { consoleLogger, logger } from "./logger";
4
- export function loadSdk() {
5
- return new Promise(function (resolve, reject) {
6
- // 获取src
7
- var sdkSrc = SDK_URL.PROD;
8
-
9
- // debug模式动态传入sdkUrl
10
- var debugContext = getDebugContext();
11
- if ((debugContext === null || debugContext === void 0 ? void 0 : debugContext.debugMode) === true) {
12
- sdkSrc = (debugContext === null || debugContext === void 0 ? void 0 : debugContext.sdkUrl) || SDK_URL.PROD;
13
- }
14
-
15
- // 校验URL合法性
16
- try {
17
- new URL(sdkSrc);
18
- } catch (e) {
19
- consoleLogger.error("Invalid SDK URL: ".concat(sdkSrc));
20
- reject(e);
21
- return;
22
- }
23
-
24
- // 检查 SDK URL 是否存在
25
- if (!sdkSrc) {
26
- consoleLogger.error("SDK URL not found for: ".concat(sdkSrc));
27
- reject("SDK URL not found for: ".concat(sdkSrc));
28
- return;
29
- }
30
-
31
- // 检查是否已经加载过该脚本
32
- var existingScript = document.querySelector("script[src=\"".concat(sdkSrc, "\"]"));
33
- if (existingScript) {
34
- consoleLogger.log("SDK already loaded: ".concat(sdkSrc));
35
- resolve({
36
- success: true,
37
- loadType: 'cached'
38
- });
39
- return;
40
- }
41
-
42
- // 注入脚本到html
43
- var script = document.createElement('script');
44
- script.src = sdkSrc;
45
- document.head.appendChild(script);
46
-
47
- // 定义onload和onerror事件
48
- script.onload = function () {
49
- consoleLogger.log("Load SDK Success , SDK URL: ".concat(sdkSrc));
50
- resolve({
51
- success: true,
52
- loadType: 'network'
53
- });
54
- };
55
- script.onerror = function () {
56
- consoleLogger.log("Failed to load SDK: ".concat(sdkSrc));
57
- logger.logError({
58
- title: 'load_sdk_resource_error'
59
- }, {
60
- sdkSrc: sdkSrc
61
- });
62
- // 失败时移除缓存脚本
63
- script.remove();
64
- reject("Failed to load SDK: ".concat(sdkSrc));
65
- };
66
- });
67
- }
68
- export function newActualInstance(constructorName, newProps) {
69
- try {
70
- var _window;
71
- // 获取构造函数
72
- if (!constructorName) {
73
- consoleLogger.error("Load SDK failed: constructorName not found, please check constructorName: ".concat(constructorName));
74
- logger.logError({
75
- title: 'load_constructor_resource_error'
76
- }, {
77
- constructorName: constructorName
78
- });
79
- return null;
80
- }
81
- var Constructor = (_window = window) === null || _window === void 0 ? void 0 : _window[constructorName];
82
- if (!Constructor) {
83
- consoleLogger.error("".concat(constructorName, " not found after SDK load"));
84
- }
85
-
86
- // 实例化对象
87
- return new Constructor(newProps);
88
- } catch (error) {
89
- consoleLogger.error('Load SDK failed:', error);
90
- return null;
91
- }
92
- }
@@ -1,10 +0,0 @@
1
- import { Logger } from '../../util/logger';
2
- export declare class ConsoleLogger {
3
- show: boolean;
4
- constructor(options: any);
5
- log(message: string, ...args: any[]): void;
6
- warn(message: string, ...args: any[]): void;
7
- error(message: string, ...args: any[]): void;
8
- }
9
- export declare const consoleLogger: ConsoleLogger;
10
- export declare const logger: Logger;
@@ -1,59 +0,0 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- 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); } }
4
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- 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; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- 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); }
8
- import { LogConfig, Logger } from "../../util/logger";
9
- import { getDebugContext } from "./debugger";
10
- export var ConsoleLogger = /*#__PURE__*/function () {
11
- function ConsoleLogger(options) {
12
- _classCallCheck(this, ConsoleLogger);
13
- _defineProperty(this, "show", false);
14
- this.show = options.show;
15
- }
16
- _createClass(ConsoleLogger, [{
17
- key: "log",
18
- value: function log(message) {
19
- var _console;
20
- if (!this.show) return;
21
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
22
- args[_key - 1] = arguments[_key];
23
- }
24
- (_console = console).log.apply(_console, ["[sdk-loader] ".concat(message)].concat(args));
25
- }
26
- }, {
27
- key: "warn",
28
- value: function warn(message) {
29
- var _console2;
30
- if (!this.show) return;
31
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
32
- args[_key2 - 1] = arguments[_key2];
33
- }
34
- (_console2 = console).warn.apply(_console2, ["[sdk-loader] ".concat(message)].concat(args));
35
- }
36
- }, {
37
- key: "error",
38
- value: function error(message) {
39
- var _console3;
40
- if (!this.show) return;
41
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
42
- args[_key3 - 1] = arguments[_key3];
43
- }
44
- (_console3 = console).error.apply(_console3, ["[sdk-loader] ".concat(message)].concat(args));
45
- }
46
- }]);
47
- return ConsoleLogger;
48
- }();
49
-
50
- // consoleLogger仅用于控制台打印
51
- var _getDebugContext = getDebugContext(),
52
- debugMode = _getDebugContext.debugMode,
53
- showLogger = _getDebugContext.showLogger;
54
- export var consoleLogger = new ConsoleLogger({
55
- show: debugMode ? showLogger : true
56
- });
57
-
58
- // SPM日志上报用logger 先全部收口到这里,后续loader单独拆包后进行解耦
59
- export var logger = new Logger(LogConfig, true);
@@ -1,20 +0,0 @@
1
- /**
2
- * 在window对象上记录商户初始化SDK的StartTime,加载结束时间
3
- * 后续传递给Web应用,用于进行端到端渲染总耗时计算
4
- * ***/
5
- import { ProductSceneEnum } from "../../types";
6
- import { EConstructorName } from '../constant';
7
- type TimeObject = {
8
- startTime: number;
9
- endTime: number;
10
- };
11
- /*** 扩展 Window 接口,添加 _ANTOM_SDK_PROXY_TIME 属性*/
12
- declare global {
13
- interface Window {
14
- _ANTOM_SDK_PROXY_TIME?: Partial<Record<EConstructorName, TimeObject>>;
15
- }
16
- }
17
- export declare function setProxyStartTime(constructorName: EConstructorName, startTime: number): number;
18
- export declare function setProxyEndTime(constructorName: EConstructorName, endTime: number): number;
19
- export declare const getProxyCostTime: (productScene: ProductSceneEnum) => number;
20
- export {};
@@ -1,66 +0,0 @@
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
- /**
3
- * 在window对象上记录商户初始化SDK的StartTime,加载结束时间
4
- * 后续传递给Web应用,用于进行端到端渲染总耗时计算
5
- * ***/
6
-
7
- import { ProductSceneEnum } from "../../types";
8
-
9
- /*** 扩展 Window 接口,添加 _ANTOM_SDK_PROXY_TIME 属性*/
10
-
11
- /*** 往window对象上注入全局变量 _ANTOM_SDK_PROXY_TIME */
12
- function injectAntomSDKProxyStartTime() {
13
- if (typeof window === 'undefined') {
14
- return;
15
- }
16
- if (_typeof(window._ANTOM_SDK_PROXY_TIME) !== 'object') {
17
- window._ANTOM_SDK_PROXY_TIME = {};
18
- }
19
- return window._ANTOM_SDK_PROXY_TIME;
20
- }
21
- export function setProxyStartTime(constructorName, startTime) {
22
- injectAntomSDKProxyStartTime();
23
- if (_typeof(window._ANTOM_SDK_PROXY_TIME) !== 'object') return startTime;
24
- var timeObject = window._ANTOM_SDK_PROXY_TIME[constructorName];
25
- if (_typeof(timeObject) !== 'object') {
26
- window._ANTOM_SDK_PROXY_TIME[constructorName] = {
27
- startTime: startTime,
28
- endTime: 0
29
- };
30
- } else {
31
- timeObject.startTime = startTime;
32
- }
33
- return startTime;
34
- }
35
- export function setProxyEndTime(constructorName, endTime) {
36
- if (_typeof(window._ANTOM_SDK_PROXY_TIME) !== 'object') return endTime;
37
- var timeObject = window._ANTOM_SDK_PROXY_TIME[constructorName];
38
- if (_typeof(timeObject) !== 'object') {
39
- window._ANTOM_SDK_PROXY_TIME[constructorName] = {
40
- startTime: 0,
41
- endTime: endTime
42
- };
43
- } else {
44
- timeObject.endTime = endTime;
45
- }
46
- return endTime;
47
- }
48
- export var getProxyCostTime = function getProxyCostTime(productScene) {
49
- var _window, _window2, _timeObj, _timeObj2;
50
- var timeObj;
51
- switch (productScene) {
52
- case ProductSceneEnum.ELEMENT_PAYMENT:
53
- timeObj = (_window = window) === null || _window === void 0 || (_window = _window._ANTOM_SDK_PROXY_TIME) === null || _window === void 0 ? void 0 : _window['AMSElement'];
54
- break;
55
- case ProductSceneEnum.EASY_PAY:
56
- timeObj = (_window2 = window) === null || _window2 === void 0 || (_window2 = _window2._ANTOM_SDK_PROXY_TIME) === null || _window2 === void 0 ? void 0 : _window2['AMSEasyPay'];
57
- break;
58
- default:
59
- timeObj = {
60
- startTime: 0,
61
- endTime: 0
62
- };
63
- break;
64
- }
65
- return ((_timeObj = timeObj) === null || _timeObj === void 0 ? void 0 : _timeObj.endTime) - ((_timeObj2 = timeObj) === null || _timeObj2 === void 0 ? void 0 : _timeObj2.startTime) || 0;
66
- };
package/esm/main.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import { AddressComponent } from './core/component/address';
2
- import { ElementComponent } from './core/component/element';
3
- import { AMSComponent } from './core/component/index';
4
- import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
5
- export { AMSCheckoutPage } from './core/component/ckp';
6
- export * from './types';
7
- export declare class AMSCheckout extends AMSComponent {
8
- constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
9
- }
10
- export declare class AMSAutoDebitPay extends AMSCheckout {
11
- constructor(options: IoptionsParams);
12
- static preload(options?: IPreloadOptions): void;
13
- }
14
- export declare class AMSCashierPayment extends AMSCheckout {
15
- constructor(options: IoptionsParams);
16
- static preload(options?: IPreloadOptions): void;
17
- }
18
- export declare class AMSVaulting extends AMSCheckout {
19
- constructor(options: IoptionsParams);
20
- static preload(options?: IPreloadOptions): void;
21
- }
22
- export declare class AntomElement extends AMSCheckout {
23
- constructor(options: IoptionsParams);
24
- }
25
- export declare class AddressElement extends AddressComponent {
26
- constructor(options: IoptionsAddressParams);
27
- }
28
- export declare class AMSElement extends ElementComponent {
29
- constructor(options: IElementOptions);
30
- }
31
- export declare class AMSEasyPay {
32
- private core;
33
- constructor(options: IoptionsParams);
34
- static preload(options?: IPreloadOptions): void;
35
- createComponent(params: IcreateComponent): void;
36
- unmount(): void;
37
- }
38
- export declare class AMSAutoDebit {
39
- private core;
40
- constructor(options: IoptionsParams);
41
- createComponent(params: IcreateComponent): Promise<void>;
42
- unmount(): void;
43
- static preload(options?: IPreloadOptions): void;
44
- }
45
- export default AMSCheckout;