@alipay/ams-checkout 0.0.1788166152-dev.7 → 0.0.1788166152-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ams-checkout.js +3 -3
- package/dist/ams-checkout.min.js +1 -1
- package/dist/ams-checkout.min.js.map +1 -1
- package/esm/config/index.js +1 -1
- package/esm/core/component/element/modernElementController/index.js +2 -2
- package/esm/modern/component/channel.d.ts +21 -0
- package/esm/modern/component/component.inline.style.d.ts +10 -0
- package/esm/modern/component/component.popup.style.d.ts +26 -0
- package/esm/modern/component/popupWindow.style.d.ts +27 -0
- package/esm/modern/config/index.d.ts +23 -0
- package/esm/modern/config/request.d.ts +21 -0
- package/esm/modern/constant/auto-debit.d.ts +12 -0
- package/esm/modern/constant/easysafepay.d.ts +16 -0
- package/esm/modern/constant/element.d.ts +27 -0
- package/esm/modern/constant/index.d.ts +331 -0
- package/esm/modern/core/bus/ability/callback.d.ts +9 -0
- package/esm/modern/core/bus/ability/security.d.ts +10 -0
- package/esm/modern/core/bus/ability/tracker.d.ts +9 -0
- package/esm/modern/core/bus/index.d.ts +125 -0
- package/esm/modern/core/bus/interface.d.ts +36 -0
- package/esm/modern/core/component/address.d.ts +8 -0
- package/esm/modern/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/modern/core/component/ckp/index.d.ts +29 -0
- package/esm/modern/core/component/element/EventCenter/index.d.ts +41 -0
- package/esm/modern/core/component/element/config.d.ts +10 -0
- package/esm/modern/core/component/element/elementContainerService/containerService.d.ts +34 -0
- package/esm/modern/core/component/element/elementContainerService/index.d.ts +20 -0
- package/esm/modern/core/component/element/elementController/index.d.ts +54 -0
- package/esm/modern/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
- package/esm/modern/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
- package/esm/modern/core/component/element/elementProcessor/baseElementProcessor.d.ts +42 -0
- package/esm/modern/core/component/element/elementProcessor/convertPaymentMethods.d.ts +22 -0
- package/esm/modern/core/component/element/elementProcessor/paymentProcessor.d.ts +37 -0
- package/esm/modern/core/component/element/index.d.ts +17 -0
- package/esm/modern/core/component/element/mock.d.ts +10 -0
- package/esm/modern/core/component/element/modernElementController/adapter.d.ts +19 -0
- package/esm/modern/core/component/element/modernElementController/index.d.ts +172 -0
- package/esm/modern/core/component/element/type.d.ts +586 -0
- package/esm/modern/core/component/element/util.d.ts +93 -0
- package/esm/modern/core/component/index.d.ts +58 -0
- package/esm/modern/core/instance/index.d.ts +97 -0
- package/esm/modern/core/utils/connectConfig.d.ts +11 -0
- package/esm/modern/foundation/core/index.d.ts +36 -0
- package/esm/modern/foundation/index.d.ts +93 -0
- package/esm/modern/foundation/product-processor/autoDebit/deps.d.ts +14 -0
- package/esm/modern/foundation/product-processor/autoDebit/index.d.ts +48 -0
- package/esm/modern/foundation/product-processor/easysafepay/deps.d.ts +20 -0
- package/esm/modern/foundation/product-processor/easysafepay/index.d.ts +29 -0
- package/esm/modern/foundation/product-processor/element/index.d.ts +7 -0
- package/esm/modern/foundation/service/api-bus/ability/globalData.d.ts +10 -0
- package/esm/modern/foundation/service/api-bus/ability/request.d.ts +10 -0
- package/esm/modern/foundation/service/api-bus/ability/security.d.ts +12 -0
- package/esm/modern/foundation/service/api-bus/ability/tracker.d.ts +9 -0
- package/esm/modern/foundation/service/api-bus/busManager.d.ts +127 -0
- package/esm/modern/foundation/service/api-bus/index.d.ts +20 -0
- package/esm/modern/foundation/service/api-bus/interface.d.ts +48 -0
- package/esm/modern/foundation/service/container/index.d.ts +42 -0
- package/esm/modern/foundation/service/container/popup.d.ts +31 -0
- package/esm/modern/foundation/service/container/utils.d.ts +7 -0
- package/esm/modern/foundation/service/event-center.d.ts +82 -0
- package/esm/modern/foundation/service/global-data/index.d.ts +11 -0
- package/esm/modern/foundation/service/index.d.ts +19 -0
- package/esm/modern/foundation/service/log/index.d.ts +44 -0
- package/esm/modern/foundation/service/log/keys.d.ts +13 -0
- package/esm/modern/foundation/service/log/processor.d.ts +9 -0
- package/esm/modern/foundation/service/log/types.d.ts +33 -0
- package/esm/modern/foundation/service/requester/deps.d.ts +17 -0
- package/esm/modern/foundation/service/requester/requester.d.ts +22 -0
- package/esm/modern/foundation/service/security/index.d.ts +33 -0
- package/esm/modern/foundation/service/security/security.d.ts +54 -0
- package/esm/modern/foundation/utils/gray_scale_utils.d.ts +7 -0
- package/esm/modern/foundation/utils/payment_context_utils.d.ts +13 -0
- package/esm/modern/foundation/utils/payment_product_utils.d.ts +13 -0
- package/esm/modern/foundation/utils/preload_helper.d.ts +24 -0
- package/esm/modern/foundation/utils/redirect_utils.d.ts +11 -0
- package/esm/modern/foundation/utils/system_events.d.ts +4 -0
- package/esm/modern/foundation/utils/web_app_url_utils.d.ts +114 -0
- package/esm/modern/index.js +1 -1
- package/esm/modern/loader/constant.d.ts +36 -0
- package/esm/modern/loader/utils/proxyPerformance.d.ts +20 -0
- package/esm/modern/main.d.ts +54 -0
- package/esm/modern/{index.d.ts → modern/index.d.ts} +1 -1
- package/esm/modern/modern/loadAntomTracker.d.ts +7 -0
- package/esm/modern/modern/preload/antomManifestAdapter.d.ts +11 -0
- package/esm/modern/modern/preload/config.d.ts +10 -0
- package/esm/modern/modern/preload/gatewayPreconnection.d.ts +53 -0
- package/esm/modern/modern/preload/preloadAntomElements.d.ts +9 -0
- package/esm/modern/modern/preload/startAntomPreload.d.ts +2 -0
- package/esm/modern/modern/sdk/applepay-core/ApplePayHostService.d.ts +102 -0
- package/esm/modern/modern/sdk/elements/CVVElement.d.ts +144 -0
- package/esm/modern/modern/sdk/elements/PaymentElement.d.ts +204 -0
- package/esm/modern/modern/sdk/elements/appearanceRules.d.ts +59 -0
- package/esm/modern/modern/sdk/elements/appearanceRulesDefaults.d.ts +2 -0
- package/esm/modern/modern/sdk/eventsMap.d.ts +135 -0
- package/esm/modern/modern/sdk/oneapi/iexpfront/PaymentSessionService.d.ts +69 -0
- package/esm/modern/modern/sdk/oneapi/iexpfront/definitions.d.ts +5311 -0
- package/esm/modern/modern/sdk/oneapi/iexpfront/preConnection.d.ts +6 -0
- package/esm/modern/modern/sdk/stageName.d.ts +3 -0
- package/esm/modern/modern/sdk/tools/awaitWrap.d.ts +14 -0
- package/esm/modern/modern/sdk/tools/buildPageUrl.d.ts +4 -0
- package/esm/modern/modern/sdk/tools/checkSessionData.d.ts +1 -0
- package/esm/modern/modern/sdk/tools/expressElement/applePay.d.ts +9 -0
- package/esm/modern/modern/sdk/tools/expressElement/applePayHostToken.d.ts +32 -0
- package/esm/modern/modern/sdk/tools/expressElement/types.d.ts +277 -0
- package/esm/modern/modern/sdk/tools/getDevReqConfig.d.ts +2 -0
- package/esm/modern/modern/sdk/tools/getLocaleFromRenderData.d.ts +6 -0
- package/esm/modern/modern/sdk/tools/getMetaData.d.ts +126 -0
- package/esm/modern/modern/sdk/tools/modalMessageMonitor.d.ts +41 -0
- package/esm/modern/modern/sdk/tools/openModal.d.ts +20 -0
- package/esm/modern/modern/sdk/tools/paymentElement/applePayHostToken.d.ts +38 -0
- package/esm/modern/modern/sdk/tools/paymentElement/googlePayHostToken.d.ts +38 -0
- package/esm/modern/modern/sdk/tools/paymentElement/tracker.d.ts +16 -0
- package/esm/modern/modern/sdk/tools/paymentElement/walletHostListeners.d.ts +19 -0
- package/esm/modern/modern/sdk/tools/preloadTracking.d.ts +5 -0
- package/esm/modern/modern/sdk/tools/showToast.d.ts +33 -0
- package/esm/modern/modern/sdk/tools/validatePaymentAmount.d.ts +19 -0
- package/esm/modern/modern/sdk/tracking/elementTracker.d.ts +65 -0
- package/esm/modern/modern/sdk/types.d.ts +310 -0
- package/esm/modern/modern/tools.d.ts +26 -0
- package/esm/modern/plugin/applepay/component.d.ts +50 -0
- package/esm/modern/plugin/applepay/index.d.ts +17 -0
- package/esm/modern/plugin/applepay/interface.d.ts +161 -0
- package/esm/modern/plugin/applepay/service.d.ts +54 -0
- package/esm/modern/plugin/component/cashierApp.d.ts +38 -0
- package/esm/modern/plugin/component/channel.d.ts +73 -0
- package/esm/modern/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/modern/plugin/component/component.popup.style.d.ts +25 -0
- package/esm/modern/plugin/component/index.d.ts +133 -0
- package/esm/modern/plugin/component/popupWindow.style.d.ts +11 -0
- package/esm/modern/plugin/const.d.ts +2 -0
- package/esm/modern/plugin/payment-element/utils.d.ts +2 -0
- package/esm/modern/plugin/paypal/index.d.ts +20 -0
- package/esm/modern/plugin/type.d.ts +34 -0
- package/esm/modern/plugin/utils.d.ts +6 -0
- package/esm/modern/preload/antomManifestAdapter.d.ts +11 -0
- package/esm/modern/preload/antomManifestAdapter.js +117 -0
- package/esm/modern/preload/config.d.ts +10 -0
- package/esm/modern/preload/config.js +37 -0
- package/esm/modern/preload/gatewayPreconnection.d.ts +53 -0
- package/esm/modern/preload/gatewayPreconnection.js +213 -0
- package/esm/modern/preload/preloadAntomElements.d.ts +9 -0
- package/esm/modern/preload/preloadAntomElements.js +95 -0
- package/esm/modern/preload/startAntomPreload.d.ts +2 -0
- package/esm/modern/preload/startAntomPreload.js +9 -0
- package/esm/modern/request/index.d.ts +9 -0
- package/esm/modern/request/utils.d.ts +28 -0
- package/esm/modern/service/index.d.ts +13 -0
- package/esm/modern/tools.js +1 -1
- package/esm/modern/types/index.d.ts +856 -0
- package/esm/modern/util/beforeConfirm.d.ts +14 -0
- package/esm/modern/util/createIframeNode.d.ts +6 -0
- package/esm/modern/util/debug.d.ts +1 -0
- package/esm/modern/util/get.d.ts +25 -0
- package/esm/modern/util/getBackScheme.d.ts +5 -0
- package/esm/modern/util/index.d.ts +61 -0
- package/esm/modern/util/jshield-apdid/apdid-loader.d.ts +89 -0
- package/esm/modern/util/jshield-apdid/index.d.ts +21 -0
- package/esm/modern/util/logger.d.ts +67 -0
- package/esm/modern/util/mock.d.ts +1 -0
- package/esm/modern/util/redirect.d.ts +6 -0
- package/esm/modern/util/security-registry.d.ts +72 -0
- package/esm/modern/util/security.d.ts +55 -0
- package/esm/modern/util/spm-map.d.ts +217 -0
- package/esm/modern/util/storage.d.ts +2 -0
- package/esm/modern/util/timezone.d.ts +1 -0
- package/esm/modern/util/upgrade.d.ts +39 -0
- package/esm/modern/util/versionCompare.d.ts +15 -0
- package/esm/util/logger.js +1 -1
- package/package.json +2 -1
- package/types.d.ts +17 -2
- package/types.untrimmed.d.ts +35 -2
|
@@ -0,0 +1,117 @@
|
|
|
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 _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
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
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; }
|
|
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
|
+
import { createPreloadPlanFromManifest, parsePreloadManifest } from '@antintl/opensdk-preload';
|
|
12
|
+
import { ANTOM_PRELOAD_ELEMENTS, ANTOM_PRELOAD_MANIFEST } from "./config";
|
|
13
|
+
var MANIFEST_TIMEOUT_MS = 5000;
|
|
14
|
+
var MANIFEST_CACHE_SYMBOL = Symbol.for('@antom/web-sdk.preload-manifest.v2');
|
|
15
|
+
var ANTOM_PRELOAD_ELEMENT_SET = new Set(ANTOM_PRELOAD_ELEMENTS);
|
|
16
|
+
export function resolveAntomPreloadPlan(_x) {
|
|
17
|
+
return _resolveAntomPreloadPlan.apply(this, arguments);
|
|
18
|
+
}
|
|
19
|
+
function _resolveAntomPreloadPlan() {
|
|
20
|
+
_resolveAntomPreloadPlan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
21
|
+
var elements, url, manifest;
|
|
22
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
elements = _toConsumableArray(new Set(options.elements)).filter(function (element) {
|
|
26
|
+
return ANTOM_PRELOAD_ELEMENT_SET.has(element);
|
|
27
|
+
});
|
|
28
|
+
if (!(elements.length === 0)) {
|
|
29
|
+
_context.next = 3;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
throw new Error('No valid Elements2 preload element');
|
|
33
|
+
case 3:
|
|
34
|
+
url = new URL(ANTOM_PRELOAD_MANIFEST, options.manifestOrigin).href;
|
|
35
|
+
_context.next = 6;
|
|
36
|
+
return fetchAntomManifestCached(url);
|
|
37
|
+
case 6:
|
|
38
|
+
manifest = _context.sent;
|
|
39
|
+
return _context.abrupt("return", adaptAntomManifest(manifest, elements, options));
|
|
40
|
+
case 8:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
}));
|
|
46
|
+
return _resolveAntomPreloadPlan.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
export function adaptAntomManifest(manifest, elements, options) {
|
|
49
|
+
return createPreloadPlanFromManifest(manifest, {
|
|
50
|
+
product: 'antom-elements2',
|
|
51
|
+
elements: elements,
|
|
52
|
+
resourceRules: options.resourceRules,
|
|
53
|
+
requireHttps: options.requireHttps
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function fetchAntomManifestCached(url) {
|
|
57
|
+
var _globalObject$MANIFES;
|
|
58
|
+
var globalObject = globalThis;
|
|
59
|
+
(_globalObject$MANIFES = globalObject[MANIFEST_CACHE_SYMBOL]) !== null && _globalObject$MANIFES !== void 0 ? _globalObject$MANIFES : globalObject[MANIFEST_CACHE_SYMBOL] = new Map();
|
|
60
|
+
var cache = globalObject[MANIFEST_CACHE_SYMBOL];
|
|
61
|
+
var cached = cache.get(url);
|
|
62
|
+
if (cached) return cached;
|
|
63
|
+
var promise = fetchAntomManifest(url).catch(function (error) {
|
|
64
|
+
cache.delete(url);
|
|
65
|
+
throw error;
|
|
66
|
+
});
|
|
67
|
+
cache.set(url, promise);
|
|
68
|
+
return promise;
|
|
69
|
+
}
|
|
70
|
+
function fetchAntomManifest(_x2) {
|
|
71
|
+
return _fetchAntomManifest.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
function _fetchAntomManifest() {
|
|
74
|
+
_fetchAntomManifest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
|
|
75
|
+
var controller, timer, response;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
controller = new AbortController();
|
|
80
|
+
timer = setTimeout(function () {
|
|
81
|
+
return controller.abort();
|
|
82
|
+
}, MANIFEST_TIMEOUT_MS);
|
|
83
|
+
_context2.prev = 2;
|
|
84
|
+
_context2.next = 5;
|
|
85
|
+
return fetch(url, {
|
|
86
|
+
mode: 'cors',
|
|
87
|
+
credentials: 'omit',
|
|
88
|
+
cache: 'no-cache',
|
|
89
|
+
redirect: 'error',
|
|
90
|
+
signal: controller.signal
|
|
91
|
+
});
|
|
92
|
+
case 5:
|
|
93
|
+
response = _context2.sent;
|
|
94
|
+
if (!(!response.ok || response.redirected)) {
|
|
95
|
+
_context2.next = 8;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
throw new Error("Manifest request failed: ".concat(response.status));
|
|
99
|
+
case 8:
|
|
100
|
+
_context2.t0 = parsePreloadManifest;
|
|
101
|
+
_context2.next = 11;
|
|
102
|
+
return response.json();
|
|
103
|
+
case 11:
|
|
104
|
+
_context2.t1 = _context2.sent;
|
|
105
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
|
|
106
|
+
case 13:
|
|
107
|
+
_context2.prev = 13;
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
return _context2.finish(13);
|
|
110
|
+
case 16:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context2.stop();
|
|
113
|
+
}
|
|
114
|
+
}, _callee2, null, [[2,, 13, 16]]);
|
|
115
|
+
}));
|
|
116
|
+
return _fetchAntomManifest.apply(this, arguments);
|
|
117
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ResourceRule } from '@antintl/opensdk-preload/types';
|
|
2
|
+
export declare const ANTOM_PRELOAD_MANIFEST = "/elements2/manifest.json";
|
|
3
|
+
export declare const ANTOM_PRELOAD_ELEMENTS: readonly ["payment", "express", "vaulting", "CVV"];
|
|
4
|
+
export type AntomPreloadElement = typeof ANTOM_PRELOAD_ELEMENTS[number];
|
|
5
|
+
export declare function getAntomPreloadRuntimeConfig(): {
|
|
6
|
+
manifestOrigin: string;
|
|
7
|
+
runnerUrl: string;
|
|
8
|
+
resourceRules: ResourceRule[];
|
|
9
|
+
requireHttps: boolean;
|
|
10
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { stageName } from "../sdk/stageName";
|
|
2
|
+
export var ANTOM_PRELOAD_MANIFEST = '/elements2/manifest.json';
|
|
3
|
+
export var ANTOM_PRELOAD_ELEMENTS = ['payment', 'express', 'vaulting', 'CVV'];
|
|
4
|
+
export function getAntomPreloadRuntimeConfig() {
|
|
5
|
+
if (stageName !== 'PROD' && typeof window !== 'undefined') {
|
|
6
|
+
return {
|
|
7
|
+
manifestOrigin: window.location.origin,
|
|
8
|
+
runnerUrl: "".concat(window.location.origin, "/elements2/preload/index.html"),
|
|
9
|
+
requireHttps: false,
|
|
10
|
+
resourceRules: [{
|
|
11
|
+
origin: window.location.origin,
|
|
12
|
+
pathnamePrefix: '/elements2/'
|
|
13
|
+
}, {
|
|
14
|
+
origin: 'http://page.alipay.net',
|
|
15
|
+
pathnamePrefix: '/page/antom-web-checkout-v2/elements2/'
|
|
16
|
+
}, {
|
|
17
|
+
origin: 'https://marmot-local-pre.oss-accelerate.aliyuncs.com',
|
|
18
|
+
pathnamePrefix: '/page/antom-web-checkout-v2/elements2/'
|
|
19
|
+
}, {
|
|
20
|
+
origin: 'https://marmot-local-dev.oss-accelerate.aliyuncs.com',
|
|
21
|
+
pathnamePrefix: '/page/antom-web-checkout-v2-'
|
|
22
|
+
}]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
manifestOrigin: 'https://checkout.antom.com',
|
|
27
|
+
runnerUrl: 'https://checkout.antom.com/elements2/preload/index.html',
|
|
28
|
+
requireHttps: true,
|
|
29
|
+
resourceRules: [{
|
|
30
|
+
origin: 'https://checkout.antom.com',
|
|
31
|
+
pathnamePrefix: '/elements2/'
|
|
32
|
+
}, {
|
|
33
|
+
origin: 'https://cdn.marmot-cloud.com',
|
|
34
|
+
pathnamePrefix: '/page/antom-web-checkout-v2/elements2/'
|
|
35
|
+
}]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare const PRECONNECTION_REGIONS: readonly ["SG", "US", "DE"];
|
|
2
|
+
export type PreconnectionRegion = (typeof PRECONNECTION_REGIONS)[number];
|
|
3
|
+
export type GatewayPreconnectionStatus = 'running' | 'completed' | 'partial_failed' | 'failed';
|
|
4
|
+
type RegionResult = {
|
|
5
|
+
status: 'completed' | 'failed';
|
|
6
|
+
endTime: number;
|
|
7
|
+
};
|
|
8
|
+
export interface GatewayPreconnectionSnapshot {
|
|
9
|
+
mode: 'configured' | 'regional';
|
|
10
|
+
preconnectedRegions: readonly PreconnectionRegion[];
|
|
11
|
+
failedRegions: PreconnectionRegion[];
|
|
12
|
+
regionResults: Partial<Record<PreconnectionRegion, RegionResult>>;
|
|
13
|
+
gatewayUrl?: string;
|
|
14
|
+
actualRegion?: string;
|
|
15
|
+
predictionResult?: 'hit' | 'miss';
|
|
16
|
+
status: GatewayPreconnectionStatus;
|
|
17
|
+
preconnectionStartTime: number;
|
|
18
|
+
preconnectionEndTime?: number;
|
|
19
|
+
firstRpcStartTime?: number;
|
|
20
|
+
firstRpcEndTime?: number;
|
|
21
|
+
firstRpcTotalMs?: number;
|
|
22
|
+
preconnectionLeadTimeMs?: number;
|
|
23
|
+
preconnectionReadyBeforeFirstRpc?: boolean;
|
|
24
|
+
dnsDurationMs?: number;
|
|
25
|
+
tcpDurationMs?: number;
|
|
26
|
+
tlsDurationMs?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function startGatewayPreconnection(env: 'sandbox' | 'prod'): Promise<GatewayPreconnectionSnapshot>;
|
|
29
|
+
export declare function recordActualRegion(region: string, env?: 'sandbox' | 'prod'): GatewayPreconnectionSnapshot | undefined;
|
|
30
|
+
export declare function recordFirstRpcStart(env?: 'sandbox' | 'prod'): GatewayPreconnectionSnapshot | undefined;
|
|
31
|
+
export declare function recordFirstRpcEnd(env?: 'sandbox' | 'prod'): GatewayPreconnectionSnapshot | undefined;
|
|
32
|
+
export declare function getGatewayPreconnectionSnapshot(env?: 'sandbox' | 'prod'): {
|
|
33
|
+
mode: "configured" | "regional";
|
|
34
|
+
preconnectedRegions: readonly ("US" | "SG" | "DE")[];
|
|
35
|
+
failedRegions: ("US" | "SG" | "DE")[];
|
|
36
|
+
regionResults: Partial<Record<"US" | "SG" | "DE", RegionResult>>;
|
|
37
|
+
gatewayUrl?: string;
|
|
38
|
+
actualRegion?: string;
|
|
39
|
+
predictionResult?: "hit" | "miss";
|
|
40
|
+
status: GatewayPreconnectionStatus;
|
|
41
|
+
preconnectionStartTime: number;
|
|
42
|
+
preconnectionEndTime?: number;
|
|
43
|
+
firstRpcStartTime?: number;
|
|
44
|
+
firstRpcEndTime?: number;
|
|
45
|
+
firstRpcTotalMs?: number;
|
|
46
|
+
preconnectionLeadTimeMs?: number;
|
|
47
|
+
preconnectionReadyBeforeFirstRpc?: boolean;
|
|
48
|
+
dnsDurationMs?: number;
|
|
49
|
+
tcpDurationMs?: number;
|
|
50
|
+
tlsDurationMs?: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function waitForGatewayPreconnection(env?: 'sandbox' | 'prod'): Promise<GatewayPreconnectionSnapshot>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,213 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
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 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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
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); }
|
|
14
|
+
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); } }
|
|
15
|
+
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); }); }; }
|
|
16
|
+
import { preConnection } from "../sdk/oneapi/iexpfront/preConnection";
|
|
17
|
+
import { getDevReqConfig } from "../sdk/tools/getDevReqConfig";
|
|
18
|
+
var REGISTRY_SYMBOL = Symbol.for('@antom/web-sdk.gateway-preconnection.v1');
|
|
19
|
+
var PRECONNECTION_REGIONS = ['SG', 'US', 'DE'];
|
|
20
|
+
function getRegistry() {
|
|
21
|
+
var _globalObject$REGISTR;
|
|
22
|
+
var globalObject = globalThis;
|
|
23
|
+
(_globalObject$REGISTR = globalObject[REGISTRY_SYMBOL]) !== null && _globalObject$REGISTR !== void 0 ? _globalObject$REGISTR : globalObject[REGISTRY_SYMBOL] = {
|
|
24
|
+
snapshots: new Map(),
|
|
25
|
+
promises: new Map()
|
|
26
|
+
};
|
|
27
|
+
return globalObject[REGISTRY_SYMBOL];
|
|
28
|
+
}
|
|
29
|
+
export function startGatewayPreconnection(env) {
|
|
30
|
+
var registry = getRegistry();
|
|
31
|
+
var existing = registry.promises.get(env);
|
|
32
|
+
if (existing) return existing;
|
|
33
|
+
var snapshot = {
|
|
34
|
+
mode: 'regional',
|
|
35
|
+
preconnectedRegions: PRECONNECTION_REGIONS,
|
|
36
|
+
failedRegions: [],
|
|
37
|
+
regionResults: {},
|
|
38
|
+
status: 'running',
|
|
39
|
+
preconnectionStartTime: now()
|
|
40
|
+
};
|
|
41
|
+
registry.snapshots.set(env, snapshot);
|
|
42
|
+
var promise = Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
43
|
+
var devRequestConfig, gatewayUrl, results, status;
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(typeof window === 'undefined' || typeof navigator === 'undefined' || typeof screen === 'undefined')) {
|
|
48
|
+
_context.next = 2;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
throw new Error('Gateway preConnection is unavailable outside the browser');
|
|
52
|
+
case 2:
|
|
53
|
+
devRequestConfig = getDevReqConfig();
|
|
54
|
+
gatewayUrl = devRequestConfig === null || devRequestConfig === void 0 ? void 0 : devRequestConfig.baseURL;
|
|
55
|
+
if (!gatewayUrl) {
|
|
56
|
+
_context.next = 11;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
snapshot.mode = 'configured';
|
|
60
|
+
snapshot.preconnectedRegions = [];
|
|
61
|
+
snapshot.gatewayUrl = gatewayUrl;
|
|
62
|
+
_context.next = 10;
|
|
63
|
+
return preConnection({}, _objectSpread({
|
|
64
|
+
env: env,
|
|
65
|
+
timeout: 5000,
|
|
66
|
+
withCredentials: true
|
|
67
|
+
}, devRequestConfig));
|
|
68
|
+
case 10:
|
|
69
|
+
return _context.abrupt("return", finishPreconnection(env, 'completed'));
|
|
70
|
+
case 11:
|
|
71
|
+
_context.next = 13;
|
|
72
|
+
return Promise.allSettled(PRECONNECTION_REGIONS.map(function (hostSign) {
|
|
73
|
+
return warmRegion(env, hostSign, snapshot);
|
|
74
|
+
}));
|
|
75
|
+
case 13:
|
|
76
|
+
results = _context.sent;
|
|
77
|
+
snapshot.failedRegions = PRECONNECTION_REGIONS.filter(function (_, index) {
|
|
78
|
+
return results[index].status === 'rejected';
|
|
79
|
+
});
|
|
80
|
+
status = resolveRegionalStatus(snapshot.failedRegions.length);
|
|
81
|
+
return _context.abrupt("return", finishPreconnection(env, status));
|
|
82
|
+
case 17:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee);
|
|
87
|
+
}))).catch(function () {
|
|
88
|
+
return finishPreconnection(env, 'failed');
|
|
89
|
+
});
|
|
90
|
+
registry.promises.set(env, promise);
|
|
91
|
+
return promise;
|
|
92
|
+
}
|
|
93
|
+
export function recordActualRegion(region) {
|
|
94
|
+
var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'prod';
|
|
95
|
+
var snapshot = getRegistry().snapshots.get(env);
|
|
96
|
+
if (!snapshot) return undefined;
|
|
97
|
+
snapshot.actualRegion = region || undefined;
|
|
98
|
+
updatePredictionResult(snapshot);
|
|
99
|
+
updateLeadTime(snapshot);
|
|
100
|
+
return _objectSpread({}, snapshot);
|
|
101
|
+
}
|
|
102
|
+
export function recordFirstRpcStart() {
|
|
103
|
+
var _snapshot$firstRpcSta;
|
|
104
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
|
105
|
+
var snapshot = getRegistry().snapshots.get(env);
|
|
106
|
+
if (!snapshot) return undefined;
|
|
107
|
+
(_snapshot$firstRpcSta = snapshot.firstRpcStartTime) !== null && _snapshot$firstRpcSta !== void 0 ? _snapshot$firstRpcSta : snapshot.firstRpcStartTime = now();
|
|
108
|
+
updateLeadTime(snapshot);
|
|
109
|
+
return _objectSpread({}, snapshot);
|
|
110
|
+
}
|
|
111
|
+
export function recordFirstRpcEnd() {
|
|
112
|
+
var _snapshot$firstRpcEnd;
|
|
113
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
|
114
|
+
var snapshot = getRegistry().snapshots.get(env);
|
|
115
|
+
if (!snapshot || snapshot.firstRpcStartTime === undefined) return snapshot ? _objectSpread({}, snapshot) : undefined;
|
|
116
|
+
(_snapshot$firstRpcEnd = snapshot.firstRpcEndTime) !== null && _snapshot$firstRpcEnd !== void 0 ? _snapshot$firstRpcEnd : snapshot.firstRpcEndTime = now();
|
|
117
|
+
snapshot.firstRpcTotalMs = snapshot.firstRpcEndTime - snapshot.firstRpcStartTime;
|
|
118
|
+
return _objectSpread({}, snapshot);
|
|
119
|
+
}
|
|
120
|
+
export function getGatewayPreconnectionSnapshot() {
|
|
121
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
|
122
|
+
var snapshot = getRegistry().snapshots.get(env);
|
|
123
|
+
return snapshot ? _objectSpread({}, snapshot) : undefined;
|
|
124
|
+
}
|
|
125
|
+
export function waitForGatewayPreconnection() {
|
|
126
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
|
127
|
+
return getRegistry().promises.get(env);
|
|
128
|
+
}
|
|
129
|
+
function resolveRegionalStatus(failedCount) {
|
|
130
|
+
if (failedCount === 0) return 'completed';
|
|
131
|
+
if (failedCount === PRECONNECTION_REGIONS.length) return 'failed';
|
|
132
|
+
return 'partial_failed';
|
|
133
|
+
}
|
|
134
|
+
function finishPreconnection(env, status) {
|
|
135
|
+
var snapshot = getRegistry().snapshots.get(env);
|
|
136
|
+
snapshot.status = status;
|
|
137
|
+
snapshot.preconnectionEndTime = now();
|
|
138
|
+
updatePredictionResult(snapshot);
|
|
139
|
+
updateLeadTime(snapshot);
|
|
140
|
+
Object.assign(snapshot, readGatewayResourceTiming(snapshot.gatewayUrl));
|
|
141
|
+
return _objectSpread({}, snapshot);
|
|
142
|
+
}
|
|
143
|
+
function warmRegion(env, hostSign, snapshot) {
|
|
144
|
+
return preConnection({}, {
|
|
145
|
+
env: env,
|
|
146
|
+
hostSign: hostSign,
|
|
147
|
+
timeout: 5000,
|
|
148
|
+
withCredentials: true
|
|
149
|
+
}).then(function (result) {
|
|
150
|
+
snapshot.regionResults[hostSign] = {
|
|
151
|
+
status: 'completed',
|
|
152
|
+
endTime: now()
|
|
153
|
+
};
|
|
154
|
+
updatePredictionResult(snapshot);
|
|
155
|
+
updateLeadTime(snapshot);
|
|
156
|
+
return result;
|
|
157
|
+
}, function (error) {
|
|
158
|
+
snapshot.regionResults[hostSign] = {
|
|
159
|
+
status: 'failed',
|
|
160
|
+
endTime: now()
|
|
161
|
+
};
|
|
162
|
+
updatePredictionResult(snapshot);
|
|
163
|
+
updateLeadTime(snapshot);
|
|
164
|
+
throw error;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function updatePredictionResult(snapshot) {
|
|
168
|
+
if (!snapshot.actualRegion) {
|
|
169
|
+
snapshot.predictionResult = undefined;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (snapshot.mode === 'configured') {
|
|
173
|
+
snapshot.predictionResult = snapshot.status === 'running' ? undefined : snapshot.status === 'completed' ? 'hit' : 'miss';
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
var actualRegion = snapshot.actualRegion;
|
|
177
|
+
var result = snapshot.regionResults[actualRegion];
|
|
178
|
+
snapshot.predictionResult = result ? result.status === 'completed' ? 'hit' : 'miss' : undefined;
|
|
179
|
+
}
|
|
180
|
+
function updateLeadTime(snapshot) {
|
|
181
|
+
var _snapshot$regionResul, _snapshot$regionResul2;
|
|
182
|
+
if (snapshot.firstRpcStartTime === undefined) return;
|
|
183
|
+
var targetEndTime = snapshot.mode === 'configured' ? snapshot.status === 'completed' ? snapshot.preconnectionEndTime : undefined : snapshot.actualRegion ? ((_snapshot$regionResul = snapshot.regionResults[snapshot.actualRegion]) === null || _snapshot$regionResul === void 0 ? void 0 : _snapshot$regionResul.status) === 'completed' ? (_snapshot$regionResul2 = snapshot.regionResults[snapshot.actualRegion]) === null || _snapshot$regionResul2 === void 0 ? void 0 : _snapshot$regionResul2.endTime : undefined : undefined;
|
|
184
|
+
if (targetEndTime === undefined) {
|
|
185
|
+
snapshot.preconnectionLeadTimeMs = undefined;
|
|
186
|
+
snapshot.preconnectionReadyBeforeFirstRpc = false;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
snapshot.preconnectionLeadTimeMs = snapshot.firstRpcStartTime - targetEndTime;
|
|
190
|
+
snapshot.preconnectionReadyBeforeFirstRpc = snapshot.preconnectionLeadTimeMs >= 0;
|
|
191
|
+
}
|
|
192
|
+
function readGatewayResourceTiming(gatewayUrl) {
|
|
193
|
+
if (!gatewayUrl || typeof performance === 'undefined' || !performance.getEntriesByType) return {};
|
|
194
|
+
var gatewayOrigin;
|
|
195
|
+
try {
|
|
196
|
+
gatewayOrigin = new URL(gatewayUrl).origin;
|
|
197
|
+
} catch (_unused) {
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
var entries = performance.getEntriesByType('resource');
|
|
201
|
+
var timing = _toConsumableArray(entries).reverse().find(function (entry) {
|
|
202
|
+
return entry.name.startsWith(gatewayOrigin);
|
|
203
|
+
});
|
|
204
|
+
if (!timing) return {};
|
|
205
|
+
return {
|
|
206
|
+
dnsDurationMs: Math.max(0, timing.domainLookupEnd - timing.domainLookupStart),
|
|
207
|
+
tcpDurationMs: Math.max(0, timing.connectEnd - timing.connectStart),
|
|
208
|
+
tlsDurationMs: timing.secureConnectionStart > 0 ? Math.max(0, timing.connectEnd - timing.secureConnectionStart) : 0
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function now() {
|
|
212
|
+
return Date.now();
|
|
213
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AntomPreloadElement } from './config';
|
|
2
|
+
export declare function preloadAntomElements(elements: readonly AntomPreloadElement[]): Promise<void>;
|
|
3
|
+
export declare function getAntomPreloadTelemetry(element: AntomPreloadElement): {
|
|
4
|
+
requested: boolean;
|
|
5
|
+
phaseAtElementCreate: "running" | "failed" | "resolving" | "critical_completed" | "skipped" | "not_requested";
|
|
6
|
+
leadTimeMs: number;
|
|
7
|
+
criticalDurationMs: number;
|
|
8
|
+
taskId: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
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 _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
|
+
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
|
+
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
|
+
import { getOrCreatePreloadController } from '@antintl/opensdk-preload';
|
|
6
|
+
import { getAntomPreloadRuntimeConfig } from "./config";
|
|
7
|
+
import { resolveAntomPreloadPlan } from "./antomManifestAdapter";
|
|
8
|
+
var STATE_SYMBOL = Symbol.for('@antom/web-sdk.elements2-preload.v1');
|
|
9
|
+
function getState() {
|
|
10
|
+
var _globalObject$STATE_S;
|
|
11
|
+
var globalObject = globalThis;
|
|
12
|
+
(_globalObject$STATE_S = globalObject[STATE_SYMBOL]) !== null && _globalObject$STATE_S !== void 0 ? _globalObject$STATE_S : globalObject[STATE_SYMBOL] = {
|
|
13
|
+
elements: new Set()
|
|
14
|
+
};
|
|
15
|
+
return globalObject[STATE_SYMBOL];
|
|
16
|
+
}
|
|
17
|
+
export function preloadAntomElements(_x) {
|
|
18
|
+
return _preloadAntomElements.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
function _preloadAntomElements() {
|
|
21
|
+
_preloadAntomElements = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(elements) {
|
|
22
|
+
var _state$requestedAt;
|
|
23
|
+
var state, config, plan, controller;
|
|
24
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
if (!(typeof window === 'undefined' || typeof document === 'undefined' || elements.length === 0)) {
|
|
28
|
+
_context.next = 2;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return _context.abrupt("return");
|
|
32
|
+
case 2:
|
|
33
|
+
state = getState();
|
|
34
|
+
(_state$requestedAt = state.requestedAt) !== null && _state$requestedAt !== void 0 ? _state$requestedAt : state.requestedAt = Date.now();
|
|
35
|
+
elements.forEach(function (element) {
|
|
36
|
+
return state.elements.add(element);
|
|
37
|
+
});
|
|
38
|
+
state.phase = 'resolving';
|
|
39
|
+
config = getAntomPreloadRuntimeConfig();
|
|
40
|
+
_context.prev = 7;
|
|
41
|
+
_context.next = 10;
|
|
42
|
+
return resolveAntomPreloadPlan({
|
|
43
|
+
elements: elements,
|
|
44
|
+
manifestOrigin: config.manifestOrigin,
|
|
45
|
+
resourceRules: config.resourceRules,
|
|
46
|
+
requireHttps: config.requireHttps
|
|
47
|
+
});
|
|
48
|
+
case 10:
|
|
49
|
+
plan = _context.sent;
|
|
50
|
+
controller = getOrCreatePreloadController({
|
|
51
|
+
product: 'antom-elements2',
|
|
52
|
+
runnerUrl: config.runnerUrl,
|
|
53
|
+
protocolVersion: 1,
|
|
54
|
+
onStateChange: function onStateChange(snapshot) {
|
|
55
|
+
state.snapshot = snapshot;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
_context.next = 14;
|
|
59
|
+
return controller.run(plan);
|
|
60
|
+
case 14:
|
|
61
|
+
state.snapshot = _context.sent;
|
|
62
|
+
_context.next = 21;
|
|
63
|
+
break;
|
|
64
|
+
case 17:
|
|
65
|
+
_context.prev = 17;
|
|
66
|
+
_context.t0 = _context["catch"](7);
|
|
67
|
+
state.phase = 'failed';
|
|
68
|
+
throw _context.t0;
|
|
69
|
+
case 21:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}, _callee, null, [[7, 17]]);
|
|
74
|
+
}));
|
|
75
|
+
return _preloadAntomElements.apply(this, arguments);
|
|
76
|
+
}
|
|
77
|
+
export function getAntomPreloadTelemetry(element) {
|
|
78
|
+
var _snapshot$state, _snapshot$critical;
|
|
79
|
+
var state = getState();
|
|
80
|
+
var snapshot = state.snapshot;
|
|
81
|
+
return {
|
|
82
|
+
requested: state.elements.has(element),
|
|
83
|
+
phaseAtElementCreate: mapPhase((_snapshot$state = snapshot === null || snapshot === void 0 ? void 0 : snapshot.state) !== null && _snapshot$state !== void 0 ? _snapshot$state : state.phase),
|
|
84
|
+
leadTimeMs: state.requestedAt ? Date.now() - state.requestedAt : undefined,
|
|
85
|
+
criticalDurationMs: snapshot === null || snapshot === void 0 || (_snapshot$critical = snapshot.critical) === null || _snapshot$critical === void 0 ? void 0 : _snapshot$critical.duration,
|
|
86
|
+
taskId: snapshot === null || snapshot === void 0 ? void 0 : snapshot.taskId
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function mapPhase(state) {
|
|
90
|
+
if (!state) return 'not_requested';
|
|
91
|
+
if (state === 'requested' || state === 'resolving' || state === 'waiting_runner') return 'resolving';
|
|
92
|
+
if (state === 'running_critical' || state === 'running_deferred') return 'running';
|
|
93
|
+
if (state === 'critical_completed' || state === 'completed') return 'critical_completed';
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { startGatewayPreconnection } from "./gatewayPreconnection";
|
|
2
|
+
import { preloadAntomElements } from "./preloadAntomElements";
|
|
3
|
+
export function startAntomPreload(env, elements) {
|
|
4
|
+
if (!(elements !== null && elements !== void 0 && elements.length)) return;
|
|
5
|
+
void startGatewayPreconnection(env);
|
|
6
|
+
void preloadAntomElements(elements).catch(function () {
|
|
7
|
+
return undefined;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestConfig } from '../types';
|
|
2
|
+
import type { Logger } from '../util/logger';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param requestData 请求参数
|
|
6
|
+
* @param options 请求配置
|
|
7
|
+
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
|
8
|
+
*/
|
|
9
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig, logger: Logger): Promise<T>;
|