@alipay/ams-checkout 0.0.1783323899-dev.1 → 0.0.1783403875-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.
Files changed (43) hide show
  1. package/ams-checkout.js +3 -4
  2. package/dist/ams-checkout.min.js +1 -2
  3. package/esm/config/index.d.ts +0 -7
  4. package/esm/config/index.js +2 -2
  5. package/esm/constant/element.d.ts +1 -2
  6. package/esm/constant/element.js +0 -1
  7. package/esm/core/component/ckp/index.d.ts +1 -1
  8. package/esm/core/component/ckp/index.js +5 -2
  9. package/esm/core/component/element/elementController/index.d.ts +3 -3
  10. package/esm/core/component/element/elementController/index.js +57 -41
  11. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +1 -0
  12. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +1 -0
  13. package/esm/core/component/element/elementProcessor/convertPaymentMethods.d.ts +22 -0
  14. package/esm/core/component/element/elementProcessor/convertPaymentMethods.js +159 -0
  15. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +5 -0
  16. package/esm/core/component/element/elementProcessor/paymentProcessor.js +105 -34
  17. package/esm/core/component/element/index.d.ts +1 -4
  18. package/esm/core/component/element/index.js +4 -19
  19. package/esm/core/component/element/mock.js +1 -1
  20. package/esm/core/component/element/type.d.ts +77 -16
  21. package/esm/core/component/element/util.d.ts +9 -2
  22. package/esm/core/component/element/util.js +3 -2
  23. package/esm/foundation/service/event-center.js +10 -13
  24. package/esm/modern/index.d.ts +1 -5
  25. package/esm/modern/index.js +51 -1
  26. package/esm/modern/stageName.d.ts +3 -0
  27. package/esm/modern/stageName.js +1 -0
  28. package/esm/plugin/component/channel.d.ts +2 -2
  29. package/esm/plugin/component/channel.js +18 -18
  30. package/esm/types/index.d.ts +4 -2
  31. package/esm/util/beforeConfirm.d.ts +4 -2
  32. package/esm/util/beforeConfirm.js +15 -14
  33. package/esm/util/logger.js +2 -1
  34. package/package.json +9 -15
  35. package/types.d.ts +94 -784
  36. package/types.untrimmed.d.ts +108 -931
  37. package/dist/ams-checkout.min.js.map +0 -1
  38. package/esm/core/component/element/modernElementController/adapter.d.ts +0 -19
  39. package/esm/core/component/element/modernElementController/adapter.js +0 -73
  40. package/esm/core/component/element/modernElementController/index.d.ts +0 -149
  41. package/esm/core/component/element/modernElementController/index.js +0 -1673
  42. package/esm/modern/global.d.ts +0 -3
  43. package/esm/modern/tools.js +0 -1
@@ -27,11 +27,13 @@ import { ELEMENT_PAGE_URL } from "../../../../constant/element";
27
27
  import { EVENT } from "../../../../constant";
28
28
  import { ServiceProvider } from "../../../../foundation/service";
29
29
  import { ApplePaySdk, handleGooglePay, isSkipRenderPaymentMethod } from "../../../../plugin/component/channel";
30
+ import { DisplayTypeEnum } from "../../../../types";
30
31
  import { queryParse } from "../../../../util";
31
32
  import { LogConfig, Logger } from "../../../../util/logger";
32
33
  import { parseSessionData } from "../../index";
33
34
  import { oneAccount, sdkAction } from "../mock";
34
- import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC, safeStringify } from "../util";
35
+ import { convertPaymentMethods } from "../elementProcessor/convertPaymentMethods";
36
+ import { generateIframeSrc as _generateIframeSrc, isElementPad, isElementPC, safeParse, safeStringify } from "../util";
35
37
  import BaseElementProcessor from "./baseElementProcessor";
36
38
  import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS } from "../../../../util/beforeConfirm";
37
39
  var logger = new Logger(LogConfig, true);
@@ -85,11 +87,44 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
85
87
  }, {
86
88
  key: "onReady",
87
89
  value: function onReady(extraParam) {
88
- var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
90
+ var _this$options, _paymentContext$displ, _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
89
91
  var paymentContext = this.elementContainer.getPaymentContext();
90
92
  this.getLogger().logInfo({
91
93
  title: 'sdk_event_renderComponent'
92
94
  });
95
+
96
+ // preview mobile 模式下,单普通支付方式(无表单、非快捷支付)不发送 renderComponent,阻止自动提交
97
+ var previewMode = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.preview;
98
+ if (previewMode === 'mobile') {
99
+ var _extraParam$originAct, _extraParam$originAct2, _paymentMethods$, _paymentMethods$2;
100
+ var paymentMethods = (extraParam === null || extraParam === void 0 || (_extraParam$originAct = extraParam.originActionQueryResult) === null || _extraParam$originAct === void 0 ? void 0 : _extraParam$originAct.paymentMethods) || [];
101
+ var savedPaymentMethods = (extraParam === null || extraParam === void 0 || (_extraParam$originAct2 = extraParam.originActionQueryResult) === null || _extraParam$originAct2 === void 0 ? void 0 : _extraParam$originAct2.savedPaymentMethods) || [];
102
+ if (paymentMethods.length === 1 && savedPaymentMethods.length === 0 && !((_paymentMethods$ = paymentMethods[0]) !== null && _paymentMethods$ !== void 0 && (_paymentMethods$ = _paymentMethods$.paymentElements) !== null && _paymentMethods$ !== void 0 && _paymentMethods$.length) && !['APPLEPAY', 'GOOGLEPAY'].includes((_paymentMethods$2 = paymentMethods[0]) === null || _paymentMethods$2 === void 0 ? void 0 : _paymentMethods$2.paymentMethodType)) {
103
+ // 跳过 renderComponent,避免触发自动提交
104
+ return;
105
+ }
106
+ }
107
+
108
+ // ===== Element 自助化运营:appearance 二选一处理(不做 deepMerge)=====
109
+ // 根据 theme 值二选一:
110
+ // - 内置 6 大主题(非 APR_ 前缀):完全使用 SDK mount 传入的 appearance
111
+ // - 自定义主题模版(APR_ 前缀 AppearanceID):完全使用后端 sdkAction.query 返回的 appearance,
112
+ // SDK mount 中传的 layout/variables/card 全部忽略
113
+ var mountAppearance = paymentContext === null || paymentContext === void 0 || (_paymentContext$displ = paymentContext.displayInfo) === null || _paymentContext$displ === void 0 ? void 0 : _paymentContext$displ.appearance;
114
+ var isAppearanceId = typeof (mountAppearance === null || mountAppearance === void 0 ? void 0 : mountAppearance.theme) === 'string' && mountAppearance.theme.startsWith('APR_');
115
+ var finalAppearance;
116
+ if (isAppearanceId) {
117
+ var _extraParam$originAct3, _safeParse;
118
+ // 分支 A:自定义主题模版(APR_xxxx)
119
+ // 完全使用后端返回的配置,忽略 SDK mount 中的 layout/variables/card
120
+ // elementSettings 可能是 JSON string,需统一解析为对象
121
+ var elementSettings = extraParam === null || extraParam === void 0 || (_extraParam$originAct3 = extraParam.originActionQueryResult) === null || _extraParam$originAct3 === void 0 || (_extraParam$originAct3 = _extraParam$originAct3.pageStyle) === null || _extraParam$originAct3 === void 0 ? void 0 : _extraParam$originAct3.elementSettings;
122
+ finalAppearance = typeof elementSettings === 'string' ? (_safeParse = safeParse(elementSettings)) === null || _safeParse === void 0 ? void 0 : _safeParse.appearance : elementSettings === null || elementSettings === void 0 ? void 0 : elementSettings.appearance;
123
+ } else {
124
+ // 分支 B:内置 6 大主题或未指定主题
125
+ // 完全使用 SDK mount 传入的配置;
126
+ finalAppearance = mountAppearance;
127
+ }
93
128
  this.eventCenter.dispatchToApp({
94
129
  event: 'renderComponent',
95
130
  data: {
@@ -108,7 +143,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
108
143
  merchantId: (_this$elementContaine4 = this.elementContainer) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.getPaymentContext()) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.paymentSessionObj) === null || _this$elementContaine4 === void 0 ? void 0 : _this$elementContaine4.clientId,
109
144
  paymentMethodType: (_this$elementContaine5 = this.elementContainer) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.getPaymentContext()) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentSessionObj) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentMethodInfoView) === null || _this$elementContaine5 === void 0 ? void 0 : _this$elementContaine5.paymentMethodType
110
145
  },
111
- appearance: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.displayInfo.appearance,
146
+ appearance: finalAppearance,
112
147
  sessionResult: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj,
113
148
  notRedirectAfterComplete: (extraParam === null || extraParam === void 0 ? void 0 : extraParam.notRedirectAfterComplete) === true,
114
149
  merchantAppointParam: extraParam === null || extraParam === void 0 ? void 0 : extraParam.merchantAppointParam,
@@ -195,7 +230,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
195
230
  // requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
196
231
  // and returns the result (continue/abort) to iframe via dispatchToApp.
197
232
  this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
198
- var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
233
+ var paymentMethodType, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue, isTimeout;
199
234
  return _regeneratorRuntime().wrap(function _callee$(_context) {
200
235
  while (1) switch (_context.prev = _context.next) {
201
236
  case 0:
@@ -235,8 +270,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
235
270
  _yield$executeWithTim = _context.sent;
236
271
  rawResult = _yield$executeWithTim.result;
237
272
  timedOut = _yield$executeWithTim.timedOut;
238
- shouldContinue = rawResult; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
239
- if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
273
+ shouldContinue = rawResult;
274
+ isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS; // 双重校验:timedOut(Promise race) + startTime(实际时间差),防止竞态误判
275
+ if (isTimeout) {
240
276
  logger.logError({
241
277
  title: 'sdk_before_confirm_timeout'
242
278
  });
@@ -249,15 +285,17 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
249
285
  });
250
286
  _this2.eventCenter.dispatchToApp({
251
287
  event: EVENT.beforeConfirm.name,
252
- data: {
288
+ data: _objectSpread({
253
289
  success: true,
254
290
  result: !!shouldContinue
255
- }
291
+ }, isTimeout ? {
292
+ isTimeout: true
293
+ } : {})
256
294
  });
257
- _context.next = 23;
295
+ _context.next = 24;
258
296
  break;
259
- case 19:
260
- _context.prev = 19;
297
+ case 20:
298
+ _context.prev = 20;
261
299
  _context.t0 = _context["catch"](6);
262
300
  logger.logError({
263
301
  title: 'sdk_before_confirm_error'
@@ -273,11 +311,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
273
311
  result: false
274
312
  }
275
313
  });
276
- case 23:
314
+ case 24:
277
315
  case "end":
278
316
  return _context.stop();
279
317
  }
280
- }, _callee, null, [[6, 19]]);
318
+ }, _callee, null, [[6, 20]]);
281
319
  })));
282
320
  }
283
321
  }, {
@@ -344,6 +382,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
344
382
  }, {
345
383
  key: "generateIframeSrc",
346
384
  value: function generateIframeSrc(_ref3) {
385
+ var _this$options3;
347
386
  var link = _ref3.link,
348
387
  instanceId = _ref3.instanceId;
349
388
  this.instanceId = instanceId;
@@ -351,12 +390,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
351
390
  paymentSession = _ref4.paymentSession,
352
391
  paymentSessionObj = _ref4.paymentSessionObj,
353
392
  sdkMetaData = _ref4.sdkMetaData;
354
- var _this$options = this.options,
355
- environment = _this$options.env.environment,
356
- analytics = _this$options.analytics,
357
- locale = _this$options.locale;
393
+ var _this$options2 = this.options,
394
+ environment = _this$options2.env.environment,
395
+ analytics = _this$options2.analytics,
396
+ locale = _this$options2.locale;
358
397
  var _ref5 = paymentSessionObj || {},
359
398
  extendInfo = _ref5.extendInfo;
399
+ // 预览模式下,若为 'mobile' 需要让 iframe 以 popup(MobileElement)形态渲染
400
+ var previewMode = (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.preview;
401
+ var renderDisplayType = previewMode === 'mobile' ? DisplayTypeEnum.popup : DisplayTypeEnum.inline;
360
402
  var url = _generateIframeSrc({
361
403
  paymentSession: paymentSession,
362
404
  paymentSessionObj: paymentSessionObj,
@@ -366,7 +408,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
366
408
  link: link,
367
409
  appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
368
410
  pageUrl: isExpressCheckout(extendInfo) ? ELEMENT_PAGE_URL.EXPRESS_CHECKOUT : ELEMENT_PAGE_URL.ELEMENT_PAYMENT,
369
- instanceId: instanceId
411
+ instanceId: instanceId,
412
+ renderDisplayType: renderDisplayType
370
413
  });
371
414
  this.setElementUrl(url);
372
415
  return url;
@@ -376,8 +419,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
376
419
  value: function () {
377
420
  var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
378
421
  var _paymentSessionObj$co,
422
+ _this$options5,
379
423
  _this3 = this;
380
- var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref6, paymentSessionConfig, hostSign, isConnect, extendInfo, onlyIntegrateCardElementConnectMerchantFlag, _JSON$parse2, shouldQueryOneAccount, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
424
+ var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options4, environment, locale, _ref6, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, previewMode, IS_PREVIEW, SHOULD_USE_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
381
425
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
382
426
  while (1) switch (_context3.prev = _context3.next) {
383
427
  case 0:
@@ -385,18 +429,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
385
429
  _this$elementContaine7 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine7.paymentSession, paymentSessionObj = _this$elementContaine7.paymentSessionObj, displayInfo = _this$elementContaine7.displayInfo;
386
430
  _displayInfo = displayInfo;
387
431
  debugProps = _displayInfo.debugProps;
388
- _this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
432
+ _this$options4 = this.options, environment = _this$options4.env.environment, locale = _this$options4.locale;
389
433
  _ref6 = paymentSessionObj || {}, paymentSessionConfig = _ref6.paymentSessionConfig;
390
434
  hostSign = paymentSession.split('&&')[1] || '';
391
435
  isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
392
- extendInfo = (paymentSessionObj === null || paymentSessionObj === void 0 ? void 0 : paymentSessionObj.extendInfo) || '';
393
- try {
394
- onlyIntegrateCardElementConnectMerchantFlag = (_JSON$parse2 = JSON.parse(extendInfo)) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2.onlyIntegrateCardElementConnectMerchantFlag;
395
- } catch (_unused) {
396
- onlyIntegrateCardElementConnectMerchantFlag = undefined;
397
- }
398
- shouldQueryOneAccount = isConnect && onlyIntegrateCardElementConnectMerchantFlag !== 'true';
399
- LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
436
+ LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock); // 兼容三种预览开关取值:true / 'web' / 'mobile'
437
+ previewMode = (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.preview;
438
+ IS_PREVIEW = previewMode === true || previewMode === 'web' || previewMode === 'mobile';
439
+ SHOULD_USE_MOCK = LOCAL_MOCK || IS_PREVIEW;
400
440
  _queryParse = queryParse(this.getElementUrl()), appType = _queryParse.appType;
401
441
  terminalType = isElementPad() ? 'WEB' : appType ? 'APP' : isElementPC() ? 'WEB' : 'WAP';
402
442
  /**
@@ -408,10 +448,14 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
408
448
  generateActionQueryPromise = function generateActionQueryPromise() {
409
449
  return new Promise(function (resolve, reject) {
410
450
  var _displayInfo$merchant;
411
- // 本地mock模式:直接返回预设的sdkAction,用于开发调试
412
- if (LOCAL_MOCK) {
451
+ if (SHOULD_USE_MOCK) {
413
452
  setTimeout(function () {
414
- resolve(sdkAction);
453
+ if (IS_PREVIEW) {
454
+ var mockData = _this3.buildPreviewMockData(sdkAction);
455
+ resolve(mockData);
456
+ } else {
457
+ resolve(sdkAction);
458
+ }
415
459
  }, 100);
416
460
  return;
417
461
  }
@@ -429,6 +473,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
429
473
  }
430
474
  };
431
475
 
476
+ // 自定义主题模版(APR_ 前缀 AppearanceID):额外传递 appearanceId
477
+ var mountAppearance = displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.appearance;
478
+ var isAppearanceId = typeof (mountAppearance === null || mountAppearance === void 0 ? void 0 : mountAppearance.theme) === 'string' && mountAppearance.theme.startsWith('APR_');
479
+ if (isAppearanceId) {
480
+ sdkRequestData.appearanceId = mountAppearance.theme;
481
+ }
432
482
  // 可选参数:商户指定的储值卡信息
433
483
  if (displayInfo !== null && displayInfo !== void 0 && (_displayInfo$merchant = displayInfo.merchantAppointParam) !== null && _displayInfo$merchant !== void 0 && _displayInfo$merchant.storedCard) {
434
484
  sdkRequestData.merchantAppointParam = displayInfo.merchantAppointParam;
@@ -493,8 +543,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
493
543
  */
494
544
  generateOneAccountQueryPromise = function generateOneAccountQueryPromise() {
495
545
  return new Promise(function (resolve, reject) {
496
- // 本地mock模式:直接返回预设的oneAccount数据,用于开发调试
497
- if (LOCAL_MOCK) {
546
+ if (SHOULD_USE_MOCK) {
498
547
  setTimeout(function () {
499
548
  resolve(oneAccount);
500
549
  }, 100);
@@ -531,7 +580,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
531
580
  });
532
581
  };
533
582
  _context3.next = 18;
534
- return Promise.all(shouldQueryOneAccount ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
583
+ return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
535
584
  case 18:
536
585
  _yield$Promise$all = _context3.sent;
537
586
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
@@ -556,6 +605,28 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
556
605
  }
557
606
  return obtainData;
558
607
  }()
608
+ /**
609
+ * 构建预览模式的 mock 数据
610
+ * 合并 mock.ts 的硬编码数据和 mount 传入的 paymentMethods 配置
611
+ */
612
+ }, {
613
+ key: "buildPreviewMockData",
614
+ value: function buildPreviewMockData(baseMock) {
615
+ var _this$elementContaine8 = this.elementContainer.getPaymentContext(),
616
+ displayInfo = _this$elementContaine8.displayInfo;
617
+ var mountOptions = displayInfo;
618
+ var paymentMethodsConfig = mountOptions === null || mountOptions === void 0 ? void 0 : mountOptions.previewPaymentMethods;
619
+
620
+ // 深拷贝 mock 数据,避免修改原始对象
621
+ var result = JSON.parse(JSON.stringify(baseMock));
622
+
623
+ // 转换 paymentMethods 配置为内部格式
624
+ var convertedMethods = convertPaymentMethods(paymentMethodsConfig);
625
+
626
+ // 替换 paymentMethods
627
+ result.paymentMethods = convertedMethods;
628
+ return result;
629
+ }
559
630
  }, {
560
631
  key: "getValue",
561
632
  value: function getValue() {
@@ -3,10 +3,7 @@ export declare class ElementComponent {
3
3
  private options;
4
4
  private controller;
5
5
  constructor(options: IElementOptions);
6
- /**
7
- * @deprecated 不要使用,internal experiment方法
8
- */
9
- updatePayment(paymentSessionData: any): Promise<boolean>;
6
+ updatePayment(paymentSessionData: any): Promise<unknown>;
10
7
  mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<import("./type").ICommonApiResponse>;
11
8
  validateFields(): Promise<{
12
9
  isValid: boolean;
@@ -1,18 +1,16 @@
1
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 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
+ 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; }
2
4
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
6
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- 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; }
6
- 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; }
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
8
  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); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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 { adjustSessionData, isElements2 } from "../../../modern/tools";
14
13
  import ElementController from "./elementController";
15
- import { ModernElementController } from "./modernElementController";
16
14
  import { InvalidElementConfigError } from "./type";
17
15
  import { formatElementOption, validateElementOption } from "./util";
18
16
  export var ElementComponent = /*#__PURE__*/function () {
@@ -25,23 +23,11 @@ export var ElementComponent = /*#__PURE__*/function () {
25
23
  throw new InvalidElementConfigError(validate.errors);
26
24
  }
27
25
  this.options = formatElementOption(options);
28
-
29
- // 核心分流逻辑
30
- if (isElements2(options.sessionData)) {
31
- this.controller = new ModernElementController(_objectSpread(_objectSpread({}, this.options), {}, {
32
- sessionData: adjustSessionData(this.options.sessionData)
33
- }));
34
- } else {
35
- this.controller = new ElementController(this.options);
36
- }
26
+ this.controller = new ElementController(options);
37
27
  }
38
-
39
- /**
40
- * @deprecated 不要使用,internal experiment方法
41
- */
42
28
  _createClass(ElementComponent, [{
43
29
  key: "updatePayment",
44
- value: (function () {
30
+ value: function () {
45
31
  var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentSessionData) {
46
32
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
33
  while (1) switch (_context.prev = _context.next) {
@@ -61,7 +47,6 @@ export var ElementComponent = /*#__PURE__*/function () {
61
47
  // mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
62
48
  // mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
63
49
  // mount(renderOptions: PaymentMountOptions, sdkSelector: string);
64
- )
65
50
  }, {
66
51
  key: "mount",
67
52
  value: function mount(renderOptions, sdkSelector) {
@@ -153,7 +153,7 @@ export var sdkAction1 = {
153
153
  }, {
154
154
  antomPage: 'paymentMetaPage',
155
155
  category: 'AC_WALLET',
156
- expressCheckout: true,
156
+ expressCheckout: false,
157
157
  icon: 'https://cdn.marmot-cloud.com/storage/2024/05/15/5b829130-42d9-46e7-a23d-6774f7352900.svg',
158
158
  iconName: 'Alipay',
159
159
  interActionType: 'REDIRECT',
@@ -1,4 +1,3 @@
1
- import type { ShippingInfo } from "../../../modern/index";
2
1
  import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IMerchantAppointParam, IPaymentMethod } from '../../../types';
3
2
  import AddressProcessor from './elementProcessor/addressProcessor';
4
3
  import AuthProcessor from './elementProcessor/authProcessor';
@@ -150,7 +149,7 @@ type CompatibleVariables<T extends Record<string, string>> = {
150
149
  export interface PaymentMountOptions extends BaseMountOptions {
151
150
  type: ElementType.payment;
152
151
  appearance?: {
153
- theme?: ThemeType;
152
+ theme?: ThemeType | `APR_${string}`;
154
153
  layout?: {
155
154
  type: PaymentElementLayout;
156
155
  };
@@ -193,6 +192,54 @@ export interface PaymentMountOptions extends BaseMountOptions {
193
192
  };
194
193
  notRedirectAfterComplete?: boolean;
195
194
  merchantAppointParam?: IMerchantAppointParam;
195
+ /**
196
+ * 支付方式配置
197
+ *
198
+ * 使用说明:
199
+ * - preview: true 时生效,用于配置预览展示的支付方式和外观
200
+ * - preview: false/undefined 时,此配置被忽略,支付方式来自后端 sdkAction.query 接口
201
+ */
202
+ previewPaymentMethods?: {
203
+ /**
204
+ * 极速支付配置
205
+ */
206
+ expressCheckout?: {
207
+ enabled: boolean;
208
+ methods?: {
209
+ /**
210
+ * 支付方式显示名称,如 "Apple Pay"
211
+ */
212
+ paymentMethodName: string;
213
+ /**
214
+ * 支付方式类型,如 "APPLEPAY"
215
+ */
216
+ paymentMethodType: string;
217
+ }[];
218
+ };
219
+ /**
220
+ * 支持的支付方式列表
221
+ * 数组顺序即为前端展示顺序
222
+ */
223
+ supportedMethods?: {
224
+ /**
225
+ * 支付方式显示名称,如 "CARD", "AlipayHK"
226
+ */
227
+ paymentMethodName: string;
228
+ /**
229
+ * 支付方式类型,如 "VISA", "ALIPAY_HK"
230
+ */
231
+ paymentMethodType: string;
232
+ /**
233
+ * 支付方式图标 URL
234
+ */
235
+ logoUrl?: string;
236
+ }[];
237
+ /**
238
+ * 推荐支付方式
239
+ * 值为 paymentMethodType,匹配的支付方式会被标记为 recommend
240
+ */
241
+ topping?: string;
242
+ };
196
243
  }
197
244
  export declare enum AddressEventCallbackName {
198
245
  SHIPPING_CHANGE = "SHIPPING_CHANGE"
@@ -245,6 +292,23 @@ export interface PaymentSubmitData {
245
292
  paymentMethodId?: string;
246
293
  };
247
294
  }
295
+ export interface ShippingInfo {
296
+ shippingName: {
297
+ firstName: string;
298
+ lastName: string;
299
+ middleName?: string;
300
+ fullName?: string;
301
+ };
302
+ shippingPhoneNo: string;
303
+ shippingAddress: {
304
+ region: string;
305
+ address1: string;
306
+ address2: string;
307
+ city?: string;
308
+ state?: string;
309
+ zipCode: string;
310
+ };
311
+ }
248
312
  export interface AddressSubmitData {
249
313
  shippingName: {
250
314
  firstName: string;
@@ -288,7 +352,8 @@ export interface SubmitFuncParams {
288
352
  * - Only effective when payment method is Apple Pay
289
353
  * - Invoked via event bridge after user FaceID/TouchID authorization on the payment sheet
290
354
  * - Return true: proceed with charge
291
- * - Return false / timeout / throw error: abort payment, returns MERCHANT_CONFIRM_ABORT error code
355
+ * - Return false / throw error: abort payment, returns MERCHANT_CONFIRM_ABORT error code
356
+ * - Timeout: abort payment, returns MERCHANT_CONFIRM_TIMEOUT error code
292
357
  */
293
358
  onBeforeConfirm?: () => Promise<boolean>;
294
359
  }
@@ -425,6 +490,15 @@ export interface IElementOptions {
425
490
  onStartLoading: () => void;
426
491
  onEndLoading: () => void;
427
492
  };
493
+ /**
494
+ * 预览模式开关
495
+ * - true / 'web': 跳过真实 API 请求,使用 mock 数据,按 WebElement(inline)方式渲染(向后兼容,等同于 'web')
496
+ * - 'mobile': 跳过真实 API 请求,使用 mock 数据,按 MobileElement(popup)方式渲染,用于 mobileElement 降级预览
497
+ * - false / undefined: 发起真实请求(默认行为)
498
+ *
499
+ * 使用场景:B 端配置后台预览,C 端生产环境不应使用
500
+ */
501
+ preview?: boolean | 'web' | 'mobile';
428
502
  }
429
503
  export interface IElementProcessors {
430
504
  [ElementType.auth]: AuthProcessor;
@@ -512,17 +586,4 @@ export interface EventDataMap {
512
586
  [EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
513
587
  [EVENTNAME.BILLINGADDRESSCHANGED]: BillingAddressChangedData;
514
588
  }
515
- export interface IElementController {
516
- mount(renderOptions: PaymentMountOptions, sdkSelector: string): Promise<ICommonApiResponse>;
517
- submitPayment(params: SubmitFuncParams): Promise<IPaymentApiResponse>;
518
- validateFields(): Promise<{
519
- isValid: boolean;
520
- }>;
521
- /**
522
- * @deprecated 不要使用,internal experiment方法
523
- */
524
- updatePayment(paymentSessionData: string): Promise<boolean>;
525
- destroy(): void;
526
- on<T extends EVENTNAME>(event: T, callback: (data: EventDataMap[T]) => void): void;
527
- }
528
589
  export {};
@@ -1,5 +1,5 @@
1
1
  import { IElementStatus } from '../../../foundation';
2
- import { CashierSdkActionQueryResult, Ianalytics, IPaymentSessionMetaData } from '../../../types';
2
+ import { CashierSdkActionQueryResult, DisplayTypeEnum, Ianalytics, IPaymentSessionMetaData } from '../../../types';
3
3
  import { ContainerController } from './elementContainerService/containerService';
4
4
  import { ELEMENT_ENVIRONMENT_TYPE, EventCallbackCode, IElementOptions, IToastOptions } from './type';
5
5
  export declare const formatElementOption: (options: IElementOptions) => {
@@ -19,6 +19,7 @@ export declare const formatElementOption: (options: IElementOptions) => {
19
19
  onStartLoading: () => void;
20
20
  onEndLoading: () => void;
21
21
  };
22
+ preview?: boolean | "mobile" | "web";
22
23
  };
23
24
  export declare const validateElementOption: (options: IElementOptions) => {
24
25
  isValid: boolean;
@@ -48,7 +49,7 @@ export declare function checkCanUpdate({ status, paymentContainerService, newPay
48
49
  newPaymentSessionData: string;
49
50
  oldPaymentSessionData: string;
50
51
  }): boolean;
51
- export declare function generateIframeSrc({ paymentSessionObj, paymentSession, instanceId, environment, appVersion, analytics, locale, pageUrl, link, }: {
52
+ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, instanceId, environment, appVersion, analytics, locale, pageUrl, link, renderDisplayType, }: {
52
53
  paymentSessionObj: IPaymentSessionMetaData;
53
54
  paymentSession: string;
54
55
  environment: string;
@@ -58,6 +59,12 @@ export declare function generateIframeSrc({ paymentSessionObj, paymentSession, i
58
59
  pageUrl: string;
59
60
  appVersion: string;
60
61
  link?: string;
62
+ /**
63
+ * iframe 中 checkout-v2 的渲染形态。
64
+ * - inline(默认): WebElement 渲染
65
+ * - popup: MobileElement 渲染(用于 mobileElement 降级预览)
66
+ */
67
+ renderDisplayType?: DisplayTypeEnum;
61
68
  }): string;
62
69
  export declare function handleRedirect(data: any, fromFastSdk: boolean, eventCallback: ({ code, message }: {
63
70
  code: any;
@@ -138,7 +138,8 @@ export function generateIframeSrc(_ref3) {
138
138
  analytics = _ref3.analytics,
139
139
  locale = _ref3.locale,
140
140
  pageUrl = _ref3.pageUrl,
141
- link = _ref3.link;
141
+ link = _ref3.link,
142
+ renderDisplayType = _ref3.renderDisplayType;
142
143
  var componentSign = getComponentSign(paymentSessionObj);
143
144
  var productSceneVersion = (paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.productSceneVersion) || '';
144
145
  var productScene = (paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$pa2 = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa2 === void 0 ? void 0 : _paymentSessionObj$pa2.productScene) || '';
@@ -151,7 +152,7 @@ export function generateIframeSrc(_ref3) {
151
152
  link = "".concat(baseUrl[_env]).concat(pageUrl);
152
153
  }
153
154
  var _getIframeUrl = getIframeUrl({
154
- renderDisplayType: DisplayTypeEnum.inline,
155
+ renderDisplayType: renderDisplayType !== null && renderDisplayType !== void 0 ? renderDisplayType : DisplayTypeEnum.inline,
155
156
  componentSign: componentSign,
156
157
  analytics: analytics,
157
158
  productScene: productScene,
@@ -1,6 +1,6 @@
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); }
1
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; }
2
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; }
3
- 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); }
4
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
5
  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
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -103,23 +103,20 @@ export var EventCenter = /*#__PURE__*/function () {
103
103
  if (!this.iframes.some(function (iframe) {
104
104
  return iframe.origin === e.origin;
105
105
  })) return;
106
- if ((_e$data = e.data) !== null && _e$data !== void 0 && _e$data.source && ['react-devtools-content-script', 'react-devtools-backend-manager', 'react-devtools-bridge'].includes(e.data.source)) {
106
+ if (((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.source) === 'react-devtools-content-script') {
107
107
  return; // Ignore messages from React DevTools
108
108
  }
109
- // postMessage 结构化克隆传递的是对象,不是 JSON 字符串;先判断是否为对象,再尝试 JSON 解析
110
- var eventPayload;
111
- if (_typeof(e.data) === 'object' && e.data !== null) {
112
- eventPayload = e.data;
113
- } else if (isJsonString(e.data)) {
114
- eventPayload = JSON.parse(e.data);
109
+ var isJson = isJsonString(e.data);
110
+ if (isJson) {
111
+ var _eventPayload = JSON.parse(e.data);
112
+ if (_eventPayload.context.event && _eventPayload.context.event !== 'onLog') {}
113
+ if (!this.checkEventCompliant(_eventPayload)) {
114
+ return;
115
+ }
116
+ this._handleAppMessage(_eventPayload);
115
117
  } else {
116
118
  console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
117
- return;
118
- }
119
- if (!this.checkEventCompliant(eventPayload)) {
120
- return;
121
119
  }
122
- this._handleAppMessage(eventPayload);
123
120
  }
124
121
  }, {
125
122
  key: "checkEventCompliant",
@@ -1,9 +1,5 @@
1
- import type { AntomSDK, LoadAntomConfig, ShippingInfo } from "../../types";
1
+ import type { AntomSDK, LoadAntomConfig } from "../../types";
2
2
  /**
3
3
  * @description load Antom instance
4
4
  */
5
5
  export declare const loadAntom: (config?: LoadAntomConfig) => Promise<AntomSDK>;
6
- /**
7
- * @description 导出给v2element使用的类型
8
- */
9
- export type { ShippingInfo };