@paynext/sdk 0.0.92 → 0.0.93

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/dist/index.es.js CHANGED
@@ -4581,25 +4581,44 @@ class vl {
4581
4581
  logPerformanceMetrics() {
4582
4582
  if (this.performanceMetrics.size === 0) return;
4583
4583
  const t = [];
4584
- let e = 0, r = 0;
4585
- this.performanceMetrics.forEach((a, i) => {
4584
+ let e = 0, r = 0, a = 0, i = 0;
4585
+ this.performanceMetrics.forEach((o, c) => {
4586
+ if (c === "__parallel_total__") {
4587
+ i = o.duration;
4588
+ return;
4589
+ }
4586
4590
  t.push({
4587
- "Payment Method": i,
4588
- Status: a.status,
4589
- "Duration (ms)": a.duration.toFixed(2)
4590
- }), e += a.duration, a.status.includes("✓") && r++;
4591
+ "Payment Method": c,
4592
+ Status: o.status,
4593
+ "Duration (ms)": o.duration.toFixed(2)
4594
+ }), e += o.duration, a = Math.max(a, o.duration), o.status.includes("✓") && r++;
4591
4595
  }), console.groupCollapsed(
4592
4596
  `%c🚀 Payment Buttons Performance (${r} rendered)`,
4593
4597
  "font-weight: bold; font-size: 14px; color: #4CAF50;"
4594
4598
  ), console.info(
4595
- `%cTotal initialization time: ${e.toFixed(2)}ms`,
4599
+ `%c⚡ Actual parallel execution time: ${i.toFixed(2)}ms`,
4600
+ "font-weight: bold; color: #4CAF50; font-size: 12px;"
4601
+ ), console.info(
4602
+ `%c📊 Sum of individual durations: ${e.toFixed(2)}ms`,
4603
+ "font-weight: bold; color: #FF9800;"
4604
+ ), console.info(
4605
+ `%c🎯 Longest button init: ${a.toFixed(2)}ms`,
4596
4606
  "font-weight: bold; color: #2196F3;"
4607
+ );
4608
+ const s = i > 0 ? (a / i * 100).toFixed(1) : 0;
4609
+ console.info(
4610
+ `%c${i <= a * 1.1 ? "✅" : "⚠️"} Parallelization efficiency: ${s}% ${i <= a * 1.1 ? "(Good!)" : "(Needs optimization)"}`,
4611
+ `font-weight: bold; color: ${i <= a * 1.1 ? "#4CAF50" : "#F44336"};`
4597
4612
  ), console.table(t), console.info(
4598
4613
  `%c📊 Legend:
4599
4614
  ✓ Rendered - Button successfully initialized and rendered
4600
4615
  ✗ Not supported - Button not supported on this device/browser
4601
4616
  ✗ Error - Initialization error occurred
4602
- Skipped - Button not configured`,
4617
+ Skipped - Button not configured
4618
+
4619
+ 💡 Note:
4620
+ If "Actual parallel execution time" ≈ "Longest button init" → buttons load in parallel ✅
4621
+ If "Actual parallel execution time" ≈ "Sum of durations" → buttons load sequentially ⚠️`,
4603
4622
  "color: #666;"
4604
4623
  ), console.groupEnd();
4605
4624
  }
@@ -4890,7 +4909,7 @@ class vl {
4890
4909
  });
4891
4910
  }
4892
4911
  // wait for element visible
4893
- waitForElementVisible(t, e = 350) {
4912
+ waitForElementVisible(t, e = 150) {
4894
4913
  return !t || !(t instanceof HTMLElement) ? Promise.resolve() : new Promise((r) => {
4895
4914
  const a = performance.now(), i = () => {
4896
4915
  const s = t.getBoundingClientRect();
@@ -4903,38 +4922,45 @@ class vl {
4903
4922
  // init payment methods
4904
4923
  initPaymentMethods() {
4905
4924
  return W(this, null, function* () {
4906
- const t = this.config.state.transaction.getState(), e = ll(Jc, (t == null ? void 0 : t.checkout_config) || [], (l, d) => l.type === d.type), r = this.config.state.checkout.getState();
4907
- let a = e.filter(({ is_active: l }) => l);
4908
- (r == null ? void 0 : r.variant) === "default" && (a = a.filter(({ type: l }) => l !== q.CARD)), this.initializeButtonInstances(a), this.buttons.innerHTML = "";
4909
- const i = a.sort((l, d) => l.order - d.order), s = /* @__PURE__ */ new Map();
4910
- for (const { type: l } of i) {
4911
- const d = document.createElement("div");
4912
- this.buttons.appendChild(d), s.set(l, d);
4913
- }
4914
- const o = i.map(({ type: l }) => {
4915
- const d = s.get(l);
4916
- switch (l) {
4925
+ const t = this.config.state.transaction.getState(), e = ll(Jc, (t == null ? void 0 : t.checkout_config) || [], (h, p) => h.type === p.type), r = this.config.state.checkout.getState();
4926
+ let a = e.filter(({ is_active: h }) => h);
4927
+ (r == null ? void 0 : r.variant) === "default" && (a = a.filter(({ type: h }) => h !== q.CARD)), this.initializeButtonInstances(a), this.buttons.innerHTML = "";
4928
+ const i = a.sort((h, p) => h.order - p.order), s = /* @__PURE__ */ new Map();
4929
+ for (const { type: h } of i) {
4930
+ const p = document.createElement("div");
4931
+ this.buttons.appendChild(p), s.set(h, p);
4932
+ }
4933
+ const o = performance.now(), c = i.map(({ type: h }) => {
4934
+ const p = s.get(h);
4935
+ switch (h) {
4917
4936
  case q.APPLE_PAY:
4918
- return this.initApple(d);
4937
+ return this.initApple(p);
4919
4938
  case q.GOOGLE_PAY:
4920
- return this.initGoogle(d);
4939
+ return this.initGoogle(p);
4921
4940
  case q.PAYPAL:
4922
- return this.initPayPal(d);
4941
+ return this.initPayPal(p);
4923
4942
  case q.VENMO:
4924
- return this.initBraintreeVenmo(d);
4943
+ return this.initBraintreeVenmo(p);
4925
4944
  case q.CARD:
4926
- return this.initCard(d);
4945
+ return this.initCard(p);
4927
4946
  default:
4928
4947
  throw new Error("Unknown button type");
4929
4948
  }
4930
4949
  });
4931
- yield Promise.all(o);
4932
- const c = [];
4933
- for (const l of s.values()) {
4934
- const d = l.firstElementChild;
4935
- d && c.push(this.waitForElementVisible(d));
4950
+ yield Promise.all(c);
4951
+ const l = performance.now(), d = l - o;
4952
+ this.performanceMetrics.set("__parallel_total__", {
4953
+ start: o,
4954
+ end: l,
4955
+ duration: d,
4956
+ status: "Parallel execution"
4957
+ });
4958
+ const u = [];
4959
+ for (const h of s.values()) {
4960
+ const p = h.firstElementChild;
4961
+ p && u.push(this.waitForElementVisible(p));
4936
4962
  }
4937
- yield Promise.all(c), this.handleReady();
4963
+ yield Promise.all(u), this.handleReady();
4938
4964
  });
4939
4965
  }
4940
4966
  // initialize button instances only for active payment methods