@kgalexander/mcreate 0.0.8 → 0.0.10
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.
|
@@ -13961,23 +13961,9 @@ import { EyeIcon } from "lucide-react";
|
|
|
13961
13961
|
|
|
13962
13962
|
// src/render/useMjmlCompiler.ts
|
|
13963
13963
|
import { useState as useState13, useCallback as useCallback15 } from "react";
|
|
13964
|
-
var htmlCache = /* @__PURE__ */ new Map();
|
|
13965
|
-
var MAX_CACHE = 50;
|
|
13966
|
-
function hashMjml(mjml) {
|
|
13967
|
-
let hash = 0;
|
|
13968
|
-
for (let i = 0; i < mjml.length; i++) {
|
|
13969
|
-
hash = (hash << 5) - hash + mjml.charCodeAt(i);
|
|
13970
|
-
hash |= 0;
|
|
13971
|
-
}
|
|
13972
|
-
return hash.toString(36);
|
|
13973
|
-
}
|
|
13974
13964
|
async function compileMjml(mjml) {
|
|
13975
|
-
|
|
13976
|
-
const
|
|
13977
|
-
if (cached) {
|
|
13978
|
-
return cached;
|
|
13979
|
-
}
|
|
13980
|
-
const response = await fetch("/api/mjml", {
|
|
13965
|
+
console.log("Compiling MJML", mjml);
|
|
13966
|
+
const response = await fetch("/api/mrender", {
|
|
13981
13967
|
method: "POST",
|
|
13982
13968
|
headers: { "Content-Type": "application/json" },
|
|
13983
13969
|
body: JSON.stringify({ mjml })
|
|
@@ -13987,11 +13973,6 @@ async function compileMjml(mjml) {
|
|
|
13987
13973
|
throw new Error(errorData.message || "Failed to compile MJML");
|
|
13988
13974
|
}
|
|
13989
13975
|
const result = await response.json();
|
|
13990
|
-
if (htmlCache.size >= MAX_CACHE) {
|
|
13991
|
-
const firstKey = htmlCache.keys().next().value;
|
|
13992
|
-
if (firstKey) htmlCache.delete(firstKey);
|
|
13993
|
-
}
|
|
13994
|
-
htmlCache.set(key, result);
|
|
13995
13976
|
return result;
|
|
13996
13977
|
}
|
|
13997
13978
|
|
|
@@ -14029,6 +14010,7 @@ function Preview() {
|
|
|
14029
14010
|
const convertMjml = async () => {
|
|
14030
14011
|
try {
|
|
14031
14012
|
const mjmlString = json2mjml(template, "production", { isPaid });
|
|
14013
|
+
console.log("MJML string:", mjmlString);
|
|
14032
14014
|
const result = await compileMjml(mjmlString);
|
|
14033
14015
|
if (result.errors?.length > 0) {
|
|
14034
14016
|
console.warn("MJML warnings:", result.errors);
|
package/dist/index.js
CHANGED
|
@@ -14611,21 +14611,9 @@ var init_spinner = __esm({
|
|
|
14611
14611
|
});
|
|
14612
14612
|
|
|
14613
14613
|
// src/render/useMjmlCompiler.ts
|
|
14614
|
-
function hashMjml(mjml) {
|
|
14615
|
-
let hash = 0;
|
|
14616
|
-
for (let i = 0; i < mjml.length; i++) {
|
|
14617
|
-
hash = (hash << 5) - hash + mjml.charCodeAt(i);
|
|
14618
|
-
hash |= 0;
|
|
14619
|
-
}
|
|
14620
|
-
return hash.toString(36);
|
|
14621
|
-
}
|
|
14622
14614
|
async function compileMjml(mjml) {
|
|
14623
|
-
|
|
14624
|
-
const
|
|
14625
|
-
if (cached) {
|
|
14626
|
-
return cached;
|
|
14627
|
-
}
|
|
14628
|
-
const response = await fetch("/api/mjml", {
|
|
14615
|
+
console.log("Compiling MJML", mjml);
|
|
14616
|
+
const response = await fetch("/api/mrender", {
|
|
14629
14617
|
method: "POST",
|
|
14630
14618
|
headers: { "Content-Type": "application/json" },
|
|
14631
14619
|
body: JSON.stringify({ mjml })
|
|
@@ -14635,20 +14623,13 @@ async function compileMjml(mjml) {
|
|
|
14635
14623
|
throw new Error(errorData.message || "Failed to compile MJML");
|
|
14636
14624
|
}
|
|
14637
14625
|
const result = await response.json();
|
|
14638
|
-
if (htmlCache.size >= MAX_CACHE) {
|
|
14639
|
-
const firstKey = htmlCache.keys().next().value;
|
|
14640
|
-
if (firstKey) htmlCache.delete(firstKey);
|
|
14641
|
-
}
|
|
14642
|
-
htmlCache.set(key, result);
|
|
14643
14626
|
return result;
|
|
14644
14627
|
}
|
|
14645
|
-
var import_react32
|
|
14628
|
+
var import_react32;
|
|
14646
14629
|
var init_useMjmlCompiler = __esm({
|
|
14647
14630
|
"src/render/useMjmlCompiler.ts"() {
|
|
14648
14631
|
"use strict";
|
|
14649
14632
|
import_react32 = require("react");
|
|
14650
|
-
htmlCache = /* @__PURE__ */ new Map();
|
|
14651
|
-
MAX_CACHE = 50;
|
|
14652
14633
|
}
|
|
14653
14634
|
});
|
|
14654
14635
|
|
|
@@ -14689,6 +14670,7 @@ function Preview() {
|
|
|
14689
14670
|
const convertMjml = async () => {
|
|
14690
14671
|
try {
|
|
14691
14672
|
const mjmlString = json2mjml(template, "production", { isPaid });
|
|
14673
|
+
console.log("MJML string:", mjmlString);
|
|
14692
14674
|
const result = await compileMjml(mjmlString);
|
|
14693
14675
|
if (result.errors?.length > 0) {
|
|
14694
14676
|
console.warn("MJML warnings:", result.errors);
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
useEditorStore,
|
|
62
62
|
useSidebarContext,
|
|
63
63
|
useUser
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-WO43X63M.mjs";
|
|
65
65
|
|
|
66
66
|
// src/core/editor/components/email-template-v2/header.tsx
|
|
67
67
|
import { ArrowLeftIcon, CopyIcon, MegaphoneIcon, MoreHorizontalIcon, PencilIcon, TrashIcon } from "lucide-react";
|
|
@@ -7810,7 +7810,7 @@ function useAutoSave() {
|
|
|
7810
7810
|
// src/core/editor/components/email-template-v2/template-page.tsx
|
|
7811
7811
|
import "react-json-view-lite/dist/index.css";
|
|
7812
7812
|
import { jsx as jsx67, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
7813
|
-
var Editor2 = lazy(() => import("./core-
|
|
7813
|
+
var Editor2 = lazy(() => import("./core-EII6HF7K.mjs").then((module) => ({
|
|
7814
7814
|
default: module.Editor
|
|
7815
7815
|
})));
|
|
7816
7816
|
function TemplatePage({
|