react-email 3.0.3 → 3.0.5

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 (224) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/index.js +96 -100
  3. package/dist/cli/index.mjs +75 -64
  4. package/dist/index.d.mts +20 -0
  5. package/dist/index.d.ts +20 -0
  6. package/dist/index.js +96 -0
  7. package/dist/index.mjs +21 -0
  8. package/dist/package/index.d.mts +33 -0
  9. package/dist/package/index.d.ts +33 -0
  10. package/dist/package/index.js +62 -0
  11. package/dist/package/index.mjs +7 -0
  12. package/dist/preview/.next/BUILD_ID +1 -1
  13. package/dist/preview/.next/app-build-manifest.json +31 -31
  14. package/dist/preview/.next/app-path-routes-manifest.json +1 -1
  15. package/dist/preview/.next/build-manifest.json +16 -15
  16. package/dist/preview/.next/cache/.rscinfo +1 -0
  17. package/dist/preview/.next/cache/eslint/.cache_1vyas3k +1 -0
  18. package/dist/preview/.next/cache/webpack/client-production/0.pack +0 -0
  19. package/dist/preview/.next/cache/webpack/client-production/index.pack +0 -0
  20. package/dist/preview/.next/cache/webpack/edge-server-production/0.pack +0 -0
  21. package/dist/preview/.next/cache/webpack/edge-server-production/index.pack +0 -0
  22. package/dist/preview/.next/cache/webpack/server-production/0.pack +0 -0
  23. package/dist/preview/.next/cache/webpack/server-production/index.pack +0 -0
  24. package/dist/preview/.next/diagnostics/build-diagnostics.json +6 -0
  25. package/dist/preview/.next/diagnostics/framework.json +1 -0
  26. package/dist/preview/.next/images-manifest.json +1 -1
  27. package/dist/preview/.next/next-minimal-server.js.nft.json +1 -1
  28. package/dist/preview/.next/next-server.js.nft.json +1 -1
  29. package/dist/preview/.next/prerender-manifest.json +1 -1
  30. package/dist/preview/.next/required-server-files.json +1 -1
  31. package/dist/preview/.next/routes-manifest.json +1 -1
  32. package/dist/preview/.next/server/app/_not-found/page.js +1 -1
  33. package/dist/preview/.next/server/app/_not-found/page.js.nft.json +1 -1
  34. package/dist/preview/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  35. package/dist/preview/.next/server/app/favicon.ico/route.js +1 -12
  36. package/dist/preview/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  37. package/dist/preview/.next/server/app/page.js +1 -1
  38. package/dist/preview/.next/server/app/page.js.nft.json +1 -1
  39. package/dist/preview/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/dist/preview/.next/server/app/preview/[...slug]/page.js +6 -6
  41. package/dist/preview/.next/server/app/preview/[...slug]/page.js.nft.json +1 -1
  42. package/dist/preview/.next/server/app/preview/[...slug]/page_client-reference-manifest.js +1 -1
  43. package/dist/preview/.next/server/app-paths-manifest.json +1 -1
  44. package/dist/preview/.next/server/chunks/300.js +13 -0
  45. package/dist/preview/.next/server/chunks/420.js +1 -0
  46. package/dist/preview/.next/server/chunks/625.js +5 -0
  47. package/dist/preview/.next/server/chunks/631.js +6 -0
  48. package/dist/preview/.next/server/chunks/720.js +10 -0
  49. package/dist/preview/.next/server/functions-config-manifest.json +1 -1
  50. package/dist/preview/.next/server/middleware-build-manifest.js +1 -1
  51. package/dist/preview/.next/server/next-font-manifest.js +1 -1
  52. package/dist/preview/.next/server/next-font-manifest.json +1 -1
  53. package/dist/preview/.next/server/pages/500.html +1 -1
  54. package/dist/preview/.next/server/pages/_app.js +1 -1
  55. package/dist/preview/.next/server/pages/_app.js.nft.json +1 -1
  56. package/dist/preview/.next/server/pages/_document.js +1 -1
  57. package/dist/preview/.next/server/pages/_document.js.nft.json +1 -1
  58. package/dist/preview/.next/server/pages/_error.js +1 -1
  59. package/dist/preview/.next/server/pages/_error.js.nft.json +1 -1
  60. package/dist/preview/.next/server/server-reference-manifest.js +1 -1
  61. package/dist/preview/.next/server/server-reference-manifest.json +1 -1
  62. package/dist/preview/.next/server/webpack-runtime.js +1 -1
  63. package/dist/preview/.next/static/6K68y2QEZ1dLbv-Xhi30p/_buildManifest.js +1 -0
  64. package/dist/preview/.next/static/chunks/12-b9450aa0845e7574.js +1 -0
  65. package/dist/preview/.next/static/chunks/154-69b91a0c2fd801b8.js +1 -0
  66. package/dist/preview/.next/static/chunks/447-886131c35ca42b91.js +1 -0
  67. package/dist/preview/.next/static/chunks/5fec7a0a-5179023f3f5a9421.js +1 -0
  68. package/dist/preview/.next/static/chunks/797-46f6c20952f0a280.js +2 -0
  69. package/dist/preview/.next/static/chunks/860-38d96c8819ba6f19.js +1 -0
  70. package/dist/preview/.next/static/chunks/app/_not-found/page-96d3eac723be3ee2.js +1 -0
  71. package/dist/preview/.next/static/chunks/app/layout-e1b6f1534cbbe5bd.js +1 -0
  72. package/dist/preview/.next/static/chunks/app/page-2c3e297e38c526ef.js +1 -0
  73. package/dist/preview/.next/static/chunks/app/preview/[...slug]/page-2b4988ba6daf34e1.js +1 -0
  74. package/dist/preview/.next/static/chunks/framework-e7cae9cecd5c9ba2.js +1 -0
  75. package/dist/preview/.next/static/chunks/main-app-2c7f96205a73f128.js +1 -0
  76. package/dist/preview/.next/static/chunks/main-df761fde212f9cda.js +1 -0
  77. package/dist/preview/.next/static/chunks/pages/_app-203a61b355820ccf.js +1 -0
  78. package/dist/preview/.next/static/chunks/pages/_error-1764ca54938748c8.js +1 -0
  79. package/dist/preview/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  80. package/dist/preview/.next/static/chunks/webpack-9255716c9496e606.js +1 -0
  81. package/dist/preview/.next/static/css/ec5d7e66bd3b6cb8.css +1 -0
  82. package/dist/preview/.next/trace +20 -52
  83. package/dist/preview/.next/types/app/layout.ts +11 -6
  84. package/dist/preview/.next/types/app/preview/[...slug]/page.ts +11 -6
  85. package/dist/preview/.next/types/cache-life.d.ts +141 -0
  86. package/next-env.d.ts +1 -1
  87. package/package.json +12 -12
  88. package/src/actions/get-email-path-from-slug.ts +3 -2
  89. package/src/actions/get-emails-directory-metadata.spec.ts +1 -0
  90. package/src/actions/get-emails-directory-metadata.ts +62 -59
  91. package/src/actions/render-email-by-path.tsx +16 -5
  92. package/src/app/preview/[...slug]/page.tsx +19 -9
  93. package/src/app/preview/[...slug]/preview.tsx +6 -7
  94. package/src/contexts/emails.tsx +2 -56
  95. package/src/hooks/use-email-rendering-result.ts +44 -0
  96. package/src/hooks/use-rendering-metadata.ts +5 -5
  97. package/src/package/body/dist/index.d.mts +6 -0
  98. package/src/package/body/dist/index.d.ts +6 -0
  99. package/src/package/body/dist/index.js +79 -0
  100. package/src/package/body/dist/index.mjs +45 -0
  101. package/src/package/button/dist/index.d.mts +6 -0
  102. package/src/package/button/dist/index.d.ts +6 -0
  103. package/src/package/button/dist/index.js +252 -0
  104. package/src/package/button/dist/index.mjs +218 -0
  105. package/src/package/code-block/dist/index.d.mts +4906 -0
  106. package/src/package/code-block/dist/index.d.ts +4906 -0
  107. package/src/package/code-block/dist/index.js +18205 -0
  108. package/src/package/code-block/dist/index.mjs +18133 -0
  109. package/src/package/code-inline/dist/index.d.mts +11 -0
  110. package/src/package/code-inline/dist/index.d.ts +11 -0
  111. package/src/package/code-inline/dist/index.js +106 -0
  112. package/src/package/code-inline/dist/index.mjs +72 -0
  113. package/src/package/column/dist/index.d.mts +6 -0
  114. package/src/package/column/dist/index.d.ts +6 -0
  115. package/src/package/column/dist/index.js +79 -0
  116. package/src/package/column/dist/index.mjs +45 -0
  117. package/src/package/components/dist/index.d.mts +20 -0
  118. package/src/package/components/dist/index.d.ts +20 -0
  119. package/src/package/components/dist/index.js +62 -0
  120. package/src/package/components/dist/index.mjs +21 -0
  121. package/src/package/container/dist/index.d.mts +6 -0
  122. package/src/package/container/dist/index.d.ts +6 -0
  123. package/src/package/container/dist/index.js +93 -0
  124. package/src/package/container/dist/index.mjs +59 -0
  125. package/src/package/font/dist/index.d.mts +25 -0
  126. package/src/package/font/dist/index.d.ts +25 -0
  127. package/src/package/font/dist/index.js +55 -0
  128. package/src/package/font/dist/index.mjs +28 -0
  129. package/src/package/head/dist/index.d.mts +6 -0
  130. package/src/package/head/dist/index.d.ts +6 -0
  131. package/src/package/head/dist/index.js +83 -0
  132. package/src/package/head/dist/index.mjs +49 -0
  133. package/src/package/heading/dist/index.d.mts +43 -0
  134. package/src/package/heading/dist/index.d.ts +43 -0
  135. package/src/package/heading/dist/index.js +113 -0
  136. package/src/package/heading/dist/index.mjs +79 -0
  137. package/src/package/hr/dist/index.d.mts +6 -0
  138. package/src/package/hr/dist/index.d.ts +6 -0
  139. package/src/package/hr/dist/index.js +89 -0
  140. package/src/package/hr/dist/index.mjs +55 -0
  141. package/src/package/html/dist/index.d.mts +6 -0
  142. package/src/package/html/dist/index.d.ts +6 -0
  143. package/src/package/html/dist/index.js +79 -0
  144. package/src/package/html/dist/index.mjs +45 -0
  145. package/src/package/img/dist/index.d.mts +6 -0
  146. package/src/package/img/dist/index.d.ts +6 -0
  147. package/src/package/img/dist/index.js +94 -0
  148. package/src/package/img/dist/index.mjs +60 -0
  149. package/src/package/link/dist/index.d.mts +6 -0
  150. package/src/package/link/dist/index.d.ts +6 -0
  151. package/src/package/link/dist/index.js +90 -0
  152. package/src/package/link/dist/index.mjs +56 -0
  153. package/src/package/markdown/dist/index.d.mts +15 -0
  154. package/src/package/markdown/dist/index.d.ts +15 -0
  155. package/src/package/markdown/dist/index.js +92 -0
  156. package/src/package/markdown/dist/index.mjs +58 -0
  157. package/src/package/preview/dist/index.d.mts +12 -0
  158. package/src/package/preview/dist/index.d.ts +12 -0
  159. package/src/package/preview/dist/index.js +108 -0
  160. package/src/package/preview/dist/index.mjs +73 -0
  161. package/src/package/render/dist/browser/index.d.mts +24 -0
  162. package/src/package/render/dist/browser/index.d.ts +24 -0
  163. package/src/package/render/dist/browser/index.js +250 -0
  164. package/src/package/render/dist/browser/index.mjs +214 -0
  165. package/src/package/render/dist/index.d.mts +23 -0
  166. package/src/package/render/dist/index.d.ts +23 -0
  167. package/src/package/render/dist/index.js +768 -0
  168. package/src/package/render/dist/index.mjs +733 -0
  169. package/src/package/render/dist/node/index.d.mts +27 -0
  170. package/src/package/render/dist/node/index.d.ts +27 -0
  171. package/src/package/render/dist/node/index.js +212 -0
  172. package/src/package/render/dist/node/index.mjs +176 -0
  173. package/src/package/row/dist/index.d.mts +10 -0
  174. package/src/package/row/dist/index.d.ts +10 -0
  175. package/src/package/row/dist/index.js +93 -0
  176. package/src/package/row/dist/index.mjs +59 -0
  177. package/src/package/section/dist/index.d.mts +6 -0
  178. package/src/package/section/dist/index.d.ts +6 -0
  179. package/src/package/section/dist/index.js +93 -0
  180. package/src/package/section/dist/index.mjs +59 -0
  181. package/src/package/tailwind/dist/index.d.ts +19 -0
  182. package/src/package/tailwind/dist/index.js +48 -0
  183. package/src/package/tailwind/dist/index.mjs +17167 -0
  184. package/src/package/tailwind/dist/tailwindcss/config.d.ts +376 -0
  185. package/src/package/tailwind/dist/tailwindcss/generated/.gitkeep +0 -0
  186. package/src/package/tailwind/dist/tailwindcss/generated/colors.d.ts +298 -0
  187. package/src/package/tailwind/dist/tailwindcss/generated/corePluginList.d.ts +1 -0
  188. package/src/package/tailwind/dist/tailwindcss/generated/default-theme.d.ts +397 -0
  189. package/src/package/tailwind/dist/tailwindcss/index.d.ts +11 -0
  190. package/src/package/text/dist/index.d.mts +6 -0
  191. package/src/package/text/dist/index.d.ts +6 -0
  192. package/src/package/text/dist/index.js +89 -0
  193. package/src/package/text/dist/index.mjs +55 -0
  194. package/src/utils/types/hot-reload-event.ts +3 -6
  195. package/dist/preview/.next/cache/eslint/.cache_117y9un +0 -1
  196. package/dist/preview/.next/server/chunks/128.js +0 -7
  197. package/dist/preview/.next/server/chunks/176.js +0 -2
  198. package/dist/preview/.next/server/chunks/287.js +0 -4
  199. package/dist/preview/.next/server/chunks/303.js +0 -6
  200. package/dist/preview/.next/server/chunks/359.js +0 -10
  201. package/dist/preview/.next/server/chunks/6.js +0 -1
  202. package/dist/preview/.next/server/chunks/894.js +0 -4
  203. package/dist/preview/.next/server/chunks/font-manifest.json +0 -1
  204. package/dist/preview/.next/server/font-manifest.json +0 -1
  205. package/dist/preview/.next/static/9wK7iUJPUvFYJNYOqHNpo/_buildManifest.js +0 -1
  206. package/dist/preview/.next/static/chunks/121-c9990f9db62882f2.js +0 -2
  207. package/dist/preview/.next/static/chunks/262-1ec6780d76508af8.js +0 -1
  208. package/dist/preview/.next/static/chunks/599-b4e686757f7b900d.js +0 -1
  209. package/dist/preview/.next/static/chunks/732-2b6186d8c8624033.js +0 -1
  210. package/dist/preview/.next/static/chunks/783-41562adc25d0c844.js +0 -9
  211. package/dist/preview/.next/static/chunks/app/_not-found/page-02dfc5a8a0bd636e.js +0 -1
  212. package/dist/preview/.next/static/chunks/app/layout-62d01ca567f6fd12.js +0 -1
  213. package/dist/preview/.next/static/chunks/app/page-630c6c846e3efc69.js +0 -1
  214. package/dist/preview/.next/static/chunks/app/preview/[...slug]/page-6547e9f3ba86c271.js +0 -1
  215. package/dist/preview/.next/static/chunks/f38cb6f6-40e76da092bb0490.js +0 -1
  216. package/dist/preview/.next/static/chunks/framework-bef83a85c94ff7de.js +0 -1
  217. package/dist/preview/.next/static/chunks/main-app-6ed588927d8fd56c.js +0 -1
  218. package/dist/preview/.next/static/chunks/main-ee2ceeb6c8bf53ac.js +0 -1
  219. package/dist/preview/.next/static/chunks/pages/_app-02aac361ebb5625a.js +0 -1
  220. package/dist/preview/.next/static/chunks/pages/_error-52f603c388364756.js +0 -1
  221. package/dist/preview/.next/static/chunks/polyfills-78c92fac7aa8fdd8.js +0 -1
  222. package/dist/preview/.next/static/chunks/webpack-cf1ab84f284a4073.js +0 -1
  223. package/dist/preview/.next/static/css/0a13d10225a26b9d.css +0 -1
  224. /package/dist/preview/.next/static/{9wK7iUJPUvFYJNYOqHNpo → 6K68y2QEZ1dLbv-Xhi30p}/_ssgManifest.js +0 -0
@@ -1,9 +1,13 @@
1
- // File: /home/gabriel/Projects/Resend/react-email.git/primary/packages/react-email/src/app/layout.tsx
1
+ // File: /home/gabriel/Projects/resend/react-email/packages/react-email/src/app/layout.tsx
2
2
  import * as entry from '../../../src/app/layout.js'
3
3
  import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'
4
4
 
5
5
  type TEntry = typeof import('../../../src/app/layout.js')
6
6
 
7
+ type SegmentParams<T extends Object = any> = T extends Record<string, any>
8
+ ? { [K in keyof T]: T[K] extends string ? string | string[] | undefined : never }
9
+ : T
10
+
7
11
  // Check that the entry is a valid entry
8
12
  checkFields<Diff<{
9
13
  default: Function
@@ -21,9 +25,11 @@ checkFields<Diff<{
21
25
  generateMetadata?: Function
22
26
  viewport?: any
23
27
  generateViewport?: Function
28
+ experimental_ppr?: boolean
24
29
 
25
30
  }, TEntry, ''>>()
26
31
 
32
+
27
33
  // Check the prop type of the entry function
28
34
  checkFields<Diff<LayoutProps, FirstArg<TEntry['default']>, 'default'>>()
29
35
 
@@ -41,19 +47,18 @@ if ('generateViewport' in entry) {
41
47
 
42
48
  // Check the arguments and return type of the generateStaticParams function
43
49
  if ('generateStaticParams' in entry) {
44
- checkFields<Diff<{ params: PageParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
50
+ checkFields<Diff<{ params: SegmentParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
45
51
  checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()
46
52
  }
47
53
 
48
- type PageParams = any
49
54
  export interface PageProps {
50
- params?: any
51
- searchParams?: any
55
+ params?: Promise<SegmentParams>
56
+ searchParams?: Promise<any>
52
57
  }
53
58
  export interface LayoutProps {
54
59
  children?: React.ReactNode
55
60
 
56
- params?: any
61
+ params?: Promise<SegmentParams>
57
62
  }
58
63
 
59
64
  // =============
@@ -1,9 +1,13 @@
1
- // File: /home/gabriel/Projects/Resend/react-email.git/primary/packages/react-email/src/app/preview/[...slug]/page.tsx
1
+ // File: /home/gabriel/Projects/resend/react-email/packages/react-email/src/app/preview/[...slug]/page.tsx
2
2
  import * as entry from '../../../../../src/app/preview/[...slug]/page.js'
3
3
  import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'
4
4
 
5
5
  type TEntry = typeof import('../../../../../src/app/preview/[...slug]/page.js')
6
6
 
7
+ type SegmentParams<T extends Object = any> = T extends Record<string, any>
8
+ ? { [K in keyof T]: T[K] extends string ? string | string[] | undefined : never }
9
+ : T
10
+
7
11
  // Check that the entry is a valid entry
8
12
  checkFields<Diff<{
9
13
  default: Function
@@ -21,9 +25,11 @@ checkFields<Diff<{
21
25
  generateMetadata?: Function
22
26
  viewport?: any
23
27
  generateViewport?: Function
28
+ experimental_ppr?: boolean
24
29
 
25
30
  }, TEntry, ''>>()
26
31
 
32
+
27
33
  // Check the prop type of the entry function
28
34
  checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
29
35
 
@@ -41,19 +47,18 @@ if ('generateViewport' in entry) {
41
47
 
42
48
  // Check the arguments and return type of the generateStaticParams function
43
49
  if ('generateStaticParams' in entry) {
44
- checkFields<Diff<{ params: PageParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
50
+ checkFields<Diff<{ params: SegmentParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()
45
51
  checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()
46
52
  }
47
53
 
48
- type PageParams = any
49
54
  export interface PageProps {
50
- params?: any
51
- searchParams?: any
55
+ params?: Promise<SegmentParams>
56
+ searchParams?: Promise<any>
52
57
  }
53
58
  export interface LayoutProps {
54
59
  children?: React.ReactNode
55
60
 
56
- params?: any
61
+ params?: Promise<SegmentParams>
57
62
  }
58
63
 
59
64
  // =============
@@ -0,0 +1,141 @@
1
+ // Type definitions for Next.js cacheLife configs
2
+
3
+ declare module 'next/cache' {
4
+ export { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache'
5
+ export {
6
+ revalidateTag,
7
+ revalidatePath,
8
+ unstable_expireTag,
9
+ unstable_expirePath,
10
+ } from 'next/dist/server/web/spec-extension/revalidate'
11
+ export { unstable_noStore } from 'next/dist/server/web/spec-extension/unstable-no-store'
12
+
13
+
14
+ /**
15
+ * Cache this `"use cache"` for a timespan defined by the `"default"` profile.
16
+ * ```
17
+ * stale: 300 seconds (5 minutes)
18
+ * revalidate: 900 seconds (15 minutes)
19
+ * expire: never
20
+ * ```
21
+ *
22
+ * This cache may be stale on clients for 5 minutes before checking with the server.
23
+ * If the server receives a new request after 15 minutes, start revalidating new values in the background.
24
+ * It lives for the maximum age of the server cache. If this entry has no traffic for a while, it may serve an old value the next request.
25
+ */
26
+ export function unstable_cacheLife(profile: "default"): void
27
+
28
+ /**
29
+ * Cache this `"use cache"` for a timespan defined by the `"seconds"` profile.
30
+ * ```
31
+ * stale: 0 seconds
32
+ * revalidate: 1 seconds
33
+ * expire: 60 seconds (1 minute)
34
+ * ```
35
+ *
36
+ * This cache may be stale on clients for 0 seconds before checking with the server.
37
+ * If the server receives a new request after 1 seconds, start revalidating new values in the background.
38
+ * If this entry has no traffic for 1 minute it will expire. The next request will recompute it.
39
+ */
40
+ export function unstable_cacheLife(profile: "seconds"): void
41
+
42
+ /**
43
+ * Cache this `"use cache"` for a timespan defined by the `"minutes"` profile.
44
+ * ```
45
+ * stale: 300 seconds (5 minutes)
46
+ * revalidate: 60 seconds (1 minute)
47
+ * expire: 3600 seconds (1 hour)
48
+ * ```
49
+ *
50
+ * This cache may be stale on clients for 5 minutes before checking with the server.
51
+ * If the server receives a new request after 1 minute, start revalidating new values in the background.
52
+ * If this entry has no traffic for 1 hour it will expire. The next request will recompute it.
53
+ */
54
+ export function unstable_cacheLife(profile: "minutes"): void
55
+
56
+ /**
57
+ * Cache this `"use cache"` for a timespan defined by the `"hours"` profile.
58
+ * ```
59
+ * stale: 300 seconds (5 minutes)
60
+ * revalidate: 3600 seconds (1 hour)
61
+ * expire: 86400 seconds (1 day)
62
+ * ```
63
+ *
64
+ * This cache may be stale on clients for 5 minutes before checking with the server.
65
+ * If the server receives a new request after 1 hour, start revalidating new values in the background.
66
+ * If this entry has no traffic for 1 day it will expire. The next request will recompute it.
67
+ */
68
+ export function unstable_cacheLife(profile: "hours"): void
69
+
70
+ /**
71
+ * Cache this `"use cache"` for a timespan defined by the `"days"` profile.
72
+ * ```
73
+ * stale: 300 seconds (5 minutes)
74
+ * revalidate: 86400 seconds (1 day)
75
+ * expire: 604800 seconds (1 week)
76
+ * ```
77
+ *
78
+ * This cache may be stale on clients for 5 minutes before checking with the server.
79
+ * If the server receives a new request after 1 day, start revalidating new values in the background.
80
+ * If this entry has no traffic for 1 week it will expire. The next request will recompute it.
81
+ */
82
+ export function unstable_cacheLife(profile: "days"): void
83
+
84
+ /**
85
+ * Cache this `"use cache"` for a timespan defined by the `"weeks"` profile.
86
+ * ```
87
+ * stale: 300 seconds (5 minutes)
88
+ * revalidate: 604800 seconds (1 week)
89
+ * expire: 2592000 seconds (30 days)
90
+ * ```
91
+ *
92
+ * This cache may be stale on clients for 5 minutes before checking with the server.
93
+ * If the server receives a new request after 1 week, start revalidating new values in the background.
94
+ * If this entry has no traffic for 30 days it will expire. The next request will recompute it.
95
+ */
96
+ export function unstable_cacheLife(profile: "weeks"): void
97
+
98
+ /**
99
+ * Cache this `"use cache"` for a timespan defined by the `"max"` profile.
100
+ * ```
101
+ * stale: 300 seconds (5 minutes)
102
+ * revalidate: 2592000 seconds (30 days)
103
+ * expire: never
104
+ * ```
105
+ *
106
+ * This cache may be stale on clients for 5 minutes before checking with the server.
107
+ * If the server receives a new request after 30 days, start revalidating new values in the background.
108
+ * It lives for the maximum age of the server cache. If this entry has no traffic for a while, it may serve an old value the next request.
109
+ */
110
+ export function unstable_cacheLife(profile: "max"): void
111
+
112
+ /**
113
+ * Cache this `"use cache"` using a custom timespan.
114
+ * ```
115
+ * stale: ... // seconds
116
+ * revalidate: ... // seconds
117
+ * expire: ... // seconds
118
+ * ```
119
+ *
120
+ * This is similar to Cache-Control: max-age=`stale`,s-max-age=`revalidate`,stale-while-revalidate=`expire-revalidate`
121
+ *
122
+ * If a value is left out, the lowest of other cacheLife() calls or the default, is used instead.
123
+ */
124
+ export function unstable_cacheLife(profile: {
125
+ /**
126
+ * This cache may be stale on clients for ... seconds before checking with the server.
127
+ */
128
+ stale?: number,
129
+ /**
130
+ * If the server receives a new request after ... seconds, start revalidating new values in the background.
131
+ */
132
+ revalidate?: number,
133
+ /**
134
+ * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.
135
+ */
136
+ expire?: number
137
+ }): void
138
+
139
+
140
+ export { cacheTag as unstable_cacheTag } from 'next/dist/server/use-cache/cache-tag'
141
+ }
package/next-env.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  /// <reference types="next/image-types/global" />
3
3
 
4
4
  // NOTE: This file should not be edited
5
- // see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/cli/index.js"
@@ -22,14 +22,14 @@
22
22
  "@babel/core": "7.24.5",
23
23
  "@babel/parser": "7.24.5",
24
24
  "chalk": "4.1.2",
25
- "chokidar": "^4.0.1",
25
+ "chokidar": "4.0.3",
26
26
  "commander": "11.1.0",
27
27
  "debounce": "2.0.0",
28
28
  "esbuild": "0.19.11",
29
29
  "glob": "10.3.4",
30
30
  "log-symbols": "4.1.0",
31
31
  "mime-types": "2.1.35",
32
- "next": "14.2.16",
32
+ "next": "15.1.2",
33
33
  "normalize-path": "3.0.0",
34
34
  "ora": "5.4.1",
35
35
  "socket.io": "4.8.0"
@@ -45,25 +45,25 @@
45
45
  "@types/babel__core": "7.20.5",
46
46
  "@types/fs-extra": "11.0.1",
47
47
  "@types/mime-types": "2.1.4",
48
- "@types/node": "18.0.0",
48
+ "@types/node": "22.10.2",
49
49
  "@types/normalize-path": "3.0.2",
50
- "@types/react": "^18.2.0",
51
- "@types/react-dom": "^18.2.0",
50
+ "@types/react": "^19",
51
+ "@types/react-dom": "^19",
52
52
  "@types/webpack": "5.28.5",
53
53
  "@vercel/style-guide": "5.1.0",
54
- "autoprefixer": "10.4.14",
54
+ "autoprefixer": "10.4.20",
55
55
  "clsx": "2.1.0",
56
56
  "eslint": "8.50.0",
57
57
  "eslint-config-prettier": "9.0.0",
58
58
  "eslint-config-turbo": "2.1.0",
59
- "framer-motion": "12.0.0-alpha.0",
59
+ "framer-motion": "12.0.0-alpha.2",
60
60
  "postcss": "8.4.40",
61
61
  "prism-react-renderer": "2.1.0",
62
- "react": "18.3.1",
63
- "react-dom": "18.3.1",
62
+ "react": "^19",
63
+ "react-dom": "^19",
64
64
  "sharp": "0.33.3",
65
65
  "socket.io-client": "4.8.0",
66
- "sonner": "1.3.1",
66
+ "sonner": "1.7.1",
67
67
  "source-map-js": "1.0.2",
68
68
  "stacktrace-parser": "0.1.10",
69
69
  "tailwind-merge": "2.2.0",
@@ -72,7 +72,7 @@
72
72
  "tsx": "4.9.0",
73
73
  "typescript": "5.1.6",
74
74
  "vitest": "1.1.3",
75
- "@react-email/render": "1.0.3"
75
+ "@react-email/render": "1.0.4"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsup-node && node build-preview-server.mjs",
@@ -1,10 +1,11 @@
1
1
  'use server';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
+ import { cache } from 'react';
4
5
  import { emailsDirectoryAbsolutePath } from '../utils/emails-directory-absolute-path';
5
6
 
6
7
  // eslint-disable-next-line @typescript-eslint/require-await
7
- export const getEmailPathFromSlug = async (slug: string) => {
8
+ export const getEmailPathFromSlug = cache(async (slug: string) => {
8
9
  if (['.tsx', '.jsx', '.ts', '.js'].includes(path.extname(slug)))
9
10
  return path.join(emailsDirectoryAbsolutePath, slug);
10
11
 
@@ -25,4 +26,4 @@ export const getEmailPathFromSlug = async (slug: string) => {
25
26
 
26
27
  This is most likely not an issue with the preview server. It most likely is that the email doesn't exist.`,
27
28
  );
28
- };
29
+ });
@@ -44,6 +44,7 @@ test('getEmailsDirectoryMetadata on demo emails', async () => {
44
44
  relativePath: 'notifications',
45
45
  emailFilenames: [
46
46
  'github-access-token',
47
+ 'papermark-year-in-review',
47
48
  'vercel-invite-user',
48
49
  'yelp-recent-login',
49
50
  ],
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
+ import { cache } from 'react';
5
6
 
6
7
  const isFileAnEmail = (fullPath: string): boolean => {
7
8
  const stat = fs.statSync(fullPath);
@@ -57,64 +58,66 @@ const mergeDirectoriesWithSubDirectories = (
57
58
  return currentResultingMergedDirectory;
58
59
  };
59
60
 
60
- export const getEmailsDirectoryMetadata = async (
61
- absolutePathToEmailsDirectory: string,
62
- keepFileExtensions = false,
63
- isSubDirectory = false,
64
-
65
- baseDirectoryPath = absolutePathToEmailsDirectory,
66
- ): Promise<EmailsDirectory | undefined> => {
67
- if (!fs.existsSync(absolutePathToEmailsDirectory)) return;
68
-
69
- const dirents = await fs.promises.readdir(absolutePathToEmailsDirectory, {
70
- withFileTypes: true,
71
- });
72
-
73
- const emailFilenames = dirents
74
- .filter((dirent) =>
75
- isFileAnEmail(path.join(absolutePathToEmailsDirectory, dirent.name)),
76
- )
77
- .map((dirent) =>
78
- keepFileExtensions
79
- ? dirent.name
80
- : dirent.name.replace(path.extname(dirent.name), ''),
81
- );
61
+ export const getEmailsDirectoryMetadata = cache(
62
+ async (
63
+ absolutePathToEmailsDirectory: string,
64
+ keepFileExtensions = false,
65
+ isSubDirectory = false,
66
+
67
+ baseDirectoryPath = absolutePathToEmailsDirectory,
68
+ ): Promise<EmailsDirectory | undefined> => {
69
+ if (!fs.existsSync(absolutePathToEmailsDirectory)) return;
82
70
 
83
- const subDirectories = await Promise.all(
84
- dirents
85
- .filter(
86
- (dirent) =>
87
- dirent.isDirectory() &&
88
- !dirent.name.startsWith('_') &&
89
- dirent.name !== 'static',
71
+ const dirents = await fs.promises.readdir(absolutePathToEmailsDirectory, {
72
+ withFileTypes: true,
73
+ });
74
+
75
+ const emailFilenames = dirents
76
+ .filter((dirent) =>
77
+ isFileAnEmail(path.join(absolutePathToEmailsDirectory, dirent.name)),
90
78
  )
91
- .map((dirent) => {
92
- const direntAbsolutePath = path.join(
93
- absolutePathToEmailsDirectory,
94
- dirent.name,
95
- );
96
-
97
- return getEmailsDirectoryMetadata(
98
- direntAbsolutePath,
99
- keepFileExtensions,
100
- true,
101
- baseDirectoryPath,
102
- ) as Promise<EmailsDirectory>;
103
- }),
104
- );
105
-
106
- const emailsMetadata = {
107
- absolutePath: absolutePathToEmailsDirectory,
108
- relativePath: path.relative(
109
- baseDirectoryPath,
110
- absolutePathToEmailsDirectory,
111
- ),
112
- directoryName: absolutePathToEmailsDirectory.split(path.sep).pop()!,
113
- emailFilenames,
114
- subDirectories,
115
- } satisfies EmailsDirectory;
116
-
117
- return isSubDirectory
118
- ? mergeDirectoriesWithSubDirectories(emailsMetadata)
119
- : emailsMetadata;
120
- };
79
+ .map((dirent) =>
80
+ keepFileExtensions
81
+ ? dirent.name
82
+ : dirent.name.replace(path.extname(dirent.name), ''),
83
+ );
84
+
85
+ const subDirectories = await Promise.all(
86
+ dirents
87
+ .filter(
88
+ (dirent) =>
89
+ dirent.isDirectory() &&
90
+ !dirent.name.startsWith('_') &&
91
+ dirent.name !== 'static',
92
+ )
93
+ .map((dirent) => {
94
+ const direntAbsolutePath = path.join(
95
+ absolutePathToEmailsDirectory,
96
+ dirent.name,
97
+ );
98
+
99
+ return getEmailsDirectoryMetadata(
100
+ direntAbsolutePath,
101
+ keepFileExtensions,
102
+ true,
103
+ baseDirectoryPath,
104
+ ) as Promise<EmailsDirectory>;
105
+ }),
106
+ );
107
+
108
+ const emailsMetadata = {
109
+ absolutePath: absolutePathToEmailsDirectory,
110
+ relativePath: path.relative(
111
+ baseDirectoryPath,
112
+ absolutePathToEmailsDirectory,
113
+ ),
114
+ directoryName: absolutePathToEmailsDirectory.split(path.sep).pop()!,
115
+ emailFilenames,
116
+ subDirectories,
117
+ } satisfies EmailsDirectory;
118
+
119
+ return isSubDirectory
120
+ ? mergeDirectoriesWithSubDirectories(emailsMetadata)
121
+ : emailsMetadata;
122
+ },
123
+ );
@@ -21,9 +21,16 @@ export type EmailRenderingResult =
21
21
  error: ErrorObject;
22
22
  };
23
23
 
24
+ const cache = new Map<string, EmailRenderingResult>();
25
+
24
26
  export const renderEmailByPath = async (
25
27
  emailPath: string,
28
+ invalidatingCache = false,
26
29
  ): Promise<EmailRenderingResult> => {
30
+ if (invalidatingCache) cache.delete(emailPath);
31
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
32
+ if (cache.has(emailPath)) return cache.get(emailPath)!;
33
+
27
34
  const timeBeforeEmailRendered = performance.now();
28
35
 
29
36
  const emailFilename = path.basename(emailPath);
@@ -36,14 +43,14 @@ export const renderEmailByPath = async (
36
43
  registerSpinnerAutostopping(spinner);
37
44
  }
38
45
 
39
- const result = await getEmailComponent(emailPath);
46
+ const componentResult = await getEmailComponent(emailPath);
40
47
 
41
- if ('error' in result) {
48
+ if ('error' in componentResult) {
42
49
  spinner?.stopAndPersist({
43
50
  symbol: logSymbols.error,
44
51
  text: `Failed while rendering ${emailFilename}`,
45
52
  });
46
- return { error: result.error };
53
+ return { error: componentResult.error };
47
54
  }
48
55
 
49
56
  const {
@@ -51,7 +58,7 @@ export const renderEmailByPath = async (
51
58
  createElement,
52
59
  render,
53
60
  sourceMapToOriginalFile,
54
- } = result;
61
+ } = componentResult;
55
62
 
56
63
  const previewProps = Email.PreviewProps || {};
57
64
  const EmailComponent = Email as React.FC;
@@ -82,7 +89,7 @@ export const renderEmailByPath = async (
82
89
  text: `Successfully rendered ${emailFilename} in ${timeForConsole}`,
83
90
  });
84
91
 
85
- return {
92
+ const renderingResult = {
86
93
  // This ensures that no null byte character ends up in the rendered
87
94
  // markup making users suspect of any issues. These null byte characters
88
95
  // only seem to happen with React 18, as it has no similar incident with React 19.
@@ -90,6 +97,10 @@ export const renderEmailByPath = async (
90
97
  plainText,
91
98
  reactMarkup,
92
99
  };
100
+
101
+ cache.set(emailPath, renderingResult);
102
+
103
+ return renderingResult;
93
104
  } catch (exception) {
94
105
  const error = exception as Error;
95
106
 
@@ -16,7 +16,12 @@ export interface PreviewParams {
16
16
  slug: string[];
17
17
  }
18
18
 
19
- const Page = async ({ params }: { params: PreviewParams }) => {
19
+ const Page = async ({
20
+ params: paramsPromise,
21
+ }: {
22
+ params: Promise<PreviewParams>;
23
+ }) => {
24
+ const params = await paramsPromise;
20
25
  // will come in here as segments of a relative path to the email
21
26
  // ex: ['authentication', 'verify-password.tsx']
22
27
  const slug = decodeURIComponent(params.slug.join('/'));
@@ -43,14 +48,14 @@ This is most likely not an issue with the preview server. Maybe there was a typo
43
48
  throw exception;
44
49
  }
45
50
 
46
- const emailRenderingResult = await renderEmailByPath(emailPath);
51
+ const serverEmailRenderingResult = await renderEmailByPath(emailPath);
47
52
 
48
53
  if (
49
- 'error' in emailRenderingResult &&
50
- process.env.NEXT_PUBLIC_IS_BUILDING === 'true'
54
+ process.env.NEXT_PUBLIC_IS_BUILDING === 'true' &&
55
+ 'error' in serverEmailRenderingResult
51
56
  ) {
52
- throw new Error(emailRenderingResult.error.message, {
53
- cause: emailRenderingResult.error,
57
+ throw new Error(serverEmailRenderingResult.error.message, {
58
+ cause: serverEmailRenderingResult.error,
54
59
  });
55
60
  }
56
61
 
@@ -62,15 +67,20 @@ This is most likely not an issue with the preview server. Maybe there was a typo
62
67
  <Preview
63
68
  emailPath={emailPath}
64
69
  pathSeparator={path.sep}
65
- renderingResult={emailRenderingResult}
70
+ serverRenderingResult={serverEmailRenderingResult}
66
71
  slug={slug}
67
72
  />
68
73
  </Suspense>
69
74
  );
70
75
  };
71
76
 
72
- export function generateMetadata({ params }: { params: PreviewParams }) {
73
- return { title: `${path.basename(params.slug.join('/'))} — React Email` };
77
+ export async function generateMetadata({
78
+ params,
79
+ }: {
80
+ params: Promise<PreviewParams>;
81
+ }) {
82
+ const { slug } = await params;
83
+ return { title: `${path.basename(slug.join('/'))} — React Email` };
74
84
  }
75
85
 
76
86
  export default Page;
@@ -8,22 +8,22 @@ import type { EmailRenderingResult } from '../../../actions/render-email-by-path
8
8
  import { CodeContainer } from '../../../components/code-container';
9
9
  import { Shell } from '../../../components/shell';
10
10
  import { Tooltip } from '../../../components/tooltip';
11
- import { useEmails } from '../../../contexts/emails';
12
11
  import { useRenderingMetadata } from '../../../hooks/use-rendering-metadata';
12
+ import { useEmailRenderingResult } from '../../../hooks/use-email-rendering-result';
13
13
  import { RenderingError } from './rendering-error';
14
14
 
15
15
  interface PreviewProps {
16
16
  slug: string;
17
17
  emailPath: string;
18
18
  pathSeparator: string;
19
- renderingResult: EmailRenderingResult;
19
+ serverRenderingResult: EmailRenderingResult;
20
20
  }
21
21
 
22
22
  const Preview = ({
23
23
  slug,
24
24
  emailPath,
25
25
  pathSeparator,
26
- renderingResult: initialRenderingResult,
26
+ serverRenderingResult,
27
27
  }: PreviewProps) => {
28
28
  const router = useRouter();
29
29
  const pathname = usePathname();
@@ -31,17 +31,16 @@ const Preview = ({
31
31
 
32
32
  const activeView = searchParams.get('view') ?? 'desktop';
33
33
  const activeLang = searchParams.get('lang') ?? 'jsx';
34
- const { useEmailRenderingResult } = useEmails();
35
34
 
36
35
  const renderingResult = useEmailRenderingResult(
37
36
  emailPath,
38
- initialRenderingResult,
37
+ serverRenderingResult,
39
38
  );
40
39
 
41
40
  const renderedEmailMetadata = useRenderingMetadata(
42
41
  emailPath,
43
42
  renderingResult,
44
- initialRenderingResult,
43
+ serverRenderingResult,
45
44
  );
46
45
 
47
46
  if (process.env.NEXT_PUBLIC_IS_BUILDING !== 'true') {
@@ -90,7 +89,6 @@ const Preview = ({
90
89
  <RenderingError error={renderingResult.error} />
91
90
  ) : null}
92
91
 
93
- {/* If this is undefined means that the initial server render of the email had errors */}
94
92
  {hasNoErrors ? (
95
93
  <>
96
94
  {activeView === 'desktop' && (
@@ -135,6 +133,7 @@ const Preview = ({
135
133
  )}
136
134
  </>
137
135
  ) : null}
136
+
138
137
  <Toaster />
139
138
  </div>
140
139
  </Shell>