@visulima/rollup-plugin-css 1.0.0-alpha.4 → 1.0.0-alpha.41
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/CHANGELOG.md +336 -0
- package/LICENSE.md +83 -79
- package/README.md +164 -146
- package/dist/css-modules-types.d.ts +38 -0
- package/dist/css-plugin.d.ts +44 -0
- package/dist/index.d.ts +40 -20
- package/dist/index.js +1 -0
- package/dist/loaders/less/importer.d.ts +2 -0
- package/dist/loaders/less/index.d.ts +37 -9
- package/dist/loaders/less/index.js +1 -0
- package/dist/loaders/less/types.d.ts +24 -0
- package/dist/loaders/lightningcss.d.ts +13 -16
- package/dist/loaders/lightningcss.js +3 -0
- package/dist/loaders/loader-manager.d.ts +78 -0
- package/dist/loaders/postcss/constants.d.ts +20 -0
- package/dist/loaders/postcss/icss/index.d.ts +8 -0
- package/dist/loaders/postcss/icss/load.d.ts +5 -0
- package/dist/loaders/postcss/icss/resolve.d.ts +6 -0
- package/dist/loaders/postcss/import/apply-conditions.d.ts +10 -0
- package/dist/loaders/postcss/import/apply-raws.d.ts +3 -0
- package/dist/loaders/postcss/import/apply-styles.d.ts +10 -0
- package/dist/loaders/postcss/import/constants.d.ts +12 -0
- package/dist/loaders/postcss/import/import-resolve.d.ts +3 -0
- package/dist/loaders/postcss/import/index.d.ts +12 -0
- package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +9 -0
- package/dist/loaders/postcss/import/parser/parse-styles.d.ts +6 -0
- package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +10 -0
- package/dist/loaders/postcss/import/types.d.ts +95 -0
- package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +3 -0
- package/dist/loaders/postcss/import/utils/data-url.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/load-content.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/process-content.d.ts +4 -0
- package/dist/loaders/postcss/import/utils/statement.d.ts +6 -0
- package/dist/loaders/postcss/index.d.ts +27 -16
- package/dist/loaders/postcss/index.js +6 -0
- package/dist/loaders/postcss/load-config.d.ts +6 -0
- package/dist/loaders/postcss/modules/generate.d.ts +11 -0
- package/dist/loaders/postcss/modules/index.d.ts +35 -0
- package/dist/loaders/postcss/noop.d.ts +22 -0
- package/dist/loaders/postcss/url/generate.d.ts +2 -0
- package/dist/loaders/postcss/url/index.d.ts +46 -0
- package/dist/loaders/postcss/url/inline.d.ts +20 -0
- package/dist/loaders/postcss/url/url-resolve.d.ts +12 -0
- package/dist/loaders/postcss/url/utils.d.ts +4 -0
- package/dist/loaders/sass/index.d.ts +5 -9
- package/dist/loaders/sass/{index.mjs → index.js} +5 -5
- package/dist/loaders/sass/modern/importer.d.ts +3 -0
- package/dist/loaders/sass/types.d.ts +20 -0
- package/dist/loaders/sass/utils/get-sass-compiler.d.ts +8 -0
- package/dist/loaders/sass/utils/get-sass-options.d.ts +7 -0
- package/dist/loaders/sass/utils/normalize-source-map.d.ts +3 -0
- package/dist/loaders/sass/utils/resolve-syntax.d.ts +2 -0
- package/dist/loaders/sass/utils/sass-error-factory.d.ts +15 -0
- package/dist/loaders/sourcemap.d.ts +24 -16
- package/dist/loaders/sourcemap.js +1 -0
- package/dist/loaders/stylus/index.d.ts +8 -9
- package/dist/loaders/stylus/index.js +2 -0
- package/dist/loaders/stylus/types.d.ts +87 -0
- package/dist/loaders/tailwindcss-oxide.d.ts +5 -16
- package/dist/loaders/tailwindcss-oxide.js +1 -0
- package/dist/loaders/types.d.ts +102 -0
- package/dist/loaders/utils/ensure-auto-modules.d.ts +39 -0
- package/dist/loaders/utils/match-file.d.ts +32 -0
- package/dist/minifiers/cssnano.d.ts +30 -16
- package/dist/minifiers/lightningcss.d.ts +29 -16
- package/dist/minifiers/types.d.ts +64 -0
- package/dist/packem_shared/concat-WcWAYbOc.js +3 -0
- package/dist/packem_shared/{cssModulesTypesPlugin-B9_bJo_B.mjs → cssModulesTypesPlugin-CjGroK2y.js} +1 -1
- package/dist/packem_shared/{generate-js-exports-Dqps7nWG.mjs → generate-js-exports-BhS4eLrN.js} +1 -1
- package/dist/packem_shared/getMap-TR-0DXUr.js +1 -0
- package/dist/packem_shared/inferModeOption-9h3Eq6JH.js +1 -0
- package/dist/packem_shared/loadModule-D20jQQNu.js +1 -0
- package/dist/packem_shared/resolve-anj9ucIq.js +1 -0
- package/dist/packem_shared/rollupCssPlugin-BxRedPmA.js +3 -0
- package/dist/packem_shared/{sourcemap-DGfgaUBb.mjs → sourcemap-CB6ochh0.js} +1 -1
- package/dist/types.d.ts +224 -0
- package/dist/utils/array-fmt.d.ts +18 -0
- package/dist/utils/concat.d.ts +34 -0
- package/dist/utils/generate-js-exports.d.ts +78 -0
- package/dist/utils/index.d.ts +9 -73
- package/dist/utils/index.js +1 -0
- package/dist/utils/load-module.d.ts +3 -0
- package/dist/utils/options.d.ts +155 -0
- package/dist/utils/resolve.d.ts +35 -0
- package/dist/utils/safe-id.d.ts +23 -0
- package/dist/utils/sourcemap.d.ts +42 -0
- package/dist/utils/url.d.ts +8 -0
- package/package.json +56 -41
- package/dist/index.d.mts +0 -20
- package/dist/index.mjs +0 -1
- package/dist/loaders/less/index.d.mts +0 -17
- package/dist/loaders/less/index.mjs +0 -1
- package/dist/loaders/lightningcss.d.mts +0 -17
- package/dist/loaders/lightningcss.mjs +0 -3
- package/dist/loaders/postcss/index.d.mts +0 -17
- package/dist/loaders/postcss/index.mjs +0 -6
- package/dist/loaders/sass/index.d.mts +0 -18
- package/dist/loaders/sourcemap.d.mts +0 -17
- package/dist/loaders/sourcemap.mjs +0 -1
- package/dist/loaders/stylus/index.d.mts +0 -17
- package/dist/loaders/stylus/index.mjs +0 -1
- package/dist/loaders/tailwindcss-oxide.d.mts +0 -17
- package/dist/loaders/tailwindcss-oxide.mjs +0 -1
- package/dist/minifiers/cssnano.d.mts +0 -17
- package/dist/minifiers/lightningcss.d.mts +0 -17
- package/dist/packem_shared/concat-BbvpVPBg.mjs +0 -3
- package/dist/packem_shared/getMap-BL5hKEnR.mjs +0 -1
- package/dist/packem_shared/inferModeOption-fAc592HP.mjs +0 -1
- package/dist/packem_shared/loadModule-CovDETwT.mjs +0 -1
- package/dist/packem_shared/resolve-nqhcPNJ9.mjs +0 -1
- package/dist/packem_shared/rollupCssPlugin-CJSS-7Mi.mjs +0 -3
- package/dist/packem_shared/types-CA9pSumu.d.mts +0 -189
- package/dist/packem_shared/types-CA9pSumu.d.ts +0 -189
- package/dist/utils/index.d.mts +0 -73
- package/dist/utils/index.mjs +0 -1
- /package/dist/minifiers/{cssnano.mjs → cssnano.js} +0 -0
- /package/dist/minifiers/{lightningcss.mjs → lightningcss.js} +0 -0
- /package/dist/packem_shared/{arrayFmt-Dek5cB7m.mjs → arrayFmt-Dek5cB7m.js} +0 -0
- /package/dist/packem_shared/{ensure-auto-modules-BU3xWEjl.mjs → ensure-auto-modules-BU3xWEjl.js} +0 -0
- /package/dist/packem_shared/{hasModuleSpecifier-DIZeev_W.mjs → hasModuleSpecifier-DIZeev_W.js} +0 -0
- /package/dist/packem_shared/{safeId-BN5akJYJ.mjs → safeId-BN5akJYJ.js} +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var Oe=Object.defineProperty;var d=(t,e)=>Oe(t,"name",{value:e,configurable:!0});import Pe from"@csstools/postcss-slow-plugins";import{dirname as b,normalize as P,parse as Q,resolve as Ee,basename as U,isAbsolute as Re,join as Ie}from"@visulima/path";import Ce from"postcss";import{g as Ne}from"../../packem_shared/generate-js-exports-BhS4eLrN.js";import{H as L,m as N,D as Ue,F as ie}from"../../packem_shared/sourcemap-CB6ochh0.js";import{n as ae}from"../../packem_shared/ensure-auto-modules-BU3xWEjl.js";import{extractICSS as Le,replaceSymbols as De,replaceValueSymbols as ze}from"icss-utils";import{readFile as Me,readFileSync as me}from"@visulima/fs";import{resolve as Y}from"../../packem_shared/resolve-anj9ucIq.js";import{isRelative as _e}from"@visulima/path/utils";import{isWhiteSpaceOrCommentNode as X,isSimpleBlockNode as We,SimpleBlockNode as qe,parseListOfComponentValues as Te,isTokenNode as W,isFunctionNode as I,stringify as S}from"@csstools/css-parser-algorithms";import{isTokenOpenParen as Fe,TokenType as se,tokenize as Ae,isTokenString as q,isTokenURL as oe,isTokenIdent as Ge}from"@csstools/css-tokenizer";import{stat as T}from"node:fs/promises";import{findMonorepoRoot as Xe,findPackageRoot as Be}from"@visulima/package";import ne from"postcss-load-config";import{ensurePCSSPlugins as He,ensurePCSSOption as F}from"../../packem_shared/inferModeOption-9h3Eq6JH.js";import Ve from"postcss-modules-extract-imports";import Je from"postcss-modules-local-by-default";import Qe from"postcss-modules-scope";import Ye from"postcss-modules-values";import{makeLegalIdentifier as Ke}from"@rollup/pluginutils";import{getHash as ue}from"@visulima/packem-share/utils";import B from"postcss-value-parser";var Ze=Object.defineProperty,et=d((t,e)=>Ze(t,"name",{value:e,configurable:!0}),"i$5");const tt=et(async(t,e,i,a,s)=>{const o=Y([t,`./${t}`],{baseDirs:[b(e)],caller:"ICSS loader",extensions:i}),r=await Me(o),{messages:l}=await a.process(r,{...s,from:o}),c={};for(const p of l)p.type==="icss"&&Object.assign(c,p.export);return c},"load");var it=Object.defineProperty,at=d((t,e)=>it(t,"name",{value:e,configurable:!0}),"t$3");const st=at(async(t,e,i,a,s,o)=>{const r={};for await(const[l,c]of Object.entries(t)){const p=await e(l,i,a,s,o);for(const[n,m]of Object.entries(c))r[n]=p[m]}return r},"resolve");var ot=Object.defineProperty,nt=d((t,e)=>ot(t,"name",{value:e,configurable:!0}),"c$4");const A="styles-icss",rt=[".css",".pcss",".postcss",".sss"],de=nt(t=>{const e=t?.load??tt,i=t?.extensions??rt;return{async OnceExit(a,{result:s}){if(!a.source?.input.file)return;const o={...s.opts,map:void 0},{icssExports:r,icssImports:l}=Le(a),c=await st(l,e,a.source.input.file,i,s.processor,o);De(a,c);for(const[p,n]of Object.entries(r))s.messages.push({export:{[p]:ze(n,c)},plugin:A,type:"icss"});for(const p of Object.keys(l))s.messages.push({import:p,plugin:A,type:"icss-dependency"})},postcssPlugin:A}},"plugin");de.postcss=!0;var pt=Object.defineProperty,lt=d((t,e)=>pt(t,"name",{value:e,configurable:!0}),"t$2");const H=lt((t,e,i,a)=>{const s=[];if(t!==void 0){let o="layer";t&&(o=`layer(${t})`),s.push(o)}return i!==void 0&&s.push(`supports(${i})`),a!==void 0&&s.push(`scope(${a})`),e!==void 0&&s.push(e),s.join(" ")},"formatImportPrelude");var ct=Object.defineProperty,mt=d((t,e)=>ct(t,"name",{value:e,configurable:!0}),"p$6");const ut=mt((t,e)=>{e.reverse();const i=e.pop();if(!i)return t;let a=`${t} ${H(i.layer,i.media,i.supports,i.scope)}`;for(const s of e)a=`'data:text/css;base64,${Buffer.from(`@import ${a}`).toString("base64")}' ${H(s.layer,s.media,s.supports,s.scope)}`;return a},"base64EncodedConditionalImport");var dt=Object.defineProperty,z=d((t,e)=>dt(t,"name",{value:e,configurable:!0}),"e$1");const ft=z(t=>t.type==="warning","isWarning"),V=z(t=>t.type==="nodes","isNodesStatement"),D=z(t=>t.type==="import","isImportStatement"),gt=z(t=>t.type==="pre-import","isPreImportStatement");var ht=Object.defineProperty,xt=d((t,e)=>ht(t,"name",{value:e,configurable:!0}),"u$2");const vt=xt((t,e)=>{t.statements.forEach((i,a)=>{if(ft(i)||gt(i)||i.conditions.length===0)return;if(D(i)){i.node.params=ut(i.fullUri,i.conditions);return}const{nodes:s}=i;if(s.length===0)return;const{parent:o}=s[0];if(!o)return;const r=[];for(const p of i.conditions){if(p.media!==void 0){const n=e({name:"media",params:p.media,source:i.importingNode?.source??o.source});r.push(n)}if(p.scope!==void 0){const n=e({name:"scope",params:p.scope,source:i.importingNode?.source??o.source});r.push(n)}if(p.supports!==void 0){const n=e({name:"supports",params:`(${p.supports})`,source:i.importingNode?.source??o.source});r.push(n)}if(p.layer!==void 0){const n=e({name:"layer",params:p.layer,source:i.importingNode?.source??o.source});r.push(n)}}const l=r[0];if(!l)return;for(let p=0;p<r.length-1;p++)r[p].append(r[p+1]);const c=r.at(-1);o.insertBefore(s[0],l),s.forEach(p=>{p.parent=void 0}),c.append(s),t.statements[a]={conditions:i.conditions,from:i.from,importingNode:i.importingNode,nodes:[l],type:"nodes"}})},"applyConditions");var yt=Object.defineProperty,bt=d((t,e)=>yt(t,"name",{value:e,configurable:!0}),"r$4");const wt=bt(t=>{t.statements.forEach((e,i)=>{if(i!==0)if(e.parent!==void 0){const{before:a}=e.parent.node.raws;V(e)?e.nodes[0].raws.before=a:e.node.raws.before=a}else V(e)&&(e.nodes[0].raws.before=e.nodes[0].raws.before??`
|
|
2
|
+
`)})},"applyRaws");var $t=Object.defineProperty,jt=d((t,e)=>$t(t,"name",{value:e,configurable:!0}),"t$1");const kt=jt((t,e)=>{e.nodes=[],t.charset&&(t.charset.parent=void 0,e.append(t.charset)),t.statements.forEach(i=>{D(i)?(i.node.parent=void 0,e.append(i.node)):V(i)&&i.nodes.forEach(a=>{a.parent=void 0,e.append(a)})})},"applyStyles");var St=Object.defineProperty,Ot=d((t,e)=>St(t,"name",{value:e,configurable:!0}),"o$3");const Pt=Ot((t,e,i)=>{const a={baseDirs:[e],caller:"@import resolver",extensions:i},s=new URL(t,"file://").pathname,o=[s];return(_e(s)||s.startsWith("/"))&&o.push(`.${s}`),s.startsWith("/")&&o.push(s.slice(1)),Y(o,a)},"importResolve");var Et=Object.defineProperty,fe=d((t,e)=>Et(t,"name",{value:e,configurable:!0}),"e");const Rt=/^data:text\/css(?:;(?:base64|plain))?,/i,It=/^data:text\/css;base64,/i,Ct=/^data:text\/css;plain,/i,J=fe(t=>t!==void 0&&Rt.test(t),"isValidDataURL"),Nt=fe(t=>It.test(t)?Buffer.from(t.slice(21),"base64").toString():Ct.test(t)?decodeURIComponent(t.slice(20)):decodeURIComponent(t.slice(14)),"dataURLContents");var Ut=Object.defineProperty,re=d((t,e)=>Ut(t,"name",{value:e,configurable:!0}),"o$1");const K=re(()=>({postcssPlugin:"css-noop",prepare:re(()=>({}),"prepare")}),"postcssNoop");K.postcss=!0;var Lt=Object.defineProperty,ge=d((t,e)=>Lt(t,"name",{value:e,configurable:!0}),"a$3");const he=ge(async(t,e,i,a,s,o)=>(o===void 0&&(o=0),a.length===0&&a.push(K()),await t(a).process(e,{from:i,parser:s[o]}).catch(async r=>{if(o++,o===s.length)throw r;return await he(t,e,i,a,s,o)})),"runPostcss"),Dt=ge(async(t,e,i,a,s)=>{const{plugins:o}=a,r=[];return t.opts.syntax?.parse&&r.push(t.opts.syntax.parse),t.opts.parser&&r.push(t.opts.parser),r.push(void 0),await he(s,e,i,o,r)},"processContent"),zt=/^charset$/i,xe=/^import$/i,Mt=/^url$/i,E=/^layer$/i,_t=/^supports$/i,Wt=/^scope$/i;var qt=Object.defineProperty,Z=d((t,e)=>qt(t,"name",{value:e,configurable:!0}),"a$2");const Tt=Z(t=>{for(let e=0;e<t.length;e++){const i=t[e];if(!X(i)&&We(i)&&Fe(i.startToken))return t}return[new qe([se.OpenParen,"(",-1,-1,void 0],[se.CloseParen,")",-1,-1,void 0],t)]},"wrapInParenthesisIfNeeded"),pe=Z(t=>{if(t.startsWith("#"))return"";if(!t.includes("#"))return t;try{const e=new URL(t,"http://example.com");return e.hash?t.slice(0,t.length-e.hash.length):t}catch{return t}},"stripHash"),Ft=Z(t=>{const e=Ae({css:t});if(e.length===2&&(q(e[0])||oe(e[0]))){let p=e[0][4].value;return p=pe(p),p?{fullUri:e[0][1],uri:p}:!1}const i=Te(e);let a="",s="",o,r,l,c;for(let p=0;p<i.length;p++){const n=i[p];if(!X(n)){if(W(n)&&(q(n.value)||oe(n.value))){if(a)return!1;a=n.value[4].value,s=n.value[1];continue}if(I(n)&&Mt.test(n.getName())){if(a)return!1;for(let m=0;m<n.value.length;m++){const u=n.value[m];if(!X(u)){if(!a&&W(u)&&q(u.value)){a=u.value[4].value,s=S([[n]]);continue}return!1}}continue}if(!a)return!1;if(W(n)&&Ge(n.value)&&E.test(n.value[4].value)){if(o!==void 0||l!==void 0)return!1;o="";continue}if(I(n)&&E.test(n.getName())){if(o!==void 0||l!==void 0)return!1;o=S([n.value]);continue}if(I(n)&&_t.test(n.getName())){if(l!==void 0)return!1;l=S([n.value]);continue}if(I(n)&&Wt.test(n.getName())){if(c!==void 0)return!1;c=S([Tt(n.value)]);continue}r=S([i.slice(p)]);break}}return a=pe(a),a?{fullUri:s,layer:o,media:r,scope:c,supports:l,uri:a}:!1},"parseAtImport");var At=Object.defineProperty,k=d((t,e)=>At(t,"name",{value:e,configurable:!0}),"l$3");const ve=k((t,e,i,a)=>{const s=[];let o=e;const r=t.length;for(o;o<r;o++){const l=t[o];if(s.push(l),t[o+1]?.type!=="comment")break}return[o,{conditions:[],from:a,importingNode:i,nodes:s,type:"nodes"}]},"consumeComments"),Gt=k((t,e,i,a,s)=>{const o=Ft(e.params);if(!o)return t.warn(`Invalid @import statement in '${e.toString()}'`,{node:e});const r={conditions:[...a],from:s,fullUri:o.fullUri,importingNode:i,node:e,type:"import",uri:o.uri};return(o.layer!==void 0||o.media!==void 0||o.supports!==void 0||o.scope!==void 0)&&r.conditions.push({layer:o.layer,media:o.media,scope:o.scope,supports:o.supports}),r},"parseImport"),Xt=k((t,e,i,a,s,o)=>{const r=[];let l=a;const c=e.length;for(l;l<c;l++){const p=e[l];if(p.type==="comment"){const[n,m]=ve(e,l,s,o);r.push(m),l=n;continue}if(p.type==="atrule"&&xe.test(p.name)){r.push(Gt(t,p,s,i,o));continue}break}return[l-1,r]},"consumeImports"),Bt=k((t,e,i,a,s)=>{const o=[];let r=i;const l=t.length;for(r;r<l;r++){const c=t[r];o.push(c);const p=t[r+1];if(!(p&&p.type==="atrule"&&E.test(p.name)&&!p.nodes))break}return[r,{conditions:[...e],from:s,importingNode:a,nodes:o,type:"nodes"}]},"consumeLayers"),Ht=k((t,e,i,a,s)=>{const o=[];let r=i;const l=t.length;for(r;r<l;r++){const c=t[r];if(c.type==="comment"){const[p,n]=ve(t,r,a,s);o.push(n),r=p;continue}if(c.type==="atrule"&&E.test(c.name)&&!c.nodes)if(e.length>0){o.push({conditions:[...e],from:s,importingNode:a,node:c,type:"pre-import"});continue}else{const[p,n]=Bt(t,e,r,a,s);o.push(n),r=p;continue}break}return[r-1,o]},"consumeBeforeImports"),ye=k((t,e,i,a,s)=>{const o={statements:[]};if(e.type==="document")return e.each(m=>{const u=ye(t,m,i,a,s);if(o.charset&&u.charset&&o.charset.params.toLowerCase()!==u.charset.params.toLowerCase())throw u.charset.error(`Incompatible @charset statements:
|
|
3
|
+
${u.charset.params} specified in ${u.charset.source?.input.file}
|
|
4
|
+
${o.charset.params} specified in ${o.charset.source?.input.file}`);!o.charset&&u.charset&&(o.charset=u.charset),o.statements.push(...u.statements)}),o;let r,l=[],c=[],p;for(let m=0;m<e.nodes.length;m++){const u=e.nodes[m];if(m===0&&u.type==="atrule"&&zt.test(u.name)){r=u;continue}if(c.length===0&&(u.type==="comment"||u.type==="atrule"&&E.test(u.name)&&!u.nodes)){[m,l]=Ht(e.nodes,a,m,i,s);continue}if(c.length===0&&u.type==="atrule"&&xe.test(u.name)){[m,c]=Xt(t,e.nodes,a,m,i,s);continue}p={conditions:[...a],from:s,importingNode:i,nodes:e.nodes.slice(m),type:"nodes"};break}const n=[];return l.length>0&&n.push(...l),c.length>0&&n.push(...c),p&&n.push(p),{charset:r,statements:n}},"parseStylesheet");var Vt=Object.defineProperty,M=d((t,e)=>Vt(t,"name",{value:e,configurable:!0}),"h");const Jt=/^(?:[a-z]+:)?\/\//i,Qt=M(t=>{if(Jt.test(t))return!1;try{if(new URL(t,"https://example.com").search)return!1}catch{}return!0},"isProcessableURL"),le=M(async(t,e,i,a,s,o)=>{const{conditions:r,from:l,node:c}=e,p=r.map(f=>H(f.layer,f.media,f.supports,f.scope)).join(":");if(a.skipDuplicates){if(s.importedFiles[i]?.[p])return{statements:[]};s.importedFiles[i]||(s.importedFiles[i]={}),s.importedFiles[i][p]=!0}if(l.includes(i))return{statements:[]};const n=await a.load(i,a);if(n.trim()===""&&a.warnOnEmpty)return t.warn(`${i} is empty`,{node:c}),{statements:[]};if(a.skipDuplicates&&s.hashFiles[n]?.[p])return{statements:[]};const m=await Dt(t,n,i,a,o),u=m.root;return a.debug&&u.append({text:i}),t.messages=[...t.messages,...m.messages],a.skipDuplicates&&(u.some(f=>f.type==="atrule"&&f.name==="import")||(s.hashFiles[n]||(s.hashFiles[n]={}),s.hashFiles[n][p]=!0)),await be(a,t,u,s,c,r,[...l,i],o)},"loadImportContent"),Yt=M(async(t,e,i,a,s)=>{if(J(i.uri)){i.stylesheet=await le(e,i,i.uri,t,a,s);return}if(J(i.from.at(-1))){i.stylesheet={statements:[]},e.warn(`Unable to import '${i.uri}' from a stylesheet that is embedded in a data url`,{node:i.node});return}const o=i.node;let r;o.source?.input.file&&(r=o.source.input.file);const l=r?b(r):t.root;for(const[p,n]of Object.entries(t.alias))i.uri!==p&&!i.uri.startsWith(`${p}/`)||(i.uri=P(n)+i.uri.slice(p.length));let c;try{c=await t.resolve(i.uri,l,t.extensions,o)}catch{i.node.warn(e,`Unable to resolve "${i.uri}" from "${l}"`);return}e.messages.push({file:c,parent:r,plugin:"packem-postcss-import",type:"dependency"}),i.stylesheet=await le(e,i,c,t,a,s)},"resolveImportId"),be=M(async(t,e,i,a,s,o,r,l)=>{let{charset:c,statements:p}=ye(e,i,s,o,r);{const n=[];for await(const m of p)!D(m)||!Qt(m.uri)||t.filter&&!t.filter(m.uri)||n.push(Yt(t,e,m,a,l));n.length>0&&await Promise.all(n)}for(let n=0;n<p.length;n++){const m=p[n];if(D(m)&&m.stylesheet){if(c&&m.stylesheet.charset&&c.params.toLowerCase()!==m.stylesheet.charset.params.toLowerCase())throw m.stylesheet.charset.error(`Incompatible @charset statements:
|
|
5
|
+
${m.stylesheet.charset.params} specified in ${m.stylesheet.charset.source?.input.file}
|
|
6
|
+
${c.params} specified in ${c.source?.input.file}`);!c&&m.stylesheet.charset&&(c=m.stylesheet.charset),p.splice(n,1,...m.stylesheet.statements),n-=1}}return{charset:c,statements:p}},"parseStyles");var Kt=Object.defineProperty,Zt=d((t,e)=>Kt(t,"name",{value:e,configurable:!0}),"r$3");const ei=Zt(t=>J(t)?Nt(t):me(t),"loadContent");var ti=Object.defineProperty,ii=d((t,e)=>ti(t,"name",{value:e,configurable:!0}),"i$1");const ai="css-import",si=[".css",".pcss",".postcss",".sss"],we=ii(t=>{const e={alias:t?.alias??{},extensions:t?.extensions??si,load:ei,plugins:[],resolve:t?.resolve??Pt,skipDuplicates:!1,...t};return{async Once(i,{atRule:a,postcss:s,result:o}){const r={hashFiles:{},importedFiles:{}};if(i.source?.input.file&&(r.importedFiles[i.source.input.file]={}),!Array.isArray(e.plugins))throw new TypeError("plugins option must be an array");const l=await be(e,o,i,r,void 0,[],[],s);wt(l),vt(l,a),kt(l,i)},postcssPlugin:ai}},"plugin");we.postcss=!0;var oi=Object.defineProperty,ni=d((t,e)=>oi(t,"name",{value:e,configurable:!0}),"y");const C=new Map,ri=ni(async(t,e,i,a,s)=>{if(!s)return{file:"",options:{},plugins:[]};const{dir:o}=Q(t),r=s.path?Ee(s.path):o;let l;try{l=(await Xe(e)).path}catch{try{l=await Be(e)}catch{}}try{let c;const p=C.get(r);if(p){let m=0;try{m=(await T(p.result.file)).mtimeMs}catch{}if(m>0&&m<=p.mtime)c=p.result;else{C.delete(r),c=await ne({cwd:e,env:i,...s.ctx},r,{stopDir:l});let u=0;try{u=(await T(c.file)).mtimeMs}catch{}C.set(r,{mtime:u,result:c})}}else{c=await ne({cwd:e,env:i,...s.ctx},r,{stopDir:l});let m=0;try{m=(await T(c.file)).mtimeMs}catch{}C.set(r,{mtime:m,result:c})}const n={file:c.file,options:c.options,plugins:await He(c.plugins,e,a)};return n.options.parser&&(n.options.parser=await F(n.options.parser,"parser",e,a)),n.options.syntax&&(n.options.syntax=await F(n.options.syntax,"syntax",e,a)),n.options.stringifier&&(n.options.stringifier=await F(n.options.stringifier,"stringifier",e,a)),n}catch(c){if(c.message.includes("No PostCSS Config found in"))return{file:"",options:{},plugins:[]};throw c}},"loadConfig");var pi=Object.defineProperty,li=d((t,e)=>pi(t,"name",{value:e,configurable:!0}),"n$3");const ci=li((t="[name]_[local]_[hash:8]")=>(e,i,a)=>{const{base:s,dir:o,name:r}=Q(i),l=ue(`${s}:${a}`),c=L.exec(t),p=c&&Number.parseInt(c[1],10);return Ke(t.replace("[dir]",U(o)).replace("[name]",r.replace(/\.module$/,"")).replace("[local]",e).replace(L,p?l.slice(0,p):l))},"generate");var mi=Object.defineProperty,ui=d((t,e)=>mi(t,"name",{value:e,configurable:!0}),"r$2");const di=ui(t=>{const e={mode:"local",...t,generateScopedName:typeof t.generateScopedName=="function"?t.generateScopedName:ci(t.generateScopedName)};return[Ye(),Je({mode:e.mode}),Ve({failOnWrongOrder:e.failOnWrongOrder}),Qe({exportGlobals:e.exportGlobals,generateScopedName:e.generateScopedName})]},"modules");var fi=Object.defineProperty,gi=d((t,e)=>fi(t,"name",{value:e,configurable:!0}),"c$2");const hi=gi((t,e,i)=>{const{base:a,dir:s,ext:o,name:r}=Q(e),l=ue(`${a}:${Buffer.from(i).toString()}`),c=L.exec(t),p=c&&Number.parseInt(c[1],10);return t.replace("[dir]",U(s)).replace("[name]",r).replace("[extname]",o).replace(".[ext]",o).replace("[ext]",o.slice(1)).replace(L,p?l.slice(0,p):l.slice(0,8))},"generate"),$e={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/dicom":["dcm"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg","one","onea"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"application/zip+dotlottie":["lottie"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a","m4b"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/ief":["ief"],"image/jaii":["jaii"],"image/jais":["jais"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpg","jpeg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxl":["jxl"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/pjpeg":["jfif"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime","mht","mhtml"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step":["step","stp","stpnc","p21","210"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts","m2t","m2ts","mts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze($e);var xi=Object.defineProperty,vi=d((t,e)=>xi(t,"name",{value:e,configurable:!0}),"g"),h=d(function(t,e,i,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(t):a?a.value:e.get(t)},"n$2"),j,O,$;let yi=class{static{d(this,"p")}static{vi(this,"Mime")}constructor(...e){j.set(this,new Map),O.set(this,new Map),$.set(this,new Map);for(const i of e)this.define(i)}define(e,i=!1){for(let[a,s]of Object.entries(e)){a=a.toLowerCase(),s=s.map(l=>l.toLowerCase()),h(this,$,"f").has(a)||h(this,$,"f").set(a,new Set);const o=h(this,$,"f").get(a);let r=!0;for(let l of s){const c=l.startsWith("*");if(l=c?l.slice(1):l,o?.add(l),r&&h(this,O,"f").set(a,l),r=!1,c)continue;const p=h(this,j,"f").get(l);if(p&&p!=a&&!i)throw new Error(`"${a} -> ${l}" conflicts with "${p} -> ${l}". Pass \`force=true\` to override this definition.`);h(this,j,"f").set(l,a)}}return this}getType(e){if(typeof e!="string")return null;const i=e.replace(/^.*[/\\]/s,"").toLowerCase(),a=i.replace(/^.*\./s,"").toLowerCase(),s=i.length<e.length;return!(a.length<i.length-1)&&s?null:h(this,j,"f").get(a)??null}getExtension(e){return typeof e!="string"?null:(e=e?.split?.(";")[0],(e&&h(this,O,"f").get(e.trim().toLowerCase()))??null)}getAllExtensions(e){return typeof e!="string"?null:h(this,$,"f").get(e.toLowerCase())??null}_freeze(){this.define=()=>{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(const e of h(this,$,"f").values())Object.freeze(e);return this}_getTestState(){return{types:h(this,j,"f"),extensions:h(this,O,"f")}}};j=new WeakMap,O=new WeakMap,$=new WeakMap;const bi=new yi($e)._freeze();var wi=Object.defineProperty,$i=d((t,e)=>wi(t,"name",{value:e,configurable:!0}),"r");const ji=$i((t,e)=>{const i=bi.getType(t)??"application/octet-stream",a=Buffer.from(e).toString("base64");return`data:${i};base64,${a}`},"inline");var ki=Object.defineProperty,Si=d((t,e)=>ki(t,"name",{value:e,configurable:!0}),"a");const Oi=Si(async(t,e)=>{const i=new URL(t,"file://"),a=i.hash?i.hash.slice(1):"",s=t.split("?")[0]??"",o=[s];s.startsWith("/")&&o.push(`.${s}`),!s.startsWith("/")&&!s.startsWith(".")&&o.push(`./${s}`);const r=Y(o,{baseDirs:e,caller:"URL resolver"}),l=new URLSearchParams(i.search).toString();return{from:r,source:me(r,{buffer:!0}),urlQuery:(l?`?${l}`:"")+(a?`#${a}`:"")}},"urlResolve");var Pi=Object.defineProperty,je=d((t,e)=>Pi(t,"name",{value:e,configurable:!0}),"n");const ce=/^url$/i,Ei=/^(?:-webkit-)?image-set$/i,Ri=je(t=>/(?:url|(?:-webkit-)?image-set)\(/i.test(t.value),"isDeclWithUrl"),Ii=je((t,e)=>{t.walk(i=>{if(i.type==="function"){if(ce.test(i.value)){const{nodes:a}=i,[s]=a,o=s?.type==="string"?s.value:B.stringify(a);e(o.replaceAll(/^\s+|\s+$/g,""),s);return}if(Ei.test(i.value))for(const a of i.nodes){if(a.type==="string"){e(a.value.replaceAll(/^\s+|\s+$/g,""),a);continue}if(a.type==="function"&&ce.test(a.value)){const{nodes:s}=a,[o]=s,r=o?.type==="string"?o.value:B.stringify(s);e(r.replaceAll(/^\s+|\s+$/g,""),o)}}}})},"walkUrls");var Ci=Object.defineProperty,Ni=d((t,e)=>Ci(t,"name",{value:e,configurable:!0}),"$");const G="packem-css-url",Ui="assets/[name]-[hash][extname]",Li="assets/[name][extname]",Di="./assets/",zi=".",ke=Ni(t=>{const e={alias:{},assetDir:zi,inline:!1,resolve:Oi,...t},i=e.hash??!0?typeof e.hash=="string"?e.hash:Ui:Li;return{async Once(a,{result:s}){if(!a.source?.input.file)return;const{file:o}=a.source.input,r=N(a.source.input.map?.text??void 0).resolve(b(o)).toConsumer(),l=[],c=new Set(s.messages.filter(n=>n.type==="dependency").map(n=>n.file));a.walkDecls(n=>{if(!Ri(n))return;const m=B(n.value);Ii(m,(u,f)=>{for(const[v,g]of Object.entries(e.alias))u!==v&&!u.startsWith(`${v}/`)||(u=P(g)+u.slice(v.length));if(!f||u.length===0){n.warn(s,`Empty URL in \`${n.toString()}\``);return}if(Ue.test(u))return;if(!Re(u))try{new URL(u);return}catch{}const y=new Set;if(n.source?.input.file&&c.has(n.source.input.file)&&y.add(b(n.source.input.file)),n.source?.start){const v=n.source.start,g=r?.originalPositionFor(v),w=g?.source&&b(g.source);w&&y.add(P(w))}y.add(b(o)),l.push({baseDirs:y,decl:n,node:f,parsed:m,url:u})})});const p=new Map;for await(const{baseDirs:n,decl:m,node:u,parsed:f,url:y}of l){let v;try{v||(v=await e.resolve(y,[...n]))}catch{}if(!v){m.warn(s,`Unresolved URL \`${y}\` in \`${m.toString()}\``);continue}const{from:g,source:w,urlQuery:ee}=v;if(!(w instanceof Uint8Array)||typeof g!="string"){m.warn(s,`Incorrectly resolved URL \`${y}\` in \`${m.toString()}\``);continue}if(s.messages.push({file:g,plugin:G,type:"dependency"}),e.inline)u.type="string",u.value=ji(g,w);else{const R=P(hi(i,g,w));let x=R;const Se=ie.test(R);for(let _=1;p.has(x)&&p.get(x)!==g;_++)x=Se?R.replace(ie,`${String(_)}$1`):`${R}${String(_)}`;p.set(x,g);const te=typeof e.publicPath=="string"?e.publicPath+(/[/\\]$/.test(e.publicPath)?"":"/")+U(x):`${Di}${U(x)}`;u.type="string",u.value=typeof e.publicPath=="function"?e.publicPath(u.value,te,o):te,ee&&(u.value+=ee),typeof e.assetDir=="string"?x=Ie(e.assetDir,x):typeof e.assetDir=="function"&&(x=e.assetDir(g,x,o)),s.messages.push({plugin:G,source:w,to:x,type:"asset"})}m.value=f.toString()}},postcssPlugin:G}},"plugin");ke.postcss=!0;const pa={alwaysProcess:!0,name:"postcss",async process({code:t,extracted:e,map:i}){const a=await ri(this.id,this.cwd,this.environment,this.logger,this.options.config),s=[];let o=!1;typeof this.options.modules=="boolean"?o=this.options.modules:typeof this.options.modules=="object"&&(o=ae(this.options.modules.include,this.id)),this.autoModules&&this.options.modules===void 0&&(o=ae(this.autoModules,this.id));const r={},l=[],c={...a.options,...this.options,from:this.id,map:{annotation:!1,inline:!1,prev:N(i).relative(b(this.id)).toObject(),sourcesContent:this.sourceMap?this.sourceMap.content:!0},plugins:[],to:this.options.to??this.id};if(this.options.import&&s.push(we({debug:this.debug,extensions:this.extensions,plugins:[],root:this.cwd,warnOnEmpty:!0,...this.options.import})),this.options.url&&s.push(ke({inline:!!this.inject,...this.options.url})),this.options.plugins&&s.push(...this.options.plugins),s.push(...a.plugins),o){const m=typeof this.options.modules=="object"?this.options.modules:{};s.push(...di({failOnWrongOrder:!0,...m}),de({extensions:this.extensions}))}s.length===0&&s.push(K),this.debug&&s.push(Pe({ignore:["css-noop"]}));const p=await Ce(s).process(t,c);for(const m of p.messages)switch(m.type){case"asset":{this.assets.set(m.to,m.source);break}case"dependency":{this.deps.add(P(m.file));break}case"icss":{Object.assign(r,m.export);break}case"icss-dependency":{l.push(m.import);break}case"warning":{this.logger.warn({message:m.text,plugin:m.plugin});break}}if(i=N(p.map.toJSON()).resolve(b(c.to)).toString(),!this.extract&&this.sourceMap){const m=N(i).modify(u=>{u.file=void 0}).relative();this.sourceMap.transform&&m.modify(this.sourceMap.transform),i=m.toString(),p.css+=m.toCommentData()}const n=Ne({css:p.css,cwd:this.cwd,dts:this.dts,emit:this.emit,extract:this.extract,icssDependencies:l,id:this.id,inject:this.inject,logger:this.logger,map:i,modulesExports:r,namedExports:this.namedExports,supportModules:o});return this.extract&&(e={css:p.css,id:this.id,map:i}),{code:n.code,extracted:e,map:n.map,meta:n.meta,moduleSideEffects:n.moduleSideEffects}}};export{pa as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
3
|
+
import type { Result } from "postcss-load-config";
|
|
4
|
+
import type { PostCSSConfigLoaderOptions } from "../../types.d.ts";
|
|
5
|
+
declare const loadConfig: (id: string, cwd: string, environment: Environment, logger: RollupLogger, options?: PostCSSConfigLoaderOptions | false) => Promise<Result>;
|
|
6
|
+
export default loadConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For reference, postcss-modules's default:
|
|
3
|
+
* https://github.com/madyankin/postcss-modules/blob/v6.0.0/src/scoping.js#L41
|
|
4
|
+
*
|
|
5
|
+
* FYI LightningCSS recommends hash first for grid compatibility,
|
|
6
|
+
* https://github.com/parcel-bundler/lightningcss/blob/v1.23.0/website/pages/css-modules.md?plain=1#L237-L238
|
|
7
|
+
*
|
|
8
|
+
* but PostCSS CSS Modules doesn't seem to transform Grid names
|
|
9
|
+
*/
|
|
10
|
+
declare const generate: (placeholder?: string) => (local: string, file: string, css: string) => string;
|
|
11
|
+
export default generate;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Plugin } from "postcss";
|
|
2
|
+
import type Processor from "postcss/lib/processor";
|
|
3
|
+
import type { AutoModules } from "../../../types.d.ts";
|
|
4
|
+
declare const modules: (options: ModulesOptions) => (Plugin | Processor)[];
|
|
5
|
+
/** Options for [CSS Modules](https://github.com/css-modules/css-modules) */
|
|
6
|
+
export interface ModulesOptions {
|
|
7
|
+
/** Export global classes */
|
|
8
|
+
exportGlobals?: boolean;
|
|
9
|
+
/** Fail on wrong order of composition */
|
|
10
|
+
failOnWrongOrder?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Placeholder or function for scoped name generation.
|
|
13
|
+
* Allowed blocks for placeholder:
|
|
14
|
+
* - `[dir]`: The directory name of the asset.
|
|
15
|
+
* - `[name]`: The file name of the asset excluding any extension.
|
|
16
|
+
* - `[local]`: The original value of the selector.
|
|
17
|
+
* - `[hash(:<num>)]`: A hash based on the name and content of the asset (with optional length).
|
|
18
|
+
* @default "[name]_[local]__[hash:8]"
|
|
19
|
+
*/
|
|
20
|
+
generateScopedName?: string | ((name: string, file: string, css: string) => string);
|
|
21
|
+
/**
|
|
22
|
+
* Files to include for [CSS Modules](https://github.com/css-modules/css-modules)
|
|
23
|
+
* for files named `[name].module.[ext]`
|
|
24
|
+
* (e.g. `foo.module.css`, `bar.module.stylus`),
|
|
25
|
+
* or pass your own function or regular expression
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
include?: AutoModules;
|
|
29
|
+
/**
|
|
30
|
+
* Default mode for classes
|
|
31
|
+
* @default "local"
|
|
32
|
+
*/
|
|
33
|
+
mode?: "global" | "local" | "pure";
|
|
34
|
+
}
|
|
35
|
+
export default modules;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PluginCreator } from "postcss";
|
|
2
|
+
/**
|
|
3
|
+
* No-operation PostCSS plugin used as a fallback when no other plugins are configured.
|
|
4
|
+
*
|
|
5
|
+
* This plugin prevents PostCSS from showing warnings about running without any plugins.
|
|
6
|
+
* It performs no transformations on the CSS - it simply ensures PostCSS has at least
|
|
7
|
+
* one plugin to execute, which is required for proper PostCSS operation.
|
|
8
|
+
*
|
|
9
|
+
* The plugin is automatically added when:
|
|
10
|
+
* - No user plugins are configured
|
|
11
|
+
* - No config file plugins are found
|
|
12
|
+
* - No built-in plugins (import, url, modules) are enabled
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Used internally when plugins array is empty
|
|
16
|
+
* if (plugins.length === 0) {
|
|
17
|
+
* plugins.push(postcssNoop);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const postcssNoop: PluginCreator<unknown>;
|
|
22
|
+
export default postcssNoop;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PluginCreator } from "postcss";
|
|
2
|
+
import type { UrlResolve } from "./url-resolve.d.ts";
|
|
3
|
+
declare const plugin: PluginCreator<UrlOptions>;
|
|
4
|
+
/** URL handler options */
|
|
5
|
+
export interface UrlOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Aliases for URL paths.
|
|
8
|
+
* Overrides the global `alias` option.
|
|
9
|
+
* - ex.: `{"foo":"bar"}`
|
|
10
|
+
*/
|
|
11
|
+
alias?: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Directory path for outputted CSS assets,
|
|
14
|
+
* which is not included into resulting URL
|
|
15
|
+
* @default "."
|
|
16
|
+
*/
|
|
17
|
+
assetDir?: string | ((original: string, resolved: string, file: string) => string);
|
|
18
|
+
/**
|
|
19
|
+
* Enable/disable name generation with hash for outputted CSS assets
|
|
20
|
+
* or provide your own placeholder with the following blocks:
|
|
21
|
+
* - `[extname]`: The file extension of the asset including a leading dot, e.g. `.png`.
|
|
22
|
+
* - `[ext]`: The file extension without a leading dot, e.g. `png`.
|
|
23
|
+
* - `[hash(:<num>)]`: A hash based on the name and content of the asset (with optional length).
|
|
24
|
+
* - `[name]`: The file name of the asset excluding any extension.
|
|
25
|
+
*
|
|
26
|
+
* Forward slashes / can be used to place files in sub-directories.
|
|
27
|
+
* @default "assets/[name]-[hash][extname]" ("assets/[name][extname]" if false)
|
|
28
|
+
*/
|
|
29
|
+
hash?: boolean | string;
|
|
30
|
+
/**
|
|
31
|
+
* Inline files instead of copying
|
|
32
|
+
* @default true for `inject` mode, otherwise false
|
|
33
|
+
*/
|
|
34
|
+
inline?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Public Path for URLs in CSS files
|
|
37
|
+
* @default "./"
|
|
38
|
+
*/
|
|
39
|
+
publicPath?: string | ((original: string, resolved: string, file: string) => string);
|
|
40
|
+
/**
|
|
41
|
+
* Provide custom resolver for URLs
|
|
42
|
+
* in place of the default one
|
|
43
|
+
*/
|
|
44
|
+
resolve?: UrlResolve;
|
|
45
|
+
}
|
|
46
|
+
export default plugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a file to a data URI for inline embedding in CSS.
|
|
3
|
+
*
|
|
4
|
+
* Creates a data URI that can be used directly in CSS
|
|
5
|
+
* without requiring a separate file request. All files are encoded
|
|
6
|
+
* using base64 for consistent behavior.
|
|
7
|
+
* @param file File path used to determine MIME type
|
|
8
|
+
* @param source File content as Uint8Array to be encoded
|
|
9
|
+
* @returns Data URI string optimized for CSS usage
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* inlineFile("image.png", pngBuffer)
|
|
13
|
+
* // Returns: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
|
14
|
+
*
|
|
15
|
+
* inlineFile("icon.svg", svgBuffer)
|
|
16
|
+
* // Returns: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDov..."
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const inline: (file: string, source: Uint8Array) => string;
|
|
20
|
+
export default inline;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** File resolved by URL resolver */
|
|
2
|
+
export interface UrlFile {
|
|
3
|
+
/** Absolute path to file */
|
|
4
|
+
from: string;
|
|
5
|
+
/** File source */
|
|
6
|
+
source: Uint8Array;
|
|
7
|
+
/** Original query extracted from the input path */
|
|
8
|
+
urlQuery?: string;
|
|
9
|
+
}
|
|
10
|
+
/** URL resolver */
|
|
11
|
+
export type UrlResolve = (inputUrl: string, baseDirectories: string[]) => Promise<UrlFile>;
|
|
12
|
+
export declare const urlResolve: UrlResolve;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Declaration } from "postcss";
|
|
2
|
+
import type { Node, ParsedValue } from "postcss-value-parser";
|
|
3
|
+
export declare const isDeclWithUrl: (decl: Declaration) => boolean;
|
|
4
|
+
export declare const walkUrls: (parsed: ParsedValue, callback: (url: string, node?: Node) => void) => void;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import _default = loader;
|
|
7
|
-
export { _default as default };
|
|
8
|
-
}
|
|
9
|
-
export = loader;
|
|
1
|
+
import type { Loader } from "../types.d.ts";
|
|
2
|
+
import type { SassLoaderOptions } from "./types.d.ts";
|
|
3
|
+
declare const loader: Loader<SassLoaderOptions>;
|
|
4
|
+
export default loader;
|
|
5
|
+
export type { SassLoaderContext, SassLoaderOptions } from "./types.d.ts";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var U=Object.defineProperty;var u=(e,t)=>U(e,"name",{value:t,configurable:!0});import{fileURLToPath as g}from"node:url";import{extname as v,dirname as x,
|
|
2
|
-
${n}`),{contents:n,sourceMapUrl:r,syntax:
|
|
1
|
+
var U=Object.defineProperty;var u=(e,t)=>U(e,"name",{value:t,configurable:!0});import{fileURLToPath as g}from"node:url";import{extname as v,dirname as x,isAbsolute as y,join as O}from"@visulima/path";import{readFileSync as A}from"@visulima/fs";import{pathToFileURL as S}from"mlly";import{resolve as D}from"../../packem_shared/resolve-anj9ucIq.js";import{normalizeUrl as L,getUrlOfPartial as j}from"../../packem_shared/hasModuleSpecifier-DIZeev_W.js";import{isWindows as R}from"@visulima/path/utils";var C=Object.defineProperty,k=u((e,t)=>C(e,"name",{value:t,configurable:!0}),"e$1");const $=k(e=>{switch(e.toLowerCase()){case".css":return"css";case".sass":return"indented";case".scss":return"scss";default:return}},"resolveSyntax");var E=Object.defineProperty,F=u((e,t)=>E(e,"name",{value:t,configurable:!0}),"i$1");const M=[".scss",".sass",".css"],T=["sass","style"],W=F((e,t)=>({canonicalize(r,s){const l=s.containingUrl?g(s.containingUrl.toString()):e;let n;const p=L(r),o=j(p);try{n=D([o,p],{baseDirs:[x(l)],caller:"Sass modern importer",extensions:M,mainFields:T})}catch{return null}return new URL(S(n))},load(r){const s=v(r.pathname),l=s?$(s.toLowerCase())??"scss":"scss";try{let n=A(r);return t&&(n=`/* ${r.pathname} */
|
|
2
|
+
${n}`),{contents:n,sourceMapUrl:r,syntax:l}}catch{return null}}}),"importer");var z=Object.defineProperty,H=u((e,t)=>z(e,"name",{value:t,configurable:!0}),"d");const N=H(async e=>{let t;if(e===void 0||e==="sass-embedded")try{t=await import("sass-embedded").then(r=>r.compileString)}catch{}if(t===void 0&&(e===void 0||e==="sass"))try{t=await import("sass").then(r=>r.compileString)}catch{}if(t===void 0)throw new Error("No supported Sass implementation found. Please install 'sass-embedded' or 'sass'.");return r=>{const{data:s,...l}=r;return t(s,l)}},"getSassCompiler");var _=Object.defineProperty,f=u((e,t)=>_(e,"name",{value:t,configurable:!0}),"p$1");const B=f(async(e,t,r,s,l)=>{const{warnRuleAsWarning:n,...p}=r;let o=s;r.additionalData&&(o=typeof r.additionalData=="function"?await r.additionalData(s,e):`${r.additionalData}
|
|
3
3
|
${s}`);const a={...p,data:o};if(!a.logger){const d=n!==!1,b=f(i=>`Warning on line ${i.start.line}, column ${i.start.column} of ${i.url??"-"}:${i.start.line}:${i.start.column}:
|
|
4
|
-
`,"formatSpan"),P=f(i=>`[debug:${i.start.line}:${i.start.column}] `,"formatDebugSpan");a.logger={debug(i,c){let
|
|
4
|
+
`,"formatSpan"),P=f(i=>`[debug:${i.start.line}:${i.start.column}] `,"formatDebugSpan");a.logger={debug(i,c){let m="";c.span&&(m=P(c.span)),m+=i,t.info({message:m})},warn(i,c){let m="";c.deprecation&&(m+="Deprecation "),c.span&&(m+=b(c.span)),m+=i,c.span?.context&&(m+=`
|
|
5
5
|
|
|
6
|
-
${c.span.start.line} | ${c.span.context}`),c.stack&&c.stack!=="undefined"&&(
|
|
6
|
+
${c.span.start.line} | ${c.span.context}`),c.stack&&c.stack!=="undefined"&&(m+=`
|
|
7
7
|
|
|
8
|
-
${c.stack}`),d?t.warn({message:
|
|
8
|
+
${c.stack}`),d?t.warn({message:m,name:"SassWarning"}):t.info({message:m})}}}const{resourcePath:h}=e;if(a.url=new URL(S(h)),l&&(a.sourceMap=!0),a.syntax===void 0){const d=v(h);d&&(a.syntax=$(d.toLowerCase()))}const w=R()?";":":";return a.loadPaths=[...(a.loadPaths?[...a.loadPaths]:[]).map(d=>y(d)?d:O(process.cwd(),d)),...process.env.SASS_PATH?process.env.SASS_PATH.split(w):[]],a.importers?Array.isArray(a.importers)?a.importers=[...a.importers]:a.importers=a.importers:a.importers=[],a},"getSassOptions");var J=Object.defineProperty,q=u((e,t)=>J(e,"name",{value:t,configurable:!0}),"r$1");const G=q(e=>{const t=e;return t.file!==void 0&&delete t.file,t.sourceRoot="",t},"normalizeSourceMap");var I=Object.defineProperty,K=u((e,t)=>I(e,"name",{value:t,configurable:!0}),"r");const Q=K((e,t)=>{const r=(e.formatted??e.message??String(e)).replace(/^.*?Error:\s*/i,""),s=new Error(r,{cause:e});return s.name=e.name,s.stack=void 0,s.id=t,e.span?.start&&(s.line=e.span.start.line+1,s.column=e.span.start.column+1),s},"errorFactory"),ae={name:"sass",async process({code:e,map:t}){const r=this.options.implementation,s=await N(r),l=await B({environment:this.environment,resourcePath:this.id,rootContext:this.cwd},this.logger,this.options,e,this.useSourcemap);l.importers??=[],l.importers.push(W(this.id,this.debug??!1));let n;try{n=await s(l)}catch(o){throw o.span&&o.span.url!==void 0&&this.deps.add(g(o.span.url)),Q(o,this.id)}let p=n.sourceMap;return p&&this.useSourcemap&&(p=G(p)),n.loadedUrls&&n.loadedUrls.filter(o=>o.protocol==="file:").forEach(o=>{const a=g(o);y(a)&&this.deps.add(a)}),{code:Buffer.from(n.css).toString(),map:p?JSON.stringify(p):t}},test:/\.(sass|scss)$/i};export{ae as default};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/webpack-contrib/sass-loader
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright JS Foundation and other contributors
|
|
7
|
+
*/
|
|
8
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
9
|
+
import type { StringOptions as SassStringOptions } from "sass";
|
|
10
|
+
import type { StringOptions as SassEmbeddedStringOptions } from "sass-embedded";
|
|
11
|
+
export type SassLoaderContext = {
|
|
12
|
+
environment: Environment;
|
|
13
|
+
resourcePath: string;
|
|
14
|
+
rootContext: string;
|
|
15
|
+
};
|
|
16
|
+
export type SassLoaderOptions = {
|
|
17
|
+
additionalData: string | ((content: string | Buffer, loaderContext: SassLoaderContext) => Promise<string>) | ((content: string | Buffer, loaderContext: SassLoaderContext) => string);
|
|
18
|
+
implementation?: "sass-embedded" | "sass";
|
|
19
|
+
warnRuleAsWarning?: boolean;
|
|
20
|
+
} & (Omit<SassEmbeddedStringOptions<"sync">, "charset" | "indentedSyntax"> | Omit<SassStringOptions<"sync">, "charset" | "indentedSyntax">);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as sass from "sass";
|
|
2
|
+
import type * as sassEmbedded from "sass-embedded";
|
|
3
|
+
declare const getSassCompiler: (implementation: "sass-embedded" | "sass" | undefined) => Promise<((sassOptions: sass.StringOptions<"sync"> & {
|
|
4
|
+
data: string;
|
|
5
|
+
}) => sass.CompileResult) | ((sassOptions: sassEmbedded.StringOptions<"sync"> & {
|
|
6
|
+
data: string;
|
|
7
|
+
}) => sassEmbedded.CompileResult)>;
|
|
8
|
+
export default getSassCompiler;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
2
|
+
import type { SassLoaderContext, SassLoaderOptions } from "../types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Derives the sass options from the loader context and normalizes its values with sane defaults.
|
|
5
|
+
*/
|
|
6
|
+
declare const getSassOptions: (loaderContext: SassLoaderContext, logger: RollupLogger, options: SassLoaderOptions, content: string, useSourceMap: boolean) => Promise<SassLoaderOptions>;
|
|
7
|
+
export default getSassOptions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type SassError = Error & {
|
|
2
|
+
column?: number;
|
|
3
|
+
id: string;
|
|
4
|
+
line?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const errorFactory: (error: Error & {
|
|
7
|
+
formatted?: string;
|
|
8
|
+
span?: {
|
|
9
|
+
start: {
|
|
10
|
+
column: number;
|
|
11
|
+
line: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}, file: string) => SassError;
|
|
15
|
+
export default errorFactory;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import type { Loader } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Source map loader for extracting and processing inline source maps from CSS.
|
|
4
|
+
*
|
|
5
|
+
* This loader:
|
|
6
|
+
* - Extracts inline source maps from CSS comments
|
|
7
|
+
* - Strips source map comments from the CSS content
|
|
8
|
+
* - Provides the extracted source map for further processing
|
|
9
|
+
*
|
|
10
|
+
* This loader always processes files regardless of file type since source maps
|
|
11
|
+
* can be present in any CSS content.
|
|
12
|
+
* @example
|
|
13
|
+
* ```css
|
|
14
|
+
* // Input CSS with inline source map
|
|
15
|
+
* .example { color: red; }
|
|
16
|
+
* //# sourceMappingURL=data:application/json;base64,...
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* ```css
|
|
20
|
+
* // Output CSS with source map stripped
|
|
21
|
+
* .example { color: red; }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
15
24
|
declare const loader: Loader;
|
|
16
|
-
|
|
17
|
-
export = loader;
|
|
25
|
+
export default loader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e,s as o}from"../packem_shared/sourcemap-CB6ochh0.js";const p={alwaysProcess:!0,name:"sourcemap",async process({code:a,map:s}){return{code:o(a),map:await e(a,this.id)??s}}};export{p as default};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export = loader;
|
|
1
|
+
import type { Loader } from "../types.d.ts";
|
|
2
|
+
import type { StylusLoaderOptions } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Stylus loader for processing Stylus stylesheets to CSS.
|
|
5
|
+
*/
|
|
6
|
+
declare const loader: Loader<StylusLoaderOptions>;
|
|
7
|
+
export default loader;
|
|
8
|
+
export type { StylusDefinition, StylusLoaderContext, StylusLoaderOptions, StylusPlugin } from "./types.d.ts";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=Object.defineProperty;var v=(t,e)=>E(t,"name",{value:e,configurable:!0});import{existsSync as F}from"node:fs";import{readFileSync as _}from"@visulima/fs";import{normalize as d,dirname as D,join as y}from"@visulima/path";import O from"stylus";import P from"../../packem_shared/loadModule-D20jQQNu.js";import{m as R}from"../../packem_shared/sourcemap-CB6ochh0.js";var k=Object.defineProperty,p=v((t,e)=>k(t,"name",{value:e,configurable:!0}),"l");const z=p(async(t,e)=>{if(!(!t.sources||t.sourcesContent))return await Promise.all(t.sources.map(async n=>{const s=d(y(e,n));if(F(s))return _(s)}).filter(Boolean))},"populateSourcemapContent"),B=p(async(t,e,n)=>{if(typeof t=="function")return t;if(typeof t=="string"){const s=await P(t,e,n);if(typeof s!="function")throw new Error(`The Stylus implementation "${t}" is not a function.`);return s}return O},"resolveImplementation"),I=p((t,e)=>{if(!e)return;const n=Array.isArray(e)?e:Object.entries(e);for(const s of n){const[r,a,c]=s;t.define(r,a,c)}},"applyDefinitions"),L=p(async(t,e,n,s)=>{if(!(!e||e.length===0))for(const r of e){if(typeof r=="function"){t.use(r);continue}const a=await P(r,n,s);if(typeof a!="function")throw new Error(`Failed to load "${r}" Stylus plugin. Are you sure it's installed and exports a function?`);const c=a();t.use(typeof c=="function"?c:a)}},"applyPlugins"),K={name:"stylus",async process({code:t,map:e}){const{additionalData:n,define:s,disableCache:r,hoistAtrules:a,implementation:c,import:h,include:w,includeCSS:b,lineNumbers:C,use:$,...m}=this.options,u=d(D(this.id)),f=this.cwd??process.cwd(),g=[u,y(u,"node_modules"),y(f,"node_modules")];m.paths&&g.push(...m.paths);let l=t;if(n!==void 0){const i={environment:this.environment,resourcePath:this.id,rootContext:f};l=typeof n=="function"?await n(l,i):`${n}
|
|
2
|
+
${l}`}const o=(await B(c,f,this.logger))(l,m).set("filename",this.id).set("paths",g).set("sourcemap",{basePath:u,comment:!1});if(b&&o.set("include css",!0),a&&o.set("hoist atrules",!0),C&&o.set("linenos",!0),r&&o.set("cache",!1),w)for(const i of w)o.include(i);if(h)for(const i of h)o.import(i);await L(o,$,f,this.logger),I(o,s);const A=await new Promise((i,j)=>{o.render((S,x)=>S?j(S):i(x))});for(const i of o.deps())this.deps.add(d(i));return o.sourcemap&&(o.sourcemap.sourcesContent=await z(o.sourcemap,u)),{code:A,map:R(o.sourcemap).toString()??e}},test:/\.(styl|stylus)$/i};export{K as default};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RenderOptions } from "stylus";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal context passed to `additionalData` functions.
|
|
5
|
+
*/
|
|
6
|
+
export type StylusLoaderContext = {
|
|
7
|
+
environment: Environment;
|
|
8
|
+
resourcePath: string;
|
|
9
|
+
rootContext: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Stylus plugin: either a function that receives the renderer,
|
|
13
|
+
* or a module id (string) that resolves to a plugin factory.
|
|
14
|
+
*/
|
|
15
|
+
export type StylusPlugin = string | ((renderer: unknown) => void);
|
|
16
|
+
/**
|
|
17
|
+
* Definition entry: `[name, value]` or `[name, value, raw]`.
|
|
18
|
+
*/
|
|
19
|
+
export type StylusDefinition = [string, unknown] | [string, unknown, boolean];
|
|
20
|
+
/**
|
|
21
|
+
* Configuration options for the Stylus loader.
|
|
22
|
+
*
|
|
23
|
+
* Extends the standard Stylus RenderOptions with loader-specific functionality.
|
|
24
|
+
* These options are passed to the Stylus compiler during processing.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const stylusOptions: StylusLoaderOptions = {
|
|
28
|
+
* paths: ['./styles', './node_modules'],
|
|
29
|
+
* define: { 'primary-color': '#007acc' },
|
|
30
|
+
* import: ['nib'],
|
|
31
|
+
* use: ['nib'],
|
|
32
|
+
* compress: true,
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
* @see {@link https://stylus-lang.com/docs/js.html} Stylus.js API Documentation
|
|
36
|
+
*/
|
|
37
|
+
export type StylusLoaderOptions = {
|
|
38
|
+
/**
|
|
39
|
+
* Prepends or appends Stylus code to the entry file before compilation.
|
|
40
|
+
* Useful for injecting shared variables, mixins, or plugin imports.
|
|
41
|
+
*/
|
|
42
|
+
additionalData?: string | ((content: string, loaderContext: StylusLoaderContext) => Promise<string> | string);
|
|
43
|
+
/**
|
|
44
|
+
* Disable stylus internal cache.
|
|
45
|
+
*/
|
|
46
|
+
disableCache?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Hoist `@import`/`@charset` at-rules to the top of the file
|
|
49
|
+
* (maps to stylus `hoist atrules`).
|
|
50
|
+
*/
|
|
51
|
+
hoistAtrules?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom stylus implementation. Either a module id to import,
|
|
54
|
+
* or a pre-imported Stylus function.
|
|
55
|
+
*/
|
|
56
|
+
implementation?: string | ((code: string, options?: unknown) => unknown);
|
|
57
|
+
/**
|
|
58
|
+
* Files to pre-import before compiling. Equivalent to calling
|
|
59
|
+
* `.import()` on the renderer for each entry.
|
|
60
|
+
*/
|
|
61
|
+
import?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Additional include paths. Equivalent to calling `.include()`
|
|
64
|
+
* on the renderer for each entry.
|
|
65
|
+
*/
|
|
66
|
+
include?: string[];
|
|
67
|
+
/**
|
|
68
|
+
* Include regular CSS on `@import` (maps to stylus `include css`).
|
|
69
|
+
*/
|
|
70
|
+
includeCSS?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Emit comments in the generated CSS indicating the corresponding
|
|
73
|
+
* stylus line (maps to stylus `linenos`).
|
|
74
|
+
*/
|
|
75
|
+
lineNumbers?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Pre-define variables/functions on the renderer.
|
|
78
|
+
* Accepts either a plain object keyed by name or a list of
|
|
79
|
+
* `[name, value]` / `[name, value, raw]` tuples.
|
|
80
|
+
*/
|
|
81
|
+
define?: Record<string, unknown> | StylusDefinition[];
|
|
82
|
+
/**
|
|
83
|
+
* Stylus plugins to apply via `.use()`.
|
|
84
|
+
* Strings are resolved and required relative to the current working directory.
|
|
85
|
+
*/
|
|
86
|
+
use?: StylusPlugin[];
|
|
87
|
+
} & RenderOptions;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import 'postcss-load-config';
|
|
6
|
-
import 'less';
|
|
7
|
-
import '@visulima/packem-share/types';
|
|
8
|
-
import 'sass';
|
|
9
|
-
import 'sass-embedded';
|
|
10
|
-
import 'stylus';
|
|
11
|
-
import '@visulima/packem-share/utils';
|
|
12
|
-
import 'rollup';
|
|
13
|
-
import 'source-map-js';
|
|
14
|
-
|
|
1
|
+
import type { Loader } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Tailwind Oxide loader for processing Tailwind CSS files
|
|
4
|
+
*/
|
|
15
5
|
declare const tailwindcssLoader: Loader;
|
|
16
|
-
|
|
17
|
-
export = tailwindcssLoader;
|
|
6
|
+
export default tailwindcssLoader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=Object.defineProperty;var y=(d,r)=>A(d,"name",{value:r,configurable:!0});import{stat as v}from"node:fs/promises";import{compile as M,Features as i,toSourceMap as P,optimize as x}from"@tailwindcss/node";import{clearRequireCache as z}from"@tailwindcss/node/require-cache";import{Scanner as $}from"@tailwindcss/oxide";import{findPackageJson as R}from"@visulima/package";import{resolve as w,dirname as C,relative as E,join as S,normalize as T}from"@visulima/path";import{resolveAlias as F}from"@visulima/path/utils";import{g as U}from"../packem_shared/generate-js-exports-BhS4eLrN.js";import{resolve as J}from"../packem_shared/resolve-anj9ucIq.js";var k=Object.defineProperty,f=y((d,r)=>k(d,"name",{value:r,configurable:!0}),"m");class j{static{y(this,"U")}constructor(r,o,g,l,h,t){this.id=r,this.base=o,this.enableSourceMaps=g,this.customCssResolver=l,this.customJsResolver=h,this.logger=t}id;base;enableSourceMaps;customCssResolver;customJsResolver;logger;static{f(this,"TailwindRoot")}compiler;scanner;candidates=new Set;buildDependencies=new Map;async generate(r,o){const g=w(this.id.replace(/\?.*$/u,"")),l=f(e=>{e!==g&&(/[#?].*\.svg$/u.test(e)||o(e))},"addWatchFileWrapper"),h=this.requiresBuild(),t=C(w(g));if(!this.compiler||!this.scanner||await h){z([...this.buildDependencies.keys()]),this.buildDependencies.clear(),this.addBuildDependency(g),this.logger.debug({message:"Setup compiler"});const e=[];this.compiler=await M(r,{base:t,customCssResolver:this.customCssResolver,customJsResolver:this.customJsResolver,from:this.enableSourceMaps?this.id:void 0,onDependency:f(m=>{l(m),e.push(this.addBuildDependency(m))},"onDependency"),shouldRewriteUrls:!0}),await Promise.all(e),this.logger.debug({message:"Setup scanner"});const a=[...this.compiler.root==="none"?[]:this.compiler.root===null?[{base:this.base,negated:!1,pattern:"**/*"}]:[{...this.compiler.root,negated:!1}],...this.compiler.sources];this.scanner=new $({sources:a})}else for(const e of this.buildDependencies.keys())l(e);const c=this.compiler.features&(i.AtApply|i.JsPluginCompat|i.ThemeFunction|i.Utilities);if(this.logger.debug({data:{availableFeatures:this.compiler.features,hasAtApply:!!(this.compiler.features&i.AtApply),hasJsPluginCompat:!!(this.compiler.features&i.JsPluginCompat),hasRequiredFeatures:!!c,hasThemeFunction:!!(this.compiler.features&i.ThemeFunction),hasUtilities:!!(this.compiler.features&i.Utilities),requiredFeatures:i.AtApply|i.JsPluginCompat|i.ThemeFunction|i.Utilities},message:"Feature analysis"}),!c)return this.logger.debug({data:{missingFeatures:{AtApply:!(this.compiler.features&i.AtApply),JsPluginCompat:!(this.compiler.features&i.JsPluginCompat),ThemeFunction:!(this.compiler.features&i.ThemeFunction),Utilities:!(this.compiler.features&i.Utilities)}},message:"Missing required features, returning false"}),!1;if(this.compiler.features&i.Utilities)if(this.logger.debug({data:{candidatesCountBefore:this.candidates.size,scannerExists:!!this.scanner,scannerHasScan:!!(this.scanner&&typeof this.scanner.scan=="function")},message:"Scan for candidates - Utilities feature enabled"}),this.scanner){const e=this.scanner.scan();this.logger.debug({data:{scannedCandidates:e.slice(0,10),scannedCandidatesCount:e.length},message:"Scanner results"});for(const a of e)this.candidates.add(a);this.logger.debug({data:{candidatesCountAfter:this.candidates.size,newCandidatesAdded:e.length},message:"Candidates updated"})}else this.logger.debug({data:{hasScanMethod:!!(this.scanner&&typeof this.scanner.scan=="function"),scannerType:typeof this.scanner},message:"Scanner not available or missing scan method"});else this.logger.debug({message:"Utilities feature not enabled, skipping candidate scanning"});if(this.compiler.features&i.Utilities){if(this.scanner&&this.scanner.files){this.logger.debug({data:{files:this.scanner.files.slice(0,5),filesCount:this.scanner.files.length},message:"Watching individual files from scanner"});for(const e of this.scanner.files)l(e)}else this.logger.debug({message:"No individual files to watch from scanner"});if(this.scanner&&this.scanner.globs){this.logger.debug({data:{globs:this.scanner.globs.slice(0,3),globsCount:this.scanner.globs.length},message:"Processing globs from scanner"});for await(const e of this.scanner.globs){if(e.pattern[0]==="!"){this.logger.debug({data:{pattern:e.pattern},message:"Skipping negated glob pattern"});continue}let a=E(this.base,e.base);a[0]!=="."&&(a=`./${a}`);const m=S(a,e.pattern);this.logger.debug({data:{base:e.base,glob:e.pattern,watchPath:m},message:"Adding glob to watch list"}),l(m);const{root:b}=this.compiler;if(b!=="none"&&b!==null){const p=w(b.base,b.pattern);try{const u=await v(p);if(u.isDirectory())this.logger.debug({data:{basePath:p,isDirectory:u.isDirectory()},message:"Valid source directory confirmed"});else{const D=`The path given to \`source(…)\` must be a directory but got \`source(${p})\` instead.`;throw this.logger.debug({data:{basePath:p,error:D,isDirectory:u.isDirectory()},message:"Invalid source path detected"}),new Error(D)}}catch(u){this.logger.debug({data:{basePath:p,error:u instanceof Error?u.message:String(u)},message:"Error checking source directory"})}}}}else this.logger.debug({message:"No globs to process from scanner"})}else this.logger.debug({message:"Utilities feature not enabled, skipping file watching"});this.logger.debug({data:{candidates:[...this.candidates].slice(0,10),candidatesCount:this.candidates.size},message:"Build CSS"});const s=this.compiler.build([...this.candidates]);this.logger.debug({data:{cssLength:s.length,cssPreview:s.slice(0,200)+(s.length>200?"...":"")},message:"CSS build completed"}),this.logger.debug({data:{enableSourceMaps:this.enableSourceMaps},message:"Build Source Map"});const n=(this.enableSourceMaps?P(this.compiler.buildSourceMap()):void 0)?.raw;if(n){const e=n;this.logger.debug({data:{hasMappings:!!e.mappings,mapSize:JSON.stringify(n).length,sourcesCount:e.sources?.length||0},message:"Source map generated"})}else this.logger.debug({message:"No source map generated"});return{code:s,map:n}}async addBuildDependency(r){let o;try{o=(await v(r)).mtimeMs}catch{}this.buildDependencies.set(r,o)}async requiresBuild(){for await(const[r,o]of this.buildDependencies){if(o===void 0)return!0;try{if((await v(r)).mtimeMs>o)return!0}catch{return!0}}return!1}}const V={name:"tailwindcss",async process({code:d,map:r}){const o=this.alias,g=f(async(s,n)=>{try{const e=await R(n),a=J([s,F(s,o??{})],{baseDirs:[n,S(C(e.path),"node_modules")],caller:"Tailwind CSS Resolver",conditionNames:["style","development|production"],extensions:[".css"],mainFields:["style"],preferRelative:!0});if(a)return this.logger.debug({message:`Resolved CSS import: ${s} -> ${a}`}),a}catch{}return this.logger.debug({message:`Failed to resolve CSS import: ${s} from ${n}`}),!1},"customCssResolver"),l=f(async(s,n)=>{try{const e=await R(n),a=J([s,F(s,o??{})],{baseDirs:[n,S(C(e.path),"node_modules")],caller:"Tailwind JS Resolver",extensions:[".js",".mjs",".cjs",".ts",".tsx",".jsx"]});if(a)return this.logger.debug({message:`Resolved JS import: ${s} -> ${a}`}),a}catch{}return this.logger.debug({message:`Failed to resolve JS import: ${s} from ${n}`}),!1},"customJsResolver"),h=this.cwd?this.sourceDir?S(this.cwd,this.sourceDir):this.cwd:this.sourceDir||process.cwd();let t=await new j(this.id,h,this.useSourcemap,g,l,this.logger).generate(d,s=>this.deps.add(T(s)));if(!t)return this.logger.debug({data:{returningOriginalContent:!0},message:"Tailwind generation returned false - not a Tailwind file or missing features"}),{code:d,map:r};if(this.logger.debug({message:"[@tailwindcss/rollup] Generate CSS"}),this.environment==="production"){this.logger.debug({data:{minify:!0,originalSize:t.code.length},message:"[@tailwindcss/rollup] Optimize CSS"});const s=x(t.code,{file:this.id,map:t.map,minify:!0});this.logger.debug({data:{optimizedSize:s.code.length,originalSize:t.code.length,sizeReduction:t.code.length-s.code.length,sizeReductionPercent:`${((t.code.length-s.code.length)/t.code.length*100).toFixed(2)}%`},message:"CSS optimization completed"}),t=s}else this.logger.debug({data:{environment:this.environment},message:"Development mode - skipping CSS optimization"});if(this.emit)return{...t,meta:{moduleContents:t,types:void 0},moduleSideEffects:!0};const c=U({css:t.code,cwd:this.cwd,dts:this.dts,emit:this.emit,extract:this.extract,icssDependencies:[],id:this.id,inject:this.inject,inline:this.inline,logger:this.logger,map:t.map,modulesExports:{},namedExports:this.namedExports,supportModules:!1});return this.extract?{code:c.code,extracted:{css:t.code,id:this.id,map:t.map},map:c.map,meta:c.meta,moduleSideEffects:c.moduleSideEffects}:{code:c.code,map:c.map,meta:c.meta,moduleSideEffects:c.moduleSideEffects}},test:/\.css$/i};export{V as default};
|