zss-engine 0.2.4 → 0.2.5

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.js CHANGED
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,n){void 0===n&&(n=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,i)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.transpiler=exports.build=exports.getServerCSS=exports.injectServerCSS=exports.injectClientGlobalCSS=exports.injectClientCSS=exports.genBase36Hash=void 0,__exportStar(require("./types"),exports),__exportStar(require("./utils/helper"),exports);var hash_1=require("./utils/hash");Object.defineProperty(exports,"genBase36Hash",{enumerable:!0,get:function(){return hash_1.genBase36Hash}});var inject_client_css_1=require("./utils/inject-client-css");Object.defineProperty(exports,"injectClientCSS",{enumerable:!0,get:function(){return inject_client_css_1.injectClientCSS}});var inject_client_global_css_1=require("./utils/inject-client-global-css");Object.defineProperty(exports,"injectClientGlobalCSS",{enumerable:!0,get:function(){return inject_client_global_css_1.injectClientGlobalCSS}});var inject_server_css_1=require("./utils/inject-server-css");Object.defineProperty(exports,"injectServerCSS",{enumerable:!0,get:function(){return inject_server_css_1.injectServerCSS}}),Object.defineProperty(exports,"getServerCSS",{enumerable:!0,get:function(){return inject_server_css_1.getServerCSS}});var build_1=require("./utils/build");Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return build_1.build}});var transpiler_1=require("./utils/transpiler");Object.defineProperty(exports,"transpiler",{enumerable:!0,get:function(){return transpiler_1.transpiler}});
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,n){if(n===undefined)n=t;var i=Object.getOwnPropertyDescriptor(r,t);if(!i||("get"in i?!r.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return r[t]}}}Object.defineProperty(e,n,i)}:function(e,r,t,n){if(n===undefined)n=t;e[n]=r[t]});var __exportStar=this&&this.__exportStar||function(e,r){for(var t in e)if(t!=="default"&&!Object.prototype.hasOwnProperty.call(r,t))__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:true});exports.transpiler=exports.build=exports.getServerCSS=exports.injectServerCSS=exports.injectClientGlobalCSS=exports.injectClientCSS=exports.genBase36Hash=void 0;__exportStar(require("./types"),exports);__exportStar(require("./utils/helper"),exports);var hash_1=require("./utils/hash");Object.defineProperty(exports,"genBase36Hash",{enumerable:true,get:function(){return hash_1.genBase36Hash}});var inject_client_css_1=require("./utils/inject-client-css");Object.defineProperty(exports,"injectClientCSS",{enumerable:true,get:function(){return inject_client_css_1.injectClientCSS}});var inject_client_global_css_1=require("./utils/inject-client-global-css");Object.defineProperty(exports,"injectClientGlobalCSS",{enumerable:true,get:function(){return inject_client_global_css_1.injectClientGlobalCSS}});var inject_server_css_1=require("./utils/inject-server-css");Object.defineProperty(exports,"injectServerCSS",{enumerable:true,get:function(){return inject_server_css_1.injectServerCSS}});Object.defineProperty(exports,"getServerCSS",{enumerable:true,get:function(){return inject_server_css_1.getServerCSS}});var build_1=require("./utils/build");Object.defineProperty(exports,"build",{enumerable:true,get:function(){return build_1.build}});var transpiler_1=require("./utils/transpiler");Object.defineProperty(exports,"transpiler",{enumerable:true,get:function(){return transpiler_1.transpiler}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./common/css-properties"),exports),__exportStar(require("./common/css-property"),exports),__exportStar(require("./main/create"),exports),__exportStar(require("./main/global"),exports),__exportStar(require("./main/vars"),exports);
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){if(i===undefined)i=t;var o=Object.getOwnPropertyDescriptor(r,t);if(!o||("get"in o?!r.__esModule:o.writable||o.configurable)){o={enumerable:true,get:function(){return r[t]}}}Object.defineProperty(e,i,o)}:function(e,r,t,i){if(i===undefined)i=t;e[i]=r[t]});var __exportStar=this&&this.__exportStar||function(e,r){for(var t in e)if(t!=="default"&&!Object.prototype.hasOwnProperty.call(r,t))__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./common/css-properties"),exports);__exportStar(require("./common/css-property"),exports);__exportStar(require("./main/create"),exports);__exportStar(require("./main/global"),exports);__exportStar(require("./main/vars"),exports);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=void 0;const helper_1=require("./helper"),build=async(e,r,l)=>{if(!helper_1.isServer)return;const t=require("fs"),{styleText:i}=require("util"),n=i("underline","--global"===l?"Generated global CSS\n\n":"Generated create CSS\n\n");try{if(t.existsSync(r)){t.readFileSync(r,"utf-8").includes(e)||(t.appendFileSync(r,e,"utf-8"),process.argv.includes("--log")&&console.log(n+e))}return}catch(e){console.error("Error writing to file:",e)}};exports.build=build;
1
+ "use server";"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.build=void 0;const helper_1=require("./helper");const build=async(e,r,n)=>{if(!helper_1.isServer)return;const t=require("fs");const{styleText:i}=require("util");const l=n==="--global"?i("underline",`✅Generated global CSS\n\n`):i("underline",`✅Generated create CSS\n\n`);try{if(t.existsSync(r)){const n=t.readFileSync(r,"utf-8");if(!n.includes(e)){t.appendFileSync(r,e,"utf-8");if(process.argv.includes("--log"))console.log(l+e)}}return}catch(e){console.error("Error writing to file:",e)}};exports.build=build;
@@ -1 +1 @@
1
- import{isServer}from"./helper";export const build=async(e,r,n)=>{if(!isServer)return;const t=require("fs"),{styleText:i}=require("util"),l=i("underline","--global"===n?"Generated global CSS\n\n":"Generated create CSS\n\n");try{if(t.existsSync(r)){t.readFileSync(r,"utf-8").includes(e)||(t.appendFileSync(r,e,"utf-8"),process.argv.includes("--log")&&console.log(l+e))}return}catch(e){console.error("Error writing to file:",e)}};
1
+ "use server";import{isServer}from"./helper";export const build=async(e,r,n)=>{if(!isServer)return;const t=require("fs");const{styleText:i}=require("util");const o=n==="--global"?i("underline",`✅Generated global CSS\n\n`):i("underline",`✅Generated create CSS\n\n`);try{if(t.existsSync(r)){const n=t.readFileSync(r,"utf-8");if(!n.includes(e)){t.appendFileSync(r,e,"utf-8");if(process.argv.includes("--log"))console.log(o+e)}}return}catch(e){console.error("Error writing to file:",e)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.genBase36Hash=genBase36Hash;const chars="abcdefghijklmnopqrstuvwxyz0123456789";function simpleHash(e){let t=0;for(let n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n)}return Math.abs(t)}function encodeBase36(e){let t="";do{t=chars[e%36]+t,e=Math.floor(e/36)}while(e>0);return t}function getStartingChar(e){const t="abcdefghijklmnopqrstuvwxyz";return t[e%26]}function genBase36Hash(e,t){const n=simpleHash(JSON.stringify(e));let s=encodeBase36(n);const r=getStartingChar(n);for(;s.length<t-1;)s=chars[n%chars.length]+s;return r+s.slice(0,t-1)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.genBase36Hash=genBase36Hash;const chars="abcdefghijklmnopqrstuvwxyz0123456789";function simpleHash(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s}return Math.abs(t)}function encodeBase36(e){let t="";do{t=chars[e%36]+t;e=Math.floor(e/36)}while(e>0);return t}function getStartingChar(e){const t="abcdefghijklmnopqrstuvwxyz";return t[e%t.length]}function genBase36Hash(e,t){const n=JSON.stringify(e);const s=simpleHash(n);let r=encodeBase36(s);const a=getStartingChar(s);while(r.length<t-1){r=chars[s%chars.length]+r}return a+r.slice(0,t-1)}
@@ -1 +1 @@
1
- const chars="abcdefghijklmnopqrstuvwxyz0123456789";function simpleHash(t){let e=0;for(let n=0;n<t.length;n++){e=(e<<5)-e+t.charCodeAt(n)}return Math.abs(e)}function encodeBase36(t){let e="";do{e=chars[t%36]+e,t=Math.floor(t/36)}while(t>0);return e}function getStartingChar(t){const e="abcdefghijklmnopqrstuvwxyz";return e[t%26]}export function genBase36Hash(t,e){const n=simpleHash(JSON.stringify(t));let r=encodeBase36(n);const s=getStartingChar(n);for(;r.length<e-1;)r=chars[n%36]+r;return s+r.slice(0,e-1)}
1
+ const chars="abcdefghijklmnopqrstuvwxyz0123456789";function simpleHash(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);e=(e<<5)-e+r}return Math.abs(e)}function encodeBase36(t){let e="";do{e=chars[t%36]+e;t=Math.floor(t/36)}while(t>0);return e}function getStartingChar(t){const e="abcdefghijklmnopqrstuvwxyz";return e[t%e.length]}export function genBase36Hash(t,e){const n=JSON.stringify(t);const r=simpleHash(n);let s=encodeBase36(r);const a=getStartingChar(r);while(s.length<e-1){s=chars[r%chars.length]+s}return a+s.slice(0,e-1)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.camelToKebabCase=exports.applyCssValue=exports.isDevServer=exports.isDevAndTest=exports.isDevelopment=exports.isServer=void 0;const isWindowDefined="undefined"!=typeof window,isDocumentDefined="undefined"!=typeof document;exports.isServer=!isWindowDefined||!isDocumentDefined,exports.isDevelopment="development"===process.env.NODE_ENV,exports.isDevAndTest="development"===process.env.NODE_ENV||"test"===process.env.NODE_ENV,exports.isDevServer=exports.isDevelopment&&exports.isServer;const exception=["line-height","font-weight","opacity","scale","z-index","column-count","order","orphans","widows"],applyCssValue=(e,s)=>"number"==typeof e?exception.includes(s)?e.toString():e+"px":e;exports.applyCssValue=applyCssValue;const camelToKebabCase=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase();exports.camelToKebabCase=camelToKebabCase;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.camelToKebabCase=exports.applyCssValue=exports.isDevServer=exports.isDevAndTest=exports.isDevelopment=exports.isServer=void 0;const isWindowDefined=typeof window!=="undefined";const isDocumentDefined=typeof document!=="undefined";exports.isServer=!isWindowDefined||!isDocumentDefined;exports.isDevelopment=process.env.NODE_ENV==="development";exports.isDevAndTest=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";exports.isDevServer=exports.isDevelopment&&exports.isServer;const exception=["line-height","font-weight","opacity","scale","z-index","column-count","order","orphans","widows"];const applyCssValue=(e,s)=>{if(typeof e==="number"){return exception.includes(s)?e.toString():e+"px"}return e};exports.applyCssValue=applyCssValue;const camelToKebabCase=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase();exports.camelToKebabCase=camelToKebabCase;
@@ -1 +1 @@
1
- const isWindowDefined="undefined"!=typeof window,isDocumentDefined="undefined"!=typeof document;export const isServer=!isWindowDefined||!isDocumentDefined;export const isDevelopment="development"===process.env.NODE_ENV;export const isDevAndTest="development"===process.env.NODE_ENV||"test"===process.env.NODE_ENV;export const isDevServer=isDevelopment&&isServer;const exception=["line-height","font-weight","opacity","scale","z-index","column-count","order","orphans","widows"];export const applyCssValue=(e,o)=>"number"==typeof e?exception.includes(o)?e.toString():e+"px":e;export const camelToKebabCase=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase();
1
+ const isWindowDefined=typeof window!=="undefined";const isDocumentDefined=typeof document!=="undefined";export const isServer=!isWindowDefined||!isDocumentDefined;export const isDevelopment=process.env.NODE_ENV==="development";export const isDevAndTest=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";export const isDevServer=isDevelopment&&isServer;const exception=["line-height","font-weight","opacity","scale","z-index","column-count","order","orphans","widows"];export const applyCssValue=(e,n)=>{if(typeof e==="number"){return exception.includes(n)?e.toString():e+"px"}return e};export const camelToKebabCase=e=>e.replace(/([A-Z])/g,"-$1").toLowerCase();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createStyleElement=createStyleElement,exports.injectClientCSS=injectClientCSS;const __1=require(".."),styleSheets={},hashCache={};function createStyleElement(e){if(document.getElementById(e))return null;const t=document.createElement("style");return t.setAttribute("id",e),t.setAttribute("type","text/css"),styleSheets[e]=t,document.head.appendChild(t),styleSheets[e]}function injectClientCSS(e,t){if(__1.isServer)return;requestAnimationFrame((()=>{styleCleanUp()})),hashCache[e]=e;const n=createStyleElement(e);null!=n&&(n.textContent=t)}function styleCleanUp(){requestAnimationFrame((()=>{for(const e in hashCache){0===document.querySelectorAll(`[class*="${e}"]`).length&&removeStyleElement(hashCache[e])}}))}function removeStyleElement(e){if(styleSheets[e]){delete styleSheets[e],hashCache.hasOwnProperty.call(hashCache,e)&&delete hashCache[e];const t=document.getElementById(e);t&&document.head.removeChild(t)}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createStyleElement=createStyleElement;exports.injectClientCSS=injectClientCSS;const __1=require("..");const styleSheets={};const hashCache={};function createStyleElement(e){if(document.getElementById(e))return null;const t=document.createElement("style");t.setAttribute("id",e);t.setAttribute("type","text/css");styleSheets[e]=t;document.head.appendChild(t);return styleSheets[e]}function injectClientCSS(e,t){if(__1.isServer)return;requestAnimationFrame((()=>{styleCleanUp()}));hashCache[e]=e;const n=createStyleElement(e);if(n==null)return;n.textContent=t}function styleCleanUp(){requestAnimationFrame((()=>{for(const e in hashCache){const t=document.querySelectorAll(`[class*="${e}"]`);if(t.length===0){removeStyleElement(hashCache[e])}}}))}function removeStyleElement(e){if(styleSheets[e]){delete styleSheets[e];if(hashCache.hasOwnProperty.call(hashCache,e)){delete hashCache[e]}const t=document.getElementById(e);if(t){document.head.removeChild(t)}}}
@@ -1 +1 @@
1
- import{isServer}from"..";const styleSheets={},hashCache={};export function createStyleElement(e){if(document.getElementById(e))return null;const t=document.createElement("style");return t.setAttribute("id",e),t.setAttribute("type","text/css"),styleSheets[e]=t,document.head.appendChild(t),styleSheets[e]}export function injectClientCSS(e,t){if(isServer)return;requestAnimationFrame((()=>{styleCleanUp()})),hashCache[e]=e;const n=createStyleElement(e);null!=n&&(n.textContent=t)}function styleCleanUp(){requestAnimationFrame((()=>{for(const e in hashCache){0===document.querySelectorAll(`[class*="${e}"]`).length&&removeStyleElement(hashCache[e])}}))}function removeStyleElement(e){if(styleSheets[e]){delete styleSheets[e],hashCache.hasOwnProperty.call(hashCache,e)&&delete hashCache[e];const t=document.getElementById(e);t&&document.head.removeChild(t)}}
1
+ import{isServer}from"..";const styleSheets={};const hashCache={};export function createStyleElement(e){if(document.getElementById(e))return null;const t=document.createElement("style");t.setAttribute("id",e);t.setAttribute("type","text/css");styleSheets[e]=t;document.head.appendChild(t);return styleSheets[e]}export function injectClientCSS(e,t){if(isServer)return;requestAnimationFrame((()=>{styleCleanUp()}));hashCache[e]=e;const n=createStyleElement(e);if(n==null)return;n.textContent=t}function styleCleanUp(){requestAnimationFrame((()=>{for(const e in hashCache){const t=document.querySelectorAll(`[class*="${e}"]`);if(t.length===0){removeStyleElement(hashCache[e])}}}))}function removeStyleElement(e){if(styleSheets[e]){delete styleSheets[e];if(hashCache.hasOwnProperty.call(hashCache,e)){delete hashCache[e]}const t=document.getElementById(e);if(t){document.head.removeChild(t)}}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.injectClientGlobalCSS=injectClientGlobalCSS;const __1=require("..");function injectClientGlobalCSS(e,t){if(__1.isServer)return;const n=document.querySelector(`[data-scope="${t}"]`);if(n instanceof HTMLStyleElement)return void(n.textContent+=e);const o=document.createElement("style");o.setAttribute("data-scope",t),o.setAttribute("type","text/css"),o.textContent=e,document.head.appendChild(o)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.injectClientGlobalCSS=injectClientGlobalCSS;const __1=require("..");function injectClientGlobalCSS(e,t){if(__1.isServer)return;const n=document.querySelector(`[data-scope="${t}"]`);if(n instanceof HTMLStyleElement){n.textContent+=e;return}const o=document.createElement("style");o.setAttribute("data-scope",t);o.setAttribute("type","text/css");o.textContent=e;document.head.appendChild(o)}
@@ -1 +1 @@
1
- import{isServer}from"..";export function injectClientGlobalCSS(t,e){if(isServer)return;const n=document.querySelector(`[data-scope="${e}"]`);if(n instanceof HTMLStyleElement)return void(n.textContent+=t);const o=document.createElement("style");o.setAttribute("data-scope",e),o.setAttribute("type","text/css"),o.textContent=t,document.head.appendChild(o)}
1
+ import{isServer}from"..";export function injectClientGlobalCSS(t,e){if(isServer)return;const n=document.querySelector(`[data-scope="${e}"]`);if(n instanceof HTMLStyleElement){n.textContent+=t;return}const o=document.createElement("style");o.setAttribute("data-scope",e);o.setAttribute("type","text/css");o.textContent=t;document.head.appendChild(o)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.injectServerCSS=injectServerCSS,exports.getServerCSS=getServerCSS;const styleSheets={};function injectServerCSS(e,t){styleSheets[e]=t}function getServerCSS(){return Object.values(styleSheets).join("\n")}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.injectServerCSS=injectServerCSS;exports.getServerCSS=getServerCSS;const styleSheets={};function injectServerCSS(e,t){styleSheets[e]=t}function getServerCSS(){return Object.values(styleSheets).join("\n")}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.transpiler=transpiler;const __1=require(".."),createKeyframes=(e,t)=>{let s=`${e} {\n`;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];s+=` ${e} {\n`;for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){const t=(0,__1.camelToKebabCase)(e),r=n[e];if("string"==typeof r||"number"==typeof r){s+=` ${t}: ${(0,__1.applyCssValue)(r,t)};\n`}}s+=" }\n"}return s+="}\n",s};function transpiler(e,t,s){let n="";const r=[],a=e=>"--global"===s?e:`.${e}_${t}`,o=(e,t,s)=>{if("string"!=typeof s)return"";const n=t[s];return`${e}${(0,__1.camelToKebabCase)(s)}: ${n};\n`},c=(e,t,s=0)=>{const n={},a="".repeat(s),l=" ".repeat(s+1);let i="";for(const p in t)if(Object.prototype.hasOwnProperty.call(t,p)){const f=t[p];if("string"==typeof f||"number"==typeof f){let e=(0,__1.camelToKebabCase)(p);p.startsWith("ms")&&(e=`-${e}`);i+=` ${e}: ${(0,__1.applyCssValue)(f,e)};\n`}else if(p.startsWith("@")){if(p.startsWith("@media")||p.startsWith("@container")){const t=p;let s="",n="";for(const t in f)if(Object.prototype.hasOwnProperty.call(f,t)){const r=f[t],a=t.startsWith(":"),c=t.startsWith("&");if(a||c){const n=(0,__1.camelToKebabCase)(t.replace("&",""));let a="";if("object"==typeof r&&null!==r)for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)){const t=(0,__1.camelToKebabCase)(e),s=(0,__1.applyCssValue)(r[e],t);a+=o(l+" ",{[e]:s},e)}s+=`${l}${e}${n} {\n${a}${l}}\n`}else{const e=(0,__1.camelToKebabCase)(t),s=(0,__1.applyCssValue)(r,e);n+=o(l+" ",{[t]:s},t)}}n?r.push({media:t,css:`${t} {\n${l}${e} {\n${n} }\n${s}${a}}${a}\n`}):r.push({media:t,css:`${t} {\n${s}${a}}\n`})}}else{const t=(0,__1.camelToKebabCase)(p.replace("&","")),r=c(e+t,f,s);Object.assign(n,r)}}return n[e]=i,n};for(const t in e){if(t.startsWith("@keyframes")){const s=e[t];n+=createKeyframes(t,s)}const s=c(a(t),e[t],1);for(const e in s)!e.startsWith("@keyframes")&&s[e]&&(n+=e+" {\n"+s[e]+"}\n")}return r.forEach((({css:e})=>{n+=e})),{styleSheet:n}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.transpiler=transpiler;const __1=require("..");const createKeyframes=(t,e)=>{let s=`${t} {\n`;for(const t in e){if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t];s+=` ${t} {\n`;for(const t in n){if(Object.prototype.hasOwnProperty.call(n,t)){const e=(0,__1.camelToKebabCase)(t);const o=n[t];if(typeof o==="string"||typeof o==="number"){const t=(0,__1.applyCssValue)(o,e);s+=` ${e}: ${t};\n`}}}s+=` }\n`}}s+=`}\n`;return s};function transpiler(t,e,s){let n="";const o=[];const r=t=>s==="--global"?t:`.${t}_${e}`;const a=(t,e,s)=>{if(typeof s!=="string")return"";const n=e[s];const o=(0,__1.camelToKebabCase)(s);return`${t}${o}: ${n};\n`};const c=(t,e,s=0)=>{const n={};const r="".repeat(s);const l=" ".repeat(s+1);let i="";for(const p in e){if(Object.prototype.hasOwnProperty.call(e,p)){const f=e[p];if(typeof f==="string"||typeof f==="number"){let t=(0,__1.camelToKebabCase)(p);if(p.startsWith("ms")){t=`-${t}`}const e=(0,__1.applyCssValue)(f,t);i+=` ${t}: ${e};\n`}else if(!p.startsWith("@")){const e=(0,__1.camelToKebabCase)(p.replace("&",""));const o=c(t+e,f,s);Object.assign(n,o)}else if(p.startsWith("@media")||p.startsWith("@container")){const e=p;let s="";let n="";for(const e in f){if(Object.prototype.hasOwnProperty.call(f,e)){const o=f[e];const r=e.startsWith(":");const c=e.startsWith("&");if(r||c){const n=(0,__1.camelToKebabCase)(e.replace("&",""));let r="";if(typeof o==="object"&&o!==null){for(const t in o){if(Object.prototype.hasOwnProperty.call(o,t)){const e=(0,__1.camelToKebabCase)(t);const s=(0,__1.applyCssValue)(o[t],e);r+=a(l+" ",{[t]:s},t)}}}s+=`${l}${t}${n} {\n${r}${l}}\n`}else{const t=(0,__1.camelToKebabCase)(e);const s=(0,__1.applyCssValue)(o,t);n+=a(l+" ",{[e]:s},e)}}}if(n){o.push({media:e,css:`${e} {\n${l}${t} {\n${n} }\n${s}${r}}${r}\n`})}else{o.push({media:e,css:`${e} {\n${s}${r}}\n`})}}}}n[t]=i;return n};for(const e in t){if(e.startsWith("@keyframes")){const s=t[e];n+=createKeyframes(e,s)}const s=c(r(e),t[e],1);for(const t in s){if(!t.startsWith("@keyframes")&&s[t]){n+=t+" {\n"+s[t]+"}\n"}}}o.forEach((({css:t})=>{n+=t}));return{styleSheet:n}}
@@ -1 +1 @@
1
- import{camelToKebabCase,applyCssValue}from"..";const createKeyframes=(e,t)=>{let s=`${e} {\n`;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const a=t[e];s+=` ${e} {\n`;for(const e in a)if(Object.prototype.hasOwnProperty.call(a,e)){const t=camelToKebabCase(e),n=a[e];if("string"==typeof n||"number"==typeof n){s+=` ${t}: ${applyCssValue(n,t)};\n`}}s+=" }\n"}return s+="}\n",s};export function transpiler(e,t,s){let a="";const n=[],o=e=>"--global"===s?e:`.${e}_${t}`,r=(e,t,s)=>{if("string"!=typeof s)return"";const a=t[s];return`${e}${camelToKebabCase(s)}: ${a};\n`},c=(e,t,s=0)=>{const a={},o="".repeat(s),l=" ".repeat(s+1);let p="";for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i)){const f=t[i];if("string"==typeof f||"number"==typeof f){let e=camelToKebabCase(i);i.startsWith("ms")&&(e=`-${e}`);p+=` ${e}: ${applyCssValue(f,e)};\n`}else if(i.startsWith("@")){if(i.startsWith("@media")||i.startsWith("@container")){const t=i;let s="",a="";for(const t in f)if(Object.prototype.hasOwnProperty.call(f,t)){const n=f[t],o=t.startsWith(":"),c=t.startsWith("&");if(o||c){const a=camelToKebabCase(t.replace("&",""));let o="";if("object"==typeof n&&null!==n)for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){const t=camelToKebabCase(e),s=applyCssValue(n[e],t);o+=r(l+" ",{[e]:s},e)}s+=`${l}${e}${a} {\n${o}${l}}\n`}else{const e=camelToKebabCase(t),s=applyCssValue(n,e);a+=r(l+" ",{[t]:s},t)}}a?n.push({media:t,css:`${t} {\n${l}${e} {\n${a} }\n${s}${o}}${o}\n`}):n.push({media:t,css:`${t} {\n${s}${o}}\n`})}}else{const t=camelToKebabCase(i.replace("&","")),n=c(e+t,f,s);Object.assign(a,n)}}return a[e]=p,a};for(const t in e){if(t.startsWith("@keyframes")){const s=e[t];a+=createKeyframes(t,s)}const s=c(o(t),e[t],1);for(const e in s)!e.startsWith("@keyframes")&&s[e]&&(a+=e+" {\n"+s[e]+"}\n")}return n.forEach((({css:e})=>{a+=e})),{styleSheet:a}}
1
+ import{camelToKebabCase,applyCssValue}from"..";const createKeyframes=(t,e)=>{let s=`${t} {\n`;for(const t in e){if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t];s+=` ${t} {\n`;for(const t in n){if(Object.prototype.hasOwnProperty.call(n,t)){const e=camelToKebabCase(t);const o=n[t];if(typeof o==="string"||typeof o==="number"){const t=applyCssValue(o,e);s+=` ${e}: ${t};\n`}}}s+=` }\n`}}s+=`}\n`;return s};export function transpiler(t,e,s){let n="";const o=[];const a=t=>s==="--global"?t:`.${t}_${e}`;const c=(t,e,s)=>{if(typeof s!=="string")return"";const n=e[s];const o=camelToKebabCase(s);return`${t}${o}: ${n};\n`};const r=(t,e,s=0)=>{const n={};const a="".repeat(s);const l=" ".repeat(s+1);let i="";for(const p in e){if(Object.prototype.hasOwnProperty.call(e,p)){const f=e[p];if(typeof f==="string"||typeof f==="number"){let t=camelToKebabCase(p);if(p.startsWith("ms")){t=`-${t}`}const e=applyCssValue(f,t);i+=` ${t}: ${e};\n`}else if(!p.startsWith("@")){const e=camelToKebabCase(p.replace("&",""));const o=r(t+e,f,s);Object.assign(n,o)}else if(p.startsWith("@media")||p.startsWith("@container")){const e=p;let s="";let n="";for(const e in f){if(Object.prototype.hasOwnProperty.call(f,e)){const o=f[e];const a=e.startsWith(":");const r=e.startsWith("&");if(a||r){const n=camelToKebabCase(e.replace("&",""));let a="";if(typeof o==="object"&&o!==null){for(const t in o){if(Object.prototype.hasOwnProperty.call(o,t)){const e=camelToKebabCase(t);const s=applyCssValue(o[t],e);a+=c(l+" ",{[t]:s},t)}}}s+=`${l}${t}${n} {\n${a}${l}}\n`}else{const t=camelToKebabCase(e);const s=applyCssValue(o,t);n+=c(l+" ",{[e]:s},e)}}}if(n){o.push({media:e,css:`${e} {\n${l}${t} {\n${n} }\n${s}${a}}${a}\n`})}else{o.push({media:e,css:`${e} {\n${s}${a}}\n`})}}}}n[t]=i;return n};for(const e in t){if(e.startsWith("@keyframes")){const s=t[e];n+=createKeyframes(e,s)}const s=r(a(e),t[e],1);for(const t in s){if(!t.startsWith("@keyframes")&&s[t]){n+=t+" {\n"+s[t]+"}\n"}}}o.forEach((({css:t})=>{n+=t}));return{styleSheet:n}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Zero-runtime Style Sheet Engine",
5
5
  "keywords": [
6
6
  "zero-runtime",