@alipay/ams-checkout 0.0.1742382470-dev.4 → 0.0.1743078169-dev.3

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 (56) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/component/popupWindow.style.js +4 -1
  4. package/esm/constant/index.d.ts +3 -0
  5. package/esm/constant/index.js +3 -0
  6. package/esm/core/component/element/elementContainerService/containerService.d.ts +29 -0
  7. package/esm/core/component/element/elementContainerService/containerService.js +101 -0
  8. package/esm/core/component/element/elementContainerService/index.d.ts +19 -0
  9. package/esm/core/component/element/elementContainerService/index.js +55 -0
  10. package/esm/core/component/element/elementController/index.d.ts +22 -0
  11. package/esm/core/component/element/elementController/index.js +364 -0
  12. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +17 -0
  13. package/esm/core/component/element/elementProcessor/addressProcessor.js +122 -0
  14. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +14 -0
  15. package/esm/core/component/element/elementProcessor/authProcessor.js +70 -0
  16. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +36 -0
  17. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +79 -0
  18. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +17 -0
  19. package/esm/core/component/element/elementProcessor/paymentProcessor.js +179 -0
  20. package/esm/core/component/element/index.d.ts +8 -46
  21. package/esm/core/component/element/index.js +28 -922
  22. package/esm/core/component/element/type.d.ts +29 -1
  23. package/esm/core/component/element/util.d.ts +58 -0
  24. package/esm/core/component/element/util.js +321 -0
  25. package/esm/core/component/index.d.ts +5 -1
  26. package/esm/core/component/index.js +1 -2
  27. package/esm/core/component/oldElement/index.d.ts +59 -0
  28. package/esm/core/component/oldElement/index.js +956 -0
  29. package/esm/core/component/oldElement/type.d.ts +351 -0
  30. package/esm/core/component/oldElement/type.js +81 -0
  31. package/esm/foundation/core/index.d.ts +6 -1
  32. package/esm/foundation/core/index.js +68 -34
  33. package/esm/foundation/index.d.ts +7 -0
  34. package/esm/foundation/index.js +10 -2
  35. package/esm/foundation/product-processor/element/index.d.ts +7 -0
  36. package/esm/foundation/product-processor/element/index.js +24 -0
  37. package/esm/foundation/service/container/index.d.ts +6 -3
  38. package/esm/foundation/service/container/index.js +19 -7
  39. package/esm/foundation/service/container/popup.d.ts +1 -1
  40. package/esm/foundation/service/event-center.js +1 -0
  41. package/esm/index.js +1 -0
  42. package/esm/plugin/component/cashierApp.d.ts +1 -1
  43. package/esm/plugin/component/index.js +1 -1
  44. package/esm/types/index.d.ts +1 -1
  45. package/esm/types/index.js +1 -1
  46. package/package.json +1 -1
  47. /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
  48. /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
  49. /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
  50. /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
  51. /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
  52. /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
  53. /package/esm/core/component/{element → oldElement}/mock.d.ts +0 -0
  54. /package/esm/core/component/{element → oldElement}/mock.js +0 -0
  55. /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
  56. /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -0,0 +1,364 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ 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; }
9
+ 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); } }
10
+ 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); }); }; }
11
+ 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; }
12
+ 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; }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ 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); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ 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; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
+ 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); }
19
+ import { EVENT } from "../../../../constant";
20
+ import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
21
+ import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
22
+ import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
23
+ import { AntomSDKCore } from "../../../../foundation/core";
24
+ import { ElementProcessor } from "../../../../foundation/product-processor/element";
25
+ import { destroyModal } from "../../../../plugin/component/popupWindow.style";
26
+ import { ProductSceneEnum } from "../../../../types";
27
+ import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
28
+ import { IContainerStatus } from "../elementContainerService/containerService";
29
+ import { ElementPaymentEvent, ElementType, EventCallbackCode } from "../type";
30
+ import { checkCanMount, checkCanUpdate, handleRedirect } from "../util";
31
+ var ElementController = /*#__PURE__*/function () {
32
+ // 新增变量
33
+
34
+ function ElementController(options) {
35
+ _classCallCheck(this, ElementController);
36
+ _defineProperty(this, "options", void 0);
37
+ _defineProperty(this, "elementContainer", void 0);
38
+ _defineProperty(this, "serviceMap", void 0);
39
+ _defineProperty(this, "loading", void 0);
40
+ _defineProperty(this, "elementProcessors", void 0);
41
+ _defineProperty(this, "elementContainerService", void 0);
42
+ _defineProperty(this, "onValidateFunc", function (event, params) {
43
+ return new Promise(function (resolve) {
44
+ event.emitAndListen({
45
+ event: ElementPaymentEvent.VALIDATE,
46
+ data: {
47
+ params: _objectSpread({}, params)
48
+ }
49
+ }, function (result) {
50
+ resolve(result);
51
+ });
52
+ });
53
+ });
54
+ this.options = options;
55
+ this.elementContainer = new AntomSDKCore();
56
+ this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
57
+ this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
58
+ this.initService();
59
+ this.elementContainerService = new ElementContainerService({
60
+ instanceId: this.elementContainer.getInstanceId()
61
+ });
62
+ this.elementContainer.setStatus(IContainerStatus.READY);
63
+ }
64
+ _createClass(ElementController, [{
65
+ key: "initService",
66
+ value: function initService() {
67
+ this.serviceMap = {
68
+ Log: this.elementContainer.getServiceProvider().getService('Log'),
69
+ EventCenter: this.elementContainer.getServiceProvider().getService('EventCenter'),
70
+ Requester: this.elementContainer.getServiceProvider().getService('Requester')
71
+ };
72
+ }
73
+ }, {
74
+ key: "initElementProcessors",
75
+ value: function initElementProcessors(elementType) {
76
+ var processorMap = {
77
+ auth: new AuthProcessor(this.options),
78
+ address: new AddressProcessor(this.options),
79
+ payment: new PaymentProcessor(this.options)
80
+ };
81
+ this.elementProcessors = _objectSpread(_objectSpread({}, this.elementProcessors), {}, _defineProperty({}, elementType, processorMap[elementType]));
82
+ this.elementProcessors[elementType].registerElementContainer(this.elementContainer);
83
+ }
84
+ }, {
85
+ key: "onEventCallback",
86
+ value: function onEventCallback(_ref) {
87
+ var code = _ref.code,
88
+ message = _ref.message;
89
+ this.options.onEventCallback({
90
+ code: code,
91
+ message: message
92
+ });
93
+ }
94
+ }, {
95
+ key: "mount",
96
+ value: function mount(renderOptions, sdkSelector, cashier) {
97
+ var _this = this;
98
+ var _checkCanMount = checkCanMount({
99
+ sdkSelector: sdkSelector,
100
+ status: this.elementContainer.getStatus()
101
+ }),
102
+ success = _checkCanMount.success,
103
+ errorMsg = _checkCanMount.errorMsg;
104
+ if (!success) {
105
+ this.onEventCallback({
106
+ code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
107
+ message: errorMsg
108
+ });
109
+ return;
110
+ }
111
+ this.changeLoading(true);
112
+ var startBizFlowData = {
113
+ paymentSession: this.options.sessionData,
114
+ displayInfo: renderOptions,
115
+ submitPayRequestExtra: {
116
+ notRedirectAfterComplete: renderOptions.type === ElementType.payment ? renderOptions.notRedirectAfterComplete : undefined,
117
+ merchantAppointParam: renderOptions.type === ElementType.payment ? renderOptions.merchantAppointParam : undefined
118
+ }
119
+ };
120
+ if (cashier && renderOptions.sessionData) {
121
+ startBizFlowData.paymentSession = renderOptions.sessionData;
122
+ }
123
+ this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
124
+ _this.onEventCallback({
125
+ code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
126
+ message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
127
+ });
128
+ _this.changeLoading(false);
129
+ return;
130
+ });
131
+ this.initElementProcessors(renderOptions.type);
132
+ this.elementContainerService.mount({
133
+ type: renderOptions.type,
134
+ selector: sdkSelector,
135
+ processor: this.elementProcessors[renderOptions.type],
136
+ options: renderOptions
137
+ });
138
+ this.elementProcessors[renderOptions.type].registerEventCenter(this.elementContainerService.getEventService(renderOptions.type));
139
+ this.sendRequestAndWaitWebLaunch(renderOptions.type);
140
+ this.addEventListener();
141
+ this.serviceMap.EventCenter.addIFrame(this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
142
+ return {
143
+ getValue: this.elementProcessors[renderOptions.type].getValue.bind(this.elementProcessors[renderOptions.type]),
144
+ on: function on(event, callback) {
145
+ _this.elementProcessors[renderOptions.type].registerEventListener(event, callback);
146
+ }
147
+ };
148
+ }
149
+ }, {
150
+ key: "submitPayment",
151
+ value: function submitPayment() {
152
+ var _this2 = this;
153
+ this.changeLoading(true);
154
+ new Promise( /*#__PURE__*/function () {
155
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
156
+ var params, _this2$elementProcess, _result$data, _result$data2, result, _this2$elementProcess2, _result$data3, _result$data4, _result, _this2$elementProcess3;
157
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
158
+ while (1) switch (_context.prev = _context.next) {
159
+ case 0:
160
+ params = {};
161
+ if (!_this2.elementProcessors[ElementType.auth]) {
162
+ _context.next = 8;
163
+ break;
164
+ }
165
+ _context.next = 4;
166
+ return _this2.onValidateFunc((_this2$elementProcess = _this2.elementProcessors[ElementType.auth]) === null || _this2$elementProcess === void 0 ? void 0 : _this2$elementProcess.eventCenter);
167
+ case 4:
168
+ result = _context.sent;
169
+ params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
170
+ if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
171
+ _context.next = 8;
172
+ break;
173
+ }
174
+ return _context.abrupt("return", resolve(undefined));
175
+ case 8:
176
+ if (!_this2.elementProcessors[ElementType.address]) {
177
+ _context.next = 15;
178
+ break;
179
+ }
180
+ _context.next = 11;
181
+ return _this2.onValidateFunc((_this2$elementProcess2 = _this2.elementProcessors[ElementType.address]) === null || _this2$elementProcess2 === void 0 ? void 0 : _this2$elementProcess2.eventCenter);
182
+ case 11:
183
+ _result = _context.sent;
184
+ params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
185
+ if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
186
+ _context.next = 15;
187
+ break;
188
+ }
189
+ return _context.abrupt("return", resolve(undefined));
190
+ case 15:
191
+ if (!_this2.elementProcessors[ElementType.payment]) {
192
+ _context.next = 25;
193
+ break;
194
+ }
195
+ _context.prev = 16;
196
+ _context.next = 19;
197
+ return _this2.onValidateFunc((_this2$elementProcess3 = _this2.elementProcessors[ElementType.payment]) === null || _this2$elementProcess3 === void 0 ? void 0 : _this2$elementProcess3.eventCenter, params);
198
+ case 19:
199
+ return _context.abrupt("return", resolve(undefined));
200
+ case 22:
201
+ _context.prev = 22;
202
+ _context.t0 = _context["catch"](16);
203
+ return _context.abrupt("return", resolve(undefined));
204
+ case 25:
205
+ resolve(params);
206
+ case 26:
207
+ case "end":
208
+ return _context.stop();
209
+ }
210
+ }, _callee, null, [[16, 22]]);
211
+ }));
212
+ return function (_x) {
213
+ return _ref2.apply(this, arguments);
214
+ };
215
+ }()).then(function () {
216
+ _this2.changeLoading(false);
217
+ }, function () {
218
+ _this2.changeLoading(false);
219
+ });
220
+ }
221
+ }, {
222
+ key: "changeLoading",
223
+ value: function changeLoading(loading) {
224
+ if (loading) {
225
+ var _this$options$loading;
226
+ if ((_this$options$loading = this.options.loading) !== null && _this$options$loading !== void 0 && _this$options$loading.onStartLoading && !this.loading) {
227
+ var _this$options$loading2, _this$options$loading3;
228
+ this.loading = true;
229
+ (_this$options$loading2 = this.options.loading) === null || _this$options$loading2 === void 0 || (_this$options$loading3 = _this$options$loading2.onStartLoading) === null || _this$options$loading3 === void 0 || _this$options$loading3.call(_this$options$loading2);
230
+ }
231
+ } else {
232
+ var _this$options$loading4;
233
+ if ((_this$options$loading4 = this.options.loading) !== null && _this$options$loading4 !== void 0 && _this$options$loading4.onEndLoading && this.loading) {
234
+ var _this$options$loading5, _this$options$loading6;
235
+ (_this$options$loading5 = this.options.loading) === null || _this$options$loading5 === void 0 || (_this$options$loading6 = _this$options$loading5.onEndLoading) === null || _this$options$loading6 === void 0 || _this$options$loading6.call(_this$options$loading5);
236
+ }
237
+ this.loading = false;
238
+ }
239
+ }
240
+ }, {
241
+ key: "addEventListener",
242
+ value: function addEventListener() {
243
+ var _this3 = this;
244
+ this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (result) {
245
+ if (_this3.elementProcessors[result.source].eventListener[result.event]) {
246
+ var _this3$elementProcess, _this3$elementProcess2;
247
+ (_this3$elementProcess = (_this3$elementProcess2 = _this3.elementProcessors[result.source].eventListener)[result.event]) === null || _this3$elementProcess === void 0 || _this3$elementProcess.call(_this3$elementProcess2, result.data);
248
+ }
249
+ });
250
+ this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
251
+ _this3.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
252
+ _this3.changeLoading(false);
253
+ // 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
254
+ // const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
255
+ // (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
256
+ // );
257
+ // if (allContainersInBizFlow) {
258
+ // this.elementContainer.setStatus(IContainerStatus.IN_BIZ_FLOW);
259
+ // }
260
+ });
261
+ this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (result) {
262
+ handleRedirect(result);
263
+ });
264
+ }
265
+ }, {
266
+ key: "sendRequestAndWaitWebLaunch",
267
+ value: function sendRequestAndWaitWebLaunch(type) {
268
+ var _this4 = this;
269
+ var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
270
+ Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
271
+ var _ref4 = _slicedToArray(_ref3, 2),
272
+ _webLaunchRes = _ref4[0],
273
+ _obtainDataRes = _ref4[1];
274
+ _this4.elementProcessors[type].onReady({
275
+ queryResult: _obtainDataRes.originActionQuery
276
+ });
277
+ });
278
+ }
279
+ }, {
280
+ key: "updatePayment",
281
+ value: function () {
282
+ var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
283
+ var _this5 = this;
284
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
285
+ while (1) switch (_context3.prev = _context3.next) {
286
+ case 0:
287
+ return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
288
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
289
+ var prePaymentSessionData, data;
290
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
291
+ while (1) switch (_context2.prev = _context2.next) {
292
+ case 0:
293
+ if (checkCanUpdate({
294
+ status: _this5.elementContainer.getStatus(),
295
+ paymentContainerService: _this5.elementContainerService.getContainerService(ElementType.payment),
296
+ newPaymentSessionData: paymentSessionData,
297
+ oldPaymentSessionData: _this5.options.sessionData
298
+ })) {
299
+ _context2.next = 2;
300
+ break;
301
+ }
302
+ return _context2.abrupt("return", resolve(false));
303
+ case 2:
304
+ prePaymentSessionData = _this5.elementContainer.getPaymentContext().paymentSession;
305
+ _this5.elementContainer.updatePaymentSessionData(paymentSessionData);
306
+ // 1、数据获取
307
+ _context2.next = 6;
308
+ return _this5.elementProcessors[ElementType.payment].obtainData();
309
+ case 6:
310
+ data = _context2.sent;
311
+ // 2、发送update消息
312
+ Object.values(_this5.elementProcessors).forEach(function (processor) {
313
+ processor.update({
314
+ data: {
315
+ originActionQuery: data.originActionQuery
316
+ },
317
+ paymentSessionData: paymentSessionData
318
+ });
319
+ });
320
+ // 3、返回更新结果
321
+ _this5.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
322
+ // 若更新不成功,还原core.paymentContext信息
323
+ if (!data.success) {
324
+ _this5.elementContainer.updatePaymentSessionData(prePaymentSessionData);
325
+ }
326
+ return resolve(data.success || false);
327
+ });
328
+ case 9:
329
+ case "end":
330
+ return _context2.stop();
331
+ }
332
+ }, _callee2);
333
+ }));
334
+ return function (_x3) {
335
+ return _ref5.apply(this, arguments);
336
+ };
337
+ }()));
338
+ case 1:
339
+ case "end":
340
+ return _context3.stop();
341
+ }
342
+ }, _callee3);
343
+ }));
344
+ function updatePayment(_x2) {
345
+ return _updatePayment.apply(this, arguments);
346
+ }
347
+ return updatePayment;
348
+ }()
349
+ }, {
350
+ key: "destroy",
351
+ value: function destroy() {
352
+ this.elementContainerService.getContainerServices().forEach(function (value) {
353
+ value.getContainerService().getWebApp().remove();
354
+ });
355
+ // popup未注册会报错,但element不需要感知popup是否被注册
356
+ try {
357
+ destroyModal(); // 关闭popup弹窗
358
+ } catch (error) {}
359
+ this.elementContainer.setStatus(IContainerStatus.DESTROYED);
360
+ }
361
+ }]);
362
+ return ElementController;
363
+ }();
364
+ export default ElementController;
@@ -0,0 +1,17 @@
1
+ import BaseElementProcessor from './baseElementProcessor';
2
+ declare class AddressProcessor extends BaseElementProcessor {
3
+ onReady(extraParam: {
4
+ [key: string]: any;
5
+ }): void;
6
+ parameterInitAndCheck(): void;
7
+ beforeMount(): void;
8
+ preload(): void;
9
+ generateIframeSrc({ link, instanceId }: {
10
+ link: any;
11
+ instanceId: any;
12
+ }): string;
13
+ obtainData(): any;
14
+ getValue(hasValidate?: boolean): any;
15
+ update(data: any): void;
16
+ }
17
+ export default AddressProcessor;
@@ -0,0 +1,122 @@
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ 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); }
8
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
+ 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); }; }
10
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
11
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
+ import PackageJson from "../../../../../package.json";
15
+ import { generateIframeSrc as _generateIframeSrc } from "../util";
16
+ import BaseElementProcessor from "./baseElementProcessor";
17
+ var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
18
+ _inherits(AddressProcessor, _BaseElementProcessor);
19
+ var _super = _createSuper(AddressProcessor);
20
+ function AddressProcessor() {
21
+ _classCallCheck(this, AddressProcessor);
22
+ return _super.apply(this, arguments);
23
+ }
24
+ _createClass(AddressProcessor, [{
25
+ key: "onReady",
26
+ value: function onReady(extraParam) {
27
+ var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
28
+ this.eventCenter.dispatchToApp({
29
+ event: 'renderComponent',
30
+ data: {
31
+ heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
32
+ paymentSessionData: (_this$elementContaine = this.elementContainer.getPaymentContext()) === null || _this$elementContaine === void 0 ? void 0 : _this$elementContaine.paymentSessionId,
33
+ queryResult: extraParam.queryResult,
34
+ envInfo: {
35
+ screenHeight: screen.height,
36
+ screenWidth: screen.width
37
+ },
38
+ appearance: (_this$elementContaine2 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.displayInfo.appearance,
39
+ sessionResult: (_this$elementContaine3 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine3 === void 0 ? void 0 : _this$elementContaine3.paymentSessionObj,
40
+ notRedirectAfterComplete: ((_this$elementContaine4 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.startBizFlowOptions.submitPayRequestExtra) === null || _this$elementContaine4 === void 0 ? void 0 : _this$elementContaine4.notRedirectAfterComplete) === true,
41
+ merchantAppointParam: (_this$elementContaine5 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.startBizFlowOptions.submitPayRequestExtra) === null || _this$elementContaine5 === void 0 ? void 0 : _this$elementContaine5.merchantAppointParam
42
+ }
43
+ });
44
+ }
45
+ }, {
46
+ key: "parameterInitAndCheck",
47
+ value: function parameterInitAndCheck() {
48
+ // 实现 parameterInitAndCheck 方法
49
+ }
50
+ }, {
51
+ key: "beforeMount",
52
+ value: function beforeMount() {
53
+ // 实现 beforeMount 方法
54
+ }
55
+ }, {
56
+ key: "preload",
57
+ value: function preload() {
58
+ // 实现 preload 方法
59
+ }
60
+ }, {
61
+ key: "generateIframeSrc",
62
+ value: function generateIframeSrc(_ref) {
63
+ var link = _ref.link,
64
+ instanceId = _ref.instanceId;
65
+ this.instanceId = instanceId;
66
+ var _ref2 = this.elementContainer.getPaymentContext() || {},
67
+ paymentSession = _ref2.paymentSession,
68
+ paymentSessionObj = _ref2.paymentSessionObj,
69
+ sdkMetaData = _ref2.sdkMetaData;
70
+ var _this$options = this.options,
71
+ environment = _this$options.env.environment,
72
+ analytics = _this$options.analytics,
73
+ locale = _this$options.locale;
74
+ var version = PackageJson.version;
75
+ var pageUrl = "/elements-address/".concat(version, "/pages/address/index.html");
76
+ return _generateIframeSrc({
77
+ paymentSession: paymentSession,
78
+ paymentSessionObj: paymentSessionObj,
79
+ environment: environment,
80
+ analytics: analytics,
81
+ locale: locale,
82
+ link: link,
83
+ appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
84
+ pageUrl: pageUrl,
85
+ instanceId: instanceId
86
+ });
87
+ }
88
+ }, {
89
+ key: "obtainData",
90
+ value: function obtainData() {
91
+ // 实现 obtainData 方法
92
+ return {};
93
+ }
94
+ }, {
95
+ key: "getValue",
96
+ value: function getValue(hasValidate) {
97
+ var _this = this;
98
+ return new Promise(function (resolve, reject) {
99
+ try {
100
+ _this.eventCenter.dispatchToApp({
101
+ event: 'getValue',
102
+ data: hasValidate
103
+ });
104
+ _this.eventCenter.listen('onAddressResult', function (res) {
105
+ resolve(res);
106
+ });
107
+ } catch (error) {
108
+ reject(error);
109
+ }
110
+ });
111
+ }
112
+ }, {
113
+ key: "update",
114
+ value: function update(data) {
115
+ // 实现 update 方法的具体逻辑
116
+ console.log('Updating address processor with data:', data);
117
+ // 具体实现可以根据实际需求来编写
118
+ }
119
+ }]);
120
+ return AddressProcessor;
121
+ }(BaseElementProcessor);
122
+ export default AddressProcessor;
@@ -0,0 +1,14 @@
1
+ import BaseElementProcessor from './baseElementProcessor';
2
+ declare class AuthProcessor extends BaseElementProcessor {
3
+ onReady(extraParam: {
4
+ [key: string]: any;
5
+ }): void;
6
+ parameterInitAndCheck(): void;
7
+ beforeMount(): void;
8
+ preload(): void;
9
+ generateIframeSrc(): string;
10
+ obtainData(): any;
11
+ getValue(): any;
12
+ update(data: any): void;
13
+ }
14
+ export default AuthProcessor;
@@ -0,0 +1,70 @@
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ 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); }
8
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
9
+ 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); }; }
10
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
11
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
+ import BaseElementProcessor from "./baseElementProcessor";
15
+ var AuthProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
16
+ _inherits(AuthProcessor, _BaseElementProcessor);
17
+ var _super = _createSuper(AuthProcessor);
18
+ function AuthProcessor() {
19
+ _classCallCheck(this, AuthProcessor);
20
+ return _super.apply(this, arguments);
21
+ }
22
+ _createClass(AuthProcessor, [{
23
+ key: "onReady",
24
+ value: function onReady(extraParam) {
25
+ throw new Error('Method not implemented.');
26
+ }
27
+ }, {
28
+ key: "parameterInitAndCheck",
29
+ value: function parameterInitAndCheck() {
30
+ // 实现 parameterInitAndCheck 方法
31
+ }
32
+ }, {
33
+ key: "beforeMount",
34
+ value: function beforeMount() {
35
+ // 实现 beforeMount 方法
36
+ }
37
+ }, {
38
+ key: "preload",
39
+ value: function preload() {
40
+ // 实现 preload 方法
41
+ }
42
+ }, {
43
+ key: "generateIframeSrc",
44
+ value: function generateIframeSrc() {
45
+ // 实现 generateIframeSrc 方法
46
+ return '';
47
+ }
48
+ }, {
49
+ key: "obtainData",
50
+ value: function obtainData() {
51
+ // 实现 obtainData 方法
52
+ return {};
53
+ }
54
+ }, {
55
+ key: "getValue",
56
+ value: function getValue() {
57
+ // 实现 getValue 方法
58
+ return {};
59
+ }
60
+ }, {
61
+ key: "update",
62
+ value: function update(data) {
63
+ // 实现 update 方法的具体逻辑
64
+ console.log('Updating auth processor with data:', data);
65
+ // 具体实现可以根据实际需求来编写
66
+ }
67
+ }]);
68
+ return AuthProcessor;
69
+ }(BaseElementProcessor);
70
+ export default AuthProcessor;
@@ -0,0 +1,36 @@
1
+ import { AntomSDKCore } from "../../../../foundation/core";
2
+ import { Ianalytics, Ienv } from '../../../../types';
3
+ import { EventCenter } from './../../../../foundation/service/event-center';
4
+ interface ElementProcessorOptions {
5
+ env: Ienv;
6
+ locale: string;
7
+ networkMode: string;
8
+ mode: string;
9
+ analytics?: Ianalytics;
10
+ product: string;
11
+ }
12
+ declare abstract class BaseElementProcessor {
13
+ elementContainer: AntomSDKCore;
14
+ instanceId: string;
15
+ options: ElementProcessorOptions;
16
+ eventCenter: EventCenter;
17
+ eventListener: {};
18
+ abstract beforeMount(): void;
19
+ abstract preload(): void;
20
+ abstract generateIframeSrc({ instanceId, link }: {
21
+ instanceId: any;
22
+ link: any;
23
+ }): string;
24
+ abstract obtainData(): any;
25
+ abstract getValue(): any;
26
+ abstract onReady(extraParam: {
27
+ [key: string]: any;
28
+ }): void;
29
+ constructor(options: any);
30
+ private _setOptions;
31
+ abstract update(data: any): void;
32
+ registerElementContainer(elementContainer: AntomSDKCore): void;
33
+ registerEventCenter(eventCenter: EventCenter): void;
34
+ registerEventListener(event: any, callback: any): void;
35
+ }
36
+ export default BaseElementProcessor;