best-email-builder 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +50 -10
  3. package/dist/ai-server.js +6 -4
  4. package/dist/ai.js +167 -39
  5. package/dist/ai.js.map +1 -1
  6. package/dist/builder.js +9 -9
  7. package/dist/{chunk-ECHGJZ2W.js → chunk-4U7L2NYQ.js} +32 -3
  8. package/dist/chunk-4U7L2NYQ.js.map +1 -0
  9. package/dist/{chunk-6D3SLT5W.js → chunk-5W4TUUPD.js} +4 -4
  10. package/dist/{chunk-LYMJ2TBX.js → chunk-CNJZLZRH.js} +2 -2
  11. package/dist/{chunk-DFNHICTF.js → chunk-JI36FNWE.js} +3 -1
  12. package/dist/chunk-JI36FNWE.js.map +1 -0
  13. package/dist/{chunk-LXR4QTGP.js → chunk-JU3OUO6X.js} +3 -3
  14. package/dist/{chunk-PB7YZ3WP.js → chunk-NC2YDZSP.js} +19 -65
  15. package/dist/chunk-NC2YDZSP.js.map +1 -0
  16. package/dist/{chunk-MPX5CWTZ.js → chunk-NZIQF7IW.js} +172 -29
  17. package/dist/chunk-NZIQF7IW.js.map +1 -0
  18. package/dist/{chunk-2RZHGAH5.js → chunk-OWVXKMLI.js} +59 -2
  19. package/dist/chunk-OWVXKMLI.js.map +1 -0
  20. package/dist/{chunk-7U6BAKM7.js → chunk-QPAZLCPO.js} +3 -3
  21. package/dist/{chunk-7U6BAKM7.js.map → chunk-QPAZLCPO.js.map} +1 -1
  22. package/dist/{chunk-KXJJSVN5.js → chunk-SAIW46IC.js} +2 -2
  23. package/dist/{chunk-5SASKCUC.js → chunk-W424KPCR.js} +2 -2
  24. package/dist/{chunk-3LKF4QBL.js → chunk-XEFBPP5Y.js} +4 -4
  25. package/dist/index.js +11 -11
  26. package/dist/library.js +5 -5
  27. package/dist/server.js +12 -29
  28. package/dist/server.js.map +1 -1
  29. package/dist/styles.css +1 -1
  30. package/dist/types/ai/ConnectAi.d.ts +4 -0
  31. package/dist/types/ai/claude.d.ts +30 -5
  32. package/dist/types/ai/createAi.d.ts +5 -3
  33. package/dist/types/ai/draft.d.ts +12 -0
  34. package/dist/types/ai/index.d.ts +2 -2
  35. package/dist/types/ai/keys.d.ts +15 -26
  36. package/dist/types/ai/providers.d.ts +24 -2
  37. package/dist/types/ai/server.d.ts +1 -1
  38. package/dist/types/core/constants.d.ts +1 -1
  39. package/dist/types/engine/NativeAdapter.d.ts +1 -1
  40. package/dist/types/renderer/prepareMjml.d.ts +8 -2
  41. package/dist/types/server/index.d.ts +1 -1
  42. package/dist/types/server/render.d.ts +5 -2
  43. package/package.json +1 -1
  44. package/dist/chunk-2RZHGAH5.js.map +0 -1
  45. package/dist/chunk-DFNHICTF.js.map +0 -1
  46. package/dist/chunk-ECHGJZ2W.js.map +0 -1
  47. package/dist/chunk-MPX5CWTZ.js.map +0 -1
  48. package/dist/chunk-PB7YZ3WP.js.map +0 -1
  49. /package/dist/{chunk-6D3SLT5W.js.map → chunk-5W4TUUPD.js.map} +0 -0
  50. /package/dist/{chunk-LYMJ2TBX.js.map → chunk-CNJZLZRH.js.map} +0 -0
  51. /package/dist/{chunk-LXR4QTGP.js.map → chunk-JU3OUO6X.js.map} +0 -0
  52. /package/dist/{chunk-KXJJSVN5.js.map → chunk-SAIW46IC.js.map} +0 -0
  53. /package/dist/{chunk-5SASKCUC.js.map → chunk-W424KPCR.js.map} +0 -0
  54. /package/dist/{chunk-3LKF4QBL.js.map → chunk-XEFBPP5Y.js.map} +0 -0
@@ -15,10 +15,10 @@ import {
15
15
  TabsTrigger,
16
16
  cn,
17
17
  useUi
18
- } from "./chunk-LXR4QTGP.js";
18
+ } from "./chunk-JU3OUO6X.js";
19
19
  import {
20
20
  EMAIL_MOBILE_WIDTH
21
- } from "./chunk-7U6BAKM7.js";
21
+ } from "./chunk-QPAZLCPO.js";
22
22
  import {
23
23
  DEFAULT_BUTTON_URL,
24
24
  FONT_STACK,
@@ -28,7 +28,7 @@ import {
28
28
  identity,
29
29
  inWhiteSection,
30
30
  prop
31
- } from "./chunk-DFNHICTF.js";
31
+ } from "./chunk-JI36FNWE.js";
32
32
 
33
33
  // src/features/templates/starter.js
34
34
  function escapeXml(text) {
@@ -592,4 +592,4 @@ export {
592
592
  useBrand,
593
593
  useLayoutWidth
594
594
  };
595
- //# sourceMappingURL=chunk-3LKF4QBL.js.map
595
+ //# sourceMappingURL=chunk-XEFBPP5Y.js.map
package/dist/index.js CHANGED
@@ -11,28 +11,28 @@ import {
11
11
  emailBlocks,
12
12
  emailBuilderFeatures,
13
13
  isFeatureEnabled
14
- } from "./chunk-PB7YZ3WP.js";
14
+ } from "./chunk-NC2YDZSP.js";
15
15
  import {
16
16
  TemplateLibrary
17
- } from "./chunk-6D3SLT5W.js";
17
+ } from "./chunk-5W4TUUPD.js";
18
18
  import {
19
19
  STARTER_MJML,
20
20
  TEMPLATE_GALLERY,
21
21
  buildGallery,
22
22
  createStarterMjml,
23
23
  withPlaceholderImages
24
- } from "./chunk-3LKF4QBL.js";
24
+ } from "./chunk-XEFBPP5Y.js";
25
25
  import {
26
26
  applyVariables,
27
27
  applyVariablesToText,
28
28
  unknownVariables,
29
29
  usedVariables
30
- } from "./chunk-LYMJ2TBX.js";
31
- import "./chunk-ECHGJZ2W.js";
30
+ } from "./chunk-CNJZLZRH.js";
31
+ import "./chunk-4U7L2NYQ.js";
32
32
  import {
33
33
  simulateDarkMode
34
34
  } from "./chunk-UFKCLU2D.js";
35
- import "./chunk-KXJJSVN5.js";
35
+ import "./chunk-SAIW46IC.js";
36
36
  import {
37
37
  StorageError,
38
38
  UiProvider,
@@ -40,7 +40,7 @@ import {
40
40
  createMemoryStorage,
41
41
  useT,
42
42
  useUi
43
- } from "./chunk-LXR4QTGP.js";
43
+ } from "./chunk-JU3OUO6X.js";
44
44
  import {
45
45
  EMAIL_BUILDER_VERSION,
46
46
  EMAIL_DEVICES,
@@ -49,9 +49,9 @@ import {
49
49
  createDocument,
50
50
  readDocument,
51
51
  serializeDocument
52
- } from "./chunk-7U6BAKM7.js";
53
- import "./chunk-2RZHGAH5.js";
54
- import "./chunk-5SASKCUC.js";
52
+ } from "./chunk-QPAZLCPO.js";
53
+ import "./chunk-OWVXKMLI.js";
54
+ import "./chunk-W424KPCR.js";
55
55
  import {
56
56
  CUSTOM_GROUP,
57
57
  DEFAULT_ASSETS_PATH,
@@ -73,7 +73,7 @@ import {
73
73
  tokenOf,
74
74
  translatorFor,
75
75
  validateCustomVariable
76
- } from "./chunk-DFNHICTF.js";
76
+ } from "./chunk-JI36FNWE.js";
77
77
 
78
78
  // src/ui/EmailStudio.jsx
79
79
  import { useMemo, useState } from "react";
package/dist/library.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  TemplateLibrary
3
- } from "./chunk-6D3SLT5W.js";
3
+ } from "./chunk-5W4TUUPD.js";
4
4
  import {
5
5
  TEMPLATE_GALLERY,
6
6
  buildGallery,
7
7
  withPlaceholderImages
8
- } from "./chunk-3LKF4QBL.js";
8
+ } from "./chunk-XEFBPP5Y.js";
9
9
  import "./chunk-UFKCLU2D.js";
10
10
  import {
11
11
  StorageError,
12
12
  createHttpStorage,
13
13
  createMemoryStorage
14
- } from "./chunk-LXR4QTGP.js";
14
+ } from "./chunk-JU3OUO6X.js";
15
15
  import {
16
16
  EMAIL_BUILDER_VERSION
17
- } from "./chunk-7U6BAKM7.js";
17
+ } from "./chunk-QPAZLCPO.js";
18
18
  import {
19
19
  LOCALES,
20
20
  createTranslator,
21
21
  translatorFor
22
- } from "./chunk-DFNHICTF.js";
22
+ } from "./chunk-JI36FNWE.js";
23
23
  export {
24
24
  EMAIL_BUILDER_VERSION,
25
25
  LOCALES,
package/dist/server.js CHANGED
@@ -5,14 +5,16 @@ import {
5
5
  sampleValues,
6
6
  unknownVariables,
7
7
  usedVariables
8
- } from "./chunk-LYMJ2TBX.js";
8
+ } from "./chunk-CNJZLZRH.js";
9
9
  import {
10
10
  BRAND_IMPORT_ERRORS,
11
11
  brandFromCss,
12
+ countImagesWithoutPicture,
12
13
  imageSize,
13
14
  logoWidthFor,
15
+ prepareMjml,
14
16
  readPage
15
- } from "./chunk-ECHGJZ2W.js";
17
+ } from "./chunk-4U7L2NYQ.js";
16
18
  import {
17
19
  simulateDarkMode
18
20
  } from "./chunk-UFKCLU2D.js";
@@ -26,14 +28,14 @@ import {
26
28
  detectImage,
27
29
  readDocument,
28
30
  serializeDocument
29
- } from "./chunk-7U6BAKM7.js";
31
+ } from "./chunk-QPAZLCPO.js";
30
32
  import {
31
33
  IMAGE_ATTRIBUTES,
32
34
  LINK_ATTRIBUTES,
33
35
  assertValidMjml,
34
36
  isSafeUrl,
35
37
  validateMjml
36
- } from "./chunk-5SASKCUC.js";
38
+ } from "./chunk-W424KPCR.js";
37
39
  import {
38
40
  DEFAULT_ASSETS_PATH,
39
41
  DEFAULT_VARIABLES,
@@ -52,7 +54,7 @@ import {
52
54
  tokenOf,
53
55
  translatorFor,
54
56
  validateCustomVariable
55
- } from "./chunk-DFNHICTF.js";
57
+ } from "./chunk-JI36FNWE.js";
56
58
 
57
59
  // src/server/assets.js
58
60
  import { createHash } from "crypto";
@@ -211,27 +213,6 @@ function qualityReport({ mjml, html = "", subject = null }, { t = identity } = {
211
213
  return issues;
212
214
  }
213
215
 
214
- // src/renderer/prepareMjml.js
215
- function escapeXml(text2) {
216
- return String(text2 ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
217
- }
218
- function prepareMjml(mjml, { title = null, preheader = null, lang = "en" } = {}) {
219
- let out = String(mjml || "").replace(/<mj-title(?:\s[^>]*)?>[\s\S]*?<\/mj-title>/gi, "").replace(/<mj-preview(?:\s[^>]*)?>[\s\S]*?<\/mj-preview>/gi, "");
220
- out = out.replace(
221
- /<mjml(\s[^>]*)?>/i,
222
- (tag, attrs = "") => /\slang\s*=/.test(attrs) ? tag : `<mjml lang="${escapeXml(lang)}"${attrs}>`
223
- );
224
- const head = [
225
- title && String(title).trim() ? `<mj-title>${escapeXml(String(title).trim())}</mj-title>` : "",
226
- preheader && String(preheader).trim() ? `<mj-preview>${escapeXml(String(preheader).trim())}</mj-preview>` : ""
227
- ].join("");
228
- if (!head) return out;
229
- if (/<mj-head(\s[^>]*)?>/i.test(out)) {
230
- return out.replace(/<mj-head(\s[^>]*)?>/i, (tag) => `${tag}${head}`);
231
- }
232
- return out.replace(/<mjml(\s[^>]*)?>/i, (tag) => `${tag}<mj-head>${head}</mj-head>`);
233
- }
234
-
235
216
  // src/server/compileMjml.js
236
217
  import mjml2html from "mjml";
237
218
  var CLIENT_METAS = '<meta name="x-apple-disable-message-reformatting"><meta name="format-detection" content="telephone=no, date=no, address=no, email=no, url=no">';
@@ -265,9 +246,10 @@ async function compileMjml(mjml) {
265
246
  }
266
247
 
267
248
  // src/server/render.js
268
- async function compileTemplate({ mjml, subject = null, preheader = null }, { t = identity, lang = "en", variables = DEFAULT_VARIABLES } = {}) {
249
+ async function compileTemplate({ mjml, subject = null, preheader = null }, { t = identity, lang = "en", variables = DEFAULT_VARIABLES, preview = false } = {}) {
269
250
  assertValidMjml(mjml, { t });
270
- const { html, warnings } = await compileMjml(prepareMjml(mjml, { title: subject, preheader, lang }));
251
+ const prepared = prepareMjml(mjml, { title: subject, preheader, lang, emptyImages: preview ? "keep" : "drop" });
252
+ const { html, warnings } = await compileMjml(prepared);
271
253
  const quality = qualityReport({ mjml, html, subject }, { t });
272
254
  const unknown = unknownVariables([mjml, subject || "", preheader || ""].join("\n"), variables);
273
255
  if (unknown.length) {
@@ -1282,7 +1264,7 @@ function createEmailBuilderHandler(options) {
1282
1264
  const catalog = await customVariables.catalog();
1283
1265
  const { compiled, warnings, quality } = await compileTemplate(
1284
1266
  { mjml: body?.mjml, subject: body?.subject, preheader: body?.preheader },
1285
- { t, lang, variables: catalog }
1267
+ { t, lang, variables: catalog, preview: true }
1286
1268
  );
1287
1269
  const values = sampleValues(catalog);
1288
1270
  const html = personalize(compiled, { values, unsubscribeUrl: previewUnsubscribeUrl, variables: catalog });
@@ -1517,6 +1499,7 @@ export {
1517
1499
  cleanBrand,
1518
1500
  compileMjml,
1519
1501
  compileTemplate,
1502
+ countImagesWithoutPicture,
1520
1503
  createAssetService,
1521
1504
  createBrandImporter,
1522
1505
  createBrandService,