remote-components 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/html/host.cjs +93 -5
  2. package/dist/html/host.cjs.map +1 -1
  3. package/dist/html/host.js +93 -5
  4. package/dist/html/host.js.map +1 -1
  5. package/dist/internal/next/host/app-router-client.cjs +4 -4
  6. package/dist/internal/next/host/app-router-client.cjs.map +1 -1
  7. package/dist/internal/next/host/app-router-client.js +5 -5
  8. package/dist/internal/next/host/app-router-client.js.map +1 -1
  9. package/dist/internal/shared/client/apply-origin.cjs +21 -1
  10. package/dist/internal/shared/client/apply-origin.cjs.map +1 -1
  11. package/dist/internal/shared/client/apply-origin.js +21 -1
  12. package/dist/internal/shared/client/apply-origin.js.map +1 -1
  13. package/dist/internal/shared/client/polyfill.cjs +69 -3
  14. package/dist/internal/shared/client/polyfill.cjs.map +1 -1
  15. package/dist/internal/shared/client/polyfill.js +69 -3
  16. package/dist/internal/shared/client/polyfill.js.map +1 -1
  17. package/dist/internal/shared/client/remote-component.cjs.map +1 -1
  18. package/dist/internal/shared/client/remote-component.js.map +1 -1
  19. package/dist/internal/shared/ssr/dom-flight.cjs +20 -0
  20. package/dist/internal/shared/ssr/dom-flight.cjs.map +1 -1
  21. package/dist/internal/shared/ssr/dom-flight.js +20 -0
  22. package/dist/internal/shared/ssr/dom-flight.js.map +1 -1
  23. package/dist/internal/shared/ssr/fetch-headers.cjs +3 -1
  24. package/dist/internal/shared/ssr/fetch-headers.cjs.map +1 -1
  25. package/dist/internal/shared/ssr/fetch-headers.d.ts +1 -6
  26. package/dist/internal/shared/ssr/fetch-headers.js +3 -1
  27. package/dist/internal/shared/ssr/fetch-headers.js.map +1 -1
  28. package/dist/internal/shared/utils.cjs +9 -0
  29. package/dist/internal/shared/utils.cjs.map +1 -1
  30. package/dist/internal/shared/utils.d.ts +2 -1
  31. package/dist/internal/shared/utils.js +8 -0
  32. package/dist/internal/shared/utils.js.map +1 -1
  33. package/dist/next/middleware.cjs +15 -22
  34. package/dist/next/middleware.cjs.map +1 -1
  35. package/dist/next/middleware.js +15 -22
  36. package/dist/next/middleware.js.map +1 -1
  37. package/dist/react/index.cjs +7 -5
  38. package/dist/react/index.cjs.map +1 -1
  39. package/dist/react/index.js +7 -5
  40. package/dist/react/index.js.map +1 -1
  41. package/package.json +1 -1
package/dist/html/host.js CHANGED
@@ -599,16 +599,70 @@ function sharedPolyfills(shared) {
599
599
  }
600
600
  };
601
601
  },
602
+ usePathname() {
603
+ return location.pathname;
604
+ },
605
+ useParams() {
606
+ return {};
607
+ },
602
608
  useSearchParams() {
603
609
  return new URLSearchParams(location.search);
604
610
  },
611
+ useSelectedLayoutSegment() {
612
+ return null;
613
+ },
614
+ useSelectedLayoutSegments() {
615
+ return [];
616
+ },
605
617
  __esModule: true
606
618
  })),
607
619
  "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
608
620
  default: ({
621
+ scroll: _,
622
+ replace,
623
+ prefetch,
624
+ onNavigate,
609
625
  children,
610
626
  ...props
611
- }) => /* @__PURE__ */ jsx("a", { ...props, href: props.href, suppressHydrationWarning: true, children: children ?? null }),
627
+ }) => {
628
+ if (prefetch) {
629
+ console.warn(
630
+ "Next.js Link prefetch is not supported in remote components"
631
+ );
632
+ }
633
+ return /* @__PURE__ */ jsx(
634
+ "a",
635
+ {
636
+ ...props,
637
+ href: props.href,
638
+ onClick: (e) => {
639
+ e.preventDefault();
640
+ let preventDefaulted = false;
641
+ e.preventDefault = () => {
642
+ preventDefaulted = true;
643
+ e.defaultPrevented = true;
644
+ };
645
+ if (typeof props.onClick === "function") {
646
+ props.onClick(e);
647
+ }
648
+ onNavigate?.(e);
649
+ if (preventDefaulted) {
650
+ return;
651
+ }
652
+ if (replace) {
653
+ history.replaceState({}, "", props.href);
654
+ } else {
655
+ history.pushState({}, "", props.href);
656
+ }
657
+ },
658
+ suppressHydrationWarning: true,
659
+ children: children ?? null
660
+ }
661
+ );
662
+ },
663
+ useLinkStatus() {
664
+ return { pending: false };
665
+ },
612
666
  __esModule: true
613
667
  })),
614
668
  "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
@@ -675,10 +729,22 @@ var imageImpl;
675
729
  var init_polyfill = __esm({
676
730
  "src/shared/client/polyfill.tsx"() {
677
731
  "use strict";
678
- imageImpl = (bundle) => function RemoteImage({ priority: _, ...props }) {
732
+ imageImpl = (bundle) => function RemoteImage({
733
+ fill: _fill,
734
+ loader: _loader,
735
+ quality: _quality,
736
+ priority: _priority,
737
+ loading: _loading,
738
+ placeholder: _placeholder,
739
+ blurDataURL: _blurDataURL,
740
+ unoptimized: _unoptimized,
741
+ overrideSrc: _overrideSrc,
742
+ src,
743
+ ...props
744
+ }) {
679
745
  const newSrc = applyBundleUrlToImagePropsSrc(
680
746
  bundle,
681
- typeof props.src === "string" ? props.src : props.src.src
747
+ typeof src === "string" ? src : src.src
682
748
  );
683
749
  return (
684
750
  // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
@@ -956,7 +1022,9 @@ function remoteFetchHeaders(additionalHeaders) {
956
1022
  * Ensure the automation bypass secret is the same on the client and host.
957
1023
  * Otherwise, manually specify x-vercel-protection-bypass for the remote in the `additionalHeaders` parameter.
958
1024
  */
959
- "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET,
1025
+ ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
1026
+ "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
1027
+ } : {},
960
1028
  ...Object.fromEntries(
961
1029
  additionalHeaders instanceof Headers ? additionalHeaders.entries() : Object.entries(additionalHeaders ?? {})
962
1030
  ),
@@ -979,12 +1047,20 @@ var tagNames = [
979
1047
  function applyOriginToNodes(doc, url) {
980
1048
  if (url.origin !== location.origin) {
981
1049
  const nodes = doc.querySelectorAll(
982
- tagNames.map((type) => `${type}[src],${type}[srcset]`).join(",")
1050
+ tagNames.map(
1051
+ (type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
1052
+ ).join(",")
983
1053
  );
984
1054
  nodes.forEach((node) => {
985
1055
  if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
986
1056
  node.src = new URL(node.getAttribute("src") ?? "/", url).href;
987
1057
  }
1058
+ if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
1059
+ node.setAttribute(
1060
+ "href",
1061
+ new URL(node.getAttribute("href") ?? "/", url).href
1062
+ );
1063
+ }
988
1064
  if (node.hasAttribute("srcset")) {
989
1065
  const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
990
1066
  const [urlPart, descriptor] = entry.trim().split(/\s+/);
@@ -997,6 +1073,18 @@ function applyOriginToNodes(doc, url) {
997
1073
  node.setAttribute("srcset", srcSet);
998
1074
  }
999
1075
  }
1076
+ if (node.hasAttribute("imagesrcset")) {
1077
+ const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
1078
+ const [urlPart, descriptor] = entry.trim().split(/\s+/);
1079
+ if (!urlPart)
1080
+ return entry;
1081
+ const absoluteUrl = new URL(urlPart, url).href;
1082
+ return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
1083
+ }).join(", ");
1084
+ if (srcSet) {
1085
+ node.setAttribute("imagesrcset", srcSet);
1086
+ }
1087
+ }
1000
1088
  });
1001
1089
  }
1002
1090
  }