remote-components 0.0.42 → 0.0.44

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 (85) hide show
  1. package/dist/{component-loader-2ca91ad8.d.ts → component-loader-26b1f55e.d.ts} +63 -1
  2. package/dist/html/host.cjs +55 -19
  3. package/dist/html/host.cjs.map +1 -1
  4. package/dist/html/host.js +55 -19
  5. package/dist/html/host.js.map +1 -1
  6. package/dist/internal/next/host/app-router-client.d.ts +30 -3
  7. package/dist/internal/next/remote/render-client.cjs +1 -1
  8. package/dist/internal/next/remote/render-client.cjs.map +1 -1
  9. package/dist/internal/next/remote/render-client.js +1 -1
  10. package/dist/internal/next/remote/render-client.js.map +1 -1
  11. package/dist/internal/shared/client/remote-component.cjs +29 -0
  12. package/dist/internal/shared/client/remote-component.cjs.map +1 -1
  13. package/dist/internal/shared/client/remote-component.d.ts +2 -2
  14. package/dist/internal/shared/client/remote-component.js +29 -0
  15. package/dist/internal/shared/client/remote-component.js.map +1 -1
  16. package/dist/internal/shared/ssr/dom-flight.d.ts +1 -1
  17. package/dist/internal/shared/ssr/fetch-headers.cjs +4 -6
  18. package/dist/internal/shared/ssr/fetch-headers.cjs.map +1 -1
  19. package/dist/internal/shared/ssr/fetch-headers.d.ts +1 -1
  20. package/dist/internal/shared/ssr/fetch-headers.js +4 -6
  21. package/dist/internal/shared/ssr/fetch-headers.js.map +1 -1
  22. package/dist/internal/shared/ssr/fetch-remote-component.cjs +14 -23
  23. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
  24. package/dist/internal/shared/ssr/fetch-remote-component.d.ts +5 -9
  25. package/dist/internal/shared/ssr/fetch-remote-component.js +13 -21
  26. package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
  27. package/dist/internal/shared/ssr/fetch-with-hooks.cjs +40 -0
  28. package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -0
  29. package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +39 -0
  30. package/dist/internal/shared/ssr/fetch-with-hooks.js +16 -0
  31. package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -0
  32. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +1 -1
  33. package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +1 -1
  34. package/dist/next/config.cjs +1 -9
  35. package/dist/next/config.cjs.map +1 -1
  36. package/dist/next/config.js +1 -9
  37. package/dist/next/config.js.map +1 -1
  38. package/dist/next/host/app-router-server.cjs +7 -8
  39. package/dist/next/host/app-router-server.cjs.map +1 -1
  40. package/dist/next/host/app-router-server.d.ts +13 -4
  41. package/dist/next/host/app-router-server.js +7 -8
  42. package/dist/next/host/app-router-server.js.map +1 -1
  43. package/dist/next/host/client/index.cjs +149 -72
  44. package/dist/next/host/client/index.cjs.map +1 -1
  45. package/dist/next/host/client/index.d.ts +2 -49
  46. package/dist/next/host/client/index.js +144 -66
  47. package/dist/next/host/client/index.js.map +1 -1
  48. package/dist/next/host/pages-router-client.cjs +62 -2
  49. package/dist/next/host/pages-router-client.cjs.map +1 -1
  50. package/dist/next/host/pages-router-client.d.ts +26 -1
  51. package/dist/next/host/pages-router-client.js +63 -3
  52. package/dist/next/host/pages-router-client.js.map +1 -1
  53. package/dist/next/host/pages-router-server.cjs +18 -22
  54. package/dist/next/host/pages-router-server.cjs.map +1 -1
  55. package/dist/next/host/pages-router-server.d.ts +36 -3
  56. package/dist/next/host/pages-router-server.js +18 -22
  57. package/dist/next/host/pages-router-server.js.map +1 -1
  58. package/dist/next/index.cjs.map +1 -1
  59. package/dist/next/index.d.ts +1 -1
  60. package/dist/next/index.js.map +1 -1
  61. package/dist/react/index.cjs +1581 -87
  62. package/dist/react/index.cjs.map +1 -1
  63. package/dist/react/index.d.ts +13 -14
  64. package/dist/react/index.js +1559 -87
  65. package/dist/react/index.js.map +1 -1
  66. package/dist/shared/host/app.cjs +1 -1
  67. package/dist/shared/host/app.cjs.map +1 -1
  68. package/dist/shared/host/app.js +1 -1
  69. package/dist/shared/host/app.js.map +1 -1
  70. package/dist/shared/host/pages.cjs +1 -1
  71. package/dist/shared/host/pages.cjs.map +1 -1
  72. package/dist/shared/host/pages.js +1 -1
  73. package/dist/shared/host/pages.js.map +1 -1
  74. package/dist/shared/remote/app.cjs +1 -1
  75. package/dist/shared/remote/app.cjs.map +1 -1
  76. package/dist/shared/remote/app.js +1 -1
  77. package/dist/shared/remote/app.js.map +1 -1
  78. package/dist/shared/remote/pages.cjs +1 -1
  79. package/dist/shared/remote/pages.cjs.map +1 -1
  80. package/dist/shared/remote/pages.js +1 -1
  81. package/dist/shared/remote/pages.js.map +1 -1
  82. package/dist/types-2ab78f67.d.ts +71 -0
  83. package/package.json +54 -32
  84. package/dist/types-235b68a5.d.ts +0 -32
  85. package/dist/types-cbf6c34f.d.ts +0 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["import 'remote-components/shared/remote/wrapper';\nimport type { RemoteComponent as RemoteComponentRenderType } from '#internal/next/remote/render-server';\nimport { RemoteComponentsError } from '#internal/shared/error';\nimport type { RemoteComponent as RemoteComponentAppServerType } from '#remote-components/next/host/app-router-server';\n\ntype RemoteComponentAppServerProps = Parameters<\n typeof RemoteComponentAppServerType\n>[0];\ntype RemoteComponentRenderProps = Parameters<\n typeof RemoteComponentRenderType\n>[0];\ntype RemoteComponentProps =\n | RemoteComponentAppServerProps\n | RemoteComponentRenderProps;\n\n/**\n * RemoteComponent is a Next.js component that exposes or consumes a remote component\n * that can be used in a host application.\n *\n * @param src - [host] The source URL of the remote component. Use this to consume a remote component from another application.\n * @param name - [host & remote] The name of the remote component. Use a unique name to expose multiple remote components from the same page.\n * @param isolate - [host] Whether to isolate the remote component's styles and scripts. Defaults to true.\n * @param mode - [host] The mode of the Shadow DOM. Defaults to `open`.\n * @param reset - [host] Whether to include a CSS reset style in the shadow DOM. Defaults to `false`.\n * @param additionalHeaders - [host] Additional headers to use when fetching the remote component.\n * @param children - [host & remote] Either the content of the remote component. Or when src is supplied, the fallback content to display while the remote component is being fetched.\n * @returns Either a React component that renders the remote component or a Next.js component that exposes the children as a remote component.\n *\n * @example\n *\n * Use the `<RemoteComponent>` in your Next.js App Router application to expose the children as a remote component without the `src` prop:\n *\n * ```tsx\n * import { RemoteComponent } from 'remote-components/next';\n *\n * export default function MyPage() {\n * return (\n * <RemoteComponent>\n * <h1>Hello from the remote component!</h1>\n * <p>This is a remote component that can be used in a host application.</p>\n * </RemoteComponent>\n * );\n * }\n * ```\n *\n * Use the `<RemoteComponent>` in your Next.js App Router application to consume a remote component from another application with the `src` prop:\n *\n * ```tsx\n * import { RemoteComponent } from 'remote-components/next';\n *\n * export default function MyPage() {\n * return (\n * <>\n * <RemoteComponent src=\"https://example.com/remote-component\" />\n * </>\n * );\n * }\n * ```\n *\n * The `children` of the `<RemoteComponent>` will be exposed as a remote component or it will be used as the loading fallback when consuming a remote component.\n */\nexport async function RemoteComponent(\n props: RemoteComponentProps,\n): Promise<React.ReactElement> {\n if ('src' in props) {\n const { RemoteComponent: RemoteComponentAppServer } = await import(\n '#remote-components/next/host/app-router-server'\n );\n return RemoteComponentAppServer(props);\n }\n\n if ('children' in props) {\n const { RemoteComponent: RemoteComponentRender } = await import(\n '#internal/next/remote/render-server'\n );\n return RemoteComponentRender(props);\n }\n\n throw new RemoteComponentsError(\n 'Invalid props passed to <RemoteComponent>. Expected either \"src\" or \"children\".',\n );\n}\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,6BAA6B;AA2DtC,eAAsB,gBACpB,OAC6B;AAC7B,MAAI,SAAS,OAAO;AAClB,UAAM,EAAE,iBAAiB,yBAAyB,IAAI,MAAM,OAC1D,gDACF;AACA,WAAO,yBAAyB,KAAK;AAAA,EACvC;AAEA,MAAI,cAAc,OAAO;AACvB,UAAM,EAAE,iBAAiB,sBAAsB,IAAI,MAAM,OACvD,qCACF;AACA,WAAO,sBAAsB,KAAK;AAAA,EACpC;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/next/index.tsx"],"sourcesContent":["import 'remote-components/shared/remote/wrapper';\nimport type { RemoteComponent as RemoteComponentRenderType } from '#internal/next/remote/render-server';\nimport { RemoteComponentsError } from '#internal/shared/error';\nimport type { RemoteComponent as RemoteComponentAppServerType } from '#remote-components/next/host/app-router-server';\n\ntype RemoteComponentAppServerProps = Parameters<\n typeof RemoteComponentAppServerType\n>[0];\ntype RemoteComponentRenderProps = Parameters<\n typeof RemoteComponentRenderType\n>[0];\ntype RemoteComponentProps =\n | RemoteComponentAppServerProps\n | RemoteComponentRenderProps;\n\n/**\n * RemoteComponent is a Next.js component that exposes or consumes a remote component\n * that can be used in a host application.\n *\n * @param src - [host] The source URL of the remote component. Use this to consume a remote component from another application.\n * @param name - [host & remote] The name of the remote component. Use a unique name to expose multiple remote components from the same page.\n * @param isolate - [host] Whether to isolate the remote component's styles and scripts. Defaults to true.\n * @param mode - [host] The mode of the Shadow DOM. Defaults to `open`.\n * @param reset - [host] Whether to include a CSS reset style in the shadow DOM. Defaults to `false`.\n * @param children - [host & remote] Either the content of the remote component. Or when src is supplied, the fallback content to display while the remote component is being fetched.\n * @returns Either a React component that renders the remote component or a Next.js component that exposes the children as a remote component.\n *\n * @example\n *\n * Use the `<RemoteComponent>` in your Next.js App Router application to expose the children as a remote component without the `src` prop:\n *\n * ```tsx\n * import { RemoteComponent } from 'remote-components/next';\n *\n * export default function MyPage() {\n * return (\n * <RemoteComponent>\n * <h1>Hello from the remote component!</h1>\n * <p>This is a remote component that can be used in a host application.</p>\n * </RemoteComponent>\n * );\n * }\n * ```\n *\n * Use the `<RemoteComponent>` in your Next.js App Router application to consume a remote component from another application with the `src` prop:\n *\n * ```tsx\n * import { RemoteComponent } from 'remote-components/next';\n *\n * export default function MyPage() {\n * return (\n * <>\n * <RemoteComponent src=\"https://example.com/remote-component\" />\n * </>\n * );\n * }\n * ```\n *\n * The `children` of the `<RemoteComponent>` will be exposed as a remote component or it will be used as the loading fallback when consuming a remote component.\n */\nexport async function RemoteComponent(\n props: RemoteComponentProps,\n): Promise<React.ReactElement> {\n if ('src' in props) {\n const { RemoteComponent: RemoteComponentAppServer } = await import(\n '#remote-components/next/host/app-router-server'\n );\n return RemoteComponentAppServer(props);\n }\n\n if ('children' in props) {\n const { RemoteComponent: RemoteComponentRender } = await import(\n '#internal/next/remote/render-server'\n );\n return RemoteComponentRender(props);\n }\n\n throw new RemoteComponentsError(\n 'Invalid props passed to <RemoteComponent>. Expected either \"src\" or \"children\".',\n );\n}\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,6BAA6B;AA0DtC,eAAsB,gBACpB,OAC6B;AAC7B,MAAI,SAAS,OAAO;AAClB,UAAM,EAAE,iBAAiB,yBAAyB,IAAI,MAAM,OAC1D,gDACF;AACA,WAAO,yBAAyB,KAAK;AAAA,EACvC;AAEA,MAAI,cAAc,OAAO;AACvB,UAAM,EAAE,iBAAiB,sBAAsB,IAAI,MAAM,OACvD,qCACF;AACA,WAAO,sBAAsB,KAAK;AAAA,EACpC;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;","names":[]}