UNPKG

@visulima/email

Version:

A comprehensive email library with multi-provider support, crypto utilities, and template engines

2 lines (1 loc) 1.69 kB
var r=Object.defineProperty;var i=(e,t)=>r(e,"name",{value:t,configurable:!0});import{createRequire as m}from"node:module";import d from"./EmailError-zm2ffVav.js";const p=m(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=i(e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,n]=a.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return a.getBuiltinModule(e)}return p(e)},"__cjs_getBuiltinModule"),{Buffer:l}=f("node:buffer");var u=Object.defineProperty,o=i((e,t)=>u(e,"name",{value:t,configurable:!0}),"o");const c=o(async(e,t)=>{let n;if(e.content)if(typeof e.content=="string")n=e.content;else if(e.content instanceof Promise){const s=await e.content;n=l.from(s).toString("base64")}else n=e.content.toString("base64");else if(e.raw)n=typeof e.raw=="string"?e.raw:e.raw.toString("base64");else throw new d(t,`Attachment ${e.filename} has no content`);return n},"processAttachmentContent");o(async(e,t)=>({content:await c(e,t),contentType:e.contentType||"application/octet-stream",disposition:e.contentDisposition||"attachment",filename:e.filename,...e.cid&&{contentId:e.cid}}),"createStandardAttachment");const _=o(async(e,t)=>({content:await c(e,t),disposition:e.contentDisposition||"attachment",filename:e.filename,type:e.contentType||"application/octet-stream",...e.cid&&{content_id:e.cid}}),"createSendGridAttachment"),b=o(async(e,t)=>({Content:await c(e,t),ContentType:e.contentType||"application/octet-stream",Name:e.filename,...e.cid&&{ContentID:e.cid}}),"createPostmarkAttachment"),w=o(async(e,t,n)=>({content:await c(e,t),key:`attachment[${n}]`}),"createMailgunAttachment");export{w as a,b,_ as c};