@teacss/directives 0.3.8 → 0.4.1
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/README.md +7 -1
- package/dist/index.js +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ lifecycle; applications should normally select a build integration instead.
|
|
|
19
19
|
.button {
|
|
20
20
|
@apply p-x:4 p-y:2 rd:2 content:["hello world"];
|
|
21
21
|
color: theme("colors.red.500");
|
|
22
|
-
background-image: icon("
|
|
22
|
+
background-image: icon("lucide-sun");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
@screen md {
|
|
@@ -35,6 +35,12 @@ lifecycle; applications should normally select a build integration instead.
|
|
|
35
35
|
`@apply` splits only whitespace outside attached `[]` literal regions, so
|
|
36
36
|
spaces in arbitrary values remain part of one TeaCSS utility.
|
|
37
37
|
|
|
38
|
+
`@apply` also reads `{a;b}@cond` group syntax, in both the at-rule and
|
|
39
|
+
`--at-apply` forms, like every other class-list surface; a group body may hold
|
|
40
|
+
another group, and the outer condition chain lands after the inner one.
|
|
41
|
+
`theme("key", fallback)` inside an arbitrary value resolves the fallback when
|
|
42
|
+
the key is missing.
|
|
43
|
+
|
|
38
44
|
Used automatically by the Vite, PostCSS, Rsbuild, Bun, and CLI pipelines.
|
|
39
45
|
When an integration splices a CSS entry, a BOM and native `@charset` remain
|
|
40
46
|
before hoisted `@import` rules.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./screen-core-WpBOgdSr.js";import{createGenerator as s,
|
|
2
|
-
`)}\n`:``)+a}function
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./screen-core-WpBOgdSr.js";import{createGenerator as s,expandClassGroups as c,expandVariantGroup as l,isCssId as u,splitClassTokens as d,toArray as f}from"@teacss/core";import{generate as p,parse as m,walk as h}from"css-tree";import{hasIconFn as g,hasThemeFn as _,transformThemeFn as v}from"@teacss/rule-helpers";import{customToTheme as y,diagnoseCustom as b,parseEntry as x,resolveEntryConfig as S,resolvePresets as C,scanTopLevelAtRules as w}from"@teacss/config";import{generateSources as T}from"@teacss/runtime/source-generation";async function E(e,t,n){let r=[],i=[],a=!1;for(let o of t.block.children)if(o.type===`Raw`)await n(o.value,o.loc.start.offset);else{let n=await D(e,t,o);if(!n)continue;r.push(n.consumedRange),i.push(...n.standaloneCss),a||=n.hasInlineUtility}let o=e.code.original,s=t.block.loc.start.offset+1,c=!1;for(let[e,t]of r){if(o.slice(s,e).trim()){c=!0;break}s=t}c||=!!o.slice(s,t.block.loc.end.offset-1).trim(),!a&&!c&&r.length>0&&e.code.remove(t.loc.start.offset,t.loc.end.offset);for(let n of i)e.code.appendLeft(t.loc.end.offset,n)}async function D({code:n,generator:o,applyVariable:s,options:u,filename:f},m,h){let g=n.original,_,y=h.loc.end.offset;if(h.type===`Atrule`&&h.name===`apply`&&h.prelude&&h.prelude.type===`Raw`)_=k(h.prelude.value.trim());else if(h.type===`Atrule`&&h.name===`apply`&&!h.prelude&&h.block)y=O(g,y),_=g.slice(h.loc.start.offset+6,y).trim();else if(h.type===`Declaration`&&s.includes(h.property)&&(h.value.type===`Value`||h.value.type===`Raw`)){let e=g.slice(h.value.loc.start.offset,h.value.loc.end.offset).trim();e=k(e),_=d(e).map(e=>k(e)).join(` `)}if(!_)return;_=A(_),_=v(_,o.config.theme,u.throwOnMissing??!0);let b=await a(d(l(c(_))),o),x=t(b);if(x.length&&(u.throwOnMissing??!0))throw Error(`${i(x)}${f?` in ${f}`:``}`);let S=e(b,o.parentOrders),C=+(g[y]===`;`),w=[h.loc.start.offset,y+C];if(!S.length)return n.remove(...w),{consumedRange:w,hasInlineUtility:!1,standaloneCss:[]};let T,E=!1,D=[];for(let e of S)if(e.kind===`top-level`)D.push(e.body);else if(e.kind===`standalone`){if(!T){let e=m.prelude;T={prelude:e,selector:p(e),replacementSelector:n.slice(m.prelude.loc.start.offset,m.prelude.loc.end.offset)}}let t=r(T,e);D.push(t)}else E=!0,n.appendLeft(h.loc.start.offset,e.body);return n.remove(...w),{consumedRange:w,hasInlineUtility:E,standaloneCss:D}}function O(e,t){let n=t;for(;e[n]===`@`;){let t=0;for(n++;n<e.length;){let r=e[n];if(r===`[`||r===`(`)t++;else if(r===`]`||r===`)`)t--;else if(t===0&&(/\s/.test(r)||r===`;`||r===`{`||r===`}`))break;n++}}return n}function k(e){return e.replace(/^(['"])(.*)\1$/,`$2`)}function A(e){return e.replace(/\/\*[\s\S]*?\*\//g,``)}async function j({code:e,generator:t,options:r},i){let a=await n(t,i,(t,n)=>e.slice(t,n),r.throwOnMissing??!0);a!==void 0&&e.overwrite(i.loc.start.offset,i.loc.end.offset,a)}const M=/(@screen [^{]+).+/g;function N({code:e,generator:t},n){if(n.prelude?.type!==`Raw`)return;let r=o(n.prelude.value,t.config.theme);if(!r)return;let i=n.loc.start.offset,a=e.original.slice(i,n.loc.end.offset);for(let t of a.matchAll(M))e.overwrite(i+t.index,i+t.index+t[1].length,`@media ${r}`)}const P=new Set([`preset`,`source`,`shortcut`,`safelist`]);function F(e){let t=e.original;if(!t.includes(`@`))return;let n=w(t);if(!n.some(e=>e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`))for(let t of n)(P.has(t.name)?t.terminator===`;`:t.name===`custom`&&t.terminator===`block`)&&e.remove(t.start,t.end)}function I(e){return e.includes(`@preset`)||e.includes(`@source`)||e.includes(`@shortcut`)||e.includes(`@safelist`)||e.includes(`@custom`)}async function L(e,t,n,r,i,a){let{applyVariable:o}=n,s=n.varStyle;o===void 0&&(o=s===void 0?[`--at-apply`]:s?[`${s}apply`]:[]),o=f(o||[]);let c=e=>e.includes(`@apply`)||o.some(t=>e.includes(t)),l=i||e.original,u=c(l),d=l.includes(`@screen`),p=_(l)||g(l);if(i===void 0&&I(l)&&F(e),!u&&!p&&!d)return;let v=m(l,{parseCustomProperty:!0,parseAtrulePrelude:!1,positions:!0,filename:r,offset:a});if(v.type!==`StyleSheet`)return;let y=[],b=new WeakSet,x=new WeakSet,S={options:n,applyVariable:o,generator:t,code:e,filename:r,offset:a},C=(i,a)=>L(e,t,n,r,i,a),w=async e=>{for(let t of e.block.children)t.type===`Raw`&&await C(t.value,t.loc.start.offset)};h(v,function(t){if(d&&t.type===`Atrule`&&t.name===`screen`)N(S,t);else if(p&&t.type===`Function`&&(t.name===`theme`||t.name===`icon`))return y.push(j(S,t)),this.skip;else u&&t.type===`Rule`&&c(e.original.slice(t.loc.start.offset,t.loc.end.offset))?(b.add(t),y.push(E(S,t,C))):t.type===`Raw`&&this.rule&&!b.has(this.rule)&&!x.has(this.rule)&&(x.add(this.rule),y.push(w(this.rule)))}),await Promise.all(y)}async function R(e,t){let{base:n,readSources:r,contents:i}=t,a=await S(e,n),o=await s(a.config),c=[],l=[];for(let e of a.config.content?.filesystem??[])e.startsWith(`!`)?l.push(e.slice(1)):c.push(e);let{files:u,sources:d}=i?{files:[],sources:i}:r?await r(c,l):{files:[],sources:[]},f=await T(o,u,d);return{layers:f.getLayers()||``,files:u,unknown:a.unknown,matched:f.matched.size,hasTeacss:a.hasTeacss,hasPreset:!!a.config.presets?.length}}function z(e,t){let n=[],r=[],i=[];for(let a of w(e))a.name===`charset`&&a.terminator===`;`?(n.push(e.slice(a.start,a.end)),i.push({start:a.start,end:a.end,replacement:``})):a.name===`import`&&a.terminator===`;`?(r.push(e.slice(a.start,a.end)),i.push({start:a.start,end:a.end,replacement:``})):(a.name===`preset`||a.name===`source`||a.name===`shortcut`||a.name===`safelist`)&&a.terminator===`;`||a.name===`custom`&&a.terminator===`block`?i.push({start:a.start,end:a.end,replacement:``}):a.name===`teacss`&&a.prelude===``&&a.terminator!==`block`&&i.push({start:a.start,end:a.end,replacement:t});i.sort((e,t)=>e.start-t.start);let a=``,o=0;for(let t of i)a+=e.slice(o,t.start)+t.replacement,o=t.end;a+=e.slice(o);let s=a.startsWith(``)?``:``;s&&(a=a.slice(1));let c=[...n,...r];return s+(c.length?`${c.join(`
|
|
2
|
+
`)}\n`:``)+a}function B(e={}){return{name:`@teacss/directives`,enforce:e.enforce,idFilter:u,transform:(t,n,r)=>L(t,r.generator,e,n)}}export{y as customToTheme,B as default,b as diagnoseCustom,R as generateEntry,x as parseEntry,C as resolvePresets,z as spliceEntry,L as transformDirectives};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/directives",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Build-time CSS directive transformer for TeaCSS — @apply, theme(), icon(), and @screen.",
|
|
5
5
|
"homepage": "https://css.teasim.com",
|
|
6
6
|
"funding": "https://github.com/sponsors/billgo",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"dev": "tsdown --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@teacss/config": "0.
|
|
27
|
-
"@teacss/core": "0.
|
|
28
|
-
"@teacss/rule-helpers": "0.
|
|
29
|
-
"@teacss/runtime": "0.
|
|
26
|
+
"@teacss/config": "0.4.1",
|
|
27
|
+
"@teacss/core": "0.4.1",
|
|
28
|
+
"@teacss/rule-helpers": "0.4.1",
|
|
29
|
+
"@teacss/runtime": "0.4.1",
|
|
30
30
|
"@types/css-tree": "^2.3.11",
|
|
31
31
|
"css-tree": "^3.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@teacss/preset-icons": "0.
|
|
35
|
-
"@teacss/preset-standard": "0.
|
|
34
|
+
"@teacss/preset-icons": "0.4.1",
|
|
35
|
+
"@teacss/preset-standard": "0.4.1",
|
|
36
36
|
"magic-string": "^1.1.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|