best-email-builder 0.1.1 → 0.2.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 (33) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +11 -1
  3. package/dist/{chunk-2DZ6BRIJ.js → chunk-MTALS5GC.js} +98 -3
  4. package/dist/chunk-MTALS5GC.js.map +1 -0
  5. package/dist/index.js +963 -295
  6. package/dist/index.js.map +1 -1
  7. package/dist/server.js +13 -13
  8. package/dist/server.js.map +1 -1
  9. package/dist/styles.css +1 -1
  10. package/dist/types/adapters/grapesjs/GrapesJsAdapter.d.ts +1 -1
  11. package/dist/types/blocks/columns/index.d.ts +3 -0
  12. package/dist/types/blocks/heading/index.d.ts +3 -0
  13. package/dist/types/blocks/hero/index.d.ts +3 -0
  14. package/dist/types/blocks/navbar/index.d.ts +6 -0
  15. package/dist/types/blocks/social/index.d.ts +13 -0
  16. package/dist/types/core/EmailEditor.d.ts +12 -4
  17. package/dist/types/core/constants.d.ts +1 -1
  18. package/dist/types/features/templates/TemplateGallery.d.ts +3 -0
  19. package/dist/types/features/templates/gallery.d.ts +41 -0
  20. package/dist/types/features/templates/index.d.ts +2 -0
  21. package/dist/types/features/templates/starter.d.ts +22 -0
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/server/compileMjml.d.ts +3 -3
  24. package/dist/types/server/render.d.ts +4 -4
  25. package/dist/types/server/templates.d.ts +2 -2
  26. package/dist/types/ui/BlockSidebar.d.ts +2 -1
  27. package/dist/types/ui/Drawer.d.ts +19 -0
  28. package/dist/types/ui/EmailBuilder.d.ts +2 -0
  29. package/dist/types/ui/PropertiesPanel.d.ts +2 -1
  30. package/dist/types/ui/Toolbar.d.ts +9 -2
  31. package/dist/types/ui/useLayoutWidth.d.ts +10 -0
  32. package/package.json +6 -6
  33. package/dist/chunk-2DZ6BRIJ.js.map +0 -1
package/dist/server.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  unknownVariables,
33
33
  usedVariables,
34
34
  validateCustomVariable
35
- } from "./chunk-2DZ6BRIJ.js";
35
+ } from "./chunk-MTALS5GC.js";
36
36
 
37
37
  // src/server/assets.js
38
38
  import { createHash } from "crypto";
@@ -406,12 +406,12 @@ function prepareMjml(mjml, { title = null, preheader = null, lang = "en" } = {})
406
406
 
407
407
  // src/server/compileMjml.js
408
408
  import mjml2html from "mjml";
409
- function compileMjml(mjml) {
409
+ async function compileMjml(mjml) {
410
410
  const compile = (
411
411
  /** @type {any} */
412
412
  mjml2html
413
413
  );
414
- const result = compile(String(mjml || ""), {
414
+ const result = await compile(String(mjml || ""), {
415
415
  validationLevel: "soft",
416
416
  keepComments: false,
417
417
  beautify: false,
@@ -430,9 +430,9 @@ function compileMjml(mjml) {
430
430
  }
431
431
 
432
432
  // src/server/render.js
433
- function compileTemplate({ mjml, subject = null, preheader = null }, { t = identity, lang = "en", variables = DEFAULT_VARIABLES } = {}) {
433
+ async function compileTemplate({ mjml, subject = null, preheader = null }, { t = identity, lang = "en", variables = DEFAULT_VARIABLES } = {}) {
434
434
  assertValidMjml(mjml, { t });
435
- const { html, warnings } = compileMjml(prepareMjml(mjml, { title: subject, preheader, lang }));
435
+ const { html, warnings } = await compileMjml(prepareMjml(mjml, { title: subject, preheader, lang }));
436
436
  const quality = qualityReport({ mjml, html, subject }, { t });
437
437
  const unknown = unknownVariables([mjml, subject || "", preheader || ""].join("\n"), variables);
438
438
  if (unknown.length) {
@@ -449,7 +449,7 @@ function personalize(compiled, { values, unsubscribeUrl, baseUrl = null, variabl
449
449
  const html = applyServiceLinks(applyVariables(compiled, values, variables), { unsubscribeUrl });
450
450
  return absoluteAssetUrls(html, baseUrl);
451
451
  }
452
- function renderEmail({
452
+ async function renderEmail({
453
453
  mjml,
454
454
  subject = null,
455
455
  preheader = null,
@@ -460,7 +460,7 @@ function renderEmail({
460
460
  t = identity,
461
461
  lang = "en"
462
462
  }) {
463
- const { compiled, warnings, quality } = compileTemplate({ mjml, subject, preheader }, { t, lang, variables });
463
+ const { compiled, warnings, quality } = await compileTemplate({ mjml, subject, preheader }, { t, lang, variables });
464
464
  return { html: personalize(compiled, { values, unsubscribeUrl, baseUrl, variables }), warnings, quality };
465
465
  }
466
466
  function htmlToText(html) {
@@ -490,7 +490,7 @@ async function sendTestEmail({
490
490
  if (valid.length > maxRecipients) {
491
491
  throw new HttpError(400, t("{max} test addresses at most", { max: maxRecipients }), "TOO_MANY_RECIPIENTS");
492
492
  }
493
- const { compiled, warnings, quality } = compileTemplate({ mjml, subject, preheader }, { t, lang, variables });
493
+ const { compiled, warnings, quality } = await compileTemplate({ mjml, subject, preheader }, { t, lang, variables });
494
494
  const results = [];
495
495
  for (const email of valid) {
496
496
  try {
@@ -658,10 +658,10 @@ function toVersion(row, { withProject = false } = {}) {
658
658
  }
659
659
  function createTemplateService({ repository, t = identity, lang = "en", maxVersions = MAX_ACTIVE_VERSIONS }) {
660
660
  const inTransaction = (work) => repository.transaction ? repository.transaction(work) : work();
661
- function compile({ document, mjml, subject = null, preheader = null }) {
661
+ async function compile({ document, mjml, subject = null, preheader = null }) {
662
662
  const { json: json2 } = assertValidProject(document, { t });
663
663
  assertValidMjml(mjml, { t });
664
- const { html, warnings } = compileMjml(prepareMjml(mjml, { title: subject, preheader, lang }));
664
+ const { html, warnings } = await compileMjml(prepareMjml(mjml, { title: subject, preheader, lang }));
665
665
  if (!html) throw new HttpError(422, t("Empty MJML compilation"), "EMPTY_COMPILATION");
666
666
  return { projectJson: json2, mjml: String(mjml), html, warnings };
667
667
  }
@@ -690,7 +690,7 @@ function createTemplateService({ repository, t = identity, lang = "en", maxVersi
690
690
  if (!name) throw new HttpError(400, t("Name required"), "NAME_REQUIRED");
691
691
  const subject = text(body?.subject, LIMITS.subject);
692
692
  const preheader = text(body?.preheader, LIMITS.preheader);
693
- const { projectJson, mjml, html, warnings } = compile({ document: body?.document, mjml: body?.mjml, subject, preheader });
693
+ const { projectJson, mjml, html, warnings } = await compile({ document: body?.document, mjml: body?.mjml, subject, preheader });
694
694
  const by = actorName(user);
695
695
  const row = await inTransaction(async () => {
696
696
  const created = await repository.insert({
@@ -727,7 +727,7 @@ function createTemplateService({ repository, t = identity, lang = "en", maxVersi
727
727
  const subject = body?.subject !== void 0 ? text(body.subject, LIMITS.subject) : current.subject;
728
728
  const preheader = body?.preheader !== void 0 ? text(body.preheader, LIMITS.preheader) : current.preheader;
729
729
  const description = body?.description !== void 0 ? text(body.description, LIMITS.description) : current.description;
730
- const { projectJson, mjml, html, warnings } = compile({ document: body?.document, mjml: body?.mjml, subject, preheader });
730
+ const { projectJson, mjml, html, warnings } = await compile({ document: body?.document, mjml: body?.mjml, subject, preheader });
731
731
  const by = actorName(user);
732
732
  const result = await inTransaction(async () => {
733
733
  const updated = await repository.update(
@@ -1059,7 +1059,7 @@ function createEmailBuilderHandler(options) {
1059
1059
  await userFor(request, "read");
1060
1060
  const body = await readJson(request);
1061
1061
  const catalog = await customVariables.catalog();
1062
- const { compiled, warnings, quality } = compileTemplate(
1062
+ const { compiled, warnings, quality } = await compileTemplate(
1063
1063
  { mjml: body?.mjml, subject: body?.subject, preheader: body?.preheader },
1064
1064
  { t, lang, variables: catalog }
1065
1065
  );