@styleframe/transpiler 3.0.1 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @styleframe/transpiler
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#155](https://github.com/styleframe-dev/styleframe/pull/155) [`cc4f170`](https://github.com/styleframe-dev/styleframe/commit/cc4f170c56ad2e246b94ab4d64b7f6c3097c7223) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Refactor recipes, improve modifier at-rule support, and forward variables through modifier factories
8
+ - Refactor recipes and utilities with improved color theming composables
9
+ - Add at-rule support for modifiers (e.g. media preference modifiers)
10
+ - Forward variables and children through all modifier factory functions
11
+ - Restructure docs for components, utilities, and modifiers into composable subdirectories
12
+ - Add Button composable recipe documentation
13
+ - Update plugin scanner for improved recipe handling
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`cc4f170`](https://github.com/styleframe-dev/styleframe/commit/cc4f170c56ad2e246b94ab4d64b7f6c3097c7223)]:
18
+ - @styleframe/core@3.2.0
19
+
3
20
  ## 3.0.1
4
21
 
5
22
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- const ke = " ", I = ["charset", "import", "namespace"], U = ["layer"];
1
+ const ke = " ", U = ["charset", "import", "namespace"], I = ["layer"];
2
2
  function M(e) {
3
3
  return typeof e == "object" && e !== null;
4
4
  }
@@ -192,7 +192,7 @@ function G(e, t = 8) {
192
192
  }
193
193
  return e ? `${e}${n}` : n;
194
194
  }
195
- const Y = ({ name: e }) => `[data-theme="${e}"]`, x = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
195
+ const Y = ({ name: e }) => `.${e}-theme, [data-theme="${e}"]`, x = ({ name: e }) => e.replace(/^\.+|\.+$/g, "").replace(/\.+/g, "--");
196
196
  function X(e, t) {
197
197
  return `@${e}${t ? " " : ""}${t}`;
198
198
  }
@@ -263,7 +263,7 @@ function le(e) {
263
263
  function fe(e) {
264
264
  return le(e);
265
265
  }
266
- function F(e, t) {
266
+ function D(e, t) {
267
267
  return `${e.startsWith("--") ? e : fe(e)}: ${t};`;
268
268
  }
269
269
  function me(e) {
@@ -271,21 +271,21 @@ function me(e) {
271
271
  ` : ""}${e.map((t) => `${ae(`${t}`)}
272
272
  `).join("")}}`;
273
273
  }
274
- function D(e) {
274
+ function F(e) {
275
275
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
276
276
  }
277
277
  function pe(e, t) {
278
- return F(D(e), t);
278
+ return D(F(e), t);
279
279
  }
280
280
  function de(e, t) {
281
- return `var(${D(e)}${t ? `, ${t}` : ""})`;
281
+ return `var(${F(e)}${t ? `, ${t}` : ""})`;
282
282
  }
283
283
  function O(e, t) {
284
284
  return `${e} ${me(t)}`;
285
285
  }
286
286
  function ye(e) {
287
287
  return function(r, n) {
288
- return Object.entries(r).map(([o, c]) => F(o, e(c, n)));
288
+ return Object.entries(r).map(([o, c]) => D(o, e(c, n)));
289
289
  };
290
290
  }
291
291
  function L(e) {
@@ -327,7 +327,7 @@ function C(e) {
327
327
  function he(e) {
328
328
  const t = C(e);
329
329
  return function(n, o) {
330
- const c = I.includes(n.identifier), s = U.includes(
330
+ const c = U.includes(n.identifier), s = I.includes(
331
331
  n.identifier
332
332
  ), a = Object.keys(n.declarations).length > 0, u = n.variables.length > 0, i = n.children.length > 0, f = X(n.identifier, n.rule);
333
333
  return c || s && !(a || u || i) ? `${f};` : t(f, n, o);
@@ -511,7 +511,7 @@ async function Be({
511
511
  function Ee(e) {
512
512
  return Object.prototype.hasOwnProperty.call(e, we);
513
513
  }
514
- async function Fe(e) {
514
+ async function De(e) {
515
515
  const t = Object.getOwnPropertyDescriptor(
516
516
  e,
517
517
  xe
@@ -544,7 +544,7 @@ async function Fe(e) {
544
544
  };
545
545
  }
546
546
  }
547
- function De(e) {
547
+ function Fe(e) {
548
548
  const t = e?.variants;
549
549
  if (!t || Object.keys(t).length === 0)
550
550
  return "Record<string, never>";
@@ -563,7 +563,7 @@ function Le(e) {
563
563
  return function(r, n) {
564
564
  let o = r._exportName;
565
565
  o || (o = E(r.name), r.name[0] && B(r.name[0]) && (o = w(o)));
566
- const c = De(r._runtime);
566
+ const c = Fe(r._runtime);
567
567
  return ` export const ${o}: (props?: ${c}) => string;`;
568
568
  };
569
569
  }
@@ -572,7 +572,7 @@ function Pe(e) {
572
572
  (t) => S(t) && !!t._exportName
573
573
  );
574
574
  }
575
- function Ie(e) {
575
+ function Ue(e) {
576
576
  return function(r, n) {
577
577
  const o = Pe(r.children), c = r.recipes.length > 0, s = o.length > 0, a = [
578
578
  "// Auto-generated by @styleframe/plugin - DO NOT EDIT",
@@ -597,13 +597,13 @@ function Ie(e) {
597
597
  `);
598
598
  };
599
599
  }
600
- function Ue(e) {
600
+ function Ie(e) {
601
601
  return function(r, n) {
602
602
  return r._exportName ? ` export const ${r._exportName}: string;` : "";
603
603
  };
604
604
  }
605
605
  function R(e, t) {
606
- const r = Ie(R), n = Le(), o = Ue();
606
+ const r = Ue(R), n = Le(), o = Ie();
607
607
  switch (!0) {
608
608
  case Array.isArray(e):
609
609
  return e.map((c) => R(c, t)).join(`
@@ -655,7 +655,7 @@ async function Ve(e, {
655
655
  } = {}) {
656
656
  const n = { files: [] }, o = e.options;
657
657
  if (Ee(e)) {
658
- const c = await Fe(e);
658
+ const c = await De(e);
659
659
  (!c.valid || c.instanceId !== e.id) && Me(e);
660
660
  }
661
661
  if (t === "all" || t === "css") {
@@ -683,8 +683,8 @@ async function Ve(e, {
683
683
  }
684
684
  export {
685
685
  ke as DEFAULT_INDENT,
686
- I as STATEMENT_AT_RULES,
687
- U as STATEMENT_OR_BLOCK_AT_RULES,
686
+ U as STATEMENT_AT_RULES,
687
+ I as STATEMENT_OR_BLOCK_AT_RULES,
688
688
  ie as addIndentToLine,
689
689
  y as consumeCSS,
690
690
  $ as consumeTS,
@@ -1,24 +1,24 @@
1
- (function(p,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(p=typeof globalThis<"u"?globalThis:p||self,j(p.transpiler={}))})(this,(function(p){"use strict";const F=["charset","import","namespace"],B=["layer"];function H(e){return typeof e=="object"&&e!==null}function b(e,t){return H(e)&&"type"in e&&e.type===t}function Q(e){return b(e,"variable")}function J(e){return b(e,"reference")}function C(e){return b(e,"selector")}function Z(e){return b(e,"at-rule")}function W(e){return b(e,"utility")}function G(e){return b(e,"css")}function Y(e){return b(e,"theme")}function $(e){return b(e,"root")}function D(e){return b(e,"recipe")}const L=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`;function U(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function S(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function ee(e){if(e=e||{},e.circular)return te(e);const t=new Map;if(t.set(Date,s=>new Date(s)),t.set(Map,(s,a)=>new Map(n(Array.from(s),a))),t.set(Set,(s,a)=>new Set(n(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)t.set(s[0],s[1]);let r;return e.proto?c:o;function n(s,a){const u=Object.keys(s),i=Array.from({length:u.length});for(let f=0;f<u.length;f++){const l=u[f],m=s[l];typeof m!="object"||m===null?i[l]=m:m.constructor!==Object&&(r=t.get(m.constructor))?i[l]=r(m,a):ArrayBuffer.isView(m)?i[l]=S(m):i[l]=a(m)}return i}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,o);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,o);const a={};for(const u in s){if(Object.hasOwnProperty.call(s,u)===!1)continue;const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,o):ArrayBuffer.isView(i)?a[u]=S(i):a[u]=o(i)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,c);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,c);const a={};for(const u in s){const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,c):ArrayBuffer.isView(i)?a[u]=S(i):a[u]=c(i)}return a}}function te(e){const t=[],r=[],n=new Map;if(n.set(Date,u=>new Date(u)),n.set(Map,(u,i)=>new Map(c(Array.from(u),i))),n.set(Set,(u,i)=>new Set(c(Array.from(u),i))),e.constructorHandlers)for(const u of e.constructorHandlers)n.set(u[0],u[1]);let o;return e.proto?a:s;function c(u,i){const f=Object.keys(u),l=Array.from({length:f.length});for(let m=0;m<f.length;m++){const y=f[m],d=u[y];if(typeof d!="object"||d===null)l[y]=d;else if(d.constructor!==Object&&(o=n.get(d.constructor)))l[y]=o(d,i);else if(ArrayBuffer.isView(d))l[y]=S(d);else{const g=t.indexOf(d);g!==-1?l[y]=r[g]:l[y]=i(d)}}return l}function s(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,s);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,s);const i={};t.push(u),r.push(i);for(const f in u){if(Object.hasOwnProperty.call(u,f)===!1)continue;const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,s);else if(ArrayBuffer.isView(l))i[f]=S(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=s(l)}}return t.pop(),r.pop(),i}function a(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,a);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,a);const i={};t.push(u),r.push(i);for(const f in u){const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,a);else if(ArrayBuffer.isView(l))i[f]=S(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=a(l)}}return t.pop(),r.pop(),i}}ee();function re(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let o=0;o<t;o++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}const I=({name:e})=>`[data-theme="${e}"]`,N=({name:e})=>e.replace(/^\.+|\.+$/g,"").replace(/\.+/g,"--");function ne(e,t){return`@${e}${t?" ":""}${t}`}const oe=/\d/,ue=["-","_","/","."];function ce(e=""){if(!oe.test(e))return e!==e.toLowerCase()}function M(e,t){const r=ue,n=[];if(!e||typeof e!="string")return n;let o="",c,s;for(const a of e){const u=r.includes(a);if(u===!0){n.push(o),o="",c=void 0;continue}const i=ce(a);if(s===!1){if(c===!1&&i===!0){n.push(o),o=a,c=i;continue}if(c===!0&&i===!1&&o.length>1){const f=o.at(-1);n.push(o.slice(0,Math.max(0,o.length-1))),o=f+a,c=i;continue}}o+=a,c=i,s=u}return n.push(o),n}function se(e){return e?e[0].toUpperCase()+e.slice(1):""}function ie(e){return e?e[0].toLowerCase()+e.slice(1):""}function ae(e,t){return e?(Array.isArray(e)?e:M(e)).map(r=>se(r)).join(""):""}function le(e,t){return ie(ae(e||""))}function fe(e,t){return e?(Array.isArray(e)?e:M(e)).map(r=>r.toLowerCase()).join("-"):""}function P(e){return` ${e}`}function x(e){return e.split(`
1
+ (function(p,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(p=typeof globalThis<"u"?globalThis:p||self,j(p.transpiler={}))})(this,(function(p){"use strict";const F=["charset","import","namespace"],B=["layer"];function H(e){return typeof e=="object"&&e!==null}function b(e,t){return H(e)&&"type"in e&&e.type===t}function Q(e){return b(e,"variable")}function J(e){return b(e,"reference")}function C(e){return b(e,"selector")}function Z(e){return b(e,"at-rule")}function W(e){return b(e,"utility")}function G(e){return b(e,"css")}function Y(e){return b(e,"theme")}function T(e){return b(e,"root")}function D(e){return b(e,"recipe")}const L=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`;function U(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function A(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function ee(e){if(e=e||{},e.circular)return te(e);const t=new Map;if(t.set(Date,s=>new Date(s)),t.set(Map,(s,a)=>new Map(n(Array.from(s),a))),t.set(Set,(s,a)=>new Set(n(Array.from(s),a))),e.constructorHandlers)for(const s of e.constructorHandlers)t.set(s[0],s[1]);let r;return e.proto?c:o;function n(s,a){const u=Object.keys(s),i=Array.from({length:u.length});for(let f=0;f<u.length;f++){const l=u[f],m=s[l];typeof m!="object"||m===null?i[l]=m:m.constructor!==Object&&(r=t.get(m.constructor))?i[l]=r(m,a):ArrayBuffer.isView(m)?i[l]=A(m):i[l]=a(m)}return i}function o(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,o);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,o);const a={};for(const u in s){if(Object.hasOwnProperty.call(s,u)===!1)continue;const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,o):ArrayBuffer.isView(i)?a[u]=A(i):a[u]=o(i)}return a}function c(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return n(s,c);if(s.constructor!==Object&&(r=t.get(s.constructor)))return r(s,c);const a={};for(const u in s){const i=s[u];typeof i!="object"||i===null?a[u]=i:i.constructor!==Object&&(r=t.get(i.constructor))?a[u]=r(i,c):ArrayBuffer.isView(i)?a[u]=A(i):a[u]=c(i)}return a}}function te(e){const t=[],r=[],n=new Map;if(n.set(Date,u=>new Date(u)),n.set(Map,(u,i)=>new Map(c(Array.from(u),i))),n.set(Set,(u,i)=>new Set(c(Array.from(u),i))),e.constructorHandlers)for(const u of e.constructorHandlers)n.set(u[0],u[1]);let o;return e.proto?a:s;function c(u,i){const f=Object.keys(u),l=Array.from({length:f.length});for(let m=0;m<f.length;m++){const y=f[m],d=u[y];if(typeof d!="object"||d===null)l[y]=d;else if(d.constructor!==Object&&(o=n.get(d.constructor)))l[y]=o(d,i);else if(ArrayBuffer.isView(d))l[y]=A(d);else{const g=t.indexOf(d);g!==-1?l[y]=r[g]:l[y]=i(d)}}return l}function s(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,s);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,s);const i={};t.push(u),r.push(i);for(const f in u){if(Object.hasOwnProperty.call(u,f)===!1)continue;const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,s);else if(ArrayBuffer.isView(l))i[f]=A(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=s(l)}}return t.pop(),r.pop(),i}function a(u){if(typeof u!="object"||u===null)return u;if(Array.isArray(u))return c(u,a);if(u.constructor!==Object&&(o=n.get(u.constructor)))return o(u,a);const i={};t.push(u),r.push(i);for(const f in u){const l=u[f];if(typeof l!="object"||l===null)i[f]=l;else if(l.constructor!==Object&&(o=n.get(l.constructor)))i[f]=o(l,a);else if(ArrayBuffer.isView(l))i[f]=A(l);else{const m=t.indexOf(l);m!==-1?i[f]=r[m]:i[f]=a(l)}}return t.pop(),r.pop(),i}}ee();function re(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let o=0;o<t;o++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}const I=({name:e})=>`.${e}-theme, [data-theme="${e}"]`,N=({name:e})=>e.replace(/^\.+|\.+$/g,"").replace(/\.+/g,"--");function ne(e,t){return`@${e}${t?" ":""}${t}`}const oe=/\d/,ue=["-","_","/","."];function ce(e=""){if(!oe.test(e))return e!==e.toLowerCase()}function M(e,t){const r=ue,n=[];if(!e||typeof e!="string")return n;let o="",c,s;for(const a of e){const u=r.includes(a);if(u===!0){n.push(o),o="",c=void 0;continue}const i=ce(a);if(s===!1){if(c===!1&&i===!0){n.push(o),o=a,c=i;continue}if(c===!0&&i===!1&&o.length>1){const f=o.at(-1);n.push(o.slice(0,Math.max(0,o.length-1))),o=f+a,c=i;continue}}o+=a,c=i,s=u}return n.push(o),n}function se(e){return e?e[0].toUpperCase()+e.slice(1):""}function ie(e){return e?e[0].toLowerCase()+e.slice(1):""}function ae(e,t){return e?(Array.isArray(e)?e:M(e)).map(r=>se(r)).join(""):""}function le(e,t){return ie(ae(e||""))}function fe(e,t){return e?(Array.isArray(e)?e:M(e)).map(r=>r.toLowerCase()).join("-"):""}function P(e){return` ${e}`}function x(e){return e.split(`
2
2
  `).map(t=>P(t)).join(`
3
- `)}function _(e){return e===e.toUpperCase()}function E(e){return le(e)}function k(e){return fe(e)}function me(e){return k(e)}function V(e,t){return`${e.startsWith("--")?e:me(e)}: ${t};`}function pe(e){return`{${e.length>0?`
3
+ `)}function _(e){return e===e.toUpperCase()}function O(e){return le(e)}function k(e){return fe(e)}function me(e){return k(e)}function V(e,t){return`${e.startsWith("--")?e:me(e)}: ${t};`}function pe(e){return`{${e.length>0?`
4
4
  `:""}${e.map(t=>`${x(`${t}`)}
5
- `).join("")}}`}function K(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function de(e,t){return V(K(e),t)}function ye(e,t){return`var(${K(e)}${t?`, ${t}`:""})`}function q(e,t){return`${e} ${pe(t)}`}function he(e){return function(r,n){return Object.entries(r).map(([o,c])=>V(o,e(c,n)))}}function z(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return de(c,e(r.value,n))}}function v(e){const t=z(e),r=he(e);return function(o,c,s){const{variables:a,declarations:u,children:i}=c,f=o===":root",l=(a??[]).map(A=>t(A,s)),m=r(u??{},s),y=(i??[]).map(A=>e(A,s)),d=l.length>0,g=m.length>0,w=y.length>0;return f?`${d||g?q(o,[...l,...d&&g?[""]:[],...m]):""}${w&&(d||g)?`
5
+ `).join("")}}`}function K(e){return`--${(e.startsWith("--")?e.slice(2):e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g,"-")||"unknown-variable"}`}function de(e,t){return V(K(e),t)}function ye(e,t){return`var(${K(e)}${t?`, ${t}`:""})`}function q(e,t){return`${e} ${pe(t)}`}function he(e){return function(r,n){return Object.entries(r).map(([o,c])=>V(o,e(c,n)))}}function z(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return de(c,e(r.value,n))}}function v(e){const t=z(e),r=he(e);return function(o,c,s){const{variables:a,declarations:u,children:i}=c,f=o===":root",l=(a??[]).map(S=>t(S,s)),m=r(u??{},s),y=(i??[]).map(S=>e(S,s)),d=l.length>0,g=m.length>0,w=y.length>0;return f?`${d||g?q(o,[...l,...d&&g?[""]:[],...m]):""}${w&&(d||g)?`
6
6
 
7
7
  `:""}${y.join(`
8
8
 
9
- `)}`:q(o,[...l,...d&&(w||g)?[""]:[],...m,...g&&w?[""]:[],...y.flatMap((A,Ke)=>Ke===y.length-1?[A]:[A,""])])}}function be(e){const t=v(e);return function(n,o){const c=F.includes(n.identifier),s=B.includes(n.identifier),a=Object.keys(n.declarations).length>0,u=n.variables.length>0,i=n.children.length>0,f=ne(n.identifier,n.rule);return c||s&&!(a||u||i)?`${f};`:t(f,n,o)}}function ge(e){return function(r,n){return r.value.map(o=>e(o,n)).join("").trim()}}function Se(e){return function(r,n){return r!=null?`${r}`:""}}function Ae(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return ye(c,r.fallback?e(r.fallback,n):void 0)}}function Ce(e){const t=v(e);return function(n,o){return n.themes.reduce((c,s)=>(c.push(e(s,o)),c),[t(":root",n,o)]).join(`
9
+ `)}`:q(o,[...l,...d&&(w||g)?[""]:[],...m,...g&&w?[""]:[],...y.flatMap((S,Ke)=>Ke===y.length-1?[S]:[S,""])])}}function be(e){const t=v(e);return function(n,o){const c=F.includes(n.identifier),s=B.includes(n.identifier),a=Object.keys(n.declarations).length>0,u=n.variables.length>0,i=n.children.length>0,f=ne(n.identifier,n.rule);return c||s&&!(a||u||i)?`${f};`:t(f,n,o)}}function ge(e){return function(r,n){return r.value.map(o=>e(o,n)).join("").trim()}}function Ae(e){return function(r,n){return r!=null?`${r}`:""}}function Se(e){return function(r,n){const c=(n.variables?.name??N)({name:r.name});return ye(c,r.fallback?e(r.fallback,n):void 0)}}function Ce(e){const t=v(e);return function(n,o){return n.themes.reduce((c,s)=>(c.push(e(s,o)),c),[t(":root",n,o)]).join(`
10
10
 
11
11
  `)}}function ve(e){const t=v(e);return function(n,o){return t(n.query,n,o)}}function je(e){const t=v(e);return function(n,o){const s=(o.themes?.selector??I)({name:n.name});return t(s,n,o)}}function Re(e){const t=v(e);return function(n,o){const c=[],a=(o.utilities?.selector??L)({name:n.name,value:n.value,modifiers:n.modifiers}),u=X(a);return c.push(t(u,n,o)),c.join(`
12
12
 
13
- `)}}function h(e,t){const r=Ce(h),n=ve(h),o=Re(h),c=be(h),s=je(h),a=z(h),u=Ae(h),i=ge(h),f=Se();switch(!0){case C(e):return n(e,t);case W(e):return o(e,t);case Z(e):return c(e,t);case $(e):return r(e,t);case Y(e):return s(e,t);case Q(e):return a(e,t);case J(e):return u(e,t);case G(e):return i(e,t);default:return f(e,t)}}function Te(e){return function(r,n){let o=r._exportName;o||(o=E(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=`${o}Recipe`,s=r._runtime??{};return`const ${c} = ${JSON.stringify(s,null,4)} as const satisfies RecipeRuntime;
13
+ `)}}function h(e,t){const r=Ce(h),n=ve(h),o=Re(h),c=be(h),s=je(h),a=z(h),u=Se(h),i=ge(h),f=Ae();switch(!0){case C(e):return n(e,t);case W(e):return o(e,t);case Z(e):return c(e,t);case T(e):return r(e,t);case Y(e):return s(e,t);case Q(e):return a(e,t);case J(e):return u(e,t);case G(e):return i(e,t);default:return f(e,t)}}function $e(e){return function(r,n){let o=r._exportName;o||(o=O(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=`${o}Recipe`,s=r._runtime??{};return`const ${c} = ${JSON.stringify(s,null,4)} as const satisfies RecipeRuntime;
14
14
 
15
15
  export const ${o} = createRecipe("${r.name}", ${c});
16
- `}}function $e(e){return e.filter(t=>C(t)&&!!t._exportName)}function Ne(e){return function(r,n){const o=$e(r.children),c=r.recipes.length>0,s=o.length>0;if(!c&&!s)return"";const a=[];return c&&(a.push(`import { createRecipe } from '@styleframe/runtime';
16
+ `}}function Te(e){return e.filter(t=>C(t)&&!!t._exportName)}function Ne(e){return function(r,n){const o=Te(r.children),c=r.recipes.length>0,s=o.length>0;if(!c&&!s)return"";const a=[];return c&&(a.push(`import { createRecipe } from '@styleframe/runtime';
17
17
  import type { RecipeRuntime } from '@styleframe/runtime';
18
18
  `),a.push(e(r.recipes,n))),s&&a.push(e(o,n)),a.join(`
19
19
  `)}}function _e(e){return function(r,n){return r._exportName?`export const ${r._exportName} = ${JSON.stringify(r.query)};
20
- `:""}}function R(e,t){const r=Ne(R),n=Te(),o=_e();switch(!0){case Array.isArray(e):return e.map(c=>R(c,t)).join(`
21
- `);case $(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}const Ee=`-----BEGIN PUBLIC KEY-----
20
+ `:""}}function R(e,t){const r=Ne(R),n=$e(),o=_e();switch(!0){case Array.isArray(e):return e.map(c=>R(c,t)).join(`
21
+ `);case T(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}const Oe=`-----BEGIN PUBLIC KEY-----
22
22
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
23
23
  qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
24
24
  BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
@@ -26,6 +26,6 @@ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
26
26
  hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
27
27
  4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
28
28
  GwIDAQAB
29
- -----END PUBLIC KEY-----`,Oe="__licenseRequired",we="__licenseValidated";async function Fe(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=Uint8Array.from(atob(t),n=>n.charCodeAt(0));return await crypto.subtle.importKey("spki",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function Be({payload:e,signature:t}){const r=new TextEncoder().encode(e),n=Uint8Array.from(atob(t),c=>c.charCodeAt(0)),o=await Fe(Ee);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,n,r))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function De(e){return Object.prototype.hasOwnProperty.call(e,Oe)}async function Le(e){const t=Object.getOwnPropertyDescriptor(e,we);if(!t?.value)return{key:"",instanceId:"",environment:"",valid:!1};const r=t.value;if(typeof r!="object"||r===null||!("payload"in r)||!("signature"in r)||typeof r.payload!="string"||typeof r.signature!="string")return{key:"",instanceId:"",environment:"",valid:!1};try{return await Be(r)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function Ue(e){const t=e?.variants;if(!t||Object.keys(t).length===0)return"Record<string, never>";const r=[];for(const[n,o]of Object.entries(t)){if(!o)continue;const c=Object.keys(o);if(c.length>0){const s=c.map(a=>`"${a}"`).join(" | ");r.push(`${n}?: ${s}`)}}return r.length===0?"Record<string, never>":`{ ${r.join("; ")} }`}function Ie(e){return function(r,n){let o=r._exportName;o||(o=E(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=Ue(r._runtime);return` export const ${o}: (props?: ${c}) => string;`}}function Me(e){return e.filter(t=>C(t)&&!!t._exportName)}function Pe(e){return function(r,n){const o=Me(r.children),c=r.recipes.length>0,s=o.length>0,a=["// Auto-generated by @styleframe/plugin - DO NOT EDIT","",'declare module "virtual:styleframe" {',' import type { Styleframe } from "@styleframe/core";',""," /** Returns the global styleframe instance from styleframe.config.ts */"," export function styleframe(): Styleframe;"];if(c){a.push("");const u=r.recipes.map(i=>e(i,n)).filter(Boolean);a.push(...u)}if(s){a.push("");const u=o.map(i=>e(i,n)).filter(Boolean);a.push(...u)}return a.push("}"),a.push(""),a.push('declare module "virtual:styleframe.css" {'),a.push(" const css: string;"),a.push(" export default css;"),a.push("}"),a.push(""),a.join(`
30
- `)}}function xe(e){return function(r,n){return r._exportName?` export const ${r._exportName}: string;`:""}}function O(e,t){const r=Pe(O),n=Ie(),o=xe();switch(!0){case Array.isArray(e):return e.map(c=>O(c,t)).join(`
31
- `);case $(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}function ke(e){const t=Math.floor(Math.random()*100);e.root.children.push({type:"selector",id:re("sel-"),query:`html:nth-of-type(${t}n+1)::after`,variables:[],children:[],declarations:{content:'"Styleframe Pro: Development Mode – License required for production use"',zIndex:99999,position:"fixed",display:"block !important",opacity:"1 !important",bottom:0,left:0,background:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"12px",lineHeight:"1",padding:"0.5rem",fontFamily:"sans-serif"}})}function T(e,t=""){return{name:e,content:t}}async function Ve(e,{type:t="all",consumers:r={css:h,ts:R,dts:O}}={}){const n={files:[]},o=e.options;if(De(e)){const c=await Le(e);(!c.valid||c.instanceId!==e.id)&&ke(e)}if(t==="all"||t==="css"){const c=T("index.css",r.css(e.root,o));n.files.push(c)}if(t==="all"||t==="ts"){const c=T("index.ts",r.ts(e.root,o));n.files.push(c)}if(t==="dts"){const c=T("index.d.ts",r.dts(e.root,o));n.files.push(c)}return n}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=F,p.STATEMENT_OR_BLOCK_AT_RULES=B,p.addIndentToLine=P,p.consumeCSS=h,p.consumeTS=R,p.createFile=T,p.defaultThemeSelectorFn=I,p.defaultUtilitySelectorFn=L,p.defaultVariableNameFn=N,p.indentLines=x,p.isUppercase=_,p.toCamelCase=E,p.toKebabCase=k,p.transpile=Ve,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
29
+ -----END PUBLIC KEY-----`,Ee="__licenseRequired",we="__licenseValidated";async function Fe(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,""),r=Uint8Array.from(atob(t),n=>n.charCodeAt(0));return await crypto.subtle.importKey("spki",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function Be({payload:e,signature:t}){const r=new TextEncoder().encode(e),n=Uint8Array.from(atob(t),c=>c.charCodeAt(0)),o=await Fe(Oe);if(!await crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,n,r))throw new Error("License validation failed: Invalid signature detected. The license may have been modified or corrupted.");return JSON.parse(e)}function De(e){return Object.prototype.hasOwnProperty.call(e,Ee)}async function Le(e){const t=Object.getOwnPropertyDescriptor(e,we);if(!t?.value)return{key:"",instanceId:"",environment:"",valid:!1};const r=t.value;if(typeof r!="object"||r===null||!("payload"in r)||!("signature"in r)||typeof r.payload!="string"||typeof r.signature!="string")return{key:"",instanceId:"",environment:"",valid:!1};try{return await Be(r)}catch{return{key:"",instanceId:"",environment:"",valid:!1}}}function Ue(e){const t=e?.variants;if(!t||Object.keys(t).length===0)return"Record<string, never>";const r=[];for(const[n,o]of Object.entries(t)){if(!o)continue;const c=Object.keys(o);if(c.length>0){const s=c.map(a=>`"${a}"`).join(" | ");r.push(`${n}?: ${s}`)}}return r.length===0?"Record<string, never>":`{ ${r.join("; ")} }`}function Ie(e){return function(r,n){let o=r._exportName;o||(o=O(r.name),r.name[0]&&_(r.name[0])&&(o=U(o)));const c=Ue(r._runtime);return` export const ${o}: (props?: ${c}) => string;`}}function Me(e){return e.filter(t=>C(t)&&!!t._exportName)}function Pe(e){return function(r,n){const o=Me(r.children),c=r.recipes.length>0,s=o.length>0,a=["// Auto-generated by @styleframe/plugin - DO NOT EDIT","",'declare module "virtual:styleframe" {',' import type { Styleframe } from "@styleframe/core";',""," /** Returns the global styleframe instance from styleframe.config.ts */"," export function styleframe(): Styleframe;"];if(c){a.push("");const u=r.recipes.map(i=>e(i,n)).filter(Boolean);a.push(...u)}if(s){a.push("");const u=o.map(i=>e(i,n)).filter(Boolean);a.push(...u)}return a.push("}"),a.push(""),a.push('declare module "virtual:styleframe.css" {'),a.push(" const css: string;"),a.push(" export default css;"),a.push("}"),a.push(""),a.join(`
30
+ `)}}function xe(e){return function(r,n){return r._exportName?` export const ${r._exportName}: string;`:""}}function E(e,t){const r=Pe(E),n=Ie(),o=xe();switch(!0){case Array.isArray(e):return e.map(c=>E(c,t)).join(`
31
+ `);case T(e):return r(e,t);case D(e):return n(e,t);case C(e):return o(e,t);default:return""}}function ke(e){const t=Math.floor(Math.random()*100);e.root.children.push({type:"selector",id:re("sel-"),query:`html:nth-of-type(${t}n+1)::after`,variables:[],children:[],declarations:{content:'"Styleframe Pro: Development Mode – License required for production use"',zIndex:99999,position:"fixed",display:"block !important",opacity:"1 !important",bottom:0,left:0,background:"rgba(0, 0, 0, 0.5)",color:"white",fontSize:"12px",lineHeight:"1",padding:"0.5rem",fontFamily:"sans-serif"}})}function $(e,t=""){return{name:e,content:t}}async function Ve(e,{type:t="all",consumers:r={css:h,ts:R,dts:E}}={}){const n={files:[]},o=e.options;if(De(e)){const c=await Le(e);(!c.valid||c.instanceId!==e.id)&&ke(e)}if(t==="all"||t==="css"){const c=$("index.css",r.css(e.root,o));n.files.push(c)}if(t==="all"||t==="ts"){const c=$("index.ts",r.ts(e.root,o));n.files.push(c)}if(t==="dts"){const c=$("index.d.ts",r.dts(e.root,o));n.files.push(c)}return n}p.DEFAULT_INDENT=" ",p.STATEMENT_AT_RULES=F,p.STATEMENT_OR_BLOCK_AT_RULES=B,p.addIndentToLine=P,p.consumeCSS=h,p.consumeTS=R,p.createFile=$,p.defaultThemeSelectorFn=I,p.defaultUtilitySelectorFn=L,p.defaultVariableNameFn=N,p.indentLines=x,p.isUppercase=_,p.toCamelCase=O,p.toKebabCase=k,p.transpile=Ve,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@styleframe/transpiler",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "types": "./dist/transpiler.d.ts",
6
6
  "module": "./dist/transpiler.js",
@@ -22,13 +22,13 @@
22
22
  "scule": "^1.3.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@styleframe/core": "^3.1.0",
25
+ "@styleframe/core": "^3.2.0",
26
26
  "@styleframe/license": "^2.0.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@styleframe/config-typescript": "^3.0.0",
30
30
  "@styleframe/config-vite": "^3.0.0",
31
- "@styleframe/core": "^3.1.0",
31
+ "@styleframe/core": "^3.2.0",
32
32
  "@styleframe/license": "^2.0.2",
33
33
  "@vitest/coverage-v8": "^3.2.4",
34
34
  "typescript": "^5.8.3",