@visulima/email 1.0.0-alpha.34 → 1.0.0-alpha.35

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 (220) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +77 -0
  3. package/dist/crypto/index.d.ts +160 -3
  4. package/dist/crypto/index.js +1 -1
  5. package/dist/deliverability/dmarc-report.d.ts +95 -0
  6. package/dist/deliverability/dmarc-report.js +1 -0
  7. package/dist/deliverability/index.d.ts +360 -0
  8. package/dist/deliverability/index.js +1 -0
  9. package/dist/events/index.d.ts +31 -0
  10. package/dist/events/index.js +1 -0
  11. package/dist/inbound/index.d.ts +375 -0
  12. package/dist/inbound/index.js +1 -0
  13. package/dist/index.d.ts +11 -734
  14. package/dist/index.js +1 -1
  15. package/dist/middleware/index.d.ts +346 -0
  16. package/dist/middleware/index.js +1 -0
  17. package/dist/packem_shared/ALL_EVENTS-A0nTVOo0.js +1 -0
  18. package/dist/packem_shared/DkimSigner-dKZ45Csc.js +18 -0
  19. package/dist/packem_shared/Mail-B2QII2P9.js +1 -0
  20. package/dist/packem_shared/{MailMessage-BvaH5tZZ.js → MailMessage-DB1zaWfM.js} +1 -1
  21. package/dist/packem_shared/MemoryEventStore-BEKPxa-I.js +1 -0
  22. package/dist/packem_shared/MemoryQueue-C-CtRRG7.js +1 -0
  23. package/dist/packem_shared/MemorySuppressionStore-BKY1FrA1.js +1 -0
  24. package/dist/packem_shared/RATE_LIMIT_PRESETS-DQF78mdO.js +1 -0
  25. package/dist/packem_shared/{SmimeEncrypter-ZhHEgDwY.js → SmimeEncrypter-BirIsrip.js} +2 -2
  26. package/dist/packem_shared/{SmimeSigner-CYSVF6ez.js → SmimeSigner-CkyaShTs.js} +2 -2
  27. package/dist/packem_shared/addDarkModeSupport-Ys9U2-GH.js +1 -0
  28. package/dist/packem_shared/address-formatter-CnPg51_n.js +1 -0
  29. package/dist/packem_shared/ahaSendProvider-yuqYMW0n.js +1 -0
  30. package/dist/packem_shared/arcMessageSignatureBase-Cpdnv-H8.js +17 -0
  31. package/dist/packem_shared/attachment-processor-CFUC3V45.js +1 -0
  32. package/dist/packem_shared/azureProvider-CK_Wuw4r.js +1 -0
  33. package/dist/packem_shared/brevoProvider-CNwuzzBA.js +1 -0
  34. package/dist/packem_shared/build-mime-message-D8WEZejb.js +3 -0
  35. package/dist/packem_shared/buildListUnsubscribe-CIbz0rtk.js +1 -0
  36. package/dist/packem_shared/circuitBreakerMiddleware-B7DlzZSG.js +1 -0
  37. package/dist/packem_shared/cloudflareEmailProvider-C-G821Hg.js +1 -0
  38. package/dist/packem_shared/composeMiddleware-CkEhbDjL.js +1 -0
  39. package/dist/packem_shared/createTestEmail-hHdtgmUM.js +1 -0
  40. package/dist/packem_shared/createWorker-Nkc1GHet.js +1 -0
  41. package/dist/packem_shared/dedupeMiddleware-JeJbff46.js +1 -0
  42. package/dist/packem_shared/{detectMimeType-bo5oxfnt.js → detectMimeType-B4QMh7k8.js} +1 -1
  43. package/dist/packem_shared/emailMatchers-CLANeU71.js +1 -0
  44. package/dist/packem_shared/event-bus.d-DEl3w_EW.d.ts +104 -0
  45. package/dist/packem_shared/extractReply-CCWnNRWe.js +5 -0
  46. package/dist/packem_shared/filterSuppressed-DntqRV0q.js +1 -0
  47. package/dist/packem_shared/format-address-Cv6uWTS5.js +1 -0
  48. package/dist/packem_shared/infobipProvider-DdV62IAG.js +1 -0
  49. package/dist/packem_shared/injectPreheader-BxPjb0eJ.js +1 -0
  50. package/dist/packem_shared/inlineCss-BLaEi337.js +1 -0
  51. package/dist/packem_shared/isValidSigningCertUrl-CF_KuCAi.js +3 -0
  52. package/dist/packem_shared/loggingMiddleware-CyHzn37U.js +1 -0
  53. package/dist/packem_shared/loopsProvider-DSedSU3q.js +1 -0
  54. package/dist/packem_shared/mail.d-LmrdSngG.d.ts +861 -0
  55. package/dist/packem_shared/{mailCrabProvider-B7H6HwWu.js → mailCrabProvider-xSLhA1CY.js} +1 -1
  56. package/dist/packem_shared/mailPaceProvider-CWBIjvvJ.js +1 -0
  57. package/dist/packem_shared/mailchannelsProvider-zKcunGDQ.js +1 -0
  58. package/dist/packem_shared/mailerSendProvider-BEvPlBKB.js +1 -0
  59. package/dist/packem_shared/mailgunProvider-CfQAINTC.js +1 -0
  60. package/dist/packem_shared/mailjetProvider-DEfKptWc.js +1 -0
  61. package/dist/packem_shared/mailomatProvider-D5sHlxZh.js +1 -0
  62. package/dist/packem_shared/mailtrapProvider-DwgMKakk.js +1 -0
  63. package/dist/packem_shared/mandrillProvider-CdGjO3Td.js +1 -0
  64. package/dist/packem_shared/normalizeMessageId-B_9mXlh4.js +1 -0
  65. package/dist/packem_shared/oauth2Middleware-B1xz58iP.js +1 -0
  66. package/dist/packem_shared/parseAddress-CrYOac3K.js +1 -0
  67. package/dist/packem_shared/parseArfReport-CUHb8WVj.js +6 -0
  68. package/dist/packem_shared/parseCloudflareInbound-BGgH5u7M.js +1 -0
  69. package/dist/packem_shared/parseDmarcRecord-DjNqCMZc.js +1 -0
  70. package/dist/packem_shared/parseInbound-BP-gEjhh.js +1 -0
  71. package/dist/packem_shared/parseMailgunInbound-C3sZ1TiH.js +1 -0
  72. package/dist/packem_shared/parseMtaStsPolicy-rFOOVXXK.js +6 -0
  73. package/dist/packem_shared/parsePostmarkInbound-C0Ttfroo.js +1 -0
  74. package/dist/packem_shared/parseSendGridInbound-BkvaoYRl.js +4 -0
  75. package/dist/packem_shared/parseSesInbound-BFS--T8X.js +1 -0
  76. package/dist/packem_shared/parseTlsRptRecord-DnLwAWsk.js +1 -0
  77. package/dist/packem_shared/plunkProvider-BIhMU2b5.js +1 -0
  78. package/dist/packem_shared/postProcessHtml-C73e0b9H.js +1 -0
  79. package/dist/packem_shared/postalProvider-CmmbCZSi.js +1 -0
  80. package/dist/packem_shared/postmarkProvider-i9u0h26U.js +1 -0
  81. package/dist/packem_shared/provider-base-BpHE_uK8.js +1 -0
  82. package/dist/packem_shared/{provider.d-DcfYeGJJ.d.ts → provider.d-J-y6iogK.d.ts} +1 -1
  83. package/dist/packem_shared/{readFile-BAVMZg5e-C4whBIPd.js → readFile-BkNfutxp-BS8Q2183.js} +1 -1
  84. package/dist/packem_shared/resendProvider-BNduBn0w.js +1 -0
  85. package/dist/packem_shared/retry-UPd8F62N.js +1 -0
  86. package/dist/packem_shared/retryMiddleware-DHespsU2.js +1 -0
  87. package/dist/packem_shared/rewriteCidLinks-B-Sd5XHs.js +1 -0
  88. package/dist/packem_shared/scalewayProvider-8gb4sIOB.js +1 -0
  89. package/dist/packem_shared/sendGridProvider-CayLXvPO.js +1 -0
  90. package/dist/packem_shared/smtpProvider-DoXVsN4p.js +24 -0
  91. package/dist/packem_shared/sweegoProvider-C0g9Ajdn.js +1 -0
  92. package/dist/packem_shared/toEmailSnapshot-CYpMmnAA.js +1 -0
  93. package/dist/packem_shared/tracer.d-MU42G1jG.d.ts +494 -0
  94. package/dist/packem_shared/{types.d-CNnnk-Ya.d.ts → types.d-BId55FW2.d.ts} +6 -1
  95. package/dist/packem_shared/types.d-BMpI2UXj.d.ts +51 -0
  96. package/dist/packem_shared/types.d-CmoWvdZi.d.ts +61 -0
  97. package/dist/packem_shared/types.d-Mpu0HZoG.d.ts +24 -0
  98. package/dist/packem_shared/{types.d-wwpgA3to.d.ts → types.d-ejzh-xBP.d.ts} +6 -1
  99. package/dist/packem_shared/types.d-lcJZmwRK.d.ts +69 -0
  100. package/dist/packem_shared/utils-BwolsGlK.js +1 -0
  101. package/dist/packem_shared/verifyMailgunWebhook-Df7n2Quh.js +1 -0
  102. package/dist/packem_shared/verifyPostmarkWebhook-D_eXt_Lq.js +1 -0
  103. package/dist/packem_shared/verifySendGridWebhook-XOSj5yTe.js +1 -0
  104. package/dist/packem_shared/verifyStandardWebhook-DdUTlIVh.js +1 -0
  105. package/dist/packem_shared/withEvents-Q9bwpCFG.js +1 -0
  106. package/dist/packem_shared/withMetrics-BPs3Kdxn.js +1 -0
  107. package/dist/packem_shared/withRender-DQM2zbbI.js +1 -0
  108. package/dist/packem_shared/withSuppression-DfjV_tbI.js +1 -0
  109. package/dist/packem_shared/withTelemetry-CsQsv1DV.js +1 -0
  110. package/dist/packem_shared/zeptomailProvider-BIbHieGJ.js +1 -0
  111. package/dist/providers/ahasend/index.d.ts +3 -3
  112. package/dist/providers/ahasend/index.js +1 -1
  113. package/dist/providers/aws-ses/index.d.ts +3 -3
  114. package/dist/providers/azure/index.d.ts +3 -3
  115. package/dist/providers/azure/index.js +1 -1
  116. package/dist/providers/brevo/index.d.ts +3 -3
  117. package/dist/providers/brevo/index.js +1 -1
  118. package/dist/providers/cloudflare-email/index.d.ts +36 -0
  119. package/dist/providers/cloudflare-email/index.js +1 -0
  120. package/dist/providers/failover/index.d.ts +3 -3
  121. package/dist/providers/http/index.d.ts +3 -3
  122. package/dist/providers/infobip/index.d.ts +3 -3
  123. package/dist/providers/infobip/index.js +1 -1
  124. package/dist/providers/loops/index.d.ts +47 -0
  125. package/dist/providers/loops/index.js +1 -0
  126. package/dist/providers/mailchannels/index.d.ts +26 -0
  127. package/dist/providers/mailchannels/index.js +1 -0
  128. package/dist/providers/mailcrab/index.d.ts +3 -3
  129. package/dist/providers/mailcrab/index.js +1 -1
  130. package/dist/providers/mailersend/index.d.ts +3 -3
  131. package/dist/providers/mailersend/index.js +1 -1
  132. package/dist/providers/mailgun/index.d.ts +3 -3
  133. package/dist/providers/mailgun/index.js +1 -1
  134. package/dist/providers/mailjet/index.d.ts +3 -3
  135. package/dist/providers/mailjet/index.js +1 -1
  136. package/dist/providers/mailomat/index.d.ts +3 -3
  137. package/dist/providers/mailomat/index.js +1 -1
  138. package/dist/providers/mailpace/index.d.ts +3 -3
  139. package/dist/providers/mailpace/index.js +1 -1
  140. package/dist/providers/mailtrap/index.d.ts +3 -3
  141. package/dist/providers/mailtrap/index.js +1 -1
  142. package/dist/providers/mandrill/index.d.ts +3 -3
  143. package/dist/providers/mandrill/index.js +1 -1
  144. package/dist/providers/mock/index.d.ts +6 -53
  145. package/dist/providers/nodemailer/index.d.ts +3 -3
  146. package/dist/providers/opentelemetry/index.d.ts +3 -495
  147. package/dist/providers/plunk/index.d.ts +3 -3
  148. package/dist/providers/plunk/index.js +1 -1
  149. package/dist/providers/postal/index.d.ts +3 -3
  150. package/dist/providers/postal/index.js +1 -1
  151. package/dist/providers/postmark/index.d.ts +3 -3
  152. package/dist/providers/postmark/index.js +1 -1
  153. package/dist/providers/resend/index.d.ts +3 -3
  154. package/dist/providers/resend/index.js +1 -1
  155. package/dist/providers/roundrobin/index.d.ts +3 -3
  156. package/dist/providers/scaleway/index.d.ts +3 -3
  157. package/dist/providers/scaleway/index.js +1 -1
  158. package/dist/providers/sendgrid/index.d.ts +3 -3
  159. package/dist/providers/sendgrid/index.js +1 -1
  160. package/dist/providers/smtp/index.d.ts +3 -3
  161. package/dist/providers/smtp/index.js +1 -1
  162. package/dist/providers/sweego/index.d.ts +3 -3
  163. package/dist/providers/sweego/index.js +1 -1
  164. package/dist/providers/zeptomail/index.d.ts +3 -3
  165. package/dist/providers/zeptomail/index.js +1 -1
  166. package/dist/queue/bullmq-queue.d.ts +46 -0
  167. package/dist/queue/bullmq-queue.js +1 -0
  168. package/dist/queue/index.d.ts +148 -0
  169. package/dist/queue/index.js +1 -0
  170. package/dist/queue/pg-boss-queue.d.ts +41 -0
  171. package/dist/queue/pg-boss-queue.js +1 -0
  172. package/dist/queue/sqs-queue.d.ts +72 -0
  173. package/dist/queue/sqs-queue.js +1 -0
  174. package/dist/queue/unstorage-queue.d.ts +81 -0
  175. package/dist/queue/unstorage-queue.js +1 -0
  176. package/dist/render/index.d.ts +107 -0
  177. package/dist/render/index.js +1 -0
  178. package/dist/template-engines/i18n.d.ts +61 -0
  179. package/dist/template-engines/i18n.js +1 -0
  180. package/dist/template-engines/jsx-email.d.ts +11 -0
  181. package/dist/template-engines/jsx-email.js +1 -0
  182. package/dist/template-engines/liquid.d.ts +12 -0
  183. package/dist/template-engines/liquid.js +1 -0
  184. package/dist/test/index.d.ts +159 -0
  185. package/dist/test/index.js +1 -0
  186. package/dist/utils/format-email-address.d.ts +1 -1
  187. package/dist/utils/format-email-address.js +1 -1
  188. package/dist/utils/parse-address.d.ts +1 -1
  189. package/dist/utils/result.d.ts +49 -0
  190. package/dist/utils/result.js +1 -0
  191. package/dist/utils/validation/check-feature-support.d.ts +1 -1
  192. package/dist/webhooks/index.d.ts +231 -0
  193. package/dist/webhooks/index.js +1 -0
  194. package/package.json +115 -3
  195. package/dist/packem_shared/DkimSigner-CT2DSHD1.js +0 -18
  196. package/dist/packem_shared/Mail-BWSWWq6m.js +0 -1
  197. package/dist/packem_shared/address-formatter-Cm_E_ZMa.js +0 -1
  198. package/dist/packem_shared/ahaSendProvider-DOAAW65O.js +0 -1
  199. package/dist/packem_shared/attachment-processor-DsmIomKc.js +0 -1
  200. package/dist/packem_shared/azureProvider-EkNYKAiF.js +0 -1
  201. package/dist/packem_shared/brevoProvider-CkR4U4RD.js +0 -1
  202. package/dist/packem_shared/build-mime-message-6xstxaUV.js +0 -2
  203. package/dist/packem_shared/infobipProvider-BhTsWi7e.js +0 -1
  204. package/dist/packem_shared/mailPaceProvider-DRt6Z9Hr.js +0 -1
  205. package/dist/packem_shared/mailerSendProvider-Dx_iHInH.js +0 -1
  206. package/dist/packem_shared/mailgunProvider-ChkLGZZW.js +0 -1
  207. package/dist/packem_shared/mailjetProvider-BMRhNe6H.js +0 -1
  208. package/dist/packem_shared/mailomatProvider-CydV-JB6.js +0 -1
  209. package/dist/packem_shared/mailtrapProvider-CuAfJWDr.js +0 -1
  210. package/dist/packem_shared/mandrillProvider-BBeLbaw0.js +0 -1
  211. package/dist/packem_shared/plunkProvider-BQyjG6YT.js +0 -1
  212. package/dist/packem_shared/postalProvider-DPHQ620q.js +0 -1
  213. package/dist/packem_shared/postmarkProvider-bMTC2gdJ.js +0 -1
  214. package/dist/packem_shared/provider-base-Cmzx6BTO.js +0 -1
  215. package/dist/packem_shared/resendProvider-Cns1tvF5.js +0 -1
  216. package/dist/packem_shared/scalewayProvider-O1dHz7iJ.js +0 -1
  217. package/dist/packem_shared/sendGridProvider-DmywC-eT.js +0 -1
  218. package/dist/packem_shared/smtpProvider-Unjao_fn.js +0 -23
  219. package/dist/packem_shared/sweegoProvider-D086G6xG.js +0 -1
  220. package/dist/packem_shared/zeptomailProvider-DKKEpEsW.js +0 -1
@@ -0,0 +1,46 @@
1
+ import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-ejzh-xBP.js";
2
+ import { E as EnqueueOptions } from "../packem_shared/types.d-lcJZmwRK.js";
3
+ import 'node:buffer';
4
+ /**
5
+ * The subset of a [BullMQ](https://docs.bullmq.io/) `Queue` this adapter uses.
6
+ */
7
+ interface BullmqQueueLike {
8
+ add: (name: string, data: unknown, options?: {
9
+ delay?: number;
10
+ }) => Promise<{
11
+ id?: string;
12
+ }>;
13
+ }
14
+ /**
15
+ * A BullMQ job, narrowed to its `data` payload.
16
+ */
17
+ interface BullmqJobLike {
18
+ data: EmailOptions;
19
+ }
20
+ /**
21
+ * A BullMQ `Worker` processor that sends a job's message and resolves with the send result.
22
+ */
23
+ type BullmqProcessor = (job: BullmqJobLike) => Promise<EmailResult>;
24
+ /**
25
+ * Adds a message to a BullMQ queue.
26
+ *
27
+ * BullMQ is push-based — jobs are consumed by a BullMQ `Worker`, not the pull-based reserve/ack model
28
+ * of `EmailQueue`. Use this to enqueue and {@link createBullmqProcessor} to consume.
29
+ * @param queue A BullMQ `Queue` instance to add the job to (optional peer).
30
+ * @param message The email payload stored as the BullMQ job data.
31
+ * @param options Optional scheduling — `scheduledAt` maps to a BullMQ `delay`.
32
+ * @param jobName The name to enqueue the job under.
33
+ * @returns The id of the created BullMQ job.
34
+ */
35
+ declare const enqueueToBullmq: (queue: BullmqQueueLike, message: EmailOptions, options?: EnqueueOptions, jobName?: string) => Promise<string>;
36
+ /**
37
+ * Builds a BullMQ `Worker` processor that sends each job's message via the given send function.
38
+ *
39
+ * Pass it to `new Worker(queueName, createBullmqProcessor(mail.send.bind(mail)), { concurrency })`.
40
+ * BullMQ then handles concurrency, retries (via the job's `attempts`/`backoff`) and dead-lettering. A
41
+ * failed send throws so BullMQ records the attempt.
42
+ * @param send The send function — typically `mail.send.bind(mail)`.
43
+ * @returns A BullMQ processor function.
44
+ */
45
+ declare const createBullmqProcessor: (send: (message: EmailOptions) => Promise<Result<EmailResult>>) => BullmqProcessor;
46
+ export { BullmqJobLike, BullmqProcessor, BullmqQueueLike, createBullmqProcessor, enqueueToBullmq };
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var o=(a,r)=>c(a,"name",{value:r,configurable:!0});var n=Object.defineProperty,d=o((a,r)=>n(a,"name",{value:r,configurable:!0}),"i");const i=d(async(a,r,e={},l="email")=>{let t;if(e.scheduledAt!==void 0){const s=e.scheduledAt instanceof Date?e.scheduledAt.getTime():e.scheduledAt;t=Math.max(0,s-Date.now())}return(await a.add(l,r,t===void 0?void 0:{delay:t})).id??""},"enqueueToBullmq"),m=d(a=>async r=>{const e=await a(r.data);if(!e.success||!e.data)throw e.error instanceof Error?e.error:new Error("Email send failed");return e.data},"createBullmqProcessor");export{m as createBullmqProcessor,i as enqueueToBullmq};
@@ -0,0 +1,148 @@
1
+ import { E as EmailOptions, a as EmailResult, R as Result } from "../packem_shared/types.d-ejzh-xBP.js";
2
+ import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-lcJZmwRK.js";
3
+ export { UnstorageQueue, type UnstorageQueueOptions, createUnstorageQueue } from "./unstorage-queue.js";
4
+ import 'node:buffer';
5
+ import 'unstorage';
6
+ /**
7
+ * Options for {@link MemoryQueue}.
8
+ */
9
+ interface MemoryQueueOptions {
10
+ /**
11
+ * Time source in milliseconds — injectable for tests. Defaults to `Date.now`.
12
+ */
13
+ now?: () => number;
14
+ /**
15
+ * How long, in milliseconds, a reserved job stays hidden before it becomes deliverable again
16
+ * (in case the worker crashed mid-process).
17
+ * @default 30000
18
+ */
19
+ visibilityTimeout?: number;
20
+ }
21
+ /**
22
+ * An in-memory {@link EmailQueue} with `scheduledAt` support and a reservation visibility timeout.
23
+ *
24
+ * Suitable for tests, single-process apps, and as a reference for adapter authors. Jobs do not survive
25
+ * a process restart — use a durable adapter in production.
26
+ */
27
+ declare class MemoryQueue implements EmailQueue {
28
+ private readonly jobs;
29
+ private readonly visibilityTimeout;
30
+ private readonly now;
31
+ private sequence;
32
+ /**
33
+ * @param options Queue options. See {@link MemoryQueueOptions}.
34
+ */
35
+ constructor(options?: MemoryQueueOptions);
36
+ /**
37
+ * Adds a message to the queue.
38
+ * @param message The message to send later.
39
+ * @param options Optional scheduling. See {@link EnqueueOptions}.
40
+ * @returns The new job id.
41
+ */
42
+ enqueue(message: EmailOptions, options?: EnqueueOptions): string;
43
+ /**
44
+ * Reserves the next ready job, hiding it for the visibility window.
45
+ * @returns The next deliverable job, or `undefined` when none is ready.
46
+ */
47
+ reserve(): QueueJob | undefined;
48
+ /**
49
+ * Marks a reserved job as processed and removes it.
50
+ * @param id The job id.
51
+ */
52
+ ack(id: string): void;
53
+ /**
54
+ * Returns a job to the queue after a delay, incrementing its attempt count.
55
+ * @param id The job id.
56
+ * @param delayMs Milliseconds to wait before the job becomes ready again.
57
+ */
58
+ retry(id: string, delayMs?: number): void;
59
+ /**
60
+ * Reports how many jobs remain (ready plus reserved).
61
+ * @returns The count of ready and reserved jobs.
62
+ */
63
+ size(): number;
64
+ }
65
+ /**
66
+ * Options for {@link createWorker}.
67
+ */
68
+ interface WorkerOptions {
69
+ /**
70
+ * Retry backoff: returns the delay (ms) before re-attempting after `attempts` failures.
71
+ * @default attempts => 1000 * 2 ** (attempts - 1)
72
+ */
73
+ backoff?: (attempts: number) => number;
74
+ /**
75
+ * How many jobs to process concurrently.
76
+ * @default 1
77
+ */
78
+ concurrency?: number;
79
+ /**
80
+ * Maximum delivery attempts before a job is dead-lettered.
81
+ * @default 3
82
+ */
83
+ maxAttempts?: number;
84
+ /**
85
+ * Called when a job exhausts its attempts and is dropped.
86
+ * @param job The dead-lettered job.
87
+ * @param result The final failed result.
88
+ */
89
+ onDeadLetter?: (job: QueueJob, result: Result<EmailResult>) => void;
90
+ /**
91
+ * Called on every failed attempt (before any retry).
92
+ * @param job The job that failed.
93
+ * @param result The failed result (or thrown error wrapped).
94
+ */
95
+ onError?: (job: QueueJob, result: Result<EmailResult>) => void;
96
+ /**
97
+ * Called when `queue.reserve()` itself rejects (e.g. a transient store error). The poll loop keeps
98
+ * running regardless; this hook just surfaces the failure.
99
+ * @param error The reserve error.
100
+ */
101
+ onReserveError?: (error: Error) => void;
102
+ /**
103
+ * Idle poll interval, in milliseconds, when no job is ready.
104
+ * @default 1000
105
+ */
106
+ pollInterval?: number;
107
+ /**
108
+ * The queue to consume.
109
+ */
110
+ queue: EmailQueue;
111
+ /**
112
+ * The send function — typically `mail.send.bind(mail)`.
113
+ */
114
+ send: (message: EmailOptions) => Promise<Result<EmailResult>>;
115
+ }
116
+ /**
117
+ * A running queue worker.
118
+ */
119
+ interface Worker {
120
+ /**
121
+ * Processes ready jobs until the queue has none currently deliverable, then resolves.
122
+ *
123
+ * Does not wait for future-scheduled jobs. Useful in tests and one-shot drains.
124
+ */
125
+ drain: () => Promise<void>;
126
+ /**
127
+ * Begins polling and processing jobs in the background.
128
+ */
129
+ start: () => void;
130
+ /**
131
+ * Stops polling. In-flight jobs are allowed to finish.
132
+ */
133
+ stop: () => void;
134
+ }
135
+ /**
136
+ * Creates a worker that durably processes queued messages with bounded concurrency, retry/backoff, and
137
+ * dead-lettering.
138
+ * @param options Worker configuration. See {@link WorkerOptions}.
139
+ * @returns The worker handle. See {@link Worker}.
140
+ * @example
141
+ * ```ts
142
+ * const queue = new MemoryQueue();
143
+ * const worker = createWorker({ queue, send: mail.send.bind(mail), concurrency: 5 });
144
+ * worker.start();
145
+ * ```
146
+ */
147
+ declare const createWorker: (options: WorkerOptions) => Worker;
148
+ export { type EmailQueue, type EnqueueOptions, MemoryQueue, type MemoryQueueOptions, type QueueJob, type Worker, type WorkerOptions, createWorker };
@@ -0,0 +1 @@
1
+ import{MemoryQueue as o}from"../packem_shared/MemoryQueue-C-CtRRG7.js";import{UnstorageQueue as u,createUnstorageQueue as a}from"./unstorage-queue.js";import{createWorker as f}from"../packem_shared/createWorker-Nkc1GHet.js";export{o as MemoryQueue,u as UnstorageQueue,a as createUnstorageQueue,f as createWorker};
@@ -0,0 +1,41 @@
1
+ import { a as EmailQueue } from "../packem_shared/types.d-lcJZmwRK.js";
2
+ import "../packem_shared/types.d-ejzh-xBP.js";
3
+ import 'node:buffer';
4
+ interface PgBossJob {
5
+ data: unknown;
6
+ id: string;
7
+ /** pg-boss retry count (present when fetched with `includeMetadata`). */
8
+ retryCount?: number;
9
+ }
10
+ /**
11
+ * The subset of a [pg-boss](https://github.com/timgit/pg-boss) instance this adapter uses (v10 API).
12
+ */
13
+ interface PgBossLike {
14
+ complete: (name: string, id: string) => Promise<unknown>;
15
+ fail: (name: string, id: string) => Promise<unknown>;
16
+ fetch: (name: string, options?: {
17
+ batchSize?: number;
18
+ includeMetadata?: boolean;
19
+ }) => Promise<PgBossJob[] | PgBossJob | null>;
20
+ getQueueSize: (name: string) => Promise<number>;
21
+ send: (name: string, data: object, options?: {
22
+ startAfter?: Date | number | string;
23
+ }) => Promise<null | string>;
24
+ }
25
+ /**
26
+ * Options for {@link createPgBossQueue}.
27
+ */
28
+ interface PgBossQueueOptions {
29
+ /**
30
+ * The pg-boss queue name.
31
+ */
32
+ queueName: string;
33
+ }
34
+ /**
35
+ * Creates an {@link EmailQueue} backed by pg-boss.
36
+ * @param boss A started pg-boss instance (optional peer).
37
+ * @param options Queue options. See {@link PgBossQueueOptions}.
38
+ * @returns The pg-boss-backed queue.
39
+ */
40
+ declare const createPgBossQueue: (boss: PgBossLike, options: PgBossQueueOptions) => EmailQueue;
41
+ export { type PgBossLike, type PgBossQueueOptions, createPgBossQueue };
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var a=(t,e)=>r(t,"name",{value:e,configurable:!0});var c=Object.defineProperty,i=a((t,e)=>c(t,"name",{value:e,configurable:!0}),"i");class o{static{a(this,"o")}static{i(this,"PgBossQueue")}boss;queueName;constructor(e,s){this.boss=e,this.queueName=s.queueName}async enqueue(e,s={}){const u=s.scheduledAt;return await this.boss.send(this.queueName,e,u===void 0?void 0:{startAfter:u})??""}async reserve(){const e=await this.boss.fetch(this.queueName,{batchSize:1,includeMetadata:!0});if(!e)return;const s=Array.isArray(e)?e[0]:e;if(s)return{attempts:s.retryCount??0,id:s.id,message:s.data,scheduledAt:0}}async ack(e){await this.boss.complete(this.queueName,e)}async retry(e){await this.boss.fail(this.queueName,e)}async size(){return this.boss.getQueueSize(this.queueName)}}const h=i((t,e)=>new o(t,e),"createPgBossQueue");export{h as createPgBossQueue};
@@ -0,0 +1,72 @@
1
+ import { a as EmailQueue } from "../packem_shared/types.d-lcJZmwRK.js";
2
+ import "../packem_shared/types.d-ejzh-xBP.js";
3
+ import 'node:buffer';
4
+ /**
5
+ * The subset of the `@aws-sdk/client-sqs` `SQS` client this adapter uses. The `SQS` class (not the
6
+ * lower-level `SQSClient`) exposes these operation methods directly.
7
+ */
8
+ interface SqsClientLike {
9
+ changeMessageVisibility: (input: {
10
+ QueueUrl: string;
11
+ ReceiptHandle: string;
12
+ VisibilityTimeout: number;
13
+ }) => Promise<unknown>;
14
+ deleteMessage: (input: {
15
+ QueueUrl: string;
16
+ ReceiptHandle: string;
17
+ }) => Promise<unknown>;
18
+ getQueueAttributes: (input: {
19
+ AttributeNames: string[];
20
+ QueueUrl: string;
21
+ }) => Promise<{
22
+ Attributes?: Record<string, string>;
23
+ }>;
24
+ receiveMessage: (input: {
25
+ AttributeNames?: string[];
26
+ MaxNumberOfMessages?: number;
27
+ QueueUrl: string;
28
+ VisibilityTimeout?: number;
29
+ WaitTimeSeconds?: number;
30
+ }) => Promise<{
31
+ Messages?: {
32
+ Attributes?: Record<string, string>;
33
+ Body?: string;
34
+ MessageId?: string;
35
+ ReceiptHandle?: string;
36
+ }[];
37
+ }>;
38
+ sendMessage: (input: {
39
+ DelaySeconds?: number;
40
+ MessageBody: string;
41
+ QueueUrl: string;
42
+ }) => Promise<{
43
+ MessageId?: string;
44
+ }>;
45
+ }
46
+ /**
47
+ * Options for {@link createSqsQueue}.
48
+ */
49
+ interface SqsQueueOptions {
50
+ /**
51
+ * The SQS queue URL.
52
+ */
53
+ queueUrl: string;
54
+ /**
55
+ * Visibility timeout (seconds) applied when reserving a message.
56
+ * @default 30
57
+ */
58
+ visibilityTimeout?: number;
59
+ /**
60
+ * Long-poll wait time (seconds) for `reserve`.
61
+ * @default 0
62
+ */
63
+ waitTimeSeconds?: number;
64
+ }
65
+ /**
66
+ * Creates an {@link EmailQueue} backed by Amazon SQS.
67
+ * @param client An `@aws-sdk/client-sqs` `SQS` instance (optional peer).
68
+ * @param options Queue options. See {@link SqsQueueOptions}.
69
+ * @returns The SQS-backed queue.
70
+ */
71
+ declare const createSqsQueue: (client: SqsClientLike, options: SqsQueueOptions) => EmailQueue;
72
+ export { type SqsClientLike, type SqsQueueOptions, createSqsQueue };
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var a=(t,e)=>c(t,"name",{value:e,configurable:!0});var l=Object.defineProperty,u=a((t,e)=>l(t,"name",{value:e,configurable:!0}),"n");const r="ApproximateNumberOfMessages",n="ApproximateNumberOfMessagesNotVisible",o=u((t,e)=>{if(t===void 0)return 0;const i=t instanceof Date?t.getTime():t,s=Math.ceil((i-e)/1e3);return Math.max(0,s)},"toDelaySeconds");class m{static{a(this,"m")}static{u(this,"SqsQueue")}client;queueUrl;visibilityTimeout;waitTimeSeconds;constructor(e,i){this.client=e,this.queueUrl=i.queueUrl,this.visibilityTimeout=i.visibilityTimeout??30,this.waitTimeSeconds=i.waitTimeSeconds??0}async enqueue(e,i={}){const s=o(i.scheduledAt,Date.now());if(s>900)throw new RangeError(`SQS supports a maximum scheduling delay of ${String(900)}s (15 minutes); use a scheduler for longer delays`);return(await this.client.sendMessage({DelaySeconds:s,MessageBody:JSON.stringify(e),QueueUrl:this.queueUrl})).MessageId??""}async reserve(){const e=(await this.client.receiveMessage({AttributeNames:["ApproximateReceiveCount"],MaxNumberOfMessages:1,QueueUrl:this.queueUrl,VisibilityTimeout:this.visibilityTimeout,WaitTimeSeconds:this.waitTimeSeconds})).Messages?.[0];if(!e?.ReceiptHandle)return;const i=Number(e.Attributes?.ApproximateReceiveCount??"1");let s;try{s=JSON.parse(e.Body??"{}")}catch{await this.client.deleteMessage({QueueUrl:this.queueUrl,ReceiptHandle:e.ReceiptHandle});return}return{attempts:Math.max(0,i-1),id:e.ReceiptHandle,message:s,scheduledAt:0}}async ack(e){await this.client.deleteMessage({QueueUrl:this.queueUrl,ReceiptHandle:e})}async retry(e,i=0){await this.client.changeMessageVisibility({QueueUrl:this.queueUrl,ReceiptHandle:e,VisibilityTimeout:Math.min(900,Math.max(0,Math.ceil(i/1e3)))})}async size(){const e=await this.client.getQueueAttributes({AttributeNames:[r,n],QueueUrl:this.queueUrl});return Number(e.Attributes?.[r]??0)+Number(e.Attributes?.[n]??0)}}const d=u((t,e)=>new m(t,e),"createSqsQueue");export{d as createSqsQueue};
@@ -0,0 +1,81 @@
1
+ import { Storage } from 'unstorage';
2
+ import { E as EmailOptions } from "../packem_shared/types.d-ejzh-xBP.js";
3
+ import { E as EnqueueOptions, Q as QueueJob, a as EmailQueue } from "../packem_shared/types.d-lcJZmwRK.js";
4
+ import 'node:buffer';
5
+ /**
6
+ * Options for {@link UnstorageQueue}.
7
+ */
8
+ interface UnstorageQueueOptions {
9
+ /**
10
+ * Time source in milliseconds — injectable for tests. Defaults to `Date.now`.
11
+ */
12
+ now?: () => number;
13
+ /**
14
+ * Key prefix under which jobs are stored.
15
+ * @default "email:queue"
16
+ */
17
+ prefix?: string;
18
+ /**
19
+ * How long, in milliseconds, a reserved job stays hidden before becoming deliverable again.
20
+ * @default 30000
21
+ */
22
+ visibilityTimeout?: number;
23
+ }
24
+ /**
25
+ * A durable {@link EmailQueue} backed by an [unstorage](https://unstorage.unjs.io/) `Storage`.
26
+ *
27
+ * Because unstorage abstracts many backends (memory, filesystem, Redis, Cloudflare KV, Postgres, …),
28
+ * a single adapter persists the queue across all of them. The stored `message` must be
29
+ * JSON-serializable (avoid `Buffer` attachments — pass `path`/`href`/base64 `content` instead).
30
+ *
31
+ * Note: unstorage has no transactions, so {@link UnstorageQueue.reserve} is best-effort under
32
+ * concurrent workers; the visibility timeout bounds duplicate delivery on a crash.
33
+ */
34
+ declare class UnstorageQueue implements EmailQueue {
35
+ private readonly storage;
36
+ private readonly prefix;
37
+ private readonly visibilityTimeout;
38
+ private readonly now;
39
+ /**
40
+ * @param storage The unstorage instance to persist jobs in.
41
+ * @param options Adapter options. See {@link UnstorageQueueOptions}.
42
+ */
43
+ constructor(storage: Storage, options?: UnstorageQueueOptions);
44
+ /**
45
+ * Persists a message to the store.
46
+ * @param message The message to send later.
47
+ * @param options Optional scheduling. See {@link EnqueueOptions}.
48
+ * @returns The new job id.
49
+ */
50
+ enqueue(message: EmailOptions, options?: EnqueueOptions): Promise<string>;
51
+ /**
52
+ * Reserves the next ready job, hiding it for the visibility window.
53
+ * @returns The next deliverable job, or `undefined` when none is ready.
54
+ */
55
+ reserve(): Promise<QueueJob | undefined>;
56
+ /**
57
+ * Removes a processed job from the store.
58
+ * @param id The job id.
59
+ */
60
+ ack(id: string): Promise<void>;
61
+ /**
62
+ * Requeues a job after a delay, incrementing its attempt count.
63
+ * @param id The job id.
64
+ * @param delayMs Milliseconds to wait before the job becomes ready again.
65
+ */
66
+ retry(id: string, delayMs?: number): Promise<void>;
67
+ /**
68
+ * Counts the jobs currently in the store.
69
+ * @returns The number of stored (ready plus reserved) jobs.
70
+ */
71
+ size(): Promise<number>;
72
+ private keyOf;
73
+ }
74
+ /**
75
+ * Creates an {@link UnstorageQueue}.
76
+ * @param storage The unstorage instance to persist jobs in.
77
+ * @param options Adapter options. See {@link UnstorageQueueOptions}.
78
+ * @returns A new {@link UnstorageQueue}.
79
+ */
80
+ declare const createUnstorageQueue: (storage: Storage, options?: UnstorageQueueOptions) => UnstorageQueue;
81
+ export { UnstorageQueue, UnstorageQueueOptions, createUnstorageQueue };
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var a=(i,e)=>u(i,"name",{value:e,configurable:!0});import{createRequire as d}from"node:module";const h=d(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=a(i=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,s]=o.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return o.getBuiltinModule(i)}return h(i)},"__cjs_getBuiltinModule"),{randomUUID:g}=l("node:crypto");var m=Object.defineProperty,n=a((i,e)=>m(i,"name",{value:e,configurable:!0}),"o");class f{static{a(this,"UnstorageQueue")}static{n(this,"UnstorageQueue")}storage;prefix;visibilityTimeout;now;constructor(e,s={}){this.storage=e,this.prefix=s.prefix??"email:queue",this.visibilityTimeout=s.visibilityTimeout??3e4,this.now=s.now??Date.now}async enqueue(e,s={}){const r=g(),t=s.scheduledAt instanceof Date?s.scheduledAt.getTime():s.scheduledAt??this.now(),c={attempts:0,id:r,message:e,reservedUntil:0,scheduledAt:t};return await this.storage.setItem(this.keyOf(r),c),r}async reserve(){const e=this.now(),s=await this.storage.getKeys(this.prefix);for(const r of s){const t=await this.storage.getItem(r);if(t&&t.scheduledAt<=e&&t.reservedUntil<=e)return t.reservedUntil=e+this.visibilityTimeout,await this.storage.setItem(r,t),{attempts:t.attempts,id:t.id,message:t.message,scheduledAt:t.scheduledAt}}}async ack(e){await this.storage.removeItem(this.keyOf(e))}async retry(e,s=0){const r=this.keyOf(e),t=await this.storage.getItem(r);t&&(t.attempts+=1,t.reservedUntil=0,t.scheduledAt=this.now()+s,await this.storage.setItem(r,t))}async size(){return(await this.storage.getKeys(this.prefix)).length}keyOf(e){return`${this.prefix}:${e}`}}const v=n((i,e)=>new f(i,e),"createUnstorageQueue");export{f as UnstorageQueue,v as createUnstorageQueue};
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Rewrites `cid:` references in `src`/`href` attributes using a resolver.
3
+ *
4
+ * Useful for turning inline (Content-ID) image references into hosted URLs for previews/webmail, or
5
+ * for normalizing them. Returning `undefined` from the resolver leaves that reference unchanged.
6
+ * @param html The HTML email.
7
+ * @param resolver Maps a Content-ID to a replacement URL (or `undefined` to keep it).
8
+ * @returns The rewritten HTML.
9
+ */
10
+ declare const rewriteCidLinks: (html: string, resolver: (cid: string) => string | undefined) => string;
11
+ /**
12
+ * Collects the Content-IDs referenced via `cid:` in `src`/`href` attributes.
13
+ * @param html The HTML email.
14
+ * @returns The referenced Content-IDs (de-duplicated, in first-seen order).
15
+ */
16
+ declare const extractCidReferences: (html: string) => string[];
17
+ /**
18
+ * Inlines `&lt;style>`/linked CSS into element `style` attributes for maximum email-client
19
+ * compatibility, via [juice](https://github.com/Automattic/juice).
20
+ *
21
+ * `juice` is an optional peer dependency — install it (`pnpm add juice`) to use this. It is loaded
22
+ * lazily (via `createRequire`) so importing the render entry point doesn't fail when `juice` is absent.
23
+ * @param html The HTML email.
24
+ * @param options Options forwarded to `juice` (e.g. `preserveImportant`, `removeStyleTags`).
25
+ * @returns The HTML with CSS inlined.
26
+ * @throws {EmailError} When `juice` is not installed or inlining fails.
27
+ */
28
+ declare const inlineCss: (html: string, options?: Record<string, unknown>) => string;
29
+ /**
30
+ * Options for {@link addDarkModeSupport}.
31
+ */
32
+ interface DarkModeOptions {
33
+ /**
34
+ * Extra CSS to wrap in a `@media (prefers-color-scheme: dark)` block (the dark-mode overrides).
35
+ */
36
+ styles?: string;
37
+ }
38
+ /**
39
+ * Adds dark-mode hooks to an HTML email: the `color-scheme` / `supported-color-schemes` meta tags and,
40
+ * when provided, a `@media (prefers-color-scheme: dark)` style block.
41
+ *
42
+ * Injected into `&lt;head>` (created after `&lt;html>` if absent, otherwise prepended).
43
+ * @param html The HTML email.
44
+ * @param options Dark-mode options. See {@link DarkModeOptions}.
45
+ * @returns The HTML with dark-mode support added.
46
+ */
47
+ declare const addDarkModeSupport: (html: string, options?: DarkModeOptions) => string;
48
+ /**
49
+ * Options for {@link injectPreheader}.
50
+ */
51
+ interface PreheaderOptions {
52
+ /**
53
+ * Append invisible padding characters so the preheader text isn't followed by leaked body content
54
+ * in the inbox preview.
55
+ * @default true
56
+ */
57
+ spacer?: boolean;
58
+ }
59
+ /**
60
+ * Injects a hidden preheader (inbox preview text) at the start of the HTML body.
61
+ *
62
+ * The preheader is wrapped in a `display:none` element with `mso-hide:all`, followed by zero-width
63
+ * padding so the preview shows only your text. Inserted right after `&lt;body>` (or prepended if no
64
+ * body tag is present).
65
+ * @param html The HTML email.
66
+ * @param preheader The preview text.
67
+ * @param options Injection options. See {@link PreheaderOptions}.
68
+ * @returns The HTML with the preheader injected.
69
+ */
70
+ declare const injectPreheader: (html: string, preheader: string, options?: PreheaderOptions) => string;
71
+ /**
72
+ * Options for {@link postProcessHtml}. Each step runs only when its option is set; the order is
73
+ * CSS-inline → preheader → dark-mode → CID rewrite.
74
+ */
75
+ interface PostProcessOptions {
76
+ /**
77
+ * Rewrite `cid:` references using this resolver (see {@link rewriteCidLinks}).
78
+ */
79
+ cidResolver?: (cid: string) => string | undefined;
80
+ /**
81
+ * Add dark-mode hooks. `true` adds the meta tags only; an object also injects dark CSS.
82
+ */
83
+ darkMode?: DarkModeOptions | boolean;
84
+ /**
85
+ * Inline CSS via `juice`. `true` uses defaults; an object forwards options to `juice`.
86
+ */
87
+ inlineCss?: Record<string, unknown> | boolean;
88
+ /**
89
+ * Inject hidden preview text at the top of the body.
90
+ */
91
+ preheader?: string;
92
+ /**
93
+ * Options for the preheader injection.
94
+ */
95
+ preheaderOptions?: PreheaderOptions;
96
+ }
97
+ /**
98
+ * Runs an HTML email through the selected post-processing steps.
99
+ *
100
+ * A convenience pipeline over {@link inlineCss}, {@link injectPreheader}, {@link addDarkModeSupport} and
101
+ * {@link rewriteCidLinks}. Only the steps whose options are provided run.
102
+ * @param html The HTML email.
103
+ * @param options Which steps to apply. See {@link PostProcessOptions}.
104
+ * @returns The processed HTML.
105
+ */
106
+ declare const postProcessHtml: (html: string, options?: PostProcessOptions) => string;
107
+ export { type DarkModeOptions, type PostProcessOptions, type PreheaderOptions, addDarkModeSupport, extractCidReferences, injectPreheader, inlineCss, postProcessHtml, rewriteCidLinks };
@@ -0,0 +1 @@
1
+ import{extractCidReferences as o,rewriteCidLinks as t}from"../packem_shared/rewriteCidLinks-B-Sd5XHs.js";import{default as s}from"../packem_shared/inlineCss-BLaEi337.js";import{addDarkModeSupport as f}from"../packem_shared/addDarkModeSupport-Ys9U2-GH.js";import{postProcessHtml as a}from"../packem_shared/postProcessHtml-C73e0b9H.js";import{injectPreheader as x}from"../packem_shared/injectPreheader-BxPjb0eJ.js";export{f as addDarkModeSupport,o as extractCidReferences,x as injectPreheader,s as inlineCss,a as postProcessHtml,t as rewriteCidLinks};
@@ -0,0 +1,61 @@
1
+ import { T as TemplateRenderer } from "../packem_shared/types.d-nyR1ty1Q.js";
2
+ /**
3
+ * A map of locale code (e.g. `en`, `en-US`, `de`) to that locale's template.
4
+ *
5
+ * The template value is whatever the underlying {@link TemplateRenderer} accepts (a string for
6
+ * Handlebars/MJML/Liquid, a component for react-email/jsx-email, etc.).
7
+ */
8
+ type LocaleTemplates = Record<string, unknown>;
9
+ /**
10
+ * Options for {@link renderI18n} and {@link createI18nRenderer}.
11
+ */
12
+ interface I18nRenderOptions {
13
+ /**
14
+ * Locale to fall back to when the requested locale (and its language root) is missing.
15
+ */
16
+ defaultLocale?: string;
17
+ /**
18
+ * Options forwarded to the underlying renderer.
19
+ */
20
+ rendererOptions?: Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Resolves the best-matching available locale key: exact match, then the language subtag
24
+ * (`en-US` → `en`), then the default locale.
25
+ * @param templates The available locale templates.
26
+ * @param locale The requested locale.
27
+ * @param defaultLocale Optional fallback locale.
28
+ * @returns The matching key, or `undefined` when nothing matches.
29
+ */
30
+ declare const resolveLocale: (templates: LocaleTemplates, locale: string, defaultLocale?: string) => string | undefined;
31
+ /**
32
+ * Renders the template for a given locale using the supplied engine, with locale fallback.
33
+ * @param templates The per-locale templates. See {@link LocaleTemplates}.
34
+ * @param locale The requested locale (e.g. `de-AT`).
35
+ * @param renderer The underlying template engine (Handlebars, MJML, Liquid, react-email, …).
36
+ * @param data Data/variables passed to the renderer.
37
+ * @param options Fallback locale and renderer options. See {@link I18nRenderOptions}.
38
+ * @returns The rendered output for the resolved locale.
39
+ * @throws {EmailError} When no template matches the locale or the fallback.
40
+ */
41
+ declare const renderI18n: (templates: LocaleTemplates, locale: string, renderer: TemplateRenderer, data?: Record<string, unknown>, options?: I18nRenderOptions) => Promise<string>;
42
+ /**
43
+ * A locale-resolving renderer produced by {@link createI18nRenderer}.
44
+ */
45
+ type LocalizedRenderer = (templates: LocaleTemplates, locale: string, data?: Record<string, unknown>, rendererOptions?: Record<string, unknown>) => Promise<string>;
46
+ /**
47
+ * Creates a reusable localized renderer bound to an engine and default locale.
48
+ * @param renderer The underlying template engine.
49
+ * @param defaultLocale Optional default/fallback locale applied to every call.
50
+ * @returns A {@link LocalizedRenderer}.
51
+ * @example
52
+ * ```ts
53
+ * import { renderHandlebars } from "@visulima/email/template/handlebars";
54
+ * import { createI18nRenderer } from "@visulima/email/template/i18n";
55
+ *
56
+ * const render = createI18nRenderer(renderHandlebars, "en");
57
+ * await render({ en: "Hello {{name}}", de: "Hallo {{name}}" }, "de", { name: "Ada" });
58
+ * ```
59
+ */
60
+ declare const createI18nRenderer: (renderer: TemplateRenderer, defaultLocale?: string) => LocalizedRenderer;
61
+ export { I18nRenderOptions, LocaleTemplates, LocalizedRenderer, createI18nRenderer, renderI18n, resolveLocale };
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var c=(r,e)=>d(r,"name",{value:e,configurable:!0});import i from"../packem_shared/EmailError-zm2ffVav.js";var s=Object.defineProperty,l=c((r,e)=>s(r,"name",{value:e,configurable:!0}),"d");const u=l((r,e,a)=>{const n=new Map(Object.keys(r).map(t=>[t.toLowerCase(),t])),o=l(t=>{if(t!==void 0)return n.get(t.toLowerCase())},"lookup");return o(e)??o(e.split("-")[0])??o(a)},"resolveLocale"),f=l(async(r,e,a,n,o)=>{const t=u(r,e,o?.defaultLocale);if(t===void 0)throw new i("i18n",`No template found for locale "${e}"${o?.defaultLocale?` or default "${o.defaultLocale}"`:""}`);return await a(r[t],n,o?.rendererOptions)},"renderI18n"),v=l((r,e)=>(a,n,o,t)=>f(a,n,r,o,{defaultLocale:e,rendererOptions:t}),"createI18nRenderer");export{v as createI18nRenderer,f as renderI18n,u as resolveLocale};
@@ -0,0 +1,11 @@
1
+ import { T as TemplateRenderer } from "../packem_shared/types.d-nyR1ty1Q.js";
2
+ /**
3
+ * Renders a [jsx-email](https://jsx.email/) component to HTML.
4
+ * @param template The jsx-email component element to render.
5
+ * @param _data Data object (unused; jsx-email components receive props directly).
6
+ * @param options Render options (`plainText`, `pretty`).
7
+ * @returns The rendered HTML (or plain text) string.
8
+ * @throws {EmailError} When `jsx-email` is not installed or rendering fails.
9
+ */
10
+ declare const jsxEmail: TemplateRenderer;
11
+ export { jsxEmail as default };
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var i=(a,t)=>r(a,"name",{value:t,configurable:!0});import s from"../packem_shared/EmailError-zm2ffVav.js";var l=Object.defineProperty,o=i((a,t)=>l(a,"name",{value:t,configurable:!0}),"t");const d=o(async(a,t,n)=>{try{const{render:e}=await import("jsx-email");return await e(a,{plainText:n?.plainText,pretty:n?.pretty})}catch(e){throw e instanceof Error&&(e.code==="ERR_MODULE_NOT_FOUND"||e.message.includes("Cannot find module")||e.message.includes("Cannot find package"))?new s("jsx-email","jsx-email is not installed. Please install it: pnpm add jsx-email",{cause:e}):new s("jsx-email",`Failed to render jsx-email component: ${e.message}`,{cause:e})}},"jsxEmail");export{d as default};
@@ -0,0 +1,12 @@
1
+ import { T as TemplateRenderer } from "../packem_shared/types.d-nyR1ty1Q.js";
2
+ /**
3
+ * Renders a [LiquidJS](https://liquidjs.com/) template to a string.
4
+ * @param template The Liquid template string.
5
+ * @param data The data/variables exposed to the template.
6
+ * @param options LiquidJS engine options (passed to the `Liquid` constructor).
7
+ * @returns The rendered output.
8
+ * @throws {TypeError} When the template is not a string.
9
+ * @throws {EmailError} When `liquidjs` is not installed or rendering fails.
10
+ */
11
+ declare const liquid: TemplateRenderer;
12
+ export { liquid as default };
@@ -0,0 +1 @@
1
+ var s=Object.defineProperty;var t=(i,a)=>s(i,"name",{value:a,configurable:!0});import n from"../packem_shared/EmailError-zm2ffVav.js";var d=Object.defineProperty,o=t((i,a)=>d(i,"name",{value:a,configurable:!0}),"i");const c=o(async(i,a,r)=>{try{if(typeof i!="string")throw new TypeError("Liquid template must be a string");const{Liquid:e}=await import("liquidjs");return await new e(r??{}).parseAndRender(i,a??{})}catch(e){throw e instanceof TypeError?e:e instanceof Error&&(e.code==="ERR_MODULE_NOT_FOUND"||e.message.includes("Cannot find module")||e.message.includes("Cannot find package"))?new n("liquid","liquidjs is not installed. Please install it: pnpm add liquidjs",{cause:e}):new n("liquid",`Failed to render Liquid template: ${e.message}`,{cause:e})}},"liquid");export{c as default};