@teacss/bun 0.3.0 → 0.3.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 +9 -8
- package/dist/index.js +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -12,8 +12,7 @@ including programmatic watch builds. It owns Bun's plugin and watcher
|
|
|
12
12
|
lifecycles; use `@teacss/cli` for standalone CSS output, or the matching
|
|
13
13
|
framework integration when another build system owns the module graph.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
`teacss`:
|
|
15
|
+
Install the owning Bun adapter beside the `teacss` runtime:
|
|
17
16
|
|
|
18
17
|
```sh
|
|
19
18
|
bun add teacss
|
|
@@ -23,7 +22,7 @@ bun add -d @teacss/bun
|
|
|
23
22
|
## Usage
|
|
24
23
|
|
|
25
24
|
```ts
|
|
26
|
-
import { pluginTeacss } from "teacss/bun";
|
|
25
|
+
import { pluginTeacss } from "@teacss/bun";
|
|
27
26
|
|
|
28
27
|
await Bun.build({
|
|
29
28
|
entrypoints: ["./src/index.ts"],
|
|
@@ -39,7 +38,7 @@ the Bun module graph together with the CSS entry, resolved config dependencies,
|
|
|
39
38
|
and positive `@source` roots:
|
|
40
39
|
|
|
41
40
|
```ts
|
|
42
|
-
import { watchTeacssBuild } from "teacss/bun";
|
|
41
|
+
import { watchTeacssBuild } from "@teacss/bun";
|
|
43
42
|
|
|
44
43
|
const session = await watchTeacssBuild(
|
|
45
44
|
{
|
|
@@ -89,9 +88,11 @@ import "virtual:teacss.css";
|
|
|
89
88
|
@teacss;
|
|
90
89
|
```
|
|
91
90
|
|
|
91
|
+
Default source discovery skips dependency and common build-output directories.
|
|
92
|
+
Explicit `@source` globs remain authoritative and can include those directories.
|
|
93
|
+
|
|
92
94
|
## Status
|
|
93
95
|
|
|
94
|
-
Pre-1.0.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
`@teacss/bun` directly when they intentionally do not use the facade.
|
|
96
|
+
Pre-1.0. `@teacss/bun` is the owning Bun adapter. Applications import it
|
|
97
|
+
directly from `@teacss/bun`. Source transformers such as `:css:` compile-class
|
|
98
|
+
are not run here.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncLocalStorage as e}from"node:async_hooks";import{existsSync as t,statSync as n,watch as r}from"node:fs";import{readFile as i,stat as a}from"node:fs/promises";import{dirname as o,isAbsolute as s,normalize as c,relative as l,resolve as u,sep as d}from"node:path";import f from"node:process";import p from"@teacss/directives";import{applyTransformerPipeline as m,createContext as h,defaultFilesystemGlobs as g}from"@teacss/runtime";import{DEFAULT_SOURCE_IGNORE as _,generateSources as v,readSourceFile as y}from"@teacss/runtime/source-generation";import{glob as b,isDynamicPattern as x}from"tinyglobby";function S(e,t){let n=l(e,t);return n===``||n!==`..`&&!n.startsWith(`..${d}`)&&!s(n)}function C(e){let t=Array.from(new Set(Array.from(e,c))).sort((e,t)=>e.length-t.length||e.localeCompare(t)),n=[];for(let e of t)n.some(t=>S(t,e))||n.push(e);return n}function ee(e,t){let n=t;for(;x(n);){let e=o(n);if(e===n)break;n=e}return u(e,n)}var te=class{createWatcher;onChange;onError;#e=!1;#t=new Map;constructor(e,t,n){this.createWatcher=e,this.onChange=t,this.onError=n}get roots(){return[...this.#t.keys()]}covers(e){for(let t of this.#t.keys())if(S(t,e))return!0;return!1}reconcile(e){if(this.#e)return;let t=C(e),n=new Set(t),r=new Map;try{for(let e of t){if(this.#t.has(e))continue;let t;try{t=this.createWatcher(e,(t,n)=>{this.onChange(n==null?void 0:u(e,n.toString()))});let n=t;t.on(`error`,t=>{this.#t.get(e)===n&&(this.#t.delete(e),this.closeWatcher(n)),this.onError(t)}),r.set(e,t)}catch(e){throw t&&this.closeWatcher(t),e}}}catch(e){for(let e of r.values())this.closeWatcher(e);throw e}if(this.#e){for(let e of r.values())this.closeWatcher(e);return}let i=new Map;for(let e of t){let t=this.#t.get(e)??r.get(e);t&&i.set(e,t)}let a=this.#t;this.#t=i;for(let[e,t]of a)n.has(e)||this.closeWatcher(t)}dispose(){if(this.#e)return;this.#e=!0;let e=this.#t;this.#t=new Map;for(let t of e.values())this.closeWatcher(t)}closeWatcher(e){try{e.close()}catch(e){this.onError(e)}}};function ne(e,t,n=Bun.version){let r={...e};return delete r.metafile,Bun.semver.satisfies(n,`>=1.3.6`)&&(r.metafile=!0),{...r,plugins:t}}const w=/^(?:virtual:)?teacss\.css$/,T=/\.css$/,E=`teacss`;function D(e,t={}){return{name:`teacss`,async setup(n){let r=h(e,{...t,transformers:[...t.transformers??[],p()]}),a=n.config.root??f.cwd();await r.updateRoot(a);let s=new Set,c=new Set,l=!0;function u(){let e=r.getConfigFileList()[0];return e?o(e):a}async function d(e){let t=e();s.add(t);try{return await t}finally{s.delete(t)}}n.onStart(async()=>{if(l){l=!1;return}await Promise.allSettled(s);for(let e of c)await r.extract(``,e);c.clear(),await r.reloadConfig()}),n.onResolve({filter:w},()=>({path:`teacss.css`,namespace:E})),n.onLoad({filter:/.*/,namespace:E},()=>d(async()=>{let
|
|
1
|
+
import{AsyncLocalStorage as e}from"node:async_hooks";import{existsSync as t,statSync as n,watch as r}from"node:fs";import{readFile as i,stat as a}from"node:fs/promises";import{dirname as o,isAbsolute as s,normalize as c,relative as l,resolve as u,sep as d}from"node:path";import f from"node:process";import p from"@teacss/directives";import{applyTransformerPipeline as m,createContext as h,defaultFilesystemGlobs as g}from"@teacss/runtime";import{DEFAULT_SOURCE_IGNORE as _,generateSources as v,readSourceFile as y}from"@teacss/runtime/source-generation";import{glob as b,isDynamicPattern as x}from"tinyglobby";function S(e,t){let n=l(e,t);return n===``||n!==`..`&&!n.startsWith(`..${d}`)&&!s(n)}function C(e){let t=Array.from(new Set(Array.from(e,c))).sort((e,t)=>e.length-t.length||e.localeCompare(t)),n=[];for(let e of t)n.some(t=>S(t,e))||n.push(e);return n}function ee(e,t){let n=t;for(;x(n);){let e=o(n);if(e===n)break;n=e}return u(e,n)}var te=class{createWatcher;onChange;onError;#e=!1;#t=new Map;constructor(e,t,n){this.createWatcher=e,this.onChange=t,this.onError=n}get roots(){return[...this.#t.keys()]}covers(e){for(let t of this.#t.keys())if(S(t,e))return!0;return!1}reconcile(e){if(this.#e)return;let t=C(e),n=new Set(t),r=new Map;try{for(let e of t){if(this.#t.has(e))continue;let t;try{t=this.createWatcher(e,(t,n)=>{this.onChange(n==null?void 0:u(e,n.toString()))});let n=t;t.on(`error`,t=>{this.#t.get(e)===n&&(this.#t.delete(e),this.closeWatcher(n)),this.onError(t)}),r.set(e,t)}catch(e){throw t&&this.closeWatcher(t),e}}}catch(e){for(let e of r.values())this.closeWatcher(e);throw e}if(this.#e){for(let e of r.values())this.closeWatcher(e);return}let i=new Map;for(let e of t){let t=this.#t.get(e)??r.get(e);t&&i.set(e,t)}let a=this.#t;this.#t=i;for(let[e,t]of a)n.has(e)||this.closeWatcher(t)}dispose(){if(this.#e)return;this.#e=!0;let e=this.#t;this.#t=new Map;for(let t of e.values())this.closeWatcher(t)}closeWatcher(e){try{e.close()}catch(e){this.onError(e)}}};function ne(e,t,n=Bun.version){let r={...e};return delete r.metafile,Bun.semver.satisfies(n,`>=1.3.6`)&&(r.metafile=!0),{...r,plugins:t}}const w=/^(?:virtual:)?teacss\.css$/,T=/\.css$/,E=`teacss`;function D(e){return e===void 0?{globs:g,ignore:_}:{globs:e,ignore:[]}}function O(e,t={}){return{name:`teacss`,async setup(n){let r=h(e,{...t,transformers:[...t.transformers??[],p()]}),a=n.config.root??f.cwd();await r.updateRoot(a);let s=new Set,c=new Set,l=!0;function u(){let e=r.getConfigFileList()[0];return e?o(e):a}async function d(e){let t=e();s.add(t);try{return await t}finally{s.delete(t)}}n.onStart(async()=>{if(l){l=!1;return}await Promise.allSettled(s);for(let e of c)await r.extract(``,e);c.clear(),await r.reloadConfig()}),n.onResolve({filter:w},()=>({path:`teacss.css`,namespace:E})),n.onLoad({filter:/.*/,namespace:E},()=>d(async()=>{let{globs:e,ignore:t}=D((await r.getConfig()).content?.filesystem),n=await b(e,{cwd:u(),absolute:!0,ignore:t}),i=n.map(y),{css:a}=await v(r.generator,n,i,{minify:!1});return{contents:a,loader:`css`}})),n.onLoad({filter:T},e=>d(async()=>{let t=await i(e.path,`utf8`);return c.add(e.path),{contents:(await m(r,t,e.path))?.code??t,loader:`css`}}))}}}function re(e){let r=e;for(n(r,{throwIfNoEntry:!1})?.isFile()&&(r=o(r));!t(r);){let e=o(r);if(e===r)break;r=e}return r}function ie(e){return`${e.mtimeMs}:${e.ctimeMs}:${e.size}:${e.ino}`}async function k(n,i={}){let c=u(n.root??f.cwd()),l=n.entrypoints.map(e=>s(e)?e:u(c,e)),{configOrPath:d,defaults:p={},debounce:m=50,onBuild:_,onError:v}=i,y=h(d,p),x=new Set,S=!1,C=!1,w,T,E=!1,k,A=!1,j=!1,M=0,N=!1,P=``,F=new Set,I,L,R=0,z=new Set,B=new e;function V(){let e=y.getConfigFileList()[0];return e?o(e):c}async function H(){let{globs:e,ignore:t}=D(y.generator.config.content?.filesystem);return await b(e,{cwd:V(),absolute:!0,ignore:t})}function ae(e){let t=e.content?.filesystem;if(!t)return e;let n=V();return{...e,content:{...e.content,filesystem:t.map(e=>e.startsWith(`!`)?`!${u(n,e.slice(1))}`:u(n,e))}}}function U(e,t,n){if(!t)return Promise.resolve();let r={active:!0},i;return i=B.run(r,()=>Promise.resolve().then(()=>t(n)).catch(t=>console.error(`[@teacss/bun] watch ${e} callback failed:`,t)).finally(()=>{r.active=!1,z.delete(i)})),z.add(i),i}async function oe(){for(;z.size>0;)await Promise.all(z)}function W(e){return C?Promise.resolve():(I=e,U(`error`,v,e))}function se(e,t=x){let n=new Set([...y.getConfigFileList(),...l,...t,...e]);if(typeof d!=`object`){let e=typeof d==`string`?u(c,d):c;n.add(e)}let r=V();for(let e of y.generator.config.content?.filesystem??g)e.startsWith(`!`)||n.add(ee(r,e));return n}function G(e,t=x){return new Set([...y.getConfigFileList(),...l,...t,...e])}async function K(e){let t=new Set(e.flatMap(e=>[...e])),n=new Map(await Promise.all([...t].map(async e=>{try{return[e,`${e}:${ie(await a(e))}`]}catch(t){if(t.code===`ENOENT`)return[e,`${e}:missing`];throw t}})));return e.map(e=>[...e].sort().map(e=>n.get(e)).join(`|`))}async function ce(e,t=x){return(await K([G(e,t)]))[0]}let q=new te((e,t)=>r(e,{recursive:!0},t),e=>{if(e!==void 0&&F.has(e)&&M++,!A){j=!0;return}$()},e=>{W(e),A?$():j=!0});function J(e,t=x){return F=G(e,t),q.reconcile(Array.from(se(e,t),re))}function Y(e,t,n){return AggregateError([e,t],n)}function X(e,n){return new Set(Object.keys(e.metafile?.inputs??{}).map(e=>s(e)?e:u(c,e)).filter(e=>!n||t(e)))}async function Z(e,t=x){if(C)return;let n=e,r=[];try{r=await H()}catch(e){n=Y(n,e,`TeaCSS build and source discovery failed`)}if(!C){try{J(r,t)}catch(e){n=Y(n,e,`TeaCSS build and watcher reconciliation failed`)}await W(n)}}async function le(){if(C)return;let e=M;if(S?await y.reloadConfig():(S=!0,await y.updateRoot(c)),C)return;let t=await H();if(C||(J(t),C))return;let r=await ce(t);if(C)return;let i=N;if(N=!1,!i&&R>0&&I===void 0&&r===P)return;let a=ae(await y.getConfig());if(C)return;let o=[...(n.plugins??[]).filter(e=>e.name!==`teacss`),O(a)],s=await Bun.build(ne(n,o));if(C)return;if(!s.success){await Z(s,new Set([...x,...X(s,!1)]));return}let l=X(s,!0),u=await H();if(C)return;let d=[...l].some(e=>!q.covers(e));if(J(u,l),C)return;let[f,p]=await K([G(u),G(u,l)]);if(C)return;let m=d||f!==r||M!==e;L=s,I=void 0,R++,x=l,P=p,await U(`build`,_,s),m&&(N=!0,A?E=!0:j=!0)}async function Q(){try{await le()}catch(e){await Z(e)}}async function ue(){do E=!1,await Q();while(E&&!C)}function $(){C||(T&&clearTimeout(T),T=setTimeout(()=>{T=void 0,E=!0,k||=ue().finally(()=>{k=void 0,E&&!C&&$()})},m))}function de(){C=!0,T&&clearTimeout(T),T=void 0,q.dispose()}return await Q(),A=!0,j&&$(),{get error(){return I},get result(){return L},get version(){return R},dispose(){return B.getStore()?.active?(de(),Promise.resolve()):(w??=(async()=>{de(),await k,await oe()})(),w)}}}export{O as pluginTeacss,k as watchTeacssBuild};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/bun",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Bun plugin for TeaCSS — generate utilities and inline @apply via Bun.build.",
|
|
5
5
|
"homepage": "https://css.teasim.com",
|
|
6
6
|
"funding": "https://github.com/sponsors/billgo",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"dev": "tsdown --watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@teacss/core": "0.3.
|
|
26
|
-
"@teacss/directives": "0.3.
|
|
27
|
-
"@teacss/runtime": "0.3.
|
|
25
|
+
"@teacss/core": "0.3.1",
|
|
26
|
+
"@teacss/directives": "0.3.1",
|
|
27
|
+
"@teacss/runtime": "0.3.1",
|
|
28
28
|
"tinyglobby": "^0.2.17"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@teacss/preset-standard": "0.3.
|
|
32
|
-
"bun-types": "^1.3.14"
|
|
31
|
+
"@teacss/preset-standard": "0.3.1",
|
|
32
|
+
"bun-types": "^1.3.14",
|
|
33
|
+
"consola": "^3.4.2"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"bun": ">=1.1.0",
|