@longzai-intelligence-builder/css 0.2.22 → 0.2.23

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.
Files changed (2) hide show
  1. package/dist/index.mjs +4 -4
  2. package/package.json +8 -5
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import"node:module";import{expandBaselineTarget as e,importWithError as t,resolveComma as n,toArray as r}from"@longzai-intelligence-builder/core";import{readFile as i}from"node:fs/promises";import a from"node:path";import{readFileSync as o}from"node:fs";import{fileURLToPath as s,pathToFileURL as c}from"node:url";import{ResolverFactory as l}from"rolldown/experimental";const u=`style.css`;function d(t={},i,a){let o;return o=t.target===!1?void 0:t.target==null?i:e(n(r(t.target))),{transformer:t.transformer??`lightningcss`,splitting:t.splitting??!!a,fileName:t.fileName??`style.css`,minify:t.minify??!1,inject:t.inject??!1,modules:t.modules===!1?!1:t.modules??{},target:o,preprocessorOptions:t.preprocessorOptions,lightningcss:t.lightningcss,postcss:t.postcss}}function f(e){let t=[],n=0;for(let[r,i]of Object.entries(e)){if(r==="default")continue;let e=`_key${n++}`;t.push(`const ${e} = ${JSON.stringify(i)};`,`export { ${e} as ${JSON.stringify(r)} };`)}return t.push(`export default ${JSON.stringify(e)};`),t.join(`
2
- `)}function p(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function m(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=p(r);switch(t){case`camelCase`:n[r]=i,e!==r&&(n[e]=i);break;case`camelCaseOnly`:n[e]=i;break;case`dashes`:n[r]=i,r.includes(`-`)&&(n[e]=i);break;case`dashesOnly`:r.includes(`-`)?n[e]=i:n[r]=i}}return n}function h(e){let t={},n=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t));for(let[e,r]of n){let n=r.name;for(let e of r.composes)n+=` ${e.name}`;t[e]=n}return t}let g,ee;function _(){return g??=new l({conditionNames:[`style`,`default`]})}function v(){return ee??=new l({conditionNames:[`sass`,`style`,`default`],mainFields:[`sass`,`style`,`main`],extensions:[`.scss`,`.sass`,`.css`]})}function y(e,t,n){let r=a.dirname(n),i=e.sync(r,t);if(!i.error&&i.path)return i.path}const te=/\.css$/,b=/[?&]inline\b/,x=/\.(css|less|sass|scss|styl|stylus)(?:$|\?)/,S=/\.(?:css|less|sass|scss|styl|stylus)\?(?:.*&)?inline\b/,C=/\.module\.(?:css|less|sass|scss|styl|stylus)(?:$|\?)/;function w(e){return e.replace(/(?:\.module)?(\.[cm]?js)$/,`.css`)}function T(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}const E={sass:`sass`,less:`less`,scss:`scss`,styl:`styl`,stylus:`stylus`};function D(e){let t=a.extname(e).slice(1);return E[t]}function O(e){let t=x.exec(e);if(t)return E[t[1]]}function k(e,t,n,r){switch(e){case`scss`:case`sass`:return R(e,t,n,r);case`less`:return G(t,n,r);case`styl`:case`stylus`:return ue(t,n,r)}}const A=/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uFFFF])url\((\s*('[^']+'|"[^"]+")\s*|(?:\\.|[^'")\\])+)\)/,j=/(?<=^|[^\w\-\u0080-\uFFFF])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/,M=/@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/;async function ne(e,t,n){e=a.resolve(e);let r=a.dirname(e),o=a.dirname(t);if(r===o)return{file:e};let s=await i(e,`utf8`),c=A.test(s),l=j.test(s),u=M.test(s);if(!c&&!l&&!u)return{file:e};let d,f=(e,t)=>{if(n?.(e,t))return!1;if(e[0]===`/`)return e;let i=a.resolve(r,e);return I(a.relative(o,i))};return u&&(d=await ae(s,f)),c&&(d=await re(d||s,f)),l&&(d=await ie(d||s,f)),{file:e,contents:d}}async function N(e,t,n){let r,i=e,a=``;for(;r=t.exec(i);)a+=i.slice(0,r.index),a+=await n(r),i=i.slice(r.index+r[0].length);return a+=i,a}function re(e,t){return N(e,A,async e=>{let[n,r]=e;return await P(r.trim(),n,t)})}function ie(e,t){return N(e,j,async e=>{let[n,r]=e;return await P(r.trim(),n,t,`data-uri`)})}function ae(e,t){return N(e,M,async e=>{let[n,r]=e;return await F(r,n,t)})}const oe=/^(?:[a-z]+:)?\/\//,se=/^\s*data:/i;function ce(e){return oe.test(e)||se.test(e)||e[0]===`#`}async function P(e,t,n,r=`url`){let i=``,a=e[0];if((a===`"`||a===`'`)&&(i=a,e=e.slice(1,-1)),ce(e))return t;let o=await n(e,t);return typeof o==`string`?(i===``&&o!==encodeURI(o)&&(i=`"`),`${r}(${i}${o}${i})`):t}async function F(e,t,n){let r=``,i=e[0];(i===`"`||i===`'`)&&(r=i,e=e.slice(1,-1));let a=await n(e,t);return typeof a==`string`?t.replace(`${r}${e}${r}`,`${r}${a}${r}`):t}function I(e){return e.replaceAll(`\\`,`/`)}async function L(e,t,n,r=``){if(!n)return e;if(typeof n==`function`){let r=await n(e,t);return typeof r==`string`?r:r.content}return n+r+e}async function R(e,t,n,r){let o=await W(),l=r?.scss??r?.sass??{},u=await L(t,n,l.additionalData),{additionalData:d,...f}=l,p=(e,t)=>t[0]!==`"`&&t[0]!==`'`&&e[0]===`$`||e.startsWith(`#{`),m={async canonicalize(e,t){let r=await z(e,t.containingUrl?s(t.containingUrl):n);return r?c(r):null},async load(e){let t=a.extname(e.pathname),r=`scss`;t===`.sass`?r=`indented`:t===`.css`&&(r=`css`);let o=await ne(s(e),n,p);return{contents:o.contents??await i(o.file,`utf8`),syntax:r,sourceMapUrl:e}}},h=await(await H(o)).compileStringAsync(u,{url:c(n),sourceMap:!1,syntax:e===`sass`?`indented`:`scss`,...f,importers:[m,...f.importers??[]]});return{code:h.css,deps:h.loadedUrls.filter(e=>e.protocol===`file:`).map(e=>s(e))}}async function z(e,t){let n=a.dirname(t),{existsSync:r}=await import(`node:fs`),i=[`.scss`,`.sass`,`.css`],o=[``,`_`];if(i.some(t=>e.endsWith(t)))for(let t of o){let i=a.resolve(n,a.dirname(e),t+a.basename(e));if(r(i))return i}else{for(let t of i)for(let i of o){let o=a.resolve(n,a.dirname(e),i+a.basename(e)+t);if(r(o))return o}for(let t of i)for(let i of o){let o=a.resolve(n,e,`${i}index${t}`);if(r(o))return o}}return y(v(),e,t)}let B,V;function H(e){return e.initAsyncCompiler?(V??=e.initAsyncCompiler().catch(e=>{throw V=void 0,e}),V):Promise.resolve(e)}async function U(){let e=V;V=void 0,await(await e?.catch(()=>void 0))?.dispose?.()}async function W(){if(B)return B;try{return B=await import(`sass-embedded`),B}catch{try{return B=await import(`sass`),B}catch{throw Error('Preprocessor dependency "sass" not found. Did you install it? Try `npm install -D sass`.')}}}async function G(e,t,n){let r=await le(),i=n?.less??{},a=await L(e,t,i.additionalData),{additionalData:o,plugins:s=[],...c}=i,l=await r.render(a,{paths:[`node_modules`],...c,filename:t,plugins:s});return{code:l.css,deps:l.imports||[]}}let K;async function le(){if(K)return K;try{return K=(await import(`less`)).default,K}catch{throw Error('Preprocessor dependency "less" not found. Did you install it? Try `npm install -D less`.')}}async function ue(e,t,n){let r=await de(),i=n?.styl??n?.stylus??{},a=await L(e,t,i.additionalData,`
3
- `),{additionalData:o,define:s,...c}=i,l=r(a,{paths:[`node_modules`],...c,filename:t});if(s)for(let e of Object.keys(s))l.define(e,s[e]);return new Promise((e,t)=>{l.render((n,r)=>{n?t(/* @__PURE__ */ Error(`[stylus] ${n.message}`)):e({code:r,deps:l.deps()})})})}let q;async function de(){if(q)return q;try{return q=(await import(`stylus`)).default,q}catch{throw Error('Preprocessor dependency "stylus" not found. Did you install it? Try `npm install -D stylus`.')}}const fe=new TextEncoder,J=new TextDecoder;async function Y(e,t,n){let r=n.lightningcss?.targets??(n.target?X(n.target):void 0);if(!r&&!n.lightningcss&&!n.minify&&!n.cssModules)return{code:e};let{transform:i}=await import(`lightningcss`),a=i({filename:t,code:fe.encode(e),...n.lightningcss,targets:r,minify:n.minify,cssModules:n.cssModules,sourceMap:n.sourceMap,inputSourceMap:n.inputSourceMap});return{code:J.decode(a.code),map:a.map?J.decode(a.map):void 0,modules:a.exports?h(a.exports):void 0}}async function pe(e,t,n){let r=t.lightningcss?.targets??(t.target?X(t.target):void 0),i=[],{bundleAsync:s}=await import(`lightningcss`),c=await s({filename:e,...t.lightningcss,targets:r,minify:t.minify,cssModules:t.cssModules,sourceMap:t.sourceMap,resolver:{async read(r){let a;a=n!=null&&r===e?n:o(r,`utf8`);let s=D(r);if(s){let e=await k(s,a,r,t.preprocessorOptions);return i.push(...e.deps),e.code}return a},resolve(e,n){return y(_(),e,n)||(t.logger.warn(`[@lzi-builder/css] Failed to resolve import '${e}' from '${n}'`),a.resolve(a.dirname(n),e))}}});return{code:J.decode(c.code),deps:i,map:c.map?J.decode(c.map):void 0,modules:c.exports?h(c.exports):void 0}}const me=/([a-z]+)(\d+(?:\.\d+)*)/g,he={chrome:`chrome`,edge:`edge`,firefox:`firefox`,ie:`ie`,ios:`ios_saf`,opera:`opera`,safari:`safari`};function ge(e){let[t,n=0,r=0]=e.split(`-`,1)[0].split(`.`).map(e=>Number.parseInt(e,10));return Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(r)?null:t<<16|n<<8|r}function X(e){let t,n=[...e.join(` `).toLowerCase().matchAll(me)];for(let e of n){let n=e[1],r=he[n];if(!r)continue;let i=e[2],a=ge(i);a!=null&&(t||={},t[r]=a)}return t}function _e(e,t){let n=[];for(let r of Object.values(e))r.type===`chunk`&&!r.exports.length&&r.moduleIds.length&&r.moduleIds.every(e=>t.has(e))&&n.push(r.fileName);let r=new Set(n);for(let i of Object.values(e))i.type!==`chunk`||i.exports.length||i.isEntry||i.isDynamicEntry||r.has(i.fileName)||i.moduleIds.some(e=>t.has(e))&&be(i.code)&&n.push(i.fileName);if(!n.length)return;let i=ve(n);for(let t of Object.values(e)){if(t.type!==`chunk`)continue;let e=!1;t.imports=t.imports.filter(t=>!n.includes(t)||(e=!0,!1)),e&&(t.code=i(t.code))}for(let t of n)delete e[t],delete e[`${t}.map`]}function ve(e){let t=e.map(e=>ye(a.basename(e))).join(`|`),n=new RegExp(String.raw`\bimport\s*["'][^"']*(?:${t})["'];`,`g`);return e=>e.replace(n,e=>`/* empty css ${``.padEnd(e.length-15)}*/`)}function ye(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function be(e){return!e.replaceAll(/\/\*[\s\S]*?\*\//g,``).replaceAll(/\/\/[^\n]*/g,``).replaceAll(/\bexport\s*\{\s*\};?/g,``).replaceAll(/\bimport\s*["'][^"']*["'];?/g,``).trim()}function xe(e,t){let n=[];async function r(t){if(!e.minify)return t;let n=(await Y(t,u,{target:e.target,lightningcss:e.lightningcss,minify:!0})).code;return n.length&&!n.endsWith(`
2
+ `)}function p(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function m(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=p(r);switch(t){case`camelCase`:n[r]=i,e!==r&&(n[e]=i);break;case`camelCaseOnly`:n[e]=i;break;case`dashes`:n[r]=i,r.includes(`-`)&&(n[e]=i);break;case`dashesOnly`:r.includes(`-`)?n[e]=i:n[r]=i}}return n}function h(e){let t={},n=Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t));for(let[e,r]of n){let n=r.name;for(let e of r.composes)n+=` ${e.name}`;t[e]=n}return t}let g,ee;function _(){return g??=new l({conditionNames:[`style`,`default`]})}function v(){return ee??=new l({conditionNames:[`sass`,`style`,`default`],mainFields:[`sass`,`style`,`main`],extensions:[`.scss`,`.sass`,`.css`]})}function y(e,t,n){let r=a.dirname(n),i=e.sync(r,t);if(!i.error&&i.path)return i.path}const te=/\.css$/,b=/[?&]inline\b/,x=/\.(css|less|sass|scss|styl|stylus)(?:$|\?)/,S=/\.(?:css|less|sass|scss|styl|stylus)\?(?:.*&)?inline\b/,C=/\.module\.(?:css|less|sass|scss|styl|stylus)(?:$|\?)/;function w(e){return e.replace(/(?:\.module)?(\.[cm]?js)$/,`.css`)}function T(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}const E={sass:`sass`,less:`less`,scss:`scss`,styl:`styl`,stylus:`stylus`};function D(e){let t=a.extname(e).slice(1);return E[t]}function O(e){let t=x.exec(e);if(!t)return;let n=t[1];if(n)return E[n]}function k(e,t,n,r){switch(e){case`scss`:case`sass`:return R(e,t,n,r);case`less`:return G(t,n,r);case`styl`:case`stylus`:return ue(t,n,r)}}const A=/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uFFFF])url\((\s*('[^']+'|"[^"]+")\s*|(?:\\.|[^'")\\])+)\)/,j=/(?<=^|[^\w\-\u0080-\uFFFF])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/,M=/@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/;async function ne(e,t,n){e=a.resolve(e);let r=a.dirname(e),o=a.dirname(t);if(r===o)return{file:e};let s=await i(e,`utf8`),c=A.test(s),l=j.test(s),u=M.test(s);if(!c&&!l&&!u)return{file:e};let d,f=(e,t)=>{if(n?.(e,t))return!1;if(e[0]===`/`)return e;let i=a.resolve(r,e);return I(a.relative(o,i))};return u&&(d=await ae(s,f)),c&&(d=await re(d||s,f)),l&&(d=await ie(d||s,f)),{file:e,contents:d}}async function N(e,t,n){let r,i=e,a=``;for(;r=t.exec(i);)a+=i.slice(0,r.index),a+=await n(r),i=i.slice(r.index+r[0].length);return a+=i,a}function re(e,t){return N(e,A,async e=>{let[n,r]=e;return r?await P(r.trim(),n,t):n})}function ie(e,t){return N(e,j,async e=>{let[n,r]=e;return r?await P(r.trim(),n,t,`data-uri`):n})}function ae(e,t){return N(e,M,async e=>{let[n,r]=e;return r?await F(r,n,t):n})}const oe=/^(?:[a-z]+:)?\/\//,se=/^\s*data:/i;function ce(e){return oe.test(e)||se.test(e)||e[0]===`#`}async function P(e,t,n,r=`url`){let i=``,a=e[0];if((a===`"`||a===`'`)&&(i=a,e=e.slice(1,-1)),ce(e))return t;let o=await n(e,t);return typeof o==`string`?(i===``&&o!==encodeURI(o)&&(i=`"`),`${r}(${i}${o}${i})`):t}async function F(e,t,n){let r=``,i=e[0];(i===`"`||i===`'`)&&(r=i,e=e.slice(1,-1));let a=await n(e,t);return typeof a==`string`?t.replace(`${r}${e}${r}`,`${r}${a}${r}`):t}function I(e){return e.replaceAll(`\\`,`/`)}async function L(e,t,n,r=``){if(!n)return e;if(typeof n==`function`){let r=await n(e,t);return typeof r==`string`?r:r.content}return n+r+e}async function R(e,t,n,r){let o=await W(),l=r?.scss??r?.sass??{},u=await L(t,n,l.additionalData),{additionalData:d,...f}=l,p=(e,t)=>t[0]!==`"`&&t[0]!==`'`&&e[0]===`$`||e.startsWith(`#{`),m={async canonicalize(e,t){let r=await z(e,t.containingUrl?s(t.containingUrl):n);return r?c(r):null},async load(e){let t=a.extname(e.pathname),r=`scss`;t===`.sass`?r=`indented`:t===`.css`&&(r=`css`);let o=await ne(s(e),n,p);return{contents:o.contents??await i(o.file,`utf8`),syntax:r,sourceMapUrl:e}}},h=await(await H(o)).compileStringAsync(u,{url:c(n),sourceMap:!1,syntax:e===`sass`?`indented`:`scss`,...f,importers:[m,...f.importers??[]]});return{code:h.css,deps:h.loadedUrls.filter(e=>e.protocol===`file:`).map(e=>s(e))}}async function z(e,t){let n=a.dirname(t),{existsSync:r}=await import(`node:fs`),i=[`.scss`,`.sass`,`.css`],o=[``,`_`];if(i.some(t=>e.endsWith(t)))for(let t of o){let i=a.resolve(n,a.dirname(e),t+a.basename(e));if(r(i))return i}else{for(let t of i)for(let i of o){let o=a.resolve(n,a.dirname(e),i+a.basename(e)+t);if(r(o))return o}for(let t of i)for(let i of o){let o=a.resolve(n,e,`${i}index${t}`);if(r(o))return o}}return y(v(),e,t)}let B,V;function H(e){return e.initAsyncCompiler?(V??=e.initAsyncCompiler().catch(e=>{throw V=void 0,e}),V):Promise.resolve(e)}async function U(){let e=V;V=void 0,await(await e?.catch(()=>void 0))?.dispose?.()}async function W(){if(B)return B;try{let e=await import(`sass-embedded`);return B=e,e}catch{try{let e=await import(`sass`);return B=e,e}catch{throw Error('Preprocessor dependency "sass" not found. Did you install it? Try `npm install -D sass`.')}}}async function G(e,t,n){let r=await le(),i=n?.less??{},a=await L(e,t,i.additionalData),{additionalData:o,plugins:s=[],...c}=i,l=await r.render(a,{paths:[`node_modules`],...c,filename:t,plugins:s});return{code:l.css,deps:l.imports||[]}}let K;async function le(){if(K)return K;try{return K=(await import(`less`)).default,K}catch{throw Error('Preprocessor dependency "less" not found. Did you install it? Try `npm install -D less`.')}}async function ue(e,t,n){let r=await de(),i=n?.styl??n?.stylus??{},a=await L(e,t,i.additionalData,`
3
+ `),{additionalData:o,define:s,...c}=i,l=r(a,{paths:[`node_modules`],...c,filename:t});if(s)for(let e of Object.keys(s))l.define(e,s[e]);return new Promise((e,t)=>{l.render((n,r)=>{n?t(/* @__PURE__ */ Error(`[stylus] ${n.message}`)):e({code:r,deps:l.deps()})})})}let q;async function de(){if(q)return q;try{return q=(await import(`stylus`)).default,q}catch{throw Error('Preprocessor dependency "stylus" not found. Did you install it? Try `npm install -D stylus`.')}}const fe=new TextEncoder,J=new TextDecoder;async function Y(e,t,n){let r=n.lightningcss?.targets??(n.target?X(n.target):void 0);if(!r&&!n.lightningcss&&!n.minify&&!n.cssModules)return{code:e};let{transform:i}=await import(`lightningcss`),a=i({filename:t,code:fe.encode(e),...n.lightningcss,targets:r,minify:n.minify,cssModules:n.cssModules,sourceMap:n.sourceMap,inputSourceMap:n.inputSourceMap});return{code:J.decode(a.code),map:a.map?J.decode(a.map):void 0,modules:a.exports?h(a.exports):void 0}}async function pe(e,t,n){let r=t.lightningcss?.targets??(t.target?X(t.target):void 0),i=[],{bundleAsync:s}=await import(`lightningcss`),c=await s({filename:e,...t.lightningcss,targets:r,minify:t.minify,cssModules:t.cssModules,sourceMap:t.sourceMap,resolver:{async read(r){let a;a=n!=null&&r===e?n:o(r,`utf8`);let s=D(r);if(s){let e=await k(s,a,r,t.preprocessorOptions);return i.push(...e.deps),e.code}return a},resolve(e,n){return y(_(),e,n)||(t.logger.warn(`[@lzi-builder/css] Failed to resolve import '${e}' from '${n}'`),a.resolve(a.dirname(n),e))}}});return{code:J.decode(c.code),deps:i,map:c.map?J.decode(c.map):void 0,modules:c.exports?h(c.exports):void 0}}const me=/([a-z]+)(\d+(?:\.\d+)*)/g,he={chrome:`chrome`,edge:`edge`,firefox:`firefox`,ie:`ie`,ios:`ios_saf`,opera:`opera`,safari:`safari`};function ge(e){let t=(e.split(`-`,1)[0]??``).split(`.`).map(e=>Number.parseInt(e,10)),n=t[0]??NaN,r=t[1]??0,i=t[2]??0;return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(i)?null:n<<16|r<<8|i}function X(e){let t,n=[...e.join(` `).toLowerCase().matchAll(me)];for(let e of n){let n=e[1];if(!n)continue;let r=he[n];if(!r)continue;let i=e[2];if(!i)continue;let a=ge(i);a!=null&&(t||={},t[r]=a)}return t}function _e(e,t){let n=[];for(let r of Object.values(e))r.type===`chunk`&&!r.exports.length&&r.moduleIds.length&&r.moduleIds.every(e=>t.has(e))&&n.push(r.fileName);let r=new Set(n);for(let i of Object.values(e))i.type!==`chunk`||i.exports.length||i.isEntry||i.isDynamicEntry||r.has(i.fileName)||i.moduleIds.some(e=>t.has(e))&&be(i.code)&&n.push(i.fileName);if(!n.length)return;let i=ve(n);for(let t of Object.values(e)){if(t.type!==`chunk`)continue;let e=!1;t.imports=t.imports.filter(t=>!n.includes(t)||(e=!0,!1)),e&&(t.code=i(t.code))}for(let t of n)delete e[t],delete e[`${t}.map`]}function ve(e){let t=e.map(e=>ye(a.basename(e))).join(`|`),n=new RegExp(String.raw`\bimport\s*["'][^"']*(?:${t})["'];`,`g`);return e=>e.replace(n,e=>`/* empty css ${``.padEnd(e.length-15)}*/`)}function ye(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function be(e){return!e.replaceAll(/\/\*[\s\S]*?\*\//g,``).replaceAll(/\/\/[^\n]*/g,``).replaceAll(/\bexport\s*\{\s*\};?/g,``).replaceAll(/\bimport\s*["'][^"']*["'];?/g,``).trim()}function xe(e,t){let n=[];async function r(t){if(!e.minify)return t;let n=(await Y(t,u,{target:e.target,lightningcss:e.lightningcss,minify:!0})).code;return n.length&&!n.endsWith(`
4
4
  `)&&(n+=`
5
5
  `),n}return{name:`lzi-builder:css-post`,renderChunk(r,i){if(t.size===0||e.splitting)return;let a=``;for(let e of Object.keys(i.modules)){let n=t.get(e);n&&(a+=n)}a&&(a.length>0&&!a.endsWith(`
6
6
  `)&&(a+=`
7
7
  `),n.push(a))},async generateBundle(i,a){if(e.splitting)for(let e of Object.values(a)){if(e.type!==`chunk`)continue;let n=``;for(let r of e.moduleIds){let e=t.get(r);e&&(n+=e)}if(!n)continue;n.endsWith(`
8
8
  `)||(n+=`
9
- `),n=await r(n);let i=w(e.fileName);this.emitFile({type:`asset`,fileName:i,source:n})}else if(n.length>0){let t=n.join(``);t&&(t=await r(t),this.emitFile({type:`asset`,fileName:e.fileName,source:t,originalFileName:u})),n.length=0}_e(a,t)}}}const Z=/* @__PURE__ */ new Map;async function Q(e){let t=Z.get(e);if(t!==void 0)return t;let n=(async()=>{try{let t=(await import(`postcss-load-config`)).default,n=await t({},e);return{options:n.options,plugins:n.plugins}}catch(e){if(e.message?.includes(`No PostCSS Config found`))return null;throw e}})();Z.set(e,n);let r=await n;return Z.set(e,r),r}function Se(e,t){if(typeof e==`object`){let{plugins:t,...n}=e;return{options:n,plugins:t||[]}}return Q(typeof e==`string`?e:t)}async function Ce(e,n,r,i,a,o,s){let c=await Se(r,i),l=[],u;if(o?.isModule){let e=await t(`postcss-modules`),{localsConvention:n,getJSON:r,...i}=o.config??{};l.push((e.default??e)({...i,getJSON(e,t,n){u=t,r?.(e,t,n)}}))}if(a){let e=await t(`postcss-import`);l.push((e.default??e)())}if(c&&l.push(...c.plugins),!l.length&&!c?.options.parser)return{code:e,deps:[]};let d=await(await t(`postcss`)).default(l).process(e,{...c?.options,from:n,to:n,map:s?{inline:!1,annotation:!1,prev:!1}:void 0}),f=[];for(let e of d.messages)if(e.type===`dependency`)f.push(e.file);else if(e.type===`dir-dependency`){let{dir:t}=e;typeof t==`string`&&f.push(t)}return{code:d.css,deps:f,map:d.map?.toString(),modules:u}}function $(e,t){let n=b.test(e);return e!==t&&!n&&x.test(t)}function we(e,{logger:t}){let n={css:d(e.css,e.target,e.unbundle),cwd:e.cwd,target:e.target,sourceMap:!!e.sourcemap},r=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s={name:`@lzi-builder/css`,buildStart(){r.clear(),o.clear()},closeBundle(){if(!this.meta.watchMode)return U()},closeWatcher(){return U()},resolveId:{filter:{id:S},async handler(e,...t){let n=T(e),r=await this.resolve(n,...t);if(r)return{...r,id:`${r.id}?inline`}}},load:{filter:{id:S},async handler(e){let t=T(e);if(r.has(e))return;let n=await i(t,`utf8`).catch(()=>null);if(n!=null)return this.addWatchFile(t),{code:n,moduleType:`js`}}},transform:{filter:{id:x},async handler(e,r){let i=T(r);if($(r,i))return;let a=!b.test(r)&&n.css.modules!==!1&&C.test(r),s=[],c,l;if(n.css.transformer===`lightningcss`){let o=await Ee(e,r,i,s,n,t,a);e=o.code,c=o.modules,l=o.map}else{let t=await De(e,r,i,s,n,a);e=t.code,c=t.modules,l=t.map}for(let e of s)this.addWatchFile(e);if(e.length&&!e.endsWith(`
9
+ `),n=await r(n);let i=w(e.fileName);this.emitFile({type:`asset`,fileName:i,source:n})}else if(n.length>0){let t=n.join(``);t&&(t=await r(t),this.emitFile({type:`asset`,fileName:e.fileName,source:t,originalFileName:u})),n.length=0}_e(a,t)}}}const Z=/* @__PURE__ */ new Map;async function Q(e){let t=Z.get(e);if(t!==void 0)return t;let n=(async()=>{try{let t=(await import(`postcss-load-config`)).default,n=await t({},e);return{options:n.options,plugins:n.plugins}}catch(e){if(e.message?.includes(`No PostCSS Config found`))return null;throw e}})();Z.set(e,n);let r=await n;return Z.set(e,r),r}function Se(e,t){if(typeof e==`object`){let{plugins:t,...n}=e;return{options:n,plugins:t||[]}}return Q(typeof e==`string`?e:t)}async function Ce(e,n,r,i,a,o,s){let c=await Se(r,i),l=[],u;if(o?.isModule){let e=await t(`postcss-modules`),{localsConvention:n,getJSON:r,...i}=o.config??{};l.push((e.default??e)({...i,getJSON(e,t,n){u=t,r?.(e,t,n)}}))}if(a){let e=await t(`postcss-import`);l.push((e.default??e)())}if(c&&l.push(...c.plugins),!l.length&&!c?.options.parser)return{code:e,deps:[]};let d=await(await t(`postcss`)).default(l).process(e,{...c?.options,from:n,to:n,map:s?{inline:!1,annotation:!1,prev:!1}:void 0}),f=[];for(let e of d.messages)if(e.type===`dependency`)f.push(e.file);else if(e.type===`dir-dependency`){let{dir:t}=e;typeof t==`string`&&f.push(t)}return{code:d.css,deps:f,map:d.map?.toString(),modules:u}}function $(e,t){let n=b.test(e);return e!==t&&!n&&x.test(t)}function we(e,{logger:t}){let n={css:d(e.css,e.target,e.unbundle),cwd:e.cwd,target:e.target,sourceMap:!!e.sourcemap},r=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s={name:`@lzi-builder/css`,buildStart(){r.clear(),o.clear()},closeBundle(){if(!this.meta.watchMode)return U()},closeWatcher(){return U()},resolveId:{filter:{id:S},async handler(e,...t){let n=T(e),r=await this.resolve(n,...t);return r?{...r,id:`${r.id}?inline`}:null}},load:{filter:{id:S},async handler(e){let t=T(e);if(r.has(e))return;let n=await i(t,`utf8`).catch(()=>null);if(n!=null)return this.addWatchFile(t),{code:n,moduleType:`js`}}},transform:{filter:{id:x},async handler(e,r){let i=T(r);if($(r,i))return;let a=!b.test(r)&&n.css.modules!==!1&&C.test(r),s=[],c,l;if(n.css.transformer===`lightningcss`){let o=await Ee(e,r,i,s,n,t,a);e=o.code,c=o.modules,l=o.map}else{let t=await De(e,r,i,s,n,a);e=t.code,c=t.modules,l=t.map}for(let e of s)this.addWatchFile(e);if(e.length&&!e.endsWith(`
10
10
  `)&&(e+=`
11
- `),c){let e=typeof n.css.modules==`object`?n.css.modules:void 0;e?.localsConvention&&(c=m(c,e.localsConvention)),e?.getJSON?.(i,c,i),o.set(r,c)}return{code:e,map:l??null}}}},c=[{name:`@lzi-builder/css:collect`,transform:{filter:{id:x},handler(e,t){if($(t,T(t)))return;let n=b.test(t),i=o.get(t);return n?{code:`export default ${JSON.stringify(e)};`,map:null,moduleSideEffects:!1,moduleType:`js`}:(e.length&&r.set(t,e),i?{code:f(i),map:null,moduleSideEffects:!1,moduleType:`js`}:{code:``,map:null,moduleSideEffects:`no-treeshake`,moduleType:`js`})}}}];return n.css.inject&&c.push({name:`@lzi-builder/css:inject`,generateBundle(e,t){let i=Object.values(t),o=/* @__PURE__ */ new Set;for(let e of i)if(e.type===`chunk`&&!e.exports.length&&e.moduleIds.length){if(e.moduleIds.every(e=>r.has(e))){o.add(e.fileName);continue}!e.isEntry&&!e.isDynamicEntry&&e.moduleIds.some(e=>r.has(e))&&Oe(e.code)&&o.add(e.fileName)}for(let e of i)if(e.type===`chunk`&&!o.has(e.fileName)){if(n.css.splitting){for(let t of e.imports){if(!o.has(t))continue;let n=a.basename(t),r=n.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),i=w(n),s=new RegExp(String.raw`(\bimport\s*["'][^"']*)${r}(["'];)`);e.code=e.code.replace(s,`$1${i}$2`)}if(e.moduleIds.some(e=>r.has(e))){let t=w(e.fileName),n=a.posix.relative(a.posix.dirname(e.fileName),t);e.code=`import '${n[0]===`.`?n:`./${n}`}';\n${e.code}`,e.map&&(e.map.mappings=`;${e.map.mappings}`)}}else if(e.moduleIds.some(e=>r.has(e))||e.imports.some(e=>o.has(e))){let t=n.css.fileName,r=a.posix.relative(a.posix.dirname(e.fileName),t);e.code=`import '${r[0]===`.`?r:`./${r}`}';\n${e.code}`,e.map&&(e.map.mappings=`;${e.map.mappings}`)}}}}),c.push(xe(n.css,r)),{pre:[s],post:c}}function Te(e,t,n){if(!t)return;let r=typeof e==`object`?e:void 0;if(!r)return!0;let i={};return typeof r.generateScopedName==`string`?i.pattern=r.generateScopedName:typeof r.generateScopedName==`function`&&n.warn('[@lzi-builder/css] `generateScopedName` as a function is not supported with `transformer: "lightningcss"`. Use a string pattern or switch to `transformer: "postcss"`.'),r.scopeBehaviour===`global`&&(i.pattern=`[local]`),Object.keys(i).length>0?i:!0}async function Ee(e,t,n,r,i,a,o){let s=O(t),c=Te(i.css.modules,o,a);if(s){let t=await k(s,e,n,i.css.preprocessorOptions);return r.push(...t.deps),Y(t.code,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,sourceMap:i.sourceMap})}if(t!==n&&!b.test(t))return Y(e,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,sourceMap:i.sourceMap});if(te.test(n)){let t=await pe(n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,preprocessorOptions:i.css.preprocessorOptions,sourceMap:i.sourceMap,logger:a},e);return r.push(...t.deps),{code:t.code,map:t.map,modules:t.modules}}return{code:``}}async function De(e,t,n,r,i,a){let o=O(t);if(o){let t=await k(o,e,n,i.css.preprocessorOptions);e=t.code,r.push(...t.deps)}let s=typeof i.css.modules==`object`?i.css.modules:void 0,c=e.includes(`@import`),l=await Ce(e,n,i.css.postcss,i.cwd,c,a?{isModule:!0,config:s}:void 0,i.sourceMap);e=l.code,r.push(...l.deps);let u=await Y(e,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,sourceMap:i.sourceMap,inputSourceMap:l.map});return{code:u.code,map:u.map??l.map,modules:l.modules}}function Oe(e){return!e.replaceAll(/\/\*[\s\S]*?\*\//g,``).replaceAll(/\/\/[^\n]*/g,``).replaceAll(/\bexport\s*\{\s*\};?/g,``).replaceAll(/\bimport\s*["'][^"']*["'];?/g,``).trim()}export{we as CssPlugin,d as resolveCssOptions};
11
+ `),c){let e=typeof n.css.modules==`object`?n.css.modules:void 0;e?.localsConvention&&(c=m(c,e.localsConvention)),e?.getJSON?.(i,c,i),o.set(r,c)}return{code:e,map:l??null}}}},c=[{name:`@lzi-builder/css:collect`,transform:{filter:{id:x},handler(e,t){if($(t,T(t)))return;let n=b.test(t),i=o.get(t);return n?{code:`export default ${JSON.stringify(e)};`,map:null,moduleSideEffects:!1,moduleType:`js`}:(e.length&&r.set(t,e),i?{code:f(i),map:null,moduleSideEffects:!1,moduleType:`js`}:{code:``,map:null,moduleSideEffects:`no-treeshake`,moduleType:`js`})}}}];return n.css.inject&&c.push({name:`@lzi-builder/css:inject`,generateBundle(e,t){let i=Object.values(t),o=/* @__PURE__ */ new Set;for(let e of i)e.type===`chunk`&&!e.exports.length&&e.moduleIds.length&&(e.moduleIds.every(e=>r.has(e))||!e.isEntry&&!e.isDynamicEntry&&e.moduleIds.some(e=>r.has(e))&&Oe(e.code))&&o.add(e.fileName);for(let e of i)if(e.type===`chunk`&&!o.has(e.fileName)){if(n.css.splitting){for(let t of e.imports){if(!o.has(t))continue;let n=a.basename(t),r=n.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),i=w(n),s=new RegExp(String.raw`(\bimport\s*["'][^"']*)${r}(["'];)`);e.code=e.code.replace(s,`$1${i}$2`)}if(e.moduleIds.some(e=>r.has(e))){let t=w(e.fileName),n=a.posix.relative(a.posix.dirname(e.fileName),t);e.code=`import '${n[0]===`.`?n:`./${n}`}';\n${e.code}`,e.map&&(e.map.mappings=`;${e.map.mappings}`)}}else if(e.moduleIds.some(e=>r.has(e))||e.imports.some(e=>o.has(e))){let t=n.css.fileName,r=a.posix.relative(a.posix.dirname(e.fileName),t);e.code=`import '${r[0]===`.`?r:`./${r}`}';\n${e.code}`,e.map&&(e.map.mappings=`;${e.map.mappings}`)}}}}),c.push(xe(n.css,r)),{pre:[s],post:c}}function Te(e,t,n){if(!t)return;let r=typeof e==`object`?e:void 0;if(!r)return!0;let i={};return typeof r.generateScopedName==`string`?i.pattern=r.generateScopedName:typeof r.generateScopedName==`function`&&n.warn('[@lzi-builder/css] `generateScopedName` as a function is not supported with `transformer: "lightningcss"`. Use a string pattern or switch to `transformer: "postcss"`.'),r.scopeBehaviour===`global`&&(i.pattern=`[local]`),Object.keys(i).length>0?i:!0}async function Ee(e,t,n,r,i,a,o){let s=O(t),c=Te(i.css.modules,o,a);if(s){let t=await k(s,e,n,i.css.preprocessorOptions);return r.push(...t.deps),Y(t.code,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,sourceMap:i.sourceMap})}if(t!==n&&!b.test(t))return Y(e,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,sourceMap:i.sourceMap});if(te.test(n)){let t=await pe(n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,cssModules:c,preprocessorOptions:i.css.preprocessorOptions,sourceMap:i.sourceMap,logger:a},e);return r.push(...t.deps),{code:t.code,map:t.map,modules:t.modules}}return{code:``}}async function De(e,t,n,r,i,a){let o=O(t);if(o){let t=await k(o,e,n,i.css.preprocessorOptions);e=t.code,r.push(...t.deps)}let s=typeof i.css.modules==`object`?i.css.modules:void 0,c=e.includes(`@import`),l=await Ce(e,n,i.css.postcss,i.cwd,c,a?{isModule:!0,config:s}:void 0,i.sourceMap);e=l.code,r.push(...l.deps);let u=await Y(e,n,{target:i.css.target,lightningcss:i.css.lightningcss,minify:i.css.minify,sourceMap:i.sourceMap,inputSourceMap:l.map});return{code:u.code,map:u.map??l.map,modules:l.modules}}function Oe(e){return!e.replaceAll(/\/\*[\s\S]*?\*\//g,``).replaceAll(/\/\/[^\n]*/g,``).replaceAll(/\bexport\s*\{\s*\};?/g,``).replaceAll(/\bimport\s*["'][^"']*["'];?/g,``).trim()}export{we as CssPlugin,d as resolveCssOptions};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-builder/css",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "Longzai Intelligence Builder CSS 处理流水线",
5
5
  "keywords": [
6
- "longzai-intelligence",
7
6
  "builder",
8
7
  "css",
8
+ "longzai-intelligence",
9
9
  "postcss",
10
10
  "styles"
11
11
  ],
@@ -26,10 +26,13 @@
26
26
  "build": "lzi-builder",
27
27
  "build:prod": "NODE_ENV=production bun run build",
28
28
  "prepublishOnly": "bun run build:prod",
29
- "typecheck": "lzi-tsgo typecheck tsconfig.json",
29
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
30
30
  "lint": "oxlint && oxfmt --check",
31
31
  "lint:fix": "oxlint --fix && oxfmt",
32
- "clean": "lzi-dev-cli clean"
32
+ "clean": "lzi-dev-cli clean",
33
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
34
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
35
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
33
36
  },
34
37
  "dependencies": {
35
38
  "lightningcss": "^1.32.0",
@@ -37,7 +40,7 @@
37
40
  "rolldown": "^1.0.0"
38
41
  },
39
42
  "peerDependencies": {
40
- "@longzai-intelligence-builder/core": "0.2.22",
43
+ "@longzai-intelligence-builder/core": "0.2.23",
41
44
  "postcss": "^8.4.0",
42
45
  "postcss-import": "^16.0.0",
43
46
  "postcss-modules": "^6.0.0",