@tailwindcss/node 4.0.0-beta.1 → 4.0.0-beta.3
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.d.mts +4 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -29,10 +29,13 @@ type DesignSystem = {
|
|
|
29
29
|
candidatesToCss(classes: string[]): (string | null)[];
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
type Resolver = (id: string, base: string) => Promise<string | false | undefined>;
|
|
33
|
+
declare function compile(css: string, { base, onDependency, shouldRewriteUrls, customCssResolver, customJsResolver, }: {
|
|
33
34
|
base: string;
|
|
34
35
|
onDependency: (path: string) => void;
|
|
35
36
|
shouldRewriteUrls?: boolean;
|
|
37
|
+
customCssResolver?: Resolver;
|
|
38
|
+
customJsResolver?: Resolver;
|
|
36
39
|
}): Promise<{
|
|
37
40
|
globs: {
|
|
38
41
|
base: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,10 +29,13 @@ type DesignSystem = {
|
|
|
29
29
|
candidatesToCss(classes: string[]): (string | null)[];
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
type Resolver = (id: string, base: string) => Promise<string | false | undefined>;
|
|
33
|
+
declare function compile(css: string, { base, onDependency, shouldRewriteUrls, customCssResolver, customJsResolver, }: {
|
|
33
34
|
base: string;
|
|
34
35
|
onDependency: (path: string) => void;
|
|
35
36
|
shouldRewriteUrls?: boolean;
|
|
37
|
+
customCssResolver?: Resolver;
|
|
38
|
+
customJsResolver?: Resolver;
|
|
36
39
|
}): Promise<{
|
|
37
40
|
globs: {
|
|
38
41
|
base: string;
|
|
@@ -47,11 +50,11 @@ declare function compile(css: string, { base, onDependency, shouldRewriteUrls, }
|
|
|
47
50
|
declare function __unstable__loadDesignSystem(css: string, { base }: {
|
|
48
51
|
base: string;
|
|
49
52
|
}): Promise<DesignSystem>;
|
|
50
|
-
declare function loadModule(id: string, base: string, onDependency: (path: string) => void): Promise<{
|
|
53
|
+
declare function loadModule(id: string, base: string, onDependency: (path: string) => void, customJsResolver?: Resolver): Promise<{
|
|
51
54
|
base: string;
|
|
52
55
|
module: any;
|
|
53
56
|
}>;
|
|
54
57
|
|
|
55
58
|
declare function normalizePath(originalPath: string): string;
|
|
56
59
|
|
|
57
|
-
export { __unstable__loadDesignSystem, compile, env, loadModule, normalizePath };
|
|
60
|
+
export { type Resolver, __unstable__loadDesignSystem, compile, env, loadModule, normalizePath };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var xe=Object.create;var _=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var xe=Object.create;var _=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty;var q=(e,t)=>{for(var s in t)_(e,s,{get:t[s],enumerable:!0})},H=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Re(t))!we.call(e,r)&&r!==s&&_(e,r,{get:()=>t[r],enumerable:!(i=ye(t,r))||i.enumerable});return e};var h=(e,t,s)=>(s=e!=null?xe(Ae(e)):{},H(t||!e||!e.__esModule?_(s,"default",{value:e,enumerable:!0}):s,e)),Ce=e=>H(_({},"__esModule",{value:!0}),e);var ot={};q(ot,{__unstable__loadDesignSystem:()=>et,compile:()=>Ze,env:()=>O,loadModule:()=>J,normalizePath:()=>b});module.exports=Ce(ot);var ge=h(require("module")),he=require("url");var O={};q(O,{DEBUG:()=>ve});var ve=Se(process.env.DEBUG);function Se(e){if(e===void 0)return!1;if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;if(e==="*")return!0;let t=e.split(",").map(s=>s.split(":")[0]);return t.includes("-tailwindcss")?!1:!!t.includes("tailwindcss")}var y=h(require("enhanced-resolve")),de=require("jiti"),j=h(require("fs")),K=h(require("fs/promises")),R=h(require("path")),z=require("url"),I=require("tailwindcss");var N=h(require("fs/promises")),w=h(require("path")),Ee=[/import[\s\S]*?['"](.{3,}?)['"]/gi,/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi,/export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi,/require\(['"`](.+)['"`]\)/gi],_e=[".js",".cjs",".mjs"],Ne=["",".js",".cjs",".mjs",".ts",".cts",".mts",".jsx",".tsx"],ke=["",".ts",".cts",".mts",".tsx",".js",".cjs",".mjs",".jsx"];async function $e(e,t){for(let s of t){let i=`${e}${s}`;if((await N.default.stat(i).catch(()=>null))?.isFile())return i}for(let s of t){let i=`${e}/index${s}`;if(await N.default.access(i).then(()=>!0,()=>!1))return i}return null}async function Q(e,t,s,i){let r=_e.includes(i)?Ne:ke,o=await $e(w.default.resolve(s,t),r);if(o===null||e.has(o))return;e.add(o),s=w.default.dirname(o),i=w.default.extname(o);let n=await N.default.readFile(o,"utf-8"),c=[];for(let a of Ee)for(let l of n.matchAll(a))l[1].startsWith(".")&&c.push(Q(e,l[1],s,i));await Promise.all(c)}async function Y(e){let t=new Set;return await Q(t,e,w.default.dirname(e),w.default.extname(e)),Array.from(t)}var B=h(require("path"));var C=92,k=47,$=42,Pe=34,De=39,Ue=58,P=59,x=10,v=32,D=9,X=123,F=125,M=40,V=41,Te=91,be=93,Z=45,L=64,je=33;function te(e){e=e.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
|
-
`);let t=[],
|
|
4
|
-
`;for(let d of l.nodes)
|
|
3
|
+
`);let t=[],s=[],i=[],r=null,o=null,n="",c="",a;for(let l=0;l<e.length;l++){let f=e.charCodeAt(l);if(f===C)n+=e.slice(l,l+2),l+=1;else if(f===k&&e.charCodeAt(l+1)===$){let u=l;for(let d=l+2;d<e.length;d++)if(a=e.charCodeAt(d),a===C)d+=1;else if(a===$&&e.charCodeAt(d+1)===k){l=d+1;break}let m=e.slice(u,l+1);m.charCodeAt(2)===je&&s.push(re(m.slice(2,-2)))}else if(f===De||f===Pe){let u=l;for(let m=l+1;m<e.length;m++)if(a=e.charCodeAt(m),a===C)m+=1;else if(a===f){l=m;break}else{if(a===P&&e.charCodeAt(m+1)===x)throw new Error(`Unterminated string: ${e.slice(u,m+1)+String.fromCharCode(f)}`);if(a===x)throw new Error(`Unterminated string: ${e.slice(u,m)+String.fromCharCode(f)}`)}n+=e.slice(u,l+1)}else{if((f===v||f===x||f===D)&&(a=e.charCodeAt(l+1))&&(a===v||a===x||a===D))continue;if(f===x){if(n.length===0)continue;a=n.charCodeAt(n.length-1),a!==v&&a!==x&&a!==D&&(n+=" ")}else if(f===Z&&e.charCodeAt(l+1)===Z&&n.length===0){let u="",m=l,d=-1;for(let p=l+2;p<e.length;p++)if(a=e.charCodeAt(p),a===C)p+=1;else if(a===k&&e.charCodeAt(p+1)===$){for(let g=p+2;g<e.length;g++)if(a=e.charCodeAt(g),a===C)g+=1;else if(a===$&&e.charCodeAt(g+1)===k){p=g+1;break}}else if(d===-1&&a===Ue)d=n.length+p-m;else if(a===P&&u.length===0){n+=e.slice(m,p),l=p;break}else if(a===M)u+=")";else if(a===Te)u+="]";else if(a===X)u+="}";else if((a===F||e.length-1===p)&&u.length===0){l=p-1,n+=e.slice(m,p);break}else(a===V||a===be||a===F)&&u.length>0&&e[p]===u[u.length-1]&&(u=u.slice(0,-1));let A=ee(n,d);r?r.nodes.push(A):t.push(A),n=""}else if(f===P&&n.charCodeAt(0)===L)o=S(n),r?r.nodes.push(o):t.push(o),n="",o=null;else if(f===P&&c[c.length-1]!==")"){let u=ee(n);r?r.nodes.push(u):t.push(u),n=""}else if(f===X&&c[c.length-1]!==")")c+="}",o=U(n.trim()),r&&r.nodes.push(o),i.push(r),r=o,n="",o=null;else if(f===F&&c[c.length-1]!==")"){if(c==="")throw new Error("Missing opening {");if(c=c.slice(0,-1),n.length>0)if(n.charCodeAt(0)===L)o=S(n),r?r.nodes.push(o):t.push(o),n="",o=null;else{let m=n.indexOf(":");if(r){let d=n.indexOf("!important",m+1);r.nodes.push({kind:"declaration",property:n.slice(0,m).trim(),value:n.slice(m+1,d===-1?n.length:d).trim(),important:d!==-1})}}let u=i.pop()??null;u===null&&r&&t.push(r),r=u,n="",o=null}else if(f===M)c+=")",n+="(";else if(f===V){if(c[c.length-1]!==")")throw new Error("Missing opening (");c=c.slice(0,-1),n+=")"}else{if(n.length===0&&(f===v||f===x||f===D))continue;n+=String.fromCharCode(f)}}}if(n.charCodeAt(0)===L&&t.push(S(n)),c.length>0&&r){if(r.kind==="rule")throw new Error(`Missing closing } at ${r.selector}`);if(r.kind==="at-rule")throw new Error(`Missing closing } at ${r.name} ${r.params}`)}return s.length>0?s.concat(t):t}function S(e,t=[]){for(let s=5;s<e.length;s++){let i=e.charCodeAt(s);if(i===v||i===M){let r=e.slice(0,s).trim(),o=e.slice(s).trim();return E(r,o,t)}}return E(e.trim(),"",t)}function ee(e,t=e.indexOf(":")){let s=e.indexOf("!important",t+1);return{kind:"declaration",property:e.slice(0,t).trim(),value:e.slice(t+1,s===-1?e.length:s).trim(),important:s!==-1}}var Ie=64;function Oe(e,t=[]){return{kind:"rule",selector:e,nodes:t}}function E(e,t="",s=[]){return{kind:"at-rule",name:e,params:t,nodes:s}}function U(e,t=[]){return e.charCodeAt(0)===Ie?S(e,t):Oe(e,t)}function se(e,t){return{kind:"declaration",property:e,value:t,important:!1}}function re(e){return{kind:"comment",value:e}}function T(e,t,s=[],i={}){for(let r=0;r<e.length;r++){let o=e[r],n=[...s,o],c=s.at(-1)??null;if(o.kind==="context"){T(o.nodes,t,s,{...i,...o.context});continue}let a=t(o,{parent:c,context:i,path:n,replaceWith(l){e.splice(r,1,...Array.isArray(l)?l:[l]),r--}})??0;if(a===2)return;a!==1&&(o.kind==="rule"||o.kind==="at-rule")&&T(o.nodes,t,n,i)}}function ne(e){let t="",s=new Set,i=[],r=[];function o(l,f=0){let u="",m=" ".repeat(f);if(l.kind==="rule"){u+=`${m}${l.selector} {
|
|
4
|
+
`;for(let d of l.nodes)u+=o(d,f+1);u+=`${m}}
|
|
5
5
|
`}else if(l.kind==="at-rule"){if(l.nodes.length===0)return`${m}${l.name} ${l.params};
|
|
6
|
-
`;if(l.name==="@property"&&
|
|
7
|
-
`;for(let d of l.nodes)
|
|
8
|
-
`}else if(l.kind==="comment")
|
|
9
|
-
`;else if(l.kind==="context")for(let d of l.nodes)
|
|
10
|
-
`);return
|
|
6
|
+
`;if(l.name==="@property"&&f===0){if(s.has(l.params))return"";let d=l.params,A=null,p=!1;for(let g of l.nodes)g.kind==="declaration"&&(g.property==="initial-value"?A=g.value:g.property==="inherits"&&(p=g.value==="true"));p?i.push(se(d,A??"initial")):r.push(se(d,A??"initial")),s.add(l.params)}u+=`${m}${l.name}${l.params?` ${l.params} `:" "}{
|
|
7
|
+
`;for(let d of l.nodes)u+=o(d,f+1);u+=`${m}}
|
|
8
|
+
`}else if(l.kind==="comment")u+=`${m}/*${l.value}*/
|
|
9
|
+
`;else if(l.kind==="context")for(let d of l.nodes)u+=o(d,f);else if(l.kind==="at-root"){for(let d of l.nodes)t+=o(d,0);return u}else l.property!=="--tw-sort"&&l.value!==void 0&&l.value!==null&&(u+=`${m}${l.property}: ${l.value}${l.important?" !important":""};
|
|
10
|
+
`);return u}let n="";for(let l of e){let f=o(l);f!==""&&(n+=f)}let c=[];i.length&&c.push(U(":root",i)),r.length&&c.push(U("*, ::before, ::after, ::backdrop",r));let a="";return c.length&&(a=o(E("@supports","(-moz-orient: inline)",[E("@layer","base",c)]))),`${n}${a}${t}`}function Fe(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var i="";if(s>4&&e[3]==="\\"){var r=e[2];(r==="?"||r===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),i="//")}var o=e.split(/[/\\]+/);return t!==!1&&o[o.length-1]===""&&o.pop(),i+o.join("/")}function b(e){let t=Fe(e);return e.startsWith("\\\\")&&t.startsWith("/")&&!t.startsWith("//")?`/${t}`:t}var W=/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/,ie=/(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/,Le=/(?:gradient|element|cross-fade|image)\(/,Me=/^\s*data:/i,Be=/^([a-z]+:)?\/\//,We=/^[A-Z_][.\w-]*\(/i,ze=/(?:^|\s)(?<url>[\w-]+\([^)]*\)|"[^"]*"|'[^']*'|[^,]\S*[^,])\s*(?:\s(?<descriptor>\w[^,]+))?(?:,|$)/g,Ge=/(?<!\\)"/g,Ke=/(?: |\\t|\\n|\\f|\\r)+/g,Je=e=>Me.test(e),qe=e=>Be.test(e);async function oe({css:e,base:t,root:s}){if(!e.includes("url(")&&!e.includes("image-set("))return e;let i=te(e),r=[];function o(n){let c=B.posix.join(b(t),n),a=B.posix.relative(b(s),c);return a.startsWith(".")||(a="./"+a),a}return T(i,n=>{if(n.kind!=="declaration"||!n.value)return;let c=W.test(n.value),a=ie.test(n.value);if(c||a){let l=a?He:le;r.push(l(n.value,o).then(f=>{n.value=f}))}}),r.length&&await Promise.all(r),ne(i)}function le(e,t){return ce(e,W,async s=>{let[i,r]=s;return await ae(r.trim(),i,t)})}async function He(e,t){return await ce(e,ie,async s=>{let[,i]=s;return await Ye(i,async({url:o})=>W.test(o)?await le(o,t):Le.test(o)?o:await ae(o,o,t))})}async function ae(e,t,s,i="url"){let r="",o=e[0];if((o==='"'||o==="'")&&(r=o,e=e.slice(1,-1)),Qe(e))return t;let n=await s(e);return r===""&&n!==encodeURI(n)&&(r='"'),r==="'"&&n.includes("'")&&(r='"'),r==='"'&&n.includes('"')&&(n=n.replace(Ge,'\\"')),`${i}(${r}${n}${r})`}function Qe(e){return qe(e)||Je(e)||e[0]==="#"||We.test(e)}function Ye(e,t){return Promise.all(Xe(e).map(async({url:s,descriptor:i})=>({url:await t({url:s,descriptor:i}),descriptor:i}))).then(Ve)}function Xe(e){let t=e.trim().replace(Ke," ").replace(/\r?\n/,"").replace(/,\s+/,", ").replaceAll(/\s+/g," ").matchAll(ze);return Array.from(t,({groups:s})=>({url:s?.url?.trim()??"",descriptor:s?.descriptor?.trim()??""})).filter(({url:s})=>!!s)}function Ve(e){return e.map(({url:t,descriptor:s})=>t+(s?` ${s}`:"")).join(", ")}async function ce(e,t,s){let i,r=e,o="";for(;i=t.exec(r);)o+=r.slice(0,i.index),o+=await s(i),r=r.slice(i.index+i[0].length);return o+=r,o}var it={};async function Ze(e,{base:t,onDependency:s,shouldRewriteUrls:i,customCssResolver:r,customJsResolver:o}){let n=await(0,I.compile)(e,{base:t,async loadModule(c,a){return J(c,a,s,o)},async loadStylesheet(c,a){let l=await pe(c,a,s,r);return i&&(l.content=await oe({css:l.content,root:a,base:l.base})),l}});if(n.root&&n.root!=="none"){let c=/[*{]/,a=[];for(let f of n.root.pattern.split("/")){if(c.test(f))break;a.push(f)}if(!await K.default.stat(R.default.resolve(t,a.join("/"))).then(f=>f.isDirectory()).catch(()=>!1))throw new Error(`The \`source(${n.root.pattern})\` does not exist`)}return n}async function et(e,{base:t}){return(0,I.__unstable__loadDesignSystem)(e,{base:t,async loadModule(s,i){return J(s,i,()=>{})},async loadStylesheet(s,i){return pe(s,i,()=>{})}})}async function J(e,t,s,i){if(e[0]!=="."){let c=await me(e,t,i);if(!c)throw new Error(`Could not resolve '${e}' from '${t}'`);let a=await ue((0,z.pathToFileURL)(c).href);return{base:(0,R.dirname)(c),module:a.default??a}}let r=await me(e,t,i);if(!r)throw new Error(`Could not resolve '${e}' from '${t}'`);let[o,n]=await Promise.all([ue((0,z.pathToFileURL)(r).href+"?id="+Date.now()),Y(r)]);for(let c of n)s(c);return{base:(0,R.dirname)(r),module:o.default??o}}async function pe(e,t,s,i){let r=await rt(e,t,i);if(!r)throw new Error(`Could not resolve '${e}' from '${t}'`);if(s(r),typeof globalThis.__tw_readFile=="function"){let n=await globalThis.__tw_readFile(r,"utf-8");if(n)return{base:R.default.dirname(r),content:n}}let o=await K.default.readFile(r,"utf-8");return{base:R.default.dirname(r),content:o}}var fe=null;async function ue(e){if(typeof globalThis.__tw_load=="function"){let t=await globalThis.__tw_load(e);if(t)return t}try{return await import(e)}catch{return fe??=(0,de.createJiti)(it.url,{moduleCache:!1,fsCache:!1}),await fe.import(e)}}var tt=y.default.ResolverFactory.createResolver({fileSystem:new y.default.CachedInputFileSystem(j.default,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});async function rt(e,t,s){if(typeof globalThis.__tw_resolve=="function"){let i=globalThis.__tw_resolve(e,t);if(i)return Promise.resolve(i)}if(s){let i=await s(e,t);if(i)return i}return G(tt,e,t)}var st=y.default.ResolverFactory.createResolver({fileSystem:new y.default.CachedInputFileSystem(j.default,4e3),useSyncFileSystemCalls:!0,extensions:[".js",".json",".node",".ts"],conditionNames:["node","import"]}),nt=y.default.ResolverFactory.createResolver({fileSystem:new y.default.CachedInputFileSystem(j.default,4e3),useSyncFileSystemCalls:!0,extensions:[".js",".json",".node",".ts"],conditionNames:["node","require"]});async function me(e,t,s){if(typeof globalThis.__tw_resolve=="function"){let i=globalThis.__tw_resolve(e,t);if(i)return Promise.resolve(i)}if(s){let i=await s(e,t);if(i)return i}return G(st,e,t).catch(()=>G(nt,e,t))}function G(e,t,s){return new Promise((i,r)=>e.resolve({},s,t,{},(o,n)=>{if(o)return r(o);i(n)}))}process.versions.bun||ge.register?.((0,he.pathToFileURL)(require.resolve("@tailwindcss/node/esm-cache-loader")));0&&(module.exports={__unstable__loadDesignSystem,compile,env,loadModule,normalizePath});
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var ue=Object.defineProperty;var me=(e,t)=>{for(var
|
|
1
|
+
var ue=Object.defineProperty;var me=(e,t)=>{for(var s in t)ue(e,s,{get:t[s],enumerable:!0})};import*as D from"node:module";import{pathToFileURL as Ve}from"node:url";var B={};me(B,{DEBUG:()=>de});var de=pe(process.env.DEBUG);function pe(e){if(e===void 0)return!1;if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;if(e==="*")return!0;let t=e.split(",").map(s=>s.split(":")[0]);return t.includes("-tailwindcss")?!1:!!t.includes("tailwindcss")}import y from"enhanced-resolve";import{createJiti as ze}from"jiti";import M from"node:fs";import ae from"node:fs/promises";import F,{dirname as se}from"node:path";import{pathToFileURL as ne}from"node:url";import{__unstable__loadDesignSystem as Ge,compile as Ke}from"tailwindcss";import P from"node:fs/promises";import R from"node:path";var ge=[/import[\s\S]*?['"](.{3,}?)['"]/gi,/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi,/export[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi,/require\(['"`](.+)['"`]\)/gi],he=[".js",".cjs",".mjs"],xe=["",".js",".cjs",".mjs",".ts",".cts",".mts",".jsx",".tsx"],ye=["",".ts",".cts",".mts",".tsx",".js",".cjs",".mjs",".jsx"];async function Re(e,t){for(let s of t){let o=`${e}${s}`;if((await P.stat(o).catch(()=>null))?.isFile())return o}for(let s of t){let o=`${e}/index${s}`;if(await P.access(o).then(()=>!0,()=>!1))return o}return null}async function W(e,t,s,o){let r=he.includes(o)?xe:ye,i=await Re(R.resolve(s,t),r);if(i===null||e.has(i))return;e.add(i),s=R.dirname(i),o=R.extname(i);let n=await P.readFile(i,"utf-8"),c=[];for(let a of ge)for(let l of n.matchAll(a))l[1].startsWith(".")&&c.push(W(e,l[1],s,o));await Promise.all(c)}async function z(e){let t=new Set;return await W(t,e,R.dirname(e),R.extname(e)),Array.from(t)}import*as I from"node:path";var A=92,v=47,E=42,Ae=34,we=39,Ce=58,_=59,h=10,w=32,N=9,G=123,U=125,b=40,K=41,Se=91,ve=93,J=45,T=64,Ee=33;function H(e){e=e.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
|
-
`);let t=[],
|
|
4
|
-
`;for(let d of l.nodes)
|
|
3
|
+
`);let t=[],s=[],o=[],r=null,i=null,n="",c="",a;for(let l=0;l<e.length;l++){let f=e.charCodeAt(l);if(f===A)n+=e.slice(l,l+2),l+=1;else if(f===v&&e.charCodeAt(l+1)===E){let u=l;for(let d=l+2;d<e.length;d++)if(a=e.charCodeAt(d),a===A)d+=1;else if(a===E&&e.charCodeAt(d+1)===v){l=d+1;break}let m=e.slice(u,l+1);m.charCodeAt(2)===Ee&&s.push(Q(m.slice(2,-2)))}else if(f===we||f===Ae){let u=l;for(let m=l+1;m<e.length;m++)if(a=e.charCodeAt(m),a===A)m+=1;else if(a===f){l=m;break}else{if(a===_&&e.charCodeAt(m+1)===h)throw new Error(`Unterminated string: ${e.slice(u,m+1)+String.fromCharCode(f)}`);if(a===h)throw new Error(`Unterminated string: ${e.slice(u,m)+String.fromCharCode(f)}`)}n+=e.slice(u,l+1)}else{if((f===w||f===h||f===N)&&(a=e.charCodeAt(l+1))&&(a===w||a===h||a===N))continue;if(f===h){if(n.length===0)continue;a=n.charCodeAt(n.length-1),a!==w&&a!==h&&a!==N&&(n+=" ")}else if(f===J&&e.charCodeAt(l+1)===J&&n.length===0){let u="",m=l,d=-1;for(let p=l+2;p<e.length;p++)if(a=e.charCodeAt(p),a===A)p+=1;else if(a===v&&e.charCodeAt(p+1)===E){for(let g=p+2;g<e.length;g++)if(a=e.charCodeAt(g),a===A)g+=1;else if(a===E&&e.charCodeAt(g+1)===v){p=g+1;break}}else if(d===-1&&a===Ce)d=n.length+p-m;else if(a===_&&u.length===0){n+=e.slice(m,p),l=p;break}else if(a===b)u+=")";else if(a===Se)u+="]";else if(a===G)u+="}";else if((a===U||e.length-1===p)&&u.length===0){l=p-1,n+=e.slice(m,p);break}else(a===K||a===ve||a===U)&&u.length>0&&e[p]===u[u.length-1]&&(u=u.slice(0,-1));let x=q(n,d);r?r.nodes.push(x):t.push(x),n=""}else if(f===_&&n.charCodeAt(0)===T)i=C(n),r?r.nodes.push(i):t.push(i),n="",i=null;else if(f===_&&c[c.length-1]!==")"){let u=q(n);r?r.nodes.push(u):t.push(u),n=""}else if(f===G&&c[c.length-1]!==")")c+="}",i=k(n.trim()),r&&r.nodes.push(i),o.push(r),r=i,n="",i=null;else if(f===U&&c[c.length-1]!==")"){if(c==="")throw new Error("Missing opening {");if(c=c.slice(0,-1),n.length>0)if(n.charCodeAt(0)===T)i=C(n),r?r.nodes.push(i):t.push(i),n="",i=null;else{let m=n.indexOf(":");if(r){let d=n.indexOf("!important",m+1);r.nodes.push({kind:"declaration",property:n.slice(0,m).trim(),value:n.slice(m+1,d===-1?n.length:d).trim(),important:d!==-1})}}let u=o.pop()??null;u===null&&r&&t.push(r),r=u,n="",i=null}else if(f===b)c+=")",n+="(";else if(f===K){if(c[c.length-1]!==")")throw new Error("Missing opening (");c=c.slice(0,-1),n+=")"}else{if(n.length===0&&(f===w||f===h||f===N))continue;n+=String.fromCharCode(f)}}}if(n.charCodeAt(0)===T&&t.push(C(n)),c.length>0&&r){if(r.kind==="rule")throw new Error(`Missing closing } at ${r.selector}`);if(r.kind==="at-rule")throw new Error(`Missing closing } at ${r.name} ${r.params}`)}return s.length>0?s.concat(t):t}function C(e,t=[]){for(let s=5;s<e.length;s++){let o=e.charCodeAt(s);if(o===w||o===b){let r=e.slice(0,s).trim(),i=e.slice(s).trim();return S(r,i,t)}}return S(e.trim(),"",t)}function q(e,t=e.indexOf(":")){let s=e.indexOf("!important",t+1);return{kind:"declaration",property:e.slice(0,t).trim(),value:e.slice(t+1,s===-1?e.length:s).trim(),important:s!==-1}}var _e=64;function Ne(e,t=[]){return{kind:"rule",selector:e,nodes:t}}function S(e,t="",s=[]){return{kind:"at-rule",name:e,params:t,nodes:s}}function k(e,t=[]){return e.charCodeAt(0)===_e?C(e,t):Ne(e,t)}function Y(e,t){return{kind:"declaration",property:e,value:t,important:!1}}function Q(e){return{kind:"comment",value:e}}function $(e,t,s=[],o={}){for(let r=0;r<e.length;r++){let i=e[r],n=[...s,i],c=s.at(-1)??null;if(i.kind==="context"){$(i.nodes,t,s,{...o,...i.context});continue}let a=t(i,{parent:c,context:o,path:n,replaceWith(l){e.splice(r,1,...Array.isArray(l)?l:[l]),r--}})??0;if(a===2)return;a!==1&&(i.kind==="rule"||i.kind==="at-rule")&&$(i.nodes,t,n,o)}}function X(e){let t="",s=new Set,o=[],r=[];function i(l,f=0){let u="",m=" ".repeat(f);if(l.kind==="rule"){u+=`${m}${l.selector} {
|
|
4
|
+
`;for(let d of l.nodes)u+=i(d,f+1);u+=`${m}}
|
|
5
5
|
`}else if(l.kind==="at-rule"){if(l.nodes.length===0)return`${m}${l.name} ${l.params};
|
|
6
|
-
`;if(l.name==="@property"&&
|
|
7
|
-
`;for(let d of l.nodes)
|
|
8
|
-
`}else if(l.kind==="comment")
|
|
9
|
-
`;else if(l.kind==="context")for(let d of l.nodes)
|
|
10
|
-
`);return
|
|
6
|
+
`;if(l.name==="@property"&&f===0){if(s.has(l.params))return"";let d=l.params,x=null,p=!1;for(let g of l.nodes)g.kind==="declaration"&&(g.property==="initial-value"?x=g.value:g.property==="inherits"&&(p=g.value==="true"));p?o.push(Y(d,x??"initial")):r.push(Y(d,x??"initial")),s.add(l.params)}u+=`${m}${l.name}${l.params?` ${l.params} `:" "}{
|
|
7
|
+
`;for(let d of l.nodes)u+=i(d,f+1);u+=`${m}}
|
|
8
|
+
`}else if(l.kind==="comment")u+=`${m}/*${l.value}*/
|
|
9
|
+
`;else if(l.kind==="context")for(let d of l.nodes)u+=i(d,f);else if(l.kind==="at-root"){for(let d of l.nodes)t+=i(d,0);return u}else l.property!=="--tw-sort"&&l.value!==void 0&&l.value!==null&&(u+=`${m}${l.property}: ${l.value}${l.important?" !important":""};
|
|
10
|
+
`);return u}let n="";for(let l of e){let f=i(l);f!==""&&(n+=f)}let c=[];o.length&&c.push(k(":root",o)),r.length&&c.push(k("*, ::before, ::after, ::backdrop",r));let a="";return c.length&&(a=i(S("@supports","(-moz-orient: inline)",[S("@layer","base",c)]))),`${n}${a}${t}`}function ke(e,t){if(typeof e!="string")throw new TypeError("expected path to be a string");if(e==="\\"||e==="/")return"/";var s=e.length;if(s<=1)return e;var o="";if(s>4&&e[3]==="\\"){var r=e[2];(r==="?"||r===".")&&e.slice(0,2)==="\\\\"&&(e=e.slice(2),o="//")}var i=e.split(/[/\\]+/);return t!==!1&&i[i.length-1]===""&&i.pop(),o+i.join("/")}function j(e){let t=ke(e);return e.startsWith("\\\\")&&t.startsWith("/")&&!t.startsWith("//")?`/${t}`:t}var O=/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/,V=/(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/,$e=/(?:gradient|element|cross-fade|image)\(/,De=/^\s*data:/i,Pe=/^([a-z]+:)?\/\//,Ue=/^[A-Z_][.\w-]*\(/i,Te=/(?:^|\s)(?<url>[\w-]+\([^)]*\)|"[^"]*"|'[^']*'|[^,]\S*[^,])\s*(?:\s(?<descriptor>\w[^,]+))?(?:,|$)/g,be=/(?<!\\)"/g,je=/(?: |\\t|\\n|\\f|\\r)+/g,Ie=e=>De.test(e),Oe=e=>Pe.test(e);async function Z({css:e,base:t,root:s}){if(!e.includes("url(")&&!e.includes("image-set("))return e;let o=H(e),r=[];function i(n){let c=I.posix.join(j(t),n),a=I.posix.relative(j(s),c);return a.startsWith(".")||(a="./"+a),a}return $(o,n=>{if(n.kind!=="declaration"||!n.value)return;let c=O.test(n.value),a=V.test(n.value);if(c||a){let l=a?Fe:ee;r.push(l(n.value,i).then(f=>{n.value=f}))}}),r.length&&await Promise.all(r),X(o)}function ee(e,t){return re(e,O,async s=>{let[o,r]=s;return await te(r.trim(),o,t)})}async function Fe(e,t){return await re(e,V,async s=>{let[,o]=s;return await Me(o,async({url:i})=>O.test(i)?await ee(i,t):$e.test(i)?i:await te(i,i,t))})}async function te(e,t,s,o="url"){let r="",i=e[0];if((i==='"'||i==="'")&&(r=i,e=e.slice(1,-1)),Le(e))return t;let n=await s(e);return r===""&&n!==encodeURI(n)&&(r='"'),r==="'"&&n.includes("'")&&(r='"'),r==='"'&&n.includes('"')&&(n=n.replace(be,'\\"')),`${o}(${r}${n}${r})`}function Le(e){return Oe(e)||Ie(e)||e[0]==="#"||Ue.test(e)}function Me(e,t){return Promise.all(Be(e).map(async({url:s,descriptor:o})=>({url:await t({url:s,descriptor:o}),descriptor:o}))).then(We)}function Be(e){let t=e.trim().replace(je," ").replace(/\r?\n/,"").replace(/,\s+/,", ").replaceAll(/\s+/g," ").matchAll(Te);return Array.from(t,({groups:s})=>({url:s?.url?.trim()??"",descriptor:s?.descriptor?.trim()??""})).filter(({url:s})=>!!s)}function We(e){return e.map(({url:t,descriptor:s})=>t+(s?` ${s}`:"")).join(", ")}async function re(e,t,s){let o,r=e,i="";for(;o=t.exec(r);)i+=r.slice(0,o.index),i+=await s(o),r=r.slice(o.index+o[0].length);return i+=r,i}async function Je(e,{base:t,onDependency:s,shouldRewriteUrls:o,customCssResolver:r,customJsResolver:i}){let n=await Ke(e,{base:t,async loadModule(c,a){return ce(c,a,s,i)},async loadStylesheet(c,a){let l=await fe(c,a,s,r);return o&&(l.content=await Z({css:l.content,root:a,base:l.base})),l}});if(n.root&&n.root!=="none"){let c=/[*{]/,a=[];for(let f of n.root.pattern.split("/")){if(c.test(f))break;a.push(f)}if(!await ae.stat(F.resolve(t,a.join("/"))).then(f=>f.isDirectory()).catch(()=>!1))throw new Error(`The \`source(${n.root.pattern})\` does not exist`)}return n}async function qe(e,{base:t}){return Ge(e,{base:t,async loadModule(s,o){return ce(s,o,()=>{})},async loadStylesheet(s,o){return fe(s,o,()=>{})}})}async function ce(e,t,s,o){if(e[0]!=="."){let c=await le(e,t,o);if(!c)throw new Error(`Could not resolve '${e}' from '${t}'`);let a=await oe(ne(c).href);return{base:se(c),module:a.default??a}}let r=await le(e,t,o);if(!r)throw new Error(`Could not resolve '${e}' from '${t}'`);let[i,n]=await Promise.all([oe(ne(r).href+"?id="+Date.now()),z(r)]);for(let c of n)s(c);return{base:se(r),module:i.default??i}}async function fe(e,t,s,o){let r=await Qe(e,t,o);if(!r)throw new Error(`Could not resolve '${e}' from '${t}'`);if(s(r),typeof globalThis.__tw_readFile=="function"){let n=await globalThis.__tw_readFile(r,"utf-8");if(n)return{base:F.dirname(r),content:n}}let i=await ae.readFile(r,"utf-8");return{base:F.dirname(r),content:i}}var ie=null;async function oe(e){if(typeof globalThis.__tw_load=="function"){let t=await globalThis.__tw_load(e);if(t)return t}try{return await import(e)}catch{return ie??=ze(import.meta.url,{moduleCache:!1,fsCache:!1}),await ie.import(e)}}var He=y.ResolverFactory.createResolver({fileSystem:new y.CachedInputFileSystem(M,4e3),useSyncFileSystemCalls:!0,extensions:[".css"],mainFields:["style"],conditionNames:["style"]});async function Qe(e,t,s){if(typeof globalThis.__tw_resolve=="function"){let o=globalThis.__tw_resolve(e,t);if(o)return Promise.resolve(o)}if(s){let o=await s(e,t);if(o)return o}return L(He,e,t)}var Ye=y.ResolverFactory.createResolver({fileSystem:new y.CachedInputFileSystem(M,4e3),useSyncFileSystemCalls:!0,extensions:[".js",".json",".node",".ts"],conditionNames:["node","import"]}),Xe=y.ResolverFactory.createResolver({fileSystem:new y.CachedInputFileSystem(M,4e3),useSyncFileSystemCalls:!0,extensions:[".js",".json",".node",".ts"],conditionNames:["node","require"]});async function le(e,t,s){if(typeof globalThis.__tw_resolve=="function"){let o=globalThis.__tw_resolve(e,t);if(o)return Promise.resolve(o)}if(s){let o=await s(e,t);if(o)return o}return L(Ye,e,t).catch(()=>L(Xe,e,t))}function L(e,t,s){return new Promise((o,r)=>e.resolve({},s,t,{},(i,n)=>{if(i)return r(i);o(n)}))}if(!process.versions.bun){let e=D.createRequire(import.meta.url);D.register?.(Ve(e.resolve("@tailwindcss/node/esm-cache-loader")))}export{qe as __unstable__loadDesignSystem,Je as compile,B as env,j as normalizePath};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/node",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"enhanced-resolve": "^5.17.1",
|
|
37
37
|
"jiti": "^2.4.0",
|
|
38
|
-
"tailwindcss": "4.0.0-beta.
|
|
38
|
+
"tailwindcss": "4.0.0-beta.3"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup-node",
|