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