@firebuzz/design-mode 0.3.0-beta.9 → 0.4.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.
- package/dist/index.d.mts +102 -1
- package/dist/index.d.ts +102 -1
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +62 -61
- package/LICENSE +0 -77
package/dist/index.d.mts
CHANGED
|
@@ -66,6 +66,70 @@ interface AllElementsStateMessage {
|
|
|
66
66
|
}
|
|
67
67
|
type DesignModeMessageType = DesignModeMessage | ElementSelectedMessage | AllElementsStateMessage;
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Email theme utilities for parsing and generating email theme configuration files.
|
|
71
|
+
* Email templates use a simpler theme format than landing pages:
|
|
72
|
+
* - Hex color values (email clients don't support oklch)
|
|
73
|
+
* - Single font (primary) instead of sans/serif/mono
|
|
74
|
+
* - Border radius object for lg/md/sm
|
|
75
|
+
* - No dark mode support
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Email theme interface matching the structure in email templates' theme.ts
|
|
79
|
+
*/
|
|
80
|
+
interface EmailTheme {
|
|
81
|
+
colors: {
|
|
82
|
+
background: string;
|
|
83
|
+
foreground: string;
|
|
84
|
+
card: string;
|
|
85
|
+
cardForeground: string;
|
|
86
|
+
popover: string;
|
|
87
|
+
popoverForeground: string;
|
|
88
|
+
primary: string;
|
|
89
|
+
primaryForeground: string;
|
|
90
|
+
secondary: string;
|
|
91
|
+
secondaryForeground: string;
|
|
92
|
+
muted: string;
|
|
93
|
+
mutedForeground: string;
|
|
94
|
+
accent: string;
|
|
95
|
+
accentForeground: string;
|
|
96
|
+
destructive: string;
|
|
97
|
+
destructiveForeground: string;
|
|
98
|
+
border: string;
|
|
99
|
+
input: string;
|
|
100
|
+
ring: string;
|
|
101
|
+
chart1: string;
|
|
102
|
+
chart2: string;
|
|
103
|
+
chart3: string;
|
|
104
|
+
chart4: string;
|
|
105
|
+
chart5: string;
|
|
106
|
+
};
|
|
107
|
+
fonts: {
|
|
108
|
+
primary: string;
|
|
109
|
+
};
|
|
110
|
+
borderRadius: {
|
|
111
|
+
lg: string;
|
|
112
|
+
md: string;
|
|
113
|
+
sm: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Parse an email theme from a theme.ts file content.
|
|
118
|
+
* Extracts color values, fonts, and border radius from the TypeScript source.
|
|
119
|
+
*
|
|
120
|
+
* @param content - The content of the theme.ts file
|
|
121
|
+
* @returns Parsed EmailTheme object
|
|
122
|
+
*/
|
|
123
|
+
declare function parseEmailThemeFromFile(content: string): EmailTheme;
|
|
124
|
+
/**
|
|
125
|
+
* Generate a theme.ts file content from an EmailTheme object.
|
|
126
|
+
* Produces a properly formatted TypeScript file that can be written to the email template.
|
|
127
|
+
*
|
|
128
|
+
* @param theme - The EmailTheme object to generate
|
|
129
|
+
* @returns TypeScript file content as a string
|
|
130
|
+
*/
|
|
131
|
+
declare function generateEmailThemeFile(theme: EmailTheme): string;
|
|
132
|
+
|
|
69
133
|
/**
|
|
70
134
|
* React plugin configuration that should be applied to enable design mode.
|
|
71
135
|
* Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.
|
|
@@ -100,4 +164,41 @@ declare function getReactPluginConfig(): {
|
|
|
100
164
|
*/
|
|
101
165
|
declare function firebuzzDesignMode(): Plugin;
|
|
102
166
|
|
|
103
|
-
|
|
167
|
+
/**
|
|
168
|
+
* React plugin configuration for email design mode.
|
|
169
|
+
* Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.
|
|
170
|
+
*
|
|
171
|
+
* Usage:
|
|
172
|
+
* ```ts
|
|
173
|
+
* import react from '@vitejs/plugin-react'
|
|
174
|
+
* import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'
|
|
175
|
+
*
|
|
176
|
+
* export default defineConfig({
|
|
177
|
+
* plugins: [
|
|
178
|
+
* react(getEmailReactPluginConfig()),
|
|
179
|
+
* firebuzzEmailDesignMode(),
|
|
180
|
+
* ],
|
|
181
|
+
* })
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare function getEmailReactPluginConfig(): {
|
|
185
|
+
babel?: undefined;
|
|
186
|
+
} | {
|
|
187
|
+
babel: {
|
|
188
|
+
plugins: {}[][];
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
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
|
+
*
|
|
196
|
+
* - Injects overlay script for element selection
|
|
197
|
+
* - Works with React Email components
|
|
198
|
+
*
|
|
199
|
+
* NOTE: You must also configure the React plugin with getEmailReactPluginConfig()
|
|
200
|
+
* to enable element source tracking.
|
|
201
|
+
*/
|
|
202
|
+
declare function firebuzzEmailDesignMode(): Plugin;
|
|
203
|
+
|
|
204
|
+
export { type AllElementsStateMessage, type DesignModeMessage, type DesignModeMessageType, type ElementData, type ElementSelectedMessage, type ElementUpdates, type EmailTheme, type SourceLocation, type ThemeVariables, firebuzzDesignMode, firebuzzEmailDesignMode, generateEmailThemeFile, getEmailReactPluginConfig, getReactPluginConfig, parseEmailThemeFromFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,70 @@ interface AllElementsStateMessage {
|
|
|
66
66
|
}
|
|
67
67
|
type DesignModeMessageType = DesignModeMessage | ElementSelectedMessage | AllElementsStateMessage;
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Email theme utilities for parsing and generating email theme configuration files.
|
|
71
|
+
* Email templates use a simpler theme format than landing pages:
|
|
72
|
+
* - Hex color values (email clients don't support oklch)
|
|
73
|
+
* - Single font (primary) instead of sans/serif/mono
|
|
74
|
+
* - Border radius object for lg/md/sm
|
|
75
|
+
* - No dark mode support
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Email theme interface matching the structure in email templates' theme.ts
|
|
79
|
+
*/
|
|
80
|
+
interface EmailTheme {
|
|
81
|
+
colors: {
|
|
82
|
+
background: string;
|
|
83
|
+
foreground: string;
|
|
84
|
+
card: string;
|
|
85
|
+
cardForeground: string;
|
|
86
|
+
popover: string;
|
|
87
|
+
popoverForeground: string;
|
|
88
|
+
primary: string;
|
|
89
|
+
primaryForeground: string;
|
|
90
|
+
secondary: string;
|
|
91
|
+
secondaryForeground: string;
|
|
92
|
+
muted: string;
|
|
93
|
+
mutedForeground: string;
|
|
94
|
+
accent: string;
|
|
95
|
+
accentForeground: string;
|
|
96
|
+
destructive: string;
|
|
97
|
+
destructiveForeground: string;
|
|
98
|
+
border: string;
|
|
99
|
+
input: string;
|
|
100
|
+
ring: string;
|
|
101
|
+
chart1: string;
|
|
102
|
+
chart2: string;
|
|
103
|
+
chart3: string;
|
|
104
|
+
chart4: string;
|
|
105
|
+
chart5: string;
|
|
106
|
+
};
|
|
107
|
+
fonts: {
|
|
108
|
+
primary: string;
|
|
109
|
+
};
|
|
110
|
+
borderRadius: {
|
|
111
|
+
lg: string;
|
|
112
|
+
md: string;
|
|
113
|
+
sm: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Parse an email theme from a theme.ts file content.
|
|
118
|
+
* Extracts color values, fonts, and border radius from the TypeScript source.
|
|
119
|
+
*
|
|
120
|
+
* @param content - The content of the theme.ts file
|
|
121
|
+
* @returns Parsed EmailTheme object
|
|
122
|
+
*/
|
|
123
|
+
declare function parseEmailThemeFromFile(content: string): EmailTheme;
|
|
124
|
+
/**
|
|
125
|
+
* Generate a theme.ts file content from an EmailTheme object.
|
|
126
|
+
* Produces a properly formatted TypeScript file that can be written to the email template.
|
|
127
|
+
*
|
|
128
|
+
* @param theme - The EmailTheme object to generate
|
|
129
|
+
* @returns TypeScript file content as a string
|
|
130
|
+
*/
|
|
131
|
+
declare function generateEmailThemeFile(theme: EmailTheme): string;
|
|
132
|
+
|
|
69
133
|
/**
|
|
70
134
|
* React plugin configuration that should be applied to enable design mode.
|
|
71
135
|
* Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.
|
|
@@ -100,4 +164,41 @@ declare function getReactPluginConfig(): {
|
|
|
100
164
|
*/
|
|
101
165
|
declare function firebuzzDesignMode(): Plugin;
|
|
102
166
|
|
|
103
|
-
|
|
167
|
+
/**
|
|
168
|
+
* React plugin configuration for email design mode.
|
|
169
|
+
* Works with both @vitejs/plugin-react and @vitejs/plugin-react-swc.
|
|
170
|
+
*
|
|
171
|
+
* Usage:
|
|
172
|
+
* ```ts
|
|
173
|
+
* import react from '@vitejs/plugin-react'
|
|
174
|
+
* import { firebuzzEmailDesignMode, getEmailReactPluginConfig } from '@firebuzz/design-mode'
|
|
175
|
+
*
|
|
176
|
+
* export default defineConfig({
|
|
177
|
+
* plugins: [
|
|
178
|
+
* react(getEmailReactPluginConfig()),
|
|
179
|
+
* firebuzzEmailDesignMode(),
|
|
180
|
+
* ],
|
|
181
|
+
* })
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare function getEmailReactPluginConfig(): {
|
|
185
|
+
babel?: undefined;
|
|
186
|
+
} | {
|
|
187
|
+
babel: {
|
|
188
|
+
plugins: {}[][];
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
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
|
+
*
|
|
196
|
+
* - Injects overlay script for element selection
|
|
197
|
+
* - Works with React Email components
|
|
198
|
+
*
|
|
199
|
+
* NOTE: You must also configure the React plugin with getEmailReactPluginConfig()
|
|
200
|
+
* to enable element source tracking.
|
|
201
|
+
*/
|
|
202
|
+
declare function firebuzzEmailDesignMode(): Plugin;
|
|
203
|
+
|
|
204
|
+
export { type AllElementsStateMessage, type DesignModeMessage, type DesignModeMessageType, type ElementData, type ElementSelectedMessage, type ElementUpdates, type EmailTheme, type SourceLocation, type ThemeVariables, firebuzzDesignMode, firebuzzEmailDesignMode, generateEmailThemeFile, getEmailReactPluginConfig, getReactPluginConfig, parseEmailThemeFromFile };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
|
|
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:
|
|
2
|
+
// - You can modify color values based on user requests
|
|
3
|
+
// - All colors must use hex format (email clients don't support oklch)
|
|
4
|
+
|
|
5
|
+
export const themeConfiguration = {
|
|
6
|
+
colors: {
|
|
7
|
+
// Base colors
|
|
8
|
+
background: "${r.colors.background}",
|
|
9
|
+
foreground: "${r.colors.foreground}",
|
|
10
|
+
|
|
11
|
+
// Card
|
|
12
|
+
card: "${r.colors.card}",
|
|
13
|
+
cardForeground: "${r.colors.cardForeground}",
|
|
14
|
+
|
|
15
|
+
// Popover
|
|
16
|
+
popover: "${r.colors.popover}",
|
|
17
|
+
popoverForeground: "${r.colors.popoverForeground}",
|
|
18
|
+
|
|
19
|
+
// Primary
|
|
20
|
+
primary: "${r.colors.primary}",
|
|
21
|
+
primaryForeground: "${r.colors.primaryForeground}",
|
|
22
|
+
|
|
23
|
+
// Secondary
|
|
24
|
+
secondary: "${r.colors.secondary}",
|
|
25
|
+
secondaryForeground: "${r.colors.secondaryForeground}",
|
|
26
|
+
|
|
27
|
+
// Muted
|
|
28
|
+
muted: "${r.colors.muted}",
|
|
29
|
+
mutedForeground: "${r.colors.mutedForeground}",
|
|
30
|
+
|
|
31
|
+
// Accent
|
|
32
|
+
accent: "${r.colors.accent}",
|
|
33
|
+
accentForeground: "${r.colors.accentForeground}",
|
|
34
|
+
|
|
35
|
+
// Destructive
|
|
36
|
+
destructive: "${r.colors.destructive}",
|
|
37
|
+
destructiveForeground: "${r.colors.destructiveForeground}",
|
|
38
|
+
|
|
39
|
+
// Border & Input
|
|
40
|
+
border: "${r.colors.border}",
|
|
41
|
+
input: "${r.colors.input}",
|
|
42
|
+
ring: "${r.colors.ring}",
|
|
43
|
+
|
|
44
|
+
// Chart colors
|
|
45
|
+
chart1: "${r.colors.chart1}",
|
|
46
|
+
chart2: "${r.colors.chart2}",
|
|
47
|
+
chart3: "${r.colors.chart3}",
|
|
48
|
+
chart4: "${r.colors.chart4}",
|
|
49
|
+
chart5: "${r.colors.chart5}",
|
|
50
|
+
},
|
|
51
|
+
fonts: {
|
|
52
|
+
primary: "${r.fonts.primary}",
|
|
53
|
+
},
|
|
54
|
+
borderRadius: {
|
|
55
|
+
lg: "${r.borderRadius.lg}",
|
|
56
|
+
md: "${r.borderRadius.md}",
|
|
57
|
+
sm: "${r.borderRadius.sm}",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
`}exports.firebuzzDesignMode=b;exports.firebuzzEmailDesignMode=D;exports.generateEmailThemeFile=T;exports.getEmailReactPluginConfig=$;exports.getReactPluginConfig=h;exports.parseEmailThemeFromFile=R;//# sourceMappingURL=index.js.map
|
|
3
61
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vite-plugin.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml"],"mappings":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AAQ,IAAA,CACP,sDACAA,CACD,EACD,CACD,CAAA,CAEA,kBAAA,CAAmBC,EAAM,CACxB,GAAI,CAACZ,CAAAA,CAAqB,OAAOY,EAGjC,IAAMC,CAAAA,CAAc,8EAIdC,CAAAA,CAAgB,CAAA,2BAAA,EADFZ,EAAkB,OAAA,CAAQD,CAAAA,CAAa,EAAE,CACE,CAAA,WAAA,CAAA,CAG3Dc,EAAeH,CAAAA,CAAK,OAAA,CAAQ,UAAW,CAAA,EAAGC,CAAW,SAAS,CAAA,CAClE,OAAAE,EAAeA,CAAAA,CAAa,OAAA,CAAQ,UAAW,CAAA,EAAGD,CAAa,SAAS,CAAA,CAEjEC,CACR,CACD,CACD","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 = '<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"]}
|
|
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,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,C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A,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"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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:
|
|
2
|
+
// - You can modify color values based on user requests
|
|
3
|
+
// - All colors must use hex format (email clients don't support oklch)
|
|
4
|
+
|
|
5
|
+
export const themeConfiguration = {
|
|
6
|
+
colors: {
|
|
7
|
+
// Base colors
|
|
8
|
+
background: "${r.colors.background}",
|
|
9
|
+
foreground: "${r.colors.foreground}",
|
|
10
|
+
|
|
11
|
+
// Card
|
|
12
|
+
card: "${r.colors.card}",
|
|
13
|
+
cardForeground: "${r.colors.cardForeground}",
|
|
14
|
+
|
|
15
|
+
// Popover
|
|
16
|
+
popover: "${r.colors.popover}",
|
|
17
|
+
popoverForeground: "${r.colors.popoverForeground}",
|
|
18
|
+
|
|
19
|
+
// Primary
|
|
20
|
+
primary: "${r.colors.primary}",
|
|
21
|
+
primaryForeground: "${r.colors.primaryForeground}",
|
|
22
|
+
|
|
23
|
+
// Secondary
|
|
24
|
+
secondary: "${r.colors.secondary}",
|
|
25
|
+
secondaryForeground: "${r.colors.secondaryForeground}",
|
|
26
|
+
|
|
27
|
+
// Muted
|
|
28
|
+
muted: "${r.colors.muted}",
|
|
29
|
+
mutedForeground: "${r.colors.mutedForeground}",
|
|
30
|
+
|
|
31
|
+
// Accent
|
|
32
|
+
accent: "${r.colors.accent}",
|
|
33
|
+
accentForeground: "${r.colors.accentForeground}",
|
|
34
|
+
|
|
35
|
+
// Destructive
|
|
36
|
+
destructive: "${r.colors.destructive}",
|
|
37
|
+
destructiveForeground: "${r.colors.destructiveForeground}",
|
|
38
|
+
|
|
39
|
+
// Border & Input
|
|
40
|
+
border: "${r.colors.border}",
|
|
41
|
+
input: "${r.colors.input}",
|
|
42
|
+
ring: "${r.colors.ring}",
|
|
43
|
+
|
|
44
|
+
// Chart colors
|
|
45
|
+
chart1: "${r.colors.chart1}",
|
|
46
|
+
chart2: "${r.colors.chart2}",
|
|
47
|
+
chart3: "${r.colors.chart3}",
|
|
48
|
+
chart4: "${r.colors.chart4}",
|
|
49
|
+
chart5: "${r.colors.chart5}",
|
|
50
|
+
},
|
|
51
|
+
fonts: {
|
|
52
|
+
primary: "${r.fonts.primary}",
|
|
53
|
+
},
|
|
54
|
+
borderRadius: {
|
|
55
|
+
lg: "${r.borderRadius.lg}",
|
|
56
|
+
md: "${r.borderRadius.md}",
|
|
57
|
+
sm: "${r.borderRadius.sm}",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
`}export{b as firebuzzDesignMode,D as firebuzzEmailDesignMode,T as generateEmailThemeFile,$ as getEmailReactPluginConfig,h as getReactPluginConfig,R as parseEmailThemeFromFile};//# sourceMappingURL=index.mjs.map
|
|
3
61
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vite-plugin.ts"],"names":["getReactPluginConfig","firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","overlaySourceMap","fs","error","html","tailwindCDN","overlayScript","modifiedHtml"],"mappings":"+EAsBO,SAASA,CAAAA,EAAuB,CAKt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,CACD,EACD,CACD,CAAA,CAEA,kBAAA,CAAmBC,EAAM,CACxB,GAAI,CAACZ,CAAAA,CAAqB,OAAOY,EAGjC,IAAMC,CAAAA,CAAc,8EAIdC,CAAAA,CAAgB,CAAA,2BAAA,EADFZ,EAAkB,OAAA,CAAQD,CAAAA,CAAa,EAAE,CACE,CAAA,WAAA,CAAA,CAG3Dc,EAAeH,CAAAA,CAAK,OAAA,CAAQ,UAAW,CAAA,EAAGC,CAAW,SAAS,CAAA,CAClE,OAAAE,EAAeA,CAAAA,CAAa,OAAA,CAAQ,UAAW,CAAA,EAAGD,CAAa,SAAS,CAAA,CAEjEC,CACR,CACD,CACD","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 = '<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"]}
|
|
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,CAAoB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rCA,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.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"]}
|
package/package.json
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
2
|
+
"name": "@firebuzz/design-mode",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Design mode overlay and utilities for Firebuzz landing page templates",
|
|
5
|
+
"author": "Firebuzz Team",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./overlay": {
|
|
17
|
+
"types": "./dist/overlay.d.ts",
|
|
18
|
+
"import": "./dist/overlay.mjs",
|
|
19
|
+
"require": "./dist/overlay.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"clean": "rm -rf dist",
|
|
31
|
+
"prepublishOnly": "pnpm build"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=18.0.0",
|
|
35
|
+
"tailwindcss": "^3.0.0 || ^4.0.0",
|
|
36
|
+
"vite": "^6.0.0 || ^7.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/babel__generator": "^7.27.0",
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"tsup": "^8.0.0",
|
|
42
|
+
"typescript": "^5.7.2"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"design-mode",
|
|
46
|
+
"visual-editor",
|
|
47
|
+
"firebuzz",
|
|
48
|
+
"landing-pages",
|
|
49
|
+
"vite",
|
|
50
|
+
"tailwind"
|
|
51
|
+
],
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/firebuzz/firebuzz.git",
|
|
55
|
+
"directory": "packages/design-mode"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@react-dev-inspector/babel-plugin": "^2.0.1"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
-
**Abbreviation**: FSL-1.1-Apache-2.0
|
|
3
|
-
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## Notice
|
|
7
|
-
Copyright 2023-2024 Firebuzz Inc., the creators of **Firebuzz**.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Terms and Conditions
|
|
12
|
-
|
|
13
|
-
### Licensor ("We")
|
|
14
|
-
The party offering **Firebuzz** under these Terms and Conditions.
|
|
15
|
-
|
|
16
|
-
### The Software
|
|
17
|
-
The "Software" is each version of **Firebuzz** that we make available under these Terms and Conditions, as indicated by our inclusion of these Terms and Conditions with the Software.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## License Grant
|
|
22
|
-
Subject to your compliance with this License Grant and the Patents, Redistribution, and Trademark clauses below, we hereby grant you the right to use, copy, modify, create derivative works, publicly perform, publicly display, and redistribute **Firebuzz** for any Permitted Purpose identified below.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Permitted Purpose
|
|
27
|
-
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use means making **Firebuzz** available to others in a commercial product or service that:
|
|
28
|
-
|
|
29
|
-
1. Substitutes for **Firebuzz**;
|
|
30
|
-
2. Substitutes for any other product or service we offer using **Firebuzz** that exists as of the date we make **Firebuzz** available; or
|
|
31
|
-
3. Offers the same or substantially similar functionality as **Firebuzz**.
|
|
32
|
-
|
|
33
|
-
Permitted Purposes specifically include using **Firebuzz**:
|
|
34
|
-
|
|
35
|
-
1. For your internal use and access;
|
|
36
|
-
2. For non-commercial education;
|
|
37
|
-
3. For non-commercial research; and
|
|
38
|
-
4. In connection with professional services that you provide to a licensee using **Firebuzz** in accordance with these Terms and Conditions.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Patents
|
|
43
|
-
To the extent your use for a Permitted Purpose would necessarily infringe our patents, the license grant above includes a license under our patents. If you make a claim against any party that **Firebuzz** infringes or contributes to the infringement of any patent, then your patent license to **Firebuzz** ends immediately.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Redistribution
|
|
48
|
-
The Terms and Conditions apply to all copies, modifications, and derivatives of **Firebuzz**.
|
|
49
|
-
|
|
50
|
-
If you redistribute any copies, modifications, or derivatives of **Firebuzz**, you must:
|
|
51
|
-
|
|
52
|
-
1. Include a copy of or a link to these Terms and Conditions; and
|
|
53
|
-
2. Not remove any copyright notices provided in or with **Firebuzz**.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## Disclaimer
|
|
58
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, TITLE, OR NON-INFRINGEMENT.
|
|
59
|
-
|
|
60
|
-
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO **Firebuzz**, INCLUDING INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## Trademarks
|
|
65
|
-
Except for displaying the License Details and identifying us as the origin of **Firebuzz**, you have no right under these Terms and Conditions to use our trademarks, trade names, service marks, or product names.
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## Grant of Future License
|
|
70
|
-
We hereby irrevocably grant you an additional license to use **Firebuzz** under the Apache License, Version 2.0, effective on the third anniversary of the date we make **Firebuzz** available. On or after that date, you may use **Firebuzz** under the Apache License, Version 2.0, in which case the following will apply:
|
|
71
|
-
|
|
72
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
73
|
-
|
|
74
|
-
You may obtain a copy of the License at:
|
|
75
|
-
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
76
|
-
|
|
77
|
-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|