@firebuzz/design-mode 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,77 @@
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.
package/dist/index.d.mts CHANGED
@@ -1,22 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- /**
4
- * Vite plugin that enables design mode features for Firebuzz templates
5
- * - Generates Tailwind config JSON for client-side use
6
- * - Injects overlay script for element selection
7
- *
8
- * NOTE: This plugin does NOT modify JSX/TSX files.
9
- * Element tracking is done at runtime using React Fiber's _debugSource.
10
- *
11
- * @param options - Plugin configuration options
12
- * @param options.tailwindConfigPath - Path to tailwind.config.js (default: "./tailwind.config.js")
13
- * @param options.outputPath - Path to output tailwind.config.json (default: "./src/design-mode/tailwind.config.json")
14
- */
15
- declare function firebuzzDesignMode(options?: {
16
- tailwindConfigPath?: string;
17
- outputPath?: string;
18
- }): Plugin;
19
-
20
3
  /**
21
4
  * TypeScript type definitions for Firebuzz Design Mode
22
5
  */
@@ -82,4 +65,14 @@ interface AllElementsStateMessage {
82
65
  }
83
66
  type DesignModeMessageType = DesignModeMessage | ElementSelectedMessage | AllElementsStateMessage;
84
67
 
68
+ /**
69
+ * Vite plugin that enables design mode features for Firebuzz templates
70
+ * - Injects Tailwind Play CDN for runtime CSS generation
71
+ * - Injects overlay script for element selection
72
+ *
73
+ * NOTE: This plugin does NOT modify JSX/TSX files.
74
+ * Element tracking is done at runtime using React Fiber's _debugSource.
75
+ */
76
+ declare function firebuzzDesignMode(): Plugin;
77
+
85
78
  export { type AllElementsStateMessage, type DesignModeMessage, type DesignModeMessageType, type ElementData, type ElementSelectedMessage, type ElementUpdates, type SourceLocation, type ThemeVariables, firebuzzDesignMode };
package/dist/index.d.ts CHANGED
@@ -1,22 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- /**
4
- * Vite plugin that enables design mode features for Firebuzz templates
5
- * - Generates Tailwind config JSON for client-side use
6
- * - Injects overlay script for element selection
7
- *
8
- * NOTE: This plugin does NOT modify JSX/TSX files.
9
- * Element tracking is done at runtime using React Fiber's _debugSource.
10
- *
11
- * @param options - Plugin configuration options
12
- * @param options.tailwindConfigPath - Path to tailwind.config.js (default: "./tailwind.config.js")
13
- * @param options.outputPath - Path to output tailwind.config.json (default: "./src/design-mode/tailwind.config.json")
14
- */
15
- declare function firebuzzDesignMode(options?: {
16
- tailwindConfigPath?: string;
17
- outputPath?: string;
18
- }): Plugin;
19
-
20
3
  /**
21
4
  * TypeScript type definitions for Firebuzz Design Mode
22
5
  */
@@ -82,4 +65,14 @@ interface AllElementsStateMessage {
82
65
  }
83
66
  type DesignModeMessageType = DesignModeMessage | ElementSelectedMessage | AllElementsStateMessage;
84
67
 
68
+ /**
69
+ * Vite plugin that enables design mode features for Firebuzz templates
70
+ * - Injects Tailwind Play CDN for runtime CSS generation
71
+ * - Injects overlay script for element selection
72
+ *
73
+ * NOTE: This plugin does NOT modify JSX/TSX files.
74
+ * Element tracking is done at runtime using React Fiber's _debugSource.
75
+ */
76
+ declare function firebuzzDesignMode(): Plugin;
77
+
85
78
  export { type AllElementsStateMessage, type DesignModeMessage, type DesignModeMessageType, type ElementData, type ElementSelectedMessage, type ElementUpdates, type SourceLocation, type ThemeVariables, firebuzzDesignMode };
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- 'use strict';var i=require('fs/promises'),r=require('path'),url=require('url'),m=require('esbuild');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__default=/*#__PURE__*/_interopDefault(i);var r__default=/*#__PURE__*/_interopDefault(r);var m__namespace=/*#__PURE__*/_interopNamespace(m);function w(d){let n=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",o=process.cwd(),a=r__default.default.resolve(o,d?.tailwindConfigPath||"./tailwind.config.js"),f=r__default.default.resolve(o,d?.outputPath||"./src/design-mode/tailwind.config.json"),s=r__default.default.resolve(o,"./.fb-tailwind.config.js"),l=r__default.default.resolve(o,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(n){try{let e=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),t=url.fileURLToPath(e),c=r__default.default.resolve(r__default.default.dirname(t),".."),u=r__default.default.join(c,"dist","overlay.mjs");await i__default.default.mkdir(r__default.default.dirname(l),{recursive:!0}),await i__default.default.copyFile(u,l);}catch(e){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",e);}try{await g();}catch(e){console.warn("[Firebuzz Design Mode] Could not generate Tailwind config:",e);}}},configureServer(e){if(n)try{e.watcher.add(a),e.watcher.on("change",async t=>{r__default.default.normalize(t)===r__default.default.normalize(a)&&await g();});}catch(t){console.warn("[Firebuzz Design Mode] Could not watch Tailwind config:",t);}},transformIndexHtml(e){if(!n)return e;let t=l.replace(o,"");return e.replace("</body>",`<script type="module" src="${t}"></script></body>`)}};async function g(){try{await m__namespace.build({entryPoints:[a],outfile:s,bundle:!0,format:"esm",banner:{js:'import { createRequire } from "module"; const require = createRequire(import.meta.url);'}});let e=await import(`${s}?update=${Date.now()}`);if(!e?.default)throw new Error("Invalid Tailwind config structure");let{default:t}=await import('tailwindcss/resolveConfig.js'),c=t(e.default),u=r__default.default.dirname(f);await i__default.default.mkdir(u,{recursive:!0}),await i__default.default.writeFile(f,JSON.stringify(c,null,2)),await i__default.default.unlink(s).catch(()=>{}),console.log("[Firebuzz Design Mode] Generated Tailwind config JSON successfully");}catch(e){throw console.error("[Firebuzz Design Mode] Error generating config:",e),e}}}exports.firebuzzDesignMode=w;//# sourceMappingURL=index.js.map
1
+ 'use strict';var l=require('fs/promises'),r=require('path'),url=require('url');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var r__default=/*#__PURE__*/_interopDefault(r);function d(){let n=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",a=process.cwd(),t=r__default.default.resolve(a,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(n)try{let e=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)),o=url.fileURLToPath(e),c=r__default.default.resolve(r__default.default.dirname(o),".."),s=r__default.default.join(c,"dist","overlay.mjs");await l__default.default.mkdir(r__default.default.dirname(t),{recursive:!0}),await l__default.default.copyFile(s,t);}catch(e){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",e);}},transformIndexHtml(e){if(!n)return e;let o='<script src="https://cdn.tailwindcss.com"></script>',s=`<script type="module" src="${t.replace(a,"")}"></script>`,i=e.replace("</head>",`${o}</head>`);return i=i.replace("</body>",`${s}</body>`),i}}}
2
+ exports.firebuzzDesignMode=d;//# sourceMappingURL=index.js.map
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts"],"names":["firebuzzDesignMode","options","isDesignModeEnabled","projectRoot","tailwindConfigFile","path","tailwindJsonOutfile","tailwindIntermediateFile","overlayOutputPath","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","fs","error","generateTailwindConfig","server","changedPath","html","overlayPath","m","userConfig","resolveConfig","resolvedConfig","outputDir"],"mappings":"8rBAkBO,SAASA,CAAAA,CAAmBC,EAGxB,CAEV,IAAMC,CAAAA,CACL,OAAA,CAAQ,IAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,mBAAqB,OAAA,CAE5BC,CAAAA,CAAc,OAAA,CAAQ,GAAA,GACtBC,CAAAA,CAAqBC,kBAAA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,SAAA,CACRR,CAAAA,CACA,KAAK,SAAA,CAAUkB,CAAAA,CAAgB,IAAA,CAAM,CAAC,CACvC,CAAA,CAGA,MAAMV,kBAAAA,CAAG,MAAA,CAAOP,CAAwB,CAAA,CAAE,KAAA,CAAM,IAAM,CAAC,CAAC,CAAA,CAExD,OAAA,CAAQ,GAAA,CACP,oEACD,EACD,CAAA,MAASQ,CAAAA,CAAO,CACf,MAAA,OAAA,CAAQ,MAAM,iDAAA,CAAmDA,CAAK,CAAA,CAChEA,CACP,CACD,CACD","file":"index.js","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as esbuild from \"esbuild\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Generates Tailwind config JSON for client-side use\n * - Injects overlay script for element selection\n *\n * NOTE: This plugin does NOT modify JSX/TSX files.\n * Element tracking is done at runtime using React Fiber's _debugSource.\n *\n * @param options - Plugin configuration options\n * @param options.tailwindConfigPath - Path to tailwind.config.js (default: \"./tailwind.config.js\")\n * @param options.outputPath - Path to output tailwind.config.json (default: \"./src/design-mode/tailwind.config.json\")\n */\nexport function firebuzzDesignMode(options?: {\n\ttailwindConfigPath?: string;\n\toutputPath?: string;\n}): 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\tconst tailwindConfigFile = path.resolve(\n\t\tprojectRoot,\n\t\toptions?.tailwindConfigPath || \"./tailwind.config.js\",\n\t);\n\tconst tailwindJsonOutfile = path.resolve(\n\t\tprojectRoot,\n\t\toptions?.outputPath || \"./src/design-mode/tailwind.config.json\",\n\t);\n\tconst tailwindIntermediateFile = path.resolve(\n\t\tprojectRoot,\n\t\t\"./.fb-tailwind.config.js\",\n\t);\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js\",\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\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\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\n\t\t\t// Generate Tailwind config JSON for client-side use\n\t\t\ttry {\n\t\t\t\tawait generateTailwindConfig();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not generate Tailwind config:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Watch Tailwind config for changes\n\t\t\ttry {\n\t\t\t\tserver.watcher.add(tailwindConfigFile);\n\t\t\t\tserver.watcher.on(\"change\", async (changedPath) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tpath.normalize(changedPath) === path.normalize(tailwindConfigFile)\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait generateTailwindConfig();\n\t\t\t\t\t}\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 watch Tailwind config:\",\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 the overlay script before </body>\n\t\t\t// Use the copied overlay file\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\treturn html.replace(\n\t\t\t\t\"</body>\",\n\t\t\t\t`<script type=\"module\" src=\"${overlayPath}\"></script></body>`,\n\t\t\t);\n\t\t},\n\t};\n\n\tasync function generateTailwindConfig() {\n\t\ttry {\n\t\t\t// Bundle Tailwind config using esbuild\n\t\t\tawait esbuild.build({\n\t\t\t\tentryPoints: [tailwindConfigFile],\n\t\t\t\toutfile: tailwindIntermediateFile,\n\t\t\t\tbundle: true,\n\t\t\t\tformat: \"esm\",\n\t\t\t\tbanner: {\n\t\t\t\t\tjs: 'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);',\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Import and resolve the config\n\t\t\tconst userConfig = await import(\n\t\t\t\t`${tailwindIntermediateFile}?update=${Date.now()}`\n\t\t\t);\n\n\t\t\tif (!userConfig?.default) {\n\t\t\t\tthrow new Error(\"Invalid Tailwind config structure\");\n\t\t\t}\n\n\t\t\t// Dynamically import tailwindcss/resolveConfig\n\t\t\tconst { default: resolveConfig } = await import(\n\t\t\t\t\"tailwindcss/resolveConfig.js\"\n\t\t\t);\n\t\t\tconst resolvedConfig = resolveConfig(userConfig.default);\n\n\t\t\t// Ensure output directory exists\n\t\t\tconst outputDir = path.dirname(tailwindJsonOutfile);\n\t\t\tawait fs.mkdir(outputDir, { recursive: true });\n\n\t\t\t// Write resolved config to JSON\n\t\t\tawait fs.writeFile(\n\t\t\t\ttailwindJsonOutfile,\n\t\t\t\tJSON.stringify(resolvedConfig, null, 2),\n\t\t\t);\n\n\t\t\t// Clean up intermediate file\n\t\t\tawait fs.unlink(tailwindIntermediateFile).catch(() => {});\n\n\t\t\tconsole.log(\n\t\t\t\t\"[Firebuzz Design Mode] Generated Tailwind config JSON successfully\",\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Firebuzz Design Mode] Error generating config:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/vite-plugin.ts"],"names":["firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","fs","error","html","tailwindCDN","overlayScript","modifiedHtml"],"mappings":"mUAaO,SAASA,CAAAA,EAA6B,CAE5C,IAAMC,CAAAA,CACL,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,gBAAA,GAAqB,OAAA,CAE5BC,CAAAA,CAAc,OAAA,CAAQ,GAAA,EAAI,CAE1BC,CAAAA,CAAoBC,kBAAAA,CAAK,OAAA,CAC9BF,EACA,6DACD,CAAA,CAEA,OAAO,CACN,IAAA,CAAM,kCAAA,CACN,OAAA,CAAS,KAAA,CAET,MAAM,UAAA,EAAa,CAClB,GAAKD,CAAAA,CAGL,GAAI,CAEH,IAAMI,EAAiB,0PAAY,CAC7BC,CAAAA,CAAkBC,iBAAAA,CAAcF,CAAc,CAAA,CAC9CG,CAAAA,CAAcJ,kBAAAA,CAAK,QAAQA,kBAAAA,CAAK,OAAA,CAAQE,CAAe,CAAA,CAAG,IAAI,CAAA,CAC9DG,CAAAA,CAAgBL,kBAAAA,CAAK,KAAKI,CAAAA,CAAa,MAAA,CAAQ,aAAa,CAAA,CAGlE,MAAME,kBAAAA,CAAG,KAAA,CAAMN,kBAAAA,CAAK,OAAA,CAAQD,CAAiB,CAAA,CAAG,CAAE,SAAA,CAAW,CAAA,CAAK,CAAC,CAAA,CAGnE,MAAMO,kBAAAA,CAAG,QAAA,CAASD,CAAAA,CAAeN,CAAiB,EACnD,CAAA,MAASQ,CAAAA,CAAO,CACf,QAAQ,IAAA,CACP,qDAAA,CACAA,CACD,EACD,CACD,CAAA,CAEA,kBAAA,CAAmBC,CAAAA,CAAM,CACxB,GAAI,CAACX,CAAAA,CAAqB,OAAOW,CAAAA,CAGjC,IAAMC,CAAAA,CACL,qDAAA,CAIKC,CAAAA,CAAgB,CAAA,2BAAA,EADFX,CAAAA,CAAkB,OAAA,CAAQD,CAAAA,CAAa,EAAE,CACE,CAAA,WAAA,CAAA,CAG3Da,EAAeH,CAAAA,CAAK,OAAA,CAAQ,SAAA,CAAW,CAAA,EAAGC,CAAW,CAAA,OAAA,CAAS,CAAA,CAClE,OAAAE,EAAeA,CAAAA,CAAa,OAAA,CAAQ,SAAA,CAAW,CAAA,EAAGD,CAAa,CAAA,OAAA,CAAS,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 * 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: This plugin does NOT modify JSX/TSX files.\n * Element tracking is done at runtime using React Fiber's _debugSource.\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.js\",\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\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\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 Play CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.tailwindcss.com\"></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"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import i from'fs/promises';import r from'path';import {fileURLToPath}from'url';import*as m from'esbuild';function w(d){let n=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",o=process.cwd(),a=r.resolve(o,d?.tailwindConfigPath||"./tailwind.config.js"),f=r.resolve(o,d?.outputPath||"./src/design-mode/tailwind.config.json"),s=r.resolve(o,"./.fb-tailwind.config.js"),l=r.resolve(o,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(n){try{let e=import.meta.url,t=fileURLToPath(e),c=r.resolve(r.dirname(t),".."),u=r.join(c,"dist","overlay.mjs");await i.mkdir(r.dirname(l),{recursive:!0}),await i.copyFile(u,l);}catch(e){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",e);}try{await g();}catch(e){console.warn("[Firebuzz Design Mode] Could not generate Tailwind config:",e);}}},configureServer(e){if(n)try{e.watcher.add(a),e.watcher.on("change",async t=>{r.normalize(t)===r.normalize(a)&&await g();});}catch(t){console.warn("[Firebuzz Design Mode] Could not watch Tailwind config:",t);}},transformIndexHtml(e){if(!n)return e;let t=l.replace(o,"");return e.replace("</body>",`<script type="module" src="${t}"></script></body>`)}};async function g(){try{await m.build({entryPoints:[a],outfile:s,bundle:!0,format:"esm",banner:{js:'import { createRequire } from "module"; const require = createRequire(import.meta.url);'}});let e=await import(`${s}?update=${Date.now()}`);if(!e?.default)throw new Error("Invalid Tailwind config structure");let{default:t}=await import('tailwindcss/resolveConfig.js'),c=t(e.default),u=r.dirname(f);await i.mkdir(u,{recursive:!0}),await i.writeFile(f,JSON.stringify(c,null,2)),await i.unlink(s).catch(()=>{}),console.log("[Firebuzz Design Mode] Generated Tailwind config JSON successfully");}catch(e){throw console.error("[Firebuzz Design Mode] Error generating config:",e),e}}}export{w as firebuzzDesignMode};//# sourceMappingURL=index.mjs.map
1
+ import l from'fs/promises';import r from'path';import {fileURLToPath}from'url';function d(){let n=process.env.NODE_ENV==="development"&&process.env.VITE_DESIGN_MODE!=="false",a=process.cwd(),t=r.resolve(a,"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js");return {name:"vite-plugin-firebuzz-design-mode",enforce:"pre",async buildStart(){if(n)try{let e=import.meta.url,o=fileURLToPath(e),c=r.resolve(r.dirname(o),".."),s=r.join(c,"dist","overlay.mjs");await l.mkdir(r.dirname(t),{recursive:!0}),await l.copyFile(s,t);}catch(e){console.warn("[Firebuzz Design Mode] Could not copy overlay file:",e);}},transformIndexHtml(e){if(!n)return e;let o='<script src="https://cdn.tailwindcss.com"></script>',s=`<script type="module" src="${t.replace(a,"")}"></script>`,i=e.replace("</head>",`${o}</head>`);return i=i.replace("</body>",`${s}</body>`),i}}}
2
+ export{d as firebuzzDesignMode};//# sourceMappingURL=index.mjs.map
2
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts"],"names":["firebuzzDesignMode","options","isDesignModeEnabled","projectRoot","tailwindConfigFile","path","tailwindJsonOutfile","tailwindIntermediateFile","overlayOutputPath","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","fs","error","generateTailwindConfig","server","changedPath","html","overlayPath","userConfig","resolveConfig","resolvedConfig","outputDir"],"mappings":"yGAkBO,SAASA,CAAAA,CAAmBC,EAGxB,CAEV,IAAMC,CAAAA,CACL,OAAA,CAAQ,IAAI,QAAA,GAAa,aAAA,EACzB,OAAA,CAAQ,GAAA,CAAI,mBAAqB,OAAA,CAE5BC,CAAAA,CAAc,OAAA,CAAQ,GAAA,GACtBC,CAAAA,CAAqBC,CAAAA,CAAK,OAAA,CAC/BF,CAAAA,CACAF,GAAS,kBAAA,EAAsB,sBAChC,CAAA,CACMK,CAAAA,CAAsBD,EAAK,OAAA,CAChCF,CAAAA,CACAF,CAAAA,EAAS,UAAA,EAAc,wCACxB,CAAA,CACMM,CAAAA,CAA2BF,CAAAA,CAAK,OAAA,CACrCF,EACA,0BACD,CAAA,CAEMK,CAAAA,CAAoBH,CAAAA,CAAK,QAC9BF,CAAAA,CACA,6DACD,CAAA,CAEA,OAAO,CACN,IAAA,CAAM,kCAAA,CACN,OAAA,CAAS,KAAA,CAET,MAAM,UAAA,EAAa,CAClB,GAAKD,CAAAA,CAGL,IAAI,CAEH,IAAMO,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K,OAAA,CACX,UACA,CAAA,2BAAA,EAA8BC,CAAW,CAAA,kBAAA,CAC1C,CACD,CACD,CAAA,CAEA,eAAeJ,CAAAA,EAAyB,CACvC,GAAI,CAEH,MAAc,CAAA,CAAA,KAAA,CAAM,CACnB,YAAa,CAACZ,CAAkB,CAAA,CAChC,OAAA,CAASG,EACT,MAAA,CAAQ,CAAA,CAAA,CACR,MAAA,CAAQ,KAAA,CACR,OAAQ,CACP,EAAA,CAAI,yFACL,CACD,CAAC,CAAA,CAGD,IAAMc,CAAAA,CAAa,MAAM,OACxB,CAAA,EAAGd,CAAwB,CAAA,QAAA,EAAW,IAAA,CAAK,GAAA,EAAK,CAAA,CAAA,CAAA,CAGjD,GAAI,CAACc,CAAAA,EAAY,OAAA,CAChB,MAAM,IAAI,MAAM,mCAAmC,CAAA,CAIpD,GAAM,CAAE,QAASC,CAAc,CAAA,CAAI,MAAM,OACxC,8BACD,CAAA,CACMC,CAAAA,CAAiBD,CAAAA,CAAcD,CAAAA,CAAW,OAAO,CAAA,CAGjDG,CAAAA,CAAYnB,CAAAA,CAAK,OAAA,CAAQC,CAAmB,CAAA,CAClD,MAAMQ,CAAAA,CAAG,KAAA,CAAMU,EAAW,CAAE,SAAA,CAAW,CAAA,CAAK,CAAC,EAG7C,MAAMV,CAAAA,CAAG,SAAA,CACRR,CAAAA,CACA,KAAK,SAAA,CAAUiB,CAAAA,CAAgB,IAAA,CAAM,CAAC,CACvC,CAAA,CAGA,MAAMT,CAAAA,CAAG,MAAA,CAAOP,CAAwB,CAAA,CAAE,KAAA,CAAM,IAAM,CAAC,CAAC,CAAA,CAExD,OAAA,CAAQ,GAAA,CACP,oEACD,EACD,CAAA,MAASQ,CAAAA,CAAO,CACf,MAAA,OAAA,CAAQ,MAAM,iDAAA,CAAmDA,CAAK,CAAA,CAChEA,CACP,CACD,CACD","file":"index.mjs","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as esbuild from \"esbuild\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Vite plugin that enables design mode features for Firebuzz templates\n * - Generates Tailwind config JSON for client-side use\n * - Injects overlay script for element selection\n *\n * NOTE: This plugin does NOT modify JSX/TSX files.\n * Element tracking is done at runtime using React Fiber's _debugSource.\n *\n * @param options - Plugin configuration options\n * @param options.tailwindConfigPath - Path to tailwind.config.js (default: \"./tailwind.config.js\")\n * @param options.outputPath - Path to output tailwind.config.json (default: \"./src/design-mode/tailwind.config.json\")\n */\nexport function firebuzzDesignMode(options?: {\n\ttailwindConfigPath?: string;\n\toutputPath?: string;\n}): 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\tconst tailwindConfigFile = path.resolve(\n\t\tprojectRoot,\n\t\toptions?.tailwindConfigPath || \"./tailwind.config.js\",\n\t);\n\tconst tailwindJsonOutfile = path.resolve(\n\t\tprojectRoot,\n\t\toptions?.outputPath || \"./src/design-mode/tailwind.config.json\",\n\t);\n\tconst tailwindIntermediateFile = path.resolve(\n\t\tprojectRoot,\n\t\t\"./.fb-tailwind.config.js\",\n\t);\n\n\tconst overlayOutputPath = path.resolve(\n\t\tprojectRoot,\n\t\t\"./node_modules/.vite-plugin-firebuzz-design-mode/overlay.js\",\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\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\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\n\t\t\t// Generate Tailwind config JSON for client-side use\n\t\t\ttry {\n\t\t\t\tawait generateTailwindConfig();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[Firebuzz Design Mode] Could not generate Tailwind config:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tif (!isDesignModeEnabled) return;\n\n\t\t\t// Watch Tailwind config for changes\n\t\t\ttry {\n\t\t\t\tserver.watcher.add(tailwindConfigFile);\n\t\t\t\tserver.watcher.on(\"change\", async (changedPath) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tpath.normalize(changedPath) === path.normalize(tailwindConfigFile)\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait generateTailwindConfig();\n\t\t\t\t\t}\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 watch Tailwind config:\",\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 the overlay script before </body>\n\t\t\t// Use the copied overlay file\n\t\t\tconst overlayPath = overlayOutputPath.replace(projectRoot, \"\");\n\t\t\treturn html.replace(\n\t\t\t\t\"</body>\",\n\t\t\t\t`<script type=\"module\" src=\"${overlayPath}\"></script></body>`,\n\t\t\t);\n\t\t},\n\t};\n\n\tasync function generateTailwindConfig() {\n\t\ttry {\n\t\t\t// Bundle Tailwind config using esbuild\n\t\t\tawait esbuild.build({\n\t\t\t\tentryPoints: [tailwindConfigFile],\n\t\t\t\toutfile: tailwindIntermediateFile,\n\t\t\t\tbundle: true,\n\t\t\t\tformat: \"esm\",\n\t\t\t\tbanner: {\n\t\t\t\t\tjs: 'import { createRequire } from \"module\"; const require = createRequire(import.meta.url);',\n\t\t\t\t},\n\t\t\t});\n\n\t\t\t// Import and resolve the config\n\t\t\tconst userConfig = await import(\n\t\t\t\t`${tailwindIntermediateFile}?update=${Date.now()}`\n\t\t\t);\n\n\t\t\tif (!userConfig?.default) {\n\t\t\t\tthrow new Error(\"Invalid Tailwind config structure\");\n\t\t\t}\n\n\t\t\t// Dynamically import tailwindcss/resolveConfig\n\t\t\tconst { default: resolveConfig } = await import(\n\t\t\t\t\"tailwindcss/resolveConfig.js\"\n\t\t\t);\n\t\t\tconst resolvedConfig = resolveConfig(userConfig.default);\n\n\t\t\t// Ensure output directory exists\n\t\t\tconst outputDir = path.dirname(tailwindJsonOutfile);\n\t\t\tawait fs.mkdir(outputDir, { recursive: true });\n\n\t\t\t// Write resolved config to JSON\n\t\t\tawait fs.writeFile(\n\t\t\t\ttailwindJsonOutfile,\n\t\t\t\tJSON.stringify(resolvedConfig, null, 2),\n\t\t\t);\n\n\t\t\t// Clean up intermediate file\n\t\t\tawait fs.unlink(tailwindIntermediateFile).catch(() => {});\n\n\t\t\tconsole.log(\n\t\t\t\t\"[Firebuzz Design Mode] Generated Tailwind config JSON successfully\",\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Firebuzz Design Mode] Error generating config:\", error);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/vite-plugin.ts"],"names":["firebuzzDesignMode","isDesignModeEnabled","projectRoot","overlayOutputPath","path","currentFileUrl","currentFilePath","fileURLToPath","packageRoot","overlaySource","fs","error","html","tailwindCDN","overlayScript","modifiedHtml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CAAA,EAAGC,CAAW,CAAA,OAAA,CAAS,CAAA,CAClE,OAAAE,EAAeA,CAAAA,CAAa,OAAA,CAAQ,SAAA,CAAW,CAAA,EAAGD,CAAa,CAAA,OAAA,CAAS,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 * 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: This plugin does NOT modify JSX/TSX files.\n * Element tracking is done at runtime using React Fiber's _debugSource.\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.js\",\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\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\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 Play CDN for runtime CSS generation\n\t\t\tconst tailwindCDN =\n\t\t\t\t'<script src=\"https://cdn.tailwindcss.com\"></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"]}