@betterstore/react 0.3.67 → 0.3.68

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.68
4
+
5
+ ### Patch Changes
6
+
7
+ - bug fix
8
+
3
9
  ## 0.3.67
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -521,6 +521,7 @@ var css_248z = "/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com *
521
521
  const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
522
522
  const [iframeBody, setIframeBody] = React.useState(null);
523
523
  const styleRef = React.useRef(null);
524
+ const motionRef = React.useRef(null);
524
525
  const resizeObserver = React.useRef();
525
526
  const injectStyles = React.useCallback((doc) => {
526
527
  var _a;
@@ -528,16 +529,25 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
528
529
  if ((_a = styleRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
529
530
  styleRef.current.parentNode.removeChild(styleRef.current);
530
531
  }
531
- // Inject global CSS
532
532
  const styleEl = doc.createElement("style");
533
533
  styleEl.textContent = css_248z;
534
534
  doc.head.appendChild(styleEl);
535
535
  styleRef.current = styleEl;
536
- // Clone Framer Motion styles into iframe
537
- Array.from(document.querySelectorAll("style[data-motion]")).forEach((styleTag) => {
538
- const clone = styleTag.cloneNode(true);
539
- doc.head.appendChild(clone);
540
- });
536
+ }, []);
537
+ const injectMotion = React.useCallback((doc) => {
538
+ var _a;
539
+ // Clean up previous style
540
+ if ((_a = motionRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
541
+ motionRef.current.parentNode.removeChild(motionRef.current);
542
+ }
543
+ const script = doc.createElement("script");
544
+ script.type = "module";
545
+ script.textContent = `
546
+ import { motion } from 'https://esm.sh/motion';
547
+ window.Motion = motion;
548
+ `;
549
+ doc.head.appendChild(script);
550
+ motionRef.current = script;
541
551
  }, []);
542
552
  const updateHeight = React.useCallback(() => {
543
553
  const iframe = iframeRef.current;
@@ -552,10 +562,11 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
552
562
  if (!iframe)
553
563
  return;
554
564
  const doc = iframe.contentDocument;
565
+ injectMotion(doc);
555
566
  injectStyles(doc);
556
567
  setIframeBody(doc.body);
557
568
  updateHeight();
558
- // Observe body size changes
569
+ // Observe body mutations & size
559
570
  if ("ResizeObserver" in window) {
560
571
  resizeObserver.current = new ResizeObserver(updateHeight);
561
572
  resizeObserver.current.observe(doc.body);
@@ -566,7 +577,9 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
566
577
  const iframe = iframeRef.current;
567
578
  if (!iframe)
568
579
  return;
580
+ // Attach onLoad
569
581
  iframe.addEventListener("load", handleLoad);
582
+ // If already loaded
570
583
  if (((_a = iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.readyState) === "complete") {
571
584
  handleLoad();
572
585
  }
@@ -579,6 +592,7 @@ const IframeWrapper = React.memo(({ children, iframeRef, wrapperRef }) => {
579
592
  }
580
593
  };
581
594
  }, [iframeRef, handleLoad]);
595
+ // Update on window resize
582
596
  React.useEffect(() => {
583
597
  window.addEventListener("resize", updateHeight);
584
598
  return () => {
package/dist/index.mjs CHANGED
@@ -498,6 +498,7 @@ var css_248z = "/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com *
498
498
  const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef }) => {
499
499
  const [iframeBody, setIframeBody] = useState(null);
500
500
  const styleRef = useRef(null);
501
+ const motionRef = useRef(null);
501
502
  const resizeObserver = useRef();
502
503
  const injectStyles = useCallback((doc) => {
503
504
  var _a;
@@ -505,16 +506,25 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
505
506
  if ((_a = styleRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
506
507
  styleRef.current.parentNode.removeChild(styleRef.current);
507
508
  }
508
- // Inject global CSS
509
509
  const styleEl = doc.createElement("style");
510
510
  styleEl.textContent = css_248z;
511
511
  doc.head.appendChild(styleEl);
512
512
  styleRef.current = styleEl;
513
- // Clone Framer Motion styles into iframe
514
- Array.from(document.querySelectorAll("style[data-motion]")).forEach((styleTag) => {
515
- const clone = styleTag.cloneNode(true);
516
- doc.head.appendChild(clone);
517
- });
513
+ }, []);
514
+ const injectMotion = useCallback((doc) => {
515
+ var _a;
516
+ // Clean up previous style
517
+ if ((_a = motionRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) {
518
+ motionRef.current.parentNode.removeChild(motionRef.current);
519
+ }
520
+ const script = doc.createElement("script");
521
+ script.type = "module";
522
+ script.textContent = `
523
+ import { motion } from 'https://esm.sh/motion';
524
+ window.Motion = motion;
525
+ `;
526
+ doc.head.appendChild(script);
527
+ motionRef.current = script;
518
528
  }, []);
519
529
  const updateHeight = useCallback(() => {
520
530
  const iframe = iframeRef.current;
@@ -529,10 +539,11 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
529
539
  if (!iframe)
530
540
  return;
531
541
  const doc = iframe.contentDocument;
542
+ injectMotion(doc);
532
543
  injectStyles(doc);
533
544
  setIframeBody(doc.body);
534
545
  updateHeight();
535
- // Observe body size changes
546
+ // Observe body mutations & size
536
547
  if ("ResizeObserver" in window) {
537
548
  resizeObserver.current = new ResizeObserver(updateHeight);
538
549
  resizeObserver.current.observe(doc.body);
@@ -543,7 +554,9 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
543
554
  const iframe = iframeRef.current;
544
555
  if (!iframe)
545
556
  return;
557
+ // Attach onLoad
546
558
  iframe.addEventListener("load", handleLoad);
559
+ // If already loaded
547
560
  if (((_a = iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.readyState) === "complete") {
548
561
  handleLoad();
549
562
  }
@@ -556,6 +569,7 @@ const IframeWrapper = React__default.memo(({ children, iframeRef, wrapperRef })
556
569
  }
557
570
  };
558
571
  }, [iframeRef, handleLoad]);
572
+ // Update on window resize
559
573
  useEffect(() => {
560
574
  window.addEventListener("resize", updateHeight);
561
575
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/react",
3
- "version": "0.3.67",
3
+ "version": "0.3.68",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {