@styleframe/core 3.5.0 → 3.6.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 +18 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/defaults.d.ts +11 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.test.d.ts +2 -0
- package/dist/defaults.test.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/styleframe.d.ts +20 -646
- package/dist/styleframe.d.ts.map +1 -0
- package/dist/styleframe.js +815 -988
- package/dist/styleframe.umd.cjs +1 -1
- package/dist/tokens/atRule.d.ts +5 -0
- package/dist/tokens/atRule.d.ts.map +1 -0
- package/dist/tokens/atRule.test.d.ts +2 -0
- package/dist/tokens/atRule.test.d.ts.map +1 -0
- package/dist/tokens/css.d.ts +3 -0
- package/dist/tokens/css.d.ts.map +1 -0
- package/dist/tokens/css.test.d.ts +2 -0
- package/dist/tokens/css.test.d.ts.map +1 -0
- package/dist/tokens/declarations.d.ts +4 -0
- package/dist/tokens/declarations.d.ts.map +1 -0
- package/dist/tokens/declarations.test.d.ts +2 -0
- package/dist/tokens/declarations.test.d.ts.map +1 -0
- package/dist/tokens/index.d.ts +13 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/modifier.d.ts +4 -0
- package/dist/tokens/modifier.d.ts.map +1 -0
- package/dist/tokens/modifier.test.d.ts +2 -0
- package/dist/tokens/modifier.test.d.ts.map +1 -0
- package/dist/tokens/recipe.d.ts +208 -0
- package/dist/tokens/recipe.d.ts.map +1 -0
- package/dist/tokens/recipe.test.d.ts +2 -0
- package/dist/tokens/recipe.test.d.ts.map +1 -0
- package/dist/tokens/ref.d.ts +3 -0
- package/dist/tokens/ref.d.ts.map +1 -0
- package/dist/tokens/ref.test.d.ts +2 -0
- package/dist/tokens/ref.test.d.ts.map +1 -0
- package/dist/tokens/resolve.d.ts +28 -0
- package/dist/tokens/resolve.d.ts.map +1 -0
- package/dist/tokens/resolve.test.d.ts +2 -0
- package/dist/tokens/resolve.test.d.ts.map +1 -0
- package/dist/tokens/root.d.ts +3 -0
- package/dist/tokens/root.d.ts.map +1 -0
- package/dist/tokens/root.test.d.ts +2 -0
- package/dist/tokens/root.test.d.ts.map +1 -0
- package/dist/tokens/root.usage.test.d.ts +2 -0
- package/dist/tokens/root.usage.test.d.ts.map +1 -0
- package/dist/tokens/selector.d.ts +3 -0
- package/dist/tokens/selector.d.ts.map +1 -0
- package/dist/tokens/selector.test.d.ts +2 -0
- package/dist/tokens/selector.test.d.ts.map +1 -0
- package/dist/tokens/theme.d.ts +3 -0
- package/dist/tokens/theme.d.ts.map +1 -0
- package/dist/tokens/theme.test.d.ts +2 -0
- package/dist/tokens/theme.test.d.ts.map +1 -0
- package/dist/tokens/utility.d.ts +6 -0
- package/dist/tokens/utility.d.ts.map +1 -0
- package/dist/tokens/utility.test.d.ts +2 -0
- package/dist/tokens/utility.test.d.ts.map +1 -0
- package/dist/tokens/variable.d.ts +5 -0
- package/dist/tokens/variable.d.ts.map +1 -0
- package/dist/tokens/variable.test.d.ts +2 -0
- package/dist/tokens/variable.test.d.ts.map +1 -0
- package/dist/typeGuards.d.ts +24 -0
- package/dist/typeGuards.d.ts.map +1 -0
- package/dist/typeGuards.test.d.ts +2 -0
- package/dist/typeGuards.test.d.ts.map +1 -0
- package/dist/types/declarations.d.ts +21 -0
- package/dist/types/declarations.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/minify.d.ts +9 -0
- package/dist/types/minify.d.ts.map +1 -0
- package/dist/types/options.d.ts +25 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/tokens.d.ts +156 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/utils/capitalizeFirst.d.ts +6 -0
- package/dist/utils/capitalizeFirst.d.ts.map +1 -0
- package/dist/utils/cssSelector.d.ts +6 -0
- package/dist/utils/cssSelector.d.ts.map +1 -0
- package/dist/utils/cssSelector.test.d.ts +2 -0
- package/dist/utils/cssSelector.test.d.ts.map +1 -0
- package/dist/utils/deepClone.d.ts +23 -0
- package/dist/utils/deepClone.d.ts.map +1 -0
- package/dist/utils/generateRandomId.d.ts +9 -0
- package/dist/utils/generateRandomId.d.ts.map +1 -0
- package/dist/utils/getters.d.ts +5 -0
- package/dist/utils/getters.d.ts.map +1 -0
- package/dist/utils/getters.test.d.ts +2 -0
- package/dist/utils/getters.test.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +9 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.test.d.ts +2 -0
- package/dist/utils/hash.test.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/isTokenEqual.d.ts +3 -0
- package/dist/utils/isTokenEqual.d.ts.map +1 -0
- package/dist/utils/isTokenEqual.test.d.ts +2 -0
- package/dist/utils/isTokenEqual.test.d.ts.map +1 -0
- package/dist/utils/merge.d.ts +8 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.test.d.ts +2 -0
- package/dist/utils/merge.test.d.ts.map +1 -0
- package/package.json +8 -11
package/dist/styleframe.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(l=typeof globalThis<"u"?globalThis:l||self,A(l.styleframe={}))})(this,(function(l){"use strict";function A(e){return typeof e=="object"&&e!==null}function b(e,t){return A(e)&&"type"in e&&e.type===t}function C(e){return b(e,"variable")}function p(e){return b(e,"reference")}function _e(e){return b(e,"selector")}function Y(e){return b(e,"at-rule")}function Fe(e){return b(e,"utility")}function Z(e){return b(e,"modifier")}function k(e){return b(e,"css")}function Se(e){return b(e,"theme")}function M(e){return b(e,"root")}function Te(e){return b(e,"recipe")}function J(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function $(e){return J(e)||p(e)||k(e)||Array.isArray(e)&&e.every($)}function $e(e){return A(e)&&"id"in e&&"children"in e&&"declarations"in e&&"variables"in e}function P(e){return A(e)&&"children"in e&&"declarations"in e&&"variables"in e}function Q(e){return typeof e=="string"&&e.startsWith("@")}function Ee(e){return A(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&M(e.root)}function x(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)&4294967295;return(t>>>0).toString(16).padStart(7,"0").slice(0,7)}function B(e){const t=typeof e=="function"?{replacer:e}:e??{},{replacer:r=c=>c,namespace:n}=t,s=Array.isArray(n)?n:n?[n]:[];return c=>{let i=c,o;if(typeof i=="string"&&i[0]==="@"){const a=i.slice(1),f=s.find(y=>a===y||a.startsWith(`${y}.`));let d,u;f?(d=a,u=a.startsWith(`${f}.`)?a.slice(f.length+1):a):s.length>0?(d=`${s[0]}.${a}`,u=a):(d=a,u=a),o=r(u),i={type:"reference",name:d}}else if(p(i)){let a=i.name;for(const f of s)if(a.startsWith(`${f}.`)){a=a.slice(f.length+1);break}o=r(a)}else{const a=String(c).trim();/\s/.test(a)?o=x(a):o=`[${a}]`}return{[o]:i}}}const ee=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`;function te(e,t){if(p(t)){e._usage.variables.add(t.name);return}if(k(t))for(const r of t.value)p(r)&&e._usage.variables.add(r.name)}const D=/@([\w.-]+)/g;function I(e){const t=[];let r=0,n;for(D.lastIndex=0;(n=D.exec(e))!==null;){const c=e.slice(r,n.index);c!==""&&t.push(c),t.push({type:"reference",name:n[1]}),r=D.lastIndex}const s=e.slice(r);return s!==""&&t.push(s),t}function ne(e,t,r){let n=t;for(;n;){if(n.variables.some(s=>s.name===e))return!0;if(n.parentId)n=r._registry.get(n.parentId);else break}return!1}function re(e,t,r){if(!ne(e,t,r))throw new Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function E(e,t){return function(n){if(typeof n!="string"||!n.includes("@"))return n;if(Q(n)&&/^@[\w.-]+$/.test(n)){const i=n.slice(1);return re(i,e,t),t._usage.variables.add(i),{type:"reference",name:i}}const s=I(n);if(s.some(i=>p(i))){for(const i of s)p(i)&&t._usage.variables.add(i.name);return{type:"css",value:s}}return n}}function K(e,t){return function(n,s){const c=E(e,t),i=s!=null?c(s):s;if(C(n))return t._usage.variables.add(n.name),{type:"reference",name:n.name,fallback:i};if(n==null)throw new Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return t._usage.variables.add(n),{type:"reference",name:n,fallback:i}}}function ie(e,t){const r=K(e,t),n=s=>{const c=I(s);for(const i of c)p(i)&&t._usage.variables.add(i.name);return c};return function(c,...i){return{type:"css",value:c.reduce((a,f,d)=>{if(a.push(...n(f)),d<i.length){const u=i[d];C(u)?a.push(r(u)):Y(u)?a.push(u.rule):typeof u=="string"&&u.includes("@")?a.push(...n(u)):a.push(u)}return a},[])}}}function Oe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ne(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function j(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 se(e){if(e=e||{},e.circular)return Ue(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,o)=>new Map(n(Array.from(i),o))),t.set(Set,(i,o)=>new Set(n(Array.from(i),o))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let r;return e.proto?c:s;function n(i,o){const a=Object.keys(i),f=Array.from({length:a.length});for(let d=0;d<a.length;d++){const u=a[d],y=i[u];typeof y!="object"||y===null?f[u]=y:y.constructor!==Object&&(r=t.get(y.constructor))?f[u]=r(y,o):ArrayBuffer.isView(y)?f[u]=j(y):f[u]=o(y)}return f}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,s);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,s);const o={};for(const a in i){if(Object.hasOwnProperty.call(i,a)===!1)continue;const f=i[a];typeof f!="object"||f===null?o[a]=f:f.constructor!==Object&&(r=t.get(f.constructor))?o[a]=r(f,s):ArrayBuffer.isView(f)?o[a]=j(f):o[a]=s(f)}return o}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,c);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,c);const o={};for(const a in i){const f=i[a];typeof f!="object"||f===null?o[a]=f:f.constructor!==Object&&(r=t.get(f.constructor))?o[a]=r(f,c):ArrayBuffer.isView(f)?o[a]=j(f):o[a]=c(f)}return o}}function Ue(e){const t=[],r=[],n=new Map;if(n.set(Date,a=>new Date(a)),n.set(Map,(a,f)=>new Map(c(Array.from(a),f))),n.set(Set,(a,f)=>new Set(c(Array.from(a),f))),e.constructorHandlers)for(const a of e.constructorHandlers)n.set(a[0],a[1]);let s;return e.proto?o:i;function c(a,f){const d=Object.keys(a),u=Array.from({length:d.length});for(let y=0;y<d.length;y++){const m=d[y],h=a[m];if(typeof h!="object"||h===null)u[m]=h;else if(h.constructor!==Object&&(s=n.get(h.constructor)))u[m]=s(h,f);else if(ArrayBuffer.isView(h))u[m]=j(h);else{const v=t.indexOf(h);v!==-1?u[m]=r[v]:u[m]=f(h)}}return u}function i(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,i);if(a.constructor!==Object&&(s=n.get(a.constructor)))return s(a,i);const f={};t.push(a),r.push(f);for(const d in a){if(Object.hasOwnProperty.call(a,d)===!1)continue;const u=a[d];if(typeof u!="object"||u===null)f[d]=u;else if(u.constructor!==Object&&(s=n.get(u.constructor)))f[d]=s(u,i);else if(ArrayBuffer.isView(u))f[d]=j(u);else{const y=t.indexOf(u);y!==-1?f[d]=r[y]:f[d]=i(u)}}return t.pop(),r.pop(),f}function o(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,o);if(a.constructor!==Object&&(s=n.get(a.constructor)))return s(a,o);const f={};t.push(a),r.push(f);for(const d in a){const u=a[d];if(typeof u!="object"||u===null)f[d]=u;else if(u.constructor!==Object&&(s=n.get(u.constructor)))f[d]=s(u,o);else if(ArrayBuffer.isView(u))f[d]=j(u);else{const y=t.indexOf(u);y!==-1?f[d]=r[y]:f[d]=o(u)}}return t.pop(),r.pop(),f}}const _=se();function w(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let s=0;s<t;s++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}function Ce(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function Pe(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function ce(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}function O(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>O(r,t[n]));if("type"in e&&"type"in t){if(e.type!==t.type)return!1;if(p(e)&&p(t))return e.name===t.name&&O(e.fallback,t.fallback);if(k(e)&&k(t))return O(e.value,t.value)}return!1}const ae="__licenseRequired";function Be(e){W(e)||Object.defineProperty(e,ae,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function W(e){return Object.prototype.hasOwnProperty.call(e,ae)}function oe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?s.value=n.value:r.push(n)}return r}function fe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?Object.assign(s,H(s,n)):r.push(n)}return r}function H(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=oe(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&M(r)&&M(e)&&M(t)?r.themes=fe(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function L(e,t){for(const r of e)"id"in r&&typeof r.id=="string"&&(t._registry.set(r.id,r),"children"in r&&L(r.children,t))}function ue(e){e._registry=new Map,e._registry.set(e.id,e),L(e.children,e);for(const t of e.themes)e._registry.set(t.id,t),L(t.children,e)}function De(e,...t){return t.reduce((r,n)=>{const s={...r,root:H(r.root,n.root)};return ue(s.root),(W(r)||W(n))&&Be(s),s},e)}function N(e,t){return function(n,s,c){const i={type:"at-rule",id:w("ar-"),parentId:e.id,identifier:n,rule:s,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);const o=R(i,t);return typeof c=="function"?i.declarations=c(o)??{}:P(c)?(i.variables=c.variables,i.declarations=c.declarations,i.children=c.children):c&&(i.declarations=c),F(i.declarations,o,i,t),e.children.push(i),i}}function le(e,t){const r=N(e,t);return function(s,c){return r("media",s,c)}}function de(e,t){const r=N(e,t);return function(s,c){return r("keyframes",s,c)}}function ye(e,t){return function(n,s){const c={type:"selector",id:w("sel-"),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(c.id,c);const i=R(c,t);return typeof s=="function"?c.declarations=s(i)??{}:P(s)?(c.variables=s.variables,c.declarations=s.declarations,c.children=s.children):c.declarations=s,F(c.declarations,i,c,t),e.children.push(c),c}}function me(e,t){return function(n,s,c={default:!1}){const i=typeof n=="string"?n:n.name,a=E(e,t)(s),f=e.variables.find(u=>u.name===i);if(c.default&&f)return f;if(f)return f.value=a,f;const d={type:"variable",id:w("var-"),parentId:e.id,name:i,value:a};return e.variables.push(d),d}}function R(e,t){const r=me(e,t),n=ye(e,t),s=N(e,t),c=de(t,t),i=le(e,t),o=K(t,t),a=ie(t,t);return{variable:r,selector:n,keyframes:c,atRule:s,media:i,ref:o,css:a}}function F(e,t,r,n){for(const c in e)if(c.startsWith("@")){const i=e[c];if(typeof i=="object"&&i!==null&&!$(i)){const o=c.replace(/^@(\w+).*/,"$1"),a=c.replace(`@${o}`,"").trim();t.atRule(o,a,i),delete e[c]}}else if(/^[.&:]/.test(c)||/^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(c)){const i=e[c];typeof i=="object"&&(t.selector(c,i),delete e[c])}const s=E(r,n);for(const c in e){const i=e[c];if($(i)){const o=s(i);o!==i&&(e[c]=o)}}return e}function he(e,t,r){const n={...e,id:w("ut-"),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...r.keys()]};if(t._registry.set(n.id,n),r.size>0){const s=[...r.values()];let c=_(e.declarations);n.declarations={},n.variables=[],n.children=[];for(let o=s.length-1;o>=0;o--){const a=R(n,t),f=s[o]?.factory({...a,declarations:_(c),variables:_(e.variables),children:_(e.children)});f&&(c=f)}n.declarations=c;const i=R(n,t);F(n.declarations,i,n,t)}return n}function ge(e,t){return function(n,s){const c={type:"modifier",key:Array.isArray(n)?n:[n],factory:s};return t.modifiers.push(c),c}}function pe(){const e={type:"root",id:w("rt-"),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map,_usage:{variables:new Set,utilities:new Set}};return e._registry.set(e.id,e),e}function Ie(e,t){const r=B({namespace:e});return n=>{if(typeof n=="string"&&n[0]==="@"){const s=n.slice(1),c=e.find(i=>s===i||s.startsWith(`${i}.`));if(c){const i=s.slice(c.length+1)||s;if(t.variables.some(o=>o.name===s))return t._usage.variables.add(s),{[i]:{type:"reference",name:s}}}else{for(const i of e){const o=`${i}.${s}`;if(t.variables.some(a=>a.name===o))return t._usage.variables.add(o),{[s]:{type:"reference",name:o}}}if(t.variables.some(i=>i.name===s))return t._usage.variables.add(s),{[s]:{type:"reference",name:s}}}return r(n)}return r(n)}}function Ke(e){let t=[new Map];for(const r of e){if(!Z(r))continue;const n=[];for(const s of r.key)for(const c of t){const i=new Map(c);i.set(s,r),n.push(i)}t=n}return t.filter(r=>r.size>0)}function be(e,t){return function(n,s,c={}){const i=t.utilities.find(a=>a.name===n);if(i)return i.create;const o={type:"utility",name:n,factory:s,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?Ie(c.namespace,t):B(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(a,f=[])=>{let d=a;if(Array.isArray(a)){d={};for(const u of a){const y=o.autogenerate(u);for(const m of Object.values(y))te(t,m);d={...d,...y}}}for(const[u,y]of Object.entries(d)){let m=y;if(typeof y=="string"&&y[0]==="@"){const g=y.slice(1);!Array.isArray(d)&&g in d&&(m=d[g])}if(o.namespace&&p(y))if(t.variables.some(g=>g.name===y.name))m=y,t._usage.variables.add(y.name);else{const g=Array.isArray(o.namespace)?o.namespace:[o.namespace];let U=!1;for(const S of g){const V=`${S}.${u}`;if(V!==y.name&&t.variables.some(T=>T.name===V)){m={type:"reference",name:V},t._usage.variables.add(V),U=!0;break}}U||(t.variables.some(S=>S.name===u)?(m={type:"reference",name:u},t._usage.variables.add(u)):m=u)}const h=o.values.find(g=>g.key===u&&g.modifiers.length===0),v={type:"utility",id:w("ut-"),parentId:e.id,name:n,value:u,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(v.id,v);const Me=R(v,t);if(v.declarations=s({...Me,value:m})??{},F(v.declarations,Me,v,t),h||(o.values.push({key:u,value:m,modifiers:[]}),e.children.push(v)),f&&f.length>0)for(const g of f){const U=Array.isArray(g)?g:[g],S=Ke(U);for(const V of S){const T=[...V.keys()];o.values.find(X=>X.key===u&&X.modifiers.length===T.length&&X.modifiers.every((He,Le)=>He===T[Le]))||(o.values.push({key:u,value:m,modifiers:T}),e.children.push(he(v,t,V)))}}}}};return t.utilities.push(o),o.create}}function ve(e,t){return function(n,s){const c=t.themes.find(a=>a.name===n),i=c??{type:"theme",id:w("th-"),parentId:t.id,name:n,declarations:{},variables:[],children:[]};c||(t._registry.set(i.id,i),t.themes.push(i));const o=R(i,t);return s&&s(o),i}}function Ae(e,t){return function(n){const s={type:"recipe",...n};return s._runtime=Re(s,t),ke(s,t),t.recipes.push(s),s}}function we(e,t){const r=e.autogenerate(t);return Object.keys(r)[0]??"default"}function z(e,t){const r={};for(const[n,s]of Object.entries(e))if(Ve(s)){const c={};for(const[i,o]of Object.entries(s)){const a=q(t,i);if(!a)throw new Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);c[i]=we(a,o)}r[je(n)]=c}else if(typeof s=="boolean")r[n]=s;else{const c=q(t,n);if(!c)throw new Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);r[n]=we(c,s)}return r}function Re(e,t){const r={};if(e.base&&(r.base=z(e.base,t)),e.variants){const n={};for(const[s,c]of Object.entries(e.variants)){const i={};for(const[o,a]of Object.entries(c))a==null?i[o]=null:i[o]=z(a,t);n[s]=i}r.variants=n}return e.defaultVariants&&(r.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(r.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},...n.css?{css:z(n.css,t)}:{},...n.className?{className:n.className}:{}}))),r}function Ve(e){return!p(e)&&typeof e=="object"&&e!==null}function je(e){return e.startsWith("&::")?e.slice(3):e.startsWith("&:")?e.slice(2):e}function G(e,t){const r=(n,s,c)=>{let i=t.get(n);i||(i=[],t.set(n,i)),i.push({value:s,modifiers:c})};for(const[n,s]of Object.entries(e))if(Ve(s)){const c=je(n).split(":");for(const[i,o]of Object.entries(s))r(i,o,c)}else r(n,s,[])}function q(e,t){const r=e.utilities.find(s=>s.name===t);if(r)return r;const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return e.utilities.find(s=>s.name===n)}function ke(e,t){const r=new Map;if(e.base&&G(e.base,r),e.variants)for(const s of Object.values(e.variants))for(const c of Object.values(s))G(c,r);if(e.compoundVariants)for(const s of e.compoundVariants)s.css&&G(s.css,r);const n=new Map;for(const[s,c]of r){const i=q(t,s);if(!i)throw new Error(`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(const o of c){const a=[];for(const d of o.modifiers){if(!n.has(d))try{n.set(d,ce(t,d))}catch{throw new Error(`[styleframe] Modifier "${d}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}const u=n.get(d);u&&a.push(u)}const f=i.autogenerate(o.value);for(const d of Object.keys(f))t._usage.utilities.add(ee({name:i.name,value:d,modifiers:o.modifiers}));i.create([o.value],a.length>0?a.length>1?[a]:a:void 0)}}}function We(e){const t=w("sf-"),r=pe(),n={...e},s=be(r,r),c=ge(r,r),i=Ae(r,r),o=ve(r,r),{variable:a,selector:f,atRule:d,keyframes:u,media:y,ref:m,css:h}=R(r,r);return{id:t,root:r,variable:a,selector:f,utility:s,modifier:c,recipe:i,theme:o,atRule:d,keyframes:u,media:y,ref:m,css:h,options:n}}l.applyModifiers=he,l.capitalizeFirst=Oe,l.classNameToCssSelector=Ne,l.createAtRuleFunction=N,l.createCssFunction=ie,l.createDeclarationsCallbackContext=R,l.createKeyframesFunction=de,l.createMediaFunction=le,l.createModifierFunction=ge,l.createPropertyValueResolver=E,l.createRecipeFunction=Ae,l.createRefFunction=K,l.createRoot=pe,l.createSelectorFunction=ye,l.createThemeFunction=ve,l.createUtilityFunction=be,l.createVariableFunction=me,l.deepClone=_,l.defaultUtilitySelectorFn=ee,l.findVariableInScope=ne,l.generateRandomId=w,l.generateRecipeRuntime=Re,l.getModifier=ce,l.getUtility=Pe,l.getVariable=Ce,l.hashValue=x,l.isAtRule=Y,l.isCSS=k,l.isContainer=$e,l.isContainerInput=P,l.isKeyReferenceValue=Q,l.isModifier=Z,l.isObject=A,l.isPrimitiveTokenValue=J,l.isRecipe=Te,l.isRef=p,l.isRoot=M,l.isSelector=_e,l.isStyleframe=Ee,l.isTheme=Se,l.isToken=b,l.isTokenEqual=O,l.isTokenValue=$,l.isUtility=Fe,l.isVariable=C,l.merge=De,l.mergeContainers=H,l.mergeThemesArray=fe,l.mergeVariablesArray=oe,l.parseAtReferences=I,l.parseDeclarationsBlock=F,l.processRecipeUtilities=ke,l.rebuildRegistry=ue,l.rfdc=se,l.styleframe=We,l.trackReferenceUsage=te,l.transformUtilityKey=B,l.validateReference=re,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.styleframe={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`object`&&!!e}function n(e,n){return t(e)&&`type`in e&&e.type===n}function r(e){return n(e,`variable`)}function i(e){return n(e,`reference`)}function a(e){return n(e,`selector`)}function o(e){return n(e,`at-rule`)}function s(e){return n(e,`utility`)}function c(e){return n(e,`modifier`)}function l(e){return n(e,`css`)}function u(e){return n(e,`theme`)}function d(e){return n(e,`root`)}function f(e){return n(e,`recipe`)}function p(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e===null}function m(e){return p(e)||i(e)||l(e)||Array.isArray(e)&&e.every(m)}function ee(e){return t(e)&&`id`in e&&`children`in e&&`declarations`in e&&`variables`in e}function h(e){return t(e)&&`children`in e&&`declarations`in e&&`variables`in e}function g(e){return typeof e==`string`&&e.startsWith(`@`)}function te(e){return t(e)&&`id`in e&&`root`in e&&`variable`in e&&`selector`in e&&`recipe`in e&&typeof e.id==`string`&&d(e.root)}function _(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)&4294967295;return(t>>>0).toString(16).padStart(7,`0`).slice(0,7)}function v(e){let{replacer:t=e=>e,namespace:n}=typeof e==`function`?{replacer:e}:e??{},r=Array.isArray(n)?n:n?[n]:[];return e=>{let n=e,a;if(typeof n==`string`&&n[0]===`@`){let e=n.slice(1),i=r.find(t=>e===t||e.startsWith(`${t}.`)),o,s;i?(o=e,s=e.startsWith(`${i}.`)?e.slice(i.length+1):e):r.length>0?(o=`${r[0]}.${e}`,s=e):(o=e,s=e),a=t(s),n={type:`reference`,name:o}}else if(i(n)){let e=n.name;for(let t of r)if(e.startsWith(`${t}.`)){e=e.slice(t.length+1);break}a=t(e)}else{let t=String(e).trim();a=/\s/.test(t)?_(t):`[${t}]`}return{[a]:n}}}var y=({name:e,value:t,modifiers:n})=>`_${[...n,e,...t===`default`?[]:[t]].filter(Boolean).join(`:`)}`;function ne(e,t){if(i(t)){e._usage.variables.add(t.name);return}if(l(t))for(let n of t.value)i(n)&&e._usage.variables.add(n.name)}var b=/@([\w.-]+)/g;function x(e){let t=[],n=0,r;for(b.lastIndex=0;(r=b.exec(e))!==null;){let i=e.slice(n,r.index);i!==``&&t.push(i),t.push({type:`reference`,name:r[1]}),n=b.lastIndex}let i=e.slice(n);return i!==``&&t.push(i),t}function re(e,t,n){let r=t;for(;r;){if(r.variables.some(t=>t.name===e))return!0;if(r.parentId)r=n._registry.get(r.parentId);else break}return!1}function S(e,t,n){if(!re(e,t,n))throw Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function C(e,t){return function(n){if(typeof n!=`string`||!n.includes(`@`))return n;if(g(n)&&/^@[\w.-]+$/.test(n)){let r=n.slice(1);return S(r,e,t),t._usage.variables.add(r),{type:`reference`,name:r}}let r=x(n);if(r.some(e=>i(e))){for(let e of r)i(e)&&t._usage.variables.add(e.name);return{type:`css`,value:r}}return n}}function w(e,t){return function(n,i){let a=C(e,t),o=i==null?i:a(i);if(r(n))return t._usage.variables.add(n.name),{type:`reference`,name:n.name,fallback:o};if(n==null)throw Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return t._usage.variables.add(n),{type:`reference`,name:n,fallback:o}}}function T(e,t){let n=w(e,t),a=e=>{let n=x(e);for(let e of n)i(e)&&t._usage.variables.add(e.name);return n};return function(e,...t){return{type:`css`,value:e.reduce((e,i,s)=>{if(e.push(...a(i)),s<t.length){let i=t[s];r(i)?e.push(n(i)):o(i)?e.push(i.rule):typeof i==`string`&&i.includes(`@`)?e.push(...a(i)):e.push(i)}return e},[])}}}function ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return`.${e.replace(/[[\].#()%,:/]/g,`\\$&`)}`}function E(e){if(e instanceof Buffer)return Buffer.from(e);let t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function oe(e){if(e||={},e.circular)return se(e);let t=new Map;if(t.set(Date,e=>new Date(e)),t.set(Map,(e,t)=>new Map(r(Array.from(e),t))),t.set(Set,(e,t)=>new Set(r(Array.from(e),t))),e.constructorHandlers)for(let n of e.constructorHandlers)t.set(n[0],n[1]);let n;return e.proto?a:i;function r(e,r){let i=Object.keys(e),a=Array.from({length:i.length});for(let o=0;o<i.length;o++){let s=i[o],c=e[s];typeof c!=`object`||!c?a[s]=c:c.constructor!==Object&&(n=t.get(c.constructor))?a[s]=n(c,r):ArrayBuffer.isView(c)?a[s]=E(c):a[s]=r(c)}return a}function i(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return r(e,i);if(e.constructor!==Object&&(n=t.get(e.constructor)))return n(e,i);let a={};for(let r in e){if(Object.hasOwnProperty.call(e,r)===!1)continue;let o=e[r];typeof o!=`object`||!o?a[r]=o:o.constructor!==Object&&(n=t.get(o.constructor))?a[r]=n(o,i):ArrayBuffer.isView(o)?a[r]=E(o):a[r]=i(o)}return a}function a(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return r(e,a);if(e.constructor!==Object&&(n=t.get(e.constructor)))return n(e,a);let i={};for(let r in e){let o=e[r];typeof o!=`object`||!o?i[r]=o:o.constructor!==Object&&(n=t.get(o.constructor))?i[r]=n(o,a):ArrayBuffer.isView(o)?i[r]=E(o):i[r]=a(o)}return i}}function se(e){let t=[],n=[],r=new Map;if(r.set(Date,e=>new Date(e)),r.set(Map,(e,t)=>new Map(a(Array.from(e),t))),r.set(Set,(e,t)=>new Set(a(Array.from(e),t))),e.constructorHandlers)for(let t of e.constructorHandlers)r.set(t[0],t[1]);let i;return e.proto?s:o;function a(e,a){let o=Object.keys(e),s=Array.from({length:o.length});for(let c=0;c<o.length;c++){let l=o[c],u=e[l];if(typeof u!=`object`||!u)s[l]=u;else if(u.constructor!==Object&&(i=r.get(u.constructor)))s[l]=i(u,a);else if(ArrayBuffer.isView(u))s[l]=E(u);else{let e=t.indexOf(u);e===-1?s[l]=a(u):s[l]=n[e]}}return s}function o(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return a(e,o);if(e.constructor!==Object&&(i=r.get(e.constructor)))return i(e,o);let s={};t.push(e),n.push(s);for(let a in e){if(Object.hasOwnProperty.call(e,a)===!1)continue;let c=e[a];if(typeof c!=`object`||!c)s[a]=c;else if(c.constructor!==Object&&(i=r.get(c.constructor)))s[a]=i(c,o);else if(ArrayBuffer.isView(c))s[a]=E(c);else{let e=t.indexOf(c);e===-1?s[a]=o(c):s[a]=n[e]}}return t.pop(),n.pop(),s}function s(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return a(e,s);if(e.constructor!==Object&&(i=r.get(e.constructor)))return i(e,s);let o={};t.push(e),n.push(o);for(let a in e){let c=e[a];if(typeof c!=`object`||!c)o[a]=c;else if(c.constructor!==Object&&(i=r.get(c.constructor)))o[a]=i(c,s);else if(ArrayBuffer.isView(c))o[a]=E(c);else{let e=t.indexOf(c);e===-1?o[a]=s(c):o[a]=n[e]}}return t.pop(),n.pop(),o}}var D=oe();function O(e,t=8){let n=``;for(let e=0;e<t;e++){let e=Math.floor(Math.random()*62);n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[e]}return e?`${e}${n}`:n}function ce(e,t){let n=e.variables.find(e=>e.name===t);if(!n)throw Error(`Variable "${t}" not found`);return n}function le(e,t){let n=e.utilities.find(e=>e.name===t);if(!n)throw Error(`Utility "${t}" not found`);return n}function k(e,t){let n=e.modifiers.find(e=>e.key.includes(t));if(!n)throw Error(`Modifier "${t}" not found`);return n}function A(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!=`object`||typeof t!=`object`)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length?e.every((e,n)=>A(e,t[n])):!1;if(`type`in e&&`type`in t){if(e.type!==t.type)return!1;if(i(e)&&i(t))return e.name===t.name&&A(e.fallback,t.fallback);if(l(e)&&l(t))return A(e.value,t.value)}return!1}var ue=`__licenseRequired`;function de(e){j(e)||Object.defineProperty(e,"__licenseRequired",{value:!0,writable:!1,configurable:!1,enumerable:!0})}function j(e){return Object.prototype.hasOwnProperty.call(e,ue)}function M(e,t){let n=[...e];for(let e of t){let t=n.find(t=>t.name===e.name);t?t.value=e.value:n.push(e)}return n}function N(e,t){let n=[...e];for(let e of t){let t=n.find(t=>t.name===e.name);t?Object.assign(t,P(t,e)):n.push(e)}return n}function P(e,t){return Object.keys(e).reduce((n,r)=>(r===`variables`?n.variables=M(e.variables,t.variables):r===`declarations`?n.declarations={...e.declarations,...t.declarations}:r===`themes`&&d(n)&&d(e)&&d(t)?n.themes=N(e.themes,t.themes):Array.isArray(e[r])&&(n[r]=e[r].concat(t[r])),n),{...e,...t})}function F(e,t){for(let n of e)`id`in n&&typeof n.id==`string`&&(t._registry.set(n.id,n),`children`in n&&F(n.children,t))}function I(e){e._registry=new Map,e._registry.set(e.id,e),F(e.children,e);for(let t of e.themes)e._registry.set(t.id,t),F(t.children,e)}function fe(e,...t){return t.reduce((e,t)=>{let n={...e,root:P(e.root,t.root)};return I(n.root),(j(e)||j(t))&&de(n),n},e)}function L(e,t){return function(n,r,i){let a={type:`at-rule`,id:O(`ar-`),parentId:e.id,identifier:n,rule:r,declarations:{},variables:[],children:[]};t._registry.set(a.id,a);let o=H(a,t);return typeof i==`function`?a.declarations=i(o)??{}:h(i)?(a.variables=i.variables,a.declarations=i.declarations,a.children=i.children):i&&(a.declarations=i),U(a.declarations,o,a,t),e.children.push(a),a}}function R(e,t){let n=L(e,t);return function(e,t){return n(`media`,e,t)}}function z(e,t){let n=L(e,t);return function(e,t){return n(`keyframes`,e,t)}}function B(e,t){return function(n,r){let i={type:`selector`,id:O(`sel-`),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);let a=H(i,t);return typeof r==`function`?i.declarations=r(a)??{}:h(r)?(i.variables=r.variables,i.declarations=r.declarations,i.children=r.children):i.declarations=r,U(i.declarations,a,i,t),e.children.push(i),i}}function V(e,t){return function(n,r,i={default:!1}){let a=typeof n==`string`?n:n.name,o=C(e,t)(r),s=e.variables.find(e=>e.name===a);if(i.default&&s)return s;if(s)return s.value=o,s;let c={type:`variable`,id:O(`var-`),parentId:e.id,name:a,value:o};return e.variables.push(c),c}}function H(e,t){let n=V(e,t),r=B(e,t),i=L(e,t);return{variable:n,selector:r,keyframes:z(t,t),atRule:i,media:R(e,t),ref:w(t,t),css:T(t,t)}}function U(e,t,n,r){for(let n in e)if(n.startsWith(`@`)){let r=e[n];if(typeof r==`object`&&r&&!m(r)){let i=n.replace(/^@(\w+).*/,`$1`),a=n.replace(`@${i}`,``).trim();t.atRule(i,a,r),delete e[n]}}else if(/^[.&:]/.test(n)||/^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(n)){let r=e[n];typeof r==`object`&&(t.selector(n,r),delete e[n])}let i=C(n,r);for(let t in e){let n=e[t];if(m(n)){let r=i(n);r!==n&&(e[t]=r)}}return e}function W(e,t,n){let r={...e,id:O(`ut-`),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...n.keys()]};if(t._registry.set(r.id,r),n.size>0){let i=[...n.values()],a=D(e.declarations);r.declarations={},r.variables=[],r.children=[];for(let n=i.length-1;n>=0;n--){let o=H(r,t),s=i[n]?.factory({...o,declarations:D(a),variables:D(e.variables),children:D(e.children)});s&&(a=s)}r.declarations=a;let o=H(r,t);U(r.declarations,o,r,t)}return r}function G(e,t){return function(e,n){let r={type:`modifier`,key:Array.isArray(e)?e:[e],factory:n};return t.modifiers.push(r),r}}function K(){let e={type:`root`,id:O(`rt-`),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map,_usage:{variables:new Set,utilities:new Set,recipes:new Set,recipeUtilities:new Map}};return e._registry.set(e.id,e),e}function pe(e,t){let n=v({namespace:e});return r=>{if(typeof r==`string`&&r[0]===`@`){let i=r.slice(1),a=e.find(e=>i===e||i.startsWith(`${e}.`));if(a){let e=i.slice(a.length+1)||i;if(t.variables.some(e=>e.name===i))return t._usage.variables.add(i),{[e]:{type:`reference`,name:i}}}else{for(let n of e){let e=`${n}.${i}`;if(t.variables.some(t=>t.name===e))return t._usage.variables.add(e),{[i]:{type:`reference`,name:e}}}if(t.variables.some(e=>e.name===i))return t._usage.variables.add(i),{[i]:{type:`reference`,name:i}}}return n(r)}return n(r)}}function me(e){let t=[new Map];for(let n of e){if(!c(n))continue;let e=[];for(let r of n.key)for(let i of t){let t=new Map(i);t.set(r,n),e.push(t)}t=e}return t.filter(e=>e.size>0)}function q(e,t){return function(n,r,a={}){let o=t.utilities.find(e=>e.name===n);if(o)return o.create;let s={type:`utility`,name:n,factory:r,values:[],autogenerate:a.autogenerate??(Array.isArray(a.namespace)?pe(a.namespace,t):v(a.namespace?{namespace:a.namespace}:void 0)),namespace:a.namespace,create:(a,o=[])=>{let c=a;if(Array.isArray(a)){c={};for(let e of a){let n=s.autogenerate(e);for(let e of Object.values(n))ne(t,e);c={...c,...n}}}for(let[a,l]of Object.entries(c)){let u=l;if(typeof l==`string`&&l[0]===`@`){let e=l.slice(1);!Array.isArray(c)&&e in c&&(u=c[e])}if(s.namespace&&i(l))if(t.variables.some(e=>e.name===l.name))u=l,t._usage.variables.add(l.name);else{let e=Array.isArray(s.namespace)?s.namespace:[s.namespace],n=!1;for(let r of e){let e=`${r}.${a}`;if(e!==l.name&&t.variables.some(t=>t.name===e)){u={type:`reference`,name:e},t._usage.variables.add(e),n=!0;break}}n||(t.variables.some(e=>e.name===a)?(u={type:`reference`,name:a},t._usage.variables.add(a)):u=a)}let d=s.values.find(e=>e.key===a&&e.modifiers.length===0),f={type:`utility`,id:O(`ut-`),parentId:e.id,name:n,value:a,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(f.id,f);let p=H(f,t);if(f.declarations=r({...p,value:u})??{},U(f.declarations,p,f,t),d||(s.values.push({key:a,value:u,modifiers:[]}),e.children.push(f)),o&&o.length>0)for(let n of o){let r=me(Array.isArray(n)?n:[n]);for(let n of r){let r=[...n.keys()];s.values.find(e=>e.key===a&&e.modifiers.length===r.length&&e.modifiers.every((e,t)=>e===r[t]))||(s.values.push({key:a,value:u,modifiers:r}),e.children.push(W(f,t,n)))}}}}};return t.utilities.push(s),s.create}}function J(e,t){return function(e,n){let r=t.themes.find(t=>t.name===e),i=r??{type:`theme`,id:O(`th-`),parentId:t.id,name:e,declarations:{},variables:[],children:[]};r||(t._registry.set(i.id,i),t.themes.push(i));let a=H(i,t);return n&&n(a),i}}function Y(e,t){return function(e){let n={type:`recipe`,...e};return n._runtime=he(n,t),ve(n,t),t.recipes.push(n),n}}function X(e,t){let n=e.autogenerate(t);return Object.keys(n)[0]??`default`}function Z(e,t){let n={};for(let[r,i]of Object.entries(e))if(ge(i)){let e={};for(let[n,r]of Object.entries(i)){let i=$(t,n);if(!i)throw Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);e[n]=X(i,r)}n[_e(r)]=e}else if(typeof i==`boolean`)n[r]=i;else{let e=$(t,r);if(!e)throw Error(`[styleframe] Utility "${r}" not found in registry. Make sure the utility is registered before using it in a recipe.`);n[r]=X(e,i)}return n}function he(e,t){let n={};if(e.base&&(n.base=Z(e.base,t)),e.variants){let r={};for(let[n,i]of Object.entries(e.variants)){let e={};for(let[n,r]of Object.entries(i))r==null?e[n]=null:e[n]=Z(r,t);r[n]=e}n.variants=r}return e.defaultVariants&&(n.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(n.compoundVariants=e.compoundVariants.map(e=>({match:{...e.match},...e.css?{css:Z(e.css,t)}:{},...e.className?{className:e.className}:{}}))),n}function ge(e){return!i(e)&&typeof e==`object`&&!!e}function _e(e){return e.startsWith(`&::`)?e.slice(3):e.startsWith(`&:`)?e.slice(2):e}function Q(e,t){let n=(e,n,r)=>{let i=t.get(e);i||(i=[],t.set(e,i)),i.push({value:n,modifiers:r})};for(let[t,r]of Object.entries(e))if(ge(r)){let e=_e(t).split(`:`);for(let[t,i]of Object.entries(r))n(t,i,e)}else n(t,r,[])}function $(e,t){let n=e.utilities.find(e=>e.name===t);if(n)return n;let r=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);return e.utilities.find(e=>e.name===r)}function ve(e,t){let n=new Map;if(e.base&&Q(e.base,n),e.variants)for(let t of Object.values(e.variants))for(let e of Object.values(t))Q(e,n);if(e.compoundVariants)for(let t of e.compoundVariants)t.css&&Q(t.css,n);let r=new Map;for(let[i,a]of n){let n=$(t,i);if(!n)throw Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(let i of a){let a=[];for(let e of i.modifiers){if(!r.has(e))try{r.set(e,k(t,e))}catch{throw Error(`[styleframe] Modifier "${e}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}let n=r.get(e);n&&a.push(n)}let o=n.autogenerate(i.value);for(let r of Object.keys(o)){let a=y({name:n.name,value:r,modifiers:i.modifiers}),o=t._usage.recipeUtilities.get(e.name);o||(o=new Set,t._usage.recipeUtilities.set(e.name,o)),o.add(a)}n.create([i.value],a.length>0?a.length>1?[a]:a:void 0)}}}function ye(e,t){for(let[n,r]of e._usage.recipeUtilities)if(!t||t.has(n))for(let t of r)e._usage.utilities.add(t)}function be(e){let t=O(`sf-`),n=K(),r={...e},i=q(n,n),a=G(n,n),o=Y(n,n),s=J(n,n),{variable:c,selector:l,atRule:u,keyframes:d,media:f,ref:p,css:m}=H(n,n);return{id:t,root:n,variable:c,selector:l,utility:i,modifier:a,recipe:o,theme:s,atRule:u,keyframes:d,media:f,ref:p,css:m,options:r}}e.applyModifiers=W,e.capitalizeFirst=ie,e.classNameToCssSelector=ae,e.createAtRuleFunction=L,e.createCssFunction=T,e.createDeclarationsCallbackContext=H,e.createKeyframesFunction=z,e.createMediaFunction=R,e.createModifierFunction=G,e.createPropertyValueResolver=C,e.createRecipeFunction=Y,e.createRefFunction=w,e.createRoot=K,e.createSelectorFunction=B,e.createThemeFunction=J,e.createUtilityFunction=q,e.createVariableFunction=V,e.deepClone=D,e.defaultUtilitySelectorFn=y,e.findVariableInScope=re,e.generateRandomId=O,e.generateRecipeRuntime=he,e.getModifier=k,e.getUtility=le,e.getVariable=ce,e.hashValue=_,e.isAtRule=o,e.isCSS=l,e.isContainer=ee,e.isContainerInput=h,e.isKeyReferenceValue=g,e.isModifier=c,e.isObject=t,e.isPrimitiveTokenValue=p,e.isRecipe=f,e.isRef=i,e.isRoot=d,e.isSelector=a,e.isStyleframe=te,e.isTheme=u,e.isToken=n,e.isTokenEqual=A,e.isTokenValue=m,e.isUtility=s,e.isVariable=r,e.merge=fe,e.mergeContainers=P,e.mergeThemesArray=N,e.mergeVariablesArray=M,e.parseAtReferences=x,e.parseDeclarationsBlock=U,e.processRecipeUtilities=ve,e.rebuildRegistry=I,e.registerRecipeUtilities=ye,e.rfdc=oe,e.styleframe=be,e.trackReferenceUsage=ne,e.transformUtilityKey=v,e.validateReference=S});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AtRule, Container, ContainerInput, DeclarationsBlock, DeclarationsCallback, Root } from '../types';
|
|
2
|
+
export declare function createAtRuleFunction(parent: Container, root: Root): (identifier: string, rule: string, declarationsOrCallback?: DeclarationsBlock | ContainerInput | DeclarationsCallback) => AtRule;
|
|
3
|
+
export declare function createMediaFunction(parent: Container, root: Root): (query: string, declarationsOrCallback?: DeclarationsBlock | ContainerInput | DeclarationsCallback) => AtRule;
|
|
4
|
+
export declare function createKeyframesFunction(parent: Container, root: Root): (name: string, declarations: Record<string, DeclarationsBlock>) => AtRule;
|
|
5
|
+
//# sourceMappingURL=atRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atRule.d.ts","sourceRoot":"","sources":["../../src/tokens/atRule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,MAAM,EACN,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,IAAI,EACJ,MAAM,UAAU,CAAC;AAOlB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAEhE,YAAY,MAAM,EAClB,MAAM,MAAM,EACZ,yBACG,iBAAiB,GACjB,cAAc,GACd,oBAAoB,KACrB,MAAM,CAwCT;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAI/D,OAAO,MAAM,EACb,yBACG,iBAAiB,GACjB,cAAc,GACd,oBAAoB,KACrB,MAAM,CAGT;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAInE,MAAM,MAAM,EACZ,cAAc,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,KAC7C,MAAM,CAGT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atRule.test.d.ts","sourceRoot":"","sources":["../../src/tokens/atRule.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AtRule, Container, CSS, Root, TokenValue, Variable } from '../types';
|
|
2
|
+
export declare function createCssFunction(_parent: Container, root: Root): (strings: TemplateStringsArray, ...interpolations: (TokenValue | Variable | AtRule)[]) => CSS;
|
|
3
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/tokens/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,SAAS,EACT,GAAG,EACH,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,MAAM,UAAU,CAAC;AAKlB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAc9D,SAAS,oBAAoB,EAC7B,GAAG,gBAAgB,CAAC,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC,EAAE,KACnD,GAAG,CA6BN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.test.d.ts","sourceRoot":"","sources":["../../src/tokens/css.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Container, DeclarationsBlock, DeclarationsCallbackContext, Root } from '../types';
|
|
2
|
+
export declare function createDeclarationsCallbackContext(parent: Container, root: Root): DeclarationsCallbackContext;
|
|
3
|
+
export declare function parseDeclarationsBlock(declarations: DeclarationsBlock, context: DeclarationsCallbackContext, parent: Container, root: Root): DeclarationsBlock;
|
|
4
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../src/tokens/declarations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,SAAS,EACT,iBAAiB,EACjB,2BAA2B,EAC3B,IAAI,EACJ,MAAM,UAAU,CAAC;AAYlB,wBAAgB,iCAAiC,CAChD,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,IAAI,GACR,2BAA2B,CAkB7B;AAED,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,iBAAiB,EAC/B,OAAO,EAAE,2BAA2B,EACpC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,IAAI,qBA0CV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.test.d.ts","sourceRoot":"","sources":["../../src/tokens/declarations.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './css';
|
|
2
|
+
export * from './declarations';
|
|
3
|
+
export * from './atRule';
|
|
4
|
+
export * from './modifier';
|
|
5
|
+
export * from './ref';
|
|
6
|
+
export * from './root';
|
|
7
|
+
export * from './selector';
|
|
8
|
+
export * from './utility';
|
|
9
|
+
export * from './variable';
|
|
10
|
+
export * from './theme';
|
|
11
|
+
export * from './recipe';
|
|
12
|
+
export * from './resolve';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Container, ModifierFactory, Root } from '../types';
|
|
2
|
+
export declare function applyModifiers<InstanceType extends Container>(baseInstance: InstanceType, root: Root, modifiers: Map<string, ModifierFactory>): InstanceType;
|
|
3
|
+
export declare function createModifierFunction(_parent: Container, root: Root): <Key extends string>(key: Key | Key[], factory: ModifierFactory["factory"]) => ModifierFactory;
|
|
4
|
+
//# sourceMappingURL=modifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifier.d.ts","sourceRoot":"","sources":["../../src/tokens/modifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAOjE,wBAAgB,cAAc,CAAC,YAAY,SAAS,SAAS,EAC5D,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACrC,YAAY,CAiDd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC3C,GAAG,SAAS,MAAM,EAC1C,KAAK,GAAG,GAAG,GAAG,EAAE,EAChB,SAAS,eAAe,CAAC,SAAS,CAAC,KACjC,eAAe,CAWlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifier.test.d.ts","sourceRoot":"","sources":["../../src/tokens/modifier.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Container, Recipe, RecipeRuntime, Root, VariantsBase } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a recipe function to define design system recipes with variants.
|
|
4
|
+
*
|
|
5
|
+
* @example ```ts
|
|
6
|
+
* recipe({
|
|
7
|
+
* name: "button",
|
|
8
|
+
* base: {
|
|
9
|
+
* borderWidth: ref(borderWidth), // Token reference => Variable<'border-width'> => Auto-generate _border-width
|
|
10
|
+
* borderStyle: ref(borderStyle), // Token reference => Variable<'border-style'> => Auto-generate _border-style
|
|
11
|
+
* boxShadow: ref(boxShadowMd), // Token reference => Variable<'box-shadow.md'> => Auto-generate _box-shadow:md
|
|
12
|
+
* 'hover:focus': { // Applying hover and focus modifiers
|
|
13
|
+
* boxShadow: ref(boxShadowSm), // Token reference => Variable<'box-shadow.sm'> => Auto-generate _hover:box-shadow:sm
|
|
14
|
+
* }
|
|
15
|
+
* },
|
|
16
|
+
* variants: {
|
|
17
|
+
* color: {
|
|
18
|
+
* primary: {
|
|
19
|
+
* background: ref(colorPrimary), // Token reference => Variable<'color.primary'> => Auto-generate _background:primary
|
|
20
|
+
* color: ref(colorWhite), // Token reference => Variable<'color.white'> => Auto-generate _color:white
|
|
21
|
+
* borderColor: ref(colorPrimaryShade50), // Token reference => Variable<'color.primary-shade-50'> => Auto-generate _border-color:primary-shade-50,
|
|
22
|
+
* },
|
|
23
|
+
* secondary: {
|
|
24
|
+
* background: "@color.secondary", // Token path => Variable<'color.secondary'> => Auto-generate _background:secondary
|
|
25
|
+
* color: "@color.white", // Token path => Variable<'color.white'> => Auto-generate _color:white
|
|
26
|
+
* borderColor: "@color.secondary-shade-50", // Token path => Variable<'color.secondary-shade-50'> => Auto-generate _border-color:secondary
|
|
27
|
+
* },
|
|
28
|
+
* disabled: {
|
|
29
|
+
* false: {},
|
|
30
|
+
* true: {
|
|
31
|
+
* opacity: "@opacity.50", // Token path => Variable<'opacity.50'> => Auto-generate _opacity:50
|
|
32
|
+
* cursor: "not-allowed", // Arbitrary value => Auto-generate _cursor:[not-allowed]
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* },
|
|
36
|
+
* size: {
|
|
37
|
+
* sm: {
|
|
38
|
+
* padding: "@spacing.sm", // Token path => Variable<'spacing.sm'> => Auto-generate _padding:sm
|
|
39
|
+
* fontSize: "@font-size.sm", // Token path => Variable<'font-size.sm'> => Auto-generate _font-size:sm
|
|
40
|
+
* },
|
|
41
|
+
* md: {
|
|
42
|
+
* padding: "1rem", // Arbitrary value => Auto-generate _padding:[1rem]
|
|
43
|
+
* fontSize: "1rem", // Arbitrary value => Auto-generate _font-size:[1rem]
|
|
44
|
+
* },
|
|
45
|
+
* lg: {
|
|
46
|
+
* padding: "@spacing.lg", // Token path => Variable<'spacing.lg'> => Auto-generate _padding:lg
|
|
47
|
+
* fontSize: "1.25rem", // Arbitrary value => Auto-generate _font-size:[1.25rem]
|
|
48
|
+
* },
|
|
49
|
+
* },
|
|
50
|
+
* },
|
|
51
|
+
* defaultVariants: {
|
|
52
|
+
* color: "primary",
|
|
53
|
+
* size: "md",
|
|
54
|
+
* },
|
|
55
|
+
* compoundVariants: [
|
|
56
|
+
* {
|
|
57
|
+
* match: {
|
|
58
|
+
* color: "primary",
|
|
59
|
+
* disabled: false
|
|
60
|
+
* },
|
|
61
|
+
* css: {
|
|
62
|
+
* hover: {
|
|
63
|
+
* background: "@color.primary-shade-50", // Token path => Variable<'color.primary-shade-50'> => Auto-generate _hover:background:primary-shade-50
|
|
64
|
+
* }
|
|
65
|
+
* },
|
|
66
|
+
* },
|
|
67
|
+
* {
|
|
68
|
+
* match: {
|
|
69
|
+
* color: "secondary",
|
|
70
|
+
* disabled: false
|
|
71
|
+
* },
|
|
72
|
+
* css: {
|
|
73
|
+
* hover: {
|
|
74
|
+
* background: ref(colorSecondaryShade50), // Token reference => Variable<'color.secondary-shade-50'> => Auto-generate _hover:background:secondary-shade-50
|
|
75
|
+
* }
|
|
76
|
+
* },
|
|
77
|
+
* },
|
|
78
|
+
* ],
|
|
79
|
+
* _runtime: {
|
|
80
|
+
* base: {
|
|
81
|
+
* borderWidth: 'default',
|
|
82
|
+
* borderStyle: 'default',
|
|
83
|
+
* boxShadow: 'md',
|
|
84
|
+
* 'hover:focus': {
|
|
85
|
+
* boxShadow: 'sm',
|
|
86
|
+
* }
|
|
87
|
+
* },
|
|
88
|
+
* variants: {
|
|
89
|
+
* color: {
|
|
90
|
+
* primary: {
|
|
91
|
+
* background: "primary",
|
|
92
|
+
* color: "white",
|
|
93
|
+
* borderColor: "primary-shade-50",
|
|
94
|
+
* },
|
|
95
|
+
* secondary: {
|
|
96
|
+
* background: "secondary",
|
|
97
|
+
* color: "white",
|
|
98
|
+
* borderColor: "secondary-shade-50",
|
|
99
|
+
* }
|
|
100
|
+
* },
|
|
101
|
+
* disabled: {
|
|
102
|
+
* false: {},
|
|
103
|
+
* true: {
|
|
104
|
+
* opacity: "50",
|
|
105
|
+
* cursor: "[not-allowed]",
|
|
106
|
+
* }
|
|
107
|
+
* },
|
|
108
|
+
* size: {
|
|
109
|
+
* sm: {
|
|
110
|
+
* padding: "sm",
|
|
111
|
+
* fontSize: "sm",
|
|
112
|
+
* },
|
|
113
|
+
* md: {
|
|
114
|
+
* padding: "[1rem]",
|
|
115
|
+
* fontSize: "[1rem]",
|
|
116
|
+
* },
|
|
117
|
+
* lg: {
|
|
118
|
+
* padding: "lg",
|
|
119
|
+
* fontSize: "[1.25rem]",
|
|
120
|
+
* },
|
|
121
|
+
* },
|
|
122
|
+
* },
|
|
123
|
+
* defaultVariants: {
|
|
124
|
+
* color: "primary",
|
|
125
|
+
* size: "md",
|
|
126
|
+
* },
|
|
127
|
+
* compoundVariants: [
|
|
128
|
+
* {
|
|
129
|
+
* match: {
|
|
130
|
+
* color: "primary",
|
|
131
|
+
* disabled: false
|
|
132
|
+
* },
|
|
133
|
+
* css: {
|
|
134
|
+
* hover: {
|
|
135
|
+
* background: "primary-shade-50",
|
|
136
|
+
* }
|
|
137
|
+
* },
|
|
138
|
+
* },
|
|
139
|
+
* {
|
|
140
|
+
* match: {
|
|
141
|
+
* color: "secondary",
|
|
142
|
+
* disabled: false
|
|
143
|
+
* },
|
|
144
|
+
* css: {
|
|
145
|
+
* hover: {
|
|
146
|
+
* background: 'secondary-shade-50',
|
|
147
|
+
* }
|
|
148
|
+
* },
|
|
149
|
+
* },
|
|
150
|
+
* ],
|
|
151
|
+
* }
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function createRecipeFunction(_parent: Container, root: Root): <Name extends string, Variants extends VariantsBase>(options: Omit<Recipe<Name, Variants>, "type">) => Recipe<Name, Variants>;
|
|
156
|
+
/**
|
|
157
|
+
* Generates the runtime object for a recipe.
|
|
158
|
+
* This object contains resolved runtime keys for efficient class name lookups.
|
|
159
|
+
*
|
|
160
|
+
* @param recipe - The recipe to generate runtime for
|
|
161
|
+
* @param root - The root object containing utility factories
|
|
162
|
+
* @returns The runtime object
|
|
163
|
+
*/
|
|
164
|
+
export declare function generateRecipeRuntime<Name extends string, Variants extends VariantsBase>(recipe: Recipe<Name, Variants>, root: Root): RecipeRuntime<Variants>;
|
|
165
|
+
/**
|
|
166
|
+
* Processes a recipe and creates utilities for all style declarations.
|
|
167
|
+
*
|
|
168
|
+
* This function iterates through all style fields in a recipe:
|
|
169
|
+
* 1. `base` - Root level field key-value pairs
|
|
170
|
+
* 2. `variants.*.*` - Each variant group's options containing field key-value pairs
|
|
171
|
+
* 3. `compoundVariants.*.css` - Each compound variant's css declarations
|
|
172
|
+
*
|
|
173
|
+
* For efficiency, it:
|
|
174
|
+
* - Collects all values needed for each utility key across the entire recipe
|
|
175
|
+
* - Retrieves each utility factory only once
|
|
176
|
+
* - Creates all utility instances in a single call per utility
|
|
177
|
+
*
|
|
178
|
+
* @param recipe - The recipe to process
|
|
179
|
+
* @param root - The root object containing utility factories
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const buttonRecipe = recipe({
|
|
184
|
+
* name: "button",
|
|
185
|
+
* base: { borderWidth: "thin" },
|
|
186
|
+
* variants: {
|
|
187
|
+
* size: {
|
|
188
|
+
* sm: { padding: "0.5rem" },
|
|
189
|
+
* lg: { padding: "1rem" },
|
|
190
|
+
* },
|
|
191
|
+
* },
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* processRecipeUtilities(buttonRecipe, root);
|
|
195
|
+
* // Creates:
|
|
196
|
+
* // - borderWidth utility with value "thin"
|
|
197
|
+
* // - padding utility with values ["0.5rem", "1rem"]
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export declare function processRecipeUtilities(recipe: Recipe, root: Root): void;
|
|
201
|
+
/**
|
|
202
|
+
* Promotes recipe utility class names from `_usage.recipeUtilities` into `_usage.utilities`.
|
|
203
|
+
*
|
|
204
|
+
* When called without `recipeNames`, promotes all recipes (backward-compatible default).
|
|
205
|
+
* When called with a set of recipe names, only promotes matching entries.
|
|
206
|
+
*/
|
|
207
|
+
export declare function registerRecipeUtilities(root: Root, recipeNames?: Set<string>): void;
|
|
208
|
+
//# sourceMappingURL=recipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../src/tokens/recipe.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,SAAS,EAGT,MAAM,EACN,aAAa,EAGb,IAAI,EAIJ,YAAY,EACZ,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwJG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC3C,IAAI,SAAS,MAAM,EAAE,QAAQ,SAAS,YAAY,EACxE,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,KAC3C,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAczB;AAkED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,SAAS,MAAM,EACnB,QAAQ,SAAS,YAAY,EAC5B,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,aAAa,CAAC,QAAQ,CAAC,CAkDrE;AA0FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CA4FvE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,IAAI,EACV,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACvB,IAAI,CAQN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipe.test.d.ts","sourceRoot":"","sources":["../../src/tokens/recipe.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../src/tokens/ref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,SAAS,EACT,SAAS,EACT,IAAI,EAEJ,QAAQ,EACR,MAAM,UAAU,CAAC;AAGlB,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC1C,IAAI,SAAS,MAAM,EACtC,UAAU,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,EAC/B,WAAW,MAAM,KACf,SAAS,CAAC,IAAI,CAAC,CA6BlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.test.d.ts","sourceRoot":"","sources":["../../src/tokens/ref.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Container, Reference, Root, TokenValue } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Records a variable name in `root._usage.variables` for any Reference
|
|
4
|
+
* embedded in the given value (either the value itself or any Reference
|
|
5
|
+
* parts inside a CSS object).
|
|
6
|
+
*/
|
|
7
|
+
export declare function trackReferenceUsage(root: Root, value: TokenValue): void;
|
|
8
|
+
export type RefFunction = (variable: string, fallback?: string) => Reference;
|
|
9
|
+
export declare function parseAtReferences(str: string): TokenValue[];
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether a variable with the given name exists in the scope chain,
|
|
12
|
+
* walking from the given scope up through ancestors via parentId.
|
|
13
|
+
*/
|
|
14
|
+
export declare function findVariableInScope(name: string, scope: Container, root: Root): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Validates that a variable name exists in the scope chain.
|
|
17
|
+
* Walks from the given scope up through ancestors to root.
|
|
18
|
+
* Throws if the variable is not defined.
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateReference(name: string, scope: Container, root: Root): void;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a resolver that converts @-prefixed variable references in string values.
|
|
23
|
+
* - Exact match "@name" → Reference object
|
|
24
|
+
* - Embedded "1px solid @name" → CSS object with mixed parts
|
|
25
|
+
* - Non-string or no @ → returns value unchanged
|
|
26
|
+
*/
|
|
27
|
+
export declare function createPropertyValueResolver(parent: Container, root: Root): (value: TokenValue) => TokenValue;
|
|
28
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/tokens/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAO,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAavE;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,SAAS,CAAC;AAI7E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,CAgB3D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,IAAI,GACR,OAAO,CAeT;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,IAAI,GACR,IAAI,CAMN;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IACnC,OAAO,UAAU,KAAG,UAAU,CA2BnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.test.d.ts","sourceRoot":"","sources":["../../src/tokens/resolve.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/tokens/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrC,wBAAgB,UAAU,IAAI,IAAI,CAuBjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.test.d.ts","sourceRoot":"","sources":["../../src/tokens/root.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.usage.test.d.ts","sourceRoot":"","sources":["../../src/tokens/root.usage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Container, ContainerInput, DeclarationsBlock, DeclarationsCallback, Root, Selector } from '../types';
|
|
2
|
+
export declare function createSelectorFunction(parent: Container, root: Root): (query: string, declarationsOrCallback: DeclarationsBlock | ContainerInput | DeclarationsCallback) => Selector;
|
|
3
|
+
//# sourceMappingURL=selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/tokens/selector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,IAAI,EACJ,QAAQ,EACR,MAAM,UAAU,CAAC;AAOlB,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAElE,OAAO,MAAM,EACb,wBACG,iBAAiB,GACjB,cAAc,GACd,oBAAoB,KACrB,QAAQ,CAmCX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.test.d.ts","sourceRoot":"","sources":["../../src/tokens/selector.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/tokens/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAI7E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC1C,MAAM,MAAM,EAAE,UAAU,oBAAoB,KAAG,KAAK,CAwB1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.test.d.ts","sourceRoot":"","sources":["../../src/tokens/theme.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Container, Root, UtilityAutogenerateFn, UtilityCallbackFn, UtilityCreatorFn } from '../types';
|
|
2
|
+
export declare function createUtilityFunction(parent: Container, root: Root): <Name extends string>(name: Name, factory: UtilityCallbackFn, options?: {
|
|
3
|
+
autogenerate?: UtilityAutogenerateFn;
|
|
4
|
+
namespace?: string | string[];
|
|
5
|
+
}) => UtilityCreatorFn;
|
|
6
|
+
//# sourceMappingURL=utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../src/tokens/utility.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,SAAS,EAGT,IAAI,EAGJ,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAEhB,MAAM,UAAU,CAAC;AAiHlB,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC1C,IAAI,SAAS,MAAM,EAC1C,MAAM,IAAI,EACV,SAAS,iBAAiB,EAC1B,UAAS;IACR,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,KACJ,gBAAgB,CAiMnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.test.d.ts","sourceRoot":"","sources":["../../src/tokens/utility.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Container, Root, TokenValue, Variable } from '../types';
|
|
2
|
+
export declare function createVariableFunction(parent: Container, root: Root): <Name extends string>(nameOrInstance: Name | Variable<Name>, value: TokenValue, options?: {
|
|
3
|
+
default: boolean;
|
|
4
|
+
}) => Variable<Name>;
|
|
5
|
+
//# sourceMappingURL=variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/tokens/variable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,IAC1C,IAAI,SAAS,MAAM,EAC3C,gBAAgB,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,EACrC,OAAO,UAAU,EACjB,UAAS;IACR,OAAO,EAAE,OAAO,CAAC;CAGjB,KACC,QAAQ,CAAC,IAAI,CAAC,CAoCjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.test.d.ts","sourceRoot":"","sources":["../../src/tokens/variable.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AtRule, Container, ContainerInput, CSS, ModifierFactory, PrimitiveTokenValue, Recipe, Reference, Root, Selector, Theme, TokenType, TokenValue, Utility, Variable } from './types';
|
|
2
|
+
import { Styleframe } from './styleframe';
|
|
3
|
+
export declare function isObject(value: unknown): value is object;
|
|
4
|
+
/**
|
|
5
|
+
* Tokens
|
|
6
|
+
*/
|
|
7
|
+
export declare function isToken<T>(value: unknown, type: TokenType): value is T;
|
|
8
|
+
export declare function isVariable<Name extends string = string>(value: unknown): value is Variable<Name>;
|
|
9
|
+
export declare function isRef<Name extends string = string>(value: unknown): value is Reference<Name>;
|
|
10
|
+
export declare function isSelector(value: unknown): value is Selector;
|
|
11
|
+
export declare function isAtRule(value: unknown): value is AtRule;
|
|
12
|
+
export declare function isUtility<Name extends string = string>(value: unknown): value is Utility<Name>;
|
|
13
|
+
export declare function isModifier(value: unknown): value is ModifierFactory;
|
|
14
|
+
export declare function isCSS(value: unknown): value is CSS;
|
|
15
|
+
export declare function isTheme(value: unknown): value is Theme;
|
|
16
|
+
export declare function isRoot(value: unknown): value is Root;
|
|
17
|
+
export declare function isRecipe(value: unknown): value is Recipe;
|
|
18
|
+
export declare function isPrimitiveTokenValue(value: unknown): value is PrimitiveTokenValue;
|
|
19
|
+
export declare function isTokenValue(value: unknown): value is TokenValue;
|
|
20
|
+
export declare function isContainer(value: unknown): value is Container;
|
|
21
|
+
export declare function isContainerInput(value: unknown): value is ContainerInput;
|
|
22
|
+
export declare function isKeyReferenceValue(value: unknown): value is `@${string}`;
|
|
23
|
+
export declare function isStyleframe(value: unknown): value is Styleframe;
|
|
24
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../src/typeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,SAAS,EACT,cAAc,EACd,GAAG,EACH,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AAEH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,KAAK,IAAI,CAAC,CAEtE;AAED,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EACtD,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,CAEzB;AAED,wBAAgB,KAAK,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EACjD,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,CAE1B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,SAAS,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EACrD,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAExB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAEnE;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAElD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,mBAAmB,CAO9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAOhE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAQ9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAOxE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,MAAM,EAAE,CAEzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAWhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.test.d.ts","sourceRoot":"","sources":["../src/typeGuards.test.ts"],"names":[],"mappings":""}
|