@zuzjs/ui 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
3
|
-
var
|
|
4
|
-
export const zuzMap: Record<string, string> = ${JSON.stringify(this.manifest,null,2)};`;
|
|
5
|
-
\u2713 Initial Build Complete.`)),console.log(c__default.default.cyan(`\u25CB Watching: ${
|
|
6
|
-
`));}),r.on("error",
|
|
2
|
+
'use strict';var chunkBZ4B5RMW_cjs=require('./chunk-BZ4B5RMW.cjs'),commander=require('commander'),Z=require('chokidar'),d=require('path'),c=require('picocolors'),u=require('fs'),tsMorph=require('ts-morph');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Z__default=/*#__PURE__*/_interopDefault(Z);var d__default=/*#__PURE__*/_interopDefault(d);var c__default=/*#__PURE__*/_interopDefault(c);var u__default=/*#__PURE__*/_interopDefault(u);/* ZuzJS UI CLI */
|
|
3
|
+
var j=class{project;stylesToGenerate;manifest={};supportedExtensions=[".tsx",".jsx",".mdx",".md"];constructor(){this.project=new tsMorph.Project({compilerOptions:{allowJs:true,jsx:1}}),this.stylesToGenerate=new Set;}extractStyles(e,t=""){if(e.asKind(tsMorph.SyntaxKind.JsxExpression)){let s=e.getExpression();s&&this.extractStyles(s,t);return}if(e.asKind(tsMorph.SyntaxKind.StringLiteral)||e.asKind(tsMorph.SyntaxKind.NoSubstitutionTemplateLiteral)||e.asKind(tsMorph.SyntaxKind.NumericLiteral))this.stylesToGenerate.add(t+e.getLiteralValue().toString());else if(e.asKind(tsMorph.SyntaxKind.TemplateExpression)){let s=e.getHead().getLiteralText();e.getTemplateSpans().forEach(o=>{this.extractStyles(o.getExpression(),t+s);});}else e.asKind(tsMorph.SyntaxKind.ConditionalExpression)?(this.extractStyles(e.getWhenTrue(),t),this.extractStyles(e.getWhenFalse(),t)):e.asKind(tsMorph.SyntaxKind.ArrayLiteralExpression)?e.getElements().forEach(s=>this.extractStyles(s,t)):e.asKind(tsMorph.SyntaxKind.BinaryExpression)&&(this.extractStyles(e.getLeft(),t),this.extractStyles(e.getRight(),t));}processFile(e){this.stylesToGenerate.clear();let t=e.endsWith(".mdx")||e.endsWith(".md"),s;if(t){let i=u__default.default.readFileSync(e,"utf-8");s=this.project.createSourceFile(e,i,{overwrite:true,scriptKind:tsMorph.ScriptKind.TSX});}else s=this.project.addSourceFileAtPath(e),s.refreshFromFileSystemSync();[...s.getDescendantsOfKind(tsMorph.SyntaxKind.JsxOpeningElement),...s.getDescendantsOfKind(tsMorph.SyntaxKind.JsxSelfClosingElement)].forEach(i=>{let l=i.getAttribute("as")?.asKind(tsMorph.SyntaxKind.JsxAttribute)?.getInitializer();l&&this.extractStyles(l);}),s.getDescendantsOfKind(tsMorph.SyntaxKind.CallExpression).filter(i=>i.getExpression().getText()==="css").forEach(i=>{let a=i.getArguments();a.length>0&&this.extractStyles(a[0]);}),this.stylesToGenerate.forEach(i=>{chunkBZ4B5RMW_cjs.h(i).filter(Boolean).forEach(l=>{let b=l.match(/^([&@][\w-]+)\((.*)\)$/);if(b){let[x,k,A]=b;chunkBZ4B5RMW_cjs.h(A).filter(Boolean).forEach(G=>{let E=`${k}(${G})`,F=chunkBZ4B5RMW_cjs.i.parseAndGenerate(E,e);F.length>0&&(this.manifest[E]=F.join(" "));});let v=chunkBZ4B5RMW_cjs.i.parseAndGenerate(l,e);v.length>0&&(this.manifest[l]=v.join(" "));}else {let x=chunkBZ4B5RMW_cjs.i.parseAndGenerate(l,e);x.length>0&&(this.manifest[l]=x.join(" "));}});}),t&&this.project.removeSourceFile(s);}isSupportedFile(e){return this.supportedExtensions.some(t=>e.endsWith(t))}getStyleCount(){return this.stylesToGenerate.size}getManifestPath=()=>{let e=process.cwd(),t=[d__default.default.join(e,"src/app/css"),d__default.default.join(e,"app/css"),d__default.default.join(e,"src/css"),d__default.default.join(e,"css")],s=t.find(o=>u__default.default.existsSync(o))||t[0];return u__default.default.existsSync(s)||u__default.default.mkdirSync(s,{recursive:true}),d__default.default.join(s,"zuzmap.ts")};saveManifest(e){let t=d__default.default.dirname(e);u__default.default.existsSync(t)||u__default.default.mkdirSync(t,{recursive:true});let s=chunkBZ4B5RMW_cjs.i.getCache(),o={};for(let[i,a]of Object.entries(this.manifest))s.has(a)&&(o[i]=a);this.manifest=o;let y=`/* Zuz Generated Manifest - Do not edit */
|
|
4
|
+
export const zuzMap: Record<string, string> = ${JSON.stringify(this.manifest,null,2)};`;u__default.default.writeFileSync(e,y);}},m=new j;commander.program.opts();var h=process.cwd(),T=false,$=d__default.default.join(h,"src","app","css"),L=d__default.default.join($,"zuz.scss"),W=d__default.default.join($,"zuzmap.ts"),K=()=>{chunkBZ4B5RMW_cjs.i.writeToDisk(L),m.saveManifest(W);};commander.program.command("init").description("Initialize Zuz snippets and configuration").action(()=>{let r=d__default.default.join(h,".vscode"),e=d__default.default.join(r,"zuz.code-snippets"),t=d__default.default.join(r,"settings.json"),s=Object.keys(chunkBZ4B5RMW_cjs.a).join(","),o=Object.keys(chunkBZ4B5RMW_cjs.b).join(","),y={"Zuz Property":{prefix:"zp",body:[`as="\${1|${s}|}:$0"`],description:"Zuz Property (adds colon)"},"Zuz Shortcut":{prefix:"zs",body:[`as="\${1|${o}|}$0"`],description:"Zuz Direct Shortcut"}},i={};if(u__default.default.existsSync(t))try{i=JSON.parse(u__default.default.readFileSync(t,"utf-8"));}catch{i={};}i["editor.suggest.snippetsPreventQuickSuggestions"]=false,i["editor.quickSuggestions"]={...typeof i["editor.quickSuggestions"]=="object"?i["editor.quickSuggestions"]:{},strings:true},u__default.default.existsSync(r)||u__default.default.mkdirSync(r,{recursive:true}),u__default.default.writeFileSync(e,JSON.stringify(y,null,2)),u__default.default.writeFileSync(t,JSON.stringify(i,null,2)),console.log(c__default.default.green("\u2714 Zuz VS Code configuration initialized!")),console.log(c__default.default.cyan(" - .vscode/zuz.code-snippets (Splitted zp/zs)")),console.log(c__default.default.cyan(" - .vscode/settings.json (QuickSuggestions enabled)"));});commander.program.command("watch").alias("w").description("Start ZuzJS watcher").action(()=>{let r=Z__default.default.watch(".",{cwd:h,ignored:[/node_modules/,/dist/,/\.next/,/\.git/],persistent:true,usePolling:true,followSymlinks:false,ignoreInitial:false});r.on("add",e=>{m.isSupportedFile(e)&&m.processFile(d__default.default.resolve(h,e)),T&&console.log(c__default.default.gray(`\u25CB File added: ${e}`));}),r.on("change",e=>{if(m.isSupportedFile(e)){console.log(c__default.default.gray(`\u25CB File changed: ${e}`));let t=d__default.default.resolve(h,e);chunkBZ4B5RMW_cjs.i.clearFileCache(t),m.processFile(t),K(),console.log(c__default.default.blue("\u26A1 Zuz CSS updated."));}}),r.on("ready",()=>{T=true,K(),console.log(c__default.default.green(`
|
|
5
|
+
\u2713 Initial Build Complete.`)),console.log(c__default.default.cyan(`\u25CB Watching: ${d.basename(h)}
|
|
6
|
+
`));}),r.on("error",e=>console.error(c__default.default.red(`Watcher Error: ${e}`)));});commander.program.parse(process.argv);
|
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a,b,i,h}from'./chunk-
|
|
3
|
-
export const zuzMap: Record<string, string> = ${JSON.stringify(this.manifest,null,2)};`;
|
|
4
|
-
\u2713 Initial Build Complete.`)),console.log(c.cyan(`\u25CB Watching: ${basename(
|
|
5
|
-
`));}),r.on("error",
|
|
2
|
+
import {a,b,i,h as h$1}from'./chunk-4GN6AE4D.js';import {program}from'commander';import D from'chokidar';import d,{basename}from'path';import c from'picocolors';import u from'fs';import {Project,SyntaxKind,ScriptKind}from'ts-morph';var j=class{project;stylesToGenerate;manifest={};supportedExtensions=[".tsx",".jsx",".mdx",".md"];constructor(){this.project=new Project({compilerOptions:{allowJs:true,jsx:1}}),this.stylesToGenerate=new Set;}extractStyles(e,t=""){if(e.asKind(SyntaxKind.JsxExpression)){let s=e.getExpression();s&&this.extractStyles(s,t);return}if(e.asKind(SyntaxKind.StringLiteral)||e.asKind(SyntaxKind.NoSubstitutionTemplateLiteral)||e.asKind(SyntaxKind.NumericLiteral))this.stylesToGenerate.add(t+e.getLiteralValue().toString());else if(e.asKind(SyntaxKind.TemplateExpression)){let s=e.getHead().getLiteralText();e.getTemplateSpans().forEach(o=>{this.extractStyles(o.getExpression(),t+s);});}else e.asKind(SyntaxKind.ConditionalExpression)?(this.extractStyles(e.getWhenTrue(),t),this.extractStyles(e.getWhenFalse(),t)):e.asKind(SyntaxKind.ArrayLiteralExpression)?e.getElements().forEach(s=>this.extractStyles(s,t)):e.asKind(SyntaxKind.BinaryExpression)&&(this.extractStyles(e.getLeft(),t),this.extractStyles(e.getRight(),t));}processFile(e){this.stylesToGenerate.clear();let t=e.endsWith(".mdx")||e.endsWith(".md"),s;if(t){let i=u.readFileSync(e,"utf-8");s=this.project.createSourceFile(e,i,{overwrite:true,scriptKind:ScriptKind.TSX});}else s=this.project.addSourceFileAtPath(e),s.refreshFromFileSystemSync();[...s.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),...s.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)].forEach(i=>{let l=i.getAttribute("as")?.asKind(SyntaxKind.JsxAttribute)?.getInitializer();l&&this.extractStyles(l);}),s.getDescendantsOfKind(SyntaxKind.CallExpression).filter(i=>i.getExpression().getText()==="css").forEach(i=>{let a=i.getArguments();a.length>0&&this.extractStyles(a[0]);}),this.stylesToGenerate.forEach(i$1=>{h$1(i$1).filter(Boolean).forEach(l=>{let b=l.match(/^([&@][\w-]+)\((.*)\)$/);if(b){let[x,k,A]=b;h$1(A).filter(Boolean).forEach(G=>{let E=`${k}(${G})`,F=i.parseAndGenerate(E,e);F.length>0&&(this.manifest[E]=F.join(" "));});let v=i.parseAndGenerate(l,e);v.length>0&&(this.manifest[l]=v.join(" "));}else {let x=i.parseAndGenerate(l,e);x.length>0&&(this.manifest[l]=x.join(" "));}});}),t&&this.project.removeSourceFile(s);}isSupportedFile(e){return this.supportedExtensions.some(t=>e.endsWith(t))}getStyleCount(){return this.stylesToGenerate.size}getManifestPath=()=>{let e=process.cwd(),t=[d.join(e,"src/app/css"),d.join(e,"app/css"),d.join(e,"src/css"),d.join(e,"css")],s=t.find(o=>u.existsSync(o))||t[0];return u.existsSync(s)||u.mkdirSync(s,{recursive:true}),d.join(s,"zuzmap.ts")};saveManifest(e){let t=d.dirname(e);u.existsSync(t)||u.mkdirSync(t,{recursive:true});let s=i.getCache(),o={};for(let[i,a]of Object.entries(this.manifest))s.has(a)&&(o[i]=a);this.manifest=o;let y=`/* Zuz Generated Manifest - Do not edit */
|
|
3
|
+
export const zuzMap: Record<string, string> = ${JSON.stringify(this.manifest,null,2)};`;u.writeFileSync(e,y);}},m=new j;program.opts();var h=process.cwd(),T=false,$=d.join(h,"src","app","css"),W=d.join($,"zuz.scss"),N=d.join($,"zuzmap.ts"),K=()=>{i.writeToDisk(W),m.saveManifest(N);};program.command("init").description("Initialize Zuz snippets and configuration").action(()=>{let r=d.join(h,".vscode"),e=d.join(r,"zuz.code-snippets"),t=d.join(r,"settings.json"),s=Object.keys(a).join(","),o=Object.keys(b).join(","),y={"Zuz Property":{prefix:"zp",body:[`as="\${1|${s}|}:$0"`],description:"Zuz Property (adds colon)"},"Zuz Shortcut":{prefix:"zs",body:[`as="\${1|${o}|}$0"`],description:"Zuz Direct Shortcut"}},i={};if(u.existsSync(t))try{i=JSON.parse(u.readFileSync(t,"utf-8"));}catch{i={};}i["editor.suggest.snippetsPreventQuickSuggestions"]=false,i["editor.quickSuggestions"]={...typeof i["editor.quickSuggestions"]=="object"?i["editor.quickSuggestions"]:{},strings:true},u.existsSync(r)||u.mkdirSync(r,{recursive:true}),u.writeFileSync(e,JSON.stringify(y,null,2)),u.writeFileSync(t,JSON.stringify(i,null,2)),console.log(c.green("\u2714 Zuz VS Code configuration initialized!")),console.log(c.cyan(" - .vscode/zuz.code-snippets (Splitted zp/zs)")),console.log(c.cyan(" - .vscode/settings.json (QuickSuggestions enabled)"));});program.command("watch").alias("w").description("Start ZuzJS watcher").action(()=>{let r=D.watch(".",{cwd:h,ignored:[/node_modules/,/dist/,/\.next/,/\.git/],persistent:true,usePolling:true,followSymlinks:false,ignoreInitial:false});r.on("add",e=>{m.isSupportedFile(e)&&m.processFile(d.resolve(h,e)),T&&console.log(c.gray(`\u25CB File added: ${e}`));}),r.on("change",e=>{if(m.isSupportedFile(e)){console.log(c.gray(`\u25CB File changed: ${e}`));let t=d.resolve(h,e);i.clearFileCache(t),m.processFile(t),K(),console.log(c.blue("\u26A1 Zuz CSS updated."));}}),r.on("ready",()=>{T=true,K(),console.log(c.green(`
|
|
4
|
+
\u2713 Initial Build Complete.`)),console.log(c.cyan(`\u25CB Watching: ${basename(h)}
|
|
5
|
+
`));}),r.on("error",e=>console.error(c.red(`Watcher Error: ${e}`)));});program.parse(process.argv);
|