remote-components 0.0.50 → 0.1.0

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 (119) hide show
  1. package/dist/{component-loader-1838f572.d.ts → component-loader-76eb1b8b.d.ts} +3 -1
  2. package/dist/html/host.cjs +486 -242
  3. package/dist/html/host.cjs.map +1 -1
  4. package/dist/html/host.d.ts +2 -0
  5. package/dist/html/host.js +485 -242
  6. package/dist/html/host.js.map +1 -1
  7. package/dist/html/remote.cjs +123 -21
  8. package/dist/html/remote.cjs.map +1 -1
  9. package/dist/html/remote.js +123 -21
  10. package/dist/html/remote.js.map +1 -1
  11. package/dist/internal/next/host/app-router-client.cjs +12 -3
  12. package/dist/internal/next/host/app-router-client.cjs.map +1 -1
  13. package/dist/internal/next/host/app-router-client.d.ts +11 -2
  14. package/dist/internal/next/host/app-router-client.js +12 -3
  15. package/dist/internal/next/host/app-router-client.js.map +1 -1
  16. package/dist/internal/react/context.cjs +43 -0
  17. package/dist/internal/react/context.cjs.map +1 -0
  18. package/dist/internal/react/context.d.ts +20 -0
  19. package/dist/internal/react/context.js +18 -0
  20. package/dist/internal/react/context.js.map +1 -0
  21. package/dist/internal/react/hooks/use-resolve-client-url.cjs +39 -0
  22. package/dist/internal/react/hooks/use-resolve-client-url.cjs.map +1 -0
  23. package/dist/internal/react/hooks/use-resolve-client-url.d.ts +5 -0
  24. package/dist/internal/react/hooks/use-resolve-client-url.js +15 -0
  25. package/dist/internal/react/hooks/use-resolve-client-url.js.map +1 -0
  26. package/dist/internal/shared/client/apply-origin.cjs +10 -5
  27. package/dist/internal/shared/client/apply-origin.cjs.map +1 -1
  28. package/dist/internal/shared/client/apply-origin.d.ts +3 -1
  29. package/dist/internal/shared/client/apply-origin.js +10 -5
  30. package/dist/internal/shared/client/apply-origin.js.map +1 -1
  31. package/dist/internal/shared/client/default-resolve-client-url.cjs +32 -0
  32. package/dist/internal/shared/client/default-resolve-client-url.cjs.map +1 -0
  33. package/dist/internal/shared/client/default-resolve-client-url.d.ts +5 -0
  34. package/dist/internal/shared/client/default-resolve-client-url.js +10 -0
  35. package/dist/internal/shared/client/default-resolve-client-url.js.map +1 -0
  36. package/dist/internal/shared/client/protected-rc-fallback.cjs +41 -0
  37. package/dist/internal/shared/client/protected-rc-fallback.cjs.map +1 -0
  38. package/dist/internal/shared/client/protected-rc-fallback.d.ts +7 -0
  39. package/dist/internal/shared/client/protected-rc-fallback.js +16 -0
  40. package/dist/internal/shared/client/protected-rc-fallback.js.map +1 -0
  41. package/dist/internal/shared/client/proxy-through-host.cjs +51 -0
  42. package/dist/internal/shared/client/proxy-through-host.cjs.map +1 -0
  43. package/dist/internal/shared/client/proxy-through-host.d.ts +57 -0
  44. package/dist/internal/shared/client/proxy-through-host.js +26 -0
  45. package/dist/internal/shared/client/proxy-through-host.js.map +1 -0
  46. package/dist/internal/shared/client/remote-component.cjs +208 -134
  47. package/dist/internal/shared/client/remote-component.cjs.map +1 -1
  48. package/dist/internal/shared/client/remote-component.d.ts +7 -5
  49. package/dist/internal/shared/client/remote-component.js +207 -134
  50. package/dist/internal/shared/client/remote-component.js.map +1 -1
  51. package/dist/internal/shared/constants.cjs +32 -0
  52. package/dist/internal/shared/constants.cjs.map +1 -0
  53. package/dist/internal/shared/constants.d.ts +4 -0
  54. package/dist/internal/shared/constants.js +7 -0
  55. package/dist/internal/shared/constants.js.map +1 -0
  56. package/dist/internal/shared/error.cjs +70 -0
  57. package/dist/internal/shared/error.cjs.map +1 -1
  58. package/dist/internal/shared/error.d.ts +3 -1
  59. package/dist/internal/shared/error.js +71 -0
  60. package/dist/internal/shared/error.js.map +1 -1
  61. package/dist/internal/shared/ssr/fetch-remote-component.cjs +1 -2
  62. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
  63. package/dist/internal/shared/ssr/fetch-remote-component.js +1 -2
  64. package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
  65. package/dist/internal/shared/ssr/fetch-with-hooks.cjs +7 -2
  66. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
  67. package/dist/internal/shared/ssr/fetch-with-hooks.js +7 -2
  68. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
  69. package/dist/internal/shared/utils/logger.cjs +26 -10
  70. package/dist/internal/shared/utils/logger.cjs.map +1 -1
  71. package/dist/internal/shared/utils/logger.d.ts +7 -2
  72. package/dist/internal/shared/utils/logger.js +24 -9
  73. package/dist/internal/shared/utils/logger.js.map +1 -1
  74. package/dist/next/config.cjs +2 -2
  75. package/dist/next/config.cjs.map +1 -1
  76. package/dist/next/config.js +2 -2
  77. package/dist/next/config.js.map +1 -1
  78. package/dist/next/host/client/index.cjs +363 -207
  79. package/dist/next/host/client/index.cjs.map +1 -1
  80. package/dist/next/host/client/index.d.ts +3 -1
  81. package/dist/next/host/client/index.js +336 -181
  82. package/dist/next/host/client/index.js.map +1 -1
  83. package/dist/next/host/pages-router-client.cjs +15 -2
  84. package/dist/next/host/pages-router-client.cjs.map +1 -1
  85. package/dist/next/host/pages-router-client.d.ts +12 -1
  86. package/dist/next/host/pages-router-client.js +15 -2
  87. package/dist/next/host/pages-router-client.js.map +1 -1
  88. package/dist/next/host/pages-router-server.cjs +3 -2
  89. package/dist/next/host/pages-router-server.cjs.map +1 -1
  90. package/dist/next/host/pages-router-server.d.ts +16 -0
  91. package/dist/next/host/pages-router-server.js +3 -2
  92. package/dist/next/host/pages-router-server.js.map +1 -1
  93. package/dist/next/proxy.cjs +66 -27
  94. package/dist/next/proxy.cjs.map +1 -1
  95. package/dist/next/proxy.d.ts +0 -1
  96. package/dist/next/proxy.js +66 -27
  97. package/dist/next/proxy.js.map +1 -1
  98. package/dist/proxy-through-host-a676a522.d.ts +52 -0
  99. package/dist/react/index.cjs +381 -206
  100. package/dist/react/index.cjs.map +1 -1
  101. package/dist/react/index.d.ts +28 -4
  102. package/dist/react/index.js +354 -181
  103. package/dist/react/index.js.map +1 -1
  104. package/dist/shared/host/proxy.cjs +52 -23
  105. package/dist/shared/host/proxy.cjs.map +1 -1
  106. package/dist/shared/host/proxy.d.ts +0 -3
  107. package/dist/shared/host/proxy.js +55 -22
  108. package/dist/shared/host/proxy.js.map +1 -1
  109. package/dist/shared/remote/proxy.cjs +9 -1
  110. package/dist/shared/remote/proxy.cjs.map +1 -1
  111. package/dist/shared/remote/proxy.d.ts +7 -1
  112. package/dist/shared/remote/proxy.js +8 -1
  113. package/dist/shared/remote/proxy.js.map +1 -1
  114. package/package.json +1 -1
  115. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs +0 -62
  116. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs.map +0 -1
  117. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.d.ts +0 -14
  118. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js +0 -37
  119. package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/shared/client/apply-origin.ts"],"sourcesContent":["const tagNames = [\n 'img',\n 'source',\n 'video',\n 'audio',\n 'track',\n 'iframe',\n 'embed',\n 'script',\n 'link',\n];\n\nexport function applyOriginToNodes(doc: Document | HTMLElement, url: URL) {\n if (url.origin !== location.origin) {\n const nodes = doc.querySelectorAll<HTMLImageElement>(\n tagNames\n .map(\n (type) =>\n `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`,\n )\n .join(','),\n );\n nodes.forEach((node) => {\n if (\n node.hasAttribute('src') &&\n /^[./]+\\/?/.test(node.getAttribute('src') ?? '')\n ) {\n node.src = new URL(node.getAttribute('src') ?? '/', url).href;\n }\n if (\n node.hasAttribute('href') &&\n /^[./]+\\/?/.test(node.getAttribute('href') ?? '')\n ) {\n node.setAttribute(\n 'href',\n new URL(node.getAttribute('href') ?? '/', url).href,\n );\n }\n if (node.hasAttribute('srcset')) {\n const srcSet = node\n .getAttribute('srcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('srcset', srcSet);\n }\n }\n if (node.hasAttribute('imagesrcset')) {\n const srcSet = node\n .getAttribute('imagesrcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('imagesrcset', srcSet);\n }\n }\n });\n }\n}\n"],"mappings":"AAAA,MAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,mBAAmB,KAA6B,KAAU;AACxE,MAAI,IAAI,WAAW,SAAS,QAAQ;AAClC,UAAM,QAAQ,IAAI;AAAA,MAChB,SACG;AAAA,QACC,CAAC,SACC,GAAG,aAAa,gBAAgB,cAAc;AAAA,MAClD,EACC,KAAK,GAAG;AAAA,IACb;AACA,UAAM,QAAQ,CAAC,SAAS;AACtB,UACE,KAAK,aAAa,KAAK,KACvB,YAAY,KAAK,KAAK,aAAa,KAAK,KAAK,EAAE,GAC/C;AACA,aAAK,MAAM,IAAI,IAAI,KAAK,aAAa,KAAK,KAAK,KAAK,GAAG,EAAE;AAAA,MAC3D;AACA,UACE,KAAK,aAAa,MAAM,KACxB,YAAY,KAAK,KAAK,aAAa,MAAM,KAAK,EAAE,GAChD;AACA,aAAK;AAAA,UACH;AAAA,UACA,IAAI,IAAI,KAAK,aAAa,MAAM,KAAK,KAAK,GAAG,EAAE;AAAA,QACjD;AAAA,MACF;AACA,UAAI,KAAK,aAAa,QAAQ,GAAG;AAC/B,cAAM,SAAS,KACZ,aAAa,QAAQ,GACpB,MAAM,GAAG,EACV,IAAI,CAAC,UAAU;AACd,gBAAM,CAAC,SAAS,UAAU,IAAI,MAAM,KAAK,EAAE,MAAM,KAAK;AACtD,cAAI,CAAC;AAAS,mBAAO;AAErB,gBAAM,cAAc,IAAI,IAAI,SAAS,GAAG,EAAE;AAC1C,iBAAO,aAAa,GAAG,eAAe,eAAe;AAAA,QACvD,CAAC,EACA,KAAK,IAAI;AACZ,YAAI,QAAQ;AACV,eAAK,aAAa,UAAU,MAAM;AAAA,QACpC;AAAA,MACF;AACA,UAAI,KAAK,aAAa,aAAa,GAAG;AACpC,cAAM,SAAS,KACZ,aAAa,aAAa,GACzB,MAAM,GAAG,EACV,IAAI,CAAC,UAAU;AACd,gBAAM,CAAC,SAAS,UAAU,IAAI,MAAM,KAAK,EAAE,MAAM,KAAK;AACtD,cAAI,CAAC;AAAS,mBAAO;AAErB,gBAAM,cAAc,IAAI,IAAI,SAAS,GAAG,EAAE;AAC1C,iBAAO,aAAa,GAAG,eAAe,eAAe;AAAA,QACvD,CAAC,EACA,KAAK,IAAI;AACZ,YAAI,QAAQ;AACV,eAAK,aAAa,eAAe,MAAM;AAAA,QACzC;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/shared/client/apply-origin.ts"],"sourcesContent":["import type { InternalResolveClientUrl } from '#internal/shared/ssr/types';\n\nconst tagNames = [\n 'img',\n 'source',\n 'video',\n 'audio',\n 'track',\n 'iframe',\n 'embed',\n 'script',\n 'link',\n];\n\nexport function applyOriginToNodes(\n doc: Document | HTMLElement,\n url: URL,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n if (url.origin !== location.origin) {\n const nodes = doc.querySelectorAll<HTMLImageElement>(\n tagNames\n .map(\n (type) =>\n `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`,\n )\n .join(','),\n );\n nodes.forEach((node) => {\n if (\n node.hasAttribute('src') &&\n /^[./]+\\/?/.test(node.getAttribute('src') ?? '')\n ) {\n const absoluteSrc = new URL(node.getAttribute('src') ?? '/', url).href;\n // Script elements are handled by the loaders (script-loader, static-loader)\n // which apply the callback themselves. Only apply it here for non-script elements.\n const isScript = node.tagName.toLowerCase() === 'script';\n node.src = isScript\n ? absoluteSrc\n : (resolveClientUrl?.(absoluteSrc) ?? absoluteSrc);\n }\n if (\n node.hasAttribute('href') &&\n /^[./]+\\/?/.test(node.getAttribute('href') ?? '')\n ) {\n const absoluteHref = new URL(node.getAttribute('href') ?? '/', url)\n .href;\n node.setAttribute(\n 'href',\n resolveClientUrl?.(absoluteHref) ?? absoluteHref,\n );\n }\n if (node.hasAttribute('srcset')) {\n const srcSet = node\n .getAttribute('srcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;\n return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('srcset', srcSet);\n }\n }\n if (node.hasAttribute('imagesrcset')) {\n const srcSet = node\n .getAttribute('imagesrcset')\n ?.split(',')\n .map((entry) => {\n const [urlPart, descriptor] = entry.trim().split(/\\s+/);\n if (!urlPart) return entry;\n\n const absoluteUrl = new URL(urlPart, url).href;\n const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;\n return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;\n })\n .join(', ');\n if (srcSet) {\n node.setAttribute('imagesrcset', srcSet);\n }\n }\n });\n }\n}\n"],"mappings":"AAEA,MAAM,WAAW;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,mBACd,KACA,KACA,kBACA;AACA,MAAI,IAAI,WAAW,SAAS,QAAQ;AAClC,UAAM,QAAQ,IAAI;AAAA,MAChB,SACG;AAAA,QACC,CAAC,SACC,GAAG,aAAa,gBAAgB,cAAc;AAAA,MAClD,EACC,KAAK,GAAG;AAAA,IACb;AACA,UAAM,QAAQ,CAAC,SAAS;AACtB,UACE,KAAK,aAAa,KAAK,KACvB,YAAY,KAAK,KAAK,aAAa,KAAK,KAAK,EAAE,GAC/C;AACA,cAAM,cAAc,IAAI,IAAI,KAAK,aAAa,KAAK,KAAK,KAAK,GAAG,EAAE;AAGlE,cAAM,WAAW,KAAK,QAAQ,YAAY,MAAM;AAChD,aAAK,MAAM,WACP,cACC,mBAAmB,WAAW,KAAK;AAAA,MAC1C;AACA,UACE,KAAK,aAAa,MAAM,KACxB,YAAY,KAAK,KAAK,aAAa,MAAM,KAAK,EAAE,GAChD;AACA,cAAM,eAAe,IAAI,IAAI,KAAK,aAAa,MAAM,KAAK,KAAK,GAAG,EAC/D;AACH,aAAK;AAAA,UACH;AAAA,UACA,mBAAmB,YAAY,KAAK;AAAA,QACtC;AAAA,MACF;AACA,UAAI,KAAK,aAAa,QAAQ,GAAG;AAC/B,cAAM,SAAS,KACZ,aAAa,QAAQ,GACpB,MAAM,GAAG,EACV,IAAI,CAAC,UAAU;AACd,gBAAM,CAAC,SAAS,UAAU,IAAI,MAAM,KAAK,EAAE,MAAM,KAAK;AACtD,cAAI,CAAC;AAAS,mBAAO;AAErB,gBAAM,cAAc,IAAI,IAAI,SAAS,GAAG,EAAE;AAC1C,gBAAM,cAAc,mBAAmB,WAAW,KAAK;AACvD,iBAAO,aAAa,GAAG,eAAe,eAAe;AAAA,QACvD,CAAC,EACA,KAAK,IAAI;AACZ,YAAI,QAAQ;AACV,eAAK,aAAa,UAAU,MAAM;AAAA,QACpC;AAAA,MACF;AACA,UAAI,KAAK,aAAa,aAAa,GAAG;AACpC,cAAM,SAAS,KACZ,aAAa,aAAa,GACzB,MAAM,GAAG,EACV,IAAI,CAAC,UAAU;AACd,gBAAM,CAAC,SAAS,UAAU,IAAI,MAAM,KAAK,EAAE,MAAM,KAAK;AACtD,cAAI,CAAC;AAAS,mBAAO;AAErB,gBAAM,cAAc,IAAI,IAAI,SAAS,GAAG,EAAE;AAC1C,gBAAM,cAAc,mBAAmB,WAAW,KAAK;AACvD,iBAAO,aAAa,GAAG,eAAe,eAAe;AAAA,QACvD,CAAC,EACA,KAAK,IAAI;AACZ,YAAI,QAAQ;AACV,eAAK,aAAa,eAAe,MAAM;AAAA,QACzC;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var default_resolve_client_url_exports = {};
20
+ __export(default_resolve_client_url_exports, {
21
+ bindResolveClientUrl: () => bindResolveClientUrl
22
+ });
23
+ module.exports = __toCommonJS(default_resolve_client_url_exports);
24
+ var import_proxy_through_host = require("./proxy-through-host");
25
+ function bindResolveClientUrl(prop, remoteSrc) {
26
+ return prop ? (0, import_proxy_through_host.withRemoteSrc)(prop, remoteSrc) : void 0;
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ bindResolveClientUrl
31
+ });
32
+ //# sourceMappingURL=default-resolve-client-url.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/default-resolve-client-url.ts"],"sourcesContent":["import {\n type InternalResolveClientUrl,\n type ResolveClientUrl,\n withRemoteSrc,\n} from './proxy-through-host';\n\nexport function bindResolveClientUrl(\n prop: ResolveClientUrl | undefined,\n remoteSrc: string,\n): InternalResolveClientUrl | undefined {\n return prop ? withRemoteSrc(prop, remoteSrc) : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAIO;AAEA,SAAS,qBACd,MACA,WACsC;AACtC,SAAO,WAAO,yCAAc,MAAM,SAAS,IAAI;AACjD;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { ResolveClientUrl, InternalResolveClientUrl } from './proxy-through-host.js';
2
+
3
+ declare function bindResolveClientUrl(prop: ResolveClientUrl | undefined, remoteSrc: string): InternalResolveClientUrl | undefined;
4
+
5
+ export { bindResolveClientUrl };
@@ -0,0 +1,10 @@
1
+ import {
2
+ withRemoteSrc
3
+ } from "./proxy-through-host";
4
+ function bindResolveClientUrl(prop, remoteSrc) {
5
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
6
+ }
7
+ export {
8
+ bindResolveClientUrl
9
+ };
10
+ //# sourceMappingURL=default-resolve-client-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/default-resolve-client-url.ts"],"sourcesContent":["import {\n type InternalResolveClientUrl,\n type ResolveClientUrl,\n withRemoteSrc,\n} from './proxy-through-host';\n\nexport function bindResolveClientUrl(\n prop: ResolveClientUrl | undefined,\n remoteSrc: string,\n): InternalResolveClientUrl | undefined {\n return prop ? withRemoteSrc(prop, remoteSrc) : undefined;\n}\n"],"mappings":"AAAA;AAAA,EAGE;AAAA,OACK;AAEA,SAAS,qBACd,MACA,WACsC;AACtC,SAAO,OAAO,cAAc,MAAM,SAAS,IAAI;AACjD;","names":[]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var protected_rc_fallback_exports = {};
20
+ __export(protected_rc_fallback_exports, {
21
+ generateProtectedRcFallbackSrc: () => generateProtectedRcFallbackSrc,
22
+ isProxiedUrl: () => isProxiedUrl
23
+ });
24
+ module.exports = __toCommonJS(protected_rc_fallback_exports);
25
+ var import_constants = require("#internal/shared/constants");
26
+ function generateProtectedRcFallbackSrc(url) {
27
+ return `${import_constants.RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
28
+ }
29
+ function isProxiedUrl(url) {
30
+ try {
31
+ return new URL(url, location.href).pathname === import_constants.RC_PROTECTED_REMOTE_FETCH_PATHNAME;
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ generateProtectedRcFallbackSrc,
39
+ isProxiedUrl
40
+ });
41
+ //# sourceMappingURL=protected-rc-fallback.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/protected-rc-fallback.ts"],"sourcesContent":["import { RC_PROTECTED_REMOTE_FETCH_PATHNAME } from '#internal/shared/constants';\n\n/**\n * Generates a fallback URL that proxies the request through the host's protected remote fetch endpoint\n */\nexport function generateProtectedRcFallbackSrc(url: string): string {\n return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;\n}\n\nexport function isProxiedUrl(url: string): boolean {\n try {\n return (\n new URL(url, location.href).pathname ===\n RC_PROTECTED_REMOTE_FETCH_PATHNAME\n );\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAmD;AAK5C,SAAS,+BAA+B,KAAqB;AAClE,SAAO,GAAG,2DAA0C,mBAAmB,GAAG;AAC5E;AAEO,SAAS,aAAa,KAAsB;AACjD,MAAI;AACF,WACE,IAAI,IAAI,KAAK,SAAS,IAAI,EAAE,aAC5B;AAAA,EAEJ,QAAE;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates a fallback URL that proxies the request through the host's protected remote fetch endpoint
3
+ */
4
+ declare function generateProtectedRcFallbackSrc(url: string): string;
5
+ declare function isProxiedUrl(url: string): boolean;
6
+
7
+ export { generateProtectedRcFallbackSrc, isProxiedUrl };
@@ -0,0 +1,16 @@
1
+ import { RC_PROTECTED_REMOTE_FETCH_PATHNAME } from "#internal/shared/constants";
2
+ function generateProtectedRcFallbackSrc(url) {
3
+ return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;
4
+ }
5
+ function isProxiedUrl(url) {
6
+ try {
7
+ return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
8
+ } catch {
9
+ return false;
10
+ }
11
+ }
12
+ export {
13
+ generateProtectedRcFallbackSrc,
14
+ isProxiedUrl
15
+ };
16
+ //# sourceMappingURL=protected-rc-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/protected-rc-fallback.ts"],"sourcesContent":["import { RC_PROTECTED_REMOTE_FETCH_PATHNAME } from '#internal/shared/constants';\n\n/**\n * Generates a fallback URL that proxies the request through the host's protected remote fetch endpoint\n */\nexport function generateProtectedRcFallbackSrc(url: string): string {\n return `${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${encodeURIComponent(url)}`;\n}\n\nexport function isProxiedUrl(url: string): boolean {\n try {\n return (\n new URL(url, location.href).pathname ===\n RC_PROTECTED_REMOTE_FETCH_PATHNAME\n );\n } catch {\n return false;\n }\n}\n"],"mappings":"AAAA,SAAS,0CAA0C;AAK5C,SAAS,+BAA+B,KAAqB;AAClE,SAAO,GAAG,0CAA0C,mBAAmB,GAAG;AAC5E;AAEO,SAAS,aAAa,KAAsB;AACjD,MAAI;AACF,WACE,IAAI,IAAI,KAAK,SAAS,IAAI,EAAE,aAC5B;AAAA,EAEJ,QAAE;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var proxy_through_host_exports = {};
20
+ __export(proxy_through_host_exports, {
21
+ proxyClientRequestsThroughHost: () => proxyClientRequestsThroughHost,
22
+ withRemoteSrc: () => withRemoteSrc
23
+ });
24
+ module.exports = __toCommonJS(proxy_through_host_exports);
25
+ var import_protected_rc_fallback = require("./protected-rc-fallback");
26
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
27
+ return (url) => resolveClientUrl(remoteSrc, url);
28
+ }
29
+ const proxyClientRequestsThroughHost = (remoteSrc, url) => {
30
+ if (typeof location === "undefined") {
31
+ return void 0;
32
+ }
33
+ const remoteOrigin = new URL(remoteSrc, location.href).origin;
34
+ if (remoteOrigin === location.origin) {
35
+ return void 0;
36
+ }
37
+ try {
38
+ const parsed = new URL(url, location.href);
39
+ if (parsed.origin === remoteOrigin) {
40
+ return (0, import_protected_rc_fallback.generateProtectedRcFallbackSrc)(url);
41
+ }
42
+ } catch {
43
+ }
44
+ return void 0;
45
+ };
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ proxyClientRequestsThroughHost,
49
+ withRemoteSrc
50
+ });
51
+ //# sourceMappingURL=proxy-through-host.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/proxy-through-host.ts"],"sourcesContent":["import { generateProtectedRcFallbackSrc } from './protected-rc-fallback';\n\n/**\n * Intercepts client-side URL resolution for remote component resources.\n * Called before each asset (script, stylesheet, chunk, module, image) is fetched.\n *\n * Return a new URL string to redirect the fetch (e.g., through a proxy),\n * or undefined to use the original URL.\n *\n * @param remoteSrc - The `src` of the remote component being loaded\n * @param url - The asset URL about to be fetched\n *\n * @example\n * // Proxy all assets from the remote's origin through the host\n * const resolveClientUrl = (remoteSrc, url) => {\n * const remoteOrigin = new URL(remoteSrc).origin;\n * const parsed = new URL(url);\n * if (parsed.origin !== location.origin && parsed.origin === remoteOrigin) {\n * return `/rc-fetch-protected-remote?url=${encodeURIComponent(url)}`;\n * }\n * };\n */\nexport type ResolveClientUrl = (\n remoteSrc: string,\n url: string,\n) => string | undefined;\n\n/**\n * Internal bound resolver — `ResolveClientUrl` with `remoteSrc` already applied.\n * Used by internal loaders that don't need to know the remote src.\n */\nexport type InternalResolveClientUrl = (url: string) => string | undefined;\n\n/**\n * Binds a `ResolveClientUrl` to a specific `remoteSrc`, producing an\n * `InternalResolveClientUrl` that only needs the asset URL.\n */\nexport function withRemoteSrc(\n resolveClientUrl: ResolveClientUrl,\n remoteSrc: string,\n): InternalResolveClientUrl {\n return (url) => resolveClientUrl(remoteSrc, url);\n}\n\n/**\n * A `ResolveClientUrl` that proxies cross-origin asset URLs\n * through the host's protected remote fetch endpoint (`/rc-fetch-protected-remote`).\n * Same-origin URLs are left unchanged.\n *\n * On Vercel preview deployments, deployment protection blocks direct cross-origin\n * asset fetches. This function proxies those requests through the host so they\n * inherit the host's authentication cookies.\n *\n * Requires `withRemoteComponentsHost` middleware on the host to handle the\n * proxied requests. Configure `allowedProxyUrls` to restrict which URLs can\n * be proxied.\n *\n * @example\n * ```tsx\n * import { RemoteComponent, proxyClientRequestsThroughHost } from 'remote-components/react';\n *\n * <RemoteComponent\n * src=\"https://remote-app.com/components/header\"\n * resolveClientUrl={proxyClientRequestsThroughHost}\n * />\n * ```\n */\nexport const proxyClientRequestsThroughHost: ResolveClientUrl = (\n remoteSrc,\n url,\n) => {\n if (typeof location === 'undefined') {\n return undefined;\n }\n const remoteOrigin = new URL(remoteSrc, location.href).origin;\n if (remoteOrigin === location.origin) {\n return undefined;\n }\n try {\n const parsed = new URL(url, location.href);\n if (parsed.origin === remoteOrigin) {\n return generateProtectedRcFallbackSrc(url);\n }\n } catch {\n // If URL parsing fails, return undefined to use the original\n }\n return undefined;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mCAA+C;AAqCxC,SAAS,cACd,kBACA,WAC0B;AAC1B,SAAO,CAAC,QAAQ,iBAAiB,WAAW,GAAG;AACjD;AAyBO,MAAM,iCAAmD,CAC9D,WACA,QACG;AACH,MAAI,OAAO,aAAa,aAAa;AACnC,WAAO;AAAA,EACT;AACA,QAAM,eAAe,IAAI,IAAI,WAAW,SAAS,IAAI,EAAE;AACvD,MAAI,iBAAiB,SAAS,QAAQ;AACpC,WAAO;AAAA,EACT;AACA,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI;AACzC,QAAI,OAAO,WAAW,cAAc;AAClC,iBAAO,6DAA+B,GAAG;AAAA,IAC3C;AAAA,EACF,QAAE;AAAA,EAEF;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Intercepts client-side URL resolution for remote component resources.
3
+ * Called before each asset (script, stylesheet, chunk, module, image) is fetched.
4
+ *
5
+ * Return a new URL string to redirect the fetch (e.g., through a proxy),
6
+ * or undefined to use the original URL.
7
+ *
8
+ * @param remoteSrc - The `src` of the remote component being loaded
9
+ * @param url - The asset URL about to be fetched
10
+ *
11
+ * @example
12
+ * // Proxy all assets from the remote's origin through the host
13
+ * const resolveClientUrl = (remoteSrc, url) => {
14
+ * const remoteOrigin = new URL(remoteSrc).origin;
15
+ * const parsed = new URL(url);
16
+ * if (parsed.origin !== location.origin && parsed.origin === remoteOrigin) {
17
+ * return `/rc-fetch-protected-remote?url=${encodeURIComponent(url)}`;
18
+ * }
19
+ * };
20
+ */
21
+ type ResolveClientUrl = (remoteSrc: string, url: string) => string | undefined;
22
+ /**
23
+ * Internal bound resolver — `ResolveClientUrl` with `remoteSrc` already applied.
24
+ * Used by internal loaders that don't need to know the remote src.
25
+ */
26
+ type InternalResolveClientUrl = (url: string) => string | undefined;
27
+ /**
28
+ * Binds a `ResolveClientUrl` to a specific `remoteSrc`, producing an
29
+ * `InternalResolveClientUrl` that only needs the asset URL.
30
+ */
31
+ declare function withRemoteSrc(resolveClientUrl: ResolveClientUrl, remoteSrc: string): InternalResolveClientUrl;
32
+ /**
33
+ * A `ResolveClientUrl` that proxies cross-origin asset URLs
34
+ * through the host's protected remote fetch endpoint (`/rc-fetch-protected-remote`).
35
+ * Same-origin URLs are left unchanged.
36
+ *
37
+ * On Vercel preview deployments, deployment protection blocks direct cross-origin
38
+ * asset fetches. This function proxies those requests through the host so they
39
+ * inherit the host's authentication cookies.
40
+ *
41
+ * Requires `withRemoteComponentsHost` middleware on the host to handle the
42
+ * proxied requests. Configure `allowedProxyUrls` to restrict which URLs can
43
+ * be proxied.
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * import { RemoteComponent, proxyClientRequestsThroughHost } from 'remote-components/react';
48
+ *
49
+ * <RemoteComponent
50
+ * src="https://remote-app.com/components/header"
51
+ * resolveClientUrl={proxyClientRequestsThroughHost}
52
+ * />
53
+ * ```
54
+ */
55
+ declare const proxyClientRequestsThroughHost: ResolveClientUrl;
56
+
57
+ export { InternalResolveClientUrl, ResolveClientUrl, proxyClientRequestsThroughHost, withRemoteSrc };
@@ -0,0 +1,26 @@
1
+ import { generateProtectedRcFallbackSrc } from "./protected-rc-fallback";
2
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
3
+ return (url) => resolveClientUrl(remoteSrc, url);
4
+ }
5
+ const proxyClientRequestsThroughHost = (remoteSrc, url) => {
6
+ if (typeof location === "undefined") {
7
+ return void 0;
8
+ }
9
+ const remoteOrigin = new URL(remoteSrc, location.href).origin;
10
+ if (remoteOrigin === location.origin) {
11
+ return void 0;
12
+ }
13
+ try {
14
+ const parsed = new URL(url, location.href);
15
+ if (parsed.origin === remoteOrigin) {
16
+ return generateProtectedRcFallbackSrc(url);
17
+ }
18
+ } catch {
19
+ }
20
+ return void 0;
21
+ };
22
+ export {
23
+ proxyClientRequestsThroughHost,
24
+ withRemoteSrc
25
+ };
26
+ //# sourceMappingURL=proxy-through-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/shared/client/proxy-through-host.ts"],"sourcesContent":["import { generateProtectedRcFallbackSrc } from './protected-rc-fallback';\n\n/**\n * Intercepts client-side URL resolution for remote component resources.\n * Called before each asset (script, stylesheet, chunk, module, image) is fetched.\n *\n * Return a new URL string to redirect the fetch (e.g., through a proxy),\n * or undefined to use the original URL.\n *\n * @param remoteSrc - The `src` of the remote component being loaded\n * @param url - The asset URL about to be fetched\n *\n * @example\n * // Proxy all assets from the remote's origin through the host\n * const resolveClientUrl = (remoteSrc, url) => {\n * const remoteOrigin = new URL(remoteSrc).origin;\n * const parsed = new URL(url);\n * if (parsed.origin !== location.origin && parsed.origin === remoteOrigin) {\n * return `/rc-fetch-protected-remote?url=${encodeURIComponent(url)}`;\n * }\n * };\n */\nexport type ResolveClientUrl = (\n remoteSrc: string,\n url: string,\n) => string | undefined;\n\n/**\n * Internal bound resolver — `ResolveClientUrl` with `remoteSrc` already applied.\n * Used by internal loaders that don't need to know the remote src.\n */\nexport type InternalResolveClientUrl = (url: string) => string | undefined;\n\n/**\n * Binds a `ResolveClientUrl` to a specific `remoteSrc`, producing an\n * `InternalResolveClientUrl` that only needs the asset URL.\n */\nexport function withRemoteSrc(\n resolveClientUrl: ResolveClientUrl,\n remoteSrc: string,\n): InternalResolveClientUrl {\n return (url) => resolveClientUrl(remoteSrc, url);\n}\n\n/**\n * A `ResolveClientUrl` that proxies cross-origin asset URLs\n * through the host's protected remote fetch endpoint (`/rc-fetch-protected-remote`).\n * Same-origin URLs are left unchanged.\n *\n * On Vercel preview deployments, deployment protection blocks direct cross-origin\n * asset fetches. This function proxies those requests through the host so they\n * inherit the host's authentication cookies.\n *\n * Requires `withRemoteComponentsHost` middleware on the host to handle the\n * proxied requests. Configure `allowedProxyUrls` to restrict which URLs can\n * be proxied.\n *\n * @example\n * ```tsx\n * import { RemoteComponent, proxyClientRequestsThroughHost } from 'remote-components/react';\n *\n * <RemoteComponent\n * src=\"https://remote-app.com/components/header\"\n * resolveClientUrl={proxyClientRequestsThroughHost}\n * />\n * ```\n */\nexport const proxyClientRequestsThroughHost: ResolveClientUrl = (\n remoteSrc,\n url,\n) => {\n if (typeof location === 'undefined') {\n return undefined;\n }\n const remoteOrigin = new URL(remoteSrc, location.href).origin;\n if (remoteOrigin === location.origin) {\n return undefined;\n }\n try {\n const parsed = new URL(url, location.href);\n if (parsed.origin === remoteOrigin) {\n return generateProtectedRcFallbackSrc(url);\n }\n } catch {\n // If URL parsing fails, return undefined to use the original\n }\n return undefined;\n};\n"],"mappings":"AAAA,SAAS,sCAAsC;AAqCxC,SAAS,cACd,kBACA,WAC0B;AAC1B,SAAO,CAAC,QAAQ,iBAAiB,WAAW,GAAG;AACjD;AAyBO,MAAM,iCAAmD,CAC9D,WACA,QACG;AACH,MAAI,OAAO,aAAa,aAAa;AACnC,WAAO;AAAA,EACT;AACA,QAAM,eAAe,IAAI,IAAI,WAAW,SAAS,IAAI,EAAE;AACvD,MAAI,iBAAiB,SAAS,QAAQ;AACpC,WAAO;AAAA,EACT;AACA,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI;AACzC,QAAI,OAAO,WAAW,cAAc;AAClC,aAAO,+BAA+B,GAAG;AAAA,IAC3C;AAAA,EACF,QAAE;AAAA,EAEF;AACA,SAAO;AACT;","names":[]}