@teacss/bun 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncLocalStorage as e}from"node:async_hooks";import{existsSync as t,watch as n}from"node:fs";import{mkdir as r,readFile as i,stat as a,writeFile as o}from"node:fs/promises";import{dirname as s,isAbsolute as c,join as l,resolve as u}from"node:path";import d from"node:process";import{entryDiscoveryFiles as f}from"@teacss/config";import{SourceWatchRegistry as p,createSourceDeclarationCheck as m,planSourceWatches as h,probeSourceDeclarations as g,scanSourceFiles as _,sourceDeclarationStateOf as v,sourceDeclarationWatchTargets as y,sourceWatchTargets as b}from"@teacss/config/internal/source-scan";import x from"@teacss/directives";import{applyTransformerPipeline as S,createContext as C,defaultFilesystemGlobs as w}from"@teacss/runtime";import{bundledAssetName as T,rewriteBundledAssets as E}from"@teacss/runtime/internal/bundled-assets";import{DEFAULT_SOURCE_IGNORE as D,generateSources as O}from"@teacss/runtime/source-generation";function
|
|
1
|
+
import{AsyncLocalStorage as e}from"node:async_hooks";import{existsSync as t,watch as n}from"node:fs";import{mkdir as r,readFile as i,stat as a,writeFile as o}from"node:fs/promises";import{dirname as s,isAbsolute as c,join as l,resolve as u}from"node:path";import d from"node:process";import{entryDiscoveryFiles as f}from"@teacss/config";import{SourceWatchRegistry as p,createSourceDeclarationCheck as m,planSourceWatches as h,probeSourceDeclarations as g,scanSourceFiles as _,sourceDeclarationStateOf as v,sourceDeclarationWatchTargets as y,sourceWatchTargets as b}from"@teacss/config/internal/source-scan";import x from"@teacss/directives";import{applyTransformerPipeline as S,createContext as C,defaultFilesystemGlobs as w}from"@teacss/runtime";import{bundledAssetName as T,rewriteBundledAssets as E}from"@teacss/runtime/internal/bundled-assets";import{enableNodeCompileCache as ee}from"@teacss/runtime/internal/compile-cache";import{DEFAULT_SOURCE_IGNORE as D,generateSources as O}from"@teacss/runtime/source-generation";function te(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}}ee();const k=/^(?:virtual:)?teacss\.css$/,A=/\.css$/,j=`teacss`;function ne(e){return e===void 0?{globs:w,ignore:D}:{globs:e,ignore:[]}}function re(e,t={}){return{name:`teacss`,async setup(n){let a=C(e,{...t,transformers:[...t.transformers??[],x()]}),c=n.config.root??d.cwd();await a.updateRoot(c);let u=new Set,f=new Set,p=!0,m=new Map;async function h(e){return n.config.outdir?(await E(e,e=>(m.set(e.digest,e),`./teacss-fonts/${T(e)}`))).toString():e}n.config.outdir&&(n.onResolve({filter:/^\.\/teacss-fonts\/teacss-[a-f0-9]{64}\.woff2$/},e=>{let t=e.path.slice(15);if([...m.values()].some(e=>T(e)===t))return{path:e.path,external:!0}}),n.onEnd(async e=>{if(e.success)for(let t of e.outputs){if(!t.path.endsWith(`.css`))continue;let e=await t.text(),n=l(s(t.path),`teacss-fonts`);for(let t of m.values()){let i=T(t);e.includes(`teacss-fonts/${i}`)&&(await r(n,{recursive:!0}),await o(l(n,i),t.bytes))}}}));function g(){let e=a.getConfigFileList()[0];return e?s(e):c}async function v(e){let t=e();u.add(t);try{return await t}finally{u.delete(t)}}n.onStart(async()=>{if(p){p=!1;return}await Promise.allSettled(u),m.clear();for(let e of f)await a.extract(``,e);f.clear(),await a.reloadConfig()}),n.onResolve({filter:k},()=>({path:`teacss.css`,namespace:j})),n.onLoad({filter:/.*/,namespace:j},()=>v(async()=>{let{globs:e,ignore:t}=ne((await a.getConfig()).content?.filesystem),n=await _(e,{cwd:g(),ignore:t,expandDirectories:!0}),{css:r}=await O(a.generator,n,void 0,{minify:!1});return{contents:await h(r),loader:`css`}})),n.onLoad({filter:A},e=>v(async()=>{let t=await i(e.path,`utf8`);return f.add(e.path),{contents:await h((await S(a,t,e.path))?.code??t),loader:`css`}}))}}}function ie(e){return`${e.mtimeMs}:${e.ctimeMs}:${e.size}:${e.ino}`}async function M(r,i={}){let o=u(r.root??d.cwd()),l=r.entrypoints.map(e=>c(e)?e:u(o,e)),{configOrPath:x,defaults:S={},debounce:T=50,onBuild:E,onError:ee}=i,D=C(x,S),O=new Set,k=!1,A=!1,j,M,N=!1,P,F=!1,I=!1,L=0,R=!1,z=``,B=new Set,V,ae,H=0,U=new Set,oe=new e;function W(){let e=D.getConfigFileList()[0];return e?s(e):o}async function G(){let{globs:e,ignore:t}=ne(D.generator.config.content?.filesystem);return await _(e,{cwd:W(),ignore:t,expandDirectories:!0})}function se(e){let t=e.content?.filesystem;if(!t)return e;let n=W();return{...e,content:{...e.content,filesystem:t.map(e=>e.startsWith(`!`)?`!${u(n,e.slice(1))}`:u(n,e))}}}function K(e,t,n){if(!t)return Promise.resolve();let r={active:!0},i;return i=oe.run(r,()=>Promise.resolve().then(()=>t(n)).catch(t=>console.error(`[@teacss/bun] watch ${e} callback failed:`,t)).finally(()=>{r.active=!1,U.delete(i)})),U.add(i),i}async function ce(){for(;U.size>0;)await Promise.all(U)}function q(e){return A?Promise.resolve():(V=e,K(`error`,ee,e))}function le(e,t=O){let n=[...D.getConfigFileList(),...l,...t,...e].map(e=>({kind:`exact`,path:e}));if(typeof x!=`object`){let e=typeof x==`string`?u(o,x):o;if(e.endsWith(`.css`))n.push({kind:`exact`,path:e});else for(let t of f)n.push({kind:`exact`,path:u(e,t)})}return n.push(...b(D.generator.config.content?.filesystem??w,W(),!0)),n.push(...y(v(D))),n}function J(e,t=O){return new Set([...D.getConfigFileList(),...l,...t,...e])}async function Y(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 ue(e,t=O){return(await Y([J(e,t)]))[0]}let de=new p((e,t,r)=>n(e,{recursive:r},t),e=>{if(e!==void 0&&B.has(e)&&L++,!F){I=!0;return}$()},e=>{q(e)});function X(e,t=O){de.reconcile(h(le(e,t))),B=J(e,t)}function fe(e,t,n){return AggregateError([e,t],n)}function pe(e,n){return new Set(Object.keys(e.metafile?.inputs??{}).map(e=>c(e)?e:u(o,e)).filter(e=>!n||t(e)))}let Z,Q;async function me(e,t=O){if(A)return;let n=e,r=[];try{r=await G()}catch(e){n=fe(n,e,`TeaCSS build and source discovery failed`)}if(!A){try{X(r,t);let e=v(D),n=await g(e,!0,Z);Q=n,(await g(e)).signature!==n.signature&&(R=!0,F?N=!0:I=!0)}catch(e){n=fe(n,e,`TeaCSS build and watcher reconciliation failed`)}await q(n)}}async function he(){if(A)return;Z=await g(v(D));let e=L,t=new Set(B),[n]=await Y([t]);if(k?await D.reloadConfig():(k=!0,await D.updateRoot(o)),A)return;let i=await G();if(A||(X(i),A))return;let a=v(D),s=await g(a,!0,Z);Q=s;let c=await g(a),l=s.signature!==c.signature,[u]=await Y([t]),d=n!==u||l,f=await ue(i);if(A)return;let p=R;if(R=!1,!p&&!d&&H>0&&V===void 0&&f===z)return;let m=se(await D.getConfig());if(A)return;let h=[...(r.plugins??[]).filter(e=>e.name!==`teacss`),re(m)],_=await Bun.build(te(r,h));if(A)return;if(!_.success){await me(_,new Set([...O,...pe(_,!1)]));return}let y=pe(_,!0),b=await G();if(A)return;let x=[...y].some(e=>!B.has(e));if(X(b,y),A)return;let[S,C]=await Y([J(b),J(b,y)]);if(A)return;let w=await g(a),T=d||s?.signature!==w?.signature||x||S!==f||L!==e;ae=_,V=void 0,H++,O=y,z=C,await K(`build`,E,_),T&&(R=!0,F?N=!0:I=!0)}async function ge(){try{await he()}catch(e){await me(e)}}async function _e(){do N=!1,await ge();while(N&&!A)}function $(){A||(M&&clearTimeout(M),M=setTimeout(()=>{M=void 0,N=!0,P||=_e().finally(()=>{P=void 0,N&&!A&&$()})},T))}function ve(){A=!0,ye.retire(),M&&clearTimeout(M),M=void 0,de.retire()}await ge(),F=!0;let ye=m(()=>v(D),async e=>{A||M||N||e.signature===Q?.signature||(P?N=!0:$())},q);return I&&$(),{get error(){return V},get result(){return ae},get version(){return H},dispose(){return oe.getStore()?.active?(ve(),Promise.resolve()):(j??=(async()=>{ve(),await ye.close(),await P,await ce()})(),j)}}}export{re as pluginTeacss,M as watchTeacssBuild};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/bun",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
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,15 +22,15 @@
|
|
|
22
22
|
"dev": "tsdown --watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@teacss/config": "0.9.
|
|
26
|
-
"@teacss/core": "0.9.
|
|
27
|
-
"@teacss/directives": "0.9.
|
|
28
|
-
"@teacss/engine": "0.9.
|
|
29
|
-
"@teacss/runtime": "0.9.
|
|
25
|
+
"@teacss/config": "0.9.2",
|
|
26
|
+
"@teacss/core": "0.9.2",
|
|
27
|
+
"@teacss/directives": "0.9.2",
|
|
28
|
+
"@teacss/engine": "0.9.3",
|
|
29
|
+
"@teacss/runtime": "0.9.2",
|
|
30
30
|
"tinyglobby": "^0.2.17"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@teacss/preset-standard": "0.9.
|
|
33
|
+
"@teacss/preset-standard": "0.9.2",
|
|
34
34
|
"bun-types": "^1.4.1",
|
|
35
35
|
"consola": "^3.4.2"
|
|
36
36
|
},
|