@alipay/ams-checkout 0.0.1726734012-dev.11 → 0.0.1726734012-dev.13

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.
@@ -5,6 +5,7 @@ export declare const getComponentSign: (params: IPaymentSessionMetaData) => Comp
5
5
  export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
6
6
  export type IAMSComponentOptions = IoptionsParams & {
7
7
  appVersion: string;
8
+ isPreload?: boolean;
8
9
  };
9
10
  export declare class AMSComponent extends CoreInstance {
10
11
  _componentApp: ComponentApp;
@@ -34,7 +35,7 @@ export declare class AMSComponent extends CoreInstance {
34
35
  */
35
36
  createComponent(params: IcreateComponent): Promise<void>;
36
37
  private createComponentProcess;
37
- preloadComponent(): void;
38
+ preloadComponent(channelType: any, productSceneVersion: any): void;
38
39
  private clearPreloadIframe;
39
40
  /**
40
41
  * @description Create and render components in the specified element area
@@ -49,7 +50,10 @@ export declare class AMSComponent extends CoreInstance {
49
50
  * @param data - Transfer information in the submission interface according to your requirements (optional)
50
51
  */
51
52
  submit(data?: Isubmit): Promise<unknown>;
52
- preload(_options: {
53
+ static preload(_options: {
54
+ appVersion: string;
53
55
  securityRegion?: 'US' | 'SG' | 'DE';
56
+ channelType: ComponentSignEnum[];
57
+ productSceneVersion: string;
54
58
  }): void;
55
59
  }
@@ -150,6 +150,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
150
150
  _this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
151
151
  _this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
152
152
  _this2.registerBusAbility();
153
+ _this2.isSuccessfullyPreloaded = options.isPreload;
153
154
  return _this2;
154
155
  }
155
156
  _createClass(AMSComponent, [{
@@ -346,10 +347,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
346
347
  key: "createComponent",
347
348
  value: function createComponent(params) {
348
349
  var _this5 = this;
349
- if (!this.isSuccessfullyPreloaded) {
350
- this.preloadComponent();
351
- }
352
- ;
353
350
  this.clearPreloadIframe();
354
351
  this.logger.setComponentStartTime(Date.now());
355
352
  return this.parameterInitAndCheck({
@@ -390,40 +387,25 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
390
387
  return this.pluginAppendIframe(appendParams);
391
388
  }
392
389
 
393
- // preloadComponent(channelType, productSceneVersion) {
394
- // this.channelType = channelType;
395
- // this.productSceneVersion = productSceneVersion;
396
- // const MAX_CLEAR_TIME = 10000;
397
-
398
- // if (Array.isArray(channelType)) {
399
- // for (let i = 0; i < channelType.length; i++) {
400
- // this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
401
- // }
402
- // } else {
403
- // this.logger.logError(
404
- // { title: 'performance_optimization_channelType_error' },
405
- // { eventMessage: channelType }
406
- // );
407
- // }
408
- // this.timer = setTimeout(() => {
409
- // this.clearPreloadIframe(true);
410
- // }, MAX_CLEAR_TIME);
411
- // }
390
+ // TODO 老逻辑predload
412
391
  }, {
413
392
  key: "preloadComponent",
414
- value: function preloadComponent() {
393
+ value: function preloadComponent(channelType, productSceneVersion) {
415
394
  var _this6 = this;
395
+ if (this.isSuccessfullyPreloaded) return;
396
+ this.channelType = channelType;
397
+ this.productSceneVersion = productSceneVersion;
416
398
  var MAX_CLEAR_TIME = 10000;
417
- if (Array.isArray(this.channelType)) {
418
- for (var i = 0; i < this.channelType.length; i++) {
419
- this._componentApp.appendPreloadIframeNodes(this.channelType[i], this.productSceneVersion);
399
+ if (Array.isArray(channelType)) {
400
+ for (var i = 0; i < channelType.length; i++) {
401
+ this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
402
+ this.isSuccessfullyPreloaded = true;
420
403
  }
421
- this.isSuccessfullyPreloaded = true;
422
404
  } else {
423
405
  this.logger.logError({
424
406
  title: 'performance_optimization_channelType_error'
425
407
  }, {
426
- eventMessage: this.channelType
408
+ eventMessage: channelType
427
409
  });
428
410
  }
429
411
  this.timer = setTimeout(function () {
@@ -461,10 +443,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
461
443
  value: function mountComponent(params, selector) {
462
444
  var _this7 = this;
463
445
  this.clearPreloadIframe();
464
- if (!this.isSuccessfullyPreloaded) {
465
- this.preloadComponent();
466
- }
467
- ;
468
446
  this.logger.setComponentStartTime(Date.now());
469
447
  return this.parameterInitAndCheck({
470
448
  params: params,
@@ -552,21 +530,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
552
530
  }
553
531
 
554
532
  // 预加载
555
- }, {
533
+ }], [{
556
534
  key: "preload",
557
535
  value: function preload(_options) {
558
536
  try {
559
- var _this$channelType;
560
- this.preloadComponent();
561
- if (this.channelType && (_this$channelType = this.channelType) !== null && _this$channelType !== void 0 && _this$channelType.some(function (val) {
537
+ var _currentCompoentApp$c;
538
+ var currentCompoentApp = new AMSComponent(_objectSpread(_objectSpread({}, _options), {}, {
539
+ isPreload: true
540
+ }));
541
+ currentCompoentApp.preloadComponent(_options.channelType, _options.productSceneVersion || '1.0');
542
+ if (currentCompoentApp.channelType && (_currentCompoentApp$c = currentCompoentApp.channelType) !== null && _currentCompoentApp$c !== void 0 && _currentCompoentApp$c.some(function (val) {
562
543
  return val === ComponentSignEnum.EASY_PAY_WALLET || val === ComponentSignEnum.EASY_PAY_APM;
563
544
  })) return;
564
- this._componentApp.AMSSDK.initSecurity({
565
- product: this.options.product,
545
+ currentCompoentApp._componentApp.AMSSDK.initSecurity({
546
+ product: currentCompoentApp.options.product,
566
547
  securityRegion: _options.securityRegion
567
548
  });
568
549
  } catch (err) {
569
- console.log('web-sdk error', err);
550
+ console.log('web-sdk preload error', err);
570
551
  }
571
552
  }
572
553
  }]);
@@ -16,6 +16,12 @@ export declare class AntomSDKCore {
16
16
  constructor();
17
17
  registerProcessor(productScene: string, paymentMethod: string, processor: ProductProcessor): void;
18
18
  init(options: IoptionsParams, productScene: ProductSceneEnum): void;
19
+ transferEasyPaySdkVersion(): {
20
+ webAppVersion: string;
21
+ greyscaleId: number;
22
+ productScene: ProductSceneEnum.EASY_PAY;
23
+ sdkVersion: string;
24
+ };
19
25
  private prepare;
20
26
  startBizFlow(options: StartBizFlowOptions): Promise<void>;
21
27
  getServiceProvider(): ServiceProvider;
@@ -10,7 +10,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
10
10
  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; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  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); }
13
- import { DisplayTypeEnum, eventCodeEnum } from "../../types";
13
+ import { DisplayTypeEnum, ProductSceneEnum, eventCodeEnum } from "../../types";
14
14
  import { DisplayInfo } from "../index";
15
15
  import { v4 as uuid } from 'uuid';
16
16
  import { ServiceProvider } from "../service";
@@ -59,6 +59,16 @@ export var AntomSDKCore = /*#__PURE__*/function () {
59
59
  ServiceProvider.getInstance(this.instanceId).init(options, this.sdkMetaData);
60
60
  this.prepare(options, this.sdkMetaData);
61
61
  }
62
+ }, {
63
+ key: "transferEasyPaySdkVersion",
64
+ value: function transferEasyPaySdkVersion() {
65
+ return this.sdkMetaData = {
66
+ webAppVersion: '',
67
+ greyscaleId: getGrayscaleId(),
68
+ productScene: ProductSceneEnum.EASY_PAY,
69
+ sdkVersion: sdkVersion
70
+ };
71
+ }
62
72
  }, {
63
73
  key: "prepare",
64
74
  value: function prepare(options, sdkMetaData) {
@@ -12,6 +12,7 @@ export declare class EasySafePayProcessor implements ProductProcessor {
12
12
  init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
13
13
  startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
14
14
  private preloadWebApp;
15
+ static preload(options: IoptionsParams, sdkVersion: SDKMetaData): void;
15
16
  private buildWebAppPreloadUrl;
16
17
  private buildWebAppUrl;
17
18
  private buildRedirectResult;
@@ -459,6 +459,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
459
459
  }
460
460
  return initSecuritySDK;
461
461
  }()
462
+ }], [{
463
+ key: "preload",
464
+ value: function preload(options, sdkVersion) {
465
+ var instanceId = uuid();
466
+ var currentEasyPay = new EasySafePayProcessor();
467
+ currentEasyPay.init(options, instanceId, sdkVersion);
468
+ }
462
469
  }]);
463
470
  return EasySafePayProcessor;
464
471
  }();
package/esm/index.d.ts CHANGED
@@ -6,6 +6,11 @@ export { AMSCheckoutPage } from './core/component/ckp';
6
6
  export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
8
8
  constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
9
+ static preload(_options: {
10
+ channelType: ComponentSignEnum[];
11
+ productSceneVersion: string;
12
+ securityRegion?: 'US' | 'SG' | 'DE';
13
+ }): void;
9
14
  }
10
15
  export declare class AMSAutoDebit extends AMSCheckout {
11
16
  constructor(options: IoptionsParams);
@@ -31,9 +36,8 @@ export declare class Element extends ElementComponent {
31
36
  export default AMSCheckout;
32
37
  export declare class AMSEasyPay {
33
38
  private core;
34
- private easySafePayProcessor;
35
39
  constructor(options: IoptionsParams);
40
+ static preload(options: IoptionsParams): void;
36
41
  createComponent(params: IcreateComponent): void;
37
- preload(): void;
38
42
  unmount(): void;
39
43
  }
package/esm/index.js CHANGED
@@ -2,11 +2,11 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  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; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
6
  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); } }
6
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
9
  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); }
9
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
10
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
11
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -43,12 +43,23 @@ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
43
43
  _this = _super.call(this, _objectSpread({
44
44
  appVersion: AMSCheckoutAppVersion
45
45
  }, _options));
46
- // this.preloadComponent(channelType, productSceneVersion);
47
- _this.channelType = channelType;
48
- _this.productSceneVersion = productSceneVersion;
46
+ console.log(_this.isSuccessfullyPreloaded, 'isSuccessfullyPreloaded');
47
+ if (!_this.isSuccessfullyPreloaded) {
48
+ _this.preloadComponent(channelType, productSceneVersion);
49
+ }
50
+ // this.channelType = channelType;
51
+ // this.productSceneVersion = productSceneVersion;
49
52
  return _this;
50
53
  }
51
- return _createClass(AMSCheckout);
54
+ _createClass(AMSCheckout, null, [{
55
+ key: "preload",
56
+ value: function preload(_options) {
57
+ AMSComponent.preload(_objectSpread(_objectSpread({}, _options), {}, {
58
+ appVersion: AMSCheckoutAppVersion
59
+ }));
60
+ }
61
+ }]);
62
+ return AMSCheckout;
52
63
  }(AMSComponent);
53
64
  export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
54
65
  _inherits(AMSAutoDebit, _AMSCheckout);
@@ -164,7 +175,6 @@ export var AMSEasyPay = /*#__PURE__*/function () {
164
175
  function AMSEasyPay(options) {
165
176
  _classCallCheck(this, AMSEasyPay);
166
177
  _defineProperty(this, "core", void 0);
167
- _defineProperty(this, "easySafePayProcessor", void 0);
168
178
  this.core = new AntomSDKCore();
169
179
  this.core.registerProcessor(ProductSceneEnum.EASY_PAY, '', new EasySafePayProcessor());
170
180
  this.core.init(options, ProductSceneEnum.EASY_PAY);
@@ -184,16 +194,18 @@ export var AMSEasyPay = /*#__PURE__*/function () {
184
194
  isAppWebview: params.isAppWebview
185
195
  });
186
196
  }
187
- }, {
188
- key: "preload",
189
- value: function preload() {
190
- this.core.init({}, ProductSceneEnum.EASY_PAY);
191
- }
192
197
  }, {
193
198
  key: "unmount",
194
199
  value: function unmount() {
195
200
  this.core.destroy();
196
201
  }
202
+ }], [{
203
+ key: "preload",
204
+ value: function preload(options) {
205
+ var core = new AntomSDKCore();
206
+ var SDkMetaData = core.transferEasyPaySdkVersion();
207
+ EasySafePayProcessor.preload(options, SDkMetaData);
208
+ }
197
209
  }]);
198
210
  return AMSEasyPay;
199
211
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1726734012-dev.11",
3
+ "version": "0.0.1726734012-dev.13",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",