@firebuzz/design-mode 0.4.1 → 0.4.2

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.
package/dist/index.d.mts CHANGED
@@ -190,12 +190,15 @@ declare function getEmailReactPluginConfig(): {
190
190
  };
191
191
  /**
192
192
  * Vite plugin that enables design mode features for Firebuzz email templates.
193
- * Unlike the landing page version, this does NOT inject Tailwind CDN
194
- * since React Email handles styling internally via inline styles.
195
193
  *
194
+ * - Injects Tailwind v4 Browser CDN for runtime class editing
196
195
  * - Injects overlay script for element selection
197
196
  * - Works with React Email components
198
197
  *
198
+ * NOTE: React Email's <Tailwind> component converts className to inline styles,
199
+ * leaving the class attribute empty. By injecting Tailwind CDN, we enable
200
+ * real-time className updates during design mode.
201
+ *
199
202
  * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()
200
203
  * to enable element source tracking.
201
204
  */
package/dist/index.d.ts CHANGED
@@ -190,12 +190,15 @@ declare function getEmailReactPluginConfig(): {
190
190
  };
191
191
  /**
192
192
  * Vite plugin that enables design mode features for Firebuzz email templates.
193
- * Unlike the landing page version, this does NOT inject Tailwind CDN
194
- * since React Email handles styling internally via inline styles.
195
193
  *
194
+ * - Injects Tailwind v4 Browser CDN for runtime class editing
196
195
  * - Injects overlay script for element selection
197
196
  * - Works with React Email components
198
197
  *
198
+ * NOTE: React Email's <Tailwind> component converts className to inline styles,
199
+ * leaving the class attribute empty. By injecting Tailwind CDN, we enable
200
+ * real-time className updates during design mode.
201
+ *
199
202
  * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()
200
203
  * to enable element source tracking.
201
204
  */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var g=require('fs/promises'),l=require('path'),url=require('url');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);var l__default=/*#__PURE__*/_interopDefault(l);function h(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function b(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",e=process.cwd(),t=l__default.default.resolve(e,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),i=url.fileURLToPath(o),n=l__default.default.resolve(l__default.default.dirname(i),".."),c=l__default.default.join(n,"dist","overlay.mjs"),s=l__default.default.join(n,"dist","overlay.mjs.map");await g__default.default.mkdir(l__default.default.dirname(t),{recursive:!0}),await g__default.default.copyFile(c,t);try{await g__default.default.copyFile(s,`${t}.map`);}catch{}}catch(o){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let i='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',c=`<script type="module" src="${t.replace(e,"")}"></script>`,s=o.replace("</head>",`${i}</head>`);return s=s.replace("</body>",`${c}</body>`),s}}}function $(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function D(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",e=process.cwd(),t=l__default.default.resolve(e,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-email-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),i=url.fileURLToPath(o),n=l__default.default.resolve(l__default.default.dirname(i),".."),c=l__default.default.join(n,"dist","overlay.mjs"),s=l__default.default.join(n,"dist","overlay.mjs.map");await g__default.default.mkdir(l__default.default.dirname(t),{recursive:!0}),await g__default.default.copyFile(c,t);try{await g__default.default.copyFile(s,`${t}.map`);}catch{}}catch(o){console.warn("[Firebuzz Email Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let n=`<script type="module" src="${t.replace(e,"")}"></script>`;return o.replace("</body>",`${n}</body>`)}}}var f={colors:{background:"#FFFFFF",foreground:"#18181B",card:"#FFFFFF",cardForeground:"#18181B",popover:"#FFFFFF",popoverForeground:"#18181B",primary:"#18181B",primaryForeground:"#FFFFFF",secondary:"#F4F4F5",secondaryForeground:"#18181B",muted:"#F4F4F5",mutedForeground:"#71717A",accent:"#F4F4F5",accentForeground:"#18181B",destructive:"#EF4444",destructiveForeground:"#FFFFFF",border:"#E4E4E7",input:"#E4E4E7",ring:"#18181B",chart1:"#E76E50",chart2:"#2A9D90",chart3:"#274754",chart4:"#E8C468",chart5:"#F4A462"},fonts:{primary:"Geist"},borderRadius:{lg:"0.75rem",md:"0.5rem",sm:"0.25rem"}};function R(r){let e=JSON.parse(JSON.stringify(f));try{let o=r.match(/colors:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s)?.[1];if(o){let u=Object.keys(f.colors);for(let a of u){let y=new RegExp(`${a}:\\s*["']([^"']+)["']`),p=o.match(y)?.[1];p&&(e.colors[a]=p);}}let n=r.match(/fonts:\s*\{([^}]+)\}/s)?.[1];if(n){let a=n.match(/primary:\s*["']([^"']+)["']/)?.[1];a&&(e.fonts.primary=a);}let s=r.match(/borderRadius:\s*\{([^}]+)\}/s)?.[1];if(s){let a=s.match(/lg:\s*["']([^"']+)["']/)?.[1];a&&(e.borderRadius.lg=a);let m=s.match(/md:\s*["']([^"']+)["']/)?.[1];m&&(e.borderRadius.md=m);let v=s.match(/sm:\s*["']([^"']+)["']/)?.[1];v&&(e.borderRadius.sm=v);}}catch(t){return console.warn("[parseEmailThemeFromFile] Failed to parse theme:",t),JSON.parse(JSON.stringify(f))}return e}function T(r){return `// LLM Directives:
1
+ 'use strict';var g=require('fs/promises'),l=require('path'),url=require('url');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);var l__default=/*#__PURE__*/_interopDefault(l);function h(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function b(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",t=process.cwd(),s=l__default.default.resolve(t,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),a=url.fileURLToPath(o),n=l__default.default.resolve(l__default.default.dirname(a),".."),i=l__default.default.join(n,"dist","overlay.mjs"),e=l__default.default.join(n,"dist","overlay.mjs.map");await g__default.default.mkdir(l__default.default.dirname(s),{recursive:!0}),await g__default.default.copyFile(i,s);try{await g__default.default.copyFile(e,`${s}.map`);}catch{}}catch(o){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let a='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',i=`<script type="module" src="${s.replace(t,"")}"></script>`,e=o.replace("</head>",`${a}</head>`);return e=e.replace("</body>",`${i}</body>`),e}}}function $(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function D(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",t=process.cwd(),s=l__default.default.resolve(t,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-email-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),a=url.fileURLToPath(o),n=l__default.default.resolve(l__default.default.dirname(a),".."),i=l__default.default.join(n,"dist","overlay.mjs"),e=l__default.default.join(n,"dist","overlay.mjs.map");await g__default.default.mkdir(l__default.default.dirname(s),{recursive:!0}),await g__default.default.copyFile(i,s);try{await g__default.default.copyFile(e,`${s}.map`);}catch{}}catch(o){console.warn("[Firebuzz Email Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let a='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',i=`<script type="module" src="${s.replace(t,"")}"></script>`,e=o.replace("</head>",`${a}</head>`);return e=e.replace("</body>",`${i}</body>`),e}}}var f={colors:{background:"#FFFFFF",foreground:"#18181B",card:"#FFFFFF",cardForeground:"#18181B",popover:"#FFFFFF",popoverForeground:"#18181B",primary:"#18181B",primaryForeground:"#FFFFFF",secondary:"#F4F4F5",secondaryForeground:"#18181B",muted:"#F4F4F5",mutedForeground:"#71717A",accent:"#F4F4F5",accentForeground:"#18181B",destructive:"#EF4444",destructiveForeground:"#FFFFFF",border:"#E4E4E7",input:"#E4E4E7",ring:"#18181B",chart1:"#E76E50",chart2:"#2A9D90",chart3:"#274754",chart4:"#E8C468",chart5:"#F4A462"},fonts:{primary:"Geist"},borderRadius:{lg:"0.75rem",md:"0.5rem",sm:"0.25rem"}};function R(r){let t=JSON.parse(JSON.stringify(f));try{let o=r.match(/colors:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s)?.[1];if(o){let u=Object.keys(f.colors);for(let c of u){let y=new RegExp(`${c}:\\s*["']([^"']+)["']`),m=o.match(y)?.[1];m&&(t.colors[c]=m);}}let n=r.match(/fonts:\s*\{([^}]+)\}/s)?.[1];if(n){let c=n.match(/primary:\s*["']([^"']+)["']/)?.[1];c&&(t.fonts.primary=c);}let e=r.match(/borderRadius:\s*\{([^}]+)\}/s)?.[1];if(e){let c=e.match(/lg:\s*["']([^"']+)["']/)?.[1];c&&(t.borderRadius.lg=c);let p=e.match(/md:\s*["']([^"']+)["']/)?.[1];p&&(t.borderRadius.md=p);let v=e.match(/sm:\s*["']([^"']+)["']/)?.[1];v&&(t.borderRadius.sm=v);}}catch(s){return console.warn("[parseEmailThemeFromFile] Failed to parse theme:",s),JSON.parse(JSON.stringify(f))}return t}function T(r){return `// LLM Directives:
2
2
  // - You can modify color values based on user requests
3
3
  // - All colors must use hex format (email clients don't support oklch)
4
4
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts","../src/vite-plugin-email.ts","../src/email-theme.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml","getEmailReactPluginConfig","firebuzzEmailDesignMode","DEFAULT_EMAIL_THEME","parseEmailThemeFromFile","content","theme","colorsBlock","colorKeys","key","regex","matchedValue","fontsBlock","primaryValue","borderRadiusBlock","lgValue","mdValue","smValue","generateEmailThemeFile"],"mappings":"mUAsBO,SAASA,CAAAA,EAAuB,CAKtC,OAHC,QAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,gBAAA,GAAqB,OAAA,CAM3B,CACN,MAAO,CACN,OAAA,CAAS,CAAC,CAAC,mCAAA,CAAqC,EAAE,CAAC,CACpD,CACD,CAAA,CAPQ,EAQT,CA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AAAA,wBAAA,EACZA,CAAAA,CAAM,OAAO,mBAAmB,CAAA;;AAAA;AAAA,UAAA,EAG9CA,CAAAA,CAAM,OAAO,KAAK,CAAA;AAAA,oBAAA,EACRA,CAAAA,CAAM,OAAO,eAAe,CAAA;;AAAA;AAAA,WAAA,EAGrCA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,qBAAA,EACTA,CAAAA,CAAM,OAAO,gBAAgB,CAAA;;AAAA;AAAA,gBAAA,EAGlCA,CAAAA,CAAM,OAAO,WAAW,CAAA;AAAA,0BAAA,EACdA,CAAAA,CAAM,OAAO,qBAAqB,CAAA;;AAAA;AAAA,WAAA,EAGjDA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,UAAA,EACpBA,CAAAA,CAAM,OAAO,KAAK,CAAA;AAAA,SAAA,EACnBA,CAAAA,CAAM,OAAO,IAAI,CAAA;;AAAA;AAAA,WAAA,EAGfA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA;AAAA;AAAA,YAAA,EAGlBA,CAAAA,CAAM,MAAM,OAAO,CAAA;AAAA;AAAA;AAAA,OAAA,EAGxBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA;AAAA;AAAA,CAI9B","file":"index.js","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration that should be applied to enable design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzDesignMode, getReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getReactPluginConfig()),\n * firebuzzDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Injects Tailwind Play CDN for runtime CSS generation\n * - Injects overlay script for element selection\n *\n * NOTE: You must also configure the React plugin with getReactPluginConfig()\n * to enable element source tracking (works with both React 18 and 19).\n */\nexport function firebuzzDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration for email design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getEmailReactPluginConfig()),\n * firebuzzEmailDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getEmailReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz email templates.\n * Unlike the landing page version, this does NOT inject Tailwind CDN\n * since React Email handles styling internally via inline styles.\n *\n * - Injects overlay script for element selection\n * - Works with React Email components\n *\n * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()\n * to enable element source tracking.\n */\nexport function firebuzzEmailDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-email-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Email Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// NOTE: Unlike landing page design mode, we do NOT inject Tailwind CDN\n\t\t\t// React Email handles styling via inline styles, so Tailwind runtime is not needed\n\n\t\t\t// Inject the overlay script for element selection\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject before </body>\n\t\t\tconst modifiedHtml = html.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","/**\n * Email theme utilities for parsing and generating email theme configuration files.\n * Email templates use a simpler theme format than landing pages:\n * - Hex color values (email clients don't support oklch)\n * - Single font (primary) instead of sans/serif/mono\n * - Border radius object for lg/md/sm\n * - No dark mode support\n */\n\n/**\n * Email theme interface matching the structure in email templates' theme.ts\n */\nexport interface EmailTheme {\n\tcolors: {\n\t\tbackground: string;\n\t\tforeground: string;\n\t\tcard: string;\n\t\tcardForeground: string;\n\t\tpopover: string;\n\t\tpopoverForeground: string;\n\t\tprimary: string;\n\t\tprimaryForeground: string;\n\t\tsecondary: string;\n\t\tsecondaryForeground: string;\n\t\tmuted: string;\n\t\tmutedForeground: string;\n\t\taccent: string;\n\t\taccentForeground: string;\n\t\tdestructive: string;\n\t\tdestructiveForeground: string;\n\t\tborder: string;\n\t\tinput: string;\n\t\tring: string;\n\t\tchart1: string;\n\t\tchart2: string;\n\t\tchart3: string;\n\t\tchart4: string;\n\t\tchart5: string;\n\t};\n\tfonts: {\n\t\tprimary: string;\n\t};\n\tborderRadius: {\n\t\tlg: string;\n\t\tmd: string;\n\t\tsm: string;\n\t};\n}\n\n/**\n * Default email theme values used when parsing fails or values are missing\n */\nconst DEFAULT_EMAIL_THEME: EmailTheme = {\n\tcolors: {\n\t\tbackground: \"#FFFFFF\",\n\t\tforeground: \"#18181B\",\n\t\tcard: \"#FFFFFF\",\n\t\tcardForeground: \"#18181B\",\n\t\tpopover: \"#FFFFFF\",\n\t\tpopoverForeground: \"#18181B\",\n\t\tprimary: \"#18181B\",\n\t\tprimaryForeground: \"#FFFFFF\",\n\t\tsecondary: \"#F4F4F5\",\n\t\tsecondaryForeground: \"#18181B\",\n\t\tmuted: \"#F4F4F5\",\n\t\tmutedForeground: \"#71717A\",\n\t\taccent: \"#F4F4F5\",\n\t\taccentForeground: \"#18181B\",\n\t\tdestructive: \"#EF4444\",\n\t\tdestructiveForeground: \"#FFFFFF\",\n\t\tborder: \"#E4E4E7\",\n\t\tinput: \"#E4E4E7\",\n\t\tring: \"#18181B\",\n\t\tchart1: \"#E76E50\",\n\t\tchart2: \"#2A9D90\",\n\t\tchart3: \"#274754\",\n\t\tchart4: \"#E8C468\",\n\t\tchart5: \"#F4A462\",\n\t},\n\tfonts: {\n\t\tprimary: \"Geist\",\n\t},\n\tborderRadius: {\n\t\tlg: \"0.75rem\",\n\t\tmd: \"0.5rem\",\n\t\tsm: \"0.25rem\",\n\t},\n};\n\n/**\n * Parse an email theme from a theme.ts file content.\n * Extracts color values, fonts, and border radius from the TypeScript source.\n *\n * @param content - The content of the theme.ts file\n * @returns Parsed EmailTheme object\n */\nexport function parseEmailThemeFromFile(content: string): EmailTheme {\n\tconst theme: EmailTheme = JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\n\ttry {\n\t\t// Extract colors object\n\t\tconst colorsMatch = content.match(/colors:\\s*\\{([^}]+(?:\\{[^}]*\\}[^}]*)*)\\}/s);\n\t\tconst colorsBlock = colorsMatch?.[1];\n\t\tif (colorsBlock) {\n\t\t\t// Parse each color property\n\t\t\tconst colorKeys = Object.keys(DEFAULT_EMAIL_THEME.colors) as Array<\n\t\t\t\tkeyof EmailTheme[\"colors\"]\n\t\t\t>;\n\t\t\tfor (const key of colorKeys) {\n\t\t\t\tconst regex = new RegExp(`${key}:\\\\s*[\"']([^\"']+)[\"']`);\n\t\t\t\tconst match = colorsBlock.match(regex);\n\t\t\t\tconst matchedValue = match?.[1];\n\t\t\t\tif (matchedValue) {\n\t\t\t\t\ttheme.colors[key] = matchedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Extract fonts object\n\t\tconst fontsMatch = content.match(/fonts:\\s*\\{([^}]+)\\}/s);\n\t\tconst fontsBlock = fontsMatch?.[1];\n\t\tif (fontsBlock) {\n\t\t\tconst primaryMatch = fontsBlock.match(/primary:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst primaryValue = primaryMatch?.[1];\n\t\t\tif (primaryValue) {\n\t\t\t\ttheme.fonts.primary = primaryValue;\n\t\t\t}\n\t\t}\n\n\t\t// Extract borderRadius object\n\t\tconst borderRadiusMatch = content.match(/borderRadius:\\s*\\{([^}]+)\\}/s);\n\t\tconst borderRadiusBlock = borderRadiusMatch?.[1];\n\t\tif (borderRadiusBlock) {\n\t\t\tconst lgMatch = borderRadiusBlock.match(/lg:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst lgValue = lgMatch?.[1];\n\t\t\tif (lgValue) {\n\t\t\t\ttheme.borderRadius.lg = lgValue;\n\t\t\t}\n\n\t\t\tconst mdMatch = borderRadiusBlock.match(/md:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst mdValue = mdMatch?.[1];\n\t\t\tif (mdValue) {\n\t\t\t\ttheme.borderRadius.md = mdValue;\n\t\t\t}\n\n\t\t\tconst smMatch = borderRadiusBlock.match(/sm:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst smValue = smMatch?.[1];\n\t\t\tif (smValue) {\n\t\t\t\ttheme.borderRadius.sm = smValue;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.warn(\"[parseEmailThemeFromFile] Failed to parse theme:\", error);\n\t\t// Return default theme on parse failure\n\t\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\t}\n\n\treturn theme;\n}\n\n/**\n * Generate a theme.ts file content from an EmailTheme object.\n * Produces a properly formatted TypeScript file that can be written to the email template.\n *\n * @param theme - The EmailTheme object to generate\n * @returns TypeScript file content as a string\n */\nexport function generateEmailThemeFile(theme: EmailTheme): string {\n\treturn `// LLM Directives:\n// - You can modify color values based on user requests\n// - All colors must use hex format (email clients don't support oklch)\n\nexport const themeConfiguration = {\n\tcolors: {\n\t\t// Base colors\n\t\tbackground: \"${theme.colors.background}\",\n\t\tforeground: \"${theme.colors.foreground}\",\n\n\t\t// Card\n\t\tcard: \"${theme.colors.card}\",\n\t\tcardForeground: \"${theme.colors.cardForeground}\",\n\n\t\t// Popover\n\t\tpopover: \"${theme.colors.popover}\",\n\t\tpopoverForeground: \"${theme.colors.popoverForeground}\",\n\n\t\t// Primary\n\t\tprimary: \"${theme.colors.primary}\",\n\t\tprimaryForeground: \"${theme.colors.primaryForeground}\",\n\n\t\t// Secondary\n\t\tsecondary: \"${theme.colors.secondary}\",\n\t\tsecondaryForeground: \"${theme.colors.secondaryForeground}\",\n\n\t\t// Muted\n\t\tmuted: \"${theme.colors.muted}\",\n\t\tmutedForeground: \"${theme.colors.mutedForeground}\",\n\n\t\t// Accent\n\t\taccent: \"${theme.colors.accent}\",\n\t\taccentForeground: \"${theme.colors.accentForeground}\",\n\n\t\t// Destructive\n\t\tdestructive: \"${theme.colors.destructive}\",\n\t\tdestructiveForeground: \"${theme.colors.destructiveForeground}\",\n\n\t\t// Border & Input\n\t\tborder: \"${theme.colors.border}\",\n\t\tinput: \"${theme.colors.input}\",\n\t\tring: \"${theme.colors.ring}\",\n\n\t\t// Chart colors\n\t\tchart1: \"${theme.colors.chart1}\",\n\t\tchart2: \"${theme.colors.chart2}\",\n\t\tchart3: \"${theme.colors.chart3}\",\n\t\tchart4: \"${theme.colors.chart4}\",\n\t\tchart5: \"${theme.colors.chart5}\",\n\t},\n\tfonts: {\n\t\tprimary: \"${theme.fonts.primary}\",\n\t},\n\tborderRadius: {\n\t\tlg: \"${theme.borderRadius.lg}\",\n\t\tmd: \"${theme.borderRadius.md}\",\n\t\tsm: \"${theme.borderRadius.sm}\",\n\t},\n};\n`;\n}\n\n/**\n * Validate that a string is a valid hex color\n */\nexport function isValidHexColor(color: string): boolean {\n\treturn /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);\n}\n\n/**\n * Get the default email theme\n */\nexport function getDefaultEmailTheme(): EmailTheme {\n\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n}\n"]}
1
+ {"version":3,"sources":["../src/vite-plugin.ts","../src/vite-plugin-email.ts","../src/email-theme.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml","getEmailReactPluginConfig","firebuzzEmailDesignMode","DEFAULT_EMAIL_THEME","parseEmailThemeFromFile","content","theme","colorsBlock","colorKeys","key","regex","matchedValue","fontsBlock","primaryValue","borderRadiusBlock","lgValue","mdValue","smValue","generateEmailThemeFile"],"mappings":"mUAsBO,SAAS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AAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA;AAAA;AAAA,CAI9B","file":"index.js","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration that should be applied to enable design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzDesignMode, getReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getReactPluginConfig()),\n * firebuzzDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Injects Tailwind Play CDN for runtime CSS generation\n * - Injects overlay script for element selection\n *\n * NOTE: You must also configure the React plugin with getReactPluginConfig()\n * to enable element source tracking (works with both React 18 and 19).\n */\nexport function firebuzzDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration for email design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getEmailReactPluginConfig()),\n * firebuzzEmailDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getEmailReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz email templates.\n *\n * - Injects Tailwind v4 Browser CDN for runtime class editing\n * - Injects overlay script for element selection\n * - Works with React Email components\n *\n * NOTE: React Email's <Tailwind> component converts className to inline styles,\n * leaving the class attribute empty. By injecting Tailwind CDN, we enable\n * real-time className updates during design mode.\n *\n * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()\n * to enable element source tracking.\n */\nexport function firebuzzEmailDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-email-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Email Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\t// React Email's <Tailwind> converts className to inline styles at render,\n\t\t\t// but we need Tailwind CDN so className edits work in real-time during design mode\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script for element selection\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","/**\n * Email theme utilities for parsing and generating email theme configuration files.\n * Email templates use a simpler theme format than landing pages:\n * - Hex color values (email clients don't support oklch)\n * - Single font (primary) instead of sans/serif/mono\n * - Border radius object for lg/md/sm\n * - No dark mode support\n */\n\n/**\n * Email theme interface matching the structure in email templates' theme.ts\n */\nexport interface EmailTheme {\n\tcolors: {\n\t\tbackground: string;\n\t\tforeground: string;\n\t\tcard: string;\n\t\tcardForeground: string;\n\t\tpopover: string;\n\t\tpopoverForeground: string;\n\t\tprimary: string;\n\t\tprimaryForeground: string;\n\t\tsecondary: string;\n\t\tsecondaryForeground: string;\n\t\tmuted: string;\n\t\tmutedForeground: string;\n\t\taccent: string;\n\t\taccentForeground: string;\n\t\tdestructive: string;\n\t\tdestructiveForeground: string;\n\t\tborder: string;\n\t\tinput: string;\n\t\tring: string;\n\t\tchart1: string;\n\t\tchart2: string;\n\t\tchart3: string;\n\t\tchart4: string;\n\t\tchart5: string;\n\t};\n\tfonts: {\n\t\tprimary: string;\n\t};\n\tborderRadius: {\n\t\tlg: string;\n\t\tmd: string;\n\t\tsm: string;\n\t};\n}\n\n/**\n * Default email theme values used when parsing fails or values are missing\n */\nconst DEFAULT_EMAIL_THEME: EmailTheme = {\n\tcolors: {\n\t\tbackground: \"#FFFFFF\",\n\t\tforeground: \"#18181B\",\n\t\tcard: \"#FFFFFF\",\n\t\tcardForeground: \"#18181B\",\n\t\tpopover: \"#FFFFFF\",\n\t\tpopoverForeground: \"#18181B\",\n\t\tprimary: \"#18181B\",\n\t\tprimaryForeground: \"#FFFFFF\",\n\t\tsecondary: \"#F4F4F5\",\n\t\tsecondaryForeground: \"#18181B\",\n\t\tmuted: \"#F4F4F5\",\n\t\tmutedForeground: \"#71717A\",\n\t\taccent: \"#F4F4F5\",\n\t\taccentForeground: \"#18181B\",\n\t\tdestructive: \"#EF4444\",\n\t\tdestructiveForeground: \"#FFFFFF\",\n\t\tborder: \"#E4E4E7\",\n\t\tinput: \"#E4E4E7\",\n\t\tring: \"#18181B\",\n\t\tchart1: \"#E76E50\",\n\t\tchart2: \"#2A9D90\",\n\t\tchart3: \"#274754\",\n\t\tchart4: \"#E8C468\",\n\t\tchart5: \"#F4A462\",\n\t},\n\tfonts: {\n\t\tprimary: \"Geist\",\n\t},\n\tborderRadius: {\n\t\tlg: \"0.75rem\",\n\t\tmd: \"0.5rem\",\n\t\tsm: \"0.25rem\",\n\t},\n};\n\n/**\n * Parse an email theme from a theme.ts file content.\n * Extracts color values, fonts, and border radius from the TypeScript source.\n *\n * @param content - The content of the theme.ts file\n * @returns Parsed EmailTheme object\n */\nexport function parseEmailThemeFromFile(content: string): EmailTheme {\n\tconst theme: EmailTheme = JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\n\ttry {\n\t\t// Extract colors object\n\t\tconst colorsMatch = content.match(/colors:\\s*\\{([^}]+(?:\\{[^}]*\\}[^}]*)*)\\}/s);\n\t\tconst colorsBlock = colorsMatch?.[1];\n\t\tif (colorsBlock) {\n\t\t\t// Parse each color property\n\t\t\tconst colorKeys = Object.keys(DEFAULT_EMAIL_THEME.colors) as Array<\n\t\t\t\tkeyof EmailTheme[\"colors\"]\n\t\t\t>;\n\t\t\tfor (const key of colorKeys) {\n\t\t\t\tconst regex = new RegExp(`${key}:\\\\s*[\"']([^\"']+)[\"']`);\n\t\t\t\tconst match = colorsBlock.match(regex);\n\t\t\t\tconst matchedValue = match?.[1];\n\t\t\t\tif (matchedValue) {\n\t\t\t\t\ttheme.colors[key] = matchedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Extract fonts object\n\t\tconst fontsMatch = content.match(/fonts:\\s*\\{([^}]+)\\}/s);\n\t\tconst fontsBlock = fontsMatch?.[1];\n\t\tif (fontsBlock) {\n\t\t\tconst primaryMatch = fontsBlock.match(/primary:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst primaryValue = primaryMatch?.[1];\n\t\t\tif (primaryValue) {\n\t\t\t\ttheme.fonts.primary = primaryValue;\n\t\t\t}\n\t\t}\n\n\t\t// Extract borderRadius object\n\t\tconst borderRadiusMatch = content.match(/borderRadius:\\s*\\{([^}]+)\\}/s);\n\t\tconst borderRadiusBlock = borderRadiusMatch?.[1];\n\t\tif (borderRadiusBlock) {\n\t\t\tconst lgMatch = borderRadiusBlock.match(/lg:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst lgValue = lgMatch?.[1];\n\t\t\tif (lgValue) {\n\t\t\t\ttheme.borderRadius.lg = lgValue;\n\t\t\t}\n\n\t\t\tconst mdMatch = borderRadiusBlock.match(/md:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst mdValue = mdMatch?.[1];\n\t\t\tif (mdValue) {\n\t\t\t\ttheme.borderRadius.md = mdValue;\n\t\t\t}\n\n\t\t\tconst smMatch = borderRadiusBlock.match(/sm:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst smValue = smMatch?.[1];\n\t\t\tif (smValue) {\n\t\t\t\ttheme.borderRadius.sm = smValue;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.warn(\"[parseEmailThemeFromFile] Failed to parse theme:\", error);\n\t\t// Return default theme on parse failure\n\t\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\t}\n\n\treturn theme;\n}\n\n/**\n * Generate a theme.ts file content from an EmailTheme object.\n * Produces a properly formatted TypeScript file that can be written to the email template.\n *\n * @param theme - The EmailTheme object to generate\n * @returns TypeScript file content as a string\n */\nexport function generateEmailThemeFile(theme: EmailTheme): string {\n\treturn `// LLM Directives:\n// - You can modify color values based on user requests\n// - All colors must use hex format (email clients don't support oklch)\n\nexport const themeConfiguration = {\n\tcolors: {\n\t\t// Base colors\n\t\tbackground: \"${theme.colors.background}\",\n\t\tforeground: \"${theme.colors.foreground}\",\n\n\t\t// Card\n\t\tcard: \"${theme.colors.card}\",\n\t\tcardForeground: \"${theme.colors.cardForeground}\",\n\n\t\t// Popover\n\t\tpopover: \"${theme.colors.popover}\",\n\t\tpopoverForeground: \"${theme.colors.popoverForeground}\",\n\n\t\t// Primary\n\t\tprimary: \"${theme.colors.primary}\",\n\t\tprimaryForeground: \"${theme.colors.primaryForeground}\",\n\n\t\t// Secondary\n\t\tsecondary: \"${theme.colors.secondary}\",\n\t\tsecondaryForeground: \"${theme.colors.secondaryForeground}\",\n\n\t\t// Muted\n\t\tmuted: \"${theme.colors.muted}\",\n\t\tmutedForeground: \"${theme.colors.mutedForeground}\",\n\n\t\t// Accent\n\t\taccent: \"${theme.colors.accent}\",\n\t\taccentForeground: \"${theme.colors.accentForeground}\",\n\n\t\t// Destructive\n\t\tdestructive: \"${theme.colors.destructive}\",\n\t\tdestructiveForeground: \"${theme.colors.destructiveForeground}\",\n\n\t\t// Border & Input\n\t\tborder: \"${theme.colors.border}\",\n\t\tinput: \"${theme.colors.input}\",\n\t\tring: \"${theme.colors.ring}\",\n\n\t\t// Chart colors\n\t\tchart1: \"${theme.colors.chart1}\",\n\t\tchart2: \"${theme.colors.chart2}\",\n\t\tchart3: \"${theme.colors.chart3}\",\n\t\tchart4: \"${theme.colors.chart4}\",\n\t\tchart5: \"${theme.colors.chart5}\",\n\t},\n\tfonts: {\n\t\tprimary: \"${theme.fonts.primary}\",\n\t},\n\tborderRadius: {\n\t\tlg: \"${theme.borderRadius.lg}\",\n\t\tmd: \"${theme.borderRadius.md}\",\n\t\tsm: \"${theme.borderRadius.sm}\",\n\t},\n};\n`;\n}\n\n/**\n * Validate that a string is a valid hex color\n */\nexport function isValidHexColor(color: string): boolean {\n\treturn /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);\n}\n\n/**\n * Get the default email theme\n */\nexport function getDefaultEmailTheme(): EmailTheme {\n\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n}\n"]}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import g from'fs/promises';import l from'path';import {fileURLToPath}from'url';function h(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function b(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",e=process.cwd(),t=l.resolve(e,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=import.meta.url,i=fileURLToPath(o),n=l.resolve(l.dirname(i),".."),c=l.join(n,"dist","overlay.mjs"),s=l.join(n,"dist","overlay.mjs.map");await g.mkdir(l.dirname(t),{recursive:!0}),await g.copyFile(c,t);try{await g.copyFile(s,`${t}.map`);}catch{}}catch(o){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let i='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',c=`<script type="module" src="${t.replace(e,"")}"></script>`,s=o.replace("</head>",`${i}</head>`);return s=s.replace("</body>",`${c}</body>`),s}}}function $(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function D(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",e=process.cwd(),t=l.resolve(e,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-email-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=import.meta.url,i=fileURLToPath(o),n=l.resolve(l.dirname(i),".."),c=l.join(n,"dist","overlay.mjs"),s=l.join(n,"dist","overlay.mjs.map");await g.mkdir(l.dirname(t),{recursive:!0}),await g.copyFile(c,t);try{await g.copyFile(s,`${t}.map`);}catch{}}catch(o){console.warn("[Firebuzz Email Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let n=`<script type="module" src="${t.replace(e,"")}"></script>`;return o.replace("</body>",`${n}</body>`)}}}var f={colors:{background:"#FFFFFF",foreground:"#18181B",card:"#FFFFFF",cardForeground:"#18181B",popover:"#FFFFFF",popoverForeground:"#18181B",primary:"#18181B",primaryForeground:"#FFFFFF",secondary:"#F4F4F5",secondaryForeground:"#18181B",muted:"#F4F4F5",mutedForeground:"#71717A",accent:"#F4F4F5",accentForeground:"#18181B",destructive:"#EF4444",destructiveForeground:"#FFFFFF",border:"#E4E4E7",input:"#E4E4E7",ring:"#18181B",chart1:"#E76E50",chart2:"#2A9D90",chart3:"#274754",chart4:"#E8C468",chart5:"#F4A462"},fonts:{primary:"Geist"},borderRadius:{lg:"0.75rem",md:"0.5rem",sm:"0.25rem"}};function R(r){let e=JSON.parse(JSON.stringify(f));try{let o=r.match(/colors:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s)?.[1];if(o){let u=Object.keys(f.colors);for(let a of u){let y=new RegExp(`${a}:\\s*["']([^"']+)["']`),p=o.match(y)?.[1];p&&(e.colors[a]=p);}}let n=r.match(/fonts:\s*\{([^}]+)\}/s)?.[1];if(n){let a=n.match(/primary:\s*["']([^"']+)["']/)?.[1];a&&(e.fonts.primary=a);}let s=r.match(/borderRadius:\s*\{([^}]+)\}/s)?.[1];if(s){let a=s.match(/lg:\s*["']([^"']+)["']/)?.[1];a&&(e.borderRadius.lg=a);let m=s.match(/md:\s*["']([^"']+)["']/)?.[1];m&&(e.borderRadius.md=m);let v=s.match(/sm:\s*["']([^"']+)["']/)?.[1];v&&(e.borderRadius.sm=v);}}catch(t){return console.warn("[parseEmailThemeFromFile] Failed to parse theme:",t),JSON.parse(JSON.stringify(f))}return e}function T(r){return `// LLM Directives:
1
+ import g from'fs/promises';import l from'path';import {fileURLToPath}from'url';function h(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function b(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",t=process.cwd(),s=l.resolve(t,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=import.meta.url,a=fileURLToPath(o),n=l.resolve(l.dirname(a),".."),i=l.join(n,"dist","overlay.mjs"),e=l.join(n,"dist","overlay.mjs.map");await g.mkdir(l.dirname(s),{recursive:!0}),await g.copyFile(i,s);try{await g.copyFile(e,`${s}.map`);}catch{}}catch(o){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let a='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',i=`<script type="module" src="${s.replace(t,"")}"></script>`,e=o.replace("</head>",`${a}</head>`);return e=e.replace("</body>",`${i}</body>`),e}}}function $(){return process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false"?{babel:{plugins:[["@react-dev-inspector/babel-plugin",{}]]}}:{}}function D(){let r=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",t=process.cwd(),s=l.resolve(t,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs");return {name:"vite-plugin-firebuzz-email-design-mode",enforce:"pre",async buildStart(){if(r)try{let o=import.meta.url,a=fileURLToPath(o),n=l.resolve(l.dirname(a),".."),i=l.join(n,"dist","overlay.mjs"),e=l.join(n,"dist","overlay.mjs.map");await g.mkdir(l.dirname(s),{recursive:!0}),await g.copyFile(i,s);try{await g.copyFile(e,`${s}.map`);}catch{}}catch(o){console.warn("[Firebuzz Email Design Mode] Could not copy overlay file:",o);}},transformIndexHtml(o){if(!r)return o;let a='<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>',i=`<script type="module" src="${s.replace(t,"")}"></script>`,e=o.replace("</head>",`${a}</head>`);return e=e.replace("</body>",`${i}</body>`),e}}}var f={colors:{background:"#FFFFFF",foreground:"#18181B",card:"#FFFFFF",cardForeground:"#18181B",popover:"#FFFFFF",popoverForeground:"#18181B",primary:"#18181B",primaryForeground:"#FFFFFF",secondary:"#F4F4F5",secondaryForeground:"#18181B",muted:"#F4F4F5",mutedForeground:"#71717A",accent:"#F4F4F5",accentForeground:"#18181B",destructive:"#EF4444",destructiveForeground:"#FFFFFF",border:"#E4E4E7",input:"#E4E4E7",ring:"#18181B",chart1:"#E76E50",chart2:"#2A9D90",chart3:"#274754",chart4:"#E8C468",chart5:"#F4A462"},fonts:{primary:"Geist"},borderRadius:{lg:"0.75rem",md:"0.5rem",sm:"0.25rem"}};function R(r){let t=JSON.parse(JSON.stringify(f));try{let o=r.match(/colors:\s*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}/s)?.[1];if(o){let u=Object.keys(f.colors);for(let c of u){let y=new RegExp(`${c}:\\s*["']([^"']+)["']`),m=o.match(y)?.[1];m&&(t.colors[c]=m);}}let n=r.match(/fonts:\s*\{([^}]+)\}/s)?.[1];if(n){let c=n.match(/primary:\s*["']([^"']+)["']/)?.[1];c&&(t.fonts.primary=c);}let e=r.match(/borderRadius:\s*\{([^}]+)\}/s)?.[1];if(e){let c=e.match(/lg:\s*["']([^"']+)["']/)?.[1];c&&(t.borderRadius.lg=c);let p=e.match(/md:\s*["']([^"']+)["']/)?.[1];p&&(t.borderRadius.md=p);let v=e.match(/sm:\s*["']([^"']+)["']/)?.[1];v&&(t.borderRadius.sm=v);}}catch(s){return console.warn("[parseEmailThemeFromFile] Failed to parse theme:",s),JSON.parse(JSON.stringify(f))}return t}function T(r){return `// LLM Directives:
2
2
  // - You can modify color values based on user requests
3
3
  // - All colors must use hex format (email clients don't support oklch)
4
4
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts","../src/vite-plugin-email.ts","../src/email-theme.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml","getEmailReactPluginConfig","firebuzzEmailDesignMode","DEFAULT_EMAIL_THEME","parseEmailThemeFromFile","content","theme","colorsBlock","colorKeys","key","regex","matchedValue","fontsBlock","primaryValue","borderRadiusBlock","lgValue","mdValue","smValue","generateEmailThemeFile"],"mappings":"+EAsBO,SAASA,CAAAA,EAAuB,CAKtC,OAHC,QAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,gBAAA,GAAqB,OAAA,CAM3B,CACN,MAAO,CACN,OAAA,CAAS,CAAC,CAAC,mCAAA,CAAqC,EAAE,CAAC,CACpD,CACD,CAAA,CAPQ,EAQT,CAUO,SAASC,CAAAA,EAA6B,CAE5C,IAAMC,CAAAA,CACL,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,gBAAA,GAAqB,QAE5BC,CAAAA,CAAc,OAAA,CAAQ,GAAA,EAAI,CAE1BC,CAAAA,CAAoBC,CAAAA,CAAK,OAAA,CAC9BF,CAAAA,CACA,8DACD,CAAA,CAEA,OAAO,CACN,IAAA,CAAM,mCACN,OAAA,CAAS,KAAA,CAET,MAAM,UAAA,EAAa,CAClB,GAAKD,CAAAA,CAGL,GAAI,CAEH,IAAMI,CAAAA,CAAiB,MAAA,CAAA,IAAA,CAAY,GAAA,CAC7BC,EAAkBC,aAAAA,CAAcF,CAAc,CAAA,CAC9CG,CAAAA,CAAcJ,CAAAA,CAAK,OAAA,CAAQA,CAAAA,CAAK,OAAA,CAAQE,CAAe,CAAA,CAAG,IAAI,CAAA,CAC9DG,CAAA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GfA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA;AAAA;AAAA,YAAA,EAGlBA,CAAAA,CAAM,MAAM,OAAO,CAAA;AAAA;AAAA;AAAA,OAAA,EAGxBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA;AAAA;AAAA,CAI9B","file":"index.mjs","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration that should be applied to enable design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzDesignMode, getReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getReactPluginConfig()),\n * firebuzzDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Injects Tailwind Play CDN for runtime CSS generation\n * - Injects overlay script for element selection\n *\n * NOTE: You must also configure the React plugin with getReactPluginConfig()\n * to enable element source tracking (works with both React 18 and 19).\n */\nexport function firebuzzDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration for email design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getEmailReactPluginConfig()),\n * firebuzzEmailDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getEmailReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz email templates.\n * Unlike the landing page version, this does NOT inject Tailwind CDN\n * since React Email handles styling internally via inline styles.\n *\n * - Injects overlay script for element selection\n * - Works with React Email components\n *\n * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()\n * to enable element source tracking.\n */\nexport function firebuzzEmailDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-email-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Email Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// NOTE: Unlike landing page design mode, we do NOT inject Tailwind CDN\n\t\t\t// React Email handles styling via inline styles, so Tailwind runtime is not needed\n\n\t\t\t// Inject the overlay script for element selection\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject before </body>\n\t\t\tconst modifiedHtml = html.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","/**\n * Email theme utilities for parsing and generating email theme configuration files.\n * Email templates use a simpler theme format than landing pages:\n * - Hex color values (email clients don't support oklch)\n * - Single font (primary) instead of sans/serif/mono\n * - Border radius object for lg/md/sm\n * - No dark mode support\n */\n\n/**\n * Email theme interface matching the structure in email templates' theme.ts\n */\nexport interface EmailTheme {\n\tcolors: {\n\t\tbackground: string;\n\t\tforeground: string;\n\t\tcard: string;\n\t\tcardForeground: string;\n\t\tpopover: string;\n\t\tpopoverForeground: string;\n\t\tprimary: string;\n\t\tprimaryForeground: string;\n\t\tsecondary: string;\n\t\tsecondaryForeground: string;\n\t\tmuted: string;\n\t\tmutedForeground: string;\n\t\taccent: string;\n\t\taccentForeground: string;\n\t\tdestructive: string;\n\t\tdestructiveForeground: string;\n\t\tborder: string;\n\t\tinput: string;\n\t\tring: string;\n\t\tchart1: string;\n\t\tchart2: string;\n\t\tchart3: string;\n\t\tchart4: string;\n\t\tchart5: string;\n\t};\n\tfonts: {\n\t\tprimary: string;\n\t};\n\tborderRadius: {\n\t\tlg: string;\n\t\tmd: string;\n\t\tsm: string;\n\t};\n}\n\n/**\n * Default email theme values used when parsing fails or values are missing\n */\nconst DEFAULT_EMAIL_THEME: EmailTheme = {\n\tcolors: {\n\t\tbackground: \"#FFFFFF\",\n\t\tforeground: \"#18181B\",\n\t\tcard: \"#FFFFFF\",\n\t\tcardForeground: \"#18181B\",\n\t\tpopover: \"#FFFFFF\",\n\t\tpopoverForeground: \"#18181B\",\n\t\tprimary: \"#18181B\",\n\t\tprimaryForeground: \"#FFFFFF\",\n\t\tsecondary: \"#F4F4F5\",\n\t\tsecondaryForeground: \"#18181B\",\n\t\tmuted: \"#F4F4F5\",\n\t\tmutedForeground: \"#71717A\",\n\t\taccent: \"#F4F4F5\",\n\t\taccentForeground: \"#18181B\",\n\t\tdestructive: \"#EF4444\",\n\t\tdestructiveForeground: \"#FFFFFF\",\n\t\tborder: \"#E4E4E7\",\n\t\tinput: \"#E4E4E7\",\n\t\tring: \"#18181B\",\n\t\tchart1: \"#E76E50\",\n\t\tchart2: \"#2A9D90\",\n\t\tchart3: \"#274754\",\n\t\tchart4: \"#E8C468\",\n\t\tchart5: \"#F4A462\",\n\t},\n\tfonts: {\n\t\tprimary: \"Geist\",\n\t},\n\tborderRadius: {\n\t\tlg: \"0.75rem\",\n\t\tmd: \"0.5rem\",\n\t\tsm: \"0.25rem\",\n\t},\n};\n\n/**\n * Parse an email theme from a theme.ts file content.\n * Extracts color values, fonts, and border radius from the TypeScript source.\n *\n * @param content - The content of the theme.ts file\n * @returns Parsed EmailTheme object\n */\nexport function parseEmailThemeFromFile(content: string): EmailTheme {\n\tconst theme: EmailTheme = JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\n\ttry {\n\t\t// Extract colors object\n\t\tconst colorsMatch = content.match(/colors:\\s*\\{([^}]+(?:\\{[^}]*\\}[^}]*)*)\\}/s);\n\t\tconst colorsBlock = colorsMatch?.[1];\n\t\tif (colorsBlock) {\n\t\t\t// Parse each color property\n\t\t\tconst colorKeys = Object.keys(DEFAULT_EMAIL_THEME.colors) as Array<\n\t\t\t\tkeyof EmailTheme[\"colors\"]\n\t\t\t>;\n\t\t\tfor (const key of colorKeys) {\n\t\t\t\tconst regex = new RegExp(`${key}:\\\\s*[\"']([^\"']+)[\"']`);\n\t\t\t\tconst match = colorsBlock.match(regex);\n\t\t\t\tconst matchedValue = match?.[1];\n\t\t\t\tif (matchedValue) {\n\t\t\t\t\ttheme.colors[key] = matchedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Extract fonts object\n\t\tconst fontsMatch = content.match(/fonts:\\s*\\{([^}]+)\\}/s);\n\t\tconst fontsBlock = fontsMatch?.[1];\n\t\tif (fontsBlock) {\n\t\t\tconst primaryMatch = fontsBlock.match(/primary:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst primaryValue = primaryMatch?.[1];\n\t\t\tif (primaryValue) {\n\t\t\t\ttheme.fonts.primary = primaryValue;\n\t\t\t}\n\t\t}\n\n\t\t// Extract borderRadius object\n\t\tconst borderRadiusMatch = content.match(/borderRadius:\\s*\\{([^}]+)\\}/s);\n\t\tconst borderRadiusBlock = borderRadiusMatch?.[1];\n\t\tif (borderRadiusBlock) {\n\t\t\tconst lgMatch = borderRadiusBlock.match(/lg:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst lgValue = lgMatch?.[1];\n\t\t\tif (lgValue) {\n\t\t\t\ttheme.borderRadius.lg = lgValue;\n\t\t\t}\n\n\t\t\tconst mdMatch = borderRadiusBlock.match(/md:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst mdValue = mdMatch?.[1];\n\t\t\tif (mdValue) {\n\t\t\t\ttheme.borderRadius.md = mdValue;\n\t\t\t}\n\n\t\t\tconst smMatch = borderRadiusBlock.match(/sm:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst smValue = smMatch?.[1];\n\t\t\tif (smValue) {\n\t\t\t\ttheme.borderRadius.sm = smValue;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.warn(\"[parseEmailThemeFromFile] Failed to parse theme:\", error);\n\t\t// Return default theme on parse failure\n\t\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\t}\n\n\treturn theme;\n}\n\n/**\n * Generate a theme.ts file content from an EmailTheme object.\n * Produces a properly formatted TypeScript file that can be written to the email template.\n *\n * @param theme - The EmailTheme object to generate\n * @returns TypeScript file content as a string\n */\nexport function generateEmailThemeFile(theme: EmailTheme): string {\n\treturn `// LLM Directives:\n// - You can modify color values based on user requests\n// - All colors must use hex format (email clients don't support oklch)\n\nexport const themeConfiguration = {\n\tcolors: {\n\t\t// Base colors\n\t\tbackground: \"${theme.colors.background}\",\n\t\tforeground: \"${theme.colors.foreground}\",\n\n\t\t// Card\n\t\tcard: \"${theme.colors.card}\",\n\t\tcardForeground: \"${theme.colors.cardForeground}\",\n\n\t\t// Popover\n\t\tpopover: \"${theme.colors.popover}\",\n\t\tpopoverForeground: \"${theme.colors.popoverForeground}\",\n\n\t\t// Primary\n\t\tprimary: \"${theme.colors.primary}\",\n\t\tprimaryForeground: \"${theme.colors.primaryForeground}\",\n\n\t\t// Secondary\n\t\tsecondary: \"${theme.colors.secondary}\",\n\t\tsecondaryForeground: \"${theme.colors.secondaryForeground}\",\n\n\t\t// Muted\n\t\tmuted: \"${theme.colors.muted}\",\n\t\tmutedForeground: \"${theme.colors.mutedForeground}\",\n\n\t\t// Accent\n\t\taccent: \"${theme.colors.accent}\",\n\t\taccentForeground: \"${theme.colors.accentForeground}\",\n\n\t\t// Destructive\n\t\tdestructive: \"${theme.colors.destructive}\",\n\t\tdestructiveForeground: \"${theme.colors.destructiveForeground}\",\n\n\t\t// Border & Input\n\t\tborder: \"${theme.colors.border}\",\n\t\tinput: \"${theme.colors.input}\",\n\t\tring: \"${theme.colors.ring}\",\n\n\t\t// Chart colors\n\t\tchart1: \"${theme.colors.chart1}\",\n\t\tchart2: \"${theme.colors.chart2}\",\n\t\tchart3: \"${theme.colors.chart3}\",\n\t\tchart4: \"${theme.colors.chart4}\",\n\t\tchart5: \"${theme.colors.chart5}\",\n\t},\n\tfonts: {\n\t\tprimary: \"${theme.fonts.primary}\",\n\t},\n\tborderRadius: {\n\t\tlg: \"${theme.borderRadius.lg}\",\n\t\tmd: \"${theme.borderRadius.md}\",\n\t\tsm: \"${theme.borderRadius.sm}\",\n\t},\n};\n`;\n}\n\n/**\n * Validate that a string is a valid hex color\n */\nexport function isValidHexColor(color: string): boolean {\n\treturn /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);\n}\n\n/**\n * Get the default email theme\n */\nexport function getDefaultEmailTheme(): EmailTheme {\n\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n}\n"]}
1
+ {"version":3,"sources":["../src/vite-plugin.ts","../src/vite-plugin-email.ts","../src/email-theme.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml","getEmailReactPluginConfig","firebuzzEmailDesignMode","DEFAULT_EMAIL_THEME","parseEmailThemeFromFile","content","theme","colorsBlock","colorKeys","key","regex","matchedValue","fontsBlock","primaryValue","borderRadiusBlock","lgValue","mdValue","smValue","generateEmailThemeFile"],"mappings":"+EAsBO,SAASA,CAAAA,EAAuB,CAKtC,OAHC,QAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,gBAAA,GAAqB,OAAA,CAM3B,CACN,MAAO,CACN,OAAA,CAAS,CAAC,CAAC,oCAAqC,EAAE,CAAC,CACpD,CACD,CAAA,CAPQ,EAQT,CAUO,SAASC,CAAAA,EAA6B,CAE5C,IAAMC,EACL,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,QAAQ,GAAA,CAAI,gBAAA,GAAqB,OAAA,CAE5BC,CAAAA,CAAc,QAAQ,GAAA,EAAI,CAE1BC,CAAAA,CAAoBC,CAAAA,CAAK,OAAA,CAC9BF,CAAAA,CACA,8DACD,CAAA,CAEA,OAAO,CACN,IAAA,CAAM,kCAAA,CACN,OAAA,CAAS,MAET,MAAM,UAAA,EAAa,CAClB,GAAKD,EAGL,GAA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AAO,gBAAgB,CAAA;;AAAA;AAAA,gBAAA,EAGlCA,CAAAA,CAAM,OAAO,WAAW,CAAA;AAAA,0BAAA,EACdA,CAAAA,CAAM,OAAO,qBAAqB,CAAA;;AAAA;AAAA,WAAA,EAGjDA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,UAAA,EACpBA,CAAAA,CAAM,OAAO,KAAK,CAAA;AAAA,SAAA,EACnBA,CAAAA,CAAM,OAAO,IAAI,CAAA;;AAAA;AAAA,WAAA,EAGfA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA,WAAA,EACnBA,CAAAA,CAAM,OAAO,MAAM,CAAA;AAAA;AAAA;AAAA,YAAA,EAGlBA,CAAAA,CAAM,MAAM,OAAO,CAAA;AAAA;AAAA;AAAA,OAAA,EAGxBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA,OAAA,EACrBA,CAAAA,CAAM,aAAa,EAAE,CAAA;AAAA;AAAA;AAAA,CAI9B","file":"index.mjs","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration that should be applied to enable design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzDesignMode, getReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getReactPluginConfig()),\n * firebuzzDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Injects Tailwind Play CDN for runtime CSS generation\n * - Injects overlay script for element selection\n *\n * NOTE: You must also configure the React plugin with getReactPluginConfig()\n * to enable element source tracking (works with both React 18 and 19).\n */\nexport function firebuzzDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Plugin } from \"vite\";\n\n/**\n * React plugin configuration for email design mode.\n * Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.\n *\n * Usage:\n * ```ts\n * import react from '@vitejs/plugin-react'\n * import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'\n *\n * export default defineConfig({\n * plugins: [\n * react(getEmailReactPluginConfig()),\n * firebuzzEmailDesignMode(),\n * ],\n * })\n * ```\n */\nexport function getEmailReactPluginConfig() {\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tif (!isDesignModeEnabled) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tbabel: {\n\t\t\tplugins: [[\"@react-dev-inspector/babel-plugin\", {}]],\n\t\t},\n\t};\n}\n\n/**\n * Vite plugin that enables design mode features for Firebuzz email templates.\n *\n * - Injects Tailwind v4 Browser CDN for runtime class editing\n * - Injects overlay script for element selection\n * - Works with React Email components\n *\n * NOTE: React Email's <Tailwind> component converts className to inline styles,\n * leaving the class attribute empty. By injecting Tailwind CDN, we enable\n * real-time className updates during design mode.\n *\n * NOTE: You must also configure the React plugin with getEmailReactPluginConfig()\n * to enable element source tracking.\n */\nexport function firebuzzEmailDesignMode(): Plugin {\n\t// Only enable in development, never in production builds\n\tconst isDesignModeEnabled =\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\tprocess.env.VITE_DESIGN_MODE !== \"false\";\n\n\tconst projectRoot = process.cwd();\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.mjs\",\n\t);\n\n\treturn {\n\t\tname: \"vite-plugin-firebuzz-email-design-mode\",\n\t\tenforce: \"pre\",\n\n\t\tasync buildStart() {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Copy overlay file to a location Vite can serve\n\t\t\ttry {\n\t\t\t\t// Find the overlay source file from the package using import.meta.url\n\t\t\t\tconst currentFileUrl = import.meta.url;\n\t\t\t\tconst currentFilePath = fileURLToPath(currentFileUrl);\n\t\t\t\tconst packageRoot = path.resolve(path.dirname(currentFilePath), \"..\");\n\t\t\t\tconst overlaySource = path.join(packageRoot, \"dist\", \"overlay.mjs\");\n\t\t\t\tconst overlaySourceMap = path.join(\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\t\"dist\",\n\t\t\t\t\t\"overlay.mjs.map\",\n\t\t\t\t);\n\n\t\t\t\t// Ensure output directory exists\n\t\t\t\tawait fs.mkdir(path.dirname(overlayOutputPath), { recursive: true });\n\n\t\t\t\t// Copy the overlay file\n\t\t\t\tawait fs.copyFile(overlaySource, overlayOutputPath);\n\n\t\t\t\t// Copy the source map file if it exists\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.copyFile(overlaySourceMap, `${overlayOutputPath}.map`);\n\t\t\t\t} catch {\n\t\t\t\t\t// Source map is optional, ignore if not found\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Email Design Mode] Could not copy overlay file:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\ttransformIndexHtml(html) {\n\t\t\tif (!isDesignModeEnabled) return html;\n\n\t\t\t// Inject Tailwind v4 Browser CDN for runtime CSS generation\n\t\t\t// React Email's <Tailwind> converts className to inline styles at render,\n\t\t\t// but we need Tailwind CDN so className edits work in real-time during design mode\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4\"></script>';\n\n\t\t\t// Inject the overlay script for element selection\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\tconst overlayScript = `<script type=\"module\" src=\"${overlayPath}\"></script>`;\n\n\t\t\t// Inject both in the head (Tailwind CDN) and before </body> (overlay)\n\t\t\tlet modifiedHtml = html.replace(\"</head>\", `${tailwindCDN}</head>`);\n\t\t\tmodifiedHtml = modifiedHtml.replace(\"</body>\", `${overlayScript}</body>`);\n\n\t\t\treturn modifiedHtml;\n\t\t},\n\t};\n}\n","/**\n * Email theme utilities for parsing and generating email theme configuration files.\n * Email templates use a simpler theme format than landing pages:\n * - Hex color values (email clients don't support oklch)\n * - Single font (primary) instead of sans/serif/mono\n * - Border radius object for lg/md/sm\n * - No dark mode support\n */\n\n/**\n * Email theme interface matching the structure in email templates' theme.ts\n */\nexport interface EmailTheme {\n\tcolors: {\n\t\tbackground: string;\n\t\tforeground: string;\n\t\tcard: string;\n\t\tcardForeground: string;\n\t\tpopover: string;\n\t\tpopoverForeground: string;\n\t\tprimary: string;\n\t\tprimaryForeground: string;\n\t\tsecondary: string;\n\t\tsecondaryForeground: string;\n\t\tmuted: string;\n\t\tmutedForeground: string;\n\t\taccent: string;\n\t\taccentForeground: string;\n\t\tdestructive: string;\n\t\tdestructiveForeground: string;\n\t\tborder: string;\n\t\tinput: string;\n\t\tring: string;\n\t\tchart1: string;\n\t\tchart2: string;\n\t\tchart3: string;\n\t\tchart4: string;\n\t\tchart5: string;\n\t};\n\tfonts: {\n\t\tprimary: string;\n\t};\n\tborderRadius: {\n\t\tlg: string;\n\t\tmd: string;\n\t\tsm: string;\n\t};\n}\n\n/**\n * Default email theme values used when parsing fails or values are missing\n */\nconst DEFAULT_EMAIL_THEME: EmailTheme = {\n\tcolors: {\n\t\tbackground: \"#FFFFFF\",\n\t\tforeground: \"#18181B\",\n\t\tcard: \"#FFFFFF\",\n\t\tcardForeground: \"#18181B\",\n\t\tpopover: \"#FFFFFF\",\n\t\tpopoverForeground: \"#18181B\",\n\t\tprimary: \"#18181B\",\n\t\tprimaryForeground: \"#FFFFFF\",\n\t\tsecondary: \"#F4F4F5\",\n\t\tsecondaryForeground: \"#18181B\",\n\t\tmuted: \"#F4F4F5\",\n\t\tmutedForeground: \"#71717A\",\n\t\taccent: \"#F4F4F5\",\n\t\taccentForeground: \"#18181B\",\n\t\tdestructive: \"#EF4444\",\n\t\tdestructiveForeground: \"#FFFFFF\",\n\t\tborder: \"#E4E4E7\",\n\t\tinput: \"#E4E4E7\",\n\t\tring: \"#18181B\",\n\t\tchart1: \"#E76E50\",\n\t\tchart2: \"#2A9D90\",\n\t\tchart3: \"#274754\",\n\t\tchart4: \"#E8C468\",\n\t\tchart5: \"#F4A462\",\n\t},\n\tfonts: {\n\t\tprimary: \"Geist\",\n\t},\n\tborderRadius: {\n\t\tlg: \"0.75rem\",\n\t\tmd: \"0.5rem\",\n\t\tsm: \"0.25rem\",\n\t},\n};\n\n/**\n * Parse an email theme from a theme.ts file content.\n * Extracts color values, fonts, and border radius from the TypeScript source.\n *\n * @param content - The content of the theme.ts file\n * @returns Parsed EmailTheme object\n */\nexport function parseEmailThemeFromFile(content: string): EmailTheme {\n\tconst theme: EmailTheme = JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\n\ttry {\n\t\t// Extract colors object\n\t\tconst colorsMatch = content.match(/colors:\\s*\\{([^}]+(?:\\{[^}]*\\}[^}]*)*)\\}/s);\n\t\tconst colorsBlock = colorsMatch?.[1];\n\t\tif (colorsBlock) {\n\t\t\t// Parse each color property\n\t\t\tconst colorKeys = Object.keys(DEFAULT_EMAIL_THEME.colors) as Array<\n\t\t\t\tkeyof EmailTheme[\"colors\"]\n\t\t\t>;\n\t\t\tfor (const key of colorKeys) {\n\t\t\t\tconst regex = new RegExp(`${key}:\\\\s*[\"']([^\"']+)[\"']`);\n\t\t\t\tconst match = colorsBlock.match(regex);\n\t\t\t\tconst matchedValue = match?.[1];\n\t\t\t\tif (matchedValue) {\n\t\t\t\t\ttheme.colors[key] = matchedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Extract fonts object\n\t\tconst fontsMatch = content.match(/fonts:\\s*\\{([^}]+)\\}/s);\n\t\tconst fontsBlock = fontsMatch?.[1];\n\t\tif (fontsBlock) {\n\t\t\tconst primaryMatch = fontsBlock.match(/primary:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst primaryValue = primaryMatch?.[1];\n\t\t\tif (primaryValue) {\n\t\t\t\ttheme.fonts.primary = primaryValue;\n\t\t\t}\n\t\t}\n\n\t\t// Extract borderRadius object\n\t\tconst borderRadiusMatch = content.match(/borderRadius:\\s*\\{([^}]+)\\}/s);\n\t\tconst borderRadiusBlock = borderRadiusMatch?.[1];\n\t\tif (borderRadiusBlock) {\n\t\t\tconst lgMatch = borderRadiusBlock.match(/lg:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst lgValue = lgMatch?.[1];\n\t\t\tif (lgValue) {\n\t\t\t\ttheme.borderRadius.lg = lgValue;\n\t\t\t}\n\n\t\t\tconst mdMatch = borderRadiusBlock.match(/md:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst mdValue = mdMatch?.[1];\n\t\t\tif (mdValue) {\n\t\t\t\ttheme.borderRadius.md = mdValue;\n\t\t\t}\n\n\t\t\tconst smMatch = borderRadiusBlock.match(/sm:\\s*[\"']([^\"']+)[\"']/);\n\t\t\tconst smValue = smMatch?.[1];\n\t\t\tif (smValue) {\n\t\t\t\ttheme.borderRadius.sm = smValue;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.warn(\"[parseEmailThemeFromFile] Failed to parse theme:\", error);\n\t\t// Return default theme on parse failure\n\t\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n\t}\n\n\treturn theme;\n}\n\n/**\n * Generate a theme.ts file content from an EmailTheme object.\n * Produces a properly formatted TypeScript file that can be written to the email template.\n *\n * @param theme - The EmailTheme object to generate\n * @returns TypeScript file content as a string\n */\nexport function generateEmailThemeFile(theme: EmailTheme): string {\n\treturn `// LLM Directives:\n// - You can modify color values based on user requests\n// - All colors must use hex format (email clients don't support oklch)\n\nexport const themeConfiguration = {\n\tcolors: {\n\t\t// Base colors\n\t\tbackground: \"${theme.colors.background}\",\n\t\tforeground: \"${theme.colors.foreground}\",\n\n\t\t// Card\n\t\tcard: \"${theme.colors.card}\",\n\t\tcardForeground: \"${theme.colors.cardForeground}\",\n\n\t\t// Popover\n\t\tpopover: \"${theme.colors.popover}\",\n\t\tpopoverForeground: \"${theme.colors.popoverForeground}\",\n\n\t\t// Primary\n\t\tprimary: \"${theme.colors.primary}\",\n\t\tprimaryForeground: \"${theme.colors.primaryForeground}\",\n\n\t\t// Secondary\n\t\tsecondary: \"${theme.colors.secondary}\",\n\t\tsecondaryForeground: \"${theme.colors.secondaryForeground}\",\n\n\t\t// Muted\n\t\tmuted: \"${theme.colors.muted}\",\n\t\tmutedForeground: \"${theme.colors.mutedForeground}\",\n\n\t\t// Accent\n\t\taccent: \"${theme.colors.accent}\",\n\t\taccentForeground: \"${theme.colors.accentForeground}\",\n\n\t\t// Destructive\n\t\tdestructive: \"${theme.colors.destructive}\",\n\t\tdestructiveForeground: \"${theme.colors.destructiveForeground}\",\n\n\t\t// Border & Input\n\t\tborder: \"${theme.colors.border}\",\n\t\tinput: \"${theme.colors.input}\",\n\t\tring: \"${theme.colors.ring}\",\n\n\t\t// Chart colors\n\t\tchart1: \"${theme.colors.chart1}\",\n\t\tchart2: \"${theme.colors.chart2}\",\n\t\tchart3: \"${theme.colors.chart3}\",\n\t\tchart4: \"${theme.colors.chart4}\",\n\t\tchart5: \"${theme.colors.chart5}\",\n\t},\n\tfonts: {\n\t\tprimary: \"${theme.fonts.primary}\",\n\t},\n\tborderRadius: {\n\t\tlg: \"${theme.borderRadius.lg}\",\n\t\tmd: \"${theme.borderRadius.md}\",\n\t\tsm: \"${theme.borderRadius.sm}\",\n\t},\n};\n`;\n}\n\n/**\n * Validate that a string is a valid hex color\n */\nexport function isValidHexColor(color: string): boolean {\n\treturn /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color);\n}\n\n/**\n * Get the default email theme\n */\nexport function getDefaultEmailTheme(): EmailTheme {\n\treturn JSON.parse(JSON.stringify(DEFAULT_EMAIL_THEME));\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebuzz/design-mode",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Design mode overlay and utilities for Firebuzz landing page templates",
5
5
  "author": "Firebuzz Team",
6
6
  "license": "MIT",