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
@@ -620,16 +620,70 @@ function sharedPolyfills(shared) {
620
620
  }
621
621
  };
622
622
  },
623
+ usePathname() {
624
+ return location.pathname;
625
+ },
626
+ useParams() {
627
+ return {};
628
+ },
623
629
  useSearchParams() {
624
630
  return new URLSearchParams(location.search);
625
631
  },
632
+ useSelectedLayoutSegment() {
633
+ return null;
634
+ },
635
+ useSelectedLayoutSegments() {
636
+ return [];
637
+ },
626
638
  __esModule: true
627
639
  })),
628
640
  "next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
629
641
  default: ({
642
+ scroll: _,
643
+ replace,
644
+ prefetch,
645
+ onNavigate,
630
646
  children,
631
647
  ...props
632
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { ...props, href: props.href, suppressHydrationWarning: true, children: children ?? null }),
648
+ }) => {
649
+ if (prefetch) {
650
+ console.warn(
651
+ "Next.js Link prefetch is not supported in remote components"
652
+ );
653
+ }
654
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
655
+ "a",
656
+ {
657
+ ...props,
658
+ href: props.href,
659
+ onClick: (e) => {
660
+ e.preventDefault();
661
+ let preventDefaulted = false;
662
+ e.preventDefault = () => {
663
+ preventDefaulted = true;
664
+ e.defaultPrevented = true;
665
+ };
666
+ if (typeof props.onClick === "function") {
667
+ props.onClick(e);
668
+ }
669
+ onNavigate?.(e);
670
+ if (preventDefaulted) {
671
+ return;
672
+ }
673
+ if (replace) {
674
+ history.replaceState({}, "", props.href);
675
+ } else {
676
+ history.pushState({}, "", props.href);
677
+ }
678
+ },
679
+ suppressHydrationWarning: true,
680
+ children: children ?? null
681
+ }
682
+ );
683
+ },
684
+ useLinkStatus() {
685
+ return { pending: false };
686
+ },
633
687
  __esModule: true
634
688
  })),
635
689
  "next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
@@ -698,10 +752,22 @@ var init_polyfill = __esm({
698
752
  "use strict";
699
753
  // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
700
754
  import_jsx_runtime = require("react/jsx-runtime");
701
- imageImpl = (bundle) => function RemoteImage({ priority: _, ...props }) {
755
+ imageImpl = (bundle) => function RemoteImage({
756
+ fill: _fill,
757
+ loader: _loader,
758
+ quality: _quality,
759
+ priority: _priority,
760
+ loading: _loading,
761
+ placeholder: _placeholder,
762
+ blurDataURL: _blurDataURL,
763
+ unoptimized: _unoptimized,
764
+ overrideSrc: _overrideSrc,
765
+ src,
766
+ ...props
767
+ }) {
702
768
  const newSrc = applyBundleUrlToImagePropsSrc(
703
769
  bundle,
704
- typeof props.src === "string" ? props.src : props.src.src
770
+ typeof src === "string" ? src : src.src
705
771
  );
706
772
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
707
773
  "img",
@@ -981,7 +1047,9 @@ function remoteFetchHeaders(additionalHeaders) {
981
1047
  * Ensure the automation bypass secret is the same on the client and host.
982
1048
  * Otherwise, manually specify x-vercel-protection-bypass for the remote in the `additionalHeaders` parameter.
983
1049
  */
984
- "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET,
1050
+ ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
1051
+ "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
1052
+ } : {},
985
1053
  ...Object.fromEntries(
986
1054
  additionalHeaders instanceof Headers ? additionalHeaders.entries() : Object.entries(additionalHeaders ?? {})
987
1055
  ),
@@ -1004,12 +1072,20 @@ var tagNames = [
1004
1072
  function applyOriginToNodes(doc, url) {
1005
1073
  if (url.origin !== location.origin) {
1006
1074
  const nodes = doc.querySelectorAll(
1007
- tagNames.map((type) => `${type}[src],${type}[srcset]`).join(",")
1075
+ tagNames.map(
1076
+ (type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
1077
+ ).join(",")
1008
1078
  );
1009
1079
  nodes.forEach((node) => {
1010
1080
  if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
1011
1081
  node.src = new URL(node.getAttribute("src") ?? "/", url).href;
1012
1082
  }
1083
+ if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
1084
+ node.setAttribute(
1085
+ "href",
1086
+ new URL(node.getAttribute("href") ?? "/", url).href
1087
+ );
1088
+ }
1013
1089
  if (node.hasAttribute("srcset")) {
1014
1090
  const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
1015
1091
  const [urlPart, descriptor] = entry.trim().split(/\s+/);
@@ -1022,6 +1098,18 @@ function applyOriginToNodes(doc, url) {
1022
1098
  node.setAttribute("srcset", srcSet);
1023
1099
  }
1024
1100
  }
1101
+ if (node.hasAttribute("imagesrcset")) {
1102
+ const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
1103
+ const [urlPart, descriptor] = entry.trim().split(/\s+/);
1104
+ if (!urlPart)
1105
+ return entry;
1106
+ const absoluteUrl = new URL(urlPart, url).href;
1107
+ return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
1108
+ }).join(", ");
1109
+ if (srcSet) {
1110
+ node.setAttribute("imagesrcset", srcSet);
1111
+ }
1112
+ }
1025
1113
  });
1026
1114
  }
1027
1115
  }