@cimplify/sdk 0.7.12 → 0.7.14

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/advanced.js CHANGED
@@ -2671,6 +2671,8 @@ var CimplifyElement = class {
2671
2671
  sendMessage(message) {
2672
2672
  if (this.iframe?.contentWindow) {
2673
2673
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
2674
+ } else {
2675
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
2674
2676
  }
2675
2677
  }
2676
2678
  getContentWindow() {
package/dist/advanced.mjs CHANGED
@@ -2669,6 +2669,8 @@ var CimplifyElement = class {
2669
2669
  sendMessage(message) {
2670
2670
  if (this.iframe?.contentWindow) {
2671
2671
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
2672
+ } else {
2673
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
2672
2674
  }
2673
2675
  }
2674
2676
  getContentWindow() {
package/dist/index.js CHANGED
@@ -3119,6 +3119,8 @@ var CimplifyElement = class {
3119
3119
  sendMessage(message) {
3120
3120
  if (this.iframe?.contentWindow) {
3121
3121
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
3122
+ } else {
3123
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
3122
3124
  }
3123
3125
  }
3124
3126
  getContentWindow() {
package/dist/index.mjs CHANGED
@@ -3117,6 +3117,8 @@ var CimplifyElement = class {
3117
3117
  sendMessage(message) {
3118
3118
  if (this.iframe?.contentWindow) {
3119
3119
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
3120
+ } else {
3121
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
3120
3122
  }
3121
3123
  }
3122
3124
  getContentWindow() {
package/dist/react.js CHANGED
@@ -422,6 +422,12 @@ function CimplifyCheckout({
422
422
  const hasWarnedInlineAppearanceRef = react.useRef(false);
423
423
  const isMountedRef = react.useRef(true);
424
424
  const demoRunRef = react.useRef(0);
425
+ const onCompleteRef = react.useRef(onComplete);
426
+ const onErrorRef = react.useRef(onError);
427
+ const onStatusChangeRef = react.useRef(onStatusChange);
428
+ onCompleteRef.current = onComplete;
429
+ onErrorRef.current = onError;
430
+ onStatusChangeRef.current = onStatusChange;
425
431
  const isDemoCheckout = demoMode ?? client.getPublicKey().trim().length === 0;
426
432
  const isTestMode = client.isTestMode();
427
433
  const primaryColor = appearance?.variables?.primaryColor || "#0a2540";
@@ -430,9 +436,9 @@ function CimplifyCheckout({
430
436
  (nextStatus, context = {}) => {
431
437
  setStatus(nextStatus);
432
438
  setStatusText(context.display_text || "");
433
- onStatusChange?.(nextStatus, context);
439
+ onStatusChangeRef.current?.(nextStatus, context);
434
440
  },
435
- [onStatusChange]
441
+ []
436
442
  );
437
443
  react.useEffect(() => {
438
444
  if (!resolvedOrderTypes.includes(orderType)) {
@@ -485,7 +491,7 @@ function CimplifyCheckout({
485
491
  setResolvedCartId(null);
486
492
  setErrorMessage(message);
487
493
  setIsInitializing(false);
488
- onError?.({ code: "BUSINESS_ID_REQUIRED", message });
494
+ onErrorRef.current?.({ code: "BUSINESS_ID_REQUIRED", message });
489
495
  }
490
496
  return;
491
497
  }
@@ -500,7 +506,7 @@ function CimplifyCheckout({
500
506
  setResolvedCartId(null);
501
507
  setErrorMessage(message);
502
508
  setIsInitializing(false);
503
- onError?.({ code: "CART_EMPTY", message });
509
+ onErrorRef.current?.({ code: "CART_EMPTY", message });
504
510
  }
505
511
  return;
506
512
  }
@@ -517,7 +523,7 @@ function CimplifyCheckout({
517
523
  return () => {
518
524
  cancelled = true;
519
525
  };
520
- }, [businessId, cartId, client, isDemoCheckout, onError]);
526
+ }, [businessId, cartId, client, isDemoCheckout]);
521
527
  react.useEffect(() => {
522
528
  return () => {
523
529
  isMountedRef.current = false;
@@ -556,7 +562,7 @@ function CimplifyCheckout({
556
562
  if (!resolvedCartId && !isInitializing) {
557
563
  const message = "Your cart is empty. Add items before checkout.";
558
564
  setErrorMessage(message);
559
- onError?.({ code: "CART_EMPTY", message });
565
+ onErrorRef.current?.({ code: "CART_EMPTY", message });
560
566
  }
561
567
  return;
562
568
  }
@@ -591,7 +597,7 @@ function CimplifyCheckout({
591
597
  order_number: result.order?.order_number,
592
598
  display_text: statusToLabel("success")
593
599
  });
594
- onComplete(result);
600
+ onCompleteRef.current(result);
595
601
  } finally {
596
602
  if (isMountedRef.current && runId === demoRunRef.current) {
597
603
  setIsSubmitting(false);
@@ -602,7 +608,7 @@ function CimplifyCheckout({
602
608
  if (!elementsRef.current) {
603
609
  const message = "Checkout is still initializing. Please try again.";
604
610
  setErrorMessage(message);
605
- onError?.({ code: "CHECKOUT_NOT_READY", message });
611
+ onErrorRef.current?.({ code: "CHECKOUT_NOT_READY", message });
606
612
  setIsSubmitting(false);
607
613
  return;
608
614
  }
@@ -617,13 +623,13 @@ function CimplifyCheckout({
617
623
  try {
618
624
  const result = await checkout;
619
625
  if (result.success) {
620
- onComplete(result);
626
+ onCompleteRef.current(result);
621
627
  return;
622
628
  }
623
629
  const code = result.error?.code || "CHECKOUT_FAILED";
624
630
  const message = result.error?.message || "Payment failed.";
625
631
  setErrorMessage(message);
626
- onError?.({ code, message });
632
+ onErrorRef.current?.({ code, message });
627
633
  } finally {
628
634
  if (isMountedRef.current) {
629
635
  activeCheckoutRef.current = null;
@@ -639,8 +645,6 @@ function CimplifyCheckout({
639
645
  isInitializing,
640
646
  isSubmitting,
641
647
  locationId,
642
- onComplete,
643
- onError,
644
648
  orderType
645
649
  ]);
646
650
  const colors = shellColors(isDark ?? false, primaryColor);
@@ -3391,6 +3395,8 @@ var CimplifyElement = class {
3391
3395
  sendMessage(message) {
3392
3396
  if (this.iframe?.contentWindow) {
3393
3397
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
3398
+ } else {
3399
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
3394
3400
  }
3395
3401
  }
3396
3402
  getContentWindow() {
package/dist/react.mjs CHANGED
@@ -420,6 +420,12 @@ function CimplifyCheckout({
420
420
  const hasWarnedInlineAppearanceRef = useRef(false);
421
421
  const isMountedRef = useRef(true);
422
422
  const demoRunRef = useRef(0);
423
+ const onCompleteRef = useRef(onComplete);
424
+ const onErrorRef = useRef(onError);
425
+ const onStatusChangeRef = useRef(onStatusChange);
426
+ onCompleteRef.current = onComplete;
427
+ onErrorRef.current = onError;
428
+ onStatusChangeRef.current = onStatusChange;
423
429
  const isDemoCheckout = demoMode ?? client.getPublicKey().trim().length === 0;
424
430
  const isTestMode = client.isTestMode();
425
431
  const primaryColor = appearance?.variables?.primaryColor || "#0a2540";
@@ -428,9 +434,9 @@ function CimplifyCheckout({
428
434
  (nextStatus, context = {}) => {
429
435
  setStatus(nextStatus);
430
436
  setStatusText(context.display_text || "");
431
- onStatusChange?.(nextStatus, context);
437
+ onStatusChangeRef.current?.(nextStatus, context);
432
438
  },
433
- [onStatusChange]
439
+ []
434
440
  );
435
441
  useEffect(() => {
436
442
  if (!resolvedOrderTypes.includes(orderType)) {
@@ -483,7 +489,7 @@ function CimplifyCheckout({
483
489
  setResolvedCartId(null);
484
490
  setErrorMessage(message);
485
491
  setIsInitializing(false);
486
- onError?.({ code: "BUSINESS_ID_REQUIRED", message });
492
+ onErrorRef.current?.({ code: "BUSINESS_ID_REQUIRED", message });
487
493
  }
488
494
  return;
489
495
  }
@@ -498,7 +504,7 @@ function CimplifyCheckout({
498
504
  setResolvedCartId(null);
499
505
  setErrorMessage(message);
500
506
  setIsInitializing(false);
501
- onError?.({ code: "CART_EMPTY", message });
507
+ onErrorRef.current?.({ code: "CART_EMPTY", message });
502
508
  }
503
509
  return;
504
510
  }
@@ -515,7 +521,7 @@ function CimplifyCheckout({
515
521
  return () => {
516
522
  cancelled = true;
517
523
  };
518
- }, [businessId, cartId, client, isDemoCheckout, onError]);
524
+ }, [businessId, cartId, client, isDemoCheckout]);
519
525
  useEffect(() => {
520
526
  return () => {
521
527
  isMountedRef.current = false;
@@ -554,7 +560,7 @@ function CimplifyCheckout({
554
560
  if (!resolvedCartId && !isInitializing) {
555
561
  const message = "Your cart is empty. Add items before checkout.";
556
562
  setErrorMessage(message);
557
- onError?.({ code: "CART_EMPTY", message });
563
+ onErrorRef.current?.({ code: "CART_EMPTY", message });
558
564
  }
559
565
  return;
560
566
  }
@@ -589,7 +595,7 @@ function CimplifyCheckout({
589
595
  order_number: result.order?.order_number,
590
596
  display_text: statusToLabel("success")
591
597
  });
592
- onComplete(result);
598
+ onCompleteRef.current(result);
593
599
  } finally {
594
600
  if (isMountedRef.current && runId === demoRunRef.current) {
595
601
  setIsSubmitting(false);
@@ -600,7 +606,7 @@ function CimplifyCheckout({
600
606
  if (!elementsRef.current) {
601
607
  const message = "Checkout is still initializing. Please try again.";
602
608
  setErrorMessage(message);
603
- onError?.({ code: "CHECKOUT_NOT_READY", message });
609
+ onErrorRef.current?.({ code: "CHECKOUT_NOT_READY", message });
604
610
  setIsSubmitting(false);
605
611
  return;
606
612
  }
@@ -615,13 +621,13 @@ function CimplifyCheckout({
615
621
  try {
616
622
  const result = await checkout;
617
623
  if (result.success) {
618
- onComplete(result);
624
+ onCompleteRef.current(result);
619
625
  return;
620
626
  }
621
627
  const code = result.error?.code || "CHECKOUT_FAILED";
622
628
  const message = result.error?.message || "Payment failed.";
623
629
  setErrorMessage(message);
624
- onError?.({ code, message });
630
+ onErrorRef.current?.({ code, message });
625
631
  } finally {
626
632
  if (isMountedRef.current) {
627
633
  activeCheckoutRef.current = null;
@@ -637,8 +643,6 @@ function CimplifyCheckout({
637
643
  isInitializing,
638
644
  isSubmitting,
639
645
  locationId,
640
- onComplete,
641
- onError,
642
646
  orderType
643
647
  ]);
644
648
  const colors = shellColors(isDark ?? false, primaryColor);
@@ -3389,6 +3393,8 @@ var CimplifyElement = class {
3389
3393
  sendMessage(message) {
3390
3394
  if (this.iframe?.contentWindow) {
3391
3395
  this.iframe.contentWindow.postMessage(message, this.linkUrl);
3396
+ } else {
3397
+ console.warn("[cimplify:checkout] sendMessage DROPPED \u2014 no contentWindow", { type: message.type, hasIframe: !!this.iframe, isConnected: this.iframe?.isConnected });
3392
3398
  }
3393
3399
  }
3394
3400
  getContentWindow() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",